ReportModuleLogic.cs 806 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520
  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. string sqlString = "";
  635. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  636. //string sqlString =
  637. // "SELECT t.groutinglinecode\n" +
  638. // " ,gl.BuildingNo\n" +
  639. // " ,gl.FloorNo\n" +
  640. // " ,gl.GroutingLineNo\n" +
  641. // " ,t.usercode\n" +
  642. // " ,t.goodscode\n" +
  643. // " ,t.GOODSSPECIFICATION\n" +
  644. // " ,t.goodstypename\n" +
  645. // " ,t.MouldQuantity\n" +
  646. // " ,gld.groutingmouldcode\n" +
  647. // " ,gms.gmouldstatusname\n" +
  648. // " ,gld.beginuseddate\n" +
  649. // " ,(SELECT MIN(ggg.groutingdate)\n" +
  650. // " FROM tp_pm_groutingdailydetail ggg\n" +
  651. // " WHERE ggg.groutinglinedetailid = t.groutinglinedetailid) groutingdate\n" +
  652. // " ,MAX(t.GroutingCount)-SUM(t.groutingflag) mingroutingcount\n" +
  653. // " ,SUM(t.groutingflag) sumgroutingcount\n" +
  654. // " ,MAX(t.GroutingCount) maxGroutingCount\n" +
  655. // " ,gld.groutingcount\n" +
  656. // " ,MAX(gld.standardgroutingcount) standardgroutingcount\n" +
  657. // " ,gld.ENDUSEDDATE\n" +
  658. // " ,gld.standardgroutingcount - (MAX(t.GroutingCount)+SUM(t.groutingflag)) - SUM(t.groutingflag) leftcount\n" +
  659. // " FROM (SELECT gd.groutinglinecode\n" +
  660. // " ,gd.usercode\n" +
  661. // " ,gdd.goodsid\n" +
  662. // " ,gd.MouldQuantity\n" +
  663. // " ,gdd.groutinglinedetailid\n" +
  664. // " ,decode(gdd.groutingflag, '1', 1, 0) groutingflag\n" +
  665. // " ,gdd.GroutingCount\n" +
  666. // " ,gt.goodstypename\n" +
  667. // " ,g.goodscode\n" +
  668. // " ,g.GOODSSPECIFICATION\n" +
  669. // " FROM TP_PM_GroutingDaily gd\n" +
  670. // " INNER JOIN TP_PM_GroutingDailyDetail gdd\n" +
  671. // " ON gdd.groutingdailyid = gd.groutingdailyid\n" +
  672. // " INNER JOIN TP_MST_Goods g\n" +
  673. // " ON g.goodsid = gdd.goodsid\n" +
  674. // " INNER JOIN TP_MST_GOODSTYPE gt\n" +
  675. // " ON gt.goodstypeid = g.goodstypeid\n" +
  676. // " WHERE gd.accountid = :AccountID\n" +
  677. // " AND gd.groutingdate >= :GDateBegin\n" +
  678. // " AND gd.groutingdate <= :GDateEnd\n" +
  679. // " AND (:groutinglinecode is null or instr(gd.groutinglinecode, :groutinglinecode) > 0)\n" +
  680. // " AND (:groutingusercode is null or instr(gdd.usercode, :groutingusercode) > 0)\n" +
  681. // " AND (:goodscode is null or instr(gdd.goodscode, :goodscode) > 0)\n" +
  682. // " AND (:goodstypecode is null or instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  683. // " ) t\n" +
  684. // " INNER JOIN tp_pc_groutinglinedetail gld\n" +
  685. // " ON gld.groutinglinedetailid = t.groutinglinedetailid\n" +
  686. // " INNER JOIN tp_pc_groutingline gl\n" +
  687. // " ON gld.groutinglineid = gl.groutinglineid\n" +
  688. // " INNER JOIN TP_SYS_GMouldStatus gms\n" +
  689. // " ON gms.gmouldstatusid = gld.gmouldstatus\n" +
  690. // " GROUP BY t.groutinglinecode\n" +
  691. // " ,gl.BuildingNo\n" +
  692. // " ,gl.FloorNo\n" +
  693. // " ,gl.GroutingLineNo\n" +
  694. // " ,t.usercode\n" +
  695. // " ,t.goodscode\n" +
  696. // " ,t.GOODSSPECIFICATION\n" +
  697. // " ,t.goodstypename\n" +
  698. // " ,t.MouldQuantity\n" +
  699. // " ,gld.groutingmouldcode\n" +
  700. // " ,gms.gmouldstatusname\n" +
  701. // " ,gld.beginuseddate\n" +
  702. // " ,gld.groutingcount\n" +
  703. // " ,gld.ENDUSEDDATE\n" +
  704. // " ,t.groutinglinedetailid\n" +
  705. // " ORDER BY t.groutinglinecode, gld.groutingmouldcode, t.groutinglinedetailid";
  706. if (se.TotalMethod != null && se.TotalMethod != "" && se.TotalMethod != "goodscode")
  707. {
  708. sqlString = @"SELECT
  709. GROUPING_ID(gmouldstatusname,goodscode) GID,
  710. CASE WHEN GROUPING_ID(gmouldstatusname,goodscode)=1 THEN '[小计]'
  711. WHEN GROUPING_ID(gmouldstatusname,goodscode)=3 AND " + se.TotalMethod + " is NOT null THEN '【合 计】'";
  712. sqlString += @"WHEN GROUPING_ID(gmouldstatusname,goodscode)=3 AND " + se.TotalMethod + " is null THEN '【总 计】' ELSE TO_CHAR(BuildingNo) END AS BuildingNo,";
  713. sqlString += @"groutinglinecode,
  714. FloorNo,
  715. GroutingLineNo,
  716. gmouldstatusname,
  717. usercode,
  718. goodscode,
  719. GOODSSPECIFICATION,
  720. goodstypename,
  721. groutingmouldcode,
  722. beginuseddate,
  723. groutingdate,
  724. ENDUSEDDATE,
  725. mingresidue,
  726. mouldGoodsCode,
  727. mouldName,
  728. SUM(MouldQuantity) AS MouldQuantity,
  729. SUM(mingroutingcount)AS mingroutingcount,
  730. SUM(sumgroutingcount)AS sumgroutingcount,
  731. SUM(maxGroutingCount)AS maxGroutingCount,
  732. SUM(groutingcount)AS groutingcount,
  733. SUM(standardgroutingcount) AS standardgroutingcount,
  734. SUM(leftcount)AS leftcount,
  735. SUM(financecount) AS financecount
  736. FROM(
  737. SELECT
  738. BuildingNo as BuildingNo,
  739. groutinglinecode,
  740. FloorNo,
  741. GroutingLineNo,
  742. gmouldstatusname,
  743. usercode,
  744. goodscode,
  745. GOODSSPECIFICATION,
  746. goodstypename,
  747. 1 AS MouldQuantity,
  748. groutingmouldcode,
  749. beginuseddate,
  750. groutingdate,
  751. mingroutingcount,
  752. sumgroutingcount,
  753. maxGroutingCount,
  754. groutingcount,
  755. standardgroutingcount,
  756. ENDUSEDDATE,
  757. standardgroutingcount - mingroutingcount - sumgroutingcount leftcount,
  758. --期初剩余注浆次数为正数模具剩余注浆次数为正数:取期初剩余注浆次数
  759. CASE WHEN gmouldstatusname = '变产' AND standardgroutingcount - mingroutingcount >= 0 AND standardgroutingcount - mingroutingcount - sumgroutingcount > 0 THEN standardgroutingcount - mingroutingcount
  760. --期初剩余注浆次数为正数模具剩余注浆次数为负数:取期初剩余注浆次类
  761. WHEN gmouldstatusname = '变产' AND standardgroutingcount - mingroutingcount >= 0 AND standardgroutingcount - mingroutingcount - sumgroutingcount < 0 THEN standardgroutingcount - mingroutingcount
  762. --期初剩余注浆次数为负数模具剩余注浆次数为负数:取0
  763. WHEN gmouldstatusname = '变产' AND standardgroutingcount - mingroutingcount < 0 AND standardgroutingcount - mingroutingcount - sumgroutingcount < 0 THEN 0
  764. --期初剩余注浆次数为正数模具剩余注浆次数为正数:取期初剩余注浆次数
  765. WHEN gmouldstatusname = '卸模' AND standardgroutingcount - mingroutingcount >= 0 AND standardgroutingcount - mingroutingcount - sumgroutingcount > 0 THEN standardgroutingcount - mingroutingcount
  766. --期初剩余注浆次数为正数模具剩余注浆次数为负数:取期初剩余注浆次类
  767. WHEN gmouldstatusname = '卸模' AND standardgroutingcount - mingroutingcount >= 0 AND standardgroutingcount - mingroutingcount - sumgroutingcount < 0 THEN standardgroutingcount - mingroutingcount
  768. --期初剩余注浆次数为负数模具剩余注浆次数为负数:取0
  769. WHEN gmouldstatusname = '卸模' AND standardgroutingcount - mingroutingcount < 0 AND standardgroutingcount - mingroutingcount - sumgroutingcount < 0 THEN 0
  770. --期初剩余注浆次数为正数模具剩余注浆次数为正数:取本期注浆次数
  771. WHEN gmouldstatusname = '正常' AND standardgroutingcount - mingroutingcount >= 0 AND standardgroutingcount - mingroutingcount - sumgroutingcount > 0 THEN sumgroutingcount
  772. --期初剩余注浆次数为正数模具剩余注浆次数为负数:取期初剩余注浆次数
  773. WHEN gmouldstatusname = '正常' AND standardgroutingcount - mingroutingcount >= 0 AND standardgroutingcount - mingroutingcount - sumgroutingcount < 0 THEN standardgroutingcount - mingroutingcount
  774. --期初剩余注浆次数为负数模具剩余注浆次数为负数:取0
  775. WHEN gmouldstatusname = '正常' AND standardgroutingcount - mingroutingcount < 0 AND standardgroutingcount - mingroutingcount - sumgroutingcount < 0 THEN 0
  776. ELSE sumgroutingcount
  777. END financecount,
  778. standardgroutingcount - mingroutingcount mingresidue,
  779. mouldGoodsCode,
  780. mouldName
  781. FROM
  782. (
  783. SELECT
  784. t.groutinglinecode,
  785. gl.BuildingNo,
  786. gl.FloorNo,
  787. gl.GroutingLineNo,
  788. t.usercode,
  789. t.goodscode,
  790. t.GOODSSPECIFICATION,
  791. t.goodstypename,
  792. t.MouldQuantity,
  793. gld.groutingmouldcode,
  794. gms.gmouldstatusname,
  795. gld.beginuseddate,
  796. ( SELECT MIN( ggg.groutingdate ) FROM tp_pm_groutingdailydetail ggg WHERE ggg.groutinglinedetailid = t.groutinglinedetailid ) groutingdate,
  797. MAX( t.GroutingCount ) - SUM( t.groutingflag ) mingroutingcount,
  798. SUM( t.groutingflag ) sumgroutingcount,
  799. MAX( t.GroutingCount ) maxGroutingCount,
  800. gld.groutingcount,
  801. MAX( gld.standardgroutingcount ) standardgroutingcount,
  802. gld.ENDUSEDDATE,
  803. mg.mouldGoodsCode,
  804. mg.mouldName
  805. FROM
  806. (
  807. SELECT
  808. gd.groutinglinecode,
  809. gd.usercode,
  810. gdd.goodsid,
  811. gd.MouldQuantity,
  812. gdd.groutinglinedetailid,
  813. decode( gdd.groutingflag, '1', 1, 0 ) groutingflag,
  814. gdd.GroutingCount,
  815. gt.goodstypename,
  816. g.goodscode,
  817. g.GOODSSPECIFICATION
  818. FROM
  819. TP_PM_GroutingDaily gd
  820. INNER JOIN TP_PM_GroutingDailyDetail gdd ON gdd.groutingdailyid = gd.groutingdailyid
  821. INNER JOIN TP_MST_Goods g ON g.goodsid = gdd.goodsid
  822. INNER JOIN TP_MST_GOODSTYPE gt ON gt.goodstypeid = g.goodstypeid
  823. WHERE
  824. gd.accountid = 1
  825. AND gd.groutingdate >= :GDateBegin
  826. AND gd.groutingdate <= :GDateEnd
  827. AND ( : groutinglinecode IS NULL OR instr( gd.groutinglinecode, : groutinglinecode ) > 0 )
  828. AND ( : groutingusercode IS NULL OR instr( gdd.usercode, : groutingusercode ) > 0 )
  829. AND ( : goodscode IS NULL OR instr( gdd.goodscode, : goodscode ) > 0 )
  830. AND ( : goodstypecode IS NULL OR instr( gt.goodstypecode, : goodstypecode ) = 1 )
  831. ) t
  832. INNER JOIN tp_pc_groutinglinedetail gld ON gld.groutinglinedetailid = t.groutinglinedetailid
  833. INNER JOIN tp_pc_groutingline gl ON gld.groutinglineid = gl.groutinglineid
  834. INNER JOIN TP_SYS_GMouldStatus gms ON gms.gmouldstatusid = gld.gmouldstatus
  835. INNER JOIN TP_MST_MOULDGOODSCODE mg ON t.goodscode = mg.goodsCode
  836. GROUP BY
  837. t.groutinglinecode,
  838. gl.BuildingNo,
  839. gl.FloorNo,
  840. gl.GroutingLineNo,
  841. t.usercode,
  842. t.goodscode,
  843. t.GOODSSPECIFICATION,
  844. t.goodstypename,
  845. t.MouldQuantity,
  846. gld.groutingmouldcode,
  847. gms.gmouldstatusname,
  848. gld.beginuseddate,
  849. gld.groutingcount,
  850. gld.ENDUSEDDATE,
  851. t.groutinglinedetailid,
  852. mg.mouldGoodsCode,
  853. mg.mouldName
  854. ORDER BY
  855. BuildingNo,
  856. GroutingLineNo,
  857. groutinglinecode,
  858. groutingmouldcode
  859. ) )
  860. GROUP BY GROUPING SETS((
  861. TO_CHAR(BuildingNo),
  862. groutinglinecode,
  863. FloorNo,
  864. GroutingLineNo,
  865. gmouldstatusname,
  866. usercode,
  867. goodscode,
  868. GOODSSPECIFICATION,
  869. goodstypename,
  870. groutingmouldcode,
  871. beginuseddate,
  872. groutingdate,
  873. ENDUSEDDATE,
  874. mingresidue,
  875. mouldGoodsCode,
  876. mouldName),";
  877. sqlString += @"(gmouldstatusname," + se.TotalMethod + "),(" + se.TotalMethod + "),()) ORDER BY " + se.TotalMethod + ",GROUPING_ID(gmouldstatusname,goodscode)";
  878. } else if (se.TotalMethod != null && se.TotalMethod != "" && se.TotalMethod == "goodscode") {
  879. sqlString = @"SELECT
  880. GROUPING_ID(gmouldstatusname,GroutingLineNo) GID,
  881. CASE WHEN GROUPING_ID(gmouldstatusname,GroutingLineNo)=1 THEN '[小计]'
  882. WHEN GROUPING_ID(gmouldstatusname,GroutingLineNo)=3 AND " + se.TotalMethod + " is NOT null THEN '【合计】'";
  883. sqlString += @"WHEN GROUPING_ID(gmouldstatusname,GroutingLineNo)=3 AND " + se.TotalMethod + " is null THEN '【总计】' ELSE TO_CHAR(BuildingNo) END AS BuildingNo,";
  884. sqlString += @"groutinglinecode,
  885. FloorNo,
  886. GroutingLineNo,
  887. gmouldstatusname,
  888. usercode,
  889. goodscode,
  890. GOODSSPECIFICATION,
  891. goodstypename,
  892. groutingmouldcode,
  893. beginuseddate,
  894. groutingdate,
  895. ENDUSEDDATE,
  896. mingresidue,
  897. mouldGoodsCode,
  898. mouldName,
  899. SUM(MouldQuantity) AS MouldQuantity,
  900. SUM(mingroutingcount)AS mingroutingcount,
  901. SUM(sumgroutingcount)AS sumgroutingcount,
  902. SUM(maxGroutingCount)AS maxGroutingCount,
  903. SUM(groutingcount)AS groutingcount,
  904. SUM(standardgroutingcount) AS standardgroutingcount,
  905. SUM(leftcount)AS leftcount,
  906. SUM(financecount) AS financecount
  907. FROM(
  908. SELECT
  909. BuildingNo as BuildingNo,
  910. groutinglinecode,
  911. FloorNo,
  912. GroutingLineNo,
  913. gmouldstatusname,
  914. usercode,
  915. goodscode,
  916. GOODSSPECIFICATION,
  917. goodstypename,
  918. 1 AS MouldQuantity,
  919. groutingmouldcode,
  920. beginuseddate,
  921. groutingdate,
  922. mingroutingcount,
  923. sumgroutingcount,
  924. maxGroutingCount,
  925. groutingcount,
  926. standardgroutingcount,
  927. ENDUSEDDATE,
  928. standardgroutingcount - mingroutingcount - sumgroutingcount leftcount,
  929. --期初剩余注浆次数为正数模具剩余注浆次数为正数:取期初剩余注浆次数
  930. CASE WHEN gmouldstatusname = '变产' AND standardgroutingcount - mingroutingcount >= 0 AND standardgroutingcount - mingroutingcount - sumgroutingcount > 0 THEN standardgroutingcount - mingroutingcount
  931. --期初剩余注浆次数为正数模具剩余注浆次数为负数:取期初剩余注浆次类
  932. WHEN gmouldstatusname = '变产' AND standardgroutingcount - mingroutingcount >= 0 AND standardgroutingcount - mingroutingcount - sumgroutingcount < 0 THEN standardgroutingcount - mingroutingcount
  933. --期初剩余注浆次数为负数模具剩余注浆次数为负数:取0
  934. WHEN gmouldstatusname = '变产' AND standardgroutingcount - mingroutingcount < 0 AND standardgroutingcount - mingroutingcount - sumgroutingcount < 0 THEN 0
  935. --期初剩余注浆次数为正数模具剩余注浆次数为正数:取期初剩余注浆次数
  936. WHEN gmouldstatusname = '卸模' AND standardgroutingcount - mingroutingcount >= 0 AND standardgroutingcount - mingroutingcount - sumgroutingcount > 0 THEN standardgroutingcount - mingroutingcount
  937. --期初剩余注浆次数为正数模具剩余注浆次数为负数:取期初剩余注浆次类
  938. WHEN gmouldstatusname = '卸模' AND standardgroutingcount - mingroutingcount >= 0 AND standardgroutingcount - mingroutingcount - sumgroutingcount < 0 THEN standardgroutingcount - mingroutingcount
  939. --期初剩余注浆次数为负数模具剩余注浆次数为负数:取0
  940. WHEN gmouldstatusname = '卸模' AND standardgroutingcount - mingroutingcount < 0 AND standardgroutingcount - mingroutingcount - sumgroutingcount < 0 THEN 0
  941. --期初剩余注浆次数为正数模具剩余注浆次数为正数:取本期注浆次数
  942. WHEN gmouldstatusname = '正常' AND standardgroutingcount - mingroutingcount >= 0 AND standardgroutingcount - mingroutingcount - sumgroutingcount > 0 THEN sumgroutingcount
  943. --期初剩余注浆次数为正数模具剩余注浆次数为负数:取期初剩余注浆次数
  944. WHEN gmouldstatusname = '正常' AND standardgroutingcount - mingroutingcount >= 0 AND standardgroutingcount - mingroutingcount - sumgroutingcount < 0 THEN standardgroutingcount - mingroutingcount
  945. --期初剩余注浆次数为负数模具剩余注浆次数为负数:取0
  946. WHEN gmouldstatusname = '正常' AND standardgroutingcount - mingroutingcount < 0 AND standardgroutingcount - mingroutingcount - sumgroutingcount < 0 THEN 0
  947. ELSE sumgroutingcount
  948. END financecount,
  949. standardgroutingcount - mingroutingcount mingresidue,
  950. mouldGoodsCode,
  951. mouldName
  952. FROM
  953. (
  954. SELECT
  955. t.groutinglinecode,
  956. gl.BuildingNo,
  957. gl.FloorNo,
  958. gl.GroutingLineNo,
  959. t.usercode,
  960. t.goodscode,
  961. t.GOODSSPECIFICATION,
  962. t.goodstypename,
  963. t.MouldQuantity,
  964. gld.groutingmouldcode,
  965. gms.gmouldstatusname,
  966. gld.beginuseddate,
  967. ( SELECT MIN( ggg.groutingdate ) FROM tp_pm_groutingdailydetail ggg WHERE ggg.groutinglinedetailid = t.groutinglinedetailid ) groutingdate,
  968. MAX( t.GroutingCount ) - SUM( t.groutingflag ) mingroutingcount,
  969. SUM( t.groutingflag ) sumgroutingcount,
  970. MAX( t.GroutingCount ) maxGroutingCount,
  971. gld.groutingcount,
  972. MAX( gld.standardgroutingcount ) standardgroutingcount,
  973. gld.ENDUSEDDATE,
  974. mg.mouldGoodsCode,
  975. mg.mouldName
  976. FROM
  977. (
  978. SELECT
  979. gd.groutinglinecode,
  980. gd.usercode,
  981. gdd.goodsid,
  982. gd.MouldQuantity,
  983. gdd.groutinglinedetailid,
  984. decode( gdd.groutingflag, '1', 1, 0 ) groutingflag,
  985. gdd.GroutingCount,
  986. gt.goodstypename,
  987. g.goodscode,
  988. g.GOODSSPECIFICATION
  989. FROM
  990. TP_PM_GroutingDaily gd
  991. INNER JOIN TP_PM_GroutingDailyDetail gdd ON gdd.groutingdailyid = gd.groutingdailyid
  992. INNER JOIN TP_MST_Goods g ON g.goodsid = gdd.goodsid
  993. INNER JOIN TP_MST_GOODSTYPE gt ON gt.goodstypeid = g.goodstypeid
  994. WHERE
  995. gd.accountid = 1
  996. AND gd.groutingdate >= :GDateBegin
  997. AND gd.groutingdate <= :GDateEnd
  998. AND ( : groutinglinecode IS NULL OR instr( gd.groutinglinecode, : groutinglinecode ) > 0 )
  999. AND ( : groutingusercode IS NULL OR instr( gdd.usercode, : groutingusercode ) > 0 )
  1000. AND ( : goodscode IS NULL OR instr( gdd.goodscode, : goodscode ) > 0 )
  1001. AND ( : goodstypecode IS NULL OR instr( gt.goodstypecode, : goodstypecode ) = 1 )
  1002. ) t
  1003. INNER JOIN tp_pc_groutinglinedetail gld ON gld.groutinglinedetailid = t.groutinglinedetailid
  1004. INNER JOIN tp_pc_groutingline gl ON gld.groutinglineid = gl.groutinglineid
  1005. INNER JOIN TP_SYS_GMouldStatus gms ON gms.gmouldstatusid = gld.gmouldstatus
  1006. INNER JOIN TP_MST_MOULDGOODSCODE mg ON t.goodscode = mg.goodsCode
  1007. GROUP BY
  1008. t.groutinglinecode,
  1009. gl.BuildingNo,
  1010. gl.FloorNo,
  1011. gl.GroutingLineNo,
  1012. t.usercode,
  1013. t.goodscode,
  1014. t.GOODSSPECIFICATION,
  1015. t.goodstypename,
  1016. t.MouldQuantity,
  1017. gld.groutingmouldcode,
  1018. gms.gmouldstatusname,
  1019. gld.beginuseddate,
  1020. gld.groutingcount,
  1021. gld.ENDUSEDDATE,
  1022. t.groutinglinedetailid,
  1023. mg.mouldGoodsCode,
  1024. mg.mouldName
  1025. ORDER BY
  1026. BuildingNo,
  1027. GroutingLineNo,
  1028. groutinglinecode,
  1029. groutingmouldcode
  1030. ) )
  1031. GROUP BY GROUPING SETS((
  1032. TO_CHAR(BuildingNo),
  1033. groutinglinecode,
  1034. FloorNo,
  1035. GroutingLineNo,
  1036. gmouldstatusname,
  1037. usercode,
  1038. goodscode,
  1039. GOODSSPECIFICATION,
  1040. goodstypename,
  1041. groutingmouldcode,
  1042. beginuseddate,
  1043. groutingdate,
  1044. ENDUSEDDATE,
  1045. mingresidue,
  1046. mouldGoodsCode,
  1047. mouldName),";
  1048. sqlString += @"(gmouldstatusname," + se.TotalMethod + "),(" + se.TotalMethod + "),()) ORDER BY " + se.TotalMethod + ",GROUPING_ID(gmouldstatusname,GroutingLineNo)";
  1049. }
  1050. else {
  1051. sqlString = @"SELECT
  1052. groutinglinecode,
  1053. BuildingNo,
  1054. FloorNo,
  1055. GroutingLineNo,
  1056. usercode,
  1057. goodscode,
  1058. GOODSSPECIFICATION,
  1059. goodstypename,
  1060. 1 MouldQuantity,
  1061. groutingmouldcode,
  1062. gmouldstatusname,
  1063. beginuseddate,
  1064. groutingdate,
  1065. mingroutingcount,
  1066. sumgroutingcount,
  1067. maxGroutingCount,
  1068. groutingcount,
  1069. standardgroutingcount,
  1070. ENDUSEDDATE,
  1071. standardgroutingcount - mingroutingcount - sumgroutingcount leftcount,
  1072. --期初剩余注浆次数为正数模具剩余注浆次数为正数:取期初剩余注浆次数
  1073. CASE WHEN gmouldstatusname = '变产' AND standardgroutingcount - mingroutingcount >= 0 AND standardgroutingcount - mingroutingcount - sumgroutingcount > 0 THEN standardgroutingcount - mingroutingcount
  1074. --期初剩余注浆次数为正数模具剩余注浆次数为负数:取期初剩余注浆次类
  1075. WHEN gmouldstatusname = '变产' AND standardgroutingcount - mingroutingcount >= 0 AND standardgroutingcount - mingroutingcount - sumgroutingcount < 0 THEN standardgroutingcount - mingroutingcount
  1076. --期初剩余注浆次数为负数模具剩余注浆次数为负数:取0
  1077. WHEN gmouldstatusname = '变产' AND standardgroutingcount - mingroutingcount < 0 AND standardgroutingcount - mingroutingcount - sumgroutingcount < 0 THEN 0
  1078. --期初剩余注浆次数为正数模具剩余注浆次数为正数:取期初剩余注浆次数
  1079. WHEN gmouldstatusname = '卸模' AND standardgroutingcount - mingroutingcount >= 0 AND standardgroutingcount - mingroutingcount - sumgroutingcount > 0 THEN standardgroutingcount - mingroutingcount
  1080. --期初剩余注浆次数为正数模具剩余注浆次数为负数:取期初剩余注浆次类
  1081. WHEN gmouldstatusname = '卸模' AND standardgroutingcount - mingroutingcount >= 0 AND standardgroutingcount - mingroutingcount - sumgroutingcount < 0 THEN standardgroutingcount - mingroutingcount
  1082. --期初剩余注浆次数为负数模具剩余注浆次数为负数:取0
  1083. WHEN gmouldstatusname = '卸模' AND standardgroutingcount - mingroutingcount < 0 AND standardgroutingcount - mingroutingcount - sumgroutingcount < 0 THEN 0
  1084. --期初剩余注浆次数为正数模具剩余注浆次数为正数:取本期注浆次数
  1085. WHEN gmouldstatusname = '正常' AND standardgroutingcount - mingroutingcount >= 0 AND standardgroutingcount - mingroutingcount - sumgroutingcount > 0 THEN sumgroutingcount
  1086. --期初剩余注浆次数为正数模具剩余注浆次数为负数:取期初剩余注浆次数
  1087. WHEN gmouldstatusname = '正常' AND standardgroutingcount - mingroutingcount >= 0 AND standardgroutingcount - mingroutingcount - sumgroutingcount < 0 THEN standardgroutingcount - mingroutingcount
  1088. --期初剩余注浆次数为负数模具剩余注浆次数为负数:取0
  1089. WHEN gmouldstatusname = '正常' AND standardgroutingcount - mingroutingcount < 0 AND standardgroutingcount - mingroutingcount - sumgroutingcount < 0 THEN 0
  1090. ELSE sumgroutingcount
  1091. END financecount,
  1092. standardgroutingcount - mingroutingcount mingresidue,
  1093. mouldGoodsCode,
  1094. mouldName
  1095. FROM
  1096. (
  1097. SELECT
  1098. t.groutinglinecode,
  1099. gl.BuildingNo,
  1100. gl.FloorNo,
  1101. gl.GroutingLineNo,
  1102. t.usercode,
  1103. t.goodscode,
  1104. t.GOODSSPECIFICATION,
  1105. t.goodstypename,
  1106. t.MouldQuantity,
  1107. gld.groutingmouldcode,
  1108. gms.gmouldstatusname,
  1109. gld.beginuseddate,
  1110. ( SELECT MIN( ggg.groutingdate ) FROM tp_pm_groutingdailydetail ggg WHERE ggg.groutinglinedetailid = t.groutinglinedetailid ) groutingdate,
  1111. MAX( t.GroutingCount ) - SUM( t.groutingflag ) mingroutingcount,
  1112. SUM( t.groutingflag ) sumgroutingcount,
  1113. MAX( t.GroutingCount ) maxGroutingCount,
  1114. gld.groutingcount,
  1115. MAX( gld.standardgroutingcount ) standardgroutingcount,
  1116. gld.ENDUSEDDATE,
  1117. mg.mouldGoodsCode,
  1118. mg.mouldName
  1119. FROM
  1120. (
  1121. SELECT
  1122. gd.groutinglinecode,
  1123. gd.usercode,
  1124. gdd.goodsid,
  1125. gd.MouldQuantity,
  1126. gdd.groutinglinedetailid,
  1127. decode( gdd.groutingflag, '1', 1, 0 ) groutingflag,
  1128. gdd.GroutingCount,
  1129. gt.goodstypename,
  1130. g.goodscode,
  1131. g.GOODSSPECIFICATION
  1132. FROM
  1133. TP_PM_GroutingDaily gd
  1134. INNER JOIN TP_PM_GroutingDailyDetail gdd ON gdd.groutingdailyid = gd.groutingdailyid
  1135. INNER JOIN TP_MST_Goods g ON g.goodsid = gdd.goodsid
  1136. INNER JOIN TP_MST_GOODSTYPE gt ON gt.goodstypeid = g.goodstypeid
  1137. WHERE
  1138. gd.accountid = 1
  1139. AND gd.groutingdate >= :GDateBegin
  1140. AND gd.groutingdate <= :GDateEnd
  1141. AND ( : groutinglinecode IS NULL OR instr( gd.groutinglinecode, : groutinglinecode ) > 0 )
  1142. AND ( : groutingusercode IS NULL OR instr( gdd.usercode, : groutingusercode ) > 0 )
  1143. AND ( : goodscode IS NULL OR instr( gdd.goodscode, : goodscode ) > 0 )
  1144. AND ( : goodstypecode IS NULL OR instr( gt.goodstypecode, : goodstypecode ) = 1 )
  1145. ) t
  1146. INNER JOIN tp_pc_groutinglinedetail gld ON gld.groutinglinedetailid = t.groutinglinedetailid
  1147. INNER JOIN tp_pc_groutingline gl ON gld.groutinglineid = gl.groutinglineid
  1148. INNER JOIN TP_SYS_GMouldStatus gms ON gms.gmouldstatusid = gld.gmouldstatus
  1149. INNER JOIN TP_MST_MOULDGOODSCODE mg ON t.goodscode = mg.goodsCode
  1150. GROUP BY
  1151. t.groutinglinecode,
  1152. gl.BuildingNo,
  1153. gl.FloorNo,
  1154. gl.GroutingLineNo,
  1155. t.usercode,
  1156. t.goodscode,
  1157. t.GOODSSPECIFICATION,
  1158. t.goodstypename,
  1159. t.MouldQuantity,
  1160. gld.groutingmouldcode,
  1161. gms.gmouldstatusname,
  1162. gld.beginuseddate,
  1163. gld.groutingcount,
  1164. gld.ENDUSEDDATE,
  1165. t.groutinglinedetailid,
  1166. mg.mouldGoodsCode,
  1167. mg.mouldName
  1168. ORDER BY
  1169. BuildingNo,
  1170. GroutingLineNo,
  1171. groutinglinecode,
  1172. groutingmouldcode
  1173. )
  1174. ";
  1175. }
  1176. List <OracleParameter> parameters = new List<OracleParameter>();
  1177. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  1178. parameters.Add(new OracleParameter(":GDateBegin", OracleDbType.Date, se.GDateBegin, ParameterDirection.Input));
  1179. parameters.Add(new OracleParameter(":GDateEnd", OracleDbType.Date, se.GDateEnd, ParameterDirection.Input));
  1180. parameters.Add(new OracleParameter(":groutinglinecode", OracleDbType.Varchar2, se.GroutingLineCode, ParameterDirection.Input));
  1181. parameters.Add(new OracleParameter(":groutingusercode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  1182. parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  1183. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  1184. DataSet ds = conn.GetSqlResultToDs(sqlString.ToString(), parameters.ToArray());
  1185. ServiceResultEntity sre = new ServiceResultEntity();
  1186. //if (data == null || data.Rows.Count == 0)
  1187. //{
  1188. // sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  1189. // return sre;
  1190. //}
  1191. //sre.Data = new DataSet();
  1192. //sre.Data.Tables.Add(data);
  1193. //return sre;
  1194. if (ds.Tables == null || ds.Tables[0].Rows.Count == 0)
  1195. {
  1196. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  1197. return sre;
  1198. }
  1199. sre.Data = ds;
  1200. return sre;
  1201. }
  1202. catch (Exception ex)
  1203. {
  1204. throw ex;
  1205. }
  1206. finally
  1207. {
  1208. if (conn != null &&
  1209. conn.ConnState == ConnectionState.Open)
  1210. {
  1211. conn.Close();
  1212. }
  1213. }
  1214. }
  1215. /// <summary>
  1216. /// 取得RPT010106画面(成型线剩余注浆次数)的查询数据
  1217. /// </summary>
  1218. /// <param name="user">登录用户信息</param>
  1219. /// <param name="se">查询条件</param>
  1220. /// <returns>查询结果</returns>
  1221. public static ServiceResultEntity GetRPT010106SData(SUserInfo user, RPT010106_SE se)
  1222. {
  1223. IDBConnection conn = null;
  1224. try
  1225. {
  1226. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1227. string sqlString =
  1228. "SELECT gl.buildingno\n" +
  1229. " ,gl.floorno\n" +
  1230. " ,gl.groutinglineno\n" +
  1231. " ,gl.groutinglinecode\n" +
  1232. " ,gl.Remarks\n" +
  1233. " ,decode(UserCount,\n" +
  1234. " 1,\n" +
  1235. " mu.usercode,\n" +
  1236. " (SELECT wmsys.wm_concat(to_char(gmu.usercode))\n" +
  1237. " FROM tp_pc_groutinguser gu\n" +
  1238. " INNER JOIN tp_mst_user gmu\n" +
  1239. " ON gmu.userid = gu.userid\n" +
  1240. " WHERE gu.groutinglineid = gl.groutinglineid)) groutingusercode\n" +
  1241. // 成型班长
  1242. " ,mnu.username as MONITORName" +
  1243. " ,g.goodscode\n" +
  1244. " ,g.goodsspecification\n" +
  1245. " ,gt.goodstypename\n" +
  1246. " --,gl.mouldquantity\n" +
  1247. " ,gldd.mouldquantity\n" +
  1248. " ,gmt.gmouldtypename\n" +
  1249. " ,gms.gmouldstatusname\n" +
  1250. " ,gldd.beginuseddate -- 上模日期\n" +
  1251. " ,gldd.groutingdate -- 首次注浆日期\n" +
  1252. " ,gldd.standardgroutingcount AS standardcount -- 标准注浆次数\n" +
  1253. " ,gldd.groutingcount -- 最大注浆次数\n" +
  1254. " ,gldd.standardgroutingcount - gldd.groutingcount AS mincount --剩余最少注浆次数\n" +
  1255. " ,gldd.sumstandardgroutingcount AS sumstandardcount -- 标准总注浆次数\n" +
  1256. " ,gldd.sumgroutingcount -- 总注浆次数\n" +
  1257. " ,gldd.sumstandardgroutingcount - gldd.sumgroutingcount AS leftcount --剩余总注浆次数\n" +
  1258. " ,round(decode(gl.mouldquantity,\n" +
  1259. " 0,\n" +
  1260. " 0,\n" +
  1261. " (gldd.sumstandardgroutingcount - gldd.sumgroutingcount) /\n" +
  1262. " gl.mouldquantity),\n" +
  1263. " 2) AS leftmaxcount -- 剩余最大注浆次数\n" +
  1264. " FROM tp_pc_groutingline gl\n" +
  1265. " INNER JOIN (SELECT gld.groutinglineid\n" +
  1266. " ,gld.goodsid\n" +
  1267. " ,COUNT(gld.groutinglinedetailid) mouldquantity\n" +
  1268. " ,MIN(gld.beginuseddate) beginuseddate\n" +
  1269. " ,MIN(gddd.groutingdate) groutingdate\n" +
  1270. " /* ,(SELECT MIN(gdd.groutingdate)\n" +
  1271. " FROM tp_pm_groutingdailydetail gdd\n" +
  1272. " WHERE gdd.groutinglinedetailid = gld.groutinglinedetailid\n" +
  1273. " AND gdd.groutingflag = '1') groutingdate*/\n" +
  1274. " ,MAX(gld.standardgroutingcount) standardgroutingcount\n" +
  1275. " ,MAX(gld.groutingcount) groutingcount\n" +
  1276. " ,SUM(gld.standardgroutingcount) sumstandardgroutingcount\n" +
  1277. " ,SUM(gld.groutingcount) sumgroutingcount\n" +
  1278. " FROM tp_pc_groutinglinedetail gld\n" +
  1279. " --LEFT JOIN tp_pm_groutingdailydetail gdd\n" +
  1280. " -- ON gdd.groutinglinedetailid = gld.groutinglinedetailid\n" +
  1281. " -- AND gdd.groutingflag = '1'\n" +
  1282. " LEFT JOIN (SELECT gdd.groutinglinedetailid\n" +
  1283. " ,gdd.mouldcode\n" +
  1284. " ,MIN(gdd.groutingdate) groutingdate\n" +
  1285. " FROM tp_pm_groutingdailydetail gdd\n" +
  1286. " WHERE gdd.accountid = :AccountID\n" +
  1287. " AND gdd.groutingflag = '1'\n" +
  1288. " GROUP BY gdd.groutinglinedetailid, gdd.mouldcode) gddd\n" +
  1289. " ON gddd.groutinglinedetailid = gld.groutinglinedetailid\n" +
  1290. " AND gddd.mouldcode = gld.mouldcode\n" +
  1291. " WHERE gld.valueflag = '1'\n" +
  1292. " GROUP BY gld.groutinglineid, gld.goodsid) gldd\n" +
  1293. " ON gldd.groutinglineid = gl.groutinglineid\n" +
  1294. " INNER JOIN tp_mst_goods g\n" +
  1295. " ON g.goodsid = gldd.goodsid\n" +
  1296. " INNER JOIN tp_mst_goodstype gt\n" +
  1297. " ON gt.goodstypeid = g.goodstypeid\n" +
  1298. " INNER JOIN tp_mst_gmouldtype gmt\n" +
  1299. " ON gmt.gmouldtypeid = gl.gmouldtypeid\n" +
  1300. " INNER JOIN tp_sys_gmouldstatus gms\n" +
  1301. " ON gms.gmouldstatusid = gl.gmouldstatus\n" +
  1302. " INNER JOIN tp_mst_user mu\n" +
  1303. " ON mu.userid = gl.userid\n" +
  1304. // 成型班长
  1305. " LEFT JOIN tp_mst_user mnu" +
  1306. " ON mnu.userid = gl.MONITORID" +
  1307. " WHERE gl.accountid = :AccountID\n" +
  1308. " AND gl.valueflag = '1'\n" +
  1309. " AND (:Remarks is null or instr(gl.Remarks, :Remarks) > 0)\n" +
  1310. " AND (:groutinglinecode is null or instr(gl.groutinglinecode, :groutinglinecode) > 0)\n" +
  1311. " AND (:goodscode is null or instr(g.goodscode, :goodscode) > 0)\n" +
  1312. " AND (:goodstypecode is null or instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  1313. " ORDER BY gl.groutinglinecode, g.goodscode";
  1314. List<OracleParameter> parameters = new List<OracleParameter>();
  1315. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  1316. parameters.Add(new OracleParameter(":Remarks", OracleDbType.Varchar2, se.Remarks, ParameterDirection.Input));
  1317. parameters.Add(new OracleParameter(":groutinglinecode", OracleDbType.Varchar2, se.GroutingLineCode, ParameterDirection.Input));
  1318. parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  1319. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  1320. DataTable data = conn.GetSqlResultToDt(sqlString.ToString(), parameters.ToArray());
  1321. ServiceResultEntity sre = new ServiceResultEntity();
  1322. if (data == null || data.Rows.Count == 0)
  1323. {
  1324. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  1325. return sre;
  1326. }
  1327. sre.Data = new DataSet();
  1328. sre.Data.Tables.Add(data);
  1329. return sre;
  1330. }
  1331. catch (Exception ex)
  1332. {
  1333. throw ex;
  1334. }
  1335. finally
  1336. {
  1337. if (conn != null &&
  1338. conn.ConnState == ConnectionState.Open)
  1339. {
  1340. conn.Close();
  1341. }
  1342. }
  1343. }
  1344. /// <summary>
  1345. /// 取得RPT010201_1画面(工序漏扫明细表)的查询数据
  1346. /// </summary>
  1347. /// <param name="user">登录用户信息</param>
  1348. /// <param name="se">查询条件</param>
  1349. /// <returns>查询结果</returns>
  1350. public static ServiceResultEntity GetRPT010201SData(SUserInfo user, RPT010201_SE se)
  1351. {
  1352. IDBConnection conn = null;
  1353. try
  1354. {
  1355. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1356. List<OracleParameter> parameters = new List<OracleParameter>();
  1357. // 校验时间--开始
  1358. if (se.beginCreateTime.HasValue)
  1359. {
  1360. parameters.Add(new OracleParameter("in_stardate", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  1361. }
  1362. // 校验时间--结束
  1363. if (se.endCreateTime.HasValue)
  1364. {
  1365. parameters.Add(new OracleParameter("in_enddate", OracleDbType.Date, se.endCreateTime.Value, ParameterDirection.Input));
  1366. }
  1367. conn.ExecStoredProcedure("PRO_PM_InitBarcodeMissing", parameters.ToArray());
  1368. parameters.Clear();
  1369. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010201SSQL(user, se, ref parameters));
  1370. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  1371. ServiceResultEntity sre = new ServiceResultEntity();
  1372. if (data == null || data.Rows.Count == 0)
  1373. {
  1374. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  1375. return sre;
  1376. }
  1377. sre.Data = new DataSet();
  1378. sre.Data.Tables.Add(data);
  1379. return sre;
  1380. }
  1381. catch (Exception ex)
  1382. {
  1383. throw ex;
  1384. }
  1385. finally
  1386. {
  1387. if (conn != null &&
  1388. conn.ConnState == ConnectionState.Open)
  1389. {
  1390. conn.Close();
  1391. }
  1392. }
  1393. }
  1394. /// <summary>
  1395. /// 获取RPT010201_1画面(工序漏扫明细表)的查询sql
  1396. /// </summary>
  1397. /// <returns>sql</returns>
  1398. private static string GetRPT010201SSQL(SUserInfo user, RPT010201_SE se, ref List<OracleParameter> parameters)
  1399. {
  1400. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  1401. #region
  1402. /*
  1403. selSql = selSql +
  1404. "select * from (" +
  1405. "select " +
  1406. "MissProcedureID, " +
  1407. "MissProcedureCode, " +
  1408. "case when GoodsType=TP_MST_GoodsType.GoodsTypeCode then to_char(TP_MST_GoodsType.GoodsTypeName) else to_char(GoodsType) end GoodsType, " +
  1409. "MissProcedureName, " +
  1410. "MissID, " +
  1411. "BarCode, " +
  1412. "OrganizationID, " +
  1413. "OrganizationName, " +
  1414. "OrganizationCode, " +
  1415. "OrganizationFullName, " +
  1416. "CompleteProcedureID, " +
  1417. "CompleteProcedureCode, " +
  1418. "CompleteProcedureName, " +
  1419. "ProcedureID, " +
  1420. "ProcedureCode, " +
  1421. "ProcedureName, " +
  1422. "GoodsID, " +
  1423. "GoodsCode, " +
  1424. "GoodsName, " +
  1425. "result.GoodsTypeID, " +
  1426. "result.CreateTime, " +
  1427. "result.GoodsTypeName, " +
  1428. "UserName, " +
  1429. "MissUserCode, " +
  1430. "barcodecount, seqno " +
  1431. "from " +
  1432. " ( " +
  1433. " select " +
  1434. " MissProcedureID, " +
  1435. " MissProcedureCode, " +
  1436. " decode(MissProcedureName,'小计',decode(MissProcedureID,'--','合计','--'),GoodsType) GoodsType, " +
  1437. " decode(MissProcedureID,'--','--',decode(MissProcedureName,'小计','小计',MissProcedureName)) MissProcedureName, " +
  1438. " MissID, " +
  1439. " BarCode, " +
  1440. " OrganizationID, " +
  1441. " OrganizationName, " +
  1442. " OrganizationCode, " +
  1443. " OrganizationFullName, " +
  1444. " CompleteProcedureID, " +
  1445. " CompleteProcedureCode, " +
  1446. " CompleteProcedureName, " +
  1447. " ProcedureID, " +
  1448. " ProcedureCode, " +
  1449. " ProcedureName, " +
  1450. " GoodsID, " +
  1451. " GoodsCode, " +
  1452. " GoodsName, " +
  1453. " GoodsTypeID, " +
  1454. " CreateTime, " +
  1455. " GoodsTypeName, " +
  1456. " UserName, " +
  1457. " MissUserCode, " +
  1458. " barcodecount,rownum seqno " +
  1459. " from " +
  1460. " ( " +
  1461. " select " +
  1462. " decode(grouping( MissProcedureID),1,'--',MissProcedureID) MissProcedureID, " +
  1463. " decode(grouping( MissProcedureCode),1,'--',MissProcedureCode) MissProcedureCode, " +
  1464. " decode(grouping( MissProcedureName),1,'小计',MissProcedureName) MissProcedureName, " +
  1465. " decode(grouping(GoodsType),1,'合计',GoodsType) GoodsType, " +
  1466. " decode(grouping(MissID),1,'--',MissID) MissID, " +
  1467. " decode(grouping(BarCode),1,'--',BarCode) BarCode, " +
  1468. " decode(grouping(OrganizationID),1,'--',OrganizationID) OrganizationID, " +
  1469. " decode(grouping(OrganizationName),1,'--',OrganizationName) OrganizationName, " +
  1470. " decode(grouping(OrganizationCode),1,'--',OrganizationCode) OrganizationCode, " +
  1471. " decode(grouping(OrganizationFullName),1,'--',OrganizationFullName) OrganizationFullName, " +
  1472. " decode(grouping(CompleteProcedureID),1,'--',CompleteProcedureID) CompleteProcedureID, " +
  1473. " decode(grouping(CompleteProcedureCode),1,'--',CompleteProcedureCode) CompleteProcedureCode, " +
  1474. " decode(grouping(CompleteProcedureName),1,'--',CompleteProcedureName) CompleteProcedureName, " +
  1475. " decode(grouping(ProcedureID),1,'--',ProcedureID) ProcedureID, " +
  1476. " decode(grouping(ProcedureCode),1,'--',ProcedureCode) ProcedureCode, " +
  1477. " decode(grouping(ProcedureName),1,'--',ProcedureName) ProcedureName, " +
  1478. " decode(grouping(GoodsID),1,'--',GoodsID) GoodsID, " +
  1479. " decode(grouping(GoodsCode),1,'--',GoodsCode) GoodsCode, " +
  1480. " decode(grouping(GoodsName),1,'--',GoodsName) GoodsName, " +
  1481. " decode(grouping(GoodsTypeID),1,'--',GoodsTypeID) GoodsTypeID, " +
  1482. " decode(grouping(CreateTime),1,'--',CreateTime) CreateTime, " +
  1483. " decode(grouping(GoodsTypeName),1,'--',GoodsTypeName) GoodsTypeName, " +
  1484. " decode(grouping(UserName),1,'--',UserName) UserName, " +
  1485. " decode(grouping(MissUserCode),1,'--',MissUserCode) MissUserCode, " +
  1486. " count(barcode) barcodecount " +
  1487. " from " +
  1488. " ( " +
  1489. " select TP_PM_BarCodeMissing.MissProcedureID, " +
  1490. " TP_PM_BarCodeMissing.MissProcedureCode, " +
  1491. " TP_PM_BarCodeMissing.MissProcedureName, " +
  1492. " substr(TP_MST_GoodsType.GOODSTYPECODE,1,6) GoodsType, " +
  1493. " TP_PM_BarCodeMissing.MissID, " +
  1494. " TP_PM_BarCodeMissing.BarCode, " +
  1495. " TP_PM_BarCodeMissing.OrganizationID, " +
  1496. " TP_PM_BarCodeMissing.OrganizationName, " +
  1497. " TP_PM_BarCodeMissing.OrganizationCode, " +
  1498. " TP_PM_BarCodeMissing.OrganizationFullName, " +
  1499. " TP_PM_BarCodeMissing.CompleteProcedureID, " +
  1500. " TP_PM_BarCodeMissing.CompleteProcedureCode, " +
  1501. " TP_PM_BarCodeMissing.CompleteProcedureName, " +
  1502. " TP_PM_BarCodeMissing.ProcedureID, " +
  1503. " TP_PM_BarCodeMissing.ProcedureCode, " +
  1504. " TP_PM_BarCodeMissing.ProcedureName, " +
  1505. " TP_PM_BarCodeMissing.GoodsID, " +
  1506. " TP_PM_BarCodeMissing.GoodsCode, " +
  1507. " TP_PM_BarCodeMissing.GoodsName, " +
  1508. " TP_PM_BarCodeMissing.GoodsTypeID, " +
  1509. " TP_PM_BarCodeMissing.MissUserCode, " +
  1510. " to_char(TP_PM_BarCodeMissing.CreateTime,'yyyy-MM-dd HH24:mi:ss') CreateTime, " +
  1511. " TP_MST_GoodsType.GoodsTypeName, " +
  1512. " TP_MST_USER.UserName " +
  1513. " from TP_PM_BarCodeMissing left join TP_MST_GoodsType " +
  1514. " on TP_PM_BarCodeMissing.GoodsTypeID=TP_MST_GoodsType.GoodsTypeID " +
  1515. " left join TP_MST_USER " +
  1516. " on TP_PM_BarCodeMissing.CreateUserID=TP_MST_USER.UserID " +
  1517. " where TP_PM_BarCodeMissing.valueflag=1 " +
  1518. " and TP_PM_BarCodeMissing.accountid=:AccountID ";
  1519. // 产品条码
  1520. if (!string.IsNullOrEmpty(se.Barcode))
  1521. {
  1522. selSql = selSql + " and TP_PM_BarCodeMissing.barcode=:Barcode ";
  1523. parameters.Add(new OracleParameter(":Barcode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  1524. }
  1525. // 组织结构
  1526. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  1527. {
  1528. selSql = selSql + " and instr(',' || :OrganizationIDS || ',' ,','||TP_PM_BarCodeMissing.OrganizationID||',' )>0 ";
  1529. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  1530. }
  1531. // 完成工序
  1532. if (!string.IsNullOrEmpty(se.CompleteProcedureIDS))
  1533. {
  1534. selSql = selSql + " and instr(',' || :CompleteProcedureIDS || ',',','||TP_PM_BarCodeMissing.CompleteProcedureID||',' )>0 ";
  1535. parameters.Add(new OracleParameter(":CompleteProcedureIDS", OracleDbType.NVarchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  1536. }
  1537. // 校验工序
  1538. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  1539. {
  1540. selSql = selSql + " and instr(',' || :ProcedureIDS || ',',','||TP_PM_BarCodeMissing.procedureID||',' )>0 ";
  1541. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  1542. }
  1543. // 漏扫工序
  1544. if (!string.IsNullOrEmpty(se.MissingProcedureIDS))
  1545. {
  1546. selSql = selSql + " and instr(',' || :MissingProcedureIDS || ',',','||TP_PM_BarCodeMissing.missProcedureID||',' )>0 ";
  1547. parameters.Add(new OracleParameter(":MissingProcedureIDS", OracleDbType.NVarchar2, se.MissingProcedureIDS, ParameterDirection.Input));
  1548. }
  1549. // 产品IDS
  1550. if (!string.IsNullOrEmpty(se.GoodsIDS))
  1551. {
  1552. selSql = selSql + " and instr(',' || :GoodsIDS || ',',','||TP_PM_BarCodeMissing.goodsID||',' )>0 ";
  1553. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  1554. }
  1555. // 产品IDS
  1556. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  1557. {
  1558. selSql = selSql + " and instr(',' || :GoodsTypeIDS || ',',','||TP_PM_BarCodeMissing.goodsTypeID||',' )>0 ";
  1559. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  1560. }
  1561. // 校验时间--开始
  1562. if (se.beginCreateTime.HasValue)
  1563. {
  1564. selSql = selSql + " and TP_PM_BarCodeMissing.CreateTime>= :CreateTimeStart ";
  1565. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  1566. }
  1567. // 校验时间--结束
  1568. if (se.endCreateTime.HasValue)
  1569. {
  1570. selSql = selSql + " and TP_PM_BarCodeMissing.CreateTime<= :CreateTimeEnd ";
  1571. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.endCreateTime.Value, ParameterDirection.Input));
  1572. }
  1573. selSql = selSql +
  1574. // " order by missprocedureid,username " +
  1575. " ) " +
  1576. " group by rollup( " +
  1577. " GoodsType, " +
  1578. " MissProcedureID, " +
  1579. " MissProcedureCode, " +
  1580. " MissProcedureName, " +
  1581. " MissID, " +
  1582. " BarCode, " +
  1583. " OrganizationID, " +
  1584. " OrganizationName, " +
  1585. " OrganizationCode, " +
  1586. " OrganizationFullName, " +
  1587. " CompleteProcedureID, " +
  1588. " CompleteProcedureCode, " +
  1589. " CompleteProcedureName, " +
  1590. " ProcedureID, " +
  1591. " ProcedureCode, " +
  1592. " ProcedureName, " +
  1593. " GoodsID, " +
  1594. " GoodsCode, " +
  1595. " GoodsName, " +
  1596. " GoodsTypeID, " +
  1597. " CreateTime, " +
  1598. " GoodsTypeName,MissUserCode, " +
  1599. " UserName ) " +
  1600. " ) " +
  1601. " where UserName!='--' or " +
  1602. " (USERNAME='--' and missprocedurename='小计'and missprocedurecode='--' and missprocedureid!='--' ) " +
  1603. " or " +
  1604. " (USERNAME='--' and missprocedureid='--' and GoodsType!='合计') " +
  1605. " ) result left join TP_MST_GoodsType on result.GoodsType=TP_MST_GoodsType.GoodsTypeCode"
  1606. + " ) order by seqno";
  1607. */
  1608. #endregion
  1609. string selSql = "select decode(tt.gid, 0, tt.MissID, null) MissID, --漏扫ID\n" +
  1610. " decode(tt.gid, 7, '总计', 0, tt.BarCode, '--') BarCode, --产品条码\n" +
  1611. " --decode(tt.gid, 0, tt.OrganizationID, null) OrganizationID,\n" +
  1612. " --decode(tt.gid, 0, tt.OrganizationCode, '--') OrganizationCode,\n" +
  1613. " decode(tt.gid, 0, tt.OrganizationName, '--') OrganizationName, --漏扫部门\n" +
  1614. " --decode(tt.gid, 0, tt.OrganizationFullName, '--') OrganizationFullName,\n" +
  1615. " --decode(tt.gid, 0, tt.CompleteProcedureID, null) CompleteProcedureID,\n" +
  1616. " --decode(tt.gid, 0, tt.CompleteProcedureCode, '--') CompleteProcedureCode,\n" +
  1617. " decode(tt.gid, 0, tt.CompleteProcedureName, '--') CompleteProcedureName,\n" +
  1618. " --decode(tt.gid, 0, tt.ProcedureID, null) ProcedureID,\n" +
  1619. " --decode(tt.gid, 0, tt.ProcedureCode, '--') ProcedureCode,\n" +
  1620. " decode(tt.gid, 0, tt.ProcedureName, '--') ProcedureName,\n" +
  1621. " --decode(tt.gid, 0, tt.MissProcedureID, null) MissProcedureID,\n" +
  1622. " --decode(tt.gid, 0, tt.MissProcedureCode, '--') MissProcedureCode,\n" +
  1623. " decode(tt.gid, 1, '小计', 0, tt.MissProcedureName, '--') MissProcedureName,\n" +
  1624. " decode(tt.gid, 0, tt.GoodsID, null) GoodsID,\n" +
  1625. " decode(tt.gid, 0, tt.GoodsCode, '--') GoodsCode,\n" +
  1626. " decode(tt.gid, 0, tt.GoodsName, '--') GoodsName,\n" +
  1627. " decode(tt.gid, 0, tt.GoodsTypeID, null) GoodsTypeID,\n" +
  1628. " decode(tt.gid, 0, tt.MissUserID, null) MissUserID,\n" +
  1629. " decode(tt.gid, 0, tt.MissUserCode, '--') MissUserCode,\n" +
  1630. " decode(tt.gid, 0, tt.CreateTime, null) CreateTime,\n" +
  1631. " decode(tt.gid, 0, tt.CreateUserID, null) CreateUserID,\n" +
  1632. " decode(tt.gid, 0, tt.username, '--') username,\n" +
  1633. " decode(tt.gid, 0, tt.repaircode, '--') repaircode,\n" +
  1634. " decode(tt.gid, 0, tt.prepaircode, '--') prepaircode,\n" +
  1635. " decode(tt.gid, 3, '合计', 0, tt.goodstypename2, '--') goodstype,\n" +
  1636. " tt.barcodecount, --数量\n" +
  1637. " tt.LogoCodeName\n" +
  1638. " from (select grouping_id(t.goodstypename2, --产品大类\n" +
  1639. " --t.MissProcedureCode,\n" +
  1640. " t.MissProcedureName,\n" +
  1641. " t.MissID) gid,\n" +
  1642. " t.MissID, --漏扫ID\n" +
  1643. " t.BarCode, --产品条码\n" +
  1644. " --t.OrganizationID,\n" +
  1645. " --t.OrganizationCode,\n" +
  1646. " t.OrganizationName, --漏扫部门\n" +
  1647. " --t.OrganizationFullName,\n" +
  1648. " --t.CompleteProcedureID,\n" +
  1649. " --t.CompleteProcedureCode,\n" +
  1650. " t.CompleteProcedureName, --完成工序\n" +
  1651. " --t.ProcedureID,\n" +
  1652. " --t.ProcedureCode,\n" +
  1653. " t.ProcedureName, --校验工序\n" +
  1654. " --t.MissProcedureID,\n" +
  1655. " --t.MissProcedureCode,\n" +
  1656. " t.MissProcedureName, --漏扫工序\n" +
  1657. " t.GoodsID,\n" +
  1658. " t.GoodsCode, --产品编码\n" +
  1659. " t.GoodsName, --产品名称\n" +
  1660. " t.GoodsTypeID,\n" +
  1661. " t.MissUserID,\n" +
  1662. " t.MissUserCode, --漏扫工号\n" +
  1663. " t.CreateTime, --校验漏扫时间\n" +
  1664. " t.CreateUserID,\n" +
  1665. " t.username, --校验者\n" +
  1666. " t.repaircode, --补扫操作工号\n" +
  1667. " t.prepaircode, --补扫生产工号\n" +
  1668. " t.goodstypename2, --产品大类\n" +
  1669. " count(t.barcodecount) barcodecount, --数量\n" +
  1670. " t.LogoCodeName\n" +
  1671. " from (select bcm.MissID, --漏扫ID\n" +
  1672. " bcm.BarCode, --产品条码\n" +
  1673. " --bcm.OrganizationID,\n" +
  1674. " --bcm.OrganizationCode,\n" +
  1675. " bcm.OrganizationName, --漏扫部门\n" +
  1676. " --bcm.OrganizationFullName,\n" +
  1677. " --bcm.CompleteProcedureID,\n" +
  1678. " --bcm.CompleteProcedureCode,\n" +
  1679. " --bcm.CompleteProcedureName, --完成工序\n" +
  1680. " cedp.ProcedureName as CompleteProcedureName, --完成工序\n" +
  1681. " --bcm.ProcedureID,\n" +
  1682. " --bcm.ProcedureCode,\n" +
  1683. " --bcm.ProcedureName, --校验工序\n" +
  1684. " cp.ProcedureName, --校验工序\n" +
  1685. " --bcm.MissProcedureID,\n" +
  1686. " --bcm.MissProcedureCode,\n" +
  1687. " --bcm.MissProcedureName, --漏扫工序\n" +
  1688. " mp.ProcedureName as MissProcedureName, --漏扫工序\n" +
  1689. " bcm.GoodsID,\n" +
  1690. " bcm.GoodsCode, --产品编码\n" +
  1691. " bcm.GoodsName, --产品名称\n" +
  1692. " bcm.GoodsTypeID,\n" +
  1693. " bcm.MissUserID,\n" +
  1694. " bcm.MissUserCode, --漏扫工号\n" +
  1695. " bcm.CreateTime, --校验漏扫时间\n" +
  1696. " bcm.CreateUserID,\n" +
  1697. " u.username, --校验者\n" +
  1698. //" MU.usercode repaircode, --补扫操作工号\n" +
  1699. //" MU.pusercode prepaircode, --补扫生产工号\n" +
  1700. " bcm.ROPUserCode repaircode, --补扫操作工号\n" +
  1701. " bcm.RWorkUserCode prepaircode, --补扫生产工号\n" +
  1702. " gt2.goodstypename goodstypename2, --产品大类\n" +
  1703. " 1 barcodecount, --数量\n" +
  1704. " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName\n" +
  1705. " from TP_PM_BarCodeMissing bcm\n" +
  1706. " left join TP_MST_User u\n" +
  1707. " on bcm.CreateUserID = u.userid\n" +
  1708. " left join TP_MST_GoodsType gt\n" +
  1709. " on bcm.GoodsTypeID = gt.GoodsTypeID\n" +
  1710. " left join TP_MST_GoodsType gt2\n" +
  1711. " on substr(gt.GoodsTypeCode, 1, 6) = gt2.GoodsTypeCode\n" +
  1712. " and gt.accountid = gt2.accountid\n" +
  1713. /*
  1714. //" left join TP_PM_ProductionData PD\n" +
  1715. //" on PD.BarCode = bcm.BarCode\n" +
  1716. //" and PD.ProcedureID = bcm.MissProcedureID\n" +
  1717. //" left join TP_MST_User MU\n" +
  1718. //" on MU.UserID = PD.CreateUserID\n" +
  1719. " left join (select pd.barcode,\n" +
  1720. " pd.procedureid,\n" +
  1721. " pd.usercode pusercode,\n" +
  1722. " mu.usercode,\n" +
  1723. //" pd.usercode,\n" +
  1724. " max(bm.missid) missid\n" +
  1725. //" row_number() over(partition by pd.barcode, pd.procedureid order by pd.productiondataid) rnum\n" +
  1726. " from tp_pm_productiondata pd\n" +
  1727. " inner join tp_pm_barcodemissing bm\n" +
  1728. " on bm.barcode = pd.barcode\n" +
  1729. " and bm.missprocedureid = pd.procedureid\n" +
  1730. " and bm.createtime < pd.createtime\n" +
  1731. " and bm.valueflag ='1'\n" +
  1732. " inner join tp_mst_user mu\n" +
  1733. " on mu.userid = pd.createuserid\n" +
  1734. " where pd.valueflag = '1'\n" +
  1735. " group by pd.barcode, pd.procedureid, pd.usercode, mu.usercode\n" +
  1736. " ) MU\n" +
  1737. " on MU.barcode = bcm.barcode\n" +
  1738. " and MU.procedureid = bcm.missprocedureid\n" +
  1739. " and MU.missid = bcm.missid" +
  1740. //" and MU.rnum = 1" +
  1741. */
  1742. " left join tp_pc_procedure cedp \n" +
  1743. " on cedp.procedureid = bcm.CompleteProcedureID\n" +
  1744. " left join tp_pc_procedure cp \n" +
  1745. " on cp.procedureid = bcm.ProcedureID\n" +
  1746. " left join tp_pc_procedure mp \n" +
  1747. " on mp.procedureid = bcm.MissProcedureID\n" +
  1748. " left join TP_PM_GroutingDailyDetail \n" +
  1749. " on TP_PM_GroutingDailyDetail.barcode = bcm.BarCode\n" +
  1750. " left join tp_mst_logo \n" +
  1751. " on tp_mst_logo.logoid = TP_PM_GroutingDailyDetail.logoid\n" +
  1752. " where bcm.valueflag='1' \n" +
  1753. " and bcm.accountid=:AccountID \n";
  1754. // 产品条码
  1755. if (!string.IsNullOrEmpty(se.Barcode))
  1756. {
  1757. selSql = selSql + " and bcm.barcode=:Barcode ";
  1758. parameters.Add(new OracleParameter(":Barcode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  1759. }
  1760. // 组织结构
  1761. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  1762. {
  1763. selSql = selSql + " and instr(',' || :OrganizationIDS || ',' ,','||bcm.OrganizationID||',' )>0 ";
  1764. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  1765. }
  1766. // 完成工序
  1767. if (!string.IsNullOrEmpty(se.CompleteProcedureIDS))
  1768. {
  1769. selSql = selSql + " and instr(',' || :CompleteProcedureIDS || ',',','||bcm.CompleteProcedureID||',' )>0 ";
  1770. parameters.Add(new OracleParameter(":CompleteProcedureIDS", OracleDbType.NVarchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  1771. }
  1772. // 校验工序
  1773. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  1774. {
  1775. selSql = selSql + " and instr(',' || :ProcedureIDS || ',',','||bcm.procedureID||',' )>0 ";
  1776. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  1777. }
  1778. // 漏扫工序
  1779. if (!string.IsNullOrEmpty(se.MissingProcedureIDS))
  1780. {
  1781. selSql = selSql + " and instr(',' || :MissingProcedureIDS || ',',','||bcm.missProcedureID||',' )>0 ";
  1782. parameters.Add(new OracleParameter(":MissingProcedureIDS", OracleDbType.NVarchar2, se.MissingProcedureIDS, ParameterDirection.Input));
  1783. }
  1784. // 产品IDS
  1785. if (!string.IsNullOrEmpty(se.GoodsIDS))
  1786. {
  1787. selSql = selSql + " and instr(',' || :GoodsIDS || ',',','||bcm.goodsID||',' )>0 ";
  1788. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  1789. }
  1790. // 产品IDS
  1791. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  1792. {
  1793. //selSql = selSql + " and instr(',' || :GoodsTypeIDS || ',',','||gt.goodsTypeCode||',' )=1 ";
  1794. selSql = selSql + " and instr(gt.goodsTypeCode,:GoodsTypeIDS )=1 ";
  1795. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  1796. }
  1797. // 校验时间--开始
  1798. if (se.beginCreateTime.HasValue)
  1799. {
  1800. selSql = selSql + " and bcm.CreateTime>= :CreateTimeStart ";
  1801. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  1802. }
  1803. // 校验时间--结束
  1804. if (se.endCreateTime.HasValue)
  1805. {
  1806. selSql = selSql + " and bcm.CreateTime<= :CreateTimeEnd ";
  1807. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.endCreateTime.Value, ParameterDirection.Input));
  1808. }
  1809. selSql += "\n" +
  1810. //" order by gt2.GoodsTypeCode,bcm.MissProcedureCode,\n" +
  1811. //" --bcm.GoodsCode,\n" +
  1812. //" bcm.BarCode,\n" +
  1813. //" bcm.ProcedureCode,\n" +
  1814. //" bcm.CompleteProcedureCode\n" +
  1815. //" ) t\n" +
  1816. " order by gt2.GoodsTypeCode,mp.ProcedureName,\n" +
  1817. " --bcm.GoodsCode,\n" +
  1818. " bcm.BarCode,\n" +
  1819. " cp.ProcedureName,\n" +
  1820. " cedp.ProcedureName\n" +
  1821. " ) t\n" +
  1822. " group by grouping sets((t.MissID, --漏扫ID\n" +
  1823. " t.BarCode, --产品条码\n" +
  1824. " t.goodstypename2, --产品大类\n" +
  1825. " /*t.OrganizationID, t.OrganizationCode,*/ t.OrganizationName, --漏扫部门\n" +
  1826. " /*t.OrganizationFullName, t.CompleteProcedureID, t.CompleteProcedureCode, t.CompleteProcedureName,*/ t.CompleteProcedureName, --完成工序\n" +
  1827. " /*t.ProcedureID, t.ProcedureCode, t.ProcedureName,*/ t.ProcedureName, --校验工序\n" +
  1828. " /*t.MissProcedureID, t.MissProcedureCode, t.MissProcedureName,*/ t.MissProcedureName, --漏扫工序\n" +
  1829. " t.GoodsID, t.GoodsCode, --产品编码\n" +
  1830. " t.GoodsName, --产品名称\n" +
  1831. " t.GoodsTypeID, t.MissUserID, t.MissUserCode, --漏扫工号\n" +
  1832. " t.CreateTime, --校验漏扫时间\n" +
  1833. " t.CreateUserID, t.username, --校验者\n" +
  1834. " t.repaircode, --补扫工号\n" +
  1835. " t.prepaircode, --补扫工号\n" +
  1836. " t.LogoCodeName --商标\n" +
  1837. " ),(t.goodstypename2, --产品大类\n" +
  1838. " /*t.MissProcedureCode,*/ t.MissProcedureName --漏扫工序\n" +
  1839. " ),(t.goodstypename2 --产品大类\n" +
  1840. " ),())) tt";
  1841. return selSql;
  1842. }
  1843. /// <summary>
  1844. /// 取得RPT010301_1画面(条码变更明细表)的查询数据
  1845. /// </summary>
  1846. /// <param name="user">登录用户信息</param>
  1847. /// <param name="se">查询条件</param>
  1848. /// <returns>查询结果</returns>
  1849. public static ServiceResultEntity GetRPT010301SData(SUserInfo user, RPT010301_SE se)
  1850. {
  1851. IDBConnection conn = null;
  1852. try
  1853. {
  1854. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1855. List<OracleParameter> parameters = new List<OracleParameter>();
  1856. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010301SSQL());
  1857. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  1858. if (se != null)
  1859. {
  1860. // 更换条码时间-开始
  1861. if (se.createTimeBegin.HasValue)
  1862. {
  1863. sql.Append(" and TP_PM_BarCodeRecord.CreateTime>= :CreateTimeBegin ");
  1864. parameters.Add(new OracleParameter(":CreateTimeBegin", OracleDbType.Date, se.createTimeBegin.Value, ParameterDirection.Input));
  1865. }
  1866. // 更换条码时间-结束
  1867. if (se.createTimeEnd.HasValue)
  1868. {
  1869. sql.Append(" and TP_PM_BarCodeRecord.CreateTime<= :CreateTimeEnd ");
  1870. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.createTimeEnd.Value, ParameterDirection.Input));
  1871. }
  1872. //成型线IDS
  1873. if (!string.IsNullOrEmpty(se.Barcode))
  1874. {
  1875. // 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 )");
  1876. 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 )");
  1877. parameters.Add(new OracleParameter(":Barcode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  1878. }
  1879. }
  1880. sql.Append(" ORDER BY TP_PM_BarCodeRecord.CREATETIME ");
  1881. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  1882. ServiceResultEntity sre = new ServiceResultEntity();
  1883. if (data == null || data.Rows.Count == 0)
  1884. {
  1885. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  1886. return sre;
  1887. }
  1888. sre.Data = new DataSet();
  1889. sre.Data.Tables.Add(data);
  1890. return sre;
  1891. }
  1892. catch (Exception ex)
  1893. {
  1894. throw ex;
  1895. }
  1896. finally
  1897. {
  1898. if (conn != null &&
  1899. conn.ConnState == ConnectionState.Open)
  1900. {
  1901. conn.Close();
  1902. }
  1903. }
  1904. }
  1905. /// <summary>
  1906. /// 获取RPT010301_1画面(条码变更明细表)的查询sql
  1907. /// </summary>
  1908. /// <returns>sql</returns>
  1909. private static string GetRPT010301SSQL()
  1910. {
  1911. string selSql =
  1912. " SELECT "
  1913. + " TP_PM_BarCodeRecord.BarCode, "
  1914. + " TP_PM_BarCodeRecord.NewBarCode, "
  1915. + " TP_PM_BarCodeRecord.FirstBarCode, "
  1916. + " TP_PM_BarCodeRecord.FinalBarCode, "
  1917. + " TP_PM_BarCodeRecord.Createtime, "
  1918. + " TP_PM_GROUTINGDAILYDETAIL.GroutingLineCode, "
  1919. + " TP_PM_GROUTINGDAILYDETAIL.GroutingLineName, "
  1920. + " TP_MST_GMouldType.Gmouldtypename, "
  1921. + " TP_PM_GROUTINGDAILYDETAIL.GroutingDate, "
  1922. + " TP_PM_GROUTINGDAILYDETAIL.GroutingMouldCode, "
  1923. + " TP_PM_GROUTINGDAILYDETAIL.MouldCode, "
  1924. + " TP_PM_GROUTINGDAILYDETAIL.UserCode GroutingUserCode, "
  1925. + " TP_PM_GROUTINGDAILYDETAIL.GroutingCount , "
  1926. + " TP_PM_GROUTINGDAILYDETAIL.GoodsCode, "
  1927. + " TP_PM_GROUTINGDAILYDETAIL.GoodsName, "
  1928. + " TP_PC_PROCEDURE.PROCEDURECODE, "
  1929. + " TP_PC_PROCEDURE.PROCEDURENAME, "
  1930. // 成型班长
  1931. + " mu.username as MONITORName,"
  1932. + " TP_MST_USER.USERNAME, "
  1933. + " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName "
  1934. + " from TP_PM_BarCodeRecord "
  1935. + " left join TP_PM_GROUTINGDAILYDETAIL on TP_PM_BarCodeRecord.FinalBarCode=TP_PM_GROUTINGDAILYDETAIL.Barcode "
  1936. + " inner join TP_PC_GroutingLine on TP_PC_GroutingLine.GroutingLineID=TP_PM_GroutingDailyDetail.GroutingLineID "
  1937. // 成型班长
  1938. + " LEFT JOIN tp_mst_user mu" +
  1939. " ON mu.userid = TP_PC_GroutingLine.MONITORID"
  1940. + " inner join TP_MST_GMouldType on TP_MST_GMouldType.GMOULDTYPEID=TP_PC_GroutingLine.GMOULDTYPEID "
  1941. + " left join TP_PC_PROCEDURE on TP_PM_BarCodeRecord.Procedureid=TP_PC_PROCEDURE.PROCEDUREID "
  1942. + " left join TP_MST_USER ON TP_PM_BarCodeRecord.CreateUserID=TP_MST_USER.USERID "
  1943. + " left join TP_MST_logo ON TP_MST_logo.logoid=TP_PM_GROUTINGDAILYDETAIL.logoid "
  1944. + " where TP_PM_GROUTINGDAILYDETAIL.ACCOUNTID=:AccountID ";
  1945. return selSql;
  1946. }
  1947. /// <summary>
  1948. /// 取得RPT010401画面(在产品明细表)的查询数据
  1949. /// </summary>
  1950. /// <param name="user">登录用户信息</param>
  1951. /// <param name="se">查询条件</param>
  1952. /// <returns>查询结果</returns>
  1953. public static ServiceResultEntity GetRPT010401SData(SUserInfo user, RPT010401_SE se)
  1954. {
  1955. IDBConnection conn = null;
  1956. try
  1957. {
  1958. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1959. List<OracleParameter> parameters = new List<OracleParameter>();
  1960. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010401SSQL());
  1961. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  1962. if (se != null)
  1963. {
  1964. // 条码
  1965. if (!string.IsNullOrEmpty(se.Barcode))
  1966. {
  1967. //sql.Append(" AND TP_PM_InProduction.BarCode=:Barcode ");
  1968. sql.Append(" AND instr(TP_PM_InProduction.BarCode,:Barcode)>0 ");
  1969. parameters.Add(new OracleParameter(":Barcode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  1970. }
  1971. // 产品IDS
  1972. if (!string.IsNullOrEmpty(se.GoodsIDS))
  1973. {
  1974. sql.Append(" AND instr(','||:GoodsIDS||',',','||TP_PM_InProduction.GoodsId||',')>0 ");
  1975. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  1976. }
  1977. //生产线IDS
  1978. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  1979. {
  1980. sql.Append(" AND instr(','||:ProductionLineIDS||',',','||TP_PM_InProduction.ProductionLineID||',')>0 ");
  1981. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  1982. }
  1983. //完成工序IDS
  1984. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  1985. {
  1986. sql.Append(" AND instr(','||:ProcedureIDS||',',','||TP_PM_InProduction.ProcedureID||',')>0 ");
  1987. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  1988. }
  1989. //生产工号IDS
  1990. if (!string.IsNullOrEmpty(se.UserIDS))
  1991. {
  1992. sql.Append(" AND instr(','||:UserIDS||',',','||TP_PM_InProduction.UserID||',')>0 ");
  1993. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  1994. }
  1995. // 成型线IDS
  1996. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  1997. {
  1998. sql.Append(" AND instr(','||:GroutingLineIDS||',',','||TP_PM_InProduction.GroutingLineID||',')>0 ");
  1999. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  2000. }
  2001. // 成型线类型IDS
  2002. if (!string.IsNullOrEmpty(se.GMouldTypeIDS))
  2003. {
  2004. sql.Append(" AND instr(','||:GMouldTypeIDS||',',','||TP_PM_InProduction.GMouldTypeID||',')>0 ");
  2005. parameters.Add(new OracleParameter(":GMouldTypeIDS", OracleDbType.NVarchar2, se.GMouldTypeIDS, ParameterDirection.Input));
  2006. }
  2007. // 交坯时间--开始
  2008. if (se.CreateTimeStart.HasValue)
  2009. {
  2010. sql.Append(" AND TP_PM_GroutingDailyDetail.delivertime >= :CreateTimeStart ");
  2011. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  2012. }
  2013. // 交坯时间--结束
  2014. if (se.CreateTimeEnd.HasValue)
  2015. {
  2016. sql.Append(" AND TP_PM_GroutingDailyDetail.delivertime <= :CreateTimeEnd ");
  2017. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  2018. }
  2019. // 完成时间--开始
  2020. if (se.UpdateTimeStart.HasValue)
  2021. {
  2022. sql.Append(" AND TP_PM_InProduction.Proceduretime >= :UpdateTimeStart ");
  2023. parameters.Add(new OracleParameter(":UpdateTimeStart", OracleDbType.Date, se.UpdateTimeStart.Value, ParameterDirection.Input));
  2024. }
  2025. // 完成时间--结束
  2026. if (se.UpdateTimeEnd.HasValue)
  2027. {
  2028. sql.Append(" AND TP_PM_InProduction.Proceduretime <= :UpdateTimeEnd ");
  2029. parameters.Add(new OracleParameter(":UpdateTimeEnd", OracleDbType.Date, se.UpdateTimeEnd.Value, ParameterDirection.Input));
  2030. }
  2031. if (se.inscrapflag != 2)
  2032. {
  2033. sql.Append(" AND TP_PM_InProduction.inscrapflag=:inscrapflag ");
  2034. parameters.Add(new OracleParameter(":inscrapflag", OracleDbType.NVarchar2, se.inscrapflag, ParameterDirection.Input));
  2035. }
  2036. if (!string.IsNullOrWhiteSpace(se.GoodsTypeCode))
  2037. {
  2038. sql.Append(" AND instr(gt.goodstypecode, :GoodsTypeCode) = 1 ");
  2039. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  2040. }
  2041. }
  2042. sql.Append(" order by TP_PM_InProduction.UpdateTime desc");
  2043. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  2044. ServiceResultEntity sre = new ServiceResultEntity();
  2045. if (data == null || data.Rows.Count == 0)
  2046. {
  2047. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2048. return sre;
  2049. }
  2050. sre.Data = new DataSet();
  2051. sre.Data.Tables.Add(data);
  2052. return sre;
  2053. }
  2054. catch (Exception ex)
  2055. {
  2056. throw ex;
  2057. }
  2058. finally
  2059. {
  2060. if (conn != null &&
  2061. conn.ConnState == ConnectionState.Open)
  2062. {
  2063. conn.Close();
  2064. }
  2065. }
  2066. }
  2067. /// <summary>
  2068. /// 获取RPT010401画面(在产品明细表)的查询sql
  2069. /// </summary>
  2070. /// <returns>sql</returns>
  2071. private static string GetRPT010401SSQL()
  2072. {
  2073. string selSql =
  2074. "SELECT " +
  2075. " TP_PM_InProduction.BarCode, " +
  2076. " TP_PM_InProduction.GoodsID,TP_PM_InProduction.GoodsCode, " +
  2077. " TP_PM_InProduction.GoodsName, gt.goodstypename," +
  2078. " TP_PM_InProduction.Userid,A.USERNAME as UserName,A.USERCode as UserCode, " +
  2079. " TP_PM_InProduction.ProductionLineID, " +
  2080. " TP_PM_InProduction.ProductionLineCode, " +
  2081. " TP_PM_InProduction.ProductionLineName, " +
  2082. " TP_PM_InProduction.ModelType, " +
  2083. " decode(TP_PM_InProduction.inscrapflag , '1', '待审核的报废品' , '正常') as inscrapflag, " +
  2084. //" decode(TP_PM_InProduction.IsPublicBody, '1', '是' , '否') as IsPublicBody, " +
  2085. " TP_PM_InProduction.IsPublicBody, " +
  2086. //" decode(TP_PM_InProduction.IsReFire, '1', '是' , '否') as IsReFire, " +
  2087. " decode(TP_PM_InProduction.IsReFire, '6', '1' , '0') as IsReFire, " +
  2088. " TP_PM_InProduction.IsReworkFlag, " +
  2089. " decode(TP_PM_InProduction.CanManyTimes, '1', '能' , '不能') as CanManyTimes, " +
  2090. " decode(TP_PM_InProduction.ProcedureModel, '1', '计件模型' , '检验模型') as ProcedureModel, " +
  2091. " TP_PM_InProduction.GroutingDailyID, " +
  2092. " TP_PM_InProduction.GroutingDailyDetailID, " +
  2093. " TP_PM_InProduction.GroutingDate, " +
  2094. " TP_PM_InProduction.GroutingLineID, " +
  2095. " TP_PM_InProduction.GroutingLineCode, " +
  2096. " TP_PM_InProduction.GroutingLineName, " +
  2097. " TP_PM_InProduction.KILNCODE, " +
  2098. " TP_PM_InProduction.KILNCARCODE, " +
  2099. " TP_PM_InProduction.ProcedureID CompleteProcedureID, " +
  2100. " D.ProcedureName as CompleteProcedureName, " +
  2101. " TP_PM_InProduction.GMouldTypeID, " +
  2102. " TP_MST_GMouldType.GMOULDTYPENAME as GMouldTypeName, " +
  2103. " TP_PM_InProduction.GroutingLineDetailID, " +
  2104. " TP_PM_InProduction.GroutingMouldCode, " +
  2105. " TP_PM_InProduction.SPECIALREPAIRFLAG, " +
  2106. " TP_PM_InProduction.GROUTINGUSERCODE, " +
  2107. " TP_PM_GroutingDailyDetail.GROUTINGCOUNT, " +
  2108. " TP_PM_GroutingDailyDetail.GROUTINGBATCHNO, " +
  2109. " TP_PM_GroutingDailyDetail.delivertime, " +
  2110. " TP_PM_InProduction.proceduretime, " +
  2111. " TP_PM_InProduction.Remarks, " +
  2112. " TP_MST_GoodsLevel.GOODSLEVELNAME AS GOODSLEVELTYPENAME,"+
  2113. "TP_PM_InProduction.GoodsLevelTypeID,"+
  2114. "TP_SYS_GoodsLevelType.GOODSLEVELTYPENAME AS GOODSLEVELNAME,"+
  2115. " TP_PM_InProduction.AccountID,TP_PM_InProduction.ValueFlag, " +
  2116. " TP_PM_GroutingDailyDetail.glazingroom," +
  2117. " TP_PM_InProduction.CreateTime,TP_PM_InProduction.CreateUserID,B.USERNAME as CreateUserName, " +
  2118. " TP_PM_InProduction.PROCEDURETIME AS UpdateTime,TP_PM_InProduction.UpdateUserID,C.USERNAME as UpdateUserName, " +
  2119. " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName, " +
  2120. //" (Goods.MaterialCode || TP_MST_Logo.tagcode || TP_PM_GroutingDailyDetail.onlycode) as FinishedBarCode " +
  2121. " 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 " +
  2122. "FROM TP_PM_InProduction " +
  2123. " inner join TP_MST_User A on A.UserID=TP_PM_InProduction.Userid " +
  2124. " inner join TP_MST_User B on B.UserID=TP_PM_InProduction.CreateUserID " +
  2125. " inner join TP_MST_User C on C.UserID=TP_PM_InProduction.UpdateUserID " +
  2126. " inner join TP_PC_Procedure D on D.PROCEDUREID=TP_PM_InProduction.ProcedureID " +
  2127. " inner join TP_MST_GMouldType on TP_MST_GMouldType.GMouldTypeID=TP_PM_InProduction.GMouldTypeID " +
  2128. " inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.ProcedureModelTypeID=TP_PM_InProduction.ModelType " +
  2129. " inner join TP_PM_GroutingDaily on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_InProduction.GroutingDailyID " +
  2130. " inner join TP_PM_GroutingDailyDetail on TP_PM_GroutingDailyDetail.Groutingdailydetailid=TP_PM_InProduction.GroutingDailyDetailID " +
  2131. " inner join TP_PC_GroutingLineDetail on TP_PC_GroutingLineDetail.Groutinglinedetailid=TP_PM_InProduction.GroutingLineDetailID " +
  2132. " inner join TP_MST_Account on TP_MST_Account.Accountid=TP_PM_InProduction.Accountid " +
  2133. " left join TP_MST_GoodsLevel on TP_MST_GoodsLevel.GoodsLevelID=TP_PM_InProduction.GoodsLevelID " +
  2134. " left join TP_SYS_GoodsLevelType on TP_SYS_GoodsLevelType.GoodsLevelTypeID=TP_PM_InProduction.GoodsLevelTypeID " +
  2135. " left join TP_MST_Logo on TP_PM_InProduction.logoid=TP_MST_Logo.logoid " +
  2136. " left join TP_MST_Goods Goods on TP_PM_InProduction.GoodsID=Goods.GoodsID " +
  2137. " left join tp_mst_goodstype gt on gt.goodstypeid = Goods.goodstypeid " +
  2138. " Where TP_PM_InProduction.ValueFlag = 1 " +
  2139. " and (TP_PM_InProduction.GoodsLevelTypeID is null or TP_PM_InProduction.GoodsLevelTypeID <> 20) " +
  2140. " and TP_PM_InProduction.AccountID=:AccountID ";
  2141. return selSql;
  2142. }
  2143. /// <summary>
  2144. /// 取得RPT010402画面(产成品明细表)的查询数据
  2145. /// </summary>
  2146. /// <param name="user">登录用户信息</param>
  2147. /// <param name="se">查询条件</param>
  2148. /// <returns>查询结果</returns>
  2149. public static ServiceResultEntity GetRPT010402SData(SUserInfo user, RPT010402_SE se)
  2150. {
  2151. IDBConnection conn = null;
  2152. try
  2153. {
  2154. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  2155. List<OracleParameter> parameters = new List<OracleParameter>();
  2156. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010402SSQL());
  2157. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2158. if (se != null)
  2159. {
  2160. // 条码
  2161. if (!string.IsNullOrEmpty(se.Barcode))
  2162. {
  2163. //sql.Append(" AND TP_PM_FinishedProduct.BarCode=:BarCode ");
  2164. sql.Append(" AND instr(TP_PM_FinishedProduct.BarCode,:Barcode)>0 ");
  2165. parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  2166. }
  2167. // 产品IDS
  2168. if (!string.IsNullOrEmpty(se.GoodsIDS))
  2169. {
  2170. sql.Append(" AND instr(','||:GoodsIDS||',',','||TP_PM_FinishedProduct.GoodsId||',')>0 ");
  2171. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  2172. }
  2173. // 生产线IDS
  2174. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  2175. {
  2176. sql.Append(" AND instr(','||:ProductionLineIDS||',',','||TP_PM_FinishedProduct.ProductionLineID||',')>0 ");
  2177. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  2178. }
  2179. // 成型线ids
  2180. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  2181. {
  2182. sql.Append(" AND instr(','||:GroutingLineIDS||',',','||TP_PM_FinishedProduct.GroutingLineID||',')>0 ");
  2183. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  2184. }
  2185. // 成型线类型ids
  2186. if (!string.IsNullOrEmpty(se.GMouldTypeIDS))
  2187. {
  2188. sql.Append(" AND instr(','||:GMouldTypeIDS||',',','||TP_PM_FinishedProduct.GMouldTypeID||',')>0 ");
  2189. parameters.Add(new OracleParameter(":GMouldTypeIDS", OracleDbType.NVarchar2, se.GMouldTypeIDS, ParameterDirection.Input));
  2190. }
  2191. // 财务日期--开始
  2192. if (se.AccountDateStart.HasValue)
  2193. {
  2194. //sql.Append(" AND TP_PM_FinishedProduct.AccountDate >= :AccountDateStart ");
  2195. sql.Append(" AND TP_PM_FinishedProduct.CreateTime >= :AccountDateStart ");
  2196. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  2197. }
  2198. // 财务日期--结束
  2199. if (se.AccountDateEnd.HasValue)
  2200. {
  2201. //sql.Append(" AND TP_PM_FinishedProduct.AccountDate <= :AccountDateEnd ");
  2202. sql.Append(" AND TP_PM_FinishedProduct.CreateTime <= :AccountDateEnd ");
  2203. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  2204. }
  2205. // 注浆时间--开始
  2206. if (se.CreateTimeStart.HasValue)
  2207. {
  2208. sql.Append(" AND TP_PM_GroutingDaily.CreateTime >= :CreateTimeStart ");
  2209. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  2210. }
  2211. // 注浆时间--结束
  2212. if (se.CreateTimeEnd.HasValue)
  2213. {
  2214. sql.Append(" AND TP_PM_GroutingDaily.CreateTime <= :CreateTimeEnd ");
  2215. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  2216. }
  2217. }
  2218. sql.Append(" order by TP_PM_FinishedProduct.UpdateTime desc");
  2219. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  2220. ServiceResultEntity sre = new ServiceResultEntity();
  2221. if (data == null || data.Rows.Count == 0)
  2222. {
  2223. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2224. return sre;
  2225. }
  2226. sre.Data = new DataSet();
  2227. sre.Data.Tables.Add(data);
  2228. return sre;
  2229. }
  2230. catch (Exception ex)
  2231. {
  2232. throw ex;
  2233. }
  2234. finally
  2235. {
  2236. if (conn != null &&
  2237. conn.ConnState == ConnectionState.Open)
  2238. {
  2239. conn.Close();
  2240. }
  2241. }
  2242. }
  2243. /// <summary>
  2244. /// 获取RPT010402画面(产成品明细表)的查询sql
  2245. /// </summary>
  2246. /// <returns>sql</returns>
  2247. private static string GetRPT010402SSQL()
  2248. {
  2249. string selSql =
  2250. "SELECT " +
  2251. " TP_PM_FinishedProduct.BarCode, " +
  2252. " TP_PM_FinishedProduct.GoodsID, " +
  2253. " TP_PM_FinishedProduct.GoodsCode, " +
  2254. " TP_PM_FinishedProduct.GoodsName, " +
  2255. " TP_PM_FinishedProduct.ProductionLineID, " +
  2256. " TP_PM_FinishedProduct.ProductionLineCode, " +
  2257. " TP_PM_FinishedProduct.ProductionLineName, " +
  2258. //" decode(TP_PM_FinishedProduct.IsPublicBody, '1', '是' , '否') as IsPublicBody, " +
  2259. //" decode(TP_PM_FinishedProduct.IsReFire, '1', '是' , '否') as IsReFire, " +
  2260. " TP_PM_FinishedProduct.IsPublicBody, " +
  2261. " decode(TP_PM_FinishedProduct.IsReFire, '6', '1' , '0') as IsReFire, " +
  2262. " decode(TP_PM_GroutingDaily.CanManyTimes, '1', '是' , '否') as CanManyTimes, " +
  2263. " decode(TP_PM_FinishedProduct.SettlementFlag, '1', '已结算' , '未结算') as SettlementFlag, " +
  2264. " TP_PM_FinishedProduct.GroutingDailyID, " +
  2265. " TP_PM_FinishedProduct.GroutingDailyDetailID, " +
  2266. " TP_PM_FinishedProduct.GroutingDate, " +
  2267. " TP_PM_FinishedProduct.GroutingLineID, " +
  2268. " TP_PM_FinishedProduct.GroutingLineCode," +
  2269. " TP_PM_FinishedProduct.GroutingLineName, " +
  2270. " TP_PM_FinishedProduct.GMouldTypeID, " +
  2271. " TP_MST_GMouldType.GMOULDTYPENAME as GMouldTypeName, " +
  2272. " TP_PM_FinishedProduct.GroutingLineDetailID, " +
  2273. " TP_PM_FinishedProduct.GroutingMouldCode," +
  2274. " TP_PM_GroutingDailyDetail.GROUTINGCOUNT," +
  2275. " TP_PM_FinishedProduct.GROUTINGUSERCODE," +
  2276. " TP_PM_FinishedProduct.SPECIALREPAIRFLAG," +
  2277. " TP_PM_FinishedProduct.KILNID," +
  2278. " TP_PM_FinishedProduct.KILNCODE," +
  2279. " TP_PM_FinishedProduct.KILNNAME," +
  2280. " TP_PM_FinishedProduct.KILNCARID," +
  2281. " TP_PM_FinishedProduct.KILNCARCODE," +
  2282. " TP_PM_FinishedProduct.KILNCARNAME," +
  2283. " TP_MST_DATADICTIONARY.DICTIONARYVALUE KILNCARPOSITION," +
  2284. " TP_PM_FinishedProduct.MouldCode, " +
  2285. " TP_PM_FinishedProduct.Remarks, " +
  2286. " TP_PM_FinishedProduct.GoodsLevelID,TP_MST_GoodsLevel.GOODSLEVELNAME, " +
  2287. " TP_PM_FinishedProduct.GoodsLevelTypeID, " +
  2288. " TP_SYS_GoodsLevelType.GOODSLEVELTYPENAME, " +
  2289. " TP_PM_FinishedProduct.FHUSERCODE, " +
  2290. " TP_PM_FinishedProduct.FHTIME, " +
  2291. " odr.ORDERNO, " +
  2292. " TP_PM_FinishedProduct.AccountID, " +
  2293. " TP_PM_FinishedProduct.ValueFlag, " +
  2294. " TP_PM_FinishedProduct.AccountDate, " +
  2295. " TP_PM_FinishedProduct.CreateTime, " +
  2296. " TP_PM_FinishedProduct.CreateUserID, " +
  2297. " B.USERNAME as CreateUserName, " +
  2298. " TP_PM_FinishedProduct.UpdateTime, " +
  2299. " TP_PM_FinishedProduct.UpdateUserID, " +
  2300. " C.USERNAME as UpdateUserName, " +
  2301. " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName," +
  2302. " TP_PM_GroutingDailyDetail.Materialcode," +
  2303. //" (Goods.MaterialCode || tp_mst_logo.tagcode || TP_PM_GroutingDailyDetail.onlycode) as FinishedBarCode " +
  2304. " TP_PM_GroutingDailyDetail.outlabelcode as FinishedBarCode " +
  2305. " FROM TP_PM_FinishedProduct " +
  2306. " left join TP_PM_ORDER odr on odr.ORDERID=TP_PM_FinishedProduct.FHORDERID " +
  2307. " left join TP_MST_User B on B.UserID=TP_PM_FinishedProduct.CreateUserID " +
  2308. " left join TP_MST_User C on C.UserID=TP_PM_FinishedProduct.UpdateUserID " +
  2309. " left join TP_MST_GMouldType on TP_MST_GMouldType.GMouldTypeID=TP_PM_FinishedProduct.GMouldTypeID " +
  2310. " left join TP_MST_DATADICTIONARY on TP_PM_FinishedProduct.KILNCARPOSITION=TP_MST_DATADICTIONARY.DICTIONARYID " +
  2311. " left join TP_PM_GroutingDaily on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_FinishedProduct.GroutingDailyID " +
  2312. " left join TP_PM_GroutingDailyDetail on TP_PM_GroutingDailyDetail.Groutingdailydetailid=TP_PM_FinishedProduct.GroutingDailyDetailID " +
  2313. " left join TP_PC_GroutingLineDetail on TP_PC_GroutingLineDetail.Groutinglinedetailid=TP_PM_FinishedProduct.GroutingLineDetailID " +
  2314. " left join TP_MST_Account on TP_MST_Account.Accountid=TP_PM_FinishedProduct.Accountid " +
  2315. " left join TP_MST_GoodsLevel on TP_MST_GoodsLevel.GOODSLEVELID=TP_PM_FinishedProduct.GoodsLevelID " +
  2316. " left join TP_SYS_GoodsLevelType on TP_SYS_GoodsLevelType.GoodsLevelTypeID=TP_PM_FinishedProduct.GoodsLevelTypeID " +
  2317. " left join tp_mst_logo on TP_PM_FinishedProduct.logoid=tp_mst_logo.logoid " +
  2318. " left join TP_MST_Goods Goods on TP_PM_FinishedProduct.GoodsID=Goods.GoodsID " +
  2319. " Where 1=1 and TP_PM_FinishedProduct.ValueFlag = 1 " +
  2320. " and TP_PM_FinishedProduct.AccountID=:AccountID ";
  2321. return selSql;
  2322. }
  2323. /// <summary>
  2324. /// 取得RPT010403画面(生产数据明细表)的查询数据
  2325. /// </summary>
  2326. /// <param name="user">登录用户信息</param>
  2327. /// <param name="se">查询条件</param>
  2328. /// <returns>查询结果</returns>
  2329. public static ServiceResultEntity GetRPT010403SData(SUserInfo user, RPT010403_SE se)
  2330. {
  2331. IDBConnection conn = null;
  2332. try
  2333. {
  2334. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  2335. List<OracleParameter> parameters = new List<OracleParameter>();
  2336. string sqlString =
  2337. "SELECT *\n" +
  2338. " FROM (SELECT pd.barcode\n" +
  2339. " ,gt2.goodstypename as goodstypename2\n" +
  2340. " ,gt.goodstypename\n" +
  2341. " ,g.goodscode\n" +
  2342. " ,PD.ProductionLineName\n" +
  2343. " ,to_char(p.ProcedureName) AS ProcedureName\n" +
  2344. " ,op.organizationfullname AS porgname\n" +
  2345. " ,pd.CreateTime\n" +
  2346. " ,PD.UserCode\n" +
  2347. " ,cu.Usercode AS CreateUsercode\n" +
  2348. " ,cu.Username AS CreateUserName\n" +
  2349. " ,co.organizationfullname corgname\n" +
  2350. " , CASE\n" +
  2351. " WHEN PD.valueflag = '0' AND PD.ProcedureModel = '1' THEN\n" +
  2352. " '撤销(['|| to_char(bu.usercode) || ']' || to_char(bu.username) || ' ' ||\n" +
  2353. " to_char(PD.Backouttime, 'yyyy-mm-dd hh24:mi:ss') || ')'\n" +
  2354. " WHEN PD.valueflag = '0' AND PD.ProcedureModel = '2' THEN\n" +
  2355. " to_char(GL.GOODSLEVELNAME) || '(被修改)'\n" +
  2356. " ELSE\n" +
  2357. " to_char(GL.GOODSLEVELNAME)\n" +
  2358. " END || CASE\n" +
  2359. " WHEN pd.modeltype = 1 THEN\n" +
  2360. " '[' || to_char(pd.kilncarcode) || ']'\n" +
  2361. " ELSE\n" +
  2362. " ''\n" +
  2363. " END GOODSLEVELNAME\n" +
  2364. " ,gdd.glazingroom" +
  2365. " FROM TP_PM_ProductionData PD\n" +
  2366. " INNER JOIN tp_pc_procedure p\n" +
  2367. " ON p.procedureid = pd.procedureid\n" +
  2368. " LEFT JOIN tp_mst_goods g\n" +
  2369. " ON g.goodsid = pd.goodsid\n" +
  2370. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  2371. " ON gdd.Groutingdailydetailid = pd.Groutingdailydetailid\n" +
  2372. " LEFT JOIN tp_mst_goodstype gt\n" +
  2373. " ON gt.goodstypeid = g.goodstypeid\n" +
  2374. " LEFT JOIN tp_mst_goodstype gt2\n" +
  2375. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  2376. " AND gt2.AccountID = :AccountID\n" +
  2377. " INNER JOIN tp_mst_organization op\n" +
  2378. " ON op.organizationid = p.organizationid\n" +
  2379. " INNER JOIN tp_mst_user cu\n" +
  2380. " ON cu.userid = PD.Createuserid\n" +
  2381. " INNER JOIN tp_mst_organization co\n" +
  2382. " ON co.organizationid = cu.organizationid\n" +
  2383. " LEFT JOIN tp_mst_user bu\n" +
  2384. " ON bu.userid = PD.Backoutuserid\n" +
  2385. " LEFT JOIN tp_mst_goodslevel GL\n" +
  2386. " ON GL.GOODSLEVELID = PD.GOODSLEVELID\n" +
  2387. " AND gl.AccountID = :AccountID\n" +
  2388. " WHERE PD.AccountID = :AccountID\n" +
  2389. " AND PD.Createtime >= :CreatetimeBegin\n" +
  2390. " AND PD.Createtime <= :CreatetimeEnd\n" +
  2391. " AND (:ProductionLineID IS NULL OR\n" +
  2392. " pd.productionlineid = :ProductionLineID)\n" +
  2393. " AND (:GoodsTypeCode IS NULL OR\n" +
  2394. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  2395. " AND (:GoodsCode IS NULL OR instr(g.GoodsCode, :GoodsCode) > 0)\n" +
  2396. " AND (:BarCode IS NULL OR instr(pd.BarCode, :BarCode) > 0)\n" +
  2397. " UNION ALL\n" +
  2398. " -- 报损\n" +
  2399. " SELECT sp.barcode\n" +
  2400. " ,gt2.goodstypename as goodstypename2\n" +
  2401. " ,gt.goodstypename\n" +
  2402. " ,g.goodscode\n" +
  2403. " ,sp.productionlinename\n" +
  2404. //" ,to_char(gl.goodslevelname) || '-完成工序【' ||\n" +
  2405. //" to_char(p.procedurename) || '】' AS procedurename\n" +
  2406. " ,'损坯-完成工序【' || to_char(p.procedurename) || '】-责任工序【' || CASE\n" +
  2407. " WHEN rpp.procedureid IS NOT NULL THEN\n" +
  2408. " to_char(rpp.procedurename)\n" +
  2409. " ELSE\n" +
  2410. " '无'\n" +
  2411. " END || '】-责任工号【[' || to_char(sruser.usercode) || ']' ||\n" +
  2412. " to_char(sruser.Username) || '】-原因【' ||\n" +
  2413. " to_char(sp.rreason) || '】' AS procedurename" +
  2414. " ,NULL AS porgname\n" +
  2415. " ,sp.Createtime\n" +
  2416. " ,NULL AS Usercode\n" +
  2417. " ,u.Usercode AS CreateUsercode\n" +
  2418. " ,U.Username AS CreateUserName\n" +
  2419. " ,co.organizationfullname corgname\n" +
  2420. " ,to_char(A.AUDITSTATUSNAME) || CASE\n" +
  2421. " WHEN Length(AU.usercode) > 0 THEN\n" +
  2422. " '(['|| to_char(AU.usercode) || ']' || to_char(AU.Username) || ' ' ||\n" +
  2423. " to_char(sp.AuditDate, 'yyyy-mm-dd hh24:mi:ss') || ')'\n" +
  2424. " ELSE\n" +
  2425. " ''\n" +
  2426. " END || CASE\n" +
  2427. " WHEN sp.valueflag = '0' THEN\n" +
  2428. " '-撤销(['|| to_char(uu.usercode) || ']' || to_char(uu.username) || ' ' ||\n" +
  2429. " to_char(sp.updatetime, 'yyyy-mm-dd hh24:mi:ss') || ')'\n" +
  2430. " ELSE\n" +
  2431. " ''\n" +
  2432. " END AS GOODSLEVELNAME\n" +
  2433. " ,null glazingroom\n" +
  2434. " FROM tp_pm_scrapproduct sp\n" +
  2435. " LEFT JOIN tp_mst_goods g\n" +
  2436. " ON g.goodsid = sp.goodsid\n" +
  2437. " LEFT JOIN tp_mst_goodstype gt\n" +
  2438. " ON gt.goodstypeid = g.goodstypeid\n" +
  2439. " LEFT JOIN tp_mst_goodstype gt2\n" +
  2440. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  2441. " AND gt2.AccountID = :AccountID\n" +
  2442. " INNER JOIN tp_pc_procedure p\n" +
  2443. " ON p.procedureid = sp.procedureid\n" +
  2444. " --inner join tp_mst_organization op\n" +
  2445. " -- on op.organizationid = p.organizationid\n" +
  2446. " INNER JOIN tp_mst_user U\n" +
  2447. " ON U.userid = sp.CREATEUSERID\n" +
  2448. " INNER JOIN tp_mst_organization co\n" +
  2449. " ON co.organizationid = u.organizationid\n" +
  2450. " INNER JOIN tp_mst_user uu\n" +
  2451. " ON uu.userid = sp.Updateuserid\n" +
  2452. " INNER JOIN tp_sys_AuditStatus A\n" +
  2453. " ON A.AuditStatusid = sp.AuditStatus\n" +
  2454. " LEFT JOIN tp_mst_goodslevel gl\n" +
  2455. " ON gl.goodsleveltypeid = 8\n" +
  2456. " AND gl.accountid = 1\n" +
  2457. " LEFT JOIN tp_mst_user AU\n" +
  2458. " ON au.userid = sp.auditor\n" +
  2459. " LEFT JOIN TP_PM_ResponProcedure rp\n" +
  2460. " ON rp.scrapproductid = sp.scrapproductid\n" +
  2461. " LEFT JOIN tp_pc_procedure rpp\n" +
  2462. " ON rpp.procedureid = rp.procedureid\n" +
  2463. " LEFT JOIN (SELECT DISTINCT sr.scrapproductid, sr.userid\n" +
  2464. " FROM TP_PM_ScrapResponsible sr\n" +
  2465. " WHERE sr.AccountID = :AccountID\n" +
  2466. " -- 编辑后 时间不一致\n" +
  2467. " --AND sr.Createtime >= :CreatetimeBegin\n" +
  2468. " --AND sr.Createtime <= :CreatetimeEnd\n" +
  2469. " ) sru\n" +
  2470. " ON sru.scrapproductid = sp.scrapproductid\n" +
  2471. " LEFT JOIN tp_mst_user sruser\n" +
  2472. " ON sruser.userid = sru.userid" +
  2473. " WHERE (sp.goodsleveltypeid = 8 OR sp.goodsleveltypeid = 9)\n" +
  2474. " AND sp.scraptype = '0'\n" +
  2475. " AND sp.AccountID = :AccountID\n" +
  2476. " AND sp.Createtime >= :CreatetimeBegin\n" +
  2477. " AND sp.Createtime <= :CreatetimeEnd\n" +
  2478. " AND (:ProductionLineID IS NULL OR\n" +
  2479. " sp.productionlineid = :ProductionLineID)\n" +
  2480. " AND (:GoodsTypeCode IS NULL OR\n" +
  2481. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  2482. " AND (:BarCode IS NULL OR instr(sp.BarCode, :BarCode) > 0)\n" +
  2483. " AND (:GoodsCode IS NULL OR instr(g.GoodsCode, :GoodsCode) > 0)) t\n" +
  2484. " ORDER BY t.barcode, t.Createtime";
  2485. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2486. parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  2487. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  2488. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  2489. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  2490. parameters.Add(new OracleParameter(":CreatetimeBegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input));
  2491. parameters.Add(new OracleParameter(":CreatetimeEnd", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input));
  2492. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  2493. ServiceResultEntity sre = new ServiceResultEntity();
  2494. if (data == null || data.Rows.Count == 0)
  2495. {
  2496. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2497. return sre;
  2498. }
  2499. sre.Data = new DataSet();
  2500. sre.Data.Tables.Add(data);
  2501. return sre;
  2502. }
  2503. catch (Exception ex)
  2504. {
  2505. throw ex;
  2506. }
  2507. finally
  2508. {
  2509. if (conn != null &&
  2510. conn.ConnState == ConnectionState.Open)
  2511. {
  2512. conn.Close();
  2513. }
  2514. }
  2515. }
  2516. /// <summary>
  2517. /// 取得RPT010302画面(商标变更明细表)的查询数据
  2518. /// </summary>
  2519. /// <param name="user">登录用户信息</param>
  2520. /// <param name="se">查询条件</param>
  2521. /// <returns>查询结果</returns>
  2522. public static ServiceResultEntity GetRPT010302SData(SUserInfo user, RPT010302_SE se)
  2523. {
  2524. IDBConnection conn = null;
  2525. try
  2526. {
  2527. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  2528. List<OracleParameter> parameters = new List<OracleParameter>();
  2529. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010302SSQL());
  2530. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2531. if (se != null)
  2532. {
  2533. // 更换条码时间-开始
  2534. if (se.createTimeBegin.HasValue)
  2535. {
  2536. sql.Append(" and lcr.CreateTime>= :CreateTimeBegin ");
  2537. parameters.Add(new OracleParameter(":CreateTimeBegin", OracleDbType.Date, se.createTimeBegin.Value, ParameterDirection.Input));
  2538. }
  2539. // 更换条码时间-结束
  2540. if (se.createTimeEnd.HasValue)
  2541. {
  2542. sql.Append(" and lcr.CreateTime<= :CreateTimeEnd ");
  2543. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.createTimeEnd.Value, ParameterDirection.Input));
  2544. }
  2545. //成型线IDS
  2546. if (!string.IsNullOrEmpty(se.Barcode))
  2547. {
  2548. // 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 )");
  2549. sql.Append(" and (instr(lcr.BARCODE,:Barcode)>0 )");
  2550. parameters.Add(new OracleParameter(":Barcode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  2551. }
  2552. }
  2553. sql.Append(" ORDER BY lcr.CREATETIME ");
  2554. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  2555. ServiceResultEntity sre = new ServiceResultEntity();
  2556. if (data == null || data.Rows.Count == 0)
  2557. {
  2558. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2559. return sre;
  2560. }
  2561. sre.Data = new DataSet();
  2562. sre.Data.Tables.Add(data);
  2563. return sre;
  2564. }
  2565. catch (Exception ex)
  2566. {
  2567. throw ex;
  2568. }
  2569. finally
  2570. {
  2571. if (conn != null &&
  2572. conn.ConnState == ConnectionState.Open)
  2573. {
  2574. conn.Close();
  2575. }
  2576. }
  2577. }
  2578. /// <summary>
  2579. /// 获取RPT010302画面(商标变更明细表)的查询sql
  2580. /// </summary>
  2581. /// <returns>sql</returns>
  2582. private static string GetRPT010302SSQL()
  2583. {
  2584. string selSql =
  2585. "SELECT lcr.BarCode\n" +
  2586. " ,REPLACE((oldlogo.Logoname || '[' || oldlogo.Logocode || ']'),\n" +
  2587. " '[]',\n" +
  2588. " '') AS oldLogoCodeName\n" +
  2589. " ,REPLACE((newlogo.Logoname || '[' || newlogo.Logocode || ']'),\n" +
  2590. " '[]',\n" +
  2591. " '') AS newLogoCodeName\n" +
  2592. " ,lcr.Createtime\n" +
  2593. " ,gdd.GroutingLineCode\n" +
  2594. " ,gdd.GroutingLineName\n" +
  2595. " ,gdd.GroutingDate\n" +
  2596. " ,gdd.GroutingMouldCode\n" +
  2597. " ,gdd.MouldCode\n" +
  2598. " ,gdd.UserCode GroutingUserCode\n" +
  2599. " ,gdd.GroutingCount\n" +
  2600. " ,gdd.GoodsCode\n" +
  2601. " ,gdd.GoodsName\n" +
  2602. " ,p.PROCEDURECODE\n" +
  2603. " ,p.PROCEDURENAME\n" +
  2604. " ,u.USERCode\n" +
  2605. " ,u.USERNAME\n" +
  2606. " FROM TP_PM_LogoChangedRecord lcr\n" +
  2607. " LEFT JOIN TP_PM_GROUTINGDAILYDETAIL gdd\n" +
  2608. " ON lcr.barcode = gdd.Barcode\n" +
  2609. " LEFT JOIN TP_PC_PROCEDURE p\n" +
  2610. " ON lcr.Procedureid = p.PROCEDUREID\n" +
  2611. " LEFT JOIN TP_MST_USER u\n" +
  2612. " ON lcr.CreateUserID = u.USERID\n" +
  2613. " LEFT JOIN TP_MST_logo oldlogo\n" +
  2614. " ON lcr.oldlogoid = oldlogo.logoid\n" +
  2615. " LEFT JOIN TP_MST_logo newlogo\n" +
  2616. " ON lcr.newlogoid = newlogo.logoid\n" +
  2617. " WHERE lcr.ACCOUNTID = :AccountID";
  2618. return selSql;
  2619. }
  2620. #endregion 明细报表
  2621. #region 分析报表
  2622. /// <summary>
  2623. /// 取得RPT040101_1画面(注浆交坯比率分析表)的查询数据
  2624. /// </summary>
  2625. /// <param name="user">登录用户信息</param>
  2626. /// <param name="se">查询条件</param>
  2627. /// <returns>查询结果</returns>
  2628. public static ServiceResultEntity GetRPT040101SData(SUserInfo user, RPT040101_SE se)
  2629. {
  2630. IDBConnection conn = null;
  2631. try
  2632. {
  2633. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  2634. #region
  2635. /*
  2636. List<OracleParameter> parameters = new List<OracleParameter>();
  2637. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT040101SSQL());
  2638. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2639. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.GroutingDateStart.Value, ParameterDirection.Input));
  2640. parameters.Add(new OracleParameter(":groutingDateEnd", OracleDbType.Date, se.GroutingDateEnd.Value, ParameterDirection.Input));
  2641. parameters.Add(new OracleParameter(":dateDifference", OracleDbType.Int32, se.DateDifference, ParameterDirection.Input));
  2642. if (se != null)
  2643. {
  2644. // 成型线IDS
  2645. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  2646. {
  2647. sql.Append(" AND instr(',' || :GroutingLineIDS ||',',','||TP_PM_GroutingDailyDetail.GroutingLineId||',')>0 ");
  2648. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  2649. }
  2650. // 成型工IDS
  2651. if (!string.IsNullOrEmpty(se.UserIDS))
  2652. {
  2653. sql.Append(" AND instr(',' || :UserIDS ||',',','||TP_PM_GroutingDailyDetail.UserId||',')>0 ");
  2654. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  2655. }
  2656. //产品类型IDS
  2657. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  2658. {
  2659. sql.Append(" AND instr(',' || :GoodsTypeIDS ||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ");
  2660. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  2661. }
  2662. //产品IDS
  2663. if (!string.IsNullOrEmpty(se.GoodsIDS))
  2664. {
  2665. sql.Append(" AND instr(',' || :GoodsIDS ||',',','||TP_PM_GroutingDailyDetail.GoodsId||',')>0 ");
  2666. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  2667. }
  2668. }
  2669. sql.Append(" group by ");
  2670. sql.Append(" TP_PM_GroutingDailyDetail.UserCode, ");
  2671. sql.Append(" TP_PM_GroutingDailyDetail.Groutinglineid, ");
  2672. sql.Append(" line.GroutinglineCode, ");
  2673. sql.Append(" TP_MST_GOODSTYPE.GoodsTypeName, ");
  2674. sql.Append(" TP_PM_GroutingDailyDetail.GoodsCode, ");
  2675. sql.Append(" TP_MST_Goods.Goodsspecification, ");
  2676. sql.Append(" TP_MST_DataDictionary.DICTIONARYVALUE, ");
  2677. sql.Append(" MouldQuantity ");
  2678. sql.Append(" ) temp ");
  2679. sql.Append(" ) a ");
  2680. sql.Append(" group by rollup( ");
  2681. sql.Append(" UserCode, ");
  2682. sql.Append(" Groutinglinecode, ");
  2683. sql.Append(" GoodsTypeName, ");
  2684. sql.Append(" GoodsCode, ");
  2685. sql.Append(" Goodsspecification, ");
  2686. sql.Append(" DICTIONARYVALUE, ");
  2687. sql.Append(" MouldQuantity, ");
  2688. sql.Append(" 注浆量, ");
  2689. sql.Append(" 交坯量 ");
  2690. sql.Append(" ) ");
  2691. sql.Append(") Temp where 交坯量 is not null");
  2692. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  2693. */
  2694. #endregion
  2695. List<OracleParameter> parameters = new List<OracleParameter>();
  2696. //StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT040101SSQL());
  2697. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2698. //parameters.Add(new OracleParameter(":dateDifference", OracleDbType.Int32, se.DateDifference, ParameterDirection.Input));
  2699. string sqlGroutingdate = null;
  2700. StringBuilder sql = new StringBuilder();
  2701. if (se != null)
  2702. {
  2703. // 成型线IDS
  2704. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  2705. {
  2706. sql.Append(" AND instr(',' || :GroutingLineIDS ||',',','||gdd.GroutingLineId||',')>0 ");
  2707. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  2708. }
  2709. // 成型工IDS
  2710. if (!string.IsNullOrEmpty(se.UserIDS))
  2711. {
  2712. sql.Append(" AND instr(',' || :UserIDS ||',',','||gdd.UserId||',')>0 ");
  2713. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  2714. }
  2715. //产品类型IDS
  2716. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  2717. {
  2718. //sql.Append(" AND instr(',' || :GoodsTypeIDS ||',',','||gt.GOODSTYPECode||',')=1");
  2719. sql.Append(" AND instr(gt.GOODSTYPECode,:GoodsTypeIDS)=1");
  2720. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  2721. }
  2722. //产品IDS
  2723. if (!string.IsNullOrEmpty(se.GoodsIDS))
  2724. {
  2725. sql.Append(" AND instr(',' || :GoodsIDS ||',',','||gdd.GoodsId||',')>0 ");
  2726. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  2727. }
  2728. if (se.GroutingDateStart.HasValue)
  2729. {
  2730. //sql.Append(" and gdd.groutingdate >= :groutingDateStart \n");
  2731. //sql.Append(" and gdd.groutingdate <= :groutingDateEnd \n");
  2732. sqlGroutingdate = " and gdd.groutingdate >= :groutingDateStart \n"
  2733. + " and gdd.groutingdate <= :groutingDateEnd \n";
  2734. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.GroutingDateStart.Value, ParameterDirection.Input));
  2735. parameters.Add(new OracleParameter(":groutingDateEnd", OracleDbType.Date, se.GroutingDateEnd.Value, ParameterDirection.Input));
  2736. parameters.Add(new OracleParameter(":DeliverTimeStart", OracleDbType.Date, se.GroutingDateStart.Value.AddDays(se.DateDifference), ParameterDirection.Input));
  2737. parameters.Add(new OracleParameter(":DeliverTimeEnd", OracleDbType.Date, se.GroutingDateEnd.Value.AddDays(se.DateDifference), ParameterDirection.Input));
  2738. }
  2739. else if (se.GCTimeBegin.HasValue)
  2740. {
  2741. //sql.Append(" and gdd.createtime >= :groutingDateStart \n");
  2742. //sql.Append(" and gdd.createtime <= :groutingDateEnd \n");
  2743. sqlGroutingdate = " and gdd.createtime >= :groutingDateStart \n"
  2744. + " and gdd.createtime <= :groutingDateEnd \n";
  2745. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.GCTimeBegin.Value, ParameterDirection.Input));
  2746. parameters.Add(new OracleParameter(":groutingDateEnd", OracleDbType.Date, se.GCTimeEnd.Value, ParameterDirection.Input));
  2747. parameters.Add(new OracleParameter(":DeliverTimeStart", OracleDbType.Date, se.GCTimeBegin.Value.Date.AddDays(se.DateDifference), ParameterDirection.Input));
  2748. parameters.Add(new OracleParameter(":DeliverTimeEnd", OracleDbType.Date, se.GCTimeEnd.Value.Date.AddDays(se.DateDifference), ParameterDirection.Input));
  2749. }
  2750. }
  2751. string sqlString =
  2752. "select decode(gid, 7, '总计', 3, '合计['|| gddata.usercode ||']', gddata.usercode) usercode,\n" +
  2753. " decode(gid, 1, '小计['|| gddata.goodscode ||']', 0, gddata.goodscode, '--') goodscode,\n" +
  2754. " decode(gid, 0, gddata.goodstypename, '--') goodstypename,\n" +
  2755. " decode(gid, 0, gddata.goodsspecification, '--') goodsspecification,\n" +
  2756. " decode(gid, 0, gddata.GlazeType, '--') GlazeType,\n" +
  2757. " decode(gid, 0, gddata.groutinglinecode, '--') groutinglinecode,\n" +
  2758. " decode(gid, 0, to_char(gddata.MouldQuantity), '--') MouldQuantity,\n" +
  2759. //" select gddata.usercode,\n" +
  2760. //" gddata.goodscode,\n" +
  2761. //" gddata.goodstypename,\n" +
  2762. //" gddata.goodsspecification,\n" +
  2763. //" gddata.GlazeType,\n" +
  2764. //" gddata.groutinglinecode,\n" +
  2765. //" gddata.MouldQuantity,\n" +
  2766. " gddata.GroutingNum,\n" +
  2767. " gddata.StrippingNum,\n" +
  2768. " gddata.DeliverNum,\n" +
  2769. " decode(gddata.GroutingNum,\n" +
  2770. " 0,\n" +
  2771. " '0.00%',\n" +
  2772. " to_char((gddata.StrippingNum / gddata.GroutingNum) * 100,\n" +
  2773. " '9,990.00') || '%') GSPercent, -- 注成比,\n" +
  2774. " decode(gddata.GroutingNum,\n" +
  2775. " 0,\n" +
  2776. " '0.00%',\n" +
  2777. " to_char((gddata.DeliverNum / gddata.GroutingNum) * 100,\n" +
  2778. " '9,990.00') || '%') GDPercent, -- 注交比,\n" +
  2779. " decode(gddata.StrippingNum,\n" +
  2780. " 0,\n" +
  2781. " '0.00%',\n" +
  2782. " to_char((gddata.DeliverNum / gddata.StrippingNum) * 100,\n" +
  2783. " '9,990.00') || '%') SDPercent -- 成交比,\n" +
  2784. " from (select grouping_id(gdd.flag,gdd.usercode, gdd.goodscode, gdd.groutinglinecode) gid,\n" +
  2785. //" select grouping_id(gdd.flag,gdd.usercode, gdd.goodscode, gdd.groutinglinecode) gid,\n" +
  2786. " gdd.usercode,\n" +
  2787. " gdd.goodscode,\n" +
  2788. " gdd.goodstypename,\n" +
  2789. " gdd.goodsspecification,\n" +
  2790. " gdd.GlazeType,\n" +
  2791. " gdd.groutinglinecode,\n" +
  2792. " gdd.MouldQuantity,\n" +
  2793. " sum(gdd.GroutingNum) GroutingNum,\n" +
  2794. " sum(gdd.StrippingNum) StrippingNum,\n" +
  2795. " sum(gdd.DeliverNum) DeliverNum\n" +
  2796. " from (select 1 flag,\n" +
  2797. //" select 1 flag,\n" +
  2798. " gddgroup.usercode,\n" +
  2799. " gddgroup.goodscode,\n" +
  2800. " gddgroup.goodstypename,\n" +
  2801. " gddgroup.goodsspecification,\n" +
  2802. " gddgroup.GlazeType,\n" +
  2803. " gddgroup.groutinglinecode,\n" +
  2804. " gddgroup.MouldQuantity,\n" +
  2805. " sum(gddgroup.GroutingNum) GroutingNum,\n" +
  2806. " sum(gddgroup.StrippingNum) StrippingNum,\n" +
  2807. " sum(gddgroup.DeliverNum) DeliverNum\n" +
  2808. " from (select --gdd.groutingdailydetailid,\n" +
  2809. " gd.groutinglinecode,\n" +
  2810. " gt.goodstypename,\n" +
  2811. " g.goodscode,\n" +
  2812. " g.goodsspecification,\n" +
  2813. " dd.dictionaryvalue GlazeType,\n" +
  2814. //" gdd.usercode,\n" +
  2815. (se.IsMonitor ? " mu.username usercode,\n" : " gdd.usercode,\n") +
  2816. " gd.MouldQuantity,\n" +
  2817. " decode(gdd.GroutingFlag, '1', 1, 0) GroutingNum,\n" +
  2818. " case\n" +
  2819. " when gdd.GroutingFlag = '1' and gdd.ScrapFlag = '0' then\n" +
  2820. " 1\n" +
  2821. " else\n" +
  2822. " 0\n" +
  2823. " end StrippingNum,\n" +
  2824. " 0 DeliverNum\n" +
  2825. " from tp_pm_groutingdaily gd\n" +
  2826. " inner join tp_pm_groutingdailydetail gdd\n" +
  2827. " on gd.groutingdailyid = gdd.groutingdailyid\n" +
  2828. " left join tp_mst_user mu\n" +
  2829. " on mu.userid = gd.MonitorID\n" +
  2830. " inner join tp_mst_goods g\n" +
  2831. " on gdd.goodsid = g.goodsid\n" +
  2832. " inner join tp_mst_goodstype gt\n" +
  2833. " on g.goodstypeid = gt.goodstypeid\n" +
  2834. " inner join tp_mst_datadictionary dd\n" +
  2835. " on dd.dictionaryid = g.GlazeTypeID\n" +
  2836. " where gd.valueflag = '1'\n" +
  2837. " and gd.accountid = :AccountID\n"
  2838. + sqlGroutingdate +
  2839. //" and gdd.groutingdate >= :groutingDateStart \n" +
  2840. //" and gdd.groutingdate <= :groutingDateEnd \n" +
  2841. sql +
  2842. " union all\n" +
  2843. " select --gdd.groutingdailydetailid,\n" +
  2844. " gd.groutinglinecode,\n" +
  2845. " gt.goodstypename,\n" +
  2846. " g.goodscode,\n" +
  2847. " g.goodsspecification,\n" +
  2848. " dd.dictionaryvalue GlazeType,\n" +
  2849. //" gdd.usercode,\n" +
  2850. (se.IsMonitor ? " mu.username usercode,\n" : " gdd.usercode,\n") +
  2851. " gd.MouldQuantity,\n" +
  2852. " 0 GroutingNum,\n" +
  2853. " 0 StrippingNum,\n" +
  2854. " decode(gdd.deliverflag, '1', 1, 0) DeliverNum\n" +
  2855. " from tp_pm_groutingdaily gd\n" +
  2856. " inner join tp_pm_groutingdailydetail gdd\n" +
  2857. " on gd.groutingdailyid = gdd.groutingdailyid\n" +
  2858. " left join tp_mst_user mu\n" +
  2859. " on mu.userid = gd.MonitorID\n" +
  2860. " inner join tp_mst_goods g\n" +
  2861. " on gdd.goodsid = g.goodsid\n" +
  2862. " inner join tp_mst_goodstype gt\n" +
  2863. " on g.goodstypeid = gt.goodstypeid\n" +
  2864. " inner join tp_mst_datadictionary dd\n" +
  2865. " on dd.dictionaryid = g.GlazeTypeID\n" +
  2866. " where gd.valueflag = '1'\n" +
  2867. " and gd.accountid = :AccountID\n" +
  2868. " and gdd.DeliverTime >= :DeliverTimeStart \n" +
  2869. " and gdd.DeliverTime <= :DeliverTimeEnd \n" + sql +
  2870. " ) gddgroup\n" +
  2871. " group by gddgroup.usercode, gddgroup.goodscode, gddgroup.goodstypename, gddgroup.goodsspecification, gddgroup.GlazeType, gddgroup.groutinglinecode, gddgroup.MouldQuantity\n" +
  2872. " order by gddgroup.usercode, gddgroup.goodscode, gddgroup.groutinglinecode\n" +
  2873. " ) gdd\n" +
  2874. " 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" +
  2875. //" order by gdd.usercode, gdd.goodscode, gdd.groutinglinecode " +
  2876. ") gddata";
  2877. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  2878. ServiceResultEntity sre = new ServiceResultEntity();
  2879. if (data == null || data.Rows.Count == 0)
  2880. {
  2881. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2882. return sre;
  2883. }
  2884. sre.Data = new DataSet();
  2885. sre.Data.Tables.Add(data);
  2886. return sre;
  2887. }
  2888. catch (Exception ex)
  2889. {
  2890. throw ex;
  2891. }
  2892. finally
  2893. {
  2894. if (conn != null &&
  2895. conn.ConnState == ConnectionState.Open)
  2896. {
  2897. conn.Close();
  2898. }
  2899. }
  2900. }
  2901. /// <summary>
  2902. /// 获取RPT040101_1画面(注浆交坯比率分析表)的查询sql
  2903. /// </summary>
  2904. /// <returns>sql</returns>
  2905. private static string GetRPT040101SSQL()
  2906. {
  2907. string selSql =
  2908. "select " +
  2909. "UserCode, " +
  2910. "Groutinglinename, " +
  2911. "GoodsTypeName, " +
  2912. "GoodsCode, " +
  2913. "Goodsspecification, " +
  2914. "DICTIONARYVALUE, " +
  2915. "MouldQuantity, " +
  2916. "注浆量, " +
  2917. "交坯量, " +
  2918. "交坯率 " +
  2919. "from " +
  2920. "( " +
  2921. " select " +
  2922. " decode(grouping(UserCode),1,'合计', UserCode) UserCode, " +
  2923. " decode(grouping(UserCode),1,'--', Groutinglinecode) Groutinglinename, " +
  2924. " decode(grouping(UserCode),1,'--', GoodsTypeName) GoodsTypeName, " +
  2925. " decode(grouping(UserCode),1,'--', GoodsCode) GoodsCode, " +
  2926. " decode(grouping(UserCode),1,'--', Goodsspecification) Goodsspecification, " +
  2927. " decode(grouping(UserCode),1,'--', DICTIONARYVALUE) DICTIONARYVALUE, " +
  2928. " decode(grouping(UserCode),1,sum(MouldQuantity), MouldQuantity) MouldQuantity, " +
  2929. " decode(grouping(UserCode),1,sum(注浆量), 注浆量) 注浆量, " +
  2930. " decode(grouping(UserCode),1,sum(交坯量), 交坯量) 交坯量, " +
  2931. " decode(grouping(UserCode),1,TO_CHAR((sum(交坯量)/sum(注浆量))*100,'9,999.99')||'%', TO_CHAR((交坯量/注浆量)*100,'9,999.99')||'%' ) 交坯率 " +
  2932. " from " +
  2933. " ( " +
  2934. " select " +
  2935. " UserCode, " +
  2936. " Groutinglinecode, " +
  2937. " GoodsTypeName, " +
  2938. " GoodsCode, " +
  2939. " Goodsspecification, " +
  2940. " DICTIONARYVALUE, " +
  2941. " MouldQuantity, " +
  2942. " 注浆量, " +
  2943. " ( " +
  2944. " select count(TP_PM_ProductionData.Productiondataid) " +
  2945. " from TP_PM_ProductionData " +
  2946. " where " +
  2947. " TP_PM_ProductionData.Accountid=:AccountID and TP_PM_ProductionData.ModelType=5 " +
  2948. " and TP_PM_ProductionData.Usercode=temp.UserCode " +
  2949. " and TP_PM_ProductionData.GROUTINGLINEID=temp.Groutinglineid " +
  2950. //--交坯比率应该是统计的某一时间段注浆的产品,其所交坯的数量,
  2951. //所以交坯的的产品应属于这段期间注浆的产品---袁新成2015-4-16改 --
  2952. //" and TP_PM_ProductionData.Barcode in (select barcode from TP_PM_GroutingDailyDetail where " +
  2953. //" TP_PM_GroutingDailyDetail.Valueflag=1 " +
  2954. //" and TP_PM_GroutingDailyDetail.GroutingFlag=1 " +
  2955. //" AND TP_PM_GroutingDailyDetail.AccountID=:AccountID " +
  2956. //" AND TP_PM_GroutingDailyDetail.GroutingDate >= :groutingDateStart " +
  2957. //" AND TP_PM_GroutingDailyDetail.GroutingDate <= :groutingDateEnd )" +
  2958. //交坯的其实日期应该还是与注浆的开始日期相同,只是结束日期推后 dateDifferentce天 ---袁新成2015-4-16改--
  2959. //" and TP_PM_ProductionData.AccountDate >= :groutingDateStart " +
  2960. " and TP_PM_ProductionData.AccountDate >= :groutingDateStart+:dateDifference " +
  2961. " and TP_PM_ProductionData.AccountDate >= :groutingDateStart " +
  2962. " and TP_PM_ProductionData.AccountDate <= :groutingDateEnd +:dateDifference " +
  2963. " ) as 交坯量 " +
  2964. " from " +
  2965. " ( " +
  2966. " select " +
  2967. " TP_PM_GroutingDailyDetail.UserCode as UserCode, " +
  2968. " TP_PM_GroutingDailyDetail.Groutinglineid, " +
  2969. " line.GroutinglineCode, " +
  2970. " TP_MST_GOODSTYPE.GoodsTypeName, " +
  2971. " TP_PM_GroutingDailyDetail.GoodsCode, " +
  2972. " TP_MST_Goods.Goodsspecification, " +
  2973. " TP_MST_DataDictionary.DICTIONARYVALUE, " +
  2974. " line.MouldQuantity, " +
  2975. " count(TP_PM_GroutingDailyDetail.GroutingCount) as 注浆量 " +
  2976. " from " +
  2977. " TP_PM_GroutingDailyDetail " +
  2978. " inner join TP_MST_Goods on TP_MST_Goods.Goodsid= TP_PM_GroutingDailyDetail.Goodsid " +
  2979. " inner join TP_MST_GOODSTYPE on TP_MST_GOODSTYPE.GOODSTYPEID = TP_MST_Goods.Goodstypeid " +
  2980. " inner join TP_MST_DataDictionary on TP_MST_DataDictionary.Dictionaryid=TP_MST_Goods.GLAZETYPEID " +
  2981. " inner join TP_PM_GroutingDaily on TP_PM_GroutingDailyDetail.Groutingdailyid=TP_PM_GroutingDaily.Groutingdailyid " +
  2982. " inner join TP_PC_GroutingLine line on line.Groutinglineid = TP_PM_GroutingDailyDetail.Groutinglineid " +
  2983. " where " +
  2984. " TP_PM_GroutingDailyDetail.Valueflag=1 " +
  2985. " and TP_PM_GroutingDailyDetail.GroutingFlag=1 " +
  2986. " AND TP_PM_GroutingDailyDetail.AccountID=:AccountID " +
  2987. " AND TP_PM_GroutingDailyDetail.GroutingDate >= :groutingDateStart " +
  2988. " AND TP_PM_GroutingDailyDetail.GroutingDate <= :groutingDateEnd ";
  2989. return selSql;
  2990. }
  2991. /// <summary>
  2992. /// 取得RPT040102_1画面(工序产量分析表)的查询数据
  2993. /// </summary>
  2994. /// <param name="user">登录用户信息</param>
  2995. /// <param name="se">查询条件</param>
  2996. /// <returns>查询结果</returns>
  2997. public static ServiceResultEntity GetRPT040102SData(SUserInfo user, RPT040102_SE se)
  2998. {
  2999. IDBConnection conn = null;
  3000. try
  3001. {
  3002. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  3003. //OracleParameter[] paras = new OracleParameter[]{
  3004. // new OracleParameter("in_goodsTypeIds",OracleDbType.Varchar2,se.GoodsTypeIDS,ParameterDirection.Input),
  3005. // new OracleParameter("in_goodsIds",OracleDbType.Varchar2,se.GoodsIDS,ParameterDirection.Input),
  3006. // new OracleParameter("in_productionLineId",OracleDbType.Int32,se.ProductionLineID,ParameterDirection.Input),
  3007. // new OracleParameter("in_accountDateStart",OracleDbType.Varchar2,se.AccountDateStart,ParameterDirection.Input),
  3008. // new OracleParameter("in_accountDateEnd",OracleDbType.Varchar2,se.AccountDateEnd,ParameterDirection.Input),
  3009. // new OracleParameter("in_accountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  3010. // new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  3011. //};
  3012. /*
  3013. OracleParameter[] paras = new OracleParameter[]{
  3014. new OracleParameter("in_productionLineId",OracleDbType.Int32,se.ProductionLineID,ParameterDirection.Input),
  3015. new OracleParameter("in_procedureids",OracleDbType.Varchar2,se.ProcedureIDs,ParameterDirection.Input),
  3016. new OracleParameter("in_goodsTypeIds",OracleDbType.Varchar2,se.GoodsTypeIDS,ParameterDirection.Input),
  3017. new OracleParameter("in_goodsIds",OracleDbType.Varchar2,se.GoodsIDS,ParameterDirection.Input),
  3018. new OracleParameter("in_accountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  3019. new OracleParameter("in_accountDateStart",OracleDbType.Date,se.AccountDateStart,ParameterDirection.Input),
  3020. new OracleParameter("in_accountDateEnd",OracleDbType.Date,se.AccountDateEnd,ParameterDirection.Input),
  3021. new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  3022. };
  3023. //DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetLineProcessTotal", paras);
  3024. DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetLineProcessTotalNew", paras);
  3025. ServiceResultEntity sre = new ServiceResultEntity();
  3026. if (data == null || data.Tables.Count == 0)
  3027. {
  3028. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  3029. return sre;
  3030. }
  3031. sre.Data = new DataSet();
  3032. sre.Data = data;
  3033. return sre;
  3034. */
  3035. ServiceResultEntity sre = new ServiceResultEntity();
  3036. List<OracleParameter> parameters = new List<OracleParameter>();
  3037. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3038. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3039. string sqlString =
  3040. "select p.procedureid, p.procedurecode, p.procedurename\n" +
  3041. " from tp_pc_procedure p\n" +
  3042. " where p.valueflag = '1'\n" +
  3043. " and p.AccountID = :AccountID" +
  3044. " and p.productionlineid = :productionlineid\n";
  3045. if (!string.IsNullOrWhiteSpace(se.ProcedureIDs))
  3046. {
  3047. sqlString += " and instr(',' || :procedureids || ',', ',' || p.procedureid || ',') > 0\n";
  3048. parameters.Add(new OracleParameter(":procedureids", OracleDbType.NVarchar2, se.ProcedureIDs, ParameterDirection.Input));
  3049. }
  3050. sqlString += "order by p.Displayno";
  3051. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  3052. if (data == null || data.Rows.Count == 0)
  3053. {
  3054. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  3055. return sre;
  3056. }
  3057. parameters.Clear();
  3058. StringBuilder sql1 = new StringBuilder();
  3059. StringBuilder sql2 = new StringBuilder();
  3060. StringBuilder sql3 = new StringBuilder();
  3061. foreach (DataRow item in data.Rows)
  3062. {
  3063. //sql1.Append(", decode(pd.procedureid, " + item["procedureid"] + ", 1, 0) as A" + item["procedurecode"] + "\n");
  3064. //sql2.Append(", sum(pdata.A" + item["procedurecode"] + ") as A" + item["procedurecode"] + "\n");
  3065. //sql3.Append(", pdg.A" + item["procedurecode"] + " as \"" + item["procedurename"] + "\" \n");
  3066. sql1.Append(", sum(decode(pd.procedureid, " + item["procedureid"] + ", 1, 0)) as A" + item["procedurecode"] + "\n");
  3067. sql2.Append(", sum(pdata.A" + item["procedurecode"] + ") as A" + item["procedurecode"] + "\n");
  3068. sql3.Append(", pdg.A" + item["procedurecode"] + " as \"" + item["procedurename"] + "\" \n");
  3069. }
  3070. sqlString =
  3071. "select --pdg.gid,\n" +
  3072. " decode(pdg.gid, 1, '小计', 3, '合计', 0, pdg.goodstypename2, '--') \"产品二级类别\",\n" +
  3073. " decode(pdg.gid, 0, pdg.goodstypename, '--') \"产品类别\",\n" +
  3074. " decode(pdg.gid, 0, pdg.goodscode, '--') \"产品编码\",\n" +
  3075. " decode(pdg.gid, 0, pdg.goodsspecification, '--') \"产品规格\",\n" +
  3076. " --decode(pdg.gid, 0, pdg.GOODSMODEL, '--') \"产品型号\",\n" +
  3077. " decode(pdg.gid, 0, pdg.GLAZETYPE, '--') \"釉料类别\"\n" +
  3078. sql3 +
  3079. " from ( select " +
  3080. " grouping_id(pdata.productionlineid,pdata.goodstypename2,pdata.goodscode) gid," +
  3081. " pdata.productionlineid,\n" +
  3082. " pdata.goodstypename2,\n" +
  3083. " pdata.goodstypename,\n" +
  3084. " pdata.goodscode,\n" +
  3085. " pdata.goodsspecification,\n" +
  3086. " pdata.GOODSMODEL,\n" +
  3087. " pdata.GLAZETYPE\n" +
  3088. sql2 +
  3089. " from (" +
  3090. " select\n" +
  3091. " pd.productionlineid,\n" +
  3092. " gt2.goodstypename goodstypename2,\n" +
  3093. " gt.goodstypename,\n" +
  3094. " g.goodscode,\n" +
  3095. " g.goodsspecification,\n" +
  3096. " g.GOODSMODEL,\n" +
  3097. " dd.dictionaryvalue GLAZETYPE\n" +
  3098. sql1 +
  3099. " from tp_pm_productiondata pd\n" +
  3100. " inner join tp_mst_goods g\n" +
  3101. " on g.goodsid = pd.goodsid\n" +
  3102. " inner join tp_mst_goodstype gt\n" +
  3103. " on gt.goodstypeid = g.goodstypeid\n" +
  3104. " inner join tp_mst_goodstype gt2\n" +
  3105. " on gt2.goodstypecode = substr(gt.goodstypecode, 0, 6)\n" +
  3106. " and gt2.accountid = gt.accountid\n" +
  3107. " inner join tp_mst_datadictionary dd\n" +
  3108. " on dd.dictionaryid = g.GLAZETYPEID\n" +
  3109. " where pd.valueflag = '1'\n" +
  3110. // 公坯、干补不算交坯工序的产量。
  3111. //" and ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.IsPublicBody = '0' and pd.SpecialRepairFlag = '0')) \n" +
  3112. // modify wangx 2015-12-3
  3113. (se.ProductionFlag == "1" ? " and ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" : "") +
  3114. " and pd.accountid = :accountid\n" +
  3115. " and pd.productionlineid = :productionlineid\n" +
  3116. " and pd.createtime >= :createtimeStart\n" +
  3117. " and pd.createtime <= :createtimeEnd\n";
  3118. StringBuilder sql = new StringBuilder(sqlString);
  3119. if (!string.IsNullOrWhiteSpace(se.GoodsIDS))
  3120. {
  3121. sql.Append(" and instr(',' || :goodsIds || ',', ',' || pd.goodsid || ',') > 0\n");
  3122. parameters.Add(new OracleParameter(":goodsIds", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3123. }
  3124. if (!string.IsNullOrWhiteSpace(se.GoodsTypeIDS))
  3125. {
  3126. //sql.Append(" and instr(',' || :goodsTypeIds || ',', ',' || gt.goodstypecode || ',') =1\n");
  3127. sql.Append(" and instr(gt.goodstypecode,:goodsTypeIds) =1\n");
  3128. parameters.Add(new OracleParameter(":goodsTypeIds", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  3129. }
  3130. if (!string.IsNullOrWhiteSpace(se.ProcedureIDs))
  3131. {
  3132. sql.Append(" and instr(',' || :procedureids || ',', ',' || pd.procedureid || ',') > 0\n");
  3133. parameters.Add(new OracleParameter(":procedureids", OracleDbType.NVarchar2, se.ProcedureIDs, ParameterDirection.Input));
  3134. }
  3135. 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))");
  3136. parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  3137. sqlString =
  3138. " group by \n" +
  3139. " pd.productionlineid,\n" +
  3140. " gt2.goodstypename,\n" +
  3141. " gt.goodstypename,\n" +
  3142. " g.goodscode,\n" +
  3143. " g.goodsspecification,\n" +
  3144. " g.GOODSMODEL,\n" +
  3145. " dd.dictionaryvalue\n" +
  3146. " order by gt2.goodstypename, g.goodscode" +
  3147. " ) pdata\n" +
  3148. " group by grouping sets((pdata.productionlineid,\n" +
  3149. " pdata.goodstypename2,\n" +
  3150. " pdata.goodstypename,\n" +
  3151. " pdata.goodsspecification,\n" +
  3152. " pdata.GOODSMODEL,\n" +
  3153. " pdata.GLAZETYPE,\n" +
  3154. " pdata.goodscode),\n" +
  3155. " (pdata.productionlineid,pdata.goodstypename2),\n" +
  3156. " pdata.productionlineid)\n" +
  3157. " ) pdg";
  3158. sql.Append(sqlString);
  3159. parameters.Add(new OracleParameter(":accountid", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3160. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  3161. parameters.Add(new OracleParameter(":createtimeStart", OracleDbType.Date, se.AccountDateStart, ParameterDirection.Input));
  3162. parameters.Add(new OracleParameter(":createtimeEnd", OracleDbType.Date, se.AccountDateEnd, ParameterDirection.Input));
  3163. DataTable data1 = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  3164. if (data1 == null || data1.Rows.Count == 0)
  3165. {
  3166. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  3167. return sre;
  3168. }
  3169. sre.Data = new DataSet();
  3170. sre.Data.Tables.Add(data1);
  3171. return sre;
  3172. }
  3173. catch (Exception ex)
  3174. {
  3175. throw ex;
  3176. }
  3177. finally
  3178. {
  3179. if (conn != null &&
  3180. conn.ConnState == ConnectionState.Open)
  3181. {
  3182. conn.Close();
  3183. }
  3184. }
  3185. }
  3186. /// <summary>
  3187. /// 取得RPT040103画面(工序质量分析表)的查询数据
  3188. /// </summary>
  3189. /// <param name="user">登录用户信息</param>
  3190. /// <param name="se">查询条件</param>
  3191. /// <returns>查询结果</returns>
  3192. public static ServiceResultEntity GetRPT040103SData(SUserInfo user, RPT040103_SE se)
  3193. {
  3194. IDBConnection conn = null;
  3195. try
  3196. {
  3197. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  3198. List<OracleParameter> parameters = new List<OracleParameter>();
  3199. //string sql = ReportModuleLogic.GetRPT040103SSQL(user, se, ref parameters);
  3200. string sql = ReportModuleLogic.GetRPT040103S1SQL(user, se, ref parameters);
  3201. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  3202. ServiceResultEntity sre = new ServiceResultEntity();
  3203. if (data == null || data.Rows.Count == 0)
  3204. {
  3205. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  3206. return sre;
  3207. }
  3208. sre.Data = new DataSet();
  3209. sre.Data.Tables.Add(data);
  3210. return sre;
  3211. }
  3212. catch (Exception ex)
  3213. {
  3214. throw ex;
  3215. }
  3216. finally
  3217. {
  3218. if (conn != null &&
  3219. conn.ConnState == ConnectionState.Open)
  3220. {
  3221. conn.Close();
  3222. }
  3223. }
  3224. }
  3225. /// <summary>
  3226. /// 获取RPT040103画面(工序质量分析表)的查询sql
  3227. /// </summary>
  3228. /// <returns>sql</returns>
  3229. private static string GetRPT040103SSQL(SUserInfo user, RPT040103_SE se, ref List<OracleParameter> parameters)
  3230. {
  3231. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3232. parameters.Add(new OracleParameter(":in_rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  3233. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  3234. // 2015-06-16 modify by chenxy
  3235. string sqlString = "\n" +
  3236. "select qdgroup.gid,\n" +
  3237. " decode(qdgroup.gid, 0, qdgroup.productionlinename, '--') productionlinename,\n" +
  3238. " decode(qdgroup.gid, 15, '总计', 0, qdgroup.procedurename, '--') procedurename,\n" +
  3239. " decode(qdgroup.gid, 7, '合计', 0, qdgroup.kilncode, '--') kilncode,\n" +
  3240. " decode(qdgroup.gid, 3, '小计', 0, qdgroup.goodstypename2, '--') goodstypename2,\n" +
  3241. " decode(qdgroup.gid, 0, qdgroup.usercode, '--') usercode,\n" +
  3242. " decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename,\n" +
  3243. " decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode,\n" +
  3244. " qdgroup.OutKilnCount,\n" +
  3245. " qdgroup.GoodCount,\n" +
  3246. " to_char((qdgroup.GoodCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' GoodPercent,\n" +
  3247. " qdgroup.SubstandardCount,\n" +
  3248. " to_char((qdgroup.SubstandardCount / qdgroup.OutKilnCount) * 100,\n" +
  3249. " '990.00') || '%' SubstandardPercent,\n" +
  3250. " qdgroup.GoodCount+qdgroup.BadCount Qualified,\n" +
  3251. " to_char(((qdgroup.GoodCount+qdgroup.BadCount) / qdgroup.OutKilnCount) * 100,\n" +
  3252. " '990.00') || '%' QualifiedPercent,\n" +
  3253. " qdgroup.BadCount,\n" +
  3254. " to_char((qdgroup.BadCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' BadPercent,\n" +
  3255. " qdgroup.ReFireCount,\n" +
  3256. " to_char((qdgroup.ReFireCount / qdgroup.OutKilnCount) * 100,\n" +
  3257. " '990.00') || '%' ReFirePercent\n" +
  3258. " from (select grouping_id(pcpl.productionlinename,\n" +
  3259. " pcp.procedurename,\n" +
  3260. " mstkiln.kilncode,\n" +
  3261. " mstgoodstype2.goodstypename,\n" +
  3262. " qd.usercode,\n" +
  3263. " --mstgoodstype.goodstypename,\n" +
  3264. " mstgoods.goodscode) gid,\n" +
  3265. " pcpl.productionlinename,\n" +
  3266. " pcp.procedurename,\n" +
  3267. " --qd.kilnid,\n" +
  3268. " mstkiln.kilncode,\n" +
  3269. " mstgoodstype2.goodstypename goodstypename2,\n" +
  3270. " qd.usercode,\n" +
  3271. " mstgoodstype.goodstypename,\n" +
  3272. " mstgoods.goodscode,\n" +
  3273. " sum(qd.OutKilnCount) OutKilnCount,\n" +
  3274. " sum(qd.GoodCount) GoodCount,\n" +
  3275. " sum(qd.SubstandardCount) SubstandardCount,\n" +
  3276. " sum(qd.BadCount) BadCount,\n" +
  3277. " sum(qd.ReFireCount) ReFireCount\n" +
  3278. " from (select --pdbc.barcode,\n" +
  3279. " pdbc.productionlineid,\n" +
  3280. " pdata.procedureid,\n" +
  3281. " pdata.usercode,\n" +
  3282. " pdbc.goodsid,\n" +
  3283. " pdbc.kilnid,\n" +
  3284. " --pdbc.kilncarid,\n" +
  3285. " --pdbc.kilncarbatchno,\n" +
  3286. " 1 OutKilnCount,\n" +
  3287. " case\n" +
  3288. " when defect.defectprocedureid is not null and glt.goodsleveltypeid in (5, 6, 7) then\n" +
  3289. " 0\n" +
  3290. " else\n" +
  3291. " 1\n" +
  3292. " end GoodCount,\n" +
  3293. " case\n" +
  3294. " when defect.defectprocedureid is not null and glt.goodsleveltypeid = 7 then\n" +
  3295. " 1\n" +
  3296. " else\n" +
  3297. " 0\n" +
  3298. " end SubstandardCount,\n" +
  3299. " case\n" +
  3300. " when defect.defectprocedureid is not null and glt.goodsleveltypeid = 6 then\n" +
  3301. " 1\n" +
  3302. " else\n" +
  3303. " 0\n" +
  3304. " end ReFireCount,\n" +
  3305. " case\n" +
  3306. " when defect.defectprocedureid is not null and glt.goodsleveltypeid = 5 then\n" +
  3307. " 1\n" +
  3308. " else\n" +
  3309. " 0\n" +
  3310. " end BadCount\n" +
  3311. " from (select distinct pd.barcode,\n" +
  3312. " pd.productionlineid,\n" +
  3313. " pd.goodsid,\n" +
  3314. " pd.kilnid,\n" +
  3315. " --pd.kilncarid,\n" +
  3316. " pd.kilncarbatchno\n" +
  3317. " from tp_pm_productiondata pd\n" +
  3318. " where pd.valueflag = '1'\n" +
  3319. " and pd.procedureid = :in_rptSprocedureId \n" +
  3320. " and pd.AccountID = :AccountID\n ";
  3321. StringBuilder selSql = new StringBuilder(sqlString);
  3322. if (se.CreateTimeStart.HasValue)
  3323. {
  3324. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  3325. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3326. }
  3327. if (se.CreateTimeEnd.HasValue)
  3328. {
  3329. selSql.Append(" AND pd.createtime <= :CreateTimeEnd\n");
  3330. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3331. }
  3332. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3333. {
  3334. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3335. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3336. }
  3337. if (se.ProductionLineID.HasValue)
  3338. {
  3339. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3340. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3341. }
  3342. //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))");
  3343. //parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  3344. if (se.KilnID.HasValue)
  3345. {
  3346. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3347. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3348. }
  3349. sqlString =
  3350. " ) pdbc\n" + // 成检交接工序
  3351. " inner join (select distinct pd.barcode,\n" +
  3352. " pd.userid,\n" +
  3353. " pd.usercode,\n" +
  3354. " pd.procedureid\n" +
  3355. " from tp_pm_productiondata pd\n" +
  3356. " where pd.valueflag = '1'\n" +
  3357. " and pd.AccountID = :AccountID\n" +
  3358. // 公坯、干补不算交坯工序的质量。
  3359. //" and ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.IsPublicBody = '0' and pd.SpecialRepairFlag = '0')) \n" +
  3360. // 干补不算交坯工序的质量。
  3361. " and ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" +
  3362. " and exists\n" +
  3363. " (select 1\n" +
  3364. " from tp_mst_rpttprocedure rptt\n" +
  3365. " where rptt.RPTPROCEDUREID = :in_rptProcedureId\n";
  3366. selSql.Append(sqlString);
  3367. if (!string.IsNullOrEmpty(se.RptTProcedureIDS))
  3368. {
  3369. selSql.Append(" AND instr(','||:rptTprocedureIDS||',', ','||rptt.procedureid||',') > 0\n");
  3370. parameters.Add(new OracleParameter(":rptTprocedureIDS", OracleDbType.NVarchar2, se.RptTProcedureIDS, ParameterDirection.Input));
  3371. }
  3372. //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))");
  3373. selSql.Append(" and rptt.procedureid = pd.procedureid)\n");
  3374. if (!string.IsNullOrEmpty(se.UserIDS))
  3375. {
  3376. selSql.Append(" and instr(','||:userIDS||',', ','||pd.Userid||',') > 0\n");
  3377. parameters.Add(new OracleParameter(":userIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  3378. }
  3379. sqlString =
  3380. " ) pdata\n" + // 生产工序
  3381. " on pdata.barcode = pdbc.barcode\n" +
  3382. " left join (select kcbc.barcode, kcbc.kilncarbatchno, kcbc.goodsleveltypeid, kcbc.productiondataid\n" +
  3383. " from (select pd.barcode,\n" +
  3384. " pd.kilncarbatchno,\n" +
  3385. " pd.goodsleveltypeid,\n" +
  3386. " pd.productiondataid,\n" +
  3387. " ROW_NUMBER() OVER(PARTITION BY pd.barcode, pd.kilncarbatchno ORDER BY pd.productiondataid desc) AS dataid\n" +
  3388. " from tp_pm_productiondata pd\n" +
  3389. " where pd.valueflag = '1'\n" +
  3390. " and pd.AccountID = :AccountID\n" +
  3391. " and length(pd.kilncarbatchno) > 0\n" +
  3392. " AND pd.createtime >= :CreateTimeStart\n" +
  3393. " and pd.modeltype = -1) kcbc\n" +
  3394. " where kcbc.dataid = 1) glt\n" +
  3395. " on pdbc.kilncarbatchno = glt.kilncarbatchno\n" +
  3396. " and pdbc.barcode = glt.barcode\n" +
  3397. " left join (select distinct productiondataid, defectprocedureid" +
  3398. " from tp_pm_defect def " +
  3399. " where def.valueflag='1'" +
  3400. " and def.AccountID = :AccountID\n" +
  3401. " AND def.createtime >= :CreateTimeStart) defect\n" +
  3402. " on defect.productiondataid = glt.productiondataid\n" +
  3403. " and pdata.procedureid = defect.defectprocedureid\n" +
  3404. " ) qd\n" +
  3405. " inner join tp_pc_productionline pcpl\n" +
  3406. " on pcpl.productionlineid = qd.productionlineid\n" +
  3407. " inner join tp_pc_procedure pcp\n" +
  3408. " on pcp.procedureid = qd.procedureid\n" +
  3409. " inner join tp_mst_kiln mstkiln\n" +
  3410. " on mstkiln.kilnid = qd.kilnid\n" +
  3411. " inner join tp_mst_goods mstgoods\n" +
  3412. " on mstgoods.goodsid = qd.goodsid\n" +
  3413. " inner join tp_mst_goodstype mstgoodstype\n" +
  3414. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  3415. " and mstgoodstype.accountid = mstgoods.accountid\n" +
  3416. " inner join tp_mst_goodstype mstgoodstype2\n" +
  3417. " on mstgoodstype2.goodstypecode =\n" +
  3418. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  3419. " and mstgoodstype.accountid = mstgoodstype2.accountid\n" +
  3420. " where 1=1\n";
  3421. selSql.Append(sqlString);
  3422. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  3423. {
  3424. //selSql.Append(" AND instr(','||:GoodsTypeIDS||',', ','||mstgoodstype.GOODSTYPECode||',')=1\n");
  3425. selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS)=1\n");
  3426. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  3427. }
  3428. sqlString =
  3429. " group by grouping sets((pcpl.productionlinename,\n" +
  3430. " pcp.procedurename,\n" +
  3431. " mstkiln.kilncode,\n" +
  3432. " mstgoodstype2.goodstypename,\n" +
  3433. " qd.usercode,\n" +
  3434. " mstgoodstype.goodstypename,\n" +
  3435. " mstgoods.goodscode),\n" +
  3436. " (pcpl.productionlinename,\n" +
  3437. " pcp.procedurename,\n" +
  3438. " mstkiln.kilncode,\n" +
  3439. " mstgoodstype2.goodstypename),\n" +
  3440. " (pcpl.productionlinename,\n" +
  3441. " pcp.procedurename,\n" +
  3442. " mstkiln.kilncode),\n" +
  3443. " (pcpl.productionlinename, pcp.procedurename))\n" +
  3444. " order by pcpl.productionlinename,\n" +
  3445. " pcp.procedurename,\n" +
  3446. " mstkiln.kilncode,\n" +
  3447. " mstgoodstype2.goodstypename,\n" +
  3448. " qd.usercode,\n" +
  3449. " mstgoodstype.goodstypename,\n" +
  3450. " mstgoods.goodscode\n" +
  3451. " ) qdgroup\n";
  3452. selSql.Append(sqlString);
  3453. return selSql.ToString();
  3454. }
  3455. /// <summary>
  3456. /// 获取RPT040103画面(工序质量分析表-按登记时间)的查询sql
  3457. /// </summary>
  3458. /// <returns>sql</returns>
  3459. private static string GetRPT040103S1SQL(SUserInfo user, RPT040103_SE se, ref List<OracleParameter> parameters)
  3460. {
  3461. parameters.Add(new OracleParameter(":in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3462. parameters.Add(new OracleParameter(":in_rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  3463. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  3464. string sqlString = "select qdgroup.gid\n" +
  3465. " ,qdgroup.productionlinename\n" +
  3466. " ,decode(qdgroup.gid\n" +
  3467. " ,15\n" +
  3468. " ,'总计[' || qdgroup.procedurename || ']'\n" +
  3469. " ,qdgroup.procedurename) procedurename\n" +
  3470. " ,decode(qdgroup.gid\n" +
  3471. " ,7\n" +
  3472. " ,'合计[' || qdgroup.kilncode || ']'\n" +
  3473. " ,15\n" +
  3474. " ,'--'\n" +
  3475. " ,qdgroup.kilncode) kilncode\n" +
  3476. " ,decode(qdgroup.gid\n" +
  3477. " ,3\n" +
  3478. " ,'小计[' || qdgroup.goodstypename2 || ']'\n" +
  3479. " ,15\n" +
  3480. " ,'--'\n" +
  3481. " ,7\n" +
  3482. " ,'--'\n" +
  3483. " ,qdgroup.goodstypename2) goodstypename2\n" +
  3484. " ,decode(qdgroup.gid, 0, qdgroup.usercode, '--') usercode\n" +
  3485. " ,decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename\n" +
  3486. " ,decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode\n" +
  3487. " ,qdgroup.OutKilnCount\n" +
  3488. " ,qdgroup.GoodCount\n" +
  3489. " ,decode(qdgroup.OutKilnCount\n" +
  3490. " ,0\n" +
  3491. " ,to_number(null)\n" +
  3492. " ,round(qdgroup.GoodCount / qdgroup.OutKilnCount, 4)) GoodPercent\n" +
  3493. " ,qdgroup.SubstandardCount\n" +
  3494. " ,decode(qdgroup.OutKilnCount\n" +
  3495. " ,0\n" +
  3496. " ,to_number(null)\n" +
  3497. " ,round(qdgroup.SubstandardCount / qdgroup.OutKilnCount, 4)) SubstandardPercent\n" +
  3498. " ,qdgroup.GoodCount + qdgroup.BadCount Qualified\n" +
  3499. " ,decode(qdgroup.OutKilnCount\n" +
  3500. " ,0\n" +
  3501. " ,to_number(null)\n" +
  3502. " ,round((qdgroup.GoodCount + qdgroup.BadCount) /\n" +
  3503. " qdgroup.OutKilnCount\n" +
  3504. " ,4)) QualifiedPercent\n" +
  3505. " ,qdgroup.BadCount\n" +
  3506. " ,decode(qdgroup.OutKilnCount\n" +
  3507. " ,0\n" +
  3508. " ,to_number(null)\n" +
  3509. " ,round(qdgroup.BadCount / qdgroup.OutKilnCount, 4)) BadPercent\n" +
  3510. " ,qdgroup.ReFireCount\n" +
  3511. " ,decode(qdgroup.OutKilnCount\n" +
  3512. " ,0\n" +
  3513. " ,to_number(null)\n" +
  3514. " ,round(qdgroup.ReFireCount / qdgroup.OutKilnCount, 4)) ReFirePercent\n" +
  3515. " from (select grouping_id(pcpl.productionlinename\n" +
  3516. " ,pcp.procedurename\n" +
  3517. " ,mstkiln.kilncode\n" +
  3518. " ,mstgoodstype2.goodstypecode\n" +
  3519. " ,pdata.usercode\n" +
  3520. " ,mstgoods.goodscode) gid\n" +
  3521. " ,pcpl.productionlinename\n" +
  3522. " ,pcp.procedurename\n" +
  3523. " ,mstkiln.kilncode\n" +
  3524. " ,mstgoodstype2.goodstypename goodstypename2\n" +
  3525. " ,mstgoodstype2.goodstypecode goodstypecode2\n" +
  3526. " ,pdata.usercode\n" +
  3527. " ,mstgoodstype.goodstypename\n" +
  3528. " ,mstgoods.goodscode\n" +
  3529. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 0)), 0) OutKilnCount\n" +
  3530. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 5, 1, 0)), 0) BadCount\n" +
  3531. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 6, 1, 0)), 0) ReFireCount\n" +
  3532. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 7, 1, 0)), 0) SubstandardCount\n" +
  3533. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 5, -1, 6, -1, 7, -1, 0)), 0) GoodCount\n" +
  3534. " from (select 0 goodsleveltypeid -- 出窑数量\n" +
  3535. " ,pd.barcode\n" +
  3536. " ,pd.productionlineid\n" +
  3537. " ,pd.goodsid\n" +
  3538. " ,pd.kilnid\n" +
  3539. " ,pd.kilncarbatchno\n" +
  3540. " ,0 procedureid\n" +
  3541. " ,1 cc\n" +
  3542. " from tp_pm_productiondata pd\n" +
  3543. " where pd.valueflag = '1'\n" +
  3544. " and pd.procedureid = :in_rptSprocedureId\n" +
  3545. " and pd.accountid = :in_AccountID\n";
  3546. StringBuilder selSql = new StringBuilder(sqlString);
  3547. if (se.CreateTimeStart.HasValue)
  3548. {
  3549. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  3550. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3551. }
  3552. if (se.CreateTimeEnd.HasValue)
  3553. {
  3554. selSql.Append(" AND pd.createtime < :CreateTimeEnd\n");
  3555. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3556. }
  3557. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3558. {
  3559. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3560. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3561. }
  3562. if (se.ProductionLineID.HasValue)
  3563. {
  3564. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3565. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3566. }
  3567. if (se.KilnID.HasValue)
  3568. {
  3569. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3570. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3571. }
  3572. sqlString =
  3573. " union all\n" +
  3574. " select distinct ppd.goodsleveltypeid\n" +
  3575. " ,dd.barcode\n" +
  3576. " ,dd.productionlineid\n" +
  3577. " ,dd.goodsid\n" +
  3578. " ,ppd.kilnid\n" +
  3579. " ,ppd.kilncarbatchno\n" +
  3580. " ,dd.defectprocedureid procedureid\n" +
  3581. " ,1 cc\n" +
  3582. " from (select pd.productiondataid\n" +
  3583. " ,pd.goodsleveltypeid\n" +
  3584. " ,pd.kilnid\n" +
  3585. " ,pd.kilncarbatchno\n" +
  3586. " from tp_pm_productiondata pd\n" +
  3587. " where pd.valueflag = '1'\n" +
  3588. " and pd.AccountID = :in_AccountID\n" +
  3589. " and length(pd.kilncarbatchno) > 0\n" +
  3590. " and pd.modeltype = -1\n";
  3591. selSql.Append(sqlString);
  3592. if (se.CreateTimeStart.HasValue)
  3593. {
  3594. //selSql.Append(" AND pd.checktime >= :checktimeStart\n");
  3595. selSql.Append(" AND pd.createtime >= :checktimeStart\n");
  3596. parameters.Add(new OracleParameter(":checktimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3597. }
  3598. if (se.CreateTimeEnd.HasValue)
  3599. {
  3600. //selSql.Append(" AND pd.checktime < :checktimeEnd\n");
  3601. selSql.Append(" AND pd.createtime < :checktimeEnd\n");
  3602. parameters.Add(new OracleParameter(":checktimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3603. }
  3604. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3605. {
  3606. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3607. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3608. }
  3609. if (se.ProductionLineID.HasValue)
  3610. {
  3611. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3612. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3613. }
  3614. if (se.KilnID.HasValue)
  3615. {
  3616. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3617. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3618. }
  3619. sqlString =
  3620. " and exists\n" +
  3621. " (select 1\n" +
  3622. " from tp_pm_productiondata outpd\n" +
  3623. " where outpd.barcode = pd.barcode\n" +
  3624. " and outpd.procedureid = :in_rptSprocedureId\n" +
  3625. " and outpd.valueflag = '1'\n" +
  3626. " and outpd.kilncarbatchno = pd.kilncarbatchno)) ppd\n" +
  3627. " inner join tp_pm_defect dd\n" +
  3628. " on dd.productiondataid = ppd.productiondataid\n" +
  3629. //" --and dd.checktime >= in_DateBegin\n" +
  3630. //" --and dd.checktime <= in_DateEnd\n" +
  3631. " ) ppcc\n" +
  3632. " inner join tp_pm_productiondata pdata\n" +
  3633. " on pdata.barcode = ppcc.barcode\n" +
  3634. // 干补不算交坯工序的质量。
  3635. " and ((pdata.modeltype <> 5) or (pdata.modeltype = 5 and pdata.SpecialRepairFlag = '0')) \n" +
  3636. " and exists\n" +
  3637. " (select 1\n" +
  3638. " from tp_mst_rpttprocedure rptt\n" +
  3639. " where rptt.RPTPROCEDUREID = :in_rptProcedureId \n";
  3640. selSql.Append(sqlString);
  3641. if (!string.IsNullOrEmpty(se.RptTProcedureIDS))
  3642. {
  3643. selSql.Append(" AND instr(','||:rptTprocedureIDS||',', ','||rptt.procedureid||',') > 0\n");
  3644. parameters.Add(new OracleParameter(":rptTprocedureIDS", OracleDbType.NVarchar2, se.RptTProcedureIDS, ParameterDirection.Input));
  3645. }
  3646. sqlString =
  3647. " and rptt.procedureid = pdata.procedureid)\n" +
  3648. " and (ppcc.procedureid = 0 or ppcc.procedureid = pdata.procedureid)\n";
  3649. selSql.Append(sqlString);
  3650. if (!string.IsNullOrEmpty(se.UserIDS))
  3651. {
  3652. selSql.Append(" and instr(','||:userIDS||',', ','||pdata.Userid||',') > 0\n");
  3653. parameters.Add(new OracleParameter(":userIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  3654. }
  3655. sqlString =
  3656. " inner join tp_pc_productionline pcpl\n" +
  3657. " on pcpl.productionlineid = pdata.productionlineid\n" +
  3658. " inner join tp_pc_procedure pcp\n" +
  3659. " on pcp.procedureid = pdata.procedureid\n" +
  3660. " inner join tp_mst_kiln mstkiln\n" +
  3661. " on mstkiln.kilnid = ppcc.kilnid\n" +
  3662. " inner join tp_mst_goods mstgoods\n" +
  3663. " on mstgoods.goodsid = pdata.goodsid\n" +
  3664. " inner join tp_mst_goodstype mstgoodstype\n" +
  3665. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  3666. " and mstgoodstype.accountid = mstgoods.accountid\n" +
  3667. " inner join tp_mst_goodstype mstgoodstype2\n" +
  3668. " on mstgoodstype2.goodstypecode =\n" +
  3669. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  3670. " and mstgoodstype.accountid = mstgoodstype2.accountid\n";
  3671. // 产品类别
  3672. selSql.Append(sqlString);
  3673. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  3674. {
  3675. selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS)=1\n");
  3676. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  3677. }
  3678. sqlString =
  3679. " 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" +
  3680. " order by pcpl.productionlinename\n" +
  3681. " ,pcp.displayno\n" +
  3682. " ,pcp.procedurename\n" +
  3683. " ,mstkiln.kilncode\n" +
  3684. " ,mstgoodstype2.goodstypecode\n" +
  3685. " ,pdata.usercode\n" +
  3686. " ,mstgoodstype.goodstypecode\n" +
  3687. " ,mstgoods.goodscode) qdgroup";
  3688. selSql.Append(sqlString);
  3689. return selSql.ToString();
  3690. }
  3691. /// <summary>
  3692. /// 取得RPT040104画面(产成品质量分析表)的查询数据
  3693. /// </summary>
  3694. /// <param name="user">登录用户信息</param>
  3695. /// <param name="se">查询条件</param>
  3696. /// <returns>查询结果</returns>
  3697. public static ServiceResultEntity GetRPT040104SData(SUserInfo user, RPT040104_SE se)
  3698. {
  3699. IDBConnection conn = null;
  3700. try
  3701. {
  3702. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  3703. List<OracleParameter> parameters = new List<OracleParameter>();
  3704. //string sql = ReportModuleLogic.GetRPT040104SSQL(user, se, ref parameters);
  3705. string sql = ReportModuleLogic.GetRPT040104S1SQL(user, se, ref parameters);
  3706. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  3707. ServiceResultEntity sre = new ServiceResultEntity();
  3708. if (data == null || data.Rows.Count == 0)
  3709. {
  3710. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  3711. return sre;
  3712. }
  3713. sre.Data = new DataSet();
  3714. sre.Data.Tables.Add(data);
  3715. return sre;
  3716. }
  3717. catch (Exception ex)
  3718. {
  3719. throw ex;
  3720. }
  3721. finally
  3722. {
  3723. if (conn != null &&
  3724. conn.ConnState == ConnectionState.Open)
  3725. {
  3726. conn.Close();
  3727. }
  3728. }
  3729. }
  3730. /// <summary>
  3731. /// 获取RPT040104画面(产成品质量分析表)的查询sql
  3732. /// </summary>
  3733. /// <returns>sql</returns>
  3734. private static string GetRPT040104SSQL(SUserInfo user, RPT040104_SE se, ref List<OracleParameter> parameters)
  3735. {
  3736. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3737. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  3738. // 2015-06-16 modify by chenxy
  3739. string sqlString = "\n" +
  3740. "select qdgroup.gid,\n" +
  3741. " decode(qdgroup.gid, 7, '总计', 0, qdgroup.productionlinename, '--') productionlinename,\n" +
  3742. " decode(qdgroup.gid, 3, '合计', 0, qdgroup.kilncode, '--') kilncode,\n" +
  3743. " decode(qdgroup.gid, 1, '小计', 0, qdgroup.goodstypename2, '--') goodstypename2,\n" +
  3744. " decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename,\n" +
  3745. " decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode,\n" +
  3746. " qdgroup.OutKilnCount,\n" +
  3747. " qdgroup.GoodCount,\n" +
  3748. " to_char((qdgroup.GoodCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' GoodPercent,\n" +
  3749. " qdgroup.SubstandardCount,\n" +
  3750. " to_char((qdgroup.SubstandardCount / qdgroup.OutKilnCount) * 100,\n" +
  3751. " '990.00') || '%' SubstandardPercent,\n" +
  3752. " qdgroup.GoodCount+qdgroup.BadCount Qualified,\n" +
  3753. " to_char(((qdgroup.GoodCount + qdgroup.BadCount) / qdgroup.OutKilnCount) * 100,\n" +
  3754. " '990.00') || '%' QualifiedPercent,\n" +
  3755. " qdgroup.BadCount,\n" +
  3756. " to_char((qdgroup.BadCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' BadPercent,\n" +
  3757. " qdgroup.ReFireCount,\n" +
  3758. " to_char((qdgroup.ReFireCount / qdgroup.OutKilnCount) * 100,\n" +
  3759. " '990.00') || '%' ReFirePercent\n" +
  3760. " from (select grouping_id(pcpl.productionlinename,\n" +
  3761. " mstkiln.kilncode,\n" +
  3762. " mstgoodstype2.goodstypename,\n" +
  3763. " --mstgoodstype.goodstypename,\n" +
  3764. " mstgoods.goodscode) gid,\n" +
  3765. " pcpl.productionlinename,\n" +
  3766. " --qd.kilnid,\n" +
  3767. " mstkiln.kilncode,\n" +
  3768. " mstgoodstype2.goodstypename goodstypename2,\n" +
  3769. " mstgoodstype.goodstypename,\n" +
  3770. " mstgoods.goodscode,\n" +
  3771. " sum(qd.OutKilnCount) OutKilnCount,\n" +
  3772. " sum(qd.GoodCount) GoodCount,\n" +
  3773. " sum(qd.SubstandardCount) SubstandardCount,\n" +
  3774. " sum(qd.BadCount) BadCount,\n" +
  3775. " sum(qd.ReFireCount) ReFireCount\n" +
  3776. " from (select --pdbc.barcode,\n" +
  3777. " pdbc.productionlineid,\n" +
  3778. " pdbc.goodsid,\n" +
  3779. " pdbc.kilnid,\n" +
  3780. " --pdbc.kilncarid,\n" +
  3781. " --pdbc.kilncarbatchno,\n" +
  3782. " 1 OutKilnCount,\n" +
  3783. " case\n" +
  3784. " when glt.goodsleveltypeid in (5, 6, 7) then\n" +
  3785. " 0\n" +
  3786. " else\n" +
  3787. " 1\n" +
  3788. " end GoodCount,\n" +
  3789. " case\n" +
  3790. " when glt.goodsleveltypeid = 7 then\n" +
  3791. " 1\n" +
  3792. " else\n" +
  3793. " 0\n" +
  3794. " end SubstandardCount,\n" +
  3795. " case\n" +
  3796. " when glt.goodsleveltypeid = 6 then\n" +
  3797. " 1\n" +
  3798. " else\n" +
  3799. " 0\n" +
  3800. " end ReFireCount,\n" +
  3801. " case\n" +
  3802. " when glt.goodsleveltypeid = 5 then\n" +
  3803. " 1\n" +
  3804. " else\n" +
  3805. " 0\n" +
  3806. " end BadCount\n" +
  3807. " from (select distinct pd.barcode,\n" +
  3808. " pd.productionlineid,\n" +
  3809. " pd.goodsid,\n" +
  3810. " pd.kilnid,\n" +
  3811. " --pd.kilncarid,\n" +
  3812. " pd.kilncarbatchno\n" +
  3813. " from tp_pm_productiondata pd\n" +
  3814. " where pd.valueflag = '1'\n" +
  3815. " and pd.procedureid = :in_rptSprocedureId \n" +
  3816. " and pd.AccountID = :AccountID\n";
  3817. StringBuilder selSql = new StringBuilder(sqlString);
  3818. if (se.CreateTimeStart.HasValue)
  3819. {
  3820. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  3821. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3822. }
  3823. if (se.CreateTimeEnd.HasValue)
  3824. {
  3825. selSql.Append(" AND pd.createtime <= :CreateTimeEnd\n");
  3826. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3827. }
  3828. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3829. {
  3830. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3831. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3832. }
  3833. if (se.ProductionLineID.HasValue)
  3834. {
  3835. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3836. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3837. }
  3838. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  3839. {
  3840. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  3841. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  3842. }
  3843. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  3844. {
  3845. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  3846. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  3847. }
  3848. //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))");
  3849. //parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  3850. if (se.KilnID.HasValue)
  3851. {
  3852. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3853. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3854. }
  3855. sqlString =
  3856. " ) pdbc\n" +
  3857. " left join (select kcbc.barcode, kcbc.kilncarbatchno, kcbc.goodsleveltypeid\n" +
  3858. " from (select pd.barcode,\n" +
  3859. " pd.kilncarbatchno,\n" +
  3860. " pd.goodsleveltypeid,\n" +
  3861. " pd.productiondataid,\n" +
  3862. " ROW_NUMBER() OVER(PARTITION BY pd.barcode, pd.kilncarbatchno ORDER BY pd.productiondataid desc) AS dataid\n" +
  3863. " from tp_pm_productiondata pd\n" +
  3864. " where pd.valueflag = '1'\n" +
  3865. " and pd.AccountID = :AccountID\n" +
  3866. " and length(pd.kilncarbatchno) > 0\n" +
  3867. " AND pd.createtime >= :CreateTimeStart\n" +
  3868. " and pd.modeltype = -1) kcbc\n" +
  3869. " where kcbc.dataid = 1) glt\n" +
  3870. " on pdbc.kilncarbatchno = glt.kilncarbatchno\n" +
  3871. " and pdbc.barcode = glt.barcode) qd\n" +
  3872. " inner join tp_pc_productionline pcpl\n" +
  3873. " on pcpl.productionlineid = qd.productionlineid\n" +
  3874. " inner join tp_mst_kiln mstkiln\n" +
  3875. " on mstkiln.kilnid = qd.kilnid\n" +
  3876. " inner join tp_mst_goods mstgoods\n" +
  3877. " on mstgoods.goodsid = qd.goodsid\n" +
  3878. " inner join tp_mst_goodstype mstgoodstype\n" +
  3879. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  3880. " and mstgoodstype.accountid = mstgoods.accountid\n" +
  3881. " inner join tp_mst_goodstype mstgoodstype2\n" +
  3882. " on mstgoodstype2.goodstypecode =\n" +
  3883. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  3884. " and mstgoodstype.accountid = mstgoodstype2.accountid\n" +
  3885. " where 1=1\n";
  3886. selSql.Append(sqlString);
  3887. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  3888. {
  3889. //selSql.Append(" AND instr(','||:GoodsTypeIDS||',', ','||mstgoodstype.GOODSTYPECode||',') =1\n");
  3890. selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS) =1\n");
  3891. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  3892. }
  3893. sqlString =
  3894. " group by grouping sets((pcpl.productionlinename,\n" +
  3895. " mstkiln.kilncode,\n" +
  3896. " mstgoodstype2.goodstypename,\n" +
  3897. " mstgoodstype.goodstypename,\n" +
  3898. " mstgoods.goodscode),\n" +
  3899. " (pcpl.productionlinename,\n" +
  3900. " mstkiln.kilncode,\n" +
  3901. " mstgoodstype2.goodstypename),\n" +
  3902. " (pcpl.productionlinename,\n" +
  3903. " mstkiln.kilncode),\n" +
  3904. " pcpl.productionlinename)\n" +
  3905. " order by pcpl.productionlinename,\n" +
  3906. " mstkiln.kilncode,\n" +
  3907. " mstgoodstype2.goodstypename,\n" +
  3908. " mstgoodstype.goodstypename,\n" +
  3909. " mstgoods.goodscode\n" +
  3910. " ) qdgroup\n";
  3911. selSql.Append(sqlString);
  3912. return selSql.ToString();
  3913. }
  3914. /// <summary>
  3915. /// 获取RPT040104画面(产成品质量分析表-按登记时间)的查询sql
  3916. /// </summary>
  3917. /// <returns>sql</returns>
  3918. private static string GetRPT040104S1SQL(SUserInfo user, RPT040104_SE se, ref List<OracleParameter> parameters)
  3919. {
  3920. parameters.Add(new OracleParameter(":in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3921. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  3922. string sqlString = "select qdgroup.gid\n" +
  3923. " ,decode(qdgroup.gid, 7, '总计', qdgroup.productionlinename) productionlinename\n" +
  3924. " ,decode(qdgroup.gid\n" +
  3925. " ,3\n" +
  3926. " ,'合计[' || qdgroup.kilncode || ']'\n" +
  3927. " ,7\n" +
  3928. " ,'--'\n" +
  3929. " ,qdgroup.kilncode) kilncode\n" +
  3930. " ,decode(qdgroup.gid\n" +
  3931. " ,1\n" +
  3932. " ,'小计[' || qdgroup.goodstypename2 || ']'\n" +
  3933. " ,0\n" +
  3934. " ,qdgroup.goodstypename2\n" +
  3935. " ,'--') goodstypename2\n" +
  3936. " ,decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename\n" +
  3937. " ,decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode\n" +
  3938. " ,qdgroup.OutKilnCount\n" +
  3939. " ,qdgroup.GoodCount\n" +
  3940. " ,decode(qdgroup.OutKilnCount\n" +
  3941. " ,0\n" +
  3942. " ,to_number(null)\n" +
  3943. " ,round(qdgroup.GoodCount / qdgroup.OutKilnCount, 4)) GoodPercent\n" +
  3944. " ,qdgroup.SubstandardCount\n" +
  3945. " ,decode(qdgroup.OutKilnCount\n" +
  3946. " ,0\n" +
  3947. " ,to_number(null)\n" +
  3948. " ,round(qdgroup.SubstandardCount / qdgroup.OutKilnCount, 4)) SubstandardPercent\n" +
  3949. " ,qdgroup.GoodCount + qdgroup.BadCount Qualified\n" +
  3950. " ,decode(qdgroup.OutKilnCount\n" +
  3951. " ,0\n" +
  3952. " ,to_number(null)\n" +
  3953. " ,round((qdgroup.GoodCount + qdgroup.BadCount) /\n" +
  3954. " qdgroup.OutKilnCount\n" +
  3955. " ,4)) QualifiedPercent\n" +
  3956. " ,qdgroup.BadCount\n" +
  3957. " ,decode(qdgroup.OutKilnCount\n" +
  3958. " ,0\n" +
  3959. " ,to_number(null)\n" +
  3960. " ,round(qdgroup.BadCount / qdgroup.OutKilnCount, 4)) BadPercent\n" +
  3961. " ,qdgroup.ReFireCount\n" +
  3962. " ,decode(qdgroup.OutKilnCount\n" +
  3963. " ,0\n" +
  3964. " ,to_number(null)\n" +
  3965. " ,round(qdgroup.ReFireCount / qdgroup.OutKilnCount, 4)) ReFirePercent\n" +
  3966. " from (select grouping_id(pcpl.productionlinename\n" +
  3967. " ,mstkiln.kilncode\n" +
  3968. " ,mstgoodstype2.goodstypecode\n" +
  3969. " ,mstgoods.goodscode) gid\n" +
  3970. " ,pcpl.productionlinename\n" +
  3971. " ,mstkiln.kilncode\n" +
  3972. " ,mstgoodstype2.goodstypename goodstypename2\n" +
  3973. " ,mstgoodstype.goodstypename\n" +
  3974. " ,mstgoods.goodscode\n" +
  3975. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 0)), 0) OutKilnCount\n" +
  3976. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 5, 1, 0)), 0) BadCount\n" +
  3977. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 6, 1, 0)), 0) ReFireCount\n" +
  3978. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 7, 1, 0)), 0) SubstandardCount\n" +
  3979. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 5, -1, 6, -1, 7, -1, 0)), 0) GoodCount\n" +
  3980. " from (select 0 goodsleveltypeid -- 出窑数量\n" +
  3981. " ,pd.barcode\n" +
  3982. " ,pd.productionlineid\n" +
  3983. " ,pd.goodsid\n" +
  3984. " ,pd.kilnid\n" +
  3985. " ,pd.kilncarbatchno\n" +
  3986. " ,1 cc\n" +
  3987. " from tp_pm_productiondata pd\n" +
  3988. " where pd.valueflag = '1'\n" +
  3989. " and pd.procedureid = :in_rptSprocedureId\n" +
  3990. " and pd.accountid = :in_AccountID\n";
  3991. StringBuilder selSql = new StringBuilder(sqlString);
  3992. if (se.CreateTimeStart.HasValue)
  3993. {
  3994. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  3995. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3996. }
  3997. if (se.CreateTimeEnd.HasValue)
  3998. {
  3999. selSql.Append(" AND pd.createtime < :CreateTimeEnd\n");
  4000. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  4001. }
  4002. if (!string.IsNullOrEmpty(se.GoodsIDS))
  4003. {
  4004. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  4005. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  4006. }
  4007. if (se.ProductionLineID.HasValue)
  4008. {
  4009. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  4010. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  4011. }
  4012. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  4013. {
  4014. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  4015. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  4016. }
  4017. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  4018. {
  4019. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  4020. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  4021. }
  4022. if (se.KilnID.HasValue)
  4023. {
  4024. selSql.Append(" AND pd.KilnID = :KilnID\n");
  4025. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  4026. }
  4027. sqlString =
  4028. " union all\n" +
  4029. " select distinct pd.goodsleveltypeid\n" +
  4030. " ,pd.barcode\n" +
  4031. " ,pd.productionlineid\n" +
  4032. " ,pd.goodsid\n" +
  4033. " ,pd.kilnid\n" +
  4034. " ,pd.kilncarbatchno\n" +
  4035. " ,1 cc\n" +
  4036. " from tp_pm_productiondata pd\n" +
  4037. " where pd.valueflag = '1'\n" +
  4038. " and pd.modeltype = -1\n" +
  4039. " and pd.AccountID = :in_AccountID\n" +
  4040. " and length(pd.kilncarbatchno) > 0\n";
  4041. selSql.Append(sqlString);
  4042. if (se.CreateTimeStart.HasValue)
  4043. {
  4044. //selSql.Append(" AND pd.checktime >= :checktimeStart\n");
  4045. selSql.Append(" AND pd.createtime >= :checktimeStart\n");
  4046. parameters.Add(new OracleParameter(":checktimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  4047. }
  4048. if (se.CreateTimeEnd.HasValue)
  4049. {
  4050. //selSql.Append(" AND pd.checktime < :checktimeEnd\n");
  4051. selSql.Append(" AND pd.createtime < :checktimeEnd\n");
  4052. parameters.Add(new OracleParameter(":checktimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  4053. }
  4054. if (!string.IsNullOrEmpty(se.GoodsIDS))
  4055. {
  4056. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  4057. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  4058. }
  4059. if (se.ProductionLineID.HasValue)
  4060. {
  4061. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  4062. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  4063. }
  4064. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  4065. {
  4066. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  4067. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  4068. }
  4069. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  4070. {
  4071. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  4072. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  4073. }
  4074. if (se.KilnID.HasValue)
  4075. {
  4076. selSql.Append(" AND pd.KilnID = :KilnID\n");
  4077. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  4078. }
  4079. sqlString =
  4080. " and exists\n" +
  4081. " (select 1\n" +
  4082. " from tp_pm_productiondata outpd\n" +
  4083. " where outpd.barcode = pd.barcode\n" +
  4084. " and outpd.procedureid = :in_rptSprocedureId\n" +
  4085. " and outpd.valueflag = '1'\n" +
  4086. " and outpd.kilncarbatchno = pd.kilncarbatchno)) ppcc\n" +
  4087. " inner join tp_pc_productionline pcpl\n" +
  4088. " on pcpl.productionlineid = ppcc.productionlineid\n" +
  4089. " inner join tp_mst_kiln mstkiln\n" +
  4090. " on mstkiln.kilnid = ppcc.kilnid\n" +
  4091. " inner join tp_mst_goods mstgoods\n" +
  4092. " on mstgoods.goodsid = ppcc.goodsid\n" +
  4093. " inner join tp_mst_goodstype mstgoodstype\n" +
  4094. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  4095. " and mstgoodstype.accountid = mstgoods.accountid\n" +
  4096. " inner join tp_mst_goodstype mstgoodstype2\n" +
  4097. " on mstgoodstype2.goodstypecode =\n" +
  4098. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  4099. " and mstgoodstype.accountid = mstgoodstype2.accountid\n";
  4100. // 产品类别
  4101. selSql.Append(sqlString);
  4102. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  4103. {
  4104. selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS)=1\n");
  4105. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  4106. }
  4107. sqlString =
  4108. " 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" +
  4109. " order by pcpl.productionlinename\n" +
  4110. " ,mstkiln.kilncode\n" +
  4111. " ,mstgoodstype2.goodstypecode\n" +
  4112. " ,mstgoodstype.goodstypecode\n" +
  4113. " ,mstgoods.goodscode) qdgroup\n";
  4114. selSql.Append(sqlString);
  4115. return selSql.ToString();
  4116. }
  4117. /// <summary>
  4118. /// 取得RPT040105画面(质量报表)的查询数据
  4119. /// </summary>
  4120. /// <param name="user">登录用户信息</param>
  4121. /// <param name="se">查询条件</param>
  4122. /// <returns>查询结果</returns>
  4123. public static ServiceResultEntity GetRPT040105SData(SUserInfo user, RPT040105_SE se)
  4124. {
  4125. IDBConnection conn = null;
  4126. try
  4127. {
  4128. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  4129. List<OracleParameter> parameters = new List<OracleParameter>();
  4130. string sqlString =
  4131. "SELECT substr(gt.goodstypecode, 1, 6) goodstypecode2, COUNT(*) barcodecount\n" +
  4132. " FROM tp_pm_groutingdailydetail gdd\n" +
  4133. " INNER JOIN tp_mst_goods g\n" +
  4134. " ON g.goodsid = gdd.goodsid\n" +
  4135. " INNER JOIN tp_mst_goodstype gt\n" +
  4136. " ON gt.goodstypeid = g.goodstypeid\n" +
  4137. " WHERE gdd.accountid = :accountid\n" +
  4138. " AND gdd.valueflag = '1'\n" +
  4139. " AND gdd.groutingdate >= :datebegin\n" +
  4140. " AND gdd.groutingdate <= :dateend\n" +
  4141. " AND gdd.groutingflag = '1'\n" +
  4142. " AND gdd.barcode IS NOT NULL\n" +
  4143. " GROUP BY GROUPING SETS(substr(gt.goodstypecode, 1, 6),())";
  4144. parameters.Add(new OracleParameter(":accountid", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  4145. parameters.Add(new OracleParameter(":datebegin", OracleDbType.Date, se.CreateTimeStart.Value.Date, ParameterDirection.Input));
  4146. parameters.Add(new OracleParameter(":dateend", OracleDbType.Date, se.CreateTimeEnd.Value.Date, ParameterDirection.Input));
  4147. DataTable dataCount = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  4148. parameters.Clear();
  4149. //string sql = ReportModuleLogic.GetRPT040105SSQL(user, se, ref parameters);
  4150. string sql = ReportModuleLogic.GetRPT040105S1SQL(user, se, ref parameters);
  4151. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  4152. ServiceResultEntity sre = new ServiceResultEntity();
  4153. if (data == null || data.Rows.Count == 0)
  4154. {
  4155. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4156. return sre;
  4157. }
  4158. data.Columns.Add("GCount", typeof(int));
  4159. //data.Columns.Add("OutGCount", typeof(string));
  4160. //data.Columns.Add("GoodGCount", typeof(string));
  4161. data.Columns.Add("OutGCount", typeof(decimal));
  4162. data.Columns.Add("GoodGCount", typeof(decimal));
  4163. foreach (DataRow item in data.Rows)
  4164. {
  4165. int gid = Convert.ToInt32(item["gid"]);
  4166. if (gid < 2)
  4167. {
  4168. continue;
  4169. }
  4170. int outKilnCount = Convert.ToInt32(item["OutKilnCount"]);
  4171. int goodCount = Convert.ToInt32(item["Qualified"]);
  4172. DataRow[] drs = null;
  4173. if (gid == 2)
  4174. {
  4175. drs = dataCount.Select("goodstypecode2 = '" + item["goodstypecode2"].ToString() + "'");
  4176. }
  4177. else if (gid == 3)
  4178. {
  4179. drs = dataCount.Select("goodstypecode2 is null");
  4180. }
  4181. if (drs != null && drs.Length > 0)
  4182. {
  4183. int barcodecount = Convert.ToInt32(drs[0]["barcodecount"]);
  4184. item["GCount"] = barcodecount;
  4185. //item["OutGCount"] = (outKilnCount * 1.0 / barcodecount).ToString("#,##0.00%");
  4186. //item["GoodGCount"] = (goodCount * 1.0 / barcodecount).ToString("#,##0.00%");
  4187. item["OutGCount"] = Math.Round(outKilnCount * 1.0 / barcodecount, 4);
  4188. item["GoodGCount"] = Math.Round(goodCount * 1.0 / barcodecount, 4);
  4189. }
  4190. else
  4191. {
  4192. item["GCount"] = 0;
  4193. //item["OutGCount"] = "#DIV/0!";
  4194. //item["GoodGCount"] = "#DIV/0!";
  4195. item["OutGCount"] = DBNull.Value;
  4196. item["GoodGCount"] = DBNull.Value;
  4197. }
  4198. }
  4199. sre.Data = new DataSet();
  4200. sre.Data.Tables.Add(data);
  4201. return sre;
  4202. }
  4203. catch (Exception ex)
  4204. {
  4205. throw ex;
  4206. }
  4207. finally
  4208. {
  4209. if (conn != null &&
  4210. conn.ConnState == ConnectionState.Open)
  4211. {
  4212. conn.Close();
  4213. }
  4214. }
  4215. }
  4216. /// <summary>
  4217. /// 获取RPT040105画面(质量报表)的查询sql
  4218. /// </summary>
  4219. /// <returns>sql</returns>
  4220. private static string GetRPT040105SSQL(SUserInfo user, RPT040105_SE se, ref List<OracleParameter> parameters)
  4221. {
  4222. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  4223. parameters.Add(new OracleParameter(":OutProcedureIDS", OracleDbType.Varchar2, se.OutProcedureIDS, ParameterDirection.Input));
  4224. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  4225. // 2015-06-16 modify by chenxy
  4226. string sqlString = "\n" +
  4227. "select qdgroup.gid,\n" +
  4228. " decode(qdgroup.gid, 3, '总计', 0, qdgroup.productionlinename, '--') productionlinename,\n" +
  4229. " decode(qdgroup.gid, 1, '合计【'||qdgroup.kilncode||'】', 0, qdgroup.kilncode, '--') kilncode,\n" +
  4230. " decode(qdgroup.gid, 2, '合计【'||qdgroup.goodstypename2||'】', 0, qdgroup.goodstypename2, '--') goodstypename2,\n" +
  4231. " qdgroup.goodstypecode2,\n" +
  4232. " qdgroup.OutKilnCount,\n" +
  4233. " qdgroup.GoodCount,\n" +
  4234. " to_char((qdgroup.GoodCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' GoodPercent,\n" +
  4235. " qdgroup.SubstandardCount,\n" +
  4236. " to_char((qdgroup.SubstandardCount / qdgroup.OutKilnCount) * 100,\n" +
  4237. " '990.00') || '%' SubstandardPercent,\n" +
  4238. " qdgroup.GoodCount+qdgroup.BadCount Qualified,\n" +
  4239. " to_char(((qdgroup.GoodCount + qdgroup.BadCount) / qdgroup.OutKilnCount) * 100,\n" +
  4240. " '990.00') || '%' QualifiedPercent,\n" +
  4241. " qdgroup.BadCount,\n" +
  4242. " to_char((qdgroup.BadCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' BadPercent,\n" +
  4243. " qdgroup.ReFireCount,\n" +
  4244. " to_char((qdgroup.ReFireCount / qdgroup.OutKilnCount) * 100,\n" +
  4245. " '990.00') || '%' ReFirePercent\n" +
  4246. " from (select grouping_id(pcpl.productionlinename,\n" +
  4247. " mstkiln.kilncode,\n" +
  4248. " mstgoodstype2.goodstypecode) gid,\n" +
  4249. " pcpl.productionlinename,\n" +
  4250. " mstkiln.kilncode,\n" +
  4251. " mstgoodstype2.goodstypecode goodstypecode2,\n" +
  4252. " mstgoodstype2.goodstypename goodstypename2,\n" +
  4253. " sum(qd.OutKilnCount) OutKilnCount,\n" +
  4254. " sum(qd.GoodCount) GoodCount,\n" +
  4255. " sum(qd.SubstandardCount) SubstandardCount,\n" +
  4256. " sum(qd.BadCount) BadCount,\n" +
  4257. " sum(qd.ReFireCount) ReFireCount\n" +
  4258. " from (select --pdbc.barcode,\n" +
  4259. " pdbc.productionlineid,\n" +
  4260. " pdbc.goodsid,\n" +
  4261. " pdbc.kilnid,\n" +
  4262. " 1 OutKilnCount,\n" +
  4263. " case\n" +
  4264. " when glt.goodsleveltypeid in (5, 6, 7) then\n" +
  4265. " 0\n" +
  4266. " else\n" +
  4267. " 1\n" +
  4268. " end GoodCount,\n" +
  4269. " case\n" +
  4270. " when glt.goodsleveltypeid = 7 then\n" +
  4271. " 1\n" +
  4272. " else\n" +
  4273. " 0\n" +
  4274. " end SubstandardCount,\n" +
  4275. " case\n" +
  4276. " when glt.goodsleveltypeid = 6 then\n" +
  4277. " 1\n" +
  4278. " else\n" +
  4279. " 0\n" +
  4280. " end ReFireCount,\n" +
  4281. " case\n" +
  4282. " when glt.goodsleveltypeid = 5 then\n" +
  4283. " 1\n" +
  4284. " else\n" +
  4285. " 0\n" +
  4286. " end BadCount\n" +
  4287. " from (select distinct pd.barcode,\n" +
  4288. " pd.productionlineid,\n" +
  4289. " pd.goodsid,\n" +
  4290. " pd.kilnid,\n" +
  4291. " pd.kilncarbatchno\n" +
  4292. " from tp_pm_productiondata pd\n" +
  4293. " where pd.valueflag = '1'\n" +
  4294. " and (:in_rptSprocedureId is null or pd.procedureid = :in_rptSprocedureId) \n" +
  4295. " and (:OutProcedureIDS is null or instr(','||:OutProcedureIDS||',', ','||pd.procedureid||',') > 0) \n" +
  4296. " and pd.AccountID = :AccountID\n";
  4297. StringBuilder selSql = new StringBuilder(sqlString);
  4298. if (se.CreateTimeStart.HasValue)
  4299. {
  4300. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  4301. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  4302. }
  4303. if (se.CreateTimeEnd.HasValue)
  4304. {
  4305. selSql.Append(" AND pd.createtime <= :CreateTimeEnd\n");
  4306. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  4307. }
  4308. if (!string.IsNullOrEmpty(se.GoodsIDS))
  4309. {
  4310. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  4311. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  4312. }
  4313. if (se.ProductionLineID.HasValue)
  4314. {
  4315. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  4316. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  4317. }
  4318. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  4319. {
  4320. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  4321. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  4322. }
  4323. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  4324. {
  4325. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  4326. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  4327. }
  4328. // 不控制权限
  4329. //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))");
  4330. //parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  4331. if (se.KilnID.HasValue)
  4332. {
  4333. selSql.Append(" AND pd.KilnID = :KilnID\n");
  4334. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  4335. }
  4336. sqlString =
  4337. " ) pdbc\n" +
  4338. " left join (select kcbc.barcode, kcbc.kilncarbatchno, kcbc.goodsleveltypeid\n" +
  4339. " from (select pd.barcode,\n" +
  4340. " pd.kilncarbatchno,\n" +
  4341. " pd.goodsleveltypeid,\n" +
  4342. " pd.productiondataid,\n" +
  4343. " ROW_NUMBER() OVER(PARTITION BY pd.barcode, pd.kilncarbatchno ORDER BY pd.productiondataid desc) AS dataid\n" +
  4344. " from tp_pm_productiondata pd\n" +
  4345. " where pd.valueflag = '1'\n" +
  4346. " and pd.AccountID = :AccountID\n" +
  4347. " and length(pd.kilncarbatchno) > 0\n" +
  4348. " AND pd.createtime >= :CreateTimeStart\n" +
  4349. " and pd.modeltype = -1) kcbc\n" +
  4350. " where kcbc.dataid = 1) glt\n" +
  4351. " on pdbc.kilncarbatchno = glt.kilncarbatchno\n" +
  4352. " and pdbc.barcode = glt.barcode) qd\n" +
  4353. " inner join tp_pc_productionline pcpl\n" +
  4354. " on pcpl.productionlineid = qd.productionlineid\n" +
  4355. " inner join tp_mst_kiln mstkiln\n" +
  4356. " on mstkiln.kilnid = qd.kilnid\n" +
  4357. " inner join tp_mst_goods mstgoods\n" +
  4358. " on mstgoods.goodsid = qd.goodsid\n" +
  4359. " inner join tp_mst_goodstype mstgoodstype\n" +
  4360. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  4361. " inner join tp_mst_goodstype mstgoodstype2\n" +
  4362. " on mstgoodstype2.goodstypecode =\n" +
  4363. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  4364. " and mstgoodstype.accountid = mstgoodstype2.accountid\n" +
  4365. " where 1=1\n";
  4366. selSql.Append(sqlString);
  4367. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  4368. {
  4369. selSql.Append(" AND instr(','||:GoodsTypeIDS||',', ','||mstgoods.GOODSTYPEId||',') > 0\n");
  4370. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  4371. }
  4372. sqlString =
  4373. " group by grouping sets((pcpl.productionlinename,\n" +
  4374. " mstkiln.kilncode,\n" +
  4375. " mstgoodstype2.goodstypecode,\n" +
  4376. " mstgoodstype2.goodstypename),\n" +
  4377. " (pcpl.productionlinename,\n" +
  4378. " mstgoodstype2.goodstypecode,\n" +
  4379. " mstgoodstype2.goodstypename),\n" +
  4380. " (pcpl.productionlinename,\n" +
  4381. " mstkiln.kilncode),\n" +
  4382. " pcpl.productionlinename)\n" +
  4383. " order by pcpl.productionlinename,\n" +
  4384. " mstkiln.kilncode,\n" +
  4385. " mstgoodstype2.goodstypename\n" +
  4386. " ) qdgroup\n";
  4387. selSql.Append(sqlString);
  4388. return selSql.ToString();
  4389. }
  4390. /// <summary>
  4391. /// 获取RPT040105画面(质量报表-按登记时间)的查询sql
  4392. /// </summary>
  4393. /// <returns>sql</returns>
  4394. private static string GetRPT040105S1SQL(SUserInfo user, RPT040105_SE se, ref List<OracleParameter> parameters)
  4395. {
  4396. parameters.Add(new OracleParameter(":in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  4397. parameters.Add(new OracleParameter(":in_OutProcedureIDS", OracleDbType.Varchar2, se.OutProcedureIDS, ParameterDirection.Input));
  4398. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  4399. string sqlString = "select qdgroup.gid\n" +
  4400. " ,decode(qdgroup.gid, 3, '总计', qdgroup.productionlinename) productionlinename\n" +
  4401. " ,decode(qdgroup.gid\n" +
  4402. " ,1\n" +
  4403. " ,'合计[' || qdgroup.kilncode || ']'\n" +
  4404. " ,0\n" +
  4405. " ,qdgroup.kilncode\n" +
  4406. " ,'--') kilncode\n" +
  4407. " ,decode(qdgroup.gid\n" +
  4408. " ,2\n" +
  4409. " ,'合计[' || qdgroup.goodstypename2 || ']'\n" +
  4410. " ,0\n" +
  4411. " ,qdgroup.goodstypename2\n" +
  4412. " ,'--') goodstypename2\n" +
  4413. " ,qdgroup.goodstypecode2\n" +
  4414. //" ,decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename\n" +
  4415. //" ,decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode\n" +
  4416. " ,qdgroup.OutKilnCount\n" +
  4417. " ,qdgroup.GoodCount\n" +
  4418. " ,decode(qdgroup.OutKilnCount\n" +
  4419. " ,0\n" +
  4420. " ,to_number(null)\n" +
  4421. " ,round(qdgroup.GoodCount / qdgroup.OutKilnCount, 4)) GoodPercent\n" +
  4422. " ,qdgroup.SubstandardCount\n" +
  4423. " ,decode(qdgroup.OutKilnCount\n" +
  4424. " ,0\n" +
  4425. " ,to_number(null)\n" +
  4426. " ,round(qdgroup.SubstandardCount / qdgroup.OutKilnCount, 4)) SubstandardPercent\n" +
  4427. " ,qdgroup.GoodCount + qdgroup.BadCount Qualified\n" +
  4428. " ,decode(qdgroup.OutKilnCount\n" +
  4429. " ,0\n" +
  4430. " ,to_number(null)\n" +
  4431. " ,round((qdgroup.GoodCount + qdgroup.BadCount) /\n" +
  4432. " qdgroup.OutKilnCount\n" +
  4433. " ,4)) QualifiedPercent\n" +
  4434. " ,qdgroup.BadCount\n" +
  4435. " ,decode(qdgroup.OutKilnCount\n" +
  4436. " ,0\n" +
  4437. " ,to_number(null)\n" +
  4438. " ,round(qdgroup.BadCount / qdgroup.OutKilnCount, 4)) BadPercent\n" +
  4439. " ,qdgroup.ReFireCount\n" +
  4440. " ,decode(qdgroup.OutKilnCount\n" +
  4441. " ,0\n" +
  4442. " ,to_number(null)\n" +
  4443. " ,round(qdgroup.ReFireCount / qdgroup.OutKilnCount, 4)) ReFirePercent\n" +
  4444. " from (select grouping_id(pcpl.productionlinename\n" +
  4445. " ,mstkiln.kilncode\n" +
  4446. " ,mstgoodstype2.goodstypecode) gid\n" +
  4447. " ,pcpl.productionlinename\n" +
  4448. " ,mstkiln.kilncode\n" +
  4449. " ,mstgoodstype2.goodstypename goodstypename2\n" +
  4450. " ,mstgoodstype2.goodstypecode goodstypecode2\n" +
  4451. //" ,mstgoodstype.goodstypename\n" +
  4452. //" ,mstgoods.goodscode\n" +
  4453. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 0)), 0) OutKilnCount\n" +
  4454. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 5, 1, 0)), 0) BadCount\n" +
  4455. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 6, 1, 0)), 0) ReFireCount\n" +
  4456. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 7, 1, 0)), 0) SubstandardCount\n" +
  4457. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 5, -1, 6, -1, 7, -1, 0)), 0) GoodCount\n" +
  4458. " from (select 0 goodsleveltypeid -- 出窑数量\n" +
  4459. " ,pd.barcode\n" +
  4460. " ,pd.productionlineid\n" +
  4461. " ,pd.goodsid\n" +
  4462. " ,pd.kilnid\n" +
  4463. " ,pd.kilncarbatchno\n" +
  4464. " ,1 cc\n" +
  4465. " from tp_pm_productiondata pd\n" +
  4466. " where pd.valueflag = '1'\n" +
  4467. " and (:in_rptSprocedureId is null or pd.procedureid = :in_rptSprocedureId)\n" +
  4468. " and (:in_OutProcedureIDS is null or instr(','||:in_OutProcedureIDS||',', ','||pd.procedureid||',') > 0)\n" +
  4469. " and pd.accountid = :in_AccountID\n";
  4470. StringBuilder selSql = new StringBuilder(sqlString);
  4471. if (se.CreateTimeStart.HasValue)
  4472. {
  4473. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  4474. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  4475. }
  4476. if (se.CreateTimeEnd.HasValue)
  4477. {
  4478. selSql.Append(" AND pd.createtime < :CreateTimeEnd\n");
  4479. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  4480. }
  4481. if (!string.IsNullOrEmpty(se.GoodsIDS))
  4482. {
  4483. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  4484. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  4485. }
  4486. if (se.ProductionLineID.HasValue)
  4487. {
  4488. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  4489. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  4490. }
  4491. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  4492. {
  4493. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  4494. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  4495. }
  4496. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  4497. {
  4498. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  4499. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  4500. }
  4501. if (se.KilnID.HasValue)
  4502. {
  4503. selSql.Append(" AND pd.KilnID = :KilnID\n");
  4504. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  4505. }
  4506. sqlString =
  4507. " union all\n" +
  4508. " select distinct pd.goodsleveltypeid\n" +
  4509. " ,pd.barcode\n" +
  4510. " ,pd.productionlineid\n" +
  4511. " ,pd.goodsid\n" +
  4512. " ,pd.kilnid\n" +
  4513. " ,pd.kilncarbatchno\n" +
  4514. " ,1 cc\n" +
  4515. " from tp_pm_productiondata pd\n" +
  4516. " where pd.valueflag = '1'\n" +
  4517. " and pd.modeltype = -1\n" +
  4518. " and pd.AccountID = :in_AccountID\n" +
  4519. " and length(pd.kilncarbatchno) > 0\n";
  4520. selSql.Append(sqlString);
  4521. if (se.CreateTimeStart.HasValue)
  4522. {
  4523. //selSql.Append(" AND pd.checktime >= :checktimeStart\n");
  4524. selSql.Append(" AND pd.createtime >= :checktimeStart\n");
  4525. parameters.Add(new OracleParameter(":checktimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  4526. }
  4527. if (se.CreateTimeEnd.HasValue)
  4528. {
  4529. //selSql.Append(" AND pd.checktime < :checktimeEnd\n");
  4530. selSql.Append(" AND pd.createtime < :checktimeEnd\n");
  4531. parameters.Add(new OracleParameter(":checktimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  4532. }
  4533. if (!string.IsNullOrEmpty(se.GoodsIDS))
  4534. {
  4535. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  4536. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  4537. }
  4538. if (se.ProductionLineID.HasValue)
  4539. {
  4540. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  4541. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  4542. }
  4543. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  4544. {
  4545. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  4546. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  4547. }
  4548. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  4549. {
  4550. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  4551. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  4552. }
  4553. if (se.KilnID.HasValue)
  4554. {
  4555. selSql.Append(" AND pd.KilnID = :KilnID\n");
  4556. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  4557. }
  4558. sqlString =
  4559. " and exists\n" +
  4560. " (select 1\n" +
  4561. " from tp_pm_productiondata outpd\n" +
  4562. " where outpd.barcode = pd.barcode\n" +
  4563. //" and outpd.procedureid = :in_rptSprocedureId\n" +
  4564. " and (:in_rptSprocedureId is null or outpd.procedureid = :in_rptSprocedureId)\n" +
  4565. " and (:in_OutProcedureIDS is null or instr(','||:in_OutProcedureIDS||',', ','||outpd.procedureid||',') > 0)\n" +
  4566. " and outpd.valueflag = '1'\n" +
  4567. " and outpd.kilncarbatchno = pd.kilncarbatchno)) ppcc\n" +
  4568. " inner join tp_pc_productionline pcpl\n" +
  4569. " on pcpl.productionlineid = ppcc.productionlineid\n" +
  4570. " inner join tp_mst_kiln mstkiln\n" +
  4571. " on mstkiln.kilnid = ppcc.kilnid\n" +
  4572. " inner join tp_mst_goods mstgoods\n" +
  4573. " on mstgoods.goodsid = ppcc.goodsid\n" +
  4574. " inner join tp_mst_goodstype mstgoodstype\n" +
  4575. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  4576. " and mstgoodstype.accountid = mstgoods.accountid\n" +
  4577. " inner join tp_mst_goodstype mstgoodstype2\n" +
  4578. " on mstgoodstype2.goodstypecode =\n" +
  4579. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  4580. " and mstgoodstype.accountid = mstgoodstype2.accountid\n";
  4581. // 产品类别
  4582. selSql.Append(sqlString);
  4583. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  4584. {
  4585. selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS)=1\n");
  4586. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  4587. }
  4588. sqlString =
  4589. " 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" +
  4590. " order by pcpl.productionlinename\n" +
  4591. " ,mstkiln.kilncode\n" +
  4592. " ,mstgoodstype2.goodstypecode\n" +
  4593. " ) qdgroup\n";
  4594. selSql.Append(sqlString);
  4595. return selSql.ToString();
  4596. }
  4597. /// <summary>
  4598. /// 取得RPT040106画面(缺陷报表)的查询数据
  4599. /// </summary>
  4600. /// <param name="user">登录用户信息</param>
  4601. /// <param name="se">查询条件</param>
  4602. /// <returns>查询结果</returns>
  4603. public static ServiceResultEntity GetRPT040106SData(SUserInfo user, RPT040106_SE se)
  4604. {
  4605. IDBConnection conn = null;
  4606. try
  4607. {
  4608. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  4609. string sqlString = null;
  4610. OracleParameter[] parameters = null;
  4611. if (se.OutKilnNumByGoodsType)
  4612. {
  4613. sqlString = "SELECT Defect.productionlinename\n" +
  4614. " ,Defect.procedurename\n" +
  4615. " ,Defect.Defectcode\n" +
  4616. " ,Defect.Defectname\n" +
  4617. " ,Defect.goodstypename2\n" +
  4618. " ,Defect.DefectCount\n" +
  4619. " ,OUT.outNum OutKilnCount\n" +
  4620. " ,decode(OUT.outNum,\n" +
  4621. " 0,\n" +
  4622. " to_number(NULL),\n" +
  4623. " ROUND(Defect.DefectCount / OUT.outNum, 4)) DefectPercent\n" +
  4624. " FROM (SELECT tp_pc_productionline.productionlinename\n" +
  4625. " ,tp_pc_procedure.procedurename\n" +
  4626. " ,TP_MST_DefectType.Defecttypename\n" +
  4627. " ,TP_MST_Defect.Defectcode\n" +
  4628. " ,TP_MST_Defect.Defectname\n" +
  4629. " ,goodstype2.goodstypename goodstypename2\n" +
  4630. " ,goodstype2.goodstypecode goodstypecode2\n" +
  4631. " --,COUNT(DISTINCT TP_PM_Defect.Barcode) DefectCount\n" +
  4632. " ,COUNT(TP_PM_Defect.Barcode) DefectCount\n" +
  4633. " FROM TP_PM_Defect\n" +
  4634. " LEFT JOIN tp_pc_procedure\n" +
  4635. " ON TP_PM_Defect.ProcedureID = tp_pc_procedure.ProcedureID\n" +
  4636. " LEFT JOIN tp_pc_productionline\n" +
  4637. " ON TP_PM_Defect.Productionlineid =\n" +
  4638. " tp_pc_productionline.Productionlineid\n" +
  4639. " LEFT JOIN TP_MST_Goods\n" +
  4640. " ON TP_PM_Defect.Goodsid = TP_MST_Goods.Goodsid\n" +
  4641. " LEFT JOIN TP_MST_GoodsType\n" +
  4642. " ON TP_MST_Goods.GoodsTypeID = TP_MST_GoodsType.GoodsTypeID\n" +
  4643. " LEFT JOIN TP_MST_GoodsType goodstype2\n" +
  4644. " ON goodstype2.goodstypecode =\n" +
  4645. " substr(TP_MST_GoodsType.goodstypecode, 0, 6)\n" +
  4646. " AND TP_MST_GoodsType.accountid = goodstype2.accountid\n" +
  4647. " LEFT JOIN TP_MST_Defect\n" +
  4648. " ON TP_PM_Defect.DefectID = TP_MST_Defect.DefectID\n" +
  4649. " LEFT JOIN TP_MST_DefectType\n" +
  4650. " ON TP_MST_Defect.DefectTypeID = TP_MST_DefectType.DefectTypeID\n" +
  4651. " --LEFT JOIN TP_PM_ProductionData\n" +
  4652. " -- ON TP_PM_ProductionData.ProductionDataID =\n" +
  4653. " -- TP_PM_Defect.ProductionDataID\n" +
  4654. " WHERE TP_PM_Defect.valueflag = '1'\n" +
  4655. " --AND tp_pc_procedure.ModelType = -1\n" +
  4656. " AND TP_PM_Defect.AccountID = :AccountID\n" +
  4657. " AND (:createtimebegin is null or TP_PM_Defect.createtime >= :createtimebegin)\n" +
  4658. " AND (:createtimeend is null or TP_PM_Defect.createtime <= :createtimeend)\n" +
  4659. " AND (:procedureids is null or instr(','||:procedureids||',', ','||TP_PM_Defect.ProcedureID||',') > 0)\n" +
  4660. " AND (:DefectCode is null or instr(TP_MST_Defect.Defectcode, :DefectCode) > 0)\n" +
  4661. " AND (:DefectName is null or instr(TP_MST_Defect.Defectname, :DefectName) > 0)\n" +
  4662. " GROUP BY tp_pc_productionline.productionlinename\n" +
  4663. " ,tp_pc_procedure.procedurename\n" +
  4664. " ,TP_MST_DefectType.Defecttypename\n" +
  4665. " ,TP_MST_Defect.Defectcode\n" +
  4666. " ,TP_MST_Defect.Defectname\n" +
  4667. " ,goodstype2.goodstypecode\n" +
  4668. " ,goodstype2.goodstypename) Defect\n" +
  4669. " LEFT JOIN ( SELECT gt2.goodstypecode goodstypecode2, COUNT(pd.barcode) outNum\n" +
  4670. " FROM tp_pm_productiondata pd\n" +
  4671. " LEFT JOIN tp_mst_goods g on g.goodsid = pd.goodsid\n" +
  4672. " LEFT JOIN tp_mst_goodstype gt on g.goodstypeid = gt.goodstypeid\n" +
  4673. " LEFT JOIN tp_mst_goodstype gt2 on gt2.AccountID = :AccountID and gt2.goodstypecode = substr(gt.goodstypecode, 0, 6)\n" +
  4674. " WHERE pd.valueflag = '1'\n" +
  4675. " AND pd.procedureid = :procedureid\n" +
  4676. " AND pd.AccountID = :AccountID\n" +
  4677. " AND (:createtimebegin is null or pd.createtime >= :createtimebegin)\n" +
  4678. " AND (:createtimeend is null or pd.createtime <= :createtimeend)\n" +
  4679. " GROUP BY gt2.goodstypecode) OUT \n" +
  4680. " ON OUT.goodstypecode2 = Defect.goodstypecode2 \n";
  4681. parameters = new OracleParameter[]
  4682. {
  4683. new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  4684. new OracleParameter(":createtimebegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  4685. new OracleParameter(":createtimeend", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  4686. new OracleParameter(":procedureids", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input),
  4687. new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input),
  4688. new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input),
  4689. //new OracleParameter(":OutKilnCount", OracleDbType.Int32, outKilnCount, ParameterDirection.Input),
  4690. new OracleParameter(":procedureid", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input),
  4691. };
  4692. }
  4693. else
  4694. {
  4695. sqlString = "SELECT COUNT(pd.barcode) \n" +
  4696. " FROM tp_pm_productiondata pd\n" +
  4697. " WHERE pd.valueflag = '1'\n" +
  4698. " AND pd.procedureid = :procedureid\n" +
  4699. " AND pd.AccountID = :AccountID\n" +
  4700. " AND (:createtimebegin is null or pd.createtime >= :createtimebegin)\n" +
  4701. " AND (:createtimeend is null or pd.createtime <= :createtimeend)";
  4702. parameters = new OracleParameter[]
  4703. {
  4704. new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  4705. new OracleParameter(":procedureid", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input),
  4706. new OracleParameter(":createtimebegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  4707. new OracleParameter(":createtimeend", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  4708. };
  4709. int outKilnCount = Convert.ToInt32(conn.GetSqlResultToStr(sqlString, parameters));
  4710. sqlString = "SELECT Defect.productionlinename\n" +
  4711. " ,Defect.procedurename\n" +
  4712. " ,Defect.Defectcode\n" +
  4713. " ,Defect.Defectname\n" +
  4714. " ,Defect.goodstypename2\n" +
  4715. " ,Defect.DefectCount\n" +
  4716. " ,:OutKilnCount OutKilnCount\n" +
  4717. " ,decode(:OutKilnCount,\n" +
  4718. " 0,\n" +
  4719. " to_number(NULL),\n" +
  4720. " ROUND(Defect.DefectCount / :OutKilnCount, 4)) DefectPercent\n" +
  4721. " FROM (SELECT tp_pc_productionline.productionlinename\n" +
  4722. " ,tp_pc_procedure.procedurename\n" +
  4723. " ,TP_MST_DefectType.Defecttypename\n" +
  4724. " ,TP_MST_Defect.Defectcode\n" +
  4725. " ,TP_MST_Defect.Defectname\n" +
  4726. " ,goodstype2.goodstypename goodstypename2\n" +
  4727. " ,:OutKilnCount OutKilnCount\n" +
  4728. " --,COUNT(DISTINCT TP_PM_Defect.Barcode) DefectCount\n" +
  4729. " ,COUNT(TP_PM_Defect.Barcode) DefectCount\n" +
  4730. " FROM TP_PM_Defect\n" +
  4731. " LEFT JOIN tp_pc_procedure\n" +
  4732. " ON TP_PM_Defect.ProcedureID = tp_pc_procedure.ProcedureID\n" +
  4733. " LEFT JOIN tp_pc_productionline\n" +
  4734. " ON TP_PM_Defect.Productionlineid =\n" +
  4735. " tp_pc_productionline.Productionlineid\n" +
  4736. " LEFT JOIN TP_MST_Goods\n" +
  4737. " ON TP_PM_Defect.Goodsid = TP_MST_Goods.Goodsid\n" +
  4738. " LEFT JOIN TP_MST_GoodsType\n" +
  4739. " ON TP_MST_Goods.GoodsTypeID = TP_MST_GoodsType.GoodsTypeID\n" +
  4740. " LEFT JOIN TP_MST_GoodsType goodstype2\n" +
  4741. " ON goodstype2.goodstypecode =\n" +
  4742. " substr(TP_MST_GoodsType.goodstypecode, 0, 6)\n" +
  4743. " AND TP_MST_GoodsType.accountid = goodstype2.accountid\n" +
  4744. " LEFT JOIN TP_MST_Defect\n" +
  4745. " ON TP_PM_Defect.DefectID = TP_MST_Defect.DefectID\n" +
  4746. " LEFT JOIN TP_MST_DefectType\n" +
  4747. " ON TP_MST_Defect.DefectTypeID = TP_MST_DefectType.DefectTypeID\n" +
  4748. " --LEFT JOIN TP_PM_ProductionData\n" +
  4749. " -- ON TP_PM_ProductionData.ProductionDataID =\n" +
  4750. " -- TP_PM_Defect.ProductionDataID\n" +
  4751. " WHERE TP_PM_Defect.valueflag = '1'\n" +
  4752. " --AND tp_pc_procedure.ModelType = -1\n" +
  4753. " AND TP_PM_Defect.AccountID = :AccountID\n" +
  4754. " AND (:createtimebegin is null or TP_PM_Defect.createtime >= :createtimebegin)\n" +
  4755. " AND (:createtimeend is null or TP_PM_Defect.createtime <= :createtimeend)\n" +
  4756. " AND (:procedureids is null or instr(','||:procedureids||',', ','||TP_PM_Defect.ProcedureID||',') > 0)\n" +
  4757. " AND (:DefectCode is null or instr(TP_MST_Defect.Defectcode, :DefectCode) > 0)\n" +
  4758. " AND (:DefectName is null or instr(TP_MST_Defect.Defectname, :DefectName) > 0)\n" +
  4759. " GROUP BY tp_pc_productionline.productionlinename\n" +
  4760. " ,tp_pc_procedure.procedurename\n" +
  4761. " ,TP_MST_DefectType.Defecttypename\n" +
  4762. " ,TP_MST_Defect.Defectcode\n" +
  4763. " ,TP_MST_Defect.Defectname\n" +
  4764. " ,goodstype2.goodstypename) Defect";
  4765. parameters = new OracleParameter[]
  4766. {
  4767. new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  4768. new OracleParameter(":createtimebegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  4769. new OracleParameter(":createtimeend", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  4770. new OracleParameter(":procedureids", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input),
  4771. new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input),
  4772. new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input),
  4773. new OracleParameter(":OutKilnCount", OracleDbType.Int32, outKilnCount, ParameterDirection.Input),
  4774. };
  4775. }
  4776. DataTable data = conn.GetSqlResultToDt(sqlString, parameters);
  4777. ServiceResultEntity sre = new ServiceResultEntity();
  4778. if (data == null || data.Rows.Count == 0)
  4779. {
  4780. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4781. return sre;
  4782. }
  4783. sre.Data = new DataSet();
  4784. sre.Data.Tables.Add(data);
  4785. return sre;
  4786. }
  4787. catch (Exception ex)
  4788. {
  4789. throw ex;
  4790. }
  4791. finally
  4792. {
  4793. if (conn != null &&
  4794. conn.ConnState == ConnectionState.Open)
  4795. {
  4796. conn.Close();
  4797. }
  4798. }
  4799. }
  4800. /// <summary>
  4801. /// 取得RPT040107画面(注浆产品工序分析表)的查询数据
  4802. /// </summary>
  4803. /// <param name="user">登录用户信息</param>
  4804. /// <param name="se">查询条件</param>
  4805. /// <returns>查询结果</returns>
  4806. public static ServiceResultEntity GetRPT040107SData(SUserInfo user, RPT040107_SE se)
  4807. {
  4808. IDBConnection conn = null;
  4809. try
  4810. {
  4811. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  4812. List<OracleParameter> parameters = new List<OracleParameter>();
  4813. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  4814. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  4815. string sqlString =
  4816. "SELECT LISTAGG('''' || p.procedureid || ''' AS ' || 'P' || p.procedureid,\n" +
  4817. " ',') WITHIN GROUP(ORDER BY p.displayno, p.pid) pivotcol\n" +
  4818. " ,LISTAGG('sum(pd.P' || p.procedureid || '_BC) AS \"' ||\n" +
  4819. " p.procedurename || '\"',\n" +
  4820. " ',') WITHIN GROUP(ORDER BY p.displayno, p.pid) groupsum\n" +
  4821. " FROM (SELECT to_char(p.procedureid) procedureid\n" +
  4822. " ,to_char(p.procedurename) procedurename\n" +
  4823. " ,p.displayno\n" +
  4824. " ,p.productionlineid plid\n" +
  4825. " ,p.procedureid pid\n" +
  4826. " FROM tp_pc_procedure p\n" +
  4827. " WHERE p.valueflag = '1'\n" +
  4828. " AND p.modeltype <> -1\n" +
  4829. " AND p.accountid = :AccountID\n" +
  4830. " UNION ALL\n" +
  4831. " SELECT to_char(p.procedureid) || 'S'\n" +
  4832. " ,to_char(p.procedurename) || '(不合格)'\n" +
  4833. " ,p.displayno\n" +
  4834. " ,p.productionlineid plid\n" +
  4835. " ,p.procedureid pid\n" +
  4836. " FROM tp_pc_procedure p\n" +
  4837. " WHERE p.valueflag = '1'\n" +
  4838. " AND p.modeltype = -1\n" +
  4839. " AND p.accountid = :AccountID) p" +
  4840. " 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" +
  4841. " 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";
  4842. // 生产线
  4843. if (se.ProductionLineID.HasValue)
  4844. {
  4845. sqlString = sqlString + " AND p.plid = :ProductionLineID ";
  4846. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  4847. }
  4848. // 生产工序
  4849. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  4850. {
  4851. sqlString = sqlString + " AND instr(:procedureids, ','||p.pid||',')>0 ";
  4852. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  4853. }
  4854. DataTable cols = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  4855. ServiceResultEntity sre = new ServiceResultEntity();
  4856. if (cols == null || cols.Rows.Count == 0)
  4857. {
  4858. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4859. return sre;
  4860. }
  4861. string pivotcol = cols.Rows[0]["pivotcol"].ToString();
  4862. string groupsum = cols.Rows[0]["groupsum"].ToString();
  4863. if (string.IsNullOrEmpty(pivotcol) || string.IsNullOrEmpty(groupsum))
  4864. {
  4865. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4866. return sre;
  4867. }
  4868. parameters.Clear();
  4869. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  4870. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  4871. sqlString =
  4872. "WITH pd_data AS\n" +
  4873. " (SELECT DISTINCT pd.goodsid pdgoodsid\n" +
  4874. " ,pd.groutingdailydetailid\n" +
  4875. " ,decode(pd.MODELTYPE,\n" +
  4876. " -1,\n" +
  4877. " to_char(pd.procedureid) || 'S',\n" +
  4878. " to_char(pd.procedureid)) procedureid\n" +
  4879. " FROM tp_pm_productiondata pd\n" +
  4880. " LEFT JOIN tp_mst_goods goods\n" +
  4881. " ON goods.goodsid = pd.goodsid\n" +
  4882. " LEFT JOIN tp_mst_goodstype gt\n" +
  4883. " ON gt.goodstypeid = goods.goodstypeid\n" +
  4884. " WHERE pd.valueflag = '1'\n" +
  4885. " AND (pd.MODELTYPE <> -1 OR pd.goodsleveltypeid IN (6, 7))\n" +
  4886. " AND pd.accountid = :AccountID\n" +
  4887. (se.Specialrepairflag ? " AND ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" : "") +
  4888. " 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" +
  4889. " 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";
  4890. // 生产线
  4891. if (se.ProductionLineID.HasValue)
  4892. {
  4893. sqlString = sqlString + " AND pd.productionlineid = :ProductionLineID ";
  4894. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  4895. }
  4896. // 生产工序
  4897. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  4898. {
  4899. sqlString = sqlString + " AND instr(:procedureids, ','||pd.procedureid||',')>0 ";
  4900. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  4901. }
  4902. // 产品型号
  4903. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  4904. {
  4905. sqlString = sqlString + " AND instr(gt.GOODSTYPECode, :GoodsTypeCode)=1 ";
  4906. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  4907. }
  4908. // 产品编码
  4909. if (!string.IsNullOrEmpty(se.GoodsCode))
  4910. {
  4911. sqlString = sqlString + " AND instr(goods.GOODSCode, :GoodsCode) > 0 ";
  4912. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  4913. }
  4914. // 注浆时间
  4915. if (se.GTimeStart.HasValue)
  4916. {
  4917. sqlString = sqlString + " AND pd.GROUTINGDATE >=:GTimeStart ";
  4918. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  4919. }
  4920. if (se.GTimeEnd.HasValue)
  4921. {
  4922. sqlString = sqlString + " AND pd.GROUTINGDATE <= :GTimeEnd ";
  4923. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  4924. }
  4925. sqlString +=
  4926. " ),\n" +
  4927. "pivot_data AS\n" +
  4928. " (SELECT *\n" +
  4929. " FROM pd_data\n" +
  4930. " PIVOT(COUNT(groutingdailydetailid) bc\n" +
  4931. " FOR procedureid IN(" + pivotcol + ")))\n" +
  4932. "SELECT decode(grouping_id(groutdetail.goodstypename2, groutdetail.goodscode),\n" +
  4933. " 3,\n" +
  4934. " '合计',\n" +
  4935. " 1,\n" +
  4936. " '小计【' || groutdetail.goodstypename2 || '】',\n" +
  4937. " groutdetail.goodstypename2) \"产量类别\"\n" +
  4938. " ,decode(grouping_id(groutdetail.goodstypename2, groutdetail.goodscode),\n" +
  4939. " 0,\n" +
  4940. " groutdetail.goodscode,\n" +
  4941. " '--') \"产品编码\"\n" +
  4942. " ,SUM(groutdetail.groutcount) \"注浆数量\"\n" +
  4943. " ,SUM(groutdetail.barcodecount) \"绑条码数量\"\n" +
  4944. " ,SUM(groutdetail.scrapcount) \"开模损坯\"\n" +
  4945. " ," + groupsum + "\n" +
  4946. " FROM (SELECT gdd.goodsid, gt2.goodstypename goodstypename2, goods.goodscode\n" +
  4947. " ,COUNT(gdd.groutingdailydetailid) AS groutcount\n" +
  4948. " ,SUM(decode(gdd.barcode, NULL, 0, 1)) AS barcodecount\n" +
  4949. " ,SUM(decode(gdd.scrapflag, '1', 1, 0)) AS scrapcount\n" +
  4950. " FROM tp_pm_groutingdailydetail gdd\n" +
  4951. " LEFT JOIN tp_mst_goods goods\n" +
  4952. " ON goods.goodsid = gdd.goodsid\n" +
  4953. " LEFT JOIN tp_mst_goodstype gt\n" +
  4954. " ON gt.goodstypeid = goods.goodstypeid\n" +
  4955. " LEFT JOIN tp_mst_goodstype gt2\n" +
  4956. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  4957. " AND gt2.accountid = gt.accountid\n" +
  4958. " WHERE gdd.valueflag = '1'\n" +
  4959. " AND gdd.accountid = :AccountID\n";
  4960. // 产品型号
  4961. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  4962. {
  4963. sqlString = sqlString + " AND instr(gt.GOODSTYPECode, :GoodsTypeCode)=1 ";
  4964. }
  4965. // 产品编码
  4966. if (!string.IsNullOrEmpty(se.GoodsCode))
  4967. {
  4968. sqlString = sqlString + " AND instr(goods.GOODSCode, :GoodsCode) > 0 ";
  4969. }
  4970. // 注浆时间
  4971. if (se.GTimeStart.HasValue)
  4972. {
  4973. sqlString = sqlString + " AND gdd.GROUTINGDATE >=:GTimeStart ";
  4974. }
  4975. if (se.GTimeEnd.HasValue)
  4976. {
  4977. sqlString = sqlString + " AND gdd.GROUTINGDATE <= :GTimeEnd ";
  4978. }
  4979. sqlString +=
  4980. " AND gdd.groutingflag = '1'\n" +
  4981. " GROUP BY gdd.goodsid, gt2.goodstypename, goods.goodscode) groutdetail\n" +
  4982. " LEFT JOIN pivot_data pd\n" +
  4983. " ON pd.pdgoodsid = groutdetail.goodsid\n" +
  4984. " GROUP BY GROUPING SETS((groutdetail.goodstypename2, groutdetail.goodscode),(groutdetail.goodstypename2),())\n" +
  4985. " ORDER BY groutdetail.goodstypename2, groutdetail.goodscode";
  4986. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  4987. if (data == null || data.Rows.Count == 0)
  4988. {
  4989. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4990. return sre;
  4991. }
  4992. sre.Data = new DataSet();
  4993. sre.Data.Tables.Add(data);
  4994. return sre;
  4995. }
  4996. catch (Exception ex)
  4997. {
  4998. throw ex;
  4999. }
  5000. finally
  5001. {
  5002. if (conn != null &&
  5003. conn.ConnState == ConnectionState.Open)
  5004. {
  5005. conn.Close();
  5006. }
  5007. }
  5008. }
  5009. /// <summary>
  5010. /// 取得RPT040108画面(成型线产量分析表)的查询数据
  5011. /// </summary>
  5012. /// <param name="user">登录用户信息</param>
  5013. /// <param name="se">查询条件</param>
  5014. /// <returns>查询结果</returns>
  5015. public static ServiceResultEntity GetRPT040108SData(SUserInfo user, RPT040108_SE se)
  5016. {
  5017. IDBConnection conn = null;
  5018. try
  5019. {
  5020. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  5021. //string sqlString =
  5022. // "SELECT t.groutinglinecode\n" +
  5023. // " ,t.BuildingNo\n" +
  5024. // " ,t.FloorNo\n" +
  5025. // " ,t.GroutingLineNo\n" +
  5026. // " ,t.usercode\n" +
  5027. // " ,t.goodscode\n" +
  5028. // " ,t.GOODSSPECIFICATION\n" +
  5029. // " ,t.goodstypename\n" +
  5030. // //" ,round(AVG(t.MouldQuantity), 2) MouldQuantity\n" +
  5031. // " ,AVG(t.MouldQuantity) MouldQuantity\n" +
  5032. // " ,SUM(decode(t.gday, '01', t.c, 0)) c01\n" +
  5033. // " ,SUM(decode(t.dday, '01', t.d, 0)) d01\n" +
  5034. // " ,SUM(decode(t.gday, '02', t.c, 0)) c02\n" +
  5035. // " ,SUM(decode(t.dday, '02', t.d, 0)) d02\n" +
  5036. // " ,SUM(decode(t.gday, '03', t.c, 0)) c03\n" +
  5037. // " ,SUM(decode(t.dday, '03', t.d, 0)) d03\n" +
  5038. // " ,SUM(decode(t.gday, '04', t.c, 0)) c04\n" +
  5039. // " ,SUM(decode(t.dday, '04', t.d, 0)) d04\n" +
  5040. // " ,SUM(decode(t.gday, '05', t.c, 0)) c05\n" +
  5041. // " ,SUM(decode(t.dday, '05', t.d, 0)) d05\n" +
  5042. // " ,SUM(decode(t.gday, '06', t.c, 0)) c06\n" +
  5043. // " ,SUM(decode(t.dday, '06', t.d, 0)) d06\n" +
  5044. // " ,SUM(decode(t.gday, '07', t.c, 0)) c07\n" +
  5045. // " ,SUM(decode(t.dday, '07', t.d, 0)) d07\n" +
  5046. // " ,SUM(decode(t.gday, '08', t.c, 0)) c08\n" +
  5047. // " ,SUM(decode(t.dday, '08', t.d, 0)) d08\n" +
  5048. // " ,SUM(decode(t.gday, '09', t.c, 0)) c09\n" +
  5049. // " ,SUM(decode(t.dday, '09', t.d, 0)) d09\n" +
  5050. // " ,SUM(decode(t.gday, '10', t.c, 0)) c10\n" +
  5051. // " ,SUM(decode(t.dday, '10', t.d, 0)) d10\n" +
  5052. // " ,SUM(decode(t.gday, '11', t.c, 0)) c11\n" +
  5053. // " ,SUM(decode(t.dday, '11', t.d, 0)) d11\n" +
  5054. // " ,SUM(decode(t.gday, '12', t.c, 0)) c12\n" +
  5055. // " ,SUM(decode(t.dday, '12', t.d, 0)) d12\n" +
  5056. // " ,SUM(decode(t.gday, '13', t.c, 0)) c13\n" +
  5057. // " ,SUM(decode(t.dday, '13', t.d, 0)) d13\n" +
  5058. // " ,SUM(decode(t.gday, '14', t.c, 0)) c14\n" +
  5059. // " ,SUM(decode(t.dday, '14', t.d, 0)) d14\n" +
  5060. // " ,SUM(decode(t.gday, '15', t.c, 0)) c15\n" +
  5061. // " ,SUM(decode(t.dday, '15', t.d, 0)) d15\n" +
  5062. // " ,SUM(decode(t.gday, '16', t.c, 0)) c16\n" +
  5063. // " ,SUM(decode(t.dday, '16', t.d, 0)) d16\n" +
  5064. // " ,SUM(decode(t.gday, '17', t.c, 0)) c17\n" +
  5065. // " ,SUM(decode(t.dday, '17', t.d, 0)) d17\n" +
  5066. // " ,SUM(decode(t.gday, '18', t.c, 0)) c18\n" +
  5067. // " ,SUM(decode(t.dday, '18', t.d, 0)) d18\n" +
  5068. // " ,SUM(decode(t.gday, '19', t.c, 0)) c19\n" +
  5069. // " ,SUM(decode(t.dday, '19', t.d, 0)) d19\n" +
  5070. // " ,SUM(decode(t.gday, '20', t.c, 0)) c20\n" +
  5071. // " ,SUM(decode(t.dday, '20', t.d, 0)) d20\n" +
  5072. // " ,SUM(decode(t.gday, '21', t.c, 0)) c21\n" +
  5073. // " ,SUM(decode(t.dday, '21', t.d, 0)) d21\n" +
  5074. // " ,SUM(decode(t.gday, '22', t.c, 0)) c22\n" +
  5075. // " ,SUM(decode(t.dday, '22', t.d, 0)) d22\n" +
  5076. // " ,SUM(decode(t.gday, '23', t.c, 0)) c23\n" +
  5077. // " ,SUM(decode(t.dday, '23', t.d, 0)) d23\n" +
  5078. // " ,SUM(decode(t.gday, '24', t.c, 0)) c24\n" +
  5079. // " ,SUM(decode(t.dday, '24', t.d, 0)) d24\n" +
  5080. // " ,SUM(decode(t.gday, '25', t.c, 0)) c25\n" +
  5081. // " ,SUM(decode(t.dday, '25', t.d, 0)) d25\n" +
  5082. // " ,SUM(decode(t.gday, '26', t.c, 0)) c26\n" +
  5083. // " ,SUM(decode(t.dday, '26', t.d, 0)) d26\n" +
  5084. // " ,SUM(decode(t.gday, '27', t.c, 0)) c27\n" +
  5085. // " ,SUM(decode(t.dday, '27', t.d, 0)) d27\n" +
  5086. // " ,SUM(decode(t.gday, '28', t.c, 0)) c28\n" +
  5087. // " ,SUM(decode(t.dday, '28', t.d, 0)) d28\n" +
  5088. // " ,SUM(decode(t.gday, '29', t.c, 0)) c29\n" +
  5089. // " ,SUM(decode(t.dday, '29', t.d, 0)) d29\n" +
  5090. // " ,SUM(decode(t.gday, '30', t.c, 0)) c30\n" +
  5091. // " ,SUM(decode(t.dday, '30', t.d, 0)) d30\n" +
  5092. // " ,SUM(decode(t.gday, '31', t.c, 0)) c31\n" +
  5093. // " ,SUM(decode(t.dday, '31', t.d, 0)) d31\n" +
  5094. // " FROM (SELECT gd.groutinglinecode\n" +
  5095. // " ,gl.BuildingNo\n" +
  5096. // " ,gl.FloorNo\n" +
  5097. // " ,gl.GroutingLineNo\n" +
  5098. // " ,gd.usercode\n" +
  5099. // " ,gdd.goodscode\n" +
  5100. // " ,g.GOODSSPECIFICATION\n" +
  5101. // " ,gt.goodstypename\n" +
  5102. // //" ,gd.MouldQuantity\n" +
  5103. // " ,gl.MouldQuantity\n" +
  5104. // " ,to_char(gd.groutingdate, 'dd') AS gday\n" +
  5105. // " ,to_char(gdd.delivertime, 'dd') AS dday\n" +
  5106. // " , CASE\n" +
  5107. // " WHEN gd.groutingdate >= :GDateBegin AND\n" +
  5108. // " gd.groutingdate <= :GDateEnd AND\n" +
  5109. // " gdd.GroutingFlag = '1' AND gdd.ScrapFlag = '0' THEN\n" +
  5110. // " 1\n" +
  5111. // " ELSE\n" +
  5112. // " 0\n" +
  5113. // " END c -- 成坯量\n" +
  5114. // " , CASE\n" +
  5115. // " WHEN gdd.delivertime >= :GDateBegin AND\n" +
  5116. // " gdd.delivertime <= :GDateEnd AND\n" +
  5117. // " gdd.deliverflag = '1' THEN\n" +
  5118. // " 1\n" +
  5119. // " ELSE\n" +
  5120. // " 0\n" +
  5121. // " END d -- 交坯量\n" +
  5122. // " FROM TP_PM_GroutingDaily gd\n" +
  5123. // " INNER JOIN TP_PM_GroutingDailyDetail gdd\n" +
  5124. // " ON gdd.groutingdailyid = gd.groutingdailyid\n" +
  5125. // " INNER JOIN TP_PC_GroutingLine gl \n" +
  5126. // " ON gl.groutinglineid = gd.groutinglineid\n" +
  5127. // " INNER JOIN TP_MST_Goods g\n" +
  5128. // " ON g.goodsid = gdd.goodsid\n" +
  5129. // " INNER JOIN TP_MST_GOODSTYPE gt\n" +
  5130. // " ON gt.goodstypeid = g.goodstypeid\n" +
  5131. // " WHERE gd.accountid = :AccountID\n" +
  5132. // " AND ((gd.groutingdate >= :GDateBegin AND\n" +
  5133. // " gd.groutingdate <= :GDateEnd) OR\n" +
  5134. // " (gdd.delivertime >= :GDateBegin AND\n" +
  5135. // " gdd.delivertime <= :GDateEnd))\n" +
  5136. // " AND (:groutinglinecode is null or instr(gd.groutinglinecode, :groutinglinecode) > 0)\n" +
  5137. // " AND (:groutingusercode is null or instr(gdd.usercode, :groutingusercode) > 0)\n" +
  5138. // " AND (:goodscode is null or instr(gdd.goodscode, :goodscode) > 0)\n" +
  5139. // " AND (:goodstypecode is null or instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  5140. // " ) t\n" +
  5141. // " GROUP BY t.groutinglinecode\n" +
  5142. // " ,t.BuildingNo\n" +
  5143. // " ,t.FloorNo\n" +
  5144. // " ,t.GroutingLineNo\n" +
  5145. // " ,t.usercode\n" +
  5146. // " ,t.goodscode\n" +
  5147. // " ,t.GOODSSPECIFICATION\n" +
  5148. // " ,t.goodstypename\n" +
  5149. // " ORDER BY t.groutinglinecode, t.usercode, t.goodscode";
  5150. string sqlString = "select nvl(t.groutinglinecode, '--') groutinglinecode\n" +
  5151. " ,nvl(t.BuildingNo, '--') BuildingNo\n" +
  5152. " ,nvl(t.FloorNo, '--') FloorNo\n" +
  5153. " ,nvl(t.GroutingLineNo, '--') GroutingLineNo\n" +
  5154. " ,nvl(t.usercode, '--') usercode\n" +
  5155. " ,nvl2(t.groutinglinecode\n" +
  5156. " ,t.goodscode\n" +
  5157. " ,nvl2(t.goodscode, '小计[' || t.goodscode || ']', '合计')) goodscode\n" +
  5158. " ,nvl2(t.goodscode, t.GOODSSPECIFICATION, '--') GOODSSPECIFICATION\n" +
  5159. " ,nvl2(t.goodscode, t.goodstypename, '--') goodstypename\n" +
  5160. " ,nvl2(t.groutinglinecode, avg(t.MouldQuantity), null) MouldQuantity\n" +
  5161. " ,sum(decode(t.gday, '01', t.c, 0)) c01\n" +
  5162. " ,sum(decode(t.dday, '01', t.d, 0)) d01\n" +
  5163. " ,sum(decode(t.gday, '02', t.c, 0)) c02\n" +
  5164. " ,sum(decode(t.dday, '02', t.d, 0)) d02\n" +
  5165. " ,sum(decode(t.gday, '03', t.c, 0)) c03\n" +
  5166. " ,sum(decode(t.dday, '03', t.d, 0)) d03\n" +
  5167. " ,sum(decode(t.gday, '04', t.c, 0)) c04\n" +
  5168. " ,sum(decode(t.dday, '04', t.d, 0)) d04\n" +
  5169. " ,sum(decode(t.gday, '05', t.c, 0)) c05\n" +
  5170. " ,sum(decode(t.dday, '05', t.d, 0)) d05\n" +
  5171. " ,sum(decode(t.gday, '06', t.c, 0)) c06\n" +
  5172. " ,sum(decode(t.dday, '06', t.d, 0)) d06\n" +
  5173. " ,sum(decode(t.gday, '07', t.c, 0)) c07\n" +
  5174. " ,sum(decode(t.dday, '07', t.d, 0)) d07\n" +
  5175. " ,sum(decode(t.gday, '08', t.c, 0)) c08\n" +
  5176. " ,sum(decode(t.dday, '08', t.d, 0)) d08\n" +
  5177. " ,sum(decode(t.gday, '09', t.c, 0)) c09\n" +
  5178. " ,sum(decode(t.dday, '09', t.d, 0)) d09\n" +
  5179. " ,sum(decode(t.gday, '10', t.c, 0)) c10\n" +
  5180. " ,sum(decode(t.dday, '10', t.d, 0)) d10\n" +
  5181. " ,sum(decode(t.gday, '11', t.c, 0)) c11\n" +
  5182. " ,sum(decode(t.dday, '11', t.d, 0)) d11\n" +
  5183. " ,sum(decode(t.gday, '12', t.c, 0)) c12\n" +
  5184. " ,sum(decode(t.dday, '12', t.d, 0)) d12\n" +
  5185. " ,sum(decode(t.gday, '13', t.c, 0)) c13\n" +
  5186. " ,sum(decode(t.dday, '13', t.d, 0)) d13\n" +
  5187. " ,sum(decode(t.gday, '14', t.c, 0)) c14\n" +
  5188. " ,sum(decode(t.dday, '14', t.d, 0)) d14\n" +
  5189. " ,sum(decode(t.gday, '15', t.c, 0)) c15\n" +
  5190. " ,sum(decode(t.dday, '15', t.d, 0)) d15\n" +
  5191. " ,sum(decode(t.gday, '16', t.c, 0)) c16\n" +
  5192. " ,sum(decode(t.dday, '16', t.d, 0)) d16\n" +
  5193. " ,sum(decode(t.gday, '17', t.c, 0)) c17\n" +
  5194. " ,sum(decode(t.dday, '17', t.d, 0)) d17\n" +
  5195. " ,sum(decode(t.gday, '18', t.c, 0)) c18\n" +
  5196. " ,sum(decode(t.dday, '18', t.d, 0)) d18\n" +
  5197. " ,sum(decode(t.gday, '19', t.c, 0)) c19\n" +
  5198. " ,sum(decode(t.dday, '19', t.d, 0)) d19\n" +
  5199. " ,sum(decode(t.gday, '20', t.c, 0)) c20\n" +
  5200. " ,sum(decode(t.dday, '20', t.d, 0)) d20\n" +
  5201. " ,sum(decode(t.gday, '21', t.c, 0)) c21\n" +
  5202. " ,sum(decode(t.dday, '21', t.d, 0)) d21\n" +
  5203. " ,sum(decode(t.gday, '22', t.c, 0)) c22\n" +
  5204. " ,sum(decode(t.dday, '22', t.d, 0)) d22\n" +
  5205. " ,sum(decode(t.gday, '23', t.c, 0)) c23\n" +
  5206. " ,sum(decode(t.dday, '23', t.d, 0)) d23\n" +
  5207. " ,sum(decode(t.gday, '24', t.c, 0)) c24\n" +
  5208. " ,sum(decode(t.dday, '24', t.d, 0)) d24\n" +
  5209. " ,sum(decode(t.gday, '25', t.c, 0)) c25\n" +
  5210. " ,sum(decode(t.dday, '25', t.d, 0)) d25\n" +
  5211. " ,sum(decode(t.gday, '26', t.c, 0)) c26\n" +
  5212. " ,sum(decode(t.dday, '26', t.d, 0)) d26\n" +
  5213. " ,sum(decode(t.gday, '27', t.c, 0)) c27\n" +
  5214. " ,sum(decode(t.dday, '27', t.d, 0)) d27\n" +
  5215. " ,sum(decode(t.gday, '28', t.c, 0)) c28\n" +
  5216. " ,sum(decode(t.dday, '28', t.d, 0)) d28\n" +
  5217. " ,sum(decode(t.gday, '29', t.c, 0)) c29\n" +
  5218. " ,sum(decode(t.dday, '29', t.d, 0)) d29\n" +
  5219. " ,sum(decode(t.gday, '30', t.c, 0)) c30\n" +
  5220. " ,sum(decode(t.dday, '30', t.d, 0)) d30\n" +
  5221. " ,sum(decode(t.gday, '31', t.c, 0)) c31\n" +
  5222. " ,sum(decode(t.dday, '31', t.d, 0)) d31\n" +
  5223. " from (select gd.groutinglinecode\n" +
  5224. " ,gl.BuildingNo\n" +
  5225. " ,gl.FloorNo\n" +
  5226. " ,gl.GroutingLineNo\n" +
  5227. " ,gd.usercode\n" +
  5228. " ,gdd.goodscode\n" +
  5229. " ,g.GOODSSPECIFICATION\n" +
  5230. " ,gt.goodstypename\n" +
  5231. " ,gl.MouldQuantity\n" +
  5232. " ,to_char(gd.groutingdate, 'dd') as gday\n" +
  5233. " ,to_char(gdd.delivertime, 'dd') as dday\n" +
  5234. " ,case\n" +
  5235. " when gd.groutingdate >= :GDateBegin and\n" +
  5236. " gd.groutingdate <= :GDateEnd and\n" +
  5237. " gdd.GroutingFlag = '1' and\n" +
  5238. " gdd.ScrapFlag = '0' then\n" +
  5239. " 1\n" +
  5240. " else\n" +
  5241. " 0\n" +
  5242. " end c -- 成坯量\n" +
  5243. " ,case\n" +
  5244. " when gdd.delivertime >= :GDateBegin and\n" +
  5245. " gdd.delivertime <= :GDateEnd and\n" +
  5246. " gdd.deliverflag = '1' then\n" +
  5247. " 1\n" +
  5248. " else\n" +
  5249. " 0\n" +
  5250. " end d -- 交坯量\n" +
  5251. " from TP_PM_GroutingDaily gd\n" +
  5252. " inner join TP_PM_GroutingDailyDetail gdd\n" +
  5253. " on gdd.groutingdailyid = gd.groutingdailyid\n" +
  5254. " inner join TP_PC_GroutingLine gl\n" +
  5255. " on gl.groutinglineid = gd.groutinglineid\n" +
  5256. " inner join TP_MST_Goods g\n" +
  5257. " on g.goodsid = gdd.goodsid\n" +
  5258. " inner join TP_MST_GOODSTYPE gt\n" +
  5259. " on gt.goodstypeid = g.goodstypeid\n" +
  5260. " where gd.accountid = :AccountID\n" +
  5261. " and ((gd.groutingdate >= :GDateBegin and\n" +
  5262. " gd.groutingdate <= :GDateEnd) or\n" +
  5263. " (gdd.delivertime >= :GDateBegin and\n" +
  5264. " gdd.delivertime <= :GDateEnd))\n" +
  5265. " and (:groutinglinecode is null or\n" +
  5266. " instr(gd.groutinglinecode, :groutinglinecode) > 0)\n" +
  5267. " and (:groutingusercode is null or\n" +
  5268. " instr(gdd.usercode, :groutingusercode) > 0)\n" +
  5269. " and (:goodscode is null or instr(gdd.goodscode, :goodscode) > 0)\n" +
  5270. " and (:goodstypecode is null or\n" +
  5271. " instr(gt.goodstypecode, :goodstypecode) = 1)) t\n" +
  5272. " 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" +
  5273. " order by t.goodscode, t.groutinglinecode, t.usercode";
  5274. List<OracleParameter> parameters = new List<OracleParameter>();
  5275. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  5276. parameters.Add(new OracleParameter(":GDateBegin", OracleDbType.Date, se.GDateBegin, ParameterDirection.Input));
  5277. parameters.Add(new OracleParameter(":GDateEnd", OracleDbType.Date, se.GDateEnd, ParameterDirection.Input));
  5278. parameters.Add(new OracleParameter(":groutinglinecode", OracleDbType.Varchar2, se.GroutingLineCode, ParameterDirection.Input));
  5279. parameters.Add(new OracleParameter(":groutingusercode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  5280. parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  5281. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  5282. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  5283. ServiceResultEntity sre = new ServiceResultEntity();
  5284. if (data == null || data.Rows.Count == 0)
  5285. {
  5286. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5287. return sre;
  5288. }
  5289. sre.Data = new DataSet();
  5290. sre.Data.Tables.Add(data);
  5291. return sre;
  5292. }
  5293. catch (Exception ex)
  5294. {
  5295. throw ex;
  5296. }
  5297. finally
  5298. {
  5299. if (conn != null &&
  5300. conn.ConnState == ConnectionState.Open)
  5301. {
  5302. conn.Close();
  5303. }
  5304. }
  5305. }
  5306. /// <summary>
  5307. /// 取得RPT040109画面(整体质量分析表)的查询数据
  5308. /// </summary>
  5309. /// <param name="user">登录用户信息</param>
  5310. /// <param name="se">查询条件</param>
  5311. /// <returns>查询结果</returns>
  5312. public static ServiceResultEntity GetRPT040109SData(SUserInfo user, RPT040109_SE se)
  5313. {
  5314. IDBTransaction conn = null;
  5315. try
  5316. {
  5317. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  5318. conn.Connect();
  5319. OracleParameter[] parameters = new OracleParameter[]
  5320. {
  5321. new OracleParameter("in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  5322. new OracleParameter("in_DateBegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  5323. new OracleParameter("in_DateEnd", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  5324. new OracleParameter("in_OutKilnProcedureID", OracleDbType.Int32, se.RptSProcedureID , ParameterDirection.Input),
  5325. new OracleParameter("in_KilnID", OracleDbType.Int32, se.KilnID , ParameterDirection.Input),
  5326. new OracleParameter("out_data1", OracleDbType.RefCursor, null , ParameterDirection.Output),
  5327. new OracleParameter("out_data2", OracleDbType.RefCursor, null , ParameterDirection.Output),
  5328. new OracleParameter("out_data3", OracleDbType.RefCursor, null, ParameterDirection.Output),
  5329. new OracleParameter("out_data4", OracleDbType.RefCursor, null, ParameterDirection.Output),
  5330. new OracleParameter("out_data21", OracleDbType.RefCursor, null, ParameterDirection.Output),
  5331. new OracleParameter("out_data31", OracleDbType.RefCursor, null, ParameterDirection.Output),
  5332. new OracleParameter("out_data32", OracleDbType.RefCursor, null, ParameterDirection.Output),
  5333. new OracleParameter("out_table1", OracleDbType.RefCursor, null, ParameterDirection.Output),
  5334. new OracleParameter("out_table2", OracleDbType.RefCursor, null, ParameterDirection.Output),
  5335. new OracleParameter("out_table3", OracleDbType.RefCursor, null, ParameterDirection.Output),
  5336. new OracleParameter("out_table4", OracleDbType.RefCursor, null, ParameterDirection.Output),
  5337. new OracleParameter("in_HasUserGroup", OracleDbType.Int32, (se.HasUserGroup?1:0), ParameterDirection.Input),
  5338. };
  5339. //out_data1 -- 质量整体情况
  5340. //out_data2 -- 各缺陷类型成品率
  5341. //out_data3 -- 各缺陷类型缺陷率
  5342. //out_data4 -- 产品质量排行榜
  5343. //out_data21 -- 各缺陷类型成品率-总成品率
  5344. //out_data31 -- 各缺陷类型缺陷率-总缺陷率
  5345. //out_data32 -- 各缺陷类型缺陷率-分缺陷率
  5346. //out_table1 -- 缺陷类别
  5347. //out_table2 -- 工号分组
  5348. //out_table3 -- 缺陷扣罚
  5349. //out_table4 -- 缺陷
  5350. //DataSet data = conn.ExecStoredProcedure("PRO_RPT_OverallQualityAnalysis", parameters);
  5351. DataSet data = conn.ExecStoredProcedure("PRO_RPT_OverallQualityA_UserG", parameters);
  5352. ServiceResultEntity sre = new ServiceResultEntity();
  5353. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  5354. {
  5355. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5356. return sre;
  5357. }
  5358. data.Tables[0].TableName = "TQ";
  5359. data.Tables[1].TableName = "FR";
  5360. data.Tables[2].TableName = "DR";
  5361. data.Tables[3].TableName = "DL";
  5362. data.Tables[4].TableName = "FR1";
  5363. data.Tables[5].TableName = "DR1";
  5364. data.Tables[6].TableName = "DR2";
  5365. data.Tables[7].TableName = "DT";
  5366. data.Tables[8].TableName = "WG";
  5367. data.Tables[9].TableName = "DF";
  5368. data.Tables[10].TableName = "D";
  5369. DataTable dtFR = data.Tables["FR"];
  5370. DataTable dtFRClone = dtFR.Clone();
  5371. for (int i = 0; i < dtFR.Columns.Count; i++)
  5372. {
  5373. dtFRClone.Columns[i].DataType = typeof(string);
  5374. }
  5375. foreach (DataRow item in dtFR.Rows)
  5376. {
  5377. item["goodstypename2"] = item["goodstypename2"] + "缺陷数";
  5378. dtFRClone.Rows.Add(item.ItemArray);
  5379. }
  5380. // 增加大小件成品率(%) modify by chenxy 2018-05-03 begin
  5381. //DataRow drFR = dtFRClone.NewRow();
  5382. //drFR["goodstypename2"] = "成品率(%)";
  5383. //foreach (DataRow row in data.Tables["FR1"].Rows)
  5384. //{
  5385. // string tid = row["tid"].ToString();
  5386. // string overRate = (row["OverRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["OverRate"]).ToString("#,##0.00%"));
  5387. // foreach (DataColumn col in dtFRClone.Columns)
  5388. // {
  5389. // if (col.ColumnName.StartsWith(tid))
  5390. // {
  5391. // drFR[col.ColumnName] = overRate;
  5392. // }
  5393. // }
  5394. //}
  5395. //dtFRClone.Rows.Add(drFR);
  5396. Dictionary<string, DataRow> drFRs = new Dictionary<string, DataRow>();
  5397. foreach (DataRow row in data.Tables["FR1"].Rows)
  5398. {
  5399. string tcode = row["goodstypecode2"].ToString();
  5400. DataRow drFR = null;
  5401. if (drFRs.ContainsKey(tcode))
  5402. {
  5403. drFR = drFRs[tcode];
  5404. }
  5405. else
  5406. {
  5407. drFR = dtFRClone.NewRow();
  5408. drFRs.Add(tcode, drFR);
  5409. drFR["goodstypename2"] = row["goodstypeName2"] + "成品率(%)";
  5410. }
  5411. string tid = row["tid"].ToString();
  5412. string overRate = (row["OverRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["OverRate"]).ToString("#,##0.00%"));
  5413. foreach (DataColumn col in dtFRClone.Columns)
  5414. {
  5415. if (col.ColumnName.StartsWith(tid))
  5416. {
  5417. drFR[col.ColumnName] = overRate;
  5418. }
  5419. }
  5420. }
  5421. foreach (DataRow item in drFRs.Values)
  5422. {
  5423. dtFRClone.Rows.Add(item);
  5424. }
  5425. // 增加大小件成品率(%) modify by chenxy 2018-05-03 end
  5426. data.Tables.Remove(dtFR);
  5427. data.Tables.Remove(data.Tables["FR1"]);
  5428. data.Tables.Add(dtFRClone);
  5429. DataTable dtDR = data.Tables["DR"];
  5430. DataTable dtDRClone = dtDR.Clone();
  5431. for (int i = 0; i < dtDR.Columns.Count; i++)
  5432. {
  5433. dtDRClone.Columns[i].DataType = typeof(string);
  5434. }
  5435. foreach (DataRow item in dtDR.Rows)
  5436. {
  5437. item["goodstypename2"] = item["goodstypename2"] + "缺陷数";
  5438. dtDRClone.Rows.Add(item.ItemArray);
  5439. }
  5440. // 增加大小件缺陷率(%) modify by chenxy 2018-05-03 begin
  5441. //DataRow drDR = dtDRClone.NewRow();
  5442. //drDR["goodstypename2"] = "缺陷率(%)";
  5443. //foreach (DataRow row in data.Tables["DR2"].Rows)
  5444. //{
  5445. // string tid = row["tdfid"].ToString();
  5446. // string defectRate = (row["DefectRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["DefectRate"]).ToString("#,##0.00%"));
  5447. // drDR[tid] = defectRate;
  5448. //}
  5449. //dtDRClone.Rows.Add(drDR);
  5450. Dictionary<string, DataRow> drDRs = new Dictionary<string, DataRow>();
  5451. foreach (DataRow row in data.Tables["DR2"].Rows)
  5452. {
  5453. string tcode = row["goodstypecode2"].ToString();
  5454. DataRow drDR = null;
  5455. if (drDRs.ContainsKey(tcode))
  5456. {
  5457. drDR = drDRs[tcode];
  5458. }
  5459. else
  5460. {
  5461. drDR = dtDRClone.NewRow();
  5462. drDRs.Add(tcode, drDR);
  5463. drDR["goodstypename2"] = row["goodstypeName2"] + "缺陷率(%)";
  5464. }
  5465. string tid = row["tdfid"].ToString();
  5466. string defectRate = (row["DefectRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["DefectRate"]).ToString("#,##0.00%"));
  5467. drDR[tid] = defectRate;
  5468. }
  5469. foreach (DataRow item in drDRs.Values)
  5470. {
  5471. dtDRClone.Rows.Add(item);
  5472. }
  5473. // 增加大小件成品率(%) modify by chenxy 2018-05-03 end
  5474. data.Tables.Remove(dtDR);
  5475. data.Tables.Remove(data.Tables["DR2"]);
  5476. data.Tables.Add(dtDRClone);
  5477. conn.Commit();
  5478. sre.Data = data;
  5479. return sre;
  5480. }
  5481. catch (Exception ex)
  5482. {
  5483. throw ex;
  5484. }
  5485. finally
  5486. {
  5487. if (conn != null &&
  5488. conn.ConnState == ConnectionState.Open)
  5489. {
  5490. conn.Disconnect();
  5491. }
  5492. }
  5493. }
  5494. /// <summary>
  5495. /// 取得RPT040110画面(产成品逐日出窑数值分析表)的查询数据
  5496. /// </summary>
  5497. /// <param name="user">登录用户信息</param>
  5498. /// <param name="se">查询条件</param>
  5499. /// <returns>查询结果</returns>
  5500. public static ServiceResultEntity GetRPT040110SData(SUserInfo user, RPT040110_SE se)
  5501. {
  5502. IDBTransaction conn = null;
  5503. try
  5504. {
  5505. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  5506. conn.Connect();
  5507. OracleParameter[] parameters = new OracleParameter[]
  5508. {
  5509. new OracleParameter("in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  5510. new OracleParameter("in_DateBegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  5511. new OracleParameter("in_DateEnd", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  5512. new OracleParameter("in_OutKilnProcedureID", OracleDbType.Int32, se.RptSProcedureID , ParameterDirection.Input),
  5513. new OracleParameter("in_KilnID", OracleDbType.Int32, se.KilnID , ParameterDirection.Input),
  5514. new OracleParameter("out_data1", OracleDbType.RefCursor, null , ParameterDirection.Output),
  5515. };
  5516. DataSet data = null;
  5517. if (se.IsShowG)
  5518. {
  5519. data = conn.ExecStoredProcedure("PRO_RPT_OverallQualityDetail_G", parameters);
  5520. }
  5521. else
  5522. {
  5523. data = conn.ExecStoredProcedure("PRO_RPT_OverallQualityDetail", parameters);
  5524. }
  5525. ServiceResultEntity sre = new ServiceResultEntity();
  5526. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  5527. {
  5528. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5529. return sre;
  5530. }
  5531. conn.Commit();
  5532. sre.Data = data;
  5533. return sre;
  5534. }
  5535. catch (Exception ex)
  5536. {
  5537. throw ex;
  5538. }
  5539. finally
  5540. {
  5541. if (conn != null &&
  5542. conn.ConnState == ConnectionState.Open)
  5543. {
  5544. conn.Disconnect();
  5545. }
  5546. }
  5547. }
  5548. #endregion 分析报表
  5549. #region 汇总报表
  5550. /// <summary>
  5551. /// 取得RPT030101_1画面(产品产量汇总表)的汇总信息查询数据
  5552. /// </summary>
  5553. /// <param name="user">登录用户信息</param>
  5554. /// <param name="se">查询条件</param>
  5555. /// <returns>查询结果</returns>
  5556. public static ServiceResultEntity GetRPT030101SData(SUserInfo user, RPT030101_SE se)
  5557. {
  5558. IDBConnection conn = null;
  5559. try
  5560. {
  5561. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  5562. List<OracleParameter> parameters = new List<OracleParameter>();
  5563. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030101SSQL(user, se, ref parameters));
  5564. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  5565. ServiceResultEntity sre = new ServiceResultEntity();
  5566. if (data == null || data.Rows.Count == 0)
  5567. {
  5568. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5569. return sre;
  5570. }
  5571. sre.Data = new DataSet();
  5572. sre.Data.Tables.Add(data);
  5573. return sre;
  5574. }
  5575. catch (Exception ex)
  5576. {
  5577. throw ex;
  5578. }
  5579. finally
  5580. {
  5581. if (conn != null &&
  5582. conn.ConnState == ConnectionState.Open)
  5583. {
  5584. conn.Close();
  5585. }
  5586. }
  5587. }
  5588. /// <summary>
  5589. /// 获取RPT030101_1画面(产品产量汇总表)的汇总信息查询sql
  5590. /// </summary>
  5591. /// <returns>sql</returns>
  5592. private static string GetRPT030101SSQL(SUserInfo user, RPT030101_SE se, ref List<OracleParameter> parameters)
  5593. {
  5594. //string selSql = "";
  5595. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  5596. /*
  5597. selSql = selSql +
  5598. "select " +
  5599. " decode(t.ProductionLineName,'合计','合计',decode(t.GoodsCode,'小计','--',t.OrganizationName)) OrganizationName, " +
  5600. " decode(t.Procedureid,'--','--',decode(t.GoodsCode,'小计','--',t.ProductionLineName)) ProductionLineName, " +
  5601. " decode(t.GoodsCode,'小计','--',t.Procedureid) Procedureid, " +
  5602. " decode(t.GoodsCode,'小计','--',t.ProcedureName) ProcedureName, " +
  5603. " decode(t.GoodsCode,'小计','小计',t.GoodsTypeName) GoodsTypeName, " +
  5604. " decode(t.GoodsTypeName,'小计','--',t.GoodsId) GoodsId, " +
  5605. " decode(t.ProductionLineName,'合计','--',decode(t.GoodsId,null,'--',t.GoodsCode)) GoodsCode, " +
  5606. " decode(t.GoodsCode,'小计','--',t.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  5607. " decode(t.GoodsCode,'小计','--',t.Dictionaryvalue) Dictionaryvalue, " +
  5608. " decode(t.GoodsCode,'小计','--',g.goodsname) goodsname, " +
  5609. " decode(t.GoodsCode,'小计','--',g.GOODSMODEL) GOODSMODEL, " +
  5610. " t.产量 " +
  5611. "from " +
  5612. "( " +
  5613. " select " +
  5614. " decode(grouping(TP_MST_Organization.OrganizationName),1,'总计',TP_MST_Organization.OrganizationName) OrganizationName, " +
  5615. " decode(grouping(TP_MST_Organization.OrganizationName),1,'--', " +
  5616. " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'合计',TP_PM_ProductionData.ProductionLineName)) ProductionLineName, " +
  5617. " decode(grouping(TP_PM_ProductionData.Procedureid),1,'--',TP_PM_ProductionData.Procedureid) Procedureid, " +
  5618. " decode(grouping(TP_PM_ProductionData.ProcedureName),1,'--',TP_PM_ProductionData.ProcedureName) ProcedureName, " +
  5619. " decode(grouping(TP_MST_GOODSTYPE.GoodsTypeName),1,'--',TP_MST_GOODSTYPE.GoodsTypeName) GoodsTypeName, " +
  5620. " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'--', " +
  5621. " decode(grouping(TP_PM_ProductionData.GoodsCode),1,'小计',TP_PM_ProductionData.GoodsCode)) GoodsCode, " +
  5622. " decode(grouping(TP_PM_ProductionData.GoodsId),1,null,TP_PM_ProductionData.GoodsId) GoodsId, " +
  5623. " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  5624. " decode(grouping(TP_MST_DATADICTIONARY.DICTIONARYVALUE),1,'--',TP_MST_DATADICTIONARY.Dictionaryvalue) Dictionaryvalue, " +
  5625. " count(BarCode) as 产量 " +
  5626. " from TP_PM_ProductionData " +
  5627. " left join TP_MST_Goods on TP_MST_Goods.GoodsID=TP_PM_ProductionData.GoodsID " +
  5628. " left join TP_MST_GoodsType on TP_MST_GoodsType.GoodsTypeID=TP_MST_Goods.GoodsTypeID " +
  5629. " left join TP_MST_Organization on TP_MST_Organization.OrganizationID=TP_PM_ProductionData.OrganizationID " +
  5630. " left join TP_MST_DATADICTIONARY on TP_MST_DATADICTIONARY.DICTIONARYID=TP_MST_Goods.GLAZETYPEID " +
  5631. " Where 1=1 and TP_PM_ProductionData.ValueFlag = 1 " +
  5632. // 公坯、干补不算交坯工序的质量。
  5633. (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" : "") +
  5634. " and TP_PM_ProductionData.AccountID=:AccountID ";
  5635. if (!string.IsNullOrEmpty(se.GoodsIDS))
  5636. {
  5637. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  5638. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  5639. }
  5640. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  5641. {
  5642. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
  5643. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPEcode,:GoodsTypeIDS)=1 ";
  5644. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  5645. }
  5646. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  5647. {
  5648. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  5649. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  5650. }
  5651. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  5652. {
  5653. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_ProductionData.ProcedureId||',')>0 ";
  5654. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  5655. }
  5656. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  5657. {
  5658. selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||TP_MST_Organization.OrganizationId||',')>0 ";
  5659. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  5660. }
  5661. if (se.AccountDateStart.HasValue)
  5662. {
  5663. selSql = selSql + " AND TP_PM_ProductionData.CREATETIME >= :AccountDateStart ";
  5664. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  5665. }
  5666. if (se.AccountDateEnd.HasValue)
  5667. {
  5668. selSql = selSql + " AND TP_PM_ProductionData.CREATETIME <= :AccountDateEnd ";
  5669. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  5670. }
  5671. selSql = selSql +
  5672. "group by " +
  5673. " rollup(TP_MST_Organization.OrganizationName, " +
  5674. " TP_PM_ProductionData.ProductionLineName, " +
  5675. " TP_PM_ProductionData.Procedureid, " +
  5676. " TP_PM_ProductionData.ProcedureName, " +
  5677. " TP_MST_GOODSTYPE.GoodsTypeName, " +
  5678. " TP_PM_ProductionData.GoodsCode, " +
  5679. " TP_PM_ProductionData.GoodsId, " +
  5680. " TP_MST_Goods.GOODSSPECIFICATION, " +
  5681. " TP_MST_DATADICTIONARY.Dictionaryvalue) " +
  5682. " order by " +
  5683. " TP_MST_Organization.OrganizationName, " +
  5684. " TP_PM_ProductionData.ProductionLineName, " +
  5685. " TP_PM_ProductionData.Procedureid, " +
  5686. " TP_PM_ProductionData.ProcedureName, " +
  5687. " TP_MST_GOODSTYPE.GoodsTypeName " +
  5688. ") t \n" +
  5689. // 增加 产品型号
  5690. "left join tp_mst_goods g on g.goodsid = t.goodsid \n" +
  5691. "where 1=1 " +
  5692. "and (t.DICTIONARYVALUE!='--' ) " +
  5693. "or (t.GoodsTypeName='--' and t.ProductionLineName='合计') " +
  5694. "or (t.GoodsTypeName='--' and t.OrganizationName='总计') " +
  5695. "or (t.GoodsCode='小计' and t.GoodsTypeName!='--')";
  5696. */
  5697. string selSql = @"
  5698. select t.gid
  5699. ,decode(t.gid
  5700. ,3
  5701. ,'--'
  5702. ,7
  5703. ,'--'
  5704. ,15
  5705. ,'--'
  5706. ,t.BUILDINGNO ) BUILDINGNO
  5707. ,decode(t.gid, 15, '总计', t.ProductionLineName) ProductionLineName
  5708. ,t.OrganizationID
  5709. --,t.OrganizationCode
  5710. ,decode(t.gid
  5711. ,7
  5712. ,'合计[' || t.OrganizationName || ']'
  5713. ,15
  5714. ,'--'
  5715. ,t.OrganizationName) OrganizationName
  5716. ,t.Procedureid
  5717. ,decode(t.gid
  5718. ,3
  5719. ,'小计[' || t.ProcedureName || ']'
  5720. ,0
  5721. ,t.ProcedureName
  5722. ,1
  5723. ,t.ProcedureName
  5724. ,'--') ProcedureName
  5725. ,t.GoodsTypeID
  5726. ,decode(t.gid
  5727. ,1
  5728. ,'小计[' || t.GoodsTypeName || ']'
  5729. ,0
  5730. ,t.GoodsTypeName
  5731. ,'--') GoodsTypeName
  5732. --,t.GoodsId
  5733. ,decode(t.gid, 0, to_char(t.GoodsId), '--') GoodsId
  5734. ,decode(t.gid, 0, t.GoodsCode, '--') GoodsCode
  5735. ,decode(t.gid, 0, t.GOODSSPECIFICATION, '--') GOODSSPECIFICATION
  5736. ,decode(t.gid, 0, t.Dictionaryvalue, '--') Dictionaryvalue
  5737. ,t.pfcount as 产量
  5738. from (select grouping_id(org.OrganizationID
  5739. ,p.Procedureid
  5740. ,gt.goodstypeid
  5741. ,g.GoodsId
  5742. ,gl.BUILDINGNO) as gid
  5743. ,pd.ProductionLineName
  5744. ,org.OrganizationID
  5745. --,org.OrganizationCode
  5746. ,org.OrganizationName
  5747. ,p.Procedureid
  5748. ,p.ProcedureName
  5749. ,gl.BUILDINGNO
  5750. ,gt.GoodsTypeID
  5751. ,gt.GoodsTypeName
  5752. ,g.GoodsId
  5753. ,g.GoodsCode
  5754. ,g.GOODSSPECIFICATION
  5755. ,d.Dictionaryvalue
  5756. ,count(PD.BarCode) as pfcount
  5757. from TP_PM_ProductionData pd
  5758. LEFT JOIN Tp_Pm_Groutingdailydetail GP on GP.BARCODE=pd.BARCODE
  5759. LEFT JOIN TP_PC_GROUTINGLINE gl on gl.GROUTINGLINEID=pd.GROUTINGLINEID
  5760. inner join tp_pc_Procedure p on p.Procedureid = pd.Procedureid
  5761. inner join TP_MST_Goods g on g.GoodsID = pd.GoodsID
  5762. inner join TP_MST_GoodsType gt on gt.GoodsTypeID = g.GoodsTypeID
  5763. inner join TP_MST_Organization org on org.OrganizationID = pd.OrganizationID
  5764. inner join TP_MST_DATADICTIONARY d on d.DICTIONARYID = GP.Glazetypeid
  5765. where pd.ValueFlag = '1'
  5766. and pd.AccountID = :AccountID ";
  5767. // 公坯、干补不算交坯工序的质量。
  5768. if (se.ProductionFlag == "1")
  5769. {
  5770. selSql += " and ((pd.modeltype <> 5) or (pd.modeltype = 5 and (pd.IsPublicBody = '0' or pd.SpecialRepairFlag = '0'))) \n";
  5771. }
  5772. if (!string.IsNullOrEmpty(se.GoodsIDS))
  5773. {
  5774. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||g.GoodsId||',')>0 ";
  5775. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  5776. }
  5777. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  5778. {
  5779. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
  5780. selSql = selSql + " AND instr(gt.GOODSTYPEcode,:GoodsTypeIDS)=1 ";
  5781. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  5782. }
  5783. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  5784. {
  5785. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pd.ProductionLineId||',')>0 ";
  5786. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  5787. }
  5788. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  5789. {
  5790. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||p.ProcedureId||',')>0 ";
  5791. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  5792. }
  5793. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  5794. {
  5795. selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||org.OrganizationId||',')>0 ";
  5796. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  5797. }
  5798. if (se.AccountDateStart.HasValue)
  5799. {
  5800. selSql = selSql + " AND pd.CREATETIME >= :AccountDateStart ";
  5801. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  5802. }
  5803. if (se.AccountDateEnd.HasValue)
  5804. {
  5805. selSql = selSql + " AND pd.CREATETIME <= :AccountDateEnd ";
  5806. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  5807. }
  5808. if (!string.IsNullOrEmpty(se.Building))
  5809. {
  5810. selSql = selSql + " AND gl.BUILDINGNO =:Building";
  5811. parameters.Add(new OracleParameter(":Building", OracleDbType.NVarchar2, se.Building, ParameterDirection.Input));
  5812. }
  5813. selSql += @" group by grouping sets((pd.ProductionLineName, org.OrganizationID, org.organizationcode, org.OrganizationName, p.Procedureid, p.ProcedureName,
  5814. p.displayno, gt.GoodsTypeID, gt.goodstypecode, gt.GoodsTypeName,gl.BUILDINGNO, g.GoodsId, g.GoodsCode, g.GOODSSPECIFICATION, d.Dictionaryvalue),
  5815. (pd.ProductionLineName, org.OrganizationID, org.organizationcode, org.OrganizationName, p.Procedureid, p.ProcedureName, p.displayno, gt.GoodsTypeID, gt.goodstypecode, gt.GoodsTypeName),
  5816. (pd.ProductionLineName, org.OrganizationID, org.organizationcode, org.OrganizationName, p.Procedureid, p.ProcedureName, p.displayno),
  5817. (pd.ProductionLineName, org.OrganizationID, org.organizationcode, org.OrganizationName),())
  5818. order by org.organizationcode
  5819. ,p.displayno
  5820. ,gt.goodstypecode
  5821. ,g.goodscode) t ";
  5822. return selSql;
  5823. }
  5824. /// <summary>
  5825. /// 取得RPT030101_1画面(产品产量汇总表)的明细信息查询数据
  5826. /// </summary>
  5827. /// <param name="user">登录用户信息</param>
  5828. /// <param name="se">查询条件</param>
  5829. /// <returns>查询结果</returns>
  5830. public static ServiceResultEntity GetRPT030101IData(SUserInfo user, RPT030101_SE se)
  5831. {
  5832. IDBConnection conn = null;
  5833. try
  5834. {
  5835. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  5836. List<OracleParameter> parameters = new List<OracleParameter>();
  5837. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030101ISQL(user, se, ref parameters));
  5838. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  5839. ServiceResultEntity sre = new ServiceResultEntity();
  5840. if (data == null || data.Rows.Count == 0)
  5841. {
  5842. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5843. return sre;
  5844. }
  5845. sre.Data = new DataSet();
  5846. sre.Data.Tables.Add(data);
  5847. return sre;
  5848. }
  5849. catch (Exception ex)
  5850. {
  5851. throw ex;
  5852. }
  5853. finally
  5854. {
  5855. if (conn != null &&
  5856. conn.ConnState == ConnectionState.Open)
  5857. {
  5858. conn.Close();
  5859. }
  5860. }
  5861. }
  5862. /// <summary>
  5863. /// 获取RPT030101_1画面(产品产量汇总表)的明细信息查询sql
  5864. /// </summary>
  5865. /// <returns>sql</returns>
  5866. private static string GetRPT030101ISQL(SUserInfo user, RPT030101_SE se, ref List<OracleParameter> parameters)
  5867. {
  5868. //string selSql = "";
  5869. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  5870. /*
  5871. selSql = selSql +
  5872. "select " +
  5873. "decode(ProductionLineName,'合计','合计',decode(temp.BarCode,'小计','--',OrganizationName)) OrganizationName, " +
  5874. "decode(ProcedureName,'--','--',decode(temp.barcode,'小计','--',temp.ProductionLineName)) ProductionLineName, " +
  5875. "decode(temp.BarCode,'小计','--',temp.ProcedureName) ProcedureName, " +
  5876. "decode(temp.BarCode,'小计','--',temp.GoodsTypeName) GoodsTypeName, " +
  5877. "decode(temp.BarCode,'小计','小计',temp.GoodsCode) GoodsCode, " +
  5878. "decode(ProductionLineName,'合计','--',decode(temp.usercode,'--','--',temp.Barcode)) BarCode, " +
  5879. "decode(temp.UserCode,'小计','--',temp.UserCode) UserCode, " +
  5880. "decode(GOODSSPECIFICATION,'小计','--',GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  5881. "decode(DICTIONARYVALUE,'小计','--',Dictionaryvalue) Dictionaryvalue, " +
  5882. "产量, " +
  5883. "replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName " +
  5884. "from " +
  5885. "( " +
  5886. " select " +
  5887. " decode(grouping(TP_MST_Organization.OrganizationName),1,'总计',TP_MST_Organization.OrganizationName) OrganizationName, " +
  5888. " decode(grouping(TP_MST_Organization.OrganizationName),1,'--', " +
  5889. " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'合计',TP_PM_ProductionData.ProductionLineName)) ProductionLineName, " +
  5890. " decode(grouping(TP_PM_ProductionData.ProcedureName),1,'--',TP_PM_ProductionData.ProcedureName) ProcedureName, " +
  5891. " decode(grouping(TP_MST_GOODSTYPE.GoodsTypeName),1,'--',TP_MST_GOODSTYPE.GoodsTypeName) GoodsTypeName, " +
  5892. " decode(grouping(TP_PM_ProductionData.GoodsCode),1,'--',TP_PM_ProductionData.GoodsCode) GoodsCode, " +
  5893. " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'--', " +
  5894. " decode(grouping(TP_PM_ProductionData.BarCode),1,'小计',TP_PM_ProductionData.BarCode)) BarCode, " +
  5895. " decode(grouping(TP_PM_ProductionData.UserCode),1,'--',TP_PM_ProductionData.UserCode) UserCode, " +
  5896. " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  5897. " decode(grouping(TP_MST_DATADICTIONARY.Dictionaryvalue),1,'--',TP_MST_DATADICTIONARY.Dictionaryvalue) Dictionaryvalue, " +
  5898. " count(BarCode) as 产量 " +
  5899. " from TP_PM_ProductionData " +
  5900. " left join TP_MST_Goods on TP_MST_Goods.GoodsID=TP_PM_ProductionData.GoodsID " +
  5901. " left join TP_MST_GoodsType on TP_MST_GoodsType.GoodsTypeID=TP_MST_Goods.GoodsTypeID " +
  5902. " left join TP_MST_Organization on TP_MST_Organization.OrganizationID=TP_PM_ProductionData.OrganizationID " +
  5903. " left join TP_MST_DATADICTIONARY on TP_MST_DATADICTIONARY.DICTIONARYID=TP_MST_Goods.GLAZETYPEID " +
  5904. " Where 1=1 " +
  5905. " and TP_PM_ProductionData.ValueFlag = 1 " +
  5906. // 公坯、干补不算交坯工序的质量。
  5907. " 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" +
  5908. " and TP_PM_ProductionData.AccountID=:AccountID ";
  5909. if (!string.IsNullOrEmpty(se.GoodsIDS))
  5910. {
  5911. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  5912. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  5913. }
  5914. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  5915. {
  5916. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
  5917. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)>0 ";
  5918. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  5919. }
  5920. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  5921. {
  5922. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  5923. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  5924. }
  5925. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  5926. {
  5927. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_ProductionData.ProcedureId||',')>0 ";
  5928. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  5929. }
  5930. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  5931. {
  5932. selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||TP_MST_Organization.OrganizationId||',')>0 ";
  5933. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  5934. }
  5935. if (se.AccountDateStart.HasValue)
  5936. {
  5937. selSql = selSql + " AND TP_PM_ProductionData.AccountDate >= :AccountDateStart ";
  5938. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  5939. }
  5940. if (se.AccountDateEnd.HasValue)
  5941. {
  5942. selSql = selSql + " AND TP_PM_ProductionData.AccountDate <= :AccountDateEnd ";
  5943. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  5944. }
  5945. selSql = selSql +
  5946. "group by " +
  5947. " rollup(TP_MST_Organization.OrganizationName, " +
  5948. " TP_PM_ProductionData.ProductionLineName, " +
  5949. " TP_PM_ProductionData.ProcedureName, " +
  5950. " TP_MST_GOODSTYPE.GoodsTypeName, " +
  5951. " TP_PM_ProductionData.GoodsCode, " +
  5952. " TP_PM_ProductionData.BarCode, " +
  5953. " TP_PM_ProductionData.UserCode, " +
  5954. " TP_MST_Goods.GOODSSPECIFICATION, " +
  5955. " TP_MST_DATADICTIONARY.Dictionaryvalue" +
  5956. " ) " +
  5957. " order by " +
  5958. " TP_MST_Organization.OrganizationName, " +
  5959. " TP_PM_ProductionData.ProductionLineName, " +
  5960. " TP_PM_ProductionData.ProcedureName, " +
  5961. " TP_MST_GOODSTYPE.GoodsTypeName " +
  5962. ") temp inner join TP_PM_GroutingDailyDetail on temp.barcode=TP_PM_GroutingDailyDetail.barcode " +
  5963. " inner join tp_mst_logo on TP_PM_GroutingDailyDetail.logoid=tp_mst_logo.logoid " +
  5964. "where 1=1 " +
  5965. "and (temp.DICTIONARYVALUE!='--') " +
  5966. "or (temp.GoodsTypeName='--' and temp.ProductionLineName='合计') " +
  5967. "or (temp.GoodsTypeName='--' and temp.OrganizationName='总计') " +
  5968. "or (temp.BarCode='小计' and temp.GoodsCode!='--')";
  5969. */
  5970. string selSql = @"SELECT
  5971. TP_PC_GROUTINGLINE.BUILDINGNO,
  5972. TP_MST_Organization.OrganizationName,
  5973. TP_PM_ProductionData.ProductionLineName,
  5974. TP_PM_ProductionData.ProcedureName,
  5975. TP_MST_GOODSTYPE.GoodsTypeName,
  5976. TP_PM_ProductionData.GoodsCode,
  5977. TP_MST_Goods.GoodsName,
  5978. TP_MST_Goods.GoodsModel,
  5979. TP_PM_ProductionData.BarCode,
  5980. TP_PM_ProductionData.UserCode,
  5981. TP_MST_Goods.GOODSSPECIFICATION,
  5982. TP_MST_DATADICTIONARY.Dictionaryvalue,
  5983. TP_PM_ProductionData.CREATETIME,
  5984. TP_PM_ProductionData.KILNcarCODE,
  5985. TP_PM_ProductionData.KILNCODE,
  5986. cu.usercode createusercode,
  5987. cu.username CreateUserName,
  5988. gdd.glazingroom,
  5989. decode( tp_mst_logo.logoid, NULL, '', TP_MST_Logo.Logoname || '[' || TP_MST_Logo.Logocode || ']' ) AS LogoCodeName
  5990. FROM
  5991. TP_PM_ProductionData
  5992. LEFT JOIN Tp_Pm_Groutingdailydetail GP ON GP.BarCode =TP_PM_ProductionData.BarCode
  5993. LEFT JOIN TP_MST_Goods ON TP_MST_Goods.GoodsID = TP_PM_ProductionData.GoodsID
  5994. LEFT JOIN TP_MST_GoodsType ON TP_MST_GoodsType.GoodsTypeID = TP_MST_Goods.GoodsTypeID
  5995. LEFT JOIN TP_MST_Organization ON TP_MST_Organization.OrganizationID = TP_PM_ProductionData.OrganizationID
  5996. LEFT JOIN TP_MST_DATADICTIONARY ON TP_MST_DATADICTIONARY.DICTIONARYID = GP.Glazetypeid
  5997. LEFT JOIN tp_mst_user cu ON TP_PM_ProductionData.createuserid = cu.userid
  5998. LEFT JOIN TP_PM_GroutingDailyDetail gdd ON gdd.Groutingdailydetailid = TP_PM_ProductionData.Groutingdailydetailid
  5999. LEFT JOIN tp_mst_logo ON gdd.logoid = tp_mst_logo.logoid
  6000. LEFT JOIN TP_PC_GROUTINGLINE on TP_PC_GROUTINGLINE.GROUTINGLINEID=TP_PM_ProductionData.GROUTINGLINEID
  6001. WHERE TP_PM_ProductionData.ValueFlag = '1'
  6002. AND ( ( TP_PM_ProductionData.modeltype <> 5 )
  6003. OR ( TP_PM_ProductionData.modeltype = 5 AND TP_PM_ProductionData.IsPublicBody = '0' AND TP_PM_ProductionData.SpecialRepairFlag = '0' ) )
  6004. AND TP_PM_ProductionData.AccountID =:AccountID ";
  6005. if (!string.IsNullOrEmpty(se.GoodsIDS))
  6006. {
  6007. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  6008. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  6009. }
  6010. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  6011. {
  6012. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
  6013. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)>0 ";
  6014. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  6015. }
  6016. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  6017. {
  6018. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  6019. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  6020. }
  6021. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  6022. {
  6023. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_ProductionData.ProcedureId||',')>0 ";
  6024. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  6025. }
  6026. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  6027. {
  6028. selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||TP_MST_Organization.OrganizationId||',')>0 ";
  6029. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  6030. }
  6031. if (se.AccountDateStart.HasValue)
  6032. {
  6033. selSql = selSql + " AND TP_PM_ProductionData.CREATETIME >= :AccountDateStart ";
  6034. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  6035. }
  6036. if (se.AccountDateEnd.HasValue)
  6037. {
  6038. selSql = selSql + " AND TP_PM_ProductionData.CREATETIME <= :AccountDateEnd ";
  6039. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  6040. }
  6041. if (!string.IsNullOrEmpty(se.Building))
  6042. {
  6043. selSql = selSql + " AND TP_PC_GROUTINGLINE.BUILDINGNO = :Building";
  6044. parameters.Add(new OracleParameter(":Building", OracleDbType.NVarchar2, se.Building, ParameterDirection.Input));
  6045. }
  6046. return selSql;
  6047. }
  6048. /// <summary>
  6049. /// 取得RPT030102_1画面(产品损坯汇总表)的汇总信息查询数据
  6050. /// </summary>
  6051. /// <param name="user">登录用户信息</param>
  6052. /// <param name="se">查询条件</param>
  6053. /// <returns>查询结果</returns>
  6054. public static ServiceResultEntity GetRPT030102SData(SUserInfo user, RPT030102_SE se)
  6055. {
  6056. IDBConnection conn = null;
  6057. try
  6058. {
  6059. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6060. List<OracleParameter> parameters = new List<OracleParameter>();
  6061. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030102SSQL(user, se, ref parameters));
  6062. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  6063. ServiceResultEntity sre = new ServiceResultEntity();
  6064. if (data == null || data.Rows.Count == 0)
  6065. {
  6066. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6067. return sre;
  6068. }
  6069. sre.Data = new DataSet();
  6070. sre.Data.Tables.Add(data);
  6071. return sre;
  6072. }
  6073. catch (Exception ex)
  6074. {
  6075. throw ex;
  6076. }
  6077. finally
  6078. {
  6079. if (conn != null &&
  6080. conn.ConnState == ConnectionState.Open)
  6081. {
  6082. conn.Close();
  6083. }
  6084. }
  6085. }
  6086. /// <summary>
  6087. /// 获取RPT030102_1画面(产品损坯汇总表)的汇总信息查询sql
  6088. /// </summary>
  6089. /// <returns>sql</returns>
  6090. private static string GetRPT030102SSQL(SUserInfo user, RPT030102_SE se, ref List<OracleParameter> parameters)
  6091. {
  6092. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6093. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  6094. string sqlString = "SELECT decode(ts.gid,\n" +
  6095. " 7,\n" +
  6096. " '总计',\n" +
  6097. " 3,\n" +
  6098. " '合计【' || ts.zrprocedurename || '】',\n" +
  6099. " 0,\n" +
  6100. " ts.zrprocedurename,\n" +
  6101. " '--') zrprocedurename\n" +
  6102. " ,decode(ts.gid,\n" +
  6103. " 1,\n" +
  6104. " '小计【' || ts.goodstypename2 || '】',\n" +
  6105. " 0,\n" +
  6106. " ts.goodstypename2,\n" +
  6107. " '--') goodstypename2\n" +
  6108. " ,decode(ts.gid, 0, ts.zrusercode, '--') zrusercode\n" +
  6109. " ,decode(ts.gid, 0, ts.goodscode, '--') goodscode\n" +
  6110. " ,decode(ts.gid, 0, ts.GOODSMODEL, '--') GOODSMODEL\n" +
  6111. " ,ts.productionlineid\n" +
  6112. " ,ts.zrprocedureid\n" +
  6113. " ,ts.goodstypecode2\n" +
  6114. " ,ts.zruserid\n" +
  6115. " ,ts.goodsid\n" +
  6116. " ,ts.barcount\n" +
  6117. " FROM (SELECT grouping_id(t.zrprocedureid, t.goodstypecode2, t.zruserid) gid\n" +
  6118. " ,t.productionlineid\n" +
  6119. " ,t.productionlinename\n" +
  6120. " ,t.displayno\n" +
  6121. " ,t.zrprocedureid\n" +
  6122. " ,t.zrprocedurename\n" +
  6123. " ,t.goodstypecode2\n" +
  6124. " ,t.goodstypename2\n" +
  6125. " ,t.zruserid\n" +
  6126. " ,t.zrusercode\n" +
  6127. " ,t.goodsid\n" +
  6128. " ,t.goodscode\n" +
  6129. " ,t.GOODSMODEL\n" +
  6130. " ,COUNT(t.barcode) barcount\n" +
  6131. " FROM (SELECT sp.productionlineid\n" +
  6132. " ,pline.productionlinename\n" +
  6133. " ,nvl(zp.displayno, -1) displayno\n" +
  6134. " ,zp.procedureid zrprocedureid\n" +
  6135. " ,zp.procedurename zrprocedurename\n" +
  6136. " ,sr.userid zruserid\n" +
  6137. " ,sr.usercode zrusercode\n" +
  6138. " ,gt2.goodstypecode goodstypecode2\n" +
  6139. " ,gt2.goodstypename goodstypename2\n" +
  6140. " ,g.goodsid\n" +
  6141. " ,g.goodscode\n" +
  6142. " ,g.GOODSMODEL\n" +
  6143. " ,sp.barcode\n" +
  6144. " FROM tp_pm_scrapproduct sp\n" +
  6145. " LEFT JOIN TP_PM_ResponProcedure rp\n" +
  6146. " ON rp.scrapproductid = sp.scrapproductid\n" +
  6147. " LEFT JOIN (SELECT DISTINCT t.ScrapProductID\n" +
  6148. " ,t.ResponProcedureID\n" +
  6149. " ,t.userid\n" +
  6150. " ,t.usercode\n" +
  6151. " FROM TP_PM_ScrapResponsible t) sr\n" +
  6152. " ON sr.scrapproductid = sp.scrapproductid\n" +
  6153. // wangx 2016-06-20
  6154. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  6155. " ON rp.barcode = gdd.barcode\n" +
  6156. // wangx 2016-06-20 end
  6157. " LEFT JOIN tp_pc_productionline pline\n" +
  6158. " ON pline.productionlineid = sp.productionlineid\n" +
  6159. " LEFT JOIN tp_pc_procedure zp\n" +
  6160. " ON zp.procedureid = rp.procedureid\n" +
  6161. " LEFT JOIN tp_mst_user cu\n" +
  6162. " ON cu.userid = sp.createuserid\n" +
  6163. " LEFT JOIN tp_mst_user au\n" +
  6164. " ON au.userid = sp.auditor\n" +
  6165. " LEFT JOIN tp_mst_goods g\n" +
  6166. " ON g.goodsid = sp.goodsid\n" +
  6167. " LEFT JOIN tp_mst_goodstype gt\n" +
  6168. " ON gt.goodstypeid = g.goodstypeid\n" +
  6169. " LEFT JOIN tp_mst_goodstype gt2\n" +
  6170. " ON gt2.accountid = gt.accountid\n" +
  6171. " AND gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  6172. " WHERE sp.valueflag = '1'\n" +
  6173. " AND sp.AuditStatus = '1'\n" +
  6174. // 生产线
  6175. //" 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))" +
  6176. // 完成工序
  6177. //" 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))" +
  6178. // 责任工序
  6179. //" 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)))" +
  6180. " AND sp.accountid = :AccountID\n" +
  6181. (se.SpecialRepairFlag ? " AND sp.GoodsLevelTypeID in (8,9) -- 8损坯、9干补\n" : " AND sp.GoodsLevelTypeID = 8 -- 8损坯、9干补\n") +
  6182. (se.ReFireFlag ? " " : " AND sp.IsReFire <> '6'\n") +
  6183. " AND sp.ScrapType = '0'\n" +
  6184. " AND (:ProductionLineID IS NULL OR\n" +
  6185. " sp.ProductionLineID = :ProductionLineID)\n" +
  6186. " AND (:GoodsTypeCode IS NULL OR\n" +
  6187. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  6188. " AND (:GoodsCode IS NULL OR\n" +
  6189. " instr(g.GoodsCode, :GoodsCode) > 0)\n" +
  6190. " AND (:ProcedureIDS IS NULL OR\n" +
  6191. " instr(:ProcedureIDS, ',' || sp.ProcedureID || ',') > 0)\n" +
  6192. " AND (:ResponProcedureIDS IS NULL OR\n" +
  6193. " instr(:ResponProcedureIDS,\n" +
  6194. " ',' || rp.ProcedureID || ',') > 0)\n" +
  6195. " AND (:ResponUserIDS IS NULL OR\n" +
  6196. " instr(:ResponUserIDS, ',' || sr.userid || ',') > 0)\n" +
  6197. // 损坯时间
  6198. " AND (:ScrapDateStart IS NULL OR\n" +
  6199. " sp.CreateTime >= :ScrapDateStart)\n" +
  6200. " AND (:ScrapDateEnd IS NULL OR\n" +
  6201. " sp.CreateTime <= :ScrapDateEnd)\n" +
  6202. // 审核时间
  6203. " AND (:AuditDateStart IS NULL OR\n" +
  6204. " sp.AuditDate >= :AuditDateStart)\n" +
  6205. " AND (:AuditDateEnd IS NULL OR\n" +
  6206. " sp.AuditDate <= :AuditDateEnd)\n" +
  6207. // 完成时间
  6208. " AND (:CTimeStart IS NULL OR\n" +
  6209. " sp.CreateTime >= :CTimeStart)\n" +
  6210. " AND (:CTimeEnd IS NULL OR\n" +
  6211. " sp.CreateTime <= :CTimeEnd)\n" +
  6212. // 交坯时间
  6213. " AND (:DTimeStart IS NULL OR\n" +
  6214. " gdd.DeliverTime >= :DTimeStart)\n" +
  6215. " AND (:DTimeEnd IS NULL OR\n" +
  6216. " gdd.DeliverTime <= :DTimeEnd)\n" +
  6217. // 注浆时间
  6218. " AND (:GTimeStart IS NULL OR\n" +
  6219. " gdd.GroutingDate >= :GTimeStart)\n" +
  6220. " AND (:GTimeEnd IS NULL OR\n" +
  6221. " gdd.GroutingDate <= :GTimeEnd)\n" +
  6222. " AND (:CreatUser IS NULL OR\n" +
  6223. " instr(cu.UserCode, :CreatUser) > 0)\n" +
  6224. " AND (:AuditUser IS NULL OR\n" +
  6225. " instr(au.UserCode, :AuditUser) > 0)) t\n" +
  6226. " 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" +
  6227. " ORDER BY t.displayno, t.goodstypecode2, t.zrusercode, t.goodscode) ts";
  6228. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  6229. if (string.IsNullOrEmpty(se.ProcedureIDS))
  6230. {
  6231. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  6232. }
  6233. else
  6234. {
  6235. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  6236. }
  6237. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  6238. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  6239. if (string.IsNullOrEmpty(se.ResponProcedureIDS))
  6240. {
  6241. parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  6242. }
  6243. else
  6244. {
  6245. parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, "," + se.ResponProcedureIDS + ",", ParameterDirection.Input));
  6246. }
  6247. if (string.IsNullOrEmpty(se.ResponUserIDS))
  6248. {
  6249. parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  6250. }
  6251. else
  6252. {
  6253. parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, "," + se.ResponUserIDS + ",", ParameterDirection.Input));
  6254. }
  6255. parameters.Add(new OracleParameter(":CreatUser", OracleDbType.Varchar2, se.CreatUser, ParameterDirection.Input));
  6256. parameters.Add(new OracleParameter(":AuditUser", OracleDbType.Varchar2, se.AuditUser, ParameterDirection.Input));
  6257. parameters.Add(new OracleParameter(":ScrapDateStart", OracleDbType.Date, se.ScrapDateStart, ParameterDirection.Input));
  6258. parameters.Add(new OracleParameter(":ScrapDateEnd", OracleDbType.Date, se.ScrapDateEnd, ParameterDirection.Input));
  6259. parameters.Add(new OracleParameter(":CTimeStart", OracleDbType.Date, se.CTimeStart, ParameterDirection.Input));
  6260. parameters.Add(new OracleParameter(":CTimeEnd", OracleDbType.Date, se.CTimeEnd, ParameterDirection.Input));
  6261. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart, ParameterDirection.Input));
  6262. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd, ParameterDirection.Input));
  6263. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart, ParameterDirection.Input));
  6264. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd, ParameterDirection.Input));
  6265. parameters.Add(new OracleParameter(":AuditDateStart", OracleDbType.Date, se.AuditTimeStart, ParameterDirection.Input));
  6266. parameters.Add(new OracleParameter(":AuditDateEnd", OracleDbType.Date, se.AuditTimeEnd, ParameterDirection.Input));
  6267. return sqlString;
  6268. }
  6269. /// <summary>
  6270. /// 取得RPT030102_1画面(产品损坯汇总表)的明细信息查询数据
  6271. /// </summary>
  6272. /// <param name="user">登录用户信息</param>
  6273. /// <param name="se">查询条件</param>
  6274. /// <returns>查询结果</returns>
  6275. public static ServiceResultEntity GetRPT030102IData(SUserInfo user, RPT030102_SE se)
  6276. {
  6277. IDBConnection conn = null;
  6278. try
  6279. {
  6280. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6281. List<OracleParameter> parameters = new List<OracleParameter>();
  6282. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030102ISQL(user, se, ref parameters));
  6283. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  6284. ServiceResultEntity sre = new ServiceResultEntity();
  6285. if (data == null || data.Rows.Count == 0)
  6286. {
  6287. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6288. return sre;
  6289. }
  6290. sre.Data = new DataSet();
  6291. sre.Data.Tables.Add(data);
  6292. return sre;
  6293. }
  6294. catch (Exception ex)
  6295. {
  6296. throw ex;
  6297. }
  6298. finally
  6299. {
  6300. if (conn != null &&
  6301. conn.ConnState == ConnectionState.Open)
  6302. {
  6303. conn.Close();
  6304. }
  6305. }
  6306. }
  6307. /// <summary>
  6308. /// 获取RPT030102_1画面(产品损坯汇总表)的明细信息查询sql
  6309. /// </summary>
  6310. /// <returns>sql</returns>
  6311. private static string GetRPT030102ISQL(SUserInfo user, RPT030102_SE se, ref List<OracleParameter> parameters)
  6312. {
  6313. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6314. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  6315. string sqlString =
  6316. "SELECT pline.productionlinename\n" +
  6317. " ,p.procedurename\n" +
  6318. " ,zp.procedurename zrprocedurename\n" +
  6319. " ,sr.usercode zrusercode\n" +
  6320. " ,sr.StaffNames zrStaffNames\n" +
  6321. " ,gt2.goodstypecode goodstypecode2\n" +
  6322. " ,gt2.goodstypename goodstypename2\n" +
  6323. " ,gt.goodstypename\n" +
  6324. " ,g.goodscode\n" +
  6325. " ,g.GOODSMODEL\n" +
  6326. " ,sp.barcode\n" +
  6327. " ,sp.createtime Scrapdate\n" +
  6328. " ,sp.Rreason\n" +
  6329. " ,sp.GroutingUserCode\n" +
  6330. " ,sp.GroutingLineCode\n" +
  6331. " ,sp.GroutingMouldCode\n" +
  6332. " ,sp.GroutingDate\n" +
  6333. " ,sp.GroutingNum\n" +
  6334. " ,cu.usercode CreateUserCode\n" +
  6335. " ,au.usercode AuditorCode\n" +
  6336. " ,sp.auditdate\n" +
  6337. " ,gdd.DeliverTime\n" +
  6338. " ,gdd.ISPUBLICBODY\n" +
  6339. " ,gdd.SPECIALREPAIRFLAG\n" +
  6340. " ,lg.logoname\n" +
  6341. " ,sp.CreateTime\n" +
  6342. " ,sp.Remarks\n" +
  6343. " FROM tp_pm_scrapproduct sp\n" +
  6344. " LEFT JOIN TP_PM_ResponProcedure rp\n" +
  6345. " ON rp.scrapproductid = sp.scrapproductid\n" +
  6346. " LEFT JOIN (SELECT DISTINCT t.ScrapProductID\n" +
  6347. " ,t.ResponProcedureID\n" +
  6348. " ,t.userid\n" +
  6349. " ,t.usercode\n" +
  6350. " ,LISTAGG(to_char(s.StaffName), ',') WITHIN GROUP(ORDER BY s.staffcode) over(partition by t.ScrapProductID) AS StaffNames\n" +
  6351. " FROM TP_PM_ScrapResponsible t\n" +
  6352. " LEFT JOIN TP_HR_Staff s \n" +
  6353. " ON s.StaffID = t.StaffID \n" +
  6354. " ) sr\n" +
  6355. " ON sr.scrapproductid = sp.scrapproductid\n" +
  6356. // wangx 2016-06-20
  6357. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  6358. " ON sp.barcode = gdd.barcode\n" +
  6359. // wangx 2016-06-20 end
  6360. " LEFT JOIN TP_mst_logo lg\n" +
  6361. " ON lg.logoid = gdd.logoid\n" +
  6362. " LEFT JOIN tp_pc_productionline pline\n" +
  6363. " ON pline.productionlineid = sp.productionlineid\n" +
  6364. " LEFT JOIN tp_pc_procedure p\n" +
  6365. " ON p.procedureid = sp.procedureid\n" +
  6366. " LEFT JOIN tp_pc_procedure zp\n" +
  6367. " ON zp.procedureid = rp.procedureid\n" +
  6368. " LEFT JOIN tp_mst_user cu\n" +
  6369. " ON cu.userid = sp.createuserid\n" +
  6370. " LEFT JOIN tp_mst_user au\n" +
  6371. " ON au.userid = sp.auditor\n" +
  6372. " LEFT JOIN tp_mst_goods g\n" +
  6373. " ON g.goodsid = sp.goodsid\n" +
  6374. " LEFT JOIN tp_mst_goodstype gt\n" +
  6375. " ON gt.goodstypeid = g.goodstypeid\n" +
  6376. " LEFT JOIN tp_mst_goodstype gt2\n" +
  6377. " ON gt2.accountid = gt.accountid\n" +
  6378. " AND gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  6379. " WHERE sp.valueflag = '1'\n" +
  6380. " AND sp.AuditStatus = '1'\n" +
  6381. " AND sp.accountid = :accountid\n" +
  6382. // 生产线
  6383. //" 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))" +
  6384. // 完成工序
  6385. //" 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))" +
  6386. // 责任工序
  6387. //" 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)))" +
  6388. //" AND sp.GoodsLevelTypeID = 8 -- 8损坯、9干补\n" +
  6389. (se.SpecialRepairFlag ? " AND sp.GoodsLevelTypeID in (8,9) -- 8损坯、9干补\n" : " AND sp.GoodsLevelTypeID = 8 -- 8损坯、9干补\n") +
  6390. (se.ReFireFlag ? " " : " AND sp.IsReFire <> '6'\n") +
  6391. " AND sp.ScrapType = '0'\n" +
  6392. " AND (:ProductionLineID IS NULL OR\n" +
  6393. " sp.ProductionLineID = :ProductionLineID)\n" +
  6394. " AND (:GoodsTypeCode IS NULL OR\n" +
  6395. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  6396. " AND (:GoodsCode IS NULL OR instr(g.GoodsCode, :GoodsCode) > 0)\n" +
  6397. " AND (:ProcedureIDS IS NULL OR\n" +
  6398. " instr(:ProcedureIDS, ',' || sp.ProcedureID || ',') > 0)\n" +
  6399. " AND (:ResponProcedureIDS IS NULL OR\n" +
  6400. " instr(:ResponProcedureIDS, ',' || rp.ProcedureID || ',') > 0)\n" +
  6401. " AND (:ResponUserIDS IS NULL OR\n" +
  6402. " instr(:ResponUserIDS, ',' || sr.userid || ',') > 0)\n" +
  6403. // 损坯时间
  6404. " AND (:ScrapDateStart IS NULL OR sp.CreateTime >= :ScrapDateStart)\n" +
  6405. " AND (:ScrapDateEnd IS NULL OR sp.CreateTime <= :ScrapDateEnd)\n" +
  6406. // 审核时间
  6407. " AND (:AuditDateStart IS NULL OR sp.AuditDate >= :AuditDateStart)\n" +
  6408. " AND (:AuditDateEnd IS NULL OR sp.AuditDate <= :AuditDateEnd)\n" +
  6409. // 完成时间
  6410. " AND (:CTimeStart IS NULL OR\n" +
  6411. " sp.CreateTime >= :CTimeStart)\n" +
  6412. " AND (:CTimeEnd IS NULL OR\n" +
  6413. " sp.CreateTime <= :CTimeEnd)\n" +
  6414. // 交坯时间
  6415. " AND (:DTimeStart IS NULL OR\n" +
  6416. " gdd.DeliverTime >= :DTimeStart)\n" +
  6417. " AND (:DTimeEnd IS NULL OR\n" +
  6418. " gdd.DeliverTime <= :DTimeEnd)\n" +
  6419. // 注浆时间
  6420. " AND (:GTimeStart IS NULL OR\n" +
  6421. " gdd.GroutingDate >= :GTimeStart)\n" +
  6422. " AND (:GTimeEnd IS NULL OR\n" +
  6423. " gdd.GroutingDate <= :GTimeEnd)\n" +
  6424. " AND (:CreatUser IS NULL OR instr(cu.UserCode, :CreatUser) > 0)\n" +
  6425. " AND (:AuditUser IS NULL OR instr(au.UserCode, :AuditUser) > 0)\n" +
  6426. " AND (:GoodsID IS NULL OR sp.goodsid = :GoodsID)\n" +
  6427. " AND (:ResponProcedureID IS NULL OR rp.procedureid = :ResponProcedureID)\n" +
  6428. " AND (:ResponUserID IS NULL OR sr.userid = :ResponUserID)\n" +
  6429. " AND (:RPF = 1 OR rp.procedureid is null)\n" +
  6430. " AND (:RUF = 1 OR sr.userid is null)\n" +
  6431. " ORDER BY pline.productionlinename, nvl(zp.displayno, -1), sp.barcode";
  6432. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  6433. if (string.IsNullOrEmpty(se.ProcedureIDS))
  6434. {
  6435. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, null, ParameterDirection.Input));
  6436. }
  6437. else
  6438. {
  6439. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  6440. }
  6441. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  6442. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  6443. if (string.IsNullOrEmpty(se.ResponProcedureIDS))
  6444. {
  6445. parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  6446. }
  6447. else
  6448. {
  6449. parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, "," + se.ResponProcedureIDS + ",", ParameterDirection.Input));
  6450. }
  6451. if (string.IsNullOrEmpty(se.ResponUserIDS))
  6452. {
  6453. parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  6454. }
  6455. else
  6456. {
  6457. parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, "," + se.ResponUserIDS + ",", ParameterDirection.Input));
  6458. }
  6459. parameters.Add(new OracleParameter(":CreatUser", OracleDbType.Varchar2, se.CreatUser, ParameterDirection.Input));
  6460. parameters.Add(new OracleParameter(":AuditUser", OracleDbType.Varchar2, se.AuditUser, ParameterDirection.Input));
  6461. parameters.Add(new OracleParameter(":ScrapDateStart", OracleDbType.Date, se.ScrapDateStart, ParameterDirection.Input));
  6462. parameters.Add(new OracleParameter(":ScrapDateEnd", OracleDbType.Date, se.ScrapDateEnd, ParameterDirection.Input));
  6463. parameters.Add(new OracleParameter(":AuditDateStart", OracleDbType.Date, se.AuditTimeStart, ParameterDirection.Input));
  6464. parameters.Add(new OracleParameter(":AuditDateEnd", OracleDbType.Date, se.AuditTimeEnd, ParameterDirection.Input));
  6465. parameters.Add(new OracleParameter(":CTimeStart", OracleDbType.Date, se.CTimeStart, ParameterDirection.Input));
  6466. parameters.Add(new OracleParameter(":CTimeEnd", OracleDbType.Date, se.CTimeEnd, ParameterDirection.Input));
  6467. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart, ParameterDirection.Input));
  6468. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd, ParameterDirection.Input));
  6469. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart, ParameterDirection.Input));
  6470. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd, ParameterDirection.Input));
  6471. parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  6472. if (se.ResponProcedureID == "")
  6473. {
  6474. parameters.Add(new OracleParameter(":RPF", OracleDbType.Int32, 0, ParameterDirection.Input));
  6475. parameters.Add(new OracleParameter(":ResponProcedureID", OracleDbType.Int32, null, ParameterDirection.Input));
  6476. }
  6477. else
  6478. {
  6479. parameters.Add(new OracleParameter(":RPF", OracleDbType.Int32, 1, ParameterDirection.Input));
  6480. parameters.Add(new OracleParameter(":ResponProcedureID", OracleDbType.Int32, se.ResponProcedureID, ParameterDirection.Input));
  6481. }
  6482. if (se.ResponUserID == "")
  6483. {
  6484. parameters.Add(new OracleParameter(":RUF", OracleDbType.Int32, 0, ParameterDirection.Input));
  6485. parameters.Add(new OracleParameter(":ResponUserID", OracleDbType.Int32, null, ParameterDirection.Input));
  6486. }
  6487. else
  6488. {
  6489. parameters.Add(new OracleParameter(":RUF", OracleDbType.Int32, 1, ParameterDirection.Input));
  6490. parameters.Add(new OracleParameter(":ResponUserID", OracleDbType.Int32, se.ResponUserID, ParameterDirection.Input));
  6491. }
  6492. return sqlString;
  6493. }
  6494. /// <summary>
  6495. /// 取得RPT030103_1画面(出窑数量汇总表)的汇总信息查询数据
  6496. /// </summary>
  6497. /// <param name="user">登录用户信息</param>
  6498. /// <param name="se">查询条件</param>
  6499. /// <returns>查询结果</returns>
  6500. public static ServiceResultEntity GetRPT030103SData(SUserInfo user, RPT030103_SE se)
  6501. {
  6502. IDBConnection conn = null;
  6503. try
  6504. {
  6505. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6506. List<OracleParameter> parameters = new List<OracleParameter>();
  6507. string sql = ReportModuleLogic.GetRPT030103SSQL(user, se, ref parameters);
  6508. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  6509. ServiceResultEntity sre = new ServiceResultEntity();
  6510. if (data == null || data.Rows.Count == 0)
  6511. {
  6512. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6513. return sre;
  6514. }
  6515. sre.Data = new DataSet();
  6516. sre.Data.Tables.Add(data);
  6517. return sre;
  6518. }
  6519. catch (Exception ex)
  6520. {
  6521. throw ex;
  6522. }
  6523. finally
  6524. {
  6525. if (conn != null &&
  6526. conn.ConnState == ConnectionState.Open)
  6527. {
  6528. conn.Close();
  6529. }
  6530. }
  6531. }
  6532. /// <summary>
  6533. /// 获取RPT030103_1画面(出窑数量汇总表)的汇总信息查询sql
  6534. /// </summary>
  6535. /// <returns>sql</returns>
  6536. private static string GetRPT030103SSQL(SUserInfo user, RPT030103_SE se, ref List<OracleParameter> parameters)
  6537. {
  6538. string selSql = "";
  6539. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6540. parameters.Add(new OracleParameter(":rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  6541. selSql = selSql +
  6542. "SELECT pdata.Procedureid Procedureid " +
  6543. " ,decode(gid, 3, '合计', 1, '小计【'||pdata.Procedurename||'】', pdata.Procedurename) Procedurename " +
  6544. " ,decode(gid, 0, to_char(pdata.Userid), '--') Userid " +
  6545. " ,decode(gid, 0, pdata.Usercode, '--') Usercode " +
  6546. " ,decode(gid, 0, to_char(pdata.KilnID), '--') Kilnid " +
  6547. " ,decode(gid, 0, pdata.Kilncode, '--') Kilncode " +
  6548. " ,decode(gid, 0, pdata.goodstypename, '--') goodstypename " +
  6549. " ,decode(gid, 0, to_char(pdata.Goodsid), '--') Goodsid " +
  6550. " ,decode(gid, 0, pdata.Goodscode, '--') Goodscode " +
  6551. " ,OutKilnCount " +
  6552. " FROM (SELECT grouping_id(pdata.Procedureid, " +
  6553. " pdata.Userid ) gid " +
  6554. " ,pdata.Procedureid " +
  6555. " ,pdata.Procedurename " +
  6556. " ,pdata.Userid " +
  6557. " ,pdata.Usercode " +
  6558. " ,pdata.Kilnid " +
  6559. " ,pdata.Kilncode " +
  6560. " ,pdata.goodstypename " +
  6561. " ,pdata.Goodsid " +
  6562. " ,pdata.Goodscode " +
  6563. " ,COUNT(pdata.Barcode) AS OutKilnCount " +
  6564. " FROM (SELECT DISTINCT " +
  6565. //" decode(grouping(TP_PM_ProductionData.Procedureid),1,'--',TP_PM_ProductionData.Procedureid) Procedureid, " +
  6566. //" decode(grouping(TP_PM_ProductionData.Procedurename),1,'合计', TP_PM_ProductionData.Procedurename) Procedurename, " +
  6567. //" decode(grouping(TP_PM_ProductionData.Userid),1,'--', TP_PM_ProductionData.Userid) Userid, " +
  6568. //" decode(grouping(TP_PM_ProductionData.Usercode),1,'--', TP_PM_ProductionData.Usercode) Usercode, " +
  6569. //" decode(grouping(temp.Kilncode),1,'--', temp.KilnID) Kilnid, " +
  6570. //" decode(grouping(temp.Kilncode),1,'--', temp.Kilncode) Kilncode, " +
  6571. //" decode(grouping(tp_mst_goodstype.goodstypename),1,'--', tp_mst_goodstype.goodstypename) goodstypename, " +
  6572. //" decode(grouping(TP_PM_ProductionData.Goodsid),1,'--', TP_PM_ProductionData.Goodsid) Goodsid, " +
  6573. //" decode(grouping(TP_PM_ProductionData.Goodscode),1,'--', TP_PM_ProductionData.Goodscode) Goodscode, " +
  6574. "TP_PM_ProductionData.Procedureid,pcp.Procedurename, " +
  6575. //"TP_PM_ProductionData.Userid,TP_PM_ProductionData.Usercode, " +
  6576. (se.DisPUserCode ? " TP_PM_ProductionData.userid, TP_PM_ProductionData.usercode, \n" : " null userid, null usercode, \n") +
  6577. "temp.Kilnid,temp.Kilncode,tp_mst_goodstype.goodstypename, " +
  6578. "TP_PM_ProductionData.Goodsid,TP_PM_ProductionData.Goodscode, TP_PM_ProductionData.barcode " +
  6579. " from TP_PM_ProductionData " +
  6580. " inner join tp_mst_goods on tp_mst_goods.goodsid=TP_PM_ProductionData.Goodsid " +
  6581. " inner join tp_mst_goodstype on tp_mst_goodstype.goodstypeid=tp_mst_goods.goodstypeid " +
  6582. " inner join TP_MST_RptTProcedure on TP_MST_RptTProcedure.Procedureid=TP_PM_ProductionData.Procedureid " +
  6583. " inner join TP_MST_RptProcedure on TP_MST_RptProcedure.Rptprocedureid=TP_MST_RptTProcedure.Rptprocedureid " +
  6584. " inner join tp_pc_procedure pcp on pcp.procedureid=TP_PM_ProductionData.Procedureid " +
  6585. " inner join " +
  6586. " ( " +
  6587. " 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 " +
  6588. " from TP_PM_ProductionData " +
  6589. " inner join TP_MST_RptSProcedure on TP_MST_RptSProcedure.Procedureid=TP_PM_ProductionData.Procedureid ";
  6590. if (se.DTimeStart.HasValue || se.DTimeEnd.HasValue)
  6591. {
  6592. selSql += " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=TP_PM_ProductionData.groutingdailydetailid ";
  6593. }
  6594. selSql +=
  6595. " where TP_PM_ProductionData.Accountid=:AccountID " +
  6596. " and TP_PM_ProductionData.Valueflag='1' " +
  6597. // 数据重复 modify by chenxy begin
  6598. // " and TP_MST_RptSProcedure.Rptprocedureid=:rptProcedureId " +
  6599. // 数据重复 modify by chenxy end
  6600. " and TP_MST_RptSProcedure.Procedureid=:rptSprocedureId ";
  6601. //if (se.CreateTimeStart.HasValue)
  6602. //{
  6603. // selSql = selSql + " AND TP_PM_ProductionData.CreateTime >= :CreateTimeStart ";
  6604. // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6605. //}
  6606. //if (se.CreateTimeEnd.HasValue)
  6607. //{
  6608. // selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :CreateTimeEnd ";
  6609. // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6610. //}
  6611. if (se.OutTimeStart.HasValue)
  6612. {
  6613. selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:OutTimeStart ";
  6614. parameters.Add(new OracleParameter(":OutTimeStart", OracleDbType.Date, se.OutTimeStart.Value, ParameterDirection.Input));
  6615. }
  6616. if (se.OutTimeEnd.HasValue)
  6617. {
  6618. selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :OutTimeEnd ";
  6619. parameters.Add(new OracleParameter(":OutTimeEnd", OracleDbType.Date, se.OutTimeEnd.Value, ParameterDirection.Input));
  6620. }
  6621. if (se.GTimeStart.HasValue)
  6622. {
  6623. selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE >=:GTimeStart ";
  6624. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  6625. }
  6626. if (se.GTimeEnd.HasValue)
  6627. {
  6628. selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE <= :GTimeEnd ";
  6629. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  6630. }
  6631. if (se.DTimeStart.HasValue)
  6632. {
  6633. selSql = selSql + " AND gdd.DELIVERTIME >=:DTimeStart ";
  6634. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
  6635. }
  6636. if (se.DTimeEnd.HasValue)
  6637. {
  6638. selSql = selSql + " AND gdd.DELIVERTIME <= :DTimeEnd ";
  6639. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
  6640. }
  6641. if (se.Specialrepairflag)
  6642. {
  6643. selSql = selSql +
  6644. " ) temp " +
  6645. " on TP_PM_ProductionData.Barcode=temp.barcode " +
  6646. " " +
  6647. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
  6648. " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
  6649. " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
  6650. " FROM TP_PM_ProductionData pp\n" +
  6651. " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
  6652. " AND pp.createtime < temp.createtime\n" +
  6653. " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
  6654. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
  6655. " where " +
  6656. // 公坯、干补不算交坯工序的质量。
  6657. // " 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" +
  6658. // modify wangx 2015-12-3
  6659. " ((TP_PM_ProductionData.modeltype <> 5) or (TP_PM_ProductionData.modeltype = 5 and TP_PM_ProductionData.SpecialRepairFlag = '0')) \n" +
  6660. " and TP_PM_ProductionData.Valueflag='1' " +
  6661. " and TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId ";
  6662. parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  6663. }
  6664. else
  6665. {
  6666. selSql = selSql +
  6667. " ) temp " +
  6668. " on TP_PM_ProductionData.Barcode=temp.barcode " +
  6669. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
  6670. " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
  6671. " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
  6672. " FROM TP_PM_ProductionData pp\n" +
  6673. " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
  6674. " AND pp.createtime < temp.createtime\n" +
  6675. " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
  6676. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
  6677. " where TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId " +
  6678. " and TP_PM_ProductionData.Valueflag='1' ";
  6679. parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  6680. }
  6681. if (se.CreateTimeStart.HasValue)
  6682. {
  6683. selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:CreateTimeStart ";
  6684. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6685. }
  6686. if (se.CreateTimeEnd.HasValue)
  6687. {
  6688. selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :CreateTimeEnd ";
  6689. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6690. }
  6691. if (!string.IsNullOrEmpty(se.GoodsIDS))
  6692. {
  6693. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  6694. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  6695. }
  6696. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  6697. {
  6698. // selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1 ";
  6699. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1 ";
  6700. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  6701. }
  6702. if (se.ProductionLineID.HasValue)
  6703. {
  6704. selSql = selSql + " AND instr(','||:productionLineId||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  6705. parameters.Add(new OracleParameter(":productionLineId", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  6706. }
  6707. //else
  6708. //{
  6709. // selSql = selSql + " AND TP_PM_ProductionData.ProductionLineId in(Select PurviewID from TP_MST_UserPurview where PurviewType= 7 and UserID = :UserID) ";
  6710. //}
  6711. 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))";
  6712. 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))";
  6713. parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  6714. if (!string.IsNullOrEmpty(se.RptTProcedureIDS))
  6715. {
  6716. selSql = selSql + " AND instr(','||:rptTprocedureId||',',','||TP_MST_RptTProcedure.ProcedureId||',')>0 ";
  6717. parameters.Add(new OracleParameter(":rptTprocedureId", OracleDbType.NVarchar2, se.RptTProcedureIDS, ParameterDirection.Input));
  6718. }
  6719. if (!string.IsNullOrEmpty(se.UserIDS))
  6720. {
  6721. selSql = selSql + " AND instr(','||:userIDS||',',','||TP_PM_ProductionData.Userid||',')>0 ";
  6722. parameters.Add(new OracleParameter(":userIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6723. }
  6724. if (se.KilnID.HasValue)
  6725. {
  6726. selSql = selSql + " AND temp.KilnID=:KilnID ";
  6727. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6728. }
  6729. if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
  6730. {
  6731. selSql = selSql + " AND instr(TP_PM_ProductionData.GroutingUserCode, :GroutingUserCode) > 0";
  6732. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  6733. }
  6734. selSql = selSql + " order by pcp.displayno, TP_PM_ProductionData.Usercode, temp.Kilncode,tp_mst_goodstype.goodstypename,TP_PM_ProductionData.Goodscode ) pdata" +
  6735. " 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),()) " +
  6736. ") pdata"
  6737. ;
  6738. return selSql;
  6739. }
  6740. /// <summary>
  6741. /// 取得RPT030103_1画面(出窑数量汇总表)的明细信息查询数据
  6742. /// </summary>
  6743. /// <param name="user">登录用户信息</param>
  6744. /// <param name="se">查询条件</param>
  6745. /// <returns>查询结果</returns>
  6746. public static ServiceResultEntity GetRPT030103IData(SUserInfo user, RPT030103_SE se)
  6747. {
  6748. IDBConnection conn = null;
  6749. try
  6750. {
  6751. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6752. List<OracleParameter> parameters = new List<OracleParameter>();
  6753. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030103ISQL(user, se, ref parameters));
  6754. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  6755. ServiceResultEntity sre = new ServiceResultEntity();
  6756. if (data == null || data.Rows.Count == 0)
  6757. {
  6758. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6759. return sre;
  6760. }
  6761. sre.Data = new DataSet();
  6762. sre.Data.Tables.Add(data);
  6763. return sre;
  6764. }
  6765. catch (Exception ex)
  6766. {
  6767. throw ex;
  6768. }
  6769. finally
  6770. {
  6771. if (conn != null &&
  6772. conn.ConnState == ConnectionState.Open)
  6773. {
  6774. conn.Close();
  6775. }
  6776. }
  6777. }
  6778. /// <summary>
  6779. /// 获取RPT030103_1画面(出窑数量汇总表)的明细信息查询sql
  6780. /// </summary>
  6781. /// <returns>sql</returns>
  6782. private static string GetRPT030103ISQL(SUserInfo user, RPT030103_SE se, ref List<OracleParameter> parameters)
  6783. {
  6784. string selSql = "";
  6785. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6786. parameters.Add(new OracleParameter(":rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  6787. selSql = selSql +
  6788. "select distinct " +
  6789. "TP_PM_ProductionData.Barcode, " +
  6790. //"TP_PM_ProductionData.UserCode, " +
  6791. (se.DisPUserCode ? " TP_PM_ProductionData.userid, TP_PM_ProductionData.usercode, cu.usercode Cusercode, \n" : " null userid, null usercode, null Cusercode, \n") +
  6792. "pcp.ProcedureName, " +
  6793. "tp_mst_goodstype.goodstypename, " +
  6794. "TP_PM_ProductionData.Goodscode, " +
  6795. "TP_PM_ProductionData.GroutingUserCode, " +
  6796. "TP_PM_ProductionData.GroutingLineCode, " +
  6797. "TP_PM_ProductionData.GroutingMouldCode, " +
  6798. // 多次干补 重复条码
  6799. //"TP_PM_ProductionData.Createtime OverDate, " +
  6800. "temp.Kilnid, " +
  6801. "temp.Kilncode, " +
  6802. "temp.Kilncarcode, " +
  6803. "temp.Createtime, " +
  6804. "temp.DELIVERTIME DDate, " +
  6805. "temp.GROUTINGDATE GDate, " +
  6806. "replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName " +
  6807. "from TP_PM_ProductionData " +
  6808. "inner join tp_mst_goods on tp_mst_goods.goodsid=TP_PM_ProductionData.Goodsid " +
  6809. "inner join tp_mst_goodstype on tp_mst_goodstype.goodstypeid=tp_mst_goods.goodstypeid " +
  6810. "inner join TP_MST_RptTProcedure on TP_MST_RptTProcedure.Procedureid=TP_PM_ProductionData.Procedureid " +
  6811. "inner join TP_MST_RptProcedure on TP_MST_RptProcedure.Rptprocedureid=TP_MST_RptTProcedure.Rptprocedureid " +
  6812. " inner join tp_pc_procedure pcp on pcp.procedureid=TP_PM_ProductionData.Procedureid " +
  6813. "left join TP_MST_logo on TP_PM_ProductionData.logoid=TP_MST_logo.logoid " +
  6814. "left join TP_MST_User cu on TP_PM_ProductionData.createuserid=cu.userid " +
  6815. "inner join " +
  6816. "( " +
  6817. " select " +
  6818. " TP_PM_ProductionData.Barcode, " +
  6819. " TP_PM_ProductionData.Kilncode, " +
  6820. " TP_PM_ProductionData.Kilncarcode, " +
  6821. " TP_PM_ProductionData.Createtime, " +
  6822. " TP_PM_ProductionData.KilnID " +
  6823. " ,gdd.DELIVERTIME " +
  6824. " ,TP_PM_ProductionData.GROUTINGDATE " +
  6825. " ,TP_PM_ProductionData.KilnCarID " +
  6826. " from TP_PM_ProductionData " +
  6827. " inner join TP_MST_RptSProcedure on TP_MST_RptSProcedure.Procedureid=TP_PM_ProductionData.Procedureid " +
  6828. //if (se.DTimeStart.HasValue || se.DTimeEnd.HasValue)
  6829. //{
  6830. // selSql += " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=TP_PM_ProductionData.groutingdailydetailid ";
  6831. //}
  6832. " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=TP_PM_ProductionData.groutingdailydetailid " +
  6833. // selSql +=
  6834. " where TP_PM_ProductionData.Accountid=:AccountID " +
  6835. " and TP_PM_ProductionData.Valueflag='1' " +
  6836. // 数据重复 modify by chenxy begin
  6837. " and TP_MST_RptSProcedure.Rptprocedureid=:rptProcedureId " +
  6838. // 数据重复 modify by chenxy end
  6839. " and TP_MST_RptSProcedure.Procedureid=:rptSprocedureId ";
  6840. if (se.OutTimeStart.HasValue)
  6841. {
  6842. selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:OutTimeStart ";
  6843. parameters.Add(new OracleParameter(":OutTimeStart", OracleDbType.Date, se.OutTimeStart.Value, ParameterDirection.Input));
  6844. }
  6845. if (se.OutTimeEnd.HasValue)
  6846. {
  6847. selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :OutTimeEnd ";
  6848. parameters.Add(new OracleParameter(":OutTimeEnd", OracleDbType.Date, se.OutTimeEnd.Value, ParameterDirection.Input));
  6849. }
  6850. if (se.GTimeStart.HasValue)
  6851. {
  6852. selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE >=:GTimeStart ";
  6853. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  6854. }
  6855. if (se.GTimeEnd.HasValue)
  6856. {
  6857. selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE <= :GTimeEnd ";
  6858. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  6859. }
  6860. if (se.DTimeStart.HasValue)
  6861. {
  6862. selSql = selSql + " AND gdd.DELIVERTIME >=:DTimeStart ";
  6863. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
  6864. }
  6865. if (se.DTimeEnd.HasValue)
  6866. {
  6867. selSql = selSql + " AND gdd.DELIVERTIME <= :DTimeEnd ";
  6868. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
  6869. }
  6870. if (se.Specialrepairflag)
  6871. {
  6872. selSql = selSql +
  6873. ") temp " +
  6874. "on TP_PM_ProductionData.Barcode=temp.barcode " +
  6875. " " +
  6876. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
  6877. " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
  6878. " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
  6879. " FROM TP_PM_ProductionData pp\n" +
  6880. " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
  6881. " AND pp.createtime < temp.createtime\n" +
  6882. " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
  6883. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
  6884. "where " + // 公坯、干补不算交坯工序的质量。
  6885. //" 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" +
  6886. // modify wangx 2015-12-3
  6887. " ((TP_PM_ProductionData.modeltype <> 5) or (TP_PM_ProductionData.modeltype = 5 and TP_PM_ProductionData.SpecialRepairFlag = '0')) \n" +
  6888. " and TP_PM_ProductionData.Valueflag='1' " +
  6889. " and TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId ";
  6890. parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  6891. }
  6892. else
  6893. {
  6894. selSql = selSql +
  6895. ") temp " +
  6896. "on TP_PM_ProductionData.Barcode=temp.barcode " +
  6897. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
  6898. " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
  6899. " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
  6900. " FROM TP_PM_ProductionData pp\n" +
  6901. " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
  6902. " AND pp.createtime < temp.createtime\n" +
  6903. " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
  6904. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
  6905. " where TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId " +
  6906. " and TP_PM_ProductionData.Valueflag='1' ";
  6907. parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  6908. }
  6909. if (se.CreateTimeStart.HasValue)
  6910. {
  6911. selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:CreateTimeStart ";
  6912. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6913. }
  6914. if (se.CreateTimeEnd.HasValue)
  6915. {
  6916. selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :CreateTimeEnd ";
  6917. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6918. }
  6919. if (!string.IsNullOrEmpty(se.GoodsIDS))
  6920. {
  6921. selSql = selSql + " AND instr(',' || :GoodsIDS ||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  6922. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  6923. }
  6924. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  6925. {
  6926. //selSql = selSql + " AND instr(',' || :GoodsTypeIDS ||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1 ";
  6927. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1 ";
  6928. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  6929. }
  6930. if (se.ProductionLineID.HasValue)
  6931. {
  6932. selSql = selSql + " AND instr(',' || :productionLineId ||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  6933. parameters.Add(new OracleParameter(":productionLineId", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  6934. }
  6935. if (!string.IsNullOrEmpty(se.RptTProcedureIDS))
  6936. {
  6937. selSql = selSql + " AND instr(',' || :rptTprocedureIDS ||',',','||TP_MST_RptTProcedure.ProcedureId||',')>0 ";
  6938. parameters.Add(new OracleParameter(":rptTprocedureIDS", OracleDbType.NVarchar2, se.RptTProcedureIDS, ParameterDirection.Input));
  6939. }
  6940. if (!string.IsNullOrEmpty(se.UserIDS))
  6941. {
  6942. selSql = selSql + " AND instr(',' || :UserIDS ||',',','||TP_PM_ProductionData.Userid||',')>0 ";
  6943. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6944. }
  6945. if (se.KilnID.HasValue)
  6946. {
  6947. selSql = selSql + " AND temp.KilnID=:KilnID ";
  6948. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6949. }
  6950. if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
  6951. {
  6952. selSql = selSql + " AND instr(TP_PM_ProductionData.GroutingUserCode, :GroutingUserCode) > 0";
  6953. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  6954. }
  6955. selSql = selSql + " order by pcp.Procedurename,temp.Kilncode,temp.Kilncarcode, " +
  6956. (se.DisPUserCode ? " TP_PM_ProductionData.usercode, \n" : "") +
  6957. " TP_PM_ProductionData.Goodscode,TP_PM_ProductionData.Barcode ";
  6958. return selSql;
  6959. }
  6960. /// <summary>
  6961. /// 取得RPT030104_1画面(窑车产量汇总表)的窑炉汇总信息查询数据
  6962. /// </summary>
  6963. /// <param name="user">登录用户信息</param>
  6964. /// <param name="se">查询条件</param>
  6965. /// <returns>查询结果</returns>
  6966. public static ServiceResultEntity GetRPT030104SData(SUserInfo user, RPT030104_SE se)
  6967. {
  6968. IDBConnection conn = null;
  6969. try
  6970. {
  6971. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6972. List<OracleParameter> parameters = new List<OracleParameter>();
  6973. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030104SSQL(user, se, ref parameters));
  6974. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  6975. ServiceResultEntity sre = new ServiceResultEntity();
  6976. if (data == null || data.Rows.Count == 0)
  6977. {
  6978. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6979. return sre;
  6980. }
  6981. sre.Data = new DataSet();
  6982. sre.Data.Tables.Add(data);
  6983. return sre;
  6984. }
  6985. catch (Exception ex)
  6986. {
  6987. throw ex;
  6988. }
  6989. finally
  6990. {
  6991. if (conn != null &&
  6992. conn.ConnState == ConnectionState.Open)
  6993. {
  6994. conn.Close();
  6995. }
  6996. }
  6997. }
  6998. /// <summary>
  6999. /// 获取RPT030104_1画面(窑车产量汇总表)的窑炉汇总查询sql
  7000. /// </summary>
  7001. /// <returns>sql</returns>
  7002. private static string GetRPT030104SSQL(SUserInfo user, RPT030104_SE se, ref List<OracleParameter> parameters)
  7003. {
  7004. string selSql = "";
  7005. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7006. parameters.Add(new OracleParameter(":ProcedureModelTypeID", OracleDbType.Int32, se.ProcedureModelTypeID, ParameterDirection.Input));
  7007. selSql = "select " +
  7008. "decode(Createtime,'小计',decode(Proceduremodeltypename,'总计','总计','--'),Proceduremodeltypename) Proceduremodeltypename, " +
  7009. "decode(usercode,'合计',decode(Kilncode,'--','--','合计'),decode(createtime,'小计','--',Kilncode)) Kilncode, " +
  7010. "decode(Createtime,'小计',decode(usercode,'合计','--','小计'),Usercode) Usercode, " +
  7011. "decode(Kilncarcode,'--','--',Createtime) Createtime, " +
  7012. "Kilncarcode, " +
  7013. "Remarks, " +
  7014. "KilnCarCount " +
  7015. " from " +
  7016. " ( " +
  7017. " select " +
  7018. " decode(grouping(TP_SYS_ProcedureModelType.Proceduremodeltypename),1,'总计',TP_SYS_ProcedureModelType.Proceduremodeltypename) Proceduremodeltypename, " +
  7019. " decode(grouping(TP_MST_Kiln.Kilncode),1,'--',TP_MST_Kiln.Kilncode) Kilncode, " +
  7020. " decode(grouping(TP_PM_KilnCarData.Usercode),1,'合计',TP_PM_KilnCarData.Usercode) Usercode, " +
  7021. " decode(grouping(TP_MST_KilnCar.Kilncarcode),1,'--',TP_MST_KilnCar.Kilncarcode) Kilncarcode, " +
  7022. " decode(grouping(TP_PM_KilnCarData.Remarks),1,'--',TP_PM_KilnCarData.Remarks) Remarks, " +
  7023. " decode(grouping(TP_PM_KilnCarData.Createtime),1,'小计',TP_PM_KilnCarData.Createtime) Createtime, " +
  7024. " count(TP_PM_KilnCarData.Kilncarid) as KilnCarCount " +
  7025. " from " +
  7026. " ( " +
  7027. " select " +
  7028. " to_char(TP_PM_KilnCarData.Createtime,'yyyy-mm-dd hh24:mi') Createtime, " +
  7029. " TP_PM_KilnCarData.Modeltype, " +
  7030. " TP_PM_KilnCarData.Kilncarid, " +
  7031. " TP_PM_KilnCarData.Kilnid, " +
  7032. " TP_PM_KilnCarData.Userid, " +
  7033. " TP_PM_KilnCarData.Remarks, " +
  7034. " TP_PM_KilnCarData.Accountid, " +
  7035. " TP_PM_KilnCarData.Usercode " +
  7036. " from TP_PM_KilnCarData " +
  7037. " left join TP_MST_KilnCar kc on kc.kilncarid = TP_PM_KilnCarData.Kilncarid " +
  7038. " where TP_PM_KilnCarData.Accountid=:AccountID " +
  7039. " and TP_PM_KilnCarData.Valueflag=1 " +
  7040. " and TP_PM_KilnCarData.Modeltype=:ProcedureModelTypeID ";
  7041. if (se.KilnID.HasValue)
  7042. {
  7043. selSql = selSql + " AND TP_PM_KilnCarData.KilnID=:KilnID ";
  7044. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  7045. }
  7046. //if (se.KilnCarID.HasValue)
  7047. //{
  7048. // selSql = selSql + " AND TP_PM_KilnCarData.KilnCarID=:KilnCarID";
  7049. // parameters.Add(new OracleParameter(":KilnCarID", OracleDbType.Int32, se.KilnCarID, ParameterDirection.Input));
  7050. //}
  7051. if (!string.IsNullOrEmpty(se.KilnCarCode))
  7052. {
  7053. selSql = selSql + " AND instr(kc.KilnCarCode, :KilnCarCode ) > 0";
  7054. parameters.Add(new OracleParameter(":KilnCarCode", OracleDbType.NVarchar2, se.KilnCarCode, ParameterDirection.Input));
  7055. }
  7056. if (se.KilnCarNumBegin.HasValue && se.KilnCarNumEnd.HasValue && se.KilnCarNumBegin.Value > se.KilnCarNumEnd.Value)
  7057. {
  7058. selSql = selSql + " AND (kc.KilnCarNum >= :KilnCarNumBegin or kc.KilnCarNum <= :KilnCarNumEnd)";
  7059. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  7060. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  7061. }
  7062. else
  7063. {
  7064. if (se.KilnCarNumBegin.HasValue)
  7065. {
  7066. selSql = selSql + " AND kc.KilnCarNum >= :KilnCarNumBegin ";
  7067. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  7068. }
  7069. if (se.KilnCarNumEnd.HasValue)
  7070. {
  7071. selSql = selSql + " AND kc.KilnCarNum <= :KilnCarNumEnd ";
  7072. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  7073. }
  7074. }
  7075. if (se.CreateTimeStart.HasValue)
  7076. {
  7077. selSql = selSql + " AND TP_PM_KilnCarData.CreateTime>=:CreateTimeStart ";
  7078. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  7079. }
  7080. if (se.CreateTimeEnd.HasValue)
  7081. {
  7082. selSql = selSql + " AND TP_PM_KilnCarData.CreateTime<= :CreateTimeEnd";
  7083. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  7084. }
  7085. selSql = selSql +
  7086. " ) TP_PM_KilnCarData " +
  7087. "inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.Proceduremodeltypeid=TP_PM_KilnCarData.Modeltype " +
  7088. "inner join TP_MST_KilnCar on TP_MST_KilnCar.Kilncarid=TP_PM_KilnCarData.Kilncarid " +
  7089. "inner join TP_MST_Kiln on TP_MST_Kiln.Kilnid=TP_PM_KilnCarData.Kilnid " +
  7090. "where 1=1";
  7091. if (!string.IsNullOrEmpty(se.UserIDS))
  7092. {
  7093. selSql = selSql + " AND instr(','||:UserIDS||',',','||TP_PM_KilnCarData.UserID||',')>0";
  7094. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  7095. }
  7096. selSql = selSql + "group by rollup( " +
  7097. " TP_SYS_ProcedureModelType.Proceduremodeltypename, " +
  7098. " TP_MST_Kiln.Kilncode, " +
  7099. " TP_PM_KilnCarData.Usercode, " +
  7100. " TP_PM_KilnCarData.Createtime, " +
  7101. " TP_PM_KilnCarData.Remarks, " +
  7102. " TP_MST_KilnCar.Kilncarcode " +
  7103. " ) " +
  7104. " ) temp " +
  7105. " where (Kilncarcode !='--' ) " +
  7106. " or " +
  7107. " (Remarks='--' and Usercode='合计' and kilncode!='--') " +
  7108. " or (Remarks='--' and Proceduremodeltypename='总计') " +
  7109. " or (Remarks='--' and createtime='小计' and kilncode!='--')";
  7110. return selSql;
  7111. }
  7112. /// <summary>
  7113. /// 取得RPT030104_1画面(窑车产量汇总表)的窑车产量汇总信息查询数据
  7114. /// </summary>
  7115. /// <param name="user">登录用户信息</param>
  7116. /// <param name="se">查询条件</param>
  7117. /// <returns>查询结果</returns>
  7118. public static ServiceResultEntity GetRPT030104IData(SUserInfo user, RPT030104_SE se)
  7119. {
  7120. IDBConnection conn = null;
  7121. try
  7122. {
  7123. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7124. List<OracleParameter> parameters = new List<OracleParameter>();
  7125. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030104ISQL(user, se, ref parameters));
  7126. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  7127. ServiceResultEntity sre = new ServiceResultEntity();
  7128. if (data == null || data.Rows.Count == 0)
  7129. {
  7130. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7131. return sre;
  7132. }
  7133. sre.Data = new DataSet();
  7134. sre.Data.Tables.Add(data);
  7135. return sre;
  7136. }
  7137. catch (Exception ex)
  7138. {
  7139. throw ex;
  7140. }
  7141. finally
  7142. {
  7143. if (conn != null &&
  7144. conn.ConnState == ConnectionState.Open)
  7145. {
  7146. conn.Close();
  7147. }
  7148. }
  7149. }
  7150. /// <summary>
  7151. /// 获取查询sql
  7152. /// </summary>
  7153. /// <returns>sql</returns>
  7154. private static string GetRPT030104ISQL(SUserInfo user, RPT030104_SE se, ref List<OracleParameter> parameters)
  7155. {
  7156. string selSql = "";
  7157. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7158. parameters.Add(new OracleParameter(":ProcedureModelTypeID", OracleDbType.Int32, se.ProcedureModelTypeID, ParameterDirection.Input));
  7159. selSql = selSql +
  7160. "SELECT " +
  7161. "decode(createtime,'小计',decode(proceduremodeltypename,'总计','总计','--'),proceduremodeltypename) proceduremodeltypename, " +
  7162. "decode(createtime,'小计','--',kilncode) kilncode, " +
  7163. "decode(kilncarcode,'合计',decode(usercode,'--','--','合计'),decode(createtime,'小计','--',usercode)) usercode, " +
  7164. "decode(createtime,'小计',decode(kilncarcode,'合计','--','小计'),kilncarcode) kilncarcode, " +
  7165. "decode(goodscode,'--','--',createtime) createtime, " +
  7166. "GOODSTYPENAME, " +
  7167. "Goodscode, " +
  7168. "GOODSSPECIFICATION, " +
  7169. "GoodsCount " +
  7170. "from " +
  7171. "( " +
  7172. " SELECT " +
  7173. " decode(grouping(TP_SYS_ProcedureModelType.Proceduremodeltypename),1,'总计',TP_SYS_ProcedureModelType.Proceduremodeltypename) Proceduremodeltypename, " +
  7174. " decode(grouping(TP_PM_ProductionData.Kilncode),1,'--',TP_PM_ProductionData.Kilncode) Kilncode, " +
  7175. " decode(grouping(TP_PM_ProductionData.Usercode),1,'--',TP_PM_ProductionData.Usercode) Usercode, " +
  7176. " decode(grouping(TP_MST_KilnCar.Kilncarcode),1,'合计',TP_MST_KilnCar.Kilncarcode) Kilncarcode, " +
  7177. " decode(grouping(TP_PM_ProductionData.CreateTime),1,'小计',TP_PM_ProductionData.CreateTime) CreateTime, " +
  7178. " decode(grouping(TP_MST_Goods.Goodscode),1,'--',TP_MST_Goods.Goodscode) Goodscode, " +
  7179. " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  7180. " decode(grouping(TP_MST_GOODSTYPE.GOODSTYPENAME),1,'--',TP_MST_GOODSTYPE.GOODSTYPENAME) GOODSTYPENAME, " +
  7181. " count(TP_MST_Goods.Goodscode) as GoodsCount " +
  7182. " from " +
  7183. " ( " +
  7184. " SELECT TP_PM_ProductionData.Modeltype, " +
  7185. " TP_PM_ProductionData.Goodsid, " +
  7186. " TP_PM_ProductionData.KilnCarID, " +
  7187. " TP_PM_ProductionData.Kilncode, " +
  7188. //" TP_PM_ProductionData.Usercode, " +
  7189. " kcd.Usercode, " +
  7190. " to_char(kcd.CreateTime,'yyyy-mm-dd hh24:mi') CreateTime " +
  7191. " from TP_PM_ProductionData " +
  7192. " left join TP_PM_KilnCarData kcd on kcd.KilnCarBatchNo = TP_PM_ProductionData.KilnCarBatchNo and kcd.ProcedureID = TP_PM_ProductionData.ProcedureID " +
  7193. " where " +
  7194. " TP_PM_ProductionData.Accountid=:AccountID " +
  7195. " and TP_PM_ProductionData.Valueflag=1 " +
  7196. " and TP_PM_ProductionData.Modeltype= :ProcedureModelTypeID ";
  7197. if (se.KilnID.HasValue)
  7198. {
  7199. selSql = selSql + " AND TP_PM_ProductionData.KilnID=:KilnID ";
  7200. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  7201. }
  7202. //if (se.KilnCarID.HasValue)
  7203. //{
  7204. // selSql = selSql + " AND TP_PM_ProductionData.KilnCarID=:KilnCarID";
  7205. // parameters.Add(new OracleParameter(":KilnCarID", OracleDbType.Int32, se.KilnCarID, ParameterDirection.Input));
  7206. //}
  7207. if (!string.IsNullOrEmpty(se.GoodsIDS))
  7208. {
  7209. selSql = selSql + " AND instr(','||:goodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  7210. parameters.Add(new OracleParameter(":goodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  7211. }
  7212. if (!string.IsNullOrEmpty(se.UserIDS))
  7213. {
  7214. //selSql = selSql + " AND instr(','||:UserIDS||',',','||TP_PM_ProductionData.UserID||',')>0 ";
  7215. selSql = selSql + " AND instr(','||:UserIDS||',',','||kcd.UserID||',')>0 ";
  7216. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  7217. }
  7218. if (se.CreateTimeStart.HasValue)
  7219. {
  7220. //selSql = selSql + " AND TP_PM_ProductionData.CreateTime>= :CreateTimeStart ";
  7221. selSql = selSql + " AND kcd.CreateTime>= :CreateTimeStart ";
  7222. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  7223. }
  7224. if (se.CreateTimeEnd.HasValue)
  7225. {
  7226. //selSql = selSql + " AND TP_PM_ProductionData.CreateTime<= :CreateTimeEnd ";
  7227. selSql = selSql + " AND kcd.CreateTime<= :CreateTimeEnd ";
  7228. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  7229. }
  7230. selSql = selSql +
  7231. " ) TP_PM_ProductionData " +
  7232. " inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.Proceduremodeltypeid=TP_PM_ProductionData.Modeltype " +
  7233. " inner join TP_MST_Goods on TP_MST_Goods.Goodsid=TP_PM_ProductionData.Goodsid " +
  7234. " inner join TP_MST_GOODSTYPE on TP_MST_GOODSTYPE.GOODSTYPEID=TP_MST_Goods.Goodstypeid " +
  7235. " inner join TP_MST_KilnCar on TP_MST_KilnCar.Kilncarid=TP_PM_ProductionData.KilnCarID " +
  7236. " where 1=1 ";
  7237. if (!string.IsNullOrEmpty(se.KilnCarCode))
  7238. {
  7239. selSql = selSql + " AND instr(TP_MST_KilnCar.KilnCarCode, :KilnCarCode ) > 0";
  7240. parameters.Add(new OracleParameter(":KilnCarCode", OracleDbType.NVarchar2, se.KilnCarCode, ParameterDirection.Input));
  7241. }
  7242. if (se.KilnCarNumBegin.HasValue && se.KilnCarNumEnd.HasValue && se.KilnCarNumBegin.Value > se.KilnCarNumEnd.Value)
  7243. {
  7244. selSql = selSql + " AND (TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin or TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd)";
  7245. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  7246. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  7247. }
  7248. else
  7249. {
  7250. if (se.KilnCarNumBegin.HasValue)
  7251. {
  7252. selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin ";
  7253. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  7254. }
  7255. if (se.KilnCarNumEnd.HasValue)
  7256. {
  7257. selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd ";
  7258. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  7259. }
  7260. }
  7261. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  7262. {
  7263. //selSql = selSql + " AND instr(','||:goodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1";
  7264. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:goodsTypeIDS)=1";
  7265. parameters.Add(new OracleParameter(":goodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  7266. }
  7267. selSql = selSql +
  7268. " group by rollup( " +
  7269. " TP_SYS_ProcedureModelType.Proceduremodeltypename, " +
  7270. " TP_PM_ProductionData.Kilncode, " +
  7271. " TP_PM_ProductionData.Usercode, " +
  7272. " TP_MST_KilnCar.Kilncarcode, " +
  7273. " TP_PM_ProductionData.CreateTime, " +
  7274. " TP_MST_GOODSTYPE.GOODSTYPENAME, " +
  7275. " TP_MST_Goods.GOODSSPECIFICATION, " +
  7276. " TP_MST_Goods.Goodscode " +
  7277. " ) " +
  7278. ") temp " +
  7279. "where 1=1 and " +
  7280. " (Goodscode !='--' ) or " +
  7281. " (Goodscode='--' and Usercode='合计' and kilncode!='--') or " +
  7282. " (Goodscode='--' and Proceduremodeltypename='总计') or " +
  7283. " (Goodscode='--' and createtime='小计' and usercode!='--')";
  7284. return selSql;
  7285. }
  7286. /// <summary>
  7287. /// 取得RPT030104_1画面(窑车产量汇总表)的窑车产量明细信息查询数据
  7288. /// </summary>
  7289. /// <param name="user">登录用户信息</param>
  7290. /// <param name="se">查询条件</param>
  7291. /// <returns>查询结果</returns>
  7292. public static ServiceResultEntity GetRPT030104UData(SUserInfo user, RPT030104_SE se)
  7293. {
  7294. IDBConnection conn = null;
  7295. try
  7296. {
  7297. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7298. List<OracleParameter> parameters = new List<OracleParameter>();
  7299. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030104USQL(user, se, ref parameters));
  7300. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  7301. ServiceResultEntity sre = new ServiceResultEntity();
  7302. if (data == null || data.Rows.Count == 0)
  7303. {
  7304. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7305. return sre;
  7306. }
  7307. sre.Data = new DataSet();
  7308. sre.Data.Tables.Add(data);
  7309. return sre;
  7310. }
  7311. catch (Exception ex)
  7312. {
  7313. throw ex;
  7314. }
  7315. finally
  7316. {
  7317. if (conn != null &&
  7318. conn.ConnState == ConnectionState.Open)
  7319. {
  7320. conn.Close();
  7321. }
  7322. }
  7323. }
  7324. /// <summary>
  7325. /// 获取RPT030104_1画面(窑车产量汇总表)的窑车产量明细查询sql
  7326. /// </summary>
  7327. /// <returns>sql</returns>
  7328. private static string GetRPT030104USQL(SUserInfo user, RPT030104_SE se, ref List<OracleParameter> parameters)
  7329. {
  7330. string selSql = "";
  7331. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7332. parameters.Add(new OracleParameter(":ProcedureModelTypeID", OracleDbType.Int32, se.ProcedureModelTypeID, ParameterDirection.Input));
  7333. selSql = selSql +
  7334. "select " +
  7335. "decode(createtime,'小计',decode(proceduremodeltypename,'总计','总计','--'),proceduremodeltypename) proceduremodeltypename, " +
  7336. "decode(createtime,'小计','--',kilncode) kilncode, " +
  7337. "decode(kilncarcode,'合计',decode(usercode,'--','--','合计'),decode(createtime,'小计','--',usercode)) usercode, " +
  7338. "decode(createtime,'小计',decode(kilncarcode,'合计','--','小计'),kilncarcode) kilncarcode, " +
  7339. "decode(goodscode,'--','--',createtime) createtime, " +
  7340. "GOODSTYPENAME, " +
  7341. "Goodscode, " +
  7342. "GOODSSPECIFICATION, " +
  7343. "Barcode, " +
  7344. "BarcodeCount, " +
  7345. "LogoCodeName " +
  7346. "from " +
  7347. " ( " +
  7348. " select " +
  7349. " decode(grouping(TP_SYS_ProcedureModelType.Proceduremodeltypename),1,'总计',TP_SYS_ProcedureModelType.Proceduremodeltypename) Proceduremodeltypename, " +
  7350. " decode(grouping(TP_PM_ProductionData.Kilncode),1,'--',TP_PM_ProductionData.Kilncode) Kilncode, " +
  7351. " decode(grouping(TP_PM_ProductionData.Usercode),1,'--',TP_PM_ProductionData.Usercode) Usercode, " +
  7352. " decode(grouping(TP_MST_KilnCar.Kilncarcode),1,'合计',TP_MST_KilnCar.Kilncarcode) Kilncarcode, " +
  7353. " decode(grouping(TP_PM_ProductionData.CreateTime),1,'小计',TP_PM_ProductionData.CreateTime) CreateTime, " +
  7354. " decode(grouping(TP_MST_GOODSTYPE.GOODSTYPENAME),1,'--',TP_MST_GOODSTYPE.GOODSTYPENAME) GOODSTYPENAME, " +
  7355. " decode(grouping(TP_MST_Goods.Goodscode),1,'--',TP_MST_Goods.Goodscode) Goodscode, " +
  7356. " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  7357. " decode(grouping(TP_PM_ProductionData.Barcode),1,'--',TP_PM_ProductionData.Barcode) Barcode, " +
  7358. " decode(grouping(TP_PM_ProductionData.LogoCodeName),1,'--',TP_PM_ProductionData.LogoCodeName) LogoCodeName, " +
  7359. " count(TP_PM_ProductionData.Barcode) as BarcodeCount " +
  7360. " from " +
  7361. " ( " +
  7362. " select TP_PM_ProductionData.logoid," +
  7363. " TP_PM_ProductionData.Modeltype, " +
  7364. " TP_PM_ProductionData.Goodsid, " +
  7365. " TP_PM_ProductionData.KilnCarID, " +
  7366. " TP_PM_ProductionData.Kilncode, " +
  7367. " TP_PM_ProductionData.Barcode, " +
  7368. " TP_PM_ProductionData.Usercode, " +
  7369. " replace((Logoname||'['||Logocode||']'),'[]','') as LogoCodeName, " +
  7370. " to_char(TP_PM_ProductionData.CreateTime,'yyyy-mm-dd hh24:mi') CreateTime " +
  7371. " from TP_PM_ProductionData inner join TP_MST_Logo on TP_PM_ProductionData.logoid=TP_MST_Logo.logoid" +
  7372. " left join TP_PM_KilnCarData kcd on kcd.KilnCarBatchNo = TP_PM_ProductionData.KilnCarBatchNo and kcd.ProcedureID = TP_PM_ProductionData.ProcedureID " +
  7373. " where " +
  7374. " TP_PM_ProductionData.Accountid=:AccountID " +
  7375. " and TP_PM_ProductionData.Valueflag=1 " +
  7376. " and TP_PM_ProductionData.Modeltype=:ProcedureModelTypeID ";
  7377. if (se.KilnID.HasValue)
  7378. {
  7379. selSql = selSql + " AND TP_PM_ProductionData.KilnID=:KilnID ";
  7380. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  7381. }
  7382. //if (se.KilnCarID.HasValue)
  7383. //{
  7384. // selSql = selSql + " AND TP_PM_ProductionData.KilnCarID=:KilnCarID ";
  7385. // parameters.Add(new OracleParameter(":KilnCarID", OracleDbType.Int32, se.KilnCarID, ParameterDirection.Input));
  7386. //}
  7387. if (!string.IsNullOrEmpty(se.GoodsIDS))
  7388. {
  7389. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  7390. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  7391. }
  7392. if (!string.IsNullOrEmpty(se.UserIDS))
  7393. {
  7394. selSql = selSql + " AND instr(','||:UserIDS||',',','||kcd.UserID||',')>0 ";
  7395. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  7396. }
  7397. if (se.CreateTimeStart.HasValue)
  7398. {
  7399. selSql = selSql + " AND kcd.CreateTime>= :CreateTimeStart ";
  7400. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  7401. }
  7402. if (se.CreateTimeEnd.HasValue)
  7403. {
  7404. selSql = selSql + " AND kcd.CreateTime<= :CreateTimeEnd ";
  7405. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  7406. }
  7407. selSql = selSql +
  7408. " ) TP_PM_ProductionData " +
  7409. " inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.Proceduremodeltypeid=TP_PM_ProductionData.Modeltype " +
  7410. " inner join TP_MST_Goods on TP_MST_Goods.Goodsid=TP_PM_ProductionData.Goodsid " +
  7411. " inner join TP_MST_GOODSTYPE on TP_MST_GOODSTYPE.GOODSTYPEID=TP_MST_Goods.Goodstypeid " +
  7412. " inner join TP_MST_KilnCar on TP_MST_KilnCar.Kilncarid=TP_PM_ProductionData.KilnCarID " +
  7413. " where 1=1";
  7414. if (!string.IsNullOrEmpty(se.KilnCarCode))
  7415. {
  7416. selSql = selSql + " AND instr(TP_MST_KilnCar.KilnCarCode, :KilnCarCode ) > 0";
  7417. parameters.Add(new OracleParameter(":KilnCarCode", OracleDbType.NVarchar2, se.KilnCarCode, ParameterDirection.Input));
  7418. }
  7419. if (se.KilnCarNumBegin.HasValue && se.KilnCarNumEnd.HasValue && se.KilnCarNumBegin.Value > se.KilnCarNumEnd.Value)
  7420. {
  7421. selSql = selSql + " AND (TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin or TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd)";
  7422. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  7423. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  7424. }
  7425. else
  7426. {
  7427. if (se.KilnCarNumBegin.HasValue)
  7428. {
  7429. selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin ";
  7430. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  7431. }
  7432. if (se.KilnCarNumEnd.HasValue)
  7433. {
  7434. selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd ";
  7435. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  7436. }
  7437. }
  7438. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  7439. {
  7440. //selSql = selSql + " AND instr(','||:goodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1 ";
  7441. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:goodsTypeIDS)=1 ";
  7442. parameters.Add(new OracleParameter(":goodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  7443. }
  7444. selSql = selSql +
  7445. " group by rollup( " +
  7446. " TP_SYS_ProcedureModelType.Proceduremodeltypename, " +
  7447. " TP_PM_ProductionData.Kilncode, " +
  7448. " TP_PM_ProductionData.Usercode, " +
  7449. " TP_MST_KilnCar.Kilncarcode, " +
  7450. " TP_PM_ProductionData.CreateTime, " +
  7451. " TP_MST_GOODSTYPE.GOODSTYPENAME, " +
  7452. " TP_MST_Goods.Goodscode, " +
  7453. " TP_MST_Goods.GOODSSPECIFICATION, " +
  7454. " TP_PM_ProductionData.Barcode, " +
  7455. " TP_PM_ProductionData.LogoCodeName " +
  7456. " ) " +
  7457. " ) temp " +
  7458. "where 1=1 and " +
  7459. "(Barcode !='--' and LogoCodeName!='--') or " +
  7460. "(Barcode='--' and Usercode='合计' and kilncode!='--') or " +
  7461. "(Barcode='--' and Proceduremodeltypename='总计' ) or " +
  7462. "(Barcode='--' and createtime='小计' and temp.usercode!='--')";
  7463. return selSql;
  7464. }
  7465. #region 工序交接数量汇总表
  7466. /// <summary>
  7467. /// 取得RPT030107画面(工序交接数量汇总表)的汇总信息查询数据
  7468. /// </summary>
  7469. /// <param name="user">登录用户信息</param>
  7470. /// <param name="se">查询条件</param>
  7471. /// <returns>查询结果</returns>
  7472. public static ServiceResultEntity GetRPT030107SData(SUserInfo user, RPT030107_SE se)
  7473. {
  7474. IDBConnection conn = null;
  7475. try
  7476. {
  7477. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7478. List<OracleParameter> parameters = new List<OracleParameter>();
  7479. string sql = ReportModuleLogic.GetRPT030107SSQL(user, se, ref parameters);
  7480. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  7481. ServiceResultEntity sre = new ServiceResultEntity();
  7482. if (data == null || data.Rows.Count == 0)
  7483. {
  7484. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7485. return sre;
  7486. }
  7487. sre.Data = new DataSet();
  7488. sre.Data.Tables.Add(data);
  7489. return sre;
  7490. }
  7491. catch (Exception ex)
  7492. {
  7493. throw ex;
  7494. }
  7495. finally
  7496. {
  7497. if (conn != null &&
  7498. conn.ConnState == ConnectionState.Open)
  7499. {
  7500. conn.Close();
  7501. }
  7502. }
  7503. }
  7504. /// <summary>
  7505. /// 获取RPT030107画面(工序交接数量汇总表)的汇总信息查询sql
  7506. /// </summary>
  7507. /// <returns>sql</returns>
  7508. private static string GetRPT030107SSQL(SUserInfo user, RPT030107_SE se, ref List<OracleParameter> parameters)
  7509. {
  7510. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7511. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  7512. string sqlString =
  7513. "SELECT p.procedureid\n" +
  7514. " ,decode(gid,\n" +
  7515. " 7,\n" +
  7516. " '总计',\n" +
  7517. " 3,\n" +
  7518. " '合计【' || p.procedurename || '】',\n" +
  7519. " 1,\n" +
  7520. " '--',\n" +
  7521. " p.procedurename) procedurename\n" +
  7522. " ,decode(gid,\n" +
  7523. " 7,\n" +
  7524. " '--',\n" +
  7525. " 3,\n" +
  7526. " '--',\n" +
  7527. " 1,\n" +
  7528. " '小计【' || p.goodstypename2 || '】',\n" +
  7529. " p.goodstypename2) goodstypename2\n" +
  7530. " ,p.goodstypecode2 \n" +
  7531. " ,decode(gid, 0, p.userid, '--') userid\n" +
  7532. " ,decode(gid, 0, p.usercode, '--') usercode\n" +
  7533. " ,decode(gid, 0, p.goodsid, '--') goodsid\n" +
  7534. " ,decode(gid, 0, p.goodscode, '--') goodscode\n" +
  7535. " ,decode(gid, 0, p.goodstypename, '--') goodstypename\n" +
  7536. " ,p.overcount\n" +
  7537. " FROM (SELECT grouping_id(pdata.Procedureid,pdata.goodstypename2, pdata.Userid) gid\n" +
  7538. " ,pdata.productionlineid\n" +
  7539. " ,pdata.procedureid\n" +
  7540. " ,to_char(pdata.procedurename) procedurename\n" +
  7541. " ,to_char(pdata.userid) userid\n" +
  7542. " ,pdata.usercode\n" +
  7543. " ,to_char(pdata.goodsid) goodsid\n" +
  7544. " ,pdata.goodscode\n" +
  7545. " ,pdata.goodstypename\n" +
  7546. " ,pdata.goodstypecode2\n" +
  7547. " ,pdata.goodstypename2\n" +
  7548. " ,COUNT(pdata.barcode) overcount\n" +
  7549. " FROM (SELECT distinct pd.barcode,pcp.displayno\n" +
  7550. " ,pd.productionlineid\n" +
  7551. " ,pd.procedureid\n" +
  7552. " ,pcp.procedurename\n" +
  7553. (se.DisPUserCode ? " ,pd.userid, pd.usercode \n" : " ,null userid, null usercode \n") +
  7554. //" ,pd.userid\n" +
  7555. //" ,pd.usercode\n" +
  7556. " ,t_over.goodsid\n" +
  7557. " ,t_over.goodscode\n" +
  7558. " ,t_over.goodstypename\n" +
  7559. " ,t_over.goodstypecode2\n" +
  7560. " ,t_over.goodstypename2\n" +
  7561. " FROM tp_pm_productiondata pd\n" +
  7562. " LEFT JOIN tp_pc_procedure pcp\n" +
  7563. " ON pcp.procedureid = pd.procedureid\n" +
  7564. " INNER JOIN (SELECT DISTINCT pd.barcode\n" +
  7565. " ,pd.productiondataid\n" +
  7566. " ,goods.goodsid\n" +
  7567. " ,goods.goodscode\n" +
  7568. " ,gt.goodstypename\n" +
  7569. " ,gt2.goodstypename goodstypename2\n" +
  7570. " ,gt2.goodstypecode goodstypecode2\n" +
  7571. " FROM tp_pm_productiondata pd\n" +
  7572. " LEFT JOIN tp_mst_goods goods\n" +
  7573. " ON goods.goodsid = pd.goodsid\n" +
  7574. " LEFT JOIN tp_mst_goodstype gt\n" +
  7575. " ON goods.goodstypeid = gt.goodstypeid\n" +
  7576. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7577. " ON gt2.goodstypecode = substr(gt.goodstypecode,1,6)\n" +
  7578. " AND gt2.accountid = gt.accountid\n" +
  7579. " --LEFT JOIN tp_pc_procedure pcp\n" +
  7580. " -- ON pcp.procedureid = pd.procedureid\n" +
  7581. ((se.DTimeStart.HasValue || se.DTimeEnd.HasValue) ? " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=pd.groutingdailydetailid \n" : "") +
  7582. " WHERE pd.valueflag = '1'\n" +
  7583. " 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))" +
  7584. " AND pd.accountid = :AccountID\n";
  7585. // 生产线
  7586. if (se.ProductionLineID.HasValue)
  7587. {
  7588. sqlString = sqlString + " AND pd.productionlineid = :productionlineid ";
  7589. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  7590. }
  7591. // 成型工号
  7592. if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
  7593. {
  7594. sqlString = sqlString + " AND instr(pd.GroutingUserCode, :GroutingUserCode) > 0";
  7595. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  7596. }
  7597. // 产品型号
  7598. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  7599. {
  7600. sqlString = sqlString + " AND instr(gt.GOODSTYPECode, :GoodsTypeCode)=1 ";
  7601. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7602. }
  7603. // 产品编码
  7604. if (!string.IsNullOrEmpty(se.GoodsCode))
  7605. {
  7606. sqlString = sqlString + " AND instr(goods.GOODSCode, :GoodsCode) > 0 ";
  7607. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7608. }
  7609. // 交接工序
  7610. if (!string.IsNullOrEmpty(se.OverProcedureIDS))
  7611. {
  7612. sqlString = sqlString + " AND instr(:overprocedureids, ','||pd.procedureid||',')>0 ";
  7613. parameters.Add(new OracleParameter(":overprocedureids", OracleDbType.Varchar2, "," + se.OverProcedureIDS + ",", ParameterDirection.Input));
  7614. }
  7615. // 交接工号
  7616. if (!string.IsNullOrEmpty(se.OverUserIDS))
  7617. {
  7618. sqlString = sqlString + " AND instr(:overuserids, ','||pd.userid||',')>0 ";
  7619. parameters.Add(new OracleParameter(":overuserids", OracleDbType.Varchar2, "," + se.OverUserIDS + ",", ParameterDirection.Input));
  7620. }
  7621. // 交接时间
  7622. if (se.OverTimeStart.HasValue)
  7623. {
  7624. sqlString = sqlString + " AND pd.CreateTime >=:OverTimeStart ";
  7625. parameters.Add(new OracleParameter(":OverTimeStart", OracleDbType.Date, se.OverTimeStart.Value, ParameterDirection.Input));
  7626. }
  7627. if (se.OverTimeEnd.HasValue)
  7628. {
  7629. sqlString = sqlString + " AND pd.CreateTime <= :OverTimeEnd ";
  7630. parameters.Add(new OracleParameter(":OverTimeEnd", OracleDbType.Date, se.OverTimeEnd.Value, ParameterDirection.Input));
  7631. }
  7632. // 注浆时间
  7633. if (se.GTimeStart.HasValue)
  7634. {
  7635. sqlString = sqlString + " AND pd.GROUTINGDATE >=:GTimeStart ";
  7636. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  7637. }
  7638. if (se.GTimeEnd.HasValue)
  7639. {
  7640. sqlString = sqlString + " AND pd.GROUTINGDATE <= :GTimeEnd ";
  7641. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  7642. }
  7643. // 交坯时间
  7644. if (se.DTimeStart.HasValue)
  7645. {
  7646. sqlString = sqlString + " AND gdd.DELIVERTIME >=:DTimeStart ";
  7647. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
  7648. }
  7649. if (se.DTimeEnd.HasValue)
  7650. {
  7651. sqlString = sqlString + " AND gdd.DELIVERTIME <= :DTimeEnd ";
  7652. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
  7653. }
  7654. sqlString = sqlString +
  7655. " ) t_over\n" +
  7656. " ON pd.barcode = t_over.barcode\n" +
  7657. // 交接工序在生产工序后
  7658. " AND pd.productiondataid <= t_over.productiondataid\n" +
  7659. " WHERE pd.valueflag = '1'\n" +
  7660. " AND pd.accountid = :AccountID\n" +
  7661. (se.Specialrepairflag ? " AND ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" : "") +
  7662. " 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))";
  7663. // 生产工序
  7664. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  7665. {
  7666. sqlString = sqlString + " AND instr(:procedureids, ','||pd.procedureid||',')>0 ";
  7667. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  7668. }
  7669. // 生产工号
  7670. if (!string.IsNullOrEmpty(se.UserIDS))
  7671. {
  7672. sqlString = sqlString + " AND instr(:userids, ','||pd.userid||',')>0 ";
  7673. parameters.Add(new OracleParameter(":userids", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
  7674. }
  7675. // 生产时间
  7676. if (se.PTimeStart.HasValue)
  7677. {
  7678. sqlString = sqlString + " AND pd.CreateTime >=:PTimeStart ";
  7679. parameters.Add(new OracleParameter(":PTimeStart", OracleDbType.Date, se.PTimeStart.Value, ParameterDirection.Input));
  7680. }
  7681. if (se.PTimeEnd.HasValue)
  7682. {
  7683. sqlString = sqlString + " AND pd.CreateTime <= :PTimeEnd ";
  7684. parameters.Add(new OracleParameter(":PTimeEnd", OracleDbType.Date, se.PTimeEnd.Value, ParameterDirection.Input));
  7685. }
  7686. sqlString = sqlString +
  7687. "\n ) pdata\n" +
  7688. " 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" +
  7689. " ORDER BY pdata.displayno\n" +
  7690. " ,pdata.goodstypename2\n" +
  7691. " ,pdata.usercode\n" +
  7692. " ,pdata.goodstypename\n" +
  7693. " ,pdata.goodscode) p";
  7694. return sqlString;
  7695. }
  7696. /// <summary>
  7697. /// 取得RPT030107画面(工序交接数量汇总表)的明细信息查询数据
  7698. /// </summary>
  7699. /// <param name="user">登录用户信息</param>
  7700. /// <param name="se">查询条件</param>
  7701. /// <returns>查询结果</returns>
  7702. public static ServiceResultEntity GetRPT030107IData(SUserInfo user, RPT030107_SE se)
  7703. {
  7704. IDBConnection conn = null;
  7705. try
  7706. {
  7707. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7708. List<OracleParameter> parameters = new List<OracleParameter>();
  7709. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030107ISQL(user, se, ref parameters));
  7710. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  7711. ServiceResultEntity sre = new ServiceResultEntity();
  7712. if (data == null || data.Rows.Count == 0)
  7713. {
  7714. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7715. return sre;
  7716. }
  7717. sre.Data = new DataSet();
  7718. sre.Data.Tables.Add(data);
  7719. return sre;
  7720. }
  7721. catch (Exception ex)
  7722. {
  7723. throw ex;
  7724. }
  7725. finally
  7726. {
  7727. if (conn != null &&
  7728. conn.ConnState == ConnectionState.Open)
  7729. {
  7730. conn.Close();
  7731. }
  7732. }
  7733. }
  7734. /// <summary>
  7735. /// 获取RPT030107画面(工序交接数量汇总表)的明细信息查询sql
  7736. /// </summary>
  7737. /// <returns>sql</returns>
  7738. private static string GetRPT030107ISQL(SUserInfo user, RPT030107_SE se, ref List<OracleParameter> parameters)
  7739. {
  7740. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7741. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  7742. string sqlString =
  7743. "SELECT distinct pcp.procedurename,pcp.displayno\n" +
  7744. (se.DisPUserCode ? " ,pd.userid, pd.usercode \n" : " ,null userid, null usercode \n") +
  7745. //" ,pd.usercode\n" +
  7746. " ,t_over.barcode\n" +
  7747. " ,t_over.goodscode\n" +
  7748. " ,t_over.goodstypename\n" +
  7749. " ,t_over.goodstypename2\n" +
  7750. //" ,pd.createtime ptime\n" +
  7751. //" ,t_over.overprocedurename\n" +
  7752. //" ,t_over.overusercode\n" +
  7753. //" ,t_over.overtime\n" +
  7754. " ,t_over.groutingusercode\n" +
  7755. " ,pd.groutinglinecode\n" +
  7756. " ,pd.groutingmouldcode\n" +
  7757. " ,t_over.groutingdate Gdate\n" +
  7758. " ,t_over.DELIVERTIME Ddate\n" +
  7759. " ,decode(logo.logoid, null, '', logo.Logoname||'['||logo.Logocode||']') as LogoCodeName " +
  7760. " FROM tp_pm_productiondata pd\n" +
  7761. " LEFT JOIN tp_pc_procedure pcp\n" +
  7762. " ON pcp.procedureid = pd.procedureid\n" +
  7763. " LEFT JOIN TP_MST_logo logo\n" +
  7764. " ON logo.logoid = pd.logoid\n" +
  7765. " INNER JOIN (SELECT DISTINCT pd.barcode\n" +
  7766. " ,pd.productiondataid\n" +
  7767. " ,goods.goodsid\n" +
  7768. " ,goods.goodscode\n" +
  7769. " ,gt.goodstypename\n" +
  7770. " ,gt2.goodstypename goodstypename2\n" +
  7771. //" ,pcp.procedurename overprocedurename\n" +
  7772. //" ,pd.usercode overusercode\n" +
  7773. //" ,pd.createtime overtime\n" +
  7774. " ,pd.groutingusercode\n" +
  7775. " ,pd.groutingdate\n" +
  7776. " ,gdd.DELIVERTIME\n" +
  7777. " FROM tp_pm_productiondata pd\n" +
  7778. " LEFT JOIN tp_mst_goods goods\n" +
  7779. " ON goods.goodsid = pd.goodsid\n" +
  7780. " LEFT JOIN tp_mst_goodstype gt\n" +
  7781. " ON goods.goodstypeid = gt.goodstypeid\n" +
  7782. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7783. " ON gt2.goodstypecode = substr(gt.goodstypecode,1,6)\n" +
  7784. " AND gt2.accountid = gt.accountid\n" +
  7785. " LEFT JOIN tp_pc_procedure pcp\n" +
  7786. " ON pcp.procedureid = pd.procedureid\n" +
  7787. " INNER JOIN tp_pm_groutingdailydetail gdd\n" +
  7788. " ON gdd.groutingdailydetailid = pd.groutingdailydetailid\n" +
  7789. " WHERE pd.valueflag = '1'\n" +
  7790. " 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))" +
  7791. " AND pd.accountid = :AccountID\n";
  7792. // 生产线
  7793. if (se.ProductionLineID.HasValue)
  7794. {
  7795. sqlString = sqlString + " AND pd.productionlineid = :productionlineid ";
  7796. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  7797. }
  7798. // 成型工号
  7799. if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
  7800. {
  7801. sqlString = sqlString + " AND instr(pd.GroutingUserCode, :GroutingUserCode) > 0";
  7802. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  7803. }
  7804. // 产品型号
  7805. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  7806. {
  7807. sqlString = sqlString + " AND instr(gt.GOODSTYPECode, :GoodsTypeCode)=1 ";
  7808. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7809. }
  7810. if (!string.IsNullOrEmpty(se.GoodsID))
  7811. {
  7812. sqlString = sqlString + " AND pd.goodsid = :GoodsID ";
  7813. parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  7814. }
  7815. // 产品编码
  7816. if (!string.IsNullOrEmpty(se.GoodsCode))
  7817. {
  7818. sqlString = sqlString + " AND instr(goods.GOODSCode, :GoodsCode) > 0 ";
  7819. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7820. }
  7821. // 交接工序
  7822. if (!string.IsNullOrEmpty(se.OverProcedureIDS))
  7823. {
  7824. sqlString = sqlString + " AND instr(:overprocedureids, ','||pd.procedureid||',')>0 ";
  7825. parameters.Add(new OracleParameter(":overprocedureids", OracleDbType.Varchar2, "," + se.OverProcedureIDS + ",", ParameterDirection.Input));
  7826. }
  7827. // 交接工号
  7828. if (!string.IsNullOrEmpty(se.OverUserIDS))
  7829. {
  7830. sqlString = sqlString + " AND instr(:overuserids, ','||pd.userid||',')>0 ";
  7831. parameters.Add(new OracleParameter(":overuserids", OracleDbType.Varchar2, "," + se.OverUserIDS + ",", ParameterDirection.Input));
  7832. }
  7833. // 交接时间
  7834. if (se.OverTimeStart.HasValue)
  7835. {
  7836. sqlString = sqlString + " AND pd.CreateTime >=:OverTimeStart ";
  7837. parameters.Add(new OracleParameter(":OverTimeStart", OracleDbType.Date, se.OverTimeStart.Value, ParameterDirection.Input));
  7838. }
  7839. if (se.OverTimeEnd.HasValue)
  7840. {
  7841. sqlString = sqlString + " AND pd.CreateTime <= :OverTimeEnd ";
  7842. parameters.Add(new OracleParameter(":OverTimeEnd", OracleDbType.Date, se.OverTimeEnd.Value, ParameterDirection.Input));
  7843. }
  7844. // 注浆时间
  7845. if (se.GTimeStart.HasValue)
  7846. {
  7847. sqlString = sqlString + " AND pd.GROUTINGDATE >=:GTimeStart ";
  7848. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  7849. }
  7850. if (se.GTimeEnd.HasValue)
  7851. {
  7852. sqlString = sqlString + " AND pd.GROUTINGDATE <= :GTimeEnd ";
  7853. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  7854. }
  7855. // 交坯时间
  7856. if (se.DTimeStart.HasValue)
  7857. {
  7858. sqlString = sqlString + " AND gdd.DELIVERTIME >=:DTimeStart ";
  7859. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
  7860. }
  7861. if (se.DTimeEnd.HasValue)
  7862. {
  7863. sqlString = sqlString + " AND gdd.DELIVERTIME <= :DTimeEnd ";
  7864. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
  7865. }
  7866. sqlString = sqlString +
  7867. " ) t_over\n" +
  7868. " ON pd.barcode = t_over.barcode\n" +
  7869. // 交接工序在生产工序后
  7870. " AND pd.productiondataid <= t_over.productiondataid\n" +
  7871. " WHERE pd.valueflag = '1'\n" +
  7872. " AND pd.accountid = :AccountID\n" +
  7873. (se.Specialrepairflag ? " AND ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" : "") +
  7874. " 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))";
  7875. // 生产工序
  7876. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  7877. {
  7878. sqlString = sqlString + " AND instr(:procedureids, ','||pd.procedureid||',')>0 ";
  7879. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  7880. }
  7881. // 生产工号
  7882. if (!string.IsNullOrEmpty(se.UserIDS))
  7883. {
  7884. sqlString = sqlString + " AND instr(:userids, ','||pd.userid||',')>0 ";
  7885. parameters.Add(new OracleParameter(":userids", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
  7886. }
  7887. // 生产时间
  7888. if (se.PTimeStart.HasValue)
  7889. {
  7890. sqlString = sqlString + " AND pd.CreateTime >=:PTimeStart ";
  7891. parameters.Add(new OracleParameter(":PTimeStart", OracleDbType.Date, se.PTimeStart.Value, ParameterDirection.Input));
  7892. }
  7893. if (se.PTimeEnd.HasValue)
  7894. {
  7895. sqlString = sqlString + " AND pd.CreateTime <= :PTimeEnd ";
  7896. parameters.Add(new OracleParameter(":PTimeEnd", OracleDbType.Date, se.PTimeEnd.Value, ParameterDirection.Input));
  7897. }
  7898. sqlString = sqlString +
  7899. "\n ORDER BY pcp.displayno\n" +
  7900. " ,t_over.goodstypename2\n" +
  7901. (se.DisPUserCode ? " ,pd.usercode\n" : "") +
  7902. " ,t_over.goodstypename\n" +
  7903. " ,t_over.goodscode\n";
  7904. return sqlString;
  7905. }
  7906. #endregion
  7907. /// <summary>
  7908. /// 取得RPT030108画面(成型信息汇总表)的查询数据
  7909. /// </summary>
  7910. /// <param name="user">登录用户信息</param>
  7911. /// <param name="se">查询条件</param>
  7912. /// <returns>查询结果</returns>
  7913. public static ServiceResultEntity GetRPT030108SData(SUserInfo user, RPT030108_SE se)
  7914. {
  7915. IDBConnection conn = null;
  7916. try
  7917. {
  7918. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7919. List<OracleParameter> parameters = new List<OracleParameter>();
  7920. string sqlString = "SELECT decode(g.gid,\n" +
  7921. " 7,\n" +
  7922. " '总计',\n" +
  7923. " 3,\n" +
  7924. " '合计【' || g.goodstypename2 || '】',\n" +
  7925. " 0,\n" +
  7926. " g.goodstypename2,\n" +
  7927. " '--') goodstypename2\n" +
  7928. " ,decode(g.gid, 0, g.goodstypename, '--') goodstypename\n" +
  7929. " ,decode(g.gid,\n" +
  7930. " 1,\n" +
  7931. " '小计【' || g.goodscode || '】',\n" +
  7932. " 0,\n" +
  7933. " g.goodscode,\n" +
  7934. " '--') goodscode\n" +
  7935. " ,decode(g.gid, 0, g.usercode, '--') usercode\n" +
  7936. " ,decode(g.gid, 0, g.MONITORName, '--') MONITORName\n" +
  7937. " ,g.groutingcount\n" +
  7938. " ,g.barcodecount\n" +
  7939. " ,g.scrapcount\n" +
  7940. " ,g.barscrapcount\n" +
  7941. " ,g.delivercount\n" +
  7942. " ,g.barcodecount - g.barscrapcount - g.delivercount incount\n" +
  7943. " FROM (SELECT grouping_id(gdd.goodstypename2, gdd.goodscode, gdd.usercode) gid\n" +
  7944. " ,gdd.goodstypename2\n" +
  7945. " ,gdd.goodstypename\n" +
  7946. " ,gdd.goodscode\n" +
  7947. " ,gdd.usercode\n" +
  7948. " ,gdd.MONITORName\n" +
  7949. " ,SUM(groutingcount) groutingcount\n" +
  7950. " ,SUM(barcodecount) barcodecount\n" +
  7951. " ,SUM(scrapcount) scrapcount\n" +
  7952. " ,SUM(barscrapcount) barscrapcount\n" +
  7953. " ,SUM(delivercount) delivercount\n" +
  7954. " FROM (SELECT gt2.goodstypename goodstypename2\n" +
  7955. " ,gdd.usercode\n" +
  7956. " ,mu.usercode as MONITORName\n" +
  7957. " ,goods.goodscode\n" +
  7958. " ,gt.goodstypename\n" +
  7959. " , CASE\n" +
  7960. " WHEN gdd.groutingdate >= :gdatabegin AND\n" +
  7961. " gdd.groutingdate <= :gdataend THEN\n" +
  7962. " 1\n" +
  7963. " ELSE\n" +
  7964. " 0\n" +
  7965. " END groutingcount\n" +
  7966. " , CASE\n" +
  7967. " WHEN gdd.groutingdate >= :gdatabegin AND\n" +
  7968. " gdd.groutingdate <= :gdataend AND\n" +
  7969. " gdd.barcode IS NOT NULL THEN\n" +
  7970. " 1\n" +
  7971. " ELSE\n" +
  7972. " 0\n" +
  7973. " END barcodecount\n" +
  7974. " , CASE\n" +
  7975. " WHEN gdd.scraptime >= :sdatabegin AND\n" +
  7976. " gdd.scraptime <= :sdataend AND\n" +
  7977. " gdd.scrapflag = '1' THEN\n" +
  7978. " 1\n" +
  7979. " ELSE\n" +
  7980. " 0\n" +
  7981. " END scrapcount\n" +
  7982. " , CASE\n" +
  7983. " WHEN gdd.scraptime >= :sdatabegin AND\n" +
  7984. " gdd.scraptime <= :sdataend AND\n" +
  7985. " gdd.barcode IS NOT NULL AND gdd.scrapflag = '1' THEN\n" +
  7986. " 1\n" +
  7987. " ELSE\n" +
  7988. " 0\n" +
  7989. " END barscrapcount\n" +
  7990. " , CASE\n" +
  7991. " WHEN gdd.delivertime >= :ddatabegin AND\n" +
  7992. " gdd.delivertime <= :ddataend AND\n" +
  7993. " gdd.deliverflag = '1' THEN\n" +
  7994. " 1\n" +
  7995. " ELSE\n" +
  7996. " 0\n" +
  7997. " END delivercount\n" +
  7998. " FROM tp_pm_groutingdailydetail gdd\n" +
  7999. " LEFT JOIN tp_mst_goods goods\n" +
  8000. " ON goods.goodsid = gdd.goodsid\n" +
  8001. // 成型线
  8002. " LEFT JOIN tp_pc_groutingline gl" +
  8003. " ON gl.groutinglineid = GDD.GroutingLineID" +
  8004. // 成型班长
  8005. " LEFT JOIN tp_mst_user mu" +
  8006. " ON mu.userid = gl.MONITORID " +
  8007. " LEFT JOIN tp_mst_goodstype gt\n" +
  8008. " ON gt.goodstypeid = goods.goodstypeid\n" +
  8009. " LEFT JOIN tp_mst_goodstype gt2\n" +
  8010. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  8011. " AND gt2.accountid = gt.accountid\n" +
  8012. " WHERE gdd.valueflag = '1'\n" +
  8013. " AND gdd.groutingflag = '1'\n" +
  8014. " AND gdd.accountid = :accountid\n" +
  8015. " AND ((gdd.groutingdate >= :gdatabegin AND\n" +
  8016. " gdd.groutingdate <= :gdataend) OR\n" +
  8017. " (gdd.scraptime >= :sdatabegin AND\n" +
  8018. " gdd.scraptime <= :sdataend) OR\n" +
  8019. " (gdd.delivertime >= :ddatabegin AND\n" +
  8020. " gdd.delivertime <= :ddataend))\n" +
  8021. " AND (:usercode IS NULL OR\n" +
  8022. " instr(gdd.usercode, :usercode) > 0)\n" +
  8023. " AND (:GoodsCode IS NULL OR\n" +
  8024. " instr(goods.GoodsCode, :GoodsCode) > 0)\n" +
  8025. " AND (:goodstypecode IS NULL OR\n" +
  8026. " instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  8027. " ORDER BY gt2.goodstypename\n" +
  8028. " ,gt.goodstypename\n" +
  8029. " ,goods.goodscode\n" +
  8030. " ,gdd.usercode) gdd\n" +
  8031. " GROUP BY GROUPING SETS((gdd.goodstypename2, gdd.goodstypename, gdd.goodscode, gdd.usercode,gdd.MONITORName),(gdd.goodstypename2, gdd.goodstypename, gdd.goodscode),(gdd.goodstypename2),())\n" +
  8032. " ORDER BY gdd.goodstypename2\n" +
  8033. " ,gdd.goodstypename\n" +
  8034. " ,gdd.goodscode\n" +
  8035. " ,gdd.usercode) g";
  8036. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8037. parameters.Add(new OracleParameter(":gdatabegin", OracleDbType.Date, se.GTimeStart, ParameterDirection.Input));
  8038. parameters.Add(new OracleParameter(":gdataend", OracleDbType.Date, se.GTimeEnd, ParameterDirection.Input));
  8039. parameters.Add(new OracleParameter(":sdatabegin", OracleDbType.Date, se.STimeStart, ParameterDirection.Input));
  8040. parameters.Add(new OracleParameter(":sdataend", OracleDbType.Date, se.STimeEnd, ParameterDirection.Input));
  8041. parameters.Add(new OracleParameter(":ddatabegin", OracleDbType.Date, se.DTimeStart, ParameterDirection.Input));
  8042. parameters.Add(new OracleParameter(":ddataend", OracleDbType.Date, se.DTimeEnd, ParameterDirection.Input));
  8043. parameters.Add(new OracleParameter(":usercode", OracleDbType.Varchar2, se.UserCode, ParameterDirection.Input));
  8044. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  8045. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  8046. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  8047. ServiceResultEntity sre = new ServiceResultEntity();
  8048. if (data == null || data.Rows.Count == 0)
  8049. {
  8050. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8051. return sre;
  8052. }
  8053. sre.Data = new DataSet();
  8054. sre.Data.Tables.Add(data);
  8055. return sre;
  8056. }
  8057. catch (Exception ex)
  8058. {
  8059. throw ex;
  8060. }
  8061. finally
  8062. {
  8063. if (conn != null &&
  8064. conn.ConnState == ConnectionState.Open)
  8065. {
  8066. conn.Close();
  8067. }
  8068. }
  8069. }
  8070. #region 撤销产品汇总表
  8071. /// <summary>
  8072. /// 取得RPT030109画面(撤销产品汇总表)的汇总信息查询数据
  8073. /// </summary>
  8074. /// <param name="user">登录用户信息</param>
  8075. /// <param name="se">查询条件</param>
  8076. /// <returns>查询结果</returns>
  8077. public static ServiceResultEntity GetRPT030109SData(SUserInfo user, RPT030109_SE se)
  8078. {
  8079. IDBConnection conn = null;
  8080. try
  8081. {
  8082. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8083. List<OracleParameter> parameters = new List<OracleParameter>();
  8084. string sql = ReportModuleLogic.GetRPT030109SSQL(user, se, ref parameters);
  8085. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  8086. ServiceResultEntity sre = new ServiceResultEntity();
  8087. if (data == null || data.Rows.Count == 0)
  8088. {
  8089. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8090. return sre;
  8091. }
  8092. sre.Data = new DataSet();
  8093. sre.Data.Tables.Add(data);
  8094. return sre;
  8095. }
  8096. catch (Exception ex)
  8097. {
  8098. throw ex;
  8099. }
  8100. finally
  8101. {
  8102. if (conn != null &&
  8103. conn.ConnState == ConnectionState.Open)
  8104. {
  8105. conn.Close();
  8106. }
  8107. }
  8108. }
  8109. /// <summary>
  8110. /// 获取RPT030109画面(撤销产品汇总表)的汇总信息查询sql
  8111. /// </summary>
  8112. /// <returns>sql</returns>
  8113. private static string GetRPT030109SSQL(SUserInfo user, RPT030109_SE se, ref List<OracleParameter> parameters)
  8114. {
  8115. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8116. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  8117. string sqlString =
  8118. "SELECT decode(p.gid,\n" +
  8119. " 7,\n" +
  8120. " '总计',\n" +
  8121. " 3,\n" +
  8122. " '合计【' || p.procedurename || '】',\n" +
  8123. " 0,\n" +
  8124. " p.procedurename,\n" +
  8125. " '--') procedurename\n" +
  8126. " ,decode(p.gid,\n" +
  8127. " 1,\n" +
  8128. " '小计【' || p.goodstypename2 || '】',\n" +
  8129. " 0,\n" +
  8130. " p.goodstypename2,\n" +
  8131. " '--') goodstypename2\n" +
  8132. " ,decode(p.gid, 0, p.goodstypename, '--') goodstypename\n" +
  8133. " ,decode(p.gid, 0, p.goodscode, '--') goodscode\n" +
  8134. " ,decode(p.gid, 0, p.usercode, '--') usercode\n" +
  8135. " ,p.codecount\n" +
  8136. " ,p.productionlineid\n" +
  8137. " ,p.procedureid\n" +
  8138. " ,p.goodstypecode2\n" +
  8139. " ,p.goodsid\n" +
  8140. " ,p.userid\n" +
  8141. " FROM (SELECT grouping_id(pd.procedureid, gt2.goodstypecode, pd.userid) gid\n" +
  8142. " ,pd.productionlineid\n" +
  8143. " ,pd.procedureid\n" +
  8144. " ,p.procedurename\n" +
  8145. " ,p.displayno\n" +
  8146. " ,gt2.goodstypecode goodstypecode2\n" +
  8147. " ,gt2.goodstypename goodstypename2\n" +
  8148. " ,gt.goodstypecode\n" +
  8149. " ,gt.goodstypename\n" +
  8150. " ,goods.goodsid\n" +
  8151. " ,goods.goodscode\n" +
  8152. " ,pd.userid\n" +
  8153. " ,pd.usercode\n" +
  8154. " ,COUNT(*) codecount\n" +
  8155. " FROM tp_pm_productiondata pd\n" +
  8156. " LEFT JOIN tp_pc_procedure p\n" +
  8157. " ON p.procedureid = pd.procedureid\n" +
  8158. " LEFT JOIN tp_mst_goods goods\n" +
  8159. " ON goods.goodsid = pd.goodsid\n" +
  8160. " LEFT JOIN tp_mst_goodstype gt\n" +
  8161. " ON gt.goodstypeid = goods.goodstypeid\n" +
  8162. " LEFT JOIN tp_mst_goodstype gt2\n" +
  8163. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  8164. " AND gt2.accountid = gt.accountid\n" +
  8165. " WHERE pd.valueflag = '0'\n" +
  8166. " AND pd.accountid = :accountid\n" +
  8167. " 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))" +
  8168. " 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))" +
  8169. " AND (:productionlineid IS NULL OR\n" +
  8170. " pd.productionlineid = :productionlineid)\n" +
  8171. " AND (:procedureids IS NULL OR\n" +
  8172. " instr(:procedureids, ',' || pd.procedureid || ',') > 0)\n" +
  8173. " AND (:goodstypecode IS NULL OR\n" +
  8174. " instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  8175. " AND (:goodscode IS NULL OR\n" +
  8176. " instr(goods.goodscode, :goodscode) > 0)\n" +
  8177. " AND (:PUserIDS IS NULL OR\n" +
  8178. " instr(:PUserIDS, ',' || pd.userid || ',') > 0)\n" +
  8179. " AND (:backusercode IS NULL OR\n" +
  8180. " instr(pd.BACKOUTUSERCODE, :backusercode) > 0)\n" +
  8181. " AND (:ptimebegin IS NULL OR pd.createtime >= :ptimebegin)\n" +
  8182. " AND (:ptimeend IS NULL OR pd.createtime <= :ptimeend)\n" +
  8183. " AND (:backtimebegin IS NULL OR pd.backouttime >= :backtimebegin)\n" +
  8184. " AND (:backtimeend IS NULL OR pd.backouttime <= :backtimeend)\n" +
  8185. " 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" +
  8186. " ORDER BY p.displayno\n" +
  8187. " ,gt2.goodstypecode\n" +
  8188. " ,gt.goodstypecode\n" +
  8189. " ,goods.goodscode\n" +
  8190. " ,pd.usercode) p";
  8191. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  8192. if (string.IsNullOrEmpty(se.ProcedureIDS))
  8193. {
  8194. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, null, ParameterDirection.Input));
  8195. }
  8196. else
  8197. {
  8198. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  8199. }
  8200. if (string.IsNullOrEmpty(se.UserIDS))
  8201. {
  8202. parameters.Add(new OracleParameter(":PUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  8203. }
  8204. else
  8205. {
  8206. parameters.Add(new OracleParameter(":PUserIDS", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
  8207. }
  8208. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  8209. parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  8210. parameters.Add(new OracleParameter(":backusercode", OracleDbType.Varchar2, se.BackUserCode, ParameterDirection.Input));
  8211. parameters.Add(new OracleParameter(":ptimebegin", OracleDbType.Date, se.PTimeStart, ParameterDirection.Input));
  8212. parameters.Add(new OracleParameter(":ptimeend", OracleDbType.Date, se.PTimeEnd, ParameterDirection.Input));
  8213. parameters.Add(new OracleParameter(":backtimebegin", OracleDbType.Date, se.BackTimeStart, ParameterDirection.Input));
  8214. parameters.Add(new OracleParameter(":backtimeend", OracleDbType.Date, se.BackTimeEnd, ParameterDirection.Input));
  8215. return sqlString;
  8216. }
  8217. /// <summary>
  8218. /// 取得RPT030109画面(撤销产品汇总表)的明细信息查询数据
  8219. /// </summary>
  8220. /// <param name="user">登录用户信息</param>
  8221. /// <param name="se">查询条件</param>
  8222. /// <returns>查询结果</returns>
  8223. public static ServiceResultEntity GetRPT030109IData(SUserInfo user, RPT030109_SE se)
  8224. {
  8225. IDBConnection conn = null;
  8226. try
  8227. {
  8228. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8229. List<OracleParameter> parameters = new List<OracleParameter>();
  8230. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030109ISQL(user, se, ref parameters));
  8231. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  8232. ServiceResultEntity sre = new ServiceResultEntity();
  8233. if (data == null || data.Rows.Count == 0)
  8234. {
  8235. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8236. return sre;
  8237. }
  8238. sre.Data = new DataSet();
  8239. sre.Data.Tables.Add(data);
  8240. return sre;
  8241. }
  8242. catch (Exception ex)
  8243. {
  8244. throw ex;
  8245. }
  8246. finally
  8247. {
  8248. if (conn != null &&
  8249. conn.ConnState == ConnectionState.Open)
  8250. {
  8251. conn.Close();
  8252. }
  8253. }
  8254. }
  8255. /// <summary>
  8256. /// 获取RPT030109画面(撤销产品汇总表)的明细信息查询sql
  8257. /// </summary>
  8258. /// <returns>sql</returns>
  8259. private static string GetRPT030109ISQL(SUserInfo user, RPT030109_SE se, ref List<OracleParameter> parameters)
  8260. {
  8261. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8262. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  8263. string sqlString =
  8264. "SELECT p.procedurename\n" +
  8265. " ,gt2.goodstypename goodstypename2\n" +
  8266. " ,gt.goodstypename\n" +
  8267. " ,goods.goodscode\n" +
  8268. " ,pd.barcode\n" +
  8269. " ,pd.usercode\n" +
  8270. " ,pd.createtime ptime\n" +
  8271. " ,pd.backoutusercode busercode\n" +
  8272. " ,pd.backouttime btime\n" +
  8273. " ,pd.groutingusercode\n" +
  8274. " ,pd.groutinglinecode\n" +
  8275. " ,pd.groutingmouldcode\n" +
  8276. " ,pd.groutingdate GDate\n" +
  8277. " FROM tp_pm_productiondata pd\n" +
  8278. " LEFT JOIN tp_pc_procedure p\n" +
  8279. " ON p.procedureid = pd.procedureid\n" +
  8280. " LEFT JOIN tp_mst_goods goods\n" +
  8281. " ON goods.goodsid = pd.goodsid\n" +
  8282. " LEFT JOIN tp_mst_goodstype gt\n" +
  8283. " ON gt.goodstypeid = goods.goodstypeid\n" +
  8284. " LEFT JOIN tp_mst_goodstype gt2\n" +
  8285. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  8286. " AND gt2.accountid = gt.accountid\n" +
  8287. " WHERE pd.valueflag = '0'\n" +
  8288. " AND pd.accountid = :accountid\n" +
  8289. " 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))" +
  8290. " 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))" +
  8291. " AND (:productionlineid IS NULL OR\n" +
  8292. " pd.productionlineid = :productionlineid)\n" +
  8293. " AND (:procedureids IS NULL OR\n" +
  8294. " instr(:procedureids, ',' || pd.procedureid || ',') > 0)\n" +
  8295. " AND (:goodstypecode IS NULL OR\n" +
  8296. " instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  8297. " AND (:goodscode IS NULL OR instr(goods.goodscode, :goodscode) > 0)\n" +
  8298. " AND (:PUserIDS IS NULL OR\n" +
  8299. " instr(:PUserIDS, ',' || pd.userid || ',') > 0)\n" +
  8300. " AND (:backusercode IS NULL OR instr(pd.BACKOUTUSERCODE, :backusercode) > 0)\n" +
  8301. " AND (:ptimebegin IS NULL OR pd.createtime >= :ptimebegin)\n" +
  8302. " AND (:ptimeend IS NULL OR pd.createtime <= :ptimeend)\n" +
  8303. " AND (:backtimebegin IS NULL OR pd.backouttime >= :backtimebegin)\n" +
  8304. " AND (:backtimeend IS NULL OR pd.backouttime <= :backtimeend)\n" +
  8305. " AND (:puserid IS NULL OR pd.userid = :puserid)\n" +
  8306. " AND (:goodsid IS NULL OR pd.goodsid = :goodsid)\n" +
  8307. " AND (:procedureid IS NULL OR pd.procedureid = :procedureid)\n" +
  8308. " ORDER BY p.displayno\n" +
  8309. " ,gt2.goodstypename\n" +
  8310. " ,gt.goodstypename\n" +
  8311. " ,goods.goodscode\n" +
  8312. " ,pd.usercode\n" +
  8313. " ,pd.barcode\n" +
  8314. " ,pd.backoutusercode\n" +
  8315. " ,pd.backouttime";
  8316. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  8317. if (string.IsNullOrEmpty(se.ProcedureIDS))
  8318. {
  8319. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, null, ParameterDirection.Input));
  8320. }
  8321. else
  8322. {
  8323. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  8324. }
  8325. if (string.IsNullOrEmpty(se.UserIDS))
  8326. {
  8327. parameters.Add(new OracleParameter(":PUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  8328. }
  8329. else
  8330. {
  8331. parameters.Add(new OracleParameter(":PUserIDS", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
  8332. }
  8333. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  8334. parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  8335. parameters.Add(new OracleParameter(":backusercode", OracleDbType.Varchar2, se.BackUserCode, ParameterDirection.Input));
  8336. parameters.Add(new OracleParameter(":ptimebegin", OracleDbType.Date, se.PTimeStart, ParameterDirection.Input));
  8337. parameters.Add(new OracleParameter(":ptimeend", OracleDbType.Date, se.PTimeEnd, ParameterDirection.Input));
  8338. parameters.Add(new OracleParameter(":backtimebegin", OracleDbType.Date, se.BackTimeStart, ParameterDirection.Input));
  8339. parameters.Add(new OracleParameter(":backtimeend", OracleDbType.Date, se.BackTimeEnd, ParameterDirection.Input));
  8340. parameters.Add(new OracleParameter(":puserid", OracleDbType.Int32, se.UserID, ParameterDirection.Input));
  8341. parameters.Add(new OracleParameter(":goodsid", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  8342. parameters.Add(new OracleParameter(":procedureid", OracleDbType.Int32, se.ProcedureID, ParameterDirection.Input));
  8343. return sqlString;
  8344. }
  8345. #endregion
  8346. /// <summary>
  8347. /// 工序收发存汇总表(初始化数据)
  8348. /// </summary>
  8349. /// <param name="user"></param>
  8350. /// <returns></returns>
  8351. public static ServiceResultEntity GetRPT030111IData(SUserInfo user)
  8352. {
  8353. IDBConnection conn = null;
  8354. try
  8355. {
  8356. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8357. OracleParameter[] parameters = new OracleParameter[]
  8358. {
  8359. new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  8360. };
  8361. string sqlString =
  8362. "SELECT t.ptid, t.name\n" +
  8363. " FROM tp_mst_rpt_transfer t\n" +
  8364. " WHERE t.AccountID = :AccountID\n" +
  8365. " AND t.valueflag = '1'\n" +
  8366. " ORDER BY t.displayno desc";
  8367. DataSet data = conn.GetSqlResultToDs(sqlString, parameters);
  8368. ServiceResultEntity sre = new ServiceResultEntity();
  8369. //if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  8370. //{
  8371. // sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8372. // return sre;
  8373. //}
  8374. sre.Data = data;
  8375. return sre;
  8376. }
  8377. catch (Exception ex)
  8378. {
  8379. throw ex;
  8380. }
  8381. finally
  8382. {
  8383. if (conn != null &&
  8384. conn.ConnState == ConnectionState.Open)
  8385. {
  8386. conn.Close();
  8387. }
  8388. }
  8389. }
  8390. /// <summary>
  8391. /// 工序收发存汇总表
  8392. /// </summary>
  8393. /// <param name="user"></param>
  8394. /// <param name="se"></param>
  8395. /// <returns></returns>
  8396. public static ServiceResultEntity GetRPT030111SData(SUserInfo user, RPT030111_SE se)
  8397. {
  8398. IDBTransaction conn = null;
  8399. try
  8400. {
  8401. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  8402. conn.Connect();
  8403. OracleParameter[] parameters = new OracleParameter[]
  8404. {
  8405. new OracleParameter("in_accountid", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  8406. new OracleParameter("in_ptid", OracleDbType.Int32, se.PTID, ParameterDirection.Input),
  8407. //new OracleParameter("in_datetimeinit", OracleDbType.Date, se.GTimeInit, ParameterDirection.Input),
  8408. new OracleParameter("in_datetimebegin", OracleDbType.Date, se.GTimeStart , ParameterDirection.Input),
  8409. new OracleParameter("in_datetimeend", OracleDbType.Date, se.GTimeEnd , ParameterDirection.Input),
  8410. new OracleParameter("in_goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode , ParameterDirection.Input),
  8411. new OracleParameter("in_goodscode", OracleDbType.Varchar2, se.GoodsCode , ParameterDirection.Input),
  8412. new OracleParameter("out_data", OracleDbType.RefCursor, null, ParameterDirection.Output),
  8413. };
  8414. DataSet data = conn.ExecStoredProcedure("pro_rpt_gettransfers_sum_c", parameters);
  8415. ServiceResultEntity sre = new ServiceResultEntity();
  8416. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  8417. {
  8418. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8419. return sre;
  8420. }
  8421. //StringBuilder intdids = new StringBuilder();
  8422. //foreach (DataRow row in data.Tables[0].Rows)
  8423. //{
  8424. // if (intdids.Length > 0)
  8425. // {
  8426. // intdids.Append(", ");
  8427. // }
  8428. // intdids.Append(row["tdid"] + " AS \"" + row["name"] + "\"\n");
  8429. //}
  8430. //string sqlString =
  8431. // "WITH ttm AS\n" +
  8432. // " (SELECT *\n" +
  8433. // " FROM TMP_RPT_TECDEP_D\n" +
  8434. // " pivot(SUM(m)\n" +
  8435. // " FOR intdid IN(" + intdids + ")))\n" +
  8436. // "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" +
  8437. // " FROM TMP_RPT_TECDEP_T t\n" +
  8438. // " LEFT JOIN ttm m\n" +
  8439. // " ON m.goodsid = t.goodsid\n" +
  8440. // " AND m.outtdid = t.tecdepid\n" +
  8441. // " ORDER BY t.goodscode, t.displayno";
  8442. //data = conn.GetSqlResultToDs(sqlString);
  8443. //if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  8444. //{
  8445. // sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8446. // return sre;
  8447. //}
  8448. conn.Commit();
  8449. sre.Data = data;
  8450. return sre;
  8451. }
  8452. catch (Exception ex)
  8453. {
  8454. throw ex;
  8455. }
  8456. finally
  8457. {
  8458. if (conn != null &&
  8459. conn.ConnState == ConnectionState.Open)
  8460. {
  8461. conn.Disconnect();
  8462. }
  8463. }
  8464. }
  8465. #endregion 汇总报表
  8466. #region 公共函数
  8467. /// <summary>
  8468. /// 取得报表的查询数据源统计工序数据
  8469. /// </summary>
  8470. /// <param name="user">登录用户信息</param>
  8471. /// <param name="se">查询条件</param>
  8472. /// <returns>查询结果</returns>
  8473. public static ServiceResultEntity GetRptSourceProcedureModule(SUserInfo user, int? RptProcedureID)
  8474. {
  8475. IDBConnection conn = null;
  8476. try
  8477. {
  8478. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8479. OracleParameter[] paras = new OracleParameter[]{
  8480. new OracleParameter("in_rptProcedureId",OracleDbType.Int32,RptProcedureID,ParameterDirection.Input),
  8481. new OracleParameter("out_rptSResult",OracleDbType.RefCursor, ParameterDirection.Output),
  8482. new OracleParameter("out_rptTresult",OracleDbType.RefCursor, ParameterDirection.Output),
  8483. };
  8484. DataSet data = conn.ExecStoredProcedure("PRO_MST_GetRptProcedureBYID", paras);
  8485. ServiceResultEntity sre = new ServiceResultEntity();
  8486. if (data == null || data.Tables.Count == 0)
  8487. {
  8488. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8489. return sre;
  8490. }
  8491. sre.Data = new DataSet();
  8492. sre.Data = data;
  8493. return sre;
  8494. }
  8495. catch (Exception ex)
  8496. {
  8497. throw ex;
  8498. }
  8499. finally
  8500. {
  8501. if (conn != null &&
  8502. conn.ConnState == ConnectionState.Open)
  8503. {
  8504. conn.Close();
  8505. }
  8506. }
  8507. }
  8508. /// <summary>
  8509. /// 取得报表数据源数据
  8510. /// </summary>
  8511. /// <param name="user">登录用户信息</param>
  8512. /// <returns>查询结果</returns>
  8513. public static ServiceResultEntity GetRptProcedureModule(SUserInfo user)
  8514. {
  8515. IDBConnection conn = null;
  8516. try
  8517. {
  8518. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8519. string selSql = " select "
  8520. + " TP_MST_RptProcedure.Rptprocedureid,"
  8521. + " TP_MST_RptProcedure.Rptprocedurecode,"
  8522. + " TP_MST_RptProcedure.Rptprocedurename,"
  8523. + " TP_MST_RptProcedure.Rptproceduretype,"
  8524. + " decode(TP_MST_RptProcedure.Rptproceduretype,'A0001','出窑统计','质量统计') RptproceduretypeName,"
  8525. + " (select wm_concat(s.procedureid) sprocedureid from tp_mst_rptsprocedure s where s.rptprocedureid = TP_MST_RptProcedure.Rptprocedureid) sprocedureid,"
  8526. + " (select wm_concat(t.procedureid) tprocedureid from tp_mst_rpttprocedure t where t.rptprocedureid = TP_MST_RptProcedure.Rptprocedureid) tprocedureid,"
  8527. + " TP_MST_RptProcedure.Optimestamp "
  8528. + " from TP_MST_RptProcedure "
  8529. + " where TP_MST_RptProcedure.ValueFlag=1 "
  8530. + " and TP_MST_RptProcedure.AccountID=:accountID order by TP_MST_RptProcedure.displayno";
  8531. List<OracleParameter> parameters = new List<OracleParameter>();
  8532. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8533. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8534. ServiceResultEntity sre = new ServiceResultEntity();
  8535. if (data == null || data.Rows.Count == 0)
  8536. {
  8537. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8538. return sre;
  8539. }
  8540. sre.Data = new DataSet();
  8541. sre.Data.Tables.Add(data);
  8542. return sre;
  8543. }
  8544. catch (Exception ex)
  8545. {
  8546. throw ex;
  8547. }
  8548. finally
  8549. {
  8550. if (conn != null &&
  8551. conn.ConnState == ConnectionState.Open)
  8552. {
  8553. conn.Close();
  8554. }
  8555. }
  8556. }
  8557. /// <summary>
  8558. /// 取得窑炉数据
  8559. /// </summary>
  8560. /// <param name="user">登录用户信息</param>
  8561. /// <param name="pValue">使用标识条件</param>
  8562. /// <returns>查询结果</returns>
  8563. public static ServiceResultEntity GetKilnData(SUserInfo user, byte pValue)
  8564. {
  8565. IDBConnection conn = null;
  8566. try
  8567. {
  8568. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8569. string selSql = string.Empty;
  8570. List<OracleParameter> parameters = new List<OracleParameter>();
  8571. //根据帐套查询数据
  8572. if (pValue.ToString() == Constant.INT_IS_ONE.ToString())
  8573. {
  8574. selSql = "Select KilnID,KilnCode,KilnName,KilnType,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,UpdateUserID,OPTimeStamp "
  8575. + "from TP_MST_Kiln where AccountID = :AccountID";
  8576. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8577. }
  8578. //根据帐套和标识查询数据
  8579. else if (pValue.ToString() == Constant.INT_IS_ZERO.ToString())
  8580. {
  8581. selSql = "Select KilnID,KilnCode,KilnName,KilnType,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,UpdateUserID,OPTimeStamp "
  8582. + "from TP_MST_Kiln where valueflag = :valueflag and AccountID = :AccountID";
  8583. parameters.Add(new OracleParameter(":valueflag", OracleDbType.NVarchar2, Constant.INT_IS_ONE.ToString(), ParameterDirection.Input));
  8584. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8585. }
  8586. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8587. ServiceResultEntity sre = new ServiceResultEntity();
  8588. if (data == null || data.Rows.Count == 0)
  8589. {
  8590. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8591. return sre;
  8592. }
  8593. sre.Data = new DataSet();
  8594. sre.Data.Tables.Add(data);
  8595. return sre;
  8596. }
  8597. catch (Exception ex)
  8598. {
  8599. throw ex;
  8600. }
  8601. finally
  8602. {
  8603. if (conn != null &&
  8604. conn.ConnState == ConnectionState.Open)
  8605. {
  8606. conn.Close();
  8607. }
  8608. }
  8609. }
  8610. /// <summary>
  8611. /// 取得窑车数据
  8612. /// </summary>
  8613. /// <param name="user">登录用户信息</param>
  8614. /// <returns>查询结果</returns>
  8615. public static ServiceResultEntity GetAllKilnCarInfo(SUserInfo user)
  8616. {
  8617. IDBConnection conn = null;
  8618. try
  8619. {
  8620. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8621. string selSql = String.Empty;
  8622. List<OracleParameter> parameters = new List<OracleParameter>();
  8623. //获取窑车管理的数据
  8624. selSql = "Select KilnCarID,KilnID,KilnCarCode,KilnCarName,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,UpdateUserID,OPTimeStamp "
  8625. + "from TP_MST_KilnCar where AccountID = :AccountID";
  8626. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8627. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8628. ServiceResultEntity sre = new ServiceResultEntity();
  8629. if (data == null || data.Rows.Count == 0)
  8630. {
  8631. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8632. return sre;
  8633. }
  8634. sre.Data = new DataSet();
  8635. sre.Data.Tables.Add(data);
  8636. return sre;
  8637. }
  8638. catch (Exception ex)
  8639. {
  8640. throw ex;
  8641. }
  8642. finally
  8643. {
  8644. if (conn != null &&
  8645. conn.ConnState == ConnectionState.Open)
  8646. {
  8647. conn.Close();
  8648. }
  8649. }
  8650. }
  8651. /// <summary>
  8652. /// 取得生产线所有的工序
  8653. /// </summary>
  8654. /// <param name="user">登录用户信息</param>
  8655. /// <returns>查询结果</returns>
  8656. public static ServiceResultEntity GetRptProductionLineProcedures(SUserInfo user, int? RptProductionLineID)
  8657. {
  8658. IDBConnection conn = null;
  8659. try
  8660. {
  8661. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8662. string selSql = "select "
  8663. + " tp_pc_procedure.procedureid, "
  8664. + " tp_pc_procedure.Procedurename "
  8665. + " from "
  8666. + " ( "
  8667. + " select TP_PM_ProductionData.Procedureid "
  8668. + " from TP_PM_ProductionData "
  8669. + " where TP_PM_ProductionData.accountid = :accountID "
  8670. + " and TP_PM_ProductionData.productionlineid = :ProductionLineID "
  8671. + " group by TP_PM_ProductionData.Procedureid "
  8672. + " order by TP_PM_ProductionData.Procedureid "
  8673. + " )temp left join tp_pc_procedure "
  8674. + " on tp_pc_procedure.procedureid=temp.procedureid ";
  8675. List<OracleParameter> parameters = new List<OracleParameter>();
  8676. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8677. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, RptProductionLineID, ParameterDirection.Input));
  8678. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8679. ServiceResultEntity sre = new ServiceResultEntity();
  8680. if (data == null || data.Rows.Count == 0)
  8681. {
  8682. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8683. return sre;
  8684. }
  8685. sre.Data = new DataSet();
  8686. sre.Data.Tables.Add(data);
  8687. return sre;
  8688. }
  8689. catch (Exception ex)
  8690. {
  8691. throw ex;
  8692. }
  8693. finally
  8694. {
  8695. if (conn != null &&
  8696. conn.ConnState == ConnectionState.Open)
  8697. {
  8698. conn.Close();
  8699. }
  8700. }
  8701. }
  8702. /// <summary>
  8703. /// 取得数据字典数据
  8704. /// </summary>
  8705. /// <param name="Pvalue">显示停用标识</param>
  8706. /// <param name="dictionaryType">字典类别</param>
  8707. /// <param name="user">登录用户信息</param>
  8708. /// <returns>查询结果</returns>
  8709. public static ServiceResultEntity GetRptDictionaryData(byte Pvalue, string dictionaryType, SUserInfo user)
  8710. {
  8711. IDBConnection conn = null;
  8712. try
  8713. {
  8714. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8715. string selSql = String.Empty;
  8716. List<OracleParameter> parameters = new List<OracleParameter>();
  8717. //根据帐套获得数据字典管理的数据
  8718. if (Pvalue.ToString() == Constant.INT_IS_ONE.ToString())
  8719. {
  8720. selSql = "Select DictionaryID,DictionaryType,DictionaryValue,DisplayNo,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,"
  8721. + "UpdateUserID,OPTimeStamp from TP_MST_DataDictionary where DictionaryType = :DictionaryType and AccountID = :AccountID";
  8722. parameters.Add(new OracleParameter(":DictionaryType", OracleDbType.NVarchar2, dictionaryType, ParameterDirection.Input));
  8723. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8724. }
  8725. //根据帐套,标识获得数据字典管理的数据
  8726. else if (Pvalue.ToString() == Constant.INT_IS_ZERO.ToString())
  8727. {
  8728. selSql = "Select DictionaryID,DictionaryType,DictionaryValue,DisplayNo,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,"
  8729. + "UpdateUserID,OPTimeStamp from TP_MST_DataDictionary where valueflag = :valueflag and DictionaryType = :DictionaryType and AccountID = :AccountID";
  8730. parameters.Add(new OracleParameter(":valueflag", OracleDbType.Int32, Constant.INT_IS_ONE, ParameterDirection.Input));
  8731. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8732. parameters.Add(new OracleParameter(":DictionaryType", OracleDbType.NVarchar2, dictionaryType, ParameterDirection.Input));
  8733. }
  8734. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8735. ServiceResultEntity sre = new ServiceResultEntity();
  8736. if (data == null || data.Rows.Count == 0)
  8737. {
  8738. //sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8739. return sre;
  8740. }
  8741. sre.Data = new DataSet();
  8742. sre.Data.Tables.Add(data);
  8743. return sre;
  8744. }
  8745. catch (Exception ex)
  8746. {
  8747. throw ex;
  8748. }
  8749. finally
  8750. {
  8751. if (conn != null &&
  8752. conn.ConnState == ConnectionState.Open)
  8753. {
  8754. conn.Close();
  8755. }
  8756. }
  8757. }
  8758. #endregion 公共函数
  8759. #endregion 统一使用Se模式rviceResultEntity类
  8760. /// <summary>
  8761. /// 获取注浆次数报表
  8762. /// </summary>
  8763. /// <param name="groutingLineEntity"></param>
  8764. /// <param name="user"></param>
  8765. /// <returns></returns>
  8766. public static ServiceResultEntity GetGroutingCount(GroutingLineEntity groutingLineEntity, SUserInfo user)
  8767. {
  8768. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8769. try
  8770. {
  8771. con.Open();
  8772. OracleParameter[] paras = new OracleParameter[]{
  8773. new OracleParameter("BuildingNo",OracleDbType.NVarchar2,
  8774. groutingLineEntity.BUILDINGNO,ParameterDirection.Input),
  8775. new OracleParameter("FloorNo",OracleDbType.NVarchar2,
  8776. groutingLineEntity.FLOORNO,ParameterDirection.Input),
  8777. new OracleParameter("GroutingLineNo",OracleDbType.NVarchar2,
  8778. groutingLineEntity.GROUTINGLINENO,ParameterDirection.Input),
  8779. new OracleParameter("GroutingLineCode",OracleDbType.NVarchar2,
  8780. groutingLineEntity.GROUTINGLINECODE,ParameterDirection.Input),
  8781. new OracleParameter("GroutingLineName",OracleDbType.NVarchar2,
  8782. groutingLineEntity.GROUTINGLINENAME,ParameterDirection.Input),
  8783. new OracleParameter("GMouldTypeID",OracleDbType.Int32,
  8784. groutingLineEntity.MOULDTYPEID,ParameterDirection.Input),
  8785. new OracleParameter("remarks",OracleDbType.NVarchar2,
  8786. groutingLineEntity.REMARKS,ParameterDirection.Input),
  8787. new OracleParameter("AccountID",OracleDbType.Int32,
  8788. user.AccountID,ParameterDirection.Input),
  8789. new OracleParameter("UserId",OracleDbType.Int32,
  8790. user.UserID,ParameterDirection.Input),
  8791. new OracleParameter("PurviewType",OracleDbType.Int32,
  8792. groutingLineEntity.Purview,ParameterDirection.Input),
  8793. new OracleParameter("rs_result",OracleDbType.RefCursor,
  8794. ParameterDirection.Output),
  8795. new OracleParameter("UserCode",OracleDbType.NVarchar2,
  8796. groutingLineEntity.USERCODE,ParameterDirection.Input),
  8797. };
  8798. //调用获取符合条件的成型线信息
  8799. DataSet ds = con.ExecStoredProcedure("PRO_RPT_GetGroutingCount", paras);
  8800. ServiceResultEntity sre = new ServiceResultEntity();
  8801. if (ds == null || ds.Tables[0].Rows.Count == 0)
  8802. {
  8803. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8804. return sre;
  8805. }
  8806. sre.Data = new DataSet();
  8807. //DataTable dt=ds.Tables[0];
  8808. sre.Data.Tables.Add(ds.Tables[0].Copy());
  8809. return sre;
  8810. }
  8811. catch (Exception ex)
  8812. {
  8813. throw ex;
  8814. }
  8815. finally
  8816. {
  8817. if (con.ConnState == ConnectionState.Open)
  8818. {
  8819. con.Close();
  8820. }
  8821. }
  8822. }
  8823. #region 在产产品汇总表
  8824. /// <summary>
  8825. /// 取得RPT030105(在产产品汇总表)的汇总信息查询数据
  8826. /// </summary>
  8827. /// <param name="user">登录用户信息</param>
  8828. /// <param name="se">查询条件</param>
  8829. /// <returns>查询结果</returns>
  8830. public static ServiceResultEntity GetRPT030105Data(SUserInfo user, RPT030105_SE se)
  8831. {
  8832. IDBConnection conn = null;
  8833. try
  8834. {
  8835. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8836. List<OracleParameter> parameters = new List<OracleParameter>();
  8837. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030105SQL(user, se, ref parameters));
  8838. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  8839. ServiceResultEntity sre = new ServiceResultEntity();
  8840. if (data == null || data.Rows.Count == 0)
  8841. {
  8842. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8843. return sre;
  8844. }
  8845. sre.Data = new DataSet();
  8846. sre.Data.Tables.Add(data);
  8847. return sre;
  8848. }
  8849. catch (Exception ex)
  8850. {
  8851. throw ex;
  8852. }
  8853. finally
  8854. {
  8855. if (conn != null &&
  8856. conn.ConnState == ConnectionState.Open)
  8857. {
  8858. conn.Close();
  8859. }
  8860. }
  8861. }
  8862. /// <summary>
  8863. /// 获取RPT030105画面(产品产量汇总表)的汇总信息查询sql
  8864. /// </summary>
  8865. /// <returns>sql</returns>
  8866. private static string GetRPT030105SQL(SUserInfo user, RPT030105_SE se, ref List<OracleParameter> parameters)
  8867. {
  8868. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8869. //"select " +
  8870. //" ProcedureID," +
  8871. //" procedurecode, " +
  8872. //" decode(Usercode, '小计', '--', procedurename) procedurename, " +
  8873. //" productionlineid, " +
  8874. //" productionlinecode, " +
  8875. //" decode(Usercode, '小计', '--', productionlinename) productionlinename, " +
  8876. //" decode(ProcedureID,'总计','总计',Usercode) Usercode, " +
  8877. //" subGoodsTypecode, " +
  8878. //" decode(usercode,'小计',decode(subGoodsTypecode,'001001','大件','小件'),Goodscode)Goodscode, " +
  8879. //" Goodstypename, " +
  8880. //" InCount " +
  8881. #region
  8882. /*
  8883. "select " +
  8884. " ProcedureID," +
  8885. " procedurecode, " +
  8886. " decode(productionlinename, '总计', '--', procedurename) procedurename, " +
  8887. " productionlineid, " +
  8888. " productionlinecode, " +
  8889. " productionlinename, " +
  8890. " decode(productionlinename, '--', '--', Usercode) Usercode, " +
  8891. " decode(productionlinename, '--', null, UserID) UserID, " +
  8892. " subGoodsTypecode, " +
  8893. " Goodsid," +
  8894. " Goodscode, " +
  8895. " Goodstypename, " +
  8896. " InCount from (" +
  8897. "select " +
  8898. " ProcedureID," +
  8899. " procedurecode, " +
  8900. " decode(usercode,'合计','合计', decode(usercode,'小计','--',decode(usercode,'--','--',procedurename))) procedurename, " +
  8901. " productionlineid, " +
  8902. " productionlinecode, " +
  8903. " decode(ProcedureID,'总计','总计',decode(usercode,'小计','--',productionlinename)) productionlinename, " +
  8904. " decode(ProcedureID,'总计','--',Usercode) Usercode, " +
  8905. " decode(ProcedureID,'总计',null,Userid) Userid, " +
  8906. " subGoodsTypecode, " +
  8907. " Goodsid," +
  8908. " Goodscode, " +
  8909. " decode(usercode,'小计','小计',Goodstypename)Goodstypename, " +
  8910. " InCount " +
  8911. "from " +
  8912. "(" +
  8913. " select " +
  8914. " ProcedureID, " +
  8915. " procedurecode, " +
  8916. " procedurename, " +
  8917. " productionlineid, " +
  8918. " productionlinecode, " +
  8919. " productionlinename, " +
  8920. " decode(procedurecode,'--','合计',Usercode) Usercode, " +
  8921. " decode(procedurecode,'--',null,Userid) Userid, " +
  8922. " subGoodsTypecode," +
  8923. " Goodsid," +
  8924. " Goodscode," +
  8925. " Goodstypename, " +
  8926. " InCount " +
  8927. " from ( select " +
  8928. " decode(grouping(tp_pc_procedure.ProcedureID),1,'总计',tp_pc_procedure.ProcedureID) ProcedureID," +
  8929. " decode(grouping(tp_pc_procedure.procedurecode),1,'--',tp_pc_procedure.procedurecode) procedurecode, " +
  8930. " decode(grouping(tp_pc_procedure.procedurename),1,'--',tp_pc_procedure.procedurename) procedurename, " +
  8931. " decode(grouping(tp_pm_inproduction.productionlineid),1,'--',tp_pm_inproduction.productionlineid) productionlineid, " +
  8932. " decode(grouping(tp_pm_inproduction.productionlinecode),1,'--',tp_pm_inproduction.productionlinecode) productionlinecode, " +
  8933. " decode(grouping(tp_pm_inproduction.productionlinename),1,'--',tp_pm_inproduction.productionlinename) productionlinename, " +
  8934. " decode(grouping(TP_MST_User.Usercode),1,'小计',TP_MST_User.Usercode) Usercode," +
  8935. " decode(grouping(TP_MST_User.Userid),1,null,TP_MST_User.Userid) Userid," +
  8936. " decode(grouping(substr(TP_MST_GoodsType.Goodstypecode,0,6)),1,'--',substr(TP_MST_GoodsType.Goodstypecode,0,6)) subGoodsTypecode," +
  8937. " decode(grouping(TP_MST_Goods.Goodscode),1,'--',TP_MST_Goods.Goodscode) Goodscode," +
  8938. " decode(grouping(TP_MST_Goods.Goodsid),1,'--',TP_MST_Goods.Goodsid) Goodsid," +
  8939. " decode(grouping(TP_MST_GoodsType.Goodstypename),1,'--',TP_MST_GoodsType.Goodstypename) Goodstypename," +
  8940. " count(barcode) as InCount " +
  8941. " from tp_pm_inproduction " +
  8942. " left join tp_pc_procedure" +
  8943. " on tp_pm_inproduction.FlowProcedureID=tp_pc_procedure.ProcedureID" +
  8944. " 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" +
  8945. " Where 1=1 " +
  8946. " and tp_pm_inproduction.AccountID=:AccountID and tp_pm_inproduction.valueflag=1";
  8947. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  8948. {
  8949. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1";
  8950. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1";
  8951. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  8952. }
  8953. if (!string.IsNullOrEmpty(se.LineIDS))
  8954. {
  8955. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||tp_pm_inproduction.ProductionLineId||',')>0 ";
  8956. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  8957. }
  8958. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  8959. {
  8960. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||tp_pm_inproduction.FlowProcedureId||',')>0 ";
  8961. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  8962. }
  8963. if (!string.IsNullOrEmpty(se.GoodsCode))
  8964. {
  8965. selSql = selSql + " AND instr(','||:GoodsCode||',',','||tp_pm_inproduction.goodsCode||',')>0 ";
  8966. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  8967. }
  8968. selSql = selSql +
  8969. "group by " +
  8970. " rollup(tp_pc_procedure.ProcedureID, " +
  8971. " tp_pc_procedure.procedurecode, " +
  8972. " tp_pc_procedure.procedurename, " +
  8973. " tp_pm_inproduction.productionlineid, " +
  8974. " tp_pm_inproduction.productionlinecode, " +
  8975. " tp_pm_inproduction.productionlinename, " +
  8976. " substr(TP_MST_GoodsType.Goodstypecode,0,6), " +
  8977. " TP_MST_User.Usercode," +
  8978. " TP_MST_Goods.Goodscode, " +
  8979. " TP_MST_User.UserID," +
  8980. " TP_MST_Goods.GoodsID, " +
  8981. " TP_MST_GoodsType.Goodstypename)) temp ) temp2 " +
  8982. "where 1=1 " +
  8983. "and (Goodstypename!='--')" +
  8984. "or (Goodstypename='--' and UserCode='小计' and subGoodsTypecode!='--') " +
  8985. "or (Goodstypename='--' and UserCode='合计') " +
  8986. "or (Goodstypename='--' and UserCode='总计') )";
  8987. */
  8988. #endregion
  8989. string sqlString = "select t.productionlineid\n" +
  8990. " ,t.productionlinecode\n" +
  8991. " ,decode(gid\n" +
  8992. " ,15\n" +
  8993. " ,'总计【' || t.productionlinename || '】'\n" +
  8994. " ,t.productionlinename) productionlinename\n" +
  8995. " ,t.ProcedureID\n" +
  8996. " ,t.procedurecode\n" +
  8997. " ,decode(gid, 3, '合计【' || t.procedurename || '】', t.procedurename) procedurename\n" +
  8998. " ,t.Goodstypeid2\n" +
  8999. " ,t.Goodstypecode2\n" +
  9000. " ,decode(gid, 1, '小计【' || t.Goodstypename2 || '】', t.Goodstypename2) Goodstypename2\n" +
  9001. " ,t.Goodsid\n" +
  9002. " ,t.Goodscode\n" +
  9003. " ,t.InCount\n" +
  9004. " from (select grouping_id(inp.productionlineid\n" +
  9005. " ,inp.ProcedureID\n" +
  9006. " ,gt2.Goodstypeid\n" +
  9007. " ,inp.Goodsid) gid\n" +
  9008. " ,inp.productionlineid\n" +
  9009. " ,pline.productionlinecode\n" +
  9010. " ,pline.productionlinename\n" +
  9011. " ,inp.ProcedureID\n" +
  9012. " ,p.procedurecode\n" +
  9013. " ,p.procedurename\n" +
  9014. " ,gt2.GoodstypeID GoodstypeID2\n" +
  9015. " ,gt2.Goodstypecode Goodstypecode2\n" +
  9016. " ,gt2.Goodstypename Goodstypename2\n" +
  9017. " ,inp.Goodsid\n" +
  9018. " ,g.Goodscode\n" +
  9019. " ,count(barcode) as InCount\n" +
  9020. " from tp_pm_inproduction inp\n" +
  9021. " inner join tp_pc_procedure p\n" +
  9022. " on inp.ProcedureID = p.ProcedureID\n" +
  9023. " inner join tp_pc_productionline pline\n" +
  9024. " on pline.productionlineid = inp.productionlineid\n" +
  9025. " inner join TP_MST_User u\n" +
  9026. " on inp.userid = u.Userid\n" +
  9027. " inner join TP_MST_Goods g\n" +
  9028. " on inp.goodsid = g.Goodsid\n" +
  9029. " inner join TP_MST_GoodsType gt\n" +
  9030. " on g.GoodsTypeID = gt.GoodsTypeID\n" +
  9031. " inner join TP_MST_GoodsType gt2\n" +
  9032. " on gt.accountid = gt2.accountid\n" +
  9033. " and substr(gt.Goodstypecode, 0, 6) = gt2.Goodstypecode\n" +
  9034. " where inp.AccountID = 1\n" +
  9035. " and inp.valueflag = '1'\n";
  9036. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  9037. {
  9038. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1";
  9039. sqlString += " AND instr(gt.GOODSTYPECode,:GoodsTypeIDS)=1";
  9040. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  9041. }
  9042. if (!string.IsNullOrEmpty(se.LineIDS))
  9043. {
  9044. sqlString += " AND instr(','||:ProductionLineIDS||',',','||inp.ProductionLineId||',')>0 ";
  9045. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  9046. }
  9047. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  9048. {
  9049. sqlString += " AND instr(','||:ProcedureIDS||',',','||inp.ProcedureId||',')>0 ";
  9050. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  9051. }
  9052. if (!string.IsNullOrEmpty(se.GoodsCode))
  9053. {
  9054. sqlString += " AND instr(','||:GoodsCode||',',','||inp.goodsCode||',')>0 ";
  9055. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  9056. }
  9057. 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";
  9058. return sqlString;
  9059. }
  9060. /// <summary>
  9061. /// 取得RPT030105(在产产品汇总表)的汇总信息查询数据
  9062. /// </summary>
  9063. /// <param name="user">登录用户信息</param>
  9064. /// <param name="se">查询条件</param>
  9065. /// <returns>查询结果</returns>
  9066. public static ServiceResultEntity GetRPT030105IData(SUserInfo user, RPT030105_SE se)
  9067. {
  9068. IDBConnection conn = null;
  9069. try
  9070. {
  9071. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  9072. List<OracleParameter> parameters = new List<OracleParameter>();
  9073. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030105ISQL(user, se, ref parameters));
  9074. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  9075. if (se != null)
  9076. {
  9077. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  9078. {
  9079. //sql.Append(" AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1");
  9080. sql.Append(" AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1");
  9081. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  9082. }
  9083. if (!string.IsNullOrEmpty(se.LineIDS))
  9084. {
  9085. sql.Append(" AND instr(','||:ProductionLineIDS||',',','||tp_pm_inproduction.ProductionLineId||',')>0 ");
  9086. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  9087. }
  9088. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  9089. {
  9090. sql.Append(" AND instr(','||:ProcedureIDS||',',','||tp_pm_inproduction.FlowProcedureId||',')>0 ");
  9091. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  9092. }
  9093. if (!string.IsNullOrEmpty(se.GoodsCode))
  9094. {
  9095. sql.Append(" AND instr(','||:GoodsCode||',',','||tp_pm_inproduction.goodsCode||',')>0 ");
  9096. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  9097. }
  9098. // 总单点击查询用
  9099. if (se.GoodsID.HasValue)
  9100. {
  9101. sql.Append(" AND tp_pm_inproduction.Goodsid = :GoodsID ");
  9102. parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  9103. }
  9104. if (se.UserID.HasValue)
  9105. {
  9106. sql.Append(" AND A.userid = :userid ");
  9107. parameters.Add(new OracleParameter(":userid", OracleDbType.Int32, se.UserID, ParameterDirection.Input));
  9108. }
  9109. }
  9110. sql.Append(" order by TP_PM_InProduction.UpdateTime desc");
  9111. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  9112. ServiceResultEntity sre = new ServiceResultEntity();
  9113. if (data == null || data.Rows.Count == 0)
  9114. {
  9115. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  9116. return sre;
  9117. }
  9118. sre.Data = new DataSet();
  9119. sre.Data.Tables.Add(data);
  9120. return sre;
  9121. }
  9122. catch (Exception ex)
  9123. {
  9124. throw ex;
  9125. }
  9126. finally
  9127. {
  9128. if (conn != null &&
  9129. conn.ConnState == ConnectionState.Open)
  9130. {
  9131. conn.Close();
  9132. }
  9133. }
  9134. }
  9135. /// <summary>
  9136. /// 获取RPT030105画面(产品产量汇总表)的汇总信息查询sql
  9137. /// </summary>
  9138. /// <returns>sql</returns>
  9139. private static string GetRPT030105ISQL(SUserInfo user, RPT030105_SE se, ref List<OracleParameter> parameters)
  9140. {
  9141. string selSql =
  9142. "SELECT " +
  9143. " TP_PM_InProduction.BarCode, " +
  9144. " TP_PM_InProduction.GoodsID,TP_PM_InProduction.GoodsCode, " +
  9145. " TP_PM_InProduction.GoodsName, " +
  9146. " TP_PM_InProduction.Userid,A.USERNAME as UserName,A.USERCode as UserCode, " +
  9147. " TP_PM_InProduction.ProductionLineID, " +
  9148. " TP_PM_InProduction.ProductionLineCode, " +
  9149. " TP_PM_InProduction.ProductionLineName, " +
  9150. " TP_PM_InProduction.ModelType, " +
  9151. " decode(TP_PM_InProduction.inscrapflag , '1', '待审核的报废品' , '正常') as inscrapflag, " +
  9152. //" decode(TP_PM_InProduction.IsPublicBody, '1', '是' , '否') as IsPublicBody, " +
  9153. //" decode(TP_PM_InProduction.IsReFire, '1', '是' , '否') as IsReFire, " +
  9154. " TP_PM_InProduction.IsPublicBody, " +
  9155. " decode(TP_PM_InProduction.IsReFire, '6', '1' , '0') as IsReFire, " +
  9156. " decode(TP_PM_InProduction.CanManyTimes, '1', '能' , '不能') as CanManyTimes, " +
  9157. " decode(TP_PM_InProduction.ProcedureModel, '1', '计件模型' , '检验模型') as ProcedureModel, " +
  9158. " TP_PM_InProduction.GroutingDailyID, " +
  9159. " TP_PM_InProduction.GroutingDailyDetailID, " +
  9160. " TP_PM_InProduction.GroutingDate, " +
  9161. " TP_PM_InProduction.GroutingLineID, " +
  9162. " TP_PM_InProduction.GroutingLineCode, " +
  9163. " TP_PM_InProduction.GroutingLineName, " +
  9164. " TP_PM_InProduction.ProcedureID CompleteProcedureID, " +
  9165. " D.ProcedureName as CompleteProcedureName, " +
  9166. " TP_PM_InProduction.GMouldTypeID, " +
  9167. " TP_MST_GMouldType.GMOULDTYPENAME as GMouldTypeName, " +
  9168. " TP_PM_InProduction.GroutingLineDetailID, " +
  9169. " TP_PM_InProduction.GroutingMouldCode, " +
  9170. " TP_PM_InProduction.SPECIALREPAIRFLAG, " +
  9171. " TP_PM_InProduction.GROUTINGUSERCODE, " +
  9172. " TP_PM_GroutingDailyDetail.GROUTINGCOUNT, " +
  9173. " TP_PM_InProduction.Remarks, " +
  9174. " TP_PM_GroutingDailyDetail.glazingroom," +
  9175. " TP_PM_InProduction.GoodsLevelID,TP_MST_GoodsLevel.GOODSLEVELNAME, " +
  9176. " TP_PM_InProduction.GoodsLevelTypeID,TP_SYS_GoodsLevelType.GOODSLEVELTYPENAME, " +
  9177. " TP_PM_InProduction.AccountID,TP_PM_InProduction.ValueFlag, " +
  9178. " TP_PM_InProduction.CreateTime,TP_PM_InProduction.CreateUserID,B.USERNAME as CreateUserName, " +
  9179. " TP_PM_InProduction.PROCEDURETIME AS UpdateTime,TP_PM_InProduction.UpdateUserID,C.USERNAME as UpdateUserName, " +
  9180. " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName " +
  9181. "FROM TP_PM_InProduction " +
  9182. " inner join TP_MST_User A on A.UserID=TP_PM_InProduction.Userid " +
  9183. " inner join TP_MST_User B on B.UserID=TP_PM_InProduction.CreateUserID " +
  9184. " inner join TP_MST_User C on C.UserID=TP_PM_InProduction.UpdateUserID " +
  9185. " inner join TP_PC_Procedure D on D.PROCEDUREID=TP_PM_InProduction.ProcedureID " +
  9186. " inner join TP_MST_GMouldType on TP_MST_GMouldType.GMouldTypeID=TP_PM_InProduction.GMouldTypeID " +
  9187. " inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.ProcedureModelTypeID=TP_PM_InProduction.ModelType " +
  9188. " inner join TP_PM_GroutingDaily on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_InProduction.GroutingDailyID " +
  9189. " inner join TP_PM_GroutingDailyDetail on TP_PM_GroutingDailyDetail.Groutingdailydetailid=TP_PM_InProduction.GroutingDailyDetailID " +
  9190. " inner join TP_PC_GroutingLineDetail on TP_PC_GroutingLineDetail.Groutinglinedetailid=TP_PM_InProduction.GroutingLineDetailID " +
  9191. " inner join TP_MST_Account on TP_MST_Account.Accountid=TP_PM_InProduction.Accountid " +
  9192. " left join TP_MST_GoodsLevel on TP_MST_GoodsLevel.GoodsLevelID=TP_PM_InProduction.GoodsLevelID " +
  9193. " left join TP_SYS_GoodsLevelType on TP_SYS_GoodsLevelType.GoodsLevelTypeID=TP_PM_InProduction.GoodsLevelTypeID " +
  9194. " left join TP_MST_Logo on TP_PM_InProduction.logoid=TP_MST_Logo.logoid " +
  9195. " left join TP_MST_Goods on tp_pm_inproduction.goodsid=TP_MST_Goods.Goodsid " +
  9196. " left join TP_MST_GoodsType on TP_MST_Goods.GoodsTypeID=TP_MST_GoodsType.GoodsTypeID" +
  9197. " Where 1=1 and TP_PM_InProduction.ValueFlag = 1 " +
  9198. " and TP_PM_InProduction.AccountID=:AccountID ";
  9199. return selSql;
  9200. }
  9201. #endregion
  9202. /// <summary>
  9203. /// 取得RPT030106(成检缺陷汇总表)的汇总信息查询数据
  9204. /// </summary>
  9205. /// <param name="user">登录用户信息</param>
  9206. /// <param name="se">查询条件</param>
  9207. /// <returns>查询结果</returns>
  9208. public static ServiceResultEntity GetRPT030106Data(SUserInfo user, RPT030106_SE se)
  9209. {
  9210. IDBConnection conn = null;
  9211. try
  9212. {
  9213. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  9214. List<OracleParameter> parameters = new List<OracleParameter>();
  9215. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106SQL(user, se, ref parameters));
  9216. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  9217. ServiceResultEntity sre = new ServiceResultEntity();
  9218. if (data == null || data.Rows.Count == 0)
  9219. {
  9220. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  9221. return sre;
  9222. }
  9223. sre.Data = new DataSet();
  9224. sre.Data.Tables.Add(data);
  9225. return sre;
  9226. }
  9227. catch (Exception ex)
  9228. {
  9229. throw ex;
  9230. }
  9231. finally
  9232. {
  9233. if (conn != null &&
  9234. conn.ConnState == ConnectionState.Open)
  9235. {
  9236. conn.Close();
  9237. }
  9238. }
  9239. }
  9240. /// <summary>
  9241. /// 获取RPT030106画面(成检缺陷汇总表)的汇总信息查询sql
  9242. /// </summary>
  9243. /// <returns>sql</returns>
  9244. private static string GetRPT030106SQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
  9245. {
  9246. #region
  9247. //string selSql = "";
  9248. //parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  9249. //selSql = selSql +
  9250. // "select " +
  9251. // " DefectProcedureID," +
  9252. // " DefectProcedureCode, " +
  9253. // " decode(DefectProcedureID, '总计', '--', decode(DefectCode, '小计', decode(DefectProcedureName, '', '', '--'), DefectProcedureName)) DefectProcedureName," +
  9254. // " ProductionLineID, " +
  9255. // " ProductionLineCode," +
  9256. // " decode(DefectProcedureID, '总计', '总计', decode(DefectCode, '小计', '--', ProductionLineName)) ProductionLineName, " +
  9257. // " ProcedureID, " +
  9258. // " ProcedureCode," +
  9259. // " decode(DefectCode, '小计', '--', ProcedureName) ProcedureName," +
  9260. // " DefectCode, " +
  9261. // " DefectName, " +
  9262. // " DefectTypeName, " +
  9263. // " Userid," +
  9264. // " Usercode," +
  9265. // " Username," +
  9266. // " Goodstypename," +
  9267. // " Goodsid," +
  9268. // " Goodscode," +
  9269. // " Goodsname," +
  9270. // " InCount from (" +
  9271. // "select " +
  9272. // " DefectProcedureID," +
  9273. // " DefectProcedureCode, " +
  9274. // " decode(DefectProcedureCode, '--', '合计', DefectProcedureName) DefectProcedureName, " +
  9275. // " ProductionLineID, " +
  9276. // " ProductionLineCode, " +
  9277. // " ProductionLineName, " +
  9278. // " ProcedureID, " +
  9279. // " ProcedureCode, " +
  9280. // " ProcedureName, " +
  9281. // " decode(DefectName, '--', decode(DefectCode, '--', '--', '小计'), DefectCode) DefectCode, " +
  9282. // " DefectName, " +
  9283. // " DefectTypeName, " +
  9284. // " Userid, " +
  9285. // " Usercode, " +
  9286. // " Username, " +
  9287. // " Goodstypename, " +
  9288. // " Goodsid, " +
  9289. // " Goodscode, " +
  9290. // " Goodsname, " +
  9291. // " InCount " +
  9292. // "from " +
  9293. // "(" +
  9294. // " select " +
  9295. // " decode(grouping(TP_PM_Defect.DefectProcedureID),1,'总计',TP_PM_Defect.DefectProcedureID) DefectProcedureID, " +
  9296. // " decode(grouping(TP_PM_Defect.DefectProcedureCode),1,'--',TP_PM_Defect.DefectProcedureCode) DefectProcedureCode, " +
  9297. // " decode(grouping(TP_PM_Defect.DefectProcedureName),1,'--',TP_PM_Defect.DefectProcedureName) DefectProcedureName, " +
  9298. // " decode(grouping(TP_PM_Defect.ProductionLineID),1,'--',TP_PM_Defect.ProductionLineID) ProductionLineID, " +
  9299. // " decode(grouping(TP_PM_Defect.ProductionLineCode),1,'--',TP_PM_Defect.ProductionLineCode) ProductionLineCode, " +
  9300. // " decode(grouping(TP_PM_Defect.ProductionLineName),1,'--',TP_PM_Defect.ProductionLineName) ProductionLineName, " +
  9301. // " decode(grouping(TP_PM_Defect.ProcedureID),1,'--',TP_PM_Defect.ProcedureID) ProcedureID, " +
  9302. // " decode(grouping(TP_PM_Defect.ProcedureCode),1,'--',TP_PM_Defect.ProcedureCode) ProcedureCode," +
  9303. // " decode(grouping(TP_PM_Defect.ProcedureName),1,'--',TP_PM_Defect.ProcedureName) ProcedureName," +
  9304. // " decode(grouping(TP_PM_Defect.DefectCode),1,'--',TP_PM_Defect.DefectCode) DefectCode, " +
  9305. // " decode(grouping(TP_PM_Defect.DefectName),1,'--',TP_PM_Defect.DefectName) DefectName, " +
  9306. // " decode(grouping(TP_MST_DefectType.DefectTypeName),1,'--',TP_MST_DefectType.DefectTypeName) DefectTypeName, " +
  9307. // " decode(grouping(TP_PM_Defect.Userid),1,'--',TP_PM_Defect.Userid) Userid, " +
  9308. // " decode(grouping(TP_PM_Defect.Usercode),1,'--',TP_PM_Defect.Usercode) Usercode, " +
  9309. // " decode(grouping(TP_PM_Defect.Username),1,'--',TP_PM_Defect.Username) Username, " +
  9310. // " decode(grouping(TP_MST_GoodsType.Goodstypename),1,'--',TP_MST_GoodsType.Goodstypename) Goodstypename, " +
  9311. // " decode(grouping(TP_PM_Defect.Goodsid),1,'--',TP_PM_Defect.Goodsid) Goodsid, " +
  9312. // " decode(grouping(TP_PM_Defect.Goodscode),1,'--',TP_PM_Defect.Goodscode) Goodscode, " +
  9313. // " decode(grouping(TP_PM_Defect.Goodsname),1,'--',TP_PM_Defect.Goodscode) Goodsname, " +
  9314. // " count(TP_PM_Defect.barcode) as InCount " +
  9315. // " from TP_PM_Defect " +
  9316. // " left join tp_pc_procedure on TP_PM_Defect.ProcedureID=tp_pc_procedure.ProcedureID " +
  9317. // " left join TP_MST_Goods on TP_PM_Defect.Goodsid=TP_MST_Goods.Goodsid" +
  9318. // " left join TP_MST_GoodsType on TP_MST_Goods.GoodsTypeID = TP_MST_GoodsType.GoodsTypeID" +
  9319. // " left join TP_MST_Defect on TP_PM_Defect.DefectID=TP_MST_Defect.DefectID" +
  9320. // " left join TP_MST_DefectType on TP_MST_Defect.DefectTypeID=TP_MST_DefectType.DefectTypeID" +
  9321. // " left join TP_PM_ProductionData on TP_PM_ProductionData.ProductionDataID=TP_PM_Defect.ProductionDataID" +
  9322. // " Where TP_PM_Defect.valueflag=1 and tp_pc_procedure.ModelType=-1" +
  9323. // " and TP_PM_Defect.AccountID=:AccountID ";
  9324. //if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  9325. //{
  9326. // selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeCode)=1 ";
  9327. // parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  9328. //}
  9329. //if (!string.IsNullOrEmpty(se.LineIDS))
  9330. //{
  9331. // selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_Defect.ProductionLineId||',')>0 ";
  9332. // parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  9333. //}
  9334. //if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  9335. //{
  9336. // //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  9337. // selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 ) ";
  9338. // parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  9339. //}
  9340. //else
  9341. //{
  9342. // // modify by chenxy :没有选择时,应全查询出来。
  9343. // //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  9344. //}
  9345. //if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  9346. //{
  9347. // selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_Defect.ProcedureID||',')>0 ";
  9348. // parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  9349. //}
  9350. //if (!string.IsNullOrEmpty(se.KilnCode))
  9351. //{
  9352. // selSql = selSql + " AND instr(tp_pm_productiondata.KilnCode,:KilnCode) >0 ";
  9353. // parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  9354. //}
  9355. //if (!string.IsNullOrEmpty(se.GoodsIDS))
  9356. //{
  9357. // selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_Defect.Goodsid||',')>0 ";
  9358. // parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  9359. //}
  9360. //if (!string.IsNullOrEmpty(se.GoodsCode))
  9361. //{
  9362. // selSql = selSql + " AND instr(TP_PM_Defect.goodsCode,:GoodsCode) >0 ";
  9363. // parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  9364. //}
  9365. //if (!string.IsNullOrEmpty(se.DefectUserCode))
  9366. //{
  9367. // selSql = selSql + " AND instr(TP_PM_Defect.DefectUserCode,:DefectUserCode) >0 ";
  9368. // parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  9369. //}
  9370. //if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  9371. //{
  9372. // selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||TP_MST_DefectType.DefectTypeID||',')>0 ";
  9373. // parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  9374. //}
  9375. //if (!string.IsNullOrEmpty(se.DefectCode))
  9376. //{
  9377. // selSql = selSql + " AND instr(TP_PM_Defect.DefectCode,:DefectCode) >0 ";
  9378. // parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  9379. //}
  9380. //if (!string.IsNullOrEmpty(se.DefectName))
  9381. //{
  9382. // selSql = selSql + " AND instr(TP_PM_Defect.DefectName,:DefectName) >0";
  9383. // parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  9384. //}
  9385. //if (!string.IsNullOrEmpty(se.CheckUserCode))
  9386. //{
  9387. // selSql = selSql + " AND instr(TP_PM_Defect.UserCode,:UserCode) >0";
  9388. // parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  9389. //}
  9390. //if (se.CreateTimeStart.HasValue)
  9391. //{
  9392. // selSql = selSql + " AND TP_PM_Defect.CreateTime>= :CreateTimeStart ";
  9393. // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9394. //}
  9395. //if (se.CreateTimeEnd.HasValue)
  9396. //{
  9397. // selSql = selSql + " AND TP_PM_Defect.CreateTime<= :CreateTimeEnd ";
  9398. // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9399. //}
  9400. //selSql = selSql +
  9401. // "group by " +
  9402. // " rollup(TP_PM_Defect.DefectProcedureID, " +
  9403. // " TP_PM_Defect.DefectProcedureCode, " +
  9404. // " TP_PM_Defect.DefectProcedureName, " +
  9405. // " TP_PM_Defect.ProductionLineID, " +
  9406. // " TP_PM_Defect.ProductionLineCode, " +
  9407. // " TP_PM_Defect.ProductionLineName, " +
  9408. // " TP_PM_Defect.ProcedureID, " +
  9409. // " TP_PM_Defect.ProcedureCode," +
  9410. // " TP_PM_Defect.ProcedureName, " +
  9411. // " TP_PM_Defect.DefectCode, " +
  9412. // " TP_PM_Defect.DefectName, " +
  9413. // " TP_MST_DefectType.DefectTypeName, " +
  9414. // " TP_PM_Defect.Userid, " +
  9415. // " TP_PM_Defect.Usercode, " +
  9416. // " TP_PM_Defect.Username, " +
  9417. // " TP_MST_GoodsType.Goodstypename, " +
  9418. // " TP_PM_Defect.Goodsid, " +
  9419. // " TP_PM_Defect.Goodscode, " +
  9420. // " TP_PM_Defect.Goodsname " +
  9421. // " )) temp ) temp2 " +
  9422. // "where 1=1 " +
  9423. // "and ((Goodsname!='--' )" +
  9424. // "or (Goodsname='--' and defectcode='小计')" +
  9425. // "or (Goodsname='--' and DefectProcedurename='合计') " +
  9426. // "or (Goodsname='--' and DefectProcedureID='总计'))";
  9427. //////----------------------
  9428. ////if (!string.IsNullOrEmpty(se.CompleteProcedureIDS))
  9429. ////{
  9430. //// selSql = selSql + @" AND exists(select 1 from tp_pm_productiondata where (instr(','||:CompleteProcedureIDS||',',','||ProcedureID||',')>0 ";
  9431. //// parameters.Add(new OracleParameter(":CompleteProcedureIDS", OracleDbType.NVarchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  9432. //// selSql = selSql + " AND TP_PM_ProductionData.CreateTime>= :CompleteCreateTimeStart ";
  9433. //// parameters.Add(new OracleParameter(":CompleteCreateTimeStart", OracleDbType.Date, se.CompleteCreateTimeStart.Value, ParameterDirection.Input));
  9434. //// selSql = selSql + " AND TP_PM_ProductionData.CreateTime<= :CompleteCreateTimeEnd )) ";
  9435. //// parameters.Add(new OracleParameter(":CompleteCreateTimeEnd", OracleDbType.Date, se.CompleteCreateTimeEnd.Value, ParameterDirection.Input));
  9436. ////}
  9437. //////----------------------
  9438. //return selSql;
  9439. #endregion
  9440. string selSql =
  9441. "SELECT t.ProductionLineID\n" +
  9442. " ,t.ProductionLineCode\n" +
  9443. " ,decode(t.gid, 31, '总计', 0, t.ProductionLineName, '--') ProductionLineName\n" +
  9444. " ,t.ProcedureID\n" +
  9445. " ,t.ProcedureCode\n" +
  9446. " ,decode(t.gid, 0, t.ProcedureName, '--') ProcedureName\n" +
  9447. " ,t.DefectProcedureID\n" +
  9448. " ,t.DefectProcedureCode\n" +
  9449. " ,decode(t.gid,\n" +
  9450. " 7,\n" +
  9451. " '合计【' || t.DefectProcedureName || '】',\n" +
  9452. " 0,\n" +
  9453. " t.DefectProcedureName,\n" +
  9454. " '--') DefectProcedureName\n" +
  9455. " ,decode(t.gid, 0, t.DefectCode, '--') DefectCode\n" +
  9456. " ,decode(t.gid,\n" +
  9457. " 3,\n" +
  9458. " '小计【[' || t.DefectCode || ']' || t.DefectName || '】',\n" +
  9459. " 0,\n" +
  9460. " t.DefectName,\n" +
  9461. " '--') DefectName\n" +
  9462. " ,decode(t.gid, 0, t.DefectTypeName, '--') DefectTypeName\n" +
  9463. " --,decode(t.gid, 0, t.Userid, '--') Userid\n" +
  9464. " ,t.Userid\n" +
  9465. " ,decode(t.gid, 0, t.Usercode, '--') Usercode\n" +
  9466. " ,decode(t.gid, 0, t.Username, '--') Username\n" +
  9467. " ,decode(t.gid, 0, t.Goodstypename, '--') Goodstypename\n" +
  9468. " --,decode(t.gid, 0, t.Goodsid, '--') Goodsid\n" +
  9469. " ,t.Goodsid\n" +
  9470. " ,decode(t.gid, 0, t.Goodscode, '--') Goodscode\n" +
  9471. " ,decode(t.gid, 0, t.Goodsname, '--') Goodsname\n" +
  9472. " ,t.InCount\n" +
  9473. " FROM (SELECT grouping_id(pmd.ProductionLineID,\n" +
  9474. " pmd.DefectProcedureID,\n" +
  9475. " pmd.DefectCode,\n" +
  9476. " pmd.userid,\n" +
  9477. " pmd.goodsid) gid\n" +
  9478. " ,pmd.ProductionLineID\n" +
  9479. " ,pmd.ProductionLineCode\n" +
  9480. " ,pmd.ProductionLineName\n" +
  9481. " ,pmd.ProcedureID\n" +
  9482. " ,pmd.ProcedureCode\n" +
  9483. " ,pmd.ProcedureName\n" +
  9484. " ,pmd.DefectProcedureID\n" +
  9485. " ,pmd.DefectProcedureCode\n" +
  9486. " ,pmd.DefectProcedureName\n" +
  9487. " ,pmd.DefectCode\n" +
  9488. " ,pmd.DefectName\n" +
  9489. " ,dt.DefectTypeName\n" +
  9490. " ,pmd.Userid\n" +
  9491. " ,pmd.Usercode\n" +
  9492. " ,pmd.Username\n" +
  9493. " ,gt.Goodstypename\n" +
  9494. " ,pmd.Goodsid\n" +
  9495. " ,pmd.Goodscode\n" +
  9496. " ,pmd.Goodsname\n" +
  9497. " ,COUNT(pmd.barcode) InCount\n" +
  9498. " FROM tp_pm_defect pmd\n" +
  9499. " LEFT JOIN TP_MST_Goods g\n" +
  9500. " ON pmd.Goodsid = g.Goodsid\n" +
  9501. " LEFT JOIN TP_MST_GoodsType gt\n" +
  9502. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  9503. " LEFT JOIN TP_MST_Defect mstd\n" +
  9504. " ON pmd.DefectID = mstd.DefectID\n" +
  9505. " LEFT JOIN TP_MST_DefectType dt\n" +
  9506. " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
  9507. " INNER JOIN tp_pm_productiondata pd\n" +
  9508. " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
  9509. " -- 交接工序\n" +
  9510. " INNER JOIN tp_pm_productiondata hopd\n" +
  9511. " ON hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  9512. " AND hopd.valueflag = '1'\n" +
  9513. " AND hopd.barcode = pd.barcode\n" +
  9514. " AND hopd.kilncarbatchno = pd.kilncarbatchno\n" +
  9515. " WHERE pmd.valueflag = '1'\n" +
  9516. " AND pd.ModelType = -1\n" +
  9517. " AND pmd.AccountID = :AccountID\n";
  9518. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  9519. parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
  9520. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  9521. {
  9522. selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
  9523. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  9524. }
  9525. if (!string.IsNullOrEmpty(se.LineIDS))
  9526. {
  9527. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
  9528. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  9529. }
  9530. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  9531. {
  9532. //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  9533. selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
  9534. parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  9535. }
  9536. else
  9537. {
  9538. // modify by chenxy :没有选择时,应全查询出来。
  9539. //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  9540. }
  9541. if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  9542. {
  9543. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
  9544. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  9545. }
  9546. if (!string.IsNullOrEmpty(se.KilnCode))
  9547. {
  9548. selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
  9549. parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  9550. }
  9551. if (!string.IsNullOrEmpty(se.GoodsIDS))
  9552. {
  9553. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
  9554. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  9555. }
  9556. if (!string.IsNullOrEmpty(se.GoodsCode))
  9557. {
  9558. selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
  9559. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  9560. }
  9561. if (!string.IsNullOrEmpty(se.DefectUserCode))
  9562. {
  9563. selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
  9564. parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  9565. }
  9566. if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  9567. {
  9568. selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
  9569. parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  9570. }
  9571. if (!string.IsNullOrEmpty(se.DefectCode))
  9572. {
  9573. selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
  9574. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  9575. }
  9576. if (!string.IsNullOrEmpty(se.DefectName))
  9577. {
  9578. selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
  9579. parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  9580. }
  9581. if (!string.IsNullOrEmpty(se.CheckUserCode))
  9582. {
  9583. selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
  9584. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  9585. }
  9586. if (se.CreateTimeStart.HasValue)
  9587. {
  9588. selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
  9589. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9590. }
  9591. if (se.CreateTimeEnd.HasValue)
  9592. {
  9593. selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
  9594. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9595. }
  9596. // 交接时间
  9597. if (se.HandOverTimeStart.HasValue)
  9598. {
  9599. selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
  9600. parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
  9601. }
  9602. if (se.HandOverTimeEnd.HasValue)
  9603. {
  9604. selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
  9605. parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
  9606. }
  9607. selSql = selSql +
  9608. " 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" +
  9609. " ORDER BY pmd.ProductionLineCode\n" +
  9610. " ,pmd.ProcedureCode\n" +
  9611. " ,pmd.DefectProcedureCode\n" +
  9612. " ,pmd.DefectCode\n" +
  9613. " ,pmd.Usercode\n" +
  9614. " ,pmd.Goodscode) t";
  9615. return selSql;
  9616. }
  9617. /// <summary>
  9618. /// 取得RPT030106(成检缺陷汇总表-明细)的汇总信息查询数据
  9619. /// </summary>
  9620. /// <param name="user">登录用户信息</param>
  9621. /// <param name="se">查询条件</param>
  9622. /// <returns>查询结果</returns>
  9623. public static ServiceResultEntity GetRPT030106IData(SUserInfo user, RPT030106_SE se)
  9624. {
  9625. IDBConnection conn = null;
  9626. try
  9627. {
  9628. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  9629. List<OracleParameter> parameters = new List<OracleParameter>();
  9630. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106ISQL(user, se, ref parameters));
  9631. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  9632. ServiceResultEntity sre = new ServiceResultEntity();
  9633. if (data == null || data.Rows.Count == 0)
  9634. {
  9635. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  9636. return sre;
  9637. }
  9638. sre.Data = new DataSet();
  9639. sre.Data.Tables.Add(data);
  9640. return sre;
  9641. }
  9642. catch (Exception ex)
  9643. {
  9644. throw ex;
  9645. }
  9646. finally
  9647. {
  9648. if (conn != null &&
  9649. conn.ConnState == ConnectionState.Open)
  9650. {
  9651. conn.Close();
  9652. }
  9653. }
  9654. }
  9655. /// <summary>
  9656. /// 获取RPT030106画面(成检缺陷汇总表-明细)的汇总信息查询sql
  9657. /// </summary>
  9658. /// <returns>sql</returns>
  9659. private static string GetRPT030106ISQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
  9660. {
  9661. // string selSql = @"select
  9662. // tp_pm_defect.productionlinename,
  9663. // tp_pm_defect.procedurename,
  9664. // tp_pm_defect.DefectProcedureCode,
  9665. // tp_pm_defect.DefectProcedureName,
  9666. // tp_pm_defect.DefectUserCode,
  9667. // tp_pm_defect.defectusername,
  9668. // tp_mst_defectType.DefectTypeName,
  9669. // TP_MST_Defect.Remarks DefectRemarks,
  9670. // tp_pm_defect.defectcode,
  9671. // tp_pm_defect.defectname,
  9672. // tp_pm_defect.UserCode,
  9673. // tp_pm_defect.username,
  9674. // tp_mst_goodstype.Goodstypename,
  9675. // tp_pm_defect.goodscode,
  9676. // tp_pm_defect.barcode,
  9677. // tp_pm_productiondata.groutingdate,
  9678. // tp_pm_productiondata.groutingnum,
  9679. // tp_pm_productiondata.groutingMouldCode,
  9680. // tp_pm_productiondata.KilnCarCode,
  9681. // tp_pm_productiondata.Procedureid,
  9682. // decode(TP_PM_ProductionData.Goodsleveltypeid, '4', '正品' , '5','副品','6','重烧','7','次品','') as Goodsleveltype,
  9683. // tp_pm_defect.DefectPositionCode,
  9684. // tp_pm_defect.DefectPositionName,
  9685. // tp_pm_productiondata.GroutingUserCode,
  9686. // --replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName
  9687. // decode(TP_MST_Logo.Logocode, null, null,TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']')) as LogoCodeName
  9688. // ,TP_PM_Defect.CreateTime
  9689. // ,(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
  9690. // ,TP_MST_DefectFine.DefectFineCode
  9691. // ,TP_PM_Defect.DefectDeductionNum
  9692. // from tp_pm_defect
  9693. // left join TP_MST_Goods
  9694. // on TP_PM_Defect.Goodsid=TP_MST_Goods.Goodsid
  9695. // left join TP_MST_GoodsType
  9696. // on TP_MST_Goods.GoodsTypeID = TP_MST_GoodsType.GoodsTypeID
  9697. // left join TP_MST_Defect
  9698. // on TP_PM_Defect.DefectID=TP_MST_Defect.DefectID
  9699. // left join TP_MST_DefectType
  9700. // on TP_MST_Defect.DefectTypeID=TP_MST_DefectType.DefectTypeID
  9701. // inner join tp_pm_productiondata
  9702. // on tp_pm_defect.ProductionDataID=tp_pm_productiondata.ProductionDataID
  9703. // left join TP_MST_DefectFine
  9704. // on tp_pm_defect.DefectFine=TP_MST_DefectFine.DefectFineID
  9705. // left join tp_mst_logo
  9706. // on tp_pm_productiondata.logoid=tp_mst_logo.logoid";
  9707. // 质量登记改判时,缺陷的登记时间是当前时间,不是交接或前次登记时间。
  9708. // 追加交接时间,改判标识。
  9709. string selSql =
  9710. "SELECT pmd.productionlinename\n" +
  9711. " ,pmd.procedurename\n" +
  9712. " ,pmd.DefectProcedureCode\n" +
  9713. " ,pmd.DefectProcedureName\n" +
  9714. " ,pmd.DefectUserCode\n" +
  9715. " ,pmd.defectusername\n" +
  9716. " ,dt.DefectTypeName\n" +
  9717. " ,mstd.Remarks DefectRemarks\n" +
  9718. " ,pmd.defectcode\n" +
  9719. " ,d.alldefectcode\n" +
  9720. " ,pmd.defectname\n" +
  9721. " ,pmd.UserCode\n" +
  9722. " ,pmd.username\n" +
  9723. " ,gt.Goodstypename\n" +
  9724. " ,pmd.goodscode\n" +
  9725. " ,pmd.barcode\n" +
  9726. " ,pd.groutingdate\n" +
  9727. " ,pd.groutingnum\n" +
  9728. " ,pd.groutingMouldCode\n" +
  9729. " ,pd.groutingLineCode\n" +
  9730. " ,pd.KilnCarCode\n" +
  9731. " ,pd.Procedureid\n" +
  9732. " ,gl.goodslevelname Goodsleveltype\n" +
  9733. " ,pmd.DefectPositionCode\n" +
  9734. " ,pmd.DefectPositionName\n" +
  9735. " ,pd.GroutingUserCode\n" +
  9736. " , CASE\n" +
  9737. " WHEN logo.logoid IS NULL THEN\n" +
  9738. " NULL\n" +
  9739. " ELSE\n" +
  9740. " logo.Logoname || '[' || logo.Logocode || ']'\n" +
  9741. " END AS LogoCodeName\n" +
  9742. " ,pmd.CreateTime\n" +
  9743. " ,mstdf.DefectFineCode\n" +
  9744. " ,pmd.DefectDeductionNum\n" +
  9745. //" ,to_char(pmd.DefectDeductionNum, '990.00') DefectDeductionNum\n" +
  9746. " ,hopd.createtime handovertime\n" +
  9747. " ,(SELECT listagg(to_char(pduc.UserCode), ',') within GROUP(ORDER BY pduc.ProductionDataID) AS WorkUserCodes\n" +
  9748. " FROM tp_pm_ProductionData pduc\n" +
  9749. " WHERE pduc.barcode = pmd.barcode\n" +
  9750. " AND pduc.valueflag = '1') AS WorkUserCodes\n" +
  9751. " ,(SELECT listagg(to_char(u.UserCode), ',') within GROUP(ORDER BY pdcu.ProductionDataID) AS CreateUserCodes\n" +
  9752. " FROM tp_pm_ProductionData pdcu\n" +
  9753. " Left join tp_mst_user u on u.userid = pdcu.createuserid\n" +
  9754. " WHERE pdcu.barcode = pmd.barcode\n" +
  9755. " AND pdcu.valueflag = '1') AS CreateUserCodes\n" +
  9756. " , CASE\n" +
  9757. " WHEN EXISTS (SELECT 1\n" +
  9758. " FROM tp_pm_ProductionData pdud\n" +
  9759. " WHERE pdud.barcode = pmd.barcode\n" +
  9760. " AND pdud.modeltype = -1\n" +
  9761. " AND pdud.procedureid = pd.procedureid\n" +
  9762. " AND pdud.kilncarbatchno = pd.kilncarbatchno\n" +
  9763. " AND pdud.valueflag = '0') THEN\n" +
  9764. " 1\n" +
  9765. " ELSE\n" +
  9766. " 0\n" +
  9767. " END AS undoflag\n" +
  9768. " , CASE\n" +
  9769. " WHEN EXISTS (SELECT 1\n" +
  9770. " FROM tp_pm_semicheck sc\n" +
  9771. " WHERE sc.barcode = pmd.barcode\n" +
  9772. " AND sc.SEMICHECKTYPE = 1\n" +
  9773. " AND sc.valueflag = '1') THEN\n" +
  9774. " 1\n" +
  9775. " ELSE\n" +
  9776. " 0\n" +
  9777. " END reworkflag" +
  9778. " ,gdd.glazingroom" +
  9779. //" ,gdd.retainflag" +
  9780. " FROM tp_pm_defect pmd\n" +
  9781. " LEFT JOIN TP_MST_Goods g\n" +
  9782. " ON pmd.Goodsid = g.Goodsid\n" +
  9783. " LEFT JOIN TP_MST_GoodsType gt\n" +
  9784. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  9785. " LEFT JOIN TP_MST_Defect mstd\n" +
  9786. " ON pmd.DefectID = mstd.DefectID\n" +
  9787. " LEFT JOIN TP_MST_DefectType dt\n" +
  9788. " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
  9789. " INNER JOIN tp_pm_productiondata pd\n" +
  9790. " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
  9791. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  9792. " ON gdd.Groutingdailydetailid = pd.Groutingdailydetailid\n" +
  9793. " LEFT JOIN tp_mst_goodslevel gl\n" +
  9794. " ON pd.goodslevelid = gl.goodslevelid\n" +
  9795. "-- 交接工序\n" +
  9796. " INNER JOIN tp_pm_productiondata hopd\n" +
  9797. " ON hopd.kilncarbatchno = pd.kilncarbatchno\n " +
  9798. " AND hopd.barcode = pd.barcode\n" +
  9799. " AND hopd.valueflag = '1'\n" +
  9800. " AND hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  9801. " LEFT JOIN TP_MST_DefectFine mstdf\n" +
  9802. " ON pmd.DefectFine = mstdf.DefectFineID\n" +
  9803. " LEFT JOIN tp_mst_logo logo\n" +
  9804. " ON pd.logoid = logo.logoid\n" +
  9805. " LEFT JOIN (SELECT def.barcode, wmsys.wm_concat( to_char(def.defectcode)) alldefectcode\n" +
  9806. " FROM tp_pm_defect def\n" +
  9807. " WHERE def.valueflag = '1'\n" +
  9808. //def.createtime
  9809. " group by def.barcode ) d\n" +
  9810. " ON d.barcode = pmd.barcode\n" +
  9811. " WHERE pmd.valueflag = '1' \n" +
  9812. " AND pd.ModelType = -1\n" +
  9813. " AND pmd.AccountID = :AccountID\n";
  9814. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  9815. parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
  9816. //selSql = selSql +
  9817. // " Where TP_PM_Defect.valueflag='1' and tp_pm_productiondata.ModelType=-1" +
  9818. // " and TP_PM_Defect.AccountID=:AccountID ";
  9819. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  9820. {
  9821. selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
  9822. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  9823. }
  9824. if (!string.IsNullOrEmpty(se.LineIDS))
  9825. {
  9826. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
  9827. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  9828. }
  9829. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  9830. {
  9831. //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  9832. selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
  9833. parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  9834. }
  9835. else
  9836. {
  9837. // modify by chenxy :没有选择时,应全查询出来。
  9838. //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  9839. }
  9840. if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  9841. {
  9842. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
  9843. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  9844. }
  9845. if (!string.IsNullOrEmpty(se.KilnCode))
  9846. {
  9847. selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
  9848. parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  9849. }
  9850. if (!string.IsNullOrEmpty(se.GoodsIDS))
  9851. {
  9852. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
  9853. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  9854. }
  9855. if (!string.IsNullOrEmpty(se.GoodsCode))
  9856. {
  9857. selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
  9858. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  9859. }
  9860. if (!string.IsNullOrEmpty(se.GoodsCodeS2D))
  9861. {
  9862. selSql = selSql + " AND pmd.goodsCode = :GoodsCodeS2D ";
  9863. parameters.Add(new OracleParameter(":GoodsCodeS2D", OracleDbType.NVarchar2, se.GoodsCodeS2D, ParameterDirection.Input));
  9864. }
  9865. if (!string.IsNullOrEmpty(se.DefectUserCode))
  9866. {
  9867. selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
  9868. parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  9869. }
  9870. if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  9871. {
  9872. selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
  9873. parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  9874. }
  9875. if (!string.IsNullOrEmpty(se.DefectCode))
  9876. {
  9877. selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
  9878. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  9879. }
  9880. if (!string.IsNullOrEmpty(se.DefectCodeS2D))
  9881. {
  9882. selSql = selSql + " AND pmd.DefectCode = :DefectCodeS2D ";
  9883. parameters.Add(new OracleParameter(":DefectCodeS2D", OracleDbType.NVarchar2, se.DefectCodeS2D, ParameterDirection.Input));
  9884. }
  9885. if (!string.IsNullOrEmpty(se.DefectName))
  9886. {
  9887. selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
  9888. parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  9889. }
  9890. if (!string.IsNullOrEmpty(se.CheckUserCode))
  9891. {
  9892. selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
  9893. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  9894. }
  9895. if (!string.IsNullOrEmpty(se.CheckUserCodeS2D))
  9896. {
  9897. selSql = selSql + " AND pmd.UserCode = :CheckUserCodeS2D ";
  9898. parameters.Add(new OracleParameter(":CheckUserCodeS2D", OracleDbType.NVarchar2, se.CheckUserCodeS2D, ParameterDirection.Input));
  9899. }
  9900. // 登记时间(缺陷)
  9901. if (se.CreateTimeStart.HasValue)
  9902. {
  9903. selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
  9904. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9905. }
  9906. if (se.CreateTimeEnd.HasValue)
  9907. {
  9908. selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
  9909. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9910. }
  9911. // 交接时间
  9912. if (se.HandOverTimeStart.HasValue)
  9913. {
  9914. selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
  9915. parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
  9916. }
  9917. if (se.HandOverTimeEnd.HasValue)
  9918. {
  9919. selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
  9920. parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
  9921. }
  9922. //if (!string.IsNullOrEmpty(se.PurViewUserCodeIDS))
  9923. //{
  9924. // selSql = selSql + " AND instr(','||:PurViewUserCodeIDS||',',','||TP_PM_Defect.DefectUserID||',')>0 ";
  9925. // parameters.Add(new OracleParameter(":PurViewUserCodeIDS", OracleDbType.NVarchar2, se.PurViewUserCodeIDS, ParameterDirection.Input));
  9926. //}
  9927. ////----------------------
  9928. //if (!string.IsNullOrEmpty(se.CompleteProcedureIDS))
  9929. //{
  9930. // selSql = selSql + @" AND exists(select 1 from tp_pm_productiondata where (instr(','||:CompleteProcedureIDS||',',','||ProcedureID||',')>0 ";
  9931. // parameters.Add(new OracleParameter(":CompleteProcedureIDS", OracleDbType.NVarchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  9932. // selSql = selSql + " AND TP_PM_ProductionData.CreateTime>= :CompleteCreateTimeStart ";
  9933. // parameters.Add(new OracleParameter(":CompleteCreateTimeStart", OracleDbType.Date, se.CompleteCreateTimeStart.Value, ParameterDirection.Input));
  9934. // selSql = selSql + " AND TP_PM_ProductionData.CreateTime<= :CompleteCreateTimeEnd )) ";
  9935. // parameters.Add(new OracleParameter(":CompleteCreateTimeEnd", OracleDbType.Date, se.CompleteCreateTimeEnd.Value, ParameterDirection.Input));
  9936. //}
  9937. ////----------------------
  9938. selSql = selSql + " order by pmd.productionlinename,pmd.procedurename,pmd.defectprocedurename,pmd.defectusercode ";
  9939. return selSql;
  9940. }
  9941. /// <summary>
  9942. /// 取得RPT030106(成检缺陷汇总表-缺陷登记明细)的汇总信息查询数据
  9943. /// </summary>
  9944. /// <param name="user">登录用户信息</param>
  9945. /// <param name="se">查询条件</param>
  9946. /// <returns>查询结果</returns>
  9947. public static ServiceResultEntity GetRPT030106DData(SUserInfo user, RPT030106_SE se)
  9948. {
  9949. IDBConnection conn = null;
  9950. try
  9951. {
  9952. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  9953. List<OracleParameter> parameters = new List<OracleParameter>();
  9954. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106DSQL(user, se, ref parameters));
  9955. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  9956. ServiceResultEntity sre = new ServiceResultEntity();
  9957. if (data == null || data.Rows.Count == 0)
  9958. {
  9959. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  9960. return sre;
  9961. }
  9962. sre.Data = new DataSet();
  9963. sre.Data.Tables.Add(data);
  9964. return sre;
  9965. }
  9966. catch (Exception ex)
  9967. {
  9968. throw ex;
  9969. }
  9970. finally
  9971. {
  9972. if (conn != null &&
  9973. conn.ConnState == ConnectionState.Open)
  9974. {
  9975. conn.Close();
  9976. }
  9977. }
  9978. }
  9979. /// <summary>
  9980. /// 获取RPT030106画面(成检缺陷汇总表-缺陷登记明细)的汇总信息查询sql
  9981. /// </summary>
  9982. /// <returns>sql</returns>
  9983. private static string GetRPT030106DSQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
  9984. {
  9985. // 质量登记改判时,缺陷的登记时间是当前时间,不是交接或前次登记时间。
  9986. // 追加交接时间,改判标识。
  9987. string selSql =
  9988. "SELECT pmd.productionlinename\n" +
  9989. " ,pmd.procedurename\n" +
  9990. " ,pmd.DefectProcedureCode\n" +
  9991. " ,pmd.DefectProcedureName\n" +
  9992. " ,pmd.DefectUserCode\n" +
  9993. " ,pmd.defectusername\n" +
  9994. " ,jobs.jobsname defectjobsname\n" +
  9995. " ,dt.DefectTypeName\n" +
  9996. " ,mstd.Remarks DefectRemarks\n" +
  9997. " ,pd.Remarks barcodeRemarks\n" +
  9998. " ,pmd.defectcode\n" +
  9999. " ,d.alldefectcode\n" +
  10000. " ,pmd.defectname\n" +
  10001. " ,pmd.UserCode\n" +
  10002. " ,pmd.username\n" +
  10003. " ,gt.Goodstypename\n" +
  10004. " ,pmd.goodscode\n" +
  10005. " ,pmd.barcode\n" +
  10006. " ,pd.groutingdate\n" +
  10007. " ,pd.groutingnum\n" +
  10008. " ,pd.groutingMouldCode\n" +
  10009. " ,pd.GroutingLineCode\n" +
  10010. " ,pd.KilnCarCode\n" +
  10011. " ,pd.Procedureid\n" +
  10012. " ,gl.goodslevelname Goodsleveltype\n" +
  10013. " ,pmd.DefectPositionCode\n" +
  10014. " ,pmd.DefectPositionName\n" +
  10015. " ,pd.GroutingUserCode\n" +
  10016. " , CASE\n" +
  10017. " WHEN logo.logoid IS NULL THEN\n" +
  10018. " NULL\n" +
  10019. " ELSE\n" +
  10020. " logo.Logoname || '[' || logo.Logocode || ']'\n" +
  10021. " END AS LogoCodeName\n" +
  10022. //" ,pmd.CreateTime\n" +
  10023. " ,pd.CheckTime pdchecktime\n" +
  10024. " ,pmd.CheckTime\n" +
  10025. " ,mstdf.DefectFineCode\n" +
  10026. " ,pmd.DefectDeductionNum\n" +
  10027. //" ,to_char(pmd.DefectDeductionNum, '990.00') DefectDeductionNum\n" +
  10028. " ,hopd.createtime handovertime\n" +
  10029. " ,(SELECT listagg(to_char(pduc.UserCode), ',') within GROUP(ORDER BY pduc.ProductionDataID) AS WorkUserCodes\n" +
  10030. " FROM tp_pm_ProductionData pduc\n" +
  10031. " WHERE pduc.barcode = pmd.barcode\n" +
  10032. " AND pduc.valueflag = '1') AS WorkUserCodes\n" +
  10033. " ,(SELECT listagg(to_char(u.UserCode), ',') within GROUP(ORDER BY pdcu.ProductionDataID) AS CreateUserCodes\n" +
  10034. " FROM tp_pm_ProductionData pdcu\n" +
  10035. " Left join tp_mst_user u on u.userid = pdcu.createuserid\n" +
  10036. " WHERE pdcu.barcode = pmd.barcode\n" +
  10037. " AND pdcu.valueflag = '1') AS CreateUserCodes\n" +
  10038. " ,(SELECT listagg(to_char(s.StaffName), ',') within GROUP(ORDER BY s.Staffid) AS DefectStaffNames\n" +
  10039. " FROM TP_PM_DefectResponsible dr\n" +
  10040. " Left join TP_HR_Staff s on s.Staffid = dr.Staffid\n" +
  10041. " WHERE dr.ProductionDefectID = pmd.ProductionDefectID --dr pdcu.valueflag = '1'\n" +
  10042. " ) AS DefectStaffNames\n" +
  10043. " , CASE\n" +
  10044. " WHEN pd.isrefire <> '0' THEN\n" +
  10045. " (select listagg(to_char(d.defectname || '[' || d.defectpositionname || ']')\n" +
  10046. " ,',') within group(order by d.productiondefectid) bsqx\n" +
  10047. " from tp_pm_productiondata p\n" +
  10048. " inner join tp_pm_defect d\n" +
  10049. " on d.productiondataid = p.productiondataid\n" +
  10050. " where p.valueflag = '1'\n" +
  10051. " and d.valueflag = '1'\n" +
  10052. " and p.barcode = pd.barcode\n" +
  10053. " and p.modeltype = -1\n" +
  10054. " and p.isrefire = '0')\n" +
  10055. " ELSE\n" +
  10056. " null\n" +
  10057. " END AS bsqx\n" +
  10058. " , CASE\n" +
  10059. " WHEN EXISTS (SELECT 1\n" +
  10060. " FROM tp_pm_ProductionData pdud\n" +
  10061. " WHERE pdud.barcode = pmd.barcode\n" +
  10062. " AND pdud.modeltype = -1\n" +
  10063. " AND pdud.procedureid = pd.procedureid\n" +
  10064. " AND pdud.kilncarbatchno = pd.kilncarbatchno\n" +
  10065. " AND pdud.valueflag = '0') THEN\n" +
  10066. " 1\n" +
  10067. " ELSE\n" +
  10068. " 0\n" +
  10069. " END AS undoflag\n" +
  10070. //" ,gdd.retainflag" +
  10071. " FROM tp_pm_defect pmd\n" +
  10072. " LEFT JOIN TP_PC_Procedure p\n" +
  10073. " ON p.procedureid = pmd.procedureid\n" +
  10074. " LEFT JOIN TP_PC_Procedure pdd\n" +
  10075. " ON pdd.procedureid = pmd.defectprocedureid\n" +
  10076. " LEFT JOIN TP_MST_Goods g\n" +
  10077. " ON pmd.Goodsid = g.Goodsid\n" +
  10078. " LEFT JOIN TP_MST_GoodsType gt\n" +
  10079. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  10080. " LEFT JOIN TP_MST_Defect mstd\n" +
  10081. " ON pmd.DefectID = mstd.DefectID\n" +
  10082. " LEFT JOIN TP_MST_Jobs jobs\n" +
  10083. " ON jobs.jobsid = pmd.Defectjobs\n" +
  10084. " LEFT JOIN TP_MST_DefectType dt\n" +
  10085. " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
  10086. " INNER JOIN tp_pm_productiondata pd\n" +
  10087. " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
  10088. // " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  10089. //" ON gdd.Groutingdailydetailid = pd.Groutingdailydetailid\n" +
  10090. " LEFT JOIN tp_mst_goodslevel gl\n" +
  10091. " ON pd.goodslevelid = gl.goodslevelid\n" +
  10092. //"-- 交接工序\n" +
  10093. //" INNER JOIN tp_pm_productiondata hopd\n" +
  10094. //" ON hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  10095. //" AND hopd.valueflag = '1'\n" +
  10096. //" AND hopd.barcode = pd.barcode\n" +
  10097. //" AND hopd.kilncarbatchno = pd.kilncarbatchno\n" +
  10098. " INNER JOIN tp_pm_productiondata hopd\n" +
  10099. " ON hopd.kilncarbatchno = pd.kilncarbatchno\n " +
  10100. " AND hopd.barcode = pd.barcode\n" +
  10101. " AND hopd.valueflag = '1'\n" +
  10102. " AND hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  10103. " LEFT JOIN TP_MST_DefectFine mstdf\n" +
  10104. " ON pmd.DefectFine = mstdf.DefectFineID\n" +
  10105. " LEFT JOIN tp_mst_logo logo\n" +
  10106. " ON pd.logoid = logo.logoid\n" +
  10107. " LEFT JOIN (SELECT def.barcode, wmsys.wm_concat( to_char(def.defectcode)) alldefectcode\n" +
  10108. " FROM tp_pm_defect def\n" +
  10109. " WHERE def.valueflag = '1'\n" +
  10110. //def.createtime
  10111. " group by def.barcode ) d\n" +
  10112. " ON d.barcode = pmd.barcode\n" +
  10113. " WHERE pmd.valueflag = '1' \n" +
  10114. " AND pd.ModelType = -1\n" +
  10115. " AND pmd.AccountID = :AccountID\n";
  10116. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  10117. parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
  10118. //selSql = selSql +
  10119. // " Where TP_PM_Defect.valueflag='1' and tp_pm_productiondata.ModelType=-1" +
  10120. // " and TP_PM_Defect.AccountID=:AccountID ";
  10121. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  10122. {
  10123. selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
  10124. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  10125. }
  10126. if (!string.IsNullOrEmpty(se.LineIDS))
  10127. {
  10128. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
  10129. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  10130. }
  10131. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  10132. {
  10133. //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  10134. selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
  10135. parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  10136. }
  10137. else
  10138. {
  10139. // modify by chenxy :没有选择时,应全查询出来。
  10140. //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  10141. }
  10142. if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  10143. {
  10144. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
  10145. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  10146. }
  10147. if (!string.IsNullOrEmpty(se.KilnCode))
  10148. {
  10149. selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
  10150. parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  10151. }
  10152. if (!string.IsNullOrEmpty(se.GoodsIDS))
  10153. {
  10154. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
  10155. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  10156. }
  10157. if (!string.IsNullOrEmpty(se.GoodsCode))
  10158. {
  10159. selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
  10160. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  10161. }
  10162. if (!string.IsNullOrEmpty(se.GoodsCodeS2D))
  10163. {
  10164. selSql = selSql + " AND pmd.goodsCode = :GoodsCodeS2D ";
  10165. parameters.Add(new OracleParameter(":GoodsCodeS2D", OracleDbType.NVarchar2, se.GoodsCodeS2D, ParameterDirection.Input));
  10166. }
  10167. if (!string.IsNullOrEmpty(se.DefectUserCode))
  10168. {
  10169. selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
  10170. parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  10171. }
  10172. if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  10173. {
  10174. selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
  10175. parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  10176. }
  10177. if (!string.IsNullOrEmpty(se.DefectCode))
  10178. {
  10179. selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
  10180. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  10181. }
  10182. if (!string.IsNullOrEmpty(se.DefectCodeS2D))
  10183. {
  10184. selSql = selSql + " AND pmd.DefectCode = :DefectCodeS2D ";
  10185. parameters.Add(new OracleParameter(":DefectCodeS2D", OracleDbType.NVarchar2, se.DefectCodeS2D, ParameterDirection.Input));
  10186. }
  10187. if (!string.IsNullOrEmpty(se.DefectName))
  10188. {
  10189. selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
  10190. parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  10191. }
  10192. if (!string.IsNullOrEmpty(se.CheckUserCode))
  10193. {
  10194. selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
  10195. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  10196. }
  10197. if (!string.IsNullOrEmpty(se.CheckUserCodeS2D))
  10198. {
  10199. selSql = selSql + " AND pmd.UserCode = :CheckUserCodeS2D ";
  10200. parameters.Add(new OracleParameter(":CheckUserCodeS2D", OracleDbType.NVarchar2, se.CheckUserCodeS2D, ParameterDirection.Input));
  10201. }
  10202. //if (se.CreateTimeStart.HasValue)
  10203. //{
  10204. // selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
  10205. // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  10206. //}
  10207. //if (se.CreateTimeEnd.HasValue)
  10208. //{
  10209. // selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
  10210. // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  10211. //}
  10212. // 登记时间(第一次成检)
  10213. if (se.CreateTimeStart.HasValue)
  10214. {
  10215. selSql = selSql + " AND pd.checktime>= :CreateTimeStart ";
  10216. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  10217. }
  10218. if (se.CreateTimeEnd.HasValue)
  10219. {
  10220. selSql = selSql + " AND pd.checktime<= :CreateTimeEnd ";
  10221. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  10222. }
  10223. // 缺陷登记时间
  10224. if (se.CheckTimeStart.HasValue)
  10225. {
  10226. selSql = selSql + " AND pmd.checktime>= :CheckTimeStart ";
  10227. parameters.Add(new OracleParameter(":CheckTimeStart", OracleDbType.Date, se.CheckTimeStart.Value, ParameterDirection.Input));
  10228. }
  10229. if (se.CheckTimeEnd.HasValue)
  10230. {
  10231. selSql = selSql + " AND pmd.checktime<= :CheckTimeEnd ";
  10232. parameters.Add(new OracleParameter(":CheckTimeEnd", OracleDbType.Date, se.CheckTimeEnd.Value, ParameterDirection.Input));
  10233. }
  10234. // 交接时间
  10235. if (se.HandOverTimeStart.HasValue)
  10236. {
  10237. selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
  10238. parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
  10239. }
  10240. if (se.HandOverTimeEnd.HasValue)
  10241. {
  10242. selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
  10243. parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
  10244. }
  10245. //selSql = selSql + " order by pmd.productionlinename,pmd.procedurename,pmd.defectprocedurename,pmd.defectusercode ";
  10246. selSql = selSql + " order by pmd.productionlinename,p.DISPLAYNO,pdd.DISPLAYNO,dt.DISPLAYNO,mstd.DISPLAYNO,pmd.defectusercode,pmd.barcode ";
  10247. return selSql;
  10248. }
  10249. /// <summary>
  10250. /// 取得RPT030106(成检缺陷汇总表-生产工序信息)的汇总信息查询数据
  10251. /// </summary>
  10252. /// <param name="user">登录用户信息</param>
  10253. /// <param name="se">查询条件</param>
  10254. /// <returns>查询结果</returns>
  10255. public static ServiceResultEntity GetRPT030106ProData(SUserInfo user, RPT030106_SE se)
  10256. {
  10257. IDBConnection conn = null;
  10258. try
  10259. {
  10260. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10261. List<OracleParameter> parameters = new List<OracleParameter>();
  10262. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106ProSQL(user, se, ref parameters));
  10263. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  10264. ServiceResultEntity sre = new ServiceResultEntity();
  10265. if (data == null || data.Rows.Count == 0)
  10266. {
  10267. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10268. return sre;
  10269. }
  10270. sre.Data = new DataSet();
  10271. sre.Data.Tables.Add(data);
  10272. return sre;
  10273. }
  10274. catch (Exception ex)
  10275. {
  10276. throw ex;
  10277. }
  10278. finally
  10279. {
  10280. if (conn != null &&
  10281. conn.ConnState == ConnectionState.Open)
  10282. {
  10283. conn.Close();
  10284. }
  10285. }
  10286. }
  10287. /// <summary>
  10288. /// 获取RPT030106画面(成检缺陷汇总表-生产工序信息)的汇总信息查询sql
  10289. /// </summary>
  10290. /// <returns>sql</returns>
  10291. private static string GetRPT030106ProSQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
  10292. {
  10293. // 质量登记改判时,缺陷的登记时间是当前时间,不是交接或前次登记时间。
  10294. // 追加交接时间,改判标识。
  10295. string selSql =
  10296. //"SELECT pmd.productionlinename\n" +
  10297. //" ,pmd.procedurename\n" +
  10298. //" ,pmd.DefectProcedureCode\n" +
  10299. //" ,pmd.DefectProcedureName\n" +
  10300. //" ,pmd.DefectUserCode\n" +
  10301. //" ,pmd.defectusername\n" +
  10302. //" ,jobs.jobsname defectjobsname\n" +
  10303. //" ,dt.DefectTypeName\n" +
  10304. //" ,mstd.Remarks DefectRemarks\n" +
  10305. //" ,pd.Remarks barcodeRemarks\n" +
  10306. //" ,pmd.defectcode\n" +
  10307. //" ,d.alldefectcode\n" +
  10308. //" ,pmd.defectname\n" +
  10309. //" ,pmd.UserCode\n" +
  10310. //" ,pmd.username\n" +
  10311. //" ,gt.Goodstypename\n" +
  10312. //" ,pmd.goodscode\n" +
  10313. //" ,pmd.barcode\n" +
  10314. //" ,pd.groutingdate\n" +
  10315. //" ,pd.groutingnum\n" +
  10316. //" ,pd.groutingMouldCode\n" +
  10317. //" ,pd.GroutingLineCode\n" +
  10318. //" ,pd.KilnCarCode\n" +
  10319. //" ,pd.Procedureid\n" +
  10320. //" ,gl.goodslevelname Goodsleveltype\n" +
  10321. //" ,pmd.DefectPositionCode\n" +
  10322. //" ,pmd.DefectPositionName\n" +
  10323. //" ,pd.GroutingUserCode\n" +
  10324. //" , CASE\n" +
  10325. //" WHEN logo.logoid IS NULL THEN\n" +
  10326. //" NULL\n" +
  10327. //" ELSE\n" +
  10328. //" logo.Logoname || '[' || logo.Logocode || ']'\n" +
  10329. //" END AS LogoCodeName\n" +
  10330. ////" ,pmd.CreateTime\n" +
  10331. //" ,pd.CheckTime pdchecktime\n" +
  10332. //" ,pmd.CheckTime\n" +
  10333. //" ,mstdf.DefectFineCode\n" +
  10334. //" ,pmd.DefectDeductionNum\n" +
  10335. ////" ,to_char(pmd.DefectDeductionNum, '990.00') DefectDeductionNum\n" +
  10336. //" ,hopd.createtime handovertime\n" +
  10337. //" ,(SELECT listagg(to_char(pduc.UserCode), ',') within GROUP(ORDER BY pduc.ProductionDataID) AS WorkUserCodes\n" +
  10338. //" FROM tp_pm_ProductionData pduc\n" +
  10339. //" WHERE pduc.barcode = pmd.barcode\n" +
  10340. //" AND pduc.valueflag = '1') AS WorkUserCodes\n" +
  10341. //" ,(SELECT listagg(to_char(u.UserCode), ',') within GROUP(ORDER BY pdcu.ProductionDataID) AS CreateUserCodes\n" +
  10342. //" FROM tp_pm_ProductionData pdcu\n" +
  10343. //" Left join tp_mst_user u on u.userid = pdcu.createuserid\n" +
  10344. //" WHERE pdcu.barcode = pmd.barcode\n" +
  10345. //" AND pdcu.valueflag = '1') AS CreateUserCodes\n" +
  10346. //" , CASE\n" +
  10347. //" WHEN EXISTS (SELECT 1\n" +
  10348. //" FROM tp_pm_ProductionData pdud\n" +
  10349. //" WHERE pdud.barcode = pmd.barcode\n" +
  10350. //" AND pdud.modeltype = -1\n" +
  10351. //" AND pdud.procedureid = pd.procedureid\n" +
  10352. //" AND pdud.kilncarbatchno = pd.kilncarbatchno\n" +
  10353. //" AND pdud.valueflag = '0') THEN\n" +
  10354. //" 1\n" +
  10355. //" ELSE\n" +
  10356. //" 0\n" +
  10357. //" END AS undoflag\n" +
  10358. "SELECT pmd.goodscode\n" +
  10359. " ,pmd.barcode\n" +
  10360. " ,pmd.defectcode\n" +
  10361. " ,pmd.defectname\n" +
  10362. " ,pmd.DefectPositionCode\n" +
  10363. " ,pmd.DefectPositionName\n" +
  10364. " ,gl.goodslevelname Goodsleveltype\n" +
  10365. " , CASE\n" +
  10366. " WHEN logo.logoid IS NULL THEN\n" +
  10367. " NULL\n" +
  10368. " ELSE\n" +
  10369. " logo.Logoname || '[' || logo.Logocode || ']'\n" +
  10370. " END AS LogoCodeName\n" +
  10371. //" ,pmd.CreateTime\n" +
  10372. " ,pd.CheckTime pdchecktime\n" +
  10373. " ,pmd.CheckTime\n" +
  10374. " ,proddata.CheckTime protime\n" +
  10375. " ,proddata.UserCode prousercode\n" +
  10376. " ,proddata.PROCEDURENAME proname\n" +
  10377. " ,pd.KILNCARCODE KILNCARCODE\n" +
  10378. " FROM tp_pm_defect pmd\n" +
  10379. " INNER JOIN tp_pm_productiondata proddata\n" +
  10380. " ON proddata.barcode = pmd.barcode\n " +
  10381. //" AND proddata.ProcedureID in ('" + se.CompleteProcedureIDS + "')\n" +
  10382. " AND (instr(','||:ProProcedureIDS||',',','||proddata.ProcedureID||',')>0 )\n" +
  10383. " AND proddata.valueflag = '1'\n" +
  10384. " INNER JOIN tp_pm_productiondata pd\n" +
  10385. " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
  10386. " LEFT JOIN TP_PC_Procedure p\n" +
  10387. " ON p.procedureid = pmd.procedureid\n" +
  10388. " LEFT JOIN TP_PC_Procedure pdd\n" +
  10389. " ON pdd.procedureid = pmd.defectprocedureid\n" +
  10390. " LEFT JOIN TP_MST_Goods g\n" +
  10391. " ON pmd.Goodsid = g.Goodsid\n" +
  10392. " LEFT JOIN TP_MST_GoodsType gt\n" +
  10393. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  10394. " LEFT JOIN TP_MST_Defect mstd\n" +
  10395. " ON pmd.DefectID = mstd.DefectID\n" +
  10396. " LEFT JOIN TP_MST_Jobs jobs\n" +
  10397. " ON jobs.jobsid = pmd.Defectjobs\n" +
  10398. " LEFT JOIN TP_MST_DefectType dt\n" +
  10399. " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
  10400. " LEFT JOIN tp_mst_goodslevel gl\n" +
  10401. " ON pd.goodslevelid = gl.goodslevelid\n" +
  10402. "-- 交接工序\n" +
  10403. " INNER JOIN tp_pm_productiondata hopd\n" +
  10404. " ON hopd.kilncarbatchno = pd.kilncarbatchno\n " +
  10405. " AND hopd.barcode = pd.barcode\n" +
  10406. " AND hopd.valueflag = '1'\n" +
  10407. " AND hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  10408. " LEFT JOIN TP_MST_DefectFine mstdf\n" +
  10409. " ON pmd.DefectFine = mstdf.DefectFineID\n" +
  10410. " LEFT JOIN tp_mst_logo logo\n" +
  10411. " ON pd.logoid = logo.logoid\n" +
  10412. //" LEFT JOIN (SELECT def.barcode, wmsys.wm_concat( to_char(def.defectcode)) alldefectcode\n" +
  10413. //" FROM tp_pm_defect def\n" +
  10414. //" WHERE def.valueflag = '1'\n" +
  10415. ////def.createtime
  10416. //" group by def.barcode ) d\n" +
  10417. //" ON d.barcode = pmd.barcode\n" +
  10418. " WHERE pmd.valueflag = '1' \n" +
  10419. " AND pd.ModelType = -1\n" +
  10420. " AND pmd.AccountID = :AccountID\n";
  10421. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  10422. parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
  10423. parameters.Add(new OracleParameter(":ProProcedureIDS", OracleDbType.Varchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  10424. //selSql = selSql +
  10425. // " Where TP_PM_Defect.valueflag='1' and tp_pm_productiondata.ModelType=-1" +
  10426. // " and TP_PM_Defect.AccountID=:AccountID ";
  10427. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  10428. {
  10429. selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
  10430. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  10431. }
  10432. if (!string.IsNullOrEmpty(se.LineIDS))
  10433. {
  10434. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
  10435. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  10436. }
  10437. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  10438. {
  10439. //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  10440. selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
  10441. parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  10442. }
  10443. else
  10444. {
  10445. // modify by chenxy :没有选择时,应全查询出来。
  10446. //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  10447. }
  10448. if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  10449. {
  10450. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
  10451. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  10452. }
  10453. if (!string.IsNullOrEmpty(se.KilnCode))
  10454. {
  10455. selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
  10456. parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  10457. }
  10458. if (!string.IsNullOrEmpty(se.GoodsIDS))
  10459. {
  10460. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
  10461. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  10462. }
  10463. if (!string.IsNullOrEmpty(se.GoodsCode))
  10464. {
  10465. selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
  10466. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  10467. }
  10468. if (!string.IsNullOrEmpty(se.GoodsCodeS2D))
  10469. {
  10470. selSql = selSql + " AND pmd.goodsCode = :GoodsCodeS2D ";
  10471. parameters.Add(new OracleParameter(":GoodsCodeS2D", OracleDbType.NVarchar2, se.GoodsCodeS2D, ParameterDirection.Input));
  10472. }
  10473. if (!string.IsNullOrEmpty(se.DefectUserCode))
  10474. {
  10475. selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
  10476. parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  10477. }
  10478. if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  10479. {
  10480. selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
  10481. parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  10482. }
  10483. if (!string.IsNullOrEmpty(se.DefectCode))
  10484. {
  10485. selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
  10486. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  10487. }
  10488. if (!string.IsNullOrEmpty(se.DefectCodeS2D))
  10489. {
  10490. selSql = selSql + " AND pmd.DefectCode = :DefectCodeS2D ";
  10491. parameters.Add(new OracleParameter(":DefectCodeS2D", OracleDbType.NVarchar2, se.DefectCodeS2D, ParameterDirection.Input));
  10492. }
  10493. if (!string.IsNullOrEmpty(se.DefectName))
  10494. {
  10495. selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
  10496. parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  10497. }
  10498. if (!string.IsNullOrEmpty(se.CheckUserCode))
  10499. {
  10500. selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
  10501. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  10502. }
  10503. if (!string.IsNullOrEmpty(se.CheckUserCodeS2D))
  10504. {
  10505. selSql = selSql + " AND pmd.UserCode = :CheckUserCodeS2D ";
  10506. parameters.Add(new OracleParameter(":CheckUserCodeS2D", OracleDbType.NVarchar2, se.CheckUserCodeS2D, ParameterDirection.Input));
  10507. }
  10508. //if (se.CreateTimeStart.HasValue)
  10509. //{
  10510. // selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
  10511. // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  10512. //}
  10513. //if (se.CreateTimeEnd.HasValue)
  10514. //{
  10515. // selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
  10516. // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  10517. //}
  10518. // 成检登记时间
  10519. if (se.CreateTimeStart.HasValue)
  10520. {
  10521. selSql = selSql + " AND pd.checktime>= :CreateTimeStart ";
  10522. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  10523. }
  10524. if (se.CreateTimeEnd.HasValue)
  10525. {
  10526. selSql = selSql + " AND pd.checktime<= :CreateTimeEnd ";
  10527. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  10528. }
  10529. // 缺陷登记时间
  10530. if (se.CheckTimeStart.HasValue)
  10531. {
  10532. selSql = selSql + " AND pmd.checktime>= :CheckTimeStart ";
  10533. parameters.Add(new OracleParameter(":CheckTimeStart", OracleDbType.Date, se.CheckTimeStart.Value, ParameterDirection.Input));
  10534. }
  10535. if (se.CheckTimeEnd.HasValue)
  10536. {
  10537. selSql = selSql + " AND pmd.checktime<= :CheckTimeEnd ";
  10538. parameters.Add(new OracleParameter(":CheckTimeEnd", OracleDbType.Date, se.CheckTimeEnd.Value, ParameterDirection.Input));
  10539. }
  10540. // 交接时间
  10541. if (se.HandOverTimeStart.HasValue)
  10542. {
  10543. selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
  10544. parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
  10545. }
  10546. if (se.HandOverTimeEnd.HasValue)
  10547. {
  10548. selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
  10549. parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
  10550. }
  10551. //selSql = selSql + " order by pmd.productionlinename,p.DISPLAYNO,pdd.DISPLAYNO,dt.DISPLAYNO,mstd.DISPLAYNO,pmd.defectusercode,pmd.barcode ";
  10552. selSql = selSql + " order by proddata.CheckTime ";
  10553. return selSql;
  10554. }
  10555. /// <summary>
  10556. /// 窑车状态主表查询
  10557. /// </summary>
  10558. /// <param name="kilnCode">窑炉编码</param>
  10559. /// <param name="kilnCarCode">窑车编码</param>
  10560. /// <param name="sUserInfo">用户基本信息</param>
  10561. /// <returns></returns>
  10562. public static ServiceResultEntity GetKilnCarStatusByCode(string kilnCode, string kilnCarCode, SUserInfo sUserInfo)
  10563. {
  10564. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10565. try
  10566. {
  10567. con.Open();
  10568. OracleParameter[] paras = new OracleParameter[]{
  10569. new OracleParameter("in_AccountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  10570. new OracleParameter("in_KilnCode",OracleDbType.Varchar2,kilnCode,ParameterDirection.Input),
  10571. new OracleParameter("in_KilnCarCode",OracleDbType.Varchar2,kilnCarCode,ParameterDirection.Input),
  10572. new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  10573. };
  10574. DataSet dsSearchReport = con.ExecStoredProcedure("PRO_RPT_GetKilnCarStatus", paras);
  10575. ServiceResultEntity sre = new ServiceResultEntity();
  10576. if (dsSearchReport == null || dsSearchReport.Tables[0].Rows.Count == 0)
  10577. {
  10578. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10579. return sre;
  10580. }
  10581. sre.Data = new DataSet();
  10582. sre.Data.Tables.Add(dsSearchReport.Tables[0].Copy());
  10583. return sre;
  10584. }
  10585. catch (Exception ex)
  10586. {
  10587. throw ex;
  10588. }
  10589. finally
  10590. {
  10591. if (con != null &&
  10592. con.ConnState == ConnectionState.Open)
  10593. {
  10594. con.Close();
  10595. }
  10596. }
  10597. }
  10598. /// <summary>
  10599. /// 窑车状态明细表查询
  10600. /// </summary>
  10601. /// <param name="kilnCarCode">窑车编码</param>
  10602. /// <param name="sUserInfo">用户基本信息</param>
  10603. /// <returns></returns>
  10604. public static ServiceResultEntity GetKilnCarStatusDetailByCode(string kilnCarCode, SUserInfo sUserInfo)
  10605. {
  10606. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10607. try
  10608. {
  10609. con.Open();
  10610. OracleParameter[] paras = new OracleParameter[]{
  10611. new OracleParameter("in_AccountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  10612. new OracleParameter("in_KilnCarCode",OracleDbType.Varchar2,kilnCarCode,ParameterDirection.Input),
  10613. new OracleParameter("out_KilnCarData",OracleDbType.RefCursor, ParameterDirection.Output),
  10614. new OracleParameter("out_KilnCarGoods",OracleDbType.RefCursor, ParameterDirection.Output),
  10615. };
  10616. DataSet dsSearchReport = con.ExecStoredProcedure("PRO_RPT_GetKilnCarData", paras);
  10617. ServiceResultEntity sre = new ServiceResultEntity();
  10618. if (dsSearchReport == null || dsSearchReport.Tables[0].Rows.Count == 0)
  10619. {
  10620. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10621. return sre;
  10622. }
  10623. sre.Data = new DataSet();
  10624. sre.Data.Tables.Add(dsSearchReport.Tables[0].Copy());//生产数据
  10625. sre.Data.Tables.Add(dsSearchReport.Tables[1].Copy());//窑车产品
  10626. return sre;
  10627. }
  10628. catch (Exception ex)
  10629. {
  10630. throw ex;
  10631. }
  10632. finally
  10633. {
  10634. if (con != null &&
  10635. con.ConnState == ConnectionState.Open)
  10636. {
  10637. con.Close();
  10638. }
  10639. }
  10640. }
  10641. /// <summary>
  10642. /// 取得RPT010201_1画面(工序漏扫明细表)的查询数据
  10643. /// </summary>
  10644. /// <param name="user">登录用户信息</param>
  10645. /// <param name="se">查询条件</param>
  10646. /// <returns>查询结果</returns>
  10647. public static ServiceResultEntity GetRPT080101SData(SUserInfo user, RPT010201_SE se)
  10648. {
  10649. IDBConnection conn = null;
  10650. try
  10651. {
  10652. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10653. List<OracleParameter> parameters = new List<OracleParameter>();
  10654. parameters.Clear();
  10655. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080101SSQL(user, se, ref parameters));
  10656. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  10657. ServiceResultEntity sre = new ServiceResultEntity();
  10658. if (data == null || data.Rows.Count == 0)
  10659. {
  10660. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10661. return sre;
  10662. }
  10663. sre.Data = new DataSet();
  10664. sre.Data.Tables.Add(data);
  10665. return sre;
  10666. }
  10667. catch (Exception ex)
  10668. {
  10669. throw ex;
  10670. }
  10671. finally
  10672. {
  10673. if (conn != null &&
  10674. conn.ConnState == ConnectionState.Open)
  10675. {
  10676. conn.Close();
  10677. }
  10678. }
  10679. }
  10680. /// <summary>
  10681. /// 获取RPT010201_1画面(工序漏扫明细表)的查询sql
  10682. /// </summary>
  10683. /// <returns>sql</returns>
  10684. private static string GetRPT080101SSQL(SUserInfo user, RPT010201_SE se, ref List<OracleParameter> parameters)
  10685. {
  10686. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  10687. #region
  10688. #endregion
  10689. string sql = @"
  10690. select gd.groutinglinecode,
  10691. gd.groutingmouldcode,
  10692. gd.mouldcode,
  10693. gd.usercode,
  10694. gs.goodscode,
  10695. gs.goodsname,
  10696. gs.goodsspecification,
  10697. gms.gmouldstatusname, -- 模具状态
  10698. --gs.goodsmodel,
  10699. gd.groutingcount, -- 注浆次数
  10700. --gd.groutingnum,
  10701. gd.scrapnum, -- 开模损坯数
  10702. gd.deliverpnum, -- 交坯数
  10703. gd.mingroutingdate, -- 开始注浆时间
  10704. gd.maxgroutingdate, -- 最后注浆时间
  10705. gld.beginuseddate, -- 开始使用时间
  10706. gld.enduseddate, -- 结束使用时间
  10707. zl.OutKilnCount, -- 质量登记数
  10708. zl.GoodCount, -- 正品数
  10709. zl.SubstandardCount, -- 副品数
  10710. zl.ReFireCount, -- 重烧数
  10711. zl.BadCount -- 次品数
  10712. from (select gdd.groutinglinecode,
  10713. gdd.groutingmouldcode,
  10714. gdd.mouldcode,
  10715. gdd.goodsid,
  10716. gdd.groutinglinedetailid,
  10717. wmsys.wm_concat(distinct to_char(gdd.usercode)) usercode,
  10718. max(gdd.groutingcount) groutingcount,
  10719. sum(decode(gdd.groutingflag, '1', 1, 0)) groutingnum,
  10720. sum(decode(gdd.scrapflag, '1', 1, 0)) scrapnum,
  10721. sum(decode(gdd.deliverflag, '1', 1, 0)) deliverpnum,
  10722. min(gdd.groutingdate) mingroutingdate,
  10723. max(gdd.groutingdate) maxgroutingdate
  10724. from tp_pm_groutingdailydetail gdd
  10725. where gdd.groutingflag = '1'
  10726. and gdd.AccountID = :AccountID
  10727. ";
  10728. // 成型线编码
  10729. if (!string.IsNullOrEmpty(se.groutinglinecode))
  10730. {
  10731. //sql = sql + " and gdd.groutinglinecode=:groutinglinecode";
  10732. sql = sql + " and instr(gdd.groutinglinecode,:groutinglinecode)>0";
  10733. parameters.Add(new OracleParameter(":groutinglinecode", OracleDbType.NVarchar2, se.groutinglinecode, ParameterDirection.Input));
  10734. }
  10735. // 模具编码
  10736. if (!string.IsNullOrEmpty(se.groutingmouldcode))
  10737. {
  10738. //sql = sql + " and gdd.groutingmouldcode=:groutingmouldcode";
  10739. sql = sql + " and instr(gdd.groutingmouldcode,:groutingmouldcode)>0";
  10740. parameters.Add(new OracleParameter(":groutingmouldcode", OracleDbType.NVarchar2, se.groutingmouldcode, ParameterDirection.Input));
  10741. }
  10742. sql = sql + @"
  10743. group by gdd.groutinglinecode,
  10744. gdd.groutingmouldcode,
  10745. gdd.mouldcode,
  10746. gdd.goodsid,
  10747. gdd.groutinglinedetailid) gd
  10748. left join (select pdbc.mouldcode,
  10749. sum(1) OutKilnCount,
  10750. sum(case
  10751. when defect.defectprocedureid is not null and
  10752. glt.goodsleveltypeid in (5, 6, 7) then
  10753. 0
  10754. else
  10755. 1
  10756. end) GoodCount,
  10757. sum(case
  10758. when defect.defectprocedureid is not null and
  10759. glt.goodsleveltypeid = 7 then
  10760. 1
  10761. else
  10762. 0
  10763. end) SubstandardCount,
  10764. sum(case
  10765. when defect.defectprocedureid is not null and
  10766. glt.goodsleveltypeid = 6 then
  10767. 1
  10768. else
  10769. 0
  10770. end) ReFireCount,
  10771. sum(case
  10772. when defect.defectprocedureid is not null and
  10773. glt.goodsleveltypeid = 5 then
  10774. 1
  10775. else
  10776. 0
  10777. end) BadCount
  10778. from (select distinct pd.barcode,
  10779. pd.mouldcode,
  10780. pd.kilncarbatchno
  10781. from tp_pm_productiondata pd
  10782. where pd.valueflag = '1'";
  10783. // 开始注浆--开始
  10784. if (se.beginCreateTime.HasValue)
  10785. {
  10786. sql = sql + " and pd.createtime>=:groutingDateStart ";
  10787. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  10788. }
  10789. //--and pd.createtime > 查询条件。开始注浆日期开始
  10790. // --and pd.procedureid = :in_rptSprocedureId
  10791. sql = sql + @"
  10792. and pd.procedureid = 11
  10793. and pd.AccountID = 1) pdbc
  10794. left join (select kcbc.barcode,
  10795. kcbc.kilncarbatchno,
  10796. kcbc.goodsleveltypeid,
  10797. kcbc.productiondataid
  10798. from (select pd.barcode,
  10799. pd.kilncarbatchno,
  10800. pd.goodsleveltypeid,
  10801. pd.productiondataid,
  10802. ROW_NUMBER() OVER(PARTITION BY pd.barcode, pd.kilncarbatchno ORDER BY pd.productiondataid desc) AS dataid
  10803. from tp_pm_productiondata pd
  10804. where pd.valueflag = '1'
  10805. --and pd.AccountID = :AccountID
  10806. and pd.AccountID = :AccountID";
  10807. //--and pd.createtime > 查询条件。开始注浆日期开始
  10808. // 开始注浆--开始
  10809. if (se.beginCreateTime.HasValue)
  10810. {
  10811. sql = sql + " and pd.createtime>=:groutingDateStart ";
  10812. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  10813. }
  10814. sql = sql + @" and length(pd.kilncarbatchno) > 0
  10815. and pd.modeltype = -1) kcbc
  10816. where kcbc.dataid = 1) glt
  10817. on pdbc.kilncarbatchno = glt.kilncarbatchno
  10818. and pdbc.barcode = glt.barcode
  10819. left join (select distinct productiondataid, defectprocedureid
  10820. from tp_pm_defect def
  10821. where def.valueflag = '1'";
  10822. //--and pd.createtime > 查询条件。开始注浆日期开始
  10823. // 开始注浆--开始
  10824. if (se.beginCreateTime.HasValue)
  10825. {
  10826. sql = sql + " and def.createtime>=:groutingDateStart ";
  10827. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  10828. }
  10829. sql = sql + @"
  10830. and def.AccountID = :AccountID) defect
  10831. on defect.productiondataid = glt.productiondataid
  10832. group by pdbc.mouldcode) zl
  10833. on zl.mouldcode = gd.mouldcode
  10834. left join tp_mst_goods gs
  10835. on gs.goodsid = gd.goodsid
  10836. left join tp_pc_groutinglinedetail gld
  10837. on gld.groutinglinedetailid = gd.groutinglinedetailid
  10838. and gld.mouldcode = gd.mouldcode
  10839. left join tp_sys_gmouldstatus gms
  10840. on gms.gmouldstatusid = gld.gmouldstatus
  10841. where 1=1
  10842. ";
  10843. // 产品编码
  10844. if (!string.IsNullOrEmpty(se.goodscode))
  10845. {
  10846. //sql = sql + " and gs.goodscode=:goodscode";
  10847. sql = sql + " and instr(gs.goodscode,:goodscode)>0";
  10848. parameters.Add(new OracleParameter(":goodscode", OracleDbType.NVarchar2, se.goodscode, ParameterDirection.Input));
  10849. }
  10850. // 成型工号
  10851. if (!string.IsNullOrEmpty(se.groutingUserCode))
  10852. {
  10853. //sql = sql + " and gd.usercode=:usercode";
  10854. sql = sql + " and instr(gd.usercode,:usercode)>0";
  10855. parameters.Add(new OracleParameter(":usercode", OracleDbType.NVarchar2, se.groutingUserCode, ParameterDirection.Input));
  10856. }
  10857. // 开始注浆--开始
  10858. if (se.beginCreateTime.HasValue)
  10859. {
  10860. sql = sql + " and gd.mingroutingdate>=:CreateTimeStart ";
  10861. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  10862. }
  10863. // 开始注浆--结束
  10864. if (se.endCreateTime.HasValue)
  10865. {
  10866. sql = sql + " and gd.mingroutingdate<=:CreateTimeEnd ";
  10867. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.endCreateTime.Value, ParameterDirection.Input));
  10868. }
  10869. // 结束注浆--开始
  10870. if (se.beginCreateTime2.HasValue)
  10871. {
  10872. sql = sql + " and gd.maxgroutingdate>=:CreateTimeotherStart2 ";
  10873. parameters.Add(new OracleParameter(":CreateTimeotherStart2", OracleDbType.Date, se.beginCreateTime2.Value, ParameterDirection.Input));
  10874. }
  10875. // 结束注浆--结束
  10876. if (se.endCreateTime2.HasValue)
  10877. {
  10878. sql = sql + " and gd.maxgroutingdate<=:CreateTimeotherEnd2";
  10879. parameters.Add(new OracleParameter(":CreateTimeotherEnd2", OracleDbType.Date, se.endCreateTime2.Value, ParameterDirection.Input));
  10880. }
  10881. // 模具状态
  10882. if (!string.IsNullOrEmpty(se.gmouldstatus))
  10883. {
  10884. sql = sql + " and gms.gmouldstatusid=:gmouldstatus";
  10885. parameters.Add(new OracleParameter(":gmouldstatus", OracleDbType.NVarchar2, se.gmouldstatus, ParameterDirection.Input));
  10886. }
  10887. sql = sql + " order by groutinglinecode,groutingmouldcode";
  10888. return sql;
  10889. }
  10890. #region 工资产量统计
  10891. /// <summary>
  10892. /// 取得RPT080102画面(成型工产量)的查询数据
  10893. /// </summary>
  10894. /// <param name="user">登录用户信息</param>
  10895. /// <param name="se">查询条件</param>
  10896. /// <returns>查询结果</returns>
  10897. public static ServiceResultEntity GetRPT080102SData(SUserInfo user, RPT080102_SE se)
  10898. {
  10899. IDBTransaction conn = null;
  10900. try
  10901. {
  10902. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  10903. conn.Connect();
  10904. OracleParameter[] paras = new OracleParameter[]{
  10905. new OracleParameter("in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  10906. new OracleParameter("in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
  10907. new OracleParameter("in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
  10908. new OracleParameter("in_deliverprocess",OracleDbType.Varchar2,se.DeliverProcedureIDS,ParameterDirection.Input),
  10909. new OracleParameter("in_IntoKilnProcess",OracleDbType.Varchar2,se.IntoProcedureIDS,ParameterDirection.Input),
  10910. new OracleParameter("in_OutKilnProcess",OracleDbType.Varchar2,se.OutProcedureIDS,ParameterDirection.Input),
  10911. new OracleParameter("in_QualityProcess",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
  10912. new OracleParameter("in_DefectFine",OracleDbType.Varchar2,se.DefectFineIDS,ParameterDirection.Input),
  10913. new OracleParameter("in_Impurity",OracleDbType.Varchar2,se.DefectIDS,ParameterDirection.Input),
  10914. new OracleParameter("out_Production",OracleDbType.RefCursor, ParameterDirection.Output),
  10915. new OracleParameter("out_Deliver",OracleDbType.RefCursor,ParameterDirection.Output),
  10916. new OracleParameter("out_Repair",OracleDbType.RefCursor,ParameterDirection.Output),
  10917. };
  10918. conn.IsCommandTimeout = false;
  10919. DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetDeliver_Production", paras);
  10920. ServiceResultEntity sre = new ServiceResultEntity();
  10921. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  10922. {
  10923. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10924. return sre;
  10925. }
  10926. sre.Data = new DataSet();
  10927. sre.Data = data;
  10928. conn.Commit();
  10929. return sre;
  10930. }
  10931. catch (Exception ex)
  10932. {
  10933. throw ex;
  10934. }
  10935. finally
  10936. {
  10937. if (conn != null &&
  10938. conn.ConnState == ConnectionState.Open)
  10939. {
  10940. conn.Disconnect();
  10941. }
  10942. }
  10943. }
  10944. /// <summary>
  10945. /// 取得RPT080103画面(烧成前工序产量明细表)的查询数据
  10946. /// </summary>
  10947. /// <param name="user">登录用户信息</param>
  10948. /// <param name="se">查询条件</param>
  10949. /// <returns>查询结果</returns>
  10950. public static ServiceResultEntity GetRPT080103SData(SUserInfo user, RPT080103_SE se)
  10951. {
  10952. IDBTransaction conn = null;
  10953. try
  10954. {
  10955. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  10956. conn.Connect();
  10957. OracleParameter[] paras = new OracleParameter[]{
  10958. new OracleParameter("in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  10959. new OracleParameter("in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
  10960. new OracleParameter("in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
  10961. new OracleParameter("in_Process",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
  10962. new OracleParameter("in_HandOverProcess",OracleDbType.Varchar2,se.HandOverProcedureIDS,ParameterDirection.Input),
  10963. new OracleParameter("in_OutKilnProcess",OracleDbType.Varchar2,se.OutProcedureIDS,ParameterDirection.Input),
  10964. new OracleParameter("in_QualityProcess",OracleDbType.Varchar2,se.QualityProcedureIDS,ParameterDirection.Input),
  10965. new OracleParameter("in_Defect1",OracleDbType.Varchar2,se.DefectIDS,ParameterDirection.Input),
  10966. new OracleParameter("in_Defect2",OracleDbType.Varchar2,se.DefectIDS2,ParameterDirection.Input),
  10967. new OracleParameter("out_Production",OracleDbType.RefCursor, ParameterDirection.Output),
  10968. };
  10969. conn.IsCommandTimeout = false;
  10970. //DataSet data = null;
  10971. //if (se.ProcedureIDS.Contains(","))
  10972. //{
  10973. // data = conn.ExecStoredProcedure("PRO_RPT_GetStandardProduction2", paras);
  10974. //}
  10975. //else
  10976. //{
  10977. // data = conn.ExecStoredProcedure("PRO_RPT_GetStandardProduction", paras);
  10978. //}
  10979. DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetStandard_Production", paras);
  10980. ServiceResultEntity sre = new ServiceResultEntity();
  10981. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  10982. {
  10983. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10984. return sre;
  10985. }
  10986. sre.Data = new DataSet();
  10987. sre.Data = data;
  10988. conn.Commit();
  10989. return sre;
  10990. }
  10991. catch (Exception ex)
  10992. {
  10993. throw ex;
  10994. }
  10995. finally
  10996. {
  10997. if (conn != null &&
  10998. conn.ConnState == ConnectionState.Open)
  10999. {
  11000. conn.Disconnect();
  11001. }
  11002. }
  11003. }
  11004. /// <summary>
  11005. /// 取得RPT080104画面(烧成工序产量明细表)的查询数据
  11006. /// </summary>
  11007. /// <param name="user">登录用户信息</param>
  11008. /// <param name="se">查询条件</param>
  11009. /// <returns>查询结果</returns>
  11010. public static ServiceResultEntity GetRPT080104SData(SUserInfo user, RPT080103_SE se)
  11011. {
  11012. IDBTransaction conn = null;
  11013. try
  11014. {
  11015. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  11016. conn.Connect();
  11017. OracleParameter[] paras = new OracleParameter[]{
  11018. new OracleParameter("in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  11019. new OracleParameter("in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
  11020. new OracleParameter("in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
  11021. new OracleParameter("in_Process",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
  11022. new OracleParameter("in_OutKilnProcess",OracleDbType.Varchar2,se.OutProcedureIDS,ParameterDirection.Input),
  11023. new OracleParameter("in_QualityProcess",OracleDbType.Varchar2,se.QualityProcedureIDS,ParameterDirection.Input),
  11024. new OracleParameter("in_Defect1",OracleDbType.Varchar2,se.DefectIDS,ParameterDirection.Input),
  11025. new OracleParameter("in_Defect2",OracleDbType.Varchar2,se.DefectIDS2,ParameterDirection.Input),
  11026. new OracleParameter("out_Production",OracleDbType.RefCursor, ParameterDirection.Output),
  11027. };
  11028. conn.IsCommandTimeout = false;
  11029. DataSet data = null;
  11030. if (se.ProcedureIDS.Contains(","))
  11031. {
  11032. data = conn.ExecStoredProcedure("PRO_RPT_GetKilnProduction2", paras);
  11033. }
  11034. else
  11035. {
  11036. data = conn.ExecStoredProcedure("PRO_RPT_GetKilnProduction", paras);
  11037. }
  11038. ServiceResultEntity sre = new ServiceResultEntity();
  11039. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  11040. {
  11041. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  11042. return sre;
  11043. }
  11044. sre.Data = data;
  11045. //string sqlString =
  11046. //"SELECT kk.procedurename\n" +
  11047. //" ,kk.usercode\n" +
  11048. //" ,kk.kilncode\n" +
  11049. //" ,kk.kdate\n" +
  11050. //" ,COUNT(*) kcount\n" +
  11051. //" FROM (SELECT k.usercode\n" +
  11052. //" ,kiln.kilncode\n" +
  11053. //" ,p.procedurename\n" +
  11054. //" ,trunc(k.createtime) kdate\n" +
  11055. //" FROM tp_pm_kilncardata k\n" +
  11056. //" LEFT JOIN tp_mst_kiln kiln\n" +
  11057. //" ON kiln.kilnid = k.kilnid\n" +
  11058. //" LEFT JOIN tp_pc_procedure p\n" +
  11059. //" ON p.procedureid = k.procedureid\n" +
  11060. //" WHERE k.valueflag = '1'\n" +
  11061. //" AND k.AccountID = :in_AccountID\n" +
  11062. //" AND k.createtime >= :in_BeginDate\n" +
  11063. //" AND k.createtime <= :in_EndDate\n" +
  11064. //" AND instr(','|| :procedureids ||',', ','|| k.procedureid ||',' ) > 0) kk\n" +
  11065. //" GROUP BY kk.procedurename, kk.usercode, kk.kilncode, kk.kdate\n" +
  11066. //" ORDER BY kk.procedurename, kk.usercode, kk.kilncode, kk.kdate";
  11067. string sqlString = "WITH kilnData AS\n" +
  11068. " (SELECT k.usercode\n" +
  11069. " ,kiln.kilncode\n" +
  11070. " ,p.procedurename\n" +
  11071. " ,trunc(k.createtime) kdate\n" +
  11072. " ,k.userid\n" +
  11073. " ,k.procedureid\n" +
  11074. " ,k.kilnid\n" +
  11075. " ,k.KILNCARBATCHNO\n" +
  11076. " FROM tp_pm_kilncardata k\n" +
  11077. " LEFT JOIN tp_mst_kiln kiln\n" +
  11078. " ON kiln.kilnid = k.kilnid\n" +
  11079. " LEFT JOIN tp_pc_procedure p\n" +
  11080. " ON p.procedureid = k.procedureid\n" +
  11081. " WHERE k.valueflag = '1'\n" +
  11082. " AND k.AccountID = :in_AccountID\n" +
  11083. " AND k.createtime >= :in_BeginDate\n" +
  11084. " AND k.createtime <= :in_EndDate\n" +
  11085. " AND instr(',' || :procedureids || ',', ',' || k.procedureid || ',') > 0)\n" +
  11086. "SELECT kd.procedurename\n" +
  11087. " ,kd.usercode\n" +
  11088. " ,kd.kilncode\n" +
  11089. " ,kd.kdate\n" +
  11090. " ,kd.kcount\n" +
  11091. " ,kpd.kpcount\n" +
  11092. " FROM (SELECT kk.procedurename\n" +
  11093. " ,kk.usercode\n" +
  11094. " ,kk.kilncode\n" +
  11095. " ,kk.kdate\n" +
  11096. " ,kk.procedureid\n" +
  11097. " ,kk.userid\n" +
  11098. " ,kk.kilnid\n" +
  11099. " ,COUNT(*) kcount\n" +
  11100. " FROM kilnData kk\n" +
  11101. " GROUP BY kk.procedurename\n" +
  11102. " ,kk.usercode\n" +
  11103. " ,kk.kilncode\n" +
  11104. " ,kk.kdate\n" +
  11105. " ,kk.procedureid\n" +
  11106. " ,kk.userid\n" +
  11107. " ,kk.kilnid) kd\n" +
  11108. " LEFT JOIN (SELECT kk.kdate\n" +
  11109. " ,kk.procedureid\n" +
  11110. " ,kk.userid\n" +
  11111. " ,kk.kilnid\n" +
  11112. " ,COUNT(*) kpcount\n" +
  11113. " FROM kilnData kk\n" +
  11114. " INNER JOIN tp_pm_productiondata pd\n" +
  11115. " ON pd.valueflag = '1'\n" +
  11116. " AND pd.procedureid = kk.procedureid\n" +
  11117. " AND pd.kilnid = kk.kilnid\n" +
  11118. " AND pd.KILNCARBATCHNO = kk.KILNCARBATCHNO\n" +
  11119. " GROUP BY kk.kdate, kk.procedureid, kk.userid, kk.kilnid) kpd\n" +
  11120. " ON kpd.kdate = kd.kdate\n" +
  11121. " AND kpd.procedureid = kd.procedureid\n" +
  11122. " AND kpd.userid = kd.userid\n" +
  11123. " AND kpd.kilnid = kd.kilnid\n" +
  11124. " ORDER BY kd.procedurename, kd.usercode, kd.kilncode, kd.kdate";
  11125. OracleParameter[] parascount = new OracleParameter[]{
  11126. new OracleParameter(":in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  11127. new OracleParameter(":in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
  11128. new OracleParameter(":in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
  11129. new OracleParameter(":procedureids",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
  11130. };
  11131. DataTable dt = conn.GetSqlResultToDt(sqlString, parascount);
  11132. if (dt != null)
  11133. {
  11134. sre.Data.Tables.Add(dt);
  11135. }
  11136. conn.Commit();
  11137. return sre;
  11138. }
  11139. catch (Exception ex)
  11140. {
  11141. throw ex;
  11142. }
  11143. finally
  11144. {
  11145. if (conn != null &&
  11146. conn.ConnState == ConnectionState.Open)
  11147. {
  11148. conn.Disconnect();
  11149. }
  11150. }
  11151. }
  11152. #endregion
  11153. /// <summary>
  11154. /// 使用存储过程PRO_PM_GetProductionData获取生产工序计件数据
  11155. /// </summary>
  11156. /// <param name="searchEntity">生产数据实体类</param>
  11157. /// <param name="user">用户基本信息</param>
  11158. /// <returns>DataTable</returns>
  11159. public static DataTable GetProductionData(SearchProductionDataEntity searchEntity, SUserInfo user)
  11160. {
  11161. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  11162. string procsql = "PRO_RPT_GetProductionData";
  11163. try
  11164. {
  11165. IDataParameter[] paras = new OracleParameter[]
  11166. {
  11167. new OracleParameter("in_procedureList",OracleDbType.Varchar2, searchEntity.ProcedureIDS, ParameterDirection.Input),
  11168. new OracleParameter("in_LineID", OracleDbType.Int32,searchEntity.ProductionLineID, ParameterDirection.Input),
  11169. new OracleParameter("in_barCode", OracleDbType.Varchar2,searchEntity.BarCode, ParameterDirection.Input),
  11170. new OracleParameter("in_goodsCode", OracleDbType.Varchar2,searchEntity.GoodsCode, ParameterDirection.Input),
  11171. new OracleParameter("in_goodsName", OracleDbType.Varchar2,searchEntity.GoodsName, ParameterDirection.Input),
  11172. new OracleParameter("in_userCode", OracleDbType.Varchar2,searchEntity.UserCode, ParameterDirection.Input),
  11173. new OracleParameter("in_organizationID", OracleDbType.Int32,searchEntity.OrganizationID, ParameterDirection.Input),
  11174. new OracleParameter("in_remarks", OracleDbType.Varchar2,searchEntity.Remarks, ParameterDirection.Input),
  11175. new OracleParameter("in_isReworked", OracleDbType.Varchar2,searchEntity.IsRework, ParameterDirection.Input),
  11176. new OracleParameter("in_begindate", OracleDbType.Date,searchEntity.BeginDate, ParameterDirection.Input),
  11177. new OracleParameter("in_enddate", OracleDbType.Date,searchEntity.EndDate, ParameterDirection.Input),
  11178. new OracleParameter("in_accountID", OracleDbType.Int32,user.AccountID, ParameterDirection.Input),
  11179. new OracleParameter("in_userID", OracleDbType.Int32,user.UserID, ParameterDirection.Input),
  11180. new OracleParameter("in_kilnCode", OracleDbType.Varchar2,searchEntity.KilnCode, ParameterDirection.Input),
  11181. new OracleParameter("in_kilnCarCode", OracleDbType.Varchar2,searchEntity.KilnCarCode, ParameterDirection.Input),
  11182. new OracleParameter("in_kilnCarPosition", OracleDbType.Int32,searchEntity.KilnCarPosition, ParameterDirection.Input),
  11183. new OracleParameter("in_currentUserID", OracleDbType.Int32,user.UserID, ParameterDirection.Input),
  11184. new OracleParameter("out_result", OracleDbType.RefCursor, ParameterDirection.Output),
  11185. new OracleParameter("in_goodsTypeCode", OracleDbType.Varchar2,searchEntity.GoodsTypeCode, ParameterDirection.Input),
  11186. };
  11187. oracleConn.Open();
  11188. DataSet returnDs = oracleConn.ExecStoredProcedure(procsql, paras);
  11189. if (returnDs != null && returnDs.Tables.Count > 0)
  11190. {
  11191. return returnDs.Tables[0];
  11192. }
  11193. else
  11194. {
  11195. return null;
  11196. }
  11197. }
  11198. catch (Exception ex)
  11199. {
  11200. throw ex;
  11201. }
  11202. finally
  11203. {
  11204. if (oracleConn.ConnState == ConnectionState.Open)
  11205. {
  11206. oracleConn.Close();
  11207. }
  11208. }
  11209. }
  11210. /// <summary>
  11211. /// 取得RPT080106(温湿计明细)的汇总信息查询数据
  11212. /// </summary>
  11213. /// <param name="user">登录用户信息</param>
  11214. /// <param name="se">查询条件</param>
  11215. /// <returns>查询结果</returns>
  11216. public static ServiceResultEntity GetRPT080106IData(SUserInfo user, CelsiusRecordEntity se)
  11217. {
  11218. IDBConnection conn = null;
  11219. try
  11220. {
  11221. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  11222. List<OracleParameter> parameters = new List<OracleParameter>();
  11223. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080106ISQL(user, se, ref parameters));
  11224. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  11225. ServiceResultEntity sre = new ServiceResultEntity();
  11226. if (data == null || data.Rows.Count == 0)
  11227. {
  11228. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  11229. return sre;
  11230. }
  11231. sre.Data = new DataSet();
  11232. sre.Data.Tables.Add(data);
  11233. return sre;
  11234. }
  11235. catch (Exception ex)
  11236. {
  11237. throw ex;
  11238. }
  11239. finally
  11240. {
  11241. if (conn != null &&
  11242. conn.ConnState == ConnectionState.Open)
  11243. {
  11244. conn.Close();
  11245. }
  11246. }
  11247. }
  11248. /// <summary>
  11249. /// 取得RPT080106(温湿计明细)的汇总信息查询数据sql
  11250. /// </summary>
  11251. /// <returns>sql</returns>
  11252. private static string GetRPT080106ISQL(SUserInfo user, CelsiusRecordEntity se, ref List<OracleParameter> parameters)
  11253. {
  11254. string selSql = @"Select cr.*,t.*,to_char(cr.RecordDate,'mm-dd hh24:mi') as RecordDateStr from TP_PM_CelsiusRecord cr
  11255. Left join TP_MST_User u On cr.ThermometerID = u.UserId
  11256. Inner join TP_MST_Thermometer t On cr.ThermometerID = t.ThermometerID
  11257. Where cr.AccountID =:AccountID and cr.ValueFlag = '1' ";
  11258. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  11259. if (!string.IsNullOrEmpty(se.ThermometerIDS))
  11260. {
  11261. selSql = selSql + " AND instr(','||:ThermometerIDS||',',','||cr.ThermometerID||',')>0 ";
  11262. parameters.Add(new OracleParameter(":ThermometerIDS", OracleDbType.NVarchar2, se.ThermometerIDS, ParameterDirection.Input));
  11263. }
  11264. if (!string.IsNullOrEmpty(se.Remarks))
  11265. {
  11266. selSql = selSql + " AND instr(cr.Remarks,:Remarks) >0 ";
  11267. parameters.Add(new OracleParameter(":Remarks", OracleDbType.NVarchar2, se.Remarks, ParameterDirection.Input));
  11268. }
  11269. if (se.RecordDate.HasValue)
  11270. {
  11271. selSql = selSql + " AND cr.CreateTime>= :CreateTimeStart ";
  11272. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.RecordDate.Value, ParameterDirection.Input));
  11273. }
  11274. if (se.RecordDateEnd.HasValue)
  11275. {
  11276. selSql = selSql + " AND cr.CreateTime<= :CreateTimeEnd ";
  11277. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.RecordDateEnd.Value, ParameterDirection.Input));
  11278. }
  11279. selSql +=
  11280. // 温湿计查看权限
  11281. " AND EXISTS (SELECT UP.PurviewID" +
  11282. " FROM TP_MST_UserPurview UP" +
  11283. " WHERE UP.PurviewType = '" + (int)Constant.PurviewType.ViewCelsius + "'" +
  11284. " AND (UP.PurviewID = -1 OR UP.PurviewID = CR.ThermometerID)" +
  11285. " AND UP.UserId = :UPUserId)";
  11286. parameters.Add(new OracleParameter(":UPUserId", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  11287. selSql = selSql + " order by RecordDate asc";
  11288. return selSql;
  11289. }
  11290. /// <summary>
  11291. /// 取得RPT030110画面(半检登记汇总表)的汇总信息查询数据
  11292. /// </summary>
  11293. /// <param name="user">登录用户信息</param>
  11294. /// <param name="se">查询条件</param>
  11295. /// <returns>查询结果</returns>
  11296. public static ServiceResultEntity GetRPT030110Data(SUserInfo user, SemiCheckEntity se)
  11297. {
  11298. IDBConnection conn = null;
  11299. try
  11300. {
  11301. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  11302. List<OracleParameter> parameters = new List<OracleParameter>();
  11303. string sql = ReportModuleLogic.GetRPT030110SSQL(user, se, ref parameters);
  11304. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  11305. ServiceResultEntity sre = new ServiceResultEntity();
  11306. if (data == null || data.Rows.Count == 0)
  11307. {
  11308. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  11309. return sre;
  11310. }
  11311. sre.Data = new DataSet();
  11312. sre.Data.Tables.Add(data);
  11313. return sre;
  11314. }
  11315. catch (Exception ex)
  11316. {
  11317. throw ex;
  11318. }
  11319. finally
  11320. {
  11321. if (conn != null &&
  11322. conn.ConnState == ConnectionState.Open)
  11323. {
  11324. conn.Close();
  11325. }
  11326. }
  11327. }
  11328. /// <summary>
  11329. /// 获取RPT030110画面(半检登记汇总表)的汇总信息查询sql
  11330. /// </summary>
  11331. /// <returns>sql</returns>
  11332. private static string GetRPT030110SSQL(SUserInfo user, SemiCheckEntity se, ref List<OracleParameter> parameters)
  11333. {
  11334. parameters.Add(new OracleParameter(":accountid", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  11335. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  11336. #region
  11337. // string sqlString = @"
  11338. // SELECT t.reworkprocedureid -- 返工工序id
  11339. // ,decode(gid,
  11340. // 7,
  11341. // '总计',
  11342. // 3,
  11343. // '合计【' || t.reworkprocedurename || '】',
  11344. // 0,
  11345. // t.reworkprocedurename,
  11346. // '--') reworkprocedurename -- 返工工序
  11347. // ,t.goodstypecode2 -- 产品二级类别
  11348. // ,decode(gid,
  11349. // 1,
  11350. // '小计【' || t.goodstypename2 || '】',
  11351. // 0,
  11352. // t.goodstypename2,
  11353. // '--') goodstypename2 -- 产品二级类别
  11354. // ,t.reworkuserid -- 返工工号id
  11355. // ,decode(gid, 0, t.reworkusercode, '--') reworkusercode -- 返工工号
  11356. // ,t.goodsid -- 产品id
  11357. // ,decode(gid, 0, t.goodscode, '--') goodscode -- 产品编码
  11358. // ,decode(gid, 0, t.goodstypename, '--') goodstypename -- 产品类别
  11359. // ,t.reworkcount -- 返工数
  11360. // ,t.badcount -- 不合格数
  11361. // ,t.regoodcount -- 复检合格数
  11362. // ,t.rebadcount -- 复检不合格数
  11363. // ,t.renocount -- 未复检
  11364. // --,t.renocountsum -- 待返工
  11365. // ,(SELECT COUNT(*)
  11366. // FROM tp_pm_semicheck sci
  11367. // WHERE sci.valueflag = '1'
  11368. // AND sci.backoutflag = '0'
  11369. // AND sci.semichecktype = 1
  11370. // AND sci.resemichecktype = 0
  11371. // AND (t.reworkprocedureid is null or sci.reworkprocedureid = t.reworkprocedureid)
  11372. // AND (t.goodsid is null or sci.goodsid = t.goodsid)
  11373. // AND (t.reworkuserid is null or sci.reworkuserid = t.reworkuserid)) AS renocountsum
  11374. // FROM (SELECT grouping_id(sc.reworkprocedureid, gt2.goodstypecode, g.goodsid) gid
  11375. // ,sc.reworkprocedureid
  11376. // ,rp.procedurename reworkprocedurename
  11377. // ,gt2.goodstypecode goodstypecode2
  11378. // ,gt2.goodstypename goodstypename2
  11379. // ,sc.reworkuserid
  11380. // ,sc.reworkusercode
  11381. // ,g.goodsid
  11382. // ,g.goodscode
  11383. // ,gt.goodstypename
  11384. // , SUM(CASE
  11385. // WHEN sc.semichecktype = 1 THEN
  11386. // 1
  11387. // ELSE
  11388. // 0
  11389. // END) reworkcount
  11390. // , SUM(CASE
  11391. // WHEN sc.semichecktype = 2 THEN
  11392. // 1
  11393. // ELSE
  11394. // 0
  11395. // END) badcount
  11396. // , SUM(CASE
  11397. // WHEN sc.semichecktype = 1 AND sc.resemichecktype = 0 THEN
  11398. // 1
  11399. // ELSE
  11400. // 0
  11401. // END) renocount
  11402. // , SUM(CASE
  11403. // WHEN sc.semichecktype = 1 AND sc.resemichecktype = 1 THEN
  11404. // 1
  11405. // ELSE
  11406. // 0
  11407. // END) regoodcount
  11408. // , SUM(CASE
  11409. // WHEN sc.semichecktype = 1 AND sc.resemichecktype = 2 THEN
  11410. // 1
  11411. // ELSE
  11412. // 0
  11413. // END) rebadcount
  11414. // --,(select count(*) from tp_pm_semicheck sci where sci.valueflag = '1' and sci.backoutflag = '0' and sci.semichecktype = 1
  11415. // -- and sci.resemichecktype = 0 and sci.reworkprocedureid = sc.reworkprocedureid and sci.reworkuserid = sc.reworkuserid and sci.goodsid = g.goodsid) as renocountsum
  11416. // --FROM tp_pm_semicheck sc
  11417. // FROM (SELECT semicheckid
  11418. // ,barcode
  11419. // ,productionlineid
  11420. // ,procedureid
  11421. // ,proceduretime
  11422. // ,proceduremodel
  11423. // ,modeltype
  11424. // ,organizationid
  11425. // ,goodsid
  11426. // ,goodscode
  11427. // ,userid
  11428. // ,usercode
  11429. // ,productiondataid
  11430. // ,logoid
  11431. // ,ispublicbody
  11432. // ,specialrepairflag
  11433. // ,goodslevelid
  11434. // ,goodsleveltypeid
  11435. // ,groutingdailyid
  11436. // ,groutingdailydetailid
  11437. // ,groutinglineid
  11438. // ,groutinglinecode
  11439. // ,groutinglinename
  11440. // ,gmouldtypeid
  11441. // ,canmanytimes
  11442. // ,groutinglinedetailid
  11443. // ,groutingdate
  11444. // ,groutingmouldcode
  11445. // ,mouldcode
  11446. // ,groutinguserid
  11447. // ,groutingusercode
  11448. // ,groutingnum
  11449. // ,semichecktype
  11450. // ,semicheckuserid
  11451. // ,semicheckusercode
  11452. // ,semichecktime
  11453. // ,reworkprocedureid
  11454. // ,reworkprocedurecode
  11455. // ,reworkuserid
  11456. // ,reworkusercode
  11457. // ,resemichecktype
  11458. // ,resemicheckuserid
  11459. // ,resemicheckusercode
  11460. // ,resemichecktime
  11461. // ,backoutflag
  11462. // ,backouttime
  11463. // ,backoutuserid
  11464. // ,backoutusercode
  11465. // ,remarks
  11466. // ,createtime
  11467. // ,createuserid
  11468. // ,updateuserid
  11469. // FROM tp_pm_semicheck sc
  11470. // WHERE sc.accountid = :accountid
  11471. // AND sc.valueflag = '1'
  11472. // AND sc.semichecktype = 1
  11473. // AND sc.backoutflag = '0'
  11474. // UNION ALL
  11475. // SELECT DISTINCT sc.semicheckid
  11476. // ,sc.barcode
  11477. // ,sc.productionlineid
  11478. // ,sc.procedureid
  11479. // ,sc.proceduretime
  11480. // ,sc.proceduremodel
  11481. // ,sc.modeltype
  11482. // ,sc.organizationid
  11483. // ,sc.goodsid
  11484. // ,sc.goodscode
  11485. // ,sc.userid
  11486. // ,sc.usercode
  11487. // ,sc.productiondataid
  11488. // ,sc.logoid
  11489. // ,sc.ispublicbody
  11490. // ,sc.specialrepairflag
  11491. // ,sc.goodslevelid
  11492. // ,sc.goodsleveltypeid
  11493. // ,sc.groutingdailyid
  11494. // ,sc.groutingdailydetailid
  11495. // ,sc.groutinglineid
  11496. // ,sc.groutinglinecode
  11497. // ,sc.groutinglinename
  11498. // ,sc.gmouldtypeid
  11499. // ,sc.canmanytimes
  11500. // ,sc.groutinglinedetailid
  11501. // ,sc.groutingdate
  11502. // ,sc.groutingmouldcode
  11503. // ,sc.mouldcode
  11504. // ,sc.groutinguserid
  11505. // ,sc.groutingusercode
  11506. // ,sc.groutingnum
  11507. // ,sc.semichecktype
  11508. // ,sc.semicheckuserid
  11509. // ,sc.semicheckusercode
  11510. // ,sc.semichecktime
  11511. // --,sc.reworkprocedureid
  11512. // --,sc.reworkprocedurecode
  11513. // --,sc.reworkuserid
  11514. // --,sc.reworkusercode
  11515. // ,scd.defectprocedureid
  11516. // ,scdp.procedurename
  11517. // ,scd.defectuserid
  11518. // ,scd.defectusercode
  11519. // ,sc.resemichecktype
  11520. // ,sc.resemicheckuserid
  11521. // ,sc.resemicheckusercode
  11522. // ,sc.resemichecktime
  11523. // ,sc.backoutflag
  11524. // ,sc.backouttime
  11525. // ,sc.backoutuserid
  11526. // ,sc.backoutusercode
  11527. // ,sc.remarks
  11528. // ,sc.createtime
  11529. // ,sc.createuserid
  11530. // ,sc.updateuserid
  11531. // FROM tp_pm_semicheck sc
  11532. // LEFT JOIN TP_PM_SemiCheckDefect scd
  11533. // ON sc.semicheckid = scd.semicheckid
  11534. // LEFT JOIN tp_pc_procedure scdp
  11535. // ON scdp.procedureid = scd.defectprocedureid
  11536. // WHERE sc.accountid = :accountid
  11537. // AND sc.valueflag = '1'
  11538. // AND sc.semichecktype = 2
  11539. // AND sc.backoutflag = '0'
  11540. // ) sc
  11541. // LEFT JOIN tp_pc_procedure rp
  11542. // ON rp.procedureid = sc.reworkprocedureid
  11543. // INNER JOIN tp_mst_goods g
  11544. // ON g.goodsid = sc.goodsid
  11545. // INNER JOIN tp_mst_goodstype gt
  11546. // ON gt.goodstypeid = g.goodstypeid
  11547. // INNER JOIN tp_mst_goodstype gt2
  11548. // ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)
  11549. // AND gt2.accountid = gt.accountid
  11550. // INNER join TP_PM_GroutingDailyDetail GroutingDailyDetail
  11551. // ON GroutingDailyDetail.GroutingDailyDetailID=sc.GroutingDailyDetailID
  11552. // 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))";
  11553. #endregion
  11554. string sqlString = "SELECT t.reworkprocedureid -- 返工工序id\n" +
  11555. " ,decode(gid,\n" +
  11556. " 7,\n" +
  11557. " '总计',\n" +
  11558. " 3,\n" +
  11559. " '合计【' || t.reworkprocedurename || '】',\n" +
  11560. " 0,\n" +
  11561. " t.reworkprocedurename,\n" +
  11562. " '--') reworkprocedurename -- 返工工序\n" +
  11563. " ,t.goodstypecode2 -- 产品二级类别\n" +
  11564. " ,decode(gid,\n" +
  11565. " 1,\n" +
  11566. " '小计【' || t.goodstypename2 || '】',\n" +
  11567. " 0,\n" +
  11568. " t.goodstypename2,\n" +
  11569. " '--') goodstypename2 -- 产品二级类别\n" +
  11570. " ,t.reworkuserid -- 返工工号id\n" +
  11571. " ,decode(gid, 0, t.reworkusercode, '--') reworkusercode -- 返工工号\n" +
  11572. " ,t.goodsid -- 产品id\n" +
  11573. " ,decode(gid, 0, t.goodscode, '--') goodscode -- 产品编码\n" +
  11574. " ,decode(gid, 0, t.goodstypename, '--') goodstypename -- 产品类别\n" +
  11575. " ,t.reworkcount -- 返工数\n" +
  11576. " ,t.badcount -- 不合格数\n" +
  11577. " ,t.regoodcount -- 复检合格数\n" +
  11578. " ,t.rebadcount -- 复检不合格数\n" +
  11579. " ,t.renocount -- 未复检\n" +
  11580. " ,t.renocountsum -- 待返工\n" +
  11581. " FROM (SELECT grouping_id(sct.reworkprocedureid,\n" +
  11582. " sct.goodstypecode2,\n" +
  11583. " sct.goodsid) gid\n" +
  11584. " ,sct.displayno\n" +
  11585. " ,sct.reworkprocedureid\n" +
  11586. " ,sct.reworkprocedurename\n" +
  11587. " ,sct.goodstypecode2\n" +
  11588. " ,sct.goodstypename2\n" +
  11589. " ,sct.reworkuserid\n" +
  11590. " ,sct.reworkusercode\n" +
  11591. " ,sct.goodsid\n" +
  11592. " ,sct.goodscode\n" +
  11593. " ,sct.goodstypename\n" +
  11594. " ,SUM(sct.reworkcount) reworkcount\n" +
  11595. " ,SUM(sct. badcount) badcount\n" +
  11596. " ,SUM(sct. renocount) renocount\n" +
  11597. " ,SUM(sct.regoodcount) regoodcount\n" +
  11598. " ,SUM(sct.rebadcount) rebadcount\n" +
  11599. " ,SUM(sct.renocountsum) renocountsum\n" +
  11600. " FROM (SELECT rp.displayno\n" +
  11601. " ,sc.reworkprocedureid\n" +
  11602. " ,rp.procedurename reworkprocedurename\n" +
  11603. " ,gt2.goodstypecode goodstypecode2\n" +
  11604. " ,gt2.goodstypename goodstypename2\n" +
  11605. " ,sc.reworkuserid\n" +
  11606. " ,sc.reworkusercode\n" +
  11607. " ,g.goodsid\n" +
  11608. " ,g.goodscode\n" +
  11609. " ,gt.goodstypename\n" +
  11610. " , SUM(CASE\n" +
  11611. " WHEN sc.semichecktype = 1 THEN\n" +
  11612. " 1\n" +
  11613. " ELSE\n" +
  11614. " 0\n" +
  11615. " END) reworkcount\n" +
  11616. " , SUM(CASE\n" +
  11617. " WHEN sc.semichecktype = 2 THEN\n" +
  11618. " 1\n" +
  11619. " ELSE\n" +
  11620. " 0\n" +
  11621. " END) badcount\n" +
  11622. " , SUM(CASE\n" +
  11623. " WHEN sc.semichecktype = 1 AND sc.resemichecktype = 0 THEN\n" +
  11624. " 1\n" +
  11625. " ELSE\n" +
  11626. " 0\n" +
  11627. " END) renocount\n" +
  11628. " , SUM(CASE\n" +
  11629. " WHEN sc.semichecktype = 1 AND sc.resemichecktype = 1 THEN\n" +
  11630. " 1\n" +
  11631. " ELSE\n" +
  11632. " 0\n" +
  11633. " END) regoodcount\n" +
  11634. " , SUM(CASE\n" +
  11635. " WHEN sc.semichecktype = 1 AND sc.resemichecktype = 2 THEN\n" +
  11636. " 1\n" +
  11637. " ELSE\n" +
  11638. " 0\n" +
  11639. " END) rebadcount\n" +
  11640. " ,(SELECT COUNT(*)\n" +
  11641. " FROM tp_pm_semicheck sci\n" +
  11642. " WHERE sci.valueflag = '1'\n" +
  11643. " AND sci.backoutflag = '0'\n" +
  11644. " AND sci.semichecktype = 1\n" +
  11645. " AND sci.resemichecktype = 0\n" +
  11646. " AND sci.accountid = :accountid\n" +
  11647. " AND sci.reworkprocedureid = sc.reworkprocedureid\n" +
  11648. " AND sci.reworkuserid = sc.reworkuserid\n" +
  11649. " AND sci.goodsid = g.goodsid) AS renocountsum\n" +
  11650. " FROM (SELECT semicheckid\n" +
  11651. " ,barcode\n" +
  11652. " ,productionlineid\n" +
  11653. " ,procedureid\n" +
  11654. " ,proceduretime\n" +
  11655. " ,proceduremodel\n" +
  11656. " ,modeltype\n" +
  11657. " ,organizationid\n" +
  11658. " ,goodsid\n" +
  11659. " ,goodscode\n" +
  11660. " ,userid\n" +
  11661. " ,usercode\n" +
  11662. " ,productiondataid\n" +
  11663. " ,logoid\n" +
  11664. " ,ispublicbody\n" +
  11665. " ,specialrepairflag\n" +
  11666. " ,goodslevelid\n" +
  11667. " ,goodsleveltypeid\n" +
  11668. " ,groutingdailyid\n" +
  11669. " ,groutingdailydetailid\n" +
  11670. " ,groutinglineid\n" +
  11671. " ,groutinglinecode\n" +
  11672. " ,groutinglinename\n" +
  11673. " ,gmouldtypeid\n" +
  11674. " ,canmanytimes\n" +
  11675. " ,groutinglinedetailid\n" +
  11676. " ,groutingdate\n" +
  11677. " ,groutingmouldcode\n" +
  11678. " ,mouldcode\n" +
  11679. " ,groutinguserid\n" +
  11680. " ,groutingusercode\n" +
  11681. " ,groutingnum\n" +
  11682. " ,semichecktype\n" +
  11683. " ,semicheckuserid\n" +
  11684. " ,semicheckusercode\n" +
  11685. " ,semichecktime\n" +
  11686. " ,reworkprocedureid\n" +
  11687. " ,reworkprocedurecode\n" +
  11688. " ,reworkuserid\n" +
  11689. " ,reworkusercode\n" +
  11690. " ,resemichecktype\n" +
  11691. " ,resemicheckuserid\n" +
  11692. " ,resemicheckusercode\n" +
  11693. " ,resemichecktime\n" +
  11694. " ,backoutflag\n" +
  11695. " ,backouttime\n" +
  11696. " ,backoutuserid\n" +
  11697. " ,backoutusercode\n" +
  11698. " ,remarks\n" +
  11699. " ,createtime\n" +
  11700. " ,createuserid\n" +
  11701. " ,updateuserid\n" +
  11702. " FROM tp_pm_semicheck sc\n" +
  11703. " WHERE sc.accountid = :accountid\n" +
  11704. " AND sc.valueflag = '1'\n" +
  11705. " AND sc.semichecktype = 1\n" +
  11706. " AND sc.backoutflag = '0'\n" +
  11707. " UNION ALL\n" +
  11708. " SELECT DISTINCT sc.semicheckid\n" +
  11709. " ,sc.barcode\n" +
  11710. " ,sc.productionlineid\n" +
  11711. " ,sc.procedureid\n" +
  11712. " ,sc.proceduretime\n" +
  11713. " ,sc.proceduremodel\n" +
  11714. " ,sc.modeltype\n" +
  11715. " ,sc.organizationid\n" +
  11716. " ,sc.goodsid\n" +
  11717. " ,sc.goodscode\n" +
  11718. " ,sc.userid\n" +
  11719. " ,sc.usercode\n" +
  11720. " ,sc.productiondataid\n" +
  11721. " ,sc.logoid\n" +
  11722. " ,sc.ispublicbody\n" +
  11723. " ,sc.specialrepairflag\n" +
  11724. " ,sc.goodslevelid\n" +
  11725. " ,sc.goodsleveltypeid\n" +
  11726. " ,sc.groutingdailyid\n" +
  11727. " ,sc.groutingdailydetailid\n" +
  11728. " ,sc.groutinglineid\n" +
  11729. " ,sc.groutinglinecode\n" +
  11730. " ,sc.groutinglinename\n" +
  11731. " ,sc.gmouldtypeid\n" +
  11732. " ,sc.canmanytimes\n" +
  11733. " ,sc.groutinglinedetailid\n" +
  11734. " ,sc.groutingdate\n" +
  11735. " ,sc.groutingmouldcode\n" +
  11736. " ,sc.mouldcode\n" +
  11737. " ,sc.groutinguserid\n" +
  11738. " ,sc.groutingusercode\n" +
  11739. " ,sc.groutingnum\n" +
  11740. " ,sc.semichecktype\n" +
  11741. " ,sc.semicheckuserid\n" +
  11742. " ,sc.semicheckusercode\n" +
  11743. " ,sc.semichecktime\n" +
  11744. " --,sc.reworkprocedureid\n" +
  11745. " --,sc.reworkprocedurecode\n" +
  11746. " --,sc.reworkuserid\n" +
  11747. " --,sc.reworkusercode\n" +
  11748. " ,scd.defectprocedureid\n" +
  11749. " ,scdp.procedurename\n" +
  11750. " ,scd.defectuserid\n" +
  11751. " ,scd.defectusercode\n" +
  11752. " ,sc.resemichecktype\n" +
  11753. " ,sc.resemicheckuserid\n" +
  11754. " ,sc.resemicheckusercode\n" +
  11755. " ,sc.resemichecktime\n" +
  11756. " ,sc.backoutflag\n" +
  11757. " ,sc.backouttime\n" +
  11758. " ,sc.backoutuserid\n" +
  11759. " ,sc.backoutusercode\n" +
  11760. " ,sc.remarks\n" +
  11761. " ,sc.createtime\n" +
  11762. " ,sc.createuserid\n" +
  11763. " ,sc.updateuserid\n" +
  11764. " FROM tp_pm_semicheck sc\n" +
  11765. " LEFT JOIN TP_PM_SemiCheckDefect scd\n" +
  11766. " ON sc.semicheckid = scd.semicheckid\n" +
  11767. " AND scd.valueflag='1'\n" +
  11768. " LEFT JOIN tp_pc_procedure scdp\n" +
  11769. " ON scdp.procedureid = scd.defectprocedureid\n" +
  11770. " WHERE sc.accountid = :accountid\n" +
  11771. " AND sc.valueflag = '1'\n" +
  11772. " AND sc.semichecktype = 2\n" +
  11773. " AND sc.backoutflag = '0') sc\n" +
  11774. " LEFT JOIN tp_pc_procedure rp\n" +
  11775. " ON rp.procedureid = sc.reworkprocedureid\n" +
  11776. " INNER JOIN tp_mst_goods g\n" +
  11777. " ON g.goodsid = sc.goodsid\n" +
  11778. " INNER JOIN tp_mst_goodstype gt\n" +
  11779. " ON gt.goodstypeid = g.goodstypeid\n" +
  11780. " INNER JOIN tp_mst_goodstype gt2\n" +
  11781. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  11782. " AND gt2.accountid = gt.accountid\n" +
  11783. " INNER JOIN TP_PM_GroutingDailyDetail GroutingDailyDetail\n" +
  11784. " ON GroutingDailyDetail.GroutingDailyDetailID =\n" +
  11785. " sc.GroutingDailyDetailID\n" //+
  11786. //" WHERE EXISTS (SELECT 1\n" +
  11787. //" FROM TP_MST_UserPurview up\n" +
  11788. //" WHERE up.PurviewType = 9\n" +
  11789. //" AND up.UserID = :UserID\n" +
  11790. //" AND (up.PurviewID = -1 OR\n" +
  11791. //" up.PurviewID = sc.procedureid))\n"
  11792. ;
  11793. // 完成工序集
  11794. if (!string.IsNullOrEmpty(se.CProcedureIDS))
  11795. {
  11796. sqlString += " AND instr(','||:procedureids||',', ',' || sc.procedureid || ',') > 0";
  11797. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, se.CProcedureIDS, ParameterDirection.Input));
  11798. }
  11799. // 完成时间起始
  11800. if (se.CDateTimeStart.HasValue)
  11801. {
  11802. sqlString = sqlString + " AND sc.ProcedureTime >= :CDateTimeStart ";
  11803. parameters.Add(new OracleParameter(":CDateTimeStart", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11804. }
  11805. // 完成时间结束
  11806. if (se.CDateTimeEnd.HasValue)
  11807. {
  11808. sqlString = sqlString + " AND sc.ProcedureTime <= :CDateTimeEnd ";
  11809. parameters.Add(new OracleParameter(":CDateTimeEnd", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11810. }
  11811. // 完成工号
  11812. if (!string.IsNullOrEmpty(se.CUserCode))
  11813. {
  11814. sqlString = sqlString + " AND instr(sc.UserCode,:UserCode)>0";
  11815. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CUserCode, ParameterDirection.Input));
  11816. }
  11817. // 产品类别
  11818. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  11819. {
  11820. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 ";
  11821. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  11822. }
  11823. // 产品编码
  11824. if (!string.IsNullOrEmpty(se.GoodsCode))
  11825. {
  11826. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0";
  11827. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  11828. }
  11829. // 成型工号
  11830. if (!string.IsNullOrEmpty(se.GroutingUserCode))
  11831. {
  11832. sqlString = sqlString + " AND instr(sc.GroutingUserCode,:GroutingUserCode)>0";
  11833. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.NVarchar2, se.GroutingUserCode, ParameterDirection.Input));
  11834. }
  11835. // 注浆时间起始
  11836. if (se.GroutingDateTimeStart.HasValue)
  11837. {
  11838. sqlString = sqlString + " AND sc.GroutingDate >= :GroutingDateTimeStart ";
  11839. parameters.Add(new OracleParameter(":GroutingDateTimeStart", OracleDbType.Date, se.GroutingDateTimeStart.Value, ParameterDirection.Input));
  11840. }
  11841. // 注浆时间结束
  11842. if (se.GroutingDateTimeEnd.HasValue)
  11843. {
  11844. sqlString = sqlString + " AND sc.GroutingDate <= :GroutingDateTimeEnd ";
  11845. parameters.Add(new OracleParameter(":GroutingDateTimeEnd", OracleDbType.Date, se.GroutingDateTimeEnd.Value, ParameterDirection.Input));
  11846. }
  11847. // 交坯时间起始
  11848. if (se.DeliveryDateTimeStart.HasValue)
  11849. {
  11850. sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime >= :DeliveryDateTimeStart ";
  11851. parameters.Add(new OracleParameter(":DeliveryDateTimeStart", OracleDbType.Date, se.DeliveryDateTimeStart.Value, ParameterDirection.Input));
  11852. }
  11853. // 交坯时间结束
  11854. if (se.DeliveryDateTimeEnd.HasValue)
  11855. {
  11856. sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime <= :DeliveryDateTimeEnd ";
  11857. parameters.Add(new OracleParameter(":DeliveryDateTimeEnd", OracleDbType.Date, se.DeliveryDateTimeEnd.Value, ParameterDirection.Input));
  11858. }
  11859. // 半检状态
  11860. if (!string.IsNullOrEmpty(se.SemiCheckType))
  11861. {
  11862. sqlString = sqlString + " AND instr(','||:SemiCheckType||',',','||sc.SemiCheckType||',')>0 ";
  11863. parameters.Add(new OracleParameter(":SemiCheckType", OracleDbType.NVarchar2, se.SemiCheckType, ParameterDirection.Input));
  11864. }
  11865. // 半检时间起始
  11866. if (se.SemiCheckDateTimeStart.HasValue)
  11867. {
  11868. sqlString = sqlString + " AND sc.SemiCheckTime >= :SemiCheckDateTimeStart ";
  11869. parameters.Add(new OracleParameter(":SemiCheckDateTimeStart", OracleDbType.Date, se.SemiCheckDateTimeStart.Value, ParameterDirection.Input));
  11870. }
  11871. // 半检时间结束
  11872. if (se.SemiCheckDateTimeEnd.HasValue)
  11873. {
  11874. sqlString = sqlString + " AND sc.SemiCheckTime <= :SemiCheckDateTimeEnd ";
  11875. parameters.Add(new OracleParameter(":SemiCheckDateTimeEnd", OracleDbType.Date, se.SemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  11876. }
  11877. // 半检工号
  11878. if (!string.IsNullOrEmpty(se.SemiCheckUserCode))
  11879. {
  11880. sqlString = sqlString + " AND instr(sc.SemiCheckUserCode,:SemiCheckUserCode)>0";
  11881. parameters.Add(new OracleParameter(":SemiCheckUserCode", OracleDbType.NVarchar2, se.SemiCheckUserCode, ParameterDirection.Input));
  11882. }
  11883. // 返工工序
  11884. if (!string.IsNullOrEmpty(se.RProcedureIDS))
  11885. {
  11886. sqlString = sqlString + " AND instr(','||:RProcedureIDS||',',','||sc.ReworkProcedureID||',')>0 ";
  11887. parameters.Add(new OracleParameter(":RProcedureIDS", OracleDbType.NVarchar2, se.RProcedureIDS, ParameterDirection.Input));
  11888. }
  11889. // 返工工号
  11890. if (!string.IsNullOrEmpty(se.ReworkUserCode))
  11891. {
  11892. sqlString = sqlString + " AND instr(sc.ReworkUserCode,:ReworkUserCode)>0";
  11893. parameters.Add(new OracleParameter(":ReworkUserCode", OracleDbType.NVarchar2, se.ReworkUserCode, ParameterDirection.Input));
  11894. }
  11895. // 复检状态
  11896. if (!string.IsNullOrEmpty(se.ReSemiCheckType))
  11897. {
  11898. sqlString = sqlString + " AND instr(','||:ReSemiCheckType||',',','||sc.ReSemiCheckType||',')>0 ";
  11899. parameters.Add(new OracleParameter(":ReSemiCheckType", OracleDbType.NVarchar2, se.ReSemiCheckType, ParameterDirection.Input));
  11900. }
  11901. // 复检时间起始
  11902. if (se.ReSemiCheckDateTimeStart.HasValue)
  11903. {
  11904. sqlString = sqlString + " AND sc.ReSemiCheckTime >= :ReSemiCheckDateTimeStart ";
  11905. parameters.Add(new OracleParameter(":ReSemiCheckDateTimeStart", OracleDbType.Date, se.ReSemiCheckDateTimeStart.Value, ParameterDirection.Input));
  11906. }
  11907. // 复检时间结束
  11908. if (se.ReSemiCheckDateTimeEnd.HasValue)
  11909. {
  11910. sqlString = sqlString + " AND sc.ReSemiCheckTime <= :ReSemiCheckDateTimeEnd ";
  11911. parameters.Add(new OracleParameter(":ReSemiCheckDateTimeEnd", OracleDbType.Date, se.ReSemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  11912. }
  11913. // 复检工号
  11914. if (!string.IsNullOrEmpty(se.ReSemiCheckUserCode))
  11915. {
  11916. sqlString = sqlString + " AND instr(sc.ReSemiCheckUserCode,:ReSemiCheckUserCode)>0";
  11917. parameters.Add(new OracleParameter(":ReSemiCheckUserCode", OracleDbType.NVarchar2, se.ReSemiCheckUserCode, ParameterDirection.Input));
  11918. }
  11919. // 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),())
  11920. // ORDER BY rp.displayno
  11921. // ,gt2.goodstypename
  11922. // ,sc.reworkusercode
  11923. // ,g.goodscode
  11924. // ,gt.goodstypename, gid) t
  11925. // ";
  11926. sqlString = sqlString +
  11927. " GROUP BY rp.displayno\n" +
  11928. " ,sc.reworkprocedureid\n" +
  11929. " ,rp.procedurename\n" +
  11930. " ,gt2.goodstypecode\n" +
  11931. " ,gt2.goodstypename\n" +
  11932. " ,sc.reworkuserid\n" +
  11933. " ,sc.reworkusercode\n" +
  11934. " ,g.goodsid\n" +
  11935. " ,g.goodscode\n" +
  11936. " ,gt.goodstypename) sct\n" +
  11937. " 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" +
  11938. " ORDER BY sct.displayno\n" +
  11939. " ,sct.goodstypename\n" +
  11940. " ,sct.reworkusercode\n" +
  11941. " ,sct.goodscode\n" +
  11942. " ,sct.goodstypename\n" +
  11943. " ,gid) t";
  11944. return sqlString;
  11945. }
  11946. /// <summary>
  11947. /// 取得RPT080107(半检登记明细)的信息查询数据
  11948. /// </summary>
  11949. /// <param name="user">登录用户信息</param>
  11950. /// <param name="se">查询条件</param>
  11951. /// <returns>查询结果</returns>
  11952. public static ServiceResultEntity GetRPT080107IData(SUserInfo user, SemiCheckEntity se)
  11953. {
  11954. IDBConnection conn = null;
  11955. try
  11956. {
  11957. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  11958. List<OracleParameter> parameters = new List<OracleParameter>();
  11959. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080107ISQL(user, se, ref parameters));
  11960. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  11961. ServiceResultEntity sre = new ServiceResultEntity();
  11962. if (data == null || data.Rows.Count == 0)
  11963. {
  11964. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  11965. return sre;
  11966. }
  11967. sre.Data = new DataSet();
  11968. sre.Data.Tables.Add(data);
  11969. return sre;
  11970. }
  11971. catch (Exception ex)
  11972. {
  11973. throw ex;
  11974. }
  11975. finally
  11976. {
  11977. if (conn != null &&
  11978. conn.ConnState == ConnectionState.Open)
  11979. {
  11980. conn.Close();
  11981. }
  11982. }
  11983. }
  11984. //xuwei add 2019-10-14
  11985. /// <summary>
  11986. /// 取得RPT080108(半检返修登记明细)的信息查询数据
  11987. /// </summary>
  11988. /// <param name="user">登录用户信息</param>
  11989. /// <param name="se">查询条件</param>
  11990. /// <returns>查询结果</returns>
  11991. public static ServiceResultEntity GetRPT080108IData(SUserInfo user, SemiCheckEntity se)
  11992. {
  11993. IDBConnection conn = null;
  11994. try
  11995. {
  11996. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  11997. List<OracleParameter> parameters = new List<OracleParameter>();
  11998. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080108ISQL(user, se, ref parameters));
  11999. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  12000. ServiceResultEntity sre = new ServiceResultEntity();
  12001. if (data == null || data.Rows.Count == 0)
  12002. {
  12003. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12004. return sre;
  12005. }
  12006. sre.Data = new DataSet();
  12007. sre.Data.Tables.Add(data);
  12008. return sre;
  12009. }
  12010. catch (Exception ex)
  12011. {
  12012. throw ex;
  12013. }
  12014. finally
  12015. {
  12016. if (conn != null &&
  12017. conn.ConnState == ConnectionState.Open)
  12018. {
  12019. conn.Close();
  12020. }
  12021. }
  12022. }
  12023. /// <summary>
  12024. /// 获取RPT080108画面(半检返修登记明细)的汇总信息查询sql
  12025. /// </summary>
  12026. /// <returns>sql</returns>
  12027. private static string GetRPT080108ISQL(SUserInfo user, SemiCheckEntity se, ref List<OracleParameter> parameters)
  12028. {
  12029. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12030. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  12031. string sqlString = @"
  12032. SELECT
  12033. sr.SEMIREWORKID ,--AS SEMIREWORKID,
  12034. p.PROCEDURECODE ,--AS 完成工序编码,
  12035. p.PROCEDURENAME ,--AS 完成工序,
  12036. sr.PROCEDURETIME ,--AS 完成时间,
  12037. sr.USERCODE ,--完成工号,
  12038. gt2.GOODSTYPENAME AS GOODSTYPENAME2,--AS 产品二级类别,
  12039. gt.GOODSTYPENAME ,--AS 产品类别,
  12040. g.GOODSCODE ,--AS 产品编码,
  12041. g.GOODSNAME,--AS 产品名称,
  12042. sr.BARCODE ,--AS 产品条码,
  12043. sr.SEMIREWORKUSERCODE ,--AS 半检工号,
  12044. sr.SEMIREWORKTIME ,--AS 半检时间,
  12045. pr.PROCEDURECODE AS REWORKPCODE,--AS 返修工序编码,
  12046. pr.PROCEDURENAME AS REWORKPNAME,--AS 返修工序,
  12047. sr.BACKOUTFLAG ,--AS 撤销标识,
  12048. sr.BACKOUTUSERCODE ,--AS 撤销工号,
  12049. sr.BACKOUTTIME ,--AS 撤销时间,
  12050. sr.GROUTINGUSERCODE ,--AS 成型工号,
  12051. sr.GROUTINGLINECODE ,--AS 成型线编码,
  12052. sr.GROUTINGMOULDCODE ,--AS 模具编号,
  12053. sr.GROUTINGDATE ,--AS 注浆时间,
  12054. gd.DELIVERTIME ,--AS 交坯时间,
  12055. l.LOGONAME ,--AS 商标,
  12056. srd.DEFECTCODE ,--AS 缺陷编码,
  12057. srd.DEFECTNAME ,--AS 缺陷名称,
  12058. srd.DEFECTPOSITIONCODE ,--AS 位置编码,
  12059. srd.DEFECTPOSITIONNAME ,--AS 缺陷位置,
  12060. pd.PROCEDURECODE AS DEFECTPCODE,--AS 责任工序编码,
  12061. pd.PROCEDURENAME AS DEFECTPNAME,--AS 责任工序,
  12062. srd.DEFECTUSERCODE ,--AS 责任工号,
  12063. inpp.PROCEDURENAME CurrPROCEDURENAME --AS 当前工序
  12064. FROM
  12065. TP_PM_SEMIREWORK sr
  12066. LEFT JOIN TP_PM_SEMIREWORKDEFECT srd ON sr.SEMIREWORKID = srd.SEMIREWORKID
  12067. LEFT JOIN TP_PC_PROCEDURE p ON p.PROCEDUREID = sr.PROCEDUREID
  12068. LEFT JOIN TP_PC_PROCEDURE pr ON pr.PROCEDUREID = sr.REWORKPROCEDUREID
  12069. LEFT JOIN TP_PC_PROCEDURE pd ON pd.PROCEDUREID = srd.DEFECTPROCEDUREID
  12070. LEFT JOIN TP_MST_GOODS g ON sr.GOODSID = g.GOODSID
  12071. LEFT JOIN TP_MST_GOODSTYPE gt ON g.GOODSTYPEID = gt.GOODSTYPEID
  12072. LEFT JOIN TP_MST_GOODSTYPE gt2 ON gt2.ACCOUNTID = gt.ACCOUNTID
  12073. AND gt2.GOODSTYPECODE = substr( gt.GOODSTYPECODE, 1, 6 )
  12074. LEFT JOIN TP_PM_GROUTINGDAILYDETAIL gd ON gd.GROUTINGDAILYDETAILID = sr.GROUTINGDAILYDETAILID
  12075. LEFT JOIN TP_MST_LOGO l ON gd.LOGOID = l.LOGOID
  12076. LEFT JOIN TP_PM_INPRODUCTION inp ON inp.BARCODE = sr.BARCODE
  12077. LEFT JOIN TP_PC_PROCEDURE inpp ON inp.PROCEDUREID = inpp.PROCEDUREID
  12078. WHERE
  12079. sr.VALUEFLAG = '1'
  12080. AND srd.VALUEFLAG = '1'
  12081. AND sr.AccountID=:AccountID
  12082. ";
  12083. //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))
  12084. // 完成工序
  12085. if (!string.IsNullOrEmpty(se.CProcedureIDS))
  12086. {
  12087. sqlString = sqlString + " AND instr(','||:CProcedureIDS||',',','||p.PROCEDURECODE||',')>0 ";
  12088. parameters.Add(new OracleParameter(":CProcedureIDS", OracleDbType.NVarchar2, se.CProcedureIDS, ParameterDirection.Input));
  12089. }
  12090. // 完成时间起始
  12091. if (se.CDateTimeStart.HasValue)
  12092. {
  12093. sqlString = sqlString + " AND sr.ProcedureTime >= :CDateTimeStart ";
  12094. parameters.Add(new OracleParameter(":CDateTimeStart", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  12095. }
  12096. // 完成时间结束
  12097. if (se.CDateTimeEnd.HasValue)
  12098. {
  12099. sqlString = sqlString + " AND sr.ProcedureTime <= :CDateTimeEnd ";
  12100. parameters.Add(new OracleParameter(":CDateTimeEnd", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  12101. }
  12102. // 完成工号
  12103. if (!string.IsNullOrEmpty(se.CUserCode))
  12104. {
  12105. sqlString = sqlString + " AND instr(','||:UserCode||',' , ','||sr.UserCode||',')>0";
  12106. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CUserCode, ParameterDirection.Input));
  12107. }
  12108. // 产品类别
  12109. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  12110. {
  12111. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 ";
  12112. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  12113. }
  12114. // 产品编码
  12115. if (!string.IsNullOrEmpty(se.GoodsCode))
  12116. {
  12117. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0";
  12118. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  12119. }
  12120. // 成型工号
  12121. if (!string.IsNullOrEmpty(se.GroutingUserCode))
  12122. {
  12123. sqlString = sqlString + " AND instr(','||:GroutingUserCode||',' , ','||sr.GroutingUserCode||',')>0";
  12124. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.NVarchar2, se.GroutingUserCode, ParameterDirection.Input));
  12125. }
  12126. // 注浆时间起始
  12127. if (se.GroutingDateTimeStart.HasValue)
  12128. {
  12129. sqlString = sqlString + " AND sr.GroutingDate >= :GroutingDateTimeStart ";
  12130. parameters.Add(new OracleParameter(":GroutingDateTimeStart", OracleDbType.Date, se.GroutingDateTimeStart.Value, ParameterDirection.Input));
  12131. }
  12132. // 注浆时间结束
  12133. if (se.GroutingDateTimeEnd.HasValue)
  12134. {
  12135. sqlString = sqlString + " AND sr.GroutingDate <= :GroutingDateTimeEnd ";
  12136. parameters.Add(new OracleParameter(":GroutingDateTimeEnd", OracleDbType.Date, se.GroutingDateTimeEnd.Value, ParameterDirection.Input));
  12137. }
  12138. // 交坯时间起始
  12139. if (se.DeliveryDateTimeStart.HasValue)
  12140. {
  12141. sqlString = sqlString + " AND gd.DeliverTime >= :DeliveryDateTimeStart ";
  12142. parameters.Add(new OracleParameter(":DeliveryDateTimeStart", OracleDbType.Date, se.DeliveryDateTimeStart.Value, ParameterDirection.Input));
  12143. }
  12144. // 交坯时间结束
  12145. if (se.DeliveryDateTimeEnd.HasValue)
  12146. {
  12147. sqlString = sqlString + " AND gd.DeliverTime <= :DeliveryDateTimeEnd ";
  12148. parameters.Add(new OracleParameter(":DeliveryDateTimeEnd", OracleDbType.Date, se.DeliveryDateTimeEnd.Value, ParameterDirection.Input));
  12149. }
  12150. // 半检时间起始
  12151. if (se.SemiCheckDateTimeStart.HasValue)
  12152. {
  12153. sqlString = sqlString + " AND sr.SEMIREWORKTIME >= :SemiCheckDateTimeStart ";
  12154. parameters.Add(new OracleParameter(":SemiCheckDateTimeStart", OracleDbType.Date, se.SemiCheckDateTimeStart.Value, ParameterDirection.Input));
  12155. }
  12156. // 半检时间结束
  12157. if (se.SemiCheckDateTimeEnd.HasValue)
  12158. {
  12159. sqlString = sqlString + " AND sr.SEMIREWORKTIME <= :SemiCheckDateTimeEnd ";
  12160. parameters.Add(new OracleParameter(":SemiCheckDateTimeEnd", OracleDbType.Date, se.SemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  12161. }
  12162. // 半检工号
  12163. if (!string.IsNullOrEmpty(se.SemiCheckUserCode))
  12164. {
  12165. sqlString = sqlString + " AND instr(','||:SemiCheckUserCode||',' , ','||sr.SEMIREWORKUSERCODE||',')>0";
  12166. parameters.Add(new OracleParameter(":SemiCheckUserCode", OracleDbType.NVarchar2, se.SemiCheckUserCode, ParameterDirection.Input));
  12167. }
  12168. // 返修工序
  12169. if (!string.IsNullOrEmpty(se.RProcedureIDS))
  12170. {
  12171. sqlString = sqlString + " AND instr(','||:RProcedureIDS||',',','||pr.PROCEDUREID||',')>0 ";
  12172. parameters.Add(new OracleParameter(":RProcedureIDS", OracleDbType.NVarchar2, se.RProcedureIDS, ParameterDirection.Input));
  12173. }
  12174. // 返修工号
  12175. if (!string.IsNullOrEmpty(se.ReworkUserCode))
  12176. {
  12177. sqlString = sqlString + " AND instr(sr.ReworkUserCode,:ReworkUserCode)>0";
  12178. parameters.Add(new OracleParameter(":ReworkUserCode", OracleDbType.NVarchar2, se.ReworkUserCode, ParameterDirection.Input));
  12179. }
  12180. // 撤销标识
  12181. if (!string.IsNullOrEmpty(se.BackOutFlag))
  12182. {
  12183. sqlString = sqlString + " AND instr(','||:BackOutFlag||',',','||sr.BackOutFlag||',')>0 ";
  12184. parameters.Add(new OracleParameter(":BackOutFlag", OracleDbType.NVarchar2, se.BackOutFlag, ParameterDirection.Input));
  12185. }
  12186. // 撤销时间起始
  12187. if (se.BackOutTimeStart.HasValue)
  12188. {
  12189. sqlString = sqlString + " AND sr.BackOutTime >= :BackOutTimeStart ";
  12190. parameters.Add(new OracleParameter(":BackOutTimeStart", OracleDbType.Date, se.BackOutTimeStart.Value, ParameterDirection.Input));
  12191. }
  12192. // 撤销时间结束
  12193. if (se.BackOutTimeEnd.HasValue)
  12194. {
  12195. sqlString = sqlString + " AND sr.BackOutTime <= :BackOutTimeEnd ";
  12196. parameters.Add(new OracleParameter(":BackOutTimeEnd", OracleDbType.Date, se.BackOutTimeEnd.Value, ParameterDirection.Input));
  12197. }
  12198. // 撤销工号
  12199. if (!string.IsNullOrEmpty(se.BackOutUserCode))
  12200. {
  12201. sqlString = sqlString + " AND instr(','||:BackOutUserCode||',' , ','||sr.BackOutUserCode||',')>0";
  12202. parameters.Add(new OracleParameter(":BackOutUserCode", OracleDbType.NVarchar2, se.BackOutUserCode, ParameterDirection.Input));
  12203. }
  12204. // 产品条码
  12205. if (!string.IsNullOrEmpty(se.BarCode))
  12206. {
  12207. sqlString = sqlString + " AND instr(sr.BarCode,:BarCode)>0";
  12208. parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.BarCode, ParameterDirection.Input));
  12209. }
  12210. // 缺陷编码
  12211. if (!string.IsNullOrEmpty(se.DefectCode))
  12212. {
  12213. sqlString = sqlString + " AND instr(srd.DefectCode,:DefectCode)>0";
  12214. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  12215. }
  12216. // 缺陷位置集
  12217. if (!string.IsNullOrEmpty(se.DefectPositionIDS))
  12218. {
  12219. sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||srd.DefectPositionID||',')>0 ";
  12220. parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectPositionIDS, ParameterDirection.Input));
  12221. }
  12222. // 责任工序集
  12223. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  12224. {
  12225. sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||pd.PROCEDUREID||',')>0 ";
  12226. parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  12227. }
  12228. // 责任工号
  12229. if (!string.IsNullOrEmpty(se.DefectUser))
  12230. {
  12231. sqlString = sqlString + " AND instr(srd.DEFECTUSERCODE,:DefectUser)>0";
  12232. parameters.Add(new OracleParameter(":DefectUser", OracleDbType.NVarchar2, se.DefectUser, ParameterDirection.Input));
  12233. }
  12234. // 只显示最后一条半检记录
  12235. if (se.SemiCheckType == "1")
  12236. {
  12237. // 撤销的记录全显示,未撤销的记录只显示最后一条
  12238. sqlString += " and (sr.backoutflag = '1' or not exists (select sw.semireworkid\n" +
  12239. " from TP_PM_SEMIREWORK sw\n" +
  12240. " where sw.barcode = sr.barcode\n" +
  12241. " and sw.valueflag = '1'\n" +
  12242. " and (sw.backoutflag = '0')\n" +
  12243. " and sw.semireworkid > sr.semireworkid) )";
  12244. }
  12245. return sqlString;
  12246. }
  12247. //xuwei end
  12248. //xuwei add 2019-10-21
  12249. /// <summary>
  12250. /// 统计当前工号,当日,按产品编码分组统计半检返修数据数量
  12251. /// </summary>
  12252. /// <param name="user">用户</param>
  12253. /// <param name="dataStr">统计日期</param>
  12254. /// <returns></returns>
  12255. public static ServiceResultEntity GetSemiReworkDayCount(SUserInfo user, string dateStr)
  12256. {
  12257. IDBConnection conn = null;
  12258. try
  12259. {
  12260. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12261. string sqlStr = $@"
  12262. SELECT
  12263. nvl(sr.SEMIREWORKUSERCODE,'--') SEMIREWORKUSERCODE,--AS 半检工号,
  12264. nvl( g.GOODSCODE, '合计' ) GOODSCODE,--AS 产品编码,
  12265. nvl(g.GOODSNAME,'--') GOODSNAME,--AS 产口名称,
  12266. to_char(count( sr.SEMIREWORKID )) GOODSCOUNT --AS 返修数量
  12267. FROM
  12268. TP_PM_SEMIREWORK sr
  12269. LEFT JOIN TP_PM_SEMIREWORKDEFECT srd ON sr.SEMIREWORKID = srd.SEMIREWORKID
  12270. LEFT JOIN TP_MST_GOODS g ON sr.GOODSID = g.GOODSID
  12271. WHERE
  12272. sr.VALUEFLAG = '1'
  12273. AND sr.ACCOUNTID = '{user.AccountID}'
  12274. AND sr.SEMIREWORKUSERCODE = '{user.UserCode}'
  12275. AND to_date(to_char(sr.CREATETIME,'yyyy-mm-dd'),'yyyy-mm-dd') = to_date('{dateStr}','yyyy-mm-dd')
  12276. GROUP BY
  12277. grouping sets ( ( sr.SEMIREWORKUSERCODE, g.GOODSCODE, g.GOODSNAME ), ( ) )
  12278. ";
  12279. DataTable data = conn.GetSqlResultToDt(sqlStr);
  12280. ServiceResultEntity sre = new ServiceResultEntity();
  12281. //if (data == null || data.Rows.Count == 0)
  12282. //{
  12283. // sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12284. // return sre;
  12285. //}
  12286. sre.Data = new DataSet();
  12287. sre.Data.Tables.Add(data);
  12288. return sre;
  12289. }
  12290. catch (Exception ex)
  12291. {
  12292. throw ex;
  12293. }
  12294. finally
  12295. {
  12296. if (conn != null &&
  12297. conn.ConnState == ConnectionState.Open)
  12298. {
  12299. conn.Close();
  12300. }
  12301. }
  12302. }
  12303. //xuwei end
  12304. /// <summary>
  12305. /// 获取RPT030110画面(半检登记汇总表)的汇总信息查询sql
  12306. /// </summary>
  12307. /// <returns>sql</returns>
  12308. private static string GetRPT080107ISQL(SUserInfo user, SemiCheckEntity se, ref List<OracleParameter> parameters)
  12309. {
  12310. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12311. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  12312. string sqlString = @"
  12313. select
  12314. SemiCheck.SemiCheckID,
  12315. CProcedure.ProcedureName as CProcedureName,
  12316. SemiCheck.ProcedureTime,
  12317. SemiCheck.UserCode,
  12318. GoodsType2.GoodsTypeName as LevelGoodsTypeName,
  12319. GoodsType.GoodsTypeName,
  12320. Goods.GoodsCode,
  12321. SemiCheck.BarCode,
  12322. -- 复检后不显示半检状态
  12323. SemiCheckType.SemiCheckTypeName,
  12324. --decode(SemiCheck.ReSemiCheckType, 0, SemiCheckType.SemiCheckTypeName, '已复检') SemiCheckTypeName,
  12325. SemiCheck.SemiCheckUserCode,
  12326. SemiCheck.SemiCheckTime,
  12327. ReSemiCheckType.ReSemiCheckTypeName,
  12328. SemiCheck.ReSemiCheckUserCode,
  12329. SemiCheck.ReSemiCheckTime,
  12330. decode(SemiCheck.BackOutFlag,'0','正常','撤销') as BackOutFlag,
  12331. SemiCheck.BackOutUserCode,
  12332. SemiCheck.BackOutTime,
  12333. SemiCheck.GroutingUserCode,
  12334. SemiCheck.GroutingLineCode,
  12335. SemiCheck.GroutingMouldCode,
  12336. SemiCheck.GroutingDate,
  12337. GroutingDailyDetail.DeliverTime,
  12338. logo.logoName,
  12339. RProcedure.ProcedureName as RProcedureName,
  12340. SemiCheck.ReworkUserCode,
  12341. SemiCheckDefect.DefectCode,
  12342. SemiCheckDefect.DefectName as DefectName1,
  12343. concat(SemiCheckDefect.DefectCode||'->',SemiCheckDefect.DefectName) as DefectName,
  12344. SemiCheckDefect.DefectPositionName,
  12345. SemiCheckDefect.DefectPositionCode,
  12346. concat(SemiCheckDefect.DefectPositionCode||'->',SemiCheckDefect.DefectPositionName) as DefectPositionName,
  12347. Procedure.ProcedureName,
  12348. inpp.ProcedureName CurrProcedureName,
  12349. DefectUser.username as DefectUser
  12350. from TP_PM_SemiCheck SemiCheck
  12351. left join TP_PC_Procedure CProcedure
  12352. on SemiCheck.ProcedureID=CProcedure.ProcedureID
  12353. left join TP_MST_Goods Goods
  12354. on SemiCheck.GoodsID=Goods.GoodsID
  12355. left join TP_MST_GoodsType GoodsType
  12356. on Goods.GoodsTypeID=GoodsType.GoodsTypeID
  12357. left join TP_MST_GoodsType GoodsType2
  12358. on GoodsType2.accountid=GoodsType.accountid
  12359. and GoodsType2.GoodsTypecode=substr(GoodsType.GoodsTypecode,1,6)
  12360. left join TP_SYS_SemiCheckType SemiCheckType
  12361. on SemiCheck.SemiCheckType=SemiCheckType.SemiCheckTypeID
  12362. left join TP_SYS_ReSemiCheckType ReSemiCheckType
  12363. on SemiCheck.ReSemiCheckType=ReSemiCheckType.ReSemiCheckTypeID
  12364. left join TP_PM_GroutingDailyDetail GroutingDailyDetail
  12365. on GroutingDailyDetail.GroutingDailyDetailID=SemiCheck.GroutingDailyDetailID
  12366. left join TP_MST_Logo logo
  12367. on GroutingDailyDetail.LogoID=logo.LogoID
  12368. left join TP_PC_Procedure RProcedure
  12369. on SemiCheck.ReworkProcedureID=RProcedure.ProcedureID
  12370. left join TP_PM_SemiCheckDefect SemiCheckDefect
  12371. on SemiCheck.SemiCheckID=SemiCheckDefect.SemiCheckID
  12372. and SemiCheckDefect.ValueFlag='1'
  12373. left join TP_PC_Procedure Procedure
  12374. on SemiCheckDefect.DefectProcedureID=Procedure.ProcedureID
  12375. left join TP_MST_User DefectUser
  12376. on DefectUser.userid=SemiCheckDefect.DefectUserID
  12377. left join tp_pm_inproduction inp on inp.barcode = SemiCheck.barcode
  12378. left join TP_PC_Procedure inpp on inp.ProcedureID = inpp.ProcedureID
  12379. where SemiCheck.AccountID=:AccountID
  12380. ";
  12381. //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))
  12382. // 完成工序
  12383. if (!string.IsNullOrEmpty(se.CProcedureIDS))
  12384. {
  12385. sqlString = sqlString + " AND instr(','||:CProcedureIDS||',',','||SemiCheck.ProcedureID||',')>0 ";
  12386. parameters.Add(new OracleParameter(":CProcedureIDS", OracleDbType.NVarchar2, se.CProcedureIDS, ParameterDirection.Input));
  12387. }
  12388. // 完成时间起始
  12389. if (se.CDateTimeStart.HasValue)
  12390. {
  12391. sqlString = sqlString + " AND SemiCheck.ProcedureTime >= :CDateTimeStart ";
  12392. parameters.Add(new OracleParameter(":CDateTimeStart", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  12393. }
  12394. // 完成时间结束
  12395. if (se.CDateTimeEnd.HasValue)
  12396. {
  12397. sqlString = sqlString + " AND SemiCheck.ProcedureTime <= :CDateTimeEnd ";
  12398. parameters.Add(new OracleParameter(":CDateTimeEnd", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  12399. }
  12400. // 完成工号
  12401. if (!string.IsNullOrEmpty(se.CUserCode))
  12402. {
  12403. sqlString = sqlString + " AND instr(SemiCheck.UserCode,:UserCode)>0";
  12404. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CUserCode, ParameterDirection.Input));
  12405. }
  12406. // 产品类别
  12407. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  12408. {
  12409. sqlString = sqlString + " AND instr(GoodsType.GoodsTypeCode,:GoodsTypeCode)=1 ";
  12410. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  12411. }
  12412. // 产品编码
  12413. if (!string.IsNullOrEmpty(se.GoodsCode))
  12414. {
  12415. sqlString = sqlString + " AND instr(Goods.GoodsCode,:GoodsCode)>0";
  12416. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  12417. }
  12418. // 成型工号
  12419. if (!string.IsNullOrEmpty(se.GroutingUserCode))
  12420. {
  12421. sqlString = sqlString + " AND instr(SemiCheck.GroutingUserCode,:GroutingUserCode)>0";
  12422. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.NVarchar2, se.GroutingUserCode, ParameterDirection.Input));
  12423. }
  12424. // 注浆时间起始
  12425. if (se.GroutingDateTimeStart.HasValue)
  12426. {
  12427. sqlString = sqlString + " AND SemiCheck.GroutingDate >= :GroutingDateTimeStart ";
  12428. parameters.Add(new OracleParameter(":GroutingDateTimeStart", OracleDbType.Date, se.GroutingDateTimeStart.Value, ParameterDirection.Input));
  12429. }
  12430. // 注浆时间结束
  12431. if (se.GroutingDateTimeEnd.HasValue)
  12432. {
  12433. sqlString = sqlString + " AND SemiCheck.GroutingDate <= :GroutingDateTimeEnd ";
  12434. parameters.Add(new OracleParameter(":GroutingDateTimeEnd", OracleDbType.Date, se.GroutingDateTimeEnd.Value, ParameterDirection.Input));
  12435. }
  12436. // 交坯时间起始
  12437. if (se.DeliveryDateTimeStart.HasValue)
  12438. {
  12439. sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime >= :DeliveryDateTimeStart ";
  12440. parameters.Add(new OracleParameter(":DeliveryDateTimeStart", OracleDbType.Date, se.DeliveryDateTimeStart.Value, ParameterDirection.Input));
  12441. }
  12442. // 交坯时间结束
  12443. if (se.DeliveryDateTimeEnd.HasValue)
  12444. {
  12445. sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime <= :DeliveryDateTimeEnd ";
  12446. parameters.Add(new OracleParameter(":DeliveryDateTimeEnd", OracleDbType.Date, se.DeliveryDateTimeEnd.Value, ParameterDirection.Input));
  12447. }
  12448. // 半检状态
  12449. if (!string.IsNullOrEmpty(se.SemiCheckType))
  12450. {
  12451. sqlString = sqlString + " AND instr(','||:SemiCheckType||',',','||SemiCheck.SemiCheckType||',')>0 ";
  12452. parameters.Add(new OracleParameter(":SemiCheckType", OracleDbType.NVarchar2, se.SemiCheckType, ParameterDirection.Input));
  12453. }
  12454. // 半检时间起始
  12455. if (se.SemiCheckDateTimeStart.HasValue)
  12456. {
  12457. sqlString = sqlString + " AND SemiCheck.SemiCheckTime >= :SemiCheckDateTimeStart ";
  12458. parameters.Add(new OracleParameter(":SemiCheckDateTimeStart", OracleDbType.Date, se.SemiCheckDateTimeStart.Value, ParameterDirection.Input));
  12459. }
  12460. // 半检时间结束
  12461. if (se.SemiCheckDateTimeEnd.HasValue)
  12462. {
  12463. sqlString = sqlString + " AND SemiCheck.SemiCheckTime <= :SemiCheckDateTimeEnd ";
  12464. parameters.Add(new OracleParameter(":SemiCheckDateTimeEnd", OracleDbType.Date, se.SemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  12465. }
  12466. // 半检工号
  12467. if (!string.IsNullOrEmpty(se.SemiCheckUserCode))
  12468. {
  12469. sqlString = sqlString + " AND instr(SemiCheck.SemiCheckUserCode,:SemiCheckUserCode)>0";
  12470. parameters.Add(new OracleParameter(":SemiCheckUserCode", OracleDbType.NVarchar2, se.SemiCheckUserCode, ParameterDirection.Input));
  12471. }
  12472. // 返工工序
  12473. if (!string.IsNullOrEmpty(se.RProcedureIDS))
  12474. {
  12475. sqlString = sqlString + " AND instr(','||:RProcedureIDS||',',','||SemiCheck.ReworkProcedureID||',')>0 ";
  12476. parameters.Add(new OracleParameter(":RProcedureIDS", OracleDbType.NVarchar2, se.RProcedureIDS, ParameterDirection.Input));
  12477. }
  12478. // 返工工号
  12479. if (!string.IsNullOrEmpty(se.ReworkUserCode))
  12480. {
  12481. sqlString = sqlString + " AND instr(SemiCheck.ReworkUserCode,:ReworkUserCode)>0";
  12482. parameters.Add(new OracleParameter(":ReworkUserCode", OracleDbType.NVarchar2, se.ReworkUserCode, ParameterDirection.Input));
  12483. }
  12484. // 复检状态
  12485. if (!string.IsNullOrEmpty(se.ReSemiCheckType))
  12486. {
  12487. sqlString = sqlString + " AND instr(','||:ReSemiCheckType||',',','||SemiCheck.ReSemiCheckType||',')>0 ";
  12488. parameters.Add(new OracleParameter(":ReSemiCheckType", OracleDbType.NVarchar2, se.ReSemiCheckType, ParameterDirection.Input));
  12489. }
  12490. // 复检时间起始
  12491. if (se.ReSemiCheckDateTimeStart.HasValue)
  12492. {
  12493. sqlString = sqlString + " AND SemiCheck.ReSemiCheckTime >= :ReSemiCheckDateTimeStart ";
  12494. parameters.Add(new OracleParameter(":ReSemiCheckDateTimeStart", OracleDbType.Date, se.ReSemiCheckDateTimeStart.Value, ParameterDirection.Input));
  12495. }
  12496. // 复检时间结束
  12497. if (se.ReSemiCheckDateTimeEnd.HasValue)
  12498. {
  12499. sqlString = sqlString + " AND SemiCheck.ReSemiCheckTime <= :ReSemiCheckDateTimeEnd ";
  12500. parameters.Add(new OracleParameter(":ReSemiCheckDateTimeEnd", OracleDbType.Date, se.ReSemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  12501. }
  12502. // 复检工号
  12503. if (!string.IsNullOrEmpty(se.ReSemiCheckUserCode))
  12504. {
  12505. sqlString = sqlString + " AND instr(SemiCheck.ReSemiCheckUserCode,:ReSemiCheckUserCode)>0";
  12506. parameters.Add(new OracleParameter(":ReSemiCheckUserCode", OracleDbType.NVarchar2, se.ReSemiCheckUserCode, ParameterDirection.Input));
  12507. }
  12508. // 撤销标识
  12509. if (!string.IsNullOrEmpty(se.BackOutFlag))
  12510. {
  12511. sqlString = sqlString + " AND instr(','||:BackOutFlag||',',','||SemiCheck.BackOutFlag||',')>0 ";
  12512. parameters.Add(new OracleParameter(":BackOutFlag", OracleDbType.NVarchar2, se.BackOutFlag, ParameterDirection.Input));
  12513. }
  12514. // 撤销时间起始
  12515. if (se.BackOutTimeStart.HasValue)
  12516. {
  12517. sqlString = sqlString + " AND SemiCheck.BackOutTime >= :BackOutTimeStart ";
  12518. parameters.Add(new OracleParameter(":BackOutTimeStart", OracleDbType.Date, se.BackOutTimeStart.Value, ParameterDirection.Input));
  12519. }
  12520. // 撤销时间结束
  12521. if (se.BackOutTimeEnd.HasValue)
  12522. {
  12523. sqlString = sqlString + " AND SemiCheck.BackOutTime <= :BackOutTimeEnd ";
  12524. parameters.Add(new OracleParameter(":BackOutTimeEnd", OracleDbType.Date, se.BackOutTimeEnd.Value, ParameterDirection.Input));
  12525. }
  12526. // 撤销工号
  12527. if (!string.IsNullOrEmpty(se.BackOutUserCode))
  12528. {
  12529. sqlString = sqlString + " AND instr(SemiCheck.BackOutUserCode,:BackOutUserCode)>0";
  12530. parameters.Add(new OracleParameter(":BackOutUserCode", OracleDbType.NVarchar2, se.BackOutUserCode, ParameterDirection.Input));
  12531. }
  12532. // 产品条码
  12533. if (!string.IsNullOrEmpty(se.BarCode))
  12534. {
  12535. sqlString = sqlString + " AND instr(SemiCheck.BarCode,:BarCode)>0";
  12536. parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.BarCode, ParameterDirection.Input));
  12537. }
  12538. // 缺陷编码
  12539. if (!string.IsNullOrEmpty(se.DefectCode))
  12540. {
  12541. sqlString = sqlString + " AND instr(SemiCheckDefect.DefectCode,:DefectCode)>0";
  12542. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  12543. }
  12544. // 缺陷位置集
  12545. if (!string.IsNullOrEmpty(se.DefectPositionIDS))
  12546. {
  12547. sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||SemiCheckDefect.DefectPositionID||',')>0 ";
  12548. parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectPositionIDS, ParameterDirection.Input));
  12549. }
  12550. // 责任工序集
  12551. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  12552. {
  12553. sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||SemiCheckDefect.DefectPositionID||',')>0 ";
  12554. parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  12555. }
  12556. // 责任工号
  12557. if (!string.IsNullOrEmpty(se.DefectUser))
  12558. {
  12559. sqlString = sqlString + " AND instr(DefectUser.UserCode,:DefectUser)>0";
  12560. parameters.Add(new OracleParameter(":DefectUser", OracleDbType.NVarchar2, se.DefectUser, ParameterDirection.Input));
  12561. }
  12562. return sqlString;
  12563. }
  12564. /// <summary>
  12565. /// 取得F_RPT_030112画面(产成品交接汇总表)的汇总信息查询数据
  12566. /// </summary>
  12567. /// <param name="user">登录用户信息</param>
  12568. /// <param name="se">查询条件</param>
  12569. /// <returns>查询结果</returns>
  12570. public static ServiceResultEntity GetRPT0030112SData(SUserInfo user, SearchFinishedProductEntity se)
  12571. {
  12572. IDBConnection conn = null;
  12573. try
  12574. {
  12575. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12576. List<OracleParameter> parameters = new List<OracleParameter>();
  12577. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030112SSQL(user, se, ref parameters));
  12578. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  12579. ServiceResultEntity sre = new ServiceResultEntity();
  12580. if (data == null || data.Rows.Count == 0)
  12581. {
  12582. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12583. return sre;
  12584. }
  12585. sre.Data = new DataSet();
  12586. sre.Data.Tables.Add(data);
  12587. return sre;
  12588. }
  12589. catch (Exception ex)
  12590. {
  12591. throw ex;
  12592. }
  12593. finally
  12594. {
  12595. if (conn != null &&
  12596. conn.ConnState == ConnectionState.Open)
  12597. {
  12598. conn.Close();
  12599. }
  12600. }
  12601. }
  12602. /// <summary>
  12603. /// 获取RPT030112画面(产成品交接汇总表)的汇总信息查询sql
  12604. /// </summary>
  12605. /// <returns>sql</returns>
  12606. private static string GetRPT030112SSQL(SUserInfo user, SearchFinishedProductEntity se, ref List<OracleParameter> parameters)
  12607. {
  12608. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12609. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  12610. string sqlString = @"SELECT ts.gid
  12611. ,logoid
  12612. ,decode(ts.gid,
  12613. '23',
  12614. '总计【' || orderno || '】',
  12615. decode(ts.gid, '1', '--', '3', '--', orderno)) AS orderno
  12616. ,decode(ts.gid,
  12617. '3',
  12618. '合计【' || logoname || '】',
  12619. decode(ts.gid, '1', '--', logoname)) AS logoname
  12620. ,decode(ts.gid, '1', '小计【' || goodscode || '】', goodscode) AS goodscode
  12621. ,decode(ts.gid, '1', '--', goodsmodel) AS goodsmodel
  12622. ,GoodsSpecification
  12623. ,fhtime
  12624. ,COUNT
  12625. FROM (SELECT grouping_id(l.logoid,
  12626. o.orderno,
  12627. l.logoname,
  12628. g.goodscode,
  12629. to_char(f.fhtime, 'yyyy-mm-dd')) AS gid
  12630. ,decode(GROUPING(l.logoid), 1, '--', l.logoid) AS logoid
  12631. ,decode(GROUPING(o.orderno), 1, '--', o.orderno) AS orderno
  12632. ,decode(GROUPING(l.logoname), 1, '--', l.logoname) AS logoname
  12633. ,decode(GROUPING(g.goodscode), 1, '--', g.goodscode) AS goodscode
  12634. ,decode(GROUPING(g.goodscode), 1, '--', g.goodsmodel) AS goodsmodel
  12635. ,decode(GROUPING(g.GoodsSpecification), 1, '--', g.GoodsSpecification) AS GoodsSpecification
  12636. ,decode(GROUPING(to_char(f.fhtime, 'yyyy-mm-dd')),
  12637. 1,
  12638. '--',
  12639. to_char(f.fhtime, 'yyyy-mm-dd')) AS fhtime
  12640. ,COUNT(f.fhtime) AS COUNT
  12641. FROM tp_pm_finishedproduct F
  12642. LEFT JOIN TP_PM_Order O ON F.Fhorderid = O.Orderid
  12643. LEFT JOIN tp_mst_logo L ON F.LOGOID = L.LOGOID
  12644. LEFT JOIN tp_mst_goods G ON g.goodsid = f.goodsid
  12645. LEFT JOIN TP_MST_GoodsType gt ON g.GoodsTypeID = gt.GoodsTypeID
  12646. where f.fhtime is not null and f.AccountID=:AccountID ";
  12647. // 交接时间起始
  12648. if (se.FHTimeStart.HasValue)
  12649. {
  12650. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart ";
  12651. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, se.FHTimeStart.Value, ParameterDirection.Input));
  12652. }
  12653. // 交接时间结束
  12654. if (se.FHTimeEnd.HasValue)
  12655. {
  12656. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd ";
  12657. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, se.FHTimeEnd.Value, ParameterDirection.Input));
  12658. }
  12659. // 订单号
  12660. if (!string.IsNullOrEmpty(se.OrderNo))
  12661. {
  12662. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0";
  12663. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, se.OrderNo, ParameterDirection.Input));
  12664. }
  12665. // 产品类别编码
  12666. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  12667. {
  12668. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1";
  12669. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  12670. }
  12671. // 产品编码
  12672. if (!string.IsNullOrEmpty(se.GoodsCode))
  12673. {
  12674. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0";
  12675. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  12676. }
  12677. // 产品型号
  12678. if (!string.IsNullOrEmpty(se.GoodsModel))
  12679. {
  12680. sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0";
  12681. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, se.GoodsModel, ParameterDirection.Input));
  12682. }
  12683. // 产品商标ID集
  12684. if (!string.IsNullOrEmpty(se.LogoIDS))
  12685. {
  12686. sqlString += " AND instr(','||:LogoIDS||',', ',' || L.logoid || ',') > 0";
  12687. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, se.LogoIDS, ParameterDirection.Input));
  12688. }
  12689. // 交接工号
  12690. if (!string.IsNullOrEmpty(se.FHUserCode))
  12691. {
  12692. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0";
  12693. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, se.FHUserCode, ParameterDirection.Input));
  12694. }
  12695. sqlString = sqlString + @" GROUP BY rollup(o.orderno,l.logoid, l.logoname,g.goodscode,g.goodsmodel,g.GoodsSpecification,to_char(f.fhtime, 'yyyy-mm-dd'))
  12696. order by o.orderno,l.logoid, l.logoname,g.goodscode,to_char(f.fhtime, 'yyyy-mm-dd')
  12697. )ts
  12698. where ( logoid!='--' and orderno!='--' and logoname!='--' and goodscode!='--' and fhtime!='--')
  12699. or (goodscode!='--')
  12700. or(logoname!='')
  12701. or (orderno!='--') and ts.gid!='7'";
  12702. return sqlString;
  12703. }
  12704. /// <summary>
  12705. /// 取得F_RPT_030112画面(产成品交接汇总表)的汇总信息
  12706. /// </summary>
  12707. /// <param name="user">登录用户信息</param>
  12708. /// <param name="se">查询条件</param>
  12709. /// <returns>查询结果</returns>
  12710. public static ServiceResultEntity GetRPT0030112SumData(ClientRequestEntity cre, SUserInfo user)
  12711. {
  12712. IDBConnection conn = null;
  12713. try
  12714. {
  12715. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12716. List<OracleParameter> parameters = new List<OracleParameter>();
  12717. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12718. //string sqlString = "SELECT trunc(f.fhtime) fhtime, g.goodscode, COUNT(*) goodscount\n" +
  12719. string sqlString = "SELECT nvl2(o.orderno,\n" +
  12720. " nvl2(l.logoname,\n" +
  12721. " o.orderno,\n" +
  12722. " to_char('合计[') || o.orderno ||\n" +
  12723. " to_char(']')),\n" +
  12724. " '总计') orderno\n" +
  12725. " ,nvl2(l.logoname,\n" +
  12726. " nvl2(g.goodscode,\n" +
  12727. " l.logoname,\n" +
  12728. " to_char('小计[' || l.logoname || ']')),\n" +
  12729. " '--') logoname\n" +
  12730. " ,nvl(g.goodscode, '--') goodscode" +
  12731. " ,nvl(g.goodsmodel, '--') goodsmodel" +
  12732. " ,nvl(gdd.materialcode, '--') mcode" +
  12733. " ,f.logoid" +
  12734. " ,f.goodsid" +
  12735. " ,f.fhorderid" +
  12736. " ,COUNT(*) count" +
  12737. " FROM tp_pm_finishedproduct f\n" +
  12738. " inner JOIN tp_pm_groutingdailydetail gdd\n" +
  12739. " ON gdd.barcode = f.barcode\n" +
  12740. " LEFT JOIN tp_mst_logo l\n" +
  12741. " ON f.logoid = l.logoid\n" +
  12742. " LEFT JOIN TP_PM_Order O\n" +
  12743. " ON f.Fhorderid = O.Orderid\n" +
  12744. " LEFT JOIN tp_mst_goods G\n" +
  12745. " ON g.goodsid = f.goodsid\n" +
  12746. " LEFT JOIN TP_MST_GoodsType gt\n" +
  12747. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  12748. " WHERE f.fhtime IS NOT NULL\n" +
  12749. " AND f.AccountID = :AccountID\n";
  12750. // 交接时间起始
  12751. if (cre.Properties["FHTimeStart"] != null)
  12752. {
  12753. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
  12754. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, cre.Properties["FHTimeStart"], ParameterDirection.Input));
  12755. }
  12756. // 交接时间结束
  12757. if (cre.Properties["FHTimeEnd"] != null)
  12758. {
  12759. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd \n";
  12760. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, cre.Properties["FHTimeEnd"], ParameterDirection.Input));
  12761. }
  12762. // 订单号
  12763. if (!string.IsNullOrEmpty(cre.Properties["OrderNo"] as string))
  12764. {
  12765. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0 \n";
  12766. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, cre.Properties["OrderNo"], ParameterDirection.Input));
  12767. }
  12768. // 产品类别编码
  12769. if (!string.IsNullOrEmpty(cre.Properties["GoodsTypeCode"] as string))
  12770. {
  12771. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 \n";
  12772. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input));
  12773. }
  12774. // 产品编码
  12775. if (!string.IsNullOrEmpty(cre.Properties["GoodsCode"] as string))
  12776. {
  12777. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
  12778. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input));
  12779. }
  12780. // 产品型号
  12781. if (!string.IsNullOrEmpty(cre.Properties["GoodsModel"] as string))
  12782. {
  12783. sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0 \n";
  12784. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, cre.Properties["GoodsModel"], ParameterDirection.Input));
  12785. }
  12786. // 产品商标ID集
  12787. if (!string.IsNullOrEmpty(cre.Properties["LogoIDS"] as string))
  12788. {
  12789. sqlString += " AND instr(','||:LogoIDS||',', ',' || f.logoid || ',') > 0 \n";
  12790. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, cre.Properties["LogoIDS"], ParameterDirection.Input));
  12791. }
  12792. // 交接工号
  12793. if (!string.IsNullOrEmpty(cre.Properties["FHUserCode"] as string))
  12794. {
  12795. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0 \n";
  12796. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, cre.Properties["FHUserCode"], ParameterDirection.Input));
  12797. }
  12798. //sqlString += " group by trunc(f.fhtime), g.goodscode order by trunc(f.fhtime), g.goodscode";
  12799. 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),())";
  12800. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  12801. ServiceResultEntity sre = new ServiceResultEntity();
  12802. if (data == null || data.Rows.Count == 0)
  12803. {
  12804. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12805. return sre;
  12806. }
  12807. sre.Data = new DataSet();
  12808. sre.Data.Tables.Add(data);
  12809. return sre;
  12810. }
  12811. catch (Exception ex)
  12812. {
  12813. throw ex;
  12814. }
  12815. finally
  12816. {
  12817. if (conn != null &&
  12818. conn.ConnState == ConnectionState.Open)
  12819. {
  12820. conn.Close();
  12821. }
  12822. }
  12823. }
  12824. /// <summary>
  12825. /// 取得F_RPT_030112画面(产成品交接汇总表)的明细信息查询数据
  12826. /// </summary>
  12827. /// <param name="user">登录用户信息</param>
  12828. /// <param name="se">查询条件</param>
  12829. /// <returns>查询结果</returns>
  12830. public static ServiceResultEntity GetRPT0030112DetailSData(SUserInfo user, SearchFinishedProductEntity se)
  12831. {
  12832. IDBConnection conn = null;
  12833. try
  12834. {
  12835. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12836. List<OracleParameter> parameters = new List<OracleParameter>();
  12837. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT0030112DetailSData(user, se, ref parameters));
  12838. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  12839. ServiceResultEntity sre = new ServiceResultEntity();
  12840. if (data == null || data.Rows.Count == 0)
  12841. {
  12842. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12843. return sre;
  12844. }
  12845. sre.Data = new DataSet();
  12846. sre.Data.Tables.Add(data);
  12847. return sre;
  12848. }
  12849. catch (Exception ex)
  12850. {
  12851. throw ex;
  12852. }
  12853. finally
  12854. {
  12855. if (conn != null &&
  12856. conn.ConnState == ConnectionState.Open)
  12857. {
  12858. conn.Close();
  12859. }
  12860. }
  12861. }
  12862. private static string GetRPT0030112DetailSData(SUserInfo user, SearchFinishedProductEntity se, ref List<OracleParameter> parameters)
  12863. {
  12864. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12865. string sqlString = "SELECT O.ORDERNO,\n" +
  12866. " F.FHTIME,\n" +
  12867. " F.FHUSERCODE,\n" +
  12868. " F.BARCODE,\n" +
  12869. " F.GOODSCODE,\n" +
  12870. " L.LOGONAME,\n" +
  12871. " F.GROUTINGUSERCODE,\n" +
  12872. " F.GROUTINGLINECODE,\n" +
  12873. " F.GROUTINGMOULDCODE,\n" +
  12874. " F.GROUTINGDATE,\n" +
  12875. " G.DELIVERTIME,\n" +
  12876. " GOODS.goodsmodel,\n" +
  12877. //" (GOODS.MATERIALCODE || L.TAGCODE || G.ONLYCODE) AS FINISHEDBARCODE,\n" +
  12878. //" 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" +
  12879. " G.outlabelcode AS FINISHEDBARCODE,\n" +
  12880. " G.MATERIALCODE AS mcode,\n" +
  12881. " F.CREATETIME AS PRODUCTFINISHEDTIME\n" +
  12882. " FROM TP_PM_FINISHEDPRODUCT F\n" +
  12883. " LEFT JOIN TP_PM_ORDER O\n" +
  12884. " ON F.FHORDERID = O.ORDERID\n" +
  12885. " LEFT JOIN TP_MST_LOGO L\n" +
  12886. " ON F.LOGOID = L.LOGOID\n" +
  12887. " LEFT JOIN TP_PM_GROUTINGDAILYDETAIL G\n" +
  12888. " ON F.GROUTINGDAILYDETAILID = G.GROUTINGDAILYDETAILID\n" +
  12889. " LEFT JOIN TP_MST_GOODS GOODS\n" +
  12890. " ON F.GOODSID = GOODS.GOODSID\n" +
  12891. " LEFT JOIN TP_MST_GOODSTYPE GOODSTYPE\n" +
  12892. " ON GOODS.GOODSTYPEID = GOODSTYPE.GOODSTYPEID\n" +
  12893. " WHERE F.ACCOUNTID = :ACCOUNTID\n" +
  12894. " AND F.FHTIME IS NOT NULL";
  12895. // 交接时间起始
  12896. if (se.FHTimeStart.HasValue)
  12897. {
  12898. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart ";
  12899. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, se.FHTimeStart.Value, ParameterDirection.Input));
  12900. }
  12901. // 交接时间结束
  12902. if (se.FHTimeEnd.HasValue)
  12903. {
  12904. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd ";
  12905. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, se.FHTimeEnd.Value, ParameterDirection.Input));
  12906. }
  12907. // 订单号
  12908. if (!string.IsNullOrEmpty(se.OrderNo))
  12909. {
  12910. //sqlString = sqlString + " AND O.OrderNo=:OrderNo";
  12911. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0";
  12912. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, se.OrderNo, ParameterDirection.Input));
  12913. }
  12914. // 产品类别编码
  12915. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  12916. {
  12917. sqlString = sqlString + " AND instr(GoodsType.GoodsTypeCode,:GoodsTypeCode)=1";
  12918. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  12919. }
  12920. // 产品编码
  12921. if (!string.IsNullOrEmpty(se.GoodsCode))
  12922. {
  12923. sqlString = sqlString + " AND instr(Goods.GoodsCode,:GoodsCode)>0";
  12924. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  12925. }
  12926. // 产品型号
  12927. if (!string.IsNullOrEmpty(se.GoodsModel))
  12928. {
  12929. sqlString = sqlString + " AND instr(Goods.GoodsModel,:GoodsModel)>0";
  12930. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, se.GoodsModel, ParameterDirection.Input));
  12931. }
  12932. // 产品商标ID集
  12933. if (!string.IsNullOrEmpty(se.LogoIDS))
  12934. {
  12935. sqlString += " AND instr(','||:LogoIDS||',', ',' || L.logoid || ',') > 0";
  12936. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, se.LogoIDS, ParameterDirection.Input));
  12937. }
  12938. // 交接工号
  12939. if (!string.IsNullOrEmpty(se.FHUserCode))
  12940. {
  12941. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0";
  12942. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, se.FHUserCode, ParameterDirection.Input));
  12943. }
  12944. if (se.OrderID != null)
  12945. {
  12946. sqlString = sqlString + " AND F.fhorderid = :fhorderid";
  12947. parameters.Add(new OracleParameter(":fhorderid", OracleDbType.Int32, se.OrderID, ParameterDirection.Input));
  12948. }
  12949. if (se.GoodsID != null)
  12950. {
  12951. sqlString = sqlString + " AND F.GoodsID = :GoodsID";
  12952. parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  12953. }
  12954. if (se.LogoID != null)
  12955. {
  12956. sqlString = sqlString + " AND F.LogoID = :LogoID";
  12957. parameters.Add(new OracleParameter(":LogoID", OracleDbType.Int32, se.LogoID, ParameterDirection.Input));
  12958. }
  12959. return sqlString;
  12960. }
  12961. /// <summary>
  12962. /// 取得F_RPT_030112画面(产成品交接汇总表)的交接数量
  12963. /// </summary>
  12964. /// <param name="user">登录用户信息</param>
  12965. /// <param name="se">查询条件</param>
  12966. /// <returns>查询结果</returns>
  12967. public static ServiceResultEntity GetRPT0030112NData(ClientRequestEntity cre, SUserInfo user)
  12968. {
  12969. IDBConnection conn = null;
  12970. try
  12971. {
  12972. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12973. List<OracleParameter> parameters = new List<OracleParameter>();
  12974. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12975. //string sqlString = "SELECT trunc(f.fhtime) fhtime, g.goodscode, COUNT(*) goodscount\n" +
  12976. string sqlString = "SELECT nvl2(trunc(f.fhtime),\n" +
  12977. " nvl2(l.logoname,\n" +
  12978. " to_char(trunc(f.fhtime), 'yyyy-mm-dd'),\n" +
  12979. " to_char('合计[') || to_char(trunc(f.fhtime), 'yyyy-mm-dd') ||\n" +
  12980. " to_char(']')),\n" +
  12981. " '总计') fhtime\n" +
  12982. " ,nvl2(l.logoname,\n" +
  12983. " nvl2(g.goodscode,\n" +
  12984. " l.logoname,\n" +
  12985. " to_char('小计[' || l.logoname || ']')),\n" +
  12986. " '--') logoname\n" +
  12987. " ,nvl(g.goodscode, '--') goodscode" +
  12988. " ,nvl(g.goodsmodel, '--') goodsmodel" +
  12989. " ,nvl(gdd.materialcode, '--') mcode" +
  12990. " ,COUNT(*) goodscount" +
  12991. " FROM tp_pm_finishedproduct f\n" +
  12992. " inner JOIN tp_pm_groutingdailydetail gdd\n" +
  12993. " ON gdd.barcode = f.barcode\n" +
  12994. " LEFT JOIN tp_mst_logo l\n" +
  12995. " ON f.logoid = l.logoid\n" +
  12996. " LEFT JOIN TP_PM_Order O\n" +
  12997. " ON f.Fhorderid = O.Orderid\n" +
  12998. " LEFT JOIN tp_mst_goods G\n" +
  12999. " ON g.goodsid = f.goodsid\n" +
  13000. " LEFT JOIN TP_MST_GoodsType gt\n" +
  13001. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  13002. " WHERE f.fhtime IS NOT NULL\n" +
  13003. " AND f.AccountID = :AccountID\n";
  13004. // 交接时间起始
  13005. if (cre.Properties["FHTimeStart"] != null)
  13006. {
  13007. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
  13008. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, cre.Properties["FHTimeStart"], ParameterDirection.Input));
  13009. }
  13010. // 交接时间结束
  13011. if (cre.Properties["FHTimeEnd"] != null)
  13012. {
  13013. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd \n";
  13014. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, cre.Properties["FHTimeEnd"], ParameterDirection.Input));
  13015. }
  13016. // 订单号
  13017. if (!string.IsNullOrEmpty(cre.Properties["OrderNo"] as string))
  13018. {
  13019. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0 \n";
  13020. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, cre.Properties["OrderNo"], ParameterDirection.Input));
  13021. }
  13022. // 产品类别编码
  13023. if (!string.IsNullOrEmpty(cre.Properties["GoodsTypeCode"] as string))
  13024. {
  13025. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 \n";
  13026. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input));
  13027. }
  13028. // 产品编码
  13029. if (!string.IsNullOrEmpty(cre.Properties["GoodsCode"] as string))
  13030. {
  13031. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
  13032. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input));
  13033. }
  13034. // 产品型号
  13035. if (!string.IsNullOrEmpty(cre.Properties["GoodsModel"] as string))
  13036. {
  13037. sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0 \n";
  13038. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, cre.Properties["GoodsModel"], ParameterDirection.Input));
  13039. }
  13040. // 产品商标ID集
  13041. if (!string.IsNullOrEmpty(cre.Properties["LogoIDS"] as string))
  13042. {
  13043. sqlString += " AND instr(','||:LogoIDS||',', ',' || f.logoid || ',') > 0 \n";
  13044. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, cre.Properties["LogoIDS"], ParameterDirection.Input));
  13045. }
  13046. // 交接工号
  13047. if (!string.IsNullOrEmpty(cre.Properties["FHUserCode"] as string))
  13048. {
  13049. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0 \n";
  13050. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, cre.Properties["FHUserCode"], ParameterDirection.Input));
  13051. }
  13052. //sqlString += " group by trunc(f.fhtime), g.goodscode order by trunc(f.fhtime), g.goodscode";
  13053. sqlString += " GROUP BY GROUPING SETS((trunc(f.fhtime), l.logoname, g.goodscode,g.goodsmodel,gdd.materialcode),(trunc(f.fhtime), l.logoname),(trunc(f.fhtime)),())";
  13054. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  13055. ServiceResultEntity sre = new ServiceResultEntity();
  13056. if (data == null || data.Rows.Count == 0)
  13057. {
  13058. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13059. return sre;
  13060. }
  13061. sre.Data = new DataSet();
  13062. sre.Data.Tables.Add(data);
  13063. return sre;
  13064. }
  13065. catch (Exception ex)
  13066. {
  13067. throw ex;
  13068. }
  13069. finally
  13070. {
  13071. if (conn != null &&
  13072. conn.ConnState == ConnectionState.Open)
  13073. {
  13074. conn.Close();
  13075. }
  13076. }
  13077. }
  13078. /// <summary>
  13079. /// 取得F_RPT_030112画面(产成品交接汇总表)的型号数量
  13080. /// </summary>
  13081. /// <param name="user">登录用户信息</param>
  13082. /// <param name="se">查询条件</param>
  13083. /// <returns>查询结果</returns>
  13084. public static ServiceResultEntity GetRPT0030112GNData(ClientRequestEntity cre, SUserInfo user)
  13085. {
  13086. IDBConnection conn = null;
  13087. try
  13088. {
  13089. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13090. List<OracleParameter> parameters = new List<OracleParameter>();
  13091. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  13092. //string sqlString = "SELECT trunc(f.fhtime) fhtime, g.goodscode, COUNT(*) goodscount\n" +
  13093. string sqlString = "SELECT --nvl2(trunc(f.fhtime),\n" +
  13094. //" nvl2(l.logoname,\n" +
  13095. //" to_char(trunc(f.fhtime), 'yyyy-mm-dd'),\n" +
  13096. //" to_char('合计[') || to_char(trunc(f.fhtime), 'yyyy-mm-dd') ||\n" +
  13097. //" to_char(']')),\n" +
  13098. //" '总计') fhtime\n" +
  13099. //" ,nvl2(l.logoname,\n" +
  13100. //" nvl2(g.goodscode,\n" +
  13101. //" l.logoname,\n" +
  13102. //" to_char('小计[' || l.logoname || ']')),\n" +
  13103. //" '--') logoname\n" +
  13104. " nvl(g.goodscode, '合计') goodscode" +
  13105. " ,nvl(g.goodsmodel, '--') goodsmodel" +
  13106. " ,nvl(gdd.materialcode, '--') mcode" +
  13107. " ,COUNT(*) goodscount" +
  13108. " FROM tp_pm_finishedproduct f\n" +
  13109. " inner JOIN tp_pm_groutingdailydetail gdd\n" +
  13110. " ON gdd.barcode = f.barcode\n" +
  13111. " LEFT JOIN tp_mst_logo l\n" +
  13112. " ON f.logoid = l.logoid\n" +
  13113. " LEFT JOIN TP_PM_Order O\n" +
  13114. " ON f.Fhorderid = O.Orderid\n" +
  13115. " LEFT JOIN tp_mst_goods G\n" +
  13116. " ON g.goodsid = f.goodsid\n" +
  13117. " LEFT JOIN TP_MST_GoodsType gt\n" +
  13118. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  13119. " WHERE f.fhtime IS NOT NULL\n" +
  13120. " AND f.AccountID = :AccountID\n";
  13121. // 交接时间起始
  13122. if (cre.Properties["FHTimeStart"] != null)
  13123. {
  13124. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
  13125. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, cre.Properties["FHTimeStart"], ParameterDirection.Input));
  13126. }
  13127. // 交接时间结束
  13128. if (cre.Properties["FHTimeEnd"] != null)
  13129. {
  13130. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd \n";
  13131. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, cre.Properties["FHTimeEnd"], ParameterDirection.Input));
  13132. }
  13133. // 订单号
  13134. if (!string.IsNullOrEmpty(cre.Properties["OrderNo"] as string))
  13135. {
  13136. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0 \n";
  13137. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, cre.Properties["OrderNo"], ParameterDirection.Input));
  13138. }
  13139. // 产品类别编码
  13140. if (!string.IsNullOrEmpty(cre.Properties["GoodsTypeCode"] as string))
  13141. {
  13142. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 \n";
  13143. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input));
  13144. }
  13145. // 产品编码
  13146. if (!string.IsNullOrEmpty(cre.Properties["GoodsCode"] as string))
  13147. {
  13148. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
  13149. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input));
  13150. }
  13151. // 产品型号
  13152. if (!string.IsNullOrEmpty(cre.Properties["GoodsModel"] as string))
  13153. {
  13154. sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0 \n";
  13155. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, cre.Properties["GoodsModel"], ParameterDirection.Input));
  13156. }
  13157. // 产品商标ID集
  13158. if (!string.IsNullOrEmpty(cre.Properties["LogoIDS"] as string))
  13159. {
  13160. sqlString += " AND instr(','||:LogoIDS||',', ',' || f.logoid || ',') > 0 \n";
  13161. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, cre.Properties["LogoIDS"], ParameterDirection.Input));
  13162. }
  13163. // 交接工号
  13164. if (!string.IsNullOrEmpty(cre.Properties["FHUserCode"] as string))
  13165. {
  13166. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0 \n";
  13167. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, cre.Properties["FHUserCode"], ParameterDirection.Input));
  13168. }
  13169. //sqlString += " group by trunc(f.fhtime), g.goodscode order by trunc(f.fhtime), g.goodscode";
  13170. sqlString += " GROUP BY GROUPING SETS((g.goodscode,g.goodsmodel,gdd.materialcode),())";
  13171. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  13172. ServiceResultEntity sre = new ServiceResultEntity();
  13173. if (data == null || data.Rows.Count == 0)
  13174. {
  13175. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13176. return sre;
  13177. }
  13178. sre.Data = new DataSet();
  13179. sre.Data.Tables.Add(data);
  13180. return sre;
  13181. }
  13182. catch (Exception ex)
  13183. {
  13184. throw ex;
  13185. }
  13186. finally
  13187. {
  13188. if (conn != null &&
  13189. conn.ConnState == ConnectionState.Open)
  13190. {
  13191. conn.Close();
  13192. }
  13193. }
  13194. }
  13195. /// <summary>
  13196. /// 取得PDA(产成品交接汇总表)的交接数量
  13197. /// </summary>
  13198. /// <param name="user">登录用户信息</param>
  13199. /// <param name="se">查询条件</param>
  13200. /// <returns>查询结果</returns>
  13201. public static ServiceResultEntity GetRPT0030112NPDAData(DateTime date, string goodscode, SUserInfo user)
  13202. {
  13203. IDBConnection conn = null;
  13204. try
  13205. {
  13206. DateTime dateStart = date;
  13207. DateTime dateEnd = dateStart.AddDays(1);
  13208. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13209. List<OracleParameter> parameters = new List<OracleParameter>();
  13210. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  13211. string sqlString = "SELECT o.orderno, g.goodscode, COUNT(*) goodscount\n" +
  13212. " FROM tp_pm_finishedproduct f\n" +
  13213. " LEFT JOIN TP_PM_Order O\n" +
  13214. " ON f.Fhorderid = O.Orderid\n" +
  13215. " LEFT JOIN tp_mst_goods G\n" +
  13216. " ON g.goodsid = f.goodsid\n" +
  13217. " LEFT JOIN TP_MST_GoodsType gt\n" +
  13218. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  13219. " WHERE f.fhtime IS NOT NULL\n" +
  13220. " AND f.AccountID = :AccountID\n";
  13221. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
  13222. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, dateStart, ParameterDirection.Input));
  13223. sqlString = sqlString + " AND F.FHTime < :FHTimeEnd \n";
  13224. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, dateEnd, ParameterDirection.Input));
  13225. // 产品型号
  13226. if (!string.IsNullOrEmpty(goodscode))
  13227. {
  13228. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
  13229. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, goodscode, ParameterDirection.Input));
  13230. }
  13231. sqlString += " group by orderno, g.goodscode order by orderno, g.goodscode";
  13232. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  13233. ServiceResultEntity sre = new ServiceResultEntity();
  13234. if (data == null || data.Rows.Count == 0)
  13235. {
  13236. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13237. return sre;
  13238. }
  13239. sre.Data = new DataSet();
  13240. sre.Data.Tables.Add(data);
  13241. return sre;
  13242. }
  13243. catch (Exception ex)
  13244. {
  13245. throw ex;
  13246. }
  13247. finally
  13248. {
  13249. if (conn != null &&
  13250. conn.ConnState == ConnectionState.Open)
  13251. {
  13252. conn.Close();
  13253. }
  13254. }
  13255. }
  13256. /// <summary>
  13257. /// 获取在产品备份表
  13258. /// </summary>
  13259. /// <param name="cre"></param>
  13260. /// <param name="sUserInfo"></param>
  13261. /// <returns></returns>
  13262. public static ServiceResultEntity GetRPT010404Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13263. {
  13264. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13265. try
  13266. {
  13267. ServiceResultEntity sre = new ServiceResultEntity();
  13268. string sqlString = "SELECT inpb.BackupMonth\n" +
  13269. " ,gdd.BarCode\n" +
  13270. //" ,inpb.GoodsID\n" +
  13271. " ,inpb.GoodsCode\n" +
  13272. " ,inpb.GoodsName\n" +
  13273. //" ,inpb.Userid\n" +
  13274. " ,worker.USERNAME AS UserName\n" +
  13275. " ,worker.USERCode AS UserCode\n" +
  13276. //" ,inpb.ProductionLineID\n" +
  13277. " ,inpb.ProductionLineCode\n" +
  13278. " ,inpb.ProductionLineName\n" +
  13279. //" ,inpb.ModelType\n" +
  13280. " ,decode(inpb.inscrapflag, '1', '待审核的报废品', '正常') AS inscrapflag\n" +
  13281. " ,inpb.IsPublicBody\n" +
  13282. " ,decode(inpb.IsReFire,'6','1','0') IsReFire\n" +
  13283. " ,inpb.IsReworkFlag\n" +
  13284. " ,decode(inpb.CanManyTimes, '1', '能', '不能') AS CanManyTimes\n" +
  13285. " ,decode(inpb.ProcedureModel, '1', '计件模型', '检验模型') AS ProcedureModel\n" +
  13286. //" ,inpb.GroutingDailyID\n" +
  13287. //" ,inpb.GroutingDailyDetailID\n" +
  13288. " ,inpb.GroutingDate\n" +
  13289. //" ,inpb.GroutingLineID\n" +
  13290. " ,inpb.GroutingLineCode\n" +
  13291. " ,inpb.GroutingLineName\n" +
  13292. //" ,inpb.ProcedureID CompleteProcedureID\n" +
  13293. " ,pro.ProcedureName AS CompleteProcedureName\n" +
  13294. //" ,inpb.GMouldTypeID\n" +
  13295. " ,gmt.GMOULDTYPENAME AS GMouldTypeName\n" +
  13296. //" ,inpb.GroutingLineDetailID\n" +
  13297. " ,inpb.GroutingMouldCode\n" +
  13298. " ,inpb.SPECIALREPAIRFLAG\n" +
  13299. " ,inpb.GROUTINGUSERCODE\n" +
  13300. " ,gdd.GROUTINGCOUNT\n" +
  13301. " ,gdd.delivertime\n" +
  13302. " ,inpb.proceduretime\n" +
  13303. " ,inpb.Remarks\n" +
  13304. //" ,inpb.GoodsLevelID\n" +
  13305. " ,mgl.GOODSLEVELNAME\n" +
  13306. //" ,inpb.GoodsLevelTypeID\n" +
  13307. " ,mglt.GOODSLEVELTYPENAME\n" +
  13308. " ,inpb.BackupTime\n" +
  13309. " ,REPLACE((logo.Logoname || '[' || logo.Logocode || ']'), '[]', '') AS LogoCodeName\n" +
  13310. //" ,(Goods.MaterialCode || logo.tagcode || gdd.onlycode) AS FinishedBarCode\n" +
  13311. " ,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" +
  13312. " FROM TP_PM_InProduction_BakByMonth inpb\n" +
  13313. " INNER JOIN TP_MST_User worker\n" +
  13314. " ON worker.UserID = inpb.Userid\n" +
  13315. " INNER JOIN TP_PC_Procedure pro\n" +
  13316. " ON pro.PROCEDUREID = inpb.ProcedureID\n" +
  13317. " INNER JOIN TP_MST_GMouldType gmt\n" +
  13318. " ON gmt.GMouldTypeID = inpb.GMouldTypeID\n" +
  13319. " INNER JOIN TP_SYS_ProcedureModelType pmt\n" +
  13320. " ON pmt.ProcedureModelTypeID = inpb.ModelType\n" +
  13321. //" INNER JOIN TP_PM_GroutingDaily gd\n" +
  13322. //" ON gd.GroutingDailyID = inpb.GroutingDailyID\n" +
  13323. " INNER JOIN TP_PM_GroutingDailyDetail gdd\n" +
  13324. " ON gdd.Groutingdailydetailid = inpb.GroutingDailyDetailID\n" +
  13325. //" INNER JOIN TP_PC_GroutingLineDetail gld\n" +
  13326. //" ON gld.Groutinglinedetailid = inpb.GroutingLineDetailID\n" +
  13327. " LEFT JOIN TP_MST_GoodsLevel mgl\n" +
  13328. " ON mgl.GoodsLevelID = inpb.GoodsLevelID\n" +
  13329. " LEFT JOIN TP_SYS_GoodsLevelType mglt\n" +
  13330. " ON mglt.GoodsLevelTypeID = inpb.GoodsLevelTypeID\n" +
  13331. " LEFT JOIN TP_MST_Logo logo\n" +
  13332. " ON inpb.logoid = logo.logoid\n" +
  13333. " LEFT JOIN TP_MST_Goods Goods\n" +
  13334. " ON inpb.GoodsID = Goods.GoodsID\n" +
  13335. " WHERE inpb.AccountID = :AccountID" +
  13336. " AND inpb.BackupMonth = :BackupMonth" +
  13337. " ORDER BY pro.displayno,inpb.proceduretime";
  13338. OracleParameter[] oracleParameter = new OracleParameter[]
  13339. {
  13340. new Oracle.ManagedDataAccess.Client.OracleParameter(":AccountID",sUserInfo.AccountID),
  13341. new Oracle.ManagedDataAccess.Client.OracleParameter(":BackupMonth",cre.Properties["BackupMonth"]),
  13342. };
  13343. oracleConn.Open();
  13344. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13345. oracleConn.Close();
  13346. sre.Data = result;
  13347. return sre;
  13348. }
  13349. catch (Exception ex)
  13350. {
  13351. if (oracleConn.ConnState == ConnectionState.Open)
  13352. {
  13353. oracleConn.Close();
  13354. }
  13355. throw ex;
  13356. }
  13357. }
  13358. /// <summary>
  13359. /// 产成品单值明细表
  13360. /// </summary>
  13361. /// <param name="cre"></param>
  13362. /// <param name="sUserInfo"></param>
  13363. /// <returns></returns>
  13364. public static ServiceResultEntity GetRPT010405Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13365. {
  13366. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13367. try
  13368. {
  13369. string sql =
  13370. "SELECT up.id, up.NAME\n" +
  13371. " FROM tp_mst_unitprice up\n" +
  13372. " WHERE up.accountid = :AccountID\n" +
  13373. " AND up.valueflag = '1'\n" +
  13374. " AND (:upname IS NULL OR instr(up.name, :upname) > 0)\n" +
  13375. " ORDER BY up.displayno";
  13376. OracleParameter[] opara = new OracleParameter[]
  13377. {
  13378. new Oracle.ManagedDataAccess.Client.OracleParameter(":AccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13379. new Oracle.ManagedDataAccess.Client.OracleParameter(":upname", OracleDbType.NVarchar2,cre.Properties["UPName"], ParameterDirection.Input),
  13380. };
  13381. DataTable upTable = oracleConn.GetSqlResultToDt(sql, opara);
  13382. StringBuilder upNames = new StringBuilder();
  13383. StringBuilder upTotals = new StringBuilder();
  13384. StringBuilder upSUMs = new StringBuilder();
  13385. foreach (DataRow item in upTable.Rows)
  13386. {
  13387. upNames.AppendFormat(", u{0} AS \"{1}\"\n", item["ID"], item["Name"]);
  13388. upTotals.AppendFormat(",(u{0} * nvl(fpcount, 0)) AS \"总【{1}】\"\n", item["ID"], item["Name"]);
  13389. upSUMs.AppendFormat(",SUM(decode(up.upid, {0}, up.unitprice, 0)) u{0}\n", item["ID"]);
  13390. }
  13391. ServiceResultEntity sre = new ServiceResultEntity();
  13392. string sqlString = "SELECT gt2.goodstypename GoodsTypeName2\n" +
  13393. " ,g.goodscode\n" +
  13394. " ,g.materialcode\n" +
  13395. " ,lg.logoname\n" +
  13396. " ,nvl(fpcount, 0) fpcount\n" +
  13397. // " ,u1 AS \"单值1\"\n" +
  13398. //" ,u2 AS \"单值2\"\n" +
  13399. upNames +
  13400. //" ,(u1 * nvl(fpcount, 0)) AS \"总【1】\"\n" +
  13401. //" ,(u2 * nvl(fpcount, 0)) AS \"总【2】\"\n" +
  13402. upTotals +
  13403. " FROM (SELECT up.goodsid\n" +
  13404. " ,up.logoid\n" +
  13405. //" ,SUM(decode(up.upid, 1, up.unitprice, 0)) u1\n" +
  13406. //" ,SUM(decode(up.upid, 2, up.unitprice, 0)) u2\n" +
  13407. upSUMs +
  13408. " FROM TP_MST_UnitPriceGoods up\n" +
  13409. " WHERE up.accountid = :AccountID\n" +
  13410. " GROUP BY up.goodsid, up.logoid) upg\n" +
  13411. " LEFT JOIN (SELECT fp.goodsid, fp.logoid, COUNT(*) fpcount\n" +
  13412. " FROM tp_pm_finishedproduct fp\n" +
  13413. " WHERE fp.accountid = :AccountID\n" +
  13414. " AND fp.fhtime BETWEEN :DateBegin AND :DateEnd\n" +
  13415. " AND (:GoodsCode IS NULL OR\n" +
  13416. " instr(fp.goodscode, :GoodsCode) > 0)\n" +
  13417. " GROUP BY fp.goodsid, fp.logoid) fpp\n" +
  13418. " ON fpp.goodsid = upg.goodsid\n" +
  13419. " AND fpp.logoid = upg.logoid\n" +
  13420. " INNER JOIN tp_mst_logo lg\n" +
  13421. " ON lg.logoid = upg.logoid\n" +
  13422. " INNER JOIN tp_mst_goods g\n" +
  13423. " ON g.goodsid = upg.goodsid\n" +
  13424. " INNER JOIN tp_mst_goodstype gt\n" +
  13425. " ON gt.goodstypeid = g.goodstypeid\n" +
  13426. " INNER JOIN tp_mst_goodstype gt2\n" +
  13427. " ON gt2.accountid = :AccountID\n" +
  13428. " AND length(gt2.goodstypecode) = 6\n" +
  13429. " AND instr(gt.goodstypecode, gt2.goodstypecode) = 1\n" +
  13430. " WHERE (:GoodsTypeCode IS NULL OR\n" +
  13431. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  13432. " AND (:GoodsCode IS NULL OR instr(g.goodscode, :GoodsCode) > 0)\n" +
  13433. " AND (:logoname IS NULL OR instr(lg.logoname, :logoname) > 0)\n" +
  13434. " ORDER BY g.goodscode, lg.displayno";
  13435. OracleParameter[] oracleParameter = new OracleParameter[]
  13436. {
  13437. new Oracle.ManagedDataAccess.Client.OracleParameter(":AccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13438. new Oracle.ManagedDataAccess.Client.OracleParameter(":DateBegin", OracleDbType.Date,cre.Properties["DateBegin"], ParameterDirection.Input),
  13439. new Oracle.ManagedDataAccess.Client.OracleParameter(":DateEnd", OracleDbType.Date,cre.Properties["DateEnd"], ParameterDirection.Input),
  13440. new Oracle.ManagedDataAccess.Client.OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2,cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13441. new Oracle.ManagedDataAccess.Client.OracleParameter(":GoodsCode", OracleDbType.NVarchar2,cre.Properties["GoodsCode"], ParameterDirection.Input),
  13442. new Oracle.ManagedDataAccess.Client.OracleParameter(":logoname", OracleDbType.NVarchar2,cre.Properties["LogoName"], ParameterDirection.Input),
  13443. };
  13444. oracleConn.Open();
  13445. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13446. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13447. {
  13448. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13449. }
  13450. sre.Data = result;
  13451. oracleConn.Close();
  13452. return sre;
  13453. }
  13454. catch (Exception ex)
  13455. {
  13456. if (oracleConn.ConnState == ConnectionState.Open)
  13457. {
  13458. oracleConn.Close();
  13459. }
  13460. throw ex;
  13461. }
  13462. }
  13463. /// <summary>
  13464. /// 产成品单值明细表-单值名管理
  13465. /// </summary>
  13466. /// <param name="cre"></param>
  13467. /// <param name="sUserInfo"></param>
  13468. /// <returns></returns>
  13469. public static ServiceResultEntity GetRPT01040501Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13470. {
  13471. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13472. try
  13473. {
  13474. ServiceResultEntity sre = new ServiceResultEntity();
  13475. string sqlString = "SELECT t.id, t.name, t.displayno, t.valueflag\n" +
  13476. " FROM TP_MST_UnitPrice t\n" +
  13477. " WHERE t.accountid = :accountid\n" +
  13478. " ORDER BY t.id";
  13479. OracleParameter[] oracleParameter = new OracleParameter[]
  13480. {
  13481. new Oracle.ManagedDataAccess.Client.OracleParameter(":AccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13482. };
  13483. oracleConn.Open();
  13484. sre.Data = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13485. oracleConn.Close();
  13486. return sre;
  13487. }
  13488. catch (Exception ex)
  13489. {
  13490. if (oracleConn.ConnState == ConnectionState.Open)
  13491. {
  13492. oracleConn.Close();
  13493. }
  13494. throw ex;
  13495. }
  13496. }
  13497. /// <summary>
  13498. /// 产成品单值明细表-单值名管理
  13499. /// </summary>
  13500. /// <param name="cre"></param>
  13501. /// <param name="sUserInfo"></param>
  13502. /// <returns></returns>
  13503. public static ServiceResultEntity SetRPT01040501Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13504. {
  13505. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13506. try
  13507. {
  13508. ServiceResultEntity sre = new ServiceResultEntity();
  13509. // 检验参数的有效性
  13510. if (cre.Data == null && cre.Data.Tables.Count == 0 ||
  13511. cre.Data.Tables[0].Rows.Count < Constant.INT_IS_ZERO)
  13512. {
  13513. return sre;
  13514. }
  13515. oracleTrConn.Connect();
  13516. foreach (DataRow dataRow in cre.Data.Tables[0].Rows)
  13517. {
  13518. // 新建
  13519. if (dataRow.RowState == DataRowState.Added)
  13520. {
  13521. #region 新增
  13522. string sqlString = "INSERT INTO TP_MST_UNITPRICE\n" +
  13523. " (NAME, displayno, accountid, valueflag, createuserid, updateuserid)\n" +
  13524. "VALUES\n" +
  13525. " (:NAME, nvl(:DisplayNo,0), :AccountID, :ValueFlag, :UserID, :UserID)";
  13526. OracleParameter[] oracleParameter = new OracleParameter[]
  13527. {
  13528. new OracleParameter(":NAME", OracleDbType.NVarchar2, dataRow["Name"],ParameterDirection.Input),
  13529. new OracleParameter(":DisplayNo",OracleDbType.Int32, dataRow["DisplayNo"], ParameterDirection.Input),
  13530. new OracleParameter(":AccountID",OracleDbType.Int32,sUserInfo.AccountID, ParameterDirection.Input),
  13531. new OracleParameter(":ValueFlag",OracleDbType.NVarchar2, dataRow["ValueFlag"],ParameterDirection.Input),
  13532. new OracleParameter(":UserID",OracleDbType.Int32,sUserInfo.UserID, ParameterDirection.Input),
  13533. };
  13534. oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  13535. #endregion
  13536. }
  13537. else if (dataRow.RowState == DataRowState.Modified)
  13538. {
  13539. #region 更新
  13540. string sqlUpdateString = "UPDATE TP_MST_UNITPRICE SET "
  13541. + " Name = :Name,"
  13542. + " DisplayNo = :DisplayNo,"
  13543. + " ValueFlag = :ValueFlag,"
  13544. + " UpdateUserID = :UserID"
  13545. + " WHERE ID = :ID";
  13546. OracleParameter[] oracleParameter = new OracleParameter[]
  13547. {
  13548. new OracleParameter(":ID",OracleDbType.Int32,dataRow["ID"], ParameterDirection.Input),
  13549. new OracleParameter(":Name", OracleDbType.NVarchar2, dataRow["Name"],ParameterDirection.Input),
  13550. new OracleParameter(":DisplayNo",OracleDbType.Int32, dataRow["DisplayNo"], ParameterDirection.Input),
  13551. new OracleParameter(":ValueFlag",OracleDbType.NVarchar2, dataRow["ValueFlag"],ParameterDirection.Input),
  13552. new OracleParameter(":UserID",OracleDbType.Int32,sUserInfo.UserID, ParameterDirection.Input),
  13553. };
  13554. oracleTrConn.ExecuteNonQuery(sqlUpdateString, oracleParameter);
  13555. #endregion
  13556. }
  13557. else if (dataRow.RowState == DataRowState.Deleted)
  13558. {
  13559. #region 删除
  13560. string sqlDeleteString = "DELETE TP_MST_UNITPRICE WHERE ID = :ID";
  13561. OracleParameter[] oracleParameter = new OracleParameter[]
  13562. {
  13563. new OracleParameter(":ID",OracleDbType.Int32,dataRow["ID"], ParameterDirection.Input),
  13564. };
  13565. oracleTrConn.ExecuteNonQuery(sqlDeleteString, oracleParameter);
  13566. #endregion
  13567. }
  13568. }
  13569. oracleTrConn.Commit();
  13570. oracleTrConn.Disconnect();
  13571. return sre;
  13572. }
  13573. catch (Exception ex)
  13574. {
  13575. if (oracleTrConn.ConnState == ConnectionState.Open)
  13576. {
  13577. oracleTrConn.Rollback();
  13578. oracleTrConn.Disconnect();
  13579. }
  13580. throw ex;
  13581. }
  13582. finally
  13583. {
  13584. if (oracleTrConn.ConnState == ConnectionState.Open)
  13585. {
  13586. oracleTrConn.Disconnect();
  13587. }
  13588. }
  13589. }
  13590. /// <summary>
  13591. /// 获取模具跟踪表
  13592. /// </summary>
  13593. /// <param name="cre"></param>
  13594. /// <param name="sUserInfo"></param>
  13595. /// <returns></returns>
  13596. public static ServiceResultEntity GetRPT020105Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13597. {
  13598. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13599. try
  13600. {
  13601. ServiceResultEntity sre = new ServiceResultEntity();
  13602. OracleParameter[] oracleParameter = new OracleParameter[]
  13603. {
  13604. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13605. new OracleParameter("in_MouldBarcode",OracleDbType.Varchar2, cre.Properties["MouldBarcode"], ParameterDirection.Input),
  13606. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13607. new OracleParameter("out_Tracking",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13608. };
  13609. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_GetMouldTracking", oracleParameter);
  13610. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13611. {
  13612. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13613. }
  13614. sre.Data = result;
  13615. return sre;
  13616. }
  13617. catch (Exception ex)
  13618. {
  13619. if (oracleConn.ConnState == ConnectionState.Open)
  13620. {
  13621. oracleConn.Close();
  13622. }
  13623. throw ex;
  13624. }
  13625. }
  13626. /// <summary>
  13627. /// 获取模具收发存汇总表
  13628. /// </summary>
  13629. /// <param name="cre"></param>
  13630. /// <param name="sUserInfo"></param>
  13631. /// <returns></returns>
  13632. public static ServiceResultEntity GetRPT030113Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13633. {
  13634. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13635. try
  13636. {
  13637. ServiceResultEntity sre = new ServiceResultEntity();
  13638. OracleParameter[] oracleParameter = new OracleParameter[]
  13639. {
  13640. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13641. new OracleParameter("in_YYYYMM",OracleDbType.Varchar2, cre.Properties["YYYYMM"], ParameterDirection.Input),
  13642. new OracleParameter("in_DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13643. new OracleParameter("in_DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13644. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13645. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13646. new OracleParameter("in_GoodsIDs",OracleDbType.Varchar2, cre.Properties["GoodsIDs"], ParameterDirection.Input),
  13647. new OracleParameter("in_GoodsID",OracleDbType.Int32, cre.Properties["GoodsID"], ParameterDirection.Input),
  13648. new OracleParameter("in_Type",OracleDbType.Int32, cre.Properties["Type"], ParameterDirection.Input),
  13649. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13650. };
  13651. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_GetMould_SUM", oracleParameter);
  13652. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13653. {
  13654. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13655. }
  13656. sre.Data = result;
  13657. oracleConn.Commit();
  13658. return sre;
  13659. }
  13660. catch (Exception ex)
  13661. {
  13662. if (oracleConn.ConnState == ConnectionState.Open)
  13663. {
  13664. oracleConn.Disconnect();
  13665. }
  13666. throw ex;
  13667. }
  13668. }
  13669. /// <summary>
  13670. /// 获取废弃产品汇总表
  13671. /// </summary>
  13672. /// <param name="cre"></param>
  13673. /// <param name="sUserInfo"></param>
  13674. /// <returns></returns>
  13675. public static ServiceResultEntity GetRPT030114Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13676. {
  13677. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13678. try
  13679. {
  13680. ServiceResultEntity sre = new ServiceResultEntity();
  13681. OracleParameter[] oracleParameter = new OracleParameter[]
  13682. {
  13683. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13684. new OracleParameter("in_DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13685. new OracleParameter("in_DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13686. new OracleParameter("in_scrapTypes",OracleDbType.Varchar2, cre.Properties["ScrapTypes"], ParameterDirection.Input),
  13687. new OracleParameter("in_ProcedureIDs",OracleDbType.Varchar2, cre.Properties["ProcedureIDs"], ParameterDirection.Input),
  13688. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13689. //new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13690. new OracleParameter("in_GoodsIDs",OracleDbType.Varchar2, cre.Properties["GoodsIDs"], ParameterDirection.Input),
  13691. new OracleParameter("in_GoodsID",OracleDbType.Int32, cre.Properties["GoodsID"], ParameterDirection.Input),
  13692. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13693. };
  13694. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_scrap_sum", oracleParameter);
  13695. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13696. {
  13697. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13698. }
  13699. sre.Data = result;
  13700. oracleConn.Commit();
  13701. return sre;
  13702. }
  13703. catch (Exception ex)
  13704. {
  13705. if (oracleConn.ConnState == ConnectionState.Open)
  13706. {
  13707. oracleConn.Disconnect();
  13708. }
  13709. throw ex;
  13710. }
  13711. }
  13712. /// <summary>
  13713. /// 获取废品损失汇总表
  13714. /// </summary>
  13715. /// <param name="cre"></param>
  13716. /// <param name="sUserInfo"></param>
  13717. /// <returns></returns>
  13718. public static ServiceResultEntity GetRPT030115Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13719. {
  13720. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13721. try
  13722. {
  13723. ServiceResultEntity sre = new ServiceResultEntity();
  13724. OracleParameter[] oracleParameter = new OracleParameter[]
  13725. {
  13726. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13727. new OracleParameter("in_ptid",OracleDbType.Int32, cre.Properties["PTID"], ParameterDirection.Input),
  13728. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13729. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13730. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13731. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13732. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13733. };
  13734. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_TECDEP_SCRAP_SUM", oracleParameter);
  13735. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13736. {
  13737. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13738. }
  13739. sre.Data = result;
  13740. oracleConn.Commit();
  13741. return sre;
  13742. }
  13743. catch (Exception ex)
  13744. {
  13745. if (oracleConn.ConnState == ConnectionState.Open)
  13746. {
  13747. oracleConn.Disconnect();
  13748. }
  13749. throw ex;
  13750. }
  13751. }
  13752. /// <summary>
  13753. /// 获取废品损失汇总-明细表
  13754. /// </summary>
  13755. /// <param name="cre"></param>
  13756. /// <param name="sUserInfo"></param>
  13757. /// <returns></returns>
  13758. public static ServiceResultEntity GetRPT030115DData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13759. {
  13760. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13761. try
  13762. {
  13763. ServiceResultEntity sre = new ServiceResultEntity();
  13764. OracleParameter[] oracleParameter = new OracleParameter[]
  13765. {
  13766. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13767. new OracleParameter("in_ptid",OracleDbType.Int32, cre.Properties["PTID"], ParameterDirection.Input),
  13768. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13769. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13770. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13771. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13772. new OracleParameter("in_GoodsID",OracleDbType.Varchar2, cre.Properties["GoodsID"], ParameterDirection.Input),
  13773. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13774. };
  13775. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_TECDEP_SCRAP_SUMDETAIL", oracleParameter);
  13776. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13777. {
  13778. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13779. }
  13780. sre.Data = result;
  13781. oracleConn.Commit();
  13782. return sre;
  13783. }
  13784. catch (Exception ex)
  13785. {
  13786. if (oracleConn.ConnState == ConnectionState.Open)
  13787. {
  13788. oracleConn.Disconnect();
  13789. }
  13790. throw ex;
  13791. }
  13792. }
  13793. /// <summary>
  13794. /// 获取废品损失汇总表-半成品损失汇总表
  13795. /// </summary>
  13796. /// <param name="cre"></param>
  13797. /// <param name="sUserInfo"></param>
  13798. /// <returns></returns>
  13799. public static ServiceResultEntity GetRPT030115SData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13800. {
  13801. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13802. try
  13803. {
  13804. ServiceResultEntity sre = new ServiceResultEntity();
  13805. OracleParameter[] oracleParameter = new OracleParameter[]
  13806. {
  13807. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13808. new OracleParameter("in_ptid",OracleDbType.Int32, cre.Properties["PTID"], ParameterDirection.Input),
  13809. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13810. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13811. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13812. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13813. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13814. };
  13815. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_TECDEP_SCRAP_SUM_semi", oracleParameter);
  13816. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13817. {
  13818. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13819. }
  13820. StringBuilder cols = new StringBuilder();
  13821. StringBuilder sumCols = new StringBuilder();
  13822. foreach (DataRow item in result.Tables[0].Rows)
  13823. {
  13824. cols.AppendFormat(", d{0} AS \"{1}\"\n", item["id"], item["name"]);
  13825. sumCols.AppendFormat(", SUM(decode(td1.id, {0}, g.d, 0)) d{0}\n", item["id"]);
  13826. }
  13827. string sqlString = "SELECT gid\n" +
  13828. " ,decode(gid, 3, '合计', 1, '小计[' || gt2name || ']', gt2name) gt2name\n" +
  13829. " ,decode(gid, 0, td2name, '--') td2name\n" +
  13830. " ,gg.gc\n" +
  13831. " ,case when gg.gc is not null and gg.gc > 0 then round(tt.d / gg.gc,4) else null end gcc\n" +
  13832. " ,d\n" +
  13833. " ,c\n" +
  13834. " ,d-c g\n" +
  13835. cols +
  13836. " FROM (SELECT grouping_id(t.tecdepid, td2.id) gid\n" +
  13837. " ,nvl(t.tecdepid, -1) gt2id\n" +
  13838. " ,t.tecdepname gt2name\n" +
  13839. " ,td2.name td2name\n" +
  13840. " ,td2.displayno td2displayno\n" +
  13841. " ,SUM(g.d) d\n" +
  13842. " ,SUM(g.c) c\n" +
  13843. sumCols +
  13844. " FROM TMP_RPT_TECDEP_G g\n" +
  13845. " INNER JOIN TMP_RPT_TECDEP_T t\n" +
  13846. " ON g.goodsid = t.goodsid\n" +
  13847. " INNER JOIN tmp_rpt_tecdep_s s1\n" +
  13848. " ON s1.procedureid = g.pid\n" +
  13849. " INNER JOIN tp_mst_tecdep td1\n" +
  13850. " ON td1.id = s1.intecdepid\n" +
  13851. " LEFT JOIN tmp_rpt_tecdep_s s2\n" +
  13852. " ON s2.procedureid = g.f\n" +
  13853. " LEFT JOIN tp_mst_tecdep td2\n" +
  13854. " ON td2.id = s2.intecdepid\n" +
  13855. " WHERE td1.technologyflag = '1' -- 半成品工艺\n" +
  13856. " AND (td2.id IS NULL OR td2.technologyflag = '1')\n" +
  13857. " GROUP BY GROUPING SETS((t.tecdepid, t.tecdepname, td2.id, td2.name, td2.displayno),(t.tecdepid, t.tecdepname),())\n" +
  13858. " ORDER BY t.tecdepname, td2.displayno) tt\n" +
  13859. " LEFT JOIN (SELECT --grouping_id(gt2.goodstypeid) gid,\n" +
  13860. " nvl(t.tecdepid, -1) gt2id, COUNT(*) gc\n" +
  13861. " FROM tp_pm_groutingdailydetail gdd\n" +
  13862. " INNER JOIN TMP_RPT_TECDEP_T t\n" +
  13863. " ON gdd.goodsid = t.goodsid\n" +
  13864. " WHERE gdd.accountid = :in_accountid\n" +
  13865. " AND gdd.valueflag = '1'\n" +
  13866. " AND gdd.groutingflag = '1'\n" +
  13867. " AND gdd.groutingdate BETWEEN :in_datetimebegin AND\n" +
  13868. " :in_datetimeend\n" +
  13869. " GROUP BY GROUPING SETS((t.tecdepid),())) gg\n" +
  13870. " ON gg.gt2id = tt.gt2id\n" +
  13871. " ORDER BY tt.gt2name, tt.gid, tt.td2displayno";
  13872. oracleParameter = new OracleParameter[]
  13873. {
  13874. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13875. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13876. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13877. };
  13878. result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13879. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13880. {
  13881. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13882. }
  13883. sre.Data = result;
  13884. oracleConn.Commit();
  13885. return sre;
  13886. }
  13887. catch (Exception ex)
  13888. {
  13889. if (oracleConn.ConnState == ConnectionState.Open)
  13890. {
  13891. oracleConn.Disconnect();
  13892. }
  13893. throw ex;
  13894. }
  13895. }
  13896. /// <summary>
  13897. /// 获取成型存坯汇总表-注浆产品存坯汇总表
  13898. /// </summary>
  13899. /// <param name="cre"></param>
  13900. /// <param name="sUserInfo"></param>
  13901. /// <returns></returns>
  13902. public static ServiceResultEntity GetRPT030116GoodsData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13903. {
  13904. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13905. try
  13906. {
  13907. ServiceResultEntity sre = new ServiceResultEntity();
  13908. /*
  13909. string sqlString =
  13910. "SELECT gdrd.goodsid\n" +
  13911. " ,gdrd.goodscode\n" +
  13912. //" ,gdrd.groutinglineid\n" +
  13913. //" ,gdrd.groutinglinecode\n" +
  13914. //" ,gdrd.userid\n" +
  13915. //" ,gdrd.usercode\n" +
  13916. " ,gdrd.gddc rdcount -- 存坯数\n" +
  13917. " ,rdd.gldcount -- 模具数\n" +
  13918. " , CASE\n" +
  13919. " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
  13920. " round(gdrd.gddc / rdd.gldcount, 2)\n" +
  13921. " ELSE\n" +
  13922. " NULL\n" +
  13923. " END rddays -- 存坯天数\n" +
  13924. " ,gdrd.reserveddays -- 应存天数\n" +
  13925. " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
  13926. " FROM (SELECT gdd.goodsid\n" +
  13927. " ,gdd.goodscode\n" +
  13928. //" ,gdd.groutinglineid\n" +
  13929. //" ,gdd.groutinglinecode\n" +
  13930. //" ,gdd.userid\n" +
  13931. //" ,gdd.usercode\n" +
  13932. " ,g.reserveddays\n" +
  13933. " ,COUNT(*) gddc\n" +
  13934. " FROM tp_pm_groutingdailydetail gdd\n" +
  13935. " INNER JOIN tp_mst_goods g\n" +
  13936. " ON g.goodsid = gdd.goodsid\n" +
  13937. " INNER JOIN tp_mst_goodstype gt\n" +
  13938. " ON g.goodstypeid = gt.goodstypeid\n" +
  13939. " WHERE gdd.accountid = :accountid\n" +
  13940. " AND gdd.valueflag = '1'\n" +
  13941. " AND gdd.groutingflag = '1'\n" +
  13942. " AND gdd.barcode IS NOT NULL\n" +
  13943. " AND gdd.scrapflag = '0'\n" +
  13944. " AND gdd.deliverflag = '0'\n" +
  13945. " AND (:LineCode IS NULL OR\n" +
  13946. " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13947. " AND (:UserCode IS NULL OR instr(gdd.UserCode, :UserCode) > 0)\n" +
  13948. " AND (:GoodsCode IS NULL OR instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13949. " AND (:GoodsTypeCode IS NULL OR\n" +
  13950. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13951. " AND (:DateBegin IS NULL OR\n" +
  13952. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
  13953. " GROUP BY gdd.goodsid\n" +
  13954. " ,gdd.goodscode\n" +
  13955. //" ,gdd.groutinglineid\n" +
  13956. //" ,gdd.groutinglinecode\n" +
  13957. //" ,gdd.userid\n" +
  13958. //" ,gdd.usercode\n" +
  13959. " ,g.reserveddays) gdrd\n" +
  13960. " LEFT JOIN (SELECT gld.goodsid\n" +
  13961. //" ,gld.groutinglineid\n" +
  13962. " ,COUNT(*) gldcount\n" +
  13963. " FROM tp_pc_groutinglinedetail gld\n" +
  13964. " INNER JOIN tp_pc_groutingline gl\n" +
  13965. " ON gl.groutinglineid = gld.groutinglineid\n" +
  13966. " WHERE gld.valueflag = '1'\n" +
  13967. " AND gld.gmouldstatus = 1\n" +
  13968. " AND gl.accountid = :accountid\n" +
  13969. " AND gl.valueflag = '1'\n" +
  13970. " AND gl.gmouldstatus = 1\n" +
  13971. " GROUP BY gld.goodsid\n" +
  13972. //" ,gld.groutinglineid\n" +
  13973. " ) rdd\n" +
  13974. " ON rdd.goodsid = gdrd.goodsid\n" +
  13975. //" AND rdd.groutinglineid = gdrd.groutinglineid\n" +
  13976. " ORDER BY gdrd.goodscode\n" +
  13977. //" ,gdrd.groutinglinecode, gdrd.usercode"
  13978. "";
  13979. */
  13980. string sqlString =
  13981. "SELECT grouping_id(t.goodstypecode2, t.goodsid) gid\n" +
  13982. " ,t.goodstypecode2\n" +
  13983. " ,decode(grouping_id(t.goodstypecode2, t.goodsid),\n" +
  13984. " 3,\n" +
  13985. " '总计',\n" +
  13986. " 1,\n" +
  13987. " '合计[' || t.goodstypename2 || ']',\n" +
  13988. " t.goodstypename2) goodstypename2\n" +
  13989. " ,t.goodstypename\n" +
  13990. " ,t.goodsid\n" +
  13991. " ,t.goodscode\n" +
  13992. //" ,t.groutinglineid\n" +
  13993. //" ,t.groutinglinecode\n" +
  13994. //" ,t.userid\n" +
  13995. //" ,t.usercode\n" +
  13996. " ,SUM(t.rdcount) rdcount\n" +
  13997. " ,t.gldcount -- 模具数\n" +
  13998. " ,t.rddays -- 存坯天数\n" +
  13999. " ,t.reserveddays -- 应存天数\n" +
  14000. " ,SUM(t.ProfitNum) ProfitNum\n" +
  14001. " FROM (SELECT gt2.goodstypecode goodstypecode2\n" +
  14002. " ,gt2.goodstypename goodstypename2\n" +
  14003. " ,gdrd.goodsid\n" +
  14004. " ,gdrd.goodscode\n" +
  14005. " ,gdrd.goodstypename\n" +
  14006. //" ,gdrd.groutinglineid\n" +
  14007. //" ,gdrd.groutinglinecode\n" +
  14008. //" ,gdrd.userid\n" +
  14009. //" ,gdrd.usercode\n" +
  14010. " ,gdrd.gddc rdcount -- 存坯数\n" +
  14011. " ,rdd.gldcount -- 模具数\n" +
  14012. " , CASE\n" +
  14013. " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
  14014. " round(gdrd.gddc / rdd.gldcount, 2)\n" +
  14015. " ELSE\n" +
  14016. " NULL\n" +
  14017. " END rddays -- 存坯天数\n" +
  14018. " ,gdrd.reserveddays -- 应存天数\n" +
  14019. // 盈亏坯数 = 存坯数-应存天数*模具数 存坯天数 = 存坯数/模具数
  14020. " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
  14021. " FROM (SELECT gdd.goodsid\n" +
  14022. " ,gdd.goodscode\n" +
  14023. //" ,gdd.groutinglineid\n" +
  14024. //" ,gdd.groutinglinecode\n" +
  14025. //" ,gdd.userid\n" +
  14026. //" ,gdd.usercode\n" +
  14027. " ,g.reserveddays\n" +
  14028. " ,substr(gt.goodstypecode, 1, 6) goodstypecode2\n" +
  14029. " ,gt.goodstypename\n" +
  14030. " ,COUNT(*) gddc\n" +
  14031. " FROM tp_pm_groutingdailydetail gdd\n" +
  14032. " INNER JOIN tp_mst_goods g\n" +
  14033. " ON g.goodsid = gdd.goodsid\n" +
  14034. " INNER JOIN tp_mst_goodstype gt\n" +
  14035. " ON g.goodstypeid = gt.goodstypeid\n" +
  14036. " WHERE gdd.accountid = :accountid\n" +
  14037. " AND gdd.valueflag = '1'\n" +
  14038. " AND gdd.groutingflag = '1'\n" +
  14039. " AND gdd.barcode IS NOT NULL\n" +
  14040. " AND gdd.scrapflag = '0'\n" +
  14041. " AND gdd.deliverflag = '0'\n" +
  14042. " AND (:LineCode IS NULL OR\n" +
  14043. " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  14044. " AND (:UserCode IS NULL OR\n" +
  14045. " instr(gdd.UserCode, :UserCode) > 0)\n" +
  14046. " AND (:GoodsCode IS NULL OR\n" +
  14047. " instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  14048. " AND (:GoodsTypeCode IS NULL OR\n" +
  14049. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  14050. " AND (:DateBegin IS NULL OR\n" +
  14051. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
  14052. " GROUP BY gt.goodstypecode,gt.goodstypename\n" +
  14053. " ,gdd.goodsid\n" +
  14054. " ,gdd.goodscode\n" +
  14055. //" ,gdd.groutinglineid\n" +
  14056. //" ,gdd.groutinglinecode\n" +
  14057. //" ,gdd.userid\n" +
  14058. //" ,gdd.usercode\n" +
  14059. " ,g.reserveddays) gdrd\n" +
  14060. " LEFT JOIN (SELECT gld.goodsid\n" +
  14061. //" ,gld.groutinglineid\n" +
  14062. " ,COUNT(*) gldcount\n" +
  14063. " FROM tp_pc_groutinglinedetail gld\n" +
  14064. " INNER JOIN tp_pc_groutingline gl\n" +
  14065. " ON gl.groutinglineid = gld.groutinglineid\n" +
  14066. " WHERE gld.valueflag = '1'\n" +
  14067. " AND gld.gmouldstatus = 1\n" +
  14068. " AND gl.accountid = :accountid\n" +
  14069. " AND gl.valueflag = '1'\n" +
  14070. " AND gl.gmouldstatus = 1\n" +
  14071. " GROUP BY gld.goodsid\n" +
  14072. //" , gld.groutinglineid" +
  14073. " ) rdd\n" +
  14074. " ON rdd.goodsid = gdrd.goodsid\n" +
  14075. //" AND rdd.groutinglineid = gdrd.groutinglineid\n" +
  14076. " INNER JOIN tp_mst_goodstype gt2\n" +
  14077. " ON gt2.accountid = :accountid\n" +
  14078. " AND gt2.goodstypecode = gdrd.goodstypecode2\n" +
  14079. " ORDER BY gt2.goodstypecode\n" +
  14080. " ,gdrd.goodscode\n" +
  14081. //" ,gdrd.groutinglinecode\n" +
  14082. //" ,gdrd.usercode" +
  14083. " ) t\n" +
  14084. " GROUP BY GROUPING SETS((t.goodstypecode2, t.goodstypename2,t.goodstypename, t.goodsid, t.goodscode, t.gldcount, t.rddays, t.reserveddays),(t.goodstypecode2, t.goodstypename2),())";
  14085. OracleParameter[] oracleParameter = new OracleParameter[]
  14086. {
  14087. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14088. new OracleParameter(":DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  14089. new OracleParameter(":DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  14090. new OracleParameter(":GoodsTypeCode",OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  14091. new OracleParameter(":GoodsCode",OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  14092. new OracleParameter(":LineCode",OracleDbType.NVarchar2, cre.Properties["LineCode"], ParameterDirection.Input),
  14093. new OracleParameter(":UserCode",OracleDbType.NVarchar2, cre.Properties["UserCode"], ParameterDirection.Input),
  14094. };
  14095. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  14096. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14097. {
  14098. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14099. }
  14100. sre.Data = result;
  14101. return sre;
  14102. }
  14103. catch (Exception ex)
  14104. {
  14105. if (oracleConn.ConnState == ConnectionState.Open)
  14106. {
  14107. oracleConn.Close();
  14108. }
  14109. throw ex;
  14110. }
  14111. }
  14112. /// <summary>
  14113. /// 获取成型存坯汇总表-成型工号存坯汇总表
  14114. /// </summary>
  14115. /// <param name="cre"></param>
  14116. /// <param name="sUserInfo"></param>
  14117. /// <returns></returns>
  14118. public static ServiceResultEntity GetRPT030116UserData(ClientRequestEntity cre, SUserInfo sUserInfo)
  14119. {
  14120. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14121. try
  14122. {
  14123. ServiceResultEntity sre = new ServiceResultEntity();
  14124. /*
  14125. string sqlString =
  14126. "SELECT gdrd.goodsid\n" +
  14127. " ,gdrd.goodscode\n" +
  14128. " ,gdrd.groutinglineid\n" +
  14129. " ,gdrd.groutinglinecode\n" +
  14130. " ,gdrd.userid\n" +
  14131. " ,gdrd.usercode\n" +
  14132. " ,gdrd.gddc rdcount -- 存坯数\n" +
  14133. " ,rdd.gldcount -- 模具数\n" +
  14134. " , CASE\n" +
  14135. " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
  14136. " round(gdrd.gddc / rdd.gldcount, 2)\n" +
  14137. " ELSE\n" +
  14138. " NULL\n" +
  14139. " END rddays -- 存坯天数\n" +
  14140. " ,gdrd.reserveddays -- 应存天数\n" +
  14141. " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
  14142. " FROM (SELECT gdd.goodsid\n" +
  14143. " ,gdd.goodscode\n" +
  14144. " ,gdd.groutinglineid\n" +
  14145. " ,gdd.groutinglinecode\n" +
  14146. " ,gdd.userid\n" +
  14147. " ,gdd.usercode\n" +
  14148. " ,g.reserveddays\n" +
  14149. " ,COUNT(*) gddc\n" +
  14150. " FROM tp_pm_groutingdailydetail gdd\n" +
  14151. " INNER JOIN tp_mst_goods g\n" +
  14152. " ON g.goodsid = gdd.goodsid\n" +
  14153. " INNER JOIN tp_mst_goodstype gt\n" +
  14154. " ON g.goodstypeid = gt.goodstypeid\n" +
  14155. " WHERE gdd.accountid = :accountid\n" +
  14156. " AND gdd.valueflag = '1'\n" +
  14157. " AND gdd.groutingflag = '1'\n" +
  14158. " AND gdd.barcode IS NOT NULL\n" +
  14159. " AND gdd.scrapflag = '0'\n" +
  14160. " AND gdd.deliverflag = '0'\n" +
  14161. " AND (:LineCode IS NULL OR\n" +
  14162. " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  14163. " AND (:UserCode IS NULL OR instr(gdd.UserCode, :UserCode) > 0)\n" +
  14164. " AND (:GoodsCode IS NULL OR instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  14165. " AND (:GoodsTypeCode IS NULL OR\n" +
  14166. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  14167. " AND (:DateBegin IS NULL OR\n" +
  14168. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
  14169. " GROUP BY gdd.goodsid\n" +
  14170. " ,gdd.goodscode\n" +
  14171. " ,gdd.groutinglineid\n" +
  14172. " ,gdd.groutinglinecode\n" +
  14173. " ,gdd.userid\n" +
  14174. " ,gdd.usercode\n" +
  14175. " ,g.reserveddays) gdrd\n" +
  14176. " LEFT JOIN (SELECT gld.goodsid\n" +
  14177. " ,gld.groutinglineid\n" +
  14178. " ,COUNT(*) gldcount\n" +
  14179. " FROM tp_pc_groutinglinedetail gld\n" +
  14180. " INNER JOIN tp_pc_groutingline gl\n" +
  14181. " ON gl.groutinglineid = gld.groutinglineid\n" +
  14182. " WHERE gld.valueflag = '1'\n" +
  14183. " AND gld.gmouldstatus = 1\n" +
  14184. " AND gl.accountid = :accountid\n" +
  14185. " AND gl.valueflag = '1'\n" +
  14186. " AND gl.gmouldstatus = 1\n" +
  14187. " GROUP BY gld.goodsid\n" +
  14188. " ,gld.groutinglineid\n" +
  14189. " ) rdd\n" +
  14190. " ON rdd.goodsid = gdrd.goodsid\n" +
  14191. " AND rdd.groutinglineid = gdrd.groutinglineid\n" +
  14192. " ORDER BY gdrd.goodscode\n" +
  14193. " ,gdrd.groutinglinecode, gdrd.usercode" +
  14194. "";
  14195. */
  14196. string sqlString =
  14197. "SELECT grouping_id(t.goodstypecode2, t.goodsid) gid\n" +
  14198. " ,t.goodstypecode2\n" +
  14199. " ,decode(grouping_id(t.goodstypecode2, t.goodsid),\n" +
  14200. " 3,\n" +
  14201. " '总计',\n" +
  14202. " 1,\n" +
  14203. " '合计[' || t.goodstypename2 || ']',\n" +
  14204. " t.goodstypename2) goodstypename2\n" +
  14205. " ,t.goodsid\n" +
  14206. " ,t.goodscode\n" +
  14207. " ,t.groutinglineid\n" +
  14208. " ,t.groutinglinecode\n" +
  14209. " ,t.userid\n" +
  14210. " ,t.usercode\n" +
  14211. " ,t.MONITORName\n" +
  14212. " ,SUM(t.rdcount) rdcount\n" +
  14213. " ,t.gldcount -- 模具数\n" +
  14214. " ,t.rddays -- 存坯天数\n" +
  14215. " ,t.reserveddays -- 应存天数\n" +
  14216. " ,SUM(t.ProfitNum) ProfitNum\n" +
  14217. " FROM (SELECT gt2.goodstypecode goodstypecode2\n" +
  14218. " ,gt2.goodstypename goodstypename2\n" +
  14219. " ,gdrd.goodsid\n" +
  14220. " ,gdrd.goodscode\n" +
  14221. " ,gdrd.groutinglineid\n" +
  14222. " ,gdrd.groutinglinecode\n" +
  14223. " ,gdrd.userid\n" +
  14224. " ,gdrd.usercode\n" +
  14225. " ,mu.username MONITORName\n" +
  14226. " ,gdrd.gddc rdcount -- 存坯数\n" +
  14227. " ,rdd.gldcount -- 模具数\n" +
  14228. " , CASE\n" +
  14229. " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
  14230. " round(gdrd.gddc / rdd.gldcount, 2)\n" +
  14231. " ELSE\n" +
  14232. " NULL\n" +
  14233. " END rddays -- 存坯天数\n" +
  14234. " ,gdrd.reserveddays -- 应存天数\n" +
  14235. " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
  14236. " FROM (SELECT gdd.goodsid\n" +
  14237. " ,gdd.goodscode\n" +
  14238. " ,gdd.groutinglineid\n" +
  14239. " ,gdd.groutinglinecode\n" +
  14240. " ,gdd.userid\n" +
  14241. " ,gdd.usercode\n" +
  14242. " ,g.reserveddays\n" +
  14243. " ,substr(gt.goodstypecode, 1, 6) goodstypecode2\n" +
  14244. " ,COUNT(*) gddc\n" +
  14245. " FROM tp_pm_groutingdailydetail gdd\n" +
  14246. " INNER JOIN tp_mst_goods g\n" +
  14247. " ON g.goodsid = gdd.goodsid\n" +
  14248. " INNER JOIN tp_mst_goodstype gt\n" +
  14249. " ON g.goodstypeid = gt.goodstypeid\n" +
  14250. " WHERE gdd.accountid = :accountid\n" +
  14251. " AND gdd.valueflag = '1'\n" +
  14252. " AND gdd.groutingflag = '1'\n" +
  14253. " AND gdd.barcode IS NOT NULL\n" +
  14254. " AND gdd.scrapflag = '0'\n" +
  14255. " AND gdd.deliverflag = '0'\n" +
  14256. " AND (:LineCode IS NULL OR\n" +
  14257. " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  14258. " AND (:UserCode IS NULL OR\n" +
  14259. " instr(gdd.UserCode, :UserCode) > 0)\n" +
  14260. " AND (:GoodsCode IS NULL OR\n" +
  14261. " instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  14262. " AND (:GoodsTypeCode IS NULL OR\n" +
  14263. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  14264. " AND (:DateBegin IS NULL OR\n" +
  14265. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
  14266. " GROUP BY gt.goodstypecode\n" +
  14267. " ,gdd.goodsid\n" +
  14268. " ,gdd.goodscode\n" +
  14269. " ,gdd.groutinglineid\n" +
  14270. " ,gdd.groutinglinecode\n" +
  14271. " ,gdd.userid\n" +
  14272. " ,gdd.usercode\n" +
  14273. " ,g.reserveddays) gdrd\n" +
  14274. " LEFT JOIN (SELECT gld.goodsid\n" +
  14275. " ,gld.groutinglineid\n" +
  14276. " ,gl.MONITORID\n" +
  14277. " ,COUNT(*) gldcount\n" +
  14278. " FROM tp_pc_groutinglinedetail gld\n" +
  14279. " INNER JOIN tp_pc_groutingline gl\n" +
  14280. " ON gl.groutinglineid = gld.groutinglineid\n" +
  14281. " WHERE gld.valueflag = '1'\n" +
  14282. " AND gld.gmouldstatus = 1\n" +
  14283. " AND gl.accountid = :accountid\n" +
  14284. " AND gl.valueflag = '1'\n" +
  14285. " AND gl.gmouldstatus = 1\n" +
  14286. " GROUP BY gld.goodsid, gld.groutinglineid,gl.MONITORID) rdd\n" +
  14287. " ON rdd.goodsid = gdrd.goodsid\n" +
  14288. " AND rdd.groutinglineid = gdrd.groutinglineid\n" +
  14289. // 成型班长
  14290. " LEFT JOIN tp_mst_user mu\n" +
  14291. " ON mu.userid = rdd.MONITORID\n" +
  14292. " INNER JOIN tp_mst_goodstype gt2\n" +
  14293. " ON gt2.accountid = :accountid\n" +
  14294. " AND gt2.goodstypecode = gdrd.goodstypecode2\n" +
  14295. " ORDER BY gt2.goodstypecode\n" +
  14296. " ,gdrd.goodscode\n" +
  14297. " ,gdrd.groutinglinecode\n" +
  14298. " ,gdrd.usercode) t\n" +
  14299. " 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),())";
  14300. OracleParameter[] oracleParameter = new OracleParameter[]
  14301. {
  14302. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14303. new OracleParameter(":DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  14304. new OracleParameter(":DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  14305. new OracleParameter(":GoodsTypeCode",OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  14306. new OracleParameter(":GoodsCode",OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  14307. new OracleParameter(":LineCode",OracleDbType.NVarchar2, cre.Properties["LineCode"], ParameterDirection.Input),
  14308. new OracleParameter(":UserCode",OracleDbType.NVarchar2, cre.Properties["UserCode"], ParameterDirection.Input),
  14309. };
  14310. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  14311. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14312. {
  14313. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14314. }
  14315. sre.Data = result;
  14316. return sre;
  14317. }
  14318. catch (Exception ex)
  14319. {
  14320. if (oracleConn.ConnState == ConnectionState.Open)
  14321. {
  14322. oracleConn.Close();
  14323. }
  14324. throw ex;
  14325. }
  14326. }
  14327. /// <summary>
  14328. /// 获取成型存坯汇总表-成型存坯明细表
  14329. /// </summary>
  14330. /// <param name="cre"></param>
  14331. /// <param name="sUserInfo"></param>
  14332. /// <returns></returns>
  14333. public static ServiceResultEntity GetRPT030116DData(ClientRequestEntity cre, SUserInfo sUserInfo)
  14334. {
  14335. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14336. try
  14337. {
  14338. ServiceResultEntity sre = new ServiceResultEntity();
  14339. string sqlString = "SELECT gdd.barcode\n" +
  14340. //" ,gdd.groutinglineid\n" +
  14341. " ,gdd.groutinglinecode\n" +
  14342. " ,gdd.GroutingMouldCode\n" +
  14343. //" ,gdd.goodsid\n" +
  14344. " ,gdd.goodscode\n" +
  14345. //" ,gdd.userid\n" +
  14346. " ,gdd.usercode\n" +
  14347. " ,gdd.groutingdate\n" +
  14348. // 成型班长
  14349. " ,mu.username as MONITORName" +
  14350. " FROM tp_pm_groutingdailydetail gdd\n" +
  14351. " INNER JOIN tp_mst_goods g\n" +
  14352. " ON g.goodsid = gdd.goodsid\n" +
  14353. // 成型线
  14354. " LEFT JOIN tp_pc_groutingline gl" +
  14355. " ON gl.groutinglineid = GDD.GroutingLineID" +
  14356. // 成型班长
  14357. " LEFT JOIN tp_mst_user mu" +
  14358. " ON mu.userid = gl.MONITORID " +
  14359. " INNER JOIN tp_mst_goodstype gt\n" +
  14360. " ON g.goodstypeid = gt.goodstypeid\n" +
  14361. " WHERE gdd.accountid = :accountid\n" +
  14362. " AND gdd.valueflag = '1'\n" +
  14363. " AND gdd.groutingflag = '1'\n" +
  14364. " AND gdd.barcode IS NOT NULL\n" +
  14365. " AND gdd.scrapflag = '0'\n" +
  14366. " AND gdd.deliverflag = '0'\n" +
  14367. " AND (:LineID IS NULL OR gdd.groutinglineid = :LineID)\n" +
  14368. " AND (:UserID IS NULL OR gdd.UserID = :UserID)\n" +
  14369. " AND (:GoodsID IS NULL OR gdd.goodsid = :GoodsID)\n" +
  14370. " AND (:LineCode IS NULL OR instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  14371. " AND (:UserCode IS NULL OR instr(gdd.UserCode, :UserCode) > 0)\n" +
  14372. " AND (:GoodsCode IS NULL OR instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  14373. " AND (:GoodsTypeCode IS NULL OR\n" +
  14374. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  14375. " AND (:DateBegin IS NULL OR\n" +
  14376. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)" +
  14377. " ORDER BY gdd.barcode\n" +
  14378. //" ,gdd.goodscode, gdrd.groutinglinecode, gdrd.usercode" +
  14379. "";
  14380. OracleParameter[] oracleParameter = new OracleParameter[]
  14381. {
  14382. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14383. new OracleParameter(":DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  14384. new OracleParameter(":DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  14385. new OracleParameter(":GoodsTypeCode",OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  14386. new OracleParameter(":GoodsCode",OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  14387. new OracleParameter(":LineCode",OracleDbType.NVarchar2, cre.Properties["LineCode"], ParameterDirection.Input),
  14388. new OracleParameter(":UserCode",OracleDbType.NVarchar2, cre.Properties["UserCode"], ParameterDirection.Input),
  14389. new OracleParameter(":GoodsID",OracleDbType.Int32, cre.Properties["GoodsID"], ParameterDirection.Input),
  14390. new OracleParameter(":LineID",OracleDbType.Int32, cre.Properties["LineID"], ParameterDirection.Input),
  14391. new OracleParameter(":UserID",OracleDbType.Int32, cre.Properties["UserID"], ParameterDirection.Input),
  14392. };
  14393. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  14394. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14395. {
  14396. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14397. }
  14398. sre.Data = result;
  14399. return sre;
  14400. }
  14401. catch (Exception ex)
  14402. {
  14403. if (oracleConn.ConnState == ConnectionState.Open)
  14404. {
  14405. oracleConn.Close();
  14406. }
  14407. throw ex;
  14408. }
  14409. }
  14410. /// <summary>
  14411. /// 年度各工序月产量统计表
  14412. /// </summary>
  14413. /// <param name="cre"></param>
  14414. /// <param name="sUserInfo"></param>
  14415. /// <returns></returns>
  14416. public static ServiceResultEntity GetRPT030118Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14417. {
  14418. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14419. try
  14420. {
  14421. ServiceResultEntity sre = new ServiceResultEntity();
  14422. string sump = INIUtility.Read("ReportParameters", "RPT_030118", AppDomain.CurrentDomain.BaseDirectory + "Config.ini");
  14423. string sqlString = "select gt2.goodstypecode\n" +
  14424. " ,nvl2(gt2.goodstypename\n" +
  14425. " ,nvl2(t.procedureid\n" +
  14426. " ,gt2.goodstypename\n" +
  14427. " ,'小计[' || gt2.goodstypename || ']')\n" +
  14428. " ,'总计') goodstypename\n" +
  14429. " ,p.displayno\n" +
  14430. " ,decode(t.procedureid, null, '--', 0, '注浆', p.procedurename) procedurename\n" +
  14431. " ,sum(decode(t.mm, '12', t.pcount, 0)) m12\n" +
  14432. " ,sum(decode(t.mm, '01', t.pcount, 0)) m01\n" +
  14433. " ,sum(decode(t.mm, '02', t.pcount, 0)) m02\n" +
  14434. " ,sum(decode(t.mm, '03', t.pcount, 0)) m03\n" +
  14435. " ,sum(decode(t.mm, '04', t.pcount, 0)) m04\n" +
  14436. " ,sum(decode(t.mm, '05', t.pcount, 0)) m05\n" +
  14437. " ,sum(decode(t.mm, '06', t.pcount, 0)) m06\n" +
  14438. " ,sum(decode(t.mm, '07', t.pcount, 0)) m07\n" +
  14439. " ,sum(decode(t.mm, '08', t.pcount, 0)) m08\n" +
  14440. " ,sum(decode(t.mm, '09', t.pcount, 0)) m09\n" +
  14441. " ,sum(decode(t.mm, '10', t.pcount, 0)) m10\n" +
  14442. " ,sum(decode(t.mm, '11', t.pcount, 0)) m11\n" +
  14443. " ,sum(t.pcount) msum\n" +
  14444. " from (select --substr(gt.goodstypecode, 1, 6) gtcode2\n" +
  14445. " gt.goodstypecode\n" +
  14446. " ,0 procedureid\n" +
  14447. " ,to_char(pd.groutingdate, 'mm') mm\n" +
  14448. " ,count(*) pcount\n" +
  14449. " from tp_pm_groutingdailydetail pd\n" +
  14450. " inner join tp_mst_goods g\n" +
  14451. " on g.goodsid = pd.goodsid\n" +
  14452. " inner join tp_mst_goodstype gt\n" +
  14453. " on gt.goodstypeid = g.goodstypeid\n" +
  14454. " where pd.accountid = :accountid\n" +
  14455. " and pd.groutingflag = '1'\n" +
  14456. " and pd.groutingdate >= :begindate\n" +
  14457. " and pd.groutingdate < :enddate\n" +
  14458. " group by --substr(gt.goodstypecode, 1, 6)\n" +
  14459. " gt.goodstypecode\n" +
  14460. " ,to_char(pd.groutingdate, 'mm')\n" +
  14461. " union all\n" +
  14462. " select --substr(gt.goodstypecode, 1, 6) gtcode2\n" +
  14463. " gt.goodstypecode\n" +
  14464. " ,pd.procedureid\n" +
  14465. " ,to_char(pd.createtime, 'mm') mm\n" +
  14466. " ,count(*) pcount\n" +
  14467. " from tp_pm_productiondata pd\n" +
  14468. " inner join tp_mst_goods g\n" +
  14469. " on g.goodsid = pd.goodsid\n" +
  14470. " inner join tp_mst_goodstype gt\n" +
  14471. " on gt.goodstypeid = g.goodstypeid\n" +
  14472. " where pd.accountid = :accountid\n" +
  14473. " and pd.createtime >= :begindate\n" +
  14474. " and pd.createtime < :enddate\n" +
  14475. (string.IsNullOrWhiteSpace(sump) ? "" : " and pd.procedureid in (" + sump + ")\n") +
  14476. " group by --substr(gt.goodstypecode, 1, 6)\n" +
  14477. " gt.goodstypecode\n" +
  14478. " ,pd.procedureid\n" +
  14479. " ,to_char(pd.createtime, 'mm')" +
  14480. " union all\n" +
  14481. " select --substr(gt.goodstypecode, 1, 6) gtcode2\n" +
  14482. " gt.goodstypecode\n" +
  14483. " ,pd.procedureid\n" +
  14484. " ,to_char(pd.BACKOUTTIME, 'mm') mm\n" +
  14485. " ,count(*) pcount\n" +
  14486. " from tp_pm_productiondata pd\n" +
  14487. " inner join tp_mst_goods g\n" +
  14488. " on g.goodsid = pd.goodsid\n" +
  14489. " inner join tp_mst_goodstype gt\n" +
  14490. " on gt.goodstypeid = g.goodstypeid\n" +
  14491. " where pd.accountid = :accountid\n" +
  14492. " and pd.valueflag = '0'\n" +
  14493. " and pd.BACKOUTTIME >= :begindate\n" +
  14494. " and pd.BACKOUTTIME < :enddate\n" +
  14495. (string.IsNullOrWhiteSpace(sump) ? "" : " and pd.procedureid in (" + sump + ")\n") +
  14496. " group by --substr(gt.goodstypecode, 1, 6)\n" +
  14497. " gt.goodstypecode\n" +
  14498. " ,pd.procedureid\n" +
  14499. " ,to_char(pd.BACKOUTTIME, 'mm')) t\n" +
  14500. " inner join tp_mst_goodstype gt2\n" +
  14501. " on gt2.accountid = 1\n" +
  14502. " and gt2.goodstypecode = substr(t.goodstypecode, 1, 6) --t.gtcode2\n" +
  14503. " left join tp_pc_procedure p\n" +
  14504. " on p.procedureid = t.procedureid\n" +
  14505. " group by grouping sets((gt2.goodstypecode, gt2.goodstypename, p.displayno, p.procedurename, t.procedureid),(gt2.goodstypecode, gt2.goodstypename),())";
  14506. OracleParameter[] oracleParameter = new OracleParameter[]
  14507. {
  14508. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14509. new OracleParameter(":begindate",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  14510. new OracleParameter(":enddate",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  14511. };
  14512. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  14513. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14514. {
  14515. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14516. }
  14517. sre.Data = result;
  14518. return sre;
  14519. }
  14520. catch (Exception ex)
  14521. {
  14522. throw ex;
  14523. }
  14524. finally
  14525. {
  14526. oracleConn?.Close();
  14527. }
  14528. }
  14529. /// <summary>
  14530. /// 半检返修缺陷汇总表
  14531. /// </summary>
  14532. /// <param name="cre"></param>
  14533. /// <param name="sUserInfo"></param>
  14534. /// <returns></returns>
  14535. public static ServiceResultEntity GetRPT030119Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14536. {
  14537. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14538. try
  14539. {
  14540. ServiceResultEntity sre = new ServiceResultEntity();
  14541. string sqlString = "select dp.defectpositionid\n" +
  14542. " ,dp.defectpositioncode\n" +
  14543. " ,dp.defectpositionname\n" +
  14544. " ,'D_' || dp.defectpositionid colname\n" +
  14545. " from tp_mst_scdefectposition dp\n" +
  14546. " where dp.valueflag = '1'\n" +
  14547. " and dp.accountid = " + sUserInfo.AccountID + "\n";
  14548. if (!string.IsNullOrWhiteSpace(cre.Properties["defectpositionIDS"] + ""))
  14549. {
  14550. sqlString += " and instr(','||'"+ cre.Properties["defectpositionIDS"] + "'||',', ','||dp.defectpositionid||',') > 0 \n";
  14551. }
  14552. sqlString += " order by dp.displayno";
  14553. DataTable scdTable = oracleConn.GetSqlResultToDt(sqlString);
  14554. if (scdTable == null || scdTable.Rows.Count == 0)
  14555. {
  14556. return sre;
  14557. }
  14558. List<string> pivotFor = new List<string>();
  14559. foreach (DataRow item in scdTable.Rows)
  14560. {
  14561. pivotFor.Add($"{item["defectpositionid"]} as {item["colname"]}");
  14562. }
  14563. List<OracleParameter> oracleParameters = new List<OracleParameter>();
  14564. oracleParameters.Add(new OracleParameter(":accountid", sUserInfo.AccountID));
  14565. sqlString = "select *\n" +
  14566. " from (select srd.defectid\n" +
  14567. " ,scd.defectcode\n" +
  14568. " ,scd.defectname\n" +
  14569. " ,nvl(srd.defectpositionid, 0) defectpositionid\n" +
  14570. " ,count(srd.semireworkdefectid) cc\n" +
  14571. " from TP_PM_SEMIREWORKDEFECT srd\n" +
  14572. " inner join TP_PM_SEMIREWORK sr\n" +
  14573. " on sr.SEMIREWORKID = srd.SEMIREWORKID\n" +
  14574. " left join tp_mst_semicheckdefect scd\n" +
  14575. " on scd.defectid = srd.defectid\n" +
  14576. " left join tp_mst_scdefectposition scdp\n" +
  14577. " on scdp.defectpositionid = srd.defectpositionid\n" +
  14578. " left join TP_MST_GOODS g on g.GOODSID = sr.GOODSID\n" + //xuwei add 2019-11-29
  14579. " left join TP_MST_GOODSTYPE gt on g.GOODSTYPEID = gt.GOODSTYPEID\n" + //xuwei add 2019-11-29
  14580. " where srd.valueflag = '1'\n" +
  14581. " and sr.BACKOUTFLAG = '0'\n" +
  14582. " and sr.valueflag = '1'\n" +
  14583. " and sr.accountid = :accountid\n";
  14584. // 半检日期
  14585. if (cre.Properties["SemireWorkTimeBegin"] != null)
  14586. {
  14587. sqlString += " and sr.SEMIREWORKTIME >= :SemireWorkTimeBegin\n";
  14588. oracleParameters.Add(new OracleParameter(":SemireWorkTimeBegin", cre.Properties["SemireWorkTimeBegin"]));
  14589. }
  14590. if (cre.Properties["SemireWorkTimeEnd"] != null)
  14591. {
  14592. sqlString += " and sr.SEMIREWORKTIME < :SemireWorkTimeEnd\n";
  14593. oracleParameters.Add(new OracleParameter(":SemireWorkTimeEnd", cre.Properties["SemireWorkTimeEnd"]));
  14594. }
  14595. // 产品编码 GOODSCODE
  14596. if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSCODE"]+""))
  14597. {
  14598. sqlString += " and instr(','||:GOODSCODE||',' , ','||sr.GOODSCODE||',') > 0 \n";
  14599. oracleParameters.Add(new OracleParameter(":GOODSCODE", cre.Properties["GOODSCODE"]));
  14600. }
  14601. // 成型工号 GROUTINGUSERCODE
  14602. if (!string.IsNullOrWhiteSpace(cre.Properties["GROUTINGUSERCODE"] + ""))
  14603. {
  14604. //xuwei modify 2019-11-13
  14605. //sqlString += " and instr(sr.GROUTINGUSERCODE,:GROUTINGUSERCODE) > 0 \n";
  14606. sqlString += " and instr(','||:GROUTINGUSERCODE||',' , ','||sr.GROUTINGUSERCODE||',') > 0 \n";
  14607. //xuwei end
  14608. oracleParameters.Add(new OracleParameter(":GROUTINGUSERCODE", cre.Properties["GROUTINGUSERCODE"]));
  14609. }
  14610. // 半检工号 SEMIREWORKUSERCODE
  14611. if (!string.IsNullOrWhiteSpace(cre.Properties["SEMIREWORKUSERCODE"] + ""))
  14612. {
  14613. //xuwei modify 2019-11-13
  14614. //sqlString += " and instr(sr.SEMIREWORKUSERCODE,:SEMIREWORKUSERCODE) > 0 \n";
  14615. sqlString += " and instr(','||:SEMIREWORKUSERCODE||',' , ','||sr.SEMIREWORKUSERCODE||',') > 0 \n";
  14616. //xuwei end
  14617. oracleParameters.Add(new OracleParameter(":SEMIREWORKUSERCODE", cre.Properties["SEMIREWORKUSERCODE"]));
  14618. }
  14619. // 缺陷位置 scdp.defectpositionname
  14620. if (!string.IsNullOrWhiteSpace(cre.Properties["defectpositionname"] + ""))
  14621. {
  14622. sqlString += " and instr(scdp.defectpositionname,:defectpositionname) > 0 \n";
  14623. oracleParameters.Add(new OracleParameter(":defectpositionname", cre.Properties["defectpositionname"]));
  14624. }
  14625. if (!string.IsNullOrWhiteSpace(cre.Properties["defectpositionIDS"] + ""))
  14626. {
  14627. sqlString += " and instr(','||:defectpositionIDS||',', ','||srd.defectpositionid||',') > 0 \n";
  14628. oracleParameters.Add(new OracleParameter(":defectpositionIDS", cre.Properties["defectpositionIDS"]));
  14629. }
  14630. // 缺陷名称 scd.defectname
  14631. if (!string.IsNullOrWhiteSpace(cre.Properties["defectname"] + ""))
  14632. {
  14633. sqlString += " and instr(scd.defectname,:defectname) > 0 \n";
  14634. oracleParameters.Add(new OracleParameter(":defectname", cre.Properties["defectname"]));
  14635. }
  14636. // 缺陷编码 scd.defectcode
  14637. if (!string.IsNullOrWhiteSpace(cre.Properties["defectcode"] + ""))
  14638. {
  14639. sqlString += " and scd.defectcode = :defectcode \n";
  14640. oracleParameters.Add(new OracleParameter(":defectcode", cre.Properties["defectcode"]));
  14641. }
  14642. //产品类别ID xuwei add 2019-11-29 g.GOODSTYPEID
  14643. if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSTYPEID"] + ""))
  14644. {
  14645. sqlString += " and instr(','||:GOODSTYPEID||',' , ','||g.GOODSTYPEID||',') > 0 \n";
  14646. oracleParameters.Add(new OracleParameter(":GOODSTYPEID", cre.Properties["GOODSTYPEID"]));
  14647. }
  14648. //产品类别Code xuwei add 2019-11-29 g.GOODSTYPECODE
  14649. if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSTYPECODE"] + ""))
  14650. {
  14651. sqlString += " and instr(gt.GOODSTYPECODE , :GOODSTYPECODE) = 1 \n";
  14652. oracleParameters.Add(new OracleParameter(":GOODSTYPECODE", cre.Properties["GOODSTYPECODE"]));
  14653. }
  14654. //返修工序 xuwei add 2019-11-29 sr.REWORKPROCEDUREID
  14655. if (!string.IsNullOrWhiteSpace(cre.Properties["REWORKPROCEDUREID"] + ""))
  14656. {
  14657. sqlString += " and instr(','||:REWORKPROCEDUREID||',' , ','||sr.REWORKPROCEDUREID||',') > 0 \n";
  14658. oracleParameters.Add(new OracleParameter(":REWORKPROCEDUREID", cre.Properties["REWORKPROCEDUREID"]));
  14659. }
  14660. sqlString +=
  14661. " group by grouping sets((srd.defectid, scd.defectcode, scd.defectname, srd.defectpositionid),(srd.defectid, scd.defectcode, scd.defectname),(srd.defectpositionid),())) t\n" +
  14662. "pivot(sum(cc)\n" +
  14663. " for defectpositionid in("+string.Join(",", pivotFor) + ", 0 AS D_0))\n" +
  14664. " order by defectid";
  14665. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameters.ToArray());
  14666. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14667. {
  14668. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14669. return sre;
  14670. }
  14671. DataTable table = result.Tables[0];
  14672. DataRow dataRow = table.Rows[table.Rows.Count - 1];
  14673. dataRow["defectname"] = "合计";
  14674. foreach (DataRow item in scdTable.Rows)
  14675. {
  14676. string colname = item["colname"] + "";
  14677. if (table.Columns.Contains(colname))
  14678. {
  14679. if (dataRow[colname] == null || dataRow[colname] == DBNull.Value)
  14680. {
  14681. table.Columns.Remove(colname);
  14682. }
  14683. else
  14684. {
  14685. table.Columns[colname].Caption = item["defectpositionname"] + "";
  14686. }
  14687. }
  14688. }
  14689. table.Columns["D_0"].Caption = "合计";
  14690. sre.Data = result;
  14691. return sre;
  14692. }
  14693. catch (Exception ex)
  14694. {
  14695. throw ex;
  14696. }
  14697. finally
  14698. {
  14699. oracleConn?.Close();
  14700. }
  14701. }
  14702. /// <summary>
  14703. /// 模具注浆分析表
  14704. /// </summary>
  14705. /// <param name="cre"></param>
  14706. /// <param name="sUserInfo"></param>
  14707. /// <returns></returns>
  14708. public static ServiceResultEntity GetRPT040111Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14709. {
  14710. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  14711. try
  14712. {
  14713. ServiceResultEntity sre = new ServiceResultEntity();
  14714. OracleParameter[] oracleParameter = new OracleParameter[]
  14715. {
  14716. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14717. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["GroutingDateBegin"], ParameterDirection.Input),
  14718. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["GroutingDateEnd"], ParameterDirection.Input),
  14719. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  14720. new OracleParameter("in_MouldBarcode",OracleDbType.Varchar2, cre.Properties["MouldBarcode"], ParameterDirection.Input),
  14721. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  14722. };
  14723. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_Mould_Groutingnum_AN", oracleParameter);
  14724. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14725. {
  14726. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14727. }
  14728. sre.Data = result;
  14729. oracleConn.Commit();
  14730. return sre;
  14731. }
  14732. catch (Exception ex)
  14733. {
  14734. if (oracleConn.ConnState == ConnectionState.Open)
  14735. {
  14736. oracleConn.Disconnect();
  14737. }
  14738. throw ex;
  14739. }
  14740. }
  14741. /// <summary>
  14742. /// 成检产品预算分析表
  14743. /// </summary>
  14744. /// <param name="cre"></param>
  14745. /// <param name="sUserInfo"></param>
  14746. /// <returns></returns>
  14747. public static ServiceResultEntity GetRPT040112Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14748. {
  14749. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  14750. try
  14751. {
  14752. ServiceResultEntity sre = new ServiceResultEntity();
  14753. OracleParameter[] oracleParameter = new OracleParameter[]
  14754. {
  14755. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14756. new OracleParameter("in_InTimeBegin",OracleDbType.Date, cre.Properties["InTimeBegin"], ParameterDirection.Input),
  14757. new OracleParameter("in_InTimeEnd",OracleDbType.Date, cre.Properties["InTimeEnd"], ParameterDirection.Input),
  14758. new OracleParameter("in_OutTimeBegin",OracleDbType.Date, cre.Properties["OutTimeBegin"], ParameterDirection.Input),
  14759. new OracleParameter("in_OutTimeEnd",OracleDbType.Date, cre.Properties["OutTimeEnd"], ParameterDirection.Input),
  14760. new OracleParameter("in_KilnID",OracleDbType.Int32, cre.Properties["KilnID"], ParameterDirection.Input),
  14761. new OracleParameter("in_KilnCarNumBegin",OracleDbType.Int32, cre.Properties["KilnCarNumBegin"], ParameterDirection.Input),
  14762. new OracleParameter("in_KilnCarNumEnd",OracleDbType.Int32, cre.Properties["KilnCarNumEnd"], ParameterDirection.Input),
  14763. new OracleParameter("out_KilnInfo",OracleDbType.RefCursor, null, ParameterDirection.Output),
  14764. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  14765. };
  14766. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_ExpectFinishedProduct", oracleParameter);
  14767. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14768. {
  14769. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14770. }
  14771. sre.Data = result;
  14772. oracleConn.Commit();
  14773. return sre;
  14774. }
  14775. catch (Exception ex)
  14776. {
  14777. if (oracleConn.ConnState == ConnectionState.Open)
  14778. {
  14779. oracleConn.Disconnect();
  14780. }
  14781. throw ex;
  14782. }
  14783. }
  14784. /// <summary>
  14785. /// 成检产品预算分析表-设置
  14786. /// </summary>
  14787. /// <param name="cre"></param>
  14788. /// <param name="sUserInfo"></param>
  14789. /// <returns></returns>
  14790. public static ServiceResultEntity GetRPT04011201Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14791. {
  14792. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14793. try
  14794. {
  14795. ServiceResultEntity sre = new ServiceResultEntity();
  14796. string sqlString = "SELECT s.settingkey, s.procedureid, p.procedurecode, p.procedurename\n" +
  14797. " FROM tp_qco_prosetting s\n" +
  14798. " LEFT JOIN tp_pc_procedure p\n" +
  14799. " ON s.procedureid = p.procedureid\n" +
  14800. " WHERE s.accountid = :accountid";
  14801. OracleParameter[] oracleParameter = new OracleParameter[]
  14802. {
  14803. new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14804. };
  14805. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  14806. sqlString = "SELECT k.kilnid, k.kilncode, k.kilnname, k.turnoverinterval\n" +
  14807. " FROM tp_mst_kiln k\n" +
  14808. " WHERE k.accountid = :accountid\n" +
  14809. " AND k.valueflag = '1'";
  14810. DataTable dt = oracleConn.GetSqlResultToDt(sqlString, oracleParameter);
  14811. result.Tables.Add(dt);
  14812. sre.Data = result;
  14813. return sre;
  14814. }
  14815. catch (Exception ex)
  14816. {
  14817. if (oracleConn.ConnState == ConnectionState.Open)
  14818. {
  14819. oracleConn.Close();
  14820. }
  14821. throw ex;
  14822. }
  14823. }
  14824. /// <summary>
  14825. /// 成检产品预算分析表-设置
  14826. /// </summary>
  14827. /// <param name="cre"></param>
  14828. /// <param name="sUserInfo"></param>
  14829. /// <returns></returns>
  14830. public static ServiceResultEntity SetRPT04011201Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14831. {
  14832. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  14833. try
  14834. {
  14835. ServiceResultEntity sre = new ServiceResultEntity();
  14836. OracleParameter[] oracleParameter = null;
  14837. string sql = "update tp_qco_prosetting s set s.procedureid=:procedureid, s.procedurecode=:procedurecode\n" +
  14838. "where s.accountid=:accountid and s.settingkey=:settingkey";
  14839. foreach (DataRow item in cre.Data.Tables[0].Rows)
  14840. {
  14841. oracleParameter = new OracleParameter[]
  14842. {
  14843. new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14844. new OracleParameter("procedureid",OracleDbType.Int32, item["procedureid"], ParameterDirection.Input),
  14845. new OracleParameter("procedurecode",OracleDbType.NVarchar2, item["procedurecode"], ParameterDirection.Input),
  14846. new OracleParameter("settingkey",OracleDbType.NVarchar2, item["settingkey"], ParameterDirection.Input),
  14847. };
  14848. oracleConn.ExecuteNonQuery(sql, oracleParameter);
  14849. }
  14850. sql = "update tp_mst_kiln k set k.turnoverinterval=:turnoverinterval\n" +
  14851. "where k.accountid=:accountid and k.kilnid=:kilnid";
  14852. foreach (DataRow item in cre.Data.Tables[1].Rows)
  14853. {
  14854. oracleParameter = new OracleParameter[]
  14855. {
  14856. new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14857. new OracleParameter("turnoverinterval",OracleDbType.Int32, item["turnoverinterval"], ParameterDirection.Input),
  14858. new OracleParameter("kilnid",OracleDbType.Int32, item["kilnid"], ParameterDirection.Input),
  14859. };
  14860. oracleConn.ExecuteNonQuery(sql, oracleParameter);
  14861. }
  14862. oracleConn.Commit();
  14863. return sre;
  14864. }
  14865. catch (Exception ex)
  14866. {
  14867. if (oracleConn.ConnState == ConnectionState.Open)
  14868. {
  14869. oracleConn.Disconnect();
  14870. }
  14871. throw ex;
  14872. }
  14873. }
  14874. /// <summary>
  14875. /// 各工序质量表-恒洁三水
  14876. /// </summary>
  14877. /// <param name="cre"></param>
  14878. /// <param name="sUserInfo"></param>
  14879. /// <returns></returns>
  14880. public static ServiceResultEntity GetRPT040113Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14881. {
  14882. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14883. try
  14884. {
  14885. int p1ID = 11; // 成检交接工序
  14886. int p2ID = 12; // 成检登记工序
  14887. string gtcode2 = cre.Properties["gtcode2"] + "";
  14888. if (gtcode2 != "001001" && gtcode2 != "001002")
  14889. {
  14890. gtcode2 = "[ALL]";
  14891. }
  14892. // DEFECTDEDUCTIONNUM 缺陷扣除数 1,2,5
  14893. // goodsleveltypeid 次品 7
  14894. string sqlString = "select t.*\n" +
  14895. " ,gt.goodstypename\n" +
  14896. " ,nvl(outk.outkcount, 0) outkcount\n" +
  14897. " ,nvl(outk.outkcount, 0) - t.defectcount cc\n" +
  14898. " ,decode(nvl(outk.outkcount, 0)\n" +
  14899. " ,0\n" +
  14900. " ,to_number(null)\n" +
  14901. " ,round((nvl(outk.outkcount, 0) - t.defectcount) /\n" +
  14902. " nvl(outk.outkcount, 0)\n" +
  14903. " ,4)) ccp\n" +
  14904. " from (select 10 pcode\n" +
  14905. " ,'成型' pname\n" +
  14906. " ,gt2.goodstypecode gtcode2\n" +
  14907. " ,count(*) defectcount\n" +
  14908. " from tp_pm_defect dd\n" +
  14909. " inner join tp_pm_productiondata pd\n" +
  14910. " on dd.productiondataid = pd.productiondataid\n" +
  14911. " inner join tp_mst_goods g\n" +
  14912. " on dd.goodsid = g.goodsid\n" +
  14913. " inner join tp_mst_goodstype gt\n" +
  14914. " on gt.goodstypeid = g.goodstypeid\n" +
  14915. " inner join tp_mst_goodstype gt2\n" +
  14916. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14917. " where dd.valueflag = '1'\n" +
  14918. " and dd.accountid = :accountid\n" +
  14919. " and pd.goodsleveltypeid = 7\n" + // 次品
  14920. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14921. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14922. " and dd.procedureid = :p2ID\n" +
  14923. " and dd.checktime >= :timebegin\n" +
  14924. " and dd.checktime < :timeend\n" +
  14925. ////" -- 交坯、干补\n" +
  14926. //" and dd.defectprocedureid in (1, 17, 18)\n" +
  14927. " 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" +
  14928. " 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" +
  14929. " )\n" +
  14930. " group by gt2.goodstypecode\n" +
  14931. " union all\n" +
  14932. " select 20 pcode\n" +
  14933. " ,'改洗' pname\n" +
  14934. " ,gt2.goodstypecode gtcode2\n" +
  14935. " ,count(*) defectcount\n" +
  14936. " from tp_pm_defect dd\n" +
  14937. " inner join tp_pm_productiondata pd\n" +
  14938. " on dd.productiondataid = pd.productiondataid\n" +
  14939. " inner join tp_mst_goods g\n" +
  14940. " on dd.goodsid = g.goodsid\n" +
  14941. " inner join tp_mst_goodstype gt\n" +
  14942. " on gt.goodstypeid = g.goodstypeid\n" +
  14943. " inner join tp_mst_goodstype gt2\n" +
  14944. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14945. " where dd.valueflag = '1'\n" +
  14946. " and dd.accountid = :accountid\n" +
  14947. " and pd.goodsleveltypeid = 7\n" + // 次品
  14948. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14949. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14950. " and dd.procedureid = :p2ID\n" +
  14951. " and dd.checktime >= :timebegin\n" +
  14952. " and dd.checktime < :timeend\n" +
  14953. ////" -- 改洗、吹风\n" +
  14954. //" and dd.defectprocedureid in (2, 62)\n" +
  14955. ////" -- 除不平\n" +
  14956. //" and dd.defectid not in (91, 240)\n" +
  14957. " and ((gt2.goodstypecode='001001' and dd.defectid in (91,94,144,113,145,114,183))\n" +
  14958. " or (gt2.goodstypecode='001002' and dd.defectid in (91,93,94,144,113,145,114))\n" +
  14959. " )\n" +
  14960. " group by gt2.goodstypecode\n" +
  14961. " union all\n" +
  14962. " select 30 pcode\n" +
  14963. " ,'二检' pname\n" +
  14964. " ,gt2.goodstypecode gtcode2\n" +
  14965. " ,count(*) defectcount\n" +
  14966. " from tp_pm_defect dd\n" +
  14967. " inner join tp_pm_productiondata pd\n" +
  14968. " on dd.productiondataid = pd.productiondataid\n" +
  14969. " inner join tp_mst_goods g\n" +
  14970. " on dd.goodsid = g.goodsid\n" +
  14971. " inner join tp_mst_goodstype gt\n" +
  14972. " on gt.goodstypeid = g.goodstypeid\n" +
  14973. " inner join tp_mst_goodstype gt2\n" +
  14974. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14975. " where dd.valueflag = '1'\n" +
  14976. " and dd.accountid = :accountid\n" +
  14977. " and pd.goodsleveltypeid = 7\n" + // 次品
  14978. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14979. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14980. " and dd.procedureid = :p2ID\n" +
  14981. " and dd.checktime >= :timebegin\n" +
  14982. " and dd.checktime < :timeend\n" +
  14983. ////" -- 二检\n" +
  14984. //" and dd.defectprocedureid in (61)\n" +
  14985. " and ((gt2.goodstypecode='001001' and dd.defectid in (89,91,92,93,94,106,115,163,159,133,166,164))\n" +
  14986. " or (gt2.goodstypecode='001002' and dd.defectid in (89,91,92,93,94,106,115,163,133,192,166,164))\n" +
  14987. " )\n" +
  14988. " group by gt2.goodstypecode\n" +
  14989. " union all\n" +
  14990. " select 40 pcode\n" +
  14991. " ,'施釉' pname\n" +
  14992. " ,gt2.goodstypecode gtcode2\n" +
  14993. " ,count(*) defectcount\n" +
  14994. " from tp_pm_defect dd\n" +
  14995. " inner join tp_pm_productiondata pd\n" +
  14996. " on dd.productiondataid = pd.productiondataid\n" +
  14997. " inner join tp_mst_goods g\n" +
  14998. " on dd.goodsid = g.goodsid\n" +
  14999. " inner join tp_mst_goodstype gt\n" +
  15000. " on gt.goodstypeid = g.goodstypeid\n" +
  15001. " inner join tp_mst_goodstype gt2\n" +
  15002. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  15003. " where dd.valueflag = '1'\n" +
  15004. " and dd.accountid = :accountid\n" +
  15005. " and pd.goodsleveltypeid = 7\n" + // 次品
  15006. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  15007. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  15008. " and dd.procedureid = :p2ID\n" +
  15009. " and dd.checktime >= :timebegin\n" +
  15010. " and dd.checktime < :timeend\n" +
  15011. ////" -- 施釉\n" +
  15012. //" and dd.defectprocedureid in (3, 4)\n" +
  15013. ////" -- 除铁、铜脏\n" +
  15014. //" and dd.defectid not in (827, 829, 398, 399, 830, 400)\n" +
  15015. " 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" +
  15016. " 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" +
  15017. " )\n" +
  15018. " group by gt2.goodstypecode\n" +
  15019. " union all\n" +
  15020. " select 50 pcode\n" +
  15021. " ,'刮登' pname\n" +
  15022. " ,gt2.goodstypecode gtcode2\n" +
  15023. " ,count(*) defectcount\n" +
  15024. " from tp_pm_defect dd\n" +
  15025. " inner join tp_pm_productiondata pd\n" +
  15026. " on dd.productiondataid = pd.productiondataid\n" +
  15027. " inner join tp_mst_goods g\n" +
  15028. " on dd.goodsid = g.goodsid\n" +
  15029. " inner join tp_mst_goodstype gt\n" +
  15030. " on gt.goodstypeid = g.goodstypeid\n" +
  15031. " inner join tp_mst_goodstype gt2\n" +
  15032. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  15033. " where dd.valueflag = '1'\n" +
  15034. " and dd.accountid = :accountid\n" +
  15035. " and pd.goodsleveltypeid = 7\n" + // 次品
  15036. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  15037. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  15038. " and dd.procedureid = :p2ID\n" +
  15039. " and dd.checktime >= :timebegin\n" +
  15040. " and dd.checktime < :timeend\n" +
  15041. ////" -- 登窑、入窑、卸窑\n" +
  15042. //" and dd.defectprocedureid in (5, 9, 10)\n" +
  15043. " 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" +
  15044. " 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" +
  15045. " )\n" +
  15046. " group by gt2.goodstypecode\n" +
  15047. " union all\n" +
  15048. " select 60 pcode\n" +
  15049. " ,'烧成' pname\n" +
  15050. " ,gt2.goodstypecode gtcode2\n" +
  15051. " ,count(*) defectcount\n" +
  15052. " from tp_pm_defect dd\n" +
  15053. " inner join tp_pm_productiondata pd\n" +
  15054. " on dd.productiondataid = pd.productiondataid\n" +
  15055. " inner join tp_mst_goods g\n" +
  15056. " on dd.goodsid = g.goodsid\n" +
  15057. " inner join tp_mst_goodstype gt\n" +
  15058. " on gt.goodstypeid = g.goodstypeid\n" +
  15059. " inner join tp_mst_goodstype gt2\n" +
  15060. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  15061. " where dd.valueflag = '1'\n" +
  15062. " and dd.accountid = :accountid\n" +
  15063. " and pd.goodsleveltypeid = 7\n" + // 次品
  15064. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  15065. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  15066. " and dd.procedureid = :p2ID\n" +
  15067. " and dd.checktime >= :timebegin\n" +
  15068. " and dd.checktime < :timeend\n" +
  15069. ////" -- 惊风、毛针孔、烧裂、窑脏、釉泡\n" +
  15070. //" and dd.defectid in (385\n" +
  15071. //" ,203\n" +
  15072. //" ,836\n" +
  15073. //" ,234\n" +
  15074. //" ,384\n" +
  15075. //" ,202\n" +
  15076. //" ,835\n" +
  15077. //" ,390\n" +
  15078. //" ,818\n" +
  15079. //" ,389\n" +
  15080. //" ,204\n" +
  15081. //" ,814\n" +
  15082. //" ,837\n" +
  15083. //" ,387)\n" +
  15084. " and dd.defectid in (234,385,386,387,388,389,390)\n" +
  15085. //" 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" +
  15086. //" 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" +
  15087. //" )\n" +
  15088. " group by gt2.goodstypecode\n" +
  15089. " union all\n" +
  15090. " select 70 pcode\n" +
  15091. " ,'杂锈点' pname\n" +
  15092. " ,gt2.goodstypecode gtcode2\n" +
  15093. " ,count(*) defectcount\n" +
  15094. " from tp_pm_defect dd\n" +
  15095. " inner join tp_pm_productiondata pd\n" +
  15096. " on dd.productiondataid = pd.productiondataid\n" +
  15097. " inner join tp_mst_goods g\n" +
  15098. " on dd.goodsid = g.goodsid\n" +
  15099. " inner join tp_mst_goodstype gt\n" +
  15100. " on gt.goodstypeid = g.goodstypeid\n" +
  15101. " inner join tp_mst_goodstype gt2\n" +
  15102. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  15103. " where dd.valueflag = '1'\n" +
  15104. " and dd.accountid = :accountid\n" +
  15105. " and pd.goodsleveltypeid = 7\n" + // 次品
  15106. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  15107. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  15108. " and dd.procedureid = :p2ID\n" +
  15109. " and dd.checktime >= :timebegin\n" +
  15110. " and dd.checktime < :timeend\n" +
  15111. ////" -- 铁脏、铜脏、窑脏、釉脏\n" +
  15112. //" and dd.defectid in\n" +
  15113. //" (730, 818, 827, 829, 830, 389, 398, 399, 400, 170)\n" +
  15114. " and dd.defectid in (170,389,398,399)\n" +
  15115. //" 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" +
  15116. //" 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" +
  15117. //" )\n" +
  15118. " group by gt2.goodstypecode\n" +
  15119. " union all\n" +
  15120. " select 80 pcode\n" +
  15121. " ,'其他' pname\n" +
  15122. " ,gt2.goodstypecode gtcode2\n" +
  15123. " ,count(*) defectcount\n" +
  15124. " from tp_pm_defect dd\n" +
  15125. " inner join tp_pm_productiondata pd\n" +
  15126. " on dd.productiondataid = pd.productiondataid\n" +
  15127. " inner join tp_mst_goods g\n" +
  15128. " on dd.goodsid = g.goodsid\n" +
  15129. " inner join tp_mst_goodstype gt\n" +
  15130. " on gt.goodstypeid = g.goodstypeid\n" +
  15131. " inner join tp_mst_goodstype gt2\n" +
  15132. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  15133. " where dd.valueflag = '1'\n" +
  15134. " and dd.accountid = :accountid\n" +
  15135. " and pd.goodsleveltypeid = 7\n" + // 次品
  15136. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  15137. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  15138. " and dd.procedureid = :p2ID\n" +
  15139. " and dd.checktime >= :timebegin\n" +
  15140. " and dd.checktime < :timeend\n" +
  15141. ////" -- 成检撞伤、炸坯、炸裂\n" +
  15142. //" and dd.defectid in (393, 180, 394, 395)\n" +
  15143. " and ((gt2.goodstypecode='001001' and dd.defectid in (402,393,395,396,397))\n" +
  15144. " or (gt2.goodstypecode='001002' and dd.defectid in (402,394,393,395,396,397))\n" +
  15145. " )\n" +
  15146. " group by gt2.goodstypecode) t\n" +
  15147. " left join (select gt2.goodstypecode gtcode2\n" +
  15148. " ,count(*) outkcount\n" +
  15149. " from tp_pm_productiondata pd\n" +
  15150. " inner join tp_mst_goods g\n" +
  15151. " on pd.goodsid = g.goodsid\n" +
  15152. " inner join tp_mst_goodstype gt\n" +
  15153. " on gt.goodstypeid = g.goodstypeid\n" +
  15154. " inner join tp_mst_goodstype gt2\n" +
  15155. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  15156. " where pd.valueflag = '1'\n" +
  15157. " and pd.accountid = :accountid\n" +
  15158. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  15159. " and pd.procedureid = :p1ID\n" +
  15160. " and pd.createtime >= :timebegin\n" +
  15161. " and pd.createtime < :timeend\n" +
  15162. " group by gt2.goodstypecode) outk\n" +
  15163. " on t.gtcode2 = outk.gtcode2\n" +
  15164. " inner join tp_mst_goodstype gt\n" +
  15165. " on gt.goodstypecode = t.gtcode2\n" +
  15166. " and gt.accountid = :accountid\n" +
  15167. " order by t.pcode, t.gtcode2";
  15168. OracleParameter[] oracleParameter = new OracleParameter[]
  15169. {
  15170. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  15171. new OracleParameter(":p1ID",OracleDbType.Int32, p1ID, ParameterDirection.Input),
  15172. new OracleParameter(":p2ID",OracleDbType.Int32, p2ID, ParameterDirection.Input),
  15173. new OracleParameter(":timebegin",OracleDbType.Date, cre.Properties["timebegin"], ParameterDirection.Input),
  15174. new OracleParameter(":timeend",OracleDbType.Date, cre.Properties["timeend"], ParameterDirection.Input),
  15175. new OracleParameter(":gtcode2",OracleDbType.Varchar2, gtcode2, ParameterDirection.Input),
  15176. };
  15177. ServiceResultEntity sre = new ServiceResultEntity();
  15178. sre.Data = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  15179. if (sre.Data != null && sre.Data.Tables.Count > 0 && sre.Data.Tables[0].Rows.Count > 0)
  15180. {
  15181. sre.Data.Tables[0].TableName = "S";
  15182. cre.Properties["pcode"] = sre.Data.Tables[0].Rows[0]["pcode"];
  15183. cre.Properties["pname"] = sre.Data.Tables[0].Rows[0]["pname"];
  15184. cre.Properties["gtcode2"] = sre.Data.Tables[0].Rows[0]["gtcode2"];
  15185. ServiceResultEntity sre1 = GetRPT040113DData(cre, sUserInfo);
  15186. if (sre1 != null&& sre1.Data != null&& sre1.Data.Tables.Count > 0)
  15187. {
  15188. sre1.Data.Tables[0].TableName = "D";
  15189. sre.Data.Merge(sre1.Data.Tables[0]);
  15190. }
  15191. }
  15192. sqlString =
  15193. "select t.gtcode2\n" +
  15194. " ,nvl(t.gtname2, '合计') gtname2\n" +
  15195. " ,sum(t.outk) outk\n" +
  15196. " ,sum(t.cipin) cipin\n" +
  15197. " ,sum(t.outk) - sum(t.cipin) hege\n" +
  15198. " ,decode(sum(t.outk), 0, to_number(null), round(1 - (sum(t.cipin) / sum(t.outk)),4)) hegep\n" +
  15199. " from (select gt2.goodstypecode gtcode2\n" +
  15200. " ,gt2.goodstypename gtname2\n" +
  15201. " ,nvl(sum(decode(pd.procedureid, :p1ID, 1, 0)), 0) outk\n" +
  15202. " ,nvl(sum(case\n" +
  15203. " when pd.procedureid = :p2ID and\n" +
  15204. " pd.goodsleveltypeid in (6, 7) then\n" +
  15205. " 1\n" +
  15206. " else\n" +
  15207. " 0\n" +
  15208. " end)\n" +
  15209. " ,0) cipin\n" +
  15210. " from tp_pm_productiondata pd\n" +
  15211. " inner join tp_mst_goods g\n" +
  15212. " on pd.goodsid = g.goodsid\n" +
  15213. " inner join tp_mst_goodstype gt\n" +
  15214. " on g.goodstypeid = gt.goodstypeid\n" +
  15215. " inner join tp_mst_goodstype gt2\n" +
  15216. " on length(gt2.goodstypecode) = 6\n" +
  15217. " and gt2.accountid = gt.accountid\n" +
  15218. " and instr(gt.goodstypecode, gt2.goodstypecode) = 1\n" +
  15219. " where pd.valueflag = '1'\n" +
  15220. " and pd.accountid = :accountid\n" +
  15221. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  15222. " and (pd.procedureid = :p1ID or pd.procedureid = :p2ID)\n" +
  15223. //" and pd.checktime > date '2018-01-01'\n" +
  15224. " and pd.checktime >= :timebegin\n" +
  15225. " and pd.checktime < :timeend\n" +
  15226. " group by gt2.goodstypecode, gt2.goodstypename) t\n" +
  15227. " group by grouping sets((t.gtcode2, t.gtname2),())";
  15228. oracleParameter = new OracleParameter[]
  15229. {
  15230. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  15231. new OracleParameter(":p1ID",OracleDbType.Int32, p1ID, ParameterDirection.Input),
  15232. new OracleParameter(":p2ID",OracleDbType.Int32, p2ID, ParameterDirection.Input),
  15233. new OracleParameter(":timebegin",OracleDbType.Date, cre.Properties["timebegin"], ParameterDirection.Input),
  15234. new OracleParameter(":timeend",OracleDbType.Date, cre.Properties["timeend"], ParameterDirection.Input),
  15235. new OracleParameter(":gtcode2",OracleDbType.Varchar2, gtcode2, ParameterDirection.Input),
  15236. };
  15237. DataTable alldata = oracleConn.GetSqlResultToDt(sqlString, oracleParameter);
  15238. alldata.TableName = "A";
  15239. DataTable data = sre.Data.Tables[0];
  15240. foreach (DataRow item in alldata.Rows)
  15241. {
  15242. data.Rows.Add(99, "总计", item["gtcode2"], item["cipin"], item["gtname2"], item["outk"], item["hege"], item["hegep"]);
  15243. }
  15244. return sre;
  15245. }
  15246. catch (Exception ex)
  15247. {
  15248. if (oracleConn.ConnState == ConnectionState.Open)
  15249. {
  15250. oracleConn.Close();
  15251. }
  15252. throw ex;
  15253. }
  15254. }
  15255. /// <summary>
  15256. /// 各工序质量表-缺陷明细-恒洁三水
  15257. /// </summary>
  15258. /// <param name="cre"></param>
  15259. /// <param name="sUserInfo"></param>
  15260. /// <returns></returns>
  15261. public static ServiceResultEntity GetRPT040113DData(ClientRequestEntity cre, SUserInfo sUserInfo)
  15262. {
  15263. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  15264. try
  15265. {
  15266. //int p1ID = 11; // 成检交接工序
  15267. int p2ID = 12; // 成检登记工序
  15268. int pcode = Convert.ToInt32(cre.Properties["pcode"]);
  15269. string sqlString =
  15270. "select :pcode pcode\n" +
  15271. " ,:pname pname\n" +
  15272. " ,gt2.goodstypecode gtcode2\n" +
  15273. " ,gt2.goodstypename gtname2\n" +
  15274. " ,dd.defectcode\n" +
  15275. " ,dd.defectname\n" +
  15276. " ,count(*) defectcount\n" +
  15277. " from tp_pm_defect dd\n" +
  15278. //"--inner join tp_mst_defect md on md.defectid=dd.defectid\n" +
  15279. " inner join tp_mst_goods g\n" +
  15280. " on dd.goodsid = g.goodsid\n" +
  15281. " inner join tp_pm_productiondata pd\n" +
  15282. " on dd.productiondataid = pd.productiondataid\n" +
  15283. " inner join tp_mst_goodstype gt\n" +
  15284. " on gt.goodstypeid = g.goodstypeid\n" +
  15285. " inner join tp_mst_goodstype gt2\n" +
  15286. " on gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  15287. " and gt2.accountid = :accountid\n" +
  15288. " where dd.valueflag = '1'\n" +
  15289. " and dd.accountid = :accountid\n" +
  15290. " and pd.goodsleveltypeid = 7\n" + // 次品
  15291. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  15292. " and dd.procedureid = :p2ID\n" +
  15293. " and gt2.goodstypecode = :gtcode2\n" +
  15294. " and dd.checktime >= :timebegin\n" +
  15295. " and dd.checktime < :timeend\n";
  15296. switch (pcode)
  15297. {
  15298. case 10:
  15299. ////" -- 交坯、干补\n" +
  15300. //sqlString += " and dd.defectprocedureid in (1, 17, 18)\n";
  15301. sqlString +=
  15302. " 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" +
  15303. " 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" +
  15304. " )\n";
  15305. break;
  15306. case 20:
  15307. sqlString +=
  15308. ////" -- 改洗、吹风\n" +
  15309. //" and dd.defectprocedureid in (2, 62)\n" +
  15310. ////" -- 除不平\n" +
  15311. //" and dd.defectid not in (91, 240)\n";
  15312. " and ((gt2.goodstypecode='001001' and dd.defectid in (91,94,144,113,145,114,183))\n" +
  15313. " or (gt2.goodstypecode='001002' and dd.defectid in (91,93,94,144,113,145,114))\n" +
  15314. " )\n";
  15315. break;
  15316. case 30:
  15317. sqlString +=
  15318. ////" -- 二检\n" +
  15319. //" and dd.defectprocedureid in (61)\n";
  15320. " and ((gt2.goodstypecode='001001' and dd.defectid in (89,91,92,93,94,106,115,163,159,133,166,164))\n" +
  15321. " or (gt2.goodstypecode='001002' and dd.defectid in (89,91,92,93,94,106,115,163,133,192,166,164))\n" +
  15322. " )\n";
  15323. break;
  15324. case 40:
  15325. sqlString +=
  15326. ////" -- 施釉\n" +
  15327. //" and dd.defectprocedureid in (3, 4)\n" +
  15328. ////" -- 除铁、铜脏\n" +
  15329. //" and dd.defectid not in (827, 829, 398, 399, 830, 400)\n";
  15330. " 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" +
  15331. " 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" +
  15332. " )\n";
  15333. break;
  15334. case 50:
  15335. sqlString +=
  15336. ////" -- 登窑、入窑、卸窑\n" +
  15337. //" and dd.defectprocedureid in (5, 9, 10)\n";
  15338. " 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" +
  15339. " 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" +
  15340. " )\n";
  15341. break;
  15342. case 60:
  15343. sqlString +=
  15344. ////" -- 惊风、毛针孔、烧裂、窑脏、釉泡\n" +
  15345. //" and dd.defectid in (385\n" +
  15346. //" ,203\n" +
  15347. //" ,836\n" +
  15348. //" ,234\n" +
  15349. //" ,384\n" +
  15350. //" ,202\n" +
  15351. //" ,835\n" +
  15352. //" ,390\n" +
  15353. //" ,818\n" +
  15354. //" ,389\n" +
  15355. //" ,204\n" +
  15356. //" ,814\n" +
  15357. //" ,837\n" +
  15358. //" ,387)\n";
  15359. " and dd.defectid in (234,385,386,387,388,389,390)\n";
  15360. break;
  15361. case 70:
  15362. sqlString +=
  15363. ////" -- 铁脏、铜脏、窑脏、釉脏\n" +
  15364. //" and dd.defectid in\n" +
  15365. //" (730, 818, 827, 829, 830, 389, 398, 399, 400, 170)\n";
  15366. " and dd.defectid in (170,389,398,399)\n";
  15367. break;
  15368. case 80:
  15369. sqlString +=
  15370. ////" -- 成检撞伤、炸坯、炸裂\n" +
  15371. //" and dd.defectid in (393, 180, 394, 395)\n";
  15372. " and ((gt2.goodstypecode='001001' and dd.defectid in (402,393,395,396,397))\n" +
  15373. " or (gt2.goodstypecode='001002' and dd.defectid in (402,394,393,395,396,397))\n" +
  15374. " )\n";
  15375. break;
  15376. default:
  15377. break;
  15378. }
  15379. sqlString +=
  15380. " group by gt2.goodstypecode\n" +
  15381. " ,gt2.goodstypename\n" +
  15382. " ,dd.defectcode\n" +
  15383. " ,dd.defectname\n" +
  15384. " order by dd.defectcode";
  15385. OracleParameter[] oracleParameter = new OracleParameter[]
  15386. {
  15387. new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  15388. //new OracleParameter("p1ID",OracleDbType.Int32, p1ID, ParameterDirection.Input),
  15389. new OracleParameter("p2ID",OracleDbType.Int32, p2ID, ParameterDirection.Input),
  15390. new OracleParameter("pcode",OracleDbType.Int32, pcode, ParameterDirection.Input),
  15391. new OracleParameter("pname",OracleDbType.NVarchar2, cre.Properties["pname"], ParameterDirection.Input),
  15392. new OracleParameter("gtcode2",OracleDbType.Varchar2, cre.Properties["gtcode2"], ParameterDirection.Input),
  15393. new OracleParameter("timebegin",OracleDbType.Date, cre.Properties["timebegin"], ParameterDirection.Input),
  15394. new OracleParameter("timeend",OracleDbType.Date, cre.Properties["timeend"], ParameterDirection.Input),
  15395. };
  15396. ServiceResultEntity sre = new ServiceResultEntity();
  15397. sre.Data = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  15398. return sre;
  15399. }
  15400. catch (Exception ex)
  15401. {
  15402. if (oracleConn.ConnState == ConnectionState.Open)
  15403. {
  15404. oracleConn.Close();
  15405. }
  15406. throw ex;
  15407. }
  15408. }
  15409. /// <summary>
  15410. /// 综合合格率分析表-半成品报废率分析表
  15411. /// </summary>
  15412. /// <param name="cre"></param>
  15413. /// <param name="sUserInfo"></param>
  15414. /// <returns></returns>
  15415. public static ServiceResultEntity GetRPT040114_1Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  15416. {
  15417. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  15418. try
  15419. {
  15420. ServiceResultEntity sre = new ServiceResultEntity();
  15421. List<OracleParameter> oracleParameters = new List<OracleParameter>();
  15422. oracleParameters.Add(new OracleParameter(":accountid", sUserInfo.AccountID));
  15423. string sqlString = "select g.goodscode\n" +
  15424. " ,tt.d_num\n" +
  15425. " ,tt.b_num\n" +
  15426. " ,tt.f_num\n" +
  15427. " ,tt.s_num\n" +
  15428. " ,decode(tt.d_num\n" +
  15429. " ,0\n" +
  15430. " ,to_number(null)\n" +
  15431. " ,round((tt.b_num + tt.f_num + tt.s_num) / tt.d_num,4)) sp_r\n" +
  15432. " from (select t.goodsid\n" +
  15433. " ,nvl(sum(decode(t.numtype, 'A', t.id_num, 0)), 0) d_num -- 交坯\n" +
  15434. " ,nvl(sum(decode(t.numtype, '2', t.id_num, 0)), 0) b_num -- 半检不合格数\n" +
  15435. " ,nvl(sum(decode(t.numtype, '3', t.id_num, 0)), 0) f_num -- 复检不合格数\n" +
  15436. " ,nvl(sum(decode(t.numtype, '0', t.id_num, 0)), 0) s_num -- 损坯数\n" +
  15437. " from (select gdd.goodsid\n" +
  15438. " ,'A' numtype\n" +
  15439. " ,count(gdd.groutingdailydetailid) id_num\n" +
  15440. " from tp_pm_groutingdailydetail gdd\n" +
  15441. " where gdd.groutingflag = '1'\n" +
  15442. " and gdd.valueflag = '1'\n" +
  15443. " and gdd.accountid = :accountid\n" +
  15444. " and gdd.deliverflag = '1'\n" +
  15445. " and gdd.delivertime >= :datebegin\n" +
  15446. " and gdd.delivertime < :dateend\n" +
  15447. " group by gdd.goodsid\n" +
  15448. " union all\n" +
  15449. " -- 半检不合格数 复检不合格数 损坯数\n" +
  15450. " select sp.goodsid\n" +
  15451. " ,sp.SCRAPTYPE numtype\n" +
  15452. " ,count(sp.scrapproductid) id_num\n" +
  15453. " from tp_pm_scrapproduct sp\n" +
  15454. " where sp.valueflag = '1'\n" +
  15455. " and sp.accountid = :accountid\n" +
  15456. " and sp.auditstatus = 1\n" +
  15457. " and sp.KILNID is null\n" +
  15458. " and sp.SCRAPTYPE <> '1'\n" +
  15459. " and sp.AUDITDATE >= :datebegin\n" +
  15460. " and sp.AUDITDATE < :dateend\n" +
  15461. " group by sp.goodsid, sp.SCRAPTYPE) t\n" +
  15462. " group by t.goodsid) tt\n" +
  15463. " inner join tp_mst_goods g\n" +
  15464. " on tt.goodsid = g.goodsid\n" +
  15465. " order by g.goodscode";
  15466. oracleParameters.Add(new OracleParameter(":datebegin", cre.Properties["datebegin"]));
  15467. oracleParameters.Add(new OracleParameter(":dateend", cre.Properties["dateend"]));
  15468. //// 产品编码 GOODSCODE
  15469. //if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSCODE"] + ""))
  15470. //{
  15471. // sqlString += " and instr(sr.GOODSCODE,:GOODSCODE) > 0 \n";
  15472. // oracleParameters.Add(new OracleParameter(":GOODSCODE", cre.Properties["GOODSCODE"]));
  15473. //}
  15474. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameters.ToArray());
  15475. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  15476. {
  15477. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  15478. return sre;
  15479. }
  15480. sre.Data = result;
  15481. return sre;
  15482. }
  15483. catch (Exception ex)
  15484. {
  15485. throw ex;
  15486. }
  15487. finally
  15488. {
  15489. oracleConn?.Close();
  15490. }
  15491. }
  15492. /// <summary>
  15493. /// 综合合格率分析表-综合优等率分析表
  15494. /// </summary>
  15495. /// <param name="cre"></param>
  15496. /// <param name="sUserInfo"></param>
  15497. /// <returns></returns>
  15498. public static ServiceResultEntity GetRPT040114_2Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  15499. {
  15500. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  15501. try
  15502. {
  15503. ServiceResultEntity sre = new ServiceResultEntity();
  15504. List<OracleParameter> oracleParameters = new List<OracleParameter>();
  15505. oracleParameters.Add(new OracleParameter(":accountid", sUserInfo.AccountID));
  15506. string sqlString = "\n" +
  15507. "select g.goodscode\n" +
  15508. " ,pp.b_out_num\n" +
  15509. " ,(pp.b_out_num - pp.b_bad_num) b_h_num\n" +
  15510. " ,(pp.c_out_num - pp.c_bad_num) c_h_num\n" +
  15511. " ,decode(pp.b_out_num\n" +
  15512. " ,0\n" +
  15513. " ,to_number(null)\n" +
  15514. " ,round((pp.b_out_num - pp.b_bad_num + pp.c_out_num - pp.c_bad_num) /\n" +
  15515. " pp.b_out_num,4)) zh_r\n" +
  15516. " from (select p.goodsid\n" +
  15517. " ,nvl(sum(decode(p.procedureid, 11, 1, 0)), 0) b_out_num -- 本烧出窑数\n" +
  15518. " ,nvl(sum(decode(p.procedureid, 12, 1, 0)), 0) b_bad_num -- 本烧不合格数\n" +
  15519. " ,nvl(sum(decode(p.procedureid, 58, 1, 0)), 0) c_out_num -- 重烧出窑数\n" +
  15520. " ,nvl(sum(decode(p.procedureid, 59, 1, 0)), 0) c_bad_num -- 重烧不合格数\n" +
  15521. " from tp_pm_productiondata p\n" +
  15522. " where p.valueflag = '1'\n" +
  15523. " and p.accountid = :accountid\n" +
  15524. " and (p.procedureid in (11, 58) or\n" +
  15525. " (p.procedureid in (12, 59) and p.goodsleveltypeid in (6, 7)))\n" +
  15526. " and p.createtime >= :datebegin\n" +
  15527. " and p.createtime < :dateend\n" +
  15528. " group by p.goodsid) pp\n" +
  15529. " inner join tp_mst_goods g\n" +
  15530. " on g.goodsid = pp.goodsid\n" +
  15531. " order by g.goodscode";
  15532. oracleParameters.Add(new OracleParameter(":datebegin", cre.Properties["datebegin"]));
  15533. oracleParameters.Add(new OracleParameter(":dateend", cre.Properties["dateend"]));
  15534. //// 产品编码 GOODSCODE
  15535. //if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSCODE"] + ""))
  15536. //{
  15537. // sqlString += " and instr(sr.GOODSCODE,:GOODSCODE) > 0 \n";
  15538. // oracleParameters.Add(new OracleParameter(":GOODSCODE", cre.Properties["GOODSCODE"]));
  15539. //}
  15540. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameters.ToArray());
  15541. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  15542. {
  15543. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  15544. return sre;
  15545. }
  15546. sre.Data = result;
  15547. return sre;
  15548. }
  15549. catch (Exception ex)
  15550. {
  15551. throw ex;
  15552. }
  15553. finally
  15554. {
  15555. oracleConn?.Close();
  15556. }
  15557. }
  15558. #region 产成品交接撤销汇总表
  15559. /// <summary>
  15560. /// 取得F_RPT_030117画面(产成品交接撤销汇总表)
  15561. /// </summary>
  15562. /// <param name="user">登录用户信息</param>
  15563. /// <param name="se">查询条件</param>
  15564. /// <returns>查询结果</returns>
  15565. public static ServiceResultEntity GetF_RPT_030117SearchTotalData(SearchFinishedProductEntity orderEntity, SUserInfo user)
  15566. {
  15567. IDBConnection conn = null;
  15568. try
  15569. {
  15570. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  15571. string sqlString = "SELECT TS.GID,\n" +
  15572. " DECODE(TS.GID, '3', '合计', DECODE(TS.GID, '1', '小计[' || CREATETIME || ']', CREATETIME)) AS CREATETIME,\n" +
  15573. " DECODE(TS.GID, '1', '--', GOODSMODEL) AS GOODSMODEL,\n" +
  15574. " GOODSCOUNT\n" +
  15575. " FROM (SELECT GROUPING_ID(TO_CHAR(F.CREATETIME, 'yyyy-mm-dd'), G.GOODSCODE) AS GID,\n" +
  15576. " DECODE(GROUPING(TO_CHAR(F.CREATETIME, 'yyyy-mm-dd')), 1, '--', TO_CHAR(F.CREATETIME, 'yyyy-mm-dd')) AS CREATETIME,\n" +
  15577. " DECODE(GROUPING(G.GOODSCODE), 1, '--', G.GOODSCODE) AS GOODSMODEL,\n" +
  15578. " COUNT(G.GOODSCODE) AS GOODSCOUNT\n" +
  15579. " FROM TP_PM_FHUNDO F\n" +
  15580. " LEFT JOIN TP_PM_GROUTINGDAILYDETAIL GDD\n" +
  15581. " ON F.GROUTINGDAILYDETAILID = GDD.GROUTINGDAILYDETAILID\n" +
  15582. " LEFT JOIN TP_MST_GOODS G\n" +
  15583. " ON G.GOODSID = GDD.GOODSID\n" +
  15584. " WHERE F.ACCOUNTID = :AccountID\n";
  15585. List<OracleParameter> parameters = new List<OracleParameter>();
  15586. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  15587. // 撤销时间
  15588. if (orderEntity.UndoTimeStart != null)
  15589. {
  15590. sqlString = sqlString + " AND F.CREATETIME BETWEEN :UndoTimeStart AND :UndoTimeEnd \n";
  15591. parameters.Add(new OracleParameter(":UndoTimeStart", OracleDbType.Date, orderEntity.UndoTimeStart, ParameterDirection.Input));
  15592. parameters.Add(new OracleParameter(":UndoTimeEnd", OracleDbType.Date, orderEntity.UndoTimeEnd, ParameterDirection.Input));
  15593. }
  15594. // 产品型号
  15595. if (!string.IsNullOrEmpty(orderEntity.GoodsModel))
  15596. {
  15597. sqlString = sqlString + " AND INSTR(g.GoodsCode,:GoodsCode)>0 \n";
  15598. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, orderEntity.GoodsModel, ParameterDirection.Input));
  15599. }
  15600. sqlString += " GROUP BY GROUPING SETS((TO_CHAR(F.CREATETIME, 'yyyy-mm-dd'), G.GOODSCODE),\n" +
  15601. " (TO_CHAR(F.CREATETIME, 'yyyy-mm-dd')),())\n" +
  15602. " ORDER BY TO_CHAR(F.CREATETIME, 'yyyy-mm-dd'), G.GOODSCODE) TS";
  15603. ServiceResultEntity sre = new ServiceResultEntity();
  15604. DataSet result = conn.GetSqlResultToDs(sqlString, parameters.ToArray());
  15605. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  15606. {
  15607. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  15608. }
  15609. sre.Data = result;
  15610. return sre;
  15611. }
  15612. catch (Exception ex)
  15613. {
  15614. throw ex;
  15615. }
  15616. finally
  15617. {
  15618. if (conn != null &&
  15619. conn.ConnState == ConnectionState.Open)
  15620. {
  15621. conn.Close();
  15622. }
  15623. }
  15624. }
  15625. /// <summary>
  15626. /// 取得F_RPT_030112画面(产成品交接汇总表)的明细信息查询数据
  15627. /// </summary>
  15628. /// <param name="user">登录用户信息</param>
  15629. /// <param name="se">查询条件</param>
  15630. /// <returns>查询结果</returns>
  15631. public static ServiceResultEntity GetF_RPT_030117SearchDetailSData(SearchFinishedProductEntity orderEntity, SUserInfo user)
  15632. {
  15633. IDBConnection conn = null;
  15634. try
  15635. {
  15636. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  15637. string sqlString = "SELECT O.ORDERNO,\n" +
  15638. " F.FHTIME,\n" +
  15639. " F.FHUSERCODE,\n" +
  15640. " GDD.BARCODE,\n" +
  15641. " GOODS.GOODSCODE,\n" +
  15642. " L.LOGONAME,\n" +
  15643. " GDD.USERCODE AS GROUTINGUSERCODE,\n" +
  15644. " GDD.GROUTINGLINECODE,\n" +
  15645. " GDD.GROUTINGMOULDCODE,\n" +
  15646. " GDD.GROUTINGDATE,\n" +
  15647. " TO_CHAR(GDD.DELIVERTIME, 'yyyy-mm-dd') AS DELIVERTIME,\n" +
  15648. //" (GOODS.MATERIALCODE || L.TAGCODE || GDD.ONLYCODE) AS FINISHEDBARCODE,\n" +
  15649. " 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" +
  15650. " TO_CHAR(F.CREATETIME, 'yyyy-mm-dd HH24:mi:ss') AS UNDOTIME,\n" +
  15651. " UNDOUSER.USERCODE AS UNDOUSERCODE\n" +
  15652. " FROM TP_PM_FHUNDO F\n" +
  15653. " LEFT JOIN TP_PM_GROUTINGDAILYDETAIL GDD\n" +
  15654. " ON F.GROUTINGDAILYDETAILID = GDD.GROUTINGDAILYDETAILID\n" +
  15655. " LEFT JOIN TP_PM_ORDER O\n" +
  15656. " ON F.FHORDERID = O.ORDERID\n" +
  15657. " LEFT JOIN TP_MST_LOGO L\n" +
  15658. " ON GDD.LOGOID = L.LOGOID\n" +
  15659. " LEFT JOIN TP_MST_GOODS GOODS\n" +
  15660. " ON GDD.GOODSID = GOODS.GOODSID\n" +
  15661. " LEFT JOIN TP_MST_USER UNDOUSER\n" +
  15662. " ON UNDOUSER.USERID = F.CREATEUSERID\n" +
  15663. " WHERE F.ACCOUNTID = :AccountID";
  15664. List<OracleParameter> parameters = new List<OracleParameter>();
  15665. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  15666. // 撤销时间
  15667. if (orderEntity.UndoTimeStart != null)
  15668. {
  15669. sqlString = sqlString + " AND F.CREATETIME BETWEEN :UndoTimeStart AND :UndoTimeEnd \n";
  15670. parameters.Add(new OracleParameter(":UndoTimeStart", OracleDbType.Date, orderEntity.UndoTimeStart, ParameterDirection.Input));
  15671. parameters.Add(new OracleParameter(":UndoTimeEnd", OracleDbType.Date, orderEntity.UndoTimeEnd, ParameterDirection.Input));
  15672. }
  15673. // 产品型号
  15674. if (!string.IsNullOrEmpty(orderEntity.GoodsModel))
  15675. {
  15676. sqlString = sqlString + " AND INSTR(GOODS.GoodsCode,:GoodsCode) > 0 \n";
  15677. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, orderEntity.GoodsModel, ParameterDirection.Input));
  15678. }
  15679. ServiceResultEntity sre = new ServiceResultEntity();
  15680. DataSet result = conn.GetSqlResultToDs(sqlString, parameters.ToArray());
  15681. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  15682. {
  15683. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  15684. }
  15685. sre.Data = result;
  15686. return sre;
  15687. }
  15688. catch (Exception ex)
  15689. {
  15690. throw ex;
  15691. }
  15692. finally
  15693. {
  15694. if (conn != null &&
  15695. conn.ConnState == ConnectionState.Open)
  15696. {
  15697. conn.Close();
  15698. }
  15699. }
  15700. }
  15701. #endregion
  15702. }
  15703. }