ReportModuleLogic.cs 785 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:ReportModuleLogic.cs
  5. * 2.功能描述:生产线报表分析
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 宋扬 2014/11/08 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Text;
  14. using Oracle.ManagedDataAccess.Client;
  15. using Dongke.IBOSS.PRD.Basics.BaseResources;
  16. using Dongke.IBOSS.PRD.Basics.DataAccess;
  17. using Dongke.IBOSS.PRD.Service.DataModels;
  18. using Dongke.IBOSS.PRD.WCF.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.DataModels.ReportModule;
  20. using Dongke.IBOSS.PRD.WCF.DataModels.PMModule;
  21. using Dongke.WinForm.Utilities;
  22. namespace Dongke.IBOSS.PRD.Service.ReportModuleLogic
  23. {
  24. /// <summary>
  25. /// 生产线报表分析
  26. /// </summary>
  27. public class ReportModuleLogic
  28. {
  29. #region 综合报表
  30. #region 跟踪统计表
  31. #region 生产管理
  32. /// <summary>
  33. /// 产品跟踪明细查询
  34. /// </summary>
  35. /// <param name="searchGoodsFollowingEntity">产品跟踪统计实体类</param>
  36. /// <param name="sUserInfo">用户基本信息</param>
  37. /// <returns>DataSet</returns>
  38. public static DataSet GetSearchGoodsFollowingDetailModule(SearchGoodsFollowingEntity searchGoodsFollowingEntity, SUserInfo sUserInfo)
  39. {
  40. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  41. try
  42. {
  43. con.Open();
  44. OracleParameter[] paras = new OracleParameter[]{
  45. new OracleParameter("in_accountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  46. new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  47. };
  48. DataSet dsSearchReport = con.ExecStoredProcedure("PRO_RPT_GetRPTDetailData", paras);
  49. return dsSearchReport;
  50. }
  51. catch (Exception ex)
  52. {
  53. throw ex;
  54. }
  55. finally
  56. {
  57. if (con.ConnState == ConnectionState.Open)
  58. {
  59. con.Close();
  60. }
  61. }
  62. }
  63. #endregion
  64. #endregion
  65. #endregion
  66. #region 统一使用ServiceResultEntity类模式
  67. #region 跟踪报表
  68. /// <summary>
  69. /// 取得RPT020101_1画面(产品跟踪)的查询数据
  70. /// </summary>
  71. /// <param name="user">登录用户信息</param>
  72. /// <param name="se">查询条件</param>
  73. /// <returns>查询结果</returns>
  74. public static ServiceResultEntity GetRPT020101SData(SUserInfo user, RPT020101_SE se)
  75. {
  76. IDBConnection conn = null;
  77. try
  78. {
  79. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  80. OracleParameter[] paras = new OracleParameter[]{
  81. new OracleParameter("in_barCode",OracleDbType.Varchar2,se.Barcode,ParameterDirection.Input),
  82. new OracleParameter("in_accountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  83. new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  84. new OracleParameter("out_result1",OracleDbType.RefCursor,ParameterDirection.Output),
  85. };
  86. //DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  87. DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetGoodsFollowingData", paras);
  88. ServiceResultEntity sre = new ServiceResultEntity();
  89. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  90. {
  91. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  92. return sre;
  93. }
  94. sre.Data = new DataSet();
  95. sre.Data = data;
  96. return sre;
  97. }
  98. catch (Exception ex)
  99. {
  100. throw ex;
  101. }
  102. finally
  103. {
  104. if (conn != null &&
  105. conn.ConnState == ConnectionState.Open)
  106. {
  107. conn.Close();
  108. }
  109. }
  110. }
  111. #endregion
  112. #region 明细报表
  113. /// <summary>
  114. /// 取得RPT010101_1画面(注浆明细表)的查询数据
  115. /// </summary>
  116. /// <param name="user">登录用户信息</param>
  117. /// <param name="se">查询条件</param>
  118. /// <returns>查询结果</returns>
  119. public static ServiceResultEntity GetRPT010101SData(SUserInfo user, RPT010101_SE se)
  120. {
  121. IDBConnection conn = null;
  122. try
  123. {
  124. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  125. List<OracleParameter> parameters = new List<OracleParameter>();
  126. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010101SSQL());
  127. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  128. if (se != null)
  129. {
  130. // 成型线类型ids
  131. if (!string.IsNullOrEmpty(se.GMouldTypeIDS))
  132. {
  133. sql.Append("AND instr(','||:GMouldTypeIDS||',',','||TP_MST_GMouldType.gMouldTypeId||',')>0 ");
  134. parameters.Add(new OracleParameter(":GMouldTypeIDS", OracleDbType.NVarchar2, se.GMouldTypeIDS, ParameterDirection.Input));
  135. }
  136. // 成型线IDS
  137. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  138. {
  139. sql.Append("AND instr(','||:GroutingLineIDS||',',','||gdd.GroutingLineId||',')>0 ");
  140. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  141. }
  142. // 产品IDS
  143. if (!string.IsNullOrEmpty(se.GoodsIDS))
  144. {
  145. sql.Append("AND instr(','||:GoodsIDS||',',','||gdd.GoodsId||',')>0 ");
  146. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  147. }
  148. // 产品类别IDS
  149. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  150. {
  151. // sql.Append("AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1 ");
  152. sql.Append("AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1 ");
  153. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  154. }
  155. // 模具号
  156. if (!string.IsNullOrEmpty(se.GroutingMouldCode))
  157. {
  158. sql.Append("AND instr(gdd.GroutingMouldCode,:GroutingMouldCode)>0 ");
  159. parameters.Add(new OracleParameter(":GroutingMouldCode", OracleDbType.NVarchar2, se.GroutingMouldCode, ParameterDirection.Input));
  160. }
  161. // 注浆时间-开始
  162. if (se.GroutingDateStart.HasValue)
  163. {
  164. sql.Append("AND gdd.GroutingDate >= :GroutingDateStart ");
  165. parameters.Add(new OracleParameter(":GroutingDateStart", OracleDbType.Date, se.GroutingDateStart.Value, ParameterDirection.Input));
  166. }
  167. // 模具类型IDS
  168. if (se.GroutingDateEnd.HasValue)
  169. {
  170. sql.Append("AND gdd.GroutingDate <= :GroutingDateEnd ");
  171. parameters.Add(new OracleParameter(":GroutingDateEnd", OracleDbType.Date, se.GroutingDateEnd.Value, ParameterDirection.Input));
  172. }
  173. if (se.GroutingBatchNo.HasValue)
  174. {
  175. //sql.Append(" AND TP_PM_GroutingDailyDetail.GroutingBatchNo = :GroutingBatchNo");
  176. sql.Append(" AND instr(gdd.GroutingBatchNo,:GroutingBatchNo)>0");
  177. parameters.Add(new OracleParameter(":GroutingBatchNo", OracleDbType.Int32, se.GroutingBatchNo, ParameterDirection.Input));
  178. }
  179. // 成型工号IDS
  180. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  181. {
  182. sql.Append("and instr(',' || :GroutingUserIDS || ',' ,','||gdd.UserID||',' )>0 ");
  183. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.Clob, se.GroutingUserIDS, ParameterDirection.Input));
  184. }
  185. // 未注浆原因
  186. if (!string.IsNullOrEmpty(se.NoGroutingRreason))
  187. {
  188. sql.Append("AND instr(b.dictionaryvalue,:NoGroutingRreason)>0 ");
  189. parameters.Add(new OracleParameter(":NoGroutingRreason", OracleDbType.NVarchar2, se.NoGroutingRreason, ParameterDirection.Input));
  190. }
  191. // 生产工号IDS
  192. if (!string.IsNullOrEmpty(se.CreateUserIDS))
  193. {
  194. sql.Append("and instr(',' || :CreateUserIDS || ',' ,','||gdd.CreateUserID||',' )>0 ");
  195. parameters.Add(new OracleParameter(":CreateUserIDS", OracleDbType.NVarchar2, se.CreateUserIDS, ParameterDirection.Input));
  196. }
  197. // 备注
  198. if (!string.IsNullOrEmpty(se.Remarks))
  199. {
  200. sql.Append(" AND INSTR(gdd.Remarks, :Remarks) > 0");
  201. parameters.Add(new OracleParameter(":Remarks", OracleDbType.NVarchar2, se.Remarks, ParameterDirection.Input));
  202. }
  203. // 注浆标识
  204. if (!string.IsNullOrEmpty(se.GroutingFlag))
  205. {
  206. sql.Append(" AND gdd.GroutingFlag = :GroutingFlag");
  207. parameters.Add(new OracleParameter(":GroutingFlag", OracleDbType.Char, se.GroutingFlag, ParameterDirection.Input));
  208. }
  209. // 损坯标识
  210. if (!string.IsNullOrEmpty(se.ScrapFlag))
  211. {
  212. sql.Append(" AND gdd.ScrapFlag = :ScrapFlag");
  213. parameters.Add(new OracleParameter(":ScrapFlag", OracleDbType.Char, se.ScrapFlag, ParameterDirection.Input));
  214. }
  215. // 绑定条码
  216. if (!string.IsNullOrEmpty(se.BarCodeFlag))
  217. {
  218. if ("1" == se.BarCodeFlag)
  219. {
  220. sql.Append(" AND LENGTH(gdd.BarCode) > 0");
  221. }
  222. else
  223. {
  224. sql.Append(" AND (gdd.BarCode IS NULL OR LENGTH(gdd.BarCode) = 0)");
  225. }
  226. }
  227. // 交坯日期-开始
  228. if (se.DeliverTimeBegin.HasValue)
  229. {
  230. sql.Append(" AND gdd.DeliverTime >= :DeliverTimeBegin");
  231. parameters.Add(new OracleParameter(":DeliverTimeBegin", OracleDbType.Date, se.DeliverTimeBegin.Value, ParameterDirection.Input));
  232. }
  233. // 交坯日期-结束
  234. if (se.DeliverTimeEnd.HasValue)
  235. {
  236. sql.Append(" AND gdd.DeliverTime <= :DeliverTimeEnd");
  237. parameters.Add(new OracleParameter(":DeliverTimeEnd", OracleDbType.Date, se.DeliverTimeEnd.Value, ParameterDirection.Input));
  238. }
  239. // 交坯标识
  240. if (!string.IsNullOrEmpty(se.DeliverFlag))
  241. {
  242. sql.Append(" AND gdd.DeliverFlag = :DeliverFlag");
  243. parameters.Add(new OracleParameter(":DeliverFlag", OracleDbType.Char, se.DeliverFlag, ParameterDirection.Input));
  244. }
  245. // 损坯日期-开始
  246. if (se.ScrapTimeBegin.HasValue)
  247. {
  248. sql.Append(" AND gdd.ScrapTime >= :ScrapTimeBegin");
  249. parameters.Add(new OracleParameter(":ScrapTimeBegin", OracleDbType.Date, se.ScrapTimeBegin.Value, ParameterDirection.Input));
  250. }
  251. // 损坯日期-结束
  252. if (se.ScrapTimeEnd.HasValue)
  253. {
  254. sql.Append(" AND gdd.ScrapTime <= :ScrapTimeEnd");
  255. parameters.Add(new OracleParameter(":ScrapTimeEnd", OracleDbType.Date, se.ScrapTimeEnd.Value, ParameterDirection.Input));
  256. }
  257. // 注浆操作时间-开始
  258. if (se.GCTimeBegin.HasValue)
  259. {
  260. sql.Append(" AND gdd.CreateTime >= :GCTimeBegin");
  261. parameters.Add(new OracleParameter(":GCTimeBegin", OracleDbType.Date, se.GCTimeBegin.Value, ParameterDirection.Input));
  262. }
  263. // 注浆操作时间-结束
  264. if (se.GCTimeEnd.HasValue)
  265. {
  266. sql.Append(" AND gdd.CreateTime <= :GCTimeEnd");
  267. parameters.Add(new OracleParameter(":GCTimeEnd", OracleDbType.Date, se.GCTimeEnd.Value, ParameterDirection.Input));
  268. }
  269. //sql.Append(" AND TP_PM_GroutingDailyDetail.GroutingLineID in(Select PurviewID from TP_MST_UserPurview where PurviewType= 5 and UserID = :UserID) ");
  270. sql.Append(" AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 5 and up.UserID = :UserID and (up.PurviewID = -1 or up.PurviewID= gdd.GroutingLineID))");
  271. parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  272. }
  273. sql.Append(" order by gdd.GroutingDate desc, ");
  274. sql.Append(" gdd.GroutingLineCode, ");
  275. sql.Append(" gdd.GroutingBatchNo, ");
  276. sql.Append(" gdd.GroutingMouldCode");
  277. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  278. ServiceResultEntity sre = new ServiceResultEntity();
  279. if (data == null || data.Rows.Count == 0)
  280. {
  281. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  282. return sre;
  283. }
  284. sre.Data = new DataSet();
  285. sre.Data.Tables.Add(data);
  286. return sre;
  287. }
  288. catch (Exception ex)
  289. {
  290. throw ex;
  291. }
  292. finally
  293. {
  294. if (conn != null &&
  295. conn.ConnState == ConnectionState.Open)
  296. {
  297. conn.Close();
  298. }
  299. }
  300. }
  301. /// <summary>
  302. /// 获取RPT010101_1画面(注浆明细表)的查询sql
  303. /// </summary>
  304. /// <returns>sql</returns>
  305. private static string GetRPT010101SSQL()
  306. {
  307. string selSql =
  308. "select " +
  309. " gdd.GroutingDate, " +
  310. " gdd.GroutingBatchNo, " +
  311. " gdd.GroutingLineCode, " +
  312. " TP_MST_GMouldType.Gmouldtypename, " +
  313. " TP_MST_GOODSTYPE.GOODSTYPENAME, " +
  314. " gdd.GoodsCode, " +
  315. " TP_MST_GOODS.GOODSSPECIFICATION, " +
  316. " gdd.GroutingMouldCode, " +
  317. " TP_MST_DataDictionary.DICTIONARYVALUE, " +
  318. " gdd.Groutingcount, " +
  319. " gdd.Barcode, " +
  320. " tp_mst_user.UserCode CreateUserCode, " +
  321. " tp_mst_user.username CreateUserName, " +
  322. " gdd.UserCode, " +
  323. " gdd.SCRAPFLAG, " +
  324. " gdd.GoodsName, " +
  325. " gdd.GROUTINGFLAG, " +
  326. " gdd.GMOULDSTATUS, " +
  327. " gdd.DeliverTime, " +
  328. " gdd.DeliverFlag, " +
  329. " tp_sys_gmouldstatus.gmouldstatusname, " +
  330. " b.dictionaryvalue AS NoGroutingRreason, " +
  331. " gdd.SCRAPTIME, " +
  332. " gdd.CreateTime GCTime, " +
  333. " mu.usercode MONITORCODE, " +
  334. " mu.username MONITORNAME, " +
  335. " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName " +
  336. "from TP_PM_GroutingDailyDetail gdd " +
  337. "inner join TP_PM_GroutingDaily gd on gd.GroutingDailyID = gdd.GroutingDailyID " +
  338. "left join tp_mst_user mu on mu.userid = gd.MONITORID " +
  339. "inner join TP_PC_GroutingLine on TP_PC_GroutingLine.GroutingLineID=gdd.GroutingLineID " +
  340. "inner join TP_MST_GMouldType on TP_MST_GMouldType.GMOULDTYPEID=TP_PC_GroutingLine.GMOULDTYPEID " +
  341. "inner join TP_MST_Goods on TP_MST_Goods.Goodsid=gdd.GoodsID " +
  342. "inner join TP_MST_DataDictionary on TP_MST_DataDictionary.Dictionaryid=TP_MST_Goods.Glazetypeid " +
  343. "inner join TP_MST_GOODSTYPE on TP_MST_GOODSTYPE.GOODSTYPEID=TP_MST_Goods.Goodstypeid " +
  344. "inner join tp_sys_gmouldstatus on gdd.gmouldstatus = tp_sys_gmouldstatus.gmouldstatusid " +
  345. "left join tp_mst_user on gdd.CreateUserID=tp_mst_user.userid " +
  346. "left join TP_MST_DataDictionary b on gdd.NoGroutingRreason=b.DictionaryID " +
  347. "left join TP_MST_logo on gdd.logoid=TP_MST_logo.logoid " +
  348. "Where 1=1 " +
  349. "and gdd.Valueflag=1 " +
  350. "and gdd.AccountID=:AccountID ";
  351. return selSql;
  352. }
  353. /// <summary>
  354. /// 取得RPT010102_1画面(半检明细表)的查询数据
  355. /// </summary>
  356. /// <param name="user">登录用户信息</param>
  357. /// <param name="se">查询条件</param>
  358. /// <returns>查询结果</returns>
  359. public static ServiceResultEntity GetRPT010102SData(SUserInfo user, RPT010102_SE se)
  360. {
  361. IDBConnection conn = null;
  362. try
  363. {
  364. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  365. OracleParameter[] paras = new OracleParameter[]{
  366. new OracleParameter("in_goodsID",OracleDbType.Varchar2,se.GoodsIDS,ParameterDirection.Input),
  367. new OracleParameter("in_testUserID",OracleDbType.Varchar2,se.TestUserIDS,ParameterDirection.Input),
  368. new OracleParameter("in_groutingUserID",OracleDbType.Varchar2,se.GroutingUserIDS,ParameterDirection.Input),
  369. new OracleParameter("in_goodsTypeID",OracleDbType.Varchar2,se.GoodsTypeIDS,ParameterDirection.Input),
  370. new OracleParameter("in_semiTestTypeID",OracleDbType.Varchar2,se.semiTestTypeID,ParameterDirection.Input),
  371. new OracleParameter("in_remarks",OracleDbType.Varchar2,se.Remarks,ParameterDirection.Input),
  372. new OracleParameter("in_semiTestDateStart",OracleDbType.Varchar2,se.SemiTestDateStart,ParameterDirection.Input),
  373. new OracleParameter("in_semiTestDateEnd",OracleDbType.Varchar2,se.SemiTestDateEnd,ParameterDirection.Input),
  374. new OracleParameter("in_accountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  375. new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  376. };
  377. DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetSemiTestDetail", paras);
  378. ServiceResultEntity sre = new ServiceResultEntity();
  379. if (data == null || data.Tables.Count == 0)
  380. {
  381. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  382. return sre;
  383. }
  384. sre.Data = new DataSet();
  385. sre.Data = data;
  386. return sre;
  387. }
  388. catch (Exception ex)
  389. {
  390. throw ex;
  391. }
  392. finally
  393. {
  394. if (conn != null &&
  395. conn.ConnState == ConnectionState.Open)
  396. {
  397. conn.Close();
  398. }
  399. }
  400. }
  401. /// <summary>
  402. /// 取得RPT010103画面(交坯明细表)的查询数据
  403. /// </summary>
  404. /// <param name="user">登录用户信息</param>
  405. /// <param name="se">查询条件</param>
  406. /// <returns>查询结果</returns>
  407. public static ServiceResultEntity GetRPT010103SData(SUserInfo user, RPT010103_SE se)
  408. {
  409. IDBConnection conn = null;
  410. try
  411. {
  412. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  413. List<OracleParameter> parameters = new List<OracleParameter>();
  414. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010103SSQL());
  415. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  416. // parameters.Add(new OracleParameter(":UPUserId", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  417. if (se != null)
  418. {
  419. //成型线IDS
  420. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  421. {
  422. sql.Append(" and instr(','||:GroutingLineIDS||',',','||pd.GroutingLineID||',')>0 ");
  423. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  424. }
  425. // 成型线类别
  426. if (!string.IsNullOrEmpty(se.GMouldTypeIDS))
  427. {
  428. sql.Append(" AND instr(','||:GMouldTypeIDS||',',','||gt.GMouldTypeID||',')>0 ");
  429. parameters.Add(new OracleParameter(":GMouldTypeIDS", OracleDbType.NVarchar2, se.GMouldTypeIDS, ParameterDirection.Input));
  430. }
  431. // 交坯日期-开始
  432. if (se.CreateTimeBegin.HasValue)
  433. {
  434. sql.Append(" AND pd.CreateTime >= :CreateTimeBegin ");
  435. parameters.Add(new OracleParameter(":CreateTimeBegin", OracleDbType.Date, se.CreateTimeBegin.Value, ParameterDirection.Input));
  436. }
  437. // 交坯日期-结束
  438. if (se.CreateTimeEnd.HasValue)
  439. {
  440. sql.Append(" AND pd.CreateTime <= :CreateTimeEnd ");
  441. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  442. }
  443. // 注浆模具编号
  444. if (!string.IsNullOrEmpty(se.GroutingMouldCode))
  445. {
  446. //sql.Append(" AND INSTR(','||:GroutingMouldCode||',',','||pd.GroutingMouldCode||',') > 0 ");
  447. sql.Append(" AND INSTR(pd.GroutingMouldCode,:GroutingMouldCode) > 0 ");
  448. parameters.Add(new OracleParameter(":GroutingMouldCode", OracleDbType.NVarchar2, se.GroutingMouldCode, ParameterDirection.Input));
  449. }
  450. //产品IDS
  451. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  452. {
  453. // sql.Append(" and instr(','||:GoodsTypeIDS||',',','||gdt.GoodsTypeCode||',')=1");
  454. sql.Append("AND instr(gdt.GoodsTypeCode,:GoodsTypeIDS)=1 ");
  455. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  456. }
  457. //产品类别IDS
  458. if (!string.IsNullOrEmpty(se.GoodsIDS))
  459. {
  460. sql.Append(" and instr(','||:GoodsIDS||',',','||pd.goodsid||',')>0");
  461. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  462. }
  463. // 备注
  464. if (!string.IsNullOrEmpty(se.Remarks))
  465. {
  466. sql.Append(" AND INSTR(pd.Remarks, :Remarks) > 0");
  467. parameters.Add(new OracleParameter(":Remarks", OracleDbType.NVarchar2, se.Remarks, ParameterDirection.Input));
  468. }
  469. // 注浆工号
  470. if (!string.IsNullOrEmpty(se.GroutingUserCode))
  471. {
  472. sql.Append(" AND INSTR( ','||:GroutingUserCode||',',','||pd.GroutingUserCode||',') > 0");
  473. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.NVarchar2, se.GroutingUserCode, ParameterDirection.Input));
  474. }
  475. // 条码
  476. if (!string.IsNullOrEmpty(se.BarCode))
  477. {
  478. //sql.Append(" AND INSTR(','||:BarCode||',',','||pd.BarCode||',') > 0");
  479. sql.Append(" AND INSTR(pd.BarCode,:BarCode) > 0");
  480. parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.BarCode, ParameterDirection.Input));
  481. }
  482. // 生产工号和注浆工号不同
  483. if (se.ProdUserIsGroutingUserFlag == 1)
  484. {
  485. sql.Append(" and pd.usercode<>pd.GroutingUserCode");
  486. }
  487. }
  488. sql.Append(" ORDER BY pd.CreateTime, pd.GroutingLineCode, pd.GroutingMouldCode");
  489. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  490. ServiceResultEntity sre = new ServiceResultEntity();
  491. if (data == null || data.Rows.Count == 0)
  492. {
  493. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  494. return sre;
  495. }
  496. sre.Data = new DataSet();
  497. sre.Data.Tables.Add(data);
  498. return sre;
  499. }
  500. catch (Exception ex)
  501. {
  502. throw ex;
  503. }
  504. finally
  505. {
  506. if (conn != null &&
  507. conn.ConnState == ConnectionState.Open)
  508. {
  509. conn.Close();
  510. }
  511. }
  512. }
  513. /// <summary>
  514. /// 获取RPT010103画面(交坯明细表)的查询sql
  515. /// </summary>
  516. /// <returns>sql</returns>
  517. private static string GetRPT010103SSQL()
  518. {
  519. string selSql =
  520. "select "
  521. //---产品条码
  522. + "pd.barcode, "
  523. //注浆时间
  524. + "pd.groutingdate,"
  525. //交坯时间
  526. + "pd.CreateTime,"
  527. //---产品类别
  528. + "g.GoodsTypeID,"
  529. //---产品类别编码
  530. + "gdt.GoodsTypeCode,"
  531. //---产品类别名称
  532. + "gdt.GoodsTypeName,"
  533. //----产品ID
  534. + "pd.goodsid,"
  535. //----产品编码
  536. + "pd.goodscode,"
  537. //----产品名称
  538. + "pd.goodsname,"
  539. //----规格
  540. + "g.GoodsSpecification,"
  541. //----釉色类别ID
  542. + "g.GlazeTypeID,"
  543. //----釉色类别描述
  544. + "dd.dictionaryvalue as GlazeTypeName,"
  545. //----注浆模具
  546. + "pd.GroutingMouldCode,"
  547. //---生产线号
  548. + "pd.ProductionLineID,"
  549. //---成型线编码
  550. + "pd.ProductionLineCode,"
  551. //---成型线名称
  552. + "pd.ProductionLineName,"
  553. //---成型线号Id
  554. + " pd.GroutingLineID,"
  555. //---成型线号
  556. + " pd.GroutingLineCode,"
  557. //---成型线类型ID
  558. + "gt.GMouldTypeID,"
  559. //---成型线类型
  560. + "gt.GMouldTypeName,"
  561. //---生产工号
  562. + "pd.UserID,"
  563. //---生产工号用户编号
  564. + "u.usercode,"
  565. //----注浆工号
  566. + "pd.GroutingUserID,"
  567. //---注浆工号用户编号
  568. + "pd.GroutingUserCode, "
  569. // 成型班长
  570. + " mu.username as MONITORName,"
  571. //--公坯标识
  572. + " pd.ISPUBLICBODY, "
  573. //--注浆次数
  574. + " gdd.GROUTINGCOUNT, "
  575. + " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName "
  576. //--查油工号
  577. + " , uc.usercode check1 "
  578. //生产数据
  579. + "from TP_PM_PRODUCTIONDATA pd "
  580. // 成型线
  581. + " LEFT JOIN tp_pc_groutingline gl" +
  582. " ON gl.groutinglineid = pd.GroutingLineID" +
  583. // 成型班长
  584. " LEFT JOIN tp_mst_user mu" +
  585. " ON mu.userid = gl.MONITORID"
  586. //注浆明细
  587. + " inner join TP_PM_GROUTINGDAILYDETAIL gdd on pd.GROUTINGDAILYDETAILID=gdd.GROUTINGDAILYDETAILID "
  588. //模具类型
  589. + "inner join TP_MST_GMouldType gt "
  590. + "on pd.GMOULDTYPEID=gt.GMouldTypeID "
  591. //产品档案
  592. + "inner join TP_MST_Goods g "
  593. + "on pd.goodsid=g.goodsid "
  594. //数据字典,TPC002为釉色类别
  595. + "inner join TP_MST_DataDictionary dd "
  596. //
  597. + "on dd.DictionaryType = 'TPC002' "
  598. //
  599. + "and dd.dictionaryid= g.GlazeTypeID "
  600. //用户信息
  601. + "inner join tp_mst_user u "
  602. + "on pd.userid=u.userid "
  603. + "inner join tp_mst_user uc "
  604. + "on pd.createuserid=uc.userid "
  605. //
  606. + "inner join TP_MST_GoodsType gdt "
  607. + "on g.GoodsTypeID=gdt.GoodsTypeID "
  608. + "inner join TP_MST_logo "
  609. + "on gdd.logoid=TP_MST_logo.logoid "
  610. // 交坯
  611. + " WHERE pd.modeltype=5 "
  612. // 账套
  613. + " and pd.AccountID=:AccountID"
  614. + " and pd.ValueFlag='" + (int)Constant.ValueFlag.Effective + "'";
  615. //成型线查看权限
  616. //+ " and exists (select up.PurviewID "
  617. //+ " from TP_MST_UserPurview up where up.PurviewType='"
  618. //+ (int)Constant.PurviewType.ViewGroutingLine
  619. //+ "' and up.PurviewID=pd.GroutingLineID "
  620. //+ " and up.UserId=:UPUserId)";
  621. return selSql;
  622. }
  623. /// <summary>
  624. /// 取得RPT010105画面(成型线模具使用明细表)的查询数据
  625. /// </summary>
  626. /// <param name="user">登录用户信息</param>
  627. /// <param name="se">查询条件</param>
  628. /// <returns>查询结果</returns>
  629. public static ServiceResultEntity GetRPT010105SData(SUserInfo user, RPT010105_SE se)
  630. {
  631. IDBConnection conn = null;
  632. try
  633. {
  634. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  635. //string sqlString =
  636. // "SELECT t.groutinglinecode\n" +
  637. // " ,gl.BuildingNo\n" +
  638. // " ,gl.FloorNo\n" +
  639. // " ,gl.GroutingLineNo\n" +
  640. // " ,t.usercode\n" +
  641. // " ,t.goodscode\n" +
  642. // " ,t.GOODSSPECIFICATION\n" +
  643. // " ,t.goodstypename\n" +
  644. // " ,t.MouldQuantity\n" +
  645. // " ,gld.groutingmouldcode\n" +
  646. // " ,gms.gmouldstatusname\n" +
  647. // " ,gld.beginuseddate\n" +
  648. // " ,(SELECT MIN(ggg.groutingdate)\n" +
  649. // " FROM tp_pm_groutingdailydetail ggg\n" +
  650. // " WHERE ggg.groutinglinedetailid = t.groutinglinedetailid) groutingdate\n" +
  651. // " ,MAX(t.GroutingCount)-SUM(t.groutingflag) mingroutingcount\n" +
  652. // " ,SUM(t.groutingflag) sumgroutingcount\n" +
  653. // " ,MAX(t.GroutingCount) maxGroutingCount\n" +
  654. // " ,gld.groutingcount\n" +
  655. // " ,MAX(gld.standardgroutingcount) standardgroutingcount\n" +
  656. // " ,gld.ENDUSEDDATE\n" +
  657. // " ,gld.standardgroutingcount - (MAX(t.GroutingCount)+SUM(t.groutingflag)) - SUM(t.groutingflag) leftcount\n" +
  658. // " FROM (SELECT gd.groutinglinecode\n" +
  659. // " ,gd.usercode\n" +
  660. // " ,gdd.goodsid\n" +
  661. // " ,gd.MouldQuantity\n" +
  662. // " ,gdd.groutinglinedetailid\n" +
  663. // " ,decode(gdd.groutingflag, '1', 1, 0) groutingflag\n" +
  664. // " ,gdd.GroutingCount\n" +
  665. // " ,gt.goodstypename\n" +
  666. // " ,g.goodscode\n" +
  667. // " ,g.GOODSSPECIFICATION\n" +
  668. // " FROM TP_PM_GroutingDaily gd\n" +
  669. // " INNER JOIN TP_PM_GroutingDailyDetail gdd\n" +
  670. // " ON gdd.groutingdailyid = gd.groutingdailyid\n" +
  671. // " INNER JOIN TP_MST_Goods g\n" +
  672. // " ON g.goodsid = gdd.goodsid\n" +
  673. // " INNER JOIN TP_MST_GOODSTYPE gt\n" +
  674. // " ON gt.goodstypeid = g.goodstypeid\n" +
  675. // " WHERE gd.accountid = :AccountID\n" +
  676. // " AND gd.groutingdate >= :GDateBegin\n" +
  677. // " AND gd.groutingdate <= :GDateEnd\n" +
  678. // " AND (:groutinglinecode is null or instr(gd.groutinglinecode, :groutinglinecode) > 0)\n" +
  679. // " AND (:groutingusercode is null or instr(gdd.usercode, :groutingusercode) > 0)\n" +
  680. // " AND (:goodscode is null or instr(gdd.goodscode, :goodscode) > 0)\n" +
  681. // " AND (:goodstypecode is null or instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  682. // " ) t\n" +
  683. // " INNER JOIN tp_pc_groutinglinedetail gld\n" +
  684. // " ON gld.groutinglinedetailid = t.groutinglinedetailid\n" +
  685. // " INNER JOIN tp_pc_groutingline gl\n" +
  686. // " ON gld.groutinglineid = gl.groutinglineid\n" +
  687. // " INNER JOIN TP_SYS_GMouldStatus gms\n" +
  688. // " ON gms.gmouldstatusid = gld.gmouldstatus\n" +
  689. // " GROUP BY t.groutinglinecode\n" +
  690. // " ,gl.BuildingNo\n" +
  691. // " ,gl.FloorNo\n" +
  692. // " ,gl.GroutingLineNo\n" +
  693. // " ,t.usercode\n" +
  694. // " ,t.goodscode\n" +
  695. // " ,t.GOODSSPECIFICATION\n" +
  696. // " ,t.goodstypename\n" +
  697. // " ,t.MouldQuantity\n" +
  698. // " ,gld.groutingmouldcode\n" +
  699. // " ,gms.gmouldstatusname\n" +
  700. // " ,gld.beginuseddate\n" +
  701. // " ,gld.groutingcount\n" +
  702. // " ,gld.ENDUSEDDATE\n" +
  703. // " ,t.groutinglinedetailid\n" +
  704. // " ORDER BY t.groutinglinecode, gld.groutingmouldcode, t.groutinglinedetailid";
  705. string sqlString = @"SELECT
  706. groutinglinecode,
  707. BuildingNo,
  708. FloorNo,
  709. GroutingLineNo,
  710. usercode,
  711. goodscode,
  712. GOODSSPECIFICATION,
  713. goodstypename,
  714. MouldQuantity,
  715. groutingmouldcode,
  716. gmouldstatusname,
  717. beginuseddate,
  718. groutingdate,
  719. mingroutingcount,
  720. sumgroutingcount,
  721. maxGroutingCount,
  722. groutingcount,
  723. standardgroutingcount,
  724. ENDUSEDDATE,
  725. standardgroutingcount - mingroutingcount - sumgroutingcount leftcount,
  726. CASE WHEN gmouldstatusname <> '正常' AND standardgroutingcount-sumgroutingcount+mingroutingcount > standardgroutingcount THEN 0
  727. WHEN gmouldstatusname <> '正常' AND standardgroutingcount-sumgroutingcount+mingroutingcount < standardgroutingcount THEN standardgroutingcount-sumgroutingcount+mingroutingcount
  728. ELSE sumgroutingcount END financecount,
  729. standardgroutingcount - mingroutingcount mingresidue
  730. FROM
  731. (
  732. SELECT
  733. t.groutinglinecode,
  734. gl.BuildingNo,
  735. gl.FloorNo,
  736. gl.GroutingLineNo,
  737. t.usercode,
  738. t.goodscode,
  739. t.GOODSSPECIFICATION,
  740. t.goodstypename,
  741. t.MouldQuantity,
  742. gld.groutingmouldcode,
  743. gms.gmouldstatusname,
  744. gld.beginuseddate,
  745. ( SELECT MIN( ggg.groutingdate ) FROM tp_pm_groutingdailydetail ggg WHERE ggg.groutinglinedetailid = t.groutinglinedetailid ) groutingdate,
  746. MAX( t.GroutingCount ) - SUM( t.groutingflag ) mingroutingcount,
  747. SUM( t.groutingflag ) sumgroutingcount,
  748. MAX( t.GroutingCount ) maxGroutingCount,
  749. gld.groutingcount,
  750. MAX( gld.standardgroutingcount ) standardgroutingcount,
  751. gld.ENDUSEDDATE
  752. FROM
  753. (
  754. SELECT
  755. gd.groutinglinecode,
  756. gd.usercode,
  757. gdd.goodsid,
  758. gd.MouldQuantity,
  759. gdd.groutinglinedetailid,
  760. decode( gdd.groutingflag, '1', 1, 0 ) groutingflag,
  761. gdd.GroutingCount,
  762. gt.goodstypename,
  763. g.goodscode,
  764. g.GOODSSPECIFICATION
  765. FROM
  766. TP_PM_GroutingDaily gd
  767. INNER JOIN TP_PM_GroutingDailyDetail gdd ON gdd.groutingdailyid = gd.groutingdailyid
  768. INNER JOIN TP_MST_Goods g ON g.goodsid = gdd.goodsid
  769. INNER JOIN TP_MST_GOODSTYPE gt ON gt.goodstypeid = g.goodstypeid
  770. WHERE
  771. gd.accountid = 1
  772. AND gd.groutingdate >= :GDateBegin
  773. AND gd.groutingdate <= :GDateEnd
  774. AND ( : groutinglinecode IS NULL OR instr( gd.groutinglinecode, : groutinglinecode ) > 0 )
  775. AND ( : groutingusercode IS NULL OR instr( gdd.usercode, : groutingusercode ) > 0 )
  776. AND ( : goodscode IS NULL OR instr( gdd.goodscode, : goodscode ) > 0 )
  777. AND ( : goodstypecode IS NULL OR instr( gt.goodstypecode, : goodstypecode ) = 1 )
  778. ) t
  779. INNER JOIN tp_pc_groutinglinedetail gld ON gld.groutinglinedetailid = t.groutinglinedetailid
  780. INNER JOIN tp_pc_groutingline gl ON gld.groutinglineid = gl.groutinglineid
  781. INNER JOIN TP_SYS_GMouldStatus gms ON gms.gmouldstatusid = gld.gmouldstatus
  782. GROUP BY
  783. t.groutinglinecode,
  784. gl.BuildingNo,
  785. gl.FloorNo,
  786. gl.GroutingLineNo,
  787. t.usercode,
  788. t.goodscode,
  789. t.GOODSSPECIFICATION,
  790. t.goodstypename,
  791. t.MouldQuantity,
  792. gld.groutingmouldcode,
  793. gms.gmouldstatusname,
  794. gld.beginuseddate,
  795. gld.groutingcount,
  796. gld.ENDUSEDDATE,
  797. t.groutinglinedetailid
  798. ORDER BY
  799. BuildingNo,
  800. GroutingLineNo,
  801. groutinglinecode,
  802. groutingmouldcode
  803. )";
  804. List <OracleParameter> parameters = new List<OracleParameter>();
  805. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  806. parameters.Add(new OracleParameter(":GDateBegin", OracleDbType.Date, se.GDateBegin, ParameterDirection.Input));
  807. parameters.Add(new OracleParameter(":GDateEnd", OracleDbType.Date, se.GDateEnd, ParameterDirection.Input));
  808. parameters.Add(new OracleParameter(":groutinglinecode", OracleDbType.Varchar2, se.GroutingLineCode, ParameterDirection.Input));
  809. parameters.Add(new OracleParameter(":groutingusercode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  810. parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  811. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  812. DataTable data = conn.GetSqlResultToDt(sqlString.ToString(), parameters.ToArray());
  813. ServiceResultEntity sre = new ServiceResultEntity();
  814. if (data == null || data.Rows.Count == 0)
  815. {
  816. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  817. return sre;
  818. }
  819. sre.Data = new DataSet();
  820. sre.Data.Tables.Add(data);
  821. return sre;
  822. }
  823. catch (Exception ex)
  824. {
  825. throw ex;
  826. }
  827. finally
  828. {
  829. if (conn != null &&
  830. conn.ConnState == ConnectionState.Open)
  831. {
  832. conn.Close();
  833. }
  834. }
  835. }
  836. /// <summary>
  837. /// 取得RPT010106画面(成型线剩余注浆次数)的查询数据
  838. /// </summary>
  839. /// <param name="user">登录用户信息</param>
  840. /// <param name="se">查询条件</param>
  841. /// <returns>查询结果</returns>
  842. public static ServiceResultEntity GetRPT010106SData(SUserInfo user, RPT010106_SE se)
  843. {
  844. IDBConnection conn = null;
  845. try
  846. {
  847. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  848. string sqlString =
  849. "SELECT gl.buildingno\n" +
  850. " ,gl.floorno\n" +
  851. " ,gl.groutinglineno\n" +
  852. " ,gl.groutinglinecode\n" +
  853. " ,gl.Remarks\n" +
  854. " ,decode(UserCount,\n" +
  855. " 1,\n" +
  856. " mu.usercode,\n" +
  857. " (SELECT wmsys.wm_concat(to_char(gmu.usercode))\n" +
  858. " FROM tp_pc_groutinguser gu\n" +
  859. " INNER JOIN tp_mst_user gmu\n" +
  860. " ON gmu.userid = gu.userid\n" +
  861. " WHERE gu.groutinglineid = gl.groutinglineid)) groutingusercode\n" +
  862. // 成型班长
  863. " ,mnu.username as MONITORName" +
  864. " ,g.goodscode\n" +
  865. " ,g.goodsspecification\n" +
  866. " ,gt.goodstypename\n" +
  867. " --,gl.mouldquantity\n" +
  868. " ,gldd.mouldquantity\n" +
  869. " ,gmt.gmouldtypename\n" +
  870. " ,gms.gmouldstatusname\n" +
  871. " ,gldd.beginuseddate -- 上模日期\n" +
  872. " ,gldd.groutingdate -- 首次注浆日期\n" +
  873. " ,gldd.standardgroutingcount AS standardcount -- 标准注浆次数\n" +
  874. " ,gldd.groutingcount -- 最大注浆次数\n" +
  875. " ,gldd.standardgroutingcount - gldd.groutingcount AS mincount --剩余最少注浆次数\n" +
  876. " ,gldd.sumstandardgroutingcount AS sumstandardcount -- 标准总注浆次数\n" +
  877. " ,gldd.sumgroutingcount -- 总注浆次数\n" +
  878. " ,gldd.sumstandardgroutingcount - gldd.sumgroutingcount AS leftcount --剩余总注浆次数\n" +
  879. " ,round(decode(gl.mouldquantity,\n" +
  880. " 0,\n" +
  881. " 0,\n" +
  882. " (gldd.sumstandardgroutingcount - gldd.sumgroutingcount) /\n" +
  883. " gl.mouldquantity),\n" +
  884. " 2) AS leftmaxcount -- 剩余最大注浆次数\n" +
  885. " FROM tp_pc_groutingline gl\n" +
  886. " INNER JOIN (SELECT gld.groutinglineid\n" +
  887. " ,gld.goodsid\n" +
  888. " ,COUNT(gld.groutinglinedetailid) mouldquantity\n" +
  889. " ,MIN(gld.beginuseddate) beginuseddate\n" +
  890. " ,MIN(gddd.groutingdate) groutingdate\n" +
  891. " /* ,(SELECT MIN(gdd.groutingdate)\n" +
  892. " FROM tp_pm_groutingdailydetail gdd\n" +
  893. " WHERE gdd.groutinglinedetailid = gld.groutinglinedetailid\n" +
  894. " AND gdd.groutingflag = '1') groutingdate*/\n" +
  895. " ,MAX(gld.standardgroutingcount) standardgroutingcount\n" +
  896. " ,MAX(gld.groutingcount) groutingcount\n" +
  897. " ,SUM(gld.standardgroutingcount) sumstandardgroutingcount\n" +
  898. " ,SUM(gld.groutingcount) sumgroutingcount\n" +
  899. " FROM tp_pc_groutinglinedetail gld\n" +
  900. " --LEFT JOIN tp_pm_groutingdailydetail gdd\n" +
  901. " -- ON gdd.groutinglinedetailid = gld.groutinglinedetailid\n" +
  902. " -- AND gdd.groutingflag = '1'\n" +
  903. " LEFT JOIN (SELECT gdd.groutinglinedetailid\n" +
  904. " ,gdd.mouldcode\n" +
  905. " ,MIN(gdd.groutingdate) groutingdate\n" +
  906. " FROM tp_pm_groutingdailydetail gdd\n" +
  907. " WHERE gdd.accountid = :AccountID\n" +
  908. " AND gdd.groutingflag = '1'\n" +
  909. " GROUP BY gdd.groutinglinedetailid, gdd.mouldcode) gddd\n" +
  910. " ON gddd.groutinglinedetailid = gld.groutinglinedetailid\n" +
  911. " AND gddd.mouldcode = gld.mouldcode\n" +
  912. " WHERE gld.valueflag = '1'\n" +
  913. " GROUP BY gld.groutinglineid, gld.goodsid) gldd\n" +
  914. " ON gldd.groutinglineid = gl.groutinglineid\n" +
  915. " INNER JOIN tp_mst_goods g\n" +
  916. " ON g.goodsid = gldd.goodsid\n" +
  917. " INNER JOIN tp_mst_goodstype gt\n" +
  918. " ON gt.goodstypeid = g.goodstypeid\n" +
  919. " INNER JOIN tp_mst_gmouldtype gmt\n" +
  920. " ON gmt.gmouldtypeid = gl.gmouldtypeid\n" +
  921. " INNER JOIN tp_sys_gmouldstatus gms\n" +
  922. " ON gms.gmouldstatusid = gl.gmouldstatus\n" +
  923. " INNER JOIN tp_mst_user mu\n" +
  924. " ON mu.userid = gl.userid\n" +
  925. // 成型班长
  926. " LEFT JOIN tp_mst_user mnu" +
  927. " ON mnu.userid = gl.MONITORID" +
  928. " WHERE gl.accountid = :AccountID\n" +
  929. " AND gl.valueflag = '1'\n" +
  930. " AND (:Remarks is null or instr(gl.Remarks, :Remarks) > 0)\n" +
  931. " AND (:groutinglinecode is null or instr(gl.groutinglinecode, :groutinglinecode) > 0)\n" +
  932. " AND (:goodscode is null or instr(g.goodscode, :goodscode) > 0)\n" +
  933. " AND (:goodstypecode is null or instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  934. " ORDER BY gl.groutinglinecode, g.goodscode";
  935. List<OracleParameter> parameters = new List<OracleParameter>();
  936. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  937. parameters.Add(new OracleParameter(":Remarks", OracleDbType.Varchar2, se.Remarks, ParameterDirection.Input));
  938. parameters.Add(new OracleParameter(":groutinglinecode", OracleDbType.Varchar2, se.GroutingLineCode, ParameterDirection.Input));
  939. parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  940. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  941. DataTable data = conn.GetSqlResultToDt(sqlString.ToString(), parameters.ToArray());
  942. ServiceResultEntity sre = new ServiceResultEntity();
  943. if (data == null || data.Rows.Count == 0)
  944. {
  945. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  946. return sre;
  947. }
  948. sre.Data = new DataSet();
  949. sre.Data.Tables.Add(data);
  950. return sre;
  951. }
  952. catch (Exception ex)
  953. {
  954. throw ex;
  955. }
  956. finally
  957. {
  958. if (conn != null &&
  959. conn.ConnState == ConnectionState.Open)
  960. {
  961. conn.Close();
  962. }
  963. }
  964. }
  965. /// <summary>
  966. /// 取得RPT010201_1画面(工序漏扫明细表)的查询数据
  967. /// </summary>
  968. /// <param name="user">登录用户信息</param>
  969. /// <param name="se">查询条件</param>
  970. /// <returns>查询结果</returns>
  971. public static ServiceResultEntity GetRPT010201SData(SUserInfo user, RPT010201_SE se)
  972. {
  973. IDBConnection conn = null;
  974. try
  975. {
  976. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  977. List<OracleParameter> parameters = new List<OracleParameter>();
  978. // 校验时间--开始
  979. if (se.beginCreateTime.HasValue)
  980. {
  981. parameters.Add(new OracleParameter("in_stardate", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  982. }
  983. // 校验时间--结束
  984. if (se.endCreateTime.HasValue)
  985. {
  986. parameters.Add(new OracleParameter("in_enddate", OracleDbType.Date, se.endCreateTime.Value, ParameterDirection.Input));
  987. }
  988. conn.ExecStoredProcedure("PRO_PM_InitBarcodeMissing", parameters.ToArray());
  989. parameters.Clear();
  990. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010201SSQL(user, se, ref parameters));
  991. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  992. ServiceResultEntity sre = new ServiceResultEntity();
  993. if (data == null || data.Rows.Count == 0)
  994. {
  995. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  996. return sre;
  997. }
  998. sre.Data = new DataSet();
  999. sre.Data.Tables.Add(data);
  1000. return sre;
  1001. }
  1002. catch (Exception ex)
  1003. {
  1004. throw ex;
  1005. }
  1006. finally
  1007. {
  1008. if (conn != null &&
  1009. conn.ConnState == ConnectionState.Open)
  1010. {
  1011. conn.Close();
  1012. }
  1013. }
  1014. }
  1015. /// <summary>
  1016. /// 获取RPT010201_1画面(工序漏扫明细表)的查询sql
  1017. /// </summary>
  1018. /// <returns>sql</returns>
  1019. private static string GetRPT010201SSQL(SUserInfo user, RPT010201_SE se, ref List<OracleParameter> parameters)
  1020. {
  1021. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  1022. #region
  1023. /*
  1024. selSql = selSql +
  1025. "select * from (" +
  1026. "select " +
  1027. "MissProcedureID, " +
  1028. "MissProcedureCode, " +
  1029. "case when GoodsType=TP_MST_GoodsType.GoodsTypeCode then to_char(TP_MST_GoodsType.GoodsTypeName) else to_char(GoodsType) end GoodsType, " +
  1030. "MissProcedureName, " +
  1031. "MissID, " +
  1032. "BarCode, " +
  1033. "OrganizationID, " +
  1034. "OrganizationName, " +
  1035. "OrganizationCode, " +
  1036. "OrganizationFullName, " +
  1037. "CompleteProcedureID, " +
  1038. "CompleteProcedureCode, " +
  1039. "CompleteProcedureName, " +
  1040. "ProcedureID, " +
  1041. "ProcedureCode, " +
  1042. "ProcedureName, " +
  1043. "GoodsID, " +
  1044. "GoodsCode, " +
  1045. "GoodsName, " +
  1046. "result.GoodsTypeID, " +
  1047. "result.CreateTime, " +
  1048. "result.GoodsTypeName, " +
  1049. "UserName, " +
  1050. "MissUserCode, " +
  1051. "barcodecount, seqno " +
  1052. "from " +
  1053. " ( " +
  1054. " select " +
  1055. " MissProcedureID, " +
  1056. " MissProcedureCode, " +
  1057. " decode(MissProcedureName,'小计',decode(MissProcedureID,'--','合计','--'),GoodsType) GoodsType, " +
  1058. " decode(MissProcedureID,'--','--',decode(MissProcedureName,'小计','小计',MissProcedureName)) MissProcedureName, " +
  1059. " MissID, " +
  1060. " BarCode, " +
  1061. " OrganizationID, " +
  1062. " OrganizationName, " +
  1063. " OrganizationCode, " +
  1064. " OrganizationFullName, " +
  1065. " CompleteProcedureID, " +
  1066. " CompleteProcedureCode, " +
  1067. " CompleteProcedureName, " +
  1068. " ProcedureID, " +
  1069. " ProcedureCode, " +
  1070. " ProcedureName, " +
  1071. " GoodsID, " +
  1072. " GoodsCode, " +
  1073. " GoodsName, " +
  1074. " GoodsTypeID, " +
  1075. " CreateTime, " +
  1076. " GoodsTypeName, " +
  1077. " UserName, " +
  1078. " MissUserCode, " +
  1079. " barcodecount,rownum seqno " +
  1080. " from " +
  1081. " ( " +
  1082. " select " +
  1083. " decode(grouping( MissProcedureID),1,'--',MissProcedureID) MissProcedureID, " +
  1084. " decode(grouping( MissProcedureCode),1,'--',MissProcedureCode) MissProcedureCode, " +
  1085. " decode(grouping( MissProcedureName),1,'小计',MissProcedureName) MissProcedureName, " +
  1086. " decode(grouping(GoodsType),1,'合计',GoodsType) GoodsType, " +
  1087. " decode(grouping(MissID),1,'--',MissID) MissID, " +
  1088. " decode(grouping(BarCode),1,'--',BarCode) BarCode, " +
  1089. " decode(grouping(OrganizationID),1,'--',OrganizationID) OrganizationID, " +
  1090. " decode(grouping(OrganizationName),1,'--',OrganizationName) OrganizationName, " +
  1091. " decode(grouping(OrganizationCode),1,'--',OrganizationCode) OrganizationCode, " +
  1092. " decode(grouping(OrganizationFullName),1,'--',OrganizationFullName) OrganizationFullName, " +
  1093. " decode(grouping(CompleteProcedureID),1,'--',CompleteProcedureID) CompleteProcedureID, " +
  1094. " decode(grouping(CompleteProcedureCode),1,'--',CompleteProcedureCode) CompleteProcedureCode, " +
  1095. " decode(grouping(CompleteProcedureName),1,'--',CompleteProcedureName) CompleteProcedureName, " +
  1096. " decode(grouping(ProcedureID),1,'--',ProcedureID) ProcedureID, " +
  1097. " decode(grouping(ProcedureCode),1,'--',ProcedureCode) ProcedureCode, " +
  1098. " decode(grouping(ProcedureName),1,'--',ProcedureName) ProcedureName, " +
  1099. " decode(grouping(GoodsID),1,'--',GoodsID) GoodsID, " +
  1100. " decode(grouping(GoodsCode),1,'--',GoodsCode) GoodsCode, " +
  1101. " decode(grouping(GoodsName),1,'--',GoodsName) GoodsName, " +
  1102. " decode(grouping(GoodsTypeID),1,'--',GoodsTypeID) GoodsTypeID, " +
  1103. " decode(grouping(CreateTime),1,'--',CreateTime) CreateTime, " +
  1104. " decode(grouping(GoodsTypeName),1,'--',GoodsTypeName) GoodsTypeName, " +
  1105. " decode(grouping(UserName),1,'--',UserName) UserName, " +
  1106. " decode(grouping(MissUserCode),1,'--',MissUserCode) MissUserCode, " +
  1107. " count(barcode) barcodecount " +
  1108. " from " +
  1109. " ( " +
  1110. " select TP_PM_BarCodeMissing.MissProcedureID, " +
  1111. " TP_PM_BarCodeMissing.MissProcedureCode, " +
  1112. " TP_PM_BarCodeMissing.MissProcedureName, " +
  1113. " substr(TP_MST_GoodsType.GOODSTYPECODE,1,6) GoodsType, " +
  1114. " TP_PM_BarCodeMissing.MissID, " +
  1115. " TP_PM_BarCodeMissing.BarCode, " +
  1116. " TP_PM_BarCodeMissing.OrganizationID, " +
  1117. " TP_PM_BarCodeMissing.OrganizationName, " +
  1118. " TP_PM_BarCodeMissing.OrganizationCode, " +
  1119. " TP_PM_BarCodeMissing.OrganizationFullName, " +
  1120. " TP_PM_BarCodeMissing.CompleteProcedureID, " +
  1121. " TP_PM_BarCodeMissing.CompleteProcedureCode, " +
  1122. " TP_PM_BarCodeMissing.CompleteProcedureName, " +
  1123. " TP_PM_BarCodeMissing.ProcedureID, " +
  1124. " TP_PM_BarCodeMissing.ProcedureCode, " +
  1125. " TP_PM_BarCodeMissing.ProcedureName, " +
  1126. " TP_PM_BarCodeMissing.GoodsID, " +
  1127. " TP_PM_BarCodeMissing.GoodsCode, " +
  1128. " TP_PM_BarCodeMissing.GoodsName, " +
  1129. " TP_PM_BarCodeMissing.GoodsTypeID, " +
  1130. " TP_PM_BarCodeMissing.MissUserCode, " +
  1131. " to_char(TP_PM_BarCodeMissing.CreateTime,'yyyy-MM-dd HH24:mi:ss') CreateTime, " +
  1132. " TP_MST_GoodsType.GoodsTypeName, " +
  1133. " TP_MST_USER.UserName " +
  1134. " from TP_PM_BarCodeMissing left join TP_MST_GoodsType " +
  1135. " on TP_PM_BarCodeMissing.GoodsTypeID=TP_MST_GoodsType.GoodsTypeID " +
  1136. " left join TP_MST_USER " +
  1137. " on TP_PM_BarCodeMissing.CreateUserID=TP_MST_USER.UserID " +
  1138. " where TP_PM_BarCodeMissing.valueflag=1 " +
  1139. " and TP_PM_BarCodeMissing.accountid=:AccountID ";
  1140. // 产品条码
  1141. if (!string.IsNullOrEmpty(se.Barcode))
  1142. {
  1143. selSql = selSql + " and TP_PM_BarCodeMissing.barcode=:Barcode ";
  1144. parameters.Add(new OracleParameter(":Barcode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  1145. }
  1146. // 组织结构
  1147. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  1148. {
  1149. selSql = selSql + " and instr(',' || :OrganizationIDS || ',' ,','||TP_PM_BarCodeMissing.OrganizationID||',' )>0 ";
  1150. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  1151. }
  1152. // 完成工序
  1153. if (!string.IsNullOrEmpty(se.CompleteProcedureIDS))
  1154. {
  1155. selSql = selSql + " and instr(',' || :CompleteProcedureIDS || ',',','||TP_PM_BarCodeMissing.CompleteProcedureID||',' )>0 ";
  1156. parameters.Add(new OracleParameter(":CompleteProcedureIDS", OracleDbType.NVarchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  1157. }
  1158. // 校验工序
  1159. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  1160. {
  1161. selSql = selSql + " and instr(',' || :ProcedureIDS || ',',','||TP_PM_BarCodeMissing.procedureID||',' )>0 ";
  1162. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  1163. }
  1164. // 漏扫工序
  1165. if (!string.IsNullOrEmpty(se.MissingProcedureIDS))
  1166. {
  1167. selSql = selSql + " and instr(',' || :MissingProcedureIDS || ',',','||TP_PM_BarCodeMissing.missProcedureID||',' )>0 ";
  1168. parameters.Add(new OracleParameter(":MissingProcedureIDS", OracleDbType.NVarchar2, se.MissingProcedureIDS, ParameterDirection.Input));
  1169. }
  1170. // 产品IDS
  1171. if (!string.IsNullOrEmpty(se.GoodsIDS))
  1172. {
  1173. selSql = selSql + " and instr(',' || :GoodsIDS || ',',','||TP_PM_BarCodeMissing.goodsID||',' )>0 ";
  1174. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  1175. }
  1176. // 产品IDS
  1177. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  1178. {
  1179. selSql = selSql + " and instr(',' || :GoodsTypeIDS || ',',','||TP_PM_BarCodeMissing.goodsTypeID||',' )>0 ";
  1180. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  1181. }
  1182. // 校验时间--开始
  1183. if (se.beginCreateTime.HasValue)
  1184. {
  1185. selSql = selSql + " and TP_PM_BarCodeMissing.CreateTime>= :CreateTimeStart ";
  1186. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  1187. }
  1188. // 校验时间--结束
  1189. if (se.endCreateTime.HasValue)
  1190. {
  1191. selSql = selSql + " and TP_PM_BarCodeMissing.CreateTime<= :CreateTimeEnd ";
  1192. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.endCreateTime.Value, ParameterDirection.Input));
  1193. }
  1194. selSql = selSql +
  1195. // " order by missprocedureid,username " +
  1196. " ) " +
  1197. " group by rollup( " +
  1198. " GoodsType, " +
  1199. " MissProcedureID, " +
  1200. " MissProcedureCode, " +
  1201. " MissProcedureName, " +
  1202. " MissID, " +
  1203. " BarCode, " +
  1204. " OrganizationID, " +
  1205. " OrganizationName, " +
  1206. " OrganizationCode, " +
  1207. " OrganizationFullName, " +
  1208. " CompleteProcedureID, " +
  1209. " CompleteProcedureCode, " +
  1210. " CompleteProcedureName, " +
  1211. " ProcedureID, " +
  1212. " ProcedureCode, " +
  1213. " ProcedureName, " +
  1214. " GoodsID, " +
  1215. " GoodsCode, " +
  1216. " GoodsName, " +
  1217. " GoodsTypeID, " +
  1218. " CreateTime, " +
  1219. " GoodsTypeName,MissUserCode, " +
  1220. " UserName ) " +
  1221. " ) " +
  1222. " where UserName!='--' or " +
  1223. " (USERNAME='--' and missprocedurename='小计'and missprocedurecode='--' and missprocedureid!='--' ) " +
  1224. " or " +
  1225. " (USERNAME='--' and missprocedureid='--' and GoodsType!='合计') " +
  1226. " ) result left join TP_MST_GoodsType on result.GoodsType=TP_MST_GoodsType.GoodsTypeCode"
  1227. + " ) order by seqno";
  1228. */
  1229. #endregion
  1230. string selSql = "select decode(tt.gid, 0, tt.MissID, null) MissID, --漏扫ID\n" +
  1231. " decode(tt.gid, 7, '总计', 0, tt.BarCode, '--') BarCode, --产品条码\n" +
  1232. " --decode(tt.gid, 0, tt.OrganizationID, null) OrganizationID,\n" +
  1233. " --decode(tt.gid, 0, tt.OrganizationCode, '--') OrganizationCode,\n" +
  1234. " decode(tt.gid, 0, tt.OrganizationName, '--') OrganizationName, --漏扫部门\n" +
  1235. " --decode(tt.gid, 0, tt.OrganizationFullName, '--') OrganizationFullName,\n" +
  1236. " --decode(tt.gid, 0, tt.CompleteProcedureID, null) CompleteProcedureID,\n" +
  1237. " --decode(tt.gid, 0, tt.CompleteProcedureCode, '--') CompleteProcedureCode,\n" +
  1238. " decode(tt.gid, 0, tt.CompleteProcedureName, '--') CompleteProcedureName,\n" +
  1239. " --decode(tt.gid, 0, tt.ProcedureID, null) ProcedureID,\n" +
  1240. " --decode(tt.gid, 0, tt.ProcedureCode, '--') ProcedureCode,\n" +
  1241. " decode(tt.gid, 0, tt.ProcedureName, '--') ProcedureName,\n" +
  1242. " --decode(tt.gid, 0, tt.MissProcedureID, null) MissProcedureID,\n" +
  1243. " --decode(tt.gid, 0, tt.MissProcedureCode, '--') MissProcedureCode,\n" +
  1244. " decode(tt.gid, 1, '小计', 0, tt.MissProcedureName, '--') MissProcedureName,\n" +
  1245. " decode(tt.gid, 0, tt.GoodsID, null) GoodsID,\n" +
  1246. " decode(tt.gid, 0, tt.GoodsCode, '--') GoodsCode,\n" +
  1247. " decode(tt.gid, 0, tt.GoodsName, '--') GoodsName,\n" +
  1248. " decode(tt.gid, 0, tt.GoodsTypeID, null) GoodsTypeID,\n" +
  1249. " decode(tt.gid, 0, tt.MissUserID, null) MissUserID,\n" +
  1250. " decode(tt.gid, 0, tt.MissUserCode, '--') MissUserCode,\n" +
  1251. " decode(tt.gid, 0, tt.CreateTime, null) CreateTime,\n" +
  1252. " decode(tt.gid, 0, tt.CreateUserID, null) CreateUserID,\n" +
  1253. " decode(tt.gid, 0, tt.username, '--') username,\n" +
  1254. " decode(tt.gid, 0, tt.repaircode, '--') repaircode,\n" +
  1255. " decode(tt.gid, 0, tt.prepaircode, '--') prepaircode,\n" +
  1256. " decode(tt.gid, 3, '合计', 0, tt.goodstypename2, '--') goodstype,\n" +
  1257. " tt.barcodecount, --数量\n" +
  1258. " tt.LogoCodeName\n" +
  1259. " from (select grouping_id(t.goodstypename2, --产品大类\n" +
  1260. " --t.MissProcedureCode,\n" +
  1261. " t.MissProcedureName,\n" +
  1262. " t.MissID) gid,\n" +
  1263. " t.MissID, --漏扫ID\n" +
  1264. " t.BarCode, --产品条码\n" +
  1265. " --t.OrganizationID,\n" +
  1266. " --t.OrganizationCode,\n" +
  1267. " t.OrganizationName, --漏扫部门\n" +
  1268. " --t.OrganizationFullName,\n" +
  1269. " --t.CompleteProcedureID,\n" +
  1270. " --t.CompleteProcedureCode,\n" +
  1271. " t.CompleteProcedureName, --完成工序\n" +
  1272. " --t.ProcedureID,\n" +
  1273. " --t.ProcedureCode,\n" +
  1274. " t.ProcedureName, --校验工序\n" +
  1275. " --t.MissProcedureID,\n" +
  1276. " --t.MissProcedureCode,\n" +
  1277. " t.MissProcedureName, --漏扫工序\n" +
  1278. " t.GoodsID,\n" +
  1279. " t.GoodsCode, --产品编码\n" +
  1280. " t.GoodsName, --产品名称\n" +
  1281. " t.GoodsTypeID,\n" +
  1282. " t.MissUserID,\n" +
  1283. " t.MissUserCode, --漏扫工号\n" +
  1284. " t.CreateTime, --校验漏扫时间\n" +
  1285. " t.CreateUserID,\n" +
  1286. " t.username, --校验者\n" +
  1287. " t.repaircode, --补扫操作工号\n" +
  1288. " t.prepaircode, --补扫生产工号\n" +
  1289. " t.goodstypename2, --产品大类\n" +
  1290. " count(t.barcodecount) barcodecount, --数量\n" +
  1291. " t.LogoCodeName\n" +
  1292. " from (select bcm.MissID, --漏扫ID\n" +
  1293. " bcm.BarCode, --产品条码\n" +
  1294. " --bcm.OrganizationID,\n" +
  1295. " --bcm.OrganizationCode,\n" +
  1296. " bcm.OrganizationName, --漏扫部门\n" +
  1297. " --bcm.OrganizationFullName,\n" +
  1298. " --bcm.CompleteProcedureID,\n" +
  1299. " --bcm.CompleteProcedureCode,\n" +
  1300. " --bcm.CompleteProcedureName, --完成工序\n" +
  1301. " cedp.ProcedureName as CompleteProcedureName, --完成工序\n" +
  1302. " --bcm.ProcedureID,\n" +
  1303. " --bcm.ProcedureCode,\n" +
  1304. " --bcm.ProcedureName, --校验工序\n" +
  1305. " cp.ProcedureName, --校验工序\n" +
  1306. " --bcm.MissProcedureID,\n" +
  1307. " --bcm.MissProcedureCode,\n" +
  1308. " --bcm.MissProcedureName, --漏扫工序\n" +
  1309. " mp.ProcedureName as MissProcedureName, --漏扫工序\n" +
  1310. " bcm.GoodsID,\n" +
  1311. " bcm.GoodsCode, --产品编码\n" +
  1312. " bcm.GoodsName, --产品名称\n" +
  1313. " bcm.GoodsTypeID,\n" +
  1314. " bcm.MissUserID,\n" +
  1315. " bcm.MissUserCode, --漏扫工号\n" +
  1316. " bcm.CreateTime, --校验漏扫时间\n" +
  1317. " bcm.CreateUserID,\n" +
  1318. " u.username, --校验者\n" +
  1319. //" MU.usercode repaircode, --补扫操作工号\n" +
  1320. //" MU.pusercode prepaircode, --补扫生产工号\n" +
  1321. " bcm.ROPUserCode repaircode, --补扫操作工号\n" +
  1322. " bcm.RWorkUserCode prepaircode, --补扫生产工号\n" +
  1323. " gt2.goodstypename goodstypename2, --产品大类\n" +
  1324. " 1 barcodecount, --数量\n" +
  1325. " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName\n" +
  1326. " from TP_PM_BarCodeMissing bcm\n" +
  1327. " left join TP_MST_User u\n" +
  1328. " on bcm.CreateUserID = u.userid\n" +
  1329. " left join TP_MST_GoodsType gt\n" +
  1330. " on bcm.GoodsTypeID = gt.GoodsTypeID\n" +
  1331. " left join TP_MST_GoodsType gt2\n" +
  1332. " on substr(gt.GoodsTypeCode, 1, 6) = gt2.GoodsTypeCode\n" +
  1333. " and gt.accountid = gt2.accountid\n" +
  1334. /*
  1335. //" left join TP_PM_ProductionData PD\n" +
  1336. //" on PD.BarCode = bcm.BarCode\n" +
  1337. //" and PD.ProcedureID = bcm.MissProcedureID\n" +
  1338. //" left join TP_MST_User MU\n" +
  1339. //" on MU.UserID = PD.CreateUserID\n" +
  1340. " left join (select pd.barcode,\n" +
  1341. " pd.procedureid,\n" +
  1342. " pd.usercode pusercode,\n" +
  1343. " mu.usercode,\n" +
  1344. //" pd.usercode,\n" +
  1345. " max(bm.missid) missid\n" +
  1346. //" row_number() over(partition by pd.barcode, pd.procedureid order by pd.productiondataid) rnum\n" +
  1347. " from tp_pm_productiondata pd\n" +
  1348. " inner join tp_pm_barcodemissing bm\n" +
  1349. " on bm.barcode = pd.barcode\n" +
  1350. " and bm.missprocedureid = pd.procedureid\n" +
  1351. " and bm.createtime < pd.createtime\n" +
  1352. " and bm.valueflag ='1'\n" +
  1353. " inner join tp_mst_user mu\n" +
  1354. " on mu.userid = pd.createuserid\n" +
  1355. " where pd.valueflag = '1'\n" +
  1356. " group by pd.barcode, pd.procedureid, pd.usercode, mu.usercode\n" +
  1357. " ) MU\n" +
  1358. " on MU.barcode = bcm.barcode\n" +
  1359. " and MU.procedureid = bcm.missprocedureid\n" +
  1360. " and MU.missid = bcm.missid" +
  1361. //" and MU.rnum = 1" +
  1362. */
  1363. " left join tp_pc_procedure cedp \n" +
  1364. " on cedp.procedureid = bcm.CompleteProcedureID\n" +
  1365. " left join tp_pc_procedure cp \n" +
  1366. " on cp.procedureid = bcm.ProcedureID\n" +
  1367. " left join tp_pc_procedure mp \n" +
  1368. " on mp.procedureid = bcm.MissProcedureID\n" +
  1369. " left join TP_PM_GroutingDailyDetail \n" +
  1370. " on TP_PM_GroutingDailyDetail.barcode = bcm.BarCode\n" +
  1371. " left join tp_mst_logo \n" +
  1372. " on tp_mst_logo.logoid = TP_PM_GroutingDailyDetail.logoid\n" +
  1373. " where bcm.valueflag='1' \n" +
  1374. " and bcm.accountid=:AccountID \n";
  1375. // 产品条码
  1376. if (!string.IsNullOrEmpty(se.Barcode))
  1377. {
  1378. selSql = selSql + " and bcm.barcode=:Barcode ";
  1379. parameters.Add(new OracleParameter(":Barcode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  1380. }
  1381. // 组织结构
  1382. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  1383. {
  1384. selSql = selSql + " and instr(',' || :OrganizationIDS || ',' ,','||bcm.OrganizationID||',' )>0 ";
  1385. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  1386. }
  1387. // 完成工序
  1388. if (!string.IsNullOrEmpty(se.CompleteProcedureIDS))
  1389. {
  1390. selSql = selSql + " and instr(',' || :CompleteProcedureIDS || ',',','||bcm.CompleteProcedureID||',' )>0 ";
  1391. parameters.Add(new OracleParameter(":CompleteProcedureIDS", OracleDbType.NVarchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  1392. }
  1393. // 校验工序
  1394. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  1395. {
  1396. selSql = selSql + " and instr(',' || :ProcedureIDS || ',',','||bcm.procedureID||',' )>0 ";
  1397. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  1398. }
  1399. // 漏扫工序
  1400. if (!string.IsNullOrEmpty(se.MissingProcedureIDS))
  1401. {
  1402. selSql = selSql + " and instr(',' || :MissingProcedureIDS || ',',','||bcm.missProcedureID||',' )>0 ";
  1403. parameters.Add(new OracleParameter(":MissingProcedureIDS", OracleDbType.NVarchar2, se.MissingProcedureIDS, ParameterDirection.Input));
  1404. }
  1405. // 产品IDS
  1406. if (!string.IsNullOrEmpty(se.GoodsIDS))
  1407. {
  1408. selSql = selSql + " and instr(',' || :GoodsIDS || ',',','||bcm.goodsID||',' )>0 ";
  1409. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  1410. }
  1411. // 产品IDS
  1412. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  1413. {
  1414. //selSql = selSql + " and instr(',' || :GoodsTypeIDS || ',',','||gt.goodsTypeCode||',' )=1 ";
  1415. selSql = selSql + " and instr(gt.goodsTypeCode,:GoodsTypeIDS )=1 ";
  1416. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  1417. }
  1418. // 校验时间--开始
  1419. if (se.beginCreateTime.HasValue)
  1420. {
  1421. selSql = selSql + " and bcm.CreateTime>= :CreateTimeStart ";
  1422. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  1423. }
  1424. // 校验时间--结束
  1425. if (se.endCreateTime.HasValue)
  1426. {
  1427. selSql = selSql + " and bcm.CreateTime<= :CreateTimeEnd ";
  1428. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.endCreateTime.Value, ParameterDirection.Input));
  1429. }
  1430. selSql += "\n" +
  1431. //" order by gt2.GoodsTypeCode,bcm.MissProcedureCode,\n" +
  1432. //" --bcm.GoodsCode,\n" +
  1433. //" bcm.BarCode,\n" +
  1434. //" bcm.ProcedureCode,\n" +
  1435. //" bcm.CompleteProcedureCode\n" +
  1436. //" ) t\n" +
  1437. " order by gt2.GoodsTypeCode,mp.ProcedureName,\n" +
  1438. " --bcm.GoodsCode,\n" +
  1439. " bcm.BarCode,\n" +
  1440. " cp.ProcedureName,\n" +
  1441. " cedp.ProcedureName\n" +
  1442. " ) t\n" +
  1443. " group by grouping sets((t.MissID, --漏扫ID\n" +
  1444. " t.BarCode, --产品条码\n" +
  1445. " t.goodstypename2, --产品大类\n" +
  1446. " /*t.OrganizationID, t.OrganizationCode,*/ t.OrganizationName, --漏扫部门\n" +
  1447. " /*t.OrganizationFullName, t.CompleteProcedureID, t.CompleteProcedureCode, t.CompleteProcedureName,*/ t.CompleteProcedureName, --完成工序\n" +
  1448. " /*t.ProcedureID, t.ProcedureCode, t.ProcedureName,*/ t.ProcedureName, --校验工序\n" +
  1449. " /*t.MissProcedureID, t.MissProcedureCode, t.MissProcedureName,*/ t.MissProcedureName, --漏扫工序\n" +
  1450. " t.GoodsID, t.GoodsCode, --产品编码\n" +
  1451. " t.GoodsName, --产品名称\n" +
  1452. " t.GoodsTypeID, t.MissUserID, t.MissUserCode, --漏扫工号\n" +
  1453. " t.CreateTime, --校验漏扫时间\n" +
  1454. " t.CreateUserID, t.username, --校验者\n" +
  1455. " t.repaircode, --补扫工号\n" +
  1456. " t.prepaircode, --补扫工号\n" +
  1457. " t.LogoCodeName --商标\n" +
  1458. " ),(t.goodstypename2, --产品大类\n" +
  1459. " /*t.MissProcedureCode,*/ t.MissProcedureName --漏扫工序\n" +
  1460. " ),(t.goodstypename2 --产品大类\n" +
  1461. " ),())) tt";
  1462. return selSql;
  1463. }
  1464. /// <summary>
  1465. /// 取得RPT010301_1画面(条码变更明细表)的查询数据
  1466. /// </summary>
  1467. /// <param name="user">登录用户信息</param>
  1468. /// <param name="se">查询条件</param>
  1469. /// <returns>查询结果</returns>
  1470. public static ServiceResultEntity GetRPT010301SData(SUserInfo user, RPT010301_SE se)
  1471. {
  1472. IDBConnection conn = null;
  1473. try
  1474. {
  1475. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1476. List<OracleParameter> parameters = new List<OracleParameter>();
  1477. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010301SSQL());
  1478. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  1479. if (se != null)
  1480. {
  1481. // 更换条码时间-开始
  1482. if (se.createTimeBegin.HasValue)
  1483. {
  1484. sql.Append(" and TP_PM_BarCodeRecord.CreateTime>= :CreateTimeBegin ");
  1485. parameters.Add(new OracleParameter(":CreateTimeBegin", OracleDbType.Date, se.createTimeBegin.Value, ParameterDirection.Input));
  1486. }
  1487. // 更换条码时间-结束
  1488. if (se.createTimeEnd.HasValue)
  1489. {
  1490. sql.Append(" and TP_PM_BarCodeRecord.CreateTime<= :CreateTimeEnd ");
  1491. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.createTimeEnd.Value, ParameterDirection.Input));
  1492. }
  1493. //成型线IDS
  1494. if (!string.IsNullOrEmpty(se.Barcode))
  1495. {
  1496. // 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 )");
  1497. 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 )");
  1498. parameters.Add(new OracleParameter(":Barcode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  1499. }
  1500. }
  1501. sql.Append(" ORDER BY TP_PM_BarCodeRecord.CREATETIME ");
  1502. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  1503. ServiceResultEntity sre = new ServiceResultEntity();
  1504. if (data == null || data.Rows.Count == 0)
  1505. {
  1506. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  1507. return sre;
  1508. }
  1509. sre.Data = new DataSet();
  1510. sre.Data.Tables.Add(data);
  1511. return sre;
  1512. }
  1513. catch (Exception ex)
  1514. {
  1515. throw ex;
  1516. }
  1517. finally
  1518. {
  1519. if (conn != null &&
  1520. conn.ConnState == ConnectionState.Open)
  1521. {
  1522. conn.Close();
  1523. }
  1524. }
  1525. }
  1526. /// <summary>
  1527. /// 获取RPT010301_1画面(条码变更明细表)的查询sql
  1528. /// </summary>
  1529. /// <returns>sql</returns>
  1530. private static string GetRPT010301SSQL()
  1531. {
  1532. string selSql =
  1533. " SELECT "
  1534. + " TP_PM_BarCodeRecord.BarCode, "
  1535. + " TP_PM_BarCodeRecord.NewBarCode, "
  1536. + " TP_PM_BarCodeRecord.FirstBarCode, "
  1537. + " TP_PM_BarCodeRecord.FinalBarCode, "
  1538. + " TP_PM_BarCodeRecord.Createtime, "
  1539. + " TP_PM_GROUTINGDAILYDETAIL.GroutingLineCode, "
  1540. + " TP_PM_GROUTINGDAILYDETAIL.GroutingLineName, "
  1541. + " TP_MST_GMouldType.Gmouldtypename, "
  1542. + " TP_PM_GROUTINGDAILYDETAIL.GroutingDate, "
  1543. + " TP_PM_GROUTINGDAILYDETAIL.GroutingMouldCode, "
  1544. + " TP_PM_GROUTINGDAILYDETAIL.MouldCode, "
  1545. + " TP_PM_GROUTINGDAILYDETAIL.UserCode GroutingUserCode, "
  1546. + " TP_PM_GROUTINGDAILYDETAIL.GroutingCount , "
  1547. + " TP_PM_GROUTINGDAILYDETAIL.GoodsCode, "
  1548. + " TP_PM_GROUTINGDAILYDETAIL.GoodsName, "
  1549. + " TP_PC_PROCEDURE.PROCEDURECODE, "
  1550. + " TP_PC_PROCEDURE.PROCEDURENAME, "
  1551. // 成型班长
  1552. + " mu.username as MONITORName,"
  1553. + " TP_MST_USER.USERNAME, "
  1554. + " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName "
  1555. + " from TP_PM_BarCodeRecord "
  1556. + " left join TP_PM_GROUTINGDAILYDETAIL on TP_PM_BarCodeRecord.FinalBarCode=TP_PM_GROUTINGDAILYDETAIL.Barcode "
  1557. + " inner join TP_PC_GroutingLine on TP_PC_GroutingLine.GroutingLineID=TP_PM_GroutingDailyDetail.GroutingLineID "
  1558. // 成型班长
  1559. + " LEFT JOIN tp_mst_user mu" +
  1560. " ON mu.userid = TP_PC_GroutingLine.MONITORID"
  1561. + " inner join TP_MST_GMouldType on TP_MST_GMouldType.GMOULDTYPEID=TP_PC_GroutingLine.GMOULDTYPEID "
  1562. + " left join TP_PC_PROCEDURE on TP_PM_BarCodeRecord.Procedureid=TP_PC_PROCEDURE.PROCEDUREID "
  1563. + " left join TP_MST_USER ON TP_PM_BarCodeRecord.CreateUserID=TP_MST_USER.USERID "
  1564. + " left join TP_MST_logo ON TP_MST_logo.logoid=TP_PM_GROUTINGDAILYDETAIL.logoid "
  1565. + " where TP_PM_GROUTINGDAILYDETAIL.ACCOUNTID=:AccountID ";
  1566. return selSql;
  1567. }
  1568. /// <summary>
  1569. /// 取得RPT010401画面(在产品明细表)的查询数据
  1570. /// </summary>
  1571. /// <param name="user">登录用户信息</param>
  1572. /// <param name="se">查询条件</param>
  1573. /// <returns>查询结果</returns>
  1574. public static ServiceResultEntity GetRPT010401SData(SUserInfo user, RPT010401_SE se)
  1575. {
  1576. IDBConnection conn = null;
  1577. try
  1578. {
  1579. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1580. List<OracleParameter> parameters = new List<OracleParameter>();
  1581. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010401SSQL());
  1582. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  1583. if (se != null)
  1584. {
  1585. // 条码
  1586. if (!string.IsNullOrEmpty(se.Barcode))
  1587. {
  1588. //sql.Append(" AND TP_PM_InProduction.BarCode=:Barcode ");
  1589. sql.Append(" AND instr(TP_PM_InProduction.BarCode,:Barcode)>0 ");
  1590. parameters.Add(new OracleParameter(":Barcode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  1591. }
  1592. // 产品IDS
  1593. if (!string.IsNullOrEmpty(se.GoodsIDS))
  1594. {
  1595. sql.Append(" AND instr(','||:GoodsIDS||',',','||TP_PM_InProduction.GoodsId||',')>0 ");
  1596. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  1597. }
  1598. //生产线IDS
  1599. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  1600. {
  1601. sql.Append(" AND instr(','||:ProductionLineIDS||',',','||TP_PM_InProduction.ProductionLineID||',')>0 ");
  1602. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  1603. }
  1604. //完成工序IDS
  1605. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  1606. {
  1607. sql.Append(" AND instr(','||:ProcedureIDS||',',','||TP_PM_InProduction.ProcedureID||',')>0 ");
  1608. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  1609. }
  1610. //生产工号IDS
  1611. if (!string.IsNullOrEmpty(se.UserIDS))
  1612. {
  1613. sql.Append(" AND instr(','||:UserIDS||',',','||TP_PM_InProduction.UserID||',')>0 ");
  1614. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  1615. }
  1616. // 成型线IDS
  1617. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  1618. {
  1619. sql.Append(" AND instr(','||:GroutingLineIDS||',',','||TP_PM_InProduction.GroutingLineID||',')>0 ");
  1620. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  1621. }
  1622. // 成型线类型IDS
  1623. if (!string.IsNullOrEmpty(se.GMouldTypeIDS))
  1624. {
  1625. sql.Append(" AND instr(','||:GMouldTypeIDS||',',','||TP_PM_InProduction.GMouldTypeID||',')>0 ");
  1626. parameters.Add(new OracleParameter(":GMouldTypeIDS", OracleDbType.NVarchar2, se.GMouldTypeIDS, ParameterDirection.Input));
  1627. }
  1628. // 交坯时间--开始
  1629. if (se.CreateTimeStart.HasValue)
  1630. {
  1631. sql.Append(" AND TP_PM_GroutingDailyDetail.delivertime >= :CreateTimeStart ");
  1632. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  1633. }
  1634. // 交坯时间--结束
  1635. if (se.CreateTimeEnd.HasValue)
  1636. {
  1637. sql.Append(" AND TP_PM_GroutingDailyDetail.delivertime <= :CreateTimeEnd ");
  1638. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  1639. }
  1640. // 完成时间--开始
  1641. if (se.UpdateTimeStart.HasValue)
  1642. {
  1643. sql.Append(" AND TP_PM_InProduction.Proceduretime >= :UpdateTimeStart ");
  1644. parameters.Add(new OracleParameter(":UpdateTimeStart", OracleDbType.Date, se.UpdateTimeStart.Value, ParameterDirection.Input));
  1645. }
  1646. // 完成时间--结束
  1647. if (se.UpdateTimeEnd.HasValue)
  1648. {
  1649. sql.Append(" AND TP_PM_InProduction.Proceduretime <= :UpdateTimeEnd ");
  1650. parameters.Add(new OracleParameter(":UpdateTimeEnd", OracleDbType.Date, se.UpdateTimeEnd.Value, ParameterDirection.Input));
  1651. }
  1652. if (se.inscrapflag != 2)
  1653. {
  1654. sql.Append(" AND TP_PM_InProduction.inscrapflag=:inscrapflag ");
  1655. parameters.Add(new OracleParameter(":inscrapflag", OracleDbType.NVarchar2, se.inscrapflag, ParameterDirection.Input));
  1656. }
  1657. if (!string.IsNullOrWhiteSpace(se.GoodsTypeCode))
  1658. {
  1659. sql.Append(" AND instr(gt.goodstypecode, :GoodsTypeCode) = 1 ");
  1660. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  1661. }
  1662. }
  1663. sql.Append(" order by TP_PM_InProduction.UpdateTime desc");
  1664. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  1665. ServiceResultEntity sre = new ServiceResultEntity();
  1666. if (data == null || data.Rows.Count == 0)
  1667. {
  1668. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  1669. return sre;
  1670. }
  1671. sre.Data = new DataSet();
  1672. sre.Data.Tables.Add(data);
  1673. return sre;
  1674. }
  1675. catch (Exception ex)
  1676. {
  1677. throw ex;
  1678. }
  1679. finally
  1680. {
  1681. if (conn != null &&
  1682. conn.ConnState == ConnectionState.Open)
  1683. {
  1684. conn.Close();
  1685. }
  1686. }
  1687. }
  1688. /// <summary>
  1689. /// 获取RPT010401画面(在产品明细表)的查询sql
  1690. /// </summary>
  1691. /// <returns>sql</returns>
  1692. private static string GetRPT010401SSQL()
  1693. {
  1694. string selSql =
  1695. "SELECT " +
  1696. " TP_PM_InProduction.BarCode, " +
  1697. " TP_PM_InProduction.GoodsID,TP_PM_InProduction.GoodsCode, " +
  1698. " TP_PM_InProduction.GoodsName, gt.goodstypename," +
  1699. " TP_PM_InProduction.Userid,A.USERNAME as UserName,A.USERCode as UserCode, " +
  1700. " TP_PM_InProduction.ProductionLineID, " +
  1701. " TP_PM_InProduction.ProductionLineCode, " +
  1702. " TP_PM_InProduction.ProductionLineName, " +
  1703. " TP_PM_InProduction.ModelType, " +
  1704. " decode(TP_PM_InProduction.inscrapflag , '1', '待审核的报废品' , '正常') as inscrapflag, " +
  1705. //" decode(TP_PM_InProduction.IsPublicBody, '1', '是' , '否') as IsPublicBody, " +
  1706. " TP_PM_InProduction.IsPublicBody, " +
  1707. //" decode(TP_PM_InProduction.IsReFire, '1', '是' , '否') as IsReFire, " +
  1708. " decode(TP_PM_InProduction.IsReFire, '6', '1' , '0') as IsReFire, " +
  1709. " TP_PM_InProduction.IsReworkFlag, " +
  1710. " decode(TP_PM_InProduction.CanManyTimes, '1', '能' , '不能') as CanManyTimes, " +
  1711. " decode(TP_PM_InProduction.ProcedureModel, '1', '计件模型' , '检验模型') as ProcedureModel, " +
  1712. " TP_PM_InProduction.GroutingDailyID, " +
  1713. " TP_PM_InProduction.GroutingDailyDetailID, " +
  1714. " TP_PM_InProduction.GroutingDate, " +
  1715. " TP_PM_InProduction.GroutingLineID, " +
  1716. " TP_PM_InProduction.GroutingLineCode, " +
  1717. " TP_PM_InProduction.GroutingLineName, " +
  1718. " TP_PM_InProduction.KILNCODE, " +
  1719. " TP_PM_InProduction.KILNCARCODE, " +
  1720. " TP_PM_InProduction.ProcedureID CompleteProcedureID, " +
  1721. " D.ProcedureName as CompleteProcedureName, " +
  1722. " TP_PM_InProduction.GMouldTypeID, " +
  1723. " TP_MST_GMouldType.GMOULDTYPENAME as GMouldTypeName, " +
  1724. " TP_PM_InProduction.GroutingLineDetailID, " +
  1725. " TP_PM_InProduction.GroutingMouldCode, " +
  1726. " TP_PM_InProduction.SPECIALREPAIRFLAG, " +
  1727. " TP_PM_InProduction.GROUTINGUSERCODE, " +
  1728. " TP_PM_GroutingDailyDetail.GROUTINGCOUNT, " +
  1729. " TP_PM_GroutingDailyDetail.GROUTINGBATCHNO, " +
  1730. " TP_PM_GroutingDailyDetail.delivertime, " +
  1731. " TP_PM_InProduction.proceduretime, " +
  1732. " TP_PM_InProduction.Remarks, " +
  1733. " TP_PM_InProduction.GoodsLevelID,TP_MST_GoodsLevel.GOODSLEVELNAME, " +
  1734. " TP_PM_InProduction.GoodsLevelTypeID,TP_SYS_GoodsLevelType.GOODSLEVELTYPENAME, " +
  1735. " TP_PM_InProduction.AccountID,TP_PM_InProduction.ValueFlag, " +
  1736. " TP_PM_GroutingDailyDetail.glazingroom," +
  1737. " TP_PM_InProduction.CreateTime,TP_PM_InProduction.CreateUserID,B.USERNAME as CreateUserName, " +
  1738. " TP_PM_InProduction.PROCEDURETIME AS UpdateTime,TP_PM_InProduction.UpdateUserID,C.USERNAME as UpdateUserName, " +
  1739. " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName, " +
  1740. //" (Goods.MaterialCode || TP_MST_Logo.tagcode || TP_PM_GroutingDailyDetail.onlycode) as FinishedBarCode " +
  1741. " 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 " +
  1742. "FROM TP_PM_InProduction " +
  1743. " inner join TP_MST_User A on A.UserID=TP_PM_InProduction.Userid " +
  1744. " inner join TP_MST_User B on B.UserID=TP_PM_InProduction.CreateUserID " +
  1745. " inner join TP_MST_User C on C.UserID=TP_PM_InProduction.UpdateUserID " +
  1746. " inner join TP_PC_Procedure D on D.PROCEDUREID=TP_PM_InProduction.ProcedureID " +
  1747. " inner join TP_MST_GMouldType on TP_MST_GMouldType.GMouldTypeID=TP_PM_InProduction.GMouldTypeID " +
  1748. " inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.ProcedureModelTypeID=TP_PM_InProduction.ModelType " +
  1749. " inner join TP_PM_GroutingDaily on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_InProduction.GroutingDailyID " +
  1750. " inner join TP_PM_GroutingDailyDetail on TP_PM_GroutingDailyDetail.Groutingdailydetailid=TP_PM_InProduction.GroutingDailyDetailID " +
  1751. " inner join TP_PC_GroutingLineDetail on TP_PC_GroutingLineDetail.Groutinglinedetailid=TP_PM_InProduction.GroutingLineDetailID " +
  1752. " inner join TP_MST_Account on TP_MST_Account.Accountid=TP_PM_InProduction.Accountid " +
  1753. " left join TP_MST_GoodsLevel on TP_MST_GoodsLevel.GoodsLevelID=TP_PM_InProduction.GoodsLevelID " +
  1754. " left join TP_SYS_GoodsLevelType on TP_SYS_GoodsLevelType.GoodsLevelTypeID=TP_PM_InProduction.GoodsLevelTypeID " +
  1755. " left join TP_MST_Logo on TP_PM_InProduction.logoid=TP_MST_Logo.logoid " +
  1756. " left join TP_MST_Goods Goods on TP_PM_InProduction.GoodsID=Goods.GoodsID " +
  1757. " left join tp_mst_goodstype gt on gt.goodstypeid = Goods.goodstypeid " +
  1758. " Where TP_PM_InProduction.ValueFlag = 1 " +
  1759. " and TP_PM_InProduction.AccountID=:AccountID ";
  1760. return selSql;
  1761. }
  1762. /// <summary>
  1763. /// 取得RPT010402画面(产成品明细表)的查询数据
  1764. /// </summary>
  1765. /// <param name="user">登录用户信息</param>
  1766. /// <param name="se">查询条件</param>
  1767. /// <returns>查询结果</returns>
  1768. public static ServiceResultEntity GetRPT010402SData(SUserInfo user, RPT010402_SE se)
  1769. {
  1770. IDBConnection conn = null;
  1771. try
  1772. {
  1773. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1774. List<OracleParameter> parameters = new List<OracleParameter>();
  1775. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010402SSQL());
  1776. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  1777. if (se != null)
  1778. {
  1779. // 条码
  1780. if (!string.IsNullOrEmpty(se.Barcode))
  1781. {
  1782. //sql.Append(" AND TP_PM_FinishedProduct.BarCode=:BarCode ");
  1783. sql.Append(" AND instr(TP_PM_FinishedProduct.BarCode,:Barcode)>0 ");
  1784. parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  1785. }
  1786. // 产品IDS
  1787. if (!string.IsNullOrEmpty(se.GoodsIDS))
  1788. {
  1789. sql.Append(" AND instr(','||:GoodsIDS||',',','||TP_PM_FinishedProduct.GoodsId||',')>0 ");
  1790. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  1791. }
  1792. // 生产线IDS
  1793. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  1794. {
  1795. sql.Append(" AND instr(','||:ProductionLineIDS||',',','||TP_PM_FinishedProduct.ProductionLineID||',')>0 ");
  1796. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  1797. }
  1798. // 成型线ids
  1799. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  1800. {
  1801. sql.Append(" AND instr(','||:GroutingLineIDS||',',','||TP_PM_FinishedProduct.GroutingLineID||',')>0 ");
  1802. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  1803. }
  1804. // 成型线类型ids
  1805. if (!string.IsNullOrEmpty(se.GMouldTypeIDS))
  1806. {
  1807. sql.Append(" AND instr(','||:GMouldTypeIDS||',',','||TP_PM_FinishedProduct.GMouldTypeID||',')>0 ");
  1808. parameters.Add(new OracleParameter(":GMouldTypeIDS", OracleDbType.NVarchar2, se.GMouldTypeIDS, ParameterDirection.Input));
  1809. }
  1810. // 财务日期--开始
  1811. if (se.AccountDateStart.HasValue)
  1812. {
  1813. //sql.Append(" AND TP_PM_FinishedProduct.AccountDate >= :AccountDateStart ");
  1814. sql.Append(" AND TP_PM_FinishedProduct.CreateTime >= :AccountDateStart ");
  1815. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  1816. }
  1817. // 财务日期--结束
  1818. if (se.AccountDateEnd.HasValue)
  1819. {
  1820. //sql.Append(" AND TP_PM_FinishedProduct.AccountDate <= :AccountDateEnd ");
  1821. sql.Append(" AND TP_PM_FinishedProduct.CreateTime <= :AccountDateEnd ");
  1822. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  1823. }
  1824. // 注浆时间--开始
  1825. if (se.CreateTimeStart.HasValue)
  1826. {
  1827. sql.Append(" AND TP_PM_GroutingDaily.CreateTime >= :CreateTimeStart ");
  1828. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  1829. }
  1830. // 注浆时间--结束
  1831. if (se.CreateTimeEnd.HasValue)
  1832. {
  1833. sql.Append(" AND TP_PM_GroutingDaily.CreateTime <= :CreateTimeEnd ");
  1834. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  1835. }
  1836. }
  1837. sql.Append(" order by TP_PM_FinishedProduct.UpdateTime desc");
  1838. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  1839. ServiceResultEntity sre = new ServiceResultEntity();
  1840. if (data == null || data.Rows.Count == 0)
  1841. {
  1842. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  1843. return sre;
  1844. }
  1845. sre.Data = new DataSet();
  1846. sre.Data.Tables.Add(data);
  1847. return sre;
  1848. }
  1849. catch (Exception ex)
  1850. {
  1851. throw ex;
  1852. }
  1853. finally
  1854. {
  1855. if (conn != null &&
  1856. conn.ConnState == ConnectionState.Open)
  1857. {
  1858. conn.Close();
  1859. }
  1860. }
  1861. }
  1862. /// <summary>
  1863. /// 获取RPT010402画面(产成品明细表)的查询sql
  1864. /// </summary>
  1865. /// <returns>sql</returns>
  1866. private static string GetRPT010402SSQL()
  1867. {
  1868. string selSql =
  1869. "SELECT " +
  1870. " TP_PM_FinishedProduct.BarCode, " +
  1871. " TP_PM_FinishedProduct.GoodsID, " +
  1872. " TP_PM_FinishedProduct.GoodsCode, " +
  1873. " TP_PM_FinishedProduct.GoodsName, " +
  1874. " TP_PM_FinishedProduct.ProductionLineID, " +
  1875. " TP_PM_FinishedProduct.ProductionLineCode, " +
  1876. " TP_PM_FinishedProduct.ProductionLineName, " +
  1877. //" decode(TP_PM_FinishedProduct.IsPublicBody, '1', '是' , '否') as IsPublicBody, " +
  1878. //" decode(TP_PM_FinishedProduct.IsReFire, '1', '是' , '否') as IsReFire, " +
  1879. " TP_PM_FinishedProduct.IsPublicBody, " +
  1880. " decode(TP_PM_FinishedProduct.IsReFire, '6', '1' , '0') as IsReFire, " +
  1881. " decode(TP_PM_GroutingDaily.CanManyTimes, '1', '是' , '否') as CanManyTimes, " +
  1882. " decode(TP_PM_FinishedProduct.SettlementFlag, '1', '已结算' , '未结算') as SettlementFlag, " +
  1883. " TP_PM_FinishedProduct.GroutingDailyID, " +
  1884. " TP_PM_FinishedProduct.GroutingDailyDetailID, " +
  1885. " TP_PM_FinishedProduct.GroutingDate, " +
  1886. " TP_PM_FinishedProduct.GroutingLineID, " +
  1887. " TP_PM_FinishedProduct.GroutingLineCode," +
  1888. " TP_PM_FinishedProduct.GroutingLineName, " +
  1889. " TP_PM_FinishedProduct.GMouldTypeID, " +
  1890. " TP_MST_GMouldType.GMOULDTYPENAME as GMouldTypeName, " +
  1891. " TP_PM_FinishedProduct.GroutingLineDetailID, " +
  1892. " TP_PM_FinishedProduct.GroutingMouldCode," +
  1893. " TP_PM_GroutingDailyDetail.GROUTINGCOUNT," +
  1894. " TP_PM_FinishedProduct.GROUTINGUSERCODE," +
  1895. " TP_PM_FinishedProduct.SPECIALREPAIRFLAG," +
  1896. " TP_PM_FinishedProduct.KILNID," +
  1897. " TP_PM_FinishedProduct.KILNCODE," +
  1898. " TP_PM_FinishedProduct.KILNNAME," +
  1899. " TP_PM_FinishedProduct.KILNCARID," +
  1900. " TP_PM_FinishedProduct.KILNCARCODE," +
  1901. " TP_PM_FinishedProduct.KILNCARNAME," +
  1902. " TP_MST_DATADICTIONARY.DICTIONARYVALUE KILNCARPOSITION," +
  1903. " TP_PM_FinishedProduct.MouldCode, " +
  1904. " TP_PM_FinishedProduct.Remarks, " +
  1905. " TP_PM_FinishedProduct.GoodsLevelID,TP_MST_GoodsLevel.GOODSLEVELNAME, " +
  1906. " TP_PM_FinishedProduct.GoodsLevelTypeID, " +
  1907. " TP_SYS_GoodsLevelType.GOODSLEVELTYPENAME, " +
  1908. " TP_PM_FinishedProduct.FHUSERCODE, " +
  1909. " TP_PM_FinishedProduct.FHTIME, " +
  1910. " odr.ORDERNO, " +
  1911. " TP_PM_FinishedProduct.AccountID, " +
  1912. " TP_PM_FinishedProduct.ValueFlag, " +
  1913. " TP_PM_FinishedProduct.AccountDate, " +
  1914. " TP_PM_FinishedProduct.CreateTime, " +
  1915. " TP_PM_FinishedProduct.CreateUserID, " +
  1916. " B.USERNAME as CreateUserName, " +
  1917. " TP_PM_FinishedProduct.UpdateTime, " +
  1918. " TP_PM_FinishedProduct.UpdateUserID, " +
  1919. " C.USERNAME as UpdateUserName, " +
  1920. " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName," +
  1921. " TP_PM_GroutingDailyDetail.Materialcode," +
  1922. //" (Goods.MaterialCode || tp_mst_logo.tagcode || TP_PM_GroutingDailyDetail.onlycode) as FinishedBarCode " +
  1923. " TP_PM_GroutingDailyDetail.outlabelcode as FinishedBarCode " +
  1924. " FROM TP_PM_FinishedProduct " +
  1925. " left join TP_PM_ORDER odr on odr.ORDERID=TP_PM_FinishedProduct.FHORDERID " +
  1926. " left join TP_MST_User B on B.UserID=TP_PM_FinishedProduct.CreateUserID " +
  1927. " left join TP_MST_User C on C.UserID=TP_PM_FinishedProduct.UpdateUserID " +
  1928. " left join TP_MST_GMouldType on TP_MST_GMouldType.GMouldTypeID=TP_PM_FinishedProduct.GMouldTypeID " +
  1929. " left join TP_MST_DATADICTIONARY on TP_PM_FinishedProduct.KILNCARPOSITION=TP_MST_DATADICTIONARY.DICTIONARYID " +
  1930. " left join TP_PM_GroutingDaily on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_FinishedProduct.GroutingDailyID " +
  1931. " left join TP_PM_GroutingDailyDetail on TP_PM_GroutingDailyDetail.Groutingdailydetailid=TP_PM_FinishedProduct.GroutingDailyDetailID " +
  1932. " left join TP_PC_GroutingLineDetail on TP_PC_GroutingLineDetail.Groutinglinedetailid=TP_PM_FinishedProduct.GroutingLineDetailID " +
  1933. " left join TP_MST_Account on TP_MST_Account.Accountid=TP_PM_FinishedProduct.Accountid " +
  1934. " left join TP_MST_GoodsLevel on TP_MST_GoodsLevel.GOODSLEVELID=TP_PM_FinishedProduct.GoodsLevelID " +
  1935. " left join TP_SYS_GoodsLevelType on TP_SYS_GoodsLevelType.GoodsLevelTypeID=TP_PM_FinishedProduct.GoodsLevelTypeID " +
  1936. " left join tp_mst_logo on TP_PM_FinishedProduct.logoid=tp_mst_logo.logoid " +
  1937. " left join TP_MST_Goods Goods on TP_PM_FinishedProduct.GoodsID=Goods.GoodsID " +
  1938. " Where 1=1 and TP_PM_FinishedProduct.ValueFlag = 1 " +
  1939. " and TP_PM_FinishedProduct.AccountID=:AccountID ";
  1940. return selSql;
  1941. }
  1942. /// <summary>
  1943. /// 取得RPT010403画面(生产数据明细表)的查询数据
  1944. /// </summary>
  1945. /// <param name="user">登录用户信息</param>
  1946. /// <param name="se">查询条件</param>
  1947. /// <returns>查询结果</returns>
  1948. public static ServiceResultEntity GetRPT010403SData(SUserInfo user, RPT010403_SE se)
  1949. {
  1950. IDBConnection conn = null;
  1951. try
  1952. {
  1953. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1954. List<OracleParameter> parameters = new List<OracleParameter>();
  1955. string sqlString =
  1956. "SELECT *\n" +
  1957. " FROM (SELECT pd.barcode\n" +
  1958. " ,gt2.goodstypename as goodstypename2\n" +
  1959. " ,gt.goodstypename\n" +
  1960. " ,g.goodscode\n" +
  1961. " ,PD.ProductionLineName\n" +
  1962. " ,to_char(p.ProcedureName) AS ProcedureName\n" +
  1963. " ,op.organizationfullname AS porgname\n" +
  1964. " ,pd.CreateTime\n" +
  1965. " ,PD.UserCode\n" +
  1966. " ,cu.Usercode AS CreateUsercode\n" +
  1967. " ,cu.Username AS CreateUserName\n" +
  1968. " ,co.organizationfullname corgname\n" +
  1969. " , CASE\n" +
  1970. " WHEN PD.valueflag = '0' AND PD.ProcedureModel = '1' THEN\n" +
  1971. " '撤销(['|| to_char(bu.usercode) || ']' || to_char(bu.username) || ' ' ||\n" +
  1972. " to_char(PD.Backouttime, 'yyyy-mm-dd hh24:mi:ss') || ')'\n" +
  1973. " WHEN PD.valueflag = '0' AND PD.ProcedureModel = '2' THEN\n" +
  1974. " to_char(GL.GOODSLEVELNAME) || '(被修改)'\n" +
  1975. " ELSE\n" +
  1976. " to_char(GL.GOODSLEVELNAME)\n" +
  1977. " END || CASE\n" +
  1978. " WHEN pd.modeltype = 1 THEN\n" +
  1979. " '[' || to_char(pd.kilncarcode) || ']'\n" +
  1980. " ELSE\n" +
  1981. " ''\n" +
  1982. " END GOODSLEVELNAME\n" +
  1983. " ,gdd.glazingroom" +
  1984. " FROM TP_PM_ProductionData PD\n" +
  1985. " INNER JOIN tp_pc_procedure p\n" +
  1986. " ON p.procedureid = pd.procedureid\n" +
  1987. " LEFT JOIN tp_mst_goods g\n" +
  1988. " ON g.goodsid = pd.goodsid\n" +
  1989. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  1990. " ON gdd.Groutingdailydetailid = pd.Groutingdailydetailid\n" +
  1991. " LEFT JOIN tp_mst_goodstype gt\n" +
  1992. " ON gt.goodstypeid = g.goodstypeid\n" +
  1993. " LEFT JOIN tp_mst_goodstype gt2\n" +
  1994. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  1995. " AND gt2.AccountID = :AccountID\n" +
  1996. " INNER JOIN tp_mst_organization op\n" +
  1997. " ON op.organizationid = p.organizationid\n" +
  1998. " INNER JOIN tp_mst_user cu\n" +
  1999. " ON cu.userid = PD.Createuserid\n" +
  2000. " INNER JOIN tp_mst_organization co\n" +
  2001. " ON co.organizationid = cu.organizationid\n" +
  2002. " LEFT JOIN tp_mst_user bu\n" +
  2003. " ON bu.userid = PD.Backoutuserid\n" +
  2004. " LEFT JOIN tp_mst_goodslevel GL\n" +
  2005. " ON GL.GOODSLEVELID = PD.GOODSLEVELID\n" +
  2006. " AND gl.AccountID = :AccountID\n" +
  2007. " WHERE PD.AccountID = :AccountID\n" +
  2008. " AND PD.Createtime >= :CreatetimeBegin\n" +
  2009. " AND PD.Createtime <= :CreatetimeEnd\n" +
  2010. " AND (:ProductionLineID IS NULL OR\n" +
  2011. " pd.productionlineid = :ProductionLineID)\n" +
  2012. " AND (:GoodsTypeCode IS NULL OR\n" +
  2013. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  2014. " AND (:GoodsCode IS NULL OR instr(g.GoodsCode, :GoodsCode) > 0)\n" +
  2015. " AND (:BarCode IS NULL OR instr(pd.BarCode, :BarCode) > 0)\n" +
  2016. " UNION ALL\n" +
  2017. " -- 报损\n" +
  2018. " SELECT sp.barcode\n" +
  2019. " ,gt2.goodstypename as goodstypename2\n" +
  2020. " ,gt.goodstypename\n" +
  2021. " ,g.goodscode\n" +
  2022. " ,sp.productionlinename\n" +
  2023. //" ,to_char(gl.goodslevelname) || '-完成工序【' ||\n" +
  2024. //" to_char(p.procedurename) || '】' AS procedurename\n" +
  2025. " ,'损坯-完成工序【' || to_char(p.procedurename) || '】-责任工序【' || CASE\n" +
  2026. " WHEN rpp.procedureid IS NOT NULL THEN\n" +
  2027. " to_char(rpp.procedurename)\n" +
  2028. " ELSE\n" +
  2029. " '无'\n" +
  2030. " END || '】-责任工号【[' || to_char(sruser.usercode) || ']' ||\n" +
  2031. " to_char(sruser.Username) || '】-原因【' ||\n" +
  2032. " to_char(sp.rreason) || '】' AS procedurename" +
  2033. " ,NULL AS porgname\n" +
  2034. " ,sp.Createtime\n" +
  2035. " ,NULL AS Usercode\n" +
  2036. " ,u.Usercode AS CreateUsercode\n" +
  2037. " ,U.Username AS CreateUserName\n" +
  2038. " ,co.organizationfullname corgname\n" +
  2039. " ,to_char(A.AUDITSTATUSNAME) || CASE\n" +
  2040. " WHEN Length(AU.usercode) > 0 THEN\n" +
  2041. " '(['|| to_char(AU.usercode) || ']' || to_char(AU.Username) || ' ' ||\n" +
  2042. " to_char(sp.AuditDate, 'yyyy-mm-dd hh24:mi:ss') || ')'\n" +
  2043. " ELSE\n" +
  2044. " ''\n" +
  2045. " END || CASE\n" +
  2046. " WHEN sp.valueflag = '0' THEN\n" +
  2047. " '-撤销(['|| to_char(uu.usercode) || ']' || to_char(uu.username) || ' ' ||\n" +
  2048. " to_char(sp.updatetime, 'yyyy-mm-dd hh24:mi:ss') || ')'\n" +
  2049. " ELSE\n" +
  2050. " ''\n" +
  2051. " END AS GOODSLEVELNAME\n" +
  2052. " ,null glazingroom\n" +
  2053. " FROM tp_pm_scrapproduct sp\n" +
  2054. " LEFT JOIN tp_mst_goods g\n" +
  2055. " ON g.goodsid = sp.goodsid\n" +
  2056. " LEFT JOIN tp_mst_goodstype gt\n" +
  2057. " ON gt.goodstypeid = g.goodstypeid\n" +
  2058. " LEFT JOIN tp_mst_goodstype gt2\n" +
  2059. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  2060. " AND gt2.AccountID = :AccountID\n" +
  2061. " INNER JOIN tp_pc_procedure p\n" +
  2062. " ON p.procedureid = sp.procedureid\n" +
  2063. " --inner join tp_mst_organization op\n" +
  2064. " -- on op.organizationid = p.organizationid\n" +
  2065. " INNER JOIN tp_mst_user U\n" +
  2066. " ON U.userid = sp.CREATEUSERID\n" +
  2067. " INNER JOIN tp_mst_organization co\n" +
  2068. " ON co.organizationid = u.organizationid\n" +
  2069. " INNER JOIN tp_mst_user uu\n" +
  2070. " ON uu.userid = sp.Updateuserid\n" +
  2071. " INNER JOIN tp_sys_AuditStatus A\n" +
  2072. " ON A.AuditStatusid = sp.AuditStatus\n" +
  2073. " LEFT JOIN tp_mst_goodslevel gl\n" +
  2074. " ON gl.goodsleveltypeid = 8\n" +
  2075. " AND gl.accountid = 1\n" +
  2076. " LEFT JOIN tp_mst_user AU\n" +
  2077. " ON au.userid = sp.auditor\n" +
  2078. " LEFT JOIN TP_PM_ResponProcedure rp\n" +
  2079. " ON rp.scrapproductid = sp.scrapproductid\n" +
  2080. " LEFT JOIN tp_pc_procedure rpp\n" +
  2081. " ON rpp.procedureid = rp.procedureid\n" +
  2082. " LEFT JOIN (SELECT DISTINCT sr.scrapproductid, sr.userid\n" +
  2083. " FROM TP_PM_ScrapResponsible sr\n" +
  2084. " WHERE sr.AccountID = :AccountID\n" +
  2085. " -- 编辑后 时间不一致\n" +
  2086. " --AND sr.Createtime >= :CreatetimeBegin\n" +
  2087. " --AND sr.Createtime <= :CreatetimeEnd\n" +
  2088. " ) sru\n" +
  2089. " ON sru.scrapproductid = sp.scrapproductid\n" +
  2090. " LEFT JOIN tp_mst_user sruser\n" +
  2091. " ON sruser.userid = sru.userid" +
  2092. " WHERE (sp.goodsleveltypeid = 8 OR sp.goodsleveltypeid = 9)\n" +
  2093. " AND sp.scraptype = '0'\n" +
  2094. " AND sp.AccountID = :AccountID\n" +
  2095. " AND sp.Createtime >= :CreatetimeBegin\n" +
  2096. " AND sp.Createtime <= :CreatetimeEnd\n" +
  2097. " AND (:ProductionLineID IS NULL OR\n" +
  2098. " sp.productionlineid = :ProductionLineID)\n" +
  2099. " AND (:GoodsTypeCode IS NULL OR\n" +
  2100. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  2101. " AND (:BarCode IS NULL OR instr(sp.BarCode, :BarCode) > 0)\n" +
  2102. " AND (:GoodsCode IS NULL OR instr(g.GoodsCode, :GoodsCode) > 0)) t\n" +
  2103. " ORDER BY t.barcode, t.Createtime";
  2104. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2105. parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  2106. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  2107. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  2108. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  2109. parameters.Add(new OracleParameter(":CreatetimeBegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input));
  2110. parameters.Add(new OracleParameter(":CreatetimeEnd", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input));
  2111. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  2112. ServiceResultEntity sre = new ServiceResultEntity();
  2113. if (data == null || data.Rows.Count == 0)
  2114. {
  2115. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2116. return sre;
  2117. }
  2118. sre.Data = new DataSet();
  2119. sre.Data.Tables.Add(data);
  2120. return sre;
  2121. }
  2122. catch (Exception ex)
  2123. {
  2124. throw ex;
  2125. }
  2126. finally
  2127. {
  2128. if (conn != null &&
  2129. conn.ConnState == ConnectionState.Open)
  2130. {
  2131. conn.Close();
  2132. }
  2133. }
  2134. }
  2135. /// <summary>
  2136. /// 取得RPT010302画面(商标变更明细表)的查询数据
  2137. /// </summary>
  2138. /// <param name="user">登录用户信息</param>
  2139. /// <param name="se">查询条件</param>
  2140. /// <returns>查询结果</returns>
  2141. public static ServiceResultEntity GetRPT010302SData(SUserInfo user, RPT010302_SE se)
  2142. {
  2143. IDBConnection conn = null;
  2144. try
  2145. {
  2146. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  2147. List<OracleParameter> parameters = new List<OracleParameter>();
  2148. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010302SSQL());
  2149. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2150. if (se != null)
  2151. {
  2152. // 更换条码时间-开始
  2153. if (se.createTimeBegin.HasValue)
  2154. {
  2155. sql.Append(" and lcr.CreateTime>= :CreateTimeBegin ");
  2156. parameters.Add(new OracleParameter(":CreateTimeBegin", OracleDbType.Date, se.createTimeBegin.Value, ParameterDirection.Input));
  2157. }
  2158. // 更换条码时间-结束
  2159. if (se.createTimeEnd.HasValue)
  2160. {
  2161. sql.Append(" and lcr.CreateTime<= :CreateTimeEnd ");
  2162. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.createTimeEnd.Value, ParameterDirection.Input));
  2163. }
  2164. //成型线IDS
  2165. if (!string.IsNullOrEmpty(se.Barcode))
  2166. {
  2167. // 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 )");
  2168. sql.Append(" and (instr(lcr.BARCODE,:Barcode)>0 )");
  2169. parameters.Add(new OracleParameter(":Barcode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  2170. }
  2171. }
  2172. sql.Append(" ORDER BY lcr.CREATETIME ");
  2173. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  2174. ServiceResultEntity sre = new ServiceResultEntity();
  2175. if (data == null || data.Rows.Count == 0)
  2176. {
  2177. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2178. return sre;
  2179. }
  2180. sre.Data = new DataSet();
  2181. sre.Data.Tables.Add(data);
  2182. return sre;
  2183. }
  2184. catch (Exception ex)
  2185. {
  2186. throw ex;
  2187. }
  2188. finally
  2189. {
  2190. if (conn != null &&
  2191. conn.ConnState == ConnectionState.Open)
  2192. {
  2193. conn.Close();
  2194. }
  2195. }
  2196. }
  2197. /// <summary>
  2198. /// 获取RPT010302画面(商标变更明细表)的查询sql
  2199. /// </summary>
  2200. /// <returns>sql</returns>
  2201. private static string GetRPT010302SSQL()
  2202. {
  2203. string selSql =
  2204. "SELECT lcr.BarCode\n" +
  2205. " ,REPLACE((oldlogo.Logoname || '[' || oldlogo.Logocode || ']'),\n" +
  2206. " '[]',\n" +
  2207. " '') AS oldLogoCodeName\n" +
  2208. " ,REPLACE((newlogo.Logoname || '[' || newlogo.Logocode || ']'),\n" +
  2209. " '[]',\n" +
  2210. " '') AS newLogoCodeName\n" +
  2211. " ,lcr.Createtime\n" +
  2212. " ,gdd.GroutingLineCode\n" +
  2213. " ,gdd.GroutingLineName\n" +
  2214. " ,gdd.GroutingDate\n" +
  2215. " ,gdd.GroutingMouldCode\n" +
  2216. " ,gdd.MouldCode\n" +
  2217. " ,gdd.UserCode GroutingUserCode\n" +
  2218. " ,gdd.GroutingCount\n" +
  2219. " ,gdd.GoodsCode\n" +
  2220. " ,gdd.GoodsName\n" +
  2221. " ,p.PROCEDURECODE\n" +
  2222. " ,p.PROCEDURENAME\n" +
  2223. " ,u.USERCode\n" +
  2224. " ,u.USERNAME\n" +
  2225. " FROM TP_PM_LogoChangedRecord lcr\n" +
  2226. " LEFT JOIN TP_PM_GROUTINGDAILYDETAIL gdd\n" +
  2227. " ON lcr.barcode = gdd.Barcode\n" +
  2228. " LEFT JOIN TP_PC_PROCEDURE p\n" +
  2229. " ON lcr.Procedureid = p.PROCEDUREID\n" +
  2230. " LEFT JOIN TP_MST_USER u\n" +
  2231. " ON lcr.CreateUserID = u.USERID\n" +
  2232. " LEFT JOIN TP_MST_logo oldlogo\n" +
  2233. " ON lcr.oldlogoid = oldlogo.logoid\n" +
  2234. " LEFT JOIN TP_MST_logo newlogo\n" +
  2235. " ON lcr.newlogoid = newlogo.logoid\n" +
  2236. " WHERE lcr.ACCOUNTID = :AccountID";
  2237. return selSql;
  2238. }
  2239. #endregion 明细报表
  2240. #region 分析报表
  2241. /// <summary>
  2242. /// 取得RPT040101_1画面(注浆交坯比率分析表)的查询数据
  2243. /// </summary>
  2244. /// <param name="user">登录用户信息</param>
  2245. /// <param name="se">查询条件</param>
  2246. /// <returns>查询结果</returns>
  2247. public static ServiceResultEntity GetRPT040101SData(SUserInfo user, RPT040101_SE se)
  2248. {
  2249. IDBConnection conn = null;
  2250. try
  2251. {
  2252. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  2253. #region
  2254. /*
  2255. List<OracleParameter> parameters = new List<OracleParameter>();
  2256. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT040101SSQL());
  2257. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2258. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.GroutingDateStart.Value, ParameterDirection.Input));
  2259. parameters.Add(new OracleParameter(":groutingDateEnd", OracleDbType.Date, se.GroutingDateEnd.Value, ParameterDirection.Input));
  2260. parameters.Add(new OracleParameter(":dateDifference", OracleDbType.Int32, se.DateDifference, ParameterDirection.Input));
  2261. if (se != null)
  2262. {
  2263. // 成型线IDS
  2264. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  2265. {
  2266. sql.Append(" AND instr(',' || :GroutingLineIDS ||',',','||TP_PM_GroutingDailyDetail.GroutingLineId||',')>0 ");
  2267. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  2268. }
  2269. // 成型工IDS
  2270. if (!string.IsNullOrEmpty(se.UserIDS))
  2271. {
  2272. sql.Append(" AND instr(',' || :UserIDS ||',',','||TP_PM_GroutingDailyDetail.UserId||',')>0 ");
  2273. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  2274. }
  2275. //产品类型IDS
  2276. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  2277. {
  2278. sql.Append(" AND instr(',' || :GoodsTypeIDS ||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ");
  2279. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  2280. }
  2281. //产品IDS
  2282. if (!string.IsNullOrEmpty(se.GoodsIDS))
  2283. {
  2284. sql.Append(" AND instr(',' || :GoodsIDS ||',',','||TP_PM_GroutingDailyDetail.GoodsId||',')>0 ");
  2285. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  2286. }
  2287. }
  2288. sql.Append(" group by ");
  2289. sql.Append(" TP_PM_GroutingDailyDetail.UserCode, ");
  2290. sql.Append(" TP_PM_GroutingDailyDetail.Groutinglineid, ");
  2291. sql.Append(" line.GroutinglineCode, ");
  2292. sql.Append(" TP_MST_GOODSTYPE.GoodsTypeName, ");
  2293. sql.Append(" TP_PM_GroutingDailyDetail.GoodsCode, ");
  2294. sql.Append(" TP_MST_Goods.Goodsspecification, ");
  2295. sql.Append(" TP_MST_DataDictionary.DICTIONARYVALUE, ");
  2296. sql.Append(" MouldQuantity ");
  2297. sql.Append(" ) temp ");
  2298. sql.Append(" ) a ");
  2299. sql.Append(" group by rollup( ");
  2300. sql.Append(" UserCode, ");
  2301. sql.Append(" Groutinglinecode, ");
  2302. sql.Append(" GoodsTypeName, ");
  2303. sql.Append(" GoodsCode, ");
  2304. sql.Append(" Goodsspecification, ");
  2305. sql.Append(" DICTIONARYVALUE, ");
  2306. sql.Append(" MouldQuantity, ");
  2307. sql.Append(" 注浆量, ");
  2308. sql.Append(" 交坯量 ");
  2309. sql.Append(" ) ");
  2310. sql.Append(") Temp where 交坯量 is not null");
  2311. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  2312. */
  2313. #endregion
  2314. List<OracleParameter> parameters = new List<OracleParameter>();
  2315. //StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT040101SSQL());
  2316. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2317. //parameters.Add(new OracleParameter(":dateDifference", OracleDbType.Int32, se.DateDifference, ParameterDirection.Input));
  2318. string sqlGroutingdate = null;
  2319. StringBuilder sql = new StringBuilder();
  2320. if (se != null)
  2321. {
  2322. // 成型线IDS
  2323. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  2324. {
  2325. sql.Append(" AND instr(',' || :GroutingLineIDS ||',',','||gdd.GroutingLineId||',')>0 ");
  2326. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  2327. }
  2328. // 成型工IDS
  2329. if (!string.IsNullOrEmpty(se.UserIDS))
  2330. {
  2331. sql.Append(" AND instr(',' || :UserIDS ||',',','||gdd.UserId||',')>0 ");
  2332. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  2333. }
  2334. //产品类型IDS
  2335. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  2336. {
  2337. //sql.Append(" AND instr(',' || :GoodsTypeIDS ||',',','||gt.GOODSTYPECode||',')=1");
  2338. sql.Append(" AND instr(gt.GOODSTYPECode,:GoodsTypeIDS)=1");
  2339. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  2340. }
  2341. //产品IDS
  2342. if (!string.IsNullOrEmpty(se.GoodsIDS))
  2343. {
  2344. sql.Append(" AND instr(',' || :GoodsIDS ||',',','||gdd.GoodsId||',')>0 ");
  2345. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  2346. }
  2347. if (se.GroutingDateStart.HasValue)
  2348. {
  2349. //sql.Append(" and gdd.groutingdate >= :groutingDateStart \n");
  2350. //sql.Append(" and gdd.groutingdate <= :groutingDateEnd \n");
  2351. sqlGroutingdate = " and gdd.groutingdate >= :groutingDateStart \n"
  2352. + " and gdd.groutingdate <= :groutingDateEnd \n";
  2353. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.GroutingDateStart.Value, ParameterDirection.Input));
  2354. parameters.Add(new OracleParameter(":groutingDateEnd", OracleDbType.Date, se.GroutingDateEnd.Value, ParameterDirection.Input));
  2355. parameters.Add(new OracleParameter(":DeliverTimeStart", OracleDbType.Date, se.GroutingDateStart.Value.AddDays(se.DateDifference), ParameterDirection.Input));
  2356. parameters.Add(new OracleParameter(":DeliverTimeEnd", OracleDbType.Date, se.GroutingDateEnd.Value.AddDays(se.DateDifference), ParameterDirection.Input));
  2357. }
  2358. else if (se.GCTimeBegin.HasValue)
  2359. {
  2360. //sql.Append(" and gdd.createtime >= :groutingDateStart \n");
  2361. //sql.Append(" and gdd.createtime <= :groutingDateEnd \n");
  2362. sqlGroutingdate = " and gdd.createtime >= :groutingDateStart \n"
  2363. + " and gdd.createtime <= :groutingDateEnd \n";
  2364. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.GCTimeBegin.Value, ParameterDirection.Input));
  2365. parameters.Add(new OracleParameter(":groutingDateEnd", OracleDbType.Date, se.GCTimeEnd.Value, ParameterDirection.Input));
  2366. parameters.Add(new OracleParameter(":DeliverTimeStart", OracleDbType.Date, se.GCTimeBegin.Value.Date.AddDays(se.DateDifference), ParameterDirection.Input));
  2367. parameters.Add(new OracleParameter(":DeliverTimeEnd", OracleDbType.Date, se.GCTimeEnd.Value.Date.AddDays(se.DateDifference), ParameterDirection.Input));
  2368. }
  2369. }
  2370. string sqlString =
  2371. "select decode(gid, 7, '总计', 3, '合计['|| gddata.usercode ||']', gddata.usercode) usercode,\n" +
  2372. " decode(gid, 1, '小计['|| gddata.goodscode ||']', 0, gddata.goodscode, '--') goodscode,\n" +
  2373. " decode(gid, 0, gddata.goodstypename, '--') goodstypename,\n" +
  2374. " decode(gid, 0, gddata.goodsspecification, '--') goodsspecification,\n" +
  2375. " decode(gid, 0, gddata.GlazeType, '--') GlazeType,\n" +
  2376. " decode(gid, 0, gddata.groutinglinecode, '--') groutinglinecode,\n" +
  2377. " decode(gid, 0, to_char(gddata.MouldQuantity), '--') MouldQuantity,\n" +
  2378. //" select gddata.usercode,\n" +
  2379. //" gddata.goodscode,\n" +
  2380. //" gddata.goodstypename,\n" +
  2381. //" gddata.goodsspecification,\n" +
  2382. //" gddata.GlazeType,\n" +
  2383. //" gddata.groutinglinecode,\n" +
  2384. //" gddata.MouldQuantity,\n" +
  2385. " gddata.GroutingNum,\n" +
  2386. " gddata.StrippingNum,\n" +
  2387. " gddata.DeliverNum,\n" +
  2388. " decode(gddata.GroutingNum,\n" +
  2389. " 0,\n" +
  2390. " '0.00%',\n" +
  2391. " to_char((gddata.StrippingNum / gddata.GroutingNum) * 100,\n" +
  2392. " '9,990.00') || '%') GSPercent, -- 注成比,\n" +
  2393. " decode(gddata.GroutingNum,\n" +
  2394. " 0,\n" +
  2395. " '0.00%',\n" +
  2396. " to_char((gddata.DeliverNum / gddata.GroutingNum) * 100,\n" +
  2397. " '9,990.00') || '%') GDPercent, -- 注交比,\n" +
  2398. " decode(gddata.StrippingNum,\n" +
  2399. " 0,\n" +
  2400. " '0.00%',\n" +
  2401. " to_char((gddata.DeliverNum / gddata.StrippingNum) * 100,\n" +
  2402. " '9,990.00') || '%') SDPercent -- 成交比,\n" +
  2403. " from (select grouping_id(gdd.flag,gdd.usercode, gdd.goodscode, gdd.groutinglinecode) gid,\n" +
  2404. //" select grouping_id(gdd.flag,gdd.usercode, gdd.goodscode, gdd.groutinglinecode) gid,\n" +
  2405. " gdd.usercode,\n" +
  2406. " gdd.goodscode,\n" +
  2407. " gdd.goodstypename,\n" +
  2408. " gdd.goodsspecification,\n" +
  2409. " gdd.GlazeType,\n" +
  2410. " gdd.groutinglinecode,\n" +
  2411. " gdd.MouldQuantity,\n" +
  2412. " sum(gdd.GroutingNum) GroutingNum,\n" +
  2413. " sum(gdd.StrippingNum) StrippingNum,\n" +
  2414. " sum(gdd.DeliverNum) DeliverNum\n" +
  2415. " from (select 1 flag,\n" +
  2416. //" select 1 flag,\n" +
  2417. " gddgroup.usercode,\n" +
  2418. " gddgroup.goodscode,\n" +
  2419. " gddgroup.goodstypename,\n" +
  2420. " gddgroup.goodsspecification,\n" +
  2421. " gddgroup.GlazeType,\n" +
  2422. " gddgroup.groutinglinecode,\n" +
  2423. " gddgroup.MouldQuantity,\n" +
  2424. " sum(gddgroup.GroutingNum) GroutingNum,\n" +
  2425. " sum(gddgroup.StrippingNum) StrippingNum,\n" +
  2426. " sum(gddgroup.DeliverNum) DeliverNum\n" +
  2427. " from (select --gdd.groutingdailydetailid,\n" +
  2428. " gd.groutinglinecode,\n" +
  2429. " gt.goodstypename,\n" +
  2430. " g.goodscode,\n" +
  2431. " g.goodsspecification,\n" +
  2432. " dd.dictionaryvalue GlazeType,\n" +
  2433. //" gdd.usercode,\n" +
  2434. (se.IsMonitor ? " mu.username usercode,\n" : " gdd.usercode,\n") +
  2435. " gd.MouldQuantity,\n" +
  2436. " decode(gdd.GroutingFlag, '1', 1, 0) GroutingNum,\n" +
  2437. " case\n" +
  2438. " when gdd.GroutingFlag = '1' and gdd.ScrapFlag = '0' then\n" +
  2439. " 1\n" +
  2440. " else\n" +
  2441. " 0\n" +
  2442. " end StrippingNum,\n" +
  2443. " 0 DeliverNum\n" +
  2444. " from tp_pm_groutingdaily gd\n" +
  2445. " inner join tp_pm_groutingdailydetail gdd\n" +
  2446. " on gd.groutingdailyid = gdd.groutingdailyid\n" +
  2447. " left join tp_mst_user mu\n" +
  2448. " on mu.userid = gd.MonitorID\n" +
  2449. " inner join tp_mst_goods g\n" +
  2450. " on gdd.goodsid = g.goodsid\n" +
  2451. " inner join tp_mst_goodstype gt\n" +
  2452. " on g.goodstypeid = gt.goodstypeid\n" +
  2453. " inner join tp_mst_datadictionary dd\n" +
  2454. " on dd.dictionaryid = g.GlazeTypeID\n" +
  2455. " where gd.valueflag = '1'\n" +
  2456. " and gd.accountid = :AccountID\n"
  2457. + sqlGroutingdate +
  2458. //" and gdd.groutingdate >= :groutingDateStart \n" +
  2459. //" and gdd.groutingdate <= :groutingDateEnd \n" +
  2460. sql +
  2461. " union all\n" +
  2462. " select --gdd.groutingdailydetailid,\n" +
  2463. " gd.groutinglinecode,\n" +
  2464. " gt.goodstypename,\n" +
  2465. " g.goodscode,\n" +
  2466. " g.goodsspecification,\n" +
  2467. " dd.dictionaryvalue GlazeType,\n" +
  2468. //" gdd.usercode,\n" +
  2469. (se.IsMonitor ? " mu.username usercode,\n" : " gdd.usercode,\n") +
  2470. " gd.MouldQuantity,\n" +
  2471. " 0 GroutingNum,\n" +
  2472. " 0 StrippingNum,\n" +
  2473. " decode(gdd.deliverflag, '1', 1, 0) DeliverNum\n" +
  2474. " from tp_pm_groutingdaily gd\n" +
  2475. " inner join tp_pm_groutingdailydetail gdd\n" +
  2476. " on gd.groutingdailyid = gdd.groutingdailyid\n" +
  2477. " left join tp_mst_user mu\n" +
  2478. " on mu.userid = gd.MonitorID\n" +
  2479. " inner join tp_mst_goods g\n" +
  2480. " on gdd.goodsid = g.goodsid\n" +
  2481. " inner join tp_mst_goodstype gt\n" +
  2482. " on g.goodstypeid = gt.goodstypeid\n" +
  2483. " inner join tp_mst_datadictionary dd\n" +
  2484. " on dd.dictionaryid = g.GlazeTypeID\n" +
  2485. " where gd.valueflag = '1'\n" +
  2486. " and gd.accountid = :AccountID\n" +
  2487. " and gdd.DeliverTime >= :DeliverTimeStart \n" +
  2488. " and gdd.DeliverTime <= :DeliverTimeEnd \n" + sql +
  2489. " ) gddgroup\n" +
  2490. " group by gddgroup.usercode, gddgroup.goodscode, gddgroup.goodstypename, gddgroup.goodsspecification, gddgroup.GlazeType, gddgroup.groutinglinecode, gddgroup.MouldQuantity\n" +
  2491. " order by gddgroup.usercode, gddgroup.goodscode, gddgroup.groutinglinecode\n" +
  2492. " ) gdd\n" +
  2493. " 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" +
  2494. //" order by gdd.usercode, gdd.goodscode, gdd.groutinglinecode " +
  2495. ") gddata";
  2496. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  2497. ServiceResultEntity sre = new ServiceResultEntity();
  2498. if (data == null || data.Rows.Count == 0)
  2499. {
  2500. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2501. return sre;
  2502. }
  2503. sre.Data = new DataSet();
  2504. sre.Data.Tables.Add(data);
  2505. return sre;
  2506. }
  2507. catch (Exception ex)
  2508. {
  2509. throw ex;
  2510. }
  2511. finally
  2512. {
  2513. if (conn != null &&
  2514. conn.ConnState == ConnectionState.Open)
  2515. {
  2516. conn.Close();
  2517. }
  2518. }
  2519. }
  2520. /// <summary>
  2521. /// 获取RPT040101_1画面(注浆交坯比率分析表)的查询sql
  2522. /// </summary>
  2523. /// <returns>sql</returns>
  2524. private static string GetRPT040101SSQL()
  2525. {
  2526. string selSql =
  2527. "select " +
  2528. "UserCode, " +
  2529. "Groutinglinename, " +
  2530. "GoodsTypeName, " +
  2531. "GoodsCode, " +
  2532. "Goodsspecification, " +
  2533. "DICTIONARYVALUE, " +
  2534. "MouldQuantity, " +
  2535. "注浆量, " +
  2536. "交坯量, " +
  2537. "交坯率 " +
  2538. "from " +
  2539. "( " +
  2540. " select " +
  2541. " decode(grouping(UserCode),1,'合计', UserCode) UserCode, " +
  2542. " decode(grouping(UserCode),1,'--', Groutinglinecode) Groutinglinename, " +
  2543. " decode(grouping(UserCode),1,'--', GoodsTypeName) GoodsTypeName, " +
  2544. " decode(grouping(UserCode),1,'--', GoodsCode) GoodsCode, " +
  2545. " decode(grouping(UserCode),1,'--', Goodsspecification) Goodsspecification, " +
  2546. " decode(grouping(UserCode),1,'--', DICTIONARYVALUE) DICTIONARYVALUE, " +
  2547. " decode(grouping(UserCode),1,sum(MouldQuantity), MouldQuantity) MouldQuantity, " +
  2548. " decode(grouping(UserCode),1,sum(注浆量), 注浆量) 注浆量, " +
  2549. " decode(grouping(UserCode),1,sum(交坯量), 交坯量) 交坯量, " +
  2550. " decode(grouping(UserCode),1,TO_CHAR((sum(交坯量)/sum(注浆量))*100,'9,999.99')||'%', TO_CHAR((交坯量/注浆量)*100,'9,999.99')||'%' ) 交坯率 " +
  2551. " from " +
  2552. " ( " +
  2553. " select " +
  2554. " UserCode, " +
  2555. " Groutinglinecode, " +
  2556. " GoodsTypeName, " +
  2557. " GoodsCode, " +
  2558. " Goodsspecification, " +
  2559. " DICTIONARYVALUE, " +
  2560. " MouldQuantity, " +
  2561. " 注浆量, " +
  2562. " ( " +
  2563. " select count(TP_PM_ProductionData.Productiondataid) " +
  2564. " from TP_PM_ProductionData " +
  2565. " where " +
  2566. " TP_PM_ProductionData.Accountid=:AccountID and TP_PM_ProductionData.ModelType=5 " +
  2567. " and TP_PM_ProductionData.Usercode=temp.UserCode " +
  2568. " and TP_PM_ProductionData.GROUTINGLINEID=temp.Groutinglineid " +
  2569. //--交坯比率应该是统计的某一时间段注浆的产品,其所交坯的数量,
  2570. //所以交坯的的产品应属于这段期间注浆的产品---袁新成2015-4-16改 --
  2571. //" and TP_PM_ProductionData.Barcode in (select barcode from TP_PM_GroutingDailyDetail where " +
  2572. //" TP_PM_GroutingDailyDetail.Valueflag=1 " +
  2573. //" and TP_PM_GroutingDailyDetail.GroutingFlag=1 " +
  2574. //" AND TP_PM_GroutingDailyDetail.AccountID=:AccountID " +
  2575. //" AND TP_PM_GroutingDailyDetail.GroutingDate >= :groutingDateStart " +
  2576. //" AND TP_PM_GroutingDailyDetail.GroutingDate <= :groutingDateEnd )" +
  2577. //交坯的其实日期应该还是与注浆的开始日期相同,只是结束日期推后 dateDifferentce天 ---袁新成2015-4-16改--
  2578. //" and TP_PM_ProductionData.AccountDate >= :groutingDateStart " +
  2579. " and TP_PM_ProductionData.AccountDate >= :groutingDateStart+:dateDifference " +
  2580. " and TP_PM_ProductionData.AccountDate >= :groutingDateStart " +
  2581. " and TP_PM_ProductionData.AccountDate <= :groutingDateEnd +:dateDifference " +
  2582. " ) as 交坯量 " +
  2583. " from " +
  2584. " ( " +
  2585. " select " +
  2586. " TP_PM_GroutingDailyDetail.UserCode as UserCode, " +
  2587. " TP_PM_GroutingDailyDetail.Groutinglineid, " +
  2588. " line.GroutinglineCode, " +
  2589. " TP_MST_GOODSTYPE.GoodsTypeName, " +
  2590. " TP_PM_GroutingDailyDetail.GoodsCode, " +
  2591. " TP_MST_Goods.Goodsspecification, " +
  2592. " TP_MST_DataDictionary.DICTIONARYVALUE, " +
  2593. " line.MouldQuantity, " +
  2594. " count(TP_PM_GroutingDailyDetail.GroutingCount) as 注浆量 " +
  2595. " from " +
  2596. " TP_PM_GroutingDailyDetail " +
  2597. " inner join TP_MST_Goods on TP_MST_Goods.Goodsid= TP_PM_GroutingDailyDetail.Goodsid " +
  2598. " inner join TP_MST_GOODSTYPE on TP_MST_GOODSTYPE.GOODSTYPEID = TP_MST_Goods.Goodstypeid " +
  2599. " inner join TP_MST_DataDictionary on TP_MST_DataDictionary.Dictionaryid=TP_MST_Goods.GLAZETYPEID " +
  2600. " inner join TP_PM_GroutingDaily on TP_PM_GroutingDailyDetail.Groutingdailyid=TP_PM_GroutingDaily.Groutingdailyid " +
  2601. " inner join TP_PC_GroutingLine line on line.Groutinglineid = TP_PM_GroutingDailyDetail.Groutinglineid " +
  2602. " where " +
  2603. " TP_PM_GroutingDailyDetail.Valueflag=1 " +
  2604. " and TP_PM_GroutingDailyDetail.GroutingFlag=1 " +
  2605. " AND TP_PM_GroutingDailyDetail.AccountID=:AccountID " +
  2606. " AND TP_PM_GroutingDailyDetail.GroutingDate >= :groutingDateStart " +
  2607. " AND TP_PM_GroutingDailyDetail.GroutingDate <= :groutingDateEnd ";
  2608. return selSql;
  2609. }
  2610. /// <summary>
  2611. /// 取得RPT040102_1画面(工序产量分析表)的查询数据
  2612. /// </summary>
  2613. /// <param name="user">登录用户信息</param>
  2614. /// <param name="se">查询条件</param>
  2615. /// <returns>查询结果</returns>
  2616. public static ServiceResultEntity GetRPT040102SData(SUserInfo user, RPT040102_SE se)
  2617. {
  2618. IDBConnection conn = null;
  2619. try
  2620. {
  2621. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  2622. //OracleParameter[] paras = new OracleParameter[]{
  2623. // new OracleParameter("in_goodsTypeIds",OracleDbType.Varchar2,se.GoodsTypeIDS,ParameterDirection.Input),
  2624. // new OracleParameter("in_goodsIds",OracleDbType.Varchar2,se.GoodsIDS,ParameterDirection.Input),
  2625. // new OracleParameter("in_productionLineId",OracleDbType.Int32,se.ProductionLineID,ParameterDirection.Input),
  2626. // new OracleParameter("in_accountDateStart",OracleDbType.Varchar2,se.AccountDateStart,ParameterDirection.Input),
  2627. // new OracleParameter("in_accountDateEnd",OracleDbType.Varchar2,se.AccountDateEnd,ParameterDirection.Input),
  2628. // new OracleParameter("in_accountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  2629. // new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  2630. //};
  2631. /*
  2632. OracleParameter[] paras = new OracleParameter[]{
  2633. new OracleParameter("in_productionLineId",OracleDbType.Int32,se.ProductionLineID,ParameterDirection.Input),
  2634. new OracleParameter("in_procedureids",OracleDbType.Varchar2,se.ProcedureIDs,ParameterDirection.Input),
  2635. new OracleParameter("in_goodsTypeIds",OracleDbType.Varchar2,se.GoodsTypeIDS,ParameterDirection.Input),
  2636. new OracleParameter("in_goodsIds",OracleDbType.Varchar2,se.GoodsIDS,ParameterDirection.Input),
  2637. new OracleParameter("in_accountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  2638. new OracleParameter("in_accountDateStart",OracleDbType.Date,se.AccountDateStart,ParameterDirection.Input),
  2639. new OracleParameter("in_accountDateEnd",OracleDbType.Date,se.AccountDateEnd,ParameterDirection.Input),
  2640. new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  2641. };
  2642. //DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetLineProcessTotal", paras);
  2643. DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetLineProcessTotalNew", paras);
  2644. ServiceResultEntity sre = new ServiceResultEntity();
  2645. if (data == null || data.Tables.Count == 0)
  2646. {
  2647. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2648. return sre;
  2649. }
  2650. sre.Data = new DataSet();
  2651. sre.Data = data;
  2652. return sre;
  2653. */
  2654. ServiceResultEntity sre = new ServiceResultEntity();
  2655. List<OracleParameter> parameters = new List<OracleParameter>();
  2656. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2657. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  2658. string sqlString =
  2659. "select p.procedureid, p.procedurecode, p.procedurename\n" +
  2660. " from tp_pc_procedure p\n" +
  2661. " where p.valueflag = '1'\n" +
  2662. " and p.AccountID = :AccountID" +
  2663. " and p.productionlineid = :productionlineid\n";
  2664. if (!string.IsNullOrWhiteSpace(se.ProcedureIDs))
  2665. {
  2666. sqlString += " and instr(',' || :procedureids || ',', ',' || p.procedureid || ',') > 0\n";
  2667. parameters.Add(new OracleParameter(":procedureids", OracleDbType.NVarchar2, se.ProcedureIDs, ParameterDirection.Input));
  2668. }
  2669. sqlString += "order by p.Displayno";
  2670. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  2671. if (data == null || data.Rows.Count == 0)
  2672. {
  2673. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2674. return sre;
  2675. }
  2676. parameters.Clear();
  2677. StringBuilder sql1 = new StringBuilder();
  2678. StringBuilder sql2 = new StringBuilder();
  2679. StringBuilder sql3 = new StringBuilder();
  2680. foreach (DataRow item in data.Rows)
  2681. {
  2682. //sql1.Append(", decode(pd.procedureid, " + item["procedureid"] + ", 1, 0) as A" + item["procedurecode"] + "\n");
  2683. //sql2.Append(", sum(pdata.A" + item["procedurecode"] + ") as A" + item["procedurecode"] + "\n");
  2684. //sql3.Append(", pdg.A" + item["procedurecode"] + " as \"" + item["procedurename"] + "\" \n");
  2685. sql1.Append(", sum(decode(pd.procedureid, " + item["procedureid"] + ", 1, 0)) as A" + item["procedurecode"] + "\n");
  2686. sql2.Append(", sum(pdata.A" + item["procedurecode"] + ") as A" + item["procedurecode"] + "\n");
  2687. sql3.Append(", pdg.A" + item["procedurecode"] + " as \"" + item["procedurename"] + "\" \n");
  2688. }
  2689. sqlString =
  2690. "select --pdg.gid,\n" +
  2691. " decode(pdg.gid, 1, '小计', 3, '合计', 0, pdg.goodstypename2, '--') \"产品二级类别\",\n" +
  2692. " decode(pdg.gid, 0, pdg.goodstypename, '--') \"产品类别\",\n" +
  2693. " decode(pdg.gid, 0, pdg.goodscode, '--') \"产品编码\",\n" +
  2694. " decode(pdg.gid, 0, pdg.goodsspecification, '--') \"产品规格\",\n" +
  2695. " --decode(pdg.gid, 0, pdg.GOODSMODEL, '--') \"产品型号\",\n" +
  2696. " decode(pdg.gid, 0, pdg.GLAZETYPE, '--') \"釉料类别\"\n" +
  2697. sql3 +
  2698. " from ( select " +
  2699. " grouping_id(pdata.productionlineid,pdata.goodstypename2,pdata.goodscode) gid," +
  2700. " pdata.productionlineid,\n" +
  2701. " pdata.goodstypename2,\n" +
  2702. " pdata.goodstypename,\n" +
  2703. " pdata.goodscode,\n" +
  2704. " pdata.goodsspecification,\n" +
  2705. " pdata.GOODSMODEL,\n" +
  2706. " pdata.GLAZETYPE\n" +
  2707. sql2 +
  2708. " from (" +
  2709. " select\n" +
  2710. " pd.productionlineid,\n" +
  2711. " gt2.goodstypename goodstypename2,\n" +
  2712. " gt.goodstypename,\n" +
  2713. " g.goodscode,\n" +
  2714. " g.goodsspecification,\n" +
  2715. " g.GOODSMODEL,\n" +
  2716. " dd.dictionaryvalue GLAZETYPE\n" +
  2717. sql1 +
  2718. " from tp_pm_productiondata pd\n" +
  2719. " inner join tp_mst_goods g\n" +
  2720. " on g.goodsid = pd.goodsid\n" +
  2721. " inner join tp_mst_goodstype gt\n" +
  2722. " on gt.goodstypeid = g.goodstypeid\n" +
  2723. " inner join tp_mst_goodstype gt2\n" +
  2724. " on gt2.goodstypecode = substr(gt.goodstypecode, 0, 6)\n" +
  2725. " and gt2.accountid = gt.accountid\n" +
  2726. " inner join tp_mst_datadictionary dd\n" +
  2727. " on dd.dictionaryid = g.GLAZETYPEID\n" +
  2728. " where pd.valueflag = '1'\n" +
  2729. // 公坯、干补不算交坯工序的产量。
  2730. //" and ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.IsPublicBody = '0' and pd.SpecialRepairFlag = '0')) \n" +
  2731. // modify wangx 2015-12-3
  2732. (se.ProductionFlag == "1" ? " and ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" : "") +
  2733. " and pd.accountid = :accountid\n" +
  2734. " and pd.productionlineid = :productionlineid\n" +
  2735. " and pd.createtime >= :createtimeStart\n" +
  2736. " and pd.createtime <= :createtimeEnd\n";
  2737. StringBuilder sql = new StringBuilder(sqlString);
  2738. if (!string.IsNullOrWhiteSpace(se.GoodsIDS))
  2739. {
  2740. sql.Append(" and instr(',' || :goodsIds || ',', ',' || pd.goodsid || ',') > 0\n");
  2741. parameters.Add(new OracleParameter(":goodsIds", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  2742. }
  2743. if (!string.IsNullOrWhiteSpace(se.GoodsTypeIDS))
  2744. {
  2745. //sql.Append(" and instr(',' || :goodsTypeIds || ',', ',' || gt.goodstypecode || ',') =1\n");
  2746. sql.Append(" and instr(gt.goodstypecode,:goodsTypeIds) =1\n");
  2747. parameters.Add(new OracleParameter(":goodsTypeIds", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  2748. }
  2749. if (!string.IsNullOrWhiteSpace(se.ProcedureIDs))
  2750. {
  2751. sql.Append(" and instr(',' || :procedureids || ',', ',' || pd.procedureid || ',') > 0\n");
  2752. parameters.Add(new OracleParameter(":procedureids", OracleDbType.NVarchar2, se.ProcedureIDs, ParameterDirection.Input));
  2753. }
  2754. 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))");
  2755. parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  2756. sqlString =
  2757. " group by \n" +
  2758. " pd.productionlineid,\n" +
  2759. " gt2.goodstypename,\n" +
  2760. " gt.goodstypename,\n" +
  2761. " g.goodscode,\n" +
  2762. " g.goodsspecification,\n" +
  2763. " g.GOODSMODEL,\n" +
  2764. " dd.dictionaryvalue\n" +
  2765. " order by gt2.goodstypename, g.goodscode" +
  2766. " ) pdata\n" +
  2767. " group by grouping sets((pdata.productionlineid,\n" +
  2768. " pdata.goodstypename2,\n" +
  2769. " pdata.goodstypename,\n" +
  2770. " pdata.goodsspecification,\n" +
  2771. " pdata.GOODSMODEL,\n" +
  2772. " pdata.GLAZETYPE,\n" +
  2773. " pdata.goodscode),\n" +
  2774. " (pdata.productionlineid,pdata.goodstypename2),\n" +
  2775. " pdata.productionlineid)\n" +
  2776. " ) pdg";
  2777. sql.Append(sqlString);
  2778. parameters.Add(new OracleParameter(":accountid", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2779. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  2780. parameters.Add(new OracleParameter(":createtimeStart", OracleDbType.Date, se.AccountDateStart, ParameterDirection.Input));
  2781. parameters.Add(new OracleParameter(":createtimeEnd", OracleDbType.Date, se.AccountDateEnd, ParameterDirection.Input));
  2782. DataTable data1 = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  2783. if (data1 == null || data1.Rows.Count == 0)
  2784. {
  2785. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2786. return sre;
  2787. }
  2788. sre.Data = new DataSet();
  2789. sre.Data.Tables.Add(data1);
  2790. return sre;
  2791. }
  2792. catch (Exception ex)
  2793. {
  2794. throw ex;
  2795. }
  2796. finally
  2797. {
  2798. if (conn != null &&
  2799. conn.ConnState == ConnectionState.Open)
  2800. {
  2801. conn.Close();
  2802. }
  2803. }
  2804. }
  2805. /// <summary>
  2806. /// 取得RPT040103画面(工序质量分析表)的查询数据
  2807. /// </summary>
  2808. /// <param name="user">登录用户信息</param>
  2809. /// <param name="se">查询条件</param>
  2810. /// <returns>查询结果</returns>
  2811. public static ServiceResultEntity GetRPT040103SData(SUserInfo user, RPT040103_SE se)
  2812. {
  2813. IDBConnection conn = null;
  2814. try
  2815. {
  2816. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  2817. List<OracleParameter> parameters = new List<OracleParameter>();
  2818. //string sql = ReportModuleLogic.GetRPT040103SSQL(user, se, ref parameters);
  2819. string sql = ReportModuleLogic.GetRPT040103S1SQL(user, se, ref parameters);
  2820. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  2821. ServiceResultEntity sre = new ServiceResultEntity();
  2822. if (data == null || data.Rows.Count == 0)
  2823. {
  2824. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2825. return sre;
  2826. }
  2827. sre.Data = new DataSet();
  2828. sre.Data.Tables.Add(data);
  2829. return sre;
  2830. }
  2831. catch (Exception ex)
  2832. {
  2833. throw ex;
  2834. }
  2835. finally
  2836. {
  2837. if (conn != null &&
  2838. conn.ConnState == ConnectionState.Open)
  2839. {
  2840. conn.Close();
  2841. }
  2842. }
  2843. }
  2844. /// <summary>
  2845. /// 获取RPT040103画面(工序质量分析表)的查询sql
  2846. /// </summary>
  2847. /// <returns>sql</returns>
  2848. private static string GetRPT040103SSQL(SUserInfo user, RPT040103_SE se, ref List<OracleParameter> parameters)
  2849. {
  2850. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2851. parameters.Add(new OracleParameter(":in_rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  2852. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  2853. // 2015-06-16 modify by chenxy
  2854. string sqlString = "\n" +
  2855. "select qdgroup.gid,\n" +
  2856. " decode(qdgroup.gid, 0, qdgroup.productionlinename, '--') productionlinename,\n" +
  2857. " decode(qdgroup.gid, 15, '总计', 0, qdgroup.procedurename, '--') procedurename,\n" +
  2858. " decode(qdgroup.gid, 7, '合计', 0, qdgroup.kilncode, '--') kilncode,\n" +
  2859. " decode(qdgroup.gid, 3, '小计', 0, qdgroup.goodstypename2, '--') goodstypename2,\n" +
  2860. " decode(qdgroup.gid, 0, qdgroup.usercode, '--') usercode,\n" +
  2861. " decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename,\n" +
  2862. " decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode,\n" +
  2863. " qdgroup.OutKilnCount,\n" +
  2864. " qdgroup.GoodCount,\n" +
  2865. " to_char((qdgroup.GoodCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' GoodPercent,\n" +
  2866. " qdgroup.SubstandardCount,\n" +
  2867. " to_char((qdgroup.SubstandardCount / qdgroup.OutKilnCount) * 100,\n" +
  2868. " '990.00') || '%' SubstandardPercent,\n" +
  2869. " qdgroup.GoodCount+qdgroup.BadCount Qualified,\n" +
  2870. " to_char(((qdgroup.GoodCount+qdgroup.BadCount) / qdgroup.OutKilnCount) * 100,\n" +
  2871. " '990.00') || '%' QualifiedPercent,\n" +
  2872. " qdgroup.BadCount,\n" +
  2873. " to_char((qdgroup.BadCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' BadPercent,\n" +
  2874. " qdgroup.ReFireCount,\n" +
  2875. " to_char((qdgroup.ReFireCount / qdgroup.OutKilnCount) * 100,\n" +
  2876. " '990.00') || '%' ReFirePercent\n" +
  2877. " from (select grouping_id(pcpl.productionlinename,\n" +
  2878. " pcp.procedurename,\n" +
  2879. " mstkiln.kilncode,\n" +
  2880. " mstgoodstype2.goodstypename,\n" +
  2881. " qd.usercode,\n" +
  2882. " --mstgoodstype.goodstypename,\n" +
  2883. " mstgoods.goodscode) gid,\n" +
  2884. " pcpl.productionlinename,\n" +
  2885. " pcp.procedurename,\n" +
  2886. " --qd.kilnid,\n" +
  2887. " mstkiln.kilncode,\n" +
  2888. " mstgoodstype2.goodstypename goodstypename2,\n" +
  2889. " qd.usercode,\n" +
  2890. " mstgoodstype.goodstypename,\n" +
  2891. " mstgoods.goodscode,\n" +
  2892. " sum(qd.OutKilnCount) OutKilnCount,\n" +
  2893. " sum(qd.GoodCount) GoodCount,\n" +
  2894. " sum(qd.SubstandardCount) SubstandardCount,\n" +
  2895. " sum(qd.BadCount) BadCount,\n" +
  2896. " sum(qd.ReFireCount) ReFireCount\n" +
  2897. " from (select --pdbc.barcode,\n" +
  2898. " pdbc.productionlineid,\n" +
  2899. " pdata.procedureid,\n" +
  2900. " pdata.usercode,\n" +
  2901. " pdbc.goodsid,\n" +
  2902. " pdbc.kilnid,\n" +
  2903. " --pdbc.kilncarid,\n" +
  2904. " --pdbc.kilncarbatchno,\n" +
  2905. " 1 OutKilnCount,\n" +
  2906. " case\n" +
  2907. " when defect.defectprocedureid is not null and glt.goodsleveltypeid in (5, 6, 7) then\n" +
  2908. " 0\n" +
  2909. " else\n" +
  2910. " 1\n" +
  2911. " end GoodCount,\n" +
  2912. " case\n" +
  2913. " when defect.defectprocedureid is not null and glt.goodsleveltypeid = 7 then\n" +
  2914. " 1\n" +
  2915. " else\n" +
  2916. " 0\n" +
  2917. " end SubstandardCount,\n" +
  2918. " case\n" +
  2919. " when defect.defectprocedureid is not null and glt.goodsleveltypeid = 6 then\n" +
  2920. " 1\n" +
  2921. " else\n" +
  2922. " 0\n" +
  2923. " end ReFireCount,\n" +
  2924. " case\n" +
  2925. " when defect.defectprocedureid is not null and glt.goodsleveltypeid = 5 then\n" +
  2926. " 1\n" +
  2927. " else\n" +
  2928. " 0\n" +
  2929. " end BadCount\n" +
  2930. " from (select distinct pd.barcode,\n" +
  2931. " pd.productionlineid,\n" +
  2932. " pd.goodsid,\n" +
  2933. " pd.kilnid,\n" +
  2934. " --pd.kilncarid,\n" +
  2935. " pd.kilncarbatchno\n" +
  2936. " from tp_pm_productiondata pd\n" +
  2937. " where pd.valueflag = '1'\n" +
  2938. " and pd.procedureid = :in_rptSprocedureId \n" +
  2939. " and pd.AccountID = :AccountID\n ";
  2940. StringBuilder selSql = new StringBuilder(sqlString);
  2941. if (se.CreateTimeStart.HasValue)
  2942. {
  2943. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  2944. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  2945. }
  2946. if (se.CreateTimeEnd.HasValue)
  2947. {
  2948. selSql.Append(" AND pd.createtime <= :CreateTimeEnd\n");
  2949. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  2950. }
  2951. if (!string.IsNullOrEmpty(se.GoodsIDS))
  2952. {
  2953. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  2954. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  2955. }
  2956. if (se.ProductionLineID.HasValue)
  2957. {
  2958. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  2959. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  2960. }
  2961. //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))");
  2962. //parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  2963. if (se.KilnID.HasValue)
  2964. {
  2965. selSql.Append(" AND pd.KilnID = :KilnID\n");
  2966. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  2967. }
  2968. sqlString =
  2969. " ) pdbc\n" + // 成检交接工序
  2970. " inner join (select distinct pd.barcode,\n" +
  2971. " pd.userid,\n" +
  2972. " pd.usercode,\n" +
  2973. " pd.procedureid\n" +
  2974. " from tp_pm_productiondata pd\n" +
  2975. " where pd.valueflag = '1'\n" +
  2976. " and pd.AccountID = :AccountID\n" +
  2977. // 公坯、干补不算交坯工序的质量。
  2978. //" and ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.IsPublicBody = '0' and pd.SpecialRepairFlag = '0')) \n" +
  2979. // 干补不算交坯工序的质量。
  2980. " and ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" +
  2981. " and exists\n" +
  2982. " (select 1\n" +
  2983. " from tp_mst_rpttprocedure rptt\n" +
  2984. " where rptt.RPTPROCEDUREID = :in_rptProcedureId\n";
  2985. selSql.Append(sqlString);
  2986. if (!string.IsNullOrEmpty(se.RptTProcedureIDS))
  2987. {
  2988. selSql.Append(" AND instr(','||:rptTprocedureIDS||',', ','||rptt.procedureid||',') > 0\n");
  2989. parameters.Add(new OracleParameter(":rptTprocedureIDS", OracleDbType.NVarchar2, se.RptTProcedureIDS, ParameterDirection.Input));
  2990. }
  2991. //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))");
  2992. selSql.Append(" and rptt.procedureid = pd.procedureid)\n");
  2993. if (!string.IsNullOrEmpty(se.UserIDS))
  2994. {
  2995. selSql.Append(" and instr(','||:userIDS||',', ','||pd.Userid||',') > 0\n");
  2996. parameters.Add(new OracleParameter(":userIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  2997. }
  2998. sqlString =
  2999. " ) pdata\n" + // 生产工序
  3000. " on pdata.barcode = pdbc.barcode\n" +
  3001. " left join (select kcbc.barcode, kcbc.kilncarbatchno, kcbc.goodsleveltypeid, kcbc.productiondataid\n" +
  3002. " from (select pd.barcode,\n" +
  3003. " pd.kilncarbatchno,\n" +
  3004. " pd.goodsleveltypeid,\n" +
  3005. " pd.productiondataid,\n" +
  3006. " ROW_NUMBER() OVER(PARTITION BY pd.barcode, pd.kilncarbatchno ORDER BY pd.productiondataid desc) AS dataid\n" +
  3007. " from tp_pm_productiondata pd\n" +
  3008. " where pd.valueflag = '1'\n" +
  3009. " and pd.AccountID = :AccountID\n" +
  3010. " and length(pd.kilncarbatchno) > 0\n" +
  3011. " AND pd.createtime >= :CreateTimeStart\n" +
  3012. " and pd.modeltype = -1) kcbc\n" +
  3013. " where kcbc.dataid = 1) glt\n" +
  3014. " on pdbc.kilncarbatchno = glt.kilncarbatchno\n" +
  3015. " and pdbc.barcode = glt.barcode\n" +
  3016. " left join (select distinct productiondataid, defectprocedureid" +
  3017. " from tp_pm_defect def " +
  3018. " where def.valueflag='1'" +
  3019. " and def.AccountID = :AccountID\n" +
  3020. " AND def.createtime >= :CreateTimeStart) defect\n" +
  3021. " on defect.productiondataid = glt.productiondataid\n" +
  3022. " and pdata.procedureid = defect.defectprocedureid\n" +
  3023. " ) qd\n" +
  3024. " inner join tp_pc_productionline pcpl\n" +
  3025. " on pcpl.productionlineid = qd.productionlineid\n" +
  3026. " inner join tp_pc_procedure pcp\n" +
  3027. " on pcp.procedureid = qd.procedureid\n" +
  3028. " inner join tp_mst_kiln mstkiln\n" +
  3029. " on mstkiln.kilnid = qd.kilnid\n" +
  3030. " inner join tp_mst_goods mstgoods\n" +
  3031. " on mstgoods.goodsid = qd.goodsid\n" +
  3032. " inner join tp_mst_goodstype mstgoodstype\n" +
  3033. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  3034. " and mstgoodstype.accountid = mstgoods.accountid\n" +
  3035. " inner join tp_mst_goodstype mstgoodstype2\n" +
  3036. " on mstgoodstype2.goodstypecode =\n" +
  3037. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  3038. " and mstgoodstype.accountid = mstgoodstype2.accountid\n" +
  3039. " where 1=1\n";
  3040. selSql.Append(sqlString);
  3041. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  3042. {
  3043. //selSql.Append(" AND instr(','||:GoodsTypeIDS||',', ','||mstgoodstype.GOODSTYPECode||',')=1\n");
  3044. selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS)=1\n");
  3045. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  3046. }
  3047. sqlString =
  3048. " group by grouping sets((pcpl.productionlinename,\n" +
  3049. " pcp.procedurename,\n" +
  3050. " mstkiln.kilncode,\n" +
  3051. " mstgoodstype2.goodstypename,\n" +
  3052. " qd.usercode,\n" +
  3053. " mstgoodstype.goodstypename,\n" +
  3054. " mstgoods.goodscode),\n" +
  3055. " (pcpl.productionlinename,\n" +
  3056. " pcp.procedurename,\n" +
  3057. " mstkiln.kilncode,\n" +
  3058. " mstgoodstype2.goodstypename),\n" +
  3059. " (pcpl.productionlinename,\n" +
  3060. " pcp.procedurename,\n" +
  3061. " mstkiln.kilncode),\n" +
  3062. " (pcpl.productionlinename, pcp.procedurename))\n" +
  3063. " order by pcpl.productionlinename,\n" +
  3064. " pcp.procedurename,\n" +
  3065. " mstkiln.kilncode,\n" +
  3066. " mstgoodstype2.goodstypename,\n" +
  3067. " qd.usercode,\n" +
  3068. " mstgoodstype.goodstypename,\n" +
  3069. " mstgoods.goodscode\n" +
  3070. " ) qdgroup\n";
  3071. selSql.Append(sqlString);
  3072. return selSql.ToString();
  3073. }
  3074. /// <summary>
  3075. /// 获取RPT040103画面(工序质量分析表-按登记时间)的查询sql
  3076. /// </summary>
  3077. /// <returns>sql</returns>
  3078. private static string GetRPT040103S1SQL(SUserInfo user, RPT040103_SE se, ref List<OracleParameter> parameters)
  3079. {
  3080. parameters.Add(new OracleParameter(":in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3081. parameters.Add(new OracleParameter(":in_rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  3082. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  3083. string sqlString = "select qdgroup.gid\n" +
  3084. " ,qdgroup.productionlinename\n" +
  3085. " ,decode(qdgroup.gid\n" +
  3086. " ,15\n" +
  3087. " ,'总计[' || qdgroup.procedurename || ']'\n" +
  3088. " ,qdgroup.procedurename) procedurename\n" +
  3089. " ,decode(qdgroup.gid\n" +
  3090. " ,7\n" +
  3091. " ,'合计[' || qdgroup.kilncode || ']'\n" +
  3092. " ,15\n" +
  3093. " ,'--'\n" +
  3094. " ,qdgroup.kilncode) kilncode\n" +
  3095. " ,decode(qdgroup.gid\n" +
  3096. " ,3\n" +
  3097. " ,'小计[' || qdgroup.goodstypename2 || ']'\n" +
  3098. " ,15\n" +
  3099. " ,'--'\n" +
  3100. " ,7\n" +
  3101. " ,'--'\n" +
  3102. " ,qdgroup.goodstypename2) goodstypename2\n" +
  3103. " ,decode(qdgroup.gid, 0, qdgroup.usercode, '--') usercode\n" +
  3104. " ,decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename\n" +
  3105. " ,decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode\n" +
  3106. " ,qdgroup.OutKilnCount\n" +
  3107. " ,qdgroup.GoodCount\n" +
  3108. " ,decode(qdgroup.OutKilnCount\n" +
  3109. " ,0\n" +
  3110. " ,to_number(null)\n" +
  3111. " ,round(qdgroup.GoodCount / qdgroup.OutKilnCount, 4)) GoodPercent\n" +
  3112. " ,qdgroup.SubstandardCount\n" +
  3113. " ,decode(qdgroup.OutKilnCount\n" +
  3114. " ,0\n" +
  3115. " ,to_number(null)\n" +
  3116. " ,round(qdgroup.SubstandardCount / qdgroup.OutKilnCount, 4)) SubstandardPercent\n" +
  3117. " ,qdgroup.GoodCount + qdgroup.BadCount Qualified\n" +
  3118. " ,decode(qdgroup.OutKilnCount\n" +
  3119. " ,0\n" +
  3120. " ,to_number(null)\n" +
  3121. " ,round((qdgroup.GoodCount + qdgroup.BadCount) /\n" +
  3122. " qdgroup.OutKilnCount\n" +
  3123. " ,4)) QualifiedPercent\n" +
  3124. " ,qdgroup.BadCount\n" +
  3125. " ,decode(qdgroup.OutKilnCount\n" +
  3126. " ,0\n" +
  3127. " ,to_number(null)\n" +
  3128. " ,round(qdgroup.BadCount / qdgroup.OutKilnCount, 4)) BadPercent\n" +
  3129. " ,qdgroup.ReFireCount\n" +
  3130. " ,decode(qdgroup.OutKilnCount\n" +
  3131. " ,0\n" +
  3132. " ,to_number(null)\n" +
  3133. " ,round(qdgroup.ReFireCount / qdgroup.OutKilnCount, 4)) ReFirePercent\n" +
  3134. " from (select grouping_id(pcpl.productionlinename\n" +
  3135. " ,pcp.procedurename\n" +
  3136. " ,mstkiln.kilncode\n" +
  3137. " ,mstgoodstype2.goodstypecode\n" +
  3138. " ,pdata.usercode\n" +
  3139. " ,mstgoods.goodscode) gid\n" +
  3140. " ,pcpl.productionlinename\n" +
  3141. " ,pcp.procedurename\n" +
  3142. " ,mstkiln.kilncode\n" +
  3143. " ,mstgoodstype2.goodstypename goodstypename2\n" +
  3144. " ,mstgoodstype2.goodstypecode goodstypecode2\n" +
  3145. " ,pdata.usercode\n" +
  3146. " ,mstgoodstype.goodstypename\n" +
  3147. " ,mstgoods.goodscode\n" +
  3148. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 0)), 0) OutKilnCount\n" +
  3149. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 5, 1, 0)), 0) BadCount\n" +
  3150. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 6, 1, 0)), 0) ReFireCount\n" +
  3151. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 7, 1, 0)), 0) SubstandardCount\n" +
  3152. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 5, -1, 6, -1, 7, -1, 0)), 0) GoodCount\n" +
  3153. " from (select 0 goodsleveltypeid -- 出窑数量\n" +
  3154. " ,pd.barcode\n" +
  3155. " ,pd.productionlineid\n" +
  3156. " ,pd.goodsid\n" +
  3157. " ,pd.kilnid\n" +
  3158. " ,pd.kilncarbatchno\n" +
  3159. " ,0 procedureid\n" +
  3160. " ,1 cc\n" +
  3161. " from tp_pm_productiondata pd\n" +
  3162. " where pd.valueflag = '1'\n" +
  3163. " and pd.procedureid = :in_rptSprocedureId\n" +
  3164. " and pd.accountid = :in_AccountID\n";
  3165. StringBuilder selSql = new StringBuilder(sqlString);
  3166. if (se.CreateTimeStart.HasValue)
  3167. {
  3168. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  3169. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3170. }
  3171. if (se.CreateTimeEnd.HasValue)
  3172. {
  3173. selSql.Append(" AND pd.createtime < :CreateTimeEnd\n");
  3174. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3175. }
  3176. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3177. {
  3178. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3179. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3180. }
  3181. if (se.ProductionLineID.HasValue)
  3182. {
  3183. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3184. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3185. }
  3186. if (se.KilnID.HasValue)
  3187. {
  3188. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3189. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3190. }
  3191. sqlString =
  3192. " union all\n" +
  3193. " select distinct ppd.goodsleveltypeid\n" +
  3194. " ,dd.barcode\n" +
  3195. " ,dd.productionlineid\n" +
  3196. " ,dd.goodsid\n" +
  3197. " ,ppd.kilnid\n" +
  3198. " ,ppd.kilncarbatchno\n" +
  3199. " ,dd.defectprocedureid procedureid\n" +
  3200. " ,1 cc\n" +
  3201. " from (select pd.productiondataid\n" +
  3202. " ,pd.goodsleveltypeid\n" +
  3203. " ,pd.kilnid\n" +
  3204. " ,pd.kilncarbatchno\n" +
  3205. " from tp_pm_productiondata pd\n" +
  3206. " where pd.valueflag = '1'\n" +
  3207. " and pd.AccountID = :in_AccountID\n" +
  3208. " and length(pd.kilncarbatchno) > 0\n" +
  3209. " and pd.modeltype = -1\n";
  3210. selSql.Append(sqlString);
  3211. if (se.CreateTimeStart.HasValue)
  3212. {
  3213. //selSql.Append(" AND pd.checktime >= :checktimeStart\n");
  3214. selSql.Append(" AND pd.createtime >= :checktimeStart\n");
  3215. parameters.Add(new OracleParameter(":checktimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3216. }
  3217. if (se.CreateTimeEnd.HasValue)
  3218. {
  3219. //selSql.Append(" AND pd.checktime < :checktimeEnd\n");
  3220. selSql.Append(" AND pd.createtime < :checktimeEnd\n");
  3221. parameters.Add(new OracleParameter(":checktimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3222. }
  3223. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3224. {
  3225. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3226. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3227. }
  3228. if (se.ProductionLineID.HasValue)
  3229. {
  3230. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3231. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3232. }
  3233. if (se.KilnID.HasValue)
  3234. {
  3235. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3236. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3237. }
  3238. sqlString =
  3239. " and exists\n" +
  3240. " (select 1\n" +
  3241. " from tp_pm_productiondata outpd\n" +
  3242. " where outpd.barcode = pd.barcode\n" +
  3243. " and outpd.procedureid = :in_rptSprocedureId\n" +
  3244. " and outpd.valueflag = '1'\n" +
  3245. " and outpd.kilncarbatchno = pd.kilncarbatchno)) ppd\n" +
  3246. " inner join tp_pm_defect dd\n" +
  3247. " on dd.productiondataid = ppd.productiondataid\n" +
  3248. //" --and dd.checktime >= in_DateBegin\n" +
  3249. //" --and dd.checktime <= in_DateEnd\n" +
  3250. " ) ppcc\n" +
  3251. " inner join tp_pm_productiondata pdata\n" +
  3252. " on pdata.barcode = ppcc.barcode\n" +
  3253. // 干补不算交坯工序的质量。
  3254. " and ((pdata.modeltype <> 5) or (pdata.modeltype = 5 and pdata.SpecialRepairFlag = '0')) \n" +
  3255. " and exists\n" +
  3256. " (select 1\n" +
  3257. " from tp_mst_rpttprocedure rptt\n" +
  3258. " where rptt.RPTPROCEDUREID = :in_rptProcedureId \n";
  3259. selSql.Append(sqlString);
  3260. if (!string.IsNullOrEmpty(se.RptTProcedureIDS))
  3261. {
  3262. selSql.Append(" AND instr(','||:rptTprocedureIDS||',', ','||rptt.procedureid||',') > 0\n");
  3263. parameters.Add(new OracleParameter(":rptTprocedureIDS", OracleDbType.NVarchar2, se.RptTProcedureIDS, ParameterDirection.Input));
  3264. }
  3265. sqlString =
  3266. " and rptt.procedureid = pdata.procedureid)\n" +
  3267. " and (ppcc.procedureid = 0 or ppcc.procedureid = pdata.procedureid)\n";
  3268. selSql.Append(sqlString);
  3269. if (!string.IsNullOrEmpty(se.UserIDS))
  3270. {
  3271. selSql.Append(" and instr(','||:userIDS||',', ','||pdata.Userid||',') > 0\n");
  3272. parameters.Add(new OracleParameter(":userIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  3273. }
  3274. sqlString =
  3275. " inner join tp_pc_productionline pcpl\n" +
  3276. " on pcpl.productionlineid = pdata.productionlineid\n" +
  3277. " inner join tp_pc_procedure pcp\n" +
  3278. " on pcp.procedureid = pdata.procedureid\n" +
  3279. " inner join tp_mst_kiln mstkiln\n" +
  3280. " on mstkiln.kilnid = ppcc.kilnid\n" +
  3281. " inner join tp_mst_goods mstgoods\n" +
  3282. " on mstgoods.goodsid = pdata.goodsid\n" +
  3283. " inner join tp_mst_goodstype mstgoodstype\n" +
  3284. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  3285. " and mstgoodstype.accountid = mstgoods.accountid\n" +
  3286. " inner join tp_mst_goodstype mstgoodstype2\n" +
  3287. " on mstgoodstype2.goodstypecode =\n" +
  3288. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  3289. " and mstgoodstype.accountid = mstgoodstype2.accountid\n";
  3290. // 产品类别
  3291. selSql.Append(sqlString);
  3292. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  3293. {
  3294. selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS)=1\n");
  3295. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  3296. }
  3297. sqlString =
  3298. " 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" +
  3299. " order by pcpl.productionlinename\n" +
  3300. " ,pcp.displayno\n" +
  3301. " ,pcp.procedurename\n" +
  3302. " ,mstkiln.kilncode\n" +
  3303. " ,mstgoodstype2.goodstypecode\n" +
  3304. " ,pdata.usercode\n" +
  3305. " ,mstgoodstype.goodstypecode\n" +
  3306. " ,mstgoods.goodscode) qdgroup";
  3307. selSql.Append(sqlString);
  3308. return selSql.ToString();
  3309. }
  3310. /// <summary>
  3311. /// 取得RPT040104画面(产成品质量分析表)的查询数据
  3312. /// </summary>
  3313. /// <param name="user">登录用户信息</param>
  3314. /// <param name="se">查询条件</param>
  3315. /// <returns>查询结果</returns>
  3316. public static ServiceResultEntity GetRPT040104SData(SUserInfo user, RPT040104_SE se)
  3317. {
  3318. IDBConnection conn = null;
  3319. try
  3320. {
  3321. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  3322. List<OracleParameter> parameters = new List<OracleParameter>();
  3323. //string sql = ReportModuleLogic.GetRPT040104SSQL(user, se, ref parameters);
  3324. string sql = ReportModuleLogic.GetRPT040104S1SQL(user, se, ref parameters);
  3325. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  3326. ServiceResultEntity sre = new ServiceResultEntity();
  3327. if (data == null || data.Rows.Count == 0)
  3328. {
  3329. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  3330. return sre;
  3331. }
  3332. sre.Data = new DataSet();
  3333. sre.Data.Tables.Add(data);
  3334. return sre;
  3335. }
  3336. catch (Exception ex)
  3337. {
  3338. throw ex;
  3339. }
  3340. finally
  3341. {
  3342. if (conn != null &&
  3343. conn.ConnState == ConnectionState.Open)
  3344. {
  3345. conn.Close();
  3346. }
  3347. }
  3348. }
  3349. /// <summary>
  3350. /// 获取RPT040104画面(产成品质量分析表)的查询sql
  3351. /// </summary>
  3352. /// <returns>sql</returns>
  3353. private static string GetRPT040104SSQL(SUserInfo user, RPT040104_SE se, ref List<OracleParameter> parameters)
  3354. {
  3355. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3356. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  3357. // 2015-06-16 modify by chenxy
  3358. string sqlString = "\n" +
  3359. "select qdgroup.gid,\n" +
  3360. " decode(qdgroup.gid, 7, '总计', 0, qdgroup.productionlinename, '--') productionlinename,\n" +
  3361. " decode(qdgroup.gid, 3, '合计', 0, qdgroup.kilncode, '--') kilncode,\n" +
  3362. " decode(qdgroup.gid, 1, '小计', 0, qdgroup.goodstypename2, '--') goodstypename2,\n" +
  3363. " decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename,\n" +
  3364. " decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode,\n" +
  3365. " qdgroup.OutKilnCount,\n" +
  3366. " qdgroup.GoodCount,\n" +
  3367. " to_char((qdgroup.GoodCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' GoodPercent,\n" +
  3368. " qdgroup.SubstandardCount,\n" +
  3369. " to_char((qdgroup.SubstandardCount / qdgroup.OutKilnCount) * 100,\n" +
  3370. " '990.00') || '%' SubstandardPercent,\n" +
  3371. " qdgroup.GoodCount+qdgroup.BadCount Qualified,\n" +
  3372. " to_char(((qdgroup.GoodCount + qdgroup.BadCount) / qdgroup.OutKilnCount) * 100,\n" +
  3373. " '990.00') || '%' QualifiedPercent,\n" +
  3374. " qdgroup.BadCount,\n" +
  3375. " to_char((qdgroup.BadCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' BadPercent,\n" +
  3376. " qdgroup.ReFireCount,\n" +
  3377. " to_char((qdgroup.ReFireCount / qdgroup.OutKilnCount) * 100,\n" +
  3378. " '990.00') || '%' ReFirePercent\n" +
  3379. " from (select grouping_id(pcpl.productionlinename,\n" +
  3380. " mstkiln.kilncode,\n" +
  3381. " mstgoodstype2.goodstypename,\n" +
  3382. " --mstgoodstype.goodstypename,\n" +
  3383. " mstgoods.goodscode) gid,\n" +
  3384. " pcpl.productionlinename,\n" +
  3385. " --qd.kilnid,\n" +
  3386. " mstkiln.kilncode,\n" +
  3387. " mstgoodstype2.goodstypename goodstypename2,\n" +
  3388. " mstgoodstype.goodstypename,\n" +
  3389. " mstgoods.goodscode,\n" +
  3390. " sum(qd.OutKilnCount) OutKilnCount,\n" +
  3391. " sum(qd.GoodCount) GoodCount,\n" +
  3392. " sum(qd.SubstandardCount) SubstandardCount,\n" +
  3393. " sum(qd.BadCount) BadCount,\n" +
  3394. " sum(qd.ReFireCount) ReFireCount\n" +
  3395. " from (select --pdbc.barcode,\n" +
  3396. " pdbc.productionlineid,\n" +
  3397. " pdbc.goodsid,\n" +
  3398. " pdbc.kilnid,\n" +
  3399. " --pdbc.kilncarid,\n" +
  3400. " --pdbc.kilncarbatchno,\n" +
  3401. " 1 OutKilnCount,\n" +
  3402. " case\n" +
  3403. " when glt.goodsleveltypeid in (5, 6, 7) then\n" +
  3404. " 0\n" +
  3405. " else\n" +
  3406. " 1\n" +
  3407. " end GoodCount,\n" +
  3408. " case\n" +
  3409. " when glt.goodsleveltypeid = 7 then\n" +
  3410. " 1\n" +
  3411. " else\n" +
  3412. " 0\n" +
  3413. " end SubstandardCount,\n" +
  3414. " case\n" +
  3415. " when glt.goodsleveltypeid = 6 then\n" +
  3416. " 1\n" +
  3417. " else\n" +
  3418. " 0\n" +
  3419. " end ReFireCount,\n" +
  3420. " case\n" +
  3421. " when glt.goodsleveltypeid = 5 then\n" +
  3422. " 1\n" +
  3423. " else\n" +
  3424. " 0\n" +
  3425. " end BadCount\n" +
  3426. " from (select distinct pd.barcode,\n" +
  3427. " pd.productionlineid,\n" +
  3428. " pd.goodsid,\n" +
  3429. " pd.kilnid,\n" +
  3430. " --pd.kilncarid,\n" +
  3431. " pd.kilncarbatchno\n" +
  3432. " from tp_pm_productiondata pd\n" +
  3433. " where pd.valueflag = '1'\n" +
  3434. " and pd.procedureid = :in_rptSprocedureId \n" +
  3435. " and pd.AccountID = :AccountID\n";
  3436. StringBuilder selSql = new StringBuilder(sqlString);
  3437. if (se.CreateTimeStart.HasValue)
  3438. {
  3439. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  3440. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3441. }
  3442. if (se.CreateTimeEnd.HasValue)
  3443. {
  3444. selSql.Append(" AND pd.createtime <= :CreateTimeEnd\n");
  3445. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3446. }
  3447. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3448. {
  3449. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3450. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3451. }
  3452. if (se.ProductionLineID.HasValue)
  3453. {
  3454. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3455. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3456. }
  3457. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  3458. {
  3459. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  3460. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  3461. }
  3462. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  3463. {
  3464. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  3465. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  3466. }
  3467. //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))");
  3468. //parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  3469. if (se.KilnID.HasValue)
  3470. {
  3471. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3472. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3473. }
  3474. sqlString =
  3475. " ) pdbc\n" +
  3476. " left join (select kcbc.barcode, kcbc.kilncarbatchno, kcbc.goodsleveltypeid\n" +
  3477. " from (select pd.barcode,\n" +
  3478. " pd.kilncarbatchno,\n" +
  3479. " pd.goodsleveltypeid,\n" +
  3480. " pd.productiondataid,\n" +
  3481. " ROW_NUMBER() OVER(PARTITION BY pd.barcode, pd.kilncarbatchno ORDER BY pd.productiondataid desc) AS dataid\n" +
  3482. " from tp_pm_productiondata pd\n" +
  3483. " where pd.valueflag = '1'\n" +
  3484. " and pd.AccountID = :AccountID\n" +
  3485. " and length(pd.kilncarbatchno) > 0\n" +
  3486. " AND pd.createtime >= :CreateTimeStart\n" +
  3487. " and pd.modeltype = -1) kcbc\n" +
  3488. " where kcbc.dataid = 1) glt\n" +
  3489. " on pdbc.kilncarbatchno = glt.kilncarbatchno\n" +
  3490. " and pdbc.barcode = glt.barcode) qd\n" +
  3491. " inner join tp_pc_productionline pcpl\n" +
  3492. " on pcpl.productionlineid = qd.productionlineid\n" +
  3493. " inner join tp_mst_kiln mstkiln\n" +
  3494. " on mstkiln.kilnid = qd.kilnid\n" +
  3495. " inner join tp_mst_goods mstgoods\n" +
  3496. " on mstgoods.goodsid = qd.goodsid\n" +
  3497. " inner join tp_mst_goodstype mstgoodstype\n" +
  3498. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  3499. " and mstgoodstype.accountid = mstgoods.accountid\n" +
  3500. " inner join tp_mst_goodstype mstgoodstype2\n" +
  3501. " on mstgoodstype2.goodstypecode =\n" +
  3502. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  3503. " and mstgoodstype.accountid = mstgoodstype2.accountid\n" +
  3504. " where 1=1\n";
  3505. selSql.Append(sqlString);
  3506. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  3507. {
  3508. //selSql.Append(" AND instr(','||:GoodsTypeIDS||',', ','||mstgoodstype.GOODSTYPECode||',') =1\n");
  3509. selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS) =1\n");
  3510. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  3511. }
  3512. sqlString =
  3513. " group by grouping sets((pcpl.productionlinename,\n" +
  3514. " mstkiln.kilncode,\n" +
  3515. " mstgoodstype2.goodstypename,\n" +
  3516. " mstgoodstype.goodstypename,\n" +
  3517. " mstgoods.goodscode),\n" +
  3518. " (pcpl.productionlinename,\n" +
  3519. " mstkiln.kilncode,\n" +
  3520. " mstgoodstype2.goodstypename),\n" +
  3521. " (pcpl.productionlinename,\n" +
  3522. " mstkiln.kilncode),\n" +
  3523. " pcpl.productionlinename)\n" +
  3524. " order by pcpl.productionlinename,\n" +
  3525. " mstkiln.kilncode,\n" +
  3526. " mstgoodstype2.goodstypename,\n" +
  3527. " mstgoodstype.goodstypename,\n" +
  3528. " mstgoods.goodscode\n" +
  3529. " ) qdgroup\n";
  3530. selSql.Append(sqlString);
  3531. return selSql.ToString();
  3532. }
  3533. /// <summary>
  3534. /// 获取RPT040104画面(产成品质量分析表-按登记时间)的查询sql
  3535. /// </summary>
  3536. /// <returns>sql</returns>
  3537. private static string GetRPT040104S1SQL(SUserInfo user, RPT040104_SE se, ref List<OracleParameter> parameters)
  3538. {
  3539. parameters.Add(new OracleParameter(":in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3540. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  3541. string sqlString = "select qdgroup.gid\n" +
  3542. " ,decode(qdgroup.gid, 7, '总计', qdgroup.productionlinename) productionlinename\n" +
  3543. " ,decode(qdgroup.gid\n" +
  3544. " ,3\n" +
  3545. " ,'合计[' || qdgroup.kilncode || ']'\n" +
  3546. " ,7\n" +
  3547. " ,'--'\n" +
  3548. " ,qdgroup.kilncode) kilncode\n" +
  3549. " ,decode(qdgroup.gid\n" +
  3550. " ,1\n" +
  3551. " ,'小计[' || qdgroup.goodstypename2 || ']'\n" +
  3552. " ,0\n" +
  3553. " ,qdgroup.goodstypename2\n" +
  3554. " ,'--') goodstypename2\n" +
  3555. " ,decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename\n" +
  3556. " ,decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode\n" +
  3557. " ,qdgroup.OutKilnCount\n" +
  3558. " ,qdgroup.GoodCount\n" +
  3559. " ,decode(qdgroup.OutKilnCount\n" +
  3560. " ,0\n" +
  3561. " ,to_number(null)\n" +
  3562. " ,round(qdgroup.GoodCount / qdgroup.OutKilnCount, 4)) GoodPercent\n" +
  3563. " ,qdgroup.SubstandardCount\n" +
  3564. " ,decode(qdgroup.OutKilnCount\n" +
  3565. " ,0\n" +
  3566. " ,to_number(null)\n" +
  3567. " ,round(qdgroup.SubstandardCount / qdgroup.OutKilnCount, 4)) SubstandardPercent\n" +
  3568. " ,qdgroup.GoodCount + qdgroup.BadCount Qualified\n" +
  3569. " ,decode(qdgroup.OutKilnCount\n" +
  3570. " ,0\n" +
  3571. " ,to_number(null)\n" +
  3572. " ,round((qdgroup.GoodCount + qdgroup.BadCount) /\n" +
  3573. " qdgroup.OutKilnCount\n" +
  3574. " ,4)) QualifiedPercent\n" +
  3575. " ,qdgroup.BadCount\n" +
  3576. " ,decode(qdgroup.OutKilnCount\n" +
  3577. " ,0\n" +
  3578. " ,to_number(null)\n" +
  3579. " ,round(qdgroup.BadCount / qdgroup.OutKilnCount, 4)) BadPercent\n" +
  3580. " ,qdgroup.ReFireCount\n" +
  3581. " ,decode(qdgroup.OutKilnCount\n" +
  3582. " ,0\n" +
  3583. " ,to_number(null)\n" +
  3584. " ,round(qdgroup.ReFireCount / qdgroup.OutKilnCount, 4)) ReFirePercent\n" +
  3585. " from (select grouping_id(pcpl.productionlinename\n" +
  3586. " ,mstkiln.kilncode\n" +
  3587. " ,mstgoodstype2.goodstypecode\n" +
  3588. " ,mstgoods.goodscode) gid\n" +
  3589. " ,pcpl.productionlinename\n" +
  3590. " ,mstkiln.kilncode\n" +
  3591. " ,mstgoodstype2.goodstypename goodstypename2\n" +
  3592. " ,mstgoodstype.goodstypename\n" +
  3593. " ,mstgoods.goodscode\n" +
  3594. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 0)), 0) OutKilnCount\n" +
  3595. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 5, 1, 0)), 0) BadCount\n" +
  3596. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 6, 1, 0)), 0) ReFireCount\n" +
  3597. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 7, 1, 0)), 0) SubstandardCount\n" +
  3598. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 5, -1, 6, -1, 7, -1, 0)), 0) GoodCount\n" +
  3599. " from (select 0 goodsleveltypeid -- 出窑数量\n" +
  3600. " ,pd.barcode\n" +
  3601. " ,pd.productionlineid\n" +
  3602. " ,pd.goodsid\n" +
  3603. " ,pd.kilnid\n" +
  3604. " ,pd.kilncarbatchno\n" +
  3605. " ,1 cc\n" +
  3606. " from tp_pm_productiondata pd\n" +
  3607. " where pd.valueflag = '1'\n" +
  3608. " and pd.procedureid = :in_rptSprocedureId\n" +
  3609. " and pd.accountid = :in_AccountID\n";
  3610. StringBuilder selSql = new StringBuilder(sqlString);
  3611. if (se.CreateTimeStart.HasValue)
  3612. {
  3613. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  3614. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3615. }
  3616. if (se.CreateTimeEnd.HasValue)
  3617. {
  3618. selSql.Append(" AND pd.createtime < :CreateTimeEnd\n");
  3619. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3620. }
  3621. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3622. {
  3623. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3624. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3625. }
  3626. if (se.ProductionLineID.HasValue)
  3627. {
  3628. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3629. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3630. }
  3631. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  3632. {
  3633. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  3634. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  3635. }
  3636. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  3637. {
  3638. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  3639. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  3640. }
  3641. if (se.KilnID.HasValue)
  3642. {
  3643. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3644. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3645. }
  3646. sqlString =
  3647. " union all\n" +
  3648. " select distinct pd.goodsleveltypeid\n" +
  3649. " ,pd.barcode\n" +
  3650. " ,pd.productionlineid\n" +
  3651. " ,pd.goodsid\n" +
  3652. " ,pd.kilnid\n" +
  3653. " ,pd.kilncarbatchno\n" +
  3654. " ,1 cc\n" +
  3655. " from tp_pm_productiondata pd\n" +
  3656. " where pd.valueflag = '1'\n" +
  3657. " and pd.modeltype = -1\n" +
  3658. " and pd.AccountID = :in_AccountID\n" +
  3659. " and length(pd.kilncarbatchno) > 0\n";
  3660. selSql.Append(sqlString);
  3661. if (se.CreateTimeStart.HasValue)
  3662. {
  3663. //selSql.Append(" AND pd.checktime >= :checktimeStart\n");
  3664. selSql.Append(" AND pd.createtime >= :checktimeStart\n");
  3665. parameters.Add(new OracleParameter(":checktimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3666. }
  3667. if (se.CreateTimeEnd.HasValue)
  3668. {
  3669. //selSql.Append(" AND pd.checktime < :checktimeEnd\n");
  3670. selSql.Append(" AND pd.createtime < :checktimeEnd\n");
  3671. parameters.Add(new OracleParameter(":checktimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3672. }
  3673. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3674. {
  3675. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3676. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3677. }
  3678. if (se.ProductionLineID.HasValue)
  3679. {
  3680. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3681. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3682. }
  3683. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  3684. {
  3685. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  3686. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  3687. }
  3688. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  3689. {
  3690. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  3691. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  3692. }
  3693. if (se.KilnID.HasValue)
  3694. {
  3695. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3696. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3697. }
  3698. sqlString =
  3699. " and exists\n" +
  3700. " (select 1\n" +
  3701. " from tp_pm_productiondata outpd\n" +
  3702. " where outpd.barcode = pd.barcode\n" +
  3703. " and outpd.procedureid = :in_rptSprocedureId\n" +
  3704. " and outpd.valueflag = '1'\n" +
  3705. " and outpd.kilncarbatchno = pd.kilncarbatchno)) ppcc\n" +
  3706. " inner join tp_pc_productionline pcpl\n" +
  3707. " on pcpl.productionlineid = ppcc.productionlineid\n" +
  3708. " inner join tp_mst_kiln mstkiln\n" +
  3709. " on mstkiln.kilnid = ppcc.kilnid\n" +
  3710. " inner join tp_mst_goods mstgoods\n" +
  3711. " on mstgoods.goodsid = ppcc.goodsid\n" +
  3712. " inner join tp_mst_goodstype mstgoodstype\n" +
  3713. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  3714. " and mstgoodstype.accountid = mstgoods.accountid\n" +
  3715. " inner join tp_mst_goodstype mstgoodstype2\n" +
  3716. " on mstgoodstype2.goodstypecode =\n" +
  3717. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  3718. " and mstgoodstype.accountid = mstgoodstype2.accountid\n";
  3719. // 产品类别
  3720. selSql.Append(sqlString);
  3721. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  3722. {
  3723. selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS)=1\n");
  3724. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  3725. }
  3726. sqlString =
  3727. " 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" +
  3728. " order by pcpl.productionlinename\n" +
  3729. " ,mstkiln.kilncode\n" +
  3730. " ,mstgoodstype2.goodstypecode\n" +
  3731. " ,mstgoodstype.goodstypecode\n" +
  3732. " ,mstgoods.goodscode) qdgroup\n";
  3733. selSql.Append(sqlString);
  3734. return selSql.ToString();
  3735. }
  3736. /// <summary>
  3737. /// 取得RPT040105画面(质量报表)的查询数据
  3738. /// </summary>
  3739. /// <param name="user">登录用户信息</param>
  3740. /// <param name="se">查询条件</param>
  3741. /// <returns>查询结果</returns>
  3742. public static ServiceResultEntity GetRPT040105SData(SUserInfo user, RPT040105_SE se)
  3743. {
  3744. IDBConnection conn = null;
  3745. try
  3746. {
  3747. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  3748. List<OracleParameter> parameters = new List<OracleParameter>();
  3749. string sqlString =
  3750. "SELECT substr(gt.goodstypecode, 1, 6) goodstypecode2, COUNT(*) barcodecount\n" +
  3751. " FROM tp_pm_groutingdailydetail gdd\n" +
  3752. " INNER JOIN tp_mst_goods g\n" +
  3753. " ON g.goodsid = gdd.goodsid\n" +
  3754. " INNER JOIN tp_mst_goodstype gt\n" +
  3755. " ON gt.goodstypeid = g.goodstypeid\n" +
  3756. " WHERE gdd.accountid = :accountid\n" +
  3757. " AND gdd.valueflag = '1'\n" +
  3758. " AND gdd.groutingdate >= :datebegin\n" +
  3759. " AND gdd.groutingdate <= :dateend\n" +
  3760. " AND gdd.groutingflag = '1'\n" +
  3761. " AND gdd.barcode IS NOT NULL\n" +
  3762. " GROUP BY GROUPING SETS(substr(gt.goodstypecode, 1, 6),())";
  3763. parameters.Add(new OracleParameter(":accountid", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3764. parameters.Add(new OracleParameter(":datebegin", OracleDbType.Date, se.CreateTimeStart.Value.Date, ParameterDirection.Input));
  3765. parameters.Add(new OracleParameter(":dateend", OracleDbType.Date, se.CreateTimeEnd.Value.Date, ParameterDirection.Input));
  3766. DataTable dataCount = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  3767. parameters.Clear();
  3768. //string sql = ReportModuleLogic.GetRPT040105SSQL(user, se, ref parameters);
  3769. string sql = ReportModuleLogic.GetRPT040105S1SQL(user, se, ref parameters);
  3770. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  3771. ServiceResultEntity sre = new ServiceResultEntity();
  3772. if (data == null || data.Rows.Count == 0)
  3773. {
  3774. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  3775. return sre;
  3776. }
  3777. data.Columns.Add("GCount", typeof(int));
  3778. //data.Columns.Add("OutGCount", typeof(string));
  3779. //data.Columns.Add("GoodGCount", typeof(string));
  3780. data.Columns.Add("OutGCount", typeof(decimal));
  3781. data.Columns.Add("GoodGCount", typeof(decimal));
  3782. foreach (DataRow item in data.Rows)
  3783. {
  3784. int gid = Convert.ToInt32(item["gid"]);
  3785. if (gid < 2)
  3786. {
  3787. continue;
  3788. }
  3789. int outKilnCount = Convert.ToInt32(item["OutKilnCount"]);
  3790. int goodCount = Convert.ToInt32(item["Qualified"]);
  3791. DataRow[] drs = null;
  3792. if (gid == 2)
  3793. {
  3794. drs = dataCount.Select("goodstypecode2 = '" + item["goodstypecode2"].ToString() + "'");
  3795. }
  3796. else if (gid == 3)
  3797. {
  3798. drs = dataCount.Select("goodstypecode2 is null");
  3799. }
  3800. if (drs != null && drs.Length > 0)
  3801. {
  3802. int barcodecount = Convert.ToInt32(drs[0]["barcodecount"]);
  3803. item["GCount"] = barcodecount;
  3804. //item["OutGCount"] = (outKilnCount * 1.0 / barcodecount).ToString("#,##0.00%");
  3805. //item["GoodGCount"] = (goodCount * 1.0 / barcodecount).ToString("#,##0.00%");
  3806. item["OutGCount"] = Math.Round(outKilnCount * 1.0 / barcodecount, 4);
  3807. item["GoodGCount"] = Math.Round(goodCount * 1.0 / barcodecount, 4);
  3808. }
  3809. else
  3810. {
  3811. item["GCount"] = 0;
  3812. //item["OutGCount"] = "#DIV/0!";
  3813. //item["GoodGCount"] = "#DIV/0!";
  3814. item["OutGCount"] = DBNull.Value;
  3815. item["GoodGCount"] = DBNull.Value;
  3816. }
  3817. }
  3818. sre.Data = new DataSet();
  3819. sre.Data.Tables.Add(data);
  3820. return sre;
  3821. }
  3822. catch (Exception ex)
  3823. {
  3824. throw ex;
  3825. }
  3826. finally
  3827. {
  3828. if (conn != null &&
  3829. conn.ConnState == ConnectionState.Open)
  3830. {
  3831. conn.Close();
  3832. }
  3833. }
  3834. }
  3835. /// <summary>
  3836. /// 获取RPT040105画面(质量报表)的查询sql
  3837. /// </summary>
  3838. /// <returns>sql</returns>
  3839. private static string GetRPT040105SSQL(SUserInfo user, RPT040105_SE se, ref List<OracleParameter> parameters)
  3840. {
  3841. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3842. parameters.Add(new OracleParameter(":OutProcedureIDS", OracleDbType.Varchar2, se.OutProcedureIDS, ParameterDirection.Input));
  3843. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  3844. // 2015-06-16 modify by chenxy
  3845. string sqlString = "\n" +
  3846. "select qdgroup.gid,\n" +
  3847. " decode(qdgroup.gid, 3, '总计', 0, qdgroup.productionlinename, '--') productionlinename,\n" +
  3848. " decode(qdgroup.gid, 1, '合计【'||qdgroup.kilncode||'】', 0, qdgroup.kilncode, '--') kilncode,\n" +
  3849. " decode(qdgroup.gid, 2, '合计【'||qdgroup.goodstypename2||'】', 0, qdgroup.goodstypename2, '--') goodstypename2,\n" +
  3850. " qdgroup.goodstypecode2,\n" +
  3851. " qdgroup.OutKilnCount,\n" +
  3852. " qdgroup.GoodCount,\n" +
  3853. " to_char((qdgroup.GoodCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' GoodPercent,\n" +
  3854. " qdgroup.SubstandardCount,\n" +
  3855. " to_char((qdgroup.SubstandardCount / qdgroup.OutKilnCount) * 100,\n" +
  3856. " '990.00') || '%' SubstandardPercent,\n" +
  3857. " qdgroup.GoodCount+qdgroup.BadCount Qualified,\n" +
  3858. " to_char(((qdgroup.GoodCount + qdgroup.BadCount) / qdgroup.OutKilnCount) * 100,\n" +
  3859. " '990.00') || '%' QualifiedPercent,\n" +
  3860. " qdgroup.BadCount,\n" +
  3861. " to_char((qdgroup.BadCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' BadPercent,\n" +
  3862. " qdgroup.ReFireCount,\n" +
  3863. " to_char((qdgroup.ReFireCount / qdgroup.OutKilnCount) * 100,\n" +
  3864. " '990.00') || '%' ReFirePercent\n" +
  3865. " from (select grouping_id(pcpl.productionlinename,\n" +
  3866. " mstkiln.kilncode,\n" +
  3867. " mstgoodstype2.goodstypecode) gid,\n" +
  3868. " pcpl.productionlinename,\n" +
  3869. " mstkiln.kilncode,\n" +
  3870. " mstgoodstype2.goodstypecode goodstypecode2,\n" +
  3871. " mstgoodstype2.goodstypename goodstypename2,\n" +
  3872. " sum(qd.OutKilnCount) OutKilnCount,\n" +
  3873. " sum(qd.GoodCount) GoodCount,\n" +
  3874. " sum(qd.SubstandardCount) SubstandardCount,\n" +
  3875. " sum(qd.BadCount) BadCount,\n" +
  3876. " sum(qd.ReFireCount) ReFireCount\n" +
  3877. " from (select --pdbc.barcode,\n" +
  3878. " pdbc.productionlineid,\n" +
  3879. " pdbc.goodsid,\n" +
  3880. " pdbc.kilnid,\n" +
  3881. " 1 OutKilnCount,\n" +
  3882. " case\n" +
  3883. " when glt.goodsleveltypeid in (5, 6, 7) then\n" +
  3884. " 0\n" +
  3885. " else\n" +
  3886. " 1\n" +
  3887. " end GoodCount,\n" +
  3888. " case\n" +
  3889. " when glt.goodsleveltypeid = 7 then\n" +
  3890. " 1\n" +
  3891. " else\n" +
  3892. " 0\n" +
  3893. " end SubstandardCount,\n" +
  3894. " case\n" +
  3895. " when glt.goodsleveltypeid = 6 then\n" +
  3896. " 1\n" +
  3897. " else\n" +
  3898. " 0\n" +
  3899. " end ReFireCount,\n" +
  3900. " case\n" +
  3901. " when glt.goodsleveltypeid = 5 then\n" +
  3902. " 1\n" +
  3903. " else\n" +
  3904. " 0\n" +
  3905. " end BadCount\n" +
  3906. " from (select distinct pd.barcode,\n" +
  3907. " pd.productionlineid,\n" +
  3908. " pd.goodsid,\n" +
  3909. " pd.kilnid,\n" +
  3910. " pd.kilncarbatchno\n" +
  3911. " from tp_pm_productiondata pd\n" +
  3912. " where pd.valueflag = '1'\n" +
  3913. " and (:in_rptSprocedureId is null or pd.procedureid = :in_rptSprocedureId) \n" +
  3914. " and (:OutProcedureIDS is null or instr(','||:OutProcedureIDS||',', ','||pd.procedureid||',') > 0) \n" +
  3915. " and pd.AccountID = :AccountID\n";
  3916. StringBuilder selSql = new StringBuilder(sqlString);
  3917. if (se.CreateTimeStart.HasValue)
  3918. {
  3919. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  3920. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3921. }
  3922. if (se.CreateTimeEnd.HasValue)
  3923. {
  3924. selSql.Append(" AND pd.createtime <= :CreateTimeEnd\n");
  3925. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3926. }
  3927. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3928. {
  3929. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3930. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3931. }
  3932. if (se.ProductionLineID.HasValue)
  3933. {
  3934. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3935. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3936. }
  3937. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  3938. {
  3939. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  3940. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  3941. }
  3942. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  3943. {
  3944. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  3945. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  3946. }
  3947. // 不控制权限
  3948. //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))");
  3949. //parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  3950. if (se.KilnID.HasValue)
  3951. {
  3952. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3953. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3954. }
  3955. sqlString =
  3956. " ) pdbc\n" +
  3957. " left join (select kcbc.barcode, kcbc.kilncarbatchno, kcbc.goodsleveltypeid\n" +
  3958. " from (select pd.barcode,\n" +
  3959. " pd.kilncarbatchno,\n" +
  3960. " pd.goodsleveltypeid,\n" +
  3961. " pd.productiondataid,\n" +
  3962. " ROW_NUMBER() OVER(PARTITION BY pd.barcode, pd.kilncarbatchno ORDER BY pd.productiondataid desc) AS dataid\n" +
  3963. " from tp_pm_productiondata pd\n" +
  3964. " where pd.valueflag = '1'\n" +
  3965. " and pd.AccountID = :AccountID\n" +
  3966. " and length(pd.kilncarbatchno) > 0\n" +
  3967. " AND pd.createtime >= :CreateTimeStart\n" +
  3968. " and pd.modeltype = -1) kcbc\n" +
  3969. " where kcbc.dataid = 1) glt\n" +
  3970. " on pdbc.kilncarbatchno = glt.kilncarbatchno\n" +
  3971. " and pdbc.barcode = glt.barcode) qd\n" +
  3972. " inner join tp_pc_productionline pcpl\n" +
  3973. " on pcpl.productionlineid = qd.productionlineid\n" +
  3974. " inner join tp_mst_kiln mstkiln\n" +
  3975. " on mstkiln.kilnid = qd.kilnid\n" +
  3976. " inner join tp_mst_goods mstgoods\n" +
  3977. " on mstgoods.goodsid = qd.goodsid\n" +
  3978. " inner join tp_mst_goodstype mstgoodstype\n" +
  3979. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  3980. " inner join tp_mst_goodstype mstgoodstype2\n" +
  3981. " on mstgoodstype2.goodstypecode =\n" +
  3982. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  3983. " and mstgoodstype.accountid = mstgoodstype2.accountid\n" +
  3984. " where 1=1\n";
  3985. selSql.Append(sqlString);
  3986. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  3987. {
  3988. selSql.Append(" AND instr(','||:GoodsTypeIDS||',', ','||mstgoods.GOODSTYPEId||',') > 0\n");
  3989. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  3990. }
  3991. sqlString =
  3992. " group by grouping sets((pcpl.productionlinename,\n" +
  3993. " mstkiln.kilncode,\n" +
  3994. " mstgoodstype2.goodstypecode,\n" +
  3995. " mstgoodstype2.goodstypename),\n" +
  3996. " (pcpl.productionlinename,\n" +
  3997. " mstgoodstype2.goodstypecode,\n" +
  3998. " mstgoodstype2.goodstypename),\n" +
  3999. " (pcpl.productionlinename,\n" +
  4000. " mstkiln.kilncode),\n" +
  4001. " pcpl.productionlinename)\n" +
  4002. " order by pcpl.productionlinename,\n" +
  4003. " mstkiln.kilncode,\n" +
  4004. " mstgoodstype2.goodstypename\n" +
  4005. " ) qdgroup\n";
  4006. selSql.Append(sqlString);
  4007. return selSql.ToString();
  4008. }
  4009. /// <summary>
  4010. /// 获取RPT040105画面(质量报表-按登记时间)的查询sql
  4011. /// </summary>
  4012. /// <returns>sql</returns>
  4013. private static string GetRPT040105S1SQL(SUserInfo user, RPT040105_SE se, ref List<OracleParameter> parameters)
  4014. {
  4015. parameters.Add(new OracleParameter(":in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  4016. parameters.Add(new OracleParameter(":in_OutProcedureIDS", OracleDbType.Varchar2, se.OutProcedureIDS, ParameterDirection.Input));
  4017. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  4018. string sqlString = "select qdgroup.gid\n" +
  4019. " ,decode(qdgroup.gid, 3, '总计', qdgroup.productionlinename) productionlinename\n" +
  4020. " ,decode(qdgroup.gid\n" +
  4021. " ,1\n" +
  4022. " ,'合计[' || qdgroup.kilncode || ']'\n" +
  4023. " ,0\n" +
  4024. " ,qdgroup.kilncode\n" +
  4025. " ,'--') kilncode\n" +
  4026. " ,decode(qdgroup.gid\n" +
  4027. " ,2\n" +
  4028. " ,'合计[' || qdgroup.goodstypename2 || ']'\n" +
  4029. " ,0\n" +
  4030. " ,qdgroup.goodstypename2\n" +
  4031. " ,'--') goodstypename2\n" +
  4032. " ,qdgroup.goodstypecode2\n" +
  4033. //" ,decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename\n" +
  4034. //" ,decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode\n" +
  4035. " ,qdgroup.OutKilnCount\n" +
  4036. " ,qdgroup.GoodCount\n" +
  4037. " ,decode(qdgroup.OutKilnCount\n" +
  4038. " ,0\n" +
  4039. " ,to_number(null)\n" +
  4040. " ,round(qdgroup.GoodCount / qdgroup.OutKilnCount, 4)) GoodPercent\n" +
  4041. " ,qdgroup.SubstandardCount\n" +
  4042. " ,decode(qdgroup.OutKilnCount\n" +
  4043. " ,0\n" +
  4044. " ,to_number(null)\n" +
  4045. " ,round(qdgroup.SubstandardCount / qdgroup.OutKilnCount, 4)) SubstandardPercent\n" +
  4046. " ,qdgroup.GoodCount + qdgroup.BadCount Qualified\n" +
  4047. " ,decode(qdgroup.OutKilnCount\n" +
  4048. " ,0\n" +
  4049. " ,to_number(null)\n" +
  4050. " ,round((qdgroup.GoodCount + qdgroup.BadCount) /\n" +
  4051. " qdgroup.OutKilnCount\n" +
  4052. " ,4)) QualifiedPercent\n" +
  4053. " ,qdgroup.BadCount\n" +
  4054. " ,decode(qdgroup.OutKilnCount\n" +
  4055. " ,0\n" +
  4056. " ,to_number(null)\n" +
  4057. " ,round(qdgroup.BadCount / qdgroup.OutKilnCount, 4)) BadPercent\n" +
  4058. " ,qdgroup.ReFireCount\n" +
  4059. " ,decode(qdgroup.OutKilnCount\n" +
  4060. " ,0\n" +
  4061. " ,to_number(null)\n" +
  4062. " ,round(qdgroup.ReFireCount / qdgroup.OutKilnCount, 4)) ReFirePercent\n" +
  4063. " from (select grouping_id(pcpl.productionlinename\n" +
  4064. " ,mstkiln.kilncode\n" +
  4065. " ,mstgoodstype2.goodstypecode) gid\n" +
  4066. " ,pcpl.productionlinename\n" +
  4067. " ,mstkiln.kilncode\n" +
  4068. " ,mstgoodstype2.goodstypename goodstypename2\n" +
  4069. " ,mstgoodstype2.goodstypecode goodstypecode2\n" +
  4070. //" ,mstgoodstype.goodstypename\n" +
  4071. //" ,mstgoods.goodscode\n" +
  4072. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 0)), 0) OutKilnCount\n" +
  4073. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 5, 1, 0)), 0) BadCount\n" +
  4074. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 6, 1, 0)), 0) ReFireCount\n" +
  4075. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 7, 1, 0)), 0) SubstandardCount\n" +
  4076. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 5, -1, 6, -1, 7, -1, 0)), 0) GoodCount\n" +
  4077. " from (select 0 goodsleveltypeid -- 出窑数量\n" +
  4078. " ,pd.barcode\n" +
  4079. " ,pd.productionlineid\n" +
  4080. " ,pd.goodsid\n" +
  4081. " ,pd.kilnid\n" +
  4082. " ,pd.kilncarbatchno\n" +
  4083. " ,1 cc\n" +
  4084. " from tp_pm_productiondata pd\n" +
  4085. " where pd.valueflag = '1'\n" +
  4086. " and (:in_rptSprocedureId is null or pd.procedureid = :in_rptSprocedureId)\n" +
  4087. " and (:in_OutProcedureIDS is null or instr(','||:in_OutProcedureIDS||',', ','||pd.procedureid||',') > 0)\n" +
  4088. " and pd.accountid = :in_AccountID\n";
  4089. StringBuilder selSql = new StringBuilder(sqlString);
  4090. if (se.CreateTimeStart.HasValue)
  4091. {
  4092. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  4093. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  4094. }
  4095. if (se.CreateTimeEnd.HasValue)
  4096. {
  4097. selSql.Append(" AND pd.createtime < :CreateTimeEnd\n");
  4098. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  4099. }
  4100. if (!string.IsNullOrEmpty(se.GoodsIDS))
  4101. {
  4102. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  4103. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  4104. }
  4105. if (se.ProductionLineID.HasValue)
  4106. {
  4107. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  4108. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  4109. }
  4110. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  4111. {
  4112. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  4113. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  4114. }
  4115. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  4116. {
  4117. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  4118. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  4119. }
  4120. if (se.KilnID.HasValue)
  4121. {
  4122. selSql.Append(" AND pd.KilnID = :KilnID\n");
  4123. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  4124. }
  4125. sqlString =
  4126. " union all\n" +
  4127. " select distinct pd.goodsleveltypeid\n" +
  4128. " ,pd.barcode\n" +
  4129. " ,pd.productionlineid\n" +
  4130. " ,pd.goodsid\n" +
  4131. " ,pd.kilnid\n" +
  4132. " ,pd.kilncarbatchno\n" +
  4133. " ,1 cc\n" +
  4134. " from tp_pm_productiondata pd\n" +
  4135. " where pd.valueflag = '1'\n" +
  4136. " and pd.modeltype = -1\n" +
  4137. " and pd.AccountID = :in_AccountID\n" +
  4138. " and length(pd.kilncarbatchno) > 0\n";
  4139. selSql.Append(sqlString);
  4140. if (se.CreateTimeStart.HasValue)
  4141. {
  4142. //selSql.Append(" AND pd.checktime >= :checktimeStart\n");
  4143. selSql.Append(" AND pd.createtime >= :checktimeStart\n");
  4144. parameters.Add(new OracleParameter(":checktimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  4145. }
  4146. if (se.CreateTimeEnd.HasValue)
  4147. {
  4148. //selSql.Append(" AND pd.checktime < :checktimeEnd\n");
  4149. selSql.Append(" AND pd.createtime < :checktimeEnd\n");
  4150. parameters.Add(new OracleParameter(":checktimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  4151. }
  4152. if (!string.IsNullOrEmpty(se.GoodsIDS))
  4153. {
  4154. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  4155. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  4156. }
  4157. if (se.ProductionLineID.HasValue)
  4158. {
  4159. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  4160. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  4161. }
  4162. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  4163. {
  4164. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  4165. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  4166. }
  4167. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  4168. {
  4169. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  4170. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  4171. }
  4172. if (se.KilnID.HasValue)
  4173. {
  4174. selSql.Append(" AND pd.KilnID = :KilnID\n");
  4175. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  4176. }
  4177. sqlString =
  4178. " and exists\n" +
  4179. " (select 1\n" +
  4180. " from tp_pm_productiondata outpd\n" +
  4181. " where outpd.barcode = pd.barcode\n" +
  4182. //" and outpd.procedureid = :in_rptSprocedureId\n" +
  4183. " and (:in_rptSprocedureId is null or outpd.procedureid = :in_rptSprocedureId)\n" +
  4184. " and (:in_OutProcedureIDS is null or instr(','||:in_OutProcedureIDS||',', ','||outpd.procedureid||',') > 0)\n" +
  4185. " and outpd.valueflag = '1'\n" +
  4186. " and outpd.kilncarbatchno = pd.kilncarbatchno)) ppcc\n" +
  4187. " inner join tp_pc_productionline pcpl\n" +
  4188. " on pcpl.productionlineid = ppcc.productionlineid\n" +
  4189. " inner join tp_mst_kiln mstkiln\n" +
  4190. " on mstkiln.kilnid = ppcc.kilnid\n" +
  4191. " inner join tp_mst_goods mstgoods\n" +
  4192. " on mstgoods.goodsid = ppcc.goodsid\n" +
  4193. " inner join tp_mst_goodstype mstgoodstype\n" +
  4194. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  4195. " and mstgoodstype.accountid = mstgoods.accountid\n" +
  4196. " inner join tp_mst_goodstype mstgoodstype2\n" +
  4197. " on mstgoodstype2.goodstypecode =\n" +
  4198. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  4199. " and mstgoodstype.accountid = mstgoodstype2.accountid\n";
  4200. // 产品类别
  4201. selSql.Append(sqlString);
  4202. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  4203. {
  4204. selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS)=1\n");
  4205. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  4206. }
  4207. sqlString =
  4208. " 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" +
  4209. " order by pcpl.productionlinename\n" +
  4210. " ,mstkiln.kilncode\n" +
  4211. " ,mstgoodstype2.goodstypecode\n" +
  4212. " ) qdgroup\n";
  4213. selSql.Append(sqlString);
  4214. return selSql.ToString();
  4215. }
  4216. /// <summary>
  4217. /// 取得RPT040106画面(缺陷报表)的查询数据
  4218. /// </summary>
  4219. /// <param name="user">登录用户信息</param>
  4220. /// <param name="se">查询条件</param>
  4221. /// <returns>查询结果</returns>
  4222. public static ServiceResultEntity GetRPT040106SData(SUserInfo user, RPT040106_SE se)
  4223. {
  4224. IDBConnection conn = null;
  4225. try
  4226. {
  4227. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  4228. string sqlString = null;
  4229. OracleParameter[] parameters = null;
  4230. if (se.OutKilnNumByGoodsType)
  4231. {
  4232. sqlString = "SELECT Defect.productionlinename\n" +
  4233. " ,Defect.procedurename\n" +
  4234. " ,Defect.Defectcode\n" +
  4235. " ,Defect.Defectname\n" +
  4236. " ,Defect.goodstypename2\n" +
  4237. " ,Defect.DefectCount\n" +
  4238. " ,OUT.outNum OutKilnCount\n" +
  4239. " ,decode(OUT.outNum,\n" +
  4240. " 0,\n" +
  4241. " to_number(NULL),\n" +
  4242. " ROUND(Defect.DefectCount / OUT.outNum, 4)) DefectPercent\n" +
  4243. " FROM (SELECT tp_pc_productionline.productionlinename\n" +
  4244. " ,tp_pc_procedure.procedurename\n" +
  4245. " ,TP_MST_DefectType.Defecttypename\n" +
  4246. " ,TP_MST_Defect.Defectcode\n" +
  4247. " ,TP_MST_Defect.Defectname\n" +
  4248. " ,goodstype2.goodstypename goodstypename2\n" +
  4249. " ,goodstype2.goodstypecode goodstypecode2\n" +
  4250. " --,COUNT(DISTINCT TP_PM_Defect.Barcode) DefectCount\n" +
  4251. " ,COUNT(TP_PM_Defect.Barcode) DefectCount\n" +
  4252. " FROM TP_PM_Defect\n" +
  4253. " LEFT JOIN tp_pc_procedure\n" +
  4254. " ON TP_PM_Defect.ProcedureID = tp_pc_procedure.ProcedureID\n" +
  4255. " LEFT JOIN tp_pc_productionline\n" +
  4256. " ON TP_PM_Defect.Productionlineid =\n" +
  4257. " tp_pc_productionline.Productionlineid\n" +
  4258. " LEFT JOIN TP_MST_Goods\n" +
  4259. " ON TP_PM_Defect.Goodsid = TP_MST_Goods.Goodsid\n" +
  4260. " LEFT JOIN TP_MST_GoodsType\n" +
  4261. " ON TP_MST_Goods.GoodsTypeID = TP_MST_GoodsType.GoodsTypeID\n" +
  4262. " LEFT JOIN TP_MST_GoodsType goodstype2\n" +
  4263. " ON goodstype2.goodstypecode =\n" +
  4264. " substr(TP_MST_GoodsType.goodstypecode, 0, 6)\n" +
  4265. " AND TP_MST_GoodsType.accountid = goodstype2.accountid\n" +
  4266. " LEFT JOIN TP_MST_Defect\n" +
  4267. " ON TP_PM_Defect.DefectID = TP_MST_Defect.DefectID\n" +
  4268. " LEFT JOIN TP_MST_DefectType\n" +
  4269. " ON TP_MST_Defect.DefectTypeID = TP_MST_DefectType.DefectTypeID\n" +
  4270. " --LEFT JOIN TP_PM_ProductionData\n" +
  4271. " -- ON TP_PM_ProductionData.ProductionDataID =\n" +
  4272. " -- TP_PM_Defect.ProductionDataID\n" +
  4273. " WHERE TP_PM_Defect.valueflag = '1'\n" +
  4274. " --AND tp_pc_procedure.ModelType = -1\n" +
  4275. " AND TP_PM_Defect.AccountID = :AccountID\n" +
  4276. " AND (:createtimebegin is null or TP_PM_Defect.createtime >= :createtimebegin)\n" +
  4277. " AND (:createtimeend is null or TP_PM_Defect.createtime <= :createtimeend)\n" +
  4278. " AND (:procedureids is null or instr(','||:procedureids||',', ','||TP_PM_Defect.ProcedureID||',') > 0)\n" +
  4279. " AND (:DefectCode is null or instr(TP_MST_Defect.Defectcode, :DefectCode) > 0)\n" +
  4280. " AND (:DefectName is null or instr(TP_MST_Defect.Defectname, :DefectName) > 0)\n" +
  4281. " GROUP BY tp_pc_productionline.productionlinename\n" +
  4282. " ,tp_pc_procedure.procedurename\n" +
  4283. " ,TP_MST_DefectType.Defecttypename\n" +
  4284. " ,TP_MST_Defect.Defectcode\n" +
  4285. " ,TP_MST_Defect.Defectname\n" +
  4286. " ,goodstype2.goodstypecode\n" +
  4287. " ,goodstype2.goodstypename) Defect\n" +
  4288. " LEFT JOIN ( SELECT gt2.goodstypecode goodstypecode2, COUNT(pd.barcode) outNum\n" +
  4289. " FROM tp_pm_productiondata pd\n" +
  4290. " LEFT JOIN tp_mst_goods g on g.goodsid = pd.goodsid\n" +
  4291. " LEFT JOIN tp_mst_goodstype gt on g.goodstypeid = gt.goodstypeid\n" +
  4292. " LEFT JOIN tp_mst_goodstype gt2 on gt2.AccountID = :AccountID and gt2.goodstypecode = substr(gt.goodstypecode, 0, 6)\n" +
  4293. " WHERE pd.valueflag = '1'\n" +
  4294. " AND pd.procedureid = :procedureid\n" +
  4295. " AND pd.AccountID = :AccountID\n" +
  4296. " AND (:createtimebegin is null or pd.createtime >= :createtimebegin)\n" +
  4297. " AND (:createtimeend is null or pd.createtime <= :createtimeend)\n" +
  4298. " GROUP BY gt2.goodstypecode) OUT \n" +
  4299. " ON OUT.goodstypecode2 = Defect.goodstypecode2 \n";
  4300. parameters = new OracleParameter[]
  4301. {
  4302. new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  4303. new OracleParameter(":createtimebegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  4304. new OracleParameter(":createtimeend", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  4305. new OracleParameter(":procedureids", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input),
  4306. new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input),
  4307. new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input),
  4308. //new OracleParameter(":OutKilnCount", OracleDbType.Int32, outKilnCount, ParameterDirection.Input),
  4309. new OracleParameter(":procedureid", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input),
  4310. };
  4311. }
  4312. else
  4313. {
  4314. sqlString = "SELECT COUNT(pd.barcode) \n" +
  4315. " FROM tp_pm_productiondata pd\n" +
  4316. " WHERE pd.valueflag = '1'\n" +
  4317. " AND pd.procedureid = :procedureid\n" +
  4318. " AND pd.AccountID = :AccountID\n" +
  4319. " AND (:createtimebegin is null or pd.createtime >= :createtimebegin)\n" +
  4320. " AND (:createtimeend is null or pd.createtime <= :createtimeend)";
  4321. parameters = new OracleParameter[]
  4322. {
  4323. new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  4324. new OracleParameter(":procedureid", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input),
  4325. new OracleParameter(":createtimebegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  4326. new OracleParameter(":createtimeend", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  4327. };
  4328. int outKilnCount = Convert.ToInt32(conn.GetSqlResultToStr(sqlString, parameters));
  4329. sqlString = "SELECT Defect.productionlinename\n" +
  4330. " ,Defect.procedurename\n" +
  4331. " ,Defect.Defectcode\n" +
  4332. " ,Defect.Defectname\n" +
  4333. " ,Defect.goodstypename2\n" +
  4334. " ,Defect.DefectCount\n" +
  4335. " ,:OutKilnCount OutKilnCount\n" +
  4336. " ,decode(:OutKilnCount,\n" +
  4337. " 0,\n" +
  4338. " to_number(NULL),\n" +
  4339. " ROUND(Defect.DefectCount / :OutKilnCount, 4)) DefectPercent\n" +
  4340. " FROM (SELECT tp_pc_productionline.productionlinename\n" +
  4341. " ,tp_pc_procedure.procedurename\n" +
  4342. " ,TP_MST_DefectType.Defecttypename\n" +
  4343. " ,TP_MST_Defect.Defectcode\n" +
  4344. " ,TP_MST_Defect.Defectname\n" +
  4345. " ,goodstype2.goodstypename goodstypename2\n" +
  4346. " ,:OutKilnCount OutKilnCount\n" +
  4347. " --,COUNT(DISTINCT TP_PM_Defect.Barcode) DefectCount\n" +
  4348. " ,COUNT(TP_PM_Defect.Barcode) DefectCount\n" +
  4349. " FROM TP_PM_Defect\n" +
  4350. " LEFT JOIN tp_pc_procedure\n" +
  4351. " ON TP_PM_Defect.ProcedureID = tp_pc_procedure.ProcedureID\n" +
  4352. " LEFT JOIN tp_pc_productionline\n" +
  4353. " ON TP_PM_Defect.Productionlineid =\n" +
  4354. " tp_pc_productionline.Productionlineid\n" +
  4355. " LEFT JOIN TP_MST_Goods\n" +
  4356. " ON TP_PM_Defect.Goodsid = TP_MST_Goods.Goodsid\n" +
  4357. " LEFT JOIN TP_MST_GoodsType\n" +
  4358. " ON TP_MST_Goods.GoodsTypeID = TP_MST_GoodsType.GoodsTypeID\n" +
  4359. " LEFT JOIN TP_MST_GoodsType goodstype2\n" +
  4360. " ON goodstype2.goodstypecode =\n" +
  4361. " substr(TP_MST_GoodsType.goodstypecode, 0, 6)\n" +
  4362. " AND TP_MST_GoodsType.accountid = goodstype2.accountid\n" +
  4363. " LEFT JOIN TP_MST_Defect\n" +
  4364. " ON TP_PM_Defect.DefectID = TP_MST_Defect.DefectID\n" +
  4365. " LEFT JOIN TP_MST_DefectType\n" +
  4366. " ON TP_MST_Defect.DefectTypeID = TP_MST_DefectType.DefectTypeID\n" +
  4367. " --LEFT JOIN TP_PM_ProductionData\n" +
  4368. " -- ON TP_PM_ProductionData.ProductionDataID =\n" +
  4369. " -- TP_PM_Defect.ProductionDataID\n" +
  4370. " WHERE TP_PM_Defect.valueflag = '1'\n" +
  4371. " --AND tp_pc_procedure.ModelType = -1\n" +
  4372. " AND TP_PM_Defect.AccountID = :AccountID\n" +
  4373. " AND (:createtimebegin is null or TP_PM_Defect.createtime >= :createtimebegin)\n" +
  4374. " AND (:createtimeend is null or TP_PM_Defect.createtime <= :createtimeend)\n" +
  4375. " AND (:procedureids is null or instr(','||:procedureids||',', ','||TP_PM_Defect.ProcedureID||',') > 0)\n" +
  4376. " AND (:DefectCode is null or instr(TP_MST_Defect.Defectcode, :DefectCode) > 0)\n" +
  4377. " AND (:DefectName is null or instr(TP_MST_Defect.Defectname, :DefectName) > 0)\n" +
  4378. " GROUP BY tp_pc_productionline.productionlinename\n" +
  4379. " ,tp_pc_procedure.procedurename\n" +
  4380. " ,TP_MST_DefectType.Defecttypename\n" +
  4381. " ,TP_MST_Defect.Defectcode\n" +
  4382. " ,TP_MST_Defect.Defectname\n" +
  4383. " ,goodstype2.goodstypename) Defect";
  4384. parameters = new OracleParameter[]
  4385. {
  4386. new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  4387. new OracleParameter(":createtimebegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  4388. new OracleParameter(":createtimeend", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  4389. new OracleParameter(":procedureids", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input),
  4390. new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input),
  4391. new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input),
  4392. new OracleParameter(":OutKilnCount", OracleDbType.Int32, outKilnCount, ParameterDirection.Input),
  4393. };
  4394. }
  4395. DataTable data = conn.GetSqlResultToDt(sqlString, parameters);
  4396. ServiceResultEntity sre = new ServiceResultEntity();
  4397. if (data == null || data.Rows.Count == 0)
  4398. {
  4399. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4400. return sre;
  4401. }
  4402. sre.Data = new DataSet();
  4403. sre.Data.Tables.Add(data);
  4404. return sre;
  4405. }
  4406. catch (Exception ex)
  4407. {
  4408. throw ex;
  4409. }
  4410. finally
  4411. {
  4412. if (conn != null &&
  4413. conn.ConnState == ConnectionState.Open)
  4414. {
  4415. conn.Close();
  4416. }
  4417. }
  4418. }
  4419. /// <summary>
  4420. /// 取得RPT040107画面(注浆产品工序分析表)的查询数据
  4421. /// </summary>
  4422. /// <param name="user">登录用户信息</param>
  4423. /// <param name="se">查询条件</param>
  4424. /// <returns>查询结果</returns>
  4425. public static ServiceResultEntity GetRPT040107SData(SUserInfo user, RPT040107_SE se)
  4426. {
  4427. IDBConnection conn = null;
  4428. try
  4429. {
  4430. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  4431. List<OracleParameter> parameters = new List<OracleParameter>();
  4432. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  4433. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  4434. string sqlString =
  4435. "SELECT LISTAGG('''' || p.procedureid || ''' AS ' || 'P' || p.procedureid,\n" +
  4436. " ',') WITHIN GROUP(ORDER BY p.displayno, p.pid) pivotcol\n" +
  4437. " ,LISTAGG('sum(pd.P' || p.procedureid || '_BC) AS \"' ||\n" +
  4438. " p.procedurename || '\"',\n" +
  4439. " ',') WITHIN GROUP(ORDER BY p.displayno, p.pid) groupsum\n" +
  4440. " FROM (SELECT to_char(p.procedureid) procedureid\n" +
  4441. " ,to_char(p.procedurename) procedurename\n" +
  4442. " ,p.displayno\n" +
  4443. " ,p.productionlineid plid\n" +
  4444. " ,p.procedureid pid\n" +
  4445. " FROM tp_pc_procedure p\n" +
  4446. " WHERE p.valueflag = '1'\n" +
  4447. " AND p.modeltype <> -1\n" +
  4448. " AND p.accountid = :AccountID\n" +
  4449. " UNION ALL\n" +
  4450. " SELECT to_char(p.procedureid) || 'S'\n" +
  4451. " ,to_char(p.procedurename) || '(不合格)'\n" +
  4452. " ,p.displayno\n" +
  4453. " ,p.productionlineid plid\n" +
  4454. " ,p.procedureid pid\n" +
  4455. " FROM tp_pc_procedure p\n" +
  4456. " WHERE p.valueflag = '1'\n" +
  4457. " AND p.modeltype = -1\n" +
  4458. " AND p.accountid = :AccountID) p" +
  4459. " 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" +
  4460. " 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";
  4461. // 生产线
  4462. if (se.ProductionLineID.HasValue)
  4463. {
  4464. sqlString = sqlString + " AND p.plid = :ProductionLineID ";
  4465. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  4466. }
  4467. // 生产工序
  4468. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  4469. {
  4470. sqlString = sqlString + " AND instr(:procedureids, ','||p.pid||',')>0 ";
  4471. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  4472. }
  4473. DataTable cols = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  4474. ServiceResultEntity sre = new ServiceResultEntity();
  4475. if (cols == null || cols.Rows.Count == 0)
  4476. {
  4477. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4478. return sre;
  4479. }
  4480. string pivotcol = cols.Rows[0]["pivotcol"].ToString();
  4481. string groupsum = cols.Rows[0]["groupsum"].ToString();
  4482. if (string.IsNullOrEmpty(pivotcol) || string.IsNullOrEmpty(groupsum))
  4483. {
  4484. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4485. return sre;
  4486. }
  4487. parameters.Clear();
  4488. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  4489. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  4490. sqlString =
  4491. "WITH pd_data AS\n" +
  4492. " (SELECT DISTINCT pd.goodsid pdgoodsid\n" +
  4493. " ,pd.groutingdailydetailid\n" +
  4494. " ,decode(pd.MODELTYPE,\n" +
  4495. " -1,\n" +
  4496. " to_char(pd.procedureid) || 'S',\n" +
  4497. " to_char(pd.procedureid)) procedureid\n" +
  4498. " FROM tp_pm_productiondata pd\n" +
  4499. " LEFT JOIN tp_mst_goods goods\n" +
  4500. " ON goods.goodsid = pd.goodsid\n" +
  4501. " LEFT JOIN tp_mst_goodstype gt\n" +
  4502. " ON gt.goodstypeid = goods.goodstypeid\n" +
  4503. " WHERE pd.valueflag = '1'\n" +
  4504. " AND (pd.MODELTYPE <> -1 OR pd.goodsleveltypeid IN (6, 7))\n" +
  4505. " AND pd.accountid = :AccountID\n" +
  4506. (se.Specialrepairflag ? " AND ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" : "") +
  4507. " 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" +
  4508. " 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";
  4509. // 生产线
  4510. if (se.ProductionLineID.HasValue)
  4511. {
  4512. sqlString = sqlString + " AND pd.productionlineid = :ProductionLineID ";
  4513. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  4514. }
  4515. // 生产工序
  4516. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  4517. {
  4518. sqlString = sqlString + " AND instr(:procedureids, ','||pd.procedureid||',')>0 ";
  4519. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  4520. }
  4521. // 产品型号
  4522. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  4523. {
  4524. sqlString = sqlString + " AND instr(gt.GOODSTYPECode, :GoodsTypeCode)=1 ";
  4525. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  4526. }
  4527. // 产品编码
  4528. if (!string.IsNullOrEmpty(se.GoodsCode))
  4529. {
  4530. sqlString = sqlString + " AND instr(goods.GOODSCode, :GoodsCode) > 0 ";
  4531. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  4532. }
  4533. // 注浆时间
  4534. if (se.GTimeStart.HasValue)
  4535. {
  4536. sqlString = sqlString + " AND pd.GROUTINGDATE >=:GTimeStart ";
  4537. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  4538. }
  4539. if (se.GTimeEnd.HasValue)
  4540. {
  4541. sqlString = sqlString + " AND pd.GROUTINGDATE <= :GTimeEnd ";
  4542. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  4543. }
  4544. sqlString +=
  4545. " ),\n" +
  4546. "pivot_data AS\n" +
  4547. " (SELECT *\n" +
  4548. " FROM pd_data\n" +
  4549. " PIVOT(COUNT(groutingdailydetailid) bc\n" +
  4550. " FOR procedureid IN(" + pivotcol + ")))\n" +
  4551. "SELECT decode(grouping_id(groutdetail.goodstypename2, groutdetail.goodscode),\n" +
  4552. " 3,\n" +
  4553. " '合计',\n" +
  4554. " 1,\n" +
  4555. " '小计【' || groutdetail.goodstypename2 || '】',\n" +
  4556. " groutdetail.goodstypename2) \"产量类别\"\n" +
  4557. " ,decode(grouping_id(groutdetail.goodstypename2, groutdetail.goodscode),\n" +
  4558. " 0,\n" +
  4559. " groutdetail.goodscode,\n" +
  4560. " '--') \"产品编码\"\n" +
  4561. " ,SUM(groutdetail.groutcount) \"注浆数量\"\n" +
  4562. " ,SUM(groutdetail.barcodecount) \"绑条码数量\"\n" +
  4563. " ,SUM(groutdetail.scrapcount) \"开模损坯\"\n" +
  4564. " ," + groupsum + "\n" +
  4565. " FROM (SELECT gdd.goodsid, gt2.goodstypename goodstypename2, goods.goodscode\n" +
  4566. " ,COUNT(gdd.groutingdailydetailid) AS groutcount\n" +
  4567. " ,SUM(decode(gdd.barcode, NULL, 0, 1)) AS barcodecount\n" +
  4568. " ,SUM(decode(gdd.scrapflag, '1', 1, 0)) AS scrapcount\n" +
  4569. " FROM tp_pm_groutingdailydetail gdd\n" +
  4570. " LEFT JOIN tp_mst_goods goods\n" +
  4571. " ON goods.goodsid = gdd.goodsid\n" +
  4572. " LEFT JOIN tp_mst_goodstype gt\n" +
  4573. " ON gt.goodstypeid = goods.goodstypeid\n" +
  4574. " LEFT JOIN tp_mst_goodstype gt2\n" +
  4575. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  4576. " AND gt2.accountid = gt.accountid\n" +
  4577. " WHERE gdd.valueflag = '1'\n" +
  4578. " AND gdd.accountid = :AccountID\n";
  4579. // 产品型号
  4580. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  4581. {
  4582. sqlString = sqlString + " AND instr(gt.GOODSTYPECode, :GoodsTypeCode)=1 ";
  4583. }
  4584. // 产品编码
  4585. if (!string.IsNullOrEmpty(se.GoodsCode))
  4586. {
  4587. sqlString = sqlString + " AND instr(goods.GOODSCode, :GoodsCode) > 0 ";
  4588. }
  4589. // 注浆时间
  4590. if (se.GTimeStart.HasValue)
  4591. {
  4592. sqlString = sqlString + " AND gdd.GROUTINGDATE >=:GTimeStart ";
  4593. }
  4594. if (se.GTimeEnd.HasValue)
  4595. {
  4596. sqlString = sqlString + " AND gdd.GROUTINGDATE <= :GTimeEnd ";
  4597. }
  4598. sqlString +=
  4599. " AND gdd.groutingflag = '1'\n" +
  4600. " GROUP BY gdd.goodsid, gt2.goodstypename, goods.goodscode) groutdetail\n" +
  4601. " LEFT JOIN pivot_data pd\n" +
  4602. " ON pd.pdgoodsid = groutdetail.goodsid\n" +
  4603. " GROUP BY GROUPING SETS((groutdetail.goodstypename2, groutdetail.goodscode),(groutdetail.goodstypename2),())\n" +
  4604. " ORDER BY groutdetail.goodstypename2, groutdetail.goodscode";
  4605. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  4606. if (data == null || data.Rows.Count == 0)
  4607. {
  4608. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4609. return sre;
  4610. }
  4611. sre.Data = new DataSet();
  4612. sre.Data.Tables.Add(data);
  4613. return sre;
  4614. }
  4615. catch (Exception ex)
  4616. {
  4617. throw ex;
  4618. }
  4619. finally
  4620. {
  4621. if (conn != null &&
  4622. conn.ConnState == ConnectionState.Open)
  4623. {
  4624. conn.Close();
  4625. }
  4626. }
  4627. }
  4628. /// <summary>
  4629. /// 取得RPT040108画面(成型线产量分析表)的查询数据
  4630. /// </summary>
  4631. /// <param name="user">登录用户信息</param>
  4632. /// <param name="se">查询条件</param>
  4633. /// <returns>查询结果</returns>
  4634. public static ServiceResultEntity GetRPT040108SData(SUserInfo user, RPT040108_SE se)
  4635. {
  4636. IDBConnection conn = null;
  4637. try
  4638. {
  4639. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  4640. //string sqlString =
  4641. // "SELECT t.groutinglinecode\n" +
  4642. // " ,t.BuildingNo\n" +
  4643. // " ,t.FloorNo\n" +
  4644. // " ,t.GroutingLineNo\n" +
  4645. // " ,t.usercode\n" +
  4646. // " ,t.goodscode\n" +
  4647. // " ,t.GOODSSPECIFICATION\n" +
  4648. // " ,t.goodstypename\n" +
  4649. // //" ,round(AVG(t.MouldQuantity), 2) MouldQuantity\n" +
  4650. // " ,AVG(t.MouldQuantity) MouldQuantity\n" +
  4651. // " ,SUM(decode(t.gday, '01', t.c, 0)) c01\n" +
  4652. // " ,SUM(decode(t.dday, '01', t.d, 0)) d01\n" +
  4653. // " ,SUM(decode(t.gday, '02', t.c, 0)) c02\n" +
  4654. // " ,SUM(decode(t.dday, '02', t.d, 0)) d02\n" +
  4655. // " ,SUM(decode(t.gday, '03', t.c, 0)) c03\n" +
  4656. // " ,SUM(decode(t.dday, '03', t.d, 0)) d03\n" +
  4657. // " ,SUM(decode(t.gday, '04', t.c, 0)) c04\n" +
  4658. // " ,SUM(decode(t.dday, '04', t.d, 0)) d04\n" +
  4659. // " ,SUM(decode(t.gday, '05', t.c, 0)) c05\n" +
  4660. // " ,SUM(decode(t.dday, '05', t.d, 0)) d05\n" +
  4661. // " ,SUM(decode(t.gday, '06', t.c, 0)) c06\n" +
  4662. // " ,SUM(decode(t.dday, '06', t.d, 0)) d06\n" +
  4663. // " ,SUM(decode(t.gday, '07', t.c, 0)) c07\n" +
  4664. // " ,SUM(decode(t.dday, '07', t.d, 0)) d07\n" +
  4665. // " ,SUM(decode(t.gday, '08', t.c, 0)) c08\n" +
  4666. // " ,SUM(decode(t.dday, '08', t.d, 0)) d08\n" +
  4667. // " ,SUM(decode(t.gday, '09', t.c, 0)) c09\n" +
  4668. // " ,SUM(decode(t.dday, '09', t.d, 0)) d09\n" +
  4669. // " ,SUM(decode(t.gday, '10', t.c, 0)) c10\n" +
  4670. // " ,SUM(decode(t.dday, '10', t.d, 0)) d10\n" +
  4671. // " ,SUM(decode(t.gday, '11', t.c, 0)) c11\n" +
  4672. // " ,SUM(decode(t.dday, '11', t.d, 0)) d11\n" +
  4673. // " ,SUM(decode(t.gday, '12', t.c, 0)) c12\n" +
  4674. // " ,SUM(decode(t.dday, '12', t.d, 0)) d12\n" +
  4675. // " ,SUM(decode(t.gday, '13', t.c, 0)) c13\n" +
  4676. // " ,SUM(decode(t.dday, '13', t.d, 0)) d13\n" +
  4677. // " ,SUM(decode(t.gday, '14', t.c, 0)) c14\n" +
  4678. // " ,SUM(decode(t.dday, '14', t.d, 0)) d14\n" +
  4679. // " ,SUM(decode(t.gday, '15', t.c, 0)) c15\n" +
  4680. // " ,SUM(decode(t.dday, '15', t.d, 0)) d15\n" +
  4681. // " ,SUM(decode(t.gday, '16', t.c, 0)) c16\n" +
  4682. // " ,SUM(decode(t.dday, '16', t.d, 0)) d16\n" +
  4683. // " ,SUM(decode(t.gday, '17', t.c, 0)) c17\n" +
  4684. // " ,SUM(decode(t.dday, '17', t.d, 0)) d17\n" +
  4685. // " ,SUM(decode(t.gday, '18', t.c, 0)) c18\n" +
  4686. // " ,SUM(decode(t.dday, '18', t.d, 0)) d18\n" +
  4687. // " ,SUM(decode(t.gday, '19', t.c, 0)) c19\n" +
  4688. // " ,SUM(decode(t.dday, '19', t.d, 0)) d19\n" +
  4689. // " ,SUM(decode(t.gday, '20', t.c, 0)) c20\n" +
  4690. // " ,SUM(decode(t.dday, '20', t.d, 0)) d20\n" +
  4691. // " ,SUM(decode(t.gday, '21', t.c, 0)) c21\n" +
  4692. // " ,SUM(decode(t.dday, '21', t.d, 0)) d21\n" +
  4693. // " ,SUM(decode(t.gday, '22', t.c, 0)) c22\n" +
  4694. // " ,SUM(decode(t.dday, '22', t.d, 0)) d22\n" +
  4695. // " ,SUM(decode(t.gday, '23', t.c, 0)) c23\n" +
  4696. // " ,SUM(decode(t.dday, '23', t.d, 0)) d23\n" +
  4697. // " ,SUM(decode(t.gday, '24', t.c, 0)) c24\n" +
  4698. // " ,SUM(decode(t.dday, '24', t.d, 0)) d24\n" +
  4699. // " ,SUM(decode(t.gday, '25', t.c, 0)) c25\n" +
  4700. // " ,SUM(decode(t.dday, '25', t.d, 0)) d25\n" +
  4701. // " ,SUM(decode(t.gday, '26', t.c, 0)) c26\n" +
  4702. // " ,SUM(decode(t.dday, '26', t.d, 0)) d26\n" +
  4703. // " ,SUM(decode(t.gday, '27', t.c, 0)) c27\n" +
  4704. // " ,SUM(decode(t.dday, '27', t.d, 0)) d27\n" +
  4705. // " ,SUM(decode(t.gday, '28', t.c, 0)) c28\n" +
  4706. // " ,SUM(decode(t.dday, '28', t.d, 0)) d28\n" +
  4707. // " ,SUM(decode(t.gday, '29', t.c, 0)) c29\n" +
  4708. // " ,SUM(decode(t.dday, '29', t.d, 0)) d29\n" +
  4709. // " ,SUM(decode(t.gday, '30', t.c, 0)) c30\n" +
  4710. // " ,SUM(decode(t.dday, '30', t.d, 0)) d30\n" +
  4711. // " ,SUM(decode(t.gday, '31', t.c, 0)) c31\n" +
  4712. // " ,SUM(decode(t.dday, '31', t.d, 0)) d31\n" +
  4713. // " FROM (SELECT gd.groutinglinecode\n" +
  4714. // " ,gl.BuildingNo\n" +
  4715. // " ,gl.FloorNo\n" +
  4716. // " ,gl.GroutingLineNo\n" +
  4717. // " ,gd.usercode\n" +
  4718. // " ,gdd.goodscode\n" +
  4719. // " ,g.GOODSSPECIFICATION\n" +
  4720. // " ,gt.goodstypename\n" +
  4721. // //" ,gd.MouldQuantity\n" +
  4722. // " ,gl.MouldQuantity\n" +
  4723. // " ,to_char(gd.groutingdate, 'dd') AS gday\n" +
  4724. // " ,to_char(gdd.delivertime, 'dd') AS dday\n" +
  4725. // " , CASE\n" +
  4726. // " WHEN gd.groutingdate >= :GDateBegin AND\n" +
  4727. // " gd.groutingdate <= :GDateEnd AND\n" +
  4728. // " gdd.GroutingFlag = '1' AND gdd.ScrapFlag = '0' THEN\n" +
  4729. // " 1\n" +
  4730. // " ELSE\n" +
  4731. // " 0\n" +
  4732. // " END c -- 成坯量\n" +
  4733. // " , CASE\n" +
  4734. // " WHEN gdd.delivertime >= :GDateBegin AND\n" +
  4735. // " gdd.delivertime <= :GDateEnd AND\n" +
  4736. // " gdd.deliverflag = '1' THEN\n" +
  4737. // " 1\n" +
  4738. // " ELSE\n" +
  4739. // " 0\n" +
  4740. // " END d -- 交坯量\n" +
  4741. // " FROM TP_PM_GroutingDaily gd\n" +
  4742. // " INNER JOIN TP_PM_GroutingDailyDetail gdd\n" +
  4743. // " ON gdd.groutingdailyid = gd.groutingdailyid\n" +
  4744. // " INNER JOIN TP_PC_GroutingLine gl \n" +
  4745. // " ON gl.groutinglineid = gd.groutinglineid\n" +
  4746. // " INNER JOIN TP_MST_Goods g\n" +
  4747. // " ON g.goodsid = gdd.goodsid\n" +
  4748. // " INNER JOIN TP_MST_GOODSTYPE gt\n" +
  4749. // " ON gt.goodstypeid = g.goodstypeid\n" +
  4750. // " WHERE gd.accountid = :AccountID\n" +
  4751. // " AND ((gd.groutingdate >= :GDateBegin AND\n" +
  4752. // " gd.groutingdate <= :GDateEnd) OR\n" +
  4753. // " (gdd.delivertime >= :GDateBegin AND\n" +
  4754. // " gdd.delivertime <= :GDateEnd))\n" +
  4755. // " AND (:groutinglinecode is null or instr(gd.groutinglinecode, :groutinglinecode) > 0)\n" +
  4756. // " AND (:groutingusercode is null or instr(gdd.usercode, :groutingusercode) > 0)\n" +
  4757. // " AND (:goodscode is null or instr(gdd.goodscode, :goodscode) > 0)\n" +
  4758. // " AND (:goodstypecode is null or instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  4759. // " ) t\n" +
  4760. // " GROUP BY t.groutinglinecode\n" +
  4761. // " ,t.BuildingNo\n" +
  4762. // " ,t.FloorNo\n" +
  4763. // " ,t.GroutingLineNo\n" +
  4764. // " ,t.usercode\n" +
  4765. // " ,t.goodscode\n" +
  4766. // " ,t.GOODSSPECIFICATION\n" +
  4767. // " ,t.goodstypename\n" +
  4768. // " ORDER BY t.groutinglinecode, t.usercode, t.goodscode";
  4769. string sqlString = "select nvl(t.groutinglinecode, '--') groutinglinecode\n" +
  4770. " ,nvl(t.BuildingNo, '--') BuildingNo\n" +
  4771. " ,nvl(t.FloorNo, '--') FloorNo\n" +
  4772. " ,nvl(t.GroutingLineNo, '--') GroutingLineNo\n" +
  4773. " ,nvl(t.usercode, '--') usercode\n" +
  4774. " ,nvl2(t.groutinglinecode\n" +
  4775. " ,t.goodscode\n" +
  4776. " ,nvl2(t.goodscode, '小计[' || t.goodscode || ']', '合计')) goodscode\n" +
  4777. " ,nvl2(t.goodscode, t.GOODSSPECIFICATION, '--') GOODSSPECIFICATION\n" +
  4778. " ,nvl2(t.goodscode, t.goodstypename, '--') goodstypename\n" +
  4779. " ,nvl2(t.groutinglinecode, avg(t.MouldQuantity), null) MouldQuantity\n" +
  4780. " ,sum(decode(t.gday, '01', t.c, 0)) c01\n" +
  4781. " ,sum(decode(t.dday, '01', t.d, 0)) d01\n" +
  4782. " ,sum(decode(t.gday, '02', t.c, 0)) c02\n" +
  4783. " ,sum(decode(t.dday, '02', t.d, 0)) d02\n" +
  4784. " ,sum(decode(t.gday, '03', t.c, 0)) c03\n" +
  4785. " ,sum(decode(t.dday, '03', t.d, 0)) d03\n" +
  4786. " ,sum(decode(t.gday, '04', t.c, 0)) c04\n" +
  4787. " ,sum(decode(t.dday, '04', t.d, 0)) d04\n" +
  4788. " ,sum(decode(t.gday, '05', t.c, 0)) c05\n" +
  4789. " ,sum(decode(t.dday, '05', t.d, 0)) d05\n" +
  4790. " ,sum(decode(t.gday, '06', t.c, 0)) c06\n" +
  4791. " ,sum(decode(t.dday, '06', t.d, 0)) d06\n" +
  4792. " ,sum(decode(t.gday, '07', t.c, 0)) c07\n" +
  4793. " ,sum(decode(t.dday, '07', t.d, 0)) d07\n" +
  4794. " ,sum(decode(t.gday, '08', t.c, 0)) c08\n" +
  4795. " ,sum(decode(t.dday, '08', t.d, 0)) d08\n" +
  4796. " ,sum(decode(t.gday, '09', t.c, 0)) c09\n" +
  4797. " ,sum(decode(t.dday, '09', t.d, 0)) d09\n" +
  4798. " ,sum(decode(t.gday, '10', t.c, 0)) c10\n" +
  4799. " ,sum(decode(t.dday, '10', t.d, 0)) d10\n" +
  4800. " ,sum(decode(t.gday, '11', t.c, 0)) c11\n" +
  4801. " ,sum(decode(t.dday, '11', t.d, 0)) d11\n" +
  4802. " ,sum(decode(t.gday, '12', t.c, 0)) c12\n" +
  4803. " ,sum(decode(t.dday, '12', t.d, 0)) d12\n" +
  4804. " ,sum(decode(t.gday, '13', t.c, 0)) c13\n" +
  4805. " ,sum(decode(t.dday, '13', t.d, 0)) d13\n" +
  4806. " ,sum(decode(t.gday, '14', t.c, 0)) c14\n" +
  4807. " ,sum(decode(t.dday, '14', t.d, 0)) d14\n" +
  4808. " ,sum(decode(t.gday, '15', t.c, 0)) c15\n" +
  4809. " ,sum(decode(t.dday, '15', t.d, 0)) d15\n" +
  4810. " ,sum(decode(t.gday, '16', t.c, 0)) c16\n" +
  4811. " ,sum(decode(t.dday, '16', t.d, 0)) d16\n" +
  4812. " ,sum(decode(t.gday, '17', t.c, 0)) c17\n" +
  4813. " ,sum(decode(t.dday, '17', t.d, 0)) d17\n" +
  4814. " ,sum(decode(t.gday, '18', t.c, 0)) c18\n" +
  4815. " ,sum(decode(t.dday, '18', t.d, 0)) d18\n" +
  4816. " ,sum(decode(t.gday, '19', t.c, 0)) c19\n" +
  4817. " ,sum(decode(t.dday, '19', t.d, 0)) d19\n" +
  4818. " ,sum(decode(t.gday, '20', t.c, 0)) c20\n" +
  4819. " ,sum(decode(t.dday, '20', t.d, 0)) d20\n" +
  4820. " ,sum(decode(t.gday, '21', t.c, 0)) c21\n" +
  4821. " ,sum(decode(t.dday, '21', t.d, 0)) d21\n" +
  4822. " ,sum(decode(t.gday, '22', t.c, 0)) c22\n" +
  4823. " ,sum(decode(t.dday, '22', t.d, 0)) d22\n" +
  4824. " ,sum(decode(t.gday, '23', t.c, 0)) c23\n" +
  4825. " ,sum(decode(t.dday, '23', t.d, 0)) d23\n" +
  4826. " ,sum(decode(t.gday, '24', t.c, 0)) c24\n" +
  4827. " ,sum(decode(t.dday, '24', t.d, 0)) d24\n" +
  4828. " ,sum(decode(t.gday, '25', t.c, 0)) c25\n" +
  4829. " ,sum(decode(t.dday, '25', t.d, 0)) d25\n" +
  4830. " ,sum(decode(t.gday, '26', t.c, 0)) c26\n" +
  4831. " ,sum(decode(t.dday, '26', t.d, 0)) d26\n" +
  4832. " ,sum(decode(t.gday, '27', t.c, 0)) c27\n" +
  4833. " ,sum(decode(t.dday, '27', t.d, 0)) d27\n" +
  4834. " ,sum(decode(t.gday, '28', t.c, 0)) c28\n" +
  4835. " ,sum(decode(t.dday, '28', t.d, 0)) d28\n" +
  4836. " ,sum(decode(t.gday, '29', t.c, 0)) c29\n" +
  4837. " ,sum(decode(t.dday, '29', t.d, 0)) d29\n" +
  4838. " ,sum(decode(t.gday, '30', t.c, 0)) c30\n" +
  4839. " ,sum(decode(t.dday, '30', t.d, 0)) d30\n" +
  4840. " ,sum(decode(t.gday, '31', t.c, 0)) c31\n" +
  4841. " ,sum(decode(t.dday, '31', t.d, 0)) d31\n" +
  4842. " from (select gd.groutinglinecode\n" +
  4843. " ,gl.BuildingNo\n" +
  4844. " ,gl.FloorNo\n" +
  4845. " ,gl.GroutingLineNo\n" +
  4846. " ,gd.usercode\n" +
  4847. " ,gdd.goodscode\n" +
  4848. " ,g.GOODSSPECIFICATION\n" +
  4849. " ,gt.goodstypename\n" +
  4850. " ,gl.MouldQuantity\n" +
  4851. " ,to_char(gd.groutingdate, 'dd') as gday\n" +
  4852. " ,to_char(gdd.delivertime, 'dd') as dday\n" +
  4853. " ,case\n" +
  4854. " when gd.groutingdate >= :GDateBegin and\n" +
  4855. " gd.groutingdate <= :GDateEnd and\n" +
  4856. " gdd.GroutingFlag = '1' and\n" +
  4857. " gdd.ScrapFlag = '0' then\n" +
  4858. " 1\n" +
  4859. " else\n" +
  4860. " 0\n" +
  4861. " end c -- 成坯量\n" +
  4862. " ,case\n" +
  4863. " when gdd.delivertime >= :GDateBegin and\n" +
  4864. " gdd.delivertime <= :GDateEnd and\n" +
  4865. " gdd.deliverflag = '1' then\n" +
  4866. " 1\n" +
  4867. " else\n" +
  4868. " 0\n" +
  4869. " end d -- 交坯量\n" +
  4870. " from TP_PM_GroutingDaily gd\n" +
  4871. " inner join TP_PM_GroutingDailyDetail gdd\n" +
  4872. " on gdd.groutingdailyid = gd.groutingdailyid\n" +
  4873. " inner join TP_PC_GroutingLine gl\n" +
  4874. " on gl.groutinglineid = gd.groutinglineid\n" +
  4875. " inner join TP_MST_Goods g\n" +
  4876. " on g.goodsid = gdd.goodsid\n" +
  4877. " inner join TP_MST_GOODSTYPE gt\n" +
  4878. " on gt.goodstypeid = g.goodstypeid\n" +
  4879. " where gd.accountid = :AccountID\n" +
  4880. " and ((gd.groutingdate >= :GDateBegin and\n" +
  4881. " gd.groutingdate <= :GDateEnd) or\n" +
  4882. " (gdd.delivertime >= :GDateBegin and\n" +
  4883. " gdd.delivertime <= :GDateEnd))\n" +
  4884. " and (:groutinglinecode is null or\n" +
  4885. " instr(gd.groutinglinecode, :groutinglinecode) > 0)\n" +
  4886. " and (:groutingusercode is null or\n" +
  4887. " instr(gdd.usercode, :groutingusercode) > 0)\n" +
  4888. " and (:goodscode is null or instr(gdd.goodscode, :goodscode) > 0)\n" +
  4889. " and (:goodstypecode is null or\n" +
  4890. " instr(gt.goodstypecode, :goodstypecode) = 1)) t\n" +
  4891. " 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" +
  4892. " order by t.goodscode, t.groutinglinecode, t.usercode";
  4893. List<OracleParameter> parameters = new List<OracleParameter>();
  4894. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  4895. parameters.Add(new OracleParameter(":GDateBegin", OracleDbType.Date, se.GDateBegin, ParameterDirection.Input));
  4896. parameters.Add(new OracleParameter(":GDateEnd", OracleDbType.Date, se.GDateEnd, ParameterDirection.Input));
  4897. parameters.Add(new OracleParameter(":groutinglinecode", OracleDbType.Varchar2, se.GroutingLineCode, ParameterDirection.Input));
  4898. parameters.Add(new OracleParameter(":groutingusercode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  4899. parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  4900. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  4901. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  4902. ServiceResultEntity sre = new ServiceResultEntity();
  4903. if (data == null || data.Rows.Count == 0)
  4904. {
  4905. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4906. return sre;
  4907. }
  4908. sre.Data = new DataSet();
  4909. sre.Data.Tables.Add(data);
  4910. return sre;
  4911. }
  4912. catch (Exception ex)
  4913. {
  4914. throw ex;
  4915. }
  4916. finally
  4917. {
  4918. if (conn != null &&
  4919. conn.ConnState == ConnectionState.Open)
  4920. {
  4921. conn.Close();
  4922. }
  4923. }
  4924. }
  4925. /// <summary>
  4926. /// 取得RPT040109画面(整体质量分析表)的查询数据
  4927. /// </summary>
  4928. /// <param name="user">登录用户信息</param>
  4929. /// <param name="se">查询条件</param>
  4930. /// <returns>查询结果</returns>
  4931. public static ServiceResultEntity GetRPT040109SData(SUserInfo user, RPT040109_SE se)
  4932. {
  4933. IDBTransaction conn = null;
  4934. try
  4935. {
  4936. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  4937. conn.Connect();
  4938. OracleParameter[] parameters = new OracleParameter[]
  4939. {
  4940. new OracleParameter("in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  4941. new OracleParameter("in_DateBegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  4942. new OracleParameter("in_DateEnd", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  4943. new OracleParameter("in_OutKilnProcedureID", OracleDbType.Int32, se.RptSProcedureID , ParameterDirection.Input),
  4944. new OracleParameter("in_KilnID", OracleDbType.Int32, se.KilnID , ParameterDirection.Input),
  4945. new OracleParameter("out_data1", OracleDbType.RefCursor, null , ParameterDirection.Output),
  4946. new OracleParameter("out_data2", OracleDbType.RefCursor, null , ParameterDirection.Output),
  4947. new OracleParameter("out_data3", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4948. new OracleParameter("out_data4", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4949. new OracleParameter("out_data21", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4950. new OracleParameter("out_data31", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4951. new OracleParameter("out_data32", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4952. new OracleParameter("out_table1", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4953. new OracleParameter("out_table2", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4954. new OracleParameter("out_table3", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4955. new OracleParameter("out_table4", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4956. new OracleParameter("in_HasUserGroup", OracleDbType.Int32, (se.HasUserGroup?1:0), ParameterDirection.Input),
  4957. };
  4958. //out_data1 -- 质量整体情况
  4959. //out_data2 -- 各缺陷类型成品率
  4960. //out_data3 -- 各缺陷类型缺陷率
  4961. //out_data4 -- 产品质量排行榜
  4962. //out_data21 -- 各缺陷类型成品率-总成品率
  4963. //out_data31 -- 各缺陷类型缺陷率-总缺陷率
  4964. //out_data32 -- 各缺陷类型缺陷率-分缺陷率
  4965. //out_table1 -- 缺陷类别
  4966. //out_table2 -- 工号分组
  4967. //out_table3 -- 缺陷扣罚
  4968. //out_table4 -- 缺陷
  4969. //DataSet data = conn.ExecStoredProcedure("PRO_RPT_OverallQualityAnalysis", parameters);
  4970. DataSet data = conn.ExecStoredProcedure("PRO_RPT_OverallQualityA_UserG", parameters);
  4971. ServiceResultEntity sre = new ServiceResultEntity();
  4972. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  4973. {
  4974. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4975. return sre;
  4976. }
  4977. data.Tables[0].TableName = "TQ";
  4978. data.Tables[1].TableName = "FR";
  4979. data.Tables[2].TableName = "DR";
  4980. data.Tables[3].TableName = "DL";
  4981. data.Tables[4].TableName = "FR1";
  4982. data.Tables[5].TableName = "DR1";
  4983. data.Tables[6].TableName = "DR2";
  4984. data.Tables[7].TableName = "DT";
  4985. data.Tables[8].TableName = "WG";
  4986. data.Tables[9].TableName = "DF";
  4987. data.Tables[10].TableName = "D";
  4988. DataTable dtFR = data.Tables["FR"];
  4989. DataTable dtFRClone = dtFR.Clone();
  4990. for (int i = 0; i < dtFR.Columns.Count; i++)
  4991. {
  4992. dtFRClone.Columns[i].DataType = typeof(string);
  4993. }
  4994. foreach (DataRow item in dtFR.Rows)
  4995. {
  4996. item["goodstypename2"] = item["goodstypename2"] + "缺陷数";
  4997. dtFRClone.Rows.Add(item.ItemArray);
  4998. }
  4999. // 增加大小件成品率(%) modify by chenxy 2018-05-03 begin
  5000. //DataRow drFR = dtFRClone.NewRow();
  5001. //drFR["goodstypename2"] = "成品率(%)";
  5002. //foreach (DataRow row in data.Tables["FR1"].Rows)
  5003. //{
  5004. // string tid = row["tid"].ToString();
  5005. // string overRate = (row["OverRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["OverRate"]).ToString("#,##0.00%"));
  5006. // foreach (DataColumn col in dtFRClone.Columns)
  5007. // {
  5008. // if (col.ColumnName.StartsWith(tid))
  5009. // {
  5010. // drFR[col.ColumnName] = overRate;
  5011. // }
  5012. // }
  5013. //}
  5014. //dtFRClone.Rows.Add(drFR);
  5015. Dictionary<string, DataRow> drFRs = new Dictionary<string, DataRow>();
  5016. foreach (DataRow row in data.Tables["FR1"].Rows)
  5017. {
  5018. string tcode = row["goodstypecode2"].ToString();
  5019. DataRow drFR = null;
  5020. if (drFRs.ContainsKey(tcode))
  5021. {
  5022. drFR = drFRs[tcode];
  5023. }
  5024. else
  5025. {
  5026. drFR = dtFRClone.NewRow();
  5027. drFRs.Add(tcode, drFR);
  5028. drFR["goodstypename2"] = row["goodstypeName2"] + "成品率(%)";
  5029. }
  5030. string tid = row["tid"].ToString();
  5031. string overRate = (row["OverRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["OverRate"]).ToString("#,##0.00%"));
  5032. foreach (DataColumn col in dtFRClone.Columns)
  5033. {
  5034. if (col.ColumnName.StartsWith(tid))
  5035. {
  5036. drFR[col.ColumnName] = overRate;
  5037. }
  5038. }
  5039. }
  5040. foreach (DataRow item in drFRs.Values)
  5041. {
  5042. dtFRClone.Rows.Add(item);
  5043. }
  5044. // 增加大小件成品率(%) modify by chenxy 2018-05-03 end
  5045. data.Tables.Remove(dtFR);
  5046. data.Tables.Remove(data.Tables["FR1"]);
  5047. data.Tables.Add(dtFRClone);
  5048. DataTable dtDR = data.Tables["DR"];
  5049. DataTable dtDRClone = dtDR.Clone();
  5050. for (int i = 0; i < dtDR.Columns.Count; i++)
  5051. {
  5052. dtDRClone.Columns[i].DataType = typeof(string);
  5053. }
  5054. foreach (DataRow item in dtDR.Rows)
  5055. {
  5056. item["goodstypename2"] = item["goodstypename2"] + "缺陷数";
  5057. dtDRClone.Rows.Add(item.ItemArray);
  5058. }
  5059. // 增加大小件缺陷率(%) modify by chenxy 2018-05-03 begin
  5060. //DataRow drDR = dtDRClone.NewRow();
  5061. //drDR["goodstypename2"] = "缺陷率(%)";
  5062. //foreach (DataRow row in data.Tables["DR2"].Rows)
  5063. //{
  5064. // string tid = row["tdfid"].ToString();
  5065. // string defectRate = (row["DefectRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["DefectRate"]).ToString("#,##0.00%"));
  5066. // drDR[tid] = defectRate;
  5067. //}
  5068. //dtDRClone.Rows.Add(drDR);
  5069. Dictionary<string, DataRow> drDRs = new Dictionary<string, DataRow>();
  5070. foreach (DataRow row in data.Tables["DR2"].Rows)
  5071. {
  5072. string tcode = row["goodstypecode2"].ToString();
  5073. DataRow drDR = null;
  5074. if (drDRs.ContainsKey(tcode))
  5075. {
  5076. drDR = drDRs[tcode];
  5077. }
  5078. else
  5079. {
  5080. drDR = dtDRClone.NewRow();
  5081. drDRs.Add(tcode, drDR);
  5082. drDR["goodstypename2"] = row["goodstypeName2"] + "缺陷率(%)";
  5083. }
  5084. string tid = row["tdfid"].ToString();
  5085. string defectRate = (row["DefectRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["DefectRate"]).ToString("#,##0.00%"));
  5086. drDR[tid] = defectRate;
  5087. }
  5088. foreach (DataRow item in drDRs.Values)
  5089. {
  5090. dtDRClone.Rows.Add(item);
  5091. }
  5092. // 增加大小件成品率(%) modify by chenxy 2018-05-03 end
  5093. data.Tables.Remove(dtDR);
  5094. data.Tables.Remove(data.Tables["DR2"]);
  5095. data.Tables.Add(dtDRClone);
  5096. conn.Commit();
  5097. sre.Data = data;
  5098. return sre;
  5099. }
  5100. catch (Exception ex)
  5101. {
  5102. throw ex;
  5103. }
  5104. finally
  5105. {
  5106. if (conn != null &&
  5107. conn.ConnState == ConnectionState.Open)
  5108. {
  5109. conn.Disconnect();
  5110. }
  5111. }
  5112. }
  5113. /// <summary>
  5114. /// 取得RPT040110画面(产成品逐日出窑数值分析表)的查询数据
  5115. /// </summary>
  5116. /// <param name="user">登录用户信息</param>
  5117. /// <param name="se">查询条件</param>
  5118. /// <returns>查询结果</returns>
  5119. public static ServiceResultEntity GetRPT040110SData(SUserInfo user, RPT040110_SE se)
  5120. {
  5121. IDBTransaction conn = null;
  5122. try
  5123. {
  5124. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  5125. conn.Connect();
  5126. OracleParameter[] parameters = new OracleParameter[]
  5127. {
  5128. new OracleParameter("in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  5129. new OracleParameter("in_DateBegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  5130. new OracleParameter("in_DateEnd", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  5131. new OracleParameter("in_OutKilnProcedureID", OracleDbType.Int32, se.RptSProcedureID , ParameterDirection.Input),
  5132. new OracleParameter("in_KilnID", OracleDbType.Int32, se.KilnID , ParameterDirection.Input),
  5133. new OracleParameter("out_data1", OracleDbType.RefCursor, null , ParameterDirection.Output),
  5134. };
  5135. DataSet data = null;
  5136. if (se.IsShowG)
  5137. {
  5138. data = conn.ExecStoredProcedure("PRO_RPT_OverallQualityDetail_G", parameters);
  5139. }
  5140. else
  5141. {
  5142. data = conn.ExecStoredProcedure("PRO_RPT_OverallQualityDetail", parameters);
  5143. }
  5144. ServiceResultEntity sre = new ServiceResultEntity();
  5145. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  5146. {
  5147. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5148. return sre;
  5149. }
  5150. conn.Commit();
  5151. sre.Data = data;
  5152. return sre;
  5153. }
  5154. catch (Exception ex)
  5155. {
  5156. throw ex;
  5157. }
  5158. finally
  5159. {
  5160. if (conn != null &&
  5161. conn.ConnState == ConnectionState.Open)
  5162. {
  5163. conn.Disconnect();
  5164. }
  5165. }
  5166. }
  5167. #endregion 分析报表
  5168. #region 汇总报表
  5169. /// <summary>
  5170. /// 取得RPT030101_1画面(产品产量汇总表)的汇总信息查询数据
  5171. /// </summary>
  5172. /// <param name="user">登录用户信息</param>
  5173. /// <param name="se">查询条件</param>
  5174. /// <returns>查询结果</returns>
  5175. public static ServiceResultEntity GetRPT030101SData(SUserInfo user, RPT030101_SE se)
  5176. {
  5177. IDBConnection conn = null;
  5178. try
  5179. {
  5180. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  5181. List<OracleParameter> parameters = new List<OracleParameter>();
  5182. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030101SSQL(user, se, ref parameters));
  5183. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  5184. ServiceResultEntity sre = new ServiceResultEntity();
  5185. if (data == null || data.Rows.Count == 0)
  5186. {
  5187. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5188. return sre;
  5189. }
  5190. sre.Data = new DataSet();
  5191. sre.Data.Tables.Add(data);
  5192. return sre;
  5193. }
  5194. catch (Exception ex)
  5195. {
  5196. throw ex;
  5197. }
  5198. finally
  5199. {
  5200. if (conn != null &&
  5201. conn.ConnState == ConnectionState.Open)
  5202. {
  5203. conn.Close();
  5204. }
  5205. }
  5206. }
  5207. /// <summary>
  5208. /// 获取RPT030101_1画面(产品产量汇总表)的汇总信息查询sql
  5209. /// </summary>
  5210. /// <returns>sql</returns>
  5211. private static string GetRPT030101SSQL(SUserInfo user, RPT030101_SE se, ref List<OracleParameter> parameters)
  5212. {
  5213. //string selSql = "";
  5214. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  5215. /*
  5216. selSql = selSql +
  5217. "select " +
  5218. " decode(t.ProductionLineName,'合计','合计',decode(t.GoodsCode,'小计','--',t.OrganizationName)) OrganizationName, " +
  5219. " decode(t.Procedureid,'--','--',decode(t.GoodsCode,'小计','--',t.ProductionLineName)) ProductionLineName, " +
  5220. " decode(t.GoodsCode,'小计','--',t.Procedureid) Procedureid, " +
  5221. " decode(t.GoodsCode,'小计','--',t.ProcedureName) ProcedureName, " +
  5222. " decode(t.GoodsCode,'小计','小计',t.GoodsTypeName) GoodsTypeName, " +
  5223. " decode(t.GoodsTypeName,'小计','--',t.GoodsId) GoodsId, " +
  5224. " decode(t.ProductionLineName,'合计','--',decode(t.GoodsId,null,'--',t.GoodsCode)) GoodsCode, " +
  5225. " decode(t.GoodsCode,'小计','--',t.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  5226. " decode(t.GoodsCode,'小计','--',t.Dictionaryvalue) Dictionaryvalue, " +
  5227. " decode(t.GoodsCode,'小计','--',g.goodsname) goodsname, " +
  5228. " decode(t.GoodsCode,'小计','--',g.GOODSMODEL) GOODSMODEL, " +
  5229. " t.产量 " +
  5230. "from " +
  5231. "( " +
  5232. " select " +
  5233. " decode(grouping(TP_MST_Organization.OrganizationName),1,'总计',TP_MST_Organization.OrganizationName) OrganizationName, " +
  5234. " decode(grouping(TP_MST_Organization.OrganizationName),1,'--', " +
  5235. " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'合计',TP_PM_ProductionData.ProductionLineName)) ProductionLineName, " +
  5236. " decode(grouping(TP_PM_ProductionData.Procedureid),1,'--',TP_PM_ProductionData.Procedureid) Procedureid, " +
  5237. " decode(grouping(TP_PM_ProductionData.ProcedureName),1,'--',TP_PM_ProductionData.ProcedureName) ProcedureName, " +
  5238. " decode(grouping(TP_MST_GOODSTYPE.GoodsTypeName),1,'--',TP_MST_GOODSTYPE.GoodsTypeName) GoodsTypeName, " +
  5239. " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'--', " +
  5240. " decode(grouping(TP_PM_ProductionData.GoodsCode),1,'小计',TP_PM_ProductionData.GoodsCode)) GoodsCode, " +
  5241. " decode(grouping(TP_PM_ProductionData.GoodsId),1,null,TP_PM_ProductionData.GoodsId) GoodsId, " +
  5242. " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  5243. " decode(grouping(TP_MST_DATADICTIONARY.DICTIONARYVALUE),1,'--',TP_MST_DATADICTIONARY.Dictionaryvalue) Dictionaryvalue, " +
  5244. " count(BarCode) as 产量 " +
  5245. " from TP_PM_ProductionData " +
  5246. " left join TP_MST_Goods on TP_MST_Goods.GoodsID=TP_PM_ProductionData.GoodsID " +
  5247. " left join TP_MST_GoodsType on TP_MST_GoodsType.GoodsTypeID=TP_MST_Goods.GoodsTypeID " +
  5248. " left join TP_MST_Organization on TP_MST_Organization.OrganizationID=TP_PM_ProductionData.OrganizationID " +
  5249. " left join TP_MST_DATADICTIONARY on TP_MST_DATADICTIONARY.DICTIONARYID=TP_MST_Goods.GLAZETYPEID " +
  5250. " Where 1=1 and TP_PM_ProductionData.ValueFlag = 1 " +
  5251. // 公坯、干补不算交坯工序的质量。
  5252. (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" : "") +
  5253. " and TP_PM_ProductionData.AccountID=:AccountID ";
  5254. if (!string.IsNullOrEmpty(se.GoodsIDS))
  5255. {
  5256. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  5257. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  5258. }
  5259. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  5260. {
  5261. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
  5262. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPEcode,:GoodsTypeIDS)=1 ";
  5263. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  5264. }
  5265. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  5266. {
  5267. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  5268. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  5269. }
  5270. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  5271. {
  5272. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_ProductionData.ProcedureId||',')>0 ";
  5273. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  5274. }
  5275. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  5276. {
  5277. selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||TP_MST_Organization.OrganizationId||',')>0 ";
  5278. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  5279. }
  5280. if (se.AccountDateStart.HasValue)
  5281. {
  5282. selSql = selSql + " AND TP_PM_ProductionData.CREATETIME >= :AccountDateStart ";
  5283. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  5284. }
  5285. if (se.AccountDateEnd.HasValue)
  5286. {
  5287. selSql = selSql + " AND TP_PM_ProductionData.CREATETIME <= :AccountDateEnd ";
  5288. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  5289. }
  5290. selSql = selSql +
  5291. "group by " +
  5292. " rollup(TP_MST_Organization.OrganizationName, " +
  5293. " TP_PM_ProductionData.ProductionLineName, " +
  5294. " TP_PM_ProductionData.Procedureid, " +
  5295. " TP_PM_ProductionData.ProcedureName, " +
  5296. " TP_MST_GOODSTYPE.GoodsTypeName, " +
  5297. " TP_PM_ProductionData.GoodsCode, " +
  5298. " TP_PM_ProductionData.GoodsId, " +
  5299. " TP_MST_Goods.GOODSSPECIFICATION, " +
  5300. " TP_MST_DATADICTIONARY.Dictionaryvalue) " +
  5301. " order by " +
  5302. " TP_MST_Organization.OrganizationName, " +
  5303. " TP_PM_ProductionData.ProductionLineName, " +
  5304. " TP_PM_ProductionData.Procedureid, " +
  5305. " TP_PM_ProductionData.ProcedureName, " +
  5306. " TP_MST_GOODSTYPE.GoodsTypeName " +
  5307. ") t \n" +
  5308. // 增加 产品型号
  5309. "left join tp_mst_goods g on g.goodsid = t.goodsid \n" +
  5310. "where 1=1 " +
  5311. "and (t.DICTIONARYVALUE!='--' ) " +
  5312. "or (t.GoodsTypeName='--' and t.ProductionLineName='合计') " +
  5313. "or (t.GoodsTypeName='--' and t.OrganizationName='总计') " +
  5314. "or (t.GoodsCode='小计' and t.GoodsTypeName!='--')";
  5315. */
  5316. string selSql = @"
  5317. select t.gid
  5318. ,decode(t.gid
  5319. ,3
  5320. ,'--'
  5321. ,7
  5322. ,'--'
  5323. ,15
  5324. ,'--'
  5325. ,t.BUILDINGNO ) BUILDINGNO
  5326. ,decode(t.gid, 15, '总计', t.ProductionLineName) ProductionLineName
  5327. ,t.OrganizationID
  5328. --,t.OrganizationCode
  5329. ,decode(t.gid
  5330. ,7
  5331. ,'合计[' || t.OrganizationName || ']'
  5332. ,15
  5333. ,'--'
  5334. ,t.OrganizationName) OrganizationName
  5335. ,t.Procedureid
  5336. ,decode(t.gid
  5337. ,3
  5338. ,'小计[' || t.ProcedureName || ']'
  5339. ,0
  5340. ,t.ProcedureName
  5341. ,1
  5342. ,t.ProcedureName
  5343. ,'--') ProcedureName
  5344. ,t.GoodsTypeID
  5345. ,decode(t.gid
  5346. ,1
  5347. ,'小计[' || t.GoodsTypeName || ']'
  5348. ,0
  5349. ,t.GoodsTypeName
  5350. ,'--') GoodsTypeName
  5351. --,t.GoodsId
  5352. ,decode(t.gid, 0, to_char(t.GoodsId), '--') GoodsId
  5353. ,decode(t.gid, 0, t.GoodsCode, '--') GoodsCode
  5354. ,decode(t.gid, 0, t.GOODSSPECIFICATION, '--') GOODSSPECIFICATION
  5355. ,decode(t.gid, 0, t.Dictionaryvalue, '--') Dictionaryvalue
  5356. ,t.pfcount as 产量
  5357. from (select grouping_id(org.OrganizationID
  5358. ,p.Procedureid
  5359. ,gt.goodstypeid
  5360. ,g.GoodsId
  5361. ,gl.BUILDINGNO) as gid
  5362. ,pd.ProductionLineName
  5363. ,org.OrganizationID
  5364. --,org.OrganizationCode
  5365. ,org.OrganizationName
  5366. ,p.Procedureid
  5367. ,p.ProcedureName
  5368. ,gl.BUILDINGNO
  5369. ,gt.GoodsTypeID
  5370. ,gt.GoodsTypeName
  5371. ,g.GoodsId
  5372. ,g.GoodsCode
  5373. ,g.GOODSSPECIFICATION
  5374. ,d.Dictionaryvalue
  5375. ,count(PD.BarCode) as pfcount
  5376. from TP_PM_ProductionData pd
  5377. LEFT JOIN Tp_Pm_Groutingdailydetail GP on GP.BARCODE=pd.BARCODE
  5378. LEFT JOIN TP_PC_GROUTINGLINE gl on gl.GROUTINGLINEID=pd.GROUTINGLINEID
  5379. inner join tp_pc_Procedure p on p.Procedureid = pd.Procedureid
  5380. inner join TP_MST_Goods g on g.GoodsID = pd.GoodsID
  5381. inner join TP_MST_GoodsType gt on gt.GoodsTypeID = g.GoodsTypeID
  5382. inner join TP_MST_Organization org on org.OrganizationID = pd.OrganizationID
  5383. inner join TP_MST_DATADICTIONARY d on d.DICTIONARYID = GP.Glazetypeid
  5384. where pd.ValueFlag = '1'
  5385. and pd.AccountID = :AccountID ";
  5386. // 公坯、干补不算交坯工序的质量。
  5387. if (se.ProductionFlag == "1")
  5388. {
  5389. selSql += " and ((pd.modeltype <> 5) or (pd.modeltype = 5 and (pd.IsPublicBody = '0' or pd.SpecialRepairFlag = '0'))) \n";
  5390. }
  5391. if (!string.IsNullOrEmpty(se.GoodsIDS))
  5392. {
  5393. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||g.GoodsId||',')>0 ";
  5394. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  5395. }
  5396. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  5397. {
  5398. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
  5399. selSql = selSql + " AND instr(gt.GOODSTYPEcode,:GoodsTypeIDS)=1 ";
  5400. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  5401. }
  5402. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  5403. {
  5404. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pd.ProductionLineId||',')>0 ";
  5405. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  5406. }
  5407. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  5408. {
  5409. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||p.ProcedureId||',')>0 ";
  5410. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  5411. }
  5412. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  5413. {
  5414. selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||org.OrganizationId||',')>0 ";
  5415. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  5416. }
  5417. if (se.AccountDateStart.HasValue)
  5418. {
  5419. selSql = selSql + " AND pd.CREATETIME >= :AccountDateStart ";
  5420. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  5421. }
  5422. if (se.AccountDateEnd.HasValue)
  5423. {
  5424. selSql = selSql + " AND pd.CREATETIME <= :AccountDateEnd ";
  5425. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  5426. }
  5427. if (!string.IsNullOrEmpty(se.Building))
  5428. {
  5429. selSql = selSql + " AND gl.BUILDINGNO =:Building";
  5430. parameters.Add(new OracleParameter(":Building", OracleDbType.NVarchar2, se.Building, ParameterDirection.Input));
  5431. }
  5432. selSql += @" group by grouping sets((pd.ProductionLineName, org.OrganizationID, org.organizationcode, org.OrganizationName, p.Procedureid, p.ProcedureName,
  5433. p.displayno, gt.GoodsTypeID, gt.goodstypecode, gt.GoodsTypeName,gl.BUILDINGNO, g.GoodsId, g.GoodsCode, g.GOODSSPECIFICATION, d.Dictionaryvalue),
  5434. (pd.ProductionLineName, org.OrganizationID, org.organizationcode, org.OrganizationName, p.Procedureid, p.ProcedureName, p.displayno, gt.GoodsTypeID, gt.goodstypecode, gt.GoodsTypeName),
  5435. (pd.ProductionLineName, org.OrganizationID, org.organizationcode, org.OrganizationName, p.Procedureid, p.ProcedureName, p.displayno),
  5436. (pd.ProductionLineName, org.OrganizationID, org.organizationcode, org.OrganizationName),())
  5437. order by org.organizationcode
  5438. ,p.displayno
  5439. ,gt.goodstypecode
  5440. ,g.goodscode) t ";
  5441. return selSql;
  5442. }
  5443. /// <summary>
  5444. /// 取得RPT030101_1画面(产品产量汇总表)的明细信息查询数据
  5445. /// </summary>
  5446. /// <param name="user">登录用户信息</param>
  5447. /// <param name="se">查询条件</param>
  5448. /// <returns>查询结果</returns>
  5449. public static ServiceResultEntity GetRPT030101IData(SUserInfo user, RPT030101_SE se)
  5450. {
  5451. IDBConnection conn = null;
  5452. try
  5453. {
  5454. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  5455. List<OracleParameter> parameters = new List<OracleParameter>();
  5456. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030101ISQL(user, se, ref parameters));
  5457. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  5458. ServiceResultEntity sre = new ServiceResultEntity();
  5459. if (data == null || data.Rows.Count == 0)
  5460. {
  5461. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5462. return sre;
  5463. }
  5464. sre.Data = new DataSet();
  5465. sre.Data.Tables.Add(data);
  5466. return sre;
  5467. }
  5468. catch (Exception ex)
  5469. {
  5470. throw ex;
  5471. }
  5472. finally
  5473. {
  5474. if (conn != null &&
  5475. conn.ConnState == ConnectionState.Open)
  5476. {
  5477. conn.Close();
  5478. }
  5479. }
  5480. }
  5481. /// <summary>
  5482. /// 获取RPT030101_1画面(产品产量汇总表)的明细信息查询sql
  5483. /// </summary>
  5484. /// <returns>sql</returns>
  5485. private static string GetRPT030101ISQL(SUserInfo user, RPT030101_SE se, ref List<OracleParameter> parameters)
  5486. {
  5487. //string selSql = "";
  5488. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  5489. /*
  5490. selSql = selSql +
  5491. "select " +
  5492. "decode(ProductionLineName,'合计','合计',decode(temp.BarCode,'小计','--',OrganizationName)) OrganizationName, " +
  5493. "decode(ProcedureName,'--','--',decode(temp.barcode,'小计','--',temp.ProductionLineName)) ProductionLineName, " +
  5494. "decode(temp.BarCode,'小计','--',temp.ProcedureName) ProcedureName, " +
  5495. "decode(temp.BarCode,'小计','--',temp.GoodsTypeName) GoodsTypeName, " +
  5496. "decode(temp.BarCode,'小计','小计',temp.GoodsCode) GoodsCode, " +
  5497. "decode(ProductionLineName,'合计','--',decode(temp.usercode,'--','--',temp.Barcode)) BarCode, " +
  5498. "decode(temp.UserCode,'小计','--',temp.UserCode) UserCode, " +
  5499. "decode(GOODSSPECIFICATION,'小计','--',GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  5500. "decode(DICTIONARYVALUE,'小计','--',Dictionaryvalue) Dictionaryvalue, " +
  5501. "产量, " +
  5502. "replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName " +
  5503. "from " +
  5504. "( " +
  5505. " select " +
  5506. " decode(grouping(TP_MST_Organization.OrganizationName),1,'总计',TP_MST_Organization.OrganizationName) OrganizationName, " +
  5507. " decode(grouping(TP_MST_Organization.OrganizationName),1,'--', " +
  5508. " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'合计',TP_PM_ProductionData.ProductionLineName)) ProductionLineName, " +
  5509. " decode(grouping(TP_PM_ProductionData.ProcedureName),1,'--',TP_PM_ProductionData.ProcedureName) ProcedureName, " +
  5510. " decode(grouping(TP_MST_GOODSTYPE.GoodsTypeName),1,'--',TP_MST_GOODSTYPE.GoodsTypeName) GoodsTypeName, " +
  5511. " decode(grouping(TP_PM_ProductionData.GoodsCode),1,'--',TP_PM_ProductionData.GoodsCode) GoodsCode, " +
  5512. " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'--', " +
  5513. " decode(grouping(TP_PM_ProductionData.BarCode),1,'小计',TP_PM_ProductionData.BarCode)) BarCode, " +
  5514. " decode(grouping(TP_PM_ProductionData.UserCode),1,'--',TP_PM_ProductionData.UserCode) UserCode, " +
  5515. " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  5516. " decode(grouping(TP_MST_DATADICTIONARY.Dictionaryvalue),1,'--',TP_MST_DATADICTIONARY.Dictionaryvalue) Dictionaryvalue, " +
  5517. " count(BarCode) as 产量 " +
  5518. " from TP_PM_ProductionData " +
  5519. " left join TP_MST_Goods on TP_MST_Goods.GoodsID=TP_PM_ProductionData.GoodsID " +
  5520. " left join TP_MST_GoodsType on TP_MST_GoodsType.GoodsTypeID=TP_MST_Goods.GoodsTypeID " +
  5521. " left join TP_MST_Organization on TP_MST_Organization.OrganizationID=TP_PM_ProductionData.OrganizationID " +
  5522. " left join TP_MST_DATADICTIONARY on TP_MST_DATADICTIONARY.DICTIONARYID=TP_MST_Goods.GLAZETYPEID " +
  5523. " Where 1=1 " +
  5524. " and TP_PM_ProductionData.ValueFlag = 1 " +
  5525. // 公坯、干补不算交坯工序的质量。
  5526. " 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" +
  5527. " and TP_PM_ProductionData.AccountID=:AccountID ";
  5528. if (!string.IsNullOrEmpty(se.GoodsIDS))
  5529. {
  5530. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  5531. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  5532. }
  5533. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  5534. {
  5535. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
  5536. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)>0 ";
  5537. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  5538. }
  5539. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  5540. {
  5541. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  5542. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  5543. }
  5544. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  5545. {
  5546. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_ProductionData.ProcedureId||',')>0 ";
  5547. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  5548. }
  5549. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  5550. {
  5551. selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||TP_MST_Organization.OrganizationId||',')>0 ";
  5552. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  5553. }
  5554. if (se.AccountDateStart.HasValue)
  5555. {
  5556. selSql = selSql + " AND TP_PM_ProductionData.AccountDate >= :AccountDateStart ";
  5557. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  5558. }
  5559. if (se.AccountDateEnd.HasValue)
  5560. {
  5561. selSql = selSql + " AND TP_PM_ProductionData.AccountDate <= :AccountDateEnd ";
  5562. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  5563. }
  5564. selSql = selSql +
  5565. "group by " +
  5566. " rollup(TP_MST_Organization.OrganizationName, " +
  5567. " TP_PM_ProductionData.ProductionLineName, " +
  5568. " TP_PM_ProductionData.ProcedureName, " +
  5569. " TP_MST_GOODSTYPE.GoodsTypeName, " +
  5570. " TP_PM_ProductionData.GoodsCode, " +
  5571. " TP_PM_ProductionData.BarCode, " +
  5572. " TP_PM_ProductionData.UserCode, " +
  5573. " TP_MST_Goods.GOODSSPECIFICATION, " +
  5574. " TP_MST_DATADICTIONARY.Dictionaryvalue" +
  5575. " ) " +
  5576. " order by " +
  5577. " TP_MST_Organization.OrganizationName, " +
  5578. " TP_PM_ProductionData.ProductionLineName, " +
  5579. " TP_PM_ProductionData.ProcedureName, " +
  5580. " TP_MST_GOODSTYPE.GoodsTypeName " +
  5581. ") temp inner join TP_PM_GroutingDailyDetail on temp.barcode=TP_PM_GroutingDailyDetail.barcode " +
  5582. " inner join tp_mst_logo on TP_PM_GroutingDailyDetail.logoid=tp_mst_logo.logoid " +
  5583. "where 1=1 " +
  5584. "and (temp.DICTIONARYVALUE!='--') " +
  5585. "or (temp.GoodsTypeName='--' and temp.ProductionLineName='合计') " +
  5586. "or (temp.GoodsTypeName='--' and temp.OrganizationName='总计') " +
  5587. "or (temp.BarCode='小计' and temp.GoodsCode!='--')";
  5588. */
  5589. string selSql = @"SELECT
  5590. TP_PC_GROUTINGLINE.BUILDINGNO,
  5591. TP_MST_Organization.OrganizationName,
  5592. TP_PM_ProductionData.ProductionLineName,
  5593. TP_PM_ProductionData.ProcedureName,
  5594. TP_MST_GOODSTYPE.GoodsTypeName,
  5595. TP_PM_ProductionData.GoodsCode,
  5596. TP_MST_Goods.GoodsName,
  5597. TP_MST_Goods.GoodsModel,
  5598. TP_PM_ProductionData.BarCode,
  5599. TP_PM_ProductionData.UserCode,
  5600. TP_MST_Goods.GOODSSPECIFICATION,
  5601. TP_MST_DATADICTIONARY.Dictionaryvalue,
  5602. TP_PM_ProductionData.CREATETIME,
  5603. TP_PM_ProductionData.KILNcarCODE,
  5604. TP_PM_ProductionData.KILNCODE,
  5605. cu.usercode createusercode,
  5606. cu.username CreateUserName,
  5607. gdd.glazingroom,
  5608. decode( tp_mst_logo.logoid, NULL, '', TP_MST_Logo.Logoname || '[' || TP_MST_Logo.Logocode || ']' ) AS LogoCodeName
  5609. FROM
  5610. TP_PM_ProductionData
  5611. LEFT JOIN Tp_Pm_Groutingdailydetail GP ON GP.BarCode =TP_PM_ProductionData.BarCode
  5612. LEFT JOIN TP_MST_Goods ON TP_MST_Goods.GoodsID = TP_PM_ProductionData.GoodsID
  5613. LEFT JOIN TP_MST_GoodsType ON TP_MST_GoodsType.GoodsTypeID = TP_MST_Goods.GoodsTypeID
  5614. LEFT JOIN TP_MST_Organization ON TP_MST_Organization.OrganizationID = TP_PM_ProductionData.OrganizationID
  5615. LEFT JOIN TP_MST_DATADICTIONARY ON TP_MST_DATADICTIONARY.DICTIONARYID = GP.Glazetypeid
  5616. LEFT JOIN tp_mst_user cu ON TP_PM_ProductionData.createuserid = cu.userid
  5617. LEFT JOIN TP_PM_GroutingDailyDetail gdd ON gdd.Groutingdailydetailid = TP_PM_ProductionData.Groutingdailydetailid
  5618. LEFT JOIN tp_mst_logo ON gdd.logoid = tp_mst_logo.logoid
  5619. LEFT JOIN TP_PC_GROUTINGLINE on TP_PC_GROUTINGLINE.GROUTINGLINEID=TP_PM_ProductionData.GROUTINGLINEID
  5620. WHERE TP_PM_ProductionData.ValueFlag = '1'
  5621. AND ( ( TP_PM_ProductionData.modeltype <> 5 )
  5622. OR ( TP_PM_ProductionData.modeltype = 5 AND TP_PM_ProductionData.IsPublicBody = '0' AND TP_PM_ProductionData.SpecialRepairFlag = '0' ) )
  5623. AND TP_PM_ProductionData.AccountID =:AccountID ";
  5624. if (!string.IsNullOrEmpty(se.GoodsIDS))
  5625. {
  5626. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  5627. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  5628. }
  5629. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  5630. {
  5631. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
  5632. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)>0 ";
  5633. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  5634. }
  5635. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  5636. {
  5637. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  5638. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  5639. }
  5640. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  5641. {
  5642. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_ProductionData.ProcedureId||',')>0 ";
  5643. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  5644. }
  5645. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  5646. {
  5647. selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||TP_MST_Organization.OrganizationId||',')>0 ";
  5648. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  5649. }
  5650. if (se.AccountDateStart.HasValue)
  5651. {
  5652. selSql = selSql + " AND TP_PM_ProductionData.CREATETIME >= :AccountDateStart ";
  5653. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  5654. }
  5655. if (se.AccountDateEnd.HasValue)
  5656. {
  5657. selSql = selSql + " AND TP_PM_ProductionData.CREATETIME <= :AccountDateEnd ";
  5658. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  5659. }
  5660. if (!string.IsNullOrEmpty(se.Building))
  5661. {
  5662. selSql = selSql + " AND TP_PC_GROUTINGLINE.BUILDINGNO = :Building";
  5663. parameters.Add(new OracleParameter(":Building", OracleDbType.NVarchar2, se.Building, ParameterDirection.Input));
  5664. }
  5665. return selSql;
  5666. }
  5667. /// <summary>
  5668. /// 取得RPT030102_1画面(产品损坯汇总表)的汇总信息查询数据
  5669. /// </summary>
  5670. /// <param name="user">登录用户信息</param>
  5671. /// <param name="se">查询条件</param>
  5672. /// <returns>查询结果</returns>
  5673. public static ServiceResultEntity GetRPT030102SData(SUserInfo user, RPT030102_SE se)
  5674. {
  5675. IDBConnection conn = null;
  5676. try
  5677. {
  5678. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  5679. List<OracleParameter> parameters = new List<OracleParameter>();
  5680. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030102SSQL(user, se, ref parameters));
  5681. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  5682. ServiceResultEntity sre = new ServiceResultEntity();
  5683. if (data == null || data.Rows.Count == 0)
  5684. {
  5685. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5686. return sre;
  5687. }
  5688. sre.Data = new DataSet();
  5689. sre.Data.Tables.Add(data);
  5690. return sre;
  5691. }
  5692. catch (Exception ex)
  5693. {
  5694. throw ex;
  5695. }
  5696. finally
  5697. {
  5698. if (conn != null &&
  5699. conn.ConnState == ConnectionState.Open)
  5700. {
  5701. conn.Close();
  5702. }
  5703. }
  5704. }
  5705. /// <summary>
  5706. /// 获取RPT030102_1画面(产品损坯汇总表)的汇总信息查询sql
  5707. /// </summary>
  5708. /// <returns>sql</returns>
  5709. private static string GetRPT030102SSQL(SUserInfo user, RPT030102_SE se, ref List<OracleParameter> parameters)
  5710. {
  5711. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  5712. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  5713. string sqlString = "SELECT decode(ts.gid,\n" +
  5714. " 7,\n" +
  5715. " '总计',\n" +
  5716. " 3,\n" +
  5717. " '合计【' || ts.zrprocedurename || '】',\n" +
  5718. " 0,\n" +
  5719. " ts.zrprocedurename,\n" +
  5720. " '--') zrprocedurename\n" +
  5721. " ,decode(ts.gid,\n" +
  5722. " 1,\n" +
  5723. " '小计【' || ts.goodstypename2 || '】',\n" +
  5724. " 0,\n" +
  5725. " ts.goodstypename2,\n" +
  5726. " '--') goodstypename2\n" +
  5727. " ,decode(ts.gid, 0, ts.zrusercode, '--') zrusercode\n" +
  5728. " ,decode(ts.gid, 0, ts.goodscode, '--') goodscode\n" +
  5729. " ,decode(ts.gid, 0, ts.GOODSMODEL, '--') GOODSMODEL\n" +
  5730. " ,ts.productionlineid\n" +
  5731. " ,ts.zrprocedureid\n" +
  5732. " ,ts.goodstypecode2\n" +
  5733. " ,ts.zruserid\n" +
  5734. " ,ts.goodsid\n" +
  5735. " ,ts.barcount\n" +
  5736. " FROM (SELECT grouping_id(t.zrprocedureid, t.goodstypecode2, t.zruserid) gid\n" +
  5737. " ,t.productionlineid\n" +
  5738. " ,t.productionlinename\n" +
  5739. " ,t.displayno\n" +
  5740. " ,t.zrprocedureid\n" +
  5741. " ,t.zrprocedurename\n" +
  5742. " ,t.goodstypecode2\n" +
  5743. " ,t.goodstypename2\n" +
  5744. " ,t.zruserid\n" +
  5745. " ,t.zrusercode\n" +
  5746. " ,t.goodsid\n" +
  5747. " ,t.goodscode\n" +
  5748. " ,t.GOODSMODEL\n" +
  5749. " ,COUNT(t.barcode) barcount\n" +
  5750. " FROM (SELECT sp.productionlineid\n" +
  5751. " ,pline.productionlinename\n" +
  5752. " ,nvl(zp.displayno, -1) displayno\n" +
  5753. " ,zp.procedureid zrprocedureid\n" +
  5754. " ,zp.procedurename zrprocedurename\n" +
  5755. " ,sr.userid zruserid\n" +
  5756. " ,sr.usercode zrusercode\n" +
  5757. " ,gt2.goodstypecode goodstypecode2\n" +
  5758. " ,gt2.goodstypename goodstypename2\n" +
  5759. " ,g.goodsid\n" +
  5760. " ,g.goodscode\n" +
  5761. " ,g.GOODSMODEL\n" +
  5762. " ,sp.barcode\n" +
  5763. " FROM tp_pm_scrapproduct sp\n" +
  5764. " LEFT JOIN TP_PM_ResponProcedure rp\n" +
  5765. " ON rp.scrapproductid = sp.scrapproductid\n" +
  5766. " LEFT JOIN (SELECT DISTINCT t.ScrapProductID\n" +
  5767. " ,t.ResponProcedureID\n" +
  5768. " ,t.userid\n" +
  5769. " ,t.usercode\n" +
  5770. " FROM TP_PM_ScrapResponsible t) sr\n" +
  5771. " ON sr.scrapproductid = sp.scrapproductid\n" +
  5772. // wangx 2016-06-20
  5773. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  5774. " ON rp.barcode = gdd.barcode\n" +
  5775. // wangx 2016-06-20 end
  5776. " LEFT JOIN tp_pc_productionline pline\n" +
  5777. " ON pline.productionlineid = sp.productionlineid\n" +
  5778. " LEFT JOIN tp_pc_procedure zp\n" +
  5779. " ON zp.procedureid = rp.procedureid\n" +
  5780. " LEFT JOIN tp_mst_user cu\n" +
  5781. " ON cu.userid = sp.createuserid\n" +
  5782. " LEFT JOIN tp_mst_user au\n" +
  5783. " ON au.userid = sp.auditor\n" +
  5784. " LEFT JOIN tp_mst_goods g\n" +
  5785. " ON g.goodsid = sp.goodsid\n" +
  5786. " LEFT JOIN tp_mst_goodstype gt\n" +
  5787. " ON gt.goodstypeid = g.goodstypeid\n" +
  5788. " LEFT JOIN tp_mst_goodstype gt2\n" +
  5789. " ON gt2.accountid = gt.accountid\n" +
  5790. " AND gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  5791. " WHERE sp.valueflag = '1'\n" +
  5792. " AND sp.AuditStatus = '1'\n" +
  5793. // 生产线
  5794. //" 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))" +
  5795. // 完成工序
  5796. //" 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))" +
  5797. // 责任工序
  5798. //" 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)))" +
  5799. " AND sp.accountid = :AccountID\n" +
  5800. (se.SpecialRepairFlag ? " AND sp.GoodsLevelTypeID in (8,9) -- 8损坯、9干补\n" : " AND sp.GoodsLevelTypeID = 8 -- 8损坯、9干补\n") +
  5801. (se.ReFireFlag ? " " : " AND sp.IsReFire <> '6'\n") +
  5802. " AND sp.ScrapType = '0'\n" +
  5803. " AND (:ProductionLineID IS NULL OR\n" +
  5804. " sp.ProductionLineID = :ProductionLineID)\n" +
  5805. " AND (:GoodsTypeCode IS NULL OR\n" +
  5806. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  5807. " AND (:GoodsCode IS NULL OR\n" +
  5808. " instr(g.GoodsCode, :GoodsCode) > 0)\n" +
  5809. " AND (:ProcedureIDS IS NULL OR\n" +
  5810. " instr(:ProcedureIDS, ',' || sp.ProcedureID || ',') > 0)\n" +
  5811. " AND (:ResponProcedureIDS IS NULL OR\n" +
  5812. " instr(:ResponProcedureIDS,\n" +
  5813. " ',' || rp.ProcedureID || ',') > 0)\n" +
  5814. " AND (:ResponUserIDS IS NULL OR\n" +
  5815. " instr(:ResponUserIDS, ',' || sr.userid || ',') > 0)\n" +
  5816. // 损坯时间
  5817. " AND (:ScrapDateStart IS NULL OR\n" +
  5818. " sp.CreateTime >= :ScrapDateStart)\n" +
  5819. " AND (:ScrapDateEnd IS NULL OR\n" +
  5820. " sp.CreateTime <= :ScrapDateEnd)\n" +
  5821. // 审核时间
  5822. " AND (:AuditDateStart IS NULL OR\n" +
  5823. " sp.AuditDate >= :AuditDateStart)\n" +
  5824. " AND (:AuditDateEnd IS NULL OR\n" +
  5825. " sp.AuditDate <= :AuditDateEnd)\n" +
  5826. // 完成时间
  5827. " AND (:CTimeStart IS NULL OR\n" +
  5828. " sp.CreateTime >= :CTimeStart)\n" +
  5829. " AND (:CTimeEnd IS NULL OR\n" +
  5830. " sp.CreateTime <= :CTimeEnd)\n" +
  5831. // 交坯时间
  5832. " AND (:DTimeStart IS NULL OR\n" +
  5833. " gdd.DeliverTime >= :DTimeStart)\n" +
  5834. " AND (:DTimeEnd IS NULL OR\n" +
  5835. " gdd.DeliverTime <= :DTimeEnd)\n" +
  5836. // 注浆时间
  5837. " AND (:GTimeStart IS NULL OR\n" +
  5838. " gdd.GroutingDate >= :GTimeStart)\n" +
  5839. " AND (:GTimeEnd IS NULL OR\n" +
  5840. " gdd.GroutingDate <= :GTimeEnd)\n" +
  5841. " AND (:CreatUser IS NULL OR\n" +
  5842. " instr(cu.UserCode, :CreatUser) > 0)\n" +
  5843. " AND (:AuditUser IS NULL OR\n" +
  5844. " instr(au.UserCode, :AuditUser) > 0)) t\n" +
  5845. " 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" +
  5846. " ORDER BY t.displayno, t.goodstypecode2, t.zrusercode, t.goodscode) ts";
  5847. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  5848. if (string.IsNullOrEmpty(se.ProcedureIDS))
  5849. {
  5850. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5851. }
  5852. else
  5853. {
  5854. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  5855. }
  5856. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  5857. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  5858. if (string.IsNullOrEmpty(se.ResponProcedureIDS))
  5859. {
  5860. parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5861. }
  5862. else
  5863. {
  5864. parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, "," + se.ResponProcedureIDS + ",", ParameterDirection.Input));
  5865. }
  5866. if (string.IsNullOrEmpty(se.ResponUserIDS))
  5867. {
  5868. parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5869. }
  5870. else
  5871. {
  5872. parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, "," + se.ResponUserIDS + ",", ParameterDirection.Input));
  5873. }
  5874. parameters.Add(new OracleParameter(":CreatUser", OracleDbType.Varchar2, se.CreatUser, ParameterDirection.Input));
  5875. parameters.Add(new OracleParameter(":AuditUser", OracleDbType.Varchar2, se.AuditUser, ParameterDirection.Input));
  5876. parameters.Add(new OracleParameter(":ScrapDateStart", OracleDbType.Date, se.ScrapDateStart, ParameterDirection.Input));
  5877. parameters.Add(new OracleParameter(":ScrapDateEnd", OracleDbType.Date, se.ScrapDateEnd, ParameterDirection.Input));
  5878. parameters.Add(new OracleParameter(":CTimeStart", OracleDbType.Date, se.CTimeStart, ParameterDirection.Input));
  5879. parameters.Add(new OracleParameter(":CTimeEnd", OracleDbType.Date, se.CTimeEnd, ParameterDirection.Input));
  5880. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart, ParameterDirection.Input));
  5881. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd, ParameterDirection.Input));
  5882. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart, ParameterDirection.Input));
  5883. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd, ParameterDirection.Input));
  5884. parameters.Add(new OracleParameter(":AuditDateStart", OracleDbType.Date, se.AuditTimeStart, ParameterDirection.Input));
  5885. parameters.Add(new OracleParameter(":AuditDateEnd", OracleDbType.Date, se.AuditTimeEnd, ParameterDirection.Input));
  5886. return sqlString;
  5887. }
  5888. /// <summary>
  5889. /// 取得RPT030102_1画面(产品损坯汇总表)的明细信息查询数据
  5890. /// </summary>
  5891. /// <param name="user">登录用户信息</param>
  5892. /// <param name="se">查询条件</param>
  5893. /// <returns>查询结果</returns>
  5894. public static ServiceResultEntity GetRPT030102IData(SUserInfo user, RPT030102_SE se)
  5895. {
  5896. IDBConnection conn = null;
  5897. try
  5898. {
  5899. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  5900. List<OracleParameter> parameters = new List<OracleParameter>();
  5901. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030102ISQL(user, se, ref parameters));
  5902. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  5903. ServiceResultEntity sre = new ServiceResultEntity();
  5904. if (data == null || data.Rows.Count == 0)
  5905. {
  5906. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5907. return sre;
  5908. }
  5909. sre.Data = new DataSet();
  5910. sre.Data.Tables.Add(data);
  5911. return sre;
  5912. }
  5913. catch (Exception ex)
  5914. {
  5915. throw ex;
  5916. }
  5917. finally
  5918. {
  5919. if (conn != null &&
  5920. conn.ConnState == ConnectionState.Open)
  5921. {
  5922. conn.Close();
  5923. }
  5924. }
  5925. }
  5926. /// <summary>
  5927. /// 获取RPT030102_1画面(产品损坯汇总表)的明细信息查询sql
  5928. /// </summary>
  5929. /// <returns>sql</returns>
  5930. private static string GetRPT030102ISQL(SUserInfo user, RPT030102_SE se, ref List<OracleParameter> parameters)
  5931. {
  5932. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  5933. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  5934. string sqlString =
  5935. "SELECT pline.productionlinename\n" +
  5936. " ,p.procedurename\n" +
  5937. " ,zp.procedurename zrprocedurename\n" +
  5938. " ,sr.usercode zrusercode\n" +
  5939. " ,sr.StaffNames zrStaffNames\n" +
  5940. " ,gt2.goodstypecode goodstypecode2\n" +
  5941. " ,gt2.goodstypename goodstypename2\n" +
  5942. " ,gt.goodstypename\n" +
  5943. " ,g.goodscode\n" +
  5944. " ,g.GOODSMODEL\n" +
  5945. " ,sp.barcode\n" +
  5946. " ,sp.createtime Scrapdate\n" +
  5947. " ,sp.Rreason\n" +
  5948. " ,sp.GroutingUserCode\n" +
  5949. " ,sp.GroutingLineCode\n" +
  5950. " ,sp.GroutingMouldCode\n" +
  5951. " ,sp.GroutingDate\n" +
  5952. " ,sp.GroutingNum\n" +
  5953. " ,cu.usercode CreateUserCode\n" +
  5954. " ,au.usercode AuditorCode\n" +
  5955. " ,sp.auditdate\n" +
  5956. " ,gdd.DeliverTime\n" +
  5957. " ,gdd.ISPUBLICBODY\n" +
  5958. " ,gdd.SPECIALREPAIRFLAG\n" +
  5959. " ,lg.logoname\n" +
  5960. " ,sp.CreateTime\n" +
  5961. " ,sp.Remarks\n" +
  5962. " FROM tp_pm_scrapproduct sp\n" +
  5963. " LEFT JOIN TP_PM_ResponProcedure rp\n" +
  5964. " ON rp.scrapproductid = sp.scrapproductid\n" +
  5965. " LEFT JOIN (SELECT DISTINCT t.ScrapProductID\n" +
  5966. " ,t.ResponProcedureID\n" +
  5967. " ,t.userid\n" +
  5968. " ,t.usercode\n" +
  5969. " ,LISTAGG(to_char(s.StaffName), ',') WITHIN GROUP(ORDER BY s.staffcode) over(partition by t.ScrapProductID) AS StaffNames\n" +
  5970. " FROM TP_PM_ScrapResponsible t\n" +
  5971. " LEFT JOIN TP_HR_Staff s \n" +
  5972. " ON s.StaffID = t.StaffID \n" +
  5973. " ) sr\n" +
  5974. " ON sr.scrapproductid = sp.scrapproductid\n" +
  5975. // wangx 2016-06-20
  5976. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  5977. " ON sp.barcode = gdd.barcode\n" +
  5978. // wangx 2016-06-20 end
  5979. " LEFT JOIN TP_mst_logo lg\n" +
  5980. " ON lg.logoid = gdd.logoid\n" +
  5981. " LEFT JOIN tp_pc_productionline pline\n" +
  5982. " ON pline.productionlineid = sp.productionlineid\n" +
  5983. " LEFT JOIN tp_pc_procedure p\n" +
  5984. " ON p.procedureid = sp.procedureid\n" +
  5985. " LEFT JOIN tp_pc_procedure zp\n" +
  5986. " ON zp.procedureid = rp.procedureid\n" +
  5987. " LEFT JOIN tp_mst_user cu\n" +
  5988. " ON cu.userid = sp.createuserid\n" +
  5989. " LEFT JOIN tp_mst_user au\n" +
  5990. " ON au.userid = sp.auditor\n" +
  5991. " LEFT JOIN tp_mst_goods g\n" +
  5992. " ON g.goodsid = sp.goodsid\n" +
  5993. " LEFT JOIN tp_mst_goodstype gt\n" +
  5994. " ON gt.goodstypeid = g.goodstypeid\n" +
  5995. " LEFT JOIN tp_mst_goodstype gt2\n" +
  5996. " ON gt2.accountid = gt.accountid\n" +
  5997. " AND gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  5998. " WHERE sp.valueflag = '1'\n" +
  5999. " AND sp.AuditStatus = '1'\n" +
  6000. " AND sp.accountid = :accountid\n" +
  6001. // 生产线
  6002. //" 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))" +
  6003. // 完成工序
  6004. //" 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))" +
  6005. // 责任工序
  6006. //" 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)))" +
  6007. //" AND sp.GoodsLevelTypeID = 8 -- 8损坯、9干补\n" +
  6008. (se.SpecialRepairFlag ? " AND sp.GoodsLevelTypeID in (8,9) -- 8损坯、9干补\n" : " AND sp.GoodsLevelTypeID = 8 -- 8损坯、9干补\n") +
  6009. (se.ReFireFlag ? " " : " AND sp.IsReFire <> '6'\n") +
  6010. " AND sp.ScrapType = '0'\n" +
  6011. " AND (:ProductionLineID IS NULL OR\n" +
  6012. " sp.ProductionLineID = :ProductionLineID)\n" +
  6013. " AND (:GoodsTypeCode IS NULL OR\n" +
  6014. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  6015. " AND (:GoodsCode IS NULL OR instr(g.GoodsCode, :GoodsCode) > 0)\n" +
  6016. " AND (:ProcedureIDS IS NULL OR\n" +
  6017. " instr(:ProcedureIDS, ',' || sp.ProcedureID || ',') > 0)\n" +
  6018. " AND (:ResponProcedureIDS IS NULL OR\n" +
  6019. " instr(:ResponProcedureIDS, ',' || rp.ProcedureID || ',') > 0)\n" +
  6020. " AND (:ResponUserIDS IS NULL OR\n" +
  6021. " instr(:ResponUserIDS, ',' || sr.userid || ',') > 0)\n" +
  6022. // 损坯时间
  6023. " AND (:ScrapDateStart IS NULL OR sp.CreateTime >= :ScrapDateStart)\n" +
  6024. " AND (:ScrapDateEnd IS NULL OR sp.CreateTime <= :ScrapDateEnd)\n" +
  6025. // 审核时间
  6026. " AND (:AuditDateStart IS NULL OR sp.AuditDate >= :AuditDateStart)\n" +
  6027. " AND (:AuditDateEnd IS NULL OR sp.AuditDate <= :AuditDateEnd)\n" +
  6028. // 完成时间
  6029. " AND (:CTimeStart IS NULL OR\n" +
  6030. " sp.CreateTime >= :CTimeStart)\n" +
  6031. " AND (:CTimeEnd IS NULL OR\n" +
  6032. " sp.CreateTime <= :CTimeEnd)\n" +
  6033. // 交坯时间
  6034. " AND (:DTimeStart IS NULL OR\n" +
  6035. " gdd.DeliverTime >= :DTimeStart)\n" +
  6036. " AND (:DTimeEnd IS NULL OR\n" +
  6037. " gdd.DeliverTime <= :DTimeEnd)\n" +
  6038. // 注浆时间
  6039. " AND (:GTimeStart IS NULL OR\n" +
  6040. " gdd.GroutingDate >= :GTimeStart)\n" +
  6041. " AND (:GTimeEnd IS NULL OR\n" +
  6042. " gdd.GroutingDate <= :GTimeEnd)\n" +
  6043. " AND (:CreatUser IS NULL OR instr(cu.UserCode, :CreatUser) > 0)\n" +
  6044. " AND (:AuditUser IS NULL OR instr(au.UserCode, :AuditUser) > 0)\n" +
  6045. " AND (:GoodsID IS NULL OR sp.goodsid = :GoodsID)\n" +
  6046. " AND (:ResponProcedureID IS NULL OR rp.procedureid = :ResponProcedureID)\n" +
  6047. " AND (:ResponUserID IS NULL OR sr.userid = :ResponUserID)\n" +
  6048. " AND (:RPF = 1 OR rp.procedureid is null)\n" +
  6049. " AND (:RUF = 1 OR sr.userid is null)\n" +
  6050. " ORDER BY pline.productionlinename, nvl(zp.displayno, -1), sp.barcode";
  6051. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  6052. if (string.IsNullOrEmpty(se.ProcedureIDS))
  6053. {
  6054. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, null, ParameterDirection.Input));
  6055. }
  6056. else
  6057. {
  6058. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  6059. }
  6060. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  6061. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  6062. if (string.IsNullOrEmpty(se.ResponProcedureIDS))
  6063. {
  6064. parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  6065. }
  6066. else
  6067. {
  6068. parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, "," + se.ResponProcedureIDS + ",", ParameterDirection.Input));
  6069. }
  6070. if (string.IsNullOrEmpty(se.ResponUserIDS))
  6071. {
  6072. parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  6073. }
  6074. else
  6075. {
  6076. parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, "," + se.ResponUserIDS + ",", ParameterDirection.Input));
  6077. }
  6078. parameters.Add(new OracleParameter(":CreatUser", OracleDbType.Varchar2, se.CreatUser, ParameterDirection.Input));
  6079. parameters.Add(new OracleParameter(":AuditUser", OracleDbType.Varchar2, se.AuditUser, ParameterDirection.Input));
  6080. parameters.Add(new OracleParameter(":ScrapDateStart", OracleDbType.Date, se.ScrapDateStart, ParameterDirection.Input));
  6081. parameters.Add(new OracleParameter(":ScrapDateEnd", OracleDbType.Date, se.ScrapDateEnd, ParameterDirection.Input));
  6082. parameters.Add(new OracleParameter(":AuditDateStart", OracleDbType.Date, se.AuditTimeStart, ParameterDirection.Input));
  6083. parameters.Add(new OracleParameter(":AuditDateEnd", OracleDbType.Date, se.AuditTimeEnd, ParameterDirection.Input));
  6084. parameters.Add(new OracleParameter(":CTimeStart", OracleDbType.Date, se.CTimeStart, ParameterDirection.Input));
  6085. parameters.Add(new OracleParameter(":CTimeEnd", OracleDbType.Date, se.CTimeEnd, ParameterDirection.Input));
  6086. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart, ParameterDirection.Input));
  6087. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd, ParameterDirection.Input));
  6088. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart, ParameterDirection.Input));
  6089. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd, ParameterDirection.Input));
  6090. parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  6091. if (se.ResponProcedureID == "")
  6092. {
  6093. parameters.Add(new OracleParameter(":RPF", OracleDbType.Int32, 0, ParameterDirection.Input));
  6094. parameters.Add(new OracleParameter(":ResponProcedureID", OracleDbType.Int32, null, ParameterDirection.Input));
  6095. }
  6096. else
  6097. {
  6098. parameters.Add(new OracleParameter(":RPF", OracleDbType.Int32, 1, ParameterDirection.Input));
  6099. parameters.Add(new OracleParameter(":ResponProcedureID", OracleDbType.Int32, se.ResponProcedureID, ParameterDirection.Input));
  6100. }
  6101. if (se.ResponUserID == "")
  6102. {
  6103. parameters.Add(new OracleParameter(":RUF", OracleDbType.Int32, 0, ParameterDirection.Input));
  6104. parameters.Add(new OracleParameter(":ResponUserID", OracleDbType.Int32, null, ParameterDirection.Input));
  6105. }
  6106. else
  6107. {
  6108. parameters.Add(new OracleParameter(":RUF", OracleDbType.Int32, 1, ParameterDirection.Input));
  6109. parameters.Add(new OracleParameter(":ResponUserID", OracleDbType.Int32, se.ResponUserID, ParameterDirection.Input));
  6110. }
  6111. return sqlString;
  6112. }
  6113. /// <summary>
  6114. /// 取得RPT030103_1画面(出窑数量汇总表)的汇总信息查询数据
  6115. /// </summary>
  6116. /// <param name="user">登录用户信息</param>
  6117. /// <param name="se">查询条件</param>
  6118. /// <returns>查询结果</returns>
  6119. public static ServiceResultEntity GetRPT030103SData(SUserInfo user, RPT030103_SE se)
  6120. {
  6121. IDBConnection conn = null;
  6122. try
  6123. {
  6124. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6125. List<OracleParameter> parameters = new List<OracleParameter>();
  6126. string sql = ReportModuleLogic.GetRPT030103SSQL(user, se, ref parameters);
  6127. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  6128. ServiceResultEntity sre = new ServiceResultEntity();
  6129. if (data == null || data.Rows.Count == 0)
  6130. {
  6131. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6132. return sre;
  6133. }
  6134. sre.Data = new DataSet();
  6135. sre.Data.Tables.Add(data);
  6136. return sre;
  6137. }
  6138. catch (Exception ex)
  6139. {
  6140. throw ex;
  6141. }
  6142. finally
  6143. {
  6144. if (conn != null &&
  6145. conn.ConnState == ConnectionState.Open)
  6146. {
  6147. conn.Close();
  6148. }
  6149. }
  6150. }
  6151. /// <summary>
  6152. /// 获取RPT030103_1画面(出窑数量汇总表)的汇总信息查询sql
  6153. /// </summary>
  6154. /// <returns>sql</returns>
  6155. private static string GetRPT030103SSQL(SUserInfo user, RPT030103_SE se, ref List<OracleParameter> parameters)
  6156. {
  6157. string selSql = "";
  6158. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6159. parameters.Add(new OracleParameter(":rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  6160. selSql = selSql +
  6161. "SELECT pdata.Procedureid Procedureid " +
  6162. " ,decode(gid, 3, '合计', 1, '小计【'||pdata.Procedurename||'】', pdata.Procedurename) Procedurename " +
  6163. " ,decode(gid, 0, to_char(pdata.Userid), '--') Userid " +
  6164. " ,decode(gid, 0, pdata.Usercode, '--') Usercode " +
  6165. " ,decode(gid, 0, to_char(pdata.KilnID), '--') Kilnid " +
  6166. " ,decode(gid, 0, pdata.Kilncode, '--') Kilncode " +
  6167. " ,decode(gid, 0, pdata.goodstypename, '--') goodstypename " +
  6168. " ,decode(gid, 0, to_char(pdata.Goodsid), '--') Goodsid " +
  6169. " ,decode(gid, 0, pdata.Goodscode, '--') Goodscode " +
  6170. " ,OutKilnCount " +
  6171. " FROM (SELECT grouping_id(pdata.Procedureid, " +
  6172. " pdata.Userid ) gid " +
  6173. " ,pdata.Procedureid " +
  6174. " ,pdata.Procedurename " +
  6175. " ,pdata.Userid " +
  6176. " ,pdata.Usercode " +
  6177. " ,pdata.Kilnid " +
  6178. " ,pdata.Kilncode " +
  6179. " ,pdata.goodstypename " +
  6180. " ,pdata.Goodsid " +
  6181. " ,pdata.Goodscode " +
  6182. " ,COUNT(pdata.Barcode) AS OutKilnCount " +
  6183. " FROM (SELECT DISTINCT " +
  6184. //" decode(grouping(TP_PM_ProductionData.Procedureid),1,'--',TP_PM_ProductionData.Procedureid) Procedureid, " +
  6185. //" decode(grouping(TP_PM_ProductionData.Procedurename),1,'合计', TP_PM_ProductionData.Procedurename) Procedurename, " +
  6186. //" decode(grouping(TP_PM_ProductionData.Userid),1,'--', TP_PM_ProductionData.Userid) Userid, " +
  6187. //" decode(grouping(TP_PM_ProductionData.Usercode),1,'--', TP_PM_ProductionData.Usercode) Usercode, " +
  6188. //" decode(grouping(temp.Kilncode),1,'--', temp.KilnID) Kilnid, " +
  6189. //" decode(grouping(temp.Kilncode),1,'--', temp.Kilncode) Kilncode, " +
  6190. //" decode(grouping(tp_mst_goodstype.goodstypename),1,'--', tp_mst_goodstype.goodstypename) goodstypename, " +
  6191. //" decode(grouping(TP_PM_ProductionData.Goodsid),1,'--', TP_PM_ProductionData.Goodsid) Goodsid, " +
  6192. //" decode(grouping(TP_PM_ProductionData.Goodscode),1,'--', TP_PM_ProductionData.Goodscode) Goodscode, " +
  6193. "TP_PM_ProductionData.Procedureid,pcp.Procedurename, " +
  6194. //"TP_PM_ProductionData.Userid,TP_PM_ProductionData.Usercode, " +
  6195. (se.DisPUserCode ? " TP_PM_ProductionData.userid, TP_PM_ProductionData.usercode, \n" : " null userid, null usercode, \n") +
  6196. "temp.Kilnid,temp.Kilncode,tp_mst_goodstype.goodstypename, " +
  6197. "TP_PM_ProductionData.Goodsid,TP_PM_ProductionData.Goodscode, TP_PM_ProductionData.barcode " +
  6198. " from TP_PM_ProductionData " +
  6199. " inner join tp_mst_goods on tp_mst_goods.goodsid=TP_PM_ProductionData.Goodsid " +
  6200. " inner join tp_mst_goodstype on tp_mst_goodstype.goodstypeid=tp_mst_goods.goodstypeid " +
  6201. " inner join TP_MST_RptTProcedure on TP_MST_RptTProcedure.Procedureid=TP_PM_ProductionData.Procedureid " +
  6202. " inner join TP_MST_RptProcedure on TP_MST_RptProcedure.Rptprocedureid=TP_MST_RptTProcedure.Rptprocedureid " +
  6203. " inner join tp_pc_procedure pcp on pcp.procedureid=TP_PM_ProductionData.Procedureid " +
  6204. " inner join " +
  6205. " ( " +
  6206. " 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 " +
  6207. " from TP_PM_ProductionData " +
  6208. " inner join TP_MST_RptSProcedure on TP_MST_RptSProcedure.Procedureid=TP_PM_ProductionData.Procedureid ";
  6209. if (se.DTimeStart.HasValue || se.DTimeEnd.HasValue)
  6210. {
  6211. selSql += " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=TP_PM_ProductionData.groutingdailydetailid ";
  6212. }
  6213. selSql +=
  6214. " where TP_PM_ProductionData.Accountid=:AccountID " +
  6215. " and TP_PM_ProductionData.Valueflag='1' " +
  6216. // 数据重复 modify by chenxy begin
  6217. // " and TP_MST_RptSProcedure.Rptprocedureid=:rptProcedureId " +
  6218. // 数据重复 modify by chenxy end
  6219. " and TP_MST_RptSProcedure.Procedureid=:rptSprocedureId ";
  6220. //if (se.CreateTimeStart.HasValue)
  6221. //{
  6222. // selSql = selSql + " AND TP_PM_ProductionData.CreateTime >= :CreateTimeStart ";
  6223. // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6224. //}
  6225. //if (se.CreateTimeEnd.HasValue)
  6226. //{
  6227. // selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :CreateTimeEnd ";
  6228. // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6229. //}
  6230. if (se.OutTimeStart.HasValue)
  6231. {
  6232. selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:OutTimeStart ";
  6233. parameters.Add(new OracleParameter(":OutTimeStart", OracleDbType.Date, se.OutTimeStart.Value, ParameterDirection.Input));
  6234. }
  6235. if (se.OutTimeEnd.HasValue)
  6236. {
  6237. selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :OutTimeEnd ";
  6238. parameters.Add(new OracleParameter(":OutTimeEnd", OracleDbType.Date, se.OutTimeEnd.Value, ParameterDirection.Input));
  6239. }
  6240. if (se.GTimeStart.HasValue)
  6241. {
  6242. selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE >=:GTimeStart ";
  6243. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  6244. }
  6245. if (se.GTimeEnd.HasValue)
  6246. {
  6247. selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE <= :GTimeEnd ";
  6248. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  6249. }
  6250. if (se.DTimeStart.HasValue)
  6251. {
  6252. selSql = selSql + " AND gdd.DELIVERTIME >=:DTimeStart ";
  6253. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
  6254. }
  6255. if (se.DTimeEnd.HasValue)
  6256. {
  6257. selSql = selSql + " AND gdd.DELIVERTIME <= :DTimeEnd ";
  6258. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
  6259. }
  6260. if (se.Specialrepairflag)
  6261. {
  6262. selSql = selSql +
  6263. " ) temp " +
  6264. " on TP_PM_ProductionData.Barcode=temp.barcode " +
  6265. " " +
  6266. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
  6267. " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
  6268. " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
  6269. " FROM TP_PM_ProductionData pp\n" +
  6270. " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
  6271. " AND pp.createtime < temp.createtime\n" +
  6272. " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
  6273. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
  6274. " where " +
  6275. // 公坯、干补不算交坯工序的质量。
  6276. // " 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" +
  6277. // modify wangx 2015-12-3
  6278. " ((TP_PM_ProductionData.modeltype <> 5) or (TP_PM_ProductionData.modeltype = 5 and TP_PM_ProductionData.SpecialRepairFlag = '0')) \n" +
  6279. " and TP_PM_ProductionData.Valueflag='1' " +
  6280. " and TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId ";
  6281. parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  6282. }
  6283. else
  6284. {
  6285. selSql = selSql +
  6286. " ) temp " +
  6287. " on TP_PM_ProductionData.Barcode=temp.barcode " +
  6288. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
  6289. " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
  6290. " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
  6291. " FROM TP_PM_ProductionData pp\n" +
  6292. " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
  6293. " AND pp.createtime < temp.createtime\n" +
  6294. " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
  6295. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
  6296. " where TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId " +
  6297. " and TP_PM_ProductionData.Valueflag='1' ";
  6298. parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  6299. }
  6300. if (se.CreateTimeStart.HasValue)
  6301. {
  6302. selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:CreateTimeStart ";
  6303. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6304. }
  6305. if (se.CreateTimeEnd.HasValue)
  6306. {
  6307. selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :CreateTimeEnd ";
  6308. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6309. }
  6310. if (!string.IsNullOrEmpty(se.GoodsIDS))
  6311. {
  6312. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  6313. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  6314. }
  6315. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  6316. {
  6317. // selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1 ";
  6318. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1 ";
  6319. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  6320. }
  6321. if (se.ProductionLineID.HasValue)
  6322. {
  6323. selSql = selSql + " AND instr(','||:productionLineId||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  6324. parameters.Add(new OracleParameter(":productionLineId", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  6325. }
  6326. //else
  6327. //{
  6328. // selSql = selSql + " AND TP_PM_ProductionData.ProductionLineId in(Select PurviewID from TP_MST_UserPurview where PurviewType= 7 and UserID = :UserID) ";
  6329. //}
  6330. 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))";
  6331. 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))";
  6332. parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  6333. if (!string.IsNullOrEmpty(se.RptTProcedureIDS))
  6334. {
  6335. selSql = selSql + " AND instr(','||:rptTprocedureId||',',','||TP_MST_RptTProcedure.ProcedureId||',')>0 ";
  6336. parameters.Add(new OracleParameter(":rptTprocedureId", OracleDbType.NVarchar2, se.RptTProcedureIDS, ParameterDirection.Input));
  6337. }
  6338. if (!string.IsNullOrEmpty(se.UserIDS))
  6339. {
  6340. selSql = selSql + " AND instr(','||:userIDS||',',','||TP_PM_ProductionData.Userid||',')>0 ";
  6341. parameters.Add(new OracleParameter(":userIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6342. }
  6343. if (se.KilnID.HasValue)
  6344. {
  6345. selSql = selSql + " AND temp.KilnID=:KilnID ";
  6346. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6347. }
  6348. if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
  6349. {
  6350. selSql = selSql + " AND instr(TP_PM_ProductionData.GroutingUserCode, :GroutingUserCode) > 0";
  6351. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  6352. }
  6353. selSql = selSql + " order by pcp.displayno, TP_PM_ProductionData.Usercode, temp.Kilncode,tp_mst_goodstype.goodstypename,TP_PM_ProductionData.Goodscode ) pdata" +
  6354. " 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),()) " +
  6355. ") pdata"
  6356. ;
  6357. return selSql;
  6358. }
  6359. /// <summary>
  6360. /// 取得RPT030103_1画面(出窑数量汇总表)的明细信息查询数据
  6361. /// </summary>
  6362. /// <param name="user">登录用户信息</param>
  6363. /// <param name="se">查询条件</param>
  6364. /// <returns>查询结果</returns>
  6365. public static ServiceResultEntity GetRPT030103IData(SUserInfo user, RPT030103_SE se)
  6366. {
  6367. IDBConnection conn = null;
  6368. try
  6369. {
  6370. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6371. List<OracleParameter> parameters = new List<OracleParameter>();
  6372. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030103ISQL(user, se, ref parameters));
  6373. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  6374. ServiceResultEntity sre = new ServiceResultEntity();
  6375. if (data == null || data.Rows.Count == 0)
  6376. {
  6377. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6378. return sre;
  6379. }
  6380. sre.Data = new DataSet();
  6381. sre.Data.Tables.Add(data);
  6382. return sre;
  6383. }
  6384. catch (Exception ex)
  6385. {
  6386. throw ex;
  6387. }
  6388. finally
  6389. {
  6390. if (conn != null &&
  6391. conn.ConnState == ConnectionState.Open)
  6392. {
  6393. conn.Close();
  6394. }
  6395. }
  6396. }
  6397. /// <summary>
  6398. /// 获取RPT030103_1画面(出窑数量汇总表)的明细信息查询sql
  6399. /// </summary>
  6400. /// <returns>sql</returns>
  6401. private static string GetRPT030103ISQL(SUserInfo user, RPT030103_SE se, ref List<OracleParameter> parameters)
  6402. {
  6403. string selSql = "";
  6404. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6405. parameters.Add(new OracleParameter(":rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  6406. selSql = selSql +
  6407. "select distinct " +
  6408. "TP_PM_ProductionData.Barcode, " +
  6409. //"TP_PM_ProductionData.UserCode, " +
  6410. (se.DisPUserCode ? " TP_PM_ProductionData.userid, TP_PM_ProductionData.usercode, cu.usercode Cusercode, \n" : " null userid, null usercode, null Cusercode, \n") +
  6411. "pcp.ProcedureName, " +
  6412. "tp_mst_goodstype.goodstypename, " +
  6413. "TP_PM_ProductionData.Goodscode, " +
  6414. "TP_PM_ProductionData.GroutingUserCode, " +
  6415. "TP_PM_ProductionData.GroutingLineCode, " +
  6416. "TP_PM_ProductionData.GroutingMouldCode, " +
  6417. // 多次干补 重复条码
  6418. //"TP_PM_ProductionData.Createtime OverDate, " +
  6419. "temp.Kilnid, " +
  6420. "temp.Kilncode, " +
  6421. "temp.Kilncarcode, " +
  6422. "temp.Createtime, " +
  6423. "temp.DELIVERTIME DDate, " +
  6424. "temp.GROUTINGDATE GDate, " +
  6425. "replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName " +
  6426. "from TP_PM_ProductionData " +
  6427. "inner join tp_mst_goods on tp_mst_goods.goodsid=TP_PM_ProductionData.Goodsid " +
  6428. "inner join tp_mst_goodstype on tp_mst_goodstype.goodstypeid=tp_mst_goods.goodstypeid " +
  6429. "inner join TP_MST_RptTProcedure on TP_MST_RptTProcedure.Procedureid=TP_PM_ProductionData.Procedureid " +
  6430. "inner join TP_MST_RptProcedure on TP_MST_RptProcedure.Rptprocedureid=TP_MST_RptTProcedure.Rptprocedureid " +
  6431. " inner join tp_pc_procedure pcp on pcp.procedureid=TP_PM_ProductionData.Procedureid " +
  6432. "left join TP_MST_logo on TP_PM_ProductionData.logoid=TP_MST_logo.logoid " +
  6433. "left join TP_MST_User cu on TP_PM_ProductionData.createuserid=cu.userid " +
  6434. "inner join " +
  6435. "( " +
  6436. " select " +
  6437. " TP_PM_ProductionData.Barcode, " +
  6438. " TP_PM_ProductionData.Kilncode, " +
  6439. " TP_PM_ProductionData.Kilncarcode, " +
  6440. " TP_PM_ProductionData.Createtime, " +
  6441. " TP_PM_ProductionData.KilnID " +
  6442. " ,gdd.DELIVERTIME " +
  6443. " ,TP_PM_ProductionData.GROUTINGDATE " +
  6444. " ,TP_PM_ProductionData.KilnCarID " +
  6445. " from TP_PM_ProductionData " +
  6446. " inner join TP_MST_RptSProcedure on TP_MST_RptSProcedure.Procedureid=TP_PM_ProductionData.Procedureid " +
  6447. //if (se.DTimeStart.HasValue || se.DTimeEnd.HasValue)
  6448. //{
  6449. // selSql += " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=TP_PM_ProductionData.groutingdailydetailid ";
  6450. //}
  6451. " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=TP_PM_ProductionData.groutingdailydetailid " +
  6452. // selSql +=
  6453. " where TP_PM_ProductionData.Accountid=:AccountID " +
  6454. " and TP_PM_ProductionData.Valueflag='1' " +
  6455. // 数据重复 modify by chenxy begin
  6456. " and TP_MST_RptSProcedure.Rptprocedureid=:rptProcedureId " +
  6457. // 数据重复 modify by chenxy end
  6458. " and TP_MST_RptSProcedure.Procedureid=:rptSprocedureId ";
  6459. if (se.OutTimeStart.HasValue)
  6460. {
  6461. selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:OutTimeStart ";
  6462. parameters.Add(new OracleParameter(":OutTimeStart", OracleDbType.Date, se.OutTimeStart.Value, ParameterDirection.Input));
  6463. }
  6464. if (se.OutTimeEnd.HasValue)
  6465. {
  6466. selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :OutTimeEnd ";
  6467. parameters.Add(new OracleParameter(":OutTimeEnd", OracleDbType.Date, se.OutTimeEnd.Value, ParameterDirection.Input));
  6468. }
  6469. if (se.GTimeStart.HasValue)
  6470. {
  6471. selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE >=:GTimeStart ";
  6472. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  6473. }
  6474. if (se.GTimeEnd.HasValue)
  6475. {
  6476. selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE <= :GTimeEnd ";
  6477. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  6478. }
  6479. if (se.DTimeStart.HasValue)
  6480. {
  6481. selSql = selSql + " AND gdd.DELIVERTIME >=:DTimeStart ";
  6482. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
  6483. }
  6484. if (se.DTimeEnd.HasValue)
  6485. {
  6486. selSql = selSql + " AND gdd.DELIVERTIME <= :DTimeEnd ";
  6487. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
  6488. }
  6489. if (se.Specialrepairflag)
  6490. {
  6491. selSql = selSql +
  6492. ") temp " +
  6493. "on TP_PM_ProductionData.Barcode=temp.barcode " +
  6494. " " +
  6495. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
  6496. " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
  6497. " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
  6498. " FROM TP_PM_ProductionData pp\n" +
  6499. " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
  6500. " AND pp.createtime < temp.createtime\n" +
  6501. " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
  6502. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
  6503. "where " + // 公坯、干补不算交坯工序的质量。
  6504. //" 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" +
  6505. // modify wangx 2015-12-3
  6506. " ((TP_PM_ProductionData.modeltype <> 5) or (TP_PM_ProductionData.modeltype = 5 and TP_PM_ProductionData.SpecialRepairFlag = '0')) \n" +
  6507. " and TP_PM_ProductionData.Valueflag='1' " +
  6508. " and TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId ";
  6509. parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  6510. }
  6511. else
  6512. {
  6513. selSql = selSql +
  6514. ") temp " +
  6515. "on TP_PM_ProductionData.Barcode=temp.barcode " +
  6516. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
  6517. " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
  6518. " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
  6519. " FROM TP_PM_ProductionData pp\n" +
  6520. " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
  6521. " AND pp.createtime < temp.createtime\n" +
  6522. " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
  6523. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
  6524. " where TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId " +
  6525. " and TP_PM_ProductionData.Valueflag='1' ";
  6526. parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  6527. }
  6528. if (se.CreateTimeStart.HasValue)
  6529. {
  6530. selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:CreateTimeStart ";
  6531. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6532. }
  6533. if (se.CreateTimeEnd.HasValue)
  6534. {
  6535. selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :CreateTimeEnd ";
  6536. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6537. }
  6538. if (!string.IsNullOrEmpty(se.GoodsIDS))
  6539. {
  6540. selSql = selSql + " AND instr(',' || :GoodsIDS ||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  6541. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  6542. }
  6543. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  6544. {
  6545. //selSql = selSql + " AND instr(',' || :GoodsTypeIDS ||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1 ";
  6546. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1 ";
  6547. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  6548. }
  6549. if (se.ProductionLineID.HasValue)
  6550. {
  6551. selSql = selSql + " AND instr(',' || :productionLineId ||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  6552. parameters.Add(new OracleParameter(":productionLineId", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  6553. }
  6554. if (!string.IsNullOrEmpty(se.RptTProcedureIDS))
  6555. {
  6556. selSql = selSql + " AND instr(',' || :rptTprocedureIDS ||',',','||TP_MST_RptTProcedure.ProcedureId||',')>0 ";
  6557. parameters.Add(new OracleParameter(":rptTprocedureIDS", OracleDbType.NVarchar2, se.RptTProcedureIDS, ParameterDirection.Input));
  6558. }
  6559. if (!string.IsNullOrEmpty(se.UserIDS))
  6560. {
  6561. selSql = selSql + " AND instr(',' || :UserIDS ||',',','||TP_PM_ProductionData.Userid||',')>0 ";
  6562. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6563. }
  6564. if (se.KilnID.HasValue)
  6565. {
  6566. selSql = selSql + " AND temp.KilnID=:KilnID ";
  6567. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6568. }
  6569. if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
  6570. {
  6571. selSql = selSql + " AND instr(TP_PM_ProductionData.GroutingUserCode, :GroutingUserCode) > 0";
  6572. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  6573. }
  6574. selSql = selSql + " order by pcp.Procedurename,temp.Kilncode,temp.Kilncarcode, " +
  6575. (se.DisPUserCode ? " TP_PM_ProductionData.usercode, \n" : "") +
  6576. " TP_PM_ProductionData.Goodscode,TP_PM_ProductionData.Barcode ";
  6577. return selSql;
  6578. }
  6579. /// <summary>
  6580. /// 取得RPT030104_1画面(窑车产量汇总表)的窑炉汇总信息查询数据
  6581. /// </summary>
  6582. /// <param name="user">登录用户信息</param>
  6583. /// <param name="se">查询条件</param>
  6584. /// <returns>查询结果</returns>
  6585. public static ServiceResultEntity GetRPT030104SData(SUserInfo user, RPT030104_SE se)
  6586. {
  6587. IDBConnection conn = null;
  6588. try
  6589. {
  6590. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6591. List<OracleParameter> parameters = new List<OracleParameter>();
  6592. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030104SSQL(user, se, ref parameters));
  6593. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  6594. ServiceResultEntity sre = new ServiceResultEntity();
  6595. if (data == null || data.Rows.Count == 0)
  6596. {
  6597. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6598. return sre;
  6599. }
  6600. sre.Data = new DataSet();
  6601. sre.Data.Tables.Add(data);
  6602. return sre;
  6603. }
  6604. catch (Exception ex)
  6605. {
  6606. throw ex;
  6607. }
  6608. finally
  6609. {
  6610. if (conn != null &&
  6611. conn.ConnState == ConnectionState.Open)
  6612. {
  6613. conn.Close();
  6614. }
  6615. }
  6616. }
  6617. /// <summary>
  6618. /// 获取RPT030104_1画面(窑车产量汇总表)的窑炉汇总查询sql
  6619. /// </summary>
  6620. /// <returns>sql</returns>
  6621. private static string GetRPT030104SSQL(SUserInfo user, RPT030104_SE se, ref List<OracleParameter> parameters)
  6622. {
  6623. string selSql = "";
  6624. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6625. parameters.Add(new OracleParameter(":ProcedureModelTypeID", OracleDbType.Int32, se.ProcedureModelTypeID, ParameterDirection.Input));
  6626. selSql = "select " +
  6627. "decode(Createtime,'小计',decode(Proceduremodeltypename,'总计','总计','--'),Proceduremodeltypename) Proceduremodeltypename, " +
  6628. "decode(usercode,'合计',decode(Kilncode,'--','--','合计'),decode(createtime,'小计','--',Kilncode)) Kilncode, " +
  6629. "decode(Createtime,'小计',decode(usercode,'合计','--','小计'),Usercode) Usercode, " +
  6630. "decode(Kilncarcode,'--','--',Createtime) Createtime, " +
  6631. "Kilncarcode, " +
  6632. "Remarks, " +
  6633. "KilnCarCount " +
  6634. " from " +
  6635. " ( " +
  6636. " select " +
  6637. " decode(grouping(TP_SYS_ProcedureModelType.Proceduremodeltypename),1,'总计',TP_SYS_ProcedureModelType.Proceduremodeltypename) Proceduremodeltypename, " +
  6638. " decode(grouping(TP_MST_Kiln.Kilncode),1,'--',TP_MST_Kiln.Kilncode) Kilncode, " +
  6639. " decode(grouping(TP_PM_KilnCarData.Usercode),1,'合计',TP_PM_KilnCarData.Usercode) Usercode, " +
  6640. " decode(grouping(TP_MST_KilnCar.Kilncarcode),1,'--',TP_MST_KilnCar.Kilncarcode) Kilncarcode, " +
  6641. " decode(grouping(TP_PM_KilnCarData.Remarks),1,'--',TP_PM_KilnCarData.Remarks) Remarks, " +
  6642. " decode(grouping(TP_PM_KilnCarData.Createtime),1,'小计',TP_PM_KilnCarData.Createtime) Createtime, " +
  6643. " count(TP_PM_KilnCarData.Kilncarid) as KilnCarCount " +
  6644. " from " +
  6645. " ( " +
  6646. " select " +
  6647. " to_char(TP_PM_KilnCarData.Createtime,'yyyy-mm-dd hh24:mi') Createtime, " +
  6648. " TP_PM_KilnCarData.Modeltype, " +
  6649. " TP_PM_KilnCarData.Kilncarid, " +
  6650. " TP_PM_KilnCarData.Kilnid, " +
  6651. " TP_PM_KilnCarData.Userid, " +
  6652. " TP_PM_KilnCarData.Remarks, " +
  6653. " TP_PM_KilnCarData.Accountid, " +
  6654. " TP_PM_KilnCarData.Usercode " +
  6655. " from TP_PM_KilnCarData " +
  6656. " left join TP_MST_KilnCar kc on kc.kilncarid = TP_PM_KilnCarData.Kilncarid " +
  6657. " where TP_PM_KilnCarData.Accountid=:AccountID " +
  6658. " and TP_PM_KilnCarData.Valueflag=1 " +
  6659. " and TP_PM_KilnCarData.Modeltype=:ProcedureModelTypeID ";
  6660. if (se.KilnID.HasValue)
  6661. {
  6662. selSql = selSql + " AND TP_PM_KilnCarData.KilnID=:KilnID ";
  6663. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6664. }
  6665. //if (se.KilnCarID.HasValue)
  6666. //{
  6667. // selSql = selSql + " AND TP_PM_KilnCarData.KilnCarID=:KilnCarID";
  6668. // parameters.Add(new OracleParameter(":KilnCarID", OracleDbType.Int32, se.KilnCarID, ParameterDirection.Input));
  6669. //}
  6670. if (!string.IsNullOrEmpty(se.KilnCarCode))
  6671. {
  6672. selSql = selSql + " AND instr(kc.KilnCarCode, :KilnCarCode ) > 0";
  6673. parameters.Add(new OracleParameter(":KilnCarCode", OracleDbType.NVarchar2, se.KilnCarCode, ParameterDirection.Input));
  6674. }
  6675. if (se.KilnCarNumBegin.HasValue && se.KilnCarNumEnd.HasValue && se.KilnCarNumBegin.Value > se.KilnCarNumEnd.Value)
  6676. {
  6677. selSql = selSql + " AND (kc.KilnCarNum >= :KilnCarNumBegin or kc.KilnCarNum <= :KilnCarNumEnd)";
  6678. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6679. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6680. }
  6681. else
  6682. {
  6683. if (se.KilnCarNumBegin.HasValue)
  6684. {
  6685. selSql = selSql + " AND kc.KilnCarNum >= :KilnCarNumBegin ";
  6686. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6687. }
  6688. if (se.KilnCarNumEnd.HasValue)
  6689. {
  6690. selSql = selSql + " AND kc.KilnCarNum <= :KilnCarNumEnd ";
  6691. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6692. }
  6693. }
  6694. if (se.CreateTimeStart.HasValue)
  6695. {
  6696. selSql = selSql + " AND TP_PM_KilnCarData.CreateTime>=:CreateTimeStart ";
  6697. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6698. }
  6699. if (se.CreateTimeEnd.HasValue)
  6700. {
  6701. selSql = selSql + " AND TP_PM_KilnCarData.CreateTime<= :CreateTimeEnd";
  6702. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6703. }
  6704. selSql = selSql +
  6705. " ) TP_PM_KilnCarData " +
  6706. "inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.Proceduremodeltypeid=TP_PM_KilnCarData.Modeltype " +
  6707. "inner join TP_MST_KilnCar on TP_MST_KilnCar.Kilncarid=TP_PM_KilnCarData.Kilncarid " +
  6708. "inner join TP_MST_Kiln on TP_MST_Kiln.Kilnid=TP_PM_KilnCarData.Kilnid " +
  6709. "where 1=1";
  6710. if (!string.IsNullOrEmpty(se.UserIDS))
  6711. {
  6712. selSql = selSql + " AND instr(','||:UserIDS||',',','||TP_PM_KilnCarData.UserID||',')>0";
  6713. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6714. }
  6715. selSql = selSql + "group by rollup( " +
  6716. " TP_SYS_ProcedureModelType.Proceduremodeltypename, " +
  6717. " TP_MST_Kiln.Kilncode, " +
  6718. " TP_PM_KilnCarData.Usercode, " +
  6719. " TP_PM_KilnCarData.Createtime, " +
  6720. " TP_PM_KilnCarData.Remarks, " +
  6721. " TP_MST_KilnCar.Kilncarcode " +
  6722. " ) " +
  6723. " ) temp " +
  6724. " where (Kilncarcode !='--' ) " +
  6725. " or " +
  6726. " (Remarks='--' and Usercode='合计' and kilncode!='--') " +
  6727. " or (Remarks='--' and Proceduremodeltypename='总计') " +
  6728. " or (Remarks='--' and createtime='小计' and kilncode!='--')";
  6729. return selSql;
  6730. }
  6731. /// <summary>
  6732. /// 取得RPT030104_1画面(窑车产量汇总表)的窑车产量汇总信息查询数据
  6733. /// </summary>
  6734. /// <param name="user">登录用户信息</param>
  6735. /// <param name="se">查询条件</param>
  6736. /// <returns>查询结果</returns>
  6737. public static ServiceResultEntity GetRPT030104IData(SUserInfo user, RPT030104_SE se)
  6738. {
  6739. IDBConnection conn = null;
  6740. try
  6741. {
  6742. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6743. List<OracleParameter> parameters = new List<OracleParameter>();
  6744. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030104ISQL(user, se, ref parameters));
  6745. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  6746. ServiceResultEntity sre = new ServiceResultEntity();
  6747. if (data == null || data.Rows.Count == 0)
  6748. {
  6749. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6750. return sre;
  6751. }
  6752. sre.Data = new DataSet();
  6753. sre.Data.Tables.Add(data);
  6754. return sre;
  6755. }
  6756. catch (Exception ex)
  6757. {
  6758. throw ex;
  6759. }
  6760. finally
  6761. {
  6762. if (conn != null &&
  6763. conn.ConnState == ConnectionState.Open)
  6764. {
  6765. conn.Close();
  6766. }
  6767. }
  6768. }
  6769. /// <summary>
  6770. /// 获取查询sql
  6771. /// </summary>
  6772. /// <returns>sql</returns>
  6773. private static string GetRPT030104ISQL(SUserInfo user, RPT030104_SE se, ref List<OracleParameter> parameters)
  6774. {
  6775. string selSql = "";
  6776. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6777. parameters.Add(new OracleParameter(":ProcedureModelTypeID", OracleDbType.Int32, se.ProcedureModelTypeID, ParameterDirection.Input));
  6778. selSql = selSql +
  6779. "SELECT " +
  6780. "decode(createtime,'小计',decode(proceduremodeltypename,'总计','总计','--'),proceduremodeltypename) proceduremodeltypename, " +
  6781. "decode(createtime,'小计','--',kilncode) kilncode, " +
  6782. "decode(kilncarcode,'合计',decode(usercode,'--','--','合计'),decode(createtime,'小计','--',usercode)) usercode, " +
  6783. "decode(createtime,'小计',decode(kilncarcode,'合计','--','小计'),kilncarcode) kilncarcode, " +
  6784. "decode(goodscode,'--','--',createtime) createtime, " +
  6785. "GOODSTYPENAME, " +
  6786. "Goodscode, " +
  6787. "GOODSSPECIFICATION, " +
  6788. "GoodsCount " +
  6789. "from " +
  6790. "( " +
  6791. " SELECT " +
  6792. " decode(grouping(TP_SYS_ProcedureModelType.Proceduremodeltypename),1,'总计',TP_SYS_ProcedureModelType.Proceduremodeltypename) Proceduremodeltypename, " +
  6793. " decode(grouping(TP_PM_ProductionData.Kilncode),1,'--',TP_PM_ProductionData.Kilncode) Kilncode, " +
  6794. " decode(grouping(TP_PM_ProductionData.Usercode),1,'--',TP_PM_ProductionData.Usercode) Usercode, " +
  6795. " decode(grouping(TP_MST_KilnCar.Kilncarcode),1,'合计',TP_MST_KilnCar.Kilncarcode) Kilncarcode, " +
  6796. " decode(grouping(TP_PM_ProductionData.CreateTime),1,'小计',TP_PM_ProductionData.CreateTime) CreateTime, " +
  6797. " decode(grouping(TP_MST_Goods.Goodscode),1,'--',TP_MST_Goods.Goodscode) Goodscode, " +
  6798. " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  6799. " decode(grouping(TP_MST_GOODSTYPE.GOODSTYPENAME),1,'--',TP_MST_GOODSTYPE.GOODSTYPENAME) GOODSTYPENAME, " +
  6800. " count(TP_MST_Goods.Goodscode) as GoodsCount " +
  6801. " from " +
  6802. " ( " +
  6803. " SELECT TP_PM_ProductionData.Modeltype, " +
  6804. " TP_PM_ProductionData.Goodsid, " +
  6805. " TP_PM_ProductionData.KilnCarID, " +
  6806. " TP_PM_ProductionData.Kilncode, " +
  6807. //" TP_PM_ProductionData.Usercode, " +
  6808. " kcd.Usercode, " +
  6809. " to_char(kcd.CreateTime,'yyyy-mm-dd hh24:mi') CreateTime " +
  6810. " from TP_PM_ProductionData " +
  6811. " left join TP_PM_KilnCarData kcd on kcd.KilnCarBatchNo = TP_PM_ProductionData.KilnCarBatchNo and kcd.ProcedureID = TP_PM_ProductionData.ProcedureID " +
  6812. " where " +
  6813. " TP_PM_ProductionData.Accountid=:AccountID " +
  6814. " and TP_PM_ProductionData.Valueflag=1 " +
  6815. " and TP_PM_ProductionData.Modeltype= :ProcedureModelTypeID ";
  6816. if (se.KilnID.HasValue)
  6817. {
  6818. selSql = selSql + " AND TP_PM_ProductionData.KilnID=:KilnID ";
  6819. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6820. }
  6821. //if (se.KilnCarID.HasValue)
  6822. //{
  6823. // selSql = selSql + " AND TP_PM_ProductionData.KilnCarID=:KilnCarID";
  6824. // parameters.Add(new OracleParameter(":KilnCarID", OracleDbType.Int32, se.KilnCarID, ParameterDirection.Input));
  6825. //}
  6826. if (!string.IsNullOrEmpty(se.GoodsIDS))
  6827. {
  6828. selSql = selSql + " AND instr(','||:goodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  6829. parameters.Add(new OracleParameter(":goodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  6830. }
  6831. if (!string.IsNullOrEmpty(se.UserIDS))
  6832. {
  6833. //selSql = selSql + " AND instr(','||:UserIDS||',',','||TP_PM_ProductionData.UserID||',')>0 ";
  6834. selSql = selSql + " AND instr(','||:UserIDS||',',','||kcd.UserID||',')>0 ";
  6835. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6836. }
  6837. if (se.CreateTimeStart.HasValue)
  6838. {
  6839. //selSql = selSql + " AND TP_PM_ProductionData.CreateTime>= :CreateTimeStart ";
  6840. selSql = selSql + " AND kcd.CreateTime>= :CreateTimeStart ";
  6841. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6842. }
  6843. if (se.CreateTimeEnd.HasValue)
  6844. {
  6845. //selSql = selSql + " AND TP_PM_ProductionData.CreateTime<= :CreateTimeEnd ";
  6846. selSql = selSql + " AND kcd.CreateTime<= :CreateTimeEnd ";
  6847. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6848. }
  6849. selSql = selSql +
  6850. " ) TP_PM_ProductionData " +
  6851. " inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.Proceduremodeltypeid=TP_PM_ProductionData.Modeltype " +
  6852. " inner join TP_MST_Goods on TP_MST_Goods.Goodsid=TP_PM_ProductionData.Goodsid " +
  6853. " inner join TP_MST_GOODSTYPE on TP_MST_GOODSTYPE.GOODSTYPEID=TP_MST_Goods.Goodstypeid " +
  6854. " inner join TP_MST_KilnCar on TP_MST_KilnCar.Kilncarid=TP_PM_ProductionData.KilnCarID " +
  6855. " where 1=1 ";
  6856. if (!string.IsNullOrEmpty(se.KilnCarCode))
  6857. {
  6858. selSql = selSql + " AND instr(TP_MST_KilnCar.KilnCarCode, :KilnCarCode ) > 0";
  6859. parameters.Add(new OracleParameter(":KilnCarCode", OracleDbType.NVarchar2, se.KilnCarCode, ParameterDirection.Input));
  6860. }
  6861. if (se.KilnCarNumBegin.HasValue && se.KilnCarNumEnd.HasValue && se.KilnCarNumBegin.Value > se.KilnCarNumEnd.Value)
  6862. {
  6863. selSql = selSql + " AND (TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin or TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd)";
  6864. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6865. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6866. }
  6867. else
  6868. {
  6869. if (se.KilnCarNumBegin.HasValue)
  6870. {
  6871. selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin ";
  6872. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6873. }
  6874. if (se.KilnCarNumEnd.HasValue)
  6875. {
  6876. selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd ";
  6877. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6878. }
  6879. }
  6880. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  6881. {
  6882. //selSql = selSql + " AND instr(','||:goodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1";
  6883. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:goodsTypeIDS)=1";
  6884. parameters.Add(new OracleParameter(":goodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  6885. }
  6886. selSql = selSql +
  6887. " group by rollup( " +
  6888. " TP_SYS_ProcedureModelType.Proceduremodeltypename, " +
  6889. " TP_PM_ProductionData.Kilncode, " +
  6890. " TP_PM_ProductionData.Usercode, " +
  6891. " TP_MST_KilnCar.Kilncarcode, " +
  6892. " TP_PM_ProductionData.CreateTime, " +
  6893. " TP_MST_GOODSTYPE.GOODSTYPENAME, " +
  6894. " TP_MST_Goods.GOODSSPECIFICATION, " +
  6895. " TP_MST_Goods.Goodscode " +
  6896. " ) " +
  6897. ") temp " +
  6898. "where 1=1 and " +
  6899. " (Goodscode !='--' ) or " +
  6900. " (Goodscode='--' and Usercode='合计' and kilncode!='--') or " +
  6901. " (Goodscode='--' and Proceduremodeltypename='总计') or " +
  6902. " (Goodscode='--' and createtime='小计' and usercode!='--')";
  6903. return selSql;
  6904. }
  6905. /// <summary>
  6906. /// 取得RPT030104_1画面(窑车产量汇总表)的窑车产量明细信息查询数据
  6907. /// </summary>
  6908. /// <param name="user">登录用户信息</param>
  6909. /// <param name="se">查询条件</param>
  6910. /// <returns>查询结果</returns>
  6911. public static ServiceResultEntity GetRPT030104UData(SUserInfo user, RPT030104_SE se)
  6912. {
  6913. IDBConnection conn = null;
  6914. try
  6915. {
  6916. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6917. List<OracleParameter> parameters = new List<OracleParameter>();
  6918. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030104USQL(user, se, ref parameters));
  6919. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  6920. ServiceResultEntity sre = new ServiceResultEntity();
  6921. if (data == null || data.Rows.Count == 0)
  6922. {
  6923. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6924. return sre;
  6925. }
  6926. sre.Data = new DataSet();
  6927. sre.Data.Tables.Add(data);
  6928. return sre;
  6929. }
  6930. catch (Exception ex)
  6931. {
  6932. throw ex;
  6933. }
  6934. finally
  6935. {
  6936. if (conn != null &&
  6937. conn.ConnState == ConnectionState.Open)
  6938. {
  6939. conn.Close();
  6940. }
  6941. }
  6942. }
  6943. /// <summary>
  6944. /// 获取RPT030104_1画面(窑车产量汇总表)的窑车产量明细查询sql
  6945. /// </summary>
  6946. /// <returns>sql</returns>
  6947. private static string GetRPT030104USQL(SUserInfo user, RPT030104_SE se, ref List<OracleParameter> parameters)
  6948. {
  6949. string selSql = "";
  6950. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6951. parameters.Add(new OracleParameter(":ProcedureModelTypeID", OracleDbType.Int32, se.ProcedureModelTypeID, ParameterDirection.Input));
  6952. selSql = selSql +
  6953. "select " +
  6954. "decode(createtime,'小计',decode(proceduremodeltypename,'总计','总计','--'),proceduremodeltypename) proceduremodeltypename, " +
  6955. "decode(createtime,'小计','--',kilncode) kilncode, " +
  6956. "decode(kilncarcode,'合计',decode(usercode,'--','--','合计'),decode(createtime,'小计','--',usercode)) usercode, " +
  6957. "decode(createtime,'小计',decode(kilncarcode,'合计','--','小计'),kilncarcode) kilncarcode, " +
  6958. "decode(goodscode,'--','--',createtime) createtime, " +
  6959. "GOODSTYPENAME, " +
  6960. "Goodscode, " +
  6961. "GOODSSPECIFICATION, " +
  6962. "Barcode, " +
  6963. "BarcodeCount, " +
  6964. "LogoCodeName " +
  6965. "from " +
  6966. " ( " +
  6967. " select " +
  6968. " decode(grouping(TP_SYS_ProcedureModelType.Proceduremodeltypename),1,'总计',TP_SYS_ProcedureModelType.Proceduremodeltypename) Proceduremodeltypename, " +
  6969. " decode(grouping(TP_PM_ProductionData.Kilncode),1,'--',TP_PM_ProductionData.Kilncode) Kilncode, " +
  6970. " decode(grouping(TP_PM_ProductionData.Usercode),1,'--',TP_PM_ProductionData.Usercode) Usercode, " +
  6971. " decode(grouping(TP_MST_KilnCar.Kilncarcode),1,'合计',TP_MST_KilnCar.Kilncarcode) Kilncarcode, " +
  6972. " decode(grouping(TP_PM_ProductionData.CreateTime),1,'小计',TP_PM_ProductionData.CreateTime) CreateTime, " +
  6973. " decode(grouping(TP_MST_GOODSTYPE.GOODSTYPENAME),1,'--',TP_MST_GOODSTYPE.GOODSTYPENAME) GOODSTYPENAME, " +
  6974. " decode(grouping(TP_MST_Goods.Goodscode),1,'--',TP_MST_Goods.Goodscode) Goodscode, " +
  6975. " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  6976. " decode(grouping(TP_PM_ProductionData.Barcode),1,'--',TP_PM_ProductionData.Barcode) Barcode, " +
  6977. " decode(grouping(TP_PM_ProductionData.LogoCodeName),1,'--',TP_PM_ProductionData.LogoCodeName) LogoCodeName, " +
  6978. " count(TP_PM_ProductionData.Barcode) as BarcodeCount " +
  6979. " from " +
  6980. " ( " +
  6981. " select TP_PM_ProductionData.logoid," +
  6982. " TP_PM_ProductionData.Modeltype, " +
  6983. " TP_PM_ProductionData.Goodsid, " +
  6984. " TP_PM_ProductionData.KilnCarID, " +
  6985. " TP_PM_ProductionData.Kilncode, " +
  6986. " TP_PM_ProductionData.Barcode, " +
  6987. " TP_PM_ProductionData.Usercode, " +
  6988. " replace((Logoname||'['||Logocode||']'),'[]','') as LogoCodeName, " +
  6989. " to_char(TP_PM_ProductionData.CreateTime,'yyyy-mm-dd hh24:mi') CreateTime " +
  6990. " from TP_PM_ProductionData inner join TP_MST_Logo on TP_PM_ProductionData.logoid=TP_MST_Logo.logoid" +
  6991. " left join TP_PM_KilnCarData kcd on kcd.KilnCarBatchNo = TP_PM_ProductionData.KilnCarBatchNo and kcd.ProcedureID = TP_PM_ProductionData.ProcedureID " +
  6992. " where " +
  6993. " TP_PM_ProductionData.Accountid=:AccountID " +
  6994. " and TP_PM_ProductionData.Valueflag=1 " +
  6995. " and TP_PM_ProductionData.Modeltype=:ProcedureModelTypeID ";
  6996. if (se.KilnID.HasValue)
  6997. {
  6998. selSql = selSql + " AND TP_PM_ProductionData.KilnID=:KilnID ";
  6999. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  7000. }
  7001. //if (se.KilnCarID.HasValue)
  7002. //{
  7003. // selSql = selSql + " AND TP_PM_ProductionData.KilnCarID=:KilnCarID ";
  7004. // parameters.Add(new OracleParameter(":KilnCarID", OracleDbType.Int32, se.KilnCarID, ParameterDirection.Input));
  7005. //}
  7006. if (!string.IsNullOrEmpty(se.GoodsIDS))
  7007. {
  7008. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  7009. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  7010. }
  7011. if (!string.IsNullOrEmpty(se.UserIDS))
  7012. {
  7013. selSql = selSql + " AND instr(','||:UserIDS||',',','||kcd.UserID||',')>0 ";
  7014. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  7015. }
  7016. if (se.CreateTimeStart.HasValue)
  7017. {
  7018. selSql = selSql + " AND kcd.CreateTime>= :CreateTimeStart ";
  7019. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  7020. }
  7021. if (se.CreateTimeEnd.HasValue)
  7022. {
  7023. selSql = selSql + " AND kcd.CreateTime<= :CreateTimeEnd ";
  7024. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  7025. }
  7026. selSql = selSql +
  7027. " ) TP_PM_ProductionData " +
  7028. " inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.Proceduremodeltypeid=TP_PM_ProductionData.Modeltype " +
  7029. " inner join TP_MST_Goods on TP_MST_Goods.Goodsid=TP_PM_ProductionData.Goodsid " +
  7030. " inner join TP_MST_GOODSTYPE on TP_MST_GOODSTYPE.GOODSTYPEID=TP_MST_Goods.Goodstypeid " +
  7031. " inner join TP_MST_KilnCar on TP_MST_KilnCar.Kilncarid=TP_PM_ProductionData.KilnCarID " +
  7032. " where 1=1";
  7033. if (!string.IsNullOrEmpty(se.KilnCarCode))
  7034. {
  7035. selSql = selSql + " AND instr(TP_MST_KilnCar.KilnCarCode, :KilnCarCode ) > 0";
  7036. parameters.Add(new OracleParameter(":KilnCarCode", OracleDbType.NVarchar2, se.KilnCarCode, ParameterDirection.Input));
  7037. }
  7038. if (se.KilnCarNumBegin.HasValue && se.KilnCarNumEnd.HasValue && se.KilnCarNumBegin.Value > se.KilnCarNumEnd.Value)
  7039. {
  7040. selSql = selSql + " AND (TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin or TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd)";
  7041. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  7042. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  7043. }
  7044. else
  7045. {
  7046. if (se.KilnCarNumBegin.HasValue)
  7047. {
  7048. selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin ";
  7049. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  7050. }
  7051. if (se.KilnCarNumEnd.HasValue)
  7052. {
  7053. selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd ";
  7054. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  7055. }
  7056. }
  7057. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  7058. {
  7059. //selSql = selSql + " AND instr(','||:goodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1 ";
  7060. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:goodsTypeIDS)=1 ";
  7061. parameters.Add(new OracleParameter(":goodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  7062. }
  7063. selSql = selSql +
  7064. " group by rollup( " +
  7065. " TP_SYS_ProcedureModelType.Proceduremodeltypename, " +
  7066. " TP_PM_ProductionData.Kilncode, " +
  7067. " TP_PM_ProductionData.Usercode, " +
  7068. " TP_MST_KilnCar.Kilncarcode, " +
  7069. " TP_PM_ProductionData.CreateTime, " +
  7070. " TP_MST_GOODSTYPE.GOODSTYPENAME, " +
  7071. " TP_MST_Goods.Goodscode, " +
  7072. " TP_MST_Goods.GOODSSPECIFICATION, " +
  7073. " TP_PM_ProductionData.Barcode, " +
  7074. " TP_PM_ProductionData.LogoCodeName " +
  7075. " ) " +
  7076. " ) temp " +
  7077. "where 1=1 and " +
  7078. "(Barcode !='--' and LogoCodeName!='--') or " +
  7079. "(Barcode='--' and Usercode='合计' and kilncode!='--') or " +
  7080. "(Barcode='--' and Proceduremodeltypename='总计' ) or " +
  7081. "(Barcode='--' and createtime='小计' and temp.usercode!='--')";
  7082. return selSql;
  7083. }
  7084. #region 工序交接数量汇总表
  7085. /// <summary>
  7086. /// 取得RPT030107画面(工序交接数量汇总表)的汇总信息查询数据
  7087. /// </summary>
  7088. /// <param name="user">登录用户信息</param>
  7089. /// <param name="se">查询条件</param>
  7090. /// <returns>查询结果</returns>
  7091. public static ServiceResultEntity GetRPT030107SData(SUserInfo user, RPT030107_SE se)
  7092. {
  7093. IDBConnection conn = null;
  7094. try
  7095. {
  7096. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7097. List<OracleParameter> parameters = new List<OracleParameter>();
  7098. string sql = ReportModuleLogic.GetRPT030107SSQL(user, se, ref parameters);
  7099. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  7100. ServiceResultEntity sre = new ServiceResultEntity();
  7101. if (data == null || data.Rows.Count == 0)
  7102. {
  7103. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7104. return sre;
  7105. }
  7106. sre.Data = new DataSet();
  7107. sre.Data.Tables.Add(data);
  7108. return sre;
  7109. }
  7110. catch (Exception ex)
  7111. {
  7112. throw ex;
  7113. }
  7114. finally
  7115. {
  7116. if (conn != null &&
  7117. conn.ConnState == ConnectionState.Open)
  7118. {
  7119. conn.Close();
  7120. }
  7121. }
  7122. }
  7123. /// <summary>
  7124. /// 获取RPT030107画面(工序交接数量汇总表)的汇总信息查询sql
  7125. /// </summary>
  7126. /// <returns>sql</returns>
  7127. private static string GetRPT030107SSQL(SUserInfo user, RPT030107_SE se, ref List<OracleParameter> parameters)
  7128. {
  7129. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7130. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  7131. string sqlString =
  7132. "SELECT p.procedureid\n" +
  7133. " ,decode(gid,\n" +
  7134. " 7,\n" +
  7135. " '总计',\n" +
  7136. " 3,\n" +
  7137. " '合计【' || p.procedurename || '】',\n" +
  7138. " 1,\n" +
  7139. " '--',\n" +
  7140. " p.procedurename) procedurename\n" +
  7141. " ,decode(gid,\n" +
  7142. " 7,\n" +
  7143. " '--',\n" +
  7144. " 3,\n" +
  7145. " '--',\n" +
  7146. " 1,\n" +
  7147. " '小计【' || p.goodstypename2 || '】',\n" +
  7148. " p.goodstypename2) goodstypename2\n" +
  7149. " ,p.goodstypecode2 \n" +
  7150. " ,decode(gid, 0, p.userid, '--') userid\n" +
  7151. " ,decode(gid, 0, p.usercode, '--') usercode\n" +
  7152. " ,decode(gid, 0, p.goodsid, '--') goodsid\n" +
  7153. " ,decode(gid, 0, p.goodscode, '--') goodscode\n" +
  7154. " ,decode(gid, 0, p.goodstypename, '--') goodstypename\n" +
  7155. " ,p.overcount\n" +
  7156. " FROM (SELECT grouping_id(pdata.Procedureid,pdata.goodstypename2, pdata.Userid) gid\n" +
  7157. " ,pdata.productionlineid\n" +
  7158. " ,pdata.procedureid\n" +
  7159. " ,to_char(pdata.procedurename) procedurename\n" +
  7160. " ,to_char(pdata.userid) userid\n" +
  7161. " ,pdata.usercode\n" +
  7162. " ,to_char(pdata.goodsid) goodsid\n" +
  7163. " ,pdata.goodscode\n" +
  7164. " ,pdata.goodstypename\n" +
  7165. " ,pdata.goodstypecode2\n" +
  7166. " ,pdata.goodstypename2\n" +
  7167. " ,COUNT(pdata.barcode) overcount\n" +
  7168. " FROM (SELECT distinct pd.barcode,pcp.displayno\n" +
  7169. " ,pd.productionlineid\n" +
  7170. " ,pd.procedureid\n" +
  7171. " ,pcp.procedurename\n" +
  7172. (se.DisPUserCode ? " ,pd.userid, pd.usercode \n" : " ,null userid, null usercode \n") +
  7173. //" ,pd.userid\n" +
  7174. //" ,pd.usercode\n" +
  7175. " ,t_over.goodsid\n" +
  7176. " ,t_over.goodscode\n" +
  7177. " ,t_over.goodstypename\n" +
  7178. " ,t_over.goodstypecode2\n" +
  7179. " ,t_over.goodstypename2\n" +
  7180. " FROM tp_pm_productiondata pd\n" +
  7181. " LEFT JOIN tp_pc_procedure pcp\n" +
  7182. " ON pcp.procedureid = pd.procedureid\n" +
  7183. " INNER JOIN (SELECT DISTINCT pd.barcode\n" +
  7184. " ,pd.productiondataid\n" +
  7185. " ,goods.goodsid\n" +
  7186. " ,goods.goodscode\n" +
  7187. " ,gt.goodstypename\n" +
  7188. " ,gt2.goodstypename goodstypename2\n" +
  7189. " ,gt2.goodstypecode goodstypecode2\n" +
  7190. " FROM tp_pm_productiondata pd\n" +
  7191. " LEFT JOIN tp_mst_goods goods\n" +
  7192. " ON goods.goodsid = pd.goodsid\n" +
  7193. " LEFT JOIN tp_mst_goodstype gt\n" +
  7194. " ON goods.goodstypeid = gt.goodstypeid\n" +
  7195. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7196. " ON gt2.goodstypecode = substr(gt.goodstypecode,1,6)\n" +
  7197. " AND gt2.accountid = gt.accountid\n" +
  7198. " --LEFT JOIN tp_pc_procedure pcp\n" +
  7199. " -- ON pcp.procedureid = pd.procedureid\n" +
  7200. ((se.DTimeStart.HasValue || se.DTimeEnd.HasValue) ? " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=pd.groutingdailydetailid \n" : "") +
  7201. " WHERE pd.valueflag = '1'\n" +
  7202. " 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))" +
  7203. " AND pd.accountid = :AccountID\n";
  7204. // 生产线
  7205. if (se.ProductionLineID.HasValue)
  7206. {
  7207. sqlString = sqlString + " AND pd.productionlineid = :productionlineid ";
  7208. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  7209. }
  7210. // 成型工号
  7211. if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
  7212. {
  7213. sqlString = sqlString + " AND instr(pd.GroutingUserCode, :GroutingUserCode) > 0";
  7214. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  7215. }
  7216. // 产品型号
  7217. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  7218. {
  7219. sqlString = sqlString + " AND instr(gt.GOODSTYPECode, :GoodsTypeCode)=1 ";
  7220. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7221. }
  7222. // 产品编码
  7223. if (!string.IsNullOrEmpty(se.GoodsCode))
  7224. {
  7225. sqlString = sqlString + " AND instr(goods.GOODSCode, :GoodsCode) > 0 ";
  7226. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7227. }
  7228. // 交接工序
  7229. if (!string.IsNullOrEmpty(se.OverProcedureIDS))
  7230. {
  7231. sqlString = sqlString + " AND instr(:overprocedureids, ','||pd.procedureid||',')>0 ";
  7232. parameters.Add(new OracleParameter(":overprocedureids", OracleDbType.Varchar2, "," + se.OverProcedureIDS + ",", ParameterDirection.Input));
  7233. }
  7234. // 交接工号
  7235. if (!string.IsNullOrEmpty(se.OverUserIDS))
  7236. {
  7237. sqlString = sqlString + " AND instr(:overuserids, ','||pd.userid||',')>0 ";
  7238. parameters.Add(new OracleParameter(":overuserids", OracleDbType.Varchar2, "," + se.OverUserIDS + ",", ParameterDirection.Input));
  7239. }
  7240. // 交接时间
  7241. if (se.OverTimeStart.HasValue)
  7242. {
  7243. sqlString = sqlString + " AND pd.CreateTime >=:OverTimeStart ";
  7244. parameters.Add(new OracleParameter(":OverTimeStart", OracleDbType.Date, se.OverTimeStart.Value, ParameterDirection.Input));
  7245. }
  7246. if (se.OverTimeEnd.HasValue)
  7247. {
  7248. sqlString = sqlString + " AND pd.CreateTime <= :OverTimeEnd ";
  7249. parameters.Add(new OracleParameter(":OverTimeEnd", OracleDbType.Date, se.OverTimeEnd.Value, ParameterDirection.Input));
  7250. }
  7251. // 注浆时间
  7252. if (se.GTimeStart.HasValue)
  7253. {
  7254. sqlString = sqlString + " AND pd.GROUTINGDATE >=:GTimeStart ";
  7255. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  7256. }
  7257. if (se.GTimeEnd.HasValue)
  7258. {
  7259. sqlString = sqlString + " AND pd.GROUTINGDATE <= :GTimeEnd ";
  7260. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  7261. }
  7262. // 交坯时间
  7263. if (se.DTimeStart.HasValue)
  7264. {
  7265. sqlString = sqlString + " AND gdd.DELIVERTIME >=:DTimeStart ";
  7266. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
  7267. }
  7268. if (se.DTimeEnd.HasValue)
  7269. {
  7270. sqlString = sqlString + " AND gdd.DELIVERTIME <= :DTimeEnd ";
  7271. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
  7272. }
  7273. sqlString = sqlString +
  7274. " ) t_over\n" +
  7275. " ON pd.barcode = t_over.barcode\n" +
  7276. // 交接工序在生产工序后
  7277. " AND pd.productiondataid <= t_over.productiondataid\n" +
  7278. " WHERE pd.valueflag = '1'\n" +
  7279. " AND pd.accountid = :AccountID\n" +
  7280. (se.Specialrepairflag ? " AND ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" : "") +
  7281. " 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))";
  7282. // 生产工序
  7283. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  7284. {
  7285. sqlString = sqlString + " AND instr(:procedureids, ','||pd.procedureid||',')>0 ";
  7286. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  7287. }
  7288. // 生产工号
  7289. if (!string.IsNullOrEmpty(se.UserIDS))
  7290. {
  7291. sqlString = sqlString + " AND instr(:userids, ','||pd.userid||',')>0 ";
  7292. parameters.Add(new OracleParameter(":userids", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
  7293. }
  7294. // 生产时间
  7295. if (se.PTimeStart.HasValue)
  7296. {
  7297. sqlString = sqlString + " AND pd.CreateTime >=:PTimeStart ";
  7298. parameters.Add(new OracleParameter(":PTimeStart", OracleDbType.Date, se.PTimeStart.Value, ParameterDirection.Input));
  7299. }
  7300. if (se.PTimeEnd.HasValue)
  7301. {
  7302. sqlString = sqlString + " AND pd.CreateTime <= :PTimeEnd ";
  7303. parameters.Add(new OracleParameter(":PTimeEnd", OracleDbType.Date, se.PTimeEnd.Value, ParameterDirection.Input));
  7304. }
  7305. sqlString = sqlString +
  7306. "\n ) pdata\n" +
  7307. " 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" +
  7308. " ORDER BY pdata.displayno\n" +
  7309. " ,pdata.goodstypename2\n" +
  7310. " ,pdata.usercode\n" +
  7311. " ,pdata.goodstypename\n" +
  7312. " ,pdata.goodscode) p";
  7313. return sqlString;
  7314. }
  7315. /// <summary>
  7316. /// 取得RPT030107画面(工序交接数量汇总表)的明细信息查询数据
  7317. /// </summary>
  7318. /// <param name="user">登录用户信息</param>
  7319. /// <param name="se">查询条件</param>
  7320. /// <returns>查询结果</returns>
  7321. public static ServiceResultEntity GetRPT030107IData(SUserInfo user, RPT030107_SE se)
  7322. {
  7323. IDBConnection conn = null;
  7324. try
  7325. {
  7326. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7327. List<OracleParameter> parameters = new List<OracleParameter>();
  7328. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030107ISQL(user, se, ref parameters));
  7329. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  7330. ServiceResultEntity sre = new ServiceResultEntity();
  7331. if (data == null || data.Rows.Count == 0)
  7332. {
  7333. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7334. return sre;
  7335. }
  7336. sre.Data = new DataSet();
  7337. sre.Data.Tables.Add(data);
  7338. return sre;
  7339. }
  7340. catch (Exception ex)
  7341. {
  7342. throw ex;
  7343. }
  7344. finally
  7345. {
  7346. if (conn != null &&
  7347. conn.ConnState == ConnectionState.Open)
  7348. {
  7349. conn.Close();
  7350. }
  7351. }
  7352. }
  7353. /// <summary>
  7354. /// 获取RPT030107画面(工序交接数量汇总表)的明细信息查询sql
  7355. /// </summary>
  7356. /// <returns>sql</returns>
  7357. private static string GetRPT030107ISQL(SUserInfo user, RPT030107_SE se, ref List<OracleParameter> parameters)
  7358. {
  7359. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7360. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  7361. string sqlString =
  7362. "SELECT distinct pcp.procedurename,pcp.displayno\n" +
  7363. (se.DisPUserCode ? " ,pd.userid, pd.usercode \n" : " ,null userid, null usercode \n") +
  7364. //" ,pd.usercode\n" +
  7365. " ,t_over.barcode\n" +
  7366. " ,t_over.goodscode\n" +
  7367. " ,t_over.goodstypename\n" +
  7368. " ,t_over.goodstypename2\n" +
  7369. //" ,pd.createtime ptime\n" +
  7370. //" ,t_over.overprocedurename\n" +
  7371. //" ,t_over.overusercode\n" +
  7372. //" ,t_over.overtime\n" +
  7373. " ,t_over.groutingusercode\n" +
  7374. " ,pd.groutinglinecode\n" +
  7375. " ,pd.groutingmouldcode\n" +
  7376. " ,t_over.groutingdate Gdate\n" +
  7377. " ,t_over.DELIVERTIME Ddate\n" +
  7378. " ,decode(logo.logoid, null, '', logo.Logoname||'['||logo.Logocode||']') as LogoCodeName " +
  7379. " FROM tp_pm_productiondata pd\n" +
  7380. " LEFT JOIN tp_pc_procedure pcp\n" +
  7381. " ON pcp.procedureid = pd.procedureid\n" +
  7382. " LEFT JOIN TP_MST_logo logo\n" +
  7383. " ON logo.logoid = pd.logoid\n" +
  7384. " INNER JOIN (SELECT DISTINCT pd.barcode\n" +
  7385. " ,pd.productiondataid\n" +
  7386. " ,goods.goodsid\n" +
  7387. " ,goods.goodscode\n" +
  7388. " ,gt.goodstypename\n" +
  7389. " ,gt2.goodstypename goodstypename2\n" +
  7390. //" ,pcp.procedurename overprocedurename\n" +
  7391. //" ,pd.usercode overusercode\n" +
  7392. //" ,pd.createtime overtime\n" +
  7393. " ,pd.groutingusercode\n" +
  7394. " ,pd.groutingdate\n" +
  7395. " ,gdd.DELIVERTIME\n" +
  7396. " FROM tp_pm_productiondata pd\n" +
  7397. " LEFT JOIN tp_mst_goods goods\n" +
  7398. " ON goods.goodsid = pd.goodsid\n" +
  7399. " LEFT JOIN tp_mst_goodstype gt\n" +
  7400. " ON goods.goodstypeid = gt.goodstypeid\n" +
  7401. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7402. " ON gt2.goodstypecode = substr(gt.goodstypecode,1,6)\n" +
  7403. " AND gt2.accountid = gt.accountid\n" +
  7404. " LEFT JOIN tp_pc_procedure pcp\n" +
  7405. " ON pcp.procedureid = pd.procedureid\n" +
  7406. " INNER JOIN tp_pm_groutingdailydetail gdd\n" +
  7407. " ON gdd.groutingdailydetailid = pd.groutingdailydetailid\n" +
  7408. " WHERE pd.valueflag = '1'\n" +
  7409. " 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))" +
  7410. " AND pd.accountid = :AccountID\n";
  7411. // 生产线
  7412. if (se.ProductionLineID.HasValue)
  7413. {
  7414. sqlString = sqlString + " AND pd.productionlineid = :productionlineid ";
  7415. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  7416. }
  7417. // 成型工号
  7418. if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
  7419. {
  7420. sqlString = sqlString + " AND instr(pd.GroutingUserCode, :GroutingUserCode) > 0";
  7421. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  7422. }
  7423. // 产品型号
  7424. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  7425. {
  7426. sqlString = sqlString + " AND instr(gt.GOODSTYPECode, :GoodsTypeCode)=1 ";
  7427. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7428. }
  7429. if (!string.IsNullOrEmpty(se.GoodsID))
  7430. {
  7431. sqlString = sqlString + " AND pd.goodsid = :GoodsID ";
  7432. parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  7433. }
  7434. // 产品编码
  7435. if (!string.IsNullOrEmpty(se.GoodsCode))
  7436. {
  7437. sqlString = sqlString + " AND instr(goods.GOODSCode, :GoodsCode) > 0 ";
  7438. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7439. }
  7440. // 交接工序
  7441. if (!string.IsNullOrEmpty(se.OverProcedureIDS))
  7442. {
  7443. sqlString = sqlString + " AND instr(:overprocedureids, ','||pd.procedureid||',')>0 ";
  7444. parameters.Add(new OracleParameter(":overprocedureids", OracleDbType.Varchar2, "," + se.OverProcedureIDS + ",", ParameterDirection.Input));
  7445. }
  7446. // 交接工号
  7447. if (!string.IsNullOrEmpty(se.OverUserIDS))
  7448. {
  7449. sqlString = sqlString + " AND instr(:overuserids, ','||pd.userid||',')>0 ";
  7450. parameters.Add(new OracleParameter(":overuserids", OracleDbType.Varchar2, "," + se.OverUserIDS + ",", ParameterDirection.Input));
  7451. }
  7452. // 交接时间
  7453. if (se.OverTimeStart.HasValue)
  7454. {
  7455. sqlString = sqlString + " AND pd.CreateTime >=:OverTimeStart ";
  7456. parameters.Add(new OracleParameter(":OverTimeStart", OracleDbType.Date, se.OverTimeStart.Value, ParameterDirection.Input));
  7457. }
  7458. if (se.OverTimeEnd.HasValue)
  7459. {
  7460. sqlString = sqlString + " AND pd.CreateTime <= :OverTimeEnd ";
  7461. parameters.Add(new OracleParameter(":OverTimeEnd", OracleDbType.Date, se.OverTimeEnd.Value, ParameterDirection.Input));
  7462. }
  7463. // 注浆时间
  7464. if (se.GTimeStart.HasValue)
  7465. {
  7466. sqlString = sqlString + " AND pd.GROUTINGDATE >=:GTimeStart ";
  7467. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  7468. }
  7469. if (se.GTimeEnd.HasValue)
  7470. {
  7471. sqlString = sqlString + " AND pd.GROUTINGDATE <= :GTimeEnd ";
  7472. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  7473. }
  7474. // 交坯时间
  7475. if (se.DTimeStart.HasValue)
  7476. {
  7477. sqlString = sqlString + " AND gdd.DELIVERTIME >=:DTimeStart ";
  7478. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
  7479. }
  7480. if (se.DTimeEnd.HasValue)
  7481. {
  7482. sqlString = sqlString + " AND gdd.DELIVERTIME <= :DTimeEnd ";
  7483. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
  7484. }
  7485. sqlString = sqlString +
  7486. " ) t_over\n" +
  7487. " ON pd.barcode = t_over.barcode\n" +
  7488. // 交接工序在生产工序后
  7489. " AND pd.productiondataid <= t_over.productiondataid\n" +
  7490. " WHERE pd.valueflag = '1'\n" +
  7491. " AND pd.accountid = :AccountID\n" +
  7492. (se.Specialrepairflag ? " AND ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" : "") +
  7493. " 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))";
  7494. // 生产工序
  7495. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  7496. {
  7497. sqlString = sqlString + " AND instr(:procedureids, ','||pd.procedureid||',')>0 ";
  7498. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  7499. }
  7500. // 生产工号
  7501. if (!string.IsNullOrEmpty(se.UserIDS))
  7502. {
  7503. sqlString = sqlString + " AND instr(:userids, ','||pd.userid||',')>0 ";
  7504. parameters.Add(new OracleParameter(":userids", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
  7505. }
  7506. // 生产时间
  7507. if (se.PTimeStart.HasValue)
  7508. {
  7509. sqlString = sqlString + " AND pd.CreateTime >=:PTimeStart ";
  7510. parameters.Add(new OracleParameter(":PTimeStart", OracleDbType.Date, se.PTimeStart.Value, ParameterDirection.Input));
  7511. }
  7512. if (se.PTimeEnd.HasValue)
  7513. {
  7514. sqlString = sqlString + " AND pd.CreateTime <= :PTimeEnd ";
  7515. parameters.Add(new OracleParameter(":PTimeEnd", OracleDbType.Date, se.PTimeEnd.Value, ParameterDirection.Input));
  7516. }
  7517. sqlString = sqlString +
  7518. "\n ORDER BY pcp.displayno\n" +
  7519. " ,t_over.goodstypename2\n" +
  7520. (se.DisPUserCode ? " ,pd.usercode\n" : "") +
  7521. " ,t_over.goodstypename\n" +
  7522. " ,t_over.goodscode\n";
  7523. return sqlString;
  7524. }
  7525. #endregion
  7526. /// <summary>
  7527. /// 取得RPT030108画面(成型信息汇总表)的查询数据
  7528. /// </summary>
  7529. /// <param name="user">登录用户信息</param>
  7530. /// <param name="se">查询条件</param>
  7531. /// <returns>查询结果</returns>
  7532. public static ServiceResultEntity GetRPT030108SData(SUserInfo user, RPT030108_SE se)
  7533. {
  7534. IDBConnection conn = null;
  7535. try
  7536. {
  7537. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7538. List<OracleParameter> parameters = new List<OracleParameter>();
  7539. string sqlString = "SELECT decode(g.gid,\n" +
  7540. " 7,\n" +
  7541. " '总计',\n" +
  7542. " 3,\n" +
  7543. " '合计【' || g.goodstypename2 || '】',\n" +
  7544. " 0,\n" +
  7545. " g.goodstypename2,\n" +
  7546. " '--') goodstypename2\n" +
  7547. " ,decode(g.gid, 0, g.goodstypename, '--') goodstypename\n" +
  7548. " ,decode(g.gid,\n" +
  7549. " 1,\n" +
  7550. " '小计【' || g.goodscode || '】',\n" +
  7551. " 0,\n" +
  7552. " g.goodscode,\n" +
  7553. " '--') goodscode\n" +
  7554. " ,decode(g.gid, 0, g.usercode, '--') usercode\n" +
  7555. " ,decode(g.gid, 0, g.MONITORName, '--') MONITORName\n" +
  7556. " ,g.groutingcount\n" +
  7557. " ,g.barcodecount\n" +
  7558. " ,g.scrapcount\n" +
  7559. " ,g.barscrapcount\n" +
  7560. " ,g.delivercount\n" +
  7561. " ,g.barcodecount - g.barscrapcount - g.delivercount incount\n" +
  7562. " FROM (SELECT grouping_id(gdd.goodstypename2, gdd.goodscode, gdd.usercode) gid\n" +
  7563. " ,gdd.goodstypename2\n" +
  7564. " ,gdd.goodstypename\n" +
  7565. " ,gdd.goodscode\n" +
  7566. " ,gdd.usercode\n" +
  7567. " ,gdd.MONITORName\n" +
  7568. " ,SUM(groutingcount) groutingcount\n" +
  7569. " ,SUM(barcodecount) barcodecount\n" +
  7570. " ,SUM(scrapcount) scrapcount\n" +
  7571. " ,SUM(barscrapcount) barscrapcount\n" +
  7572. " ,SUM(delivercount) delivercount\n" +
  7573. " FROM (SELECT gt2.goodstypename goodstypename2\n" +
  7574. " ,gdd.usercode\n" +
  7575. " ,mu.usercode as MONITORName\n" +
  7576. " ,goods.goodscode\n" +
  7577. " ,gt.goodstypename\n" +
  7578. " , CASE\n" +
  7579. " WHEN gdd.groutingdate >= :gdatabegin AND\n" +
  7580. " gdd.groutingdate <= :gdataend THEN\n" +
  7581. " 1\n" +
  7582. " ELSE\n" +
  7583. " 0\n" +
  7584. " END groutingcount\n" +
  7585. " , CASE\n" +
  7586. " WHEN gdd.groutingdate >= :gdatabegin AND\n" +
  7587. " gdd.groutingdate <= :gdataend AND\n" +
  7588. " gdd.barcode IS NOT NULL THEN\n" +
  7589. " 1\n" +
  7590. " ELSE\n" +
  7591. " 0\n" +
  7592. " END barcodecount\n" +
  7593. " , CASE\n" +
  7594. " WHEN gdd.scraptime >= :sdatabegin AND\n" +
  7595. " gdd.scraptime <= :sdataend AND\n" +
  7596. " gdd.scrapflag = '1' THEN\n" +
  7597. " 1\n" +
  7598. " ELSE\n" +
  7599. " 0\n" +
  7600. " END scrapcount\n" +
  7601. " , CASE\n" +
  7602. " WHEN gdd.scraptime >= :sdatabegin AND\n" +
  7603. " gdd.scraptime <= :sdataend AND\n" +
  7604. " gdd.barcode IS NOT NULL AND gdd.scrapflag = '1' THEN\n" +
  7605. " 1\n" +
  7606. " ELSE\n" +
  7607. " 0\n" +
  7608. " END barscrapcount\n" +
  7609. " , CASE\n" +
  7610. " WHEN gdd.delivertime >= :ddatabegin AND\n" +
  7611. " gdd.delivertime <= :ddataend AND\n" +
  7612. " gdd.deliverflag = '1' THEN\n" +
  7613. " 1\n" +
  7614. " ELSE\n" +
  7615. " 0\n" +
  7616. " END delivercount\n" +
  7617. " FROM tp_pm_groutingdailydetail gdd\n" +
  7618. " LEFT JOIN tp_mst_goods goods\n" +
  7619. " ON goods.goodsid = gdd.goodsid\n" +
  7620. // 成型线
  7621. " LEFT JOIN tp_pc_groutingline gl" +
  7622. " ON gl.groutinglineid = GDD.GroutingLineID" +
  7623. // 成型班长
  7624. " LEFT JOIN tp_mst_user mu" +
  7625. " ON mu.userid = gl.MONITORID " +
  7626. " LEFT JOIN tp_mst_goodstype gt\n" +
  7627. " ON gt.goodstypeid = goods.goodstypeid\n" +
  7628. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7629. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  7630. " AND gt2.accountid = gt.accountid\n" +
  7631. " WHERE gdd.valueflag = '1'\n" +
  7632. " AND gdd.groutingflag = '1'\n" +
  7633. " AND gdd.accountid = :accountid\n" +
  7634. " AND ((gdd.groutingdate >= :gdatabegin AND\n" +
  7635. " gdd.groutingdate <= :gdataend) OR\n" +
  7636. " (gdd.scraptime >= :sdatabegin AND\n" +
  7637. " gdd.scraptime <= :sdataend) OR\n" +
  7638. " (gdd.delivertime >= :ddatabegin AND\n" +
  7639. " gdd.delivertime <= :ddataend))\n" +
  7640. " AND (:usercode IS NULL OR\n" +
  7641. " instr(gdd.usercode, :usercode) > 0)\n" +
  7642. " AND (:GoodsCode IS NULL OR\n" +
  7643. " instr(goods.GoodsCode, :GoodsCode) > 0)\n" +
  7644. " AND (:goodstypecode IS NULL OR\n" +
  7645. " instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  7646. " ORDER BY gt2.goodstypename\n" +
  7647. " ,gt.goodstypename\n" +
  7648. " ,goods.goodscode\n" +
  7649. " ,gdd.usercode) gdd\n" +
  7650. " GROUP BY GROUPING SETS((gdd.goodstypename2, gdd.goodstypename, gdd.goodscode, gdd.usercode,gdd.MONITORName),(gdd.goodstypename2, gdd.goodstypename, gdd.goodscode),(gdd.goodstypename2),())\n" +
  7651. " ORDER BY gdd.goodstypename2\n" +
  7652. " ,gdd.goodstypename\n" +
  7653. " ,gdd.goodscode\n" +
  7654. " ,gdd.usercode) g";
  7655. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7656. parameters.Add(new OracleParameter(":gdatabegin", OracleDbType.Date, se.GTimeStart, ParameterDirection.Input));
  7657. parameters.Add(new OracleParameter(":gdataend", OracleDbType.Date, se.GTimeEnd, ParameterDirection.Input));
  7658. parameters.Add(new OracleParameter(":sdatabegin", OracleDbType.Date, se.STimeStart, ParameterDirection.Input));
  7659. parameters.Add(new OracleParameter(":sdataend", OracleDbType.Date, se.STimeEnd, ParameterDirection.Input));
  7660. parameters.Add(new OracleParameter(":ddatabegin", OracleDbType.Date, se.DTimeStart, ParameterDirection.Input));
  7661. parameters.Add(new OracleParameter(":ddataend", OracleDbType.Date, se.DTimeEnd, ParameterDirection.Input));
  7662. parameters.Add(new OracleParameter(":usercode", OracleDbType.Varchar2, se.UserCode, ParameterDirection.Input));
  7663. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7664. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7665. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  7666. ServiceResultEntity sre = new ServiceResultEntity();
  7667. if (data == null || data.Rows.Count == 0)
  7668. {
  7669. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7670. return sre;
  7671. }
  7672. sre.Data = new DataSet();
  7673. sre.Data.Tables.Add(data);
  7674. return sre;
  7675. }
  7676. catch (Exception ex)
  7677. {
  7678. throw ex;
  7679. }
  7680. finally
  7681. {
  7682. if (conn != null &&
  7683. conn.ConnState == ConnectionState.Open)
  7684. {
  7685. conn.Close();
  7686. }
  7687. }
  7688. }
  7689. #region 撤销产品汇总表
  7690. /// <summary>
  7691. /// 取得RPT030109画面(撤销产品汇总表)的汇总信息查询数据
  7692. /// </summary>
  7693. /// <param name="user">登录用户信息</param>
  7694. /// <param name="se">查询条件</param>
  7695. /// <returns>查询结果</returns>
  7696. public static ServiceResultEntity GetRPT030109SData(SUserInfo user, RPT030109_SE se)
  7697. {
  7698. IDBConnection conn = null;
  7699. try
  7700. {
  7701. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7702. List<OracleParameter> parameters = new List<OracleParameter>();
  7703. string sql = ReportModuleLogic.GetRPT030109SSQL(user, se, ref parameters);
  7704. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  7705. ServiceResultEntity sre = new ServiceResultEntity();
  7706. if (data == null || data.Rows.Count == 0)
  7707. {
  7708. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7709. return sre;
  7710. }
  7711. sre.Data = new DataSet();
  7712. sre.Data.Tables.Add(data);
  7713. return sre;
  7714. }
  7715. catch (Exception ex)
  7716. {
  7717. throw ex;
  7718. }
  7719. finally
  7720. {
  7721. if (conn != null &&
  7722. conn.ConnState == ConnectionState.Open)
  7723. {
  7724. conn.Close();
  7725. }
  7726. }
  7727. }
  7728. /// <summary>
  7729. /// 获取RPT030109画面(撤销产品汇总表)的汇总信息查询sql
  7730. /// </summary>
  7731. /// <returns>sql</returns>
  7732. private static string GetRPT030109SSQL(SUserInfo user, RPT030109_SE se, ref List<OracleParameter> parameters)
  7733. {
  7734. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7735. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  7736. string sqlString =
  7737. "SELECT decode(p.gid,\n" +
  7738. " 7,\n" +
  7739. " '总计',\n" +
  7740. " 3,\n" +
  7741. " '合计【' || p.procedurename || '】',\n" +
  7742. " 0,\n" +
  7743. " p.procedurename,\n" +
  7744. " '--') procedurename\n" +
  7745. " ,decode(p.gid,\n" +
  7746. " 1,\n" +
  7747. " '小计【' || p.goodstypename2 || '】',\n" +
  7748. " 0,\n" +
  7749. " p.goodstypename2,\n" +
  7750. " '--') goodstypename2\n" +
  7751. " ,decode(p.gid, 0, p.goodstypename, '--') goodstypename\n" +
  7752. " ,decode(p.gid, 0, p.goodscode, '--') goodscode\n" +
  7753. " ,decode(p.gid, 0, p.usercode, '--') usercode\n" +
  7754. " ,p.codecount\n" +
  7755. " ,p.productionlineid\n" +
  7756. " ,p.procedureid\n" +
  7757. " ,p.goodstypecode2\n" +
  7758. " ,p.goodsid\n" +
  7759. " ,p.userid\n" +
  7760. " FROM (SELECT grouping_id(pd.procedureid, gt2.goodstypecode, pd.userid) gid\n" +
  7761. " ,pd.productionlineid\n" +
  7762. " ,pd.procedureid\n" +
  7763. " ,p.procedurename\n" +
  7764. " ,p.displayno\n" +
  7765. " ,gt2.goodstypecode goodstypecode2\n" +
  7766. " ,gt2.goodstypename goodstypename2\n" +
  7767. " ,gt.goodstypecode\n" +
  7768. " ,gt.goodstypename\n" +
  7769. " ,goods.goodsid\n" +
  7770. " ,goods.goodscode\n" +
  7771. " ,pd.userid\n" +
  7772. " ,pd.usercode\n" +
  7773. " ,COUNT(*) codecount\n" +
  7774. " FROM tp_pm_productiondata pd\n" +
  7775. " LEFT JOIN tp_pc_procedure p\n" +
  7776. " ON p.procedureid = pd.procedureid\n" +
  7777. " LEFT JOIN tp_mst_goods goods\n" +
  7778. " ON goods.goodsid = pd.goodsid\n" +
  7779. " LEFT JOIN tp_mst_goodstype gt\n" +
  7780. " ON gt.goodstypeid = goods.goodstypeid\n" +
  7781. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7782. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  7783. " AND gt2.accountid = gt.accountid\n" +
  7784. " WHERE pd.valueflag = '0'\n" +
  7785. " AND pd.accountid = :accountid\n" +
  7786. " 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))" +
  7787. " 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))" +
  7788. " AND (:productionlineid IS NULL OR\n" +
  7789. " pd.productionlineid = :productionlineid)\n" +
  7790. " AND (:procedureids IS NULL OR\n" +
  7791. " instr(:procedureids, ',' || pd.procedureid || ',') > 0)\n" +
  7792. " AND (:goodstypecode IS NULL OR\n" +
  7793. " instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  7794. " AND (:goodscode IS NULL OR\n" +
  7795. " instr(goods.goodscode, :goodscode) > 0)\n" +
  7796. " AND (:PUserIDS IS NULL OR\n" +
  7797. " instr(:PUserIDS, ',' || pd.userid || ',') > 0)\n" +
  7798. " AND (:backusercode IS NULL OR\n" +
  7799. " instr(pd.BACKOUTUSERCODE, :backusercode) > 0)\n" +
  7800. " AND (:ptimebegin IS NULL OR pd.createtime >= :ptimebegin)\n" +
  7801. " AND (:ptimeend IS NULL OR pd.createtime <= :ptimeend)\n" +
  7802. " AND (:backtimebegin IS NULL OR pd.backouttime >= :backtimebegin)\n" +
  7803. " AND (:backtimeend IS NULL OR pd.backouttime <= :backtimeend)\n" +
  7804. " 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" +
  7805. " ORDER BY p.displayno\n" +
  7806. " ,gt2.goodstypecode\n" +
  7807. " ,gt.goodstypecode\n" +
  7808. " ,goods.goodscode\n" +
  7809. " ,pd.usercode) p";
  7810. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  7811. if (string.IsNullOrEmpty(se.ProcedureIDS))
  7812. {
  7813. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, null, ParameterDirection.Input));
  7814. }
  7815. else
  7816. {
  7817. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  7818. }
  7819. if (string.IsNullOrEmpty(se.UserIDS))
  7820. {
  7821. parameters.Add(new OracleParameter(":PUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  7822. }
  7823. else
  7824. {
  7825. parameters.Add(new OracleParameter(":PUserIDS", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
  7826. }
  7827. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7828. parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7829. parameters.Add(new OracleParameter(":backusercode", OracleDbType.Varchar2, se.BackUserCode, ParameterDirection.Input));
  7830. parameters.Add(new OracleParameter(":ptimebegin", OracleDbType.Date, se.PTimeStart, ParameterDirection.Input));
  7831. parameters.Add(new OracleParameter(":ptimeend", OracleDbType.Date, se.PTimeEnd, ParameterDirection.Input));
  7832. parameters.Add(new OracleParameter(":backtimebegin", OracleDbType.Date, se.BackTimeStart, ParameterDirection.Input));
  7833. parameters.Add(new OracleParameter(":backtimeend", OracleDbType.Date, se.BackTimeEnd, ParameterDirection.Input));
  7834. return sqlString;
  7835. }
  7836. /// <summary>
  7837. /// 取得RPT030109画面(撤销产品汇总表)的明细信息查询数据
  7838. /// </summary>
  7839. /// <param name="user">登录用户信息</param>
  7840. /// <param name="se">查询条件</param>
  7841. /// <returns>查询结果</returns>
  7842. public static ServiceResultEntity GetRPT030109IData(SUserInfo user, RPT030109_SE se)
  7843. {
  7844. IDBConnection conn = null;
  7845. try
  7846. {
  7847. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7848. List<OracleParameter> parameters = new List<OracleParameter>();
  7849. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030109ISQL(user, se, ref parameters));
  7850. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  7851. ServiceResultEntity sre = new ServiceResultEntity();
  7852. if (data == null || data.Rows.Count == 0)
  7853. {
  7854. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7855. return sre;
  7856. }
  7857. sre.Data = new DataSet();
  7858. sre.Data.Tables.Add(data);
  7859. return sre;
  7860. }
  7861. catch (Exception ex)
  7862. {
  7863. throw ex;
  7864. }
  7865. finally
  7866. {
  7867. if (conn != null &&
  7868. conn.ConnState == ConnectionState.Open)
  7869. {
  7870. conn.Close();
  7871. }
  7872. }
  7873. }
  7874. /// <summary>
  7875. /// 获取RPT030109画面(撤销产品汇总表)的明细信息查询sql
  7876. /// </summary>
  7877. /// <returns>sql</returns>
  7878. private static string GetRPT030109ISQL(SUserInfo user, RPT030109_SE se, ref List<OracleParameter> parameters)
  7879. {
  7880. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7881. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  7882. string sqlString =
  7883. "SELECT p.procedurename\n" +
  7884. " ,gt2.goodstypename goodstypename2\n" +
  7885. " ,gt.goodstypename\n" +
  7886. " ,goods.goodscode\n" +
  7887. " ,pd.barcode\n" +
  7888. " ,pd.usercode\n" +
  7889. " ,pd.createtime ptime\n" +
  7890. " ,pd.backoutusercode busercode\n" +
  7891. " ,pd.backouttime btime\n" +
  7892. " ,pd.groutingusercode\n" +
  7893. " ,pd.groutinglinecode\n" +
  7894. " ,pd.groutingmouldcode\n" +
  7895. " ,pd.groutingdate GDate\n" +
  7896. " FROM tp_pm_productiondata pd\n" +
  7897. " LEFT JOIN tp_pc_procedure p\n" +
  7898. " ON p.procedureid = pd.procedureid\n" +
  7899. " LEFT JOIN tp_mst_goods goods\n" +
  7900. " ON goods.goodsid = pd.goodsid\n" +
  7901. " LEFT JOIN tp_mst_goodstype gt\n" +
  7902. " ON gt.goodstypeid = goods.goodstypeid\n" +
  7903. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7904. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  7905. " AND gt2.accountid = gt.accountid\n" +
  7906. " WHERE pd.valueflag = '0'\n" +
  7907. " AND pd.accountid = :accountid\n" +
  7908. " 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))" +
  7909. " 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))" +
  7910. " AND (:productionlineid IS NULL OR\n" +
  7911. " pd.productionlineid = :productionlineid)\n" +
  7912. " AND (:procedureids IS NULL OR\n" +
  7913. " instr(:procedureids, ',' || pd.procedureid || ',') > 0)\n" +
  7914. " AND (:goodstypecode IS NULL OR\n" +
  7915. " instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  7916. " AND (:goodscode IS NULL OR instr(goods.goodscode, :goodscode) > 0)\n" +
  7917. " AND (:PUserIDS IS NULL OR\n" +
  7918. " instr(:PUserIDS, ',' || pd.userid || ',') > 0)\n" +
  7919. " AND (:backusercode IS NULL OR instr(pd.BACKOUTUSERCODE, :backusercode) > 0)\n" +
  7920. " AND (:ptimebegin IS NULL OR pd.createtime >= :ptimebegin)\n" +
  7921. " AND (:ptimeend IS NULL OR pd.createtime <= :ptimeend)\n" +
  7922. " AND (:backtimebegin IS NULL OR pd.backouttime >= :backtimebegin)\n" +
  7923. " AND (:backtimeend IS NULL OR pd.backouttime <= :backtimeend)\n" +
  7924. " AND (:puserid IS NULL OR pd.userid = :puserid)\n" +
  7925. " AND (:goodsid IS NULL OR pd.goodsid = :goodsid)\n" +
  7926. " AND (:procedureid IS NULL OR pd.procedureid = :procedureid)\n" +
  7927. " ORDER BY p.displayno\n" +
  7928. " ,gt2.goodstypename\n" +
  7929. " ,gt.goodstypename\n" +
  7930. " ,goods.goodscode\n" +
  7931. " ,pd.usercode\n" +
  7932. " ,pd.barcode\n" +
  7933. " ,pd.backoutusercode\n" +
  7934. " ,pd.backouttime";
  7935. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  7936. if (string.IsNullOrEmpty(se.ProcedureIDS))
  7937. {
  7938. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, null, ParameterDirection.Input));
  7939. }
  7940. else
  7941. {
  7942. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  7943. }
  7944. if (string.IsNullOrEmpty(se.UserIDS))
  7945. {
  7946. parameters.Add(new OracleParameter(":PUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  7947. }
  7948. else
  7949. {
  7950. parameters.Add(new OracleParameter(":PUserIDS", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
  7951. }
  7952. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7953. parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7954. parameters.Add(new OracleParameter(":backusercode", OracleDbType.Varchar2, se.BackUserCode, ParameterDirection.Input));
  7955. parameters.Add(new OracleParameter(":ptimebegin", OracleDbType.Date, se.PTimeStart, ParameterDirection.Input));
  7956. parameters.Add(new OracleParameter(":ptimeend", OracleDbType.Date, se.PTimeEnd, ParameterDirection.Input));
  7957. parameters.Add(new OracleParameter(":backtimebegin", OracleDbType.Date, se.BackTimeStart, ParameterDirection.Input));
  7958. parameters.Add(new OracleParameter(":backtimeend", OracleDbType.Date, se.BackTimeEnd, ParameterDirection.Input));
  7959. parameters.Add(new OracleParameter(":puserid", OracleDbType.Int32, se.UserID, ParameterDirection.Input));
  7960. parameters.Add(new OracleParameter(":goodsid", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  7961. parameters.Add(new OracleParameter(":procedureid", OracleDbType.Int32, se.ProcedureID, ParameterDirection.Input));
  7962. return sqlString;
  7963. }
  7964. #endregion
  7965. /// <summary>
  7966. /// 工序收发存汇总表(初始化数据)
  7967. /// </summary>
  7968. /// <param name="user"></param>
  7969. /// <returns></returns>
  7970. public static ServiceResultEntity GetRPT030111IData(SUserInfo user)
  7971. {
  7972. IDBConnection conn = null;
  7973. try
  7974. {
  7975. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7976. OracleParameter[] parameters = new OracleParameter[]
  7977. {
  7978. new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  7979. };
  7980. string sqlString =
  7981. "SELECT t.ptid, t.name\n" +
  7982. " FROM tp_mst_rpt_transfer t\n" +
  7983. " WHERE t.AccountID = :AccountID\n" +
  7984. " AND t.valueflag = '1'\n" +
  7985. " ORDER BY t.displayno desc";
  7986. DataSet data = conn.GetSqlResultToDs(sqlString, parameters);
  7987. ServiceResultEntity sre = new ServiceResultEntity();
  7988. //if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  7989. //{
  7990. // sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7991. // return sre;
  7992. //}
  7993. sre.Data = data;
  7994. return sre;
  7995. }
  7996. catch (Exception ex)
  7997. {
  7998. throw ex;
  7999. }
  8000. finally
  8001. {
  8002. if (conn != null &&
  8003. conn.ConnState == ConnectionState.Open)
  8004. {
  8005. conn.Close();
  8006. }
  8007. }
  8008. }
  8009. /// <summary>
  8010. /// 工序收发存汇总表
  8011. /// </summary>
  8012. /// <param name="user"></param>
  8013. /// <param name="se"></param>
  8014. /// <returns></returns>
  8015. public static ServiceResultEntity GetRPT030111SData(SUserInfo user, RPT030111_SE se)
  8016. {
  8017. IDBTransaction conn = null;
  8018. try
  8019. {
  8020. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  8021. conn.Connect();
  8022. OracleParameter[] parameters = new OracleParameter[]
  8023. {
  8024. new OracleParameter("in_accountid", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  8025. new OracleParameter("in_ptid", OracleDbType.Int32, se.PTID, ParameterDirection.Input),
  8026. //new OracleParameter("in_datetimeinit", OracleDbType.Date, se.GTimeInit, ParameterDirection.Input),
  8027. new OracleParameter("in_datetimebegin", OracleDbType.Date, se.GTimeStart , ParameterDirection.Input),
  8028. new OracleParameter("in_datetimeend", OracleDbType.Date, se.GTimeEnd , ParameterDirection.Input),
  8029. new OracleParameter("in_goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode , ParameterDirection.Input),
  8030. new OracleParameter("in_goodscode", OracleDbType.Varchar2, se.GoodsCode , ParameterDirection.Input),
  8031. new OracleParameter("out_data", OracleDbType.RefCursor, null, ParameterDirection.Output),
  8032. };
  8033. DataSet data = conn.ExecStoredProcedure("pro_rpt_gettransfers_sum_c", parameters);
  8034. ServiceResultEntity sre = new ServiceResultEntity();
  8035. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  8036. {
  8037. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8038. return sre;
  8039. }
  8040. //StringBuilder intdids = new StringBuilder();
  8041. //foreach (DataRow row in data.Tables[0].Rows)
  8042. //{
  8043. // if (intdids.Length > 0)
  8044. // {
  8045. // intdids.Append(", ");
  8046. // }
  8047. // intdids.Append(row["tdid"] + " AS \"" + row["name"] + "\"\n");
  8048. //}
  8049. //string sqlString =
  8050. // "WITH ttm AS\n" +
  8051. // " (SELECT *\n" +
  8052. // " FROM TMP_RPT_TECDEP_D\n" +
  8053. // " pivot(SUM(m)\n" +
  8054. // " FOR intdid IN(" + intdids + ")))\n" +
  8055. // "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" +
  8056. // " FROM TMP_RPT_TECDEP_T t\n" +
  8057. // " LEFT JOIN ttm m\n" +
  8058. // " ON m.goodsid = t.goodsid\n" +
  8059. // " AND m.outtdid = t.tecdepid\n" +
  8060. // " ORDER BY t.goodscode, t.displayno";
  8061. //data = conn.GetSqlResultToDs(sqlString);
  8062. //if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  8063. //{
  8064. // sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8065. // return sre;
  8066. //}
  8067. conn.Commit();
  8068. sre.Data = data;
  8069. return sre;
  8070. }
  8071. catch (Exception ex)
  8072. {
  8073. throw ex;
  8074. }
  8075. finally
  8076. {
  8077. if (conn != null &&
  8078. conn.ConnState == ConnectionState.Open)
  8079. {
  8080. conn.Disconnect();
  8081. }
  8082. }
  8083. }
  8084. #endregion 汇总报表
  8085. #region 公共函数
  8086. /// <summary>
  8087. /// 取得报表的查询数据源统计工序数据
  8088. /// </summary>
  8089. /// <param name="user">登录用户信息</param>
  8090. /// <param name="se">查询条件</param>
  8091. /// <returns>查询结果</returns>
  8092. public static ServiceResultEntity GetRptSourceProcedureModule(SUserInfo user, int? RptProcedureID)
  8093. {
  8094. IDBConnection conn = null;
  8095. try
  8096. {
  8097. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8098. OracleParameter[] paras = new OracleParameter[]{
  8099. new OracleParameter("in_rptProcedureId",OracleDbType.Int32,RptProcedureID,ParameterDirection.Input),
  8100. new OracleParameter("out_rptSResult",OracleDbType.RefCursor, ParameterDirection.Output),
  8101. new OracleParameter("out_rptTresult",OracleDbType.RefCursor, ParameterDirection.Output),
  8102. };
  8103. DataSet data = conn.ExecStoredProcedure("PRO_MST_GetRptProcedureBYID", paras);
  8104. ServiceResultEntity sre = new ServiceResultEntity();
  8105. if (data == null || data.Tables.Count == 0)
  8106. {
  8107. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8108. return sre;
  8109. }
  8110. sre.Data = new DataSet();
  8111. sre.Data = data;
  8112. return sre;
  8113. }
  8114. catch (Exception ex)
  8115. {
  8116. throw ex;
  8117. }
  8118. finally
  8119. {
  8120. if (conn != null &&
  8121. conn.ConnState == ConnectionState.Open)
  8122. {
  8123. conn.Close();
  8124. }
  8125. }
  8126. }
  8127. /// <summary>
  8128. /// 取得报表数据源数据
  8129. /// </summary>
  8130. /// <param name="user">登录用户信息</param>
  8131. /// <returns>查询结果</returns>
  8132. public static ServiceResultEntity GetRptProcedureModule(SUserInfo user)
  8133. {
  8134. IDBConnection conn = null;
  8135. try
  8136. {
  8137. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8138. string selSql = " select "
  8139. + " TP_MST_RptProcedure.Rptprocedureid,"
  8140. + " TP_MST_RptProcedure.Rptprocedurecode,"
  8141. + " TP_MST_RptProcedure.Rptprocedurename,"
  8142. + " TP_MST_RptProcedure.Rptproceduretype,"
  8143. + " decode(TP_MST_RptProcedure.Rptproceduretype,'A0001','出窑统计','质量统计') RptproceduretypeName,"
  8144. + " (select wm_concat(s.procedureid) sprocedureid from tp_mst_rptsprocedure s where s.rptprocedureid = TP_MST_RptProcedure.Rptprocedureid) sprocedureid,"
  8145. + " (select wm_concat(t.procedureid) tprocedureid from tp_mst_rpttprocedure t where t.rptprocedureid = TP_MST_RptProcedure.Rptprocedureid) tprocedureid,"
  8146. + " TP_MST_RptProcedure.Optimestamp "
  8147. + " from TP_MST_RptProcedure "
  8148. + " where TP_MST_RptProcedure.ValueFlag=1 "
  8149. + " and TP_MST_RptProcedure.AccountID=:accountID order by TP_MST_RptProcedure.displayno";
  8150. List<OracleParameter> parameters = new List<OracleParameter>();
  8151. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8152. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8153. ServiceResultEntity sre = new ServiceResultEntity();
  8154. if (data == null || data.Rows.Count == 0)
  8155. {
  8156. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8157. return sre;
  8158. }
  8159. sre.Data = new DataSet();
  8160. sre.Data.Tables.Add(data);
  8161. return sre;
  8162. }
  8163. catch (Exception ex)
  8164. {
  8165. throw ex;
  8166. }
  8167. finally
  8168. {
  8169. if (conn != null &&
  8170. conn.ConnState == ConnectionState.Open)
  8171. {
  8172. conn.Close();
  8173. }
  8174. }
  8175. }
  8176. /// <summary>
  8177. /// 取得窑炉数据
  8178. /// </summary>
  8179. /// <param name="user">登录用户信息</param>
  8180. /// <param name="pValue">使用标识条件</param>
  8181. /// <returns>查询结果</returns>
  8182. public static ServiceResultEntity GetKilnData(SUserInfo user, byte pValue)
  8183. {
  8184. IDBConnection conn = null;
  8185. try
  8186. {
  8187. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8188. string selSql = string.Empty;
  8189. List<OracleParameter> parameters = new List<OracleParameter>();
  8190. //根据帐套查询数据
  8191. if (pValue.ToString() == Constant.INT_IS_ONE.ToString())
  8192. {
  8193. selSql = "Select KilnID,KilnCode,KilnName,KilnType,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,UpdateUserID,OPTimeStamp "
  8194. + "from TP_MST_Kiln where AccountID = :AccountID";
  8195. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8196. }
  8197. //根据帐套和标识查询数据
  8198. else if (pValue.ToString() == Constant.INT_IS_ZERO.ToString())
  8199. {
  8200. selSql = "Select KilnID,KilnCode,KilnName,KilnType,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,UpdateUserID,OPTimeStamp "
  8201. + "from TP_MST_Kiln where valueflag = :valueflag and AccountID = :AccountID";
  8202. parameters.Add(new OracleParameter(":valueflag", OracleDbType.NVarchar2, Constant.INT_IS_ONE.ToString(), ParameterDirection.Input));
  8203. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8204. }
  8205. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8206. ServiceResultEntity sre = new ServiceResultEntity();
  8207. if (data == null || data.Rows.Count == 0)
  8208. {
  8209. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8210. return sre;
  8211. }
  8212. sre.Data = new DataSet();
  8213. sre.Data.Tables.Add(data);
  8214. return sre;
  8215. }
  8216. catch (Exception ex)
  8217. {
  8218. throw ex;
  8219. }
  8220. finally
  8221. {
  8222. if (conn != null &&
  8223. conn.ConnState == ConnectionState.Open)
  8224. {
  8225. conn.Close();
  8226. }
  8227. }
  8228. }
  8229. /// <summary>
  8230. /// 取得窑车数据
  8231. /// </summary>
  8232. /// <param name="user">登录用户信息</param>
  8233. /// <returns>查询结果</returns>
  8234. public static ServiceResultEntity GetAllKilnCarInfo(SUserInfo user)
  8235. {
  8236. IDBConnection conn = null;
  8237. try
  8238. {
  8239. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8240. string selSql = String.Empty;
  8241. List<OracleParameter> parameters = new List<OracleParameter>();
  8242. //获取窑车管理的数据
  8243. selSql = "Select KilnCarID,KilnID,KilnCarCode,KilnCarName,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,UpdateUserID,OPTimeStamp "
  8244. + "from TP_MST_KilnCar where AccountID = :AccountID";
  8245. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8246. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8247. ServiceResultEntity sre = new ServiceResultEntity();
  8248. if (data == null || data.Rows.Count == 0)
  8249. {
  8250. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8251. return sre;
  8252. }
  8253. sre.Data = new DataSet();
  8254. sre.Data.Tables.Add(data);
  8255. return sre;
  8256. }
  8257. catch (Exception ex)
  8258. {
  8259. throw ex;
  8260. }
  8261. finally
  8262. {
  8263. if (conn != null &&
  8264. conn.ConnState == ConnectionState.Open)
  8265. {
  8266. conn.Close();
  8267. }
  8268. }
  8269. }
  8270. /// <summary>
  8271. /// 取得生产线所有的工序
  8272. /// </summary>
  8273. /// <param name="user">登录用户信息</param>
  8274. /// <returns>查询结果</returns>
  8275. public static ServiceResultEntity GetRptProductionLineProcedures(SUserInfo user, int? RptProductionLineID)
  8276. {
  8277. IDBConnection conn = null;
  8278. try
  8279. {
  8280. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8281. string selSql = "select "
  8282. + " tp_pc_procedure.procedureid, "
  8283. + " tp_pc_procedure.Procedurename "
  8284. + " from "
  8285. + " ( "
  8286. + " select TP_PM_ProductionData.Procedureid "
  8287. + " from TP_PM_ProductionData "
  8288. + " where TP_PM_ProductionData.accountid = :accountID "
  8289. + " and TP_PM_ProductionData.productionlineid = :ProductionLineID "
  8290. + " group by TP_PM_ProductionData.Procedureid "
  8291. + " order by TP_PM_ProductionData.Procedureid "
  8292. + " )temp left join tp_pc_procedure "
  8293. + " on tp_pc_procedure.procedureid=temp.procedureid ";
  8294. List<OracleParameter> parameters = new List<OracleParameter>();
  8295. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8296. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, RptProductionLineID, ParameterDirection.Input));
  8297. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8298. ServiceResultEntity sre = new ServiceResultEntity();
  8299. if (data == null || data.Rows.Count == 0)
  8300. {
  8301. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8302. return sre;
  8303. }
  8304. sre.Data = new DataSet();
  8305. sre.Data.Tables.Add(data);
  8306. return sre;
  8307. }
  8308. catch (Exception ex)
  8309. {
  8310. throw ex;
  8311. }
  8312. finally
  8313. {
  8314. if (conn != null &&
  8315. conn.ConnState == ConnectionState.Open)
  8316. {
  8317. conn.Close();
  8318. }
  8319. }
  8320. }
  8321. /// <summary>
  8322. /// 取得数据字典数据
  8323. /// </summary>
  8324. /// <param name="Pvalue">显示停用标识</param>
  8325. /// <param name="dictionaryType">字典类别</param>
  8326. /// <param name="user">登录用户信息</param>
  8327. /// <returns>查询结果</returns>
  8328. public static ServiceResultEntity GetRptDictionaryData(byte Pvalue, string dictionaryType, SUserInfo user)
  8329. {
  8330. IDBConnection conn = null;
  8331. try
  8332. {
  8333. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8334. string selSql = String.Empty;
  8335. List<OracleParameter> parameters = new List<OracleParameter>();
  8336. //根据帐套获得数据字典管理的数据
  8337. if (Pvalue.ToString() == Constant.INT_IS_ONE.ToString())
  8338. {
  8339. selSql = "Select DictionaryID,DictionaryType,DictionaryValue,DisplayNo,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,"
  8340. + "UpdateUserID,OPTimeStamp from TP_MST_DataDictionary where DictionaryType = :DictionaryType and AccountID = :AccountID";
  8341. parameters.Add(new OracleParameter(":DictionaryType", OracleDbType.NVarchar2, dictionaryType, ParameterDirection.Input));
  8342. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8343. }
  8344. //根据帐套,标识获得数据字典管理的数据
  8345. else if (Pvalue.ToString() == Constant.INT_IS_ZERO.ToString())
  8346. {
  8347. selSql = "Select DictionaryID,DictionaryType,DictionaryValue,DisplayNo,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,"
  8348. + "UpdateUserID,OPTimeStamp from TP_MST_DataDictionary where valueflag = :valueflag and DictionaryType = :DictionaryType and AccountID = :AccountID";
  8349. parameters.Add(new OracleParameter(":valueflag", OracleDbType.Int32, Constant.INT_IS_ONE, ParameterDirection.Input));
  8350. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8351. parameters.Add(new OracleParameter(":DictionaryType", OracleDbType.NVarchar2, dictionaryType, ParameterDirection.Input));
  8352. }
  8353. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8354. ServiceResultEntity sre = new ServiceResultEntity();
  8355. if (data == null || data.Rows.Count == 0)
  8356. {
  8357. //sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8358. return sre;
  8359. }
  8360. sre.Data = new DataSet();
  8361. sre.Data.Tables.Add(data);
  8362. return sre;
  8363. }
  8364. catch (Exception ex)
  8365. {
  8366. throw ex;
  8367. }
  8368. finally
  8369. {
  8370. if (conn != null &&
  8371. conn.ConnState == ConnectionState.Open)
  8372. {
  8373. conn.Close();
  8374. }
  8375. }
  8376. }
  8377. #endregion 公共函数
  8378. #endregion 统一使用Se模式rviceResultEntity类
  8379. /// <summary>
  8380. /// 获取注浆次数报表
  8381. /// </summary>
  8382. /// <param name="groutingLineEntity"></param>
  8383. /// <param name="user"></param>
  8384. /// <returns></returns>
  8385. public static ServiceResultEntity GetGroutingCount(GroutingLineEntity groutingLineEntity, SUserInfo user)
  8386. {
  8387. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8388. try
  8389. {
  8390. con.Open();
  8391. OracleParameter[] paras = new OracleParameter[]{
  8392. new OracleParameter("BuildingNo",OracleDbType.NVarchar2,
  8393. groutingLineEntity.BUILDINGNO,ParameterDirection.Input),
  8394. new OracleParameter("FloorNo",OracleDbType.NVarchar2,
  8395. groutingLineEntity.FLOORNO,ParameterDirection.Input),
  8396. new OracleParameter("GroutingLineNo",OracleDbType.NVarchar2,
  8397. groutingLineEntity.GROUTINGLINENO,ParameterDirection.Input),
  8398. new OracleParameter("GroutingLineCode",OracleDbType.NVarchar2,
  8399. groutingLineEntity.GROUTINGLINECODE,ParameterDirection.Input),
  8400. new OracleParameter("GroutingLineName",OracleDbType.NVarchar2,
  8401. groutingLineEntity.GROUTINGLINENAME,ParameterDirection.Input),
  8402. new OracleParameter("GMouldTypeID",OracleDbType.Int32,
  8403. groutingLineEntity.MOULDTYPEID,ParameterDirection.Input),
  8404. new OracleParameter("remarks",OracleDbType.NVarchar2,
  8405. groutingLineEntity.REMARKS,ParameterDirection.Input),
  8406. new OracleParameter("AccountID",OracleDbType.Int32,
  8407. user.AccountID,ParameterDirection.Input),
  8408. new OracleParameter("UserId",OracleDbType.Int32,
  8409. user.UserID,ParameterDirection.Input),
  8410. new OracleParameter("PurviewType",OracleDbType.Int32,
  8411. groutingLineEntity.Purview,ParameterDirection.Input),
  8412. new OracleParameter("rs_result",OracleDbType.RefCursor,
  8413. ParameterDirection.Output),
  8414. new OracleParameter("UserCode",OracleDbType.NVarchar2,
  8415. groutingLineEntity.USERCODE,ParameterDirection.Input),
  8416. };
  8417. //调用获取符合条件的成型线信息
  8418. DataSet ds = con.ExecStoredProcedure("PRO_RPT_GetGroutingCount", paras);
  8419. ServiceResultEntity sre = new ServiceResultEntity();
  8420. if (ds == null || ds.Tables[0].Rows.Count == 0)
  8421. {
  8422. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8423. return sre;
  8424. }
  8425. sre.Data = new DataSet();
  8426. //DataTable dt=ds.Tables[0];
  8427. sre.Data.Tables.Add(ds.Tables[0].Copy());
  8428. return sre;
  8429. }
  8430. catch (Exception ex)
  8431. {
  8432. throw ex;
  8433. }
  8434. finally
  8435. {
  8436. if (con.ConnState == ConnectionState.Open)
  8437. {
  8438. con.Close();
  8439. }
  8440. }
  8441. }
  8442. #region 在产产品汇总表
  8443. /// <summary>
  8444. /// 取得RPT030105(在产产品汇总表)的汇总信息查询数据
  8445. /// </summary>
  8446. /// <param name="user">登录用户信息</param>
  8447. /// <param name="se">查询条件</param>
  8448. /// <returns>查询结果</returns>
  8449. public static ServiceResultEntity GetRPT030105Data(SUserInfo user, RPT030105_SE se)
  8450. {
  8451. IDBConnection conn = null;
  8452. try
  8453. {
  8454. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8455. List<OracleParameter> parameters = new List<OracleParameter>();
  8456. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030105SQL(user, se, ref parameters));
  8457. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  8458. ServiceResultEntity sre = new ServiceResultEntity();
  8459. if (data == null || data.Rows.Count == 0)
  8460. {
  8461. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8462. return sre;
  8463. }
  8464. sre.Data = new DataSet();
  8465. sre.Data.Tables.Add(data);
  8466. return sre;
  8467. }
  8468. catch (Exception ex)
  8469. {
  8470. throw ex;
  8471. }
  8472. finally
  8473. {
  8474. if (conn != null &&
  8475. conn.ConnState == ConnectionState.Open)
  8476. {
  8477. conn.Close();
  8478. }
  8479. }
  8480. }
  8481. /// <summary>
  8482. /// 获取RPT030105画面(产品产量汇总表)的汇总信息查询sql
  8483. /// </summary>
  8484. /// <returns>sql</returns>
  8485. private static string GetRPT030105SQL(SUserInfo user, RPT030105_SE se, ref List<OracleParameter> parameters)
  8486. {
  8487. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8488. //"select " +
  8489. //" ProcedureID," +
  8490. //" procedurecode, " +
  8491. //" decode(Usercode, '小计', '--', procedurename) procedurename, " +
  8492. //" productionlineid, " +
  8493. //" productionlinecode, " +
  8494. //" decode(Usercode, '小计', '--', productionlinename) productionlinename, " +
  8495. //" decode(ProcedureID,'总计','总计',Usercode) Usercode, " +
  8496. //" subGoodsTypecode, " +
  8497. //" decode(usercode,'小计',decode(subGoodsTypecode,'001001','大件','小件'),Goodscode)Goodscode, " +
  8498. //" Goodstypename, " +
  8499. //" InCount " +
  8500. #region
  8501. /*
  8502. "select " +
  8503. " ProcedureID," +
  8504. " procedurecode, " +
  8505. " decode(productionlinename, '总计', '--', procedurename) procedurename, " +
  8506. " productionlineid, " +
  8507. " productionlinecode, " +
  8508. " productionlinename, " +
  8509. " decode(productionlinename, '--', '--', Usercode) Usercode, " +
  8510. " decode(productionlinename, '--', null, UserID) UserID, " +
  8511. " subGoodsTypecode, " +
  8512. " Goodsid," +
  8513. " Goodscode, " +
  8514. " Goodstypename, " +
  8515. " InCount from (" +
  8516. "select " +
  8517. " ProcedureID," +
  8518. " procedurecode, " +
  8519. " decode(usercode,'合计','合计', decode(usercode,'小计','--',decode(usercode,'--','--',procedurename))) procedurename, " +
  8520. " productionlineid, " +
  8521. " productionlinecode, " +
  8522. " decode(ProcedureID,'总计','总计',decode(usercode,'小计','--',productionlinename)) productionlinename, " +
  8523. " decode(ProcedureID,'总计','--',Usercode) Usercode, " +
  8524. " decode(ProcedureID,'总计',null,Userid) Userid, " +
  8525. " subGoodsTypecode, " +
  8526. " Goodsid," +
  8527. " Goodscode, " +
  8528. " decode(usercode,'小计','小计',Goodstypename)Goodstypename, " +
  8529. " InCount " +
  8530. "from " +
  8531. "(" +
  8532. " select " +
  8533. " ProcedureID, " +
  8534. " procedurecode, " +
  8535. " procedurename, " +
  8536. " productionlineid, " +
  8537. " productionlinecode, " +
  8538. " productionlinename, " +
  8539. " decode(procedurecode,'--','合计',Usercode) Usercode, " +
  8540. " decode(procedurecode,'--',null,Userid) Userid, " +
  8541. " subGoodsTypecode," +
  8542. " Goodsid," +
  8543. " Goodscode," +
  8544. " Goodstypename, " +
  8545. " InCount " +
  8546. " from ( select " +
  8547. " decode(grouping(tp_pc_procedure.ProcedureID),1,'总计',tp_pc_procedure.ProcedureID) ProcedureID," +
  8548. " decode(grouping(tp_pc_procedure.procedurecode),1,'--',tp_pc_procedure.procedurecode) procedurecode, " +
  8549. " decode(grouping(tp_pc_procedure.procedurename),1,'--',tp_pc_procedure.procedurename) procedurename, " +
  8550. " decode(grouping(tp_pm_inproduction.productionlineid),1,'--',tp_pm_inproduction.productionlineid) productionlineid, " +
  8551. " decode(grouping(tp_pm_inproduction.productionlinecode),1,'--',tp_pm_inproduction.productionlinecode) productionlinecode, " +
  8552. " decode(grouping(tp_pm_inproduction.productionlinename),1,'--',tp_pm_inproduction.productionlinename) productionlinename, " +
  8553. " decode(grouping(TP_MST_User.Usercode),1,'小计',TP_MST_User.Usercode) Usercode," +
  8554. " decode(grouping(TP_MST_User.Userid),1,null,TP_MST_User.Userid) Userid," +
  8555. " decode(grouping(substr(TP_MST_GoodsType.Goodstypecode,0,6)),1,'--',substr(TP_MST_GoodsType.Goodstypecode,0,6)) subGoodsTypecode," +
  8556. " decode(grouping(TP_MST_Goods.Goodscode),1,'--',TP_MST_Goods.Goodscode) Goodscode," +
  8557. " decode(grouping(TP_MST_Goods.Goodsid),1,'--',TP_MST_Goods.Goodsid) Goodsid," +
  8558. " decode(grouping(TP_MST_GoodsType.Goodstypename),1,'--',TP_MST_GoodsType.Goodstypename) Goodstypename," +
  8559. " count(barcode) as InCount " +
  8560. " from tp_pm_inproduction " +
  8561. " left join tp_pc_procedure" +
  8562. " on tp_pm_inproduction.FlowProcedureID=tp_pc_procedure.ProcedureID" +
  8563. " 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" +
  8564. " Where 1=1 " +
  8565. " and tp_pm_inproduction.AccountID=:AccountID and tp_pm_inproduction.valueflag=1";
  8566. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  8567. {
  8568. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1";
  8569. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1";
  8570. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  8571. }
  8572. if (!string.IsNullOrEmpty(se.LineIDS))
  8573. {
  8574. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||tp_pm_inproduction.ProductionLineId||',')>0 ";
  8575. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  8576. }
  8577. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  8578. {
  8579. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||tp_pm_inproduction.FlowProcedureId||',')>0 ";
  8580. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  8581. }
  8582. if (!string.IsNullOrEmpty(se.GoodsCode))
  8583. {
  8584. selSql = selSql + " AND instr(','||:GoodsCode||',',','||tp_pm_inproduction.goodsCode||',')>0 ";
  8585. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  8586. }
  8587. selSql = selSql +
  8588. "group by " +
  8589. " rollup(tp_pc_procedure.ProcedureID, " +
  8590. " tp_pc_procedure.procedurecode, " +
  8591. " tp_pc_procedure.procedurename, " +
  8592. " tp_pm_inproduction.productionlineid, " +
  8593. " tp_pm_inproduction.productionlinecode, " +
  8594. " tp_pm_inproduction.productionlinename, " +
  8595. " substr(TP_MST_GoodsType.Goodstypecode,0,6), " +
  8596. " TP_MST_User.Usercode," +
  8597. " TP_MST_Goods.Goodscode, " +
  8598. " TP_MST_User.UserID," +
  8599. " TP_MST_Goods.GoodsID, " +
  8600. " TP_MST_GoodsType.Goodstypename)) temp ) temp2 " +
  8601. "where 1=1 " +
  8602. "and (Goodstypename!='--')" +
  8603. "or (Goodstypename='--' and UserCode='小计' and subGoodsTypecode!='--') " +
  8604. "or (Goodstypename='--' and UserCode='合计') " +
  8605. "or (Goodstypename='--' and UserCode='总计') )";
  8606. */
  8607. #endregion
  8608. string sqlString = "select t.productionlineid\n" +
  8609. " ,t.productionlinecode\n" +
  8610. " ,decode(gid\n" +
  8611. " ,15\n" +
  8612. " ,'总计【' || t.productionlinename || '】'\n" +
  8613. " ,t.productionlinename) productionlinename\n" +
  8614. " ,t.ProcedureID\n" +
  8615. " ,t.procedurecode\n" +
  8616. " ,decode(gid, 3, '合计【' || t.procedurename || '】', t.procedurename) procedurename\n" +
  8617. " ,t.Goodstypeid2\n" +
  8618. " ,t.Goodstypecode2\n" +
  8619. " ,decode(gid, 1, '小计【' || t.Goodstypename2 || '】', t.Goodstypename2) Goodstypename2\n" +
  8620. " ,t.Goodsid\n" +
  8621. " ,t.Goodscode\n" +
  8622. " ,t.InCount\n" +
  8623. " from (select grouping_id(inp.productionlineid\n" +
  8624. " ,inp.ProcedureID\n" +
  8625. " ,gt2.Goodstypeid\n" +
  8626. " ,inp.Goodsid) gid\n" +
  8627. " ,inp.productionlineid\n" +
  8628. " ,pline.productionlinecode\n" +
  8629. " ,pline.productionlinename\n" +
  8630. " ,inp.ProcedureID\n" +
  8631. " ,p.procedurecode\n" +
  8632. " ,p.procedurename\n" +
  8633. " ,gt2.GoodstypeID GoodstypeID2\n" +
  8634. " ,gt2.Goodstypecode Goodstypecode2\n" +
  8635. " ,gt2.Goodstypename Goodstypename2\n" +
  8636. " ,inp.Goodsid\n" +
  8637. " ,g.Goodscode\n" +
  8638. " ,count(barcode) as InCount\n" +
  8639. " from tp_pm_inproduction inp\n" +
  8640. " inner join tp_pc_procedure p\n" +
  8641. " on inp.ProcedureID = p.ProcedureID\n" +
  8642. " inner join tp_pc_productionline pline\n" +
  8643. " on pline.productionlineid = inp.productionlineid\n" +
  8644. " inner join TP_MST_User u\n" +
  8645. " on inp.userid = u.Userid\n" +
  8646. " inner join TP_MST_Goods g\n" +
  8647. " on inp.goodsid = g.Goodsid\n" +
  8648. " inner join TP_MST_GoodsType gt\n" +
  8649. " on g.GoodsTypeID = gt.GoodsTypeID\n" +
  8650. " inner join TP_MST_GoodsType gt2\n" +
  8651. " on gt.accountid = gt2.accountid\n" +
  8652. " and substr(gt.Goodstypecode, 0, 6) = gt2.Goodstypecode\n" +
  8653. " where inp.AccountID = 1\n" +
  8654. " and inp.valueflag = '1'\n";
  8655. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  8656. {
  8657. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1";
  8658. sqlString += " AND instr(gt.GOODSTYPECode,:GoodsTypeIDS)=1";
  8659. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  8660. }
  8661. if (!string.IsNullOrEmpty(se.LineIDS))
  8662. {
  8663. sqlString += " AND instr(','||:ProductionLineIDS||',',','||inp.ProductionLineId||',')>0 ";
  8664. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  8665. }
  8666. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  8667. {
  8668. sqlString += " AND instr(','||:ProcedureIDS||',',','||inp.ProcedureId||',')>0 ";
  8669. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  8670. }
  8671. if (!string.IsNullOrEmpty(se.GoodsCode))
  8672. {
  8673. sqlString += " AND instr(','||:GoodsCode||',',','||inp.goodsCode||',')>0 ";
  8674. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  8675. }
  8676. 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";
  8677. return sqlString;
  8678. }
  8679. /// <summary>
  8680. /// 取得RPT030105(在产产品汇总表)的汇总信息查询数据
  8681. /// </summary>
  8682. /// <param name="user">登录用户信息</param>
  8683. /// <param name="se">查询条件</param>
  8684. /// <returns>查询结果</returns>
  8685. public static ServiceResultEntity GetRPT030105IData(SUserInfo user, RPT030105_SE se)
  8686. {
  8687. IDBConnection conn = null;
  8688. try
  8689. {
  8690. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8691. List<OracleParameter> parameters = new List<OracleParameter>();
  8692. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030105ISQL(user, se, ref parameters));
  8693. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8694. if (se != null)
  8695. {
  8696. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  8697. {
  8698. //sql.Append(" AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1");
  8699. sql.Append(" AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1");
  8700. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  8701. }
  8702. if (!string.IsNullOrEmpty(se.LineIDS))
  8703. {
  8704. sql.Append(" AND instr(','||:ProductionLineIDS||',',','||tp_pm_inproduction.ProductionLineId||',')>0 ");
  8705. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  8706. }
  8707. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  8708. {
  8709. sql.Append(" AND instr(','||:ProcedureIDS||',',','||tp_pm_inproduction.FlowProcedureId||',')>0 ");
  8710. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  8711. }
  8712. if (!string.IsNullOrEmpty(se.GoodsCode))
  8713. {
  8714. sql.Append(" AND instr(','||:GoodsCode||',',','||tp_pm_inproduction.goodsCode||',')>0 ");
  8715. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  8716. }
  8717. // 总单点击查询用
  8718. if (se.GoodsID.HasValue)
  8719. {
  8720. sql.Append(" AND tp_pm_inproduction.Goodsid = :GoodsID ");
  8721. parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  8722. }
  8723. if (se.UserID.HasValue)
  8724. {
  8725. sql.Append(" AND A.userid = :userid ");
  8726. parameters.Add(new OracleParameter(":userid", OracleDbType.Int32, se.UserID, ParameterDirection.Input));
  8727. }
  8728. }
  8729. sql.Append(" order by TP_PM_InProduction.UpdateTime desc");
  8730. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  8731. ServiceResultEntity sre = new ServiceResultEntity();
  8732. if (data == null || data.Rows.Count == 0)
  8733. {
  8734. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8735. return sre;
  8736. }
  8737. sre.Data = new DataSet();
  8738. sre.Data.Tables.Add(data);
  8739. return sre;
  8740. }
  8741. catch (Exception ex)
  8742. {
  8743. throw ex;
  8744. }
  8745. finally
  8746. {
  8747. if (conn != null &&
  8748. conn.ConnState == ConnectionState.Open)
  8749. {
  8750. conn.Close();
  8751. }
  8752. }
  8753. }
  8754. /// <summary>
  8755. /// 获取RPT030105画面(产品产量汇总表)的汇总信息查询sql
  8756. /// </summary>
  8757. /// <returns>sql</returns>
  8758. private static string GetRPT030105ISQL(SUserInfo user, RPT030105_SE se, ref List<OracleParameter> parameters)
  8759. {
  8760. string selSql =
  8761. "SELECT " +
  8762. " TP_PM_InProduction.BarCode, " +
  8763. " TP_PM_InProduction.GoodsID,TP_PM_InProduction.GoodsCode, " +
  8764. " TP_PM_InProduction.GoodsName, " +
  8765. " TP_PM_InProduction.Userid,A.USERNAME as UserName,A.USERCode as UserCode, " +
  8766. " TP_PM_InProduction.ProductionLineID, " +
  8767. " TP_PM_InProduction.ProductionLineCode, " +
  8768. " TP_PM_InProduction.ProductionLineName, " +
  8769. " TP_PM_InProduction.ModelType, " +
  8770. " decode(TP_PM_InProduction.inscrapflag , '1', '待审核的报废品' , '正常') as inscrapflag, " +
  8771. //" decode(TP_PM_InProduction.IsPublicBody, '1', '是' , '否') as IsPublicBody, " +
  8772. //" decode(TP_PM_InProduction.IsReFire, '1', '是' , '否') as IsReFire, " +
  8773. " TP_PM_InProduction.IsPublicBody, " +
  8774. " decode(TP_PM_InProduction.IsReFire, '6', '1' , '0') as IsReFire, " +
  8775. " decode(TP_PM_InProduction.CanManyTimes, '1', '能' , '不能') as CanManyTimes, " +
  8776. " decode(TP_PM_InProduction.ProcedureModel, '1', '计件模型' , '检验模型') as ProcedureModel, " +
  8777. " TP_PM_InProduction.GroutingDailyID, " +
  8778. " TP_PM_InProduction.GroutingDailyDetailID, " +
  8779. " TP_PM_InProduction.GroutingDate, " +
  8780. " TP_PM_InProduction.GroutingLineID, " +
  8781. " TP_PM_InProduction.GroutingLineCode, " +
  8782. " TP_PM_InProduction.GroutingLineName, " +
  8783. " TP_PM_InProduction.ProcedureID CompleteProcedureID, " +
  8784. " D.ProcedureName as CompleteProcedureName, " +
  8785. " TP_PM_InProduction.GMouldTypeID, " +
  8786. " TP_MST_GMouldType.GMOULDTYPENAME as GMouldTypeName, " +
  8787. " TP_PM_InProduction.GroutingLineDetailID, " +
  8788. " TP_PM_InProduction.GroutingMouldCode, " +
  8789. " TP_PM_InProduction.SPECIALREPAIRFLAG, " +
  8790. " TP_PM_InProduction.GROUTINGUSERCODE, " +
  8791. " TP_PM_GroutingDailyDetail.GROUTINGCOUNT, " +
  8792. " TP_PM_InProduction.Remarks, " +
  8793. " TP_PM_GroutingDailyDetail.glazingroom," +
  8794. " TP_PM_InProduction.GoodsLevelID,TP_MST_GoodsLevel.GOODSLEVELNAME, " +
  8795. " TP_PM_InProduction.GoodsLevelTypeID,TP_SYS_GoodsLevelType.GOODSLEVELTYPENAME, " +
  8796. " TP_PM_InProduction.AccountID,TP_PM_InProduction.ValueFlag, " +
  8797. " TP_PM_InProduction.CreateTime,TP_PM_InProduction.CreateUserID,B.USERNAME as CreateUserName, " +
  8798. " TP_PM_InProduction.PROCEDURETIME AS UpdateTime,TP_PM_InProduction.UpdateUserID,C.USERNAME as UpdateUserName, " +
  8799. " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName " +
  8800. "FROM TP_PM_InProduction " +
  8801. " inner join TP_MST_User A on A.UserID=TP_PM_InProduction.Userid " +
  8802. " inner join TP_MST_User B on B.UserID=TP_PM_InProduction.CreateUserID " +
  8803. " inner join TP_MST_User C on C.UserID=TP_PM_InProduction.UpdateUserID " +
  8804. " inner join TP_PC_Procedure D on D.PROCEDUREID=TP_PM_InProduction.ProcedureID " +
  8805. " inner join TP_MST_GMouldType on TP_MST_GMouldType.GMouldTypeID=TP_PM_InProduction.GMouldTypeID " +
  8806. " inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.ProcedureModelTypeID=TP_PM_InProduction.ModelType " +
  8807. " inner join TP_PM_GroutingDaily on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_InProduction.GroutingDailyID " +
  8808. " inner join TP_PM_GroutingDailyDetail on TP_PM_GroutingDailyDetail.Groutingdailydetailid=TP_PM_InProduction.GroutingDailyDetailID " +
  8809. " inner join TP_PC_GroutingLineDetail on TP_PC_GroutingLineDetail.Groutinglinedetailid=TP_PM_InProduction.GroutingLineDetailID " +
  8810. " inner join TP_MST_Account on TP_MST_Account.Accountid=TP_PM_InProduction.Accountid " +
  8811. " left join TP_MST_GoodsLevel on TP_MST_GoodsLevel.GoodsLevelID=TP_PM_InProduction.GoodsLevelID " +
  8812. " left join TP_SYS_GoodsLevelType on TP_SYS_GoodsLevelType.GoodsLevelTypeID=TP_PM_InProduction.GoodsLevelTypeID " +
  8813. " left join TP_MST_Logo on TP_PM_InProduction.logoid=TP_MST_Logo.logoid " +
  8814. " left join TP_MST_Goods on tp_pm_inproduction.goodsid=TP_MST_Goods.Goodsid " +
  8815. " left join TP_MST_GoodsType on TP_MST_Goods.GoodsTypeID=TP_MST_GoodsType.GoodsTypeID" +
  8816. " Where 1=1 and TP_PM_InProduction.ValueFlag = 1 " +
  8817. " and TP_PM_InProduction.AccountID=:AccountID ";
  8818. return selSql;
  8819. }
  8820. #endregion
  8821. /// <summary>
  8822. /// 取得RPT030106(成检缺陷汇总表)的汇总信息查询数据
  8823. /// </summary>
  8824. /// <param name="user">登录用户信息</param>
  8825. /// <param name="se">查询条件</param>
  8826. /// <returns>查询结果</returns>
  8827. public static ServiceResultEntity GetRPT030106Data(SUserInfo user, RPT030106_SE se)
  8828. {
  8829. IDBConnection conn = null;
  8830. try
  8831. {
  8832. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8833. List<OracleParameter> parameters = new List<OracleParameter>();
  8834. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106SQL(user, se, ref parameters));
  8835. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  8836. ServiceResultEntity sre = new ServiceResultEntity();
  8837. if (data == null || data.Rows.Count == 0)
  8838. {
  8839. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8840. return sre;
  8841. }
  8842. sre.Data = new DataSet();
  8843. sre.Data.Tables.Add(data);
  8844. return sre;
  8845. }
  8846. catch (Exception ex)
  8847. {
  8848. throw ex;
  8849. }
  8850. finally
  8851. {
  8852. if (conn != null &&
  8853. conn.ConnState == ConnectionState.Open)
  8854. {
  8855. conn.Close();
  8856. }
  8857. }
  8858. }
  8859. /// <summary>
  8860. /// 获取RPT030106画面(成检缺陷汇总表)的汇总信息查询sql
  8861. /// </summary>
  8862. /// <returns>sql</returns>
  8863. private static string GetRPT030106SQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
  8864. {
  8865. #region
  8866. //string selSql = "";
  8867. //parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8868. //selSql = selSql +
  8869. // "select " +
  8870. // " DefectProcedureID," +
  8871. // " DefectProcedureCode, " +
  8872. // " decode(DefectProcedureID, '总计', '--', decode(DefectCode, '小计', decode(DefectProcedureName, '', '', '--'), DefectProcedureName)) DefectProcedureName," +
  8873. // " ProductionLineID, " +
  8874. // " ProductionLineCode," +
  8875. // " decode(DefectProcedureID, '总计', '总计', decode(DefectCode, '小计', '--', ProductionLineName)) ProductionLineName, " +
  8876. // " ProcedureID, " +
  8877. // " ProcedureCode," +
  8878. // " decode(DefectCode, '小计', '--', ProcedureName) ProcedureName," +
  8879. // " DefectCode, " +
  8880. // " DefectName, " +
  8881. // " DefectTypeName, " +
  8882. // " Userid," +
  8883. // " Usercode," +
  8884. // " Username," +
  8885. // " Goodstypename," +
  8886. // " Goodsid," +
  8887. // " Goodscode," +
  8888. // " Goodsname," +
  8889. // " InCount from (" +
  8890. // "select " +
  8891. // " DefectProcedureID," +
  8892. // " DefectProcedureCode, " +
  8893. // " decode(DefectProcedureCode, '--', '合计', DefectProcedureName) DefectProcedureName, " +
  8894. // " ProductionLineID, " +
  8895. // " ProductionLineCode, " +
  8896. // " ProductionLineName, " +
  8897. // " ProcedureID, " +
  8898. // " ProcedureCode, " +
  8899. // " ProcedureName, " +
  8900. // " decode(DefectName, '--', decode(DefectCode, '--', '--', '小计'), DefectCode) DefectCode, " +
  8901. // " DefectName, " +
  8902. // " DefectTypeName, " +
  8903. // " Userid, " +
  8904. // " Usercode, " +
  8905. // " Username, " +
  8906. // " Goodstypename, " +
  8907. // " Goodsid, " +
  8908. // " Goodscode, " +
  8909. // " Goodsname, " +
  8910. // " InCount " +
  8911. // "from " +
  8912. // "(" +
  8913. // " select " +
  8914. // " decode(grouping(TP_PM_Defect.DefectProcedureID),1,'总计',TP_PM_Defect.DefectProcedureID) DefectProcedureID, " +
  8915. // " decode(grouping(TP_PM_Defect.DefectProcedureCode),1,'--',TP_PM_Defect.DefectProcedureCode) DefectProcedureCode, " +
  8916. // " decode(grouping(TP_PM_Defect.DefectProcedureName),1,'--',TP_PM_Defect.DefectProcedureName) DefectProcedureName, " +
  8917. // " decode(grouping(TP_PM_Defect.ProductionLineID),1,'--',TP_PM_Defect.ProductionLineID) ProductionLineID, " +
  8918. // " decode(grouping(TP_PM_Defect.ProductionLineCode),1,'--',TP_PM_Defect.ProductionLineCode) ProductionLineCode, " +
  8919. // " decode(grouping(TP_PM_Defect.ProductionLineName),1,'--',TP_PM_Defect.ProductionLineName) ProductionLineName, " +
  8920. // " decode(grouping(TP_PM_Defect.ProcedureID),1,'--',TP_PM_Defect.ProcedureID) ProcedureID, " +
  8921. // " decode(grouping(TP_PM_Defect.ProcedureCode),1,'--',TP_PM_Defect.ProcedureCode) ProcedureCode," +
  8922. // " decode(grouping(TP_PM_Defect.ProcedureName),1,'--',TP_PM_Defect.ProcedureName) ProcedureName," +
  8923. // " decode(grouping(TP_PM_Defect.DefectCode),1,'--',TP_PM_Defect.DefectCode) DefectCode, " +
  8924. // " decode(grouping(TP_PM_Defect.DefectName),1,'--',TP_PM_Defect.DefectName) DefectName, " +
  8925. // " decode(grouping(TP_MST_DefectType.DefectTypeName),1,'--',TP_MST_DefectType.DefectTypeName) DefectTypeName, " +
  8926. // " decode(grouping(TP_PM_Defect.Userid),1,'--',TP_PM_Defect.Userid) Userid, " +
  8927. // " decode(grouping(TP_PM_Defect.Usercode),1,'--',TP_PM_Defect.Usercode) Usercode, " +
  8928. // " decode(grouping(TP_PM_Defect.Username),1,'--',TP_PM_Defect.Username) Username, " +
  8929. // " decode(grouping(TP_MST_GoodsType.Goodstypename),1,'--',TP_MST_GoodsType.Goodstypename) Goodstypename, " +
  8930. // " decode(grouping(TP_PM_Defect.Goodsid),1,'--',TP_PM_Defect.Goodsid) Goodsid, " +
  8931. // " decode(grouping(TP_PM_Defect.Goodscode),1,'--',TP_PM_Defect.Goodscode) Goodscode, " +
  8932. // " decode(grouping(TP_PM_Defect.Goodsname),1,'--',TP_PM_Defect.Goodscode) Goodsname, " +
  8933. // " count(TP_PM_Defect.barcode) as InCount " +
  8934. // " from TP_PM_Defect " +
  8935. // " left join tp_pc_procedure on TP_PM_Defect.ProcedureID=tp_pc_procedure.ProcedureID " +
  8936. // " left join TP_MST_Goods on TP_PM_Defect.Goodsid=TP_MST_Goods.Goodsid" +
  8937. // " left join TP_MST_GoodsType on TP_MST_Goods.GoodsTypeID = TP_MST_GoodsType.GoodsTypeID" +
  8938. // " left join TP_MST_Defect on TP_PM_Defect.DefectID=TP_MST_Defect.DefectID" +
  8939. // " left join TP_MST_DefectType on TP_MST_Defect.DefectTypeID=TP_MST_DefectType.DefectTypeID" +
  8940. // " left join TP_PM_ProductionData on TP_PM_ProductionData.ProductionDataID=TP_PM_Defect.ProductionDataID" +
  8941. // " Where TP_PM_Defect.valueflag=1 and tp_pc_procedure.ModelType=-1" +
  8942. // " and TP_PM_Defect.AccountID=:AccountID ";
  8943. //if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  8944. //{
  8945. // selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeCode)=1 ";
  8946. // parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  8947. //}
  8948. //if (!string.IsNullOrEmpty(se.LineIDS))
  8949. //{
  8950. // selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_Defect.ProductionLineId||',')>0 ";
  8951. // parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  8952. //}
  8953. //if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  8954. //{
  8955. // //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  8956. // selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 ) ";
  8957. // parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  8958. //}
  8959. //else
  8960. //{
  8961. // // modify by chenxy :没有选择时,应全查询出来。
  8962. // //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  8963. //}
  8964. //if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  8965. //{
  8966. // selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_Defect.ProcedureID||',')>0 ";
  8967. // parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  8968. //}
  8969. //if (!string.IsNullOrEmpty(se.KilnCode))
  8970. //{
  8971. // selSql = selSql + " AND instr(tp_pm_productiondata.KilnCode,:KilnCode) >0 ";
  8972. // parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  8973. //}
  8974. //if (!string.IsNullOrEmpty(se.GoodsIDS))
  8975. //{
  8976. // selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_Defect.Goodsid||',')>0 ";
  8977. // parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  8978. //}
  8979. //if (!string.IsNullOrEmpty(se.GoodsCode))
  8980. //{
  8981. // selSql = selSql + " AND instr(TP_PM_Defect.goodsCode,:GoodsCode) >0 ";
  8982. // parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  8983. //}
  8984. //if (!string.IsNullOrEmpty(se.DefectUserCode))
  8985. //{
  8986. // selSql = selSql + " AND instr(TP_PM_Defect.DefectUserCode,:DefectUserCode) >0 ";
  8987. // parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  8988. //}
  8989. //if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  8990. //{
  8991. // selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||TP_MST_DefectType.DefectTypeID||',')>0 ";
  8992. // parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  8993. //}
  8994. //if (!string.IsNullOrEmpty(se.DefectCode))
  8995. //{
  8996. // selSql = selSql + " AND instr(TP_PM_Defect.DefectCode,:DefectCode) >0 ";
  8997. // parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  8998. //}
  8999. //if (!string.IsNullOrEmpty(se.DefectName))
  9000. //{
  9001. // selSql = selSql + " AND instr(TP_PM_Defect.DefectName,:DefectName) >0";
  9002. // parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  9003. //}
  9004. //if (!string.IsNullOrEmpty(se.CheckUserCode))
  9005. //{
  9006. // selSql = selSql + " AND instr(TP_PM_Defect.UserCode,:UserCode) >0";
  9007. // parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  9008. //}
  9009. //if (se.CreateTimeStart.HasValue)
  9010. //{
  9011. // selSql = selSql + " AND TP_PM_Defect.CreateTime>= :CreateTimeStart ";
  9012. // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9013. //}
  9014. //if (se.CreateTimeEnd.HasValue)
  9015. //{
  9016. // selSql = selSql + " AND TP_PM_Defect.CreateTime<= :CreateTimeEnd ";
  9017. // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9018. //}
  9019. //selSql = selSql +
  9020. // "group by " +
  9021. // " rollup(TP_PM_Defect.DefectProcedureID, " +
  9022. // " TP_PM_Defect.DefectProcedureCode, " +
  9023. // " TP_PM_Defect.DefectProcedureName, " +
  9024. // " TP_PM_Defect.ProductionLineID, " +
  9025. // " TP_PM_Defect.ProductionLineCode, " +
  9026. // " TP_PM_Defect.ProductionLineName, " +
  9027. // " TP_PM_Defect.ProcedureID, " +
  9028. // " TP_PM_Defect.ProcedureCode," +
  9029. // " TP_PM_Defect.ProcedureName, " +
  9030. // " TP_PM_Defect.DefectCode, " +
  9031. // " TP_PM_Defect.DefectName, " +
  9032. // " TP_MST_DefectType.DefectTypeName, " +
  9033. // " TP_PM_Defect.Userid, " +
  9034. // " TP_PM_Defect.Usercode, " +
  9035. // " TP_PM_Defect.Username, " +
  9036. // " TP_MST_GoodsType.Goodstypename, " +
  9037. // " TP_PM_Defect.Goodsid, " +
  9038. // " TP_PM_Defect.Goodscode, " +
  9039. // " TP_PM_Defect.Goodsname " +
  9040. // " )) temp ) temp2 " +
  9041. // "where 1=1 " +
  9042. // "and ((Goodsname!='--' )" +
  9043. // "or (Goodsname='--' and defectcode='小计')" +
  9044. // "or (Goodsname='--' and DefectProcedurename='合计') " +
  9045. // "or (Goodsname='--' and DefectProcedureID='总计'))";
  9046. //////----------------------
  9047. ////if (!string.IsNullOrEmpty(se.CompleteProcedureIDS))
  9048. ////{
  9049. //// selSql = selSql + @" AND exists(select 1 from tp_pm_productiondata where (instr(','||:CompleteProcedureIDS||',',','||ProcedureID||',')>0 ";
  9050. //// parameters.Add(new OracleParameter(":CompleteProcedureIDS", OracleDbType.NVarchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  9051. //// selSql = selSql + " AND TP_PM_ProductionData.CreateTime>= :CompleteCreateTimeStart ";
  9052. //// parameters.Add(new OracleParameter(":CompleteCreateTimeStart", OracleDbType.Date, se.CompleteCreateTimeStart.Value, ParameterDirection.Input));
  9053. //// selSql = selSql + " AND TP_PM_ProductionData.CreateTime<= :CompleteCreateTimeEnd )) ";
  9054. //// parameters.Add(new OracleParameter(":CompleteCreateTimeEnd", OracleDbType.Date, se.CompleteCreateTimeEnd.Value, ParameterDirection.Input));
  9055. ////}
  9056. //////----------------------
  9057. //return selSql;
  9058. #endregion
  9059. string selSql =
  9060. "SELECT t.ProductionLineID\n" +
  9061. " ,t.ProductionLineCode\n" +
  9062. " ,decode(t.gid, 31, '总计', 0, t.ProductionLineName, '--') ProductionLineName\n" +
  9063. " ,t.ProcedureID\n" +
  9064. " ,t.ProcedureCode\n" +
  9065. " ,decode(t.gid, 0, t.ProcedureName, '--') ProcedureName\n" +
  9066. " ,t.DefectProcedureID\n" +
  9067. " ,t.DefectProcedureCode\n" +
  9068. " ,decode(t.gid,\n" +
  9069. " 7,\n" +
  9070. " '合计【' || t.DefectProcedureName || '】',\n" +
  9071. " 0,\n" +
  9072. " t.DefectProcedureName,\n" +
  9073. " '--') DefectProcedureName\n" +
  9074. " ,decode(t.gid, 0, t.DefectCode, '--') DefectCode\n" +
  9075. " ,decode(t.gid,\n" +
  9076. " 3,\n" +
  9077. " '小计【[' || t.DefectCode || ']' || t.DefectName || '】',\n" +
  9078. " 0,\n" +
  9079. " t.DefectName,\n" +
  9080. " '--') DefectName\n" +
  9081. " ,decode(t.gid, 0, t.DefectTypeName, '--') DefectTypeName\n" +
  9082. " --,decode(t.gid, 0, t.Userid, '--') Userid\n" +
  9083. " ,t.Userid\n" +
  9084. " ,decode(t.gid, 0, t.Usercode, '--') Usercode\n" +
  9085. " ,decode(t.gid, 0, t.Username, '--') Username\n" +
  9086. " ,decode(t.gid, 0, t.Goodstypename, '--') Goodstypename\n" +
  9087. " --,decode(t.gid, 0, t.Goodsid, '--') Goodsid\n" +
  9088. " ,t.Goodsid\n" +
  9089. " ,decode(t.gid, 0, t.Goodscode, '--') Goodscode\n" +
  9090. " ,decode(t.gid, 0, t.Goodsname, '--') Goodsname\n" +
  9091. " ,t.InCount\n" +
  9092. " FROM (SELECT grouping_id(pmd.ProductionLineID,\n" +
  9093. " pmd.DefectProcedureID,\n" +
  9094. " pmd.DefectCode,\n" +
  9095. " pmd.userid,\n" +
  9096. " pmd.goodsid) gid\n" +
  9097. " ,pmd.ProductionLineID\n" +
  9098. " ,pmd.ProductionLineCode\n" +
  9099. " ,pmd.ProductionLineName\n" +
  9100. " ,pmd.ProcedureID\n" +
  9101. " ,pmd.ProcedureCode\n" +
  9102. " ,pmd.ProcedureName\n" +
  9103. " ,pmd.DefectProcedureID\n" +
  9104. " ,pmd.DefectProcedureCode\n" +
  9105. " ,pmd.DefectProcedureName\n" +
  9106. " ,pmd.DefectCode\n" +
  9107. " ,pmd.DefectName\n" +
  9108. " ,dt.DefectTypeName\n" +
  9109. " ,pmd.Userid\n" +
  9110. " ,pmd.Usercode\n" +
  9111. " ,pmd.Username\n" +
  9112. " ,gt.Goodstypename\n" +
  9113. " ,pmd.Goodsid\n" +
  9114. " ,pmd.Goodscode\n" +
  9115. " ,pmd.Goodsname\n" +
  9116. " ,COUNT(pmd.barcode) InCount\n" +
  9117. " FROM tp_pm_defect pmd\n" +
  9118. " LEFT JOIN TP_MST_Goods g\n" +
  9119. " ON pmd.Goodsid = g.Goodsid\n" +
  9120. " LEFT JOIN TP_MST_GoodsType gt\n" +
  9121. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  9122. " LEFT JOIN TP_MST_Defect mstd\n" +
  9123. " ON pmd.DefectID = mstd.DefectID\n" +
  9124. " LEFT JOIN TP_MST_DefectType dt\n" +
  9125. " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
  9126. " INNER JOIN tp_pm_productiondata pd\n" +
  9127. " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
  9128. " -- 交接工序\n" +
  9129. " INNER JOIN tp_pm_productiondata hopd\n" +
  9130. " ON hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  9131. " AND hopd.valueflag = '1'\n" +
  9132. " AND hopd.barcode = pd.barcode\n" +
  9133. " AND hopd.kilncarbatchno = pd.kilncarbatchno\n" +
  9134. " WHERE pmd.valueflag = '1'\n" +
  9135. " AND pd.ModelType = -1\n" +
  9136. " AND pmd.AccountID = :AccountID\n";
  9137. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  9138. parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
  9139. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  9140. {
  9141. selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
  9142. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  9143. }
  9144. if (!string.IsNullOrEmpty(se.LineIDS))
  9145. {
  9146. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
  9147. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  9148. }
  9149. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  9150. {
  9151. //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  9152. selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
  9153. parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  9154. }
  9155. else
  9156. {
  9157. // modify by chenxy :没有选择时,应全查询出来。
  9158. //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  9159. }
  9160. if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  9161. {
  9162. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
  9163. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  9164. }
  9165. if (!string.IsNullOrEmpty(se.KilnCode))
  9166. {
  9167. selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
  9168. parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  9169. }
  9170. if (!string.IsNullOrEmpty(se.GoodsIDS))
  9171. {
  9172. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
  9173. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  9174. }
  9175. if (!string.IsNullOrEmpty(se.GoodsCode))
  9176. {
  9177. selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
  9178. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  9179. }
  9180. if (!string.IsNullOrEmpty(se.DefectUserCode))
  9181. {
  9182. selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
  9183. parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  9184. }
  9185. if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  9186. {
  9187. selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
  9188. parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  9189. }
  9190. if (!string.IsNullOrEmpty(se.DefectCode))
  9191. {
  9192. selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
  9193. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  9194. }
  9195. if (!string.IsNullOrEmpty(se.DefectName))
  9196. {
  9197. selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
  9198. parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  9199. }
  9200. if (!string.IsNullOrEmpty(se.CheckUserCode))
  9201. {
  9202. selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
  9203. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  9204. }
  9205. if (se.CreateTimeStart.HasValue)
  9206. {
  9207. selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
  9208. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9209. }
  9210. if (se.CreateTimeEnd.HasValue)
  9211. {
  9212. selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
  9213. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9214. }
  9215. // 交接时间
  9216. if (se.HandOverTimeStart.HasValue)
  9217. {
  9218. selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
  9219. parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
  9220. }
  9221. if (se.HandOverTimeEnd.HasValue)
  9222. {
  9223. selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
  9224. parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
  9225. }
  9226. selSql = selSql +
  9227. " 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" +
  9228. " ORDER BY pmd.ProductionLineCode\n" +
  9229. " ,pmd.ProcedureCode\n" +
  9230. " ,pmd.DefectProcedureCode\n" +
  9231. " ,pmd.DefectCode\n" +
  9232. " ,pmd.Usercode\n" +
  9233. " ,pmd.Goodscode) t";
  9234. return selSql;
  9235. }
  9236. /// <summary>
  9237. /// 取得RPT030106(成检缺陷汇总表-明细)的汇总信息查询数据
  9238. /// </summary>
  9239. /// <param name="user">登录用户信息</param>
  9240. /// <param name="se">查询条件</param>
  9241. /// <returns>查询结果</returns>
  9242. public static ServiceResultEntity GetRPT030106IData(SUserInfo user, RPT030106_SE se)
  9243. {
  9244. IDBConnection conn = null;
  9245. try
  9246. {
  9247. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  9248. List<OracleParameter> parameters = new List<OracleParameter>();
  9249. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106ISQL(user, se, ref parameters));
  9250. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  9251. ServiceResultEntity sre = new ServiceResultEntity();
  9252. if (data == null || data.Rows.Count == 0)
  9253. {
  9254. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  9255. return sre;
  9256. }
  9257. sre.Data = new DataSet();
  9258. sre.Data.Tables.Add(data);
  9259. return sre;
  9260. }
  9261. catch (Exception ex)
  9262. {
  9263. throw ex;
  9264. }
  9265. finally
  9266. {
  9267. if (conn != null &&
  9268. conn.ConnState == ConnectionState.Open)
  9269. {
  9270. conn.Close();
  9271. }
  9272. }
  9273. }
  9274. /// <summary>
  9275. /// 获取RPT030106画面(成检缺陷汇总表-明细)的汇总信息查询sql
  9276. /// </summary>
  9277. /// <returns>sql</returns>
  9278. private static string GetRPT030106ISQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
  9279. {
  9280. // string selSql = @"select
  9281. // tp_pm_defect.productionlinename,
  9282. // tp_pm_defect.procedurename,
  9283. // tp_pm_defect.DefectProcedureCode,
  9284. // tp_pm_defect.DefectProcedureName,
  9285. // tp_pm_defect.DefectUserCode,
  9286. // tp_pm_defect.defectusername,
  9287. // tp_mst_defectType.DefectTypeName,
  9288. // TP_MST_Defect.Remarks DefectRemarks,
  9289. // tp_pm_defect.defectcode,
  9290. // tp_pm_defect.defectname,
  9291. // tp_pm_defect.UserCode,
  9292. // tp_pm_defect.username,
  9293. // tp_mst_goodstype.Goodstypename,
  9294. // tp_pm_defect.goodscode,
  9295. // tp_pm_defect.barcode,
  9296. // tp_pm_productiondata.groutingdate,
  9297. // tp_pm_productiondata.groutingnum,
  9298. // tp_pm_productiondata.groutingMouldCode,
  9299. // tp_pm_productiondata.KilnCarCode,
  9300. // tp_pm_productiondata.Procedureid,
  9301. // decode(TP_PM_ProductionData.Goodsleveltypeid, '4', '正品' , '5','副品','6','重烧','7','次品','') as Goodsleveltype,
  9302. // tp_pm_defect.DefectPositionCode,
  9303. // tp_pm_defect.DefectPositionName,
  9304. // tp_pm_productiondata.GroutingUserCode,
  9305. // --replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName
  9306. // decode(TP_MST_Logo.Logocode, null, null,TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']')) as LogoCodeName
  9307. // ,TP_PM_Defect.CreateTime
  9308. // ,(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
  9309. // ,TP_MST_DefectFine.DefectFineCode
  9310. // ,TP_PM_Defect.DefectDeductionNum
  9311. // from tp_pm_defect
  9312. // left join TP_MST_Goods
  9313. // on TP_PM_Defect.Goodsid=TP_MST_Goods.Goodsid
  9314. // left join TP_MST_GoodsType
  9315. // on TP_MST_Goods.GoodsTypeID = TP_MST_GoodsType.GoodsTypeID
  9316. // left join TP_MST_Defect
  9317. // on TP_PM_Defect.DefectID=TP_MST_Defect.DefectID
  9318. // left join TP_MST_DefectType
  9319. // on TP_MST_Defect.DefectTypeID=TP_MST_DefectType.DefectTypeID
  9320. // inner join tp_pm_productiondata
  9321. // on tp_pm_defect.ProductionDataID=tp_pm_productiondata.ProductionDataID
  9322. // left join TP_MST_DefectFine
  9323. // on tp_pm_defect.DefectFine=TP_MST_DefectFine.DefectFineID
  9324. // left join tp_mst_logo
  9325. // on tp_pm_productiondata.logoid=tp_mst_logo.logoid";
  9326. // 质量登记改判时,缺陷的登记时间是当前时间,不是交接或前次登记时间。
  9327. // 追加交接时间,改判标识。
  9328. string selSql =
  9329. "SELECT pmd.productionlinename\n" +
  9330. " ,pmd.procedurename\n" +
  9331. " ,pmd.DefectProcedureCode\n" +
  9332. " ,pmd.DefectProcedureName\n" +
  9333. " ,pmd.DefectUserCode\n" +
  9334. " ,pmd.defectusername\n" +
  9335. " ,dt.DefectTypeName\n" +
  9336. " ,mstd.Remarks DefectRemarks\n" +
  9337. " ,pmd.defectcode\n" +
  9338. " ,d.alldefectcode\n" +
  9339. " ,pmd.defectname\n" +
  9340. " ,pmd.UserCode\n" +
  9341. " ,pmd.username\n" +
  9342. " ,gt.Goodstypename\n" +
  9343. " ,pmd.goodscode\n" +
  9344. " ,pmd.barcode\n" +
  9345. " ,pd.groutingdate\n" +
  9346. " ,pd.groutingnum\n" +
  9347. " ,pd.groutingMouldCode\n" +
  9348. " ,pd.groutingLineCode\n" +
  9349. " ,pd.KilnCarCode\n" +
  9350. " ,pd.Procedureid\n" +
  9351. " ,gl.goodslevelname Goodsleveltype\n" +
  9352. " ,pmd.DefectPositionCode\n" +
  9353. " ,pmd.DefectPositionName\n" +
  9354. " ,pd.GroutingUserCode\n" +
  9355. " , CASE\n" +
  9356. " WHEN logo.logoid IS NULL THEN\n" +
  9357. " NULL\n" +
  9358. " ELSE\n" +
  9359. " logo.Logoname || '[' || logo.Logocode || ']'\n" +
  9360. " END AS LogoCodeName\n" +
  9361. " ,pmd.CreateTime\n" +
  9362. " ,mstdf.DefectFineCode\n" +
  9363. " ,pmd.DefectDeductionNum\n" +
  9364. //" ,to_char(pmd.DefectDeductionNum, '990.00') DefectDeductionNum\n" +
  9365. " ,hopd.createtime handovertime\n" +
  9366. " ,(SELECT listagg(to_char(pduc.UserCode), ',') within GROUP(ORDER BY pduc.ProductionDataID) AS WorkUserCodes\n" +
  9367. " FROM tp_pm_ProductionData pduc\n" +
  9368. " WHERE pduc.barcode = pmd.barcode\n" +
  9369. " AND pduc.valueflag = '1') AS WorkUserCodes\n" +
  9370. " ,(SELECT listagg(to_char(u.UserCode), ',') within GROUP(ORDER BY pdcu.ProductionDataID) AS CreateUserCodes\n" +
  9371. " FROM tp_pm_ProductionData pdcu\n" +
  9372. " Left join tp_mst_user u on u.userid = pdcu.createuserid\n" +
  9373. " WHERE pdcu.barcode = pmd.barcode\n" +
  9374. " AND pdcu.valueflag = '1') AS CreateUserCodes\n" +
  9375. " , CASE\n" +
  9376. " WHEN EXISTS (SELECT 1\n" +
  9377. " FROM tp_pm_ProductionData pdud\n" +
  9378. " WHERE pdud.barcode = pmd.barcode\n" +
  9379. " AND pdud.modeltype = -1\n" +
  9380. " AND pdud.procedureid = pd.procedureid\n" +
  9381. " AND pdud.kilncarbatchno = pd.kilncarbatchno\n" +
  9382. " AND pdud.valueflag = '0') THEN\n" +
  9383. " 1\n" +
  9384. " ELSE\n" +
  9385. " 0\n" +
  9386. " END AS undoflag\n" +
  9387. " , CASE\n" +
  9388. " WHEN EXISTS (SELECT 1\n" +
  9389. " FROM tp_pm_semicheck sc\n" +
  9390. " WHERE sc.barcode = pmd.barcode\n" +
  9391. " AND sc.SEMICHECKTYPE = 1\n" +
  9392. " AND sc.valueflag = '1') THEN\n" +
  9393. " 1\n" +
  9394. " ELSE\n" +
  9395. " 0\n" +
  9396. " END reworkflag" +
  9397. " ,gdd.glazingroom" +
  9398. //" ,gdd.retainflag" +
  9399. " FROM tp_pm_defect pmd\n" +
  9400. " LEFT JOIN TP_MST_Goods g\n" +
  9401. " ON pmd.Goodsid = g.Goodsid\n" +
  9402. " LEFT JOIN TP_MST_GoodsType gt\n" +
  9403. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  9404. " LEFT JOIN TP_MST_Defect mstd\n" +
  9405. " ON pmd.DefectID = mstd.DefectID\n" +
  9406. " LEFT JOIN TP_MST_DefectType dt\n" +
  9407. " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
  9408. " INNER JOIN tp_pm_productiondata pd\n" +
  9409. " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
  9410. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  9411. " ON gdd.Groutingdailydetailid = pd.Groutingdailydetailid\n" +
  9412. " LEFT JOIN tp_mst_goodslevel gl\n" +
  9413. " ON pd.goodslevelid = gl.goodslevelid\n" +
  9414. "-- 交接工序\n" +
  9415. " INNER JOIN tp_pm_productiondata hopd\n" +
  9416. " ON hopd.kilncarbatchno = pd.kilncarbatchno\n " +
  9417. " AND hopd.barcode = pd.barcode\n" +
  9418. " AND hopd.valueflag = '1'\n" +
  9419. " AND hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  9420. " LEFT JOIN TP_MST_DefectFine mstdf\n" +
  9421. " ON pmd.DefectFine = mstdf.DefectFineID\n" +
  9422. " LEFT JOIN tp_mst_logo logo\n" +
  9423. " ON pd.logoid = logo.logoid\n" +
  9424. " LEFT JOIN (SELECT def.barcode, wmsys.wm_concat( to_char(def.defectcode)) alldefectcode\n" +
  9425. " FROM tp_pm_defect def\n" +
  9426. " WHERE def.valueflag = '1'\n" +
  9427. //def.createtime
  9428. " group by def.barcode ) d\n" +
  9429. " ON d.barcode = pmd.barcode\n" +
  9430. " WHERE pmd.valueflag = '1' \n" +
  9431. " AND pd.ModelType = -1\n" +
  9432. " AND pmd.AccountID = :AccountID\n";
  9433. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  9434. parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
  9435. //selSql = selSql +
  9436. // " Where TP_PM_Defect.valueflag='1' and tp_pm_productiondata.ModelType=-1" +
  9437. // " and TP_PM_Defect.AccountID=:AccountID ";
  9438. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  9439. {
  9440. selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
  9441. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  9442. }
  9443. if (!string.IsNullOrEmpty(se.LineIDS))
  9444. {
  9445. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
  9446. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  9447. }
  9448. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  9449. {
  9450. //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  9451. selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
  9452. parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  9453. }
  9454. else
  9455. {
  9456. // modify by chenxy :没有选择时,应全查询出来。
  9457. //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  9458. }
  9459. if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  9460. {
  9461. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
  9462. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  9463. }
  9464. if (!string.IsNullOrEmpty(se.KilnCode))
  9465. {
  9466. selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
  9467. parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  9468. }
  9469. if (!string.IsNullOrEmpty(se.GoodsIDS))
  9470. {
  9471. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
  9472. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  9473. }
  9474. if (!string.IsNullOrEmpty(se.GoodsCode))
  9475. {
  9476. selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
  9477. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  9478. }
  9479. if (!string.IsNullOrEmpty(se.GoodsCodeS2D))
  9480. {
  9481. selSql = selSql + " AND pmd.goodsCode = :GoodsCodeS2D ";
  9482. parameters.Add(new OracleParameter(":GoodsCodeS2D", OracleDbType.NVarchar2, se.GoodsCodeS2D, ParameterDirection.Input));
  9483. }
  9484. if (!string.IsNullOrEmpty(se.DefectUserCode))
  9485. {
  9486. selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
  9487. parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  9488. }
  9489. if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  9490. {
  9491. selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
  9492. parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  9493. }
  9494. if (!string.IsNullOrEmpty(se.DefectCode))
  9495. {
  9496. selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
  9497. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  9498. }
  9499. if (!string.IsNullOrEmpty(se.DefectCodeS2D))
  9500. {
  9501. selSql = selSql + " AND pmd.DefectCode = :DefectCodeS2D ";
  9502. parameters.Add(new OracleParameter(":DefectCodeS2D", OracleDbType.NVarchar2, se.DefectCodeS2D, ParameterDirection.Input));
  9503. }
  9504. if (!string.IsNullOrEmpty(se.DefectName))
  9505. {
  9506. selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
  9507. parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  9508. }
  9509. if (!string.IsNullOrEmpty(se.CheckUserCode))
  9510. {
  9511. selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
  9512. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  9513. }
  9514. if (!string.IsNullOrEmpty(se.CheckUserCodeS2D))
  9515. {
  9516. selSql = selSql + " AND pmd.UserCode = :CheckUserCodeS2D ";
  9517. parameters.Add(new OracleParameter(":CheckUserCodeS2D", OracleDbType.NVarchar2, se.CheckUserCodeS2D, ParameterDirection.Input));
  9518. }
  9519. // 登记时间(缺陷)
  9520. if (se.CreateTimeStart.HasValue)
  9521. {
  9522. selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
  9523. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9524. }
  9525. if (se.CreateTimeEnd.HasValue)
  9526. {
  9527. selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
  9528. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9529. }
  9530. // 交接时间
  9531. if (se.HandOverTimeStart.HasValue)
  9532. {
  9533. selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
  9534. parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
  9535. }
  9536. if (se.HandOverTimeEnd.HasValue)
  9537. {
  9538. selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
  9539. parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
  9540. }
  9541. //if (!string.IsNullOrEmpty(se.PurViewUserCodeIDS))
  9542. //{
  9543. // selSql = selSql + " AND instr(','||:PurViewUserCodeIDS||',',','||TP_PM_Defect.DefectUserID||',')>0 ";
  9544. // parameters.Add(new OracleParameter(":PurViewUserCodeIDS", OracleDbType.NVarchar2, se.PurViewUserCodeIDS, ParameterDirection.Input));
  9545. //}
  9546. ////----------------------
  9547. //if (!string.IsNullOrEmpty(se.CompleteProcedureIDS))
  9548. //{
  9549. // selSql = selSql + @" AND exists(select 1 from tp_pm_productiondata where (instr(','||:CompleteProcedureIDS||',',','||ProcedureID||',')>0 ";
  9550. // parameters.Add(new OracleParameter(":CompleteProcedureIDS", OracleDbType.NVarchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  9551. // selSql = selSql + " AND TP_PM_ProductionData.CreateTime>= :CompleteCreateTimeStart ";
  9552. // parameters.Add(new OracleParameter(":CompleteCreateTimeStart", OracleDbType.Date, se.CompleteCreateTimeStart.Value, ParameterDirection.Input));
  9553. // selSql = selSql + " AND TP_PM_ProductionData.CreateTime<= :CompleteCreateTimeEnd )) ";
  9554. // parameters.Add(new OracleParameter(":CompleteCreateTimeEnd", OracleDbType.Date, se.CompleteCreateTimeEnd.Value, ParameterDirection.Input));
  9555. //}
  9556. ////----------------------
  9557. selSql = selSql + " order by pmd.productionlinename,pmd.procedurename,pmd.defectprocedurename,pmd.defectusercode ";
  9558. return selSql;
  9559. }
  9560. /// <summary>
  9561. /// 取得RPT030106(成检缺陷汇总表-缺陷登记明细)的汇总信息查询数据
  9562. /// </summary>
  9563. /// <param name="user">登录用户信息</param>
  9564. /// <param name="se">查询条件</param>
  9565. /// <returns>查询结果</returns>
  9566. public static ServiceResultEntity GetRPT030106DData(SUserInfo user, RPT030106_SE se)
  9567. {
  9568. IDBConnection conn = null;
  9569. try
  9570. {
  9571. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  9572. List<OracleParameter> parameters = new List<OracleParameter>();
  9573. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106DSQL(user, se, ref parameters));
  9574. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  9575. ServiceResultEntity sre = new ServiceResultEntity();
  9576. if (data == null || data.Rows.Count == 0)
  9577. {
  9578. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  9579. return sre;
  9580. }
  9581. sre.Data = new DataSet();
  9582. sre.Data.Tables.Add(data);
  9583. return sre;
  9584. }
  9585. catch (Exception ex)
  9586. {
  9587. throw ex;
  9588. }
  9589. finally
  9590. {
  9591. if (conn != null &&
  9592. conn.ConnState == ConnectionState.Open)
  9593. {
  9594. conn.Close();
  9595. }
  9596. }
  9597. }
  9598. /// <summary>
  9599. /// 获取RPT030106画面(成检缺陷汇总表-缺陷登记明细)的汇总信息查询sql
  9600. /// </summary>
  9601. /// <returns>sql</returns>
  9602. private static string GetRPT030106DSQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
  9603. {
  9604. // 质量登记改判时,缺陷的登记时间是当前时间,不是交接或前次登记时间。
  9605. // 追加交接时间,改判标识。
  9606. string selSql =
  9607. "SELECT pmd.productionlinename\n" +
  9608. " ,pmd.procedurename\n" +
  9609. " ,pmd.DefectProcedureCode\n" +
  9610. " ,pmd.DefectProcedureName\n" +
  9611. " ,pmd.DefectUserCode\n" +
  9612. " ,pmd.defectusername\n" +
  9613. " ,jobs.jobsname defectjobsname\n" +
  9614. " ,dt.DefectTypeName\n" +
  9615. " ,mstd.Remarks DefectRemarks\n" +
  9616. " ,pd.Remarks barcodeRemarks\n" +
  9617. " ,pmd.defectcode\n" +
  9618. " ,d.alldefectcode\n" +
  9619. " ,pmd.defectname\n" +
  9620. " ,pmd.UserCode\n" +
  9621. " ,pmd.username\n" +
  9622. " ,gt.Goodstypename\n" +
  9623. " ,pmd.goodscode\n" +
  9624. " ,pmd.barcode\n" +
  9625. " ,pd.groutingdate\n" +
  9626. " ,pd.groutingnum\n" +
  9627. " ,pd.groutingMouldCode\n" +
  9628. " ,pd.GroutingLineCode\n" +
  9629. " ,pd.KilnCarCode\n" +
  9630. " ,pd.Procedureid\n" +
  9631. " ,gl.goodslevelname Goodsleveltype\n" +
  9632. " ,pmd.DefectPositionCode\n" +
  9633. " ,pmd.DefectPositionName\n" +
  9634. " ,pd.GroutingUserCode\n" +
  9635. " , CASE\n" +
  9636. " WHEN logo.logoid IS NULL THEN\n" +
  9637. " NULL\n" +
  9638. " ELSE\n" +
  9639. " logo.Logoname || '[' || logo.Logocode || ']'\n" +
  9640. " END AS LogoCodeName\n" +
  9641. //" ,pmd.CreateTime\n" +
  9642. " ,pd.CheckTime pdchecktime\n" +
  9643. " ,pmd.CheckTime\n" +
  9644. " ,mstdf.DefectFineCode\n" +
  9645. " ,pmd.DefectDeductionNum\n" +
  9646. //" ,to_char(pmd.DefectDeductionNum, '990.00') DefectDeductionNum\n" +
  9647. " ,hopd.createtime handovertime\n" +
  9648. " ,(SELECT listagg(to_char(pduc.UserCode), ',') within GROUP(ORDER BY pduc.ProductionDataID) AS WorkUserCodes\n" +
  9649. " FROM tp_pm_ProductionData pduc\n" +
  9650. " WHERE pduc.barcode = pmd.barcode\n" +
  9651. " AND pduc.valueflag = '1') AS WorkUserCodes\n" +
  9652. " ,(SELECT listagg(to_char(u.UserCode), ',') within GROUP(ORDER BY pdcu.ProductionDataID) AS CreateUserCodes\n" +
  9653. " FROM tp_pm_ProductionData pdcu\n" +
  9654. " Left join tp_mst_user u on u.userid = pdcu.createuserid\n" +
  9655. " WHERE pdcu.barcode = pmd.barcode\n" +
  9656. " AND pdcu.valueflag = '1') AS CreateUserCodes\n" +
  9657. " ,(SELECT listagg(to_char(s.StaffName), ',') within GROUP(ORDER BY s.Staffid) AS DefectStaffNames\n" +
  9658. " FROM TP_PM_DefectResponsible dr\n" +
  9659. " Left join TP_HR_Staff s on s.Staffid = dr.Staffid\n" +
  9660. " WHERE dr.ProductionDefectID = pmd.ProductionDefectID --dr pdcu.valueflag = '1'\n" +
  9661. " ) AS DefectStaffNames\n" +
  9662. " , CASE\n" +
  9663. " WHEN pd.isrefire <> '0' THEN\n" +
  9664. " (select listagg(to_char(d.defectname || '[' || d.defectpositionname || ']')\n" +
  9665. " ,',') within group(order by d.productiondefectid) bsqx\n" +
  9666. " from tp_pm_productiondata p\n" +
  9667. " inner join tp_pm_defect d\n" +
  9668. " on d.productiondataid = p.productiondataid\n" +
  9669. " where p.valueflag = '1'\n" +
  9670. " and d.valueflag = '1'\n" +
  9671. " and p.barcode = pd.barcode\n" +
  9672. " and p.modeltype = -1\n" +
  9673. " and p.isrefire = '0')\n" +
  9674. " ELSE\n" +
  9675. " null\n" +
  9676. " END AS bsqx\n" +
  9677. " , CASE\n" +
  9678. " WHEN EXISTS (SELECT 1\n" +
  9679. " FROM tp_pm_ProductionData pdud\n" +
  9680. " WHERE pdud.barcode = pmd.barcode\n" +
  9681. " AND pdud.modeltype = -1\n" +
  9682. " AND pdud.procedureid = pd.procedureid\n" +
  9683. " AND pdud.kilncarbatchno = pd.kilncarbatchno\n" +
  9684. " AND pdud.valueflag = '0') THEN\n" +
  9685. " 1\n" +
  9686. " ELSE\n" +
  9687. " 0\n" +
  9688. " END AS undoflag\n" +
  9689. //" ,gdd.retainflag" +
  9690. " FROM tp_pm_defect pmd\n" +
  9691. " LEFT JOIN TP_PC_Procedure p\n" +
  9692. " ON p.procedureid = pmd.procedureid\n" +
  9693. " LEFT JOIN TP_PC_Procedure pdd\n" +
  9694. " ON pdd.procedureid = pmd.defectprocedureid\n" +
  9695. " LEFT JOIN TP_MST_Goods g\n" +
  9696. " ON pmd.Goodsid = g.Goodsid\n" +
  9697. " LEFT JOIN TP_MST_GoodsType gt\n" +
  9698. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  9699. " LEFT JOIN TP_MST_Defect mstd\n" +
  9700. " ON pmd.DefectID = mstd.DefectID\n" +
  9701. " LEFT JOIN TP_MST_Jobs jobs\n" +
  9702. " ON jobs.jobsid = pmd.Defectjobs\n" +
  9703. " LEFT JOIN TP_MST_DefectType dt\n" +
  9704. " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
  9705. " INNER JOIN tp_pm_productiondata pd\n" +
  9706. " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
  9707. // " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  9708. //" ON gdd.Groutingdailydetailid = pd.Groutingdailydetailid\n" +
  9709. " LEFT JOIN tp_mst_goodslevel gl\n" +
  9710. " ON pd.goodslevelid = gl.goodslevelid\n" +
  9711. //"-- 交接工序\n" +
  9712. //" INNER JOIN tp_pm_productiondata hopd\n" +
  9713. //" ON hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  9714. //" AND hopd.valueflag = '1'\n" +
  9715. //" AND hopd.barcode = pd.barcode\n" +
  9716. //" AND hopd.kilncarbatchno = pd.kilncarbatchno\n" +
  9717. " INNER JOIN tp_pm_productiondata hopd\n" +
  9718. " ON hopd.kilncarbatchno = pd.kilncarbatchno\n " +
  9719. " AND hopd.barcode = pd.barcode\n" +
  9720. " AND hopd.valueflag = '1'\n" +
  9721. " AND hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  9722. " LEFT JOIN TP_MST_DefectFine mstdf\n" +
  9723. " ON pmd.DefectFine = mstdf.DefectFineID\n" +
  9724. " LEFT JOIN tp_mst_logo logo\n" +
  9725. " ON pd.logoid = logo.logoid\n" +
  9726. " LEFT JOIN (SELECT def.barcode, wmsys.wm_concat( to_char(def.defectcode)) alldefectcode\n" +
  9727. " FROM tp_pm_defect def\n" +
  9728. " WHERE def.valueflag = '1'\n" +
  9729. //def.createtime
  9730. " group by def.barcode ) d\n" +
  9731. " ON d.barcode = pmd.barcode\n" +
  9732. " WHERE pmd.valueflag = '1' \n" +
  9733. " AND pd.ModelType = -1\n" +
  9734. " AND pmd.AccountID = :AccountID\n";
  9735. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  9736. parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
  9737. //selSql = selSql +
  9738. // " Where TP_PM_Defect.valueflag='1' and tp_pm_productiondata.ModelType=-1" +
  9739. // " and TP_PM_Defect.AccountID=:AccountID ";
  9740. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  9741. {
  9742. selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
  9743. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  9744. }
  9745. if (!string.IsNullOrEmpty(se.LineIDS))
  9746. {
  9747. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
  9748. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  9749. }
  9750. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  9751. {
  9752. //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  9753. selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
  9754. parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  9755. }
  9756. else
  9757. {
  9758. // modify by chenxy :没有选择时,应全查询出来。
  9759. //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  9760. }
  9761. if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  9762. {
  9763. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
  9764. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  9765. }
  9766. if (!string.IsNullOrEmpty(se.KilnCode))
  9767. {
  9768. selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
  9769. parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  9770. }
  9771. if (!string.IsNullOrEmpty(se.GoodsIDS))
  9772. {
  9773. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
  9774. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  9775. }
  9776. if (!string.IsNullOrEmpty(se.GoodsCode))
  9777. {
  9778. selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
  9779. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  9780. }
  9781. if (!string.IsNullOrEmpty(se.GoodsCodeS2D))
  9782. {
  9783. selSql = selSql + " AND pmd.goodsCode = :GoodsCodeS2D ";
  9784. parameters.Add(new OracleParameter(":GoodsCodeS2D", OracleDbType.NVarchar2, se.GoodsCodeS2D, ParameterDirection.Input));
  9785. }
  9786. if (!string.IsNullOrEmpty(se.DefectUserCode))
  9787. {
  9788. selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
  9789. parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  9790. }
  9791. if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  9792. {
  9793. selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
  9794. parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  9795. }
  9796. if (!string.IsNullOrEmpty(se.DefectCode))
  9797. {
  9798. selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
  9799. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  9800. }
  9801. if (!string.IsNullOrEmpty(se.DefectCodeS2D))
  9802. {
  9803. selSql = selSql + " AND pmd.DefectCode = :DefectCodeS2D ";
  9804. parameters.Add(new OracleParameter(":DefectCodeS2D", OracleDbType.NVarchar2, se.DefectCodeS2D, ParameterDirection.Input));
  9805. }
  9806. if (!string.IsNullOrEmpty(se.DefectName))
  9807. {
  9808. selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
  9809. parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  9810. }
  9811. if (!string.IsNullOrEmpty(se.CheckUserCode))
  9812. {
  9813. selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
  9814. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  9815. }
  9816. if (!string.IsNullOrEmpty(se.CheckUserCodeS2D))
  9817. {
  9818. selSql = selSql + " AND pmd.UserCode = :CheckUserCodeS2D ";
  9819. parameters.Add(new OracleParameter(":CheckUserCodeS2D", OracleDbType.NVarchar2, se.CheckUserCodeS2D, ParameterDirection.Input));
  9820. }
  9821. //if (se.CreateTimeStart.HasValue)
  9822. //{
  9823. // selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
  9824. // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9825. //}
  9826. //if (se.CreateTimeEnd.HasValue)
  9827. //{
  9828. // selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
  9829. // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9830. //}
  9831. // 登记时间(第一次成检)
  9832. if (se.CreateTimeStart.HasValue)
  9833. {
  9834. selSql = selSql + " AND pd.checktime>= :CreateTimeStart ";
  9835. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9836. }
  9837. if (se.CreateTimeEnd.HasValue)
  9838. {
  9839. selSql = selSql + " AND pd.checktime<= :CreateTimeEnd ";
  9840. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9841. }
  9842. // 缺陷登记时间
  9843. if (se.CheckTimeStart.HasValue)
  9844. {
  9845. selSql = selSql + " AND pmd.checktime>= :CheckTimeStart ";
  9846. parameters.Add(new OracleParameter(":CheckTimeStart", OracleDbType.Date, se.CheckTimeStart.Value, ParameterDirection.Input));
  9847. }
  9848. if (se.CheckTimeEnd.HasValue)
  9849. {
  9850. selSql = selSql + " AND pmd.checktime<= :CheckTimeEnd ";
  9851. parameters.Add(new OracleParameter(":CheckTimeEnd", OracleDbType.Date, se.CheckTimeEnd.Value, ParameterDirection.Input));
  9852. }
  9853. // 交接时间
  9854. if (se.HandOverTimeStart.HasValue)
  9855. {
  9856. selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
  9857. parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
  9858. }
  9859. if (se.HandOverTimeEnd.HasValue)
  9860. {
  9861. selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
  9862. parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
  9863. }
  9864. //selSql = selSql + " order by pmd.productionlinename,pmd.procedurename,pmd.defectprocedurename,pmd.defectusercode ";
  9865. selSql = selSql + " order by pmd.productionlinename,p.DISPLAYNO,pdd.DISPLAYNO,dt.DISPLAYNO,mstd.DISPLAYNO,pmd.defectusercode,pmd.barcode ";
  9866. return selSql;
  9867. }
  9868. /// <summary>
  9869. /// 取得RPT030106(成检缺陷汇总表-生产工序信息)的汇总信息查询数据
  9870. /// </summary>
  9871. /// <param name="user">登录用户信息</param>
  9872. /// <param name="se">查询条件</param>
  9873. /// <returns>查询结果</returns>
  9874. public static ServiceResultEntity GetRPT030106ProData(SUserInfo user, RPT030106_SE se)
  9875. {
  9876. IDBConnection conn = null;
  9877. try
  9878. {
  9879. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  9880. List<OracleParameter> parameters = new List<OracleParameter>();
  9881. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106ProSQL(user, se, ref parameters));
  9882. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  9883. ServiceResultEntity sre = new ServiceResultEntity();
  9884. if (data == null || data.Rows.Count == 0)
  9885. {
  9886. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  9887. return sre;
  9888. }
  9889. sre.Data = new DataSet();
  9890. sre.Data.Tables.Add(data);
  9891. return sre;
  9892. }
  9893. catch (Exception ex)
  9894. {
  9895. throw ex;
  9896. }
  9897. finally
  9898. {
  9899. if (conn != null &&
  9900. conn.ConnState == ConnectionState.Open)
  9901. {
  9902. conn.Close();
  9903. }
  9904. }
  9905. }
  9906. /// <summary>
  9907. /// 获取RPT030106画面(成检缺陷汇总表-生产工序信息)的汇总信息查询sql
  9908. /// </summary>
  9909. /// <returns>sql</returns>
  9910. private static string GetRPT030106ProSQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
  9911. {
  9912. // 质量登记改判时,缺陷的登记时间是当前时间,不是交接或前次登记时间。
  9913. // 追加交接时间,改判标识。
  9914. string selSql =
  9915. //"SELECT pmd.productionlinename\n" +
  9916. //" ,pmd.procedurename\n" +
  9917. //" ,pmd.DefectProcedureCode\n" +
  9918. //" ,pmd.DefectProcedureName\n" +
  9919. //" ,pmd.DefectUserCode\n" +
  9920. //" ,pmd.defectusername\n" +
  9921. //" ,jobs.jobsname defectjobsname\n" +
  9922. //" ,dt.DefectTypeName\n" +
  9923. //" ,mstd.Remarks DefectRemarks\n" +
  9924. //" ,pd.Remarks barcodeRemarks\n" +
  9925. //" ,pmd.defectcode\n" +
  9926. //" ,d.alldefectcode\n" +
  9927. //" ,pmd.defectname\n" +
  9928. //" ,pmd.UserCode\n" +
  9929. //" ,pmd.username\n" +
  9930. //" ,gt.Goodstypename\n" +
  9931. //" ,pmd.goodscode\n" +
  9932. //" ,pmd.barcode\n" +
  9933. //" ,pd.groutingdate\n" +
  9934. //" ,pd.groutingnum\n" +
  9935. //" ,pd.groutingMouldCode\n" +
  9936. //" ,pd.GroutingLineCode\n" +
  9937. //" ,pd.KilnCarCode\n" +
  9938. //" ,pd.Procedureid\n" +
  9939. //" ,gl.goodslevelname Goodsleveltype\n" +
  9940. //" ,pmd.DefectPositionCode\n" +
  9941. //" ,pmd.DefectPositionName\n" +
  9942. //" ,pd.GroutingUserCode\n" +
  9943. //" , CASE\n" +
  9944. //" WHEN logo.logoid IS NULL THEN\n" +
  9945. //" NULL\n" +
  9946. //" ELSE\n" +
  9947. //" logo.Logoname || '[' || logo.Logocode || ']'\n" +
  9948. //" END AS LogoCodeName\n" +
  9949. ////" ,pmd.CreateTime\n" +
  9950. //" ,pd.CheckTime pdchecktime\n" +
  9951. //" ,pmd.CheckTime\n" +
  9952. //" ,mstdf.DefectFineCode\n" +
  9953. //" ,pmd.DefectDeductionNum\n" +
  9954. ////" ,to_char(pmd.DefectDeductionNum, '990.00') DefectDeductionNum\n" +
  9955. //" ,hopd.createtime handovertime\n" +
  9956. //" ,(SELECT listagg(to_char(pduc.UserCode), ',') within GROUP(ORDER BY pduc.ProductionDataID) AS WorkUserCodes\n" +
  9957. //" FROM tp_pm_ProductionData pduc\n" +
  9958. //" WHERE pduc.barcode = pmd.barcode\n" +
  9959. //" AND pduc.valueflag = '1') AS WorkUserCodes\n" +
  9960. //" ,(SELECT listagg(to_char(u.UserCode), ',') within GROUP(ORDER BY pdcu.ProductionDataID) AS CreateUserCodes\n" +
  9961. //" FROM tp_pm_ProductionData pdcu\n" +
  9962. //" Left join tp_mst_user u on u.userid = pdcu.createuserid\n" +
  9963. //" WHERE pdcu.barcode = pmd.barcode\n" +
  9964. //" AND pdcu.valueflag = '1') AS CreateUserCodes\n" +
  9965. //" , CASE\n" +
  9966. //" WHEN EXISTS (SELECT 1\n" +
  9967. //" FROM tp_pm_ProductionData pdud\n" +
  9968. //" WHERE pdud.barcode = pmd.barcode\n" +
  9969. //" AND pdud.modeltype = -1\n" +
  9970. //" AND pdud.procedureid = pd.procedureid\n" +
  9971. //" AND pdud.kilncarbatchno = pd.kilncarbatchno\n" +
  9972. //" AND pdud.valueflag = '0') THEN\n" +
  9973. //" 1\n" +
  9974. //" ELSE\n" +
  9975. //" 0\n" +
  9976. //" END AS undoflag\n" +
  9977. "SELECT pmd.goodscode\n" +
  9978. " ,pmd.barcode\n" +
  9979. " ,pmd.defectcode\n" +
  9980. " ,pmd.defectname\n" +
  9981. " ,pmd.DefectPositionCode\n" +
  9982. " ,pmd.DefectPositionName\n" +
  9983. " ,gl.goodslevelname Goodsleveltype\n" +
  9984. " , CASE\n" +
  9985. " WHEN logo.logoid IS NULL THEN\n" +
  9986. " NULL\n" +
  9987. " ELSE\n" +
  9988. " logo.Logoname || '[' || logo.Logocode || ']'\n" +
  9989. " END AS LogoCodeName\n" +
  9990. //" ,pmd.CreateTime\n" +
  9991. " ,pd.CheckTime pdchecktime\n" +
  9992. " ,pmd.CheckTime\n" +
  9993. " ,proddata.CheckTime protime\n" +
  9994. " ,proddata.UserCode prousercode\n" +
  9995. " ,proddata.PROCEDURENAME proname\n" +
  9996. " ,pd.KILNCARCODE KILNCARCODE\n" +
  9997. " FROM tp_pm_defect pmd\n" +
  9998. " INNER JOIN tp_pm_productiondata proddata\n" +
  9999. " ON proddata.barcode = pmd.barcode\n " +
  10000. //" AND proddata.ProcedureID in ('" + se.CompleteProcedureIDS + "')\n" +
  10001. " AND (instr(','||:ProProcedureIDS||',',','||proddata.ProcedureID||',')>0 )\n" +
  10002. " AND proddata.valueflag = '1'\n" +
  10003. " INNER JOIN tp_pm_productiondata pd\n" +
  10004. " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
  10005. " LEFT JOIN TP_PC_Procedure p\n" +
  10006. " ON p.procedureid = pmd.procedureid\n" +
  10007. " LEFT JOIN TP_PC_Procedure pdd\n" +
  10008. " ON pdd.procedureid = pmd.defectprocedureid\n" +
  10009. " LEFT JOIN TP_MST_Goods g\n" +
  10010. " ON pmd.Goodsid = g.Goodsid\n" +
  10011. " LEFT JOIN TP_MST_GoodsType gt\n" +
  10012. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  10013. " LEFT JOIN TP_MST_Defect mstd\n" +
  10014. " ON pmd.DefectID = mstd.DefectID\n" +
  10015. " LEFT JOIN TP_MST_Jobs jobs\n" +
  10016. " ON jobs.jobsid = pmd.Defectjobs\n" +
  10017. " LEFT JOIN TP_MST_DefectType dt\n" +
  10018. " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
  10019. " LEFT JOIN tp_mst_goodslevel gl\n" +
  10020. " ON pd.goodslevelid = gl.goodslevelid\n" +
  10021. "-- 交接工序\n" +
  10022. " INNER JOIN tp_pm_productiondata hopd\n" +
  10023. " ON hopd.kilncarbatchno = pd.kilncarbatchno\n " +
  10024. " AND hopd.barcode = pd.barcode\n" +
  10025. " AND hopd.valueflag = '1'\n" +
  10026. " AND hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  10027. " LEFT JOIN TP_MST_DefectFine mstdf\n" +
  10028. " ON pmd.DefectFine = mstdf.DefectFineID\n" +
  10029. " LEFT JOIN tp_mst_logo logo\n" +
  10030. " ON pd.logoid = logo.logoid\n" +
  10031. //" LEFT JOIN (SELECT def.barcode, wmsys.wm_concat( to_char(def.defectcode)) alldefectcode\n" +
  10032. //" FROM tp_pm_defect def\n" +
  10033. //" WHERE def.valueflag = '1'\n" +
  10034. ////def.createtime
  10035. //" group by def.barcode ) d\n" +
  10036. //" ON d.barcode = pmd.barcode\n" +
  10037. " WHERE pmd.valueflag = '1' \n" +
  10038. " AND pd.ModelType = -1\n" +
  10039. " AND pmd.AccountID = :AccountID\n";
  10040. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  10041. parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
  10042. parameters.Add(new OracleParameter(":ProProcedureIDS", OracleDbType.Varchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  10043. //selSql = selSql +
  10044. // " Where TP_PM_Defect.valueflag='1' and tp_pm_productiondata.ModelType=-1" +
  10045. // " and TP_PM_Defect.AccountID=:AccountID ";
  10046. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  10047. {
  10048. selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
  10049. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  10050. }
  10051. if (!string.IsNullOrEmpty(se.LineIDS))
  10052. {
  10053. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
  10054. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  10055. }
  10056. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  10057. {
  10058. //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  10059. selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
  10060. parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  10061. }
  10062. else
  10063. {
  10064. // modify by chenxy :没有选择时,应全查询出来。
  10065. //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  10066. }
  10067. if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  10068. {
  10069. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
  10070. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  10071. }
  10072. if (!string.IsNullOrEmpty(se.KilnCode))
  10073. {
  10074. selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
  10075. parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  10076. }
  10077. if (!string.IsNullOrEmpty(se.GoodsIDS))
  10078. {
  10079. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
  10080. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  10081. }
  10082. if (!string.IsNullOrEmpty(se.GoodsCode))
  10083. {
  10084. selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
  10085. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  10086. }
  10087. if (!string.IsNullOrEmpty(se.GoodsCodeS2D))
  10088. {
  10089. selSql = selSql + " AND pmd.goodsCode = :GoodsCodeS2D ";
  10090. parameters.Add(new OracleParameter(":GoodsCodeS2D", OracleDbType.NVarchar2, se.GoodsCodeS2D, ParameterDirection.Input));
  10091. }
  10092. if (!string.IsNullOrEmpty(se.DefectUserCode))
  10093. {
  10094. selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
  10095. parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  10096. }
  10097. if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  10098. {
  10099. selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
  10100. parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  10101. }
  10102. if (!string.IsNullOrEmpty(se.DefectCode))
  10103. {
  10104. selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
  10105. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  10106. }
  10107. if (!string.IsNullOrEmpty(se.DefectCodeS2D))
  10108. {
  10109. selSql = selSql + " AND pmd.DefectCode = :DefectCodeS2D ";
  10110. parameters.Add(new OracleParameter(":DefectCodeS2D", OracleDbType.NVarchar2, se.DefectCodeS2D, ParameterDirection.Input));
  10111. }
  10112. if (!string.IsNullOrEmpty(se.DefectName))
  10113. {
  10114. selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
  10115. parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  10116. }
  10117. if (!string.IsNullOrEmpty(se.CheckUserCode))
  10118. {
  10119. selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
  10120. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  10121. }
  10122. if (!string.IsNullOrEmpty(se.CheckUserCodeS2D))
  10123. {
  10124. selSql = selSql + " AND pmd.UserCode = :CheckUserCodeS2D ";
  10125. parameters.Add(new OracleParameter(":CheckUserCodeS2D", OracleDbType.NVarchar2, se.CheckUserCodeS2D, ParameterDirection.Input));
  10126. }
  10127. //if (se.CreateTimeStart.HasValue)
  10128. //{
  10129. // selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
  10130. // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  10131. //}
  10132. //if (se.CreateTimeEnd.HasValue)
  10133. //{
  10134. // selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
  10135. // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  10136. //}
  10137. // 成检登记时间
  10138. if (se.CreateTimeStart.HasValue)
  10139. {
  10140. selSql = selSql + " AND pd.checktime>= :CreateTimeStart ";
  10141. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  10142. }
  10143. if (se.CreateTimeEnd.HasValue)
  10144. {
  10145. selSql = selSql + " AND pd.checktime<= :CreateTimeEnd ";
  10146. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  10147. }
  10148. // 缺陷登记时间
  10149. if (se.CheckTimeStart.HasValue)
  10150. {
  10151. selSql = selSql + " AND pmd.checktime>= :CheckTimeStart ";
  10152. parameters.Add(new OracleParameter(":CheckTimeStart", OracleDbType.Date, se.CheckTimeStart.Value, ParameterDirection.Input));
  10153. }
  10154. if (se.CheckTimeEnd.HasValue)
  10155. {
  10156. selSql = selSql + " AND pmd.checktime<= :CheckTimeEnd ";
  10157. parameters.Add(new OracleParameter(":CheckTimeEnd", OracleDbType.Date, se.CheckTimeEnd.Value, ParameterDirection.Input));
  10158. }
  10159. // 交接时间
  10160. if (se.HandOverTimeStart.HasValue)
  10161. {
  10162. selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
  10163. parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
  10164. }
  10165. if (se.HandOverTimeEnd.HasValue)
  10166. {
  10167. selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
  10168. parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
  10169. }
  10170. //selSql = selSql + " order by pmd.productionlinename,p.DISPLAYNO,pdd.DISPLAYNO,dt.DISPLAYNO,mstd.DISPLAYNO,pmd.defectusercode,pmd.barcode ";
  10171. selSql = selSql + " order by proddata.CheckTime ";
  10172. return selSql;
  10173. }
  10174. /// <summary>
  10175. /// 窑车状态主表查询
  10176. /// </summary>
  10177. /// <param name="kilnCode">窑炉编码</param>
  10178. /// <param name="kilnCarCode">窑车编码</param>
  10179. /// <param name="sUserInfo">用户基本信息</param>
  10180. /// <returns></returns>
  10181. public static ServiceResultEntity GetKilnCarStatusByCode(string kilnCode, string kilnCarCode, SUserInfo sUserInfo)
  10182. {
  10183. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10184. try
  10185. {
  10186. con.Open();
  10187. OracleParameter[] paras = new OracleParameter[]{
  10188. new OracleParameter("in_AccountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  10189. new OracleParameter("in_KilnCode",OracleDbType.Varchar2,kilnCode,ParameterDirection.Input),
  10190. new OracleParameter("in_KilnCarCode",OracleDbType.Varchar2,kilnCarCode,ParameterDirection.Input),
  10191. new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  10192. };
  10193. DataSet dsSearchReport = con.ExecStoredProcedure("PRO_RPT_GetKilnCarStatus", paras);
  10194. ServiceResultEntity sre = new ServiceResultEntity();
  10195. if (dsSearchReport == null || dsSearchReport.Tables[0].Rows.Count == 0)
  10196. {
  10197. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10198. return sre;
  10199. }
  10200. sre.Data = new DataSet();
  10201. sre.Data.Tables.Add(dsSearchReport.Tables[0].Copy());
  10202. return sre;
  10203. }
  10204. catch (Exception ex)
  10205. {
  10206. throw ex;
  10207. }
  10208. finally
  10209. {
  10210. if (con != null &&
  10211. con.ConnState == ConnectionState.Open)
  10212. {
  10213. con.Close();
  10214. }
  10215. }
  10216. }
  10217. /// <summary>
  10218. /// 窑车状态明细表查询
  10219. /// </summary>
  10220. /// <param name="kilnCarCode">窑车编码</param>
  10221. /// <param name="sUserInfo">用户基本信息</param>
  10222. /// <returns></returns>
  10223. public static ServiceResultEntity GetKilnCarStatusDetailByCode(string kilnCarCode, SUserInfo sUserInfo)
  10224. {
  10225. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10226. try
  10227. {
  10228. con.Open();
  10229. OracleParameter[] paras = new OracleParameter[]{
  10230. new OracleParameter("in_AccountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  10231. new OracleParameter("in_KilnCarCode",OracleDbType.Varchar2,kilnCarCode,ParameterDirection.Input),
  10232. new OracleParameter("out_KilnCarData",OracleDbType.RefCursor, ParameterDirection.Output),
  10233. new OracleParameter("out_KilnCarGoods",OracleDbType.RefCursor, ParameterDirection.Output),
  10234. };
  10235. DataSet dsSearchReport = con.ExecStoredProcedure("PRO_RPT_GetKilnCarData", paras);
  10236. ServiceResultEntity sre = new ServiceResultEntity();
  10237. if (dsSearchReport == null || dsSearchReport.Tables[0].Rows.Count == 0)
  10238. {
  10239. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10240. return sre;
  10241. }
  10242. sre.Data = new DataSet();
  10243. sre.Data.Tables.Add(dsSearchReport.Tables[0].Copy());//生产数据
  10244. sre.Data.Tables.Add(dsSearchReport.Tables[1].Copy());//窑车产品
  10245. return sre;
  10246. }
  10247. catch (Exception ex)
  10248. {
  10249. throw ex;
  10250. }
  10251. finally
  10252. {
  10253. if (con != null &&
  10254. con.ConnState == ConnectionState.Open)
  10255. {
  10256. con.Close();
  10257. }
  10258. }
  10259. }
  10260. /// <summary>
  10261. /// 取得RPT010201_1画面(工序漏扫明细表)的查询数据
  10262. /// </summary>
  10263. /// <param name="user">登录用户信息</param>
  10264. /// <param name="se">查询条件</param>
  10265. /// <returns>查询结果</returns>
  10266. public static ServiceResultEntity GetRPT080101SData(SUserInfo user, RPT010201_SE se)
  10267. {
  10268. IDBConnection conn = null;
  10269. try
  10270. {
  10271. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10272. List<OracleParameter> parameters = new List<OracleParameter>();
  10273. parameters.Clear();
  10274. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080101SSQL(user, se, ref parameters));
  10275. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  10276. ServiceResultEntity sre = new ServiceResultEntity();
  10277. if (data == null || data.Rows.Count == 0)
  10278. {
  10279. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10280. return sre;
  10281. }
  10282. sre.Data = new DataSet();
  10283. sre.Data.Tables.Add(data);
  10284. return sre;
  10285. }
  10286. catch (Exception ex)
  10287. {
  10288. throw ex;
  10289. }
  10290. finally
  10291. {
  10292. if (conn != null &&
  10293. conn.ConnState == ConnectionState.Open)
  10294. {
  10295. conn.Close();
  10296. }
  10297. }
  10298. }
  10299. /// <summary>
  10300. /// 获取RPT010201_1画面(工序漏扫明细表)的查询sql
  10301. /// </summary>
  10302. /// <returns>sql</returns>
  10303. private static string GetRPT080101SSQL(SUserInfo user, RPT010201_SE se, ref List<OracleParameter> parameters)
  10304. {
  10305. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  10306. #region
  10307. #endregion
  10308. string sql = @"
  10309. select gd.groutinglinecode,
  10310. gd.groutingmouldcode,
  10311. gd.mouldcode,
  10312. gd.usercode,
  10313. gs.goodscode,
  10314. gs.goodsname,
  10315. gs.goodsspecification,
  10316. gms.gmouldstatusname, -- 模具状态
  10317. --gs.goodsmodel,
  10318. gd.groutingcount, -- 注浆次数
  10319. --gd.groutingnum,
  10320. gd.scrapnum, -- 开模损坯数
  10321. gd.deliverpnum, -- 交坯数
  10322. gd.mingroutingdate, -- 开始注浆时间
  10323. gd.maxgroutingdate, -- 最后注浆时间
  10324. gld.beginuseddate, -- 开始使用时间
  10325. gld.enduseddate, -- 结束使用时间
  10326. zl.OutKilnCount, -- 质量登记数
  10327. zl.GoodCount, -- 正品数
  10328. zl.SubstandardCount, -- 副品数
  10329. zl.ReFireCount, -- 重烧数
  10330. zl.BadCount -- 次品数
  10331. from (select gdd.groutinglinecode,
  10332. gdd.groutingmouldcode,
  10333. gdd.mouldcode,
  10334. gdd.goodsid,
  10335. gdd.groutinglinedetailid,
  10336. wmsys.wm_concat(distinct to_char(gdd.usercode)) usercode,
  10337. max(gdd.groutingcount) groutingcount,
  10338. sum(decode(gdd.groutingflag, '1', 1, 0)) groutingnum,
  10339. sum(decode(gdd.scrapflag, '1', 1, 0)) scrapnum,
  10340. sum(decode(gdd.deliverflag, '1', 1, 0)) deliverpnum,
  10341. min(gdd.groutingdate) mingroutingdate,
  10342. max(gdd.groutingdate) maxgroutingdate
  10343. from tp_pm_groutingdailydetail gdd
  10344. where gdd.groutingflag = '1'
  10345. and gdd.AccountID = :AccountID
  10346. ";
  10347. // 成型线编码
  10348. if (!string.IsNullOrEmpty(se.groutinglinecode))
  10349. {
  10350. //sql = sql + " and gdd.groutinglinecode=:groutinglinecode";
  10351. sql = sql + " and instr(gdd.groutinglinecode,:groutinglinecode)>0";
  10352. parameters.Add(new OracleParameter(":groutinglinecode", OracleDbType.NVarchar2, se.groutinglinecode, ParameterDirection.Input));
  10353. }
  10354. // 模具编码
  10355. if (!string.IsNullOrEmpty(se.groutingmouldcode))
  10356. {
  10357. //sql = sql + " and gdd.groutingmouldcode=:groutingmouldcode";
  10358. sql = sql + " and instr(gdd.groutingmouldcode,:groutingmouldcode)>0";
  10359. parameters.Add(new OracleParameter(":groutingmouldcode", OracleDbType.NVarchar2, se.groutingmouldcode, ParameterDirection.Input));
  10360. }
  10361. sql = sql + @"
  10362. group by gdd.groutinglinecode,
  10363. gdd.groutingmouldcode,
  10364. gdd.mouldcode,
  10365. gdd.goodsid,
  10366. gdd.groutinglinedetailid) gd
  10367. left join (select pdbc.mouldcode,
  10368. sum(1) OutKilnCount,
  10369. sum(case
  10370. when defect.defectprocedureid is not null and
  10371. glt.goodsleveltypeid in (5, 6, 7) then
  10372. 0
  10373. else
  10374. 1
  10375. end) GoodCount,
  10376. sum(case
  10377. when defect.defectprocedureid is not null and
  10378. glt.goodsleveltypeid = 7 then
  10379. 1
  10380. else
  10381. 0
  10382. end) SubstandardCount,
  10383. sum(case
  10384. when defect.defectprocedureid is not null and
  10385. glt.goodsleveltypeid = 6 then
  10386. 1
  10387. else
  10388. 0
  10389. end) ReFireCount,
  10390. sum(case
  10391. when defect.defectprocedureid is not null and
  10392. glt.goodsleveltypeid = 5 then
  10393. 1
  10394. else
  10395. 0
  10396. end) BadCount
  10397. from (select distinct pd.barcode,
  10398. pd.mouldcode,
  10399. pd.kilncarbatchno
  10400. from tp_pm_productiondata pd
  10401. where pd.valueflag = '1'";
  10402. // 开始注浆--开始
  10403. if (se.beginCreateTime.HasValue)
  10404. {
  10405. sql = sql + " and pd.createtime>=:groutingDateStart ";
  10406. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  10407. }
  10408. //--and pd.createtime > 查询条件。开始注浆日期开始
  10409. // --and pd.procedureid = :in_rptSprocedureId
  10410. sql = sql + @"
  10411. and pd.procedureid = 11
  10412. and pd.AccountID = 1) pdbc
  10413. left join (select kcbc.barcode,
  10414. kcbc.kilncarbatchno,
  10415. kcbc.goodsleveltypeid,
  10416. kcbc.productiondataid
  10417. from (select pd.barcode,
  10418. pd.kilncarbatchno,
  10419. pd.goodsleveltypeid,
  10420. pd.productiondataid,
  10421. ROW_NUMBER() OVER(PARTITION BY pd.barcode, pd.kilncarbatchno ORDER BY pd.productiondataid desc) AS dataid
  10422. from tp_pm_productiondata pd
  10423. where pd.valueflag = '1'
  10424. --and pd.AccountID = :AccountID
  10425. and pd.AccountID = :AccountID";
  10426. //--and pd.createtime > 查询条件。开始注浆日期开始
  10427. // 开始注浆--开始
  10428. if (se.beginCreateTime.HasValue)
  10429. {
  10430. sql = sql + " and pd.createtime>=:groutingDateStart ";
  10431. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  10432. }
  10433. sql = sql + @" and length(pd.kilncarbatchno) > 0
  10434. and pd.modeltype = -1) kcbc
  10435. where kcbc.dataid = 1) glt
  10436. on pdbc.kilncarbatchno = glt.kilncarbatchno
  10437. and pdbc.barcode = glt.barcode
  10438. left join (select distinct productiondataid, defectprocedureid
  10439. from tp_pm_defect def
  10440. where def.valueflag = '1'";
  10441. //--and pd.createtime > 查询条件。开始注浆日期开始
  10442. // 开始注浆--开始
  10443. if (se.beginCreateTime.HasValue)
  10444. {
  10445. sql = sql + " and def.createtime>=:groutingDateStart ";
  10446. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  10447. }
  10448. sql = sql + @"
  10449. and def.AccountID = :AccountID) defect
  10450. on defect.productiondataid = glt.productiondataid
  10451. group by pdbc.mouldcode) zl
  10452. on zl.mouldcode = gd.mouldcode
  10453. left join tp_mst_goods gs
  10454. on gs.goodsid = gd.goodsid
  10455. left join tp_pc_groutinglinedetail gld
  10456. on gld.groutinglinedetailid = gd.groutinglinedetailid
  10457. and gld.mouldcode = gd.mouldcode
  10458. left join tp_sys_gmouldstatus gms
  10459. on gms.gmouldstatusid = gld.gmouldstatus
  10460. where 1=1
  10461. ";
  10462. // 产品编码
  10463. if (!string.IsNullOrEmpty(se.goodscode))
  10464. {
  10465. //sql = sql + " and gs.goodscode=:goodscode";
  10466. sql = sql + " and instr(gs.goodscode,:goodscode)>0";
  10467. parameters.Add(new OracleParameter(":goodscode", OracleDbType.NVarchar2, se.goodscode, ParameterDirection.Input));
  10468. }
  10469. // 成型工号
  10470. if (!string.IsNullOrEmpty(se.groutingUserCode))
  10471. {
  10472. //sql = sql + " and gd.usercode=:usercode";
  10473. sql = sql + " and instr(gd.usercode,:usercode)>0";
  10474. parameters.Add(new OracleParameter(":usercode", OracleDbType.NVarchar2, se.groutingUserCode, ParameterDirection.Input));
  10475. }
  10476. // 开始注浆--开始
  10477. if (se.beginCreateTime.HasValue)
  10478. {
  10479. sql = sql + " and gd.mingroutingdate>=:CreateTimeStart ";
  10480. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  10481. }
  10482. // 开始注浆--结束
  10483. if (se.endCreateTime.HasValue)
  10484. {
  10485. sql = sql + " and gd.mingroutingdate<=:CreateTimeEnd ";
  10486. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.endCreateTime.Value, ParameterDirection.Input));
  10487. }
  10488. // 结束注浆--开始
  10489. if (se.beginCreateTime2.HasValue)
  10490. {
  10491. sql = sql + " and gd.maxgroutingdate>=:CreateTimeotherStart2 ";
  10492. parameters.Add(new OracleParameter(":CreateTimeotherStart2", OracleDbType.Date, se.beginCreateTime2.Value, ParameterDirection.Input));
  10493. }
  10494. // 结束注浆--结束
  10495. if (se.endCreateTime2.HasValue)
  10496. {
  10497. sql = sql + " and gd.maxgroutingdate<=:CreateTimeotherEnd2";
  10498. parameters.Add(new OracleParameter(":CreateTimeotherEnd2", OracleDbType.Date, se.endCreateTime2.Value, ParameterDirection.Input));
  10499. }
  10500. // 模具状态
  10501. if (!string.IsNullOrEmpty(se.gmouldstatus))
  10502. {
  10503. sql = sql + " and gms.gmouldstatusid=:gmouldstatus";
  10504. parameters.Add(new OracleParameter(":gmouldstatus", OracleDbType.NVarchar2, se.gmouldstatus, ParameterDirection.Input));
  10505. }
  10506. sql = sql + " order by groutinglinecode,groutingmouldcode";
  10507. return sql;
  10508. }
  10509. #region 工资产量统计
  10510. /// <summary>
  10511. /// 取得RPT080102画面(成型工产量)的查询数据
  10512. /// </summary>
  10513. /// <param name="user">登录用户信息</param>
  10514. /// <param name="se">查询条件</param>
  10515. /// <returns>查询结果</returns>
  10516. public static ServiceResultEntity GetRPT080102SData(SUserInfo user, RPT080102_SE se)
  10517. {
  10518. IDBTransaction conn = null;
  10519. try
  10520. {
  10521. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  10522. conn.Connect();
  10523. OracleParameter[] paras = new OracleParameter[]{
  10524. new OracleParameter("in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  10525. new OracleParameter("in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
  10526. new OracleParameter("in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
  10527. new OracleParameter("in_deliverprocess",OracleDbType.Varchar2,se.DeliverProcedureIDS,ParameterDirection.Input),
  10528. new OracleParameter("in_IntoKilnProcess",OracleDbType.Varchar2,se.IntoProcedureIDS,ParameterDirection.Input),
  10529. new OracleParameter("in_OutKilnProcess",OracleDbType.Varchar2,se.OutProcedureIDS,ParameterDirection.Input),
  10530. new OracleParameter("in_QualityProcess",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
  10531. new OracleParameter("in_DefectFine",OracleDbType.Varchar2,se.DefectFineIDS,ParameterDirection.Input),
  10532. new OracleParameter("in_Impurity",OracleDbType.Varchar2,se.DefectIDS,ParameterDirection.Input),
  10533. new OracleParameter("out_Production",OracleDbType.RefCursor, ParameterDirection.Output),
  10534. new OracleParameter("out_Deliver",OracleDbType.RefCursor,ParameterDirection.Output),
  10535. new OracleParameter("out_Repair",OracleDbType.RefCursor,ParameterDirection.Output),
  10536. };
  10537. conn.IsCommandTimeout = false;
  10538. DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetDeliver_Production", paras);
  10539. ServiceResultEntity sre = new ServiceResultEntity();
  10540. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  10541. {
  10542. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10543. return sre;
  10544. }
  10545. sre.Data = new DataSet();
  10546. sre.Data = data;
  10547. conn.Commit();
  10548. return sre;
  10549. }
  10550. catch (Exception ex)
  10551. {
  10552. throw ex;
  10553. }
  10554. finally
  10555. {
  10556. if (conn != null &&
  10557. conn.ConnState == ConnectionState.Open)
  10558. {
  10559. conn.Disconnect();
  10560. }
  10561. }
  10562. }
  10563. /// <summary>
  10564. /// 取得RPT080103画面(烧成前工序产量明细表)的查询数据
  10565. /// </summary>
  10566. /// <param name="user">登录用户信息</param>
  10567. /// <param name="se">查询条件</param>
  10568. /// <returns>查询结果</returns>
  10569. public static ServiceResultEntity GetRPT080103SData(SUserInfo user, RPT080103_SE se)
  10570. {
  10571. IDBTransaction conn = null;
  10572. try
  10573. {
  10574. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  10575. conn.Connect();
  10576. OracleParameter[] paras = new OracleParameter[]{
  10577. new OracleParameter("in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  10578. new OracleParameter("in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
  10579. new OracleParameter("in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
  10580. new OracleParameter("in_Process",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
  10581. new OracleParameter("in_HandOverProcess",OracleDbType.Varchar2,se.HandOverProcedureIDS,ParameterDirection.Input),
  10582. new OracleParameter("in_OutKilnProcess",OracleDbType.Varchar2,se.OutProcedureIDS,ParameterDirection.Input),
  10583. new OracleParameter("in_QualityProcess",OracleDbType.Varchar2,se.QualityProcedureIDS,ParameterDirection.Input),
  10584. new OracleParameter("in_Defect1",OracleDbType.Varchar2,se.DefectIDS,ParameterDirection.Input),
  10585. new OracleParameter("in_Defect2",OracleDbType.Varchar2,se.DefectIDS2,ParameterDirection.Input),
  10586. new OracleParameter("out_Production",OracleDbType.RefCursor, ParameterDirection.Output),
  10587. };
  10588. conn.IsCommandTimeout = false;
  10589. //DataSet data = null;
  10590. //if (se.ProcedureIDS.Contains(","))
  10591. //{
  10592. // data = conn.ExecStoredProcedure("PRO_RPT_GetStandardProduction2", paras);
  10593. //}
  10594. //else
  10595. //{
  10596. // data = conn.ExecStoredProcedure("PRO_RPT_GetStandardProduction", paras);
  10597. //}
  10598. DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetStandard_Production", paras);
  10599. ServiceResultEntity sre = new ServiceResultEntity();
  10600. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  10601. {
  10602. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10603. return sre;
  10604. }
  10605. sre.Data = new DataSet();
  10606. sre.Data = data;
  10607. conn.Commit();
  10608. return sre;
  10609. }
  10610. catch (Exception ex)
  10611. {
  10612. throw ex;
  10613. }
  10614. finally
  10615. {
  10616. if (conn != null &&
  10617. conn.ConnState == ConnectionState.Open)
  10618. {
  10619. conn.Disconnect();
  10620. }
  10621. }
  10622. }
  10623. /// <summary>
  10624. /// 取得RPT080104画面(烧成工序产量明细表)的查询数据
  10625. /// </summary>
  10626. /// <param name="user">登录用户信息</param>
  10627. /// <param name="se">查询条件</param>
  10628. /// <returns>查询结果</returns>
  10629. public static ServiceResultEntity GetRPT080104SData(SUserInfo user, RPT080103_SE se)
  10630. {
  10631. IDBTransaction conn = null;
  10632. try
  10633. {
  10634. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  10635. conn.Connect();
  10636. OracleParameter[] paras = new OracleParameter[]{
  10637. new OracleParameter("in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  10638. new OracleParameter("in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
  10639. new OracleParameter("in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
  10640. new OracleParameter("in_Process",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
  10641. new OracleParameter("in_OutKilnProcess",OracleDbType.Varchar2,se.OutProcedureIDS,ParameterDirection.Input),
  10642. new OracleParameter("in_QualityProcess",OracleDbType.Varchar2,se.QualityProcedureIDS,ParameterDirection.Input),
  10643. new OracleParameter("in_Defect1",OracleDbType.Varchar2,se.DefectIDS,ParameterDirection.Input),
  10644. new OracleParameter("in_Defect2",OracleDbType.Varchar2,se.DefectIDS2,ParameterDirection.Input),
  10645. new OracleParameter("out_Production",OracleDbType.RefCursor, ParameterDirection.Output),
  10646. };
  10647. conn.IsCommandTimeout = false;
  10648. DataSet data = null;
  10649. if (se.ProcedureIDS.Contains(","))
  10650. {
  10651. data = conn.ExecStoredProcedure("PRO_RPT_GetKilnProduction2", paras);
  10652. }
  10653. else
  10654. {
  10655. data = conn.ExecStoredProcedure("PRO_RPT_GetKilnProduction", paras);
  10656. }
  10657. ServiceResultEntity sre = new ServiceResultEntity();
  10658. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  10659. {
  10660. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10661. return sre;
  10662. }
  10663. sre.Data = data;
  10664. //string sqlString =
  10665. //"SELECT kk.procedurename\n" +
  10666. //" ,kk.usercode\n" +
  10667. //" ,kk.kilncode\n" +
  10668. //" ,kk.kdate\n" +
  10669. //" ,COUNT(*) kcount\n" +
  10670. //" FROM (SELECT k.usercode\n" +
  10671. //" ,kiln.kilncode\n" +
  10672. //" ,p.procedurename\n" +
  10673. //" ,trunc(k.createtime) kdate\n" +
  10674. //" FROM tp_pm_kilncardata k\n" +
  10675. //" LEFT JOIN tp_mst_kiln kiln\n" +
  10676. //" ON kiln.kilnid = k.kilnid\n" +
  10677. //" LEFT JOIN tp_pc_procedure p\n" +
  10678. //" ON p.procedureid = k.procedureid\n" +
  10679. //" WHERE k.valueflag = '1'\n" +
  10680. //" AND k.AccountID = :in_AccountID\n" +
  10681. //" AND k.createtime >= :in_BeginDate\n" +
  10682. //" AND k.createtime <= :in_EndDate\n" +
  10683. //" AND instr(','|| :procedureids ||',', ','|| k.procedureid ||',' ) > 0) kk\n" +
  10684. //" GROUP BY kk.procedurename, kk.usercode, kk.kilncode, kk.kdate\n" +
  10685. //" ORDER BY kk.procedurename, kk.usercode, kk.kilncode, kk.kdate";
  10686. string sqlString = "WITH kilnData AS\n" +
  10687. " (SELECT k.usercode\n" +
  10688. " ,kiln.kilncode\n" +
  10689. " ,p.procedurename\n" +
  10690. " ,trunc(k.createtime) kdate\n" +
  10691. " ,k.userid\n" +
  10692. " ,k.procedureid\n" +
  10693. " ,k.kilnid\n" +
  10694. " ,k.KILNCARBATCHNO\n" +
  10695. " FROM tp_pm_kilncardata k\n" +
  10696. " LEFT JOIN tp_mst_kiln kiln\n" +
  10697. " ON kiln.kilnid = k.kilnid\n" +
  10698. " LEFT JOIN tp_pc_procedure p\n" +
  10699. " ON p.procedureid = k.procedureid\n" +
  10700. " WHERE k.valueflag = '1'\n" +
  10701. " AND k.AccountID = :in_AccountID\n" +
  10702. " AND k.createtime >= :in_BeginDate\n" +
  10703. " AND k.createtime <= :in_EndDate\n" +
  10704. " AND instr(',' || :procedureids || ',', ',' || k.procedureid || ',') > 0)\n" +
  10705. "SELECT kd.procedurename\n" +
  10706. " ,kd.usercode\n" +
  10707. " ,kd.kilncode\n" +
  10708. " ,kd.kdate\n" +
  10709. " ,kd.kcount\n" +
  10710. " ,kpd.kpcount\n" +
  10711. " FROM (SELECT kk.procedurename\n" +
  10712. " ,kk.usercode\n" +
  10713. " ,kk.kilncode\n" +
  10714. " ,kk.kdate\n" +
  10715. " ,kk.procedureid\n" +
  10716. " ,kk.userid\n" +
  10717. " ,kk.kilnid\n" +
  10718. " ,COUNT(*) kcount\n" +
  10719. " FROM kilnData kk\n" +
  10720. " GROUP BY kk.procedurename\n" +
  10721. " ,kk.usercode\n" +
  10722. " ,kk.kilncode\n" +
  10723. " ,kk.kdate\n" +
  10724. " ,kk.procedureid\n" +
  10725. " ,kk.userid\n" +
  10726. " ,kk.kilnid) kd\n" +
  10727. " LEFT JOIN (SELECT kk.kdate\n" +
  10728. " ,kk.procedureid\n" +
  10729. " ,kk.userid\n" +
  10730. " ,kk.kilnid\n" +
  10731. " ,COUNT(*) kpcount\n" +
  10732. " FROM kilnData kk\n" +
  10733. " INNER JOIN tp_pm_productiondata pd\n" +
  10734. " ON pd.valueflag = '1'\n" +
  10735. " AND pd.procedureid = kk.procedureid\n" +
  10736. " AND pd.kilnid = kk.kilnid\n" +
  10737. " AND pd.KILNCARBATCHNO = kk.KILNCARBATCHNO\n" +
  10738. " GROUP BY kk.kdate, kk.procedureid, kk.userid, kk.kilnid) kpd\n" +
  10739. " ON kpd.kdate = kd.kdate\n" +
  10740. " AND kpd.procedureid = kd.procedureid\n" +
  10741. " AND kpd.userid = kd.userid\n" +
  10742. " AND kpd.kilnid = kd.kilnid\n" +
  10743. " ORDER BY kd.procedurename, kd.usercode, kd.kilncode, kd.kdate";
  10744. OracleParameter[] parascount = new OracleParameter[]{
  10745. new OracleParameter(":in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  10746. new OracleParameter(":in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
  10747. new OracleParameter(":in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
  10748. new OracleParameter(":procedureids",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
  10749. };
  10750. DataTable dt = conn.GetSqlResultToDt(sqlString, parascount);
  10751. if (dt != null)
  10752. {
  10753. sre.Data.Tables.Add(dt);
  10754. }
  10755. conn.Commit();
  10756. return sre;
  10757. }
  10758. catch (Exception ex)
  10759. {
  10760. throw ex;
  10761. }
  10762. finally
  10763. {
  10764. if (conn != null &&
  10765. conn.ConnState == ConnectionState.Open)
  10766. {
  10767. conn.Disconnect();
  10768. }
  10769. }
  10770. }
  10771. #endregion
  10772. /// <summary>
  10773. /// 使用存储过程PRO_PM_GetProductionData获取生产工序计件数据
  10774. /// </summary>
  10775. /// <param name="searchEntity">生产数据实体类</param>
  10776. /// <param name="user">用户基本信息</param>
  10777. /// <returns>DataTable</returns>
  10778. public static DataTable GetProductionData(SearchProductionDataEntity searchEntity, SUserInfo user)
  10779. {
  10780. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10781. string procsql = "PRO_RPT_GetProductionData";
  10782. try
  10783. {
  10784. IDataParameter[] paras = new OracleParameter[]
  10785. {
  10786. new OracleParameter("in_procedureList",OracleDbType.Varchar2, searchEntity.ProcedureIDS, ParameterDirection.Input),
  10787. new OracleParameter("in_LineID", OracleDbType.Int32,searchEntity.ProductionLineID, ParameterDirection.Input),
  10788. new OracleParameter("in_barCode", OracleDbType.Varchar2,searchEntity.BarCode, ParameterDirection.Input),
  10789. new OracleParameter("in_goodsCode", OracleDbType.Varchar2,searchEntity.GoodsCode, ParameterDirection.Input),
  10790. new OracleParameter("in_goodsName", OracleDbType.Varchar2,searchEntity.GoodsName, ParameterDirection.Input),
  10791. new OracleParameter("in_userCode", OracleDbType.Varchar2,searchEntity.UserCode, ParameterDirection.Input),
  10792. new OracleParameter("in_organizationID", OracleDbType.Int32,searchEntity.OrganizationID, ParameterDirection.Input),
  10793. new OracleParameter("in_remarks", OracleDbType.Varchar2,searchEntity.Remarks, ParameterDirection.Input),
  10794. new OracleParameter("in_isReworked", OracleDbType.Varchar2,searchEntity.IsRework, ParameterDirection.Input),
  10795. new OracleParameter("in_begindate", OracleDbType.Date,searchEntity.BeginDate, ParameterDirection.Input),
  10796. new OracleParameter("in_enddate", OracleDbType.Date,searchEntity.EndDate, ParameterDirection.Input),
  10797. new OracleParameter("in_accountID", OracleDbType.Int32,user.AccountID, ParameterDirection.Input),
  10798. new OracleParameter("in_userID", OracleDbType.Int32,user.UserID, ParameterDirection.Input),
  10799. new OracleParameter("in_kilnCode", OracleDbType.Varchar2,searchEntity.KilnCode, ParameterDirection.Input),
  10800. new OracleParameter("in_kilnCarCode", OracleDbType.Varchar2,searchEntity.KilnCarCode, ParameterDirection.Input),
  10801. new OracleParameter("in_kilnCarPosition", OracleDbType.Int32,searchEntity.KilnCarPosition, ParameterDirection.Input),
  10802. new OracleParameter("in_currentUserID", OracleDbType.Int32,user.UserID, ParameterDirection.Input),
  10803. new OracleParameter("out_result", OracleDbType.RefCursor, ParameterDirection.Output),
  10804. new OracleParameter("in_goodsTypeCode", OracleDbType.Varchar2,searchEntity.GoodsTypeCode, ParameterDirection.Input),
  10805. };
  10806. oracleConn.Open();
  10807. DataSet returnDs = oracleConn.ExecStoredProcedure(procsql, paras);
  10808. if (returnDs != null && returnDs.Tables.Count > 0)
  10809. {
  10810. return returnDs.Tables[0];
  10811. }
  10812. else
  10813. {
  10814. return null;
  10815. }
  10816. }
  10817. catch (Exception ex)
  10818. {
  10819. throw ex;
  10820. }
  10821. finally
  10822. {
  10823. if (oracleConn.ConnState == ConnectionState.Open)
  10824. {
  10825. oracleConn.Close();
  10826. }
  10827. }
  10828. }
  10829. /// <summary>
  10830. /// 取得RPT080106(温湿计明细)的汇总信息查询数据
  10831. /// </summary>
  10832. /// <param name="user">登录用户信息</param>
  10833. /// <param name="se">查询条件</param>
  10834. /// <returns>查询结果</returns>
  10835. public static ServiceResultEntity GetRPT080106IData(SUserInfo user, CelsiusRecordEntity se)
  10836. {
  10837. IDBConnection conn = null;
  10838. try
  10839. {
  10840. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10841. List<OracleParameter> parameters = new List<OracleParameter>();
  10842. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080106ISQL(user, se, ref parameters));
  10843. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  10844. ServiceResultEntity sre = new ServiceResultEntity();
  10845. if (data == null || data.Rows.Count == 0)
  10846. {
  10847. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10848. return sre;
  10849. }
  10850. sre.Data = new DataSet();
  10851. sre.Data.Tables.Add(data);
  10852. return sre;
  10853. }
  10854. catch (Exception ex)
  10855. {
  10856. throw ex;
  10857. }
  10858. finally
  10859. {
  10860. if (conn != null &&
  10861. conn.ConnState == ConnectionState.Open)
  10862. {
  10863. conn.Close();
  10864. }
  10865. }
  10866. }
  10867. /// <summary>
  10868. /// 取得RPT080106(温湿计明细)的汇总信息查询数据sql
  10869. /// </summary>
  10870. /// <returns>sql</returns>
  10871. private static string GetRPT080106ISQL(SUserInfo user, CelsiusRecordEntity se, ref List<OracleParameter> parameters)
  10872. {
  10873. string selSql = @"Select cr.*,t.*,to_char(cr.RecordDate,'mm-dd hh24:mi') as RecordDateStr from TP_PM_CelsiusRecord cr
  10874. Left join TP_MST_User u On cr.ThermometerID = u.UserId
  10875. Inner join TP_MST_Thermometer t On cr.ThermometerID = t.ThermometerID
  10876. Where cr.AccountID =:AccountID and cr.ValueFlag = '1' ";
  10877. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  10878. if (!string.IsNullOrEmpty(se.ThermometerIDS))
  10879. {
  10880. selSql = selSql + " AND instr(','||:ThermometerIDS||',',','||cr.ThermometerID||',')>0 ";
  10881. parameters.Add(new OracleParameter(":ThermometerIDS", OracleDbType.NVarchar2, se.ThermometerIDS, ParameterDirection.Input));
  10882. }
  10883. if (!string.IsNullOrEmpty(se.Remarks))
  10884. {
  10885. selSql = selSql + " AND instr(cr.Remarks,:Remarks) >0 ";
  10886. parameters.Add(new OracleParameter(":Remarks", OracleDbType.NVarchar2, se.Remarks, ParameterDirection.Input));
  10887. }
  10888. if (se.RecordDate.HasValue)
  10889. {
  10890. selSql = selSql + " AND cr.CreateTime>= :CreateTimeStart ";
  10891. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.RecordDate.Value, ParameterDirection.Input));
  10892. }
  10893. if (se.RecordDateEnd.HasValue)
  10894. {
  10895. selSql = selSql + " AND cr.CreateTime<= :CreateTimeEnd ";
  10896. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.RecordDateEnd.Value, ParameterDirection.Input));
  10897. }
  10898. selSql +=
  10899. // 温湿计查看权限
  10900. " AND EXISTS (SELECT UP.PurviewID" +
  10901. " FROM TP_MST_UserPurview UP" +
  10902. " WHERE UP.PurviewType = '" + (int)Constant.PurviewType.ViewCelsius + "'" +
  10903. " AND (UP.PurviewID = -1 OR UP.PurviewID = CR.ThermometerID)" +
  10904. " AND UP.UserId = :UPUserId)";
  10905. parameters.Add(new OracleParameter(":UPUserId", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  10906. selSql = selSql + " order by RecordDate asc";
  10907. return selSql;
  10908. }
  10909. /// <summary>
  10910. /// 取得RPT030110画面(半检登记汇总表)的汇总信息查询数据
  10911. /// </summary>
  10912. /// <param name="user">登录用户信息</param>
  10913. /// <param name="se">查询条件</param>
  10914. /// <returns>查询结果</returns>
  10915. public static ServiceResultEntity GetRPT030110Data(SUserInfo user, SemiCheckEntity se)
  10916. {
  10917. IDBConnection conn = null;
  10918. try
  10919. {
  10920. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10921. List<OracleParameter> parameters = new List<OracleParameter>();
  10922. string sql = ReportModuleLogic.GetRPT030110SSQL(user, se, ref parameters);
  10923. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  10924. ServiceResultEntity sre = new ServiceResultEntity();
  10925. if (data == null || data.Rows.Count == 0)
  10926. {
  10927. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10928. return sre;
  10929. }
  10930. sre.Data = new DataSet();
  10931. sre.Data.Tables.Add(data);
  10932. return sre;
  10933. }
  10934. catch (Exception ex)
  10935. {
  10936. throw ex;
  10937. }
  10938. finally
  10939. {
  10940. if (conn != null &&
  10941. conn.ConnState == ConnectionState.Open)
  10942. {
  10943. conn.Close();
  10944. }
  10945. }
  10946. }
  10947. /// <summary>
  10948. /// 获取RPT030110画面(半检登记汇总表)的汇总信息查询sql
  10949. /// </summary>
  10950. /// <returns>sql</returns>
  10951. private static string GetRPT030110SSQL(SUserInfo user, SemiCheckEntity se, ref List<OracleParameter> parameters)
  10952. {
  10953. parameters.Add(new OracleParameter(":accountid", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  10954. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  10955. #region
  10956. // string sqlString = @"
  10957. // SELECT t.reworkprocedureid -- 返工工序id
  10958. // ,decode(gid,
  10959. // 7,
  10960. // '总计',
  10961. // 3,
  10962. // '合计【' || t.reworkprocedurename || '】',
  10963. // 0,
  10964. // t.reworkprocedurename,
  10965. // '--') reworkprocedurename -- 返工工序
  10966. // ,t.goodstypecode2 -- 产品二级类别
  10967. // ,decode(gid,
  10968. // 1,
  10969. // '小计【' || t.goodstypename2 || '】',
  10970. // 0,
  10971. // t.goodstypename2,
  10972. // '--') goodstypename2 -- 产品二级类别
  10973. // ,t.reworkuserid -- 返工工号id
  10974. // ,decode(gid, 0, t.reworkusercode, '--') reworkusercode -- 返工工号
  10975. // ,t.goodsid -- 产品id
  10976. // ,decode(gid, 0, t.goodscode, '--') goodscode -- 产品编码
  10977. // ,decode(gid, 0, t.goodstypename, '--') goodstypename -- 产品类别
  10978. // ,t.reworkcount -- 返工数
  10979. // ,t.badcount -- 不合格数
  10980. // ,t.regoodcount -- 复检合格数
  10981. // ,t.rebadcount -- 复检不合格数
  10982. // ,t.renocount -- 未复检
  10983. // --,t.renocountsum -- 待返工
  10984. // ,(SELECT COUNT(*)
  10985. // FROM tp_pm_semicheck sci
  10986. // WHERE sci.valueflag = '1'
  10987. // AND sci.backoutflag = '0'
  10988. // AND sci.semichecktype = 1
  10989. // AND sci.resemichecktype = 0
  10990. // AND (t.reworkprocedureid is null or sci.reworkprocedureid = t.reworkprocedureid)
  10991. // AND (t.goodsid is null or sci.goodsid = t.goodsid)
  10992. // AND (t.reworkuserid is null or sci.reworkuserid = t.reworkuserid)) AS renocountsum
  10993. // FROM (SELECT grouping_id(sc.reworkprocedureid, gt2.goodstypecode, g.goodsid) gid
  10994. // ,sc.reworkprocedureid
  10995. // ,rp.procedurename reworkprocedurename
  10996. // ,gt2.goodstypecode goodstypecode2
  10997. // ,gt2.goodstypename goodstypename2
  10998. // ,sc.reworkuserid
  10999. // ,sc.reworkusercode
  11000. // ,g.goodsid
  11001. // ,g.goodscode
  11002. // ,gt.goodstypename
  11003. // , SUM(CASE
  11004. // WHEN sc.semichecktype = 1 THEN
  11005. // 1
  11006. // ELSE
  11007. // 0
  11008. // END) reworkcount
  11009. // , SUM(CASE
  11010. // WHEN sc.semichecktype = 2 THEN
  11011. // 1
  11012. // ELSE
  11013. // 0
  11014. // END) badcount
  11015. // , SUM(CASE
  11016. // WHEN sc.semichecktype = 1 AND sc.resemichecktype = 0 THEN
  11017. // 1
  11018. // ELSE
  11019. // 0
  11020. // END) renocount
  11021. // , SUM(CASE
  11022. // WHEN sc.semichecktype = 1 AND sc.resemichecktype = 1 THEN
  11023. // 1
  11024. // ELSE
  11025. // 0
  11026. // END) regoodcount
  11027. // , SUM(CASE
  11028. // WHEN sc.semichecktype = 1 AND sc.resemichecktype = 2 THEN
  11029. // 1
  11030. // ELSE
  11031. // 0
  11032. // END) rebadcount
  11033. // --,(select count(*) from tp_pm_semicheck sci where sci.valueflag = '1' and sci.backoutflag = '0' and sci.semichecktype = 1
  11034. // -- and sci.resemichecktype = 0 and sci.reworkprocedureid = sc.reworkprocedureid and sci.reworkuserid = sc.reworkuserid and sci.goodsid = g.goodsid) as renocountsum
  11035. // --FROM tp_pm_semicheck sc
  11036. // FROM (SELECT semicheckid
  11037. // ,barcode
  11038. // ,productionlineid
  11039. // ,procedureid
  11040. // ,proceduretime
  11041. // ,proceduremodel
  11042. // ,modeltype
  11043. // ,organizationid
  11044. // ,goodsid
  11045. // ,goodscode
  11046. // ,userid
  11047. // ,usercode
  11048. // ,productiondataid
  11049. // ,logoid
  11050. // ,ispublicbody
  11051. // ,specialrepairflag
  11052. // ,goodslevelid
  11053. // ,goodsleveltypeid
  11054. // ,groutingdailyid
  11055. // ,groutingdailydetailid
  11056. // ,groutinglineid
  11057. // ,groutinglinecode
  11058. // ,groutinglinename
  11059. // ,gmouldtypeid
  11060. // ,canmanytimes
  11061. // ,groutinglinedetailid
  11062. // ,groutingdate
  11063. // ,groutingmouldcode
  11064. // ,mouldcode
  11065. // ,groutinguserid
  11066. // ,groutingusercode
  11067. // ,groutingnum
  11068. // ,semichecktype
  11069. // ,semicheckuserid
  11070. // ,semicheckusercode
  11071. // ,semichecktime
  11072. // ,reworkprocedureid
  11073. // ,reworkprocedurecode
  11074. // ,reworkuserid
  11075. // ,reworkusercode
  11076. // ,resemichecktype
  11077. // ,resemicheckuserid
  11078. // ,resemicheckusercode
  11079. // ,resemichecktime
  11080. // ,backoutflag
  11081. // ,backouttime
  11082. // ,backoutuserid
  11083. // ,backoutusercode
  11084. // ,remarks
  11085. // ,createtime
  11086. // ,createuserid
  11087. // ,updateuserid
  11088. // FROM tp_pm_semicheck sc
  11089. // WHERE sc.accountid = :accountid
  11090. // AND sc.valueflag = '1'
  11091. // AND sc.semichecktype = 1
  11092. // AND sc.backoutflag = '0'
  11093. // UNION ALL
  11094. // SELECT DISTINCT sc.semicheckid
  11095. // ,sc.barcode
  11096. // ,sc.productionlineid
  11097. // ,sc.procedureid
  11098. // ,sc.proceduretime
  11099. // ,sc.proceduremodel
  11100. // ,sc.modeltype
  11101. // ,sc.organizationid
  11102. // ,sc.goodsid
  11103. // ,sc.goodscode
  11104. // ,sc.userid
  11105. // ,sc.usercode
  11106. // ,sc.productiondataid
  11107. // ,sc.logoid
  11108. // ,sc.ispublicbody
  11109. // ,sc.specialrepairflag
  11110. // ,sc.goodslevelid
  11111. // ,sc.goodsleveltypeid
  11112. // ,sc.groutingdailyid
  11113. // ,sc.groutingdailydetailid
  11114. // ,sc.groutinglineid
  11115. // ,sc.groutinglinecode
  11116. // ,sc.groutinglinename
  11117. // ,sc.gmouldtypeid
  11118. // ,sc.canmanytimes
  11119. // ,sc.groutinglinedetailid
  11120. // ,sc.groutingdate
  11121. // ,sc.groutingmouldcode
  11122. // ,sc.mouldcode
  11123. // ,sc.groutinguserid
  11124. // ,sc.groutingusercode
  11125. // ,sc.groutingnum
  11126. // ,sc.semichecktype
  11127. // ,sc.semicheckuserid
  11128. // ,sc.semicheckusercode
  11129. // ,sc.semichecktime
  11130. // --,sc.reworkprocedureid
  11131. // --,sc.reworkprocedurecode
  11132. // --,sc.reworkuserid
  11133. // --,sc.reworkusercode
  11134. // ,scd.defectprocedureid
  11135. // ,scdp.procedurename
  11136. // ,scd.defectuserid
  11137. // ,scd.defectusercode
  11138. // ,sc.resemichecktype
  11139. // ,sc.resemicheckuserid
  11140. // ,sc.resemicheckusercode
  11141. // ,sc.resemichecktime
  11142. // ,sc.backoutflag
  11143. // ,sc.backouttime
  11144. // ,sc.backoutuserid
  11145. // ,sc.backoutusercode
  11146. // ,sc.remarks
  11147. // ,sc.createtime
  11148. // ,sc.createuserid
  11149. // ,sc.updateuserid
  11150. // FROM tp_pm_semicheck sc
  11151. // LEFT JOIN TP_PM_SemiCheckDefect scd
  11152. // ON sc.semicheckid = scd.semicheckid
  11153. // LEFT JOIN tp_pc_procedure scdp
  11154. // ON scdp.procedureid = scd.defectprocedureid
  11155. // WHERE sc.accountid = :accountid
  11156. // AND sc.valueflag = '1'
  11157. // AND sc.semichecktype = 2
  11158. // AND sc.backoutflag = '0'
  11159. // ) sc
  11160. // LEFT JOIN tp_pc_procedure rp
  11161. // ON rp.procedureid = sc.reworkprocedureid
  11162. // INNER JOIN tp_mst_goods g
  11163. // ON g.goodsid = sc.goodsid
  11164. // INNER JOIN tp_mst_goodstype gt
  11165. // ON gt.goodstypeid = g.goodstypeid
  11166. // INNER JOIN tp_mst_goodstype gt2
  11167. // ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)
  11168. // AND gt2.accountid = gt.accountid
  11169. // INNER join TP_PM_GroutingDailyDetail GroutingDailyDetail
  11170. // ON GroutingDailyDetail.GroutingDailyDetailID=sc.GroutingDailyDetailID
  11171. // 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))";
  11172. #endregion
  11173. string sqlString = "SELECT t.reworkprocedureid -- 返工工序id\n" +
  11174. " ,decode(gid,\n" +
  11175. " 7,\n" +
  11176. " '总计',\n" +
  11177. " 3,\n" +
  11178. " '合计【' || t.reworkprocedurename || '】',\n" +
  11179. " 0,\n" +
  11180. " t.reworkprocedurename,\n" +
  11181. " '--') reworkprocedurename -- 返工工序\n" +
  11182. " ,t.goodstypecode2 -- 产品二级类别\n" +
  11183. " ,decode(gid,\n" +
  11184. " 1,\n" +
  11185. " '小计【' || t.goodstypename2 || '】',\n" +
  11186. " 0,\n" +
  11187. " t.goodstypename2,\n" +
  11188. " '--') goodstypename2 -- 产品二级类别\n" +
  11189. " ,t.reworkuserid -- 返工工号id\n" +
  11190. " ,decode(gid, 0, t.reworkusercode, '--') reworkusercode -- 返工工号\n" +
  11191. " ,t.goodsid -- 产品id\n" +
  11192. " ,decode(gid, 0, t.goodscode, '--') goodscode -- 产品编码\n" +
  11193. " ,decode(gid, 0, t.goodstypename, '--') goodstypename -- 产品类别\n" +
  11194. " ,t.reworkcount -- 返工数\n" +
  11195. " ,t.badcount -- 不合格数\n" +
  11196. " ,t.regoodcount -- 复检合格数\n" +
  11197. " ,t.rebadcount -- 复检不合格数\n" +
  11198. " ,t.renocount -- 未复检\n" +
  11199. " ,t.renocountsum -- 待返工\n" +
  11200. " FROM (SELECT grouping_id(sct.reworkprocedureid,\n" +
  11201. " sct.goodstypecode2,\n" +
  11202. " sct.goodsid) gid\n" +
  11203. " ,sct.displayno\n" +
  11204. " ,sct.reworkprocedureid\n" +
  11205. " ,sct.reworkprocedurename\n" +
  11206. " ,sct.goodstypecode2\n" +
  11207. " ,sct.goodstypename2\n" +
  11208. " ,sct.reworkuserid\n" +
  11209. " ,sct.reworkusercode\n" +
  11210. " ,sct.goodsid\n" +
  11211. " ,sct.goodscode\n" +
  11212. " ,sct.goodstypename\n" +
  11213. " ,SUM(sct.reworkcount) reworkcount\n" +
  11214. " ,SUM(sct. badcount) badcount\n" +
  11215. " ,SUM(sct. renocount) renocount\n" +
  11216. " ,SUM(sct.regoodcount) regoodcount\n" +
  11217. " ,SUM(sct.rebadcount) rebadcount\n" +
  11218. " ,SUM(sct.renocountsum) renocountsum\n" +
  11219. " FROM (SELECT rp.displayno\n" +
  11220. " ,sc.reworkprocedureid\n" +
  11221. " ,rp.procedurename reworkprocedurename\n" +
  11222. " ,gt2.goodstypecode goodstypecode2\n" +
  11223. " ,gt2.goodstypename goodstypename2\n" +
  11224. " ,sc.reworkuserid\n" +
  11225. " ,sc.reworkusercode\n" +
  11226. " ,g.goodsid\n" +
  11227. " ,g.goodscode\n" +
  11228. " ,gt.goodstypename\n" +
  11229. " , SUM(CASE\n" +
  11230. " WHEN sc.semichecktype = 1 THEN\n" +
  11231. " 1\n" +
  11232. " ELSE\n" +
  11233. " 0\n" +
  11234. " END) reworkcount\n" +
  11235. " , SUM(CASE\n" +
  11236. " WHEN sc.semichecktype = 2 THEN\n" +
  11237. " 1\n" +
  11238. " ELSE\n" +
  11239. " 0\n" +
  11240. " END) badcount\n" +
  11241. " , SUM(CASE\n" +
  11242. " WHEN sc.semichecktype = 1 AND sc.resemichecktype = 0 THEN\n" +
  11243. " 1\n" +
  11244. " ELSE\n" +
  11245. " 0\n" +
  11246. " END) renocount\n" +
  11247. " , SUM(CASE\n" +
  11248. " WHEN sc.semichecktype = 1 AND sc.resemichecktype = 1 THEN\n" +
  11249. " 1\n" +
  11250. " ELSE\n" +
  11251. " 0\n" +
  11252. " END) regoodcount\n" +
  11253. " , SUM(CASE\n" +
  11254. " WHEN sc.semichecktype = 1 AND sc.resemichecktype = 2 THEN\n" +
  11255. " 1\n" +
  11256. " ELSE\n" +
  11257. " 0\n" +
  11258. " END) rebadcount\n" +
  11259. " ,(SELECT COUNT(*)\n" +
  11260. " FROM tp_pm_semicheck sci\n" +
  11261. " WHERE sci.valueflag = '1'\n" +
  11262. " AND sci.backoutflag = '0'\n" +
  11263. " AND sci.semichecktype = 1\n" +
  11264. " AND sci.resemichecktype = 0\n" +
  11265. " AND sci.accountid = :accountid\n" +
  11266. " AND sci.reworkprocedureid = sc.reworkprocedureid\n" +
  11267. " AND sci.reworkuserid = sc.reworkuserid\n" +
  11268. " AND sci.goodsid = g.goodsid) AS renocountsum\n" +
  11269. " FROM (SELECT semicheckid\n" +
  11270. " ,barcode\n" +
  11271. " ,productionlineid\n" +
  11272. " ,procedureid\n" +
  11273. " ,proceduretime\n" +
  11274. " ,proceduremodel\n" +
  11275. " ,modeltype\n" +
  11276. " ,organizationid\n" +
  11277. " ,goodsid\n" +
  11278. " ,goodscode\n" +
  11279. " ,userid\n" +
  11280. " ,usercode\n" +
  11281. " ,productiondataid\n" +
  11282. " ,logoid\n" +
  11283. " ,ispublicbody\n" +
  11284. " ,specialrepairflag\n" +
  11285. " ,goodslevelid\n" +
  11286. " ,goodsleveltypeid\n" +
  11287. " ,groutingdailyid\n" +
  11288. " ,groutingdailydetailid\n" +
  11289. " ,groutinglineid\n" +
  11290. " ,groutinglinecode\n" +
  11291. " ,groutinglinename\n" +
  11292. " ,gmouldtypeid\n" +
  11293. " ,canmanytimes\n" +
  11294. " ,groutinglinedetailid\n" +
  11295. " ,groutingdate\n" +
  11296. " ,groutingmouldcode\n" +
  11297. " ,mouldcode\n" +
  11298. " ,groutinguserid\n" +
  11299. " ,groutingusercode\n" +
  11300. " ,groutingnum\n" +
  11301. " ,semichecktype\n" +
  11302. " ,semicheckuserid\n" +
  11303. " ,semicheckusercode\n" +
  11304. " ,semichecktime\n" +
  11305. " ,reworkprocedureid\n" +
  11306. " ,reworkprocedurecode\n" +
  11307. " ,reworkuserid\n" +
  11308. " ,reworkusercode\n" +
  11309. " ,resemichecktype\n" +
  11310. " ,resemicheckuserid\n" +
  11311. " ,resemicheckusercode\n" +
  11312. " ,resemichecktime\n" +
  11313. " ,backoutflag\n" +
  11314. " ,backouttime\n" +
  11315. " ,backoutuserid\n" +
  11316. " ,backoutusercode\n" +
  11317. " ,remarks\n" +
  11318. " ,createtime\n" +
  11319. " ,createuserid\n" +
  11320. " ,updateuserid\n" +
  11321. " FROM tp_pm_semicheck sc\n" +
  11322. " WHERE sc.accountid = :accountid\n" +
  11323. " AND sc.valueflag = '1'\n" +
  11324. " AND sc.semichecktype = 1\n" +
  11325. " AND sc.backoutflag = '0'\n" +
  11326. " UNION ALL\n" +
  11327. " SELECT DISTINCT sc.semicheckid\n" +
  11328. " ,sc.barcode\n" +
  11329. " ,sc.productionlineid\n" +
  11330. " ,sc.procedureid\n" +
  11331. " ,sc.proceduretime\n" +
  11332. " ,sc.proceduremodel\n" +
  11333. " ,sc.modeltype\n" +
  11334. " ,sc.organizationid\n" +
  11335. " ,sc.goodsid\n" +
  11336. " ,sc.goodscode\n" +
  11337. " ,sc.userid\n" +
  11338. " ,sc.usercode\n" +
  11339. " ,sc.productiondataid\n" +
  11340. " ,sc.logoid\n" +
  11341. " ,sc.ispublicbody\n" +
  11342. " ,sc.specialrepairflag\n" +
  11343. " ,sc.goodslevelid\n" +
  11344. " ,sc.goodsleveltypeid\n" +
  11345. " ,sc.groutingdailyid\n" +
  11346. " ,sc.groutingdailydetailid\n" +
  11347. " ,sc.groutinglineid\n" +
  11348. " ,sc.groutinglinecode\n" +
  11349. " ,sc.groutinglinename\n" +
  11350. " ,sc.gmouldtypeid\n" +
  11351. " ,sc.canmanytimes\n" +
  11352. " ,sc.groutinglinedetailid\n" +
  11353. " ,sc.groutingdate\n" +
  11354. " ,sc.groutingmouldcode\n" +
  11355. " ,sc.mouldcode\n" +
  11356. " ,sc.groutinguserid\n" +
  11357. " ,sc.groutingusercode\n" +
  11358. " ,sc.groutingnum\n" +
  11359. " ,sc.semichecktype\n" +
  11360. " ,sc.semicheckuserid\n" +
  11361. " ,sc.semicheckusercode\n" +
  11362. " ,sc.semichecktime\n" +
  11363. " --,sc.reworkprocedureid\n" +
  11364. " --,sc.reworkprocedurecode\n" +
  11365. " --,sc.reworkuserid\n" +
  11366. " --,sc.reworkusercode\n" +
  11367. " ,scd.defectprocedureid\n" +
  11368. " ,scdp.procedurename\n" +
  11369. " ,scd.defectuserid\n" +
  11370. " ,scd.defectusercode\n" +
  11371. " ,sc.resemichecktype\n" +
  11372. " ,sc.resemicheckuserid\n" +
  11373. " ,sc.resemicheckusercode\n" +
  11374. " ,sc.resemichecktime\n" +
  11375. " ,sc.backoutflag\n" +
  11376. " ,sc.backouttime\n" +
  11377. " ,sc.backoutuserid\n" +
  11378. " ,sc.backoutusercode\n" +
  11379. " ,sc.remarks\n" +
  11380. " ,sc.createtime\n" +
  11381. " ,sc.createuserid\n" +
  11382. " ,sc.updateuserid\n" +
  11383. " FROM tp_pm_semicheck sc\n" +
  11384. " LEFT JOIN TP_PM_SemiCheckDefect scd\n" +
  11385. " ON sc.semicheckid = scd.semicheckid\n" +
  11386. " AND scd.valueflag='1'\n" +
  11387. " LEFT JOIN tp_pc_procedure scdp\n" +
  11388. " ON scdp.procedureid = scd.defectprocedureid\n" +
  11389. " WHERE sc.accountid = :accountid\n" +
  11390. " AND sc.valueflag = '1'\n" +
  11391. " AND sc.semichecktype = 2\n" +
  11392. " AND sc.backoutflag = '0') sc\n" +
  11393. " LEFT JOIN tp_pc_procedure rp\n" +
  11394. " ON rp.procedureid = sc.reworkprocedureid\n" +
  11395. " INNER JOIN tp_mst_goods g\n" +
  11396. " ON g.goodsid = sc.goodsid\n" +
  11397. " INNER JOIN tp_mst_goodstype gt\n" +
  11398. " ON gt.goodstypeid = g.goodstypeid\n" +
  11399. " INNER JOIN tp_mst_goodstype gt2\n" +
  11400. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  11401. " AND gt2.accountid = gt.accountid\n" +
  11402. " INNER JOIN TP_PM_GroutingDailyDetail GroutingDailyDetail\n" +
  11403. " ON GroutingDailyDetail.GroutingDailyDetailID =\n" +
  11404. " sc.GroutingDailyDetailID\n" //+
  11405. //" WHERE EXISTS (SELECT 1\n" +
  11406. //" FROM TP_MST_UserPurview up\n" +
  11407. //" WHERE up.PurviewType = 9\n" +
  11408. //" AND up.UserID = :UserID\n" +
  11409. //" AND (up.PurviewID = -1 OR\n" +
  11410. //" up.PurviewID = sc.procedureid))\n"
  11411. ;
  11412. // 完成工序集
  11413. if (!string.IsNullOrEmpty(se.CProcedureIDS))
  11414. {
  11415. sqlString += " AND instr(','||:procedureids||',', ',' || sc.procedureid || ',') > 0";
  11416. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, se.CProcedureIDS, ParameterDirection.Input));
  11417. }
  11418. // 完成时间起始
  11419. if (se.CDateTimeStart.HasValue)
  11420. {
  11421. sqlString = sqlString + " AND sc.ProcedureTime >= :CDateTimeStart ";
  11422. parameters.Add(new OracleParameter(":CDateTimeStart", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11423. }
  11424. // 完成时间结束
  11425. if (se.CDateTimeEnd.HasValue)
  11426. {
  11427. sqlString = sqlString + " AND sc.ProcedureTime <= :CDateTimeEnd ";
  11428. parameters.Add(new OracleParameter(":CDateTimeEnd", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11429. }
  11430. // 完成工号
  11431. if (!string.IsNullOrEmpty(se.CUserCode))
  11432. {
  11433. sqlString = sqlString + " AND instr(sc.UserCode,:UserCode)>0";
  11434. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CUserCode, ParameterDirection.Input));
  11435. }
  11436. // 产品类别
  11437. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  11438. {
  11439. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 ";
  11440. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  11441. }
  11442. // 产品编码
  11443. if (!string.IsNullOrEmpty(se.GoodsCode))
  11444. {
  11445. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0";
  11446. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  11447. }
  11448. // 成型工号
  11449. if (!string.IsNullOrEmpty(se.GroutingUserCode))
  11450. {
  11451. sqlString = sqlString + " AND instr(sc.GroutingUserCode,:GroutingUserCode)>0";
  11452. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.NVarchar2, se.GroutingUserCode, ParameterDirection.Input));
  11453. }
  11454. // 注浆时间起始
  11455. if (se.GroutingDateTimeStart.HasValue)
  11456. {
  11457. sqlString = sqlString + " AND sc.GroutingDate >= :GroutingDateTimeStart ";
  11458. parameters.Add(new OracleParameter(":GroutingDateTimeStart", OracleDbType.Date, se.GroutingDateTimeStart.Value, ParameterDirection.Input));
  11459. }
  11460. // 注浆时间结束
  11461. if (se.GroutingDateTimeEnd.HasValue)
  11462. {
  11463. sqlString = sqlString + " AND sc.GroutingDate <= :GroutingDateTimeEnd ";
  11464. parameters.Add(new OracleParameter(":GroutingDateTimeEnd", OracleDbType.Date, se.GroutingDateTimeEnd.Value, ParameterDirection.Input));
  11465. }
  11466. // 交坯时间起始
  11467. if (se.DeliveryDateTimeStart.HasValue)
  11468. {
  11469. sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime >= :DeliveryDateTimeStart ";
  11470. parameters.Add(new OracleParameter(":DeliveryDateTimeStart", OracleDbType.Date, se.DeliveryDateTimeStart.Value, ParameterDirection.Input));
  11471. }
  11472. // 交坯时间结束
  11473. if (se.DeliveryDateTimeEnd.HasValue)
  11474. {
  11475. sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime <= :DeliveryDateTimeEnd ";
  11476. parameters.Add(new OracleParameter(":DeliveryDateTimeEnd", OracleDbType.Date, se.DeliveryDateTimeEnd.Value, ParameterDirection.Input));
  11477. }
  11478. // 半检状态
  11479. if (!string.IsNullOrEmpty(se.SemiCheckType))
  11480. {
  11481. sqlString = sqlString + " AND instr(','||:SemiCheckType||',',','||sc.SemiCheckType||',')>0 ";
  11482. parameters.Add(new OracleParameter(":SemiCheckType", OracleDbType.NVarchar2, se.SemiCheckType, ParameterDirection.Input));
  11483. }
  11484. // 半检时间起始
  11485. if (se.SemiCheckDateTimeStart.HasValue)
  11486. {
  11487. sqlString = sqlString + " AND sc.SemiCheckTime >= :SemiCheckDateTimeStart ";
  11488. parameters.Add(new OracleParameter(":SemiCheckDateTimeStart", OracleDbType.Date, se.SemiCheckDateTimeStart.Value, ParameterDirection.Input));
  11489. }
  11490. // 半检时间结束
  11491. if (se.SemiCheckDateTimeEnd.HasValue)
  11492. {
  11493. sqlString = sqlString + " AND sc.SemiCheckTime <= :SemiCheckDateTimeEnd ";
  11494. parameters.Add(new OracleParameter(":SemiCheckDateTimeEnd", OracleDbType.Date, se.SemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  11495. }
  11496. // 半检工号
  11497. if (!string.IsNullOrEmpty(se.SemiCheckUserCode))
  11498. {
  11499. sqlString = sqlString + " AND instr(sc.SemiCheckUserCode,:SemiCheckUserCode)>0";
  11500. parameters.Add(new OracleParameter(":SemiCheckUserCode", OracleDbType.NVarchar2, se.SemiCheckUserCode, ParameterDirection.Input));
  11501. }
  11502. // 返工工序
  11503. if (!string.IsNullOrEmpty(se.RProcedureIDS))
  11504. {
  11505. sqlString = sqlString + " AND instr(','||:RProcedureIDS||',',','||sc.ReworkProcedureID||',')>0 ";
  11506. parameters.Add(new OracleParameter(":RProcedureIDS", OracleDbType.NVarchar2, se.RProcedureIDS, ParameterDirection.Input));
  11507. }
  11508. // 返工工号
  11509. if (!string.IsNullOrEmpty(se.ReworkUserCode))
  11510. {
  11511. sqlString = sqlString + " AND instr(sc.ReworkUserCode,:ReworkUserCode)>0";
  11512. parameters.Add(new OracleParameter(":ReworkUserCode", OracleDbType.NVarchar2, se.ReworkUserCode, ParameterDirection.Input));
  11513. }
  11514. // 复检状态
  11515. if (!string.IsNullOrEmpty(se.ReSemiCheckType))
  11516. {
  11517. sqlString = sqlString + " AND instr(','||:ReSemiCheckType||',',','||sc.ReSemiCheckType||',')>0 ";
  11518. parameters.Add(new OracleParameter(":ReSemiCheckType", OracleDbType.NVarchar2, se.ReSemiCheckType, ParameterDirection.Input));
  11519. }
  11520. // 复检时间起始
  11521. if (se.ReSemiCheckDateTimeStart.HasValue)
  11522. {
  11523. sqlString = sqlString + " AND sc.ReSemiCheckTime >= :ReSemiCheckDateTimeStart ";
  11524. parameters.Add(new OracleParameter(":ReSemiCheckDateTimeStart", OracleDbType.Date, se.ReSemiCheckDateTimeStart.Value, ParameterDirection.Input));
  11525. }
  11526. // 复检时间结束
  11527. if (se.ReSemiCheckDateTimeEnd.HasValue)
  11528. {
  11529. sqlString = sqlString + " AND sc.ReSemiCheckTime <= :ReSemiCheckDateTimeEnd ";
  11530. parameters.Add(new OracleParameter(":ReSemiCheckDateTimeEnd", OracleDbType.Date, se.ReSemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  11531. }
  11532. // 复检工号
  11533. if (!string.IsNullOrEmpty(se.ReSemiCheckUserCode))
  11534. {
  11535. sqlString = sqlString + " AND instr(sc.ReSemiCheckUserCode,:ReSemiCheckUserCode)>0";
  11536. parameters.Add(new OracleParameter(":ReSemiCheckUserCode", OracleDbType.NVarchar2, se.ReSemiCheckUserCode, ParameterDirection.Input));
  11537. }
  11538. // 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),())
  11539. // ORDER BY rp.displayno
  11540. // ,gt2.goodstypename
  11541. // ,sc.reworkusercode
  11542. // ,g.goodscode
  11543. // ,gt.goodstypename, gid) t
  11544. // ";
  11545. sqlString = sqlString +
  11546. " GROUP BY rp.displayno\n" +
  11547. " ,sc.reworkprocedureid\n" +
  11548. " ,rp.procedurename\n" +
  11549. " ,gt2.goodstypecode\n" +
  11550. " ,gt2.goodstypename\n" +
  11551. " ,sc.reworkuserid\n" +
  11552. " ,sc.reworkusercode\n" +
  11553. " ,g.goodsid\n" +
  11554. " ,g.goodscode\n" +
  11555. " ,gt.goodstypename) sct\n" +
  11556. " 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" +
  11557. " ORDER BY sct.displayno\n" +
  11558. " ,sct.goodstypename\n" +
  11559. " ,sct.reworkusercode\n" +
  11560. " ,sct.goodscode\n" +
  11561. " ,sct.goodstypename\n" +
  11562. " ,gid) t";
  11563. return sqlString;
  11564. }
  11565. /// <summary>
  11566. /// 取得RPT080107(半检登记明细)的信息查询数据
  11567. /// </summary>
  11568. /// <param name="user">登录用户信息</param>
  11569. /// <param name="se">查询条件</param>
  11570. /// <returns>查询结果</returns>
  11571. public static ServiceResultEntity GetRPT080107IData(SUserInfo user, SemiCheckEntity se)
  11572. {
  11573. IDBConnection conn = null;
  11574. try
  11575. {
  11576. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  11577. List<OracleParameter> parameters = new List<OracleParameter>();
  11578. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080107ISQL(user, se, ref parameters));
  11579. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  11580. ServiceResultEntity sre = new ServiceResultEntity();
  11581. if (data == null || data.Rows.Count == 0)
  11582. {
  11583. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  11584. return sre;
  11585. }
  11586. sre.Data = new DataSet();
  11587. sre.Data.Tables.Add(data);
  11588. return sre;
  11589. }
  11590. catch (Exception ex)
  11591. {
  11592. throw ex;
  11593. }
  11594. finally
  11595. {
  11596. if (conn != null &&
  11597. conn.ConnState == ConnectionState.Open)
  11598. {
  11599. conn.Close();
  11600. }
  11601. }
  11602. }
  11603. //xuwei add 2019-10-14
  11604. /// <summary>
  11605. /// 取得RPT080108(半检返修登记明细)的信息查询数据
  11606. /// </summary>
  11607. /// <param name="user">登录用户信息</param>
  11608. /// <param name="se">查询条件</param>
  11609. /// <returns>查询结果</returns>
  11610. public static ServiceResultEntity GetRPT080108IData(SUserInfo user, SemiCheckEntity se)
  11611. {
  11612. IDBConnection conn = null;
  11613. try
  11614. {
  11615. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  11616. List<OracleParameter> parameters = new List<OracleParameter>();
  11617. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080108ISQL(user, se, ref parameters));
  11618. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  11619. ServiceResultEntity sre = new ServiceResultEntity();
  11620. if (data == null || data.Rows.Count == 0)
  11621. {
  11622. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  11623. return sre;
  11624. }
  11625. sre.Data = new DataSet();
  11626. sre.Data.Tables.Add(data);
  11627. return sre;
  11628. }
  11629. catch (Exception ex)
  11630. {
  11631. throw ex;
  11632. }
  11633. finally
  11634. {
  11635. if (conn != null &&
  11636. conn.ConnState == ConnectionState.Open)
  11637. {
  11638. conn.Close();
  11639. }
  11640. }
  11641. }
  11642. /// <summary>
  11643. /// 获取RPT080108画面(半检返修登记明细)的汇总信息查询sql
  11644. /// </summary>
  11645. /// <returns>sql</returns>
  11646. private static string GetRPT080108ISQL(SUserInfo user, SemiCheckEntity se, ref List<OracleParameter> parameters)
  11647. {
  11648. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  11649. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  11650. string sqlString = @"
  11651. SELECT
  11652. sr.SEMIREWORKID ,--AS SEMIREWORKID,
  11653. p.PROCEDURECODE ,--AS 完成工序编码,
  11654. p.PROCEDURENAME ,--AS 完成工序,
  11655. sr.PROCEDURETIME ,--AS 完成时间,
  11656. sr.USERCODE ,--完成工号,
  11657. gt2.GOODSTYPENAME AS GOODSTYPENAME2,--AS 产品二级类别,
  11658. gt.GOODSTYPENAME ,--AS 产品类别,
  11659. g.GOODSCODE ,--AS 产品编码,
  11660. g.GOODSNAME,--AS 产品名称,
  11661. sr.BARCODE ,--AS 产品条码,
  11662. sr.SEMIREWORKUSERCODE ,--AS 半检工号,
  11663. sr.SEMIREWORKTIME ,--AS 半检时间,
  11664. pr.PROCEDURECODE AS REWORKPCODE,--AS 返修工序编码,
  11665. pr.PROCEDURENAME AS REWORKPNAME,--AS 返修工序,
  11666. sr.BACKOUTFLAG ,--AS 撤销标识,
  11667. sr.BACKOUTUSERCODE ,--AS 撤销工号,
  11668. sr.BACKOUTTIME ,--AS 撤销时间,
  11669. sr.GROUTINGUSERCODE ,--AS 成型工号,
  11670. sr.GROUTINGLINECODE ,--AS 成型线编码,
  11671. sr.GROUTINGMOULDCODE ,--AS 模具编号,
  11672. sr.GROUTINGDATE ,--AS 注浆时间,
  11673. gd.DELIVERTIME ,--AS 交坯时间,
  11674. l.LOGONAME ,--AS 商标,
  11675. srd.DEFECTCODE ,--AS 缺陷编码,
  11676. srd.DEFECTNAME ,--AS 缺陷名称,
  11677. srd.DEFECTPOSITIONCODE ,--AS 位置编码,
  11678. srd.DEFECTPOSITIONNAME ,--AS 缺陷位置,
  11679. pd.PROCEDURECODE AS DEFECTPCODE,--AS 责任工序编码,
  11680. pd.PROCEDURENAME AS DEFECTPNAME,--AS 责任工序,
  11681. srd.DEFECTUSERCODE ,--AS 责任工号,
  11682. inpp.PROCEDURENAME CurrPROCEDURENAME --AS 当前工序
  11683. FROM
  11684. TP_PM_SEMIREWORK sr
  11685. LEFT JOIN TP_PM_SEMIREWORKDEFECT srd ON sr.SEMIREWORKID = srd.SEMIREWORKID
  11686. LEFT JOIN TP_PC_PROCEDURE p ON p.PROCEDUREID = sr.PROCEDUREID
  11687. LEFT JOIN TP_PC_PROCEDURE pr ON pr.PROCEDUREID = sr.REWORKPROCEDUREID
  11688. LEFT JOIN TP_PC_PROCEDURE pd ON pd.PROCEDUREID = srd.DEFECTPROCEDUREID
  11689. LEFT JOIN TP_MST_GOODS g ON sr.GOODSID = g.GOODSID
  11690. LEFT JOIN TP_MST_GOODSTYPE gt ON g.GOODSTYPEID = gt.GOODSTYPEID
  11691. LEFT JOIN TP_MST_GOODSTYPE gt2 ON gt2.ACCOUNTID = gt.ACCOUNTID
  11692. AND gt2.GOODSTYPECODE = substr( gt.GOODSTYPECODE, 1, 6 )
  11693. LEFT JOIN TP_PM_GROUTINGDAILYDETAIL gd ON gd.GROUTINGDAILYDETAILID = sr.GROUTINGDAILYDETAILID
  11694. LEFT JOIN TP_MST_LOGO l ON gd.LOGOID = l.LOGOID
  11695. LEFT JOIN TP_PM_INPRODUCTION inp ON inp.BARCODE = sr.BARCODE
  11696. LEFT JOIN TP_PC_PROCEDURE inpp ON inp.PROCEDUREID = inpp.PROCEDUREID
  11697. WHERE
  11698. sr.VALUEFLAG = '1'
  11699. AND srd.VALUEFLAG = '1'
  11700. AND sr.AccountID=:AccountID
  11701. ";
  11702. //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))
  11703. // 完成工序
  11704. if (!string.IsNullOrEmpty(se.CProcedureIDS))
  11705. {
  11706. sqlString = sqlString + " AND instr(','||:CProcedureIDS||',',','||p.PROCEDURECODE||',')>0 ";
  11707. parameters.Add(new OracleParameter(":CProcedureIDS", OracleDbType.NVarchar2, se.CProcedureIDS, ParameterDirection.Input));
  11708. }
  11709. // 完成时间起始
  11710. if (se.CDateTimeStart.HasValue)
  11711. {
  11712. sqlString = sqlString + " AND sr.ProcedureTime >= :CDateTimeStart ";
  11713. parameters.Add(new OracleParameter(":CDateTimeStart", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11714. }
  11715. // 完成时间结束
  11716. if (se.CDateTimeEnd.HasValue)
  11717. {
  11718. sqlString = sqlString + " AND sr.ProcedureTime <= :CDateTimeEnd ";
  11719. parameters.Add(new OracleParameter(":CDateTimeEnd", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11720. }
  11721. // 完成工号
  11722. if (!string.IsNullOrEmpty(se.CUserCode))
  11723. {
  11724. sqlString = sqlString + " AND instr(','||:UserCode||',' , ','||sr.UserCode||',')>0";
  11725. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CUserCode, ParameterDirection.Input));
  11726. }
  11727. // 产品类别
  11728. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  11729. {
  11730. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 ";
  11731. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  11732. }
  11733. // 产品编码
  11734. if (!string.IsNullOrEmpty(se.GoodsCode))
  11735. {
  11736. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0";
  11737. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  11738. }
  11739. // 成型工号
  11740. if (!string.IsNullOrEmpty(se.GroutingUserCode))
  11741. {
  11742. sqlString = sqlString + " AND instr(','||:GroutingUserCode||',' , ','||sr.GroutingUserCode||',')>0";
  11743. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.NVarchar2, se.GroutingUserCode, ParameterDirection.Input));
  11744. }
  11745. // 注浆时间起始
  11746. if (se.GroutingDateTimeStart.HasValue)
  11747. {
  11748. sqlString = sqlString + " AND sr.GroutingDate >= :GroutingDateTimeStart ";
  11749. parameters.Add(new OracleParameter(":GroutingDateTimeStart", OracleDbType.Date, se.GroutingDateTimeStart.Value, ParameterDirection.Input));
  11750. }
  11751. // 注浆时间结束
  11752. if (se.GroutingDateTimeEnd.HasValue)
  11753. {
  11754. sqlString = sqlString + " AND sr.GroutingDate <= :GroutingDateTimeEnd ";
  11755. parameters.Add(new OracleParameter(":GroutingDateTimeEnd", OracleDbType.Date, se.GroutingDateTimeEnd.Value, ParameterDirection.Input));
  11756. }
  11757. // 交坯时间起始
  11758. if (se.DeliveryDateTimeStart.HasValue)
  11759. {
  11760. sqlString = sqlString + " AND gd.DeliverTime >= :DeliveryDateTimeStart ";
  11761. parameters.Add(new OracleParameter(":DeliveryDateTimeStart", OracleDbType.Date, se.DeliveryDateTimeStart.Value, ParameterDirection.Input));
  11762. }
  11763. // 交坯时间结束
  11764. if (se.DeliveryDateTimeEnd.HasValue)
  11765. {
  11766. sqlString = sqlString + " AND gd.DeliverTime <= :DeliveryDateTimeEnd ";
  11767. parameters.Add(new OracleParameter(":DeliveryDateTimeEnd", OracleDbType.Date, se.DeliveryDateTimeEnd.Value, ParameterDirection.Input));
  11768. }
  11769. // 半检时间起始
  11770. if (se.SemiCheckDateTimeStart.HasValue)
  11771. {
  11772. sqlString = sqlString + " AND sr.SEMIREWORKTIME >= :SemiCheckDateTimeStart ";
  11773. parameters.Add(new OracleParameter(":SemiCheckDateTimeStart", OracleDbType.Date, se.SemiCheckDateTimeStart.Value, ParameterDirection.Input));
  11774. }
  11775. // 半检时间结束
  11776. if (se.SemiCheckDateTimeEnd.HasValue)
  11777. {
  11778. sqlString = sqlString + " AND sr.SEMIREWORKTIME <= :SemiCheckDateTimeEnd ";
  11779. parameters.Add(new OracleParameter(":SemiCheckDateTimeEnd", OracleDbType.Date, se.SemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  11780. }
  11781. // 半检工号
  11782. if (!string.IsNullOrEmpty(se.SemiCheckUserCode))
  11783. {
  11784. sqlString = sqlString + " AND instr(','||:SemiCheckUserCode||',' , ','||sr.SEMIREWORKUSERCODE||',')>0";
  11785. parameters.Add(new OracleParameter(":SemiCheckUserCode", OracleDbType.NVarchar2, se.SemiCheckUserCode, ParameterDirection.Input));
  11786. }
  11787. // 返修工序
  11788. if (!string.IsNullOrEmpty(se.RProcedureIDS))
  11789. {
  11790. sqlString = sqlString + " AND instr(','||:RProcedureIDS||',',','||pr.PROCEDUREID||',')>0 ";
  11791. parameters.Add(new OracleParameter(":RProcedureIDS", OracleDbType.NVarchar2, se.RProcedureIDS, ParameterDirection.Input));
  11792. }
  11793. // 返修工号
  11794. if (!string.IsNullOrEmpty(se.ReworkUserCode))
  11795. {
  11796. sqlString = sqlString + " AND instr(sr.ReworkUserCode,:ReworkUserCode)>0";
  11797. parameters.Add(new OracleParameter(":ReworkUserCode", OracleDbType.NVarchar2, se.ReworkUserCode, ParameterDirection.Input));
  11798. }
  11799. // 撤销标识
  11800. if (!string.IsNullOrEmpty(se.BackOutFlag))
  11801. {
  11802. sqlString = sqlString + " AND instr(','||:BackOutFlag||',',','||sr.BackOutFlag||',')>0 ";
  11803. parameters.Add(new OracleParameter(":BackOutFlag", OracleDbType.NVarchar2, se.BackOutFlag, ParameterDirection.Input));
  11804. }
  11805. // 撤销时间起始
  11806. if (se.BackOutTimeStart.HasValue)
  11807. {
  11808. sqlString = sqlString + " AND sr.BackOutTime >= :BackOutTimeStart ";
  11809. parameters.Add(new OracleParameter(":BackOutTimeStart", OracleDbType.Date, se.BackOutTimeStart.Value, ParameterDirection.Input));
  11810. }
  11811. // 撤销时间结束
  11812. if (se.BackOutTimeEnd.HasValue)
  11813. {
  11814. sqlString = sqlString + " AND sr.BackOutTime <= :BackOutTimeEnd ";
  11815. parameters.Add(new OracleParameter(":BackOutTimeEnd", OracleDbType.Date, se.BackOutTimeEnd.Value, ParameterDirection.Input));
  11816. }
  11817. // 撤销工号
  11818. if (!string.IsNullOrEmpty(se.BackOutUserCode))
  11819. {
  11820. sqlString = sqlString + " AND instr(','||:BackOutUserCode||',' , ','||sr.BackOutUserCode||',')>0";
  11821. parameters.Add(new OracleParameter(":BackOutUserCode", OracleDbType.NVarchar2, se.BackOutUserCode, ParameterDirection.Input));
  11822. }
  11823. // 产品条码
  11824. if (!string.IsNullOrEmpty(se.BarCode))
  11825. {
  11826. sqlString = sqlString + " AND instr(sr.BarCode,:BarCode)>0";
  11827. parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.BarCode, ParameterDirection.Input));
  11828. }
  11829. // 缺陷编码
  11830. if (!string.IsNullOrEmpty(se.DefectCode))
  11831. {
  11832. sqlString = sqlString + " AND instr(srd.DefectCode,:DefectCode)>0";
  11833. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  11834. }
  11835. // 缺陷位置集
  11836. if (!string.IsNullOrEmpty(se.DefectPositionIDS))
  11837. {
  11838. sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||srd.DefectPositionID||',')>0 ";
  11839. parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectPositionIDS, ParameterDirection.Input));
  11840. }
  11841. // 责任工序集
  11842. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  11843. {
  11844. sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||pd.PROCEDUREID||',')>0 ";
  11845. parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  11846. }
  11847. // 责任工号
  11848. if (!string.IsNullOrEmpty(se.DefectUser))
  11849. {
  11850. sqlString = sqlString + " AND instr(srd.DEFECTUSERCODE,:DefectUser)>0";
  11851. parameters.Add(new OracleParameter(":DefectUser", OracleDbType.NVarchar2, se.DefectUser, ParameterDirection.Input));
  11852. }
  11853. // 只显示最后一条半检记录
  11854. if (se.SemiCheckType == "1")
  11855. {
  11856. // 撤销的记录全显示,未撤销的记录只显示最后一条
  11857. sqlString += " and (sr.backoutflag = '1' or not exists (select sw.semireworkid\n" +
  11858. " from TP_PM_SEMIREWORK sw\n" +
  11859. " where sw.barcode = sr.barcode\n" +
  11860. " and sw.valueflag = '1'\n" +
  11861. " and (sw.backoutflag = '0')\n" +
  11862. " and sw.semireworkid > sr.semireworkid) )";
  11863. }
  11864. return sqlString;
  11865. }
  11866. //xuwei end
  11867. //xuwei add 2019-10-21
  11868. /// <summary>
  11869. /// 统计当前工号,当日,按产品编码分组统计半检返修数据数量
  11870. /// </summary>
  11871. /// <param name="user">用户</param>
  11872. /// <param name="dataStr">统计日期</param>
  11873. /// <returns></returns>
  11874. public static ServiceResultEntity GetSemiReworkDayCount(SUserInfo user, string dateStr)
  11875. {
  11876. IDBConnection conn = null;
  11877. try
  11878. {
  11879. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  11880. string sqlStr = $@"
  11881. SELECT
  11882. nvl(sr.SEMIREWORKUSERCODE,'--') SEMIREWORKUSERCODE,--AS 半检工号,
  11883. nvl( g.GOODSCODE, '合计' ) GOODSCODE,--AS 产品编码,
  11884. nvl(g.GOODSNAME,'--') GOODSNAME,--AS 产口名称,
  11885. to_char(count( sr.SEMIREWORKID )) GOODSCOUNT --AS 返修数量
  11886. FROM
  11887. TP_PM_SEMIREWORK sr
  11888. LEFT JOIN TP_PM_SEMIREWORKDEFECT srd ON sr.SEMIREWORKID = srd.SEMIREWORKID
  11889. LEFT JOIN TP_MST_GOODS g ON sr.GOODSID = g.GOODSID
  11890. WHERE
  11891. sr.VALUEFLAG = '1'
  11892. AND sr.ACCOUNTID = '{user.AccountID}'
  11893. AND sr.SEMIREWORKUSERCODE = '{user.UserCode}'
  11894. AND to_date(to_char(sr.CREATETIME,'yyyy-mm-dd'),'yyyy-mm-dd') = to_date('{dateStr}','yyyy-mm-dd')
  11895. GROUP BY
  11896. grouping sets ( ( sr.SEMIREWORKUSERCODE, g.GOODSCODE, g.GOODSNAME ), ( ) )
  11897. ";
  11898. DataTable data = conn.GetSqlResultToDt(sqlStr);
  11899. ServiceResultEntity sre = new ServiceResultEntity();
  11900. //if (data == null || data.Rows.Count == 0)
  11901. //{
  11902. // sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  11903. // return sre;
  11904. //}
  11905. sre.Data = new DataSet();
  11906. sre.Data.Tables.Add(data);
  11907. return sre;
  11908. }
  11909. catch (Exception ex)
  11910. {
  11911. throw ex;
  11912. }
  11913. finally
  11914. {
  11915. if (conn != null &&
  11916. conn.ConnState == ConnectionState.Open)
  11917. {
  11918. conn.Close();
  11919. }
  11920. }
  11921. }
  11922. //xuwei end
  11923. /// <summary>
  11924. /// 获取RPT030110画面(半检登记汇总表)的汇总信息查询sql
  11925. /// </summary>
  11926. /// <returns>sql</returns>
  11927. private static string GetRPT080107ISQL(SUserInfo user, SemiCheckEntity se, ref List<OracleParameter> parameters)
  11928. {
  11929. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  11930. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  11931. string sqlString = @"
  11932. select
  11933. SemiCheck.SemiCheckID,
  11934. CProcedure.ProcedureName as CProcedureName,
  11935. SemiCheck.ProcedureTime,
  11936. SemiCheck.UserCode,
  11937. GoodsType2.GoodsTypeName as LevelGoodsTypeName,
  11938. GoodsType.GoodsTypeName,
  11939. Goods.GoodsCode,
  11940. SemiCheck.BarCode,
  11941. -- 复检后不显示半检状态
  11942. SemiCheckType.SemiCheckTypeName,
  11943. --decode(SemiCheck.ReSemiCheckType, 0, SemiCheckType.SemiCheckTypeName, '已复检') SemiCheckTypeName,
  11944. SemiCheck.SemiCheckUserCode,
  11945. SemiCheck.SemiCheckTime,
  11946. ReSemiCheckType.ReSemiCheckTypeName,
  11947. SemiCheck.ReSemiCheckUserCode,
  11948. SemiCheck.ReSemiCheckTime,
  11949. decode(SemiCheck.BackOutFlag,'0','正常','撤销') as BackOutFlag,
  11950. SemiCheck.BackOutUserCode,
  11951. SemiCheck.BackOutTime,
  11952. SemiCheck.GroutingUserCode,
  11953. SemiCheck.GroutingLineCode,
  11954. SemiCheck.GroutingMouldCode,
  11955. SemiCheck.GroutingDate,
  11956. GroutingDailyDetail.DeliverTime,
  11957. logo.logoName,
  11958. RProcedure.ProcedureName as RProcedureName,
  11959. SemiCheck.ReworkUserCode,
  11960. SemiCheckDefect.DefectCode,
  11961. SemiCheckDefect.DefectName as DefectName1,
  11962. concat(SemiCheckDefect.DefectCode||'->',SemiCheckDefect.DefectName) as DefectName,
  11963. SemiCheckDefect.DefectPositionName,
  11964. SemiCheckDefect.DefectPositionCode,
  11965. concat(SemiCheckDefect.DefectPositionCode||'->',SemiCheckDefect.DefectPositionName) as DefectPositionName,
  11966. Procedure.ProcedureName,
  11967. inpp.ProcedureName CurrProcedureName,
  11968. DefectUser.username as DefectUser
  11969. from TP_PM_SemiCheck SemiCheck
  11970. left join TP_PC_Procedure CProcedure
  11971. on SemiCheck.ProcedureID=CProcedure.ProcedureID
  11972. left join TP_MST_Goods Goods
  11973. on SemiCheck.GoodsID=Goods.GoodsID
  11974. left join TP_MST_GoodsType GoodsType
  11975. on Goods.GoodsTypeID=GoodsType.GoodsTypeID
  11976. left join TP_MST_GoodsType GoodsType2
  11977. on GoodsType2.accountid=GoodsType.accountid
  11978. and GoodsType2.GoodsTypecode=substr(GoodsType.GoodsTypecode,1,6)
  11979. left join TP_SYS_SemiCheckType SemiCheckType
  11980. on SemiCheck.SemiCheckType=SemiCheckType.SemiCheckTypeID
  11981. left join TP_SYS_ReSemiCheckType ReSemiCheckType
  11982. on SemiCheck.ReSemiCheckType=ReSemiCheckType.ReSemiCheckTypeID
  11983. left join TP_PM_GroutingDailyDetail GroutingDailyDetail
  11984. on GroutingDailyDetail.GroutingDailyDetailID=SemiCheck.GroutingDailyDetailID
  11985. left join TP_MST_Logo logo
  11986. on GroutingDailyDetail.LogoID=logo.LogoID
  11987. left join TP_PC_Procedure RProcedure
  11988. on SemiCheck.ReworkProcedureID=RProcedure.ProcedureID
  11989. left join TP_PM_SemiCheckDefect SemiCheckDefect
  11990. on SemiCheck.SemiCheckID=SemiCheckDefect.SemiCheckID
  11991. and SemiCheckDefect.ValueFlag='1'
  11992. left join TP_PC_Procedure Procedure
  11993. on SemiCheckDefect.DefectProcedureID=Procedure.ProcedureID
  11994. left join TP_MST_User DefectUser
  11995. on DefectUser.userid=SemiCheckDefect.DefectUserID
  11996. left join tp_pm_inproduction inp on inp.barcode = SemiCheck.barcode
  11997. left join TP_PC_Procedure inpp on inp.ProcedureID = inpp.ProcedureID
  11998. where SemiCheck.AccountID=:AccountID
  11999. ";
  12000. //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))
  12001. // 完成工序
  12002. if (!string.IsNullOrEmpty(se.CProcedureIDS))
  12003. {
  12004. sqlString = sqlString + " AND instr(','||:CProcedureIDS||',',','||SemiCheck.ProcedureID||',')>0 ";
  12005. parameters.Add(new OracleParameter(":CProcedureIDS", OracleDbType.NVarchar2, se.CProcedureIDS, ParameterDirection.Input));
  12006. }
  12007. // 完成时间起始
  12008. if (se.CDateTimeStart.HasValue)
  12009. {
  12010. sqlString = sqlString + " AND SemiCheck.ProcedureTime >= :CDateTimeStart ";
  12011. parameters.Add(new OracleParameter(":CDateTimeStart", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  12012. }
  12013. // 完成时间结束
  12014. if (se.CDateTimeEnd.HasValue)
  12015. {
  12016. sqlString = sqlString + " AND SemiCheck.ProcedureTime <= :CDateTimeEnd ";
  12017. parameters.Add(new OracleParameter(":CDateTimeEnd", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  12018. }
  12019. // 完成工号
  12020. if (!string.IsNullOrEmpty(se.CUserCode))
  12021. {
  12022. sqlString = sqlString + " AND instr(SemiCheck.UserCode,:UserCode)>0";
  12023. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CUserCode, ParameterDirection.Input));
  12024. }
  12025. // 产品类别
  12026. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  12027. {
  12028. sqlString = sqlString + " AND instr(GoodsType.GoodsTypeCode,:GoodsTypeCode)=1 ";
  12029. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  12030. }
  12031. // 产品编码
  12032. if (!string.IsNullOrEmpty(se.GoodsCode))
  12033. {
  12034. sqlString = sqlString + " AND instr(Goods.GoodsCode,:GoodsCode)>0";
  12035. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  12036. }
  12037. // 成型工号
  12038. if (!string.IsNullOrEmpty(se.GroutingUserCode))
  12039. {
  12040. sqlString = sqlString + " AND instr(SemiCheck.GroutingUserCode,:GroutingUserCode)>0";
  12041. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.NVarchar2, se.GroutingUserCode, ParameterDirection.Input));
  12042. }
  12043. // 注浆时间起始
  12044. if (se.GroutingDateTimeStart.HasValue)
  12045. {
  12046. sqlString = sqlString + " AND SemiCheck.GroutingDate >= :GroutingDateTimeStart ";
  12047. parameters.Add(new OracleParameter(":GroutingDateTimeStart", OracleDbType.Date, se.GroutingDateTimeStart.Value, ParameterDirection.Input));
  12048. }
  12049. // 注浆时间结束
  12050. if (se.GroutingDateTimeEnd.HasValue)
  12051. {
  12052. sqlString = sqlString + " AND SemiCheck.GroutingDate <= :GroutingDateTimeEnd ";
  12053. parameters.Add(new OracleParameter(":GroutingDateTimeEnd", OracleDbType.Date, se.GroutingDateTimeEnd.Value, ParameterDirection.Input));
  12054. }
  12055. // 交坯时间起始
  12056. if (se.DeliveryDateTimeStart.HasValue)
  12057. {
  12058. sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime >= :DeliveryDateTimeStart ";
  12059. parameters.Add(new OracleParameter(":DeliveryDateTimeStart", OracleDbType.Date, se.DeliveryDateTimeStart.Value, ParameterDirection.Input));
  12060. }
  12061. // 交坯时间结束
  12062. if (se.DeliveryDateTimeEnd.HasValue)
  12063. {
  12064. sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime <= :DeliveryDateTimeEnd ";
  12065. parameters.Add(new OracleParameter(":DeliveryDateTimeEnd", OracleDbType.Date, se.DeliveryDateTimeEnd.Value, ParameterDirection.Input));
  12066. }
  12067. // 半检状态
  12068. if (!string.IsNullOrEmpty(se.SemiCheckType))
  12069. {
  12070. sqlString = sqlString + " AND instr(','||:SemiCheckType||',',','||SemiCheck.SemiCheckType||',')>0 ";
  12071. parameters.Add(new OracleParameter(":SemiCheckType", OracleDbType.NVarchar2, se.SemiCheckType, ParameterDirection.Input));
  12072. }
  12073. // 半检时间起始
  12074. if (se.SemiCheckDateTimeStart.HasValue)
  12075. {
  12076. sqlString = sqlString + " AND SemiCheck.SemiCheckTime >= :SemiCheckDateTimeStart ";
  12077. parameters.Add(new OracleParameter(":SemiCheckDateTimeStart", OracleDbType.Date, se.SemiCheckDateTimeStart.Value, ParameterDirection.Input));
  12078. }
  12079. // 半检时间结束
  12080. if (se.SemiCheckDateTimeEnd.HasValue)
  12081. {
  12082. sqlString = sqlString + " AND SemiCheck.SemiCheckTime <= :SemiCheckDateTimeEnd ";
  12083. parameters.Add(new OracleParameter(":SemiCheckDateTimeEnd", OracleDbType.Date, se.SemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  12084. }
  12085. // 半检工号
  12086. if (!string.IsNullOrEmpty(se.SemiCheckUserCode))
  12087. {
  12088. sqlString = sqlString + " AND instr(SemiCheck.SemiCheckUserCode,:SemiCheckUserCode)>0";
  12089. parameters.Add(new OracleParameter(":SemiCheckUserCode", OracleDbType.NVarchar2, se.SemiCheckUserCode, ParameterDirection.Input));
  12090. }
  12091. // 返工工序
  12092. if (!string.IsNullOrEmpty(se.RProcedureIDS))
  12093. {
  12094. sqlString = sqlString + " AND instr(','||:RProcedureIDS||',',','||SemiCheck.ReworkProcedureID||',')>0 ";
  12095. parameters.Add(new OracleParameter(":RProcedureIDS", OracleDbType.NVarchar2, se.RProcedureIDS, ParameterDirection.Input));
  12096. }
  12097. // 返工工号
  12098. if (!string.IsNullOrEmpty(se.ReworkUserCode))
  12099. {
  12100. sqlString = sqlString + " AND instr(SemiCheck.ReworkUserCode,:ReworkUserCode)>0";
  12101. parameters.Add(new OracleParameter(":ReworkUserCode", OracleDbType.NVarchar2, se.ReworkUserCode, ParameterDirection.Input));
  12102. }
  12103. // 复检状态
  12104. if (!string.IsNullOrEmpty(se.ReSemiCheckType))
  12105. {
  12106. sqlString = sqlString + " AND instr(','||:ReSemiCheckType||',',','||SemiCheck.ReSemiCheckType||',')>0 ";
  12107. parameters.Add(new OracleParameter(":ReSemiCheckType", OracleDbType.NVarchar2, se.ReSemiCheckType, ParameterDirection.Input));
  12108. }
  12109. // 复检时间起始
  12110. if (se.ReSemiCheckDateTimeStart.HasValue)
  12111. {
  12112. sqlString = sqlString + " AND SemiCheck.ReSemiCheckTime >= :ReSemiCheckDateTimeStart ";
  12113. parameters.Add(new OracleParameter(":ReSemiCheckDateTimeStart", OracleDbType.Date, se.ReSemiCheckDateTimeStart.Value, ParameterDirection.Input));
  12114. }
  12115. // 复检时间结束
  12116. if (se.ReSemiCheckDateTimeEnd.HasValue)
  12117. {
  12118. sqlString = sqlString + " AND SemiCheck.ReSemiCheckTime <= :ReSemiCheckDateTimeEnd ";
  12119. parameters.Add(new OracleParameter(":ReSemiCheckDateTimeEnd", OracleDbType.Date, se.ReSemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  12120. }
  12121. // 复检工号
  12122. if (!string.IsNullOrEmpty(se.ReSemiCheckUserCode))
  12123. {
  12124. sqlString = sqlString + " AND instr(SemiCheck.ReSemiCheckUserCode,:ReSemiCheckUserCode)>0";
  12125. parameters.Add(new OracleParameter(":ReSemiCheckUserCode", OracleDbType.NVarchar2, se.ReSemiCheckUserCode, ParameterDirection.Input));
  12126. }
  12127. // 撤销标识
  12128. if (!string.IsNullOrEmpty(se.BackOutFlag))
  12129. {
  12130. sqlString = sqlString + " AND instr(','||:BackOutFlag||',',','||SemiCheck.BackOutFlag||',')>0 ";
  12131. parameters.Add(new OracleParameter(":BackOutFlag", OracleDbType.NVarchar2, se.BackOutFlag, ParameterDirection.Input));
  12132. }
  12133. // 撤销时间起始
  12134. if (se.BackOutTimeStart.HasValue)
  12135. {
  12136. sqlString = sqlString + " AND SemiCheck.BackOutTime >= :BackOutTimeStart ";
  12137. parameters.Add(new OracleParameter(":BackOutTimeStart", OracleDbType.Date, se.BackOutTimeStart.Value, ParameterDirection.Input));
  12138. }
  12139. // 撤销时间结束
  12140. if (se.BackOutTimeEnd.HasValue)
  12141. {
  12142. sqlString = sqlString + " AND SemiCheck.BackOutTime <= :BackOutTimeEnd ";
  12143. parameters.Add(new OracleParameter(":BackOutTimeEnd", OracleDbType.Date, se.BackOutTimeEnd.Value, ParameterDirection.Input));
  12144. }
  12145. // 撤销工号
  12146. if (!string.IsNullOrEmpty(se.BackOutUserCode))
  12147. {
  12148. sqlString = sqlString + " AND instr(SemiCheck.BackOutUserCode,:BackOutUserCode)>0";
  12149. parameters.Add(new OracleParameter(":BackOutUserCode", OracleDbType.NVarchar2, se.BackOutUserCode, ParameterDirection.Input));
  12150. }
  12151. // 产品条码
  12152. if (!string.IsNullOrEmpty(se.BarCode))
  12153. {
  12154. sqlString = sqlString + " AND instr(SemiCheck.BarCode,:BarCode)>0";
  12155. parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.BarCode, ParameterDirection.Input));
  12156. }
  12157. // 缺陷编码
  12158. if (!string.IsNullOrEmpty(se.DefectCode))
  12159. {
  12160. sqlString = sqlString + " AND instr(SemiCheckDefect.DefectCode,:DefectCode)>0";
  12161. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  12162. }
  12163. // 缺陷位置集
  12164. if (!string.IsNullOrEmpty(se.DefectPositionIDS))
  12165. {
  12166. sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||SemiCheckDefect.DefectPositionID||',')>0 ";
  12167. parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectPositionIDS, ParameterDirection.Input));
  12168. }
  12169. // 责任工序集
  12170. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  12171. {
  12172. sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||SemiCheckDefect.DefectPositionID||',')>0 ";
  12173. parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  12174. }
  12175. // 责任工号
  12176. if (!string.IsNullOrEmpty(se.DefectUser))
  12177. {
  12178. sqlString = sqlString + " AND instr(DefectUser.UserCode,:DefectUser)>0";
  12179. parameters.Add(new OracleParameter(":DefectUser", OracleDbType.NVarchar2, se.DefectUser, ParameterDirection.Input));
  12180. }
  12181. return sqlString;
  12182. }
  12183. /// <summary>
  12184. /// 取得F_RPT_030112画面(产成品交接汇总表)的汇总信息查询数据
  12185. /// </summary>
  12186. /// <param name="user">登录用户信息</param>
  12187. /// <param name="se">查询条件</param>
  12188. /// <returns>查询结果</returns>
  12189. public static ServiceResultEntity GetRPT0030112SData(SUserInfo user, SearchFinishedProductEntity se)
  12190. {
  12191. IDBConnection conn = null;
  12192. try
  12193. {
  12194. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12195. List<OracleParameter> parameters = new List<OracleParameter>();
  12196. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030112SSQL(user, se, ref parameters));
  12197. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  12198. ServiceResultEntity sre = new ServiceResultEntity();
  12199. if (data == null || data.Rows.Count == 0)
  12200. {
  12201. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12202. return sre;
  12203. }
  12204. sre.Data = new DataSet();
  12205. sre.Data.Tables.Add(data);
  12206. return sre;
  12207. }
  12208. catch (Exception ex)
  12209. {
  12210. throw ex;
  12211. }
  12212. finally
  12213. {
  12214. if (conn != null &&
  12215. conn.ConnState == ConnectionState.Open)
  12216. {
  12217. conn.Close();
  12218. }
  12219. }
  12220. }
  12221. /// <summary>
  12222. /// 获取RPT030112画面(产成品交接汇总表)的汇总信息查询sql
  12223. /// </summary>
  12224. /// <returns>sql</returns>
  12225. private static string GetRPT030112SSQL(SUserInfo user, SearchFinishedProductEntity se, ref List<OracleParameter> parameters)
  12226. {
  12227. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12228. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  12229. string sqlString = @"SELECT ts.gid
  12230. ,logoid
  12231. ,decode(ts.gid,
  12232. '23',
  12233. '总计【' || orderno || '】',
  12234. decode(ts.gid, '1', '--', '3', '--', orderno)) AS orderno
  12235. ,decode(ts.gid,
  12236. '3',
  12237. '合计【' || logoname || '】',
  12238. decode(ts.gid, '1', '--', logoname)) AS logoname
  12239. ,decode(ts.gid, '1', '小计【' || goodscode || '】', goodscode) AS goodscode
  12240. ,decode(ts.gid, '1', '--', goodsmodel) AS goodsmodel
  12241. ,GoodsSpecification
  12242. ,fhtime
  12243. ,COUNT
  12244. FROM (SELECT grouping_id(l.logoid,
  12245. o.orderno,
  12246. l.logoname,
  12247. g.goodscode,
  12248. to_char(f.fhtime, 'yyyy-mm-dd')) AS gid
  12249. ,decode(GROUPING(l.logoid), 1, '--', l.logoid) AS logoid
  12250. ,decode(GROUPING(o.orderno), 1, '--', o.orderno) AS orderno
  12251. ,decode(GROUPING(l.logoname), 1, '--', l.logoname) AS logoname
  12252. ,decode(GROUPING(g.goodscode), 1, '--', g.goodscode) AS goodscode
  12253. ,decode(GROUPING(g.goodscode), 1, '--', g.goodsmodel) AS goodsmodel
  12254. ,decode(GROUPING(g.GoodsSpecification), 1, '--', g.GoodsSpecification) AS GoodsSpecification
  12255. ,decode(GROUPING(to_char(f.fhtime, 'yyyy-mm-dd')),
  12256. 1,
  12257. '--',
  12258. to_char(f.fhtime, 'yyyy-mm-dd')) AS fhtime
  12259. ,COUNT(f.fhtime) AS COUNT
  12260. FROM tp_pm_finishedproduct F
  12261. LEFT JOIN TP_PM_Order O ON F.Fhorderid = O.Orderid
  12262. LEFT JOIN tp_mst_logo L ON F.LOGOID = L.LOGOID
  12263. LEFT JOIN tp_mst_goods G ON g.goodsid = f.goodsid
  12264. LEFT JOIN TP_MST_GoodsType gt ON g.GoodsTypeID = gt.GoodsTypeID
  12265. where f.fhtime is not null and f.AccountID=:AccountID ";
  12266. // 交接时间起始
  12267. if (se.FHTimeStart.HasValue)
  12268. {
  12269. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart ";
  12270. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, se.FHTimeStart.Value, ParameterDirection.Input));
  12271. }
  12272. // 交接时间结束
  12273. if (se.FHTimeEnd.HasValue)
  12274. {
  12275. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd ";
  12276. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, se.FHTimeEnd.Value, ParameterDirection.Input));
  12277. }
  12278. // 订单号
  12279. if (!string.IsNullOrEmpty(se.OrderNo))
  12280. {
  12281. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0";
  12282. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, se.OrderNo, ParameterDirection.Input));
  12283. }
  12284. // 产品类别编码
  12285. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  12286. {
  12287. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1";
  12288. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  12289. }
  12290. // 产品编码
  12291. if (!string.IsNullOrEmpty(se.GoodsCode))
  12292. {
  12293. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0";
  12294. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  12295. }
  12296. // 产品型号
  12297. if (!string.IsNullOrEmpty(se.GoodsModel))
  12298. {
  12299. sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0";
  12300. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, se.GoodsModel, ParameterDirection.Input));
  12301. }
  12302. // 产品商标ID集
  12303. if (!string.IsNullOrEmpty(se.LogoIDS))
  12304. {
  12305. sqlString += " AND instr(','||:LogoIDS||',', ',' || L.logoid || ',') > 0";
  12306. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, se.LogoIDS, ParameterDirection.Input));
  12307. }
  12308. // 交接工号
  12309. if (!string.IsNullOrEmpty(se.FHUserCode))
  12310. {
  12311. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0";
  12312. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, se.FHUserCode, ParameterDirection.Input));
  12313. }
  12314. sqlString = sqlString + @" GROUP BY rollup(o.orderno,l.logoid, l.logoname,g.goodscode,g.goodsmodel,g.GoodsSpecification,to_char(f.fhtime, 'yyyy-mm-dd'))
  12315. order by o.orderno,l.logoid, l.logoname,g.goodscode,to_char(f.fhtime, 'yyyy-mm-dd')
  12316. )ts
  12317. where ( logoid!='--' and orderno!='--' and logoname!='--' and goodscode!='--' and fhtime!='--')
  12318. or (goodscode!='--')
  12319. or(logoname!='')
  12320. or (orderno!='--') and ts.gid!='7'";
  12321. return sqlString;
  12322. }
  12323. /// <summary>
  12324. /// 取得F_RPT_030112画面(产成品交接汇总表)的汇总信息
  12325. /// </summary>
  12326. /// <param name="user">登录用户信息</param>
  12327. /// <param name="se">查询条件</param>
  12328. /// <returns>查询结果</returns>
  12329. public static ServiceResultEntity GetRPT0030112SumData(ClientRequestEntity cre, SUserInfo user)
  12330. {
  12331. IDBConnection conn = null;
  12332. try
  12333. {
  12334. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12335. List<OracleParameter> parameters = new List<OracleParameter>();
  12336. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12337. //string sqlString = "SELECT trunc(f.fhtime) fhtime, g.goodscode, COUNT(*) goodscount\n" +
  12338. string sqlString = "SELECT nvl2(o.orderno,\n" +
  12339. " nvl2(l.logoname,\n" +
  12340. " o.orderno,\n" +
  12341. " to_char('合计[') || o.orderno ||\n" +
  12342. " to_char(']')),\n" +
  12343. " '总计') orderno\n" +
  12344. " ,nvl2(l.logoname,\n" +
  12345. " nvl2(g.goodscode,\n" +
  12346. " l.logoname,\n" +
  12347. " to_char('小计[' || l.logoname || ']')),\n" +
  12348. " '--') logoname\n" +
  12349. " ,nvl(g.goodscode, '--') goodscode" +
  12350. " ,nvl(g.goodsmodel, '--') goodsmodel" +
  12351. " ,nvl(gdd.materialcode, '--') mcode" +
  12352. " ,f.logoid" +
  12353. " ,f.goodsid" +
  12354. " ,f.fhorderid" +
  12355. " ,COUNT(*) count" +
  12356. " FROM tp_pm_finishedproduct f\n" +
  12357. " inner JOIN tp_pm_groutingdailydetail gdd\n" +
  12358. " ON gdd.barcode = f.barcode\n" +
  12359. " LEFT JOIN tp_mst_logo l\n" +
  12360. " ON f.logoid = l.logoid\n" +
  12361. " LEFT JOIN TP_PM_Order O\n" +
  12362. " ON f.Fhorderid = O.Orderid\n" +
  12363. " LEFT JOIN tp_mst_goods G\n" +
  12364. " ON g.goodsid = f.goodsid\n" +
  12365. " LEFT JOIN TP_MST_GoodsType gt\n" +
  12366. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  12367. " WHERE f.fhtime IS NOT NULL\n" +
  12368. " AND f.AccountID = :AccountID\n";
  12369. // 交接时间起始
  12370. if (cre.Properties["FHTimeStart"] != null)
  12371. {
  12372. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
  12373. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, cre.Properties["FHTimeStart"], ParameterDirection.Input));
  12374. }
  12375. // 交接时间结束
  12376. if (cre.Properties["FHTimeEnd"] != null)
  12377. {
  12378. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd \n";
  12379. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, cre.Properties["FHTimeEnd"], ParameterDirection.Input));
  12380. }
  12381. // 订单号
  12382. if (!string.IsNullOrEmpty(cre.Properties["OrderNo"] as string))
  12383. {
  12384. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0 \n";
  12385. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, cre.Properties["OrderNo"], ParameterDirection.Input));
  12386. }
  12387. // 产品类别编码
  12388. if (!string.IsNullOrEmpty(cre.Properties["GoodsTypeCode"] as string))
  12389. {
  12390. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 \n";
  12391. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input));
  12392. }
  12393. // 产品编码
  12394. if (!string.IsNullOrEmpty(cre.Properties["GoodsCode"] as string))
  12395. {
  12396. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
  12397. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input));
  12398. }
  12399. // 产品型号
  12400. if (!string.IsNullOrEmpty(cre.Properties["GoodsModel"] as string))
  12401. {
  12402. sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0 \n";
  12403. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, cre.Properties["GoodsModel"], ParameterDirection.Input));
  12404. }
  12405. // 产品商标ID集
  12406. if (!string.IsNullOrEmpty(cre.Properties["LogoIDS"] as string))
  12407. {
  12408. sqlString += " AND instr(','||:LogoIDS||',', ',' || f.logoid || ',') > 0 \n";
  12409. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, cre.Properties["LogoIDS"], ParameterDirection.Input));
  12410. }
  12411. // 交接工号
  12412. if (!string.IsNullOrEmpty(cre.Properties["FHUserCode"] as string))
  12413. {
  12414. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0 \n";
  12415. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, cre.Properties["FHUserCode"], ParameterDirection.Input));
  12416. }
  12417. //sqlString += " group by trunc(f.fhtime), g.goodscode order by trunc(f.fhtime), g.goodscode";
  12418. 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),())";
  12419. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  12420. ServiceResultEntity sre = new ServiceResultEntity();
  12421. if (data == null || data.Rows.Count == 0)
  12422. {
  12423. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12424. return sre;
  12425. }
  12426. sre.Data = new DataSet();
  12427. sre.Data.Tables.Add(data);
  12428. return sre;
  12429. }
  12430. catch (Exception ex)
  12431. {
  12432. throw ex;
  12433. }
  12434. finally
  12435. {
  12436. if (conn != null &&
  12437. conn.ConnState == ConnectionState.Open)
  12438. {
  12439. conn.Close();
  12440. }
  12441. }
  12442. }
  12443. /// <summary>
  12444. /// 取得F_RPT_030112画面(产成品交接汇总表)的明细信息查询数据
  12445. /// </summary>
  12446. /// <param name="user">登录用户信息</param>
  12447. /// <param name="se">查询条件</param>
  12448. /// <returns>查询结果</returns>
  12449. public static ServiceResultEntity GetRPT0030112DetailSData(SUserInfo user, SearchFinishedProductEntity se)
  12450. {
  12451. IDBConnection conn = null;
  12452. try
  12453. {
  12454. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12455. List<OracleParameter> parameters = new List<OracleParameter>();
  12456. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT0030112DetailSData(user, se, ref parameters));
  12457. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  12458. ServiceResultEntity sre = new ServiceResultEntity();
  12459. if (data == null || data.Rows.Count == 0)
  12460. {
  12461. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12462. return sre;
  12463. }
  12464. sre.Data = new DataSet();
  12465. sre.Data.Tables.Add(data);
  12466. return sre;
  12467. }
  12468. catch (Exception ex)
  12469. {
  12470. throw ex;
  12471. }
  12472. finally
  12473. {
  12474. if (conn != null &&
  12475. conn.ConnState == ConnectionState.Open)
  12476. {
  12477. conn.Close();
  12478. }
  12479. }
  12480. }
  12481. private static string GetRPT0030112DetailSData(SUserInfo user, SearchFinishedProductEntity se, ref List<OracleParameter> parameters)
  12482. {
  12483. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12484. string sqlString = "SELECT O.ORDERNO,\n" +
  12485. " F.FHTIME,\n" +
  12486. " F.FHUSERCODE,\n" +
  12487. " F.BARCODE,\n" +
  12488. " F.GOODSCODE,\n" +
  12489. " L.LOGONAME,\n" +
  12490. " F.GROUTINGUSERCODE,\n" +
  12491. " F.GROUTINGLINECODE,\n" +
  12492. " F.GROUTINGMOULDCODE,\n" +
  12493. " F.GROUTINGDATE,\n" +
  12494. " G.DELIVERTIME,\n" +
  12495. " GOODS.goodsmodel,\n" +
  12496. //" (GOODS.MATERIALCODE || L.TAGCODE || G.ONLYCODE) AS FINISHEDBARCODE,\n" +
  12497. //" 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" +
  12498. " G.outlabelcode AS FINISHEDBARCODE,\n" +
  12499. " G.MATERIALCODE AS mcode,\n" +
  12500. " F.CREATETIME AS PRODUCTFINISHEDTIME\n" +
  12501. " FROM TP_PM_FINISHEDPRODUCT F\n" +
  12502. " LEFT JOIN TP_PM_ORDER O\n" +
  12503. " ON F.FHORDERID = O.ORDERID\n" +
  12504. " LEFT JOIN TP_MST_LOGO L\n" +
  12505. " ON F.LOGOID = L.LOGOID\n" +
  12506. " LEFT JOIN TP_PM_GROUTINGDAILYDETAIL G\n" +
  12507. " ON F.GROUTINGDAILYDETAILID = G.GROUTINGDAILYDETAILID\n" +
  12508. " LEFT JOIN TP_MST_GOODS GOODS\n" +
  12509. " ON F.GOODSID = GOODS.GOODSID\n" +
  12510. " LEFT JOIN TP_MST_GOODSTYPE GOODSTYPE\n" +
  12511. " ON GOODS.GOODSTYPEID = GOODSTYPE.GOODSTYPEID\n" +
  12512. " WHERE F.ACCOUNTID = :ACCOUNTID\n" +
  12513. " AND F.FHTIME IS NOT NULL";
  12514. // 交接时间起始
  12515. if (se.FHTimeStart.HasValue)
  12516. {
  12517. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart ";
  12518. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, se.FHTimeStart.Value, ParameterDirection.Input));
  12519. }
  12520. // 交接时间结束
  12521. if (se.FHTimeEnd.HasValue)
  12522. {
  12523. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd ";
  12524. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, se.FHTimeEnd.Value, ParameterDirection.Input));
  12525. }
  12526. // 订单号
  12527. if (!string.IsNullOrEmpty(se.OrderNo))
  12528. {
  12529. //sqlString = sqlString + " AND O.OrderNo=:OrderNo";
  12530. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0";
  12531. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, se.OrderNo, ParameterDirection.Input));
  12532. }
  12533. // 产品类别编码
  12534. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  12535. {
  12536. sqlString = sqlString + " AND instr(GoodsType.GoodsTypeCode,:GoodsTypeCode)=1";
  12537. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  12538. }
  12539. // 产品编码
  12540. if (!string.IsNullOrEmpty(se.GoodsCode))
  12541. {
  12542. sqlString = sqlString + " AND instr(Goods.GoodsCode,:GoodsCode)>0";
  12543. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  12544. }
  12545. // 产品型号
  12546. if (!string.IsNullOrEmpty(se.GoodsModel))
  12547. {
  12548. sqlString = sqlString + " AND instr(Goods.GoodsModel,:GoodsModel)>0";
  12549. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, se.GoodsModel, ParameterDirection.Input));
  12550. }
  12551. // 产品商标ID集
  12552. if (!string.IsNullOrEmpty(se.LogoIDS))
  12553. {
  12554. sqlString += " AND instr(','||:LogoIDS||',', ',' || L.logoid || ',') > 0";
  12555. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, se.LogoIDS, ParameterDirection.Input));
  12556. }
  12557. // 交接工号
  12558. if (!string.IsNullOrEmpty(se.FHUserCode))
  12559. {
  12560. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0";
  12561. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, se.FHUserCode, ParameterDirection.Input));
  12562. }
  12563. if (se.OrderID != null)
  12564. {
  12565. sqlString = sqlString + " AND F.fhorderid = :fhorderid";
  12566. parameters.Add(new OracleParameter(":fhorderid", OracleDbType.Int32, se.OrderID, ParameterDirection.Input));
  12567. }
  12568. if (se.GoodsID != null)
  12569. {
  12570. sqlString = sqlString + " AND F.GoodsID = :GoodsID";
  12571. parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  12572. }
  12573. if (se.LogoID != null)
  12574. {
  12575. sqlString = sqlString + " AND F.LogoID = :LogoID";
  12576. parameters.Add(new OracleParameter(":LogoID", OracleDbType.Int32, se.LogoID, ParameterDirection.Input));
  12577. }
  12578. return sqlString;
  12579. }
  12580. /// <summary>
  12581. /// 取得F_RPT_030112画面(产成品交接汇总表)的交接数量
  12582. /// </summary>
  12583. /// <param name="user">登录用户信息</param>
  12584. /// <param name="se">查询条件</param>
  12585. /// <returns>查询结果</returns>
  12586. public static ServiceResultEntity GetRPT0030112NData(ClientRequestEntity cre, SUserInfo user)
  12587. {
  12588. IDBConnection conn = null;
  12589. try
  12590. {
  12591. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12592. List<OracleParameter> parameters = new List<OracleParameter>();
  12593. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12594. //string sqlString = "SELECT trunc(f.fhtime) fhtime, g.goodscode, COUNT(*) goodscount\n" +
  12595. string sqlString = "SELECT nvl2(trunc(f.fhtime),\n" +
  12596. " nvl2(l.logoname,\n" +
  12597. " to_char(trunc(f.fhtime), 'yyyy-mm-dd'),\n" +
  12598. " to_char('合计[') || to_char(trunc(f.fhtime), 'yyyy-mm-dd') ||\n" +
  12599. " to_char(']')),\n" +
  12600. " '总计') fhtime\n" +
  12601. " ,nvl2(l.logoname,\n" +
  12602. " nvl2(g.goodscode,\n" +
  12603. " l.logoname,\n" +
  12604. " to_char('小计[' || l.logoname || ']')),\n" +
  12605. " '--') logoname\n" +
  12606. " ,nvl(g.goodscode, '--') goodscode" +
  12607. " ,nvl(g.goodsmodel, '--') goodsmodel" +
  12608. " ,nvl(gdd.materialcode, '--') mcode" +
  12609. " ,COUNT(*) goodscount" +
  12610. " FROM tp_pm_finishedproduct f\n" +
  12611. " inner JOIN tp_pm_groutingdailydetail gdd\n" +
  12612. " ON gdd.barcode = f.barcode\n" +
  12613. " LEFT JOIN tp_mst_logo l\n" +
  12614. " ON f.logoid = l.logoid\n" +
  12615. " LEFT JOIN TP_PM_Order O\n" +
  12616. " ON f.Fhorderid = O.Orderid\n" +
  12617. " LEFT JOIN tp_mst_goods G\n" +
  12618. " ON g.goodsid = f.goodsid\n" +
  12619. " LEFT JOIN TP_MST_GoodsType gt\n" +
  12620. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  12621. " WHERE f.fhtime IS NOT NULL\n" +
  12622. " AND f.AccountID = :AccountID\n";
  12623. // 交接时间起始
  12624. if (cre.Properties["FHTimeStart"] != null)
  12625. {
  12626. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
  12627. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, cre.Properties["FHTimeStart"], ParameterDirection.Input));
  12628. }
  12629. // 交接时间结束
  12630. if (cre.Properties["FHTimeEnd"] != null)
  12631. {
  12632. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd \n";
  12633. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, cre.Properties["FHTimeEnd"], ParameterDirection.Input));
  12634. }
  12635. // 订单号
  12636. if (!string.IsNullOrEmpty(cre.Properties["OrderNo"] as string))
  12637. {
  12638. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0 \n";
  12639. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, cre.Properties["OrderNo"], ParameterDirection.Input));
  12640. }
  12641. // 产品类别编码
  12642. if (!string.IsNullOrEmpty(cre.Properties["GoodsTypeCode"] as string))
  12643. {
  12644. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 \n";
  12645. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input));
  12646. }
  12647. // 产品编码
  12648. if (!string.IsNullOrEmpty(cre.Properties["GoodsCode"] as string))
  12649. {
  12650. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
  12651. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input));
  12652. }
  12653. // 产品型号
  12654. if (!string.IsNullOrEmpty(cre.Properties["GoodsModel"] as string))
  12655. {
  12656. sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0 \n";
  12657. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, cre.Properties["GoodsModel"], ParameterDirection.Input));
  12658. }
  12659. // 产品商标ID集
  12660. if (!string.IsNullOrEmpty(cre.Properties["LogoIDS"] as string))
  12661. {
  12662. sqlString += " AND instr(','||:LogoIDS||',', ',' || f.logoid || ',') > 0 \n";
  12663. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, cre.Properties["LogoIDS"], ParameterDirection.Input));
  12664. }
  12665. // 交接工号
  12666. if (!string.IsNullOrEmpty(cre.Properties["FHUserCode"] as string))
  12667. {
  12668. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0 \n";
  12669. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, cre.Properties["FHUserCode"], ParameterDirection.Input));
  12670. }
  12671. //sqlString += " group by trunc(f.fhtime), g.goodscode order by trunc(f.fhtime), g.goodscode";
  12672. sqlString += " GROUP BY GROUPING SETS((trunc(f.fhtime), l.logoname, g.goodscode,g.goodsmodel,gdd.materialcode),(trunc(f.fhtime), l.logoname),(trunc(f.fhtime)),())";
  12673. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  12674. ServiceResultEntity sre = new ServiceResultEntity();
  12675. if (data == null || data.Rows.Count == 0)
  12676. {
  12677. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12678. return sre;
  12679. }
  12680. sre.Data = new DataSet();
  12681. sre.Data.Tables.Add(data);
  12682. return sre;
  12683. }
  12684. catch (Exception ex)
  12685. {
  12686. throw ex;
  12687. }
  12688. finally
  12689. {
  12690. if (conn != null &&
  12691. conn.ConnState == ConnectionState.Open)
  12692. {
  12693. conn.Close();
  12694. }
  12695. }
  12696. }
  12697. /// <summary>
  12698. /// 取得F_RPT_030112画面(产成品交接汇总表)的型号数量
  12699. /// </summary>
  12700. /// <param name="user">登录用户信息</param>
  12701. /// <param name="se">查询条件</param>
  12702. /// <returns>查询结果</returns>
  12703. public static ServiceResultEntity GetRPT0030112GNData(ClientRequestEntity cre, SUserInfo user)
  12704. {
  12705. IDBConnection conn = null;
  12706. try
  12707. {
  12708. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12709. List<OracleParameter> parameters = new List<OracleParameter>();
  12710. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12711. //string sqlString = "SELECT trunc(f.fhtime) fhtime, g.goodscode, COUNT(*) goodscount\n" +
  12712. string sqlString = "SELECT --nvl2(trunc(f.fhtime),\n" +
  12713. //" nvl2(l.logoname,\n" +
  12714. //" to_char(trunc(f.fhtime), 'yyyy-mm-dd'),\n" +
  12715. //" to_char('合计[') || to_char(trunc(f.fhtime), 'yyyy-mm-dd') ||\n" +
  12716. //" to_char(']')),\n" +
  12717. //" '总计') fhtime\n" +
  12718. //" ,nvl2(l.logoname,\n" +
  12719. //" nvl2(g.goodscode,\n" +
  12720. //" l.logoname,\n" +
  12721. //" to_char('小计[' || l.logoname || ']')),\n" +
  12722. //" '--') logoname\n" +
  12723. " nvl(g.goodscode, '合计') goodscode" +
  12724. " ,nvl(g.goodsmodel, '--') goodsmodel" +
  12725. " ,nvl(gdd.materialcode, '--') mcode" +
  12726. " ,COUNT(*) goodscount" +
  12727. " FROM tp_pm_finishedproduct f\n" +
  12728. " inner JOIN tp_pm_groutingdailydetail gdd\n" +
  12729. " ON gdd.barcode = f.barcode\n" +
  12730. " LEFT JOIN tp_mst_logo l\n" +
  12731. " ON f.logoid = l.logoid\n" +
  12732. " LEFT JOIN TP_PM_Order O\n" +
  12733. " ON f.Fhorderid = O.Orderid\n" +
  12734. " LEFT JOIN tp_mst_goods G\n" +
  12735. " ON g.goodsid = f.goodsid\n" +
  12736. " LEFT JOIN TP_MST_GoodsType gt\n" +
  12737. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  12738. " WHERE f.fhtime IS NOT NULL\n" +
  12739. " AND f.AccountID = :AccountID\n";
  12740. // 交接时间起始
  12741. if (cre.Properties["FHTimeStart"] != null)
  12742. {
  12743. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
  12744. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, cre.Properties["FHTimeStart"], ParameterDirection.Input));
  12745. }
  12746. // 交接时间结束
  12747. if (cre.Properties["FHTimeEnd"] != null)
  12748. {
  12749. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd \n";
  12750. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, cre.Properties["FHTimeEnd"], ParameterDirection.Input));
  12751. }
  12752. // 订单号
  12753. if (!string.IsNullOrEmpty(cre.Properties["OrderNo"] as string))
  12754. {
  12755. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0 \n";
  12756. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, cre.Properties["OrderNo"], ParameterDirection.Input));
  12757. }
  12758. // 产品类别编码
  12759. if (!string.IsNullOrEmpty(cre.Properties["GoodsTypeCode"] as string))
  12760. {
  12761. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 \n";
  12762. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input));
  12763. }
  12764. // 产品编码
  12765. if (!string.IsNullOrEmpty(cre.Properties["GoodsCode"] as string))
  12766. {
  12767. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
  12768. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input));
  12769. }
  12770. // 产品型号
  12771. if (!string.IsNullOrEmpty(cre.Properties["GoodsModel"] as string))
  12772. {
  12773. sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0 \n";
  12774. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, cre.Properties["GoodsModel"], ParameterDirection.Input));
  12775. }
  12776. // 产品商标ID集
  12777. if (!string.IsNullOrEmpty(cre.Properties["LogoIDS"] as string))
  12778. {
  12779. sqlString += " AND instr(','||:LogoIDS||',', ',' || f.logoid || ',') > 0 \n";
  12780. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, cre.Properties["LogoIDS"], ParameterDirection.Input));
  12781. }
  12782. // 交接工号
  12783. if (!string.IsNullOrEmpty(cre.Properties["FHUserCode"] as string))
  12784. {
  12785. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0 \n";
  12786. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, cre.Properties["FHUserCode"], ParameterDirection.Input));
  12787. }
  12788. //sqlString += " group by trunc(f.fhtime), g.goodscode order by trunc(f.fhtime), g.goodscode";
  12789. sqlString += " GROUP BY GROUPING SETS((g.goodscode,g.goodsmodel,gdd.materialcode),())";
  12790. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  12791. ServiceResultEntity sre = new ServiceResultEntity();
  12792. if (data == null || data.Rows.Count == 0)
  12793. {
  12794. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12795. return sre;
  12796. }
  12797. sre.Data = new DataSet();
  12798. sre.Data.Tables.Add(data);
  12799. return sre;
  12800. }
  12801. catch (Exception ex)
  12802. {
  12803. throw ex;
  12804. }
  12805. finally
  12806. {
  12807. if (conn != null &&
  12808. conn.ConnState == ConnectionState.Open)
  12809. {
  12810. conn.Close();
  12811. }
  12812. }
  12813. }
  12814. /// <summary>
  12815. /// 取得PDA(产成品交接汇总表)的交接数量
  12816. /// </summary>
  12817. /// <param name="user">登录用户信息</param>
  12818. /// <param name="se">查询条件</param>
  12819. /// <returns>查询结果</returns>
  12820. public static ServiceResultEntity GetRPT0030112NPDAData(DateTime date, string goodscode, SUserInfo user)
  12821. {
  12822. IDBConnection conn = null;
  12823. try
  12824. {
  12825. DateTime dateStart = date;
  12826. DateTime dateEnd = dateStart.AddDays(1);
  12827. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12828. List<OracleParameter> parameters = new List<OracleParameter>();
  12829. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12830. string sqlString = "SELECT o.orderno, g.goodscode, COUNT(*) goodscount\n" +
  12831. " FROM tp_pm_finishedproduct f\n" +
  12832. " LEFT JOIN TP_PM_Order O\n" +
  12833. " ON f.Fhorderid = O.Orderid\n" +
  12834. " LEFT JOIN tp_mst_goods G\n" +
  12835. " ON g.goodsid = f.goodsid\n" +
  12836. " LEFT JOIN TP_MST_GoodsType gt\n" +
  12837. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  12838. " WHERE f.fhtime IS NOT NULL\n" +
  12839. " AND f.AccountID = :AccountID\n";
  12840. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
  12841. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, dateStart, ParameterDirection.Input));
  12842. sqlString = sqlString + " AND F.FHTime < :FHTimeEnd \n";
  12843. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, dateEnd, ParameterDirection.Input));
  12844. // 产品型号
  12845. if (!string.IsNullOrEmpty(goodscode))
  12846. {
  12847. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
  12848. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, goodscode, ParameterDirection.Input));
  12849. }
  12850. sqlString += " group by orderno, g.goodscode order by orderno, g.goodscode";
  12851. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  12852. ServiceResultEntity sre = new ServiceResultEntity();
  12853. if (data == null || data.Rows.Count == 0)
  12854. {
  12855. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12856. return sre;
  12857. }
  12858. sre.Data = new DataSet();
  12859. sre.Data.Tables.Add(data);
  12860. return sre;
  12861. }
  12862. catch (Exception ex)
  12863. {
  12864. throw ex;
  12865. }
  12866. finally
  12867. {
  12868. if (conn != null &&
  12869. conn.ConnState == ConnectionState.Open)
  12870. {
  12871. conn.Close();
  12872. }
  12873. }
  12874. }
  12875. /// <summary>
  12876. /// 获取在产品备份表
  12877. /// </summary>
  12878. /// <param name="cre"></param>
  12879. /// <param name="sUserInfo"></param>
  12880. /// <returns></returns>
  12881. public static ServiceResultEntity GetRPT010404Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  12882. {
  12883. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12884. try
  12885. {
  12886. ServiceResultEntity sre = new ServiceResultEntity();
  12887. string sqlString = "SELECT inpb.BackupMonth\n" +
  12888. " ,gdd.BarCode\n" +
  12889. //" ,inpb.GoodsID\n" +
  12890. " ,inpb.GoodsCode\n" +
  12891. " ,inpb.GoodsName\n" +
  12892. //" ,inpb.Userid\n" +
  12893. " ,worker.USERNAME AS UserName\n" +
  12894. " ,worker.USERCode AS UserCode\n" +
  12895. //" ,inpb.ProductionLineID\n" +
  12896. " ,inpb.ProductionLineCode\n" +
  12897. " ,inpb.ProductionLineName\n" +
  12898. //" ,inpb.ModelType\n" +
  12899. " ,decode(inpb.inscrapflag, '1', '待审核的报废品', '正常') AS inscrapflag\n" +
  12900. " ,inpb.IsPublicBody\n" +
  12901. " ,decode(inpb.IsReFire,'6','1','0') IsReFire\n" +
  12902. " ,inpb.IsReworkFlag\n" +
  12903. " ,decode(inpb.CanManyTimes, '1', '能', '不能') AS CanManyTimes\n" +
  12904. " ,decode(inpb.ProcedureModel, '1', '计件模型', '检验模型') AS ProcedureModel\n" +
  12905. //" ,inpb.GroutingDailyID\n" +
  12906. //" ,inpb.GroutingDailyDetailID\n" +
  12907. " ,inpb.GroutingDate\n" +
  12908. //" ,inpb.GroutingLineID\n" +
  12909. " ,inpb.GroutingLineCode\n" +
  12910. " ,inpb.GroutingLineName\n" +
  12911. //" ,inpb.ProcedureID CompleteProcedureID\n" +
  12912. " ,pro.ProcedureName AS CompleteProcedureName\n" +
  12913. //" ,inpb.GMouldTypeID\n" +
  12914. " ,gmt.GMOULDTYPENAME AS GMouldTypeName\n" +
  12915. //" ,inpb.GroutingLineDetailID\n" +
  12916. " ,inpb.GroutingMouldCode\n" +
  12917. " ,inpb.SPECIALREPAIRFLAG\n" +
  12918. " ,inpb.GROUTINGUSERCODE\n" +
  12919. " ,gdd.GROUTINGCOUNT\n" +
  12920. " ,gdd.delivertime\n" +
  12921. " ,inpb.proceduretime\n" +
  12922. " ,inpb.Remarks\n" +
  12923. //" ,inpb.GoodsLevelID\n" +
  12924. " ,mgl.GOODSLEVELNAME\n" +
  12925. //" ,inpb.GoodsLevelTypeID\n" +
  12926. " ,mglt.GOODSLEVELTYPENAME\n" +
  12927. " ,inpb.BackupTime\n" +
  12928. " ,REPLACE((logo.Logoname || '[' || logo.Logocode || ']'), '[]', '') AS LogoCodeName\n" +
  12929. //" ,(Goods.MaterialCode || logo.tagcode || gdd.onlycode) AS FinishedBarCode\n" +
  12930. " ,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" +
  12931. " FROM TP_PM_InProduction_BakByMonth inpb\n" +
  12932. " INNER JOIN TP_MST_User worker\n" +
  12933. " ON worker.UserID = inpb.Userid\n" +
  12934. " INNER JOIN TP_PC_Procedure pro\n" +
  12935. " ON pro.PROCEDUREID = inpb.ProcedureID\n" +
  12936. " INNER JOIN TP_MST_GMouldType gmt\n" +
  12937. " ON gmt.GMouldTypeID = inpb.GMouldTypeID\n" +
  12938. " INNER JOIN TP_SYS_ProcedureModelType pmt\n" +
  12939. " ON pmt.ProcedureModelTypeID = inpb.ModelType\n" +
  12940. //" INNER JOIN TP_PM_GroutingDaily gd\n" +
  12941. //" ON gd.GroutingDailyID = inpb.GroutingDailyID\n" +
  12942. " INNER JOIN TP_PM_GroutingDailyDetail gdd\n" +
  12943. " ON gdd.Groutingdailydetailid = inpb.GroutingDailyDetailID\n" +
  12944. //" INNER JOIN TP_PC_GroutingLineDetail gld\n" +
  12945. //" ON gld.Groutinglinedetailid = inpb.GroutingLineDetailID\n" +
  12946. " LEFT JOIN TP_MST_GoodsLevel mgl\n" +
  12947. " ON mgl.GoodsLevelID = inpb.GoodsLevelID\n" +
  12948. " LEFT JOIN TP_SYS_GoodsLevelType mglt\n" +
  12949. " ON mglt.GoodsLevelTypeID = inpb.GoodsLevelTypeID\n" +
  12950. " LEFT JOIN TP_MST_Logo logo\n" +
  12951. " ON inpb.logoid = logo.logoid\n" +
  12952. " LEFT JOIN TP_MST_Goods Goods\n" +
  12953. " ON inpb.GoodsID = Goods.GoodsID\n" +
  12954. " WHERE inpb.AccountID = :AccountID" +
  12955. " AND inpb.BackupMonth = :BackupMonth" +
  12956. " ORDER BY pro.displayno,inpb.proceduretime";
  12957. OracleParameter[] oracleParameter = new OracleParameter[]
  12958. {
  12959. new Oracle.ManagedDataAccess.Client.OracleParameter(":AccountID",sUserInfo.AccountID),
  12960. new Oracle.ManagedDataAccess.Client.OracleParameter(":BackupMonth",cre.Properties["BackupMonth"]),
  12961. };
  12962. oracleConn.Open();
  12963. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  12964. oracleConn.Close();
  12965. sre.Data = result;
  12966. return sre;
  12967. }
  12968. catch (Exception ex)
  12969. {
  12970. if (oracleConn.ConnState == ConnectionState.Open)
  12971. {
  12972. oracleConn.Close();
  12973. }
  12974. throw ex;
  12975. }
  12976. }
  12977. /// <summary>
  12978. /// 产成品单值明细表
  12979. /// </summary>
  12980. /// <param name="cre"></param>
  12981. /// <param name="sUserInfo"></param>
  12982. /// <returns></returns>
  12983. public static ServiceResultEntity GetRPT010405Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  12984. {
  12985. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12986. try
  12987. {
  12988. string sql =
  12989. "SELECT up.id, up.NAME\n" +
  12990. " FROM tp_mst_unitprice up\n" +
  12991. " WHERE up.accountid = :AccountID\n" +
  12992. " AND up.valueflag = '1'\n" +
  12993. " AND (:upname IS NULL OR instr(up.name, :upname) > 0)\n" +
  12994. " ORDER BY up.displayno";
  12995. OracleParameter[] opara = new OracleParameter[]
  12996. {
  12997. new Oracle.ManagedDataAccess.Client.OracleParameter(":AccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  12998. new Oracle.ManagedDataAccess.Client.OracleParameter(":upname", OracleDbType.NVarchar2,cre.Properties["UPName"], ParameterDirection.Input),
  12999. };
  13000. DataTable upTable = oracleConn.GetSqlResultToDt(sql, opara);
  13001. StringBuilder upNames = new StringBuilder();
  13002. StringBuilder upTotals = new StringBuilder();
  13003. StringBuilder upSUMs = new StringBuilder();
  13004. foreach (DataRow item in upTable.Rows)
  13005. {
  13006. upNames.AppendFormat(", u{0} AS \"{1}\"\n", item["ID"], item["Name"]);
  13007. upTotals.AppendFormat(",(u{0} * nvl(fpcount, 0)) AS \"总【{1}】\"\n", item["ID"], item["Name"]);
  13008. upSUMs.AppendFormat(",SUM(decode(up.upid, {0}, up.unitprice, 0)) u{0}\n", item["ID"]);
  13009. }
  13010. ServiceResultEntity sre = new ServiceResultEntity();
  13011. string sqlString = "SELECT gt2.goodstypename GoodsTypeName2\n" +
  13012. " ,g.goodscode\n" +
  13013. " ,g.materialcode\n" +
  13014. " ,lg.logoname\n" +
  13015. " ,nvl(fpcount, 0) fpcount\n" +
  13016. // " ,u1 AS \"单值1\"\n" +
  13017. //" ,u2 AS \"单值2\"\n" +
  13018. upNames +
  13019. //" ,(u1 * nvl(fpcount, 0)) AS \"总【1】\"\n" +
  13020. //" ,(u2 * nvl(fpcount, 0)) AS \"总【2】\"\n" +
  13021. upTotals +
  13022. " FROM (SELECT up.goodsid\n" +
  13023. " ,up.logoid\n" +
  13024. //" ,SUM(decode(up.upid, 1, up.unitprice, 0)) u1\n" +
  13025. //" ,SUM(decode(up.upid, 2, up.unitprice, 0)) u2\n" +
  13026. upSUMs +
  13027. " FROM TP_MST_UnitPriceGoods up\n" +
  13028. " WHERE up.accountid = :AccountID\n" +
  13029. " GROUP BY up.goodsid, up.logoid) upg\n" +
  13030. " LEFT JOIN (SELECT fp.goodsid, fp.logoid, COUNT(*) fpcount\n" +
  13031. " FROM tp_pm_finishedproduct fp\n" +
  13032. " WHERE fp.accountid = :AccountID\n" +
  13033. " AND fp.fhtime BETWEEN :DateBegin AND :DateEnd\n" +
  13034. " AND (:GoodsCode IS NULL OR\n" +
  13035. " instr(fp.goodscode, :GoodsCode) > 0)\n" +
  13036. " GROUP BY fp.goodsid, fp.logoid) fpp\n" +
  13037. " ON fpp.goodsid = upg.goodsid\n" +
  13038. " AND fpp.logoid = upg.logoid\n" +
  13039. " INNER JOIN tp_mst_logo lg\n" +
  13040. " ON lg.logoid = upg.logoid\n" +
  13041. " INNER JOIN tp_mst_goods g\n" +
  13042. " ON g.goodsid = upg.goodsid\n" +
  13043. " INNER JOIN tp_mst_goodstype gt\n" +
  13044. " ON gt.goodstypeid = g.goodstypeid\n" +
  13045. " INNER JOIN tp_mst_goodstype gt2\n" +
  13046. " ON gt2.accountid = :AccountID\n" +
  13047. " AND length(gt2.goodstypecode) = 6\n" +
  13048. " AND instr(gt.goodstypecode, gt2.goodstypecode) = 1\n" +
  13049. " WHERE (:GoodsTypeCode IS NULL OR\n" +
  13050. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  13051. " AND (:GoodsCode IS NULL OR instr(g.goodscode, :GoodsCode) > 0)\n" +
  13052. " AND (:logoname IS NULL OR instr(lg.logoname, :logoname) > 0)\n" +
  13053. " ORDER BY g.goodscode, lg.displayno";
  13054. OracleParameter[] oracleParameter = new OracleParameter[]
  13055. {
  13056. new Oracle.ManagedDataAccess.Client.OracleParameter(":AccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13057. new Oracle.ManagedDataAccess.Client.OracleParameter(":DateBegin", OracleDbType.Date,cre.Properties["DateBegin"], ParameterDirection.Input),
  13058. new Oracle.ManagedDataAccess.Client.OracleParameter(":DateEnd", OracleDbType.Date,cre.Properties["DateEnd"], ParameterDirection.Input),
  13059. new Oracle.ManagedDataAccess.Client.OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2,cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13060. new Oracle.ManagedDataAccess.Client.OracleParameter(":GoodsCode", OracleDbType.NVarchar2,cre.Properties["GoodsCode"], ParameterDirection.Input),
  13061. new Oracle.ManagedDataAccess.Client.OracleParameter(":logoname", OracleDbType.NVarchar2,cre.Properties["LogoName"], ParameterDirection.Input),
  13062. };
  13063. oracleConn.Open();
  13064. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13065. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13066. {
  13067. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13068. }
  13069. sre.Data = result;
  13070. oracleConn.Close();
  13071. return sre;
  13072. }
  13073. catch (Exception ex)
  13074. {
  13075. if (oracleConn.ConnState == ConnectionState.Open)
  13076. {
  13077. oracleConn.Close();
  13078. }
  13079. throw ex;
  13080. }
  13081. }
  13082. /// <summary>
  13083. /// 产成品单值明细表-单值名管理
  13084. /// </summary>
  13085. /// <param name="cre"></param>
  13086. /// <param name="sUserInfo"></param>
  13087. /// <returns></returns>
  13088. public static ServiceResultEntity GetRPT01040501Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13089. {
  13090. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13091. try
  13092. {
  13093. ServiceResultEntity sre = new ServiceResultEntity();
  13094. string sqlString = "SELECT t.id, t.name, t.displayno, t.valueflag\n" +
  13095. " FROM TP_MST_UnitPrice t\n" +
  13096. " WHERE t.accountid = :accountid\n" +
  13097. " ORDER BY t.id";
  13098. OracleParameter[] oracleParameter = new OracleParameter[]
  13099. {
  13100. new Oracle.ManagedDataAccess.Client.OracleParameter(":AccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13101. };
  13102. oracleConn.Open();
  13103. sre.Data = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13104. oracleConn.Close();
  13105. return sre;
  13106. }
  13107. catch (Exception ex)
  13108. {
  13109. if (oracleConn.ConnState == ConnectionState.Open)
  13110. {
  13111. oracleConn.Close();
  13112. }
  13113. throw ex;
  13114. }
  13115. }
  13116. /// <summary>
  13117. /// 产成品单值明细表-单值名管理
  13118. /// </summary>
  13119. /// <param name="cre"></param>
  13120. /// <param name="sUserInfo"></param>
  13121. /// <returns></returns>
  13122. public static ServiceResultEntity SetRPT01040501Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13123. {
  13124. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13125. try
  13126. {
  13127. ServiceResultEntity sre = new ServiceResultEntity();
  13128. // 检验参数的有效性
  13129. if (cre.Data == null && cre.Data.Tables.Count == 0 ||
  13130. cre.Data.Tables[0].Rows.Count < Constant.INT_IS_ZERO)
  13131. {
  13132. return sre;
  13133. }
  13134. oracleTrConn.Connect();
  13135. foreach (DataRow dataRow in cre.Data.Tables[0].Rows)
  13136. {
  13137. // 新建
  13138. if (dataRow.RowState == DataRowState.Added)
  13139. {
  13140. #region 新增
  13141. string sqlString = "INSERT INTO TP_MST_UNITPRICE\n" +
  13142. " (NAME, displayno, accountid, valueflag, createuserid, updateuserid)\n" +
  13143. "VALUES\n" +
  13144. " (:NAME, nvl(:DisplayNo,0), :AccountID, :ValueFlag, :UserID, :UserID)";
  13145. OracleParameter[] oracleParameter = new OracleParameter[]
  13146. {
  13147. new OracleParameter(":NAME", OracleDbType.NVarchar2, dataRow["Name"],ParameterDirection.Input),
  13148. new OracleParameter(":DisplayNo",OracleDbType.Int32, dataRow["DisplayNo"], ParameterDirection.Input),
  13149. new OracleParameter(":AccountID",OracleDbType.Int32,sUserInfo.AccountID, ParameterDirection.Input),
  13150. new OracleParameter(":ValueFlag",OracleDbType.NVarchar2, dataRow["ValueFlag"],ParameterDirection.Input),
  13151. new OracleParameter(":UserID",OracleDbType.Int32,sUserInfo.UserID, ParameterDirection.Input),
  13152. };
  13153. oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  13154. #endregion
  13155. }
  13156. else if (dataRow.RowState == DataRowState.Modified)
  13157. {
  13158. #region 更新
  13159. string sqlUpdateString = "UPDATE TP_MST_UNITPRICE SET "
  13160. + " Name = :Name,"
  13161. + " DisplayNo = :DisplayNo,"
  13162. + " ValueFlag = :ValueFlag,"
  13163. + " UpdateUserID = :UserID"
  13164. + " WHERE ID = :ID";
  13165. OracleParameter[] oracleParameter = new OracleParameter[]
  13166. {
  13167. new OracleParameter(":ID",OracleDbType.Int32,dataRow["ID"], ParameterDirection.Input),
  13168. new OracleParameter(":Name", OracleDbType.NVarchar2, dataRow["Name"],ParameterDirection.Input),
  13169. new OracleParameter(":DisplayNo",OracleDbType.Int32, dataRow["DisplayNo"], ParameterDirection.Input),
  13170. new OracleParameter(":ValueFlag",OracleDbType.NVarchar2, dataRow["ValueFlag"],ParameterDirection.Input),
  13171. new OracleParameter(":UserID",OracleDbType.Int32,sUserInfo.UserID, ParameterDirection.Input),
  13172. };
  13173. oracleTrConn.ExecuteNonQuery(sqlUpdateString, oracleParameter);
  13174. #endregion
  13175. }
  13176. else if (dataRow.RowState == DataRowState.Deleted)
  13177. {
  13178. #region 删除
  13179. string sqlDeleteString = "DELETE TP_MST_UNITPRICE WHERE ID = :ID";
  13180. OracleParameter[] oracleParameter = new OracleParameter[]
  13181. {
  13182. new OracleParameter(":ID",OracleDbType.Int32,dataRow["ID"], ParameterDirection.Input),
  13183. };
  13184. oracleTrConn.ExecuteNonQuery(sqlDeleteString, oracleParameter);
  13185. #endregion
  13186. }
  13187. }
  13188. oracleTrConn.Commit();
  13189. oracleTrConn.Disconnect();
  13190. return sre;
  13191. }
  13192. catch (Exception ex)
  13193. {
  13194. if (oracleTrConn.ConnState == ConnectionState.Open)
  13195. {
  13196. oracleTrConn.Rollback();
  13197. oracleTrConn.Disconnect();
  13198. }
  13199. throw ex;
  13200. }
  13201. finally
  13202. {
  13203. if (oracleTrConn.ConnState == ConnectionState.Open)
  13204. {
  13205. oracleTrConn.Disconnect();
  13206. }
  13207. }
  13208. }
  13209. /// <summary>
  13210. /// 获取模具跟踪表
  13211. /// </summary>
  13212. /// <param name="cre"></param>
  13213. /// <param name="sUserInfo"></param>
  13214. /// <returns></returns>
  13215. public static ServiceResultEntity GetRPT020105Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13216. {
  13217. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13218. try
  13219. {
  13220. ServiceResultEntity sre = new ServiceResultEntity();
  13221. OracleParameter[] oracleParameter = new OracleParameter[]
  13222. {
  13223. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13224. new OracleParameter("in_MouldBarcode",OracleDbType.Varchar2, cre.Properties["MouldBarcode"], ParameterDirection.Input),
  13225. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13226. new OracleParameter("out_Tracking",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13227. };
  13228. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_GetMouldTracking", oracleParameter);
  13229. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13230. {
  13231. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13232. }
  13233. sre.Data = result;
  13234. return sre;
  13235. }
  13236. catch (Exception ex)
  13237. {
  13238. if (oracleConn.ConnState == ConnectionState.Open)
  13239. {
  13240. oracleConn.Close();
  13241. }
  13242. throw ex;
  13243. }
  13244. }
  13245. /// <summary>
  13246. /// 获取模具收发存汇总表
  13247. /// </summary>
  13248. /// <param name="cre"></param>
  13249. /// <param name="sUserInfo"></param>
  13250. /// <returns></returns>
  13251. public static ServiceResultEntity GetRPT030113Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13252. {
  13253. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13254. try
  13255. {
  13256. ServiceResultEntity sre = new ServiceResultEntity();
  13257. OracleParameter[] oracleParameter = new OracleParameter[]
  13258. {
  13259. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13260. new OracleParameter("in_YYYYMM",OracleDbType.Varchar2, cre.Properties["YYYYMM"], ParameterDirection.Input),
  13261. new OracleParameter("in_DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13262. new OracleParameter("in_DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13263. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13264. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13265. new OracleParameter("in_GoodsIDs",OracleDbType.Varchar2, cre.Properties["GoodsIDs"], ParameterDirection.Input),
  13266. new OracleParameter("in_GoodsID",OracleDbType.Int32, cre.Properties["GoodsID"], ParameterDirection.Input),
  13267. new OracleParameter("in_Type",OracleDbType.Int32, cre.Properties["Type"], ParameterDirection.Input),
  13268. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13269. };
  13270. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_GetMould_SUM", oracleParameter);
  13271. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13272. {
  13273. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13274. }
  13275. sre.Data = result;
  13276. oracleConn.Commit();
  13277. return sre;
  13278. }
  13279. catch (Exception ex)
  13280. {
  13281. if (oracleConn.ConnState == ConnectionState.Open)
  13282. {
  13283. oracleConn.Disconnect();
  13284. }
  13285. throw ex;
  13286. }
  13287. }
  13288. /// <summary>
  13289. /// 获取废弃产品汇总表
  13290. /// </summary>
  13291. /// <param name="cre"></param>
  13292. /// <param name="sUserInfo"></param>
  13293. /// <returns></returns>
  13294. public static ServiceResultEntity GetRPT030114Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13295. {
  13296. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13297. try
  13298. {
  13299. ServiceResultEntity sre = new ServiceResultEntity();
  13300. OracleParameter[] oracleParameter = new OracleParameter[]
  13301. {
  13302. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13303. new OracleParameter("in_DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13304. new OracleParameter("in_DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13305. new OracleParameter("in_scrapTypes",OracleDbType.Varchar2, cre.Properties["ScrapTypes"], ParameterDirection.Input),
  13306. new OracleParameter("in_ProcedureIDs",OracleDbType.Varchar2, cre.Properties["ProcedureIDs"], ParameterDirection.Input),
  13307. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13308. //new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13309. new OracleParameter("in_GoodsIDs",OracleDbType.Varchar2, cre.Properties["GoodsIDs"], ParameterDirection.Input),
  13310. new OracleParameter("in_GoodsID",OracleDbType.Int32, cre.Properties["GoodsID"], ParameterDirection.Input),
  13311. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13312. };
  13313. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_scrap_sum", oracleParameter);
  13314. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13315. {
  13316. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13317. }
  13318. sre.Data = result;
  13319. oracleConn.Commit();
  13320. return sre;
  13321. }
  13322. catch (Exception ex)
  13323. {
  13324. if (oracleConn.ConnState == ConnectionState.Open)
  13325. {
  13326. oracleConn.Disconnect();
  13327. }
  13328. throw ex;
  13329. }
  13330. }
  13331. /// <summary>
  13332. /// 获取废品损失汇总表
  13333. /// </summary>
  13334. /// <param name="cre"></param>
  13335. /// <param name="sUserInfo"></param>
  13336. /// <returns></returns>
  13337. public static ServiceResultEntity GetRPT030115Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13338. {
  13339. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13340. try
  13341. {
  13342. ServiceResultEntity sre = new ServiceResultEntity();
  13343. OracleParameter[] oracleParameter = new OracleParameter[]
  13344. {
  13345. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13346. new OracleParameter("in_ptid",OracleDbType.Int32, cre.Properties["PTID"], ParameterDirection.Input),
  13347. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13348. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13349. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13350. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13351. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13352. };
  13353. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_TECDEP_SCRAP_SUM", oracleParameter);
  13354. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13355. {
  13356. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13357. }
  13358. sre.Data = result;
  13359. oracleConn.Commit();
  13360. return sre;
  13361. }
  13362. catch (Exception ex)
  13363. {
  13364. if (oracleConn.ConnState == ConnectionState.Open)
  13365. {
  13366. oracleConn.Disconnect();
  13367. }
  13368. throw ex;
  13369. }
  13370. }
  13371. /// <summary>
  13372. /// 获取废品损失汇总-明细表
  13373. /// </summary>
  13374. /// <param name="cre"></param>
  13375. /// <param name="sUserInfo"></param>
  13376. /// <returns></returns>
  13377. public static ServiceResultEntity GetRPT030115DData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13378. {
  13379. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13380. try
  13381. {
  13382. ServiceResultEntity sre = new ServiceResultEntity();
  13383. OracleParameter[] oracleParameter = new OracleParameter[]
  13384. {
  13385. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13386. new OracleParameter("in_ptid",OracleDbType.Int32, cre.Properties["PTID"], ParameterDirection.Input),
  13387. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13388. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13389. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13390. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13391. new OracleParameter("in_GoodsID",OracleDbType.Varchar2, cre.Properties["GoodsID"], ParameterDirection.Input),
  13392. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13393. };
  13394. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_TECDEP_SCRAP_SUMDETAIL", oracleParameter);
  13395. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13396. {
  13397. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13398. }
  13399. sre.Data = result;
  13400. oracleConn.Commit();
  13401. return sre;
  13402. }
  13403. catch (Exception ex)
  13404. {
  13405. if (oracleConn.ConnState == ConnectionState.Open)
  13406. {
  13407. oracleConn.Disconnect();
  13408. }
  13409. throw ex;
  13410. }
  13411. }
  13412. /// <summary>
  13413. /// 获取废品损失汇总表-半成品损失汇总表
  13414. /// </summary>
  13415. /// <param name="cre"></param>
  13416. /// <param name="sUserInfo"></param>
  13417. /// <returns></returns>
  13418. public static ServiceResultEntity GetRPT030115SData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13419. {
  13420. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13421. try
  13422. {
  13423. ServiceResultEntity sre = new ServiceResultEntity();
  13424. OracleParameter[] oracleParameter = new OracleParameter[]
  13425. {
  13426. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13427. new OracleParameter("in_ptid",OracleDbType.Int32, cre.Properties["PTID"], ParameterDirection.Input),
  13428. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13429. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13430. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13431. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13432. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13433. };
  13434. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_TECDEP_SCRAP_SUM_semi", oracleParameter);
  13435. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13436. {
  13437. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13438. }
  13439. StringBuilder cols = new StringBuilder();
  13440. StringBuilder sumCols = new StringBuilder();
  13441. foreach (DataRow item in result.Tables[0].Rows)
  13442. {
  13443. cols.AppendFormat(", d{0} AS \"{1}\"\n", item["id"], item["name"]);
  13444. sumCols.AppendFormat(", SUM(decode(td1.id, {0}, g.d, 0)) d{0}\n", item["id"]);
  13445. }
  13446. string sqlString = "SELECT gid\n" +
  13447. " ,decode(gid, 3, '合计', 1, '小计[' || gt2name || ']', gt2name) gt2name\n" +
  13448. " ,decode(gid, 0, td2name, '--') td2name\n" +
  13449. " ,gg.gc\n" +
  13450. " ,case when gg.gc is not null and gg.gc > 0 then round(tt.d / gg.gc,4) else null end gcc\n" +
  13451. " ,d\n" +
  13452. " ,c\n" +
  13453. " ,d-c g\n" +
  13454. cols +
  13455. " FROM (SELECT grouping_id(t.tecdepid, td2.id) gid\n" +
  13456. " ,nvl(t.tecdepid, -1) gt2id\n" +
  13457. " ,t.tecdepname gt2name\n" +
  13458. " ,td2.name td2name\n" +
  13459. " ,td2.displayno td2displayno\n" +
  13460. " ,SUM(g.d) d\n" +
  13461. " ,SUM(g.c) c\n" +
  13462. sumCols +
  13463. " FROM TMP_RPT_TECDEP_G g\n" +
  13464. " INNER JOIN TMP_RPT_TECDEP_T t\n" +
  13465. " ON g.goodsid = t.goodsid\n" +
  13466. " INNER JOIN tmp_rpt_tecdep_s s1\n" +
  13467. " ON s1.procedureid = g.pid\n" +
  13468. " INNER JOIN tp_mst_tecdep td1\n" +
  13469. " ON td1.id = s1.intecdepid\n" +
  13470. " LEFT JOIN tmp_rpt_tecdep_s s2\n" +
  13471. " ON s2.procedureid = g.f\n" +
  13472. " LEFT JOIN tp_mst_tecdep td2\n" +
  13473. " ON td2.id = s2.intecdepid\n" +
  13474. " WHERE td1.technologyflag = '1' -- 半成品工艺\n" +
  13475. " AND (td2.id IS NULL OR td2.technologyflag = '1')\n" +
  13476. " GROUP BY GROUPING SETS((t.tecdepid, t.tecdepname, td2.id, td2.name, td2.displayno),(t.tecdepid, t.tecdepname),())\n" +
  13477. " ORDER BY t.tecdepname, td2.displayno) tt\n" +
  13478. " LEFT JOIN (SELECT --grouping_id(gt2.goodstypeid) gid,\n" +
  13479. " nvl(t.tecdepid, -1) gt2id, COUNT(*) gc\n" +
  13480. " FROM tp_pm_groutingdailydetail gdd\n" +
  13481. " INNER JOIN TMP_RPT_TECDEP_T t\n" +
  13482. " ON gdd.goodsid = t.goodsid\n" +
  13483. " WHERE gdd.accountid = :in_accountid\n" +
  13484. " AND gdd.valueflag = '1'\n" +
  13485. " AND gdd.groutingflag = '1'\n" +
  13486. " AND gdd.groutingdate BETWEEN :in_datetimebegin AND\n" +
  13487. " :in_datetimeend\n" +
  13488. " GROUP BY GROUPING SETS((t.tecdepid),())) gg\n" +
  13489. " ON gg.gt2id = tt.gt2id\n" +
  13490. " ORDER BY tt.gt2name, tt.gid, tt.td2displayno";
  13491. oracleParameter = new OracleParameter[]
  13492. {
  13493. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13494. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13495. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13496. };
  13497. result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13498. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13499. {
  13500. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13501. }
  13502. sre.Data = result;
  13503. oracleConn.Commit();
  13504. return sre;
  13505. }
  13506. catch (Exception ex)
  13507. {
  13508. if (oracleConn.ConnState == ConnectionState.Open)
  13509. {
  13510. oracleConn.Disconnect();
  13511. }
  13512. throw ex;
  13513. }
  13514. }
  13515. /// <summary>
  13516. /// 获取成型存坯汇总表-注浆产品存坯汇总表
  13517. /// </summary>
  13518. /// <param name="cre"></param>
  13519. /// <param name="sUserInfo"></param>
  13520. /// <returns></returns>
  13521. public static ServiceResultEntity GetRPT030116GoodsData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13522. {
  13523. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13524. try
  13525. {
  13526. ServiceResultEntity sre = new ServiceResultEntity();
  13527. /*
  13528. string sqlString =
  13529. "SELECT gdrd.goodsid\n" +
  13530. " ,gdrd.goodscode\n" +
  13531. //" ,gdrd.groutinglineid\n" +
  13532. //" ,gdrd.groutinglinecode\n" +
  13533. //" ,gdrd.userid\n" +
  13534. //" ,gdrd.usercode\n" +
  13535. " ,gdrd.gddc rdcount -- 存坯数\n" +
  13536. " ,rdd.gldcount -- 模具数\n" +
  13537. " , CASE\n" +
  13538. " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
  13539. " round(gdrd.gddc / rdd.gldcount, 2)\n" +
  13540. " ELSE\n" +
  13541. " NULL\n" +
  13542. " END rddays -- 存坯天数\n" +
  13543. " ,gdrd.reserveddays -- 应存天数\n" +
  13544. " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
  13545. " FROM (SELECT gdd.goodsid\n" +
  13546. " ,gdd.goodscode\n" +
  13547. //" ,gdd.groutinglineid\n" +
  13548. //" ,gdd.groutinglinecode\n" +
  13549. //" ,gdd.userid\n" +
  13550. //" ,gdd.usercode\n" +
  13551. " ,g.reserveddays\n" +
  13552. " ,COUNT(*) gddc\n" +
  13553. " FROM tp_pm_groutingdailydetail gdd\n" +
  13554. " INNER JOIN tp_mst_goods g\n" +
  13555. " ON g.goodsid = gdd.goodsid\n" +
  13556. " INNER JOIN tp_mst_goodstype gt\n" +
  13557. " ON g.goodstypeid = gt.goodstypeid\n" +
  13558. " WHERE gdd.accountid = :accountid\n" +
  13559. " AND gdd.valueflag = '1'\n" +
  13560. " AND gdd.groutingflag = '1'\n" +
  13561. " AND gdd.barcode IS NOT NULL\n" +
  13562. " AND gdd.scrapflag = '0'\n" +
  13563. " AND gdd.deliverflag = '0'\n" +
  13564. " AND (:LineCode IS NULL OR\n" +
  13565. " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13566. " AND (:UserCode IS NULL OR instr(gdd.UserCode, :UserCode) > 0)\n" +
  13567. " AND (:GoodsCode IS NULL OR instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13568. " AND (:GoodsTypeCode IS NULL OR\n" +
  13569. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13570. " AND (:DateBegin IS NULL OR\n" +
  13571. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
  13572. " GROUP BY gdd.goodsid\n" +
  13573. " ,gdd.goodscode\n" +
  13574. //" ,gdd.groutinglineid\n" +
  13575. //" ,gdd.groutinglinecode\n" +
  13576. //" ,gdd.userid\n" +
  13577. //" ,gdd.usercode\n" +
  13578. " ,g.reserveddays) gdrd\n" +
  13579. " LEFT JOIN (SELECT gld.goodsid\n" +
  13580. //" ,gld.groutinglineid\n" +
  13581. " ,COUNT(*) gldcount\n" +
  13582. " FROM tp_pc_groutinglinedetail gld\n" +
  13583. " INNER JOIN tp_pc_groutingline gl\n" +
  13584. " ON gl.groutinglineid = gld.groutinglineid\n" +
  13585. " WHERE gld.valueflag = '1'\n" +
  13586. " AND gld.gmouldstatus = 1\n" +
  13587. " AND gl.accountid = :accountid\n" +
  13588. " AND gl.valueflag = '1'\n" +
  13589. " AND gl.gmouldstatus = 1\n" +
  13590. " GROUP BY gld.goodsid\n" +
  13591. //" ,gld.groutinglineid\n" +
  13592. " ) rdd\n" +
  13593. " ON rdd.goodsid = gdrd.goodsid\n" +
  13594. //" AND rdd.groutinglineid = gdrd.groutinglineid\n" +
  13595. " ORDER BY gdrd.goodscode\n" +
  13596. //" ,gdrd.groutinglinecode, gdrd.usercode"
  13597. "";
  13598. */
  13599. string sqlString =
  13600. "SELECT grouping_id(t.goodstypecode2, t.goodsid) gid\n" +
  13601. " ,t.goodstypecode2\n" +
  13602. " ,decode(grouping_id(t.goodstypecode2, t.goodsid),\n" +
  13603. " 3,\n" +
  13604. " '总计',\n" +
  13605. " 1,\n" +
  13606. " '合计[' || t.goodstypename2 || ']',\n" +
  13607. " t.goodstypename2) goodstypename2\n" +
  13608. " ,t.goodstypename\n" +
  13609. " ,t.goodsid\n" +
  13610. " ,t.goodscode\n" +
  13611. //" ,t.groutinglineid\n" +
  13612. //" ,t.groutinglinecode\n" +
  13613. //" ,t.userid\n" +
  13614. //" ,t.usercode\n" +
  13615. " ,SUM(t.rdcount) rdcount\n" +
  13616. " ,t.gldcount -- 模具数\n" +
  13617. " ,t.rddays -- 存坯天数\n" +
  13618. " ,t.reserveddays -- 应存天数\n" +
  13619. " ,SUM(t.ProfitNum) ProfitNum\n" +
  13620. " FROM (SELECT gt2.goodstypecode goodstypecode2\n" +
  13621. " ,gt2.goodstypename goodstypename2\n" +
  13622. " ,gdrd.goodsid\n" +
  13623. " ,gdrd.goodscode\n" +
  13624. " ,gdrd.goodstypename\n" +
  13625. //" ,gdrd.groutinglineid\n" +
  13626. //" ,gdrd.groutinglinecode\n" +
  13627. //" ,gdrd.userid\n" +
  13628. //" ,gdrd.usercode\n" +
  13629. " ,gdrd.gddc rdcount -- 存坯数\n" +
  13630. " ,rdd.gldcount -- 模具数\n" +
  13631. " , CASE\n" +
  13632. " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
  13633. " round(gdrd.gddc / rdd.gldcount, 2)\n" +
  13634. " ELSE\n" +
  13635. " NULL\n" +
  13636. " END rddays -- 存坯天数\n" +
  13637. " ,gdrd.reserveddays -- 应存天数\n" +
  13638. // 盈亏坯数 = 存坯数-应存天数*模具数 存坯天数 = 存坯数/模具数
  13639. " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
  13640. " FROM (SELECT gdd.goodsid\n" +
  13641. " ,gdd.goodscode\n" +
  13642. //" ,gdd.groutinglineid\n" +
  13643. //" ,gdd.groutinglinecode\n" +
  13644. //" ,gdd.userid\n" +
  13645. //" ,gdd.usercode\n" +
  13646. " ,g.reserveddays\n" +
  13647. " ,substr(gt.goodstypecode, 1, 6) goodstypecode2\n" +
  13648. " ,gt.goodstypename\n" +
  13649. " ,COUNT(*) gddc\n" +
  13650. " FROM tp_pm_groutingdailydetail gdd\n" +
  13651. " INNER JOIN tp_mst_goods g\n" +
  13652. " ON g.goodsid = gdd.goodsid\n" +
  13653. " INNER JOIN tp_mst_goodstype gt\n" +
  13654. " ON g.goodstypeid = gt.goodstypeid\n" +
  13655. " WHERE gdd.accountid = :accountid\n" +
  13656. " AND gdd.valueflag = '1'\n" +
  13657. " AND gdd.groutingflag = '1'\n" +
  13658. " AND gdd.barcode IS NOT NULL\n" +
  13659. " AND gdd.scrapflag = '0'\n" +
  13660. " AND gdd.deliverflag = '0'\n" +
  13661. " AND (:LineCode IS NULL OR\n" +
  13662. " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13663. " AND (:UserCode IS NULL OR\n" +
  13664. " instr(gdd.UserCode, :UserCode) > 0)\n" +
  13665. " AND (:GoodsCode IS NULL OR\n" +
  13666. " instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13667. " AND (:GoodsTypeCode IS NULL OR\n" +
  13668. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13669. " AND (:DateBegin IS NULL OR\n" +
  13670. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
  13671. " GROUP BY gt.goodstypecode,gt.goodstypename\n" +
  13672. " ,gdd.goodsid\n" +
  13673. " ,gdd.goodscode\n" +
  13674. //" ,gdd.groutinglineid\n" +
  13675. //" ,gdd.groutinglinecode\n" +
  13676. //" ,gdd.userid\n" +
  13677. //" ,gdd.usercode\n" +
  13678. " ,g.reserveddays) gdrd\n" +
  13679. " LEFT JOIN (SELECT gld.goodsid\n" +
  13680. //" ,gld.groutinglineid\n" +
  13681. " ,COUNT(*) gldcount\n" +
  13682. " FROM tp_pc_groutinglinedetail gld\n" +
  13683. " INNER JOIN tp_pc_groutingline gl\n" +
  13684. " ON gl.groutinglineid = gld.groutinglineid\n" +
  13685. " WHERE gld.valueflag = '1'\n" +
  13686. " AND gld.gmouldstatus = 1\n" +
  13687. " AND gl.accountid = :accountid\n" +
  13688. " AND gl.valueflag = '1'\n" +
  13689. " AND gl.gmouldstatus = 1\n" +
  13690. " GROUP BY gld.goodsid\n" +
  13691. //" , gld.groutinglineid" +
  13692. " ) rdd\n" +
  13693. " ON rdd.goodsid = gdrd.goodsid\n" +
  13694. //" AND rdd.groutinglineid = gdrd.groutinglineid\n" +
  13695. " INNER JOIN tp_mst_goodstype gt2\n" +
  13696. " ON gt2.accountid = :accountid\n" +
  13697. " AND gt2.goodstypecode = gdrd.goodstypecode2\n" +
  13698. " ORDER BY gt2.goodstypecode\n" +
  13699. " ,gdrd.goodscode\n" +
  13700. //" ,gdrd.groutinglinecode\n" +
  13701. //" ,gdrd.usercode" +
  13702. " ) t\n" +
  13703. " GROUP BY GROUPING SETS((t.goodstypecode2, t.goodstypename2,t.goodstypename, t.goodsid, t.goodscode, t.gldcount, t.rddays, t.reserveddays),(t.goodstypecode2, t.goodstypename2),())";
  13704. OracleParameter[] oracleParameter = new OracleParameter[]
  13705. {
  13706. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13707. new OracleParameter(":DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13708. new OracleParameter(":DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13709. new OracleParameter(":GoodsTypeCode",OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13710. new OracleParameter(":GoodsCode",OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13711. new OracleParameter(":LineCode",OracleDbType.NVarchar2, cre.Properties["LineCode"], ParameterDirection.Input),
  13712. new OracleParameter(":UserCode",OracleDbType.NVarchar2, cre.Properties["UserCode"], ParameterDirection.Input),
  13713. };
  13714. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13715. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13716. {
  13717. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13718. }
  13719. sre.Data = result;
  13720. return sre;
  13721. }
  13722. catch (Exception ex)
  13723. {
  13724. if (oracleConn.ConnState == ConnectionState.Open)
  13725. {
  13726. oracleConn.Close();
  13727. }
  13728. throw ex;
  13729. }
  13730. }
  13731. /// <summary>
  13732. /// 获取成型存坯汇总表-成型工号存坯汇总表
  13733. /// </summary>
  13734. /// <param name="cre"></param>
  13735. /// <param name="sUserInfo"></param>
  13736. /// <returns></returns>
  13737. public static ServiceResultEntity GetRPT030116UserData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13738. {
  13739. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13740. try
  13741. {
  13742. ServiceResultEntity sre = new ServiceResultEntity();
  13743. /*
  13744. string sqlString =
  13745. "SELECT gdrd.goodsid\n" +
  13746. " ,gdrd.goodscode\n" +
  13747. " ,gdrd.groutinglineid\n" +
  13748. " ,gdrd.groutinglinecode\n" +
  13749. " ,gdrd.userid\n" +
  13750. " ,gdrd.usercode\n" +
  13751. " ,gdrd.gddc rdcount -- 存坯数\n" +
  13752. " ,rdd.gldcount -- 模具数\n" +
  13753. " , CASE\n" +
  13754. " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
  13755. " round(gdrd.gddc / rdd.gldcount, 2)\n" +
  13756. " ELSE\n" +
  13757. " NULL\n" +
  13758. " END rddays -- 存坯天数\n" +
  13759. " ,gdrd.reserveddays -- 应存天数\n" +
  13760. " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
  13761. " FROM (SELECT gdd.goodsid\n" +
  13762. " ,gdd.goodscode\n" +
  13763. " ,gdd.groutinglineid\n" +
  13764. " ,gdd.groutinglinecode\n" +
  13765. " ,gdd.userid\n" +
  13766. " ,gdd.usercode\n" +
  13767. " ,g.reserveddays\n" +
  13768. " ,COUNT(*) gddc\n" +
  13769. " FROM tp_pm_groutingdailydetail gdd\n" +
  13770. " INNER JOIN tp_mst_goods g\n" +
  13771. " ON g.goodsid = gdd.goodsid\n" +
  13772. " INNER JOIN tp_mst_goodstype gt\n" +
  13773. " ON g.goodstypeid = gt.goodstypeid\n" +
  13774. " WHERE gdd.accountid = :accountid\n" +
  13775. " AND gdd.valueflag = '1'\n" +
  13776. " AND gdd.groutingflag = '1'\n" +
  13777. " AND gdd.barcode IS NOT NULL\n" +
  13778. " AND gdd.scrapflag = '0'\n" +
  13779. " AND gdd.deliverflag = '0'\n" +
  13780. " AND (:LineCode IS NULL OR\n" +
  13781. " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13782. " AND (:UserCode IS NULL OR instr(gdd.UserCode, :UserCode) > 0)\n" +
  13783. " AND (:GoodsCode IS NULL OR instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13784. " AND (:GoodsTypeCode IS NULL OR\n" +
  13785. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13786. " AND (:DateBegin IS NULL OR\n" +
  13787. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
  13788. " GROUP BY gdd.goodsid\n" +
  13789. " ,gdd.goodscode\n" +
  13790. " ,gdd.groutinglineid\n" +
  13791. " ,gdd.groutinglinecode\n" +
  13792. " ,gdd.userid\n" +
  13793. " ,gdd.usercode\n" +
  13794. " ,g.reserveddays) gdrd\n" +
  13795. " LEFT JOIN (SELECT gld.goodsid\n" +
  13796. " ,gld.groutinglineid\n" +
  13797. " ,COUNT(*) gldcount\n" +
  13798. " FROM tp_pc_groutinglinedetail gld\n" +
  13799. " INNER JOIN tp_pc_groutingline gl\n" +
  13800. " ON gl.groutinglineid = gld.groutinglineid\n" +
  13801. " WHERE gld.valueflag = '1'\n" +
  13802. " AND gld.gmouldstatus = 1\n" +
  13803. " AND gl.accountid = :accountid\n" +
  13804. " AND gl.valueflag = '1'\n" +
  13805. " AND gl.gmouldstatus = 1\n" +
  13806. " GROUP BY gld.goodsid\n" +
  13807. " ,gld.groutinglineid\n" +
  13808. " ) rdd\n" +
  13809. " ON rdd.goodsid = gdrd.goodsid\n" +
  13810. " AND rdd.groutinglineid = gdrd.groutinglineid\n" +
  13811. " ORDER BY gdrd.goodscode\n" +
  13812. " ,gdrd.groutinglinecode, gdrd.usercode" +
  13813. "";
  13814. */
  13815. string sqlString =
  13816. "SELECT grouping_id(t.goodstypecode2, t.goodsid) gid\n" +
  13817. " ,t.goodstypecode2\n" +
  13818. " ,decode(grouping_id(t.goodstypecode2, t.goodsid),\n" +
  13819. " 3,\n" +
  13820. " '总计',\n" +
  13821. " 1,\n" +
  13822. " '合计[' || t.goodstypename2 || ']',\n" +
  13823. " t.goodstypename2) goodstypename2\n" +
  13824. " ,t.goodsid\n" +
  13825. " ,t.goodscode\n" +
  13826. " ,t.groutinglineid\n" +
  13827. " ,t.groutinglinecode\n" +
  13828. " ,t.userid\n" +
  13829. " ,t.usercode\n" +
  13830. " ,t.MONITORName\n" +
  13831. " ,SUM(t.rdcount) rdcount\n" +
  13832. " ,t.gldcount -- 模具数\n" +
  13833. " ,t.rddays -- 存坯天数\n" +
  13834. " ,t.reserveddays -- 应存天数\n" +
  13835. " ,SUM(t.ProfitNum) ProfitNum\n" +
  13836. " FROM (SELECT gt2.goodstypecode goodstypecode2\n" +
  13837. " ,gt2.goodstypename goodstypename2\n" +
  13838. " ,gdrd.goodsid\n" +
  13839. " ,gdrd.goodscode\n" +
  13840. " ,gdrd.groutinglineid\n" +
  13841. " ,gdrd.groutinglinecode\n" +
  13842. " ,gdrd.userid\n" +
  13843. " ,gdrd.usercode\n" +
  13844. " ,mu.username MONITORName\n" +
  13845. " ,gdrd.gddc rdcount -- 存坯数\n" +
  13846. " ,rdd.gldcount -- 模具数\n" +
  13847. " , CASE\n" +
  13848. " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
  13849. " round(gdrd.gddc / rdd.gldcount, 2)\n" +
  13850. " ELSE\n" +
  13851. " NULL\n" +
  13852. " END rddays -- 存坯天数\n" +
  13853. " ,gdrd.reserveddays -- 应存天数\n" +
  13854. " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
  13855. " FROM (SELECT gdd.goodsid\n" +
  13856. " ,gdd.goodscode\n" +
  13857. " ,gdd.groutinglineid\n" +
  13858. " ,gdd.groutinglinecode\n" +
  13859. " ,gdd.userid\n" +
  13860. " ,gdd.usercode\n" +
  13861. " ,g.reserveddays\n" +
  13862. " ,substr(gt.goodstypecode, 1, 6) goodstypecode2\n" +
  13863. " ,COUNT(*) gddc\n" +
  13864. " FROM tp_pm_groutingdailydetail gdd\n" +
  13865. " INNER JOIN tp_mst_goods g\n" +
  13866. " ON g.goodsid = gdd.goodsid\n" +
  13867. " INNER JOIN tp_mst_goodstype gt\n" +
  13868. " ON g.goodstypeid = gt.goodstypeid\n" +
  13869. " WHERE gdd.accountid = :accountid\n" +
  13870. " AND gdd.valueflag = '1'\n" +
  13871. " AND gdd.groutingflag = '1'\n" +
  13872. " AND gdd.barcode IS NOT NULL\n" +
  13873. " AND gdd.scrapflag = '0'\n" +
  13874. " AND gdd.deliverflag = '0'\n" +
  13875. " AND (:LineCode IS NULL OR\n" +
  13876. " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13877. " AND (:UserCode IS NULL OR\n" +
  13878. " instr(gdd.UserCode, :UserCode) > 0)\n" +
  13879. " AND (:GoodsCode IS NULL OR\n" +
  13880. " instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13881. " AND (:GoodsTypeCode IS NULL OR\n" +
  13882. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13883. " AND (:DateBegin IS NULL OR\n" +
  13884. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
  13885. " GROUP BY gt.goodstypecode\n" +
  13886. " ,gdd.goodsid\n" +
  13887. " ,gdd.goodscode\n" +
  13888. " ,gdd.groutinglineid\n" +
  13889. " ,gdd.groutinglinecode\n" +
  13890. " ,gdd.userid\n" +
  13891. " ,gdd.usercode\n" +
  13892. " ,g.reserveddays) gdrd\n" +
  13893. " LEFT JOIN (SELECT gld.goodsid\n" +
  13894. " ,gld.groutinglineid\n" +
  13895. " ,gl.MONITORID\n" +
  13896. " ,COUNT(*) gldcount\n" +
  13897. " FROM tp_pc_groutinglinedetail gld\n" +
  13898. " INNER JOIN tp_pc_groutingline gl\n" +
  13899. " ON gl.groutinglineid = gld.groutinglineid\n" +
  13900. " WHERE gld.valueflag = '1'\n" +
  13901. " AND gld.gmouldstatus = 1\n" +
  13902. " AND gl.accountid = :accountid\n" +
  13903. " AND gl.valueflag = '1'\n" +
  13904. " AND gl.gmouldstatus = 1\n" +
  13905. " GROUP BY gld.goodsid, gld.groutinglineid,gl.MONITORID) rdd\n" +
  13906. " ON rdd.goodsid = gdrd.goodsid\n" +
  13907. " AND rdd.groutinglineid = gdrd.groutinglineid\n" +
  13908. // 成型班长
  13909. " LEFT JOIN tp_mst_user mu\n" +
  13910. " ON mu.userid = rdd.MONITORID\n" +
  13911. " INNER JOIN tp_mst_goodstype gt2\n" +
  13912. " ON gt2.accountid = :accountid\n" +
  13913. " AND gt2.goodstypecode = gdrd.goodstypecode2\n" +
  13914. " ORDER BY gt2.goodstypecode\n" +
  13915. " ,gdrd.goodscode\n" +
  13916. " ,gdrd.groutinglinecode\n" +
  13917. " ,gdrd.usercode) t\n" +
  13918. " 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),())";
  13919. OracleParameter[] oracleParameter = new OracleParameter[]
  13920. {
  13921. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13922. new OracleParameter(":DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13923. new OracleParameter(":DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13924. new OracleParameter(":GoodsTypeCode",OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13925. new OracleParameter(":GoodsCode",OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13926. new OracleParameter(":LineCode",OracleDbType.NVarchar2, cre.Properties["LineCode"], ParameterDirection.Input),
  13927. new OracleParameter(":UserCode",OracleDbType.NVarchar2, cre.Properties["UserCode"], ParameterDirection.Input),
  13928. };
  13929. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13930. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13931. {
  13932. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13933. }
  13934. sre.Data = result;
  13935. return sre;
  13936. }
  13937. catch (Exception ex)
  13938. {
  13939. if (oracleConn.ConnState == ConnectionState.Open)
  13940. {
  13941. oracleConn.Close();
  13942. }
  13943. throw ex;
  13944. }
  13945. }
  13946. /// <summary>
  13947. /// 获取成型存坯汇总表-成型存坯明细表
  13948. /// </summary>
  13949. /// <param name="cre"></param>
  13950. /// <param name="sUserInfo"></param>
  13951. /// <returns></returns>
  13952. public static ServiceResultEntity GetRPT030116DData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13953. {
  13954. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13955. try
  13956. {
  13957. ServiceResultEntity sre = new ServiceResultEntity();
  13958. string sqlString = "SELECT gdd.barcode\n" +
  13959. //" ,gdd.groutinglineid\n" +
  13960. " ,gdd.groutinglinecode\n" +
  13961. " ,gdd.GroutingMouldCode\n" +
  13962. //" ,gdd.goodsid\n" +
  13963. " ,gdd.goodscode\n" +
  13964. //" ,gdd.userid\n" +
  13965. " ,gdd.usercode\n" +
  13966. " ,gdd.groutingdate\n" +
  13967. // 成型班长
  13968. " ,mu.username as MONITORName" +
  13969. " FROM tp_pm_groutingdailydetail gdd\n" +
  13970. " INNER JOIN tp_mst_goods g\n" +
  13971. " ON g.goodsid = gdd.goodsid\n" +
  13972. // 成型线
  13973. " LEFT JOIN tp_pc_groutingline gl" +
  13974. " ON gl.groutinglineid = GDD.GroutingLineID" +
  13975. // 成型班长
  13976. " LEFT JOIN tp_mst_user mu" +
  13977. " ON mu.userid = gl.MONITORID " +
  13978. " INNER JOIN tp_mst_goodstype gt\n" +
  13979. " ON g.goodstypeid = gt.goodstypeid\n" +
  13980. " WHERE gdd.accountid = :accountid\n" +
  13981. " AND gdd.valueflag = '1'\n" +
  13982. " AND gdd.groutingflag = '1'\n" +
  13983. " AND gdd.barcode IS NOT NULL\n" +
  13984. " AND gdd.scrapflag = '0'\n" +
  13985. " AND gdd.deliverflag = '0'\n" +
  13986. " AND (:LineID IS NULL OR gdd.groutinglineid = :LineID)\n" +
  13987. " AND (:UserID IS NULL OR gdd.UserID = :UserID)\n" +
  13988. " AND (:GoodsID IS NULL OR gdd.goodsid = :GoodsID)\n" +
  13989. " AND (:LineCode IS NULL OR instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13990. " AND (:UserCode IS NULL OR instr(gdd.UserCode, :UserCode) > 0)\n" +
  13991. " AND (:GoodsCode IS NULL OR instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13992. " AND (:GoodsTypeCode IS NULL OR\n" +
  13993. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13994. " AND (:DateBegin IS NULL OR\n" +
  13995. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)" +
  13996. " ORDER BY gdd.barcode\n" +
  13997. //" ,gdd.goodscode, gdrd.groutinglinecode, gdrd.usercode" +
  13998. "";
  13999. OracleParameter[] oracleParameter = new OracleParameter[]
  14000. {
  14001. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14002. new OracleParameter(":DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  14003. new OracleParameter(":DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  14004. new OracleParameter(":GoodsTypeCode",OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  14005. new OracleParameter(":GoodsCode",OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  14006. new OracleParameter(":LineCode",OracleDbType.NVarchar2, cre.Properties["LineCode"], ParameterDirection.Input),
  14007. new OracleParameter(":UserCode",OracleDbType.NVarchar2, cre.Properties["UserCode"], ParameterDirection.Input),
  14008. new OracleParameter(":GoodsID",OracleDbType.Int32, cre.Properties["GoodsID"], ParameterDirection.Input),
  14009. new OracleParameter(":LineID",OracleDbType.Int32, cre.Properties["LineID"], ParameterDirection.Input),
  14010. new OracleParameter(":UserID",OracleDbType.Int32, cre.Properties["UserID"], ParameterDirection.Input),
  14011. };
  14012. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  14013. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14014. {
  14015. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14016. }
  14017. sre.Data = result;
  14018. return sre;
  14019. }
  14020. catch (Exception ex)
  14021. {
  14022. if (oracleConn.ConnState == ConnectionState.Open)
  14023. {
  14024. oracleConn.Close();
  14025. }
  14026. throw ex;
  14027. }
  14028. }
  14029. /// <summary>
  14030. /// 年度各工序月产量统计表
  14031. /// </summary>
  14032. /// <param name="cre"></param>
  14033. /// <param name="sUserInfo"></param>
  14034. /// <returns></returns>
  14035. public static ServiceResultEntity GetRPT030118Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14036. {
  14037. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14038. try
  14039. {
  14040. ServiceResultEntity sre = new ServiceResultEntity();
  14041. string sump = INIUtility.Read("ReportParameters", "RPT_030118", AppDomain.CurrentDomain.BaseDirectory + "Config.ini");
  14042. string sqlString = "select gt2.goodstypecode\n" +
  14043. " ,nvl2(gt2.goodstypename\n" +
  14044. " ,nvl2(t.procedureid\n" +
  14045. " ,gt2.goodstypename\n" +
  14046. " ,'小计[' || gt2.goodstypename || ']')\n" +
  14047. " ,'总计') goodstypename\n" +
  14048. " ,p.displayno\n" +
  14049. " ,decode(t.procedureid, null, '--', 0, '注浆', p.procedurename) procedurename\n" +
  14050. " ,sum(decode(t.mm, '12', t.pcount, 0)) m12\n" +
  14051. " ,sum(decode(t.mm, '01', t.pcount, 0)) m01\n" +
  14052. " ,sum(decode(t.mm, '02', t.pcount, 0)) m02\n" +
  14053. " ,sum(decode(t.mm, '03', t.pcount, 0)) m03\n" +
  14054. " ,sum(decode(t.mm, '04', t.pcount, 0)) m04\n" +
  14055. " ,sum(decode(t.mm, '05', t.pcount, 0)) m05\n" +
  14056. " ,sum(decode(t.mm, '06', t.pcount, 0)) m06\n" +
  14057. " ,sum(decode(t.mm, '07', t.pcount, 0)) m07\n" +
  14058. " ,sum(decode(t.mm, '08', t.pcount, 0)) m08\n" +
  14059. " ,sum(decode(t.mm, '09', t.pcount, 0)) m09\n" +
  14060. " ,sum(decode(t.mm, '10', t.pcount, 0)) m10\n" +
  14061. " ,sum(decode(t.mm, '11', t.pcount, 0)) m11\n" +
  14062. " ,sum(t.pcount) msum\n" +
  14063. " from (select --substr(gt.goodstypecode, 1, 6) gtcode2\n" +
  14064. " gt.goodstypecode\n" +
  14065. " ,0 procedureid\n" +
  14066. " ,to_char(pd.groutingdate, 'mm') mm\n" +
  14067. " ,count(*) pcount\n" +
  14068. " from tp_pm_groutingdailydetail pd\n" +
  14069. " inner join tp_mst_goods g\n" +
  14070. " on g.goodsid = pd.goodsid\n" +
  14071. " inner join tp_mst_goodstype gt\n" +
  14072. " on gt.goodstypeid = g.goodstypeid\n" +
  14073. " where pd.accountid = :accountid\n" +
  14074. " and pd.groutingflag = '1'\n" +
  14075. " and pd.groutingdate >= :begindate\n" +
  14076. " and pd.groutingdate < :enddate\n" +
  14077. " group by --substr(gt.goodstypecode, 1, 6)\n" +
  14078. " gt.goodstypecode\n" +
  14079. " ,to_char(pd.groutingdate, 'mm')\n" +
  14080. " union all\n" +
  14081. " select --substr(gt.goodstypecode, 1, 6) gtcode2\n" +
  14082. " gt.goodstypecode\n" +
  14083. " ,pd.procedureid\n" +
  14084. " ,to_char(pd.createtime, 'mm') mm\n" +
  14085. " ,count(*) pcount\n" +
  14086. " from tp_pm_productiondata pd\n" +
  14087. " inner join tp_mst_goods g\n" +
  14088. " on g.goodsid = pd.goodsid\n" +
  14089. " inner join tp_mst_goodstype gt\n" +
  14090. " on gt.goodstypeid = g.goodstypeid\n" +
  14091. " where pd.accountid = :accountid\n" +
  14092. " and pd.createtime >= :begindate\n" +
  14093. " and pd.createtime < :enddate\n" +
  14094. (string.IsNullOrWhiteSpace(sump) ? "" : " and pd.procedureid in (" + sump + ")\n") +
  14095. " group by --substr(gt.goodstypecode, 1, 6)\n" +
  14096. " gt.goodstypecode\n" +
  14097. " ,pd.procedureid\n" +
  14098. " ,to_char(pd.createtime, 'mm')" +
  14099. " union all\n" +
  14100. " select --substr(gt.goodstypecode, 1, 6) gtcode2\n" +
  14101. " gt.goodstypecode\n" +
  14102. " ,pd.procedureid\n" +
  14103. " ,to_char(pd.BACKOUTTIME, 'mm') mm\n" +
  14104. " ,count(*) pcount\n" +
  14105. " from tp_pm_productiondata pd\n" +
  14106. " inner join tp_mst_goods g\n" +
  14107. " on g.goodsid = pd.goodsid\n" +
  14108. " inner join tp_mst_goodstype gt\n" +
  14109. " on gt.goodstypeid = g.goodstypeid\n" +
  14110. " where pd.accountid = :accountid\n" +
  14111. " and pd.valueflag = '0'\n" +
  14112. " and pd.BACKOUTTIME >= :begindate\n" +
  14113. " and pd.BACKOUTTIME < :enddate\n" +
  14114. (string.IsNullOrWhiteSpace(sump) ? "" : " and pd.procedureid in (" + sump + ")\n") +
  14115. " group by --substr(gt.goodstypecode, 1, 6)\n" +
  14116. " gt.goodstypecode\n" +
  14117. " ,pd.procedureid\n" +
  14118. " ,to_char(pd.BACKOUTTIME, 'mm')) t\n" +
  14119. " inner join tp_mst_goodstype gt2\n" +
  14120. " on gt2.accountid = 1\n" +
  14121. " and gt2.goodstypecode = substr(t.goodstypecode, 1, 6) --t.gtcode2\n" +
  14122. " left join tp_pc_procedure p\n" +
  14123. " on p.procedureid = t.procedureid\n" +
  14124. " group by grouping sets((gt2.goodstypecode, gt2.goodstypename, p.displayno, p.procedurename, t.procedureid),(gt2.goodstypecode, gt2.goodstypename),())";
  14125. OracleParameter[] oracleParameter = new OracleParameter[]
  14126. {
  14127. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14128. new OracleParameter(":begindate",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  14129. new OracleParameter(":enddate",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  14130. };
  14131. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  14132. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14133. {
  14134. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14135. }
  14136. sre.Data = result;
  14137. return sre;
  14138. }
  14139. catch (Exception ex)
  14140. {
  14141. throw ex;
  14142. }
  14143. finally
  14144. {
  14145. oracleConn?.Close();
  14146. }
  14147. }
  14148. /// <summary>
  14149. /// 半检返修缺陷汇总表
  14150. /// </summary>
  14151. /// <param name="cre"></param>
  14152. /// <param name="sUserInfo"></param>
  14153. /// <returns></returns>
  14154. public static ServiceResultEntity GetRPT030119Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14155. {
  14156. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14157. try
  14158. {
  14159. ServiceResultEntity sre = new ServiceResultEntity();
  14160. string sqlString = "select dp.defectpositionid\n" +
  14161. " ,dp.defectpositioncode\n" +
  14162. " ,dp.defectpositionname\n" +
  14163. " ,'D_' || dp.defectpositionid colname\n" +
  14164. " from tp_mst_scdefectposition dp\n" +
  14165. " where dp.valueflag = '1'\n" +
  14166. " and dp.accountid = " + sUserInfo.AccountID + "\n";
  14167. if (!string.IsNullOrWhiteSpace(cre.Properties["defectpositionIDS"] + ""))
  14168. {
  14169. sqlString += " and instr(','||'"+ cre.Properties["defectpositionIDS"] + "'||',', ','||dp.defectpositionid||',') > 0 \n";
  14170. }
  14171. sqlString += " order by dp.displayno";
  14172. DataTable scdTable = oracleConn.GetSqlResultToDt(sqlString);
  14173. if (scdTable == null || scdTable.Rows.Count == 0)
  14174. {
  14175. return sre;
  14176. }
  14177. List<string> pivotFor = new List<string>();
  14178. foreach (DataRow item in scdTable.Rows)
  14179. {
  14180. pivotFor.Add($"{item["defectpositionid"]} as {item["colname"]}");
  14181. }
  14182. List<OracleParameter> oracleParameters = new List<OracleParameter>();
  14183. oracleParameters.Add(new OracleParameter(":accountid", sUserInfo.AccountID));
  14184. sqlString = "select *\n" +
  14185. " from (select srd.defectid\n" +
  14186. " ,scd.defectcode\n" +
  14187. " ,scd.defectname\n" +
  14188. " ,nvl(srd.defectpositionid, 0) defectpositionid\n" +
  14189. " ,count(srd.semireworkdefectid) cc\n" +
  14190. " from TP_PM_SEMIREWORKDEFECT srd\n" +
  14191. " inner join TP_PM_SEMIREWORK sr\n" +
  14192. " on sr.SEMIREWORKID = srd.SEMIREWORKID\n" +
  14193. " left join tp_mst_semicheckdefect scd\n" +
  14194. " on scd.defectid = srd.defectid\n" +
  14195. " left join tp_mst_scdefectposition scdp\n" +
  14196. " on scdp.defectpositionid = srd.defectpositionid\n" +
  14197. " left join TP_MST_GOODS g on g.GOODSID = sr.GOODSID\n" + //xuwei add 2019-11-29
  14198. " left join TP_MST_GOODSTYPE gt on g.GOODSTYPEID = gt.GOODSTYPEID\n" + //xuwei add 2019-11-29
  14199. " where srd.valueflag = '1'\n" +
  14200. " and sr.BACKOUTFLAG = '0'\n" +
  14201. " and sr.valueflag = '1'\n" +
  14202. " and sr.accountid = :accountid\n";
  14203. // 半检日期
  14204. if (cre.Properties["SemireWorkTimeBegin"] != null)
  14205. {
  14206. sqlString += " and sr.SEMIREWORKTIME >= :SemireWorkTimeBegin\n";
  14207. oracleParameters.Add(new OracleParameter(":SemireWorkTimeBegin", cre.Properties["SemireWorkTimeBegin"]));
  14208. }
  14209. if (cre.Properties["SemireWorkTimeEnd"] != null)
  14210. {
  14211. sqlString += " and sr.SEMIREWORKTIME < :SemireWorkTimeEnd\n";
  14212. oracleParameters.Add(new OracleParameter(":SemireWorkTimeEnd", cre.Properties["SemireWorkTimeEnd"]));
  14213. }
  14214. // 产品编码 GOODSCODE
  14215. if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSCODE"]+""))
  14216. {
  14217. sqlString += " and instr(','||:GOODSCODE||',' , ','||sr.GOODSCODE||',') > 0 \n";
  14218. oracleParameters.Add(new OracleParameter(":GOODSCODE", cre.Properties["GOODSCODE"]));
  14219. }
  14220. // 成型工号 GROUTINGUSERCODE
  14221. if (!string.IsNullOrWhiteSpace(cre.Properties["GROUTINGUSERCODE"] + ""))
  14222. {
  14223. //xuwei modify 2019-11-13
  14224. //sqlString += " and instr(sr.GROUTINGUSERCODE,:GROUTINGUSERCODE) > 0 \n";
  14225. sqlString += " and instr(','||:GROUTINGUSERCODE||',' , ','||sr.GROUTINGUSERCODE||',') > 0 \n";
  14226. //xuwei end
  14227. oracleParameters.Add(new OracleParameter(":GROUTINGUSERCODE", cre.Properties["GROUTINGUSERCODE"]));
  14228. }
  14229. // 半检工号 SEMIREWORKUSERCODE
  14230. if (!string.IsNullOrWhiteSpace(cre.Properties["SEMIREWORKUSERCODE"] + ""))
  14231. {
  14232. //xuwei modify 2019-11-13
  14233. //sqlString += " and instr(sr.SEMIREWORKUSERCODE,:SEMIREWORKUSERCODE) > 0 \n";
  14234. sqlString += " and instr(','||:SEMIREWORKUSERCODE||',' , ','||sr.SEMIREWORKUSERCODE||',') > 0 \n";
  14235. //xuwei end
  14236. oracleParameters.Add(new OracleParameter(":SEMIREWORKUSERCODE", cre.Properties["SEMIREWORKUSERCODE"]));
  14237. }
  14238. // 缺陷位置 scdp.defectpositionname
  14239. if (!string.IsNullOrWhiteSpace(cre.Properties["defectpositionname"] + ""))
  14240. {
  14241. sqlString += " and instr(scdp.defectpositionname,:defectpositionname) > 0 \n";
  14242. oracleParameters.Add(new OracleParameter(":defectpositionname", cre.Properties["defectpositionname"]));
  14243. }
  14244. if (!string.IsNullOrWhiteSpace(cre.Properties["defectpositionIDS"] + ""))
  14245. {
  14246. sqlString += " and instr(','||:defectpositionIDS||',', ','||srd.defectpositionid||',') > 0 \n";
  14247. oracleParameters.Add(new OracleParameter(":defectpositionIDS", cre.Properties["defectpositionIDS"]));
  14248. }
  14249. // 缺陷名称 scd.defectname
  14250. if (!string.IsNullOrWhiteSpace(cre.Properties["defectname"] + ""))
  14251. {
  14252. sqlString += " and instr(scd.defectname,:defectname) > 0 \n";
  14253. oracleParameters.Add(new OracleParameter(":defectname", cre.Properties["defectname"]));
  14254. }
  14255. // 缺陷编码 scd.defectcode
  14256. if (!string.IsNullOrWhiteSpace(cre.Properties["defectcode"] + ""))
  14257. {
  14258. sqlString += " and scd.defectcode = :defectcode \n";
  14259. oracleParameters.Add(new OracleParameter(":defectcode", cre.Properties["defectcode"]));
  14260. }
  14261. //产品类别ID xuwei add 2019-11-29 g.GOODSTYPEID
  14262. if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSTYPEID"] + ""))
  14263. {
  14264. sqlString += " and instr(','||:GOODSTYPEID||',' , ','||g.GOODSTYPEID||',') > 0 \n";
  14265. oracleParameters.Add(new OracleParameter(":GOODSTYPEID", cre.Properties["GOODSTYPEID"]));
  14266. }
  14267. //产品类别Code xuwei add 2019-11-29 g.GOODSTYPECODE
  14268. if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSTYPECODE"] + ""))
  14269. {
  14270. sqlString += " and instr(gt.GOODSTYPECODE , :GOODSTYPECODE) = 1 \n";
  14271. oracleParameters.Add(new OracleParameter(":GOODSTYPECODE", cre.Properties["GOODSTYPECODE"]));
  14272. }
  14273. //返修工序 xuwei add 2019-11-29 sr.REWORKPROCEDUREID
  14274. if (!string.IsNullOrWhiteSpace(cre.Properties["REWORKPROCEDUREID"] + ""))
  14275. {
  14276. sqlString += " and instr(','||:REWORKPROCEDUREID||',' , ','||sr.REWORKPROCEDUREID||',') > 0 \n";
  14277. oracleParameters.Add(new OracleParameter(":REWORKPROCEDUREID", cre.Properties["REWORKPROCEDUREID"]));
  14278. }
  14279. sqlString +=
  14280. " group by grouping sets((srd.defectid, scd.defectcode, scd.defectname, srd.defectpositionid),(srd.defectid, scd.defectcode, scd.defectname),(srd.defectpositionid),())) t\n" +
  14281. "pivot(sum(cc)\n" +
  14282. " for defectpositionid in("+string.Join(",", pivotFor) + ", 0 AS D_0))\n" +
  14283. " order by defectid";
  14284. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameters.ToArray());
  14285. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14286. {
  14287. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14288. return sre;
  14289. }
  14290. DataTable table = result.Tables[0];
  14291. DataRow dataRow = table.Rows[table.Rows.Count - 1];
  14292. dataRow["defectname"] = "合计";
  14293. foreach (DataRow item in scdTable.Rows)
  14294. {
  14295. string colname = item["colname"] + "";
  14296. if (table.Columns.Contains(colname))
  14297. {
  14298. if (dataRow[colname] == null || dataRow[colname] == DBNull.Value)
  14299. {
  14300. table.Columns.Remove(colname);
  14301. }
  14302. else
  14303. {
  14304. table.Columns[colname].Caption = item["defectpositionname"] + "";
  14305. }
  14306. }
  14307. }
  14308. table.Columns["D_0"].Caption = "合计";
  14309. sre.Data = result;
  14310. return sre;
  14311. }
  14312. catch (Exception ex)
  14313. {
  14314. throw ex;
  14315. }
  14316. finally
  14317. {
  14318. oracleConn?.Close();
  14319. }
  14320. }
  14321. /// <summary>
  14322. /// 模具注浆分析表
  14323. /// </summary>
  14324. /// <param name="cre"></param>
  14325. /// <param name="sUserInfo"></param>
  14326. /// <returns></returns>
  14327. public static ServiceResultEntity GetRPT040111Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14328. {
  14329. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  14330. try
  14331. {
  14332. ServiceResultEntity sre = new ServiceResultEntity();
  14333. OracleParameter[] oracleParameter = new OracleParameter[]
  14334. {
  14335. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14336. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["GroutingDateBegin"], ParameterDirection.Input),
  14337. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["GroutingDateEnd"], ParameterDirection.Input),
  14338. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  14339. new OracleParameter("in_MouldBarcode",OracleDbType.Varchar2, cre.Properties["MouldBarcode"], ParameterDirection.Input),
  14340. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  14341. };
  14342. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_Mould_Groutingnum_AN", oracleParameter);
  14343. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14344. {
  14345. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14346. }
  14347. sre.Data = result;
  14348. oracleConn.Commit();
  14349. return sre;
  14350. }
  14351. catch (Exception ex)
  14352. {
  14353. if (oracleConn.ConnState == ConnectionState.Open)
  14354. {
  14355. oracleConn.Disconnect();
  14356. }
  14357. throw ex;
  14358. }
  14359. }
  14360. /// <summary>
  14361. /// 成检产品预算分析表
  14362. /// </summary>
  14363. /// <param name="cre"></param>
  14364. /// <param name="sUserInfo"></param>
  14365. /// <returns></returns>
  14366. public static ServiceResultEntity GetRPT040112Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14367. {
  14368. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  14369. try
  14370. {
  14371. ServiceResultEntity sre = new ServiceResultEntity();
  14372. OracleParameter[] oracleParameter = new OracleParameter[]
  14373. {
  14374. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14375. new OracleParameter("in_InTimeBegin",OracleDbType.Date, cre.Properties["InTimeBegin"], ParameterDirection.Input),
  14376. new OracleParameter("in_InTimeEnd",OracleDbType.Date, cre.Properties["InTimeEnd"], ParameterDirection.Input),
  14377. new OracleParameter("in_OutTimeBegin",OracleDbType.Date, cre.Properties["OutTimeBegin"], ParameterDirection.Input),
  14378. new OracleParameter("in_OutTimeEnd",OracleDbType.Date, cre.Properties["OutTimeEnd"], ParameterDirection.Input),
  14379. new OracleParameter("in_KilnID",OracleDbType.Int32, cre.Properties["KilnID"], ParameterDirection.Input),
  14380. new OracleParameter("in_KilnCarNumBegin",OracleDbType.Int32, cre.Properties["KilnCarNumBegin"], ParameterDirection.Input),
  14381. new OracleParameter("in_KilnCarNumEnd",OracleDbType.Int32, cre.Properties["KilnCarNumEnd"], ParameterDirection.Input),
  14382. new OracleParameter("out_KilnInfo",OracleDbType.RefCursor, null, ParameterDirection.Output),
  14383. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  14384. };
  14385. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_ExpectFinishedProduct", oracleParameter);
  14386. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14387. {
  14388. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14389. }
  14390. sre.Data = result;
  14391. oracleConn.Commit();
  14392. return sre;
  14393. }
  14394. catch (Exception ex)
  14395. {
  14396. if (oracleConn.ConnState == ConnectionState.Open)
  14397. {
  14398. oracleConn.Disconnect();
  14399. }
  14400. throw ex;
  14401. }
  14402. }
  14403. /// <summary>
  14404. /// 成检产品预算分析表-设置
  14405. /// </summary>
  14406. /// <param name="cre"></param>
  14407. /// <param name="sUserInfo"></param>
  14408. /// <returns></returns>
  14409. public static ServiceResultEntity GetRPT04011201Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14410. {
  14411. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14412. try
  14413. {
  14414. ServiceResultEntity sre = new ServiceResultEntity();
  14415. string sqlString = "SELECT s.settingkey, s.procedureid, p.procedurecode, p.procedurename\n" +
  14416. " FROM tp_qco_prosetting s\n" +
  14417. " LEFT JOIN tp_pc_procedure p\n" +
  14418. " ON s.procedureid = p.procedureid\n" +
  14419. " WHERE s.accountid = :accountid";
  14420. OracleParameter[] oracleParameter = new OracleParameter[]
  14421. {
  14422. new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14423. };
  14424. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  14425. sqlString = "SELECT k.kilnid, k.kilncode, k.kilnname, k.turnoverinterval\n" +
  14426. " FROM tp_mst_kiln k\n" +
  14427. " WHERE k.accountid = :accountid\n" +
  14428. " AND k.valueflag = '1'";
  14429. DataTable dt = oracleConn.GetSqlResultToDt(sqlString, oracleParameter);
  14430. result.Tables.Add(dt);
  14431. sre.Data = result;
  14432. return sre;
  14433. }
  14434. catch (Exception ex)
  14435. {
  14436. if (oracleConn.ConnState == ConnectionState.Open)
  14437. {
  14438. oracleConn.Close();
  14439. }
  14440. throw ex;
  14441. }
  14442. }
  14443. /// <summary>
  14444. /// 成检产品预算分析表-设置
  14445. /// </summary>
  14446. /// <param name="cre"></param>
  14447. /// <param name="sUserInfo"></param>
  14448. /// <returns></returns>
  14449. public static ServiceResultEntity SetRPT04011201Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14450. {
  14451. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  14452. try
  14453. {
  14454. ServiceResultEntity sre = new ServiceResultEntity();
  14455. OracleParameter[] oracleParameter = null;
  14456. string sql = "update tp_qco_prosetting s set s.procedureid=:procedureid, s.procedurecode=:procedurecode\n" +
  14457. "where s.accountid=:accountid and s.settingkey=:settingkey";
  14458. foreach (DataRow item in cre.Data.Tables[0].Rows)
  14459. {
  14460. oracleParameter = new OracleParameter[]
  14461. {
  14462. new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14463. new OracleParameter("procedureid",OracleDbType.Int32, item["procedureid"], ParameterDirection.Input),
  14464. new OracleParameter("procedurecode",OracleDbType.NVarchar2, item["procedurecode"], ParameterDirection.Input),
  14465. new OracleParameter("settingkey",OracleDbType.NVarchar2, item["settingkey"], ParameterDirection.Input),
  14466. };
  14467. oracleConn.ExecuteNonQuery(sql, oracleParameter);
  14468. }
  14469. sql = "update tp_mst_kiln k set k.turnoverinterval=:turnoverinterval\n" +
  14470. "where k.accountid=:accountid and k.kilnid=:kilnid";
  14471. foreach (DataRow item in cre.Data.Tables[1].Rows)
  14472. {
  14473. oracleParameter = new OracleParameter[]
  14474. {
  14475. new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14476. new OracleParameter("turnoverinterval",OracleDbType.Int32, item["turnoverinterval"], ParameterDirection.Input),
  14477. new OracleParameter("kilnid",OracleDbType.Int32, item["kilnid"], ParameterDirection.Input),
  14478. };
  14479. oracleConn.ExecuteNonQuery(sql, oracleParameter);
  14480. }
  14481. oracleConn.Commit();
  14482. return sre;
  14483. }
  14484. catch (Exception ex)
  14485. {
  14486. if (oracleConn.ConnState == ConnectionState.Open)
  14487. {
  14488. oracleConn.Disconnect();
  14489. }
  14490. throw ex;
  14491. }
  14492. }
  14493. /// <summary>
  14494. /// 各工序质量表-恒洁三水
  14495. /// </summary>
  14496. /// <param name="cre"></param>
  14497. /// <param name="sUserInfo"></param>
  14498. /// <returns></returns>
  14499. public static ServiceResultEntity GetRPT040113Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14500. {
  14501. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14502. try
  14503. {
  14504. int p1ID = 11; // 成检交接工序
  14505. int p2ID = 12; // 成检登记工序
  14506. string gtcode2 = cre.Properties["gtcode2"] + "";
  14507. if (gtcode2 != "001001" && gtcode2 != "001002")
  14508. {
  14509. gtcode2 = "[ALL]";
  14510. }
  14511. // DEFECTDEDUCTIONNUM 缺陷扣除数 1,2,5
  14512. // goodsleveltypeid 次品 7
  14513. string sqlString = "select t.*\n" +
  14514. " ,gt.goodstypename\n" +
  14515. " ,nvl(outk.outkcount, 0) outkcount\n" +
  14516. " ,nvl(outk.outkcount, 0) - t.defectcount cc\n" +
  14517. " ,decode(nvl(outk.outkcount, 0)\n" +
  14518. " ,0\n" +
  14519. " ,to_number(null)\n" +
  14520. " ,round((nvl(outk.outkcount, 0) - t.defectcount) /\n" +
  14521. " nvl(outk.outkcount, 0)\n" +
  14522. " ,4)) ccp\n" +
  14523. " from (select 10 pcode\n" +
  14524. " ,'成型' pname\n" +
  14525. " ,gt2.goodstypecode gtcode2\n" +
  14526. " ,count(*) defectcount\n" +
  14527. " from tp_pm_defect dd\n" +
  14528. " inner join tp_pm_productiondata pd\n" +
  14529. " on dd.productiondataid = pd.productiondataid\n" +
  14530. " inner join tp_mst_goods g\n" +
  14531. " on dd.goodsid = g.goodsid\n" +
  14532. " inner join tp_mst_goodstype gt\n" +
  14533. " on gt.goodstypeid = g.goodstypeid\n" +
  14534. " inner join tp_mst_goodstype gt2\n" +
  14535. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14536. " where dd.valueflag = '1'\n" +
  14537. " and dd.accountid = :accountid\n" +
  14538. " and pd.goodsleveltypeid = 7\n" + // 次品
  14539. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14540. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14541. " and dd.procedureid = :p2ID\n" +
  14542. " and dd.checktime >= :timebegin\n" +
  14543. " and dd.checktime < :timeend\n" +
  14544. ////" -- 交坯、干补\n" +
  14545. //" and dd.defectprocedureid in (1, 17, 18)\n" +
  14546. " 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" +
  14547. " 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" +
  14548. " )\n" +
  14549. " group by gt2.goodstypecode\n" +
  14550. " union all\n" +
  14551. " select 20 pcode\n" +
  14552. " ,'改洗' pname\n" +
  14553. " ,gt2.goodstypecode gtcode2\n" +
  14554. " ,count(*) defectcount\n" +
  14555. " from tp_pm_defect dd\n" +
  14556. " inner join tp_pm_productiondata pd\n" +
  14557. " on dd.productiondataid = pd.productiondataid\n" +
  14558. " inner join tp_mst_goods g\n" +
  14559. " on dd.goodsid = g.goodsid\n" +
  14560. " inner join tp_mst_goodstype gt\n" +
  14561. " on gt.goodstypeid = g.goodstypeid\n" +
  14562. " inner join tp_mst_goodstype gt2\n" +
  14563. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14564. " where dd.valueflag = '1'\n" +
  14565. " and dd.accountid = :accountid\n" +
  14566. " and pd.goodsleveltypeid = 7\n" + // 次品
  14567. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14568. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14569. " and dd.procedureid = :p2ID\n" +
  14570. " and dd.checktime >= :timebegin\n" +
  14571. " and dd.checktime < :timeend\n" +
  14572. ////" -- 改洗、吹风\n" +
  14573. //" and dd.defectprocedureid in (2, 62)\n" +
  14574. ////" -- 除不平\n" +
  14575. //" and dd.defectid not in (91, 240)\n" +
  14576. " and ((gt2.goodstypecode='001001' and dd.defectid in (91,94,144,113,145,114,183))\n" +
  14577. " or (gt2.goodstypecode='001002' and dd.defectid in (91,93,94,144,113,145,114))\n" +
  14578. " )\n" +
  14579. " group by gt2.goodstypecode\n" +
  14580. " union all\n" +
  14581. " select 30 pcode\n" +
  14582. " ,'二检' pname\n" +
  14583. " ,gt2.goodstypecode gtcode2\n" +
  14584. " ,count(*) defectcount\n" +
  14585. " from tp_pm_defect dd\n" +
  14586. " inner join tp_pm_productiondata pd\n" +
  14587. " on dd.productiondataid = pd.productiondataid\n" +
  14588. " inner join tp_mst_goods g\n" +
  14589. " on dd.goodsid = g.goodsid\n" +
  14590. " inner join tp_mst_goodstype gt\n" +
  14591. " on gt.goodstypeid = g.goodstypeid\n" +
  14592. " inner join tp_mst_goodstype gt2\n" +
  14593. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14594. " where dd.valueflag = '1'\n" +
  14595. " and dd.accountid = :accountid\n" +
  14596. " and pd.goodsleveltypeid = 7\n" + // 次品
  14597. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14598. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14599. " and dd.procedureid = :p2ID\n" +
  14600. " and dd.checktime >= :timebegin\n" +
  14601. " and dd.checktime < :timeend\n" +
  14602. ////" -- 二检\n" +
  14603. //" and dd.defectprocedureid in (61)\n" +
  14604. " and ((gt2.goodstypecode='001001' and dd.defectid in (89,91,92,93,94,106,115,163,159,133,166,164))\n" +
  14605. " or (gt2.goodstypecode='001002' and dd.defectid in (89,91,92,93,94,106,115,163,133,192,166,164))\n" +
  14606. " )\n" +
  14607. " group by gt2.goodstypecode\n" +
  14608. " union all\n" +
  14609. " select 40 pcode\n" +
  14610. " ,'施釉' pname\n" +
  14611. " ,gt2.goodstypecode gtcode2\n" +
  14612. " ,count(*) defectcount\n" +
  14613. " from tp_pm_defect dd\n" +
  14614. " inner join tp_pm_productiondata pd\n" +
  14615. " on dd.productiondataid = pd.productiondataid\n" +
  14616. " inner join tp_mst_goods g\n" +
  14617. " on dd.goodsid = g.goodsid\n" +
  14618. " inner join tp_mst_goodstype gt\n" +
  14619. " on gt.goodstypeid = g.goodstypeid\n" +
  14620. " inner join tp_mst_goodstype gt2\n" +
  14621. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14622. " where dd.valueflag = '1'\n" +
  14623. " and dd.accountid = :accountid\n" +
  14624. " and pd.goodsleveltypeid = 7\n" + // 次品
  14625. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14626. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14627. " and dd.procedureid = :p2ID\n" +
  14628. " and dd.checktime >= :timebegin\n" +
  14629. " and dd.checktime < :timeend\n" +
  14630. ////" -- 施釉\n" +
  14631. //" and dd.defectprocedureid in (3, 4)\n" +
  14632. ////" -- 除铁、铜脏\n" +
  14633. //" and dd.defectid not in (827, 829, 398, 399, 830, 400)\n" +
  14634. " 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" +
  14635. " 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" +
  14636. " )\n" +
  14637. " group by gt2.goodstypecode\n" +
  14638. " union all\n" +
  14639. " select 50 pcode\n" +
  14640. " ,'刮登' pname\n" +
  14641. " ,gt2.goodstypecode gtcode2\n" +
  14642. " ,count(*) defectcount\n" +
  14643. " from tp_pm_defect dd\n" +
  14644. " inner join tp_pm_productiondata pd\n" +
  14645. " on dd.productiondataid = pd.productiondataid\n" +
  14646. " inner join tp_mst_goods g\n" +
  14647. " on dd.goodsid = g.goodsid\n" +
  14648. " inner join tp_mst_goodstype gt\n" +
  14649. " on gt.goodstypeid = g.goodstypeid\n" +
  14650. " inner join tp_mst_goodstype gt2\n" +
  14651. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14652. " where dd.valueflag = '1'\n" +
  14653. " and dd.accountid = :accountid\n" +
  14654. " and pd.goodsleveltypeid = 7\n" + // 次品
  14655. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14656. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14657. " and dd.procedureid = :p2ID\n" +
  14658. " and dd.checktime >= :timebegin\n" +
  14659. " and dd.checktime < :timeend\n" +
  14660. ////" -- 登窑、入窑、卸窑\n" +
  14661. //" and dd.defectprocedureid in (5, 9, 10)\n" +
  14662. " 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" +
  14663. " 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" +
  14664. " )\n" +
  14665. " group by gt2.goodstypecode\n" +
  14666. " union all\n" +
  14667. " select 60 pcode\n" +
  14668. " ,'烧成' pname\n" +
  14669. " ,gt2.goodstypecode gtcode2\n" +
  14670. " ,count(*) defectcount\n" +
  14671. " from tp_pm_defect dd\n" +
  14672. " inner join tp_pm_productiondata pd\n" +
  14673. " on dd.productiondataid = pd.productiondataid\n" +
  14674. " inner join tp_mst_goods g\n" +
  14675. " on dd.goodsid = g.goodsid\n" +
  14676. " inner join tp_mst_goodstype gt\n" +
  14677. " on gt.goodstypeid = g.goodstypeid\n" +
  14678. " inner join tp_mst_goodstype gt2\n" +
  14679. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14680. " where dd.valueflag = '1'\n" +
  14681. " and dd.accountid = :accountid\n" +
  14682. " and pd.goodsleveltypeid = 7\n" + // 次品
  14683. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14684. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14685. " and dd.procedureid = :p2ID\n" +
  14686. " and dd.checktime >= :timebegin\n" +
  14687. " and dd.checktime < :timeend\n" +
  14688. ////" -- 惊风、毛针孔、烧裂、窑脏、釉泡\n" +
  14689. //" and dd.defectid in (385\n" +
  14690. //" ,203\n" +
  14691. //" ,836\n" +
  14692. //" ,234\n" +
  14693. //" ,384\n" +
  14694. //" ,202\n" +
  14695. //" ,835\n" +
  14696. //" ,390\n" +
  14697. //" ,818\n" +
  14698. //" ,389\n" +
  14699. //" ,204\n" +
  14700. //" ,814\n" +
  14701. //" ,837\n" +
  14702. //" ,387)\n" +
  14703. " and dd.defectid in (234,385,386,387,388,389,390)\n" +
  14704. //" 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" +
  14705. //" 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" +
  14706. //" )\n" +
  14707. " group by gt2.goodstypecode\n" +
  14708. " union all\n" +
  14709. " select 70 pcode\n" +
  14710. " ,'杂锈点' pname\n" +
  14711. " ,gt2.goodstypecode gtcode2\n" +
  14712. " ,count(*) defectcount\n" +
  14713. " from tp_pm_defect dd\n" +
  14714. " inner join tp_pm_productiondata pd\n" +
  14715. " on dd.productiondataid = pd.productiondataid\n" +
  14716. " inner join tp_mst_goods g\n" +
  14717. " on dd.goodsid = g.goodsid\n" +
  14718. " inner join tp_mst_goodstype gt\n" +
  14719. " on gt.goodstypeid = g.goodstypeid\n" +
  14720. " inner join tp_mst_goodstype gt2\n" +
  14721. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14722. " where dd.valueflag = '1'\n" +
  14723. " and dd.accountid = :accountid\n" +
  14724. " and pd.goodsleveltypeid = 7\n" + // 次品
  14725. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14726. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14727. " and dd.procedureid = :p2ID\n" +
  14728. " and dd.checktime >= :timebegin\n" +
  14729. " and dd.checktime < :timeend\n" +
  14730. ////" -- 铁脏、铜脏、窑脏、釉脏\n" +
  14731. //" and dd.defectid in\n" +
  14732. //" (730, 818, 827, 829, 830, 389, 398, 399, 400, 170)\n" +
  14733. " and dd.defectid in (170,389,398,399)\n" +
  14734. //" 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" +
  14735. //" 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" +
  14736. //" )\n" +
  14737. " group by gt2.goodstypecode\n" +
  14738. " union all\n" +
  14739. " select 80 pcode\n" +
  14740. " ,'其他' pname\n" +
  14741. " ,gt2.goodstypecode gtcode2\n" +
  14742. " ,count(*) defectcount\n" +
  14743. " from tp_pm_defect dd\n" +
  14744. " inner join tp_pm_productiondata pd\n" +
  14745. " on dd.productiondataid = pd.productiondataid\n" +
  14746. " inner join tp_mst_goods g\n" +
  14747. " on dd.goodsid = g.goodsid\n" +
  14748. " inner join tp_mst_goodstype gt\n" +
  14749. " on gt.goodstypeid = g.goodstypeid\n" +
  14750. " inner join tp_mst_goodstype gt2\n" +
  14751. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14752. " where dd.valueflag = '1'\n" +
  14753. " and dd.accountid = :accountid\n" +
  14754. " and pd.goodsleveltypeid = 7\n" + // 次品
  14755. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14756. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14757. " and dd.procedureid = :p2ID\n" +
  14758. " and dd.checktime >= :timebegin\n" +
  14759. " and dd.checktime < :timeend\n" +
  14760. ////" -- 成检撞伤、炸坯、炸裂\n" +
  14761. //" and dd.defectid in (393, 180, 394, 395)\n" +
  14762. " and ((gt2.goodstypecode='001001' and dd.defectid in (402,393,395,396,397))\n" +
  14763. " or (gt2.goodstypecode='001002' and dd.defectid in (402,394,393,395,396,397))\n" +
  14764. " )\n" +
  14765. " group by gt2.goodstypecode) t\n" +
  14766. " left join (select gt2.goodstypecode gtcode2\n" +
  14767. " ,count(*) outkcount\n" +
  14768. " from tp_pm_productiondata pd\n" +
  14769. " inner join tp_mst_goods g\n" +
  14770. " on pd.goodsid = g.goodsid\n" +
  14771. " inner join tp_mst_goodstype gt\n" +
  14772. " on gt.goodstypeid = g.goodstypeid\n" +
  14773. " inner join tp_mst_goodstype gt2\n" +
  14774. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14775. " where pd.valueflag = '1'\n" +
  14776. " and pd.accountid = :accountid\n" +
  14777. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14778. " and pd.procedureid = :p1ID\n" +
  14779. " and pd.createtime >= :timebegin\n" +
  14780. " and pd.createtime < :timeend\n" +
  14781. " group by gt2.goodstypecode) outk\n" +
  14782. " on t.gtcode2 = outk.gtcode2\n" +
  14783. " inner join tp_mst_goodstype gt\n" +
  14784. " on gt.goodstypecode = t.gtcode2\n" +
  14785. " and gt.accountid = :accountid\n" +
  14786. " order by t.pcode, t.gtcode2";
  14787. OracleParameter[] oracleParameter = new OracleParameter[]
  14788. {
  14789. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14790. new OracleParameter(":p1ID",OracleDbType.Int32, p1ID, ParameterDirection.Input),
  14791. new OracleParameter(":p2ID",OracleDbType.Int32, p2ID, ParameterDirection.Input),
  14792. new OracleParameter(":timebegin",OracleDbType.Date, cre.Properties["timebegin"], ParameterDirection.Input),
  14793. new OracleParameter(":timeend",OracleDbType.Date, cre.Properties["timeend"], ParameterDirection.Input),
  14794. new OracleParameter(":gtcode2",OracleDbType.Varchar2, gtcode2, ParameterDirection.Input),
  14795. };
  14796. ServiceResultEntity sre = new ServiceResultEntity();
  14797. sre.Data = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  14798. if (sre.Data != null && sre.Data.Tables.Count > 0 && sre.Data.Tables[0].Rows.Count > 0)
  14799. {
  14800. sre.Data.Tables[0].TableName = "S";
  14801. cre.Properties["pcode"] = sre.Data.Tables[0].Rows[0]["pcode"];
  14802. cre.Properties["pname"] = sre.Data.Tables[0].Rows[0]["pname"];
  14803. cre.Properties["gtcode2"] = sre.Data.Tables[0].Rows[0]["gtcode2"];
  14804. ServiceResultEntity sre1 = GetRPT040113DData(cre, sUserInfo);
  14805. if (sre1 != null&& sre1.Data != null&& sre1.Data.Tables.Count > 0)
  14806. {
  14807. sre1.Data.Tables[0].TableName = "D";
  14808. sre.Data.Merge(sre1.Data.Tables[0]);
  14809. }
  14810. }
  14811. sqlString =
  14812. "select t.gtcode2\n" +
  14813. " ,nvl(t.gtname2, '合计') gtname2\n" +
  14814. " ,sum(t.outk) outk\n" +
  14815. " ,sum(t.cipin) cipin\n" +
  14816. " ,sum(t.outk) - sum(t.cipin) hege\n" +
  14817. " ,decode(sum(t.outk), 0, to_number(null), round(1 - (sum(t.cipin) / sum(t.outk)),4)) hegep\n" +
  14818. " from (select gt2.goodstypecode gtcode2\n" +
  14819. " ,gt2.goodstypename gtname2\n" +
  14820. " ,nvl(sum(decode(pd.procedureid, :p1ID, 1, 0)), 0) outk\n" +
  14821. " ,nvl(sum(case\n" +
  14822. " when pd.procedureid = :p2ID and\n" +
  14823. " pd.goodsleveltypeid in (6, 7) then\n" +
  14824. " 1\n" +
  14825. " else\n" +
  14826. " 0\n" +
  14827. " end)\n" +
  14828. " ,0) cipin\n" +
  14829. " from tp_pm_productiondata pd\n" +
  14830. " inner join tp_mst_goods g\n" +
  14831. " on pd.goodsid = g.goodsid\n" +
  14832. " inner join tp_mst_goodstype gt\n" +
  14833. " on g.goodstypeid = gt.goodstypeid\n" +
  14834. " inner join tp_mst_goodstype gt2\n" +
  14835. " on length(gt2.goodstypecode) = 6\n" +
  14836. " and gt2.accountid = gt.accountid\n" +
  14837. " and instr(gt.goodstypecode, gt2.goodstypecode) = 1\n" +
  14838. " where pd.valueflag = '1'\n" +
  14839. " and pd.accountid = :accountid\n" +
  14840. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14841. " and (pd.procedureid = :p1ID or pd.procedureid = :p2ID)\n" +
  14842. //" and pd.checktime > date '2018-01-01'\n" +
  14843. " and pd.checktime >= :timebegin\n" +
  14844. " and pd.checktime < :timeend\n" +
  14845. " group by gt2.goodstypecode, gt2.goodstypename) t\n" +
  14846. " group by grouping sets((t.gtcode2, t.gtname2),())";
  14847. oracleParameter = new OracleParameter[]
  14848. {
  14849. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14850. new OracleParameter(":p1ID",OracleDbType.Int32, p1ID, ParameterDirection.Input),
  14851. new OracleParameter(":p2ID",OracleDbType.Int32, p2ID, ParameterDirection.Input),
  14852. new OracleParameter(":timebegin",OracleDbType.Date, cre.Properties["timebegin"], ParameterDirection.Input),
  14853. new OracleParameter(":timeend",OracleDbType.Date, cre.Properties["timeend"], ParameterDirection.Input),
  14854. new OracleParameter(":gtcode2",OracleDbType.Varchar2, gtcode2, ParameterDirection.Input),
  14855. };
  14856. DataTable alldata = oracleConn.GetSqlResultToDt(sqlString, oracleParameter);
  14857. alldata.TableName = "A";
  14858. DataTable data = sre.Data.Tables[0];
  14859. foreach (DataRow item in alldata.Rows)
  14860. {
  14861. data.Rows.Add(99, "总计", item["gtcode2"], item["cipin"], item["gtname2"], item["outk"], item["hege"], item["hegep"]);
  14862. }
  14863. return sre;
  14864. }
  14865. catch (Exception ex)
  14866. {
  14867. if (oracleConn.ConnState == ConnectionState.Open)
  14868. {
  14869. oracleConn.Close();
  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 GetRPT040113DData(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. int pcode = Convert.ToInt32(cre.Properties["pcode"]);
  14888. string sqlString =
  14889. "select :pcode pcode\n" +
  14890. " ,:pname pname\n" +
  14891. " ,gt2.goodstypecode gtcode2\n" +
  14892. " ,gt2.goodstypename gtname2\n" +
  14893. " ,dd.defectcode\n" +
  14894. " ,dd.defectname\n" +
  14895. " ,count(*) defectcount\n" +
  14896. " from tp_pm_defect dd\n" +
  14897. //"--inner join tp_mst_defect md on md.defectid=dd.defectid\n" +
  14898. " inner join tp_mst_goods g\n" +
  14899. " on dd.goodsid = g.goodsid\n" +
  14900. " inner join tp_pm_productiondata pd\n" +
  14901. " on dd.productiondataid = pd.productiondataid\n" +
  14902. " inner join tp_mst_goodstype gt\n" +
  14903. " on gt.goodstypeid = g.goodstypeid\n" +
  14904. " inner join tp_mst_goodstype gt2\n" +
  14905. " on gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  14906. " and gt2.accountid = :accountid\n" +
  14907. " where dd.valueflag = '1'\n" +
  14908. " and dd.accountid = :accountid\n" +
  14909. " and pd.goodsleveltypeid = 7\n" + // 次品
  14910. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14911. " and dd.procedureid = :p2ID\n" +
  14912. " and gt2.goodstypecode = :gtcode2\n" +
  14913. " and dd.checktime >= :timebegin\n" +
  14914. " and dd.checktime < :timeend\n";
  14915. switch (pcode)
  14916. {
  14917. case 10:
  14918. ////" -- 交坯、干补\n" +
  14919. //sqlString += " and dd.defectprocedureid in (1, 17, 18)\n";
  14920. sqlString +=
  14921. " 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" +
  14922. " 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" +
  14923. " )\n";
  14924. break;
  14925. case 20:
  14926. sqlString +=
  14927. ////" -- 改洗、吹风\n" +
  14928. //" and dd.defectprocedureid in (2, 62)\n" +
  14929. ////" -- 除不平\n" +
  14930. //" and dd.defectid not in (91, 240)\n";
  14931. " and ((gt2.goodstypecode='001001' and dd.defectid in (91,94,144,113,145,114,183))\n" +
  14932. " or (gt2.goodstypecode='001002' and dd.defectid in (91,93,94,144,113,145,114))\n" +
  14933. " )\n";
  14934. break;
  14935. case 30:
  14936. sqlString +=
  14937. ////" -- 二检\n" +
  14938. //" and dd.defectprocedureid in (61)\n";
  14939. " and ((gt2.goodstypecode='001001' and dd.defectid in (89,91,92,93,94,106,115,163,159,133,166,164))\n" +
  14940. " or (gt2.goodstypecode='001002' and dd.defectid in (89,91,92,93,94,106,115,163,133,192,166,164))\n" +
  14941. " )\n";
  14942. break;
  14943. case 40:
  14944. sqlString +=
  14945. ////" -- 施釉\n" +
  14946. //" and dd.defectprocedureid in (3, 4)\n" +
  14947. ////" -- 除铁、铜脏\n" +
  14948. //" and dd.defectid not in (827, 829, 398, 399, 830, 400)\n";
  14949. " 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" +
  14950. " 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" +
  14951. " )\n";
  14952. break;
  14953. case 50:
  14954. sqlString +=
  14955. ////" -- 登窑、入窑、卸窑\n" +
  14956. //" and dd.defectprocedureid in (5, 9, 10)\n";
  14957. " 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" +
  14958. " 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" +
  14959. " )\n";
  14960. break;
  14961. case 60:
  14962. sqlString +=
  14963. ////" -- 惊风、毛针孔、烧裂、窑脏、釉泡\n" +
  14964. //" and dd.defectid in (385\n" +
  14965. //" ,203\n" +
  14966. //" ,836\n" +
  14967. //" ,234\n" +
  14968. //" ,384\n" +
  14969. //" ,202\n" +
  14970. //" ,835\n" +
  14971. //" ,390\n" +
  14972. //" ,818\n" +
  14973. //" ,389\n" +
  14974. //" ,204\n" +
  14975. //" ,814\n" +
  14976. //" ,837\n" +
  14977. //" ,387)\n";
  14978. " and dd.defectid in (234,385,386,387,388,389,390)\n";
  14979. break;
  14980. case 70:
  14981. sqlString +=
  14982. ////" -- 铁脏、铜脏、窑脏、釉脏\n" +
  14983. //" and dd.defectid in\n" +
  14984. //" (730, 818, 827, 829, 830, 389, 398, 399, 400, 170)\n";
  14985. " and dd.defectid in (170,389,398,399)\n";
  14986. break;
  14987. case 80:
  14988. sqlString +=
  14989. ////" -- 成检撞伤、炸坯、炸裂\n" +
  14990. //" and dd.defectid in (393, 180, 394, 395)\n";
  14991. " and ((gt2.goodstypecode='001001' and dd.defectid in (402,393,395,396,397))\n" +
  14992. " or (gt2.goodstypecode='001002' and dd.defectid in (402,394,393,395,396,397))\n" +
  14993. " )\n";
  14994. break;
  14995. default:
  14996. break;
  14997. }
  14998. sqlString +=
  14999. " group by gt2.goodstypecode\n" +
  15000. " ,gt2.goodstypename\n" +
  15001. " ,dd.defectcode\n" +
  15002. " ,dd.defectname\n" +
  15003. " order by dd.defectcode";
  15004. OracleParameter[] oracleParameter = new OracleParameter[]
  15005. {
  15006. new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  15007. //new OracleParameter("p1ID",OracleDbType.Int32, p1ID, ParameterDirection.Input),
  15008. new OracleParameter("p2ID",OracleDbType.Int32, p2ID, ParameterDirection.Input),
  15009. new OracleParameter("pcode",OracleDbType.Int32, pcode, ParameterDirection.Input),
  15010. new OracleParameter("pname",OracleDbType.NVarchar2, cre.Properties["pname"], ParameterDirection.Input),
  15011. new OracleParameter("gtcode2",OracleDbType.Varchar2, cre.Properties["gtcode2"], ParameterDirection.Input),
  15012. new OracleParameter("timebegin",OracleDbType.Date, cre.Properties["timebegin"], ParameterDirection.Input),
  15013. new OracleParameter("timeend",OracleDbType.Date, cre.Properties["timeend"], ParameterDirection.Input),
  15014. };
  15015. ServiceResultEntity sre = new ServiceResultEntity();
  15016. sre.Data = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  15017. return sre;
  15018. }
  15019. catch (Exception ex)
  15020. {
  15021. if (oracleConn.ConnState == ConnectionState.Open)
  15022. {
  15023. oracleConn.Close();
  15024. }
  15025. throw ex;
  15026. }
  15027. }
  15028. /// <summary>
  15029. /// 综合合格率分析表-半成品报废率分析表
  15030. /// </summary>
  15031. /// <param name="cre"></param>
  15032. /// <param name="sUserInfo"></param>
  15033. /// <returns></returns>
  15034. public static ServiceResultEntity GetRPT040114_1Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  15035. {
  15036. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  15037. try
  15038. {
  15039. ServiceResultEntity sre = new ServiceResultEntity();
  15040. List<OracleParameter> oracleParameters = new List<OracleParameter>();
  15041. oracleParameters.Add(new OracleParameter(":accountid", sUserInfo.AccountID));
  15042. string sqlString = "select g.goodscode\n" +
  15043. " ,tt.d_num\n" +
  15044. " ,tt.b_num\n" +
  15045. " ,tt.f_num\n" +
  15046. " ,tt.s_num\n" +
  15047. " ,decode(tt.d_num\n" +
  15048. " ,0\n" +
  15049. " ,to_number(null)\n" +
  15050. " ,round((tt.b_num + tt.f_num + tt.s_num) / tt.d_num,4)) sp_r\n" +
  15051. " from (select t.goodsid\n" +
  15052. " ,nvl(sum(decode(t.numtype, 'A', t.id_num, 0)), 0) d_num -- 交坯\n" +
  15053. " ,nvl(sum(decode(t.numtype, '2', t.id_num, 0)), 0) b_num -- 半检不合格数\n" +
  15054. " ,nvl(sum(decode(t.numtype, '3', t.id_num, 0)), 0) f_num -- 复检不合格数\n" +
  15055. " ,nvl(sum(decode(t.numtype, '0', t.id_num, 0)), 0) s_num -- 损坯数\n" +
  15056. " from (select gdd.goodsid\n" +
  15057. " ,'A' numtype\n" +
  15058. " ,count(gdd.groutingdailydetailid) id_num\n" +
  15059. " from tp_pm_groutingdailydetail gdd\n" +
  15060. " where gdd.groutingflag = '1'\n" +
  15061. " and gdd.valueflag = '1'\n" +
  15062. " and gdd.accountid = :accountid\n" +
  15063. " and gdd.deliverflag = '1'\n" +
  15064. " and gdd.delivertime >= :datebegin\n" +
  15065. " and gdd.delivertime < :dateend\n" +
  15066. " group by gdd.goodsid\n" +
  15067. " union all\n" +
  15068. " -- 半检不合格数 复检不合格数 损坯数\n" +
  15069. " select sp.goodsid\n" +
  15070. " ,sp.SCRAPTYPE numtype\n" +
  15071. " ,count(sp.scrapproductid) id_num\n" +
  15072. " from tp_pm_scrapproduct sp\n" +
  15073. " where sp.valueflag = '1'\n" +
  15074. " and sp.accountid = :accountid\n" +
  15075. " and sp.auditstatus = 1\n" +
  15076. " and sp.KILNID is null\n" +
  15077. " and sp.SCRAPTYPE <> '1'\n" +
  15078. " and sp.AUDITDATE >= :datebegin\n" +
  15079. " and sp.AUDITDATE < :dateend\n" +
  15080. " group by sp.goodsid, sp.SCRAPTYPE) t\n" +
  15081. " group by t.goodsid) tt\n" +
  15082. " inner join tp_mst_goods g\n" +
  15083. " on tt.goodsid = g.goodsid\n" +
  15084. " order by g.goodscode";
  15085. oracleParameters.Add(new OracleParameter(":datebegin", cre.Properties["datebegin"]));
  15086. oracleParameters.Add(new OracleParameter(":dateend", cre.Properties["dateend"]));
  15087. //// 产品编码 GOODSCODE
  15088. //if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSCODE"] + ""))
  15089. //{
  15090. // sqlString += " and instr(sr.GOODSCODE,:GOODSCODE) > 0 \n";
  15091. // oracleParameters.Add(new OracleParameter(":GOODSCODE", cre.Properties["GOODSCODE"]));
  15092. //}
  15093. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameters.ToArray());
  15094. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  15095. {
  15096. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  15097. return sre;
  15098. }
  15099. sre.Data = result;
  15100. return sre;
  15101. }
  15102. catch (Exception ex)
  15103. {
  15104. throw ex;
  15105. }
  15106. finally
  15107. {
  15108. oracleConn?.Close();
  15109. }
  15110. }
  15111. /// <summary>
  15112. /// 综合合格率分析表-综合优等率分析表
  15113. /// </summary>
  15114. /// <param name="cre"></param>
  15115. /// <param name="sUserInfo"></param>
  15116. /// <returns></returns>
  15117. public static ServiceResultEntity GetRPT040114_2Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  15118. {
  15119. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  15120. try
  15121. {
  15122. ServiceResultEntity sre = new ServiceResultEntity();
  15123. List<OracleParameter> oracleParameters = new List<OracleParameter>();
  15124. oracleParameters.Add(new OracleParameter(":accountid", sUserInfo.AccountID));
  15125. string sqlString = "\n" +
  15126. "select g.goodscode\n" +
  15127. " ,pp.b_out_num\n" +
  15128. " ,(pp.b_out_num - pp.b_bad_num) b_h_num\n" +
  15129. " ,(pp.c_out_num - pp.c_bad_num) c_h_num\n" +
  15130. " ,decode(pp.b_out_num\n" +
  15131. " ,0\n" +
  15132. " ,to_number(null)\n" +
  15133. " ,round((pp.b_out_num - pp.b_bad_num + pp.c_out_num - pp.c_bad_num) /\n" +
  15134. " pp.b_out_num,4)) zh_r\n" +
  15135. " from (select p.goodsid\n" +
  15136. " ,nvl(sum(decode(p.procedureid, 11, 1, 0)), 0) b_out_num -- 本烧出窑数\n" +
  15137. " ,nvl(sum(decode(p.procedureid, 12, 1, 0)), 0) b_bad_num -- 本烧不合格数\n" +
  15138. " ,nvl(sum(decode(p.procedureid, 58, 1, 0)), 0) c_out_num -- 重烧出窑数\n" +
  15139. " ,nvl(sum(decode(p.procedureid, 59, 1, 0)), 0) c_bad_num -- 重烧不合格数\n" +
  15140. " from tp_pm_productiondata p\n" +
  15141. " where p.valueflag = '1'\n" +
  15142. " and p.accountid = :accountid\n" +
  15143. " and (p.procedureid in (11, 58) or\n" +
  15144. " (p.procedureid in (12, 59) and p.goodsleveltypeid in (6, 7)))\n" +
  15145. " and p.createtime >= :datebegin\n" +
  15146. " and p.createtime < :dateend\n" +
  15147. " group by p.goodsid) pp\n" +
  15148. " inner join tp_mst_goods g\n" +
  15149. " on g.goodsid = pp.goodsid\n" +
  15150. " order by g.goodscode";
  15151. oracleParameters.Add(new OracleParameter(":datebegin", cre.Properties["datebegin"]));
  15152. oracleParameters.Add(new OracleParameter(":dateend", cre.Properties["dateend"]));
  15153. //// 产品编码 GOODSCODE
  15154. //if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSCODE"] + ""))
  15155. //{
  15156. // sqlString += " and instr(sr.GOODSCODE,:GOODSCODE) > 0 \n";
  15157. // oracleParameters.Add(new OracleParameter(":GOODSCODE", cre.Properties["GOODSCODE"]));
  15158. //}
  15159. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameters.ToArray());
  15160. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  15161. {
  15162. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  15163. return sre;
  15164. }
  15165. sre.Data = result;
  15166. return sre;
  15167. }
  15168. catch (Exception ex)
  15169. {
  15170. throw ex;
  15171. }
  15172. finally
  15173. {
  15174. oracleConn?.Close();
  15175. }
  15176. }
  15177. #region 产成品交接撤销汇总表
  15178. /// <summary>
  15179. /// 取得F_RPT_030117画面(产成品交接撤销汇总表)
  15180. /// </summary>
  15181. /// <param name="user">登录用户信息</param>
  15182. /// <param name="se">查询条件</param>
  15183. /// <returns>查询结果</returns>
  15184. public static ServiceResultEntity GetF_RPT_030117SearchTotalData(SearchFinishedProductEntity orderEntity, SUserInfo user)
  15185. {
  15186. IDBConnection conn = null;
  15187. try
  15188. {
  15189. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  15190. string sqlString = "SELECT TS.GID,\n" +
  15191. " DECODE(TS.GID, '3', '合计', DECODE(TS.GID, '1', '小计[' || CREATETIME || ']', CREATETIME)) AS CREATETIME,\n" +
  15192. " DECODE(TS.GID, '1', '--', GOODSMODEL) AS GOODSMODEL,\n" +
  15193. " GOODSCOUNT\n" +
  15194. " FROM (SELECT GROUPING_ID(TO_CHAR(F.CREATETIME, 'yyyy-mm-dd'), G.GOODSCODE) AS GID,\n" +
  15195. " DECODE(GROUPING(TO_CHAR(F.CREATETIME, 'yyyy-mm-dd')), 1, '--', TO_CHAR(F.CREATETIME, 'yyyy-mm-dd')) AS CREATETIME,\n" +
  15196. " DECODE(GROUPING(G.GOODSCODE), 1, '--', G.GOODSCODE) AS GOODSMODEL,\n" +
  15197. " COUNT(G.GOODSCODE) AS GOODSCOUNT\n" +
  15198. " FROM TP_PM_FHUNDO F\n" +
  15199. " LEFT JOIN TP_PM_GROUTINGDAILYDETAIL GDD\n" +
  15200. " ON F.GROUTINGDAILYDETAILID = GDD.GROUTINGDAILYDETAILID\n" +
  15201. " LEFT JOIN TP_MST_GOODS G\n" +
  15202. " ON G.GOODSID = GDD.GOODSID\n" +
  15203. " WHERE F.ACCOUNTID = :AccountID\n";
  15204. List<OracleParameter> parameters = new List<OracleParameter>();
  15205. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  15206. // 撤销时间
  15207. if (orderEntity.UndoTimeStart != null)
  15208. {
  15209. sqlString = sqlString + " AND F.CREATETIME BETWEEN :UndoTimeStart AND :UndoTimeEnd \n";
  15210. parameters.Add(new OracleParameter(":UndoTimeStart", OracleDbType.Date, orderEntity.UndoTimeStart, ParameterDirection.Input));
  15211. parameters.Add(new OracleParameter(":UndoTimeEnd", OracleDbType.Date, orderEntity.UndoTimeEnd, ParameterDirection.Input));
  15212. }
  15213. // 产品型号
  15214. if (!string.IsNullOrEmpty(orderEntity.GoodsModel))
  15215. {
  15216. sqlString = sqlString + " AND INSTR(g.GoodsCode,:GoodsCode)>0 \n";
  15217. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, orderEntity.GoodsModel, ParameterDirection.Input));
  15218. }
  15219. sqlString += " GROUP BY GROUPING SETS((TO_CHAR(F.CREATETIME, 'yyyy-mm-dd'), G.GOODSCODE),\n" +
  15220. " (TO_CHAR(F.CREATETIME, 'yyyy-mm-dd')),())\n" +
  15221. " ORDER BY TO_CHAR(F.CREATETIME, 'yyyy-mm-dd'), G.GOODSCODE) TS";
  15222. ServiceResultEntity sre = new ServiceResultEntity();
  15223. DataSet result = conn.GetSqlResultToDs(sqlString, parameters.ToArray());
  15224. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  15225. {
  15226. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  15227. }
  15228. sre.Data = result;
  15229. return sre;
  15230. }
  15231. catch (Exception ex)
  15232. {
  15233. throw ex;
  15234. }
  15235. finally
  15236. {
  15237. if (conn != null &&
  15238. conn.ConnState == ConnectionState.Open)
  15239. {
  15240. conn.Close();
  15241. }
  15242. }
  15243. }
  15244. /// <summary>
  15245. /// 取得F_RPT_030112画面(产成品交接汇总表)的明细信息查询数据
  15246. /// </summary>
  15247. /// <param name="user">登录用户信息</param>
  15248. /// <param name="se">查询条件</param>
  15249. /// <returns>查询结果</returns>
  15250. public static ServiceResultEntity GetF_RPT_030117SearchDetailSData(SearchFinishedProductEntity orderEntity, SUserInfo user)
  15251. {
  15252. IDBConnection conn = null;
  15253. try
  15254. {
  15255. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  15256. string sqlString = "SELECT O.ORDERNO,\n" +
  15257. " F.FHTIME,\n" +
  15258. " F.FHUSERCODE,\n" +
  15259. " GDD.BARCODE,\n" +
  15260. " GOODS.GOODSCODE,\n" +
  15261. " L.LOGONAME,\n" +
  15262. " GDD.USERCODE AS GROUTINGUSERCODE,\n" +
  15263. " GDD.GROUTINGLINECODE,\n" +
  15264. " GDD.GROUTINGMOULDCODE,\n" +
  15265. " GDD.GROUTINGDATE,\n" +
  15266. " TO_CHAR(GDD.DELIVERTIME, 'yyyy-mm-dd') AS DELIVERTIME,\n" +
  15267. //" (GOODS.MATERIALCODE || L.TAGCODE || GDD.ONLYCODE) AS FINISHEDBARCODE,\n" +
  15268. " 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" +
  15269. " TO_CHAR(F.CREATETIME, 'yyyy-mm-dd HH24:mi:ss') AS UNDOTIME,\n" +
  15270. " UNDOUSER.USERCODE AS UNDOUSERCODE\n" +
  15271. " FROM TP_PM_FHUNDO F\n" +
  15272. " LEFT JOIN TP_PM_GROUTINGDAILYDETAIL GDD\n" +
  15273. " ON F.GROUTINGDAILYDETAILID = GDD.GROUTINGDAILYDETAILID\n" +
  15274. " LEFT JOIN TP_PM_ORDER O\n" +
  15275. " ON F.FHORDERID = O.ORDERID\n" +
  15276. " LEFT JOIN TP_MST_LOGO L\n" +
  15277. " ON GDD.LOGOID = L.LOGOID\n" +
  15278. " LEFT JOIN TP_MST_GOODS GOODS\n" +
  15279. " ON GDD.GOODSID = GOODS.GOODSID\n" +
  15280. " LEFT JOIN TP_MST_USER UNDOUSER\n" +
  15281. " ON UNDOUSER.USERID = F.CREATEUSERID\n" +
  15282. " WHERE F.ACCOUNTID = :AccountID";
  15283. List<OracleParameter> parameters = new List<OracleParameter>();
  15284. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  15285. // 撤销时间
  15286. if (orderEntity.UndoTimeStart != null)
  15287. {
  15288. sqlString = sqlString + " AND F.CREATETIME BETWEEN :UndoTimeStart AND :UndoTimeEnd \n";
  15289. parameters.Add(new OracleParameter(":UndoTimeStart", OracleDbType.Date, orderEntity.UndoTimeStart, ParameterDirection.Input));
  15290. parameters.Add(new OracleParameter(":UndoTimeEnd", OracleDbType.Date, orderEntity.UndoTimeEnd, ParameterDirection.Input));
  15291. }
  15292. // 产品型号
  15293. if (!string.IsNullOrEmpty(orderEntity.GoodsModel))
  15294. {
  15295. sqlString = sqlString + " AND INSTR(GOODS.GoodsCode,:GoodsCode) > 0 \n";
  15296. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, orderEntity.GoodsModel, ParameterDirection.Input));
  15297. }
  15298. ServiceResultEntity sre = new ServiceResultEntity();
  15299. DataSet result = conn.GetSqlResultToDs(sqlString, parameters.ToArray());
  15300. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  15301. {
  15302. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  15303. }
  15304. sre.Data = result;
  15305. return sre;
  15306. }
  15307. catch (Exception ex)
  15308. {
  15309. throw ex;
  15310. }
  15311. finally
  15312. {
  15313. if (conn != null &&
  15314. conn.ConnState == ConnectionState.Open)
  15315. {
  15316. conn.Close();
  15317. }
  15318. }
  15319. }
  15320. #endregion
  15321. }
  15322. }