ReportModuleLogic.cs 781 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:ReportModuleLogic.cs
  5. * 2.功能描述:生产线报表分析
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 宋扬 2014/11/08 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Text;
  14. using Oracle.ManagedDataAccess.Client;
  15. using Dongke.IBOSS.PRD.Basics.BaseResources;
  16. using Dongke.IBOSS.PRD.Basics.DataAccess;
  17. using Dongke.IBOSS.PRD.Service.DataModels;
  18. using Dongke.IBOSS.PRD.WCF.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.DataModels.ReportModule;
  20. using Dongke.IBOSS.PRD.WCF.DataModels.PMModule;
  21. using Dongke.WinForm.Utilities;
  22. namespace Dongke.IBOSS.PRD.Service.ReportModuleLogic
  23. {
  24. /// <summary>
  25. /// 生产线报表分析
  26. /// </summary>
  27. public class ReportModuleLogic
  28. {
  29. #region 综合报表
  30. #region 跟踪统计表
  31. #region 生产管理
  32. /// <summary>
  33. /// 产品跟踪明细查询
  34. /// </summary>
  35. /// <param name="searchGoodsFollowingEntity">产品跟踪统计实体类</param>
  36. /// <param name="sUserInfo">用户基本信息</param>
  37. /// <returns>DataSet</returns>
  38. public static DataSet GetSearchGoodsFollowingDetailModule(SearchGoodsFollowingEntity searchGoodsFollowingEntity, SUserInfo sUserInfo)
  39. {
  40. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  41. try
  42. {
  43. con.Open();
  44. OracleParameter[] paras = new OracleParameter[]{
  45. new OracleParameter("in_accountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  46. new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  47. };
  48. DataSet dsSearchReport = con.ExecStoredProcedure("PRO_RPT_GetRPTDetailData", paras);
  49. return dsSearchReport;
  50. }
  51. catch (Exception ex)
  52. {
  53. throw ex;
  54. }
  55. finally
  56. {
  57. if (con.ConnState == ConnectionState.Open)
  58. {
  59. con.Close();
  60. }
  61. }
  62. }
  63. #endregion
  64. #endregion
  65. #endregion
  66. #region 统一使用ServiceResultEntity类模式
  67. #region 跟踪报表
  68. /// <summary>
  69. /// 取得RPT020101_1画面(产品跟踪)的查询数据
  70. /// </summary>
  71. /// <param name="user">登录用户信息</param>
  72. /// <param name="se">查询条件</param>
  73. /// <returns>查询结果</returns>
  74. public static ServiceResultEntity GetRPT020101SData(SUserInfo user, RPT020101_SE se)
  75. {
  76. IDBConnection conn = null;
  77. try
  78. {
  79. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  80. OracleParameter[] paras = new OracleParameter[]{
  81. new OracleParameter("in_barCode",OracleDbType.Varchar2,se.Barcode,ParameterDirection.Input),
  82. new OracleParameter("in_accountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  83. new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  84. new OracleParameter("out_result1",OracleDbType.RefCursor,ParameterDirection.Output),
  85. };
  86. //DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  87. DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetGoodsFollowingData", paras);
  88. ServiceResultEntity sre = new ServiceResultEntity();
  89. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  90. {
  91. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  92. return sre;
  93. }
  94. sre.Data = new DataSet();
  95. sre.Data = data;
  96. return sre;
  97. }
  98. catch (Exception ex)
  99. {
  100. throw ex;
  101. }
  102. finally
  103. {
  104. if (conn != null &&
  105. conn.ConnState == ConnectionState.Open)
  106. {
  107. conn.Close();
  108. }
  109. }
  110. }
  111. #endregion
  112. #region 明细报表
  113. /// <summary>
  114. /// 取得RPT010101_1画面(注浆明细表)的查询数据
  115. /// </summary>
  116. /// <param name="user">登录用户信息</param>
  117. /// <param name="se">查询条件</param>
  118. /// <returns>查询结果</returns>
  119. public static ServiceResultEntity GetRPT010101SData(SUserInfo user, RPT010101_SE se)
  120. {
  121. IDBConnection conn = null;
  122. try
  123. {
  124. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  125. List<OracleParameter> parameters = new List<OracleParameter>();
  126. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010101SSQL());
  127. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  128. if (se != null)
  129. {
  130. // 成型线类型ids
  131. if (!string.IsNullOrEmpty(se.GMouldTypeIDS))
  132. {
  133. sql.Append("AND instr(','||:GMouldTypeIDS||',',','||TP_MST_GMouldType.gMouldTypeId||',')>0 ");
  134. parameters.Add(new OracleParameter(":GMouldTypeIDS", OracleDbType.NVarchar2, se.GMouldTypeIDS, ParameterDirection.Input));
  135. }
  136. // 成型线IDS
  137. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  138. {
  139. sql.Append("AND instr(','||:GroutingLineIDS||',',','||gdd.GroutingLineId||',')>0 ");
  140. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  141. }
  142. // 产品IDS
  143. if (!string.IsNullOrEmpty(se.GoodsIDS))
  144. {
  145. sql.Append("AND instr(','||:GoodsIDS||',',','||gdd.GoodsId||',')>0 ");
  146. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  147. }
  148. // 产品类别IDS
  149. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  150. {
  151. // sql.Append("AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1 ");
  152. sql.Append("AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1 ");
  153. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  154. }
  155. // 模具号
  156. if (!string.IsNullOrEmpty(se.GroutingMouldCode))
  157. {
  158. sql.Append("AND instr(gdd.GroutingMouldCode,:GroutingMouldCode)>0 ");
  159. parameters.Add(new OracleParameter(":GroutingMouldCode", OracleDbType.NVarchar2, se.GroutingMouldCode, ParameterDirection.Input));
  160. }
  161. // 注浆时间-开始
  162. if (se.GroutingDateStart.HasValue)
  163. {
  164. sql.Append("AND gdd.GroutingDate >= :GroutingDateStart ");
  165. parameters.Add(new OracleParameter(":GroutingDateStart", OracleDbType.Date, se.GroutingDateStart.Value, ParameterDirection.Input));
  166. }
  167. // 模具类型IDS
  168. if (se.GroutingDateEnd.HasValue)
  169. {
  170. sql.Append("AND gdd.GroutingDate <= :GroutingDateEnd ");
  171. parameters.Add(new OracleParameter(":GroutingDateEnd", OracleDbType.Date, se.GroutingDateEnd.Value, ParameterDirection.Input));
  172. }
  173. if (se.GroutingBatchNo.HasValue)
  174. {
  175. //sql.Append(" AND TP_PM_GroutingDailyDetail.GroutingBatchNo = :GroutingBatchNo");
  176. sql.Append(" AND instr(gdd.GroutingBatchNo,:GroutingBatchNo)>0");
  177. parameters.Add(new OracleParameter(":GroutingBatchNo", OracleDbType.Int32, se.GroutingBatchNo, ParameterDirection.Input));
  178. }
  179. // 成型工号IDS
  180. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  181. {
  182. sql.Append("and instr(',' || :GroutingUserIDS || ',' ,','||gdd.UserID||',' )>0 ");
  183. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.Clob, se.GroutingUserIDS, ParameterDirection.Input));
  184. }
  185. // 未注浆原因
  186. if (!string.IsNullOrEmpty(se.NoGroutingRreason))
  187. {
  188. sql.Append("AND instr(b.dictionaryvalue,:NoGroutingRreason)>0 ");
  189. parameters.Add(new OracleParameter(":NoGroutingRreason", OracleDbType.NVarchar2, se.NoGroutingRreason, ParameterDirection.Input));
  190. }
  191. // 生产工号IDS
  192. if (!string.IsNullOrEmpty(se.CreateUserIDS))
  193. {
  194. sql.Append("and instr(',' || :CreateUserIDS || ',' ,','||gdd.CreateUserID||',' )>0 ");
  195. parameters.Add(new OracleParameter(":CreateUserIDS", OracleDbType.NVarchar2, se.CreateUserIDS, ParameterDirection.Input));
  196. }
  197. // 备注
  198. if (!string.IsNullOrEmpty(se.Remarks))
  199. {
  200. sql.Append(" AND INSTR(gdd.Remarks, :Remarks) > 0");
  201. parameters.Add(new OracleParameter(":Remarks", OracleDbType.NVarchar2, se.Remarks, ParameterDirection.Input));
  202. }
  203. // 注浆标识
  204. if (!string.IsNullOrEmpty(se.GroutingFlag))
  205. {
  206. sql.Append(" AND gdd.GroutingFlag = :GroutingFlag");
  207. parameters.Add(new OracleParameter(":GroutingFlag", OracleDbType.Char, se.GroutingFlag, ParameterDirection.Input));
  208. }
  209. // 损坯标识
  210. if (!string.IsNullOrEmpty(se.ScrapFlag))
  211. {
  212. sql.Append(" AND gdd.ScrapFlag = :ScrapFlag");
  213. parameters.Add(new OracleParameter(":ScrapFlag", OracleDbType.Char, se.ScrapFlag, ParameterDirection.Input));
  214. }
  215. // 绑定条码
  216. if (!string.IsNullOrEmpty(se.BarCodeFlag))
  217. {
  218. if ("1" == se.BarCodeFlag)
  219. {
  220. sql.Append(" AND LENGTH(gdd.BarCode) > 0");
  221. }
  222. else
  223. {
  224. sql.Append(" AND (gdd.BarCode IS NULL OR LENGTH(gdd.BarCode) = 0)");
  225. }
  226. }
  227. // 交坯日期-开始
  228. if (se.DeliverTimeBegin.HasValue)
  229. {
  230. sql.Append(" AND gdd.DeliverTime >= :DeliverTimeBegin");
  231. parameters.Add(new OracleParameter(":DeliverTimeBegin", OracleDbType.Date, se.DeliverTimeBegin.Value, ParameterDirection.Input));
  232. }
  233. // 交坯日期-结束
  234. if (se.DeliverTimeEnd.HasValue)
  235. {
  236. sql.Append(" AND gdd.DeliverTime <= :DeliverTimeEnd");
  237. parameters.Add(new OracleParameter(":DeliverTimeEnd", OracleDbType.Date, se.DeliverTimeEnd.Value, ParameterDirection.Input));
  238. }
  239. // 交坯标识
  240. if (!string.IsNullOrEmpty(se.DeliverFlag))
  241. {
  242. sql.Append(" AND gdd.DeliverFlag = :DeliverFlag");
  243. parameters.Add(new OracleParameter(":DeliverFlag", OracleDbType.Char, se.DeliverFlag, ParameterDirection.Input));
  244. }
  245. // 损坯日期-开始
  246. if (se.ScrapTimeBegin.HasValue)
  247. {
  248. sql.Append(" AND gdd.ScrapTime >= :ScrapTimeBegin");
  249. parameters.Add(new OracleParameter(":ScrapTimeBegin", OracleDbType.Date, se.ScrapTimeBegin.Value, ParameterDirection.Input));
  250. }
  251. // 损坯日期-结束
  252. if (se.ScrapTimeEnd.HasValue)
  253. {
  254. sql.Append(" AND gdd.ScrapTime <= :ScrapTimeEnd");
  255. parameters.Add(new OracleParameter(":ScrapTimeEnd", OracleDbType.Date, se.ScrapTimeEnd.Value, ParameterDirection.Input));
  256. }
  257. // 注浆操作时间-开始
  258. if (se.GCTimeBegin.HasValue)
  259. {
  260. sql.Append(" AND gdd.CreateTime >= :GCTimeBegin");
  261. parameters.Add(new OracleParameter(":GCTimeBegin", OracleDbType.Date, se.GCTimeBegin.Value, ParameterDirection.Input));
  262. }
  263. // 注浆操作时间-结束
  264. if (se.GCTimeEnd.HasValue)
  265. {
  266. sql.Append(" AND gdd.CreateTime <= :GCTimeEnd");
  267. parameters.Add(new OracleParameter(":GCTimeEnd", OracleDbType.Date, se.GCTimeEnd.Value, ParameterDirection.Input));
  268. }
  269. //sql.Append(" AND TP_PM_GroutingDailyDetail.GroutingLineID in(Select PurviewID from TP_MST_UserPurview where PurviewType= 5 and UserID = :UserID) ");
  270. sql.Append(" AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 5 and up.UserID = :UserID and (up.PurviewID = -1 or up.PurviewID= gdd.GroutingLineID))");
  271. parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  272. }
  273. sql.Append(" order by gdd.GroutingDate desc, ");
  274. sql.Append(" gdd.GroutingLineCode, ");
  275. sql.Append(" gdd.GroutingBatchNo, ");
  276. sql.Append(" gdd.GroutingMouldCode");
  277. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  278. ServiceResultEntity sre = new ServiceResultEntity();
  279. if (data == null || data.Rows.Count == 0)
  280. {
  281. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  282. return sre;
  283. }
  284. sre.Data = new DataSet();
  285. sre.Data.Tables.Add(data);
  286. return sre;
  287. }
  288. catch (Exception ex)
  289. {
  290. throw ex;
  291. }
  292. finally
  293. {
  294. if (conn != null &&
  295. conn.ConnState == ConnectionState.Open)
  296. {
  297. conn.Close();
  298. }
  299. }
  300. }
  301. /// <summary>
  302. /// 获取RPT010101_1画面(注浆明细表)的查询sql
  303. /// </summary>
  304. /// <returns>sql</returns>
  305. private static string GetRPT010101SSQL()
  306. {
  307. string selSql =
  308. "select " +
  309. " gdd.GroutingDate, " +
  310. " gdd.GroutingBatchNo, " +
  311. " gdd.GroutingLineCode, " +
  312. " TP_MST_GMouldType.Gmouldtypename, " +
  313. " TP_MST_GOODSTYPE.GOODSTYPENAME, " +
  314. " gdd.GoodsCode, " +
  315. " TP_MST_GOODS.GOODSSPECIFICATION, " +
  316. " gdd.GroutingMouldCode, " +
  317. " TP_MST_DataDictionary.DICTIONARYVALUE, " +
  318. " gdd.Groutingcount, " +
  319. " gdd.Barcode, " +
  320. " tp_mst_user.UserCode CreateUserCode, " +
  321. " tp_mst_user.username CreateUserName, " +
  322. " gdd.UserCode, " +
  323. " gdd.SCRAPFLAG, " +
  324. " gdd.GoodsName, " +
  325. " gdd.GROUTINGFLAG, " +
  326. " gdd.GMOULDSTATUS, " +
  327. " gdd.DeliverTime, " +
  328. " gdd.DeliverFlag, " +
  329. " tp_sys_gmouldstatus.gmouldstatusname, " +
  330. " b.dictionaryvalue AS NoGroutingRreason, " +
  331. " gdd.SCRAPTIME, " +
  332. " gdd.CreateTime GCTime, " +
  333. " mu.usercode MONITORCODE, " +
  334. " mu.username MONITORNAME, " +
  335. " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName " +
  336. "from TP_PM_GroutingDailyDetail gdd " +
  337. "inner join TP_PM_GroutingDaily gd on gd.GroutingDailyID = gdd.GroutingDailyID " +
  338. "left join tp_mst_user mu on mu.userid = gd.MONITORID " +
  339. "inner join TP_PC_GroutingLine on TP_PC_GroutingLine.GroutingLineID=gdd.GroutingLineID " +
  340. "inner join TP_MST_GMouldType on TP_MST_GMouldType.GMOULDTYPEID=TP_PC_GroutingLine.GMOULDTYPEID " +
  341. "inner join TP_MST_Goods on TP_MST_Goods.Goodsid=gdd.GoodsID " +
  342. "inner join TP_MST_DataDictionary on TP_MST_DataDictionary.Dictionaryid=TP_MST_Goods.Glazetypeid " +
  343. "inner join TP_MST_GOODSTYPE on TP_MST_GOODSTYPE.GOODSTYPEID=TP_MST_Goods.Goodstypeid " +
  344. "inner join tp_sys_gmouldstatus on gdd.gmouldstatus = tp_sys_gmouldstatus.gmouldstatusid " +
  345. "left join tp_mst_user on gdd.CreateUserID=tp_mst_user.userid " +
  346. "left join TP_MST_DataDictionary b on gdd.NoGroutingRreason=b.DictionaryID " +
  347. "left join TP_MST_logo on gdd.logoid=TP_MST_logo.logoid " +
  348. "Where 1=1 " +
  349. "and gdd.Valueflag=1 " +
  350. "and gdd.AccountID=:AccountID ";
  351. return selSql;
  352. }
  353. /// <summary>
  354. /// 取得RPT010102_1画面(半检明细表)的查询数据
  355. /// </summary>
  356. /// <param name="user">登录用户信息</param>
  357. /// <param name="se">查询条件</param>
  358. /// <returns>查询结果</returns>
  359. public static ServiceResultEntity GetRPT010102SData(SUserInfo user, RPT010102_SE se)
  360. {
  361. IDBConnection conn = null;
  362. try
  363. {
  364. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  365. OracleParameter[] paras = new OracleParameter[]{
  366. new OracleParameter("in_goodsID",OracleDbType.Varchar2,se.GoodsIDS,ParameterDirection.Input),
  367. new OracleParameter("in_testUserID",OracleDbType.Varchar2,se.TestUserIDS,ParameterDirection.Input),
  368. new OracleParameter("in_groutingUserID",OracleDbType.Varchar2,se.GroutingUserIDS,ParameterDirection.Input),
  369. new OracleParameter("in_goodsTypeID",OracleDbType.Varchar2,se.GoodsTypeIDS,ParameterDirection.Input),
  370. new OracleParameter("in_semiTestTypeID",OracleDbType.Varchar2,se.semiTestTypeID,ParameterDirection.Input),
  371. new OracleParameter("in_remarks",OracleDbType.Varchar2,se.Remarks,ParameterDirection.Input),
  372. new OracleParameter("in_semiTestDateStart",OracleDbType.Varchar2,se.SemiTestDateStart,ParameterDirection.Input),
  373. new OracleParameter("in_semiTestDateEnd",OracleDbType.Varchar2,se.SemiTestDateEnd,ParameterDirection.Input),
  374. new OracleParameter("in_accountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  375. new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  376. };
  377. DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetSemiTestDetail", paras);
  378. ServiceResultEntity sre = new ServiceResultEntity();
  379. if (data == null || data.Tables.Count == 0)
  380. {
  381. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  382. return sre;
  383. }
  384. sre.Data = new DataSet();
  385. sre.Data = data;
  386. return sre;
  387. }
  388. catch (Exception ex)
  389. {
  390. throw ex;
  391. }
  392. finally
  393. {
  394. if (conn != null &&
  395. conn.ConnState == ConnectionState.Open)
  396. {
  397. conn.Close();
  398. }
  399. }
  400. }
  401. /// <summary>
  402. /// 取得RPT010103画面(交坯明细表)的查询数据
  403. /// </summary>
  404. /// <param name="user">登录用户信息</param>
  405. /// <param name="se">查询条件</param>
  406. /// <returns>查询结果</returns>
  407. public static ServiceResultEntity GetRPT010103SData(SUserInfo user, RPT010103_SE se)
  408. {
  409. IDBConnection conn = null;
  410. try
  411. {
  412. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  413. List<OracleParameter> parameters = new List<OracleParameter>();
  414. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010103SSQL());
  415. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  416. // parameters.Add(new OracleParameter(":UPUserId", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  417. if (se != null)
  418. {
  419. //成型线IDS
  420. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  421. {
  422. sql.Append(" and instr(','||:GroutingLineIDS||',',','||pd.GroutingLineID||',')>0 ");
  423. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  424. }
  425. // 成型线类别
  426. if (!string.IsNullOrEmpty(se.GMouldTypeIDS))
  427. {
  428. sql.Append(" AND instr(','||:GMouldTypeIDS||',',','||gt.GMouldTypeID||',')>0 ");
  429. parameters.Add(new OracleParameter(":GMouldTypeIDS", OracleDbType.NVarchar2, se.GMouldTypeIDS, ParameterDirection.Input));
  430. }
  431. // 交坯日期-开始
  432. if (se.CreateTimeBegin.HasValue)
  433. {
  434. sql.Append(" AND pd.CreateTime >= :CreateTimeBegin ");
  435. parameters.Add(new OracleParameter(":CreateTimeBegin", OracleDbType.Date, se.CreateTimeBegin.Value, ParameterDirection.Input));
  436. }
  437. // 交坯日期-结束
  438. if (se.CreateTimeEnd.HasValue)
  439. {
  440. sql.Append(" AND pd.CreateTime <= :CreateTimeEnd ");
  441. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  442. }
  443. // 注浆模具编号
  444. if (!string.IsNullOrEmpty(se.GroutingMouldCode))
  445. {
  446. //sql.Append(" AND INSTR(','||:GroutingMouldCode||',',','||pd.GroutingMouldCode||',') > 0 ");
  447. sql.Append(" AND INSTR(pd.GroutingMouldCode,:GroutingMouldCode) > 0 ");
  448. parameters.Add(new OracleParameter(":GroutingMouldCode", OracleDbType.NVarchar2, se.GroutingMouldCode, ParameterDirection.Input));
  449. }
  450. //产品IDS
  451. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  452. {
  453. // sql.Append(" and instr(','||:GoodsTypeIDS||',',','||gdt.GoodsTypeCode||',')=1");
  454. sql.Append("AND instr(gdt.GoodsTypeCode,:GoodsTypeIDS)=1 ");
  455. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  456. }
  457. //产品类别IDS
  458. if (!string.IsNullOrEmpty(se.GoodsIDS))
  459. {
  460. sql.Append(" and instr(','||:GoodsIDS||',',','||pd.goodsid||',')>0");
  461. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  462. }
  463. // 备注
  464. if (!string.IsNullOrEmpty(se.Remarks))
  465. {
  466. sql.Append(" AND INSTR(pd.Remarks, :Remarks) > 0");
  467. parameters.Add(new OracleParameter(":Remarks", OracleDbType.NVarchar2, se.Remarks, ParameterDirection.Input));
  468. }
  469. // 注浆工号
  470. if (!string.IsNullOrEmpty(se.GroutingUserCode))
  471. {
  472. sql.Append(" AND INSTR( ','||:GroutingUserCode||',',','||pd.GroutingUserCode||',') > 0");
  473. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.NVarchar2, se.GroutingUserCode, ParameterDirection.Input));
  474. }
  475. // 条码
  476. if (!string.IsNullOrEmpty(se.BarCode))
  477. {
  478. //sql.Append(" AND INSTR(','||:BarCode||',',','||pd.BarCode||',') > 0");
  479. sql.Append(" AND INSTR(pd.BarCode,:BarCode) > 0");
  480. parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.BarCode, ParameterDirection.Input));
  481. }
  482. // 生产工号和注浆工号不同
  483. if (se.ProdUserIsGroutingUserFlag == 1)
  484. {
  485. sql.Append(" and pd.usercode<>pd.GroutingUserCode");
  486. }
  487. }
  488. sql.Append(" ORDER BY pd.CreateTime, pd.GroutingLineCode, pd.GroutingMouldCode");
  489. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  490. ServiceResultEntity sre = new ServiceResultEntity();
  491. if (data == null || data.Rows.Count == 0)
  492. {
  493. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  494. return sre;
  495. }
  496. sre.Data = new DataSet();
  497. sre.Data.Tables.Add(data);
  498. return sre;
  499. }
  500. catch (Exception ex)
  501. {
  502. throw ex;
  503. }
  504. finally
  505. {
  506. if (conn != null &&
  507. conn.ConnState == ConnectionState.Open)
  508. {
  509. conn.Close();
  510. }
  511. }
  512. }
  513. /// <summary>
  514. /// 获取RPT010103画面(交坯明细表)的查询sql
  515. /// </summary>
  516. /// <returns>sql</returns>
  517. private static string GetRPT010103SSQL()
  518. {
  519. string selSql =
  520. "select "
  521. //---产品条码
  522. + "pd.barcode, "
  523. //注浆时间
  524. + "pd.groutingdate,"
  525. //交坯时间
  526. + "pd.CreateTime,"
  527. //---产品类别
  528. + "g.GoodsTypeID,"
  529. //---产品类别编码
  530. + "gdt.GoodsTypeCode,"
  531. //---产品类别名称
  532. + "gdt.GoodsTypeName,"
  533. //----产品ID
  534. + "pd.goodsid,"
  535. //----产品编码
  536. + "pd.goodscode,"
  537. //----产品名称
  538. + "pd.goodsname,"
  539. //----规格
  540. + "g.GoodsSpecification,"
  541. //----釉色类别ID
  542. + "g.GlazeTypeID,"
  543. //----釉色类别描述
  544. + "dd.dictionaryvalue as GlazeTypeName,"
  545. //----注浆模具
  546. + "pd.GroutingMouldCode,"
  547. //---生产线号
  548. + "pd.ProductionLineID,"
  549. //---成型线编码
  550. + "pd.ProductionLineCode,"
  551. //---成型线名称
  552. + "pd.ProductionLineName,"
  553. //---成型线号Id
  554. + " pd.GroutingLineID,"
  555. //---成型线号
  556. + " pd.GroutingLineCode,"
  557. //---成型线类型ID
  558. + "gt.GMouldTypeID,"
  559. //---成型线类型
  560. + "gt.GMouldTypeName,"
  561. //---生产工号
  562. + "pd.UserID,"
  563. //---生产工号用户编号
  564. + "u.usercode,"
  565. //----注浆工号
  566. + "pd.GroutingUserID,"
  567. //---注浆工号用户编号
  568. + "pd.GroutingUserCode, "
  569. // 成型班长
  570. + " mu.username as MONITORName,"
  571. //--公坯标识
  572. + " pd.ISPUBLICBODY, "
  573. //--注浆次数
  574. + " gdd.GROUTINGCOUNT, "
  575. + " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName "
  576. //--查油工号
  577. + " , uc.usercode check1 "
  578. //生产数据
  579. + "from TP_PM_PRODUCTIONDATA pd "
  580. // 成型线
  581. + " LEFT JOIN tp_pc_groutingline gl" +
  582. " ON gl.groutinglineid = pd.GroutingLineID" +
  583. // 成型班长
  584. " LEFT JOIN tp_mst_user mu" +
  585. " ON mu.userid = gl.MONITORID"
  586. //注浆明细
  587. + " inner join TP_PM_GROUTINGDAILYDETAIL gdd on pd.GROUTINGDAILYDETAILID=gdd.GROUTINGDAILYDETAILID "
  588. //模具类型
  589. + "inner join TP_MST_GMouldType gt "
  590. + "on pd.GMOULDTYPEID=gt.GMouldTypeID "
  591. //产品档案
  592. + "inner join TP_MST_Goods g "
  593. + "on pd.goodsid=g.goodsid "
  594. //数据字典,TPC002为釉色类别
  595. + "inner join TP_MST_DataDictionary dd "
  596. //
  597. + "on dd.DictionaryType = 'TPC002' "
  598. //
  599. + "and dd.dictionaryid= g.GlazeTypeID "
  600. //用户信息
  601. + "inner join tp_mst_user u "
  602. + "on pd.userid=u.userid "
  603. + "inner join tp_mst_user uc "
  604. + "on pd.createuserid=uc.userid "
  605. //
  606. + "inner join TP_MST_GoodsType gdt "
  607. + "on g.GoodsTypeID=gdt.GoodsTypeID "
  608. + "inner join TP_MST_logo "
  609. + "on gdd.logoid=TP_MST_logo.logoid "
  610. // 交坯
  611. + " WHERE pd.modeltype=5 "
  612. // 账套
  613. + " and pd.AccountID=:AccountID"
  614. + " and pd.ValueFlag='" + (int)Constant.ValueFlag.Effective + "'";
  615. //成型线查看权限
  616. //+ " and exists (select up.PurviewID "
  617. //+ " from TP_MST_UserPurview up where up.PurviewType='"
  618. //+ (int)Constant.PurviewType.ViewGroutingLine
  619. //+ "' and up.PurviewID=pd.GroutingLineID "
  620. //+ " and up.UserId=:UPUserId)";
  621. return selSql;
  622. }
  623. /// <summary>
  624. /// 取得RPT010105画面(成型线模具使用明细表)的查询数据
  625. /// </summary>
  626. /// <param name="user">登录用户信息</param>
  627. /// <param name="se">查询条件</param>
  628. /// <returns>查询结果</returns>
  629. public static ServiceResultEntity GetRPT010105SData(SUserInfo user, RPT010105_SE se)
  630. {
  631. IDBConnection conn = null;
  632. try
  633. {
  634. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  635. string sqlString =
  636. "SELECT t.groutinglinecode\n" +
  637. " ,gl.BuildingNo\n" +
  638. " ,gl.FloorNo\n" +
  639. " ,gl.GroutingLineNo\n" +
  640. " ,t.usercode\n" +
  641. " ,t.goodscode\n" +
  642. " ,t.GOODSSPECIFICATION\n" +
  643. " ,t.goodstypename\n" +
  644. " ,t.MouldQuantity\n" +
  645. " ,gld.groutingmouldcode\n" +
  646. " ,gms.gmouldstatusname\n" +
  647. " ,gld.beginuseddate\n" +
  648. " ,(SELECT MIN(ggg.groutingdate)\n" +
  649. " FROM tp_pm_groutingdailydetail ggg\n" +
  650. " WHERE ggg.groutinglinedetailid = t.groutinglinedetailid) groutingdate\n" +
  651. " ,MAX(t.GroutingCount)-SUM(t.groutingflag) mingroutingcount\n" +
  652. " ,SUM(t.groutingflag) sumgroutingcount\n" +
  653. " ,MAX(t.GroutingCount) maxGroutingCount\n" +
  654. " ,gld.groutingcount\n" +
  655. " FROM (SELECT gd.groutinglinecode\n" +
  656. " ,gd.usercode\n" +
  657. " ,gdd.goodsid\n" +
  658. " ,gd.MouldQuantity\n" +
  659. " ,gdd.groutinglinedetailid\n" +
  660. " ,decode(gdd.groutingflag, '1', 1, 0) groutingflag\n" +
  661. " ,gdd.GroutingCount\n" +
  662. " ,gt.goodstypename\n" +
  663. " ,g.goodscode\n" +
  664. " ,g.GOODSSPECIFICATION\n" +
  665. " FROM TP_PM_GroutingDaily gd\n" +
  666. " INNER JOIN TP_PM_GroutingDailyDetail gdd\n" +
  667. " ON gdd.groutingdailyid = gd.groutingdailyid\n" +
  668. " INNER JOIN TP_MST_Goods g\n" +
  669. " ON g.goodsid = gdd.goodsid\n" +
  670. " INNER JOIN TP_MST_GOODSTYPE gt\n" +
  671. " ON gt.goodstypeid = g.goodstypeid\n" +
  672. " WHERE gd.accountid = :AccountID\n" +
  673. " AND gd.groutingdate >= :GDateBegin\n" +
  674. " AND gd.groutingdate <= :GDateEnd\n" +
  675. " AND (:groutinglinecode is null or instr(gd.groutinglinecode, :groutinglinecode) > 0)\n" +
  676. " AND (:groutingusercode is null or instr(gdd.usercode, :groutingusercode) > 0)\n" +
  677. " AND (:goodscode is null or instr(gdd.goodscode, :goodscode) > 0)\n" +
  678. " AND (:goodstypecode is null or instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  679. " ) t\n" +
  680. " INNER JOIN tp_pc_groutinglinedetail gld\n" +
  681. " ON gld.groutinglinedetailid = t.groutinglinedetailid\n" +
  682. " INNER JOIN tp_pc_groutingline gl\n" +
  683. " ON gld.groutinglineid = gl.groutinglineid\n" +
  684. " INNER JOIN TP_SYS_GMouldStatus gms\n" +
  685. " ON gms.gmouldstatusid = gld.gmouldstatus\n" +
  686. " GROUP BY t.groutinglinecode\n" +
  687. " ,gl.BuildingNo\n" +
  688. " ,gl.FloorNo\n" +
  689. " ,gl.GroutingLineNo\n" +
  690. " ,t.usercode\n" +
  691. " ,t.goodscode\n" +
  692. " ,t.GOODSSPECIFICATION\n" +
  693. " ,t.goodstypename\n" +
  694. " ,t.MouldQuantity\n" +
  695. " ,gld.groutingmouldcode\n" +
  696. " ,gms.gmouldstatusname\n" +
  697. " ,gld.beginuseddate\n" +
  698. " ,gld.groutingcount\n" +
  699. " ,t.groutinglinedetailid\n" +
  700. " ORDER BY t.groutinglinecode, gld.groutingmouldcode, t.groutinglinedetailid";
  701. List<OracleParameter> parameters = new List<OracleParameter>();
  702. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  703. parameters.Add(new OracleParameter(":GDateBegin", OracleDbType.Date, se.GDateBegin, ParameterDirection.Input));
  704. parameters.Add(new OracleParameter(":GDateEnd", OracleDbType.Date, se.GDateEnd, ParameterDirection.Input));
  705. parameters.Add(new OracleParameter(":groutinglinecode", OracleDbType.Varchar2, se.GroutingLineCode, ParameterDirection.Input));
  706. parameters.Add(new OracleParameter(":groutingusercode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  707. parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  708. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  709. DataTable data = conn.GetSqlResultToDt(sqlString.ToString(), parameters.ToArray());
  710. ServiceResultEntity sre = new ServiceResultEntity();
  711. if (data == null || data.Rows.Count == 0)
  712. {
  713. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  714. return sre;
  715. }
  716. sre.Data = new DataSet();
  717. sre.Data.Tables.Add(data);
  718. return sre;
  719. }
  720. catch (Exception ex)
  721. {
  722. throw ex;
  723. }
  724. finally
  725. {
  726. if (conn != null &&
  727. conn.ConnState == ConnectionState.Open)
  728. {
  729. conn.Close();
  730. }
  731. }
  732. }
  733. /// <summary>
  734. /// 取得RPT010106画面(成型线剩余注浆次数)的查询数据
  735. /// </summary>
  736. /// <param name="user">登录用户信息</param>
  737. /// <param name="se">查询条件</param>
  738. /// <returns>查询结果</returns>
  739. public static ServiceResultEntity GetRPT010106SData(SUserInfo user, RPT010106_SE se)
  740. {
  741. IDBConnection conn = null;
  742. try
  743. {
  744. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  745. string sqlString =
  746. "SELECT gl.buildingno\n" +
  747. " ,gl.floorno\n" +
  748. " ,gl.groutinglineno\n" +
  749. " ,gl.groutinglinecode\n" +
  750. " ,gl.Remarks\n" +
  751. " ,decode(UserCount,\n" +
  752. " 1,\n" +
  753. " mu.usercode,\n" +
  754. " (SELECT wmsys.wm_concat(to_char(gmu.usercode))\n" +
  755. " FROM tp_pc_groutinguser gu\n" +
  756. " INNER JOIN tp_mst_user gmu\n" +
  757. " ON gmu.userid = gu.userid\n" +
  758. " WHERE gu.groutinglineid = gl.groutinglineid)) groutingusercode\n" +
  759. // 成型班长
  760. " ,mnu.username as MONITORName" +
  761. " ,g.goodscode\n" +
  762. " ,g.goodsspecification\n" +
  763. " ,gt.goodstypename\n" +
  764. " --,gl.mouldquantity\n" +
  765. " ,gldd.mouldquantity\n" +
  766. " ,gmt.gmouldtypename\n" +
  767. " ,gms.gmouldstatusname\n" +
  768. " ,gldd.beginuseddate -- 上模日期\n" +
  769. " ,gldd.groutingdate -- 首次注浆日期\n" +
  770. " ,gldd.standardgroutingcount AS standardcount -- 标准注浆次数\n" +
  771. " ,gldd.groutingcount -- 最大注浆次数\n" +
  772. " ,gldd.standardgroutingcount - gldd.groutingcount AS mincount --剩余最少注浆次数\n" +
  773. " ,gldd.sumstandardgroutingcount AS sumstandardcount -- 标准总注浆次数\n" +
  774. " ,gldd.sumgroutingcount -- 总注浆次数\n" +
  775. " ,gldd.sumstandardgroutingcount - gldd.sumgroutingcount AS leftcount --剩余总注浆次数\n" +
  776. " ,round(decode(gl.mouldquantity,\n" +
  777. " 0,\n" +
  778. " 0,\n" +
  779. " (gldd.sumstandardgroutingcount - gldd.sumgroutingcount) /\n" +
  780. " gl.mouldquantity),\n" +
  781. " 2) AS leftmaxcount -- 剩余最大注浆次数\n" +
  782. " FROM tp_pc_groutingline gl\n" +
  783. " INNER JOIN (SELECT gld.groutinglineid\n" +
  784. " ,gld.goodsid\n" +
  785. " ,COUNT(gld.groutinglinedetailid) mouldquantity\n" +
  786. " ,MIN(gld.beginuseddate) beginuseddate\n" +
  787. " ,MIN(gddd.groutingdate) groutingdate\n" +
  788. " /* ,(SELECT MIN(gdd.groutingdate)\n" +
  789. " FROM tp_pm_groutingdailydetail gdd\n" +
  790. " WHERE gdd.groutinglinedetailid = gld.groutinglinedetailid\n" +
  791. " AND gdd.groutingflag = '1') groutingdate*/\n" +
  792. " ,MAX(gld.standardgroutingcount) standardgroutingcount\n" +
  793. " ,MAX(gld.groutingcount) groutingcount\n" +
  794. " ,SUM(gld.standardgroutingcount) sumstandardgroutingcount\n" +
  795. " ,SUM(gld.groutingcount) sumgroutingcount\n" +
  796. " FROM tp_pc_groutinglinedetail gld\n" +
  797. " --LEFT JOIN tp_pm_groutingdailydetail gdd\n" +
  798. " -- ON gdd.groutinglinedetailid = gld.groutinglinedetailid\n" +
  799. " -- AND gdd.groutingflag = '1'\n" +
  800. " LEFT JOIN (SELECT gdd.groutinglinedetailid\n" +
  801. " ,gdd.mouldcode\n" +
  802. " ,MIN(gdd.groutingdate) groutingdate\n" +
  803. " FROM tp_pm_groutingdailydetail gdd\n" +
  804. " WHERE gdd.accountid = :AccountID\n" +
  805. " AND gdd.groutingflag = '1'\n" +
  806. " GROUP BY gdd.groutinglinedetailid, gdd.mouldcode) gddd\n" +
  807. " ON gddd.groutinglinedetailid = gld.groutinglinedetailid\n" +
  808. " AND gddd.mouldcode = gld.mouldcode\n" +
  809. " WHERE gld.valueflag = '1'\n" +
  810. " GROUP BY gld.groutinglineid, gld.goodsid) gldd\n" +
  811. " ON gldd.groutinglineid = gl.groutinglineid\n" +
  812. " INNER JOIN tp_mst_goods g\n" +
  813. " ON g.goodsid = gldd.goodsid\n" +
  814. " INNER JOIN tp_mst_goodstype gt\n" +
  815. " ON gt.goodstypeid = g.goodstypeid\n" +
  816. " INNER JOIN tp_mst_gmouldtype gmt\n" +
  817. " ON gmt.gmouldtypeid = gl.gmouldtypeid\n" +
  818. " INNER JOIN tp_sys_gmouldstatus gms\n" +
  819. " ON gms.gmouldstatusid = gl.gmouldstatus\n" +
  820. " INNER JOIN tp_mst_user mu\n" +
  821. " ON mu.userid = gl.userid\n" +
  822. // 成型班长
  823. " LEFT JOIN tp_mst_user mnu" +
  824. " ON mnu.userid = gl.MONITORID" +
  825. " WHERE gl.accountid = :AccountID\n" +
  826. " AND gl.valueflag = '1'\n" +
  827. " AND (:Remarks is null or instr(gl.Remarks, :Remarks) > 0)\n" +
  828. " AND (:groutinglinecode is null or instr(gl.groutinglinecode, :groutinglinecode) > 0)\n" +
  829. " AND (:goodscode is null or instr(g.goodscode, :goodscode) > 0)\n" +
  830. " AND (:goodstypecode is null or instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  831. " ORDER BY gl.groutinglinecode, g.goodscode";
  832. List<OracleParameter> parameters = new List<OracleParameter>();
  833. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  834. parameters.Add(new OracleParameter(":Remarks", OracleDbType.Varchar2, se.Remarks, ParameterDirection.Input));
  835. parameters.Add(new OracleParameter(":groutinglinecode", OracleDbType.Varchar2, se.GroutingLineCode, ParameterDirection.Input));
  836. parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  837. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  838. DataTable data = conn.GetSqlResultToDt(sqlString.ToString(), parameters.ToArray());
  839. ServiceResultEntity sre = new ServiceResultEntity();
  840. if (data == null || data.Rows.Count == 0)
  841. {
  842. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  843. return sre;
  844. }
  845. sre.Data = new DataSet();
  846. sre.Data.Tables.Add(data);
  847. return sre;
  848. }
  849. catch (Exception ex)
  850. {
  851. throw ex;
  852. }
  853. finally
  854. {
  855. if (conn != null &&
  856. conn.ConnState == ConnectionState.Open)
  857. {
  858. conn.Close();
  859. }
  860. }
  861. }
  862. /// <summary>
  863. /// 取得RPT010201_1画面(工序漏扫明细表)的查询数据
  864. /// </summary>
  865. /// <param name="user">登录用户信息</param>
  866. /// <param name="se">查询条件</param>
  867. /// <returns>查询结果</returns>
  868. public static ServiceResultEntity GetRPT010201SData(SUserInfo user, RPT010201_SE se)
  869. {
  870. IDBConnection conn = null;
  871. try
  872. {
  873. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  874. List<OracleParameter> parameters = new List<OracleParameter>();
  875. // 校验时间--开始
  876. if (se.beginCreateTime.HasValue)
  877. {
  878. parameters.Add(new OracleParameter("in_stardate", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  879. }
  880. // 校验时间--结束
  881. if (se.endCreateTime.HasValue)
  882. {
  883. parameters.Add(new OracleParameter("in_enddate", OracleDbType.Date, se.endCreateTime.Value, ParameterDirection.Input));
  884. }
  885. conn.ExecStoredProcedure("PRO_PM_InitBarcodeMissing", parameters.ToArray());
  886. parameters.Clear();
  887. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010201SSQL(user, se, ref parameters));
  888. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  889. ServiceResultEntity sre = new ServiceResultEntity();
  890. if (data == null || data.Rows.Count == 0)
  891. {
  892. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  893. return sre;
  894. }
  895. sre.Data = new DataSet();
  896. sre.Data.Tables.Add(data);
  897. return sre;
  898. }
  899. catch (Exception ex)
  900. {
  901. throw ex;
  902. }
  903. finally
  904. {
  905. if (conn != null &&
  906. conn.ConnState == ConnectionState.Open)
  907. {
  908. conn.Close();
  909. }
  910. }
  911. }
  912. /// <summary>
  913. /// 获取RPT010201_1画面(工序漏扫明细表)的查询sql
  914. /// </summary>
  915. /// <returns>sql</returns>
  916. private static string GetRPT010201SSQL(SUserInfo user, RPT010201_SE se, ref List<OracleParameter> parameters)
  917. {
  918. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  919. #region
  920. /*
  921. selSql = selSql +
  922. "select * from (" +
  923. "select " +
  924. "MissProcedureID, " +
  925. "MissProcedureCode, " +
  926. "case when GoodsType=TP_MST_GoodsType.GoodsTypeCode then to_char(TP_MST_GoodsType.GoodsTypeName) else to_char(GoodsType) end GoodsType, " +
  927. "MissProcedureName, " +
  928. "MissID, " +
  929. "BarCode, " +
  930. "OrganizationID, " +
  931. "OrganizationName, " +
  932. "OrganizationCode, " +
  933. "OrganizationFullName, " +
  934. "CompleteProcedureID, " +
  935. "CompleteProcedureCode, " +
  936. "CompleteProcedureName, " +
  937. "ProcedureID, " +
  938. "ProcedureCode, " +
  939. "ProcedureName, " +
  940. "GoodsID, " +
  941. "GoodsCode, " +
  942. "GoodsName, " +
  943. "result.GoodsTypeID, " +
  944. "result.CreateTime, " +
  945. "result.GoodsTypeName, " +
  946. "UserName, " +
  947. "MissUserCode, " +
  948. "barcodecount, seqno " +
  949. "from " +
  950. " ( " +
  951. " select " +
  952. " MissProcedureID, " +
  953. " MissProcedureCode, " +
  954. " decode(MissProcedureName,'小计',decode(MissProcedureID,'--','合计','--'),GoodsType) GoodsType, " +
  955. " decode(MissProcedureID,'--','--',decode(MissProcedureName,'小计','小计',MissProcedureName)) MissProcedureName, " +
  956. " MissID, " +
  957. " BarCode, " +
  958. " OrganizationID, " +
  959. " OrganizationName, " +
  960. " OrganizationCode, " +
  961. " OrganizationFullName, " +
  962. " CompleteProcedureID, " +
  963. " CompleteProcedureCode, " +
  964. " CompleteProcedureName, " +
  965. " ProcedureID, " +
  966. " ProcedureCode, " +
  967. " ProcedureName, " +
  968. " GoodsID, " +
  969. " GoodsCode, " +
  970. " GoodsName, " +
  971. " GoodsTypeID, " +
  972. " CreateTime, " +
  973. " GoodsTypeName, " +
  974. " UserName, " +
  975. " MissUserCode, " +
  976. " barcodecount,rownum seqno " +
  977. " from " +
  978. " ( " +
  979. " select " +
  980. " decode(grouping( MissProcedureID),1,'--',MissProcedureID) MissProcedureID, " +
  981. " decode(grouping( MissProcedureCode),1,'--',MissProcedureCode) MissProcedureCode, " +
  982. " decode(grouping( MissProcedureName),1,'小计',MissProcedureName) MissProcedureName, " +
  983. " decode(grouping(GoodsType),1,'合计',GoodsType) GoodsType, " +
  984. " decode(grouping(MissID),1,'--',MissID) MissID, " +
  985. " decode(grouping(BarCode),1,'--',BarCode) BarCode, " +
  986. " decode(grouping(OrganizationID),1,'--',OrganizationID) OrganizationID, " +
  987. " decode(grouping(OrganizationName),1,'--',OrganizationName) OrganizationName, " +
  988. " decode(grouping(OrganizationCode),1,'--',OrganizationCode) OrganizationCode, " +
  989. " decode(grouping(OrganizationFullName),1,'--',OrganizationFullName) OrganizationFullName, " +
  990. " decode(grouping(CompleteProcedureID),1,'--',CompleteProcedureID) CompleteProcedureID, " +
  991. " decode(grouping(CompleteProcedureCode),1,'--',CompleteProcedureCode) CompleteProcedureCode, " +
  992. " decode(grouping(CompleteProcedureName),1,'--',CompleteProcedureName) CompleteProcedureName, " +
  993. " decode(grouping(ProcedureID),1,'--',ProcedureID) ProcedureID, " +
  994. " decode(grouping(ProcedureCode),1,'--',ProcedureCode) ProcedureCode, " +
  995. " decode(grouping(ProcedureName),1,'--',ProcedureName) ProcedureName, " +
  996. " decode(grouping(GoodsID),1,'--',GoodsID) GoodsID, " +
  997. " decode(grouping(GoodsCode),1,'--',GoodsCode) GoodsCode, " +
  998. " decode(grouping(GoodsName),1,'--',GoodsName) GoodsName, " +
  999. " decode(grouping(GoodsTypeID),1,'--',GoodsTypeID) GoodsTypeID, " +
  1000. " decode(grouping(CreateTime),1,'--',CreateTime) CreateTime, " +
  1001. " decode(grouping(GoodsTypeName),1,'--',GoodsTypeName) GoodsTypeName, " +
  1002. " decode(grouping(UserName),1,'--',UserName) UserName, " +
  1003. " decode(grouping(MissUserCode),1,'--',MissUserCode) MissUserCode, " +
  1004. " count(barcode) barcodecount " +
  1005. " from " +
  1006. " ( " +
  1007. " select TP_PM_BarCodeMissing.MissProcedureID, " +
  1008. " TP_PM_BarCodeMissing.MissProcedureCode, " +
  1009. " TP_PM_BarCodeMissing.MissProcedureName, " +
  1010. " substr(TP_MST_GoodsType.GOODSTYPECODE,1,6) GoodsType, " +
  1011. " TP_PM_BarCodeMissing.MissID, " +
  1012. " TP_PM_BarCodeMissing.BarCode, " +
  1013. " TP_PM_BarCodeMissing.OrganizationID, " +
  1014. " TP_PM_BarCodeMissing.OrganizationName, " +
  1015. " TP_PM_BarCodeMissing.OrganizationCode, " +
  1016. " TP_PM_BarCodeMissing.OrganizationFullName, " +
  1017. " TP_PM_BarCodeMissing.CompleteProcedureID, " +
  1018. " TP_PM_BarCodeMissing.CompleteProcedureCode, " +
  1019. " TP_PM_BarCodeMissing.CompleteProcedureName, " +
  1020. " TP_PM_BarCodeMissing.ProcedureID, " +
  1021. " TP_PM_BarCodeMissing.ProcedureCode, " +
  1022. " TP_PM_BarCodeMissing.ProcedureName, " +
  1023. " TP_PM_BarCodeMissing.GoodsID, " +
  1024. " TP_PM_BarCodeMissing.GoodsCode, " +
  1025. " TP_PM_BarCodeMissing.GoodsName, " +
  1026. " TP_PM_BarCodeMissing.GoodsTypeID, " +
  1027. " TP_PM_BarCodeMissing.MissUserCode, " +
  1028. " to_char(TP_PM_BarCodeMissing.CreateTime,'yyyy-MM-dd HH24:mi:ss') CreateTime, " +
  1029. " TP_MST_GoodsType.GoodsTypeName, " +
  1030. " TP_MST_USER.UserName " +
  1031. " from TP_PM_BarCodeMissing left join TP_MST_GoodsType " +
  1032. " on TP_PM_BarCodeMissing.GoodsTypeID=TP_MST_GoodsType.GoodsTypeID " +
  1033. " left join TP_MST_USER " +
  1034. " on TP_PM_BarCodeMissing.CreateUserID=TP_MST_USER.UserID " +
  1035. " where TP_PM_BarCodeMissing.valueflag=1 " +
  1036. " and TP_PM_BarCodeMissing.accountid=:AccountID ";
  1037. // 产品条码
  1038. if (!string.IsNullOrEmpty(se.Barcode))
  1039. {
  1040. selSql = selSql + " and TP_PM_BarCodeMissing.barcode=:Barcode ";
  1041. parameters.Add(new OracleParameter(":Barcode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  1042. }
  1043. // 组织结构
  1044. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  1045. {
  1046. selSql = selSql + " and instr(',' || :OrganizationIDS || ',' ,','||TP_PM_BarCodeMissing.OrganizationID||',' )>0 ";
  1047. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  1048. }
  1049. // 完成工序
  1050. if (!string.IsNullOrEmpty(se.CompleteProcedureIDS))
  1051. {
  1052. selSql = selSql + " and instr(',' || :CompleteProcedureIDS || ',',','||TP_PM_BarCodeMissing.CompleteProcedureID||',' )>0 ";
  1053. parameters.Add(new OracleParameter(":CompleteProcedureIDS", OracleDbType.NVarchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  1054. }
  1055. // 校验工序
  1056. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  1057. {
  1058. selSql = selSql + " and instr(',' || :ProcedureIDS || ',',','||TP_PM_BarCodeMissing.procedureID||',' )>0 ";
  1059. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  1060. }
  1061. // 漏扫工序
  1062. if (!string.IsNullOrEmpty(se.MissingProcedureIDS))
  1063. {
  1064. selSql = selSql + " and instr(',' || :MissingProcedureIDS || ',',','||TP_PM_BarCodeMissing.missProcedureID||',' )>0 ";
  1065. parameters.Add(new OracleParameter(":MissingProcedureIDS", OracleDbType.NVarchar2, se.MissingProcedureIDS, ParameterDirection.Input));
  1066. }
  1067. // 产品IDS
  1068. if (!string.IsNullOrEmpty(se.GoodsIDS))
  1069. {
  1070. selSql = selSql + " and instr(',' || :GoodsIDS || ',',','||TP_PM_BarCodeMissing.goodsID||',' )>0 ";
  1071. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  1072. }
  1073. // 产品IDS
  1074. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  1075. {
  1076. selSql = selSql + " and instr(',' || :GoodsTypeIDS || ',',','||TP_PM_BarCodeMissing.goodsTypeID||',' )>0 ";
  1077. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  1078. }
  1079. // 校验时间--开始
  1080. if (se.beginCreateTime.HasValue)
  1081. {
  1082. selSql = selSql + " and TP_PM_BarCodeMissing.CreateTime>= :CreateTimeStart ";
  1083. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  1084. }
  1085. // 校验时间--结束
  1086. if (se.endCreateTime.HasValue)
  1087. {
  1088. selSql = selSql + " and TP_PM_BarCodeMissing.CreateTime<= :CreateTimeEnd ";
  1089. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.endCreateTime.Value, ParameterDirection.Input));
  1090. }
  1091. selSql = selSql +
  1092. // " order by missprocedureid,username " +
  1093. " ) " +
  1094. " group by rollup( " +
  1095. " GoodsType, " +
  1096. " MissProcedureID, " +
  1097. " MissProcedureCode, " +
  1098. " MissProcedureName, " +
  1099. " MissID, " +
  1100. " BarCode, " +
  1101. " OrganizationID, " +
  1102. " OrganizationName, " +
  1103. " OrganizationCode, " +
  1104. " OrganizationFullName, " +
  1105. " CompleteProcedureID, " +
  1106. " CompleteProcedureCode, " +
  1107. " CompleteProcedureName, " +
  1108. " ProcedureID, " +
  1109. " ProcedureCode, " +
  1110. " ProcedureName, " +
  1111. " GoodsID, " +
  1112. " GoodsCode, " +
  1113. " GoodsName, " +
  1114. " GoodsTypeID, " +
  1115. " CreateTime, " +
  1116. " GoodsTypeName,MissUserCode, " +
  1117. " UserName ) " +
  1118. " ) " +
  1119. " where UserName!='--' or " +
  1120. " (USERNAME='--' and missprocedurename='小计'and missprocedurecode='--' and missprocedureid!='--' ) " +
  1121. " or " +
  1122. " (USERNAME='--' and missprocedureid='--' and GoodsType!='合计') " +
  1123. " ) result left join TP_MST_GoodsType on result.GoodsType=TP_MST_GoodsType.GoodsTypeCode"
  1124. + " ) order by seqno";
  1125. */
  1126. #endregion
  1127. string selSql = "select decode(tt.gid, 0, tt.MissID, null) MissID, --漏扫ID\n" +
  1128. " decode(tt.gid, 7, '总计', 0, tt.BarCode, '--') BarCode, --产品条码\n" +
  1129. " --decode(tt.gid, 0, tt.OrganizationID, null) OrganizationID,\n" +
  1130. " --decode(tt.gid, 0, tt.OrganizationCode, '--') OrganizationCode,\n" +
  1131. " decode(tt.gid, 0, tt.OrganizationName, '--') OrganizationName, --漏扫部门\n" +
  1132. " --decode(tt.gid, 0, tt.OrganizationFullName, '--') OrganizationFullName,\n" +
  1133. " --decode(tt.gid, 0, tt.CompleteProcedureID, null) CompleteProcedureID,\n" +
  1134. " --decode(tt.gid, 0, tt.CompleteProcedureCode, '--') CompleteProcedureCode,\n" +
  1135. " decode(tt.gid, 0, tt.CompleteProcedureName, '--') CompleteProcedureName,\n" +
  1136. " --decode(tt.gid, 0, tt.ProcedureID, null) ProcedureID,\n" +
  1137. " --decode(tt.gid, 0, tt.ProcedureCode, '--') ProcedureCode,\n" +
  1138. " decode(tt.gid, 0, tt.ProcedureName, '--') ProcedureName,\n" +
  1139. " --decode(tt.gid, 0, tt.MissProcedureID, null) MissProcedureID,\n" +
  1140. " --decode(tt.gid, 0, tt.MissProcedureCode, '--') MissProcedureCode,\n" +
  1141. " decode(tt.gid, 1, '小计', 0, tt.MissProcedureName, '--') MissProcedureName,\n" +
  1142. " decode(tt.gid, 0, tt.GoodsID, null) GoodsID,\n" +
  1143. " decode(tt.gid, 0, tt.GoodsCode, '--') GoodsCode,\n" +
  1144. " decode(tt.gid, 0, tt.GoodsName, '--') GoodsName,\n" +
  1145. " decode(tt.gid, 0, tt.GoodsTypeID, null) GoodsTypeID,\n" +
  1146. " decode(tt.gid, 0, tt.MissUserID, null) MissUserID,\n" +
  1147. " decode(tt.gid, 0, tt.MissUserCode, '--') MissUserCode,\n" +
  1148. " decode(tt.gid, 0, tt.CreateTime, null) CreateTime,\n" +
  1149. " decode(tt.gid, 0, tt.CreateUserID, null) CreateUserID,\n" +
  1150. " decode(tt.gid, 0, tt.username, '--') username,\n" +
  1151. " decode(tt.gid, 0, tt.repaircode, '--') repaircode,\n" +
  1152. " decode(tt.gid, 0, tt.prepaircode, '--') prepaircode,\n" +
  1153. " decode(tt.gid, 3, '合计', 0, tt.goodstypename2, '--') goodstype,\n" +
  1154. " tt.barcodecount, --数量\n" +
  1155. " tt.LogoCodeName\n" +
  1156. " from (select grouping_id(t.goodstypename2, --产品大类\n" +
  1157. " --t.MissProcedureCode,\n" +
  1158. " t.MissProcedureName,\n" +
  1159. " t.MissID) gid,\n" +
  1160. " t.MissID, --漏扫ID\n" +
  1161. " t.BarCode, --产品条码\n" +
  1162. " --t.OrganizationID,\n" +
  1163. " --t.OrganizationCode,\n" +
  1164. " t.OrganizationName, --漏扫部门\n" +
  1165. " --t.OrganizationFullName,\n" +
  1166. " --t.CompleteProcedureID,\n" +
  1167. " --t.CompleteProcedureCode,\n" +
  1168. " t.CompleteProcedureName, --完成工序\n" +
  1169. " --t.ProcedureID,\n" +
  1170. " --t.ProcedureCode,\n" +
  1171. " t.ProcedureName, --校验工序\n" +
  1172. " --t.MissProcedureID,\n" +
  1173. " --t.MissProcedureCode,\n" +
  1174. " t.MissProcedureName, --漏扫工序\n" +
  1175. " t.GoodsID,\n" +
  1176. " t.GoodsCode, --产品编码\n" +
  1177. " t.GoodsName, --产品名称\n" +
  1178. " t.GoodsTypeID,\n" +
  1179. " t.MissUserID,\n" +
  1180. " t.MissUserCode, --漏扫工号\n" +
  1181. " t.CreateTime, --校验漏扫时间\n" +
  1182. " t.CreateUserID,\n" +
  1183. " t.username, --校验者\n" +
  1184. " t.repaircode, --补扫操作工号\n" +
  1185. " t.prepaircode, --补扫生产工号\n" +
  1186. " t.goodstypename2, --产品大类\n" +
  1187. " count(t.barcodecount) barcodecount, --数量\n" +
  1188. " t.LogoCodeName\n" +
  1189. " from (select bcm.MissID, --漏扫ID\n" +
  1190. " bcm.BarCode, --产品条码\n" +
  1191. " --bcm.OrganizationID,\n" +
  1192. " --bcm.OrganizationCode,\n" +
  1193. " bcm.OrganizationName, --漏扫部门\n" +
  1194. " --bcm.OrganizationFullName,\n" +
  1195. " --bcm.CompleteProcedureID,\n" +
  1196. " --bcm.CompleteProcedureCode,\n" +
  1197. " --bcm.CompleteProcedureName, --完成工序\n" +
  1198. " cedp.ProcedureName as CompleteProcedureName, --完成工序\n" +
  1199. " --bcm.ProcedureID,\n" +
  1200. " --bcm.ProcedureCode,\n" +
  1201. " --bcm.ProcedureName, --校验工序\n" +
  1202. " cp.ProcedureName, --校验工序\n" +
  1203. " --bcm.MissProcedureID,\n" +
  1204. " --bcm.MissProcedureCode,\n" +
  1205. " --bcm.MissProcedureName, --漏扫工序\n" +
  1206. " mp.ProcedureName as MissProcedureName, --漏扫工序\n" +
  1207. " bcm.GoodsID,\n" +
  1208. " bcm.GoodsCode, --产品编码\n" +
  1209. " bcm.GoodsName, --产品名称\n" +
  1210. " bcm.GoodsTypeID,\n" +
  1211. " bcm.MissUserID,\n" +
  1212. " bcm.MissUserCode, --漏扫工号\n" +
  1213. " bcm.CreateTime, --校验漏扫时间\n" +
  1214. " bcm.CreateUserID,\n" +
  1215. " u.username, --校验者\n" +
  1216. //" MU.usercode repaircode, --补扫操作工号\n" +
  1217. //" MU.pusercode prepaircode, --补扫生产工号\n" +
  1218. " bcm.ROPUserCode repaircode, --补扫操作工号\n" +
  1219. " bcm.RWorkUserCode prepaircode, --补扫生产工号\n" +
  1220. " gt2.goodstypename goodstypename2, --产品大类\n" +
  1221. " 1 barcodecount, --数量\n" +
  1222. " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName\n" +
  1223. " from TP_PM_BarCodeMissing bcm\n" +
  1224. " left join TP_MST_User u\n" +
  1225. " on bcm.CreateUserID = u.userid\n" +
  1226. " left join TP_MST_GoodsType gt\n" +
  1227. " on bcm.GoodsTypeID = gt.GoodsTypeID\n" +
  1228. " left join TP_MST_GoodsType gt2\n" +
  1229. " on substr(gt.GoodsTypeCode, 1, 6) = gt2.GoodsTypeCode\n" +
  1230. " and gt.accountid = gt2.accountid\n" +
  1231. /*
  1232. //" left join TP_PM_ProductionData PD\n" +
  1233. //" on PD.BarCode = bcm.BarCode\n" +
  1234. //" and PD.ProcedureID = bcm.MissProcedureID\n" +
  1235. //" left join TP_MST_User MU\n" +
  1236. //" on MU.UserID = PD.CreateUserID\n" +
  1237. " left join (select pd.barcode,\n" +
  1238. " pd.procedureid,\n" +
  1239. " pd.usercode pusercode,\n" +
  1240. " mu.usercode,\n" +
  1241. //" pd.usercode,\n" +
  1242. " max(bm.missid) missid\n" +
  1243. //" row_number() over(partition by pd.barcode, pd.procedureid order by pd.productiondataid) rnum\n" +
  1244. " from tp_pm_productiondata pd\n" +
  1245. " inner join tp_pm_barcodemissing bm\n" +
  1246. " on bm.barcode = pd.barcode\n" +
  1247. " and bm.missprocedureid = pd.procedureid\n" +
  1248. " and bm.createtime < pd.createtime\n" +
  1249. " and bm.valueflag ='1'\n" +
  1250. " inner join tp_mst_user mu\n" +
  1251. " on mu.userid = pd.createuserid\n" +
  1252. " where pd.valueflag = '1'\n" +
  1253. " group by pd.barcode, pd.procedureid, pd.usercode, mu.usercode\n" +
  1254. " ) MU\n" +
  1255. " on MU.barcode = bcm.barcode\n" +
  1256. " and MU.procedureid = bcm.missprocedureid\n" +
  1257. " and MU.missid = bcm.missid" +
  1258. //" and MU.rnum = 1" +
  1259. */
  1260. " left join tp_pc_procedure cedp \n" +
  1261. " on cedp.procedureid = bcm.CompleteProcedureID\n" +
  1262. " left join tp_pc_procedure cp \n" +
  1263. " on cp.procedureid = bcm.ProcedureID\n" +
  1264. " left join tp_pc_procedure mp \n" +
  1265. " on mp.procedureid = bcm.MissProcedureID\n" +
  1266. " left join TP_PM_GroutingDailyDetail \n" +
  1267. " on TP_PM_GroutingDailyDetail.barcode = bcm.BarCode\n" +
  1268. " left join tp_mst_logo \n" +
  1269. " on tp_mst_logo.logoid = TP_PM_GroutingDailyDetail.logoid\n" +
  1270. " where bcm.valueflag='1' \n" +
  1271. " and bcm.accountid=:AccountID \n";
  1272. // 产品条码
  1273. if (!string.IsNullOrEmpty(se.Barcode))
  1274. {
  1275. selSql = selSql + " and bcm.barcode=:Barcode ";
  1276. parameters.Add(new OracleParameter(":Barcode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  1277. }
  1278. // 组织结构
  1279. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  1280. {
  1281. selSql = selSql + " and instr(',' || :OrganizationIDS || ',' ,','||bcm.OrganizationID||',' )>0 ";
  1282. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  1283. }
  1284. // 完成工序
  1285. if (!string.IsNullOrEmpty(se.CompleteProcedureIDS))
  1286. {
  1287. selSql = selSql + " and instr(',' || :CompleteProcedureIDS || ',',','||bcm.CompleteProcedureID||',' )>0 ";
  1288. parameters.Add(new OracleParameter(":CompleteProcedureIDS", OracleDbType.NVarchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  1289. }
  1290. // 校验工序
  1291. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  1292. {
  1293. selSql = selSql + " and instr(',' || :ProcedureIDS || ',',','||bcm.procedureID||',' )>0 ";
  1294. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  1295. }
  1296. // 漏扫工序
  1297. if (!string.IsNullOrEmpty(se.MissingProcedureIDS))
  1298. {
  1299. selSql = selSql + " and instr(',' || :MissingProcedureIDS || ',',','||bcm.missProcedureID||',' )>0 ";
  1300. parameters.Add(new OracleParameter(":MissingProcedureIDS", OracleDbType.NVarchar2, se.MissingProcedureIDS, ParameterDirection.Input));
  1301. }
  1302. // 产品IDS
  1303. if (!string.IsNullOrEmpty(se.GoodsIDS))
  1304. {
  1305. selSql = selSql + " and instr(',' || :GoodsIDS || ',',','||bcm.goodsID||',' )>0 ";
  1306. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  1307. }
  1308. // 产品IDS
  1309. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  1310. {
  1311. //selSql = selSql + " and instr(',' || :GoodsTypeIDS || ',',','||gt.goodsTypeCode||',' )=1 ";
  1312. selSql = selSql + " and instr(gt.goodsTypeCode,:GoodsTypeIDS )=1 ";
  1313. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  1314. }
  1315. // 校验时间--开始
  1316. if (se.beginCreateTime.HasValue)
  1317. {
  1318. selSql = selSql + " and bcm.CreateTime>= :CreateTimeStart ";
  1319. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  1320. }
  1321. // 校验时间--结束
  1322. if (se.endCreateTime.HasValue)
  1323. {
  1324. selSql = selSql + " and bcm.CreateTime<= :CreateTimeEnd ";
  1325. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.endCreateTime.Value, ParameterDirection.Input));
  1326. }
  1327. selSql += "\n" +
  1328. //" order by gt2.GoodsTypeCode,bcm.MissProcedureCode,\n" +
  1329. //" --bcm.GoodsCode,\n" +
  1330. //" bcm.BarCode,\n" +
  1331. //" bcm.ProcedureCode,\n" +
  1332. //" bcm.CompleteProcedureCode\n" +
  1333. //" ) t\n" +
  1334. " order by gt2.GoodsTypeCode,mp.ProcedureName,\n" +
  1335. " --bcm.GoodsCode,\n" +
  1336. " bcm.BarCode,\n" +
  1337. " cp.ProcedureName,\n" +
  1338. " cedp.ProcedureName\n" +
  1339. " ) t\n" +
  1340. " group by grouping sets((t.MissID, --漏扫ID\n" +
  1341. " t.BarCode, --产品条码\n" +
  1342. " t.goodstypename2, --产品大类\n" +
  1343. " /*t.OrganizationID, t.OrganizationCode,*/ t.OrganizationName, --漏扫部门\n" +
  1344. " /*t.OrganizationFullName, t.CompleteProcedureID, t.CompleteProcedureCode, t.CompleteProcedureName,*/ t.CompleteProcedureName, --完成工序\n" +
  1345. " /*t.ProcedureID, t.ProcedureCode, t.ProcedureName,*/ t.ProcedureName, --校验工序\n" +
  1346. " /*t.MissProcedureID, t.MissProcedureCode, t.MissProcedureName,*/ t.MissProcedureName, --漏扫工序\n" +
  1347. " t.GoodsID, t.GoodsCode, --产品编码\n" +
  1348. " t.GoodsName, --产品名称\n" +
  1349. " t.GoodsTypeID, t.MissUserID, t.MissUserCode, --漏扫工号\n" +
  1350. " t.CreateTime, --校验漏扫时间\n" +
  1351. " t.CreateUserID, t.username, --校验者\n" +
  1352. " t.repaircode, --补扫工号\n" +
  1353. " t.prepaircode, --补扫工号\n" +
  1354. " t.LogoCodeName --商标\n" +
  1355. " ),(t.goodstypename2, --产品大类\n" +
  1356. " /*t.MissProcedureCode,*/ t.MissProcedureName --漏扫工序\n" +
  1357. " ),(t.goodstypename2 --产品大类\n" +
  1358. " ),())) tt";
  1359. return selSql;
  1360. }
  1361. /// <summary>
  1362. /// 取得RPT010301_1画面(条码变更明细表)的查询数据
  1363. /// </summary>
  1364. /// <param name="user">登录用户信息</param>
  1365. /// <param name="se">查询条件</param>
  1366. /// <returns>查询结果</returns>
  1367. public static ServiceResultEntity GetRPT010301SData(SUserInfo user, RPT010301_SE se)
  1368. {
  1369. IDBConnection conn = null;
  1370. try
  1371. {
  1372. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1373. List<OracleParameter> parameters = new List<OracleParameter>();
  1374. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010301SSQL());
  1375. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  1376. if (se != null)
  1377. {
  1378. // 更换条码时间-开始
  1379. if (se.createTimeBegin.HasValue)
  1380. {
  1381. sql.Append(" and TP_PM_BarCodeRecord.CreateTime>= :CreateTimeBegin ");
  1382. parameters.Add(new OracleParameter(":CreateTimeBegin", OracleDbType.Date, se.createTimeBegin.Value, ParameterDirection.Input));
  1383. }
  1384. // 更换条码时间-结束
  1385. if (se.createTimeEnd.HasValue)
  1386. {
  1387. sql.Append(" and TP_PM_BarCodeRecord.CreateTime<= :CreateTimeEnd ");
  1388. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.createTimeEnd.Value, ParameterDirection.Input));
  1389. }
  1390. //成型线IDS
  1391. if (!string.IsNullOrEmpty(se.Barcode))
  1392. {
  1393. // sql.Append(" and (TP_PM_BarCodeRecord.BARCODE=:Barcode or TP_PM_BarCodeRecord.NEWBARCODE=:Barcode or TP_PM_BarCodeRecord.FIRSTBARCODE=:Barcode or TP_PM_BarCodeRecord.FINALBARCODE=:Barcode )");
  1394. sql.Append(" and (instr(TP_PM_BarCodeRecord.BARCODE,:Barcode)>0 or instr(TP_PM_BarCodeRecord.NEWBARCODE,:Barcode)>0 or instr(TP_PM_BarCodeRecord.FIRSTBARCODE,:Barcode)>0 or instr(TP_PM_BarCodeRecord.FINALBARCODE,:Barcode)>0 )");
  1395. parameters.Add(new OracleParameter(":Barcode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  1396. }
  1397. }
  1398. sql.Append(" ORDER BY TP_PM_BarCodeRecord.CREATETIME ");
  1399. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  1400. ServiceResultEntity sre = new ServiceResultEntity();
  1401. if (data == null || data.Rows.Count == 0)
  1402. {
  1403. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  1404. return sre;
  1405. }
  1406. sre.Data = new DataSet();
  1407. sre.Data.Tables.Add(data);
  1408. return sre;
  1409. }
  1410. catch (Exception ex)
  1411. {
  1412. throw ex;
  1413. }
  1414. finally
  1415. {
  1416. if (conn != null &&
  1417. conn.ConnState == ConnectionState.Open)
  1418. {
  1419. conn.Close();
  1420. }
  1421. }
  1422. }
  1423. /// <summary>
  1424. /// 获取RPT010301_1画面(条码变更明细表)的查询sql
  1425. /// </summary>
  1426. /// <returns>sql</returns>
  1427. private static string GetRPT010301SSQL()
  1428. {
  1429. string selSql =
  1430. " SELECT "
  1431. + " TP_PM_BarCodeRecord.BarCode, "
  1432. + " TP_PM_BarCodeRecord.NewBarCode, "
  1433. + " TP_PM_BarCodeRecord.FirstBarCode, "
  1434. + " TP_PM_BarCodeRecord.FinalBarCode, "
  1435. + " TP_PM_BarCodeRecord.Createtime, "
  1436. + " TP_PM_GROUTINGDAILYDETAIL.GroutingLineCode, "
  1437. + " TP_PM_GROUTINGDAILYDETAIL.GroutingLineName, "
  1438. + " TP_MST_GMouldType.Gmouldtypename, "
  1439. + " TP_PM_GROUTINGDAILYDETAIL.GroutingDate, "
  1440. + " TP_PM_GROUTINGDAILYDETAIL.GroutingMouldCode, "
  1441. + " TP_PM_GROUTINGDAILYDETAIL.MouldCode, "
  1442. + " TP_PM_GROUTINGDAILYDETAIL.UserCode GroutingUserCode, "
  1443. + " TP_PM_GROUTINGDAILYDETAIL.GroutingCount , "
  1444. + " TP_PM_GROUTINGDAILYDETAIL.GoodsCode, "
  1445. + " TP_PM_GROUTINGDAILYDETAIL.GoodsName, "
  1446. + " TP_PC_PROCEDURE.PROCEDURECODE, "
  1447. + " TP_PC_PROCEDURE.PROCEDURENAME, "
  1448. // 成型班长
  1449. + " mu.username as MONITORName,"
  1450. + " TP_MST_USER.USERNAME, "
  1451. + " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName "
  1452. + " from TP_PM_BarCodeRecord "
  1453. + " left join TP_PM_GROUTINGDAILYDETAIL on TP_PM_BarCodeRecord.FinalBarCode=TP_PM_GROUTINGDAILYDETAIL.Barcode "
  1454. + " inner join TP_PC_GroutingLine on TP_PC_GroutingLine.GroutingLineID=TP_PM_GroutingDailyDetail.GroutingLineID "
  1455. // 成型班长
  1456. + " LEFT JOIN tp_mst_user mu" +
  1457. " ON mu.userid = TP_PC_GroutingLine.MONITORID"
  1458. + " inner join TP_MST_GMouldType on TP_MST_GMouldType.GMOULDTYPEID=TP_PC_GroutingLine.GMOULDTYPEID "
  1459. + " left join TP_PC_PROCEDURE on TP_PM_BarCodeRecord.Procedureid=TP_PC_PROCEDURE.PROCEDUREID "
  1460. + " left join TP_MST_USER ON TP_PM_BarCodeRecord.CreateUserID=TP_MST_USER.USERID "
  1461. + " left join TP_MST_logo ON TP_MST_logo.logoid=TP_PM_GROUTINGDAILYDETAIL.logoid "
  1462. + " where TP_PM_GROUTINGDAILYDETAIL.ACCOUNTID=:AccountID ";
  1463. return selSql;
  1464. }
  1465. /// <summary>
  1466. /// 取得RPT010401画面(在产品明细表)的查询数据
  1467. /// </summary>
  1468. /// <param name="user">登录用户信息</param>
  1469. /// <param name="se">查询条件</param>
  1470. /// <returns>查询结果</returns>
  1471. public static ServiceResultEntity GetRPT010401SData(SUserInfo user, RPT010401_SE se)
  1472. {
  1473. IDBConnection conn = null;
  1474. try
  1475. {
  1476. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1477. List<OracleParameter> parameters = new List<OracleParameter>();
  1478. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010401SSQL());
  1479. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  1480. if (se != null)
  1481. {
  1482. // 条码
  1483. if (!string.IsNullOrEmpty(se.Barcode))
  1484. {
  1485. //sql.Append(" AND TP_PM_InProduction.BarCode=:Barcode ");
  1486. sql.Append(" AND instr(TP_PM_InProduction.BarCode,:Barcode)>0 ");
  1487. parameters.Add(new OracleParameter(":Barcode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  1488. }
  1489. // 产品IDS
  1490. if (!string.IsNullOrEmpty(se.GoodsIDS))
  1491. {
  1492. sql.Append(" AND instr(','||:GoodsIDS||',',','||TP_PM_InProduction.GoodsId||',')>0 ");
  1493. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  1494. }
  1495. //生产线IDS
  1496. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  1497. {
  1498. sql.Append(" AND instr(','||:ProductionLineIDS||',',','||TP_PM_InProduction.ProductionLineID||',')>0 ");
  1499. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  1500. }
  1501. //完成工序IDS
  1502. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  1503. {
  1504. sql.Append(" AND instr(','||:ProcedureIDS||',',','||TP_PM_InProduction.ProcedureID||',')>0 ");
  1505. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  1506. }
  1507. //生产工号IDS
  1508. if (!string.IsNullOrEmpty(se.UserIDS))
  1509. {
  1510. sql.Append(" AND instr(','||:UserIDS||',',','||TP_PM_InProduction.UserID||',')>0 ");
  1511. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  1512. }
  1513. // 成型线IDS
  1514. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  1515. {
  1516. sql.Append(" AND instr(','||:GroutingLineIDS||',',','||TP_PM_InProduction.GroutingLineID||',')>0 ");
  1517. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  1518. }
  1519. // 成型线类型IDS
  1520. if (!string.IsNullOrEmpty(se.GMouldTypeIDS))
  1521. {
  1522. sql.Append(" AND instr(','||:GMouldTypeIDS||',',','||TP_PM_InProduction.GMouldTypeID||',')>0 ");
  1523. parameters.Add(new OracleParameter(":GMouldTypeIDS", OracleDbType.NVarchar2, se.GMouldTypeIDS, ParameterDirection.Input));
  1524. }
  1525. // 交坯时间--开始
  1526. if (se.CreateTimeStart.HasValue)
  1527. {
  1528. sql.Append(" AND TP_PM_GroutingDailyDetail.delivertime >= :CreateTimeStart ");
  1529. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  1530. }
  1531. // 交坯时间--结束
  1532. if (se.CreateTimeEnd.HasValue)
  1533. {
  1534. sql.Append(" AND TP_PM_GroutingDailyDetail.delivertime <= :CreateTimeEnd ");
  1535. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  1536. }
  1537. // 完成时间--开始
  1538. if (se.UpdateTimeStart.HasValue)
  1539. {
  1540. sql.Append(" AND TP_PM_InProduction.Proceduretime >= :UpdateTimeStart ");
  1541. parameters.Add(new OracleParameter(":UpdateTimeStart", OracleDbType.Date, se.UpdateTimeStart.Value, ParameterDirection.Input));
  1542. }
  1543. // 完成时间--结束
  1544. if (se.UpdateTimeEnd.HasValue)
  1545. {
  1546. sql.Append(" AND TP_PM_InProduction.Proceduretime <= :UpdateTimeEnd ");
  1547. parameters.Add(new OracleParameter(":UpdateTimeEnd", OracleDbType.Date, se.UpdateTimeEnd.Value, ParameterDirection.Input));
  1548. }
  1549. if (se.inscrapflag != 2)
  1550. {
  1551. sql.Append(" AND TP_PM_InProduction.inscrapflag=:inscrapflag ");
  1552. parameters.Add(new OracleParameter(":inscrapflag", OracleDbType.NVarchar2, se.inscrapflag, ParameterDirection.Input));
  1553. }
  1554. if (!string.IsNullOrWhiteSpace(se.GoodsTypeCode))
  1555. {
  1556. sql.Append(" AND instr(gt.goodstypecode, :GoodsTypeCode) = 1 ");
  1557. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  1558. }
  1559. }
  1560. sql.Append(" order by TP_PM_InProduction.UpdateTime desc");
  1561. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  1562. ServiceResultEntity sre = new ServiceResultEntity();
  1563. if (data == null || data.Rows.Count == 0)
  1564. {
  1565. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  1566. return sre;
  1567. }
  1568. sre.Data = new DataSet();
  1569. sre.Data.Tables.Add(data);
  1570. return sre;
  1571. }
  1572. catch (Exception ex)
  1573. {
  1574. throw ex;
  1575. }
  1576. finally
  1577. {
  1578. if (conn != null &&
  1579. conn.ConnState == ConnectionState.Open)
  1580. {
  1581. conn.Close();
  1582. }
  1583. }
  1584. }
  1585. /// <summary>
  1586. /// 获取RPT010401画面(在产品明细表)的查询sql
  1587. /// </summary>
  1588. /// <returns>sql</returns>
  1589. private static string GetRPT010401SSQL()
  1590. {
  1591. string selSql =
  1592. "SELECT " +
  1593. " TP_PM_InProduction.BarCode, " +
  1594. " TP_PM_InProduction.GoodsID,TP_PM_InProduction.GoodsCode, " +
  1595. " TP_PM_InProduction.GoodsName, gt.goodstypename," +
  1596. " TP_PM_InProduction.Userid,A.USERNAME as UserName,A.USERCode as UserCode, " +
  1597. " TP_PM_InProduction.ProductionLineID, " +
  1598. " TP_PM_InProduction.ProductionLineCode, " +
  1599. " TP_PM_InProduction.ProductionLineName, " +
  1600. " TP_PM_InProduction.ModelType, " +
  1601. " decode(TP_PM_InProduction.inscrapflag , '1', '待审核的报废品' , '正常') as inscrapflag, " +
  1602. //" decode(TP_PM_InProduction.IsPublicBody, '1', '是' , '否') as IsPublicBody, " +
  1603. " TP_PM_InProduction.IsPublicBody, " +
  1604. //" decode(TP_PM_InProduction.IsReFire, '1', '是' , '否') as IsReFire, " +
  1605. " decode(TP_PM_InProduction.IsReFire, '6', '1' , '0') as IsReFire, " +
  1606. " TP_PM_InProduction.IsReworkFlag, " +
  1607. " decode(TP_PM_InProduction.CanManyTimes, '1', '能' , '不能') as CanManyTimes, " +
  1608. " decode(TP_PM_InProduction.ProcedureModel, '1', '计件模型' , '检验模型') as ProcedureModel, " +
  1609. " TP_PM_InProduction.GroutingDailyID, " +
  1610. " TP_PM_InProduction.GroutingDailyDetailID, " +
  1611. " TP_PM_InProduction.GroutingDate, " +
  1612. " TP_PM_InProduction.GroutingLineID, " +
  1613. " TP_PM_InProduction.GroutingLineCode, " +
  1614. " TP_PM_InProduction.GroutingLineName, " +
  1615. " TP_PM_InProduction.KILNCODE, " +
  1616. " TP_PM_InProduction.KILNCARCODE, " +
  1617. " TP_PM_InProduction.ProcedureID CompleteProcedureID, " +
  1618. " D.ProcedureName as CompleteProcedureName, " +
  1619. " TP_PM_InProduction.GMouldTypeID, " +
  1620. " TP_MST_GMouldType.GMOULDTYPENAME as GMouldTypeName, " +
  1621. " TP_PM_InProduction.GroutingLineDetailID, " +
  1622. " TP_PM_InProduction.GroutingMouldCode, " +
  1623. " TP_PM_InProduction.SPECIALREPAIRFLAG, " +
  1624. " TP_PM_InProduction.GROUTINGUSERCODE, " +
  1625. " TP_PM_GroutingDailyDetail.GROUTINGCOUNT, " +
  1626. " TP_PM_GroutingDailyDetail.GROUTINGBATCHNO, " +
  1627. " TP_PM_GroutingDailyDetail.delivertime, " +
  1628. " TP_PM_InProduction.proceduretime, " +
  1629. " TP_PM_InProduction.Remarks, " +
  1630. " TP_PM_InProduction.GoodsLevelID,TP_MST_GoodsLevel.GOODSLEVELNAME, " +
  1631. " TP_PM_InProduction.GoodsLevelTypeID,TP_SYS_GoodsLevelType.GOODSLEVELTYPENAME, " +
  1632. " TP_PM_InProduction.AccountID,TP_PM_InProduction.ValueFlag, " +
  1633. " TP_PM_GroutingDailyDetail.glazingroom," +
  1634. " TP_PM_InProduction.CreateTime,TP_PM_InProduction.CreateUserID,B.USERNAME as CreateUserName, " +
  1635. " TP_PM_InProduction.PROCEDURETIME AS UpdateTime,TP_PM_InProduction.UpdateUserID,C.USERNAME as UpdateUserName, " +
  1636. " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName, " +
  1637. //" (Goods.MaterialCode || TP_MST_Logo.tagcode || TP_PM_GroutingDailyDetail.onlycode) as FinishedBarCode " +
  1638. " nvl(TP_PM_GroutingDailyDetail.outlabelcode, TP_PM_GroutingDailyDetail.MaterialCode || (select a.workcode from tp_mst_account a where a.accountid = TP_PM_GroutingDailyDetail.accountid) || TP_MST_Logo.tagcode || TP_PM_GroutingDailyDetail.onlycode) as FinishedBarCode " +
  1639. "FROM TP_PM_InProduction " +
  1640. " inner join TP_MST_User A on A.UserID=TP_PM_InProduction.Userid " +
  1641. " inner join TP_MST_User B on B.UserID=TP_PM_InProduction.CreateUserID " +
  1642. " inner join TP_MST_User C on C.UserID=TP_PM_InProduction.UpdateUserID " +
  1643. " inner join TP_PC_Procedure D on D.PROCEDUREID=TP_PM_InProduction.ProcedureID " +
  1644. " inner join TP_MST_GMouldType on TP_MST_GMouldType.GMouldTypeID=TP_PM_InProduction.GMouldTypeID " +
  1645. " inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.ProcedureModelTypeID=TP_PM_InProduction.ModelType " +
  1646. " inner join TP_PM_GroutingDaily on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_InProduction.GroutingDailyID " +
  1647. " inner join TP_PM_GroutingDailyDetail on TP_PM_GroutingDailyDetail.Groutingdailydetailid=TP_PM_InProduction.GroutingDailyDetailID " +
  1648. " inner join TP_PC_GroutingLineDetail on TP_PC_GroutingLineDetail.Groutinglinedetailid=TP_PM_InProduction.GroutingLineDetailID " +
  1649. " inner join TP_MST_Account on TP_MST_Account.Accountid=TP_PM_InProduction.Accountid " +
  1650. " left join TP_MST_GoodsLevel on TP_MST_GoodsLevel.GoodsLevelID=TP_PM_InProduction.GoodsLevelID " +
  1651. " left join TP_SYS_GoodsLevelType on TP_SYS_GoodsLevelType.GoodsLevelTypeID=TP_PM_InProduction.GoodsLevelTypeID " +
  1652. " left join TP_MST_Logo on TP_PM_InProduction.logoid=TP_MST_Logo.logoid " +
  1653. " left join TP_MST_Goods Goods on TP_PM_InProduction.GoodsID=Goods.GoodsID " +
  1654. " left join tp_mst_goodstype gt on gt.goodstypeid = Goods.goodstypeid " +
  1655. " Where TP_PM_InProduction.ValueFlag = 1 " +
  1656. " and TP_PM_InProduction.AccountID=:AccountID ";
  1657. return selSql;
  1658. }
  1659. /// <summary>
  1660. /// 取得RPT010402画面(产成品明细表)的查询数据
  1661. /// </summary>
  1662. /// <param name="user">登录用户信息</param>
  1663. /// <param name="se">查询条件</param>
  1664. /// <returns>查询结果</returns>
  1665. public static ServiceResultEntity GetRPT010402SData(SUserInfo user, RPT010402_SE se)
  1666. {
  1667. IDBConnection conn = null;
  1668. try
  1669. {
  1670. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1671. List<OracleParameter> parameters = new List<OracleParameter>();
  1672. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010402SSQL());
  1673. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  1674. if (se != null)
  1675. {
  1676. // 条码
  1677. if (!string.IsNullOrEmpty(se.Barcode))
  1678. {
  1679. //sql.Append(" AND TP_PM_FinishedProduct.BarCode=:BarCode ");
  1680. sql.Append(" AND instr(TP_PM_FinishedProduct.BarCode,:Barcode)>0 ");
  1681. parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  1682. }
  1683. // 产品IDS
  1684. if (!string.IsNullOrEmpty(se.GoodsIDS))
  1685. {
  1686. sql.Append(" AND instr(','||:GoodsIDS||',',','||TP_PM_FinishedProduct.GoodsId||',')>0 ");
  1687. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  1688. }
  1689. // 生产线IDS
  1690. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  1691. {
  1692. sql.Append(" AND instr(','||:ProductionLineIDS||',',','||TP_PM_FinishedProduct.ProductionLineID||',')>0 ");
  1693. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  1694. }
  1695. // 成型线ids
  1696. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  1697. {
  1698. sql.Append(" AND instr(','||:GroutingLineIDS||',',','||TP_PM_FinishedProduct.GroutingLineID||',')>0 ");
  1699. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  1700. }
  1701. // 成型线类型ids
  1702. if (!string.IsNullOrEmpty(se.GMouldTypeIDS))
  1703. {
  1704. sql.Append(" AND instr(','||:GMouldTypeIDS||',',','||TP_PM_FinishedProduct.GMouldTypeID||',')>0 ");
  1705. parameters.Add(new OracleParameter(":GMouldTypeIDS", OracleDbType.NVarchar2, se.GMouldTypeIDS, ParameterDirection.Input));
  1706. }
  1707. // 财务日期--开始
  1708. if (se.AccountDateStart.HasValue)
  1709. {
  1710. //sql.Append(" AND TP_PM_FinishedProduct.AccountDate >= :AccountDateStart ");
  1711. sql.Append(" AND TP_PM_FinishedProduct.CreateTime >= :AccountDateStart ");
  1712. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  1713. }
  1714. // 财务日期--结束
  1715. if (se.AccountDateEnd.HasValue)
  1716. {
  1717. //sql.Append(" AND TP_PM_FinishedProduct.AccountDate <= :AccountDateEnd ");
  1718. sql.Append(" AND TP_PM_FinishedProduct.CreateTime <= :AccountDateEnd ");
  1719. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  1720. }
  1721. // 注浆时间--开始
  1722. if (se.CreateTimeStart.HasValue)
  1723. {
  1724. sql.Append(" AND TP_PM_GroutingDaily.CreateTime >= :CreateTimeStart ");
  1725. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  1726. }
  1727. // 注浆时间--结束
  1728. if (se.CreateTimeEnd.HasValue)
  1729. {
  1730. sql.Append(" AND TP_PM_GroutingDaily.CreateTime <= :CreateTimeEnd ");
  1731. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  1732. }
  1733. }
  1734. sql.Append(" order by TP_PM_FinishedProduct.UpdateTime desc");
  1735. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  1736. ServiceResultEntity sre = new ServiceResultEntity();
  1737. if (data == null || data.Rows.Count == 0)
  1738. {
  1739. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  1740. return sre;
  1741. }
  1742. sre.Data = new DataSet();
  1743. sre.Data.Tables.Add(data);
  1744. return sre;
  1745. }
  1746. catch (Exception ex)
  1747. {
  1748. throw ex;
  1749. }
  1750. finally
  1751. {
  1752. if (conn != null &&
  1753. conn.ConnState == ConnectionState.Open)
  1754. {
  1755. conn.Close();
  1756. }
  1757. }
  1758. }
  1759. /// <summary>
  1760. /// 获取RPT010402画面(产成品明细表)的查询sql
  1761. /// </summary>
  1762. /// <returns>sql</returns>
  1763. private static string GetRPT010402SSQL()
  1764. {
  1765. string selSql =
  1766. "SELECT " +
  1767. " TP_PM_FinishedProduct.BarCode, " +
  1768. " TP_PM_FinishedProduct.GoodsID, " +
  1769. " TP_PM_FinishedProduct.GoodsCode, " +
  1770. " TP_PM_FinishedProduct.GoodsName, " +
  1771. " TP_PM_FinishedProduct.ProductionLineID, " +
  1772. " TP_PM_FinishedProduct.ProductionLineCode, " +
  1773. " TP_PM_FinishedProduct.ProductionLineName, " +
  1774. //" decode(TP_PM_FinishedProduct.IsPublicBody, '1', '是' , '否') as IsPublicBody, " +
  1775. //" decode(TP_PM_FinishedProduct.IsReFire, '1', '是' , '否') as IsReFire, " +
  1776. " TP_PM_FinishedProduct.IsPublicBody, " +
  1777. " decode(TP_PM_FinishedProduct.IsReFire, '6', '1' , '0') as IsReFire, " +
  1778. " decode(TP_PM_GroutingDaily.CanManyTimes, '1', '是' , '否') as CanManyTimes, " +
  1779. " decode(TP_PM_FinishedProduct.SettlementFlag, '1', '已结算' , '未结算') as SettlementFlag, " +
  1780. " TP_PM_FinishedProduct.GroutingDailyID, " +
  1781. " TP_PM_FinishedProduct.GroutingDailyDetailID, " +
  1782. " TP_PM_FinishedProduct.GroutingDate, " +
  1783. " TP_PM_FinishedProduct.GroutingLineID, " +
  1784. " TP_PM_FinishedProduct.GroutingLineCode," +
  1785. " TP_PM_FinishedProduct.GroutingLineName, " +
  1786. " TP_PM_FinishedProduct.GMouldTypeID, " +
  1787. " TP_MST_GMouldType.GMOULDTYPENAME as GMouldTypeName, " +
  1788. " TP_PM_FinishedProduct.GroutingLineDetailID, " +
  1789. " TP_PM_FinishedProduct.GroutingMouldCode," +
  1790. " TP_PM_GroutingDailyDetail.GROUTINGCOUNT," +
  1791. " TP_PM_FinishedProduct.GROUTINGUSERCODE," +
  1792. " TP_PM_FinishedProduct.SPECIALREPAIRFLAG," +
  1793. " TP_PM_FinishedProduct.KILNID," +
  1794. " TP_PM_FinishedProduct.KILNCODE," +
  1795. " TP_PM_FinishedProduct.KILNNAME," +
  1796. " TP_PM_FinishedProduct.KILNCARID," +
  1797. " TP_PM_FinishedProduct.KILNCARCODE," +
  1798. " TP_PM_FinishedProduct.KILNCARNAME," +
  1799. " TP_MST_DATADICTIONARY.DICTIONARYVALUE KILNCARPOSITION," +
  1800. " TP_PM_FinishedProduct.MouldCode, " +
  1801. " TP_PM_FinishedProduct.Remarks, " +
  1802. " TP_PM_FinishedProduct.GoodsLevelID,TP_MST_GoodsLevel.GOODSLEVELNAME, " +
  1803. " TP_PM_FinishedProduct.GoodsLevelTypeID, " +
  1804. " TP_SYS_GoodsLevelType.GOODSLEVELTYPENAME, " +
  1805. " TP_PM_FinishedProduct.FHUSERCODE, " +
  1806. " TP_PM_FinishedProduct.FHTIME, " +
  1807. " odr.ORDERNO, " +
  1808. " TP_PM_FinishedProduct.AccountID, " +
  1809. " TP_PM_FinishedProduct.ValueFlag, " +
  1810. " TP_PM_FinishedProduct.AccountDate, " +
  1811. " TP_PM_FinishedProduct.CreateTime, " +
  1812. " TP_PM_FinishedProduct.CreateUserID, " +
  1813. " B.USERNAME as CreateUserName, " +
  1814. " TP_PM_FinishedProduct.UpdateTime, " +
  1815. " TP_PM_FinishedProduct.UpdateUserID, " +
  1816. " C.USERNAME as UpdateUserName, " +
  1817. " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName," +
  1818. " TP_PM_GroutingDailyDetail.Materialcode," +
  1819. //" (Goods.MaterialCode || tp_mst_logo.tagcode || TP_PM_GroutingDailyDetail.onlycode) as FinishedBarCode " +
  1820. " TP_PM_GroutingDailyDetail.outlabelcode as FinishedBarCode " +
  1821. " FROM TP_PM_FinishedProduct " +
  1822. " left join TP_PM_ORDER odr on odr.ORDERID=TP_PM_FinishedProduct.FHORDERID " +
  1823. " left join TP_MST_User B on B.UserID=TP_PM_FinishedProduct.CreateUserID " +
  1824. " left join TP_MST_User C on C.UserID=TP_PM_FinishedProduct.UpdateUserID " +
  1825. " left join TP_MST_GMouldType on TP_MST_GMouldType.GMouldTypeID=TP_PM_FinishedProduct.GMouldTypeID " +
  1826. " left join TP_MST_DATADICTIONARY on TP_PM_FinishedProduct.KILNCARPOSITION=TP_MST_DATADICTIONARY.DICTIONARYID " +
  1827. " left join TP_PM_GroutingDaily on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_FinishedProduct.GroutingDailyID " +
  1828. " left join TP_PM_GroutingDailyDetail on TP_PM_GroutingDailyDetail.Groutingdailydetailid=TP_PM_FinishedProduct.GroutingDailyDetailID " +
  1829. " left join TP_PC_GroutingLineDetail on TP_PC_GroutingLineDetail.Groutinglinedetailid=TP_PM_FinishedProduct.GroutingLineDetailID " +
  1830. " left join TP_MST_Account on TP_MST_Account.Accountid=TP_PM_FinishedProduct.Accountid " +
  1831. " left join TP_MST_GoodsLevel on TP_MST_GoodsLevel.GOODSLEVELID=TP_PM_FinishedProduct.GoodsLevelID " +
  1832. " left join TP_SYS_GoodsLevelType on TP_SYS_GoodsLevelType.GoodsLevelTypeID=TP_PM_FinishedProduct.GoodsLevelTypeID " +
  1833. " left join tp_mst_logo on TP_PM_FinishedProduct.logoid=tp_mst_logo.logoid " +
  1834. " left join TP_MST_Goods Goods on TP_PM_FinishedProduct.GoodsID=Goods.GoodsID " +
  1835. " Where 1=1 and TP_PM_FinishedProduct.ValueFlag = 1 " +
  1836. " and TP_PM_FinishedProduct.AccountID=:AccountID ";
  1837. return selSql;
  1838. }
  1839. /// <summary>
  1840. /// 取得RPT010403画面(生产数据明细表)的查询数据
  1841. /// </summary>
  1842. /// <param name="user">登录用户信息</param>
  1843. /// <param name="se">查询条件</param>
  1844. /// <returns>查询结果</returns>
  1845. public static ServiceResultEntity GetRPT010403SData(SUserInfo user, RPT010403_SE se)
  1846. {
  1847. IDBConnection conn = null;
  1848. try
  1849. {
  1850. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  1851. List<OracleParameter> parameters = new List<OracleParameter>();
  1852. string sqlString =
  1853. "SELECT *\n" +
  1854. " FROM (SELECT pd.barcode\n" +
  1855. " ,gt2.goodstypename as goodstypename2\n" +
  1856. " ,gt.goodstypename\n" +
  1857. " ,g.goodscode\n" +
  1858. " ,PD.ProductionLineName\n" +
  1859. " ,to_char(p.ProcedureName) AS ProcedureName\n" +
  1860. " ,op.organizationfullname AS porgname\n" +
  1861. " ,pd.CreateTime\n" +
  1862. " ,PD.UserCode\n" +
  1863. " ,cu.Usercode AS CreateUsercode\n" +
  1864. " ,cu.Username AS CreateUserName\n" +
  1865. " ,co.organizationfullname corgname\n" +
  1866. " , CASE\n" +
  1867. " WHEN PD.valueflag = '0' AND PD.ProcedureModel = '1' THEN\n" +
  1868. " '撤销(['|| to_char(bu.usercode) || ']' || to_char(bu.username) || ' ' ||\n" +
  1869. " to_char(PD.Backouttime, 'yyyy-mm-dd hh24:mi:ss') || ')'\n" +
  1870. " WHEN PD.valueflag = '0' AND PD.ProcedureModel = '2' THEN\n" +
  1871. " to_char(GL.GOODSLEVELNAME) || '(被修改)'\n" +
  1872. " ELSE\n" +
  1873. " to_char(GL.GOODSLEVELNAME)\n" +
  1874. " END || CASE\n" +
  1875. " WHEN pd.modeltype = 1 THEN\n" +
  1876. " '[' || to_char(pd.kilncarcode) || ']'\n" +
  1877. " ELSE\n" +
  1878. " ''\n" +
  1879. " END GOODSLEVELNAME\n" +
  1880. " ,gdd.glazingroom" +
  1881. " FROM TP_PM_ProductionData PD\n" +
  1882. " INNER JOIN tp_pc_procedure p\n" +
  1883. " ON p.procedureid = pd.procedureid\n" +
  1884. " LEFT JOIN tp_mst_goods g\n" +
  1885. " ON g.goodsid = pd.goodsid\n" +
  1886. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  1887. " ON gdd.Groutingdailydetailid = pd.Groutingdailydetailid\n" +
  1888. " LEFT JOIN tp_mst_goodstype gt\n" +
  1889. " ON gt.goodstypeid = g.goodstypeid\n" +
  1890. " LEFT JOIN tp_mst_goodstype gt2\n" +
  1891. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  1892. " AND gt2.AccountID = :AccountID\n" +
  1893. " INNER JOIN tp_mst_organization op\n" +
  1894. " ON op.organizationid = p.organizationid\n" +
  1895. " INNER JOIN tp_mst_user cu\n" +
  1896. " ON cu.userid = PD.Createuserid\n" +
  1897. " INNER JOIN tp_mst_organization co\n" +
  1898. " ON co.organizationid = cu.organizationid\n" +
  1899. " LEFT JOIN tp_mst_user bu\n" +
  1900. " ON bu.userid = PD.Backoutuserid\n" +
  1901. " LEFT JOIN tp_mst_goodslevel GL\n" +
  1902. " ON GL.GOODSLEVELID = PD.GOODSLEVELID\n" +
  1903. " AND gl.AccountID = :AccountID\n" +
  1904. " WHERE PD.AccountID = :AccountID\n" +
  1905. " AND PD.Createtime >= :CreatetimeBegin\n" +
  1906. " AND PD.Createtime <= :CreatetimeEnd\n" +
  1907. " AND (:ProductionLineID IS NULL OR\n" +
  1908. " pd.productionlineid = :ProductionLineID)\n" +
  1909. " AND (:GoodsTypeCode IS NULL OR\n" +
  1910. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  1911. " AND (:GoodsCode IS NULL OR instr(g.GoodsCode, :GoodsCode) > 0)\n" +
  1912. " AND (:BarCode IS NULL OR instr(pd.BarCode, :BarCode) > 0)\n" +
  1913. " UNION ALL\n" +
  1914. " -- 报损\n" +
  1915. " SELECT sp.barcode\n" +
  1916. " ,gt2.goodstypename as goodstypename2\n" +
  1917. " ,gt.goodstypename\n" +
  1918. " ,g.goodscode\n" +
  1919. " ,sp.productionlinename\n" +
  1920. //" ,to_char(gl.goodslevelname) || '-完成工序【' ||\n" +
  1921. //" to_char(p.procedurename) || '】' AS procedurename\n" +
  1922. " ,'损坯-完成工序【' || to_char(p.procedurename) || '】-责任工序【' || CASE\n" +
  1923. " WHEN rpp.procedureid IS NOT NULL THEN\n" +
  1924. " to_char(rpp.procedurename)\n" +
  1925. " ELSE\n" +
  1926. " '无'\n" +
  1927. " END || '】-责任工号【[' || to_char(sruser.usercode) || ']' ||\n" +
  1928. " to_char(sruser.Username) || '】-原因【' ||\n" +
  1929. " to_char(sp.rreason) || '】' AS procedurename" +
  1930. " ,NULL AS porgname\n" +
  1931. " ,sp.Createtime\n" +
  1932. " ,NULL AS Usercode\n" +
  1933. " ,u.Usercode AS CreateUsercode\n" +
  1934. " ,U.Username AS CreateUserName\n" +
  1935. " ,co.organizationfullname corgname\n" +
  1936. " ,to_char(A.AUDITSTATUSNAME) || CASE\n" +
  1937. " WHEN Length(AU.usercode) > 0 THEN\n" +
  1938. " '(['|| to_char(AU.usercode) || ']' || to_char(AU.Username) || ' ' ||\n" +
  1939. " to_char(sp.AuditDate, 'yyyy-mm-dd hh24:mi:ss') || ')'\n" +
  1940. " ELSE\n" +
  1941. " ''\n" +
  1942. " END || CASE\n" +
  1943. " WHEN sp.valueflag = '0' THEN\n" +
  1944. " '-撤销(['|| to_char(uu.usercode) || ']' || to_char(uu.username) || ' ' ||\n" +
  1945. " to_char(sp.updatetime, 'yyyy-mm-dd hh24:mi:ss') || ')'\n" +
  1946. " ELSE\n" +
  1947. " ''\n" +
  1948. " END AS GOODSLEVELNAME\n" +
  1949. " ,null glazingroom\n" +
  1950. " FROM tp_pm_scrapproduct sp\n" +
  1951. " LEFT JOIN tp_mst_goods g\n" +
  1952. " ON g.goodsid = sp.goodsid\n" +
  1953. " LEFT JOIN tp_mst_goodstype gt\n" +
  1954. " ON gt.goodstypeid = g.goodstypeid\n" +
  1955. " LEFT JOIN tp_mst_goodstype gt2\n" +
  1956. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  1957. " AND gt2.AccountID = :AccountID\n" +
  1958. " INNER JOIN tp_pc_procedure p\n" +
  1959. " ON p.procedureid = sp.procedureid\n" +
  1960. " --inner join tp_mst_organization op\n" +
  1961. " -- on op.organizationid = p.organizationid\n" +
  1962. " INNER JOIN tp_mst_user U\n" +
  1963. " ON U.userid = sp.CREATEUSERID\n" +
  1964. " INNER JOIN tp_mst_organization co\n" +
  1965. " ON co.organizationid = u.organizationid\n" +
  1966. " INNER JOIN tp_mst_user uu\n" +
  1967. " ON uu.userid = sp.Updateuserid\n" +
  1968. " INNER JOIN tp_sys_AuditStatus A\n" +
  1969. " ON A.AuditStatusid = sp.AuditStatus\n" +
  1970. " LEFT JOIN tp_mst_goodslevel gl\n" +
  1971. " ON gl.goodsleveltypeid = 8\n" +
  1972. " AND gl.accountid = 1\n" +
  1973. " LEFT JOIN tp_mst_user AU\n" +
  1974. " ON au.userid = sp.auditor\n" +
  1975. " LEFT JOIN TP_PM_ResponProcedure rp\n" +
  1976. " ON rp.scrapproductid = sp.scrapproductid\n" +
  1977. " LEFT JOIN tp_pc_procedure rpp\n" +
  1978. " ON rpp.procedureid = rp.procedureid\n" +
  1979. " LEFT JOIN (SELECT DISTINCT sr.scrapproductid, sr.userid\n" +
  1980. " FROM TP_PM_ScrapResponsible sr\n" +
  1981. " WHERE sr.AccountID = :AccountID\n" +
  1982. " -- 编辑后 时间不一致\n" +
  1983. " --AND sr.Createtime >= :CreatetimeBegin\n" +
  1984. " --AND sr.Createtime <= :CreatetimeEnd\n" +
  1985. " ) sru\n" +
  1986. " ON sru.scrapproductid = sp.scrapproductid\n" +
  1987. " LEFT JOIN tp_mst_user sruser\n" +
  1988. " ON sruser.userid = sru.userid" +
  1989. " WHERE (sp.goodsleveltypeid = 8 OR sp.goodsleveltypeid = 9)\n" +
  1990. " AND sp.scraptype = '0'\n" +
  1991. " AND sp.AccountID = :AccountID\n" +
  1992. " AND sp.Createtime >= :CreatetimeBegin\n" +
  1993. " AND sp.Createtime <= :CreatetimeEnd\n" +
  1994. " AND (:ProductionLineID IS NULL OR\n" +
  1995. " sp.productionlineid = :ProductionLineID)\n" +
  1996. " AND (:GoodsTypeCode IS NULL OR\n" +
  1997. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  1998. " AND (:BarCode IS NULL OR instr(sp.BarCode, :BarCode) > 0)\n" +
  1999. " AND (:GoodsCode IS NULL OR instr(g.GoodsCode, :GoodsCode) > 0)) t\n" +
  2000. " ORDER BY t.barcode, t.Createtime";
  2001. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2002. parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  2003. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  2004. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  2005. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  2006. parameters.Add(new OracleParameter(":CreatetimeBegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input));
  2007. parameters.Add(new OracleParameter(":CreatetimeEnd", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input));
  2008. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  2009. ServiceResultEntity sre = new ServiceResultEntity();
  2010. if (data == null || data.Rows.Count == 0)
  2011. {
  2012. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2013. return sre;
  2014. }
  2015. sre.Data = new DataSet();
  2016. sre.Data.Tables.Add(data);
  2017. return sre;
  2018. }
  2019. catch (Exception ex)
  2020. {
  2021. throw ex;
  2022. }
  2023. finally
  2024. {
  2025. if (conn != null &&
  2026. conn.ConnState == ConnectionState.Open)
  2027. {
  2028. conn.Close();
  2029. }
  2030. }
  2031. }
  2032. /// <summary>
  2033. /// 取得RPT010302画面(商标变更明细表)的查询数据
  2034. /// </summary>
  2035. /// <param name="user">登录用户信息</param>
  2036. /// <param name="se">查询条件</param>
  2037. /// <returns>查询结果</returns>
  2038. public static ServiceResultEntity GetRPT010302SData(SUserInfo user, RPT010302_SE se)
  2039. {
  2040. IDBConnection conn = null;
  2041. try
  2042. {
  2043. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  2044. List<OracleParameter> parameters = new List<OracleParameter>();
  2045. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT010302SSQL());
  2046. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2047. if (se != null)
  2048. {
  2049. // 更换条码时间-开始
  2050. if (se.createTimeBegin.HasValue)
  2051. {
  2052. sql.Append(" and lcr.CreateTime>= :CreateTimeBegin ");
  2053. parameters.Add(new OracleParameter(":CreateTimeBegin", OracleDbType.Date, se.createTimeBegin.Value, ParameterDirection.Input));
  2054. }
  2055. // 更换条码时间-结束
  2056. if (se.createTimeEnd.HasValue)
  2057. {
  2058. sql.Append(" and lcr.CreateTime<= :CreateTimeEnd ");
  2059. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.createTimeEnd.Value, ParameterDirection.Input));
  2060. }
  2061. //成型线IDS
  2062. if (!string.IsNullOrEmpty(se.Barcode))
  2063. {
  2064. // sql.Append(" and (TP_PM_BarCodeRecord.BARCODE=:Barcode or TP_PM_BarCodeRecord.NEWBARCODE=:Barcode or TP_PM_BarCodeRecord.FIRSTBARCODE=:Barcode or TP_PM_BarCodeRecord.FINALBARCODE=:Barcode )");
  2065. sql.Append(" and (instr(lcr.BARCODE,:Barcode)>0 )");
  2066. parameters.Add(new OracleParameter(":Barcode", OracleDbType.NVarchar2, se.Barcode, ParameterDirection.Input));
  2067. }
  2068. }
  2069. sql.Append(" ORDER BY lcr.CREATETIME ");
  2070. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  2071. ServiceResultEntity sre = new ServiceResultEntity();
  2072. if (data == null || data.Rows.Count == 0)
  2073. {
  2074. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2075. return sre;
  2076. }
  2077. sre.Data = new DataSet();
  2078. sre.Data.Tables.Add(data);
  2079. return sre;
  2080. }
  2081. catch (Exception ex)
  2082. {
  2083. throw ex;
  2084. }
  2085. finally
  2086. {
  2087. if (conn != null &&
  2088. conn.ConnState == ConnectionState.Open)
  2089. {
  2090. conn.Close();
  2091. }
  2092. }
  2093. }
  2094. /// <summary>
  2095. /// 获取RPT010302画面(商标变更明细表)的查询sql
  2096. /// </summary>
  2097. /// <returns>sql</returns>
  2098. private static string GetRPT010302SSQL()
  2099. {
  2100. string selSql =
  2101. "SELECT lcr.BarCode\n" +
  2102. " ,REPLACE((oldlogo.Logoname || '[' || oldlogo.Logocode || ']'),\n" +
  2103. " '[]',\n" +
  2104. " '') AS oldLogoCodeName\n" +
  2105. " ,REPLACE((newlogo.Logoname || '[' || newlogo.Logocode || ']'),\n" +
  2106. " '[]',\n" +
  2107. " '') AS newLogoCodeName\n" +
  2108. " ,lcr.Createtime\n" +
  2109. " ,gdd.GroutingLineCode\n" +
  2110. " ,gdd.GroutingLineName\n" +
  2111. " ,gdd.GroutingDate\n" +
  2112. " ,gdd.GroutingMouldCode\n" +
  2113. " ,gdd.MouldCode\n" +
  2114. " ,gdd.UserCode GroutingUserCode\n" +
  2115. " ,gdd.GroutingCount\n" +
  2116. " ,gdd.GoodsCode\n" +
  2117. " ,gdd.GoodsName\n" +
  2118. " ,p.PROCEDURECODE\n" +
  2119. " ,p.PROCEDURENAME\n" +
  2120. " ,u.USERCode\n" +
  2121. " ,u.USERNAME\n" +
  2122. " FROM TP_PM_LogoChangedRecord lcr\n" +
  2123. " LEFT JOIN TP_PM_GROUTINGDAILYDETAIL gdd\n" +
  2124. " ON lcr.barcode = gdd.Barcode\n" +
  2125. " LEFT JOIN TP_PC_PROCEDURE p\n" +
  2126. " ON lcr.Procedureid = p.PROCEDUREID\n" +
  2127. " LEFT JOIN TP_MST_USER u\n" +
  2128. " ON lcr.CreateUserID = u.USERID\n" +
  2129. " LEFT JOIN TP_MST_logo oldlogo\n" +
  2130. " ON lcr.oldlogoid = oldlogo.logoid\n" +
  2131. " LEFT JOIN TP_MST_logo newlogo\n" +
  2132. " ON lcr.newlogoid = newlogo.logoid\n" +
  2133. " WHERE lcr.ACCOUNTID = :AccountID";
  2134. return selSql;
  2135. }
  2136. #endregion 明细报表
  2137. #region 分析报表
  2138. /// <summary>
  2139. /// 取得RPT040101_1画面(注浆交坯比率分析表)的查询数据
  2140. /// </summary>
  2141. /// <param name="user">登录用户信息</param>
  2142. /// <param name="se">查询条件</param>
  2143. /// <returns>查询结果</returns>
  2144. public static ServiceResultEntity GetRPT040101SData(SUserInfo user, RPT040101_SE se)
  2145. {
  2146. IDBConnection conn = null;
  2147. try
  2148. {
  2149. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  2150. #region
  2151. /*
  2152. List<OracleParameter> parameters = new List<OracleParameter>();
  2153. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT040101SSQL());
  2154. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2155. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.GroutingDateStart.Value, ParameterDirection.Input));
  2156. parameters.Add(new OracleParameter(":groutingDateEnd", OracleDbType.Date, se.GroutingDateEnd.Value, ParameterDirection.Input));
  2157. parameters.Add(new OracleParameter(":dateDifference", OracleDbType.Int32, se.DateDifference, ParameterDirection.Input));
  2158. if (se != null)
  2159. {
  2160. // 成型线IDS
  2161. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  2162. {
  2163. sql.Append(" AND instr(',' || :GroutingLineIDS ||',',','||TP_PM_GroutingDailyDetail.GroutingLineId||',')>0 ");
  2164. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  2165. }
  2166. // 成型工IDS
  2167. if (!string.IsNullOrEmpty(se.UserIDS))
  2168. {
  2169. sql.Append(" AND instr(',' || :UserIDS ||',',','||TP_PM_GroutingDailyDetail.UserId||',')>0 ");
  2170. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  2171. }
  2172. //产品类型IDS
  2173. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  2174. {
  2175. sql.Append(" AND instr(',' || :GoodsTypeIDS ||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ");
  2176. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  2177. }
  2178. //产品IDS
  2179. if (!string.IsNullOrEmpty(se.GoodsIDS))
  2180. {
  2181. sql.Append(" AND instr(',' || :GoodsIDS ||',',','||TP_PM_GroutingDailyDetail.GoodsId||',')>0 ");
  2182. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  2183. }
  2184. }
  2185. sql.Append(" group by ");
  2186. sql.Append(" TP_PM_GroutingDailyDetail.UserCode, ");
  2187. sql.Append(" TP_PM_GroutingDailyDetail.Groutinglineid, ");
  2188. sql.Append(" line.GroutinglineCode, ");
  2189. sql.Append(" TP_MST_GOODSTYPE.GoodsTypeName, ");
  2190. sql.Append(" TP_PM_GroutingDailyDetail.GoodsCode, ");
  2191. sql.Append(" TP_MST_Goods.Goodsspecification, ");
  2192. sql.Append(" TP_MST_DataDictionary.DICTIONARYVALUE, ");
  2193. sql.Append(" MouldQuantity ");
  2194. sql.Append(" ) temp ");
  2195. sql.Append(" ) a ");
  2196. sql.Append(" group by rollup( ");
  2197. sql.Append(" UserCode, ");
  2198. sql.Append(" Groutinglinecode, ");
  2199. sql.Append(" GoodsTypeName, ");
  2200. sql.Append(" GoodsCode, ");
  2201. sql.Append(" Goodsspecification, ");
  2202. sql.Append(" DICTIONARYVALUE, ");
  2203. sql.Append(" MouldQuantity, ");
  2204. sql.Append(" 注浆量, ");
  2205. sql.Append(" 交坯量 ");
  2206. sql.Append(" ) ");
  2207. sql.Append(") Temp where 交坯量 is not null");
  2208. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  2209. */
  2210. #endregion
  2211. List<OracleParameter> parameters = new List<OracleParameter>();
  2212. //StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT040101SSQL());
  2213. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2214. //parameters.Add(new OracleParameter(":dateDifference", OracleDbType.Int32, se.DateDifference, ParameterDirection.Input));
  2215. string sqlGroutingdate = null;
  2216. StringBuilder sql = new StringBuilder();
  2217. if (se != null)
  2218. {
  2219. // 成型线IDS
  2220. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  2221. {
  2222. sql.Append(" AND instr(',' || :GroutingLineIDS ||',',','||gdd.GroutingLineId||',')>0 ");
  2223. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  2224. }
  2225. // 成型工IDS
  2226. if (!string.IsNullOrEmpty(se.UserIDS))
  2227. {
  2228. sql.Append(" AND instr(',' || :UserIDS ||',',','||gdd.UserId||',')>0 ");
  2229. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  2230. }
  2231. //产品类型IDS
  2232. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  2233. {
  2234. //sql.Append(" AND instr(',' || :GoodsTypeIDS ||',',','||gt.GOODSTYPECode||',')=1");
  2235. sql.Append(" AND instr(gt.GOODSTYPECode,:GoodsTypeIDS)=1");
  2236. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  2237. }
  2238. //产品IDS
  2239. if (!string.IsNullOrEmpty(se.GoodsIDS))
  2240. {
  2241. sql.Append(" AND instr(',' || :GoodsIDS ||',',','||gdd.GoodsId||',')>0 ");
  2242. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  2243. }
  2244. if (se.GroutingDateStart.HasValue)
  2245. {
  2246. //sql.Append(" and gdd.groutingdate >= :groutingDateStart \n");
  2247. //sql.Append(" and gdd.groutingdate <= :groutingDateEnd \n");
  2248. sqlGroutingdate = " and gdd.groutingdate >= :groutingDateStart \n"
  2249. + " and gdd.groutingdate <= :groutingDateEnd \n";
  2250. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.GroutingDateStart.Value, ParameterDirection.Input));
  2251. parameters.Add(new OracleParameter(":groutingDateEnd", OracleDbType.Date, se.GroutingDateEnd.Value, ParameterDirection.Input));
  2252. parameters.Add(new OracleParameter(":DeliverTimeStart", OracleDbType.Date, se.GroutingDateStart.Value.AddDays(se.DateDifference), ParameterDirection.Input));
  2253. parameters.Add(new OracleParameter(":DeliverTimeEnd", OracleDbType.Date, se.GroutingDateEnd.Value.AddDays(se.DateDifference), ParameterDirection.Input));
  2254. }
  2255. else if (se.GCTimeBegin.HasValue)
  2256. {
  2257. //sql.Append(" and gdd.createtime >= :groutingDateStart \n");
  2258. //sql.Append(" and gdd.createtime <= :groutingDateEnd \n");
  2259. sqlGroutingdate = " and gdd.createtime >= :groutingDateStart \n"
  2260. + " and gdd.createtime <= :groutingDateEnd \n";
  2261. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.GCTimeBegin.Value, ParameterDirection.Input));
  2262. parameters.Add(new OracleParameter(":groutingDateEnd", OracleDbType.Date, se.GCTimeEnd.Value, ParameterDirection.Input));
  2263. parameters.Add(new OracleParameter(":DeliverTimeStart", OracleDbType.Date, se.GCTimeBegin.Value.Date.AddDays(se.DateDifference), ParameterDirection.Input));
  2264. parameters.Add(new OracleParameter(":DeliverTimeEnd", OracleDbType.Date, se.GCTimeEnd.Value.Date.AddDays(se.DateDifference), ParameterDirection.Input));
  2265. }
  2266. }
  2267. string sqlString =
  2268. "select decode(gid, 7, '总计', 3, '合计['|| gddata.usercode ||']', gddata.usercode) usercode,\n" +
  2269. " decode(gid, 1, '小计['|| gddata.goodscode ||']', 0, gddata.goodscode, '--') goodscode,\n" +
  2270. " decode(gid, 0, gddata.goodstypename, '--') goodstypename,\n" +
  2271. " decode(gid, 0, gddata.goodsspecification, '--') goodsspecification,\n" +
  2272. " decode(gid, 0, gddata.GlazeType, '--') GlazeType,\n" +
  2273. " decode(gid, 0, gddata.groutinglinecode, '--') groutinglinecode,\n" +
  2274. " decode(gid, 0, to_char(gddata.MouldQuantity), '--') MouldQuantity,\n" +
  2275. //" select gddata.usercode,\n" +
  2276. //" gddata.goodscode,\n" +
  2277. //" gddata.goodstypename,\n" +
  2278. //" gddata.goodsspecification,\n" +
  2279. //" gddata.GlazeType,\n" +
  2280. //" gddata.groutinglinecode,\n" +
  2281. //" gddata.MouldQuantity,\n" +
  2282. " gddata.GroutingNum,\n" +
  2283. " gddata.StrippingNum,\n" +
  2284. " gddata.DeliverNum,\n" +
  2285. " decode(gddata.GroutingNum,\n" +
  2286. " 0,\n" +
  2287. " '0.00%',\n" +
  2288. " to_char((gddata.StrippingNum / gddata.GroutingNum) * 100,\n" +
  2289. " '9,990.00') || '%') GSPercent, -- 注成比,\n" +
  2290. " decode(gddata.GroutingNum,\n" +
  2291. " 0,\n" +
  2292. " '0.00%',\n" +
  2293. " to_char((gddata.DeliverNum / gddata.GroutingNum) * 100,\n" +
  2294. " '9,990.00') || '%') GDPercent, -- 注交比,\n" +
  2295. " decode(gddata.StrippingNum,\n" +
  2296. " 0,\n" +
  2297. " '0.00%',\n" +
  2298. " to_char((gddata.DeliverNum / gddata.StrippingNum) * 100,\n" +
  2299. " '9,990.00') || '%') SDPercent -- 成交比,\n" +
  2300. " from (select grouping_id(gdd.flag,gdd.usercode, gdd.goodscode, gdd.groutinglinecode) gid,\n" +
  2301. //" select grouping_id(gdd.flag,gdd.usercode, gdd.goodscode, gdd.groutinglinecode) gid,\n" +
  2302. " gdd.usercode,\n" +
  2303. " gdd.goodscode,\n" +
  2304. " gdd.goodstypename,\n" +
  2305. " gdd.goodsspecification,\n" +
  2306. " gdd.GlazeType,\n" +
  2307. " gdd.groutinglinecode,\n" +
  2308. " gdd.MouldQuantity,\n" +
  2309. " sum(gdd.GroutingNum) GroutingNum,\n" +
  2310. " sum(gdd.StrippingNum) StrippingNum,\n" +
  2311. " sum(gdd.DeliverNum) DeliverNum\n" +
  2312. " from (select 1 flag,\n" +
  2313. //" select 1 flag,\n" +
  2314. " gddgroup.usercode,\n" +
  2315. " gddgroup.goodscode,\n" +
  2316. " gddgroup.goodstypename,\n" +
  2317. " gddgroup.goodsspecification,\n" +
  2318. " gddgroup.GlazeType,\n" +
  2319. " gddgroup.groutinglinecode,\n" +
  2320. " gddgroup.MouldQuantity,\n" +
  2321. " sum(gddgroup.GroutingNum) GroutingNum,\n" +
  2322. " sum(gddgroup.StrippingNum) StrippingNum,\n" +
  2323. " sum(gddgroup.DeliverNum) DeliverNum\n" +
  2324. " from (select --gdd.groutingdailydetailid,\n" +
  2325. " gd.groutinglinecode,\n" +
  2326. " gt.goodstypename,\n" +
  2327. " g.goodscode,\n" +
  2328. " g.goodsspecification,\n" +
  2329. " dd.dictionaryvalue GlazeType,\n" +
  2330. //" gdd.usercode,\n" +
  2331. (se.IsMonitor ? " mu.username usercode,\n" : " gdd.usercode,\n") +
  2332. " gd.MouldQuantity,\n" +
  2333. " decode(gdd.GroutingFlag, '1', 1, 0) GroutingNum,\n" +
  2334. " case\n" +
  2335. " when gdd.GroutingFlag = '1' and gdd.ScrapFlag = '0' then\n" +
  2336. " 1\n" +
  2337. " else\n" +
  2338. " 0\n" +
  2339. " end StrippingNum,\n" +
  2340. " 0 DeliverNum\n" +
  2341. " from tp_pm_groutingdaily gd\n" +
  2342. " inner join tp_pm_groutingdailydetail gdd\n" +
  2343. " on gd.groutingdailyid = gdd.groutingdailyid\n" +
  2344. " left join tp_mst_user mu\n" +
  2345. " on mu.userid = gd.MonitorID\n" +
  2346. " inner join tp_mst_goods g\n" +
  2347. " on gdd.goodsid = g.goodsid\n" +
  2348. " inner join tp_mst_goodstype gt\n" +
  2349. " on g.goodstypeid = gt.goodstypeid\n" +
  2350. " inner join tp_mst_datadictionary dd\n" +
  2351. " on dd.dictionaryid = g.GlazeTypeID\n" +
  2352. " where gd.valueflag = '1'\n" +
  2353. " and gd.accountid = :AccountID\n"
  2354. + sqlGroutingdate +
  2355. //" and gdd.groutingdate >= :groutingDateStart \n" +
  2356. //" and gdd.groutingdate <= :groutingDateEnd \n" +
  2357. sql +
  2358. " union all\n" +
  2359. " select --gdd.groutingdailydetailid,\n" +
  2360. " gd.groutinglinecode,\n" +
  2361. " gt.goodstypename,\n" +
  2362. " g.goodscode,\n" +
  2363. " g.goodsspecification,\n" +
  2364. " dd.dictionaryvalue GlazeType,\n" +
  2365. //" gdd.usercode,\n" +
  2366. (se.IsMonitor ? " mu.username usercode,\n" : " gdd.usercode,\n") +
  2367. " gd.MouldQuantity,\n" +
  2368. " 0 GroutingNum,\n" +
  2369. " 0 StrippingNum,\n" +
  2370. " decode(gdd.deliverflag, '1', 1, 0) DeliverNum\n" +
  2371. " from tp_pm_groutingdaily gd\n" +
  2372. " inner join tp_pm_groutingdailydetail gdd\n" +
  2373. " on gd.groutingdailyid = gdd.groutingdailyid\n" +
  2374. " left join tp_mst_user mu\n" +
  2375. " on mu.userid = gd.MonitorID\n" +
  2376. " inner join tp_mst_goods g\n" +
  2377. " on gdd.goodsid = g.goodsid\n" +
  2378. " inner join tp_mst_goodstype gt\n" +
  2379. " on g.goodstypeid = gt.goodstypeid\n" +
  2380. " inner join tp_mst_datadictionary dd\n" +
  2381. " on dd.dictionaryid = g.GlazeTypeID\n" +
  2382. " where gd.valueflag = '1'\n" +
  2383. " and gd.accountid = :AccountID\n" +
  2384. " and gdd.DeliverTime >= :DeliverTimeStart \n" +
  2385. " and gdd.DeliverTime <= :DeliverTimeEnd \n" + sql +
  2386. " ) gddgroup\n" +
  2387. " group by gddgroup.usercode, gddgroup.goodscode, gddgroup.goodstypename, gddgroup.goodsspecification, gddgroup.GlazeType, gddgroup.groutinglinecode, gddgroup.MouldQuantity\n" +
  2388. " order by gddgroup.usercode, gddgroup.goodscode, gddgroup.groutinglinecode\n" +
  2389. " ) gdd\n" +
  2390. " group by grouping sets((gdd.flag,gdd.usercode, gdd.goodscode, gdd.goodstypename, gdd.goodsspecification, gdd.GlazeType, gdd.groutinglinecode, gdd.MouldQuantity),(gdd.flag,gdd.usercode, gdd.goodscode),(gdd.flag,gdd.usercode),gdd.flag)\n" +
  2391. //" order by gdd.usercode, gdd.goodscode, gdd.groutinglinecode " +
  2392. ") gddata";
  2393. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  2394. ServiceResultEntity sre = new ServiceResultEntity();
  2395. if (data == null || data.Rows.Count == 0)
  2396. {
  2397. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2398. return sre;
  2399. }
  2400. sre.Data = new DataSet();
  2401. sre.Data.Tables.Add(data);
  2402. return sre;
  2403. }
  2404. catch (Exception ex)
  2405. {
  2406. throw ex;
  2407. }
  2408. finally
  2409. {
  2410. if (conn != null &&
  2411. conn.ConnState == ConnectionState.Open)
  2412. {
  2413. conn.Close();
  2414. }
  2415. }
  2416. }
  2417. /// <summary>
  2418. /// 获取RPT040101_1画面(注浆交坯比率分析表)的查询sql
  2419. /// </summary>
  2420. /// <returns>sql</returns>
  2421. private static string GetRPT040101SSQL()
  2422. {
  2423. string selSql =
  2424. "select " +
  2425. "UserCode, " +
  2426. "Groutinglinename, " +
  2427. "GoodsTypeName, " +
  2428. "GoodsCode, " +
  2429. "Goodsspecification, " +
  2430. "DICTIONARYVALUE, " +
  2431. "MouldQuantity, " +
  2432. "注浆量, " +
  2433. "交坯量, " +
  2434. "交坯率 " +
  2435. "from " +
  2436. "( " +
  2437. " select " +
  2438. " decode(grouping(UserCode),1,'合计', UserCode) UserCode, " +
  2439. " decode(grouping(UserCode),1,'--', Groutinglinecode) Groutinglinename, " +
  2440. " decode(grouping(UserCode),1,'--', GoodsTypeName) GoodsTypeName, " +
  2441. " decode(grouping(UserCode),1,'--', GoodsCode) GoodsCode, " +
  2442. " decode(grouping(UserCode),1,'--', Goodsspecification) Goodsspecification, " +
  2443. " decode(grouping(UserCode),1,'--', DICTIONARYVALUE) DICTIONARYVALUE, " +
  2444. " decode(grouping(UserCode),1,sum(MouldQuantity), MouldQuantity) MouldQuantity, " +
  2445. " decode(grouping(UserCode),1,sum(注浆量), 注浆量) 注浆量, " +
  2446. " decode(grouping(UserCode),1,sum(交坯量), 交坯量) 交坯量, " +
  2447. " decode(grouping(UserCode),1,TO_CHAR((sum(交坯量)/sum(注浆量))*100,'9,999.99')||'%', TO_CHAR((交坯量/注浆量)*100,'9,999.99')||'%' ) 交坯率 " +
  2448. " from " +
  2449. " ( " +
  2450. " select " +
  2451. " UserCode, " +
  2452. " Groutinglinecode, " +
  2453. " GoodsTypeName, " +
  2454. " GoodsCode, " +
  2455. " Goodsspecification, " +
  2456. " DICTIONARYVALUE, " +
  2457. " MouldQuantity, " +
  2458. " 注浆量, " +
  2459. " ( " +
  2460. " select count(TP_PM_ProductionData.Productiondataid) " +
  2461. " from TP_PM_ProductionData " +
  2462. " where " +
  2463. " TP_PM_ProductionData.Accountid=:AccountID and TP_PM_ProductionData.ModelType=5 " +
  2464. " and TP_PM_ProductionData.Usercode=temp.UserCode " +
  2465. " and TP_PM_ProductionData.GROUTINGLINEID=temp.Groutinglineid " +
  2466. //--交坯比率应该是统计的某一时间段注浆的产品,其所交坯的数量,
  2467. //所以交坯的的产品应属于这段期间注浆的产品---袁新成2015-4-16改 --
  2468. //" and TP_PM_ProductionData.Barcode in (select barcode from TP_PM_GroutingDailyDetail where " +
  2469. //" TP_PM_GroutingDailyDetail.Valueflag=1 " +
  2470. //" and TP_PM_GroutingDailyDetail.GroutingFlag=1 " +
  2471. //" AND TP_PM_GroutingDailyDetail.AccountID=:AccountID " +
  2472. //" AND TP_PM_GroutingDailyDetail.GroutingDate >= :groutingDateStart " +
  2473. //" AND TP_PM_GroutingDailyDetail.GroutingDate <= :groutingDateEnd )" +
  2474. //交坯的其实日期应该还是与注浆的开始日期相同,只是结束日期推后 dateDifferentce天 ---袁新成2015-4-16改--
  2475. //" and TP_PM_ProductionData.AccountDate >= :groutingDateStart " +
  2476. " and TP_PM_ProductionData.AccountDate >= :groutingDateStart+:dateDifference " +
  2477. " and TP_PM_ProductionData.AccountDate >= :groutingDateStart " +
  2478. " and TP_PM_ProductionData.AccountDate <= :groutingDateEnd +:dateDifference " +
  2479. " ) as 交坯量 " +
  2480. " from " +
  2481. " ( " +
  2482. " select " +
  2483. " TP_PM_GroutingDailyDetail.UserCode as UserCode, " +
  2484. " TP_PM_GroutingDailyDetail.Groutinglineid, " +
  2485. " line.GroutinglineCode, " +
  2486. " TP_MST_GOODSTYPE.GoodsTypeName, " +
  2487. " TP_PM_GroutingDailyDetail.GoodsCode, " +
  2488. " TP_MST_Goods.Goodsspecification, " +
  2489. " TP_MST_DataDictionary.DICTIONARYVALUE, " +
  2490. " line.MouldQuantity, " +
  2491. " count(TP_PM_GroutingDailyDetail.GroutingCount) as 注浆量 " +
  2492. " from " +
  2493. " TP_PM_GroutingDailyDetail " +
  2494. " inner join TP_MST_Goods on TP_MST_Goods.Goodsid= TP_PM_GroutingDailyDetail.Goodsid " +
  2495. " inner join TP_MST_GOODSTYPE on TP_MST_GOODSTYPE.GOODSTYPEID = TP_MST_Goods.Goodstypeid " +
  2496. " inner join TP_MST_DataDictionary on TP_MST_DataDictionary.Dictionaryid=TP_MST_Goods.GLAZETYPEID " +
  2497. " inner join TP_PM_GroutingDaily on TP_PM_GroutingDailyDetail.Groutingdailyid=TP_PM_GroutingDaily.Groutingdailyid " +
  2498. " inner join TP_PC_GroutingLine line on line.Groutinglineid = TP_PM_GroutingDailyDetail.Groutinglineid " +
  2499. " where " +
  2500. " TP_PM_GroutingDailyDetail.Valueflag=1 " +
  2501. " and TP_PM_GroutingDailyDetail.GroutingFlag=1 " +
  2502. " AND TP_PM_GroutingDailyDetail.AccountID=:AccountID " +
  2503. " AND TP_PM_GroutingDailyDetail.GroutingDate >= :groutingDateStart " +
  2504. " AND TP_PM_GroutingDailyDetail.GroutingDate <= :groutingDateEnd ";
  2505. return selSql;
  2506. }
  2507. /// <summary>
  2508. /// 取得RPT040102_1画面(工序产量分析表)的查询数据
  2509. /// </summary>
  2510. /// <param name="user">登录用户信息</param>
  2511. /// <param name="se">查询条件</param>
  2512. /// <returns>查询结果</returns>
  2513. public static ServiceResultEntity GetRPT040102SData(SUserInfo user, RPT040102_SE se)
  2514. {
  2515. IDBConnection conn = null;
  2516. try
  2517. {
  2518. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  2519. //OracleParameter[] paras = new OracleParameter[]{
  2520. // new OracleParameter("in_goodsTypeIds",OracleDbType.Varchar2,se.GoodsTypeIDS,ParameterDirection.Input),
  2521. // new OracleParameter("in_goodsIds",OracleDbType.Varchar2,se.GoodsIDS,ParameterDirection.Input),
  2522. // new OracleParameter("in_productionLineId",OracleDbType.Int32,se.ProductionLineID,ParameterDirection.Input),
  2523. // new OracleParameter("in_accountDateStart",OracleDbType.Varchar2,se.AccountDateStart,ParameterDirection.Input),
  2524. // new OracleParameter("in_accountDateEnd",OracleDbType.Varchar2,se.AccountDateEnd,ParameterDirection.Input),
  2525. // new OracleParameter("in_accountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  2526. // new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  2527. //};
  2528. /*
  2529. OracleParameter[] paras = new OracleParameter[]{
  2530. new OracleParameter("in_productionLineId",OracleDbType.Int32,se.ProductionLineID,ParameterDirection.Input),
  2531. new OracleParameter("in_procedureids",OracleDbType.Varchar2,se.ProcedureIDs,ParameterDirection.Input),
  2532. new OracleParameter("in_goodsTypeIds",OracleDbType.Varchar2,se.GoodsTypeIDS,ParameterDirection.Input),
  2533. new OracleParameter("in_goodsIds",OracleDbType.Varchar2,se.GoodsIDS,ParameterDirection.Input),
  2534. new OracleParameter("in_accountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  2535. new OracleParameter("in_accountDateStart",OracleDbType.Date,se.AccountDateStart,ParameterDirection.Input),
  2536. new OracleParameter("in_accountDateEnd",OracleDbType.Date,se.AccountDateEnd,ParameterDirection.Input),
  2537. new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  2538. };
  2539. //DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetLineProcessTotal", paras);
  2540. DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetLineProcessTotalNew", paras);
  2541. ServiceResultEntity sre = new ServiceResultEntity();
  2542. if (data == null || data.Tables.Count == 0)
  2543. {
  2544. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2545. return sre;
  2546. }
  2547. sre.Data = new DataSet();
  2548. sre.Data = data;
  2549. return sre;
  2550. */
  2551. ServiceResultEntity sre = new ServiceResultEntity();
  2552. List<OracleParameter> parameters = new List<OracleParameter>();
  2553. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2554. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  2555. string sqlString =
  2556. "select p.procedureid, p.procedurecode, p.procedurename\n" +
  2557. " from tp_pc_procedure p\n" +
  2558. " where p.valueflag = '1'\n" +
  2559. " and p.AccountID = :AccountID" +
  2560. " and p.productionlineid = :productionlineid\n";
  2561. if (!string.IsNullOrWhiteSpace(se.ProcedureIDs))
  2562. {
  2563. sqlString += " and instr(',' || :procedureids || ',', ',' || p.procedureid || ',') > 0\n";
  2564. parameters.Add(new OracleParameter(":procedureids", OracleDbType.NVarchar2, se.ProcedureIDs, ParameterDirection.Input));
  2565. }
  2566. sqlString += "order by p.Displayno";
  2567. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  2568. if (data == null || data.Rows.Count == 0)
  2569. {
  2570. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2571. return sre;
  2572. }
  2573. parameters.Clear();
  2574. StringBuilder sql1 = new StringBuilder();
  2575. StringBuilder sql2 = new StringBuilder();
  2576. StringBuilder sql3 = new StringBuilder();
  2577. foreach (DataRow item in data.Rows)
  2578. {
  2579. //sql1.Append(", decode(pd.procedureid, " + item["procedureid"] + ", 1, 0) as A" + item["procedurecode"] + "\n");
  2580. //sql2.Append(", sum(pdata.A" + item["procedurecode"] + ") as A" + item["procedurecode"] + "\n");
  2581. //sql3.Append(", pdg.A" + item["procedurecode"] + " as \"" + item["procedurename"] + "\" \n");
  2582. sql1.Append(", sum(decode(pd.procedureid, " + item["procedureid"] + ", 1, 0)) as A" + item["procedurecode"] + "\n");
  2583. sql2.Append(", sum(pdata.A" + item["procedurecode"] + ") as A" + item["procedurecode"] + "\n");
  2584. sql3.Append(", pdg.A" + item["procedurecode"] + " as \"" + item["procedurename"] + "\" \n");
  2585. }
  2586. sqlString =
  2587. "select --pdg.gid,\n" +
  2588. " decode(pdg.gid, 1, '小计', 3, '合计', 0, pdg.goodstypename2, '--') \"产品二级类别\",\n" +
  2589. " decode(pdg.gid, 0, pdg.goodstypename, '--') \"产品类别\",\n" +
  2590. " decode(pdg.gid, 0, pdg.goodscode, '--') \"产品编码\",\n" +
  2591. " decode(pdg.gid, 0, pdg.goodsspecification, '--') \"产品规格\",\n" +
  2592. " --decode(pdg.gid, 0, pdg.GOODSMODEL, '--') \"产品型号\",\n" +
  2593. " decode(pdg.gid, 0, pdg.GLAZETYPE, '--') \"釉料类别\"\n" +
  2594. sql3 +
  2595. " from ( select " +
  2596. " grouping_id(pdata.productionlineid,pdata.goodstypename2,pdata.goodscode) gid," +
  2597. " pdata.productionlineid,\n" +
  2598. " pdata.goodstypename2,\n" +
  2599. " pdata.goodstypename,\n" +
  2600. " pdata.goodscode,\n" +
  2601. " pdata.goodsspecification,\n" +
  2602. " pdata.GOODSMODEL,\n" +
  2603. " pdata.GLAZETYPE\n" +
  2604. sql2 +
  2605. " from (" +
  2606. " select\n" +
  2607. " pd.productionlineid,\n" +
  2608. " gt2.goodstypename goodstypename2,\n" +
  2609. " gt.goodstypename,\n" +
  2610. " g.goodscode,\n" +
  2611. " g.goodsspecification,\n" +
  2612. " g.GOODSMODEL,\n" +
  2613. " dd.dictionaryvalue GLAZETYPE\n" +
  2614. sql1 +
  2615. " from tp_pm_productiondata pd\n" +
  2616. " inner join tp_mst_goods g\n" +
  2617. " on g.goodsid = pd.goodsid\n" +
  2618. " inner join tp_mst_goodstype gt\n" +
  2619. " on gt.goodstypeid = g.goodstypeid\n" +
  2620. " inner join tp_mst_goodstype gt2\n" +
  2621. " on gt2.goodstypecode = substr(gt.goodstypecode, 0, 6)\n" +
  2622. " and gt2.accountid = gt.accountid\n" +
  2623. " inner join tp_mst_datadictionary dd\n" +
  2624. " on dd.dictionaryid = g.GLAZETYPEID\n" +
  2625. " where pd.valueflag = '1'\n" +
  2626. // 公坯、干补不算交坯工序的产量。
  2627. //" and ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.IsPublicBody = '0' and pd.SpecialRepairFlag = '0')) \n" +
  2628. // modify wangx 2015-12-3
  2629. (se.ProductionFlag == "1" ? " and ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" : "") +
  2630. " and pd.accountid = :accountid\n" +
  2631. " and pd.productionlineid = :productionlineid\n" +
  2632. " and pd.createtime >= :createtimeStart\n" +
  2633. " and pd.createtime <= :createtimeEnd\n";
  2634. StringBuilder sql = new StringBuilder(sqlString);
  2635. if (!string.IsNullOrWhiteSpace(se.GoodsIDS))
  2636. {
  2637. sql.Append(" and instr(',' || :goodsIds || ',', ',' || pd.goodsid || ',') > 0\n");
  2638. parameters.Add(new OracleParameter(":goodsIds", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  2639. }
  2640. if (!string.IsNullOrWhiteSpace(se.GoodsTypeIDS))
  2641. {
  2642. //sql.Append(" and instr(',' || :goodsTypeIds || ',', ',' || gt.goodstypecode || ',') =1\n");
  2643. sql.Append(" and instr(gt.goodstypecode,:goodsTypeIds) =1\n");
  2644. parameters.Add(new OracleParameter(":goodsTypeIds", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  2645. }
  2646. if (!string.IsNullOrWhiteSpace(se.ProcedureIDs))
  2647. {
  2648. sql.Append(" and instr(',' || :procedureids || ',', ',' || pd.procedureid || ',') > 0\n");
  2649. parameters.Add(new OracleParameter(":procedureids", OracleDbType.NVarchar2, se.ProcedureIDs, ParameterDirection.Input));
  2650. }
  2651. sql.Append(" AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 7 and up.UserID = :UserID and (up.PurviewID = -1 or up.PurviewID= pd.ProductionLineId))");
  2652. parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  2653. sqlString =
  2654. " group by \n" +
  2655. " pd.productionlineid,\n" +
  2656. " gt2.goodstypename,\n" +
  2657. " gt.goodstypename,\n" +
  2658. " g.goodscode,\n" +
  2659. " g.goodsspecification,\n" +
  2660. " g.GOODSMODEL,\n" +
  2661. " dd.dictionaryvalue\n" +
  2662. " order by gt2.goodstypename, g.goodscode" +
  2663. " ) pdata\n" +
  2664. " group by grouping sets((pdata.productionlineid,\n" +
  2665. " pdata.goodstypename2,\n" +
  2666. " pdata.goodstypename,\n" +
  2667. " pdata.goodsspecification,\n" +
  2668. " pdata.GOODSMODEL,\n" +
  2669. " pdata.GLAZETYPE,\n" +
  2670. " pdata.goodscode),\n" +
  2671. " (pdata.productionlineid,pdata.goodstypename2),\n" +
  2672. " pdata.productionlineid)\n" +
  2673. " ) pdg";
  2674. sql.Append(sqlString);
  2675. parameters.Add(new OracleParameter(":accountid", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2676. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  2677. parameters.Add(new OracleParameter(":createtimeStart", OracleDbType.Date, se.AccountDateStart, ParameterDirection.Input));
  2678. parameters.Add(new OracleParameter(":createtimeEnd", OracleDbType.Date, se.AccountDateEnd, ParameterDirection.Input));
  2679. DataTable data1 = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  2680. if (data1 == null || data1.Rows.Count == 0)
  2681. {
  2682. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2683. return sre;
  2684. }
  2685. sre.Data = new DataSet();
  2686. sre.Data.Tables.Add(data1);
  2687. return sre;
  2688. }
  2689. catch (Exception ex)
  2690. {
  2691. throw ex;
  2692. }
  2693. finally
  2694. {
  2695. if (conn != null &&
  2696. conn.ConnState == ConnectionState.Open)
  2697. {
  2698. conn.Close();
  2699. }
  2700. }
  2701. }
  2702. /// <summary>
  2703. /// 取得RPT040103画面(工序质量分析表)的查询数据
  2704. /// </summary>
  2705. /// <param name="user">登录用户信息</param>
  2706. /// <param name="se">查询条件</param>
  2707. /// <returns>查询结果</returns>
  2708. public static ServiceResultEntity GetRPT040103SData(SUserInfo user, RPT040103_SE se)
  2709. {
  2710. IDBConnection conn = null;
  2711. try
  2712. {
  2713. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  2714. List<OracleParameter> parameters = new List<OracleParameter>();
  2715. //string sql = ReportModuleLogic.GetRPT040103SSQL(user, se, ref parameters);
  2716. string sql = ReportModuleLogic.GetRPT040103S1SQL(user, se, ref parameters);
  2717. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  2718. ServiceResultEntity sre = new ServiceResultEntity();
  2719. if (data == null || data.Rows.Count == 0)
  2720. {
  2721. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  2722. return sre;
  2723. }
  2724. sre.Data = new DataSet();
  2725. sre.Data.Tables.Add(data);
  2726. return sre;
  2727. }
  2728. catch (Exception ex)
  2729. {
  2730. throw ex;
  2731. }
  2732. finally
  2733. {
  2734. if (conn != null &&
  2735. conn.ConnState == ConnectionState.Open)
  2736. {
  2737. conn.Close();
  2738. }
  2739. }
  2740. }
  2741. /// <summary>
  2742. /// 获取RPT040103画面(工序质量分析表)的查询sql
  2743. /// </summary>
  2744. /// <returns>sql</returns>
  2745. private static string GetRPT040103SSQL(SUserInfo user, RPT040103_SE se, ref List<OracleParameter> parameters)
  2746. {
  2747. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2748. parameters.Add(new OracleParameter(":in_rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  2749. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  2750. // 2015-06-16 modify by chenxy
  2751. string sqlString = "\n" +
  2752. "select qdgroup.gid,\n" +
  2753. " decode(qdgroup.gid, 0, qdgroup.productionlinename, '--') productionlinename,\n" +
  2754. " decode(qdgroup.gid, 15, '总计', 0, qdgroup.procedurename, '--') procedurename,\n" +
  2755. " decode(qdgroup.gid, 7, '合计', 0, qdgroup.kilncode, '--') kilncode,\n" +
  2756. " decode(qdgroup.gid, 3, '小计', 0, qdgroup.goodstypename2, '--') goodstypename2,\n" +
  2757. " decode(qdgroup.gid, 0, qdgroup.usercode, '--') usercode,\n" +
  2758. " decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename,\n" +
  2759. " decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode,\n" +
  2760. " qdgroup.OutKilnCount,\n" +
  2761. " qdgroup.GoodCount,\n" +
  2762. " to_char((qdgroup.GoodCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' GoodPercent,\n" +
  2763. " qdgroup.SubstandardCount,\n" +
  2764. " to_char((qdgroup.SubstandardCount / qdgroup.OutKilnCount) * 100,\n" +
  2765. " '990.00') || '%' SubstandardPercent,\n" +
  2766. " qdgroup.GoodCount+qdgroup.BadCount Qualified,\n" +
  2767. " to_char(((qdgroup.GoodCount+qdgroup.BadCount) / qdgroup.OutKilnCount) * 100,\n" +
  2768. " '990.00') || '%' QualifiedPercent,\n" +
  2769. " qdgroup.BadCount,\n" +
  2770. " to_char((qdgroup.BadCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' BadPercent,\n" +
  2771. " qdgroup.ReFireCount,\n" +
  2772. " to_char((qdgroup.ReFireCount / qdgroup.OutKilnCount) * 100,\n" +
  2773. " '990.00') || '%' ReFirePercent\n" +
  2774. " from (select grouping_id(pcpl.productionlinename,\n" +
  2775. " pcp.procedurename,\n" +
  2776. " mstkiln.kilncode,\n" +
  2777. " mstgoodstype2.goodstypename,\n" +
  2778. " qd.usercode,\n" +
  2779. " --mstgoodstype.goodstypename,\n" +
  2780. " mstgoods.goodscode) gid,\n" +
  2781. " pcpl.productionlinename,\n" +
  2782. " pcp.procedurename,\n" +
  2783. " --qd.kilnid,\n" +
  2784. " mstkiln.kilncode,\n" +
  2785. " mstgoodstype2.goodstypename goodstypename2,\n" +
  2786. " qd.usercode,\n" +
  2787. " mstgoodstype.goodstypename,\n" +
  2788. " mstgoods.goodscode,\n" +
  2789. " sum(qd.OutKilnCount) OutKilnCount,\n" +
  2790. " sum(qd.GoodCount) GoodCount,\n" +
  2791. " sum(qd.SubstandardCount) SubstandardCount,\n" +
  2792. " sum(qd.BadCount) BadCount,\n" +
  2793. " sum(qd.ReFireCount) ReFireCount\n" +
  2794. " from (select --pdbc.barcode,\n" +
  2795. " pdbc.productionlineid,\n" +
  2796. " pdata.procedureid,\n" +
  2797. " pdata.usercode,\n" +
  2798. " pdbc.goodsid,\n" +
  2799. " pdbc.kilnid,\n" +
  2800. " --pdbc.kilncarid,\n" +
  2801. " --pdbc.kilncarbatchno,\n" +
  2802. " 1 OutKilnCount,\n" +
  2803. " case\n" +
  2804. " when defect.defectprocedureid is not null and glt.goodsleveltypeid in (5, 6, 7) then\n" +
  2805. " 0\n" +
  2806. " else\n" +
  2807. " 1\n" +
  2808. " end GoodCount,\n" +
  2809. " case\n" +
  2810. " when defect.defectprocedureid is not null and glt.goodsleveltypeid = 7 then\n" +
  2811. " 1\n" +
  2812. " else\n" +
  2813. " 0\n" +
  2814. " end SubstandardCount,\n" +
  2815. " case\n" +
  2816. " when defect.defectprocedureid is not null and glt.goodsleveltypeid = 6 then\n" +
  2817. " 1\n" +
  2818. " else\n" +
  2819. " 0\n" +
  2820. " end ReFireCount,\n" +
  2821. " case\n" +
  2822. " when defect.defectprocedureid is not null and glt.goodsleveltypeid = 5 then\n" +
  2823. " 1\n" +
  2824. " else\n" +
  2825. " 0\n" +
  2826. " end BadCount\n" +
  2827. " from (select distinct pd.barcode,\n" +
  2828. " pd.productionlineid,\n" +
  2829. " pd.goodsid,\n" +
  2830. " pd.kilnid,\n" +
  2831. " --pd.kilncarid,\n" +
  2832. " pd.kilncarbatchno\n" +
  2833. " from tp_pm_productiondata pd\n" +
  2834. " where pd.valueflag = '1'\n" +
  2835. " and pd.procedureid = :in_rptSprocedureId \n" +
  2836. " and pd.AccountID = :AccountID\n ";
  2837. StringBuilder selSql = new StringBuilder(sqlString);
  2838. if (se.CreateTimeStart.HasValue)
  2839. {
  2840. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  2841. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  2842. }
  2843. if (se.CreateTimeEnd.HasValue)
  2844. {
  2845. selSql.Append(" AND pd.createtime <= :CreateTimeEnd\n");
  2846. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  2847. }
  2848. if (!string.IsNullOrEmpty(se.GoodsIDS))
  2849. {
  2850. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  2851. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  2852. }
  2853. if (se.ProductionLineID.HasValue)
  2854. {
  2855. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  2856. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  2857. }
  2858. //selSql.Append(" AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 7 and up.UserID = :UserID and (up.PurviewID = -1 or up.PurviewID= pd.ProductionLineId))");
  2859. //parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  2860. if (se.KilnID.HasValue)
  2861. {
  2862. selSql.Append(" AND pd.KilnID = :KilnID\n");
  2863. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  2864. }
  2865. sqlString =
  2866. " ) pdbc\n" + // 成检交接工序
  2867. " inner join (select distinct pd.barcode,\n" +
  2868. " pd.userid,\n" +
  2869. " pd.usercode,\n" +
  2870. " pd.procedureid\n" +
  2871. " from tp_pm_productiondata pd\n" +
  2872. " where pd.valueflag = '1'\n" +
  2873. " and pd.AccountID = :AccountID\n" +
  2874. // 公坯、干补不算交坯工序的质量。
  2875. //" and ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.IsPublicBody = '0' and pd.SpecialRepairFlag = '0')) \n" +
  2876. // 干补不算交坯工序的质量。
  2877. " and ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" +
  2878. " and exists\n" +
  2879. " (select 1\n" +
  2880. " from tp_mst_rpttprocedure rptt\n" +
  2881. " where rptt.RPTPROCEDUREID = :in_rptProcedureId\n";
  2882. selSql.Append(sqlString);
  2883. if (!string.IsNullOrEmpty(se.RptTProcedureIDS))
  2884. {
  2885. selSql.Append(" AND instr(','||:rptTprocedureIDS||',', ','||rptt.procedureid||',') > 0\n");
  2886. parameters.Add(new OracleParameter(":rptTprocedureIDS", OracleDbType.NVarchar2, se.RptTProcedureIDS, ParameterDirection.Input));
  2887. }
  2888. //selSql.Append(" AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 9 and up.UserID = :UserID and (up.PurviewID=-1 or up.PurviewID=pd.procedureid))");
  2889. selSql.Append(" and rptt.procedureid = pd.procedureid)\n");
  2890. if (!string.IsNullOrEmpty(se.UserIDS))
  2891. {
  2892. selSql.Append(" and instr(','||:userIDS||',', ','||pd.Userid||',') > 0\n");
  2893. parameters.Add(new OracleParameter(":userIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  2894. }
  2895. sqlString =
  2896. " ) pdata\n" + // 生产工序
  2897. " on pdata.barcode = pdbc.barcode\n" +
  2898. " left join (select kcbc.barcode, kcbc.kilncarbatchno, kcbc.goodsleveltypeid, kcbc.productiondataid\n" +
  2899. " from (select pd.barcode,\n" +
  2900. " pd.kilncarbatchno,\n" +
  2901. " pd.goodsleveltypeid,\n" +
  2902. " pd.productiondataid,\n" +
  2903. " ROW_NUMBER() OVER(PARTITION BY pd.barcode, pd.kilncarbatchno ORDER BY pd.productiondataid desc) AS dataid\n" +
  2904. " from tp_pm_productiondata pd\n" +
  2905. " where pd.valueflag = '1'\n" +
  2906. " and pd.AccountID = :AccountID\n" +
  2907. " and length(pd.kilncarbatchno) > 0\n" +
  2908. " AND pd.createtime >= :CreateTimeStart\n" +
  2909. " and pd.modeltype = -1) kcbc\n" +
  2910. " where kcbc.dataid = 1) glt\n" +
  2911. " on pdbc.kilncarbatchno = glt.kilncarbatchno\n" +
  2912. " and pdbc.barcode = glt.barcode\n" +
  2913. " left join (select distinct productiondataid, defectprocedureid" +
  2914. " from tp_pm_defect def " +
  2915. " where def.valueflag='1'" +
  2916. " and def.AccountID = :AccountID\n" +
  2917. " AND def.createtime >= :CreateTimeStart) defect\n" +
  2918. " on defect.productiondataid = glt.productiondataid\n" +
  2919. " and pdata.procedureid = defect.defectprocedureid\n" +
  2920. " ) qd\n" +
  2921. " inner join tp_pc_productionline pcpl\n" +
  2922. " on pcpl.productionlineid = qd.productionlineid\n" +
  2923. " inner join tp_pc_procedure pcp\n" +
  2924. " on pcp.procedureid = qd.procedureid\n" +
  2925. " inner join tp_mst_kiln mstkiln\n" +
  2926. " on mstkiln.kilnid = qd.kilnid\n" +
  2927. " inner join tp_mst_goods mstgoods\n" +
  2928. " on mstgoods.goodsid = qd.goodsid\n" +
  2929. " inner join tp_mst_goodstype mstgoodstype\n" +
  2930. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  2931. " and mstgoodstype.accountid = mstgoods.accountid\n" +
  2932. " inner join tp_mst_goodstype mstgoodstype2\n" +
  2933. " on mstgoodstype2.goodstypecode =\n" +
  2934. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  2935. " and mstgoodstype.accountid = mstgoodstype2.accountid\n" +
  2936. " where 1=1\n";
  2937. selSql.Append(sqlString);
  2938. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  2939. {
  2940. //selSql.Append(" AND instr(','||:GoodsTypeIDS||',', ','||mstgoodstype.GOODSTYPECode||',')=1\n");
  2941. selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS)=1\n");
  2942. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  2943. }
  2944. sqlString =
  2945. " group by grouping sets((pcpl.productionlinename,\n" +
  2946. " pcp.procedurename,\n" +
  2947. " mstkiln.kilncode,\n" +
  2948. " mstgoodstype2.goodstypename,\n" +
  2949. " qd.usercode,\n" +
  2950. " mstgoodstype.goodstypename,\n" +
  2951. " mstgoods.goodscode),\n" +
  2952. " (pcpl.productionlinename,\n" +
  2953. " pcp.procedurename,\n" +
  2954. " mstkiln.kilncode,\n" +
  2955. " mstgoodstype2.goodstypename),\n" +
  2956. " (pcpl.productionlinename,\n" +
  2957. " pcp.procedurename,\n" +
  2958. " mstkiln.kilncode),\n" +
  2959. " (pcpl.productionlinename, pcp.procedurename))\n" +
  2960. " order by pcpl.productionlinename,\n" +
  2961. " pcp.procedurename,\n" +
  2962. " mstkiln.kilncode,\n" +
  2963. " mstgoodstype2.goodstypename,\n" +
  2964. " qd.usercode,\n" +
  2965. " mstgoodstype.goodstypename,\n" +
  2966. " mstgoods.goodscode\n" +
  2967. " ) qdgroup\n";
  2968. selSql.Append(sqlString);
  2969. return selSql.ToString();
  2970. }
  2971. /// <summary>
  2972. /// 获取RPT040103画面(工序质量分析表-按登记时间)的查询sql
  2973. /// </summary>
  2974. /// <returns>sql</returns>
  2975. private static string GetRPT040103S1SQL(SUserInfo user, RPT040103_SE se, ref List<OracleParameter> parameters)
  2976. {
  2977. parameters.Add(new OracleParameter(":in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  2978. parameters.Add(new OracleParameter(":in_rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  2979. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  2980. string sqlString = "select qdgroup.gid\n" +
  2981. " ,qdgroup.productionlinename\n" +
  2982. " ,decode(qdgroup.gid\n" +
  2983. " ,15\n" +
  2984. " ,'总计[' || qdgroup.procedurename || ']'\n" +
  2985. " ,qdgroup.procedurename) procedurename\n" +
  2986. " ,decode(qdgroup.gid\n" +
  2987. " ,7\n" +
  2988. " ,'合计[' || qdgroup.kilncode || ']'\n" +
  2989. " ,15\n" +
  2990. " ,'--'\n" +
  2991. " ,qdgroup.kilncode) kilncode\n" +
  2992. " ,decode(qdgroup.gid\n" +
  2993. " ,3\n" +
  2994. " ,'小计[' || qdgroup.goodstypename2 || ']'\n" +
  2995. " ,15\n" +
  2996. " ,'--'\n" +
  2997. " ,7\n" +
  2998. " ,'--'\n" +
  2999. " ,qdgroup.goodstypename2) goodstypename2\n" +
  3000. " ,decode(qdgroup.gid, 0, qdgroup.usercode, '--') usercode\n" +
  3001. " ,decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename\n" +
  3002. " ,decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode\n" +
  3003. " ,qdgroup.OutKilnCount\n" +
  3004. " ,qdgroup.GoodCount\n" +
  3005. " ,decode(qdgroup.OutKilnCount\n" +
  3006. " ,0\n" +
  3007. " ,to_number(null)\n" +
  3008. " ,round(qdgroup.GoodCount / qdgroup.OutKilnCount, 4)) GoodPercent\n" +
  3009. " ,qdgroup.SubstandardCount\n" +
  3010. " ,decode(qdgroup.OutKilnCount\n" +
  3011. " ,0\n" +
  3012. " ,to_number(null)\n" +
  3013. " ,round(qdgroup.SubstandardCount / qdgroup.OutKilnCount, 4)) SubstandardPercent\n" +
  3014. " ,qdgroup.GoodCount + qdgroup.BadCount Qualified\n" +
  3015. " ,decode(qdgroup.OutKilnCount\n" +
  3016. " ,0\n" +
  3017. " ,to_number(null)\n" +
  3018. " ,round((qdgroup.GoodCount + qdgroup.BadCount) /\n" +
  3019. " qdgroup.OutKilnCount\n" +
  3020. " ,4)) QualifiedPercent\n" +
  3021. " ,qdgroup.BadCount\n" +
  3022. " ,decode(qdgroup.OutKilnCount\n" +
  3023. " ,0\n" +
  3024. " ,to_number(null)\n" +
  3025. " ,round(qdgroup.BadCount / qdgroup.OutKilnCount, 4)) BadPercent\n" +
  3026. " ,qdgroup.ReFireCount\n" +
  3027. " ,decode(qdgroup.OutKilnCount\n" +
  3028. " ,0\n" +
  3029. " ,to_number(null)\n" +
  3030. " ,round(qdgroup.ReFireCount / qdgroup.OutKilnCount, 4)) ReFirePercent\n" +
  3031. " from (select grouping_id(pcpl.productionlinename\n" +
  3032. " ,pcp.procedurename\n" +
  3033. " ,mstkiln.kilncode\n" +
  3034. " ,mstgoodstype2.goodstypecode\n" +
  3035. " ,pdata.usercode\n" +
  3036. " ,mstgoods.goodscode) gid\n" +
  3037. " ,pcpl.productionlinename\n" +
  3038. " ,pcp.procedurename\n" +
  3039. " ,mstkiln.kilncode\n" +
  3040. " ,mstgoodstype2.goodstypename goodstypename2\n" +
  3041. " ,mstgoodstype2.goodstypecode goodstypecode2\n" +
  3042. " ,pdata.usercode\n" +
  3043. " ,mstgoodstype.goodstypename\n" +
  3044. " ,mstgoods.goodscode\n" +
  3045. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 0)), 0) OutKilnCount\n" +
  3046. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 5, 1, 0)), 0) BadCount\n" +
  3047. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 6, 1, 0)), 0) ReFireCount\n" +
  3048. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 7, 1, 0)), 0) SubstandardCount\n" +
  3049. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 5, -1, 6, -1, 7, -1, 0)), 0) GoodCount\n" +
  3050. " from (select 0 goodsleveltypeid -- 出窑数量\n" +
  3051. " ,pd.barcode\n" +
  3052. " ,pd.productionlineid\n" +
  3053. " ,pd.goodsid\n" +
  3054. " ,pd.kilnid\n" +
  3055. " ,pd.kilncarbatchno\n" +
  3056. " ,0 procedureid\n" +
  3057. " ,1 cc\n" +
  3058. " from tp_pm_productiondata pd\n" +
  3059. " where pd.valueflag = '1'\n" +
  3060. " and pd.procedureid = :in_rptSprocedureId\n" +
  3061. " and pd.accountid = :in_AccountID\n";
  3062. StringBuilder selSql = new StringBuilder(sqlString);
  3063. if (se.CreateTimeStart.HasValue)
  3064. {
  3065. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  3066. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3067. }
  3068. if (se.CreateTimeEnd.HasValue)
  3069. {
  3070. selSql.Append(" AND pd.createtime < :CreateTimeEnd\n");
  3071. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3072. }
  3073. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3074. {
  3075. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3076. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3077. }
  3078. if (se.ProductionLineID.HasValue)
  3079. {
  3080. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3081. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3082. }
  3083. if (se.KilnID.HasValue)
  3084. {
  3085. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3086. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3087. }
  3088. sqlString =
  3089. " union all\n" +
  3090. " select distinct ppd.goodsleveltypeid\n" +
  3091. " ,dd.barcode\n" +
  3092. " ,dd.productionlineid\n" +
  3093. " ,dd.goodsid\n" +
  3094. " ,ppd.kilnid\n" +
  3095. " ,ppd.kilncarbatchno\n" +
  3096. " ,dd.defectprocedureid procedureid\n" +
  3097. " ,1 cc\n" +
  3098. " from (select pd.productiondataid\n" +
  3099. " ,pd.goodsleveltypeid\n" +
  3100. " ,pd.kilnid\n" +
  3101. " ,pd.kilncarbatchno\n" +
  3102. " from tp_pm_productiondata pd\n" +
  3103. " where pd.valueflag = '1'\n" +
  3104. " and pd.AccountID = :in_AccountID\n" +
  3105. " and length(pd.kilncarbatchno) > 0\n" +
  3106. " and pd.modeltype = -1\n";
  3107. selSql.Append(sqlString);
  3108. if (se.CreateTimeStart.HasValue)
  3109. {
  3110. //selSql.Append(" AND pd.checktime >= :checktimeStart\n");
  3111. selSql.Append(" AND pd.createtime >= :checktimeStart\n");
  3112. parameters.Add(new OracleParameter(":checktimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3113. }
  3114. if (se.CreateTimeEnd.HasValue)
  3115. {
  3116. //selSql.Append(" AND pd.checktime < :checktimeEnd\n");
  3117. selSql.Append(" AND pd.createtime < :checktimeEnd\n");
  3118. parameters.Add(new OracleParameter(":checktimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3119. }
  3120. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3121. {
  3122. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3123. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3124. }
  3125. if (se.ProductionLineID.HasValue)
  3126. {
  3127. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3128. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3129. }
  3130. if (se.KilnID.HasValue)
  3131. {
  3132. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3133. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3134. }
  3135. sqlString =
  3136. " and exists\n" +
  3137. " (select 1\n" +
  3138. " from tp_pm_productiondata outpd\n" +
  3139. " where outpd.barcode = pd.barcode\n" +
  3140. " and outpd.procedureid = :in_rptSprocedureId\n" +
  3141. " and outpd.valueflag = '1'\n" +
  3142. " and outpd.kilncarbatchno = pd.kilncarbatchno)) ppd\n" +
  3143. " inner join tp_pm_defect dd\n" +
  3144. " on dd.productiondataid = ppd.productiondataid\n" +
  3145. //" --and dd.checktime >= in_DateBegin\n" +
  3146. //" --and dd.checktime <= in_DateEnd\n" +
  3147. " ) ppcc\n" +
  3148. " inner join tp_pm_productiondata pdata\n" +
  3149. " on pdata.barcode = ppcc.barcode\n" +
  3150. // 干补不算交坯工序的质量。
  3151. " and ((pdata.modeltype <> 5) or (pdata.modeltype = 5 and pdata.SpecialRepairFlag = '0')) \n" +
  3152. " and exists\n" +
  3153. " (select 1\n" +
  3154. " from tp_mst_rpttprocedure rptt\n" +
  3155. " where rptt.RPTPROCEDUREID = :in_rptProcedureId \n";
  3156. selSql.Append(sqlString);
  3157. if (!string.IsNullOrEmpty(se.RptTProcedureIDS))
  3158. {
  3159. selSql.Append(" AND instr(','||:rptTprocedureIDS||',', ','||rptt.procedureid||',') > 0\n");
  3160. parameters.Add(new OracleParameter(":rptTprocedureIDS", OracleDbType.NVarchar2, se.RptTProcedureIDS, ParameterDirection.Input));
  3161. }
  3162. sqlString =
  3163. " and rptt.procedureid = pdata.procedureid)\n" +
  3164. " and (ppcc.procedureid = 0 or ppcc.procedureid = pdata.procedureid)\n";
  3165. selSql.Append(sqlString);
  3166. if (!string.IsNullOrEmpty(se.UserIDS))
  3167. {
  3168. selSql.Append(" and instr(','||:userIDS||',', ','||pdata.Userid||',') > 0\n");
  3169. parameters.Add(new OracleParameter(":userIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  3170. }
  3171. sqlString =
  3172. " inner join tp_pc_productionline pcpl\n" +
  3173. " on pcpl.productionlineid = pdata.productionlineid\n" +
  3174. " inner join tp_pc_procedure pcp\n" +
  3175. " on pcp.procedureid = pdata.procedureid\n" +
  3176. " inner join tp_mst_kiln mstkiln\n" +
  3177. " on mstkiln.kilnid = ppcc.kilnid\n" +
  3178. " inner join tp_mst_goods mstgoods\n" +
  3179. " on mstgoods.goodsid = pdata.goodsid\n" +
  3180. " inner join tp_mst_goodstype mstgoodstype\n" +
  3181. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  3182. " and mstgoodstype.accountid = mstgoods.accountid\n" +
  3183. " inner join tp_mst_goodstype mstgoodstype2\n" +
  3184. " on mstgoodstype2.goodstypecode =\n" +
  3185. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  3186. " and mstgoodstype.accountid = mstgoodstype2.accountid\n";
  3187. // 产品类别
  3188. selSql.Append(sqlString);
  3189. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  3190. {
  3191. selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS)=1\n");
  3192. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  3193. }
  3194. sqlString =
  3195. " group by grouping sets((pcpl.productionlinename, pcp.displayno, pcp.procedurename, mstkiln.kilncode, mstgoodstype2.goodstypecode, mstgoodstype2.goodstypename, pdata.usercode, mstgoodstype.goodstypecode, mstgoodstype.goodstypename, mstgoods.goodscode),(pcpl.productionlinename, pcp.displayno, pcp.procedurename, mstkiln.kilncode, mstgoodstype2.goodstypecode, mstgoodstype2.goodstypename),(pcpl.productionlinename, pcp.displayno, pcp.procedurename, mstkiln.kilncode),(pcpl.productionlinename, pcp.displayno, pcp.procedurename))\n" +
  3196. " order by pcpl.productionlinename\n" +
  3197. " ,pcp.displayno\n" +
  3198. " ,pcp.procedurename\n" +
  3199. " ,mstkiln.kilncode\n" +
  3200. " ,mstgoodstype2.goodstypecode\n" +
  3201. " ,pdata.usercode\n" +
  3202. " ,mstgoodstype.goodstypecode\n" +
  3203. " ,mstgoods.goodscode) qdgroup";
  3204. selSql.Append(sqlString);
  3205. return selSql.ToString();
  3206. }
  3207. /// <summary>
  3208. /// 取得RPT040104画面(产成品质量分析表)的查询数据
  3209. /// </summary>
  3210. /// <param name="user">登录用户信息</param>
  3211. /// <param name="se">查询条件</param>
  3212. /// <returns>查询结果</returns>
  3213. public static ServiceResultEntity GetRPT040104SData(SUserInfo user, RPT040104_SE se)
  3214. {
  3215. IDBConnection conn = null;
  3216. try
  3217. {
  3218. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  3219. List<OracleParameter> parameters = new List<OracleParameter>();
  3220. //string sql = ReportModuleLogic.GetRPT040104SSQL(user, se, ref parameters);
  3221. string sql = ReportModuleLogic.GetRPT040104S1SQL(user, se, ref parameters);
  3222. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  3223. ServiceResultEntity sre = new ServiceResultEntity();
  3224. if (data == null || data.Rows.Count == 0)
  3225. {
  3226. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  3227. return sre;
  3228. }
  3229. sre.Data = new DataSet();
  3230. sre.Data.Tables.Add(data);
  3231. return sre;
  3232. }
  3233. catch (Exception ex)
  3234. {
  3235. throw ex;
  3236. }
  3237. finally
  3238. {
  3239. if (conn != null &&
  3240. conn.ConnState == ConnectionState.Open)
  3241. {
  3242. conn.Close();
  3243. }
  3244. }
  3245. }
  3246. /// <summary>
  3247. /// 获取RPT040104画面(产成品质量分析表)的查询sql
  3248. /// </summary>
  3249. /// <returns>sql</returns>
  3250. private static string GetRPT040104SSQL(SUserInfo user, RPT040104_SE se, ref List<OracleParameter> parameters)
  3251. {
  3252. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3253. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  3254. // 2015-06-16 modify by chenxy
  3255. string sqlString = "\n" +
  3256. "select qdgroup.gid,\n" +
  3257. " decode(qdgroup.gid, 7, '总计', 0, qdgroup.productionlinename, '--') productionlinename,\n" +
  3258. " decode(qdgroup.gid, 3, '合计', 0, qdgroup.kilncode, '--') kilncode,\n" +
  3259. " decode(qdgroup.gid, 1, '小计', 0, qdgroup.goodstypename2, '--') goodstypename2,\n" +
  3260. " decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename,\n" +
  3261. " decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode,\n" +
  3262. " qdgroup.OutKilnCount,\n" +
  3263. " qdgroup.GoodCount,\n" +
  3264. " to_char((qdgroup.GoodCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' GoodPercent,\n" +
  3265. " qdgroup.SubstandardCount,\n" +
  3266. " to_char((qdgroup.SubstandardCount / qdgroup.OutKilnCount) * 100,\n" +
  3267. " '990.00') || '%' SubstandardPercent,\n" +
  3268. " qdgroup.GoodCount+qdgroup.BadCount Qualified,\n" +
  3269. " to_char(((qdgroup.GoodCount + qdgroup.BadCount) / qdgroup.OutKilnCount) * 100,\n" +
  3270. " '990.00') || '%' QualifiedPercent,\n" +
  3271. " qdgroup.BadCount,\n" +
  3272. " to_char((qdgroup.BadCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' BadPercent,\n" +
  3273. " qdgroup.ReFireCount,\n" +
  3274. " to_char((qdgroup.ReFireCount / qdgroup.OutKilnCount) * 100,\n" +
  3275. " '990.00') || '%' ReFirePercent\n" +
  3276. " from (select grouping_id(pcpl.productionlinename,\n" +
  3277. " mstkiln.kilncode,\n" +
  3278. " mstgoodstype2.goodstypename,\n" +
  3279. " --mstgoodstype.goodstypename,\n" +
  3280. " mstgoods.goodscode) gid,\n" +
  3281. " pcpl.productionlinename,\n" +
  3282. " --qd.kilnid,\n" +
  3283. " mstkiln.kilncode,\n" +
  3284. " mstgoodstype2.goodstypename goodstypename2,\n" +
  3285. " mstgoodstype.goodstypename,\n" +
  3286. " mstgoods.goodscode,\n" +
  3287. " sum(qd.OutKilnCount) OutKilnCount,\n" +
  3288. " sum(qd.GoodCount) GoodCount,\n" +
  3289. " sum(qd.SubstandardCount) SubstandardCount,\n" +
  3290. " sum(qd.BadCount) BadCount,\n" +
  3291. " sum(qd.ReFireCount) ReFireCount\n" +
  3292. " from (select --pdbc.barcode,\n" +
  3293. " pdbc.productionlineid,\n" +
  3294. " pdbc.goodsid,\n" +
  3295. " pdbc.kilnid,\n" +
  3296. " --pdbc.kilncarid,\n" +
  3297. " --pdbc.kilncarbatchno,\n" +
  3298. " 1 OutKilnCount,\n" +
  3299. " case\n" +
  3300. " when glt.goodsleveltypeid in (5, 6, 7) then\n" +
  3301. " 0\n" +
  3302. " else\n" +
  3303. " 1\n" +
  3304. " end GoodCount,\n" +
  3305. " case\n" +
  3306. " when glt.goodsleveltypeid = 7 then\n" +
  3307. " 1\n" +
  3308. " else\n" +
  3309. " 0\n" +
  3310. " end SubstandardCount,\n" +
  3311. " case\n" +
  3312. " when glt.goodsleveltypeid = 6 then\n" +
  3313. " 1\n" +
  3314. " else\n" +
  3315. " 0\n" +
  3316. " end ReFireCount,\n" +
  3317. " case\n" +
  3318. " when glt.goodsleveltypeid = 5 then\n" +
  3319. " 1\n" +
  3320. " else\n" +
  3321. " 0\n" +
  3322. " end BadCount\n" +
  3323. " from (select distinct pd.barcode,\n" +
  3324. " pd.productionlineid,\n" +
  3325. " pd.goodsid,\n" +
  3326. " pd.kilnid,\n" +
  3327. " --pd.kilncarid,\n" +
  3328. " pd.kilncarbatchno\n" +
  3329. " from tp_pm_productiondata pd\n" +
  3330. " where pd.valueflag = '1'\n" +
  3331. " and pd.procedureid = :in_rptSprocedureId \n" +
  3332. " and pd.AccountID = :AccountID\n";
  3333. StringBuilder selSql = new StringBuilder(sqlString);
  3334. if (se.CreateTimeStart.HasValue)
  3335. {
  3336. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  3337. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3338. }
  3339. if (se.CreateTimeEnd.HasValue)
  3340. {
  3341. selSql.Append(" AND pd.createtime <= :CreateTimeEnd\n");
  3342. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3343. }
  3344. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3345. {
  3346. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3347. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3348. }
  3349. if (se.ProductionLineID.HasValue)
  3350. {
  3351. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3352. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3353. }
  3354. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  3355. {
  3356. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  3357. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  3358. }
  3359. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  3360. {
  3361. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  3362. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  3363. }
  3364. //selSql.Append(" AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 7 and up.UserID = :UserID and (up.PurviewID=-1 or up.PurviewID= pd.ProductionLineId))");
  3365. //parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  3366. if (se.KilnID.HasValue)
  3367. {
  3368. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3369. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3370. }
  3371. sqlString =
  3372. " ) pdbc\n" +
  3373. " left join (select kcbc.barcode, kcbc.kilncarbatchno, kcbc.goodsleveltypeid\n" +
  3374. " from (select pd.barcode,\n" +
  3375. " pd.kilncarbatchno,\n" +
  3376. " pd.goodsleveltypeid,\n" +
  3377. " pd.productiondataid,\n" +
  3378. " ROW_NUMBER() OVER(PARTITION BY pd.barcode, pd.kilncarbatchno ORDER BY pd.productiondataid desc) AS dataid\n" +
  3379. " from tp_pm_productiondata pd\n" +
  3380. " where pd.valueflag = '1'\n" +
  3381. " and pd.AccountID = :AccountID\n" +
  3382. " and length(pd.kilncarbatchno) > 0\n" +
  3383. " AND pd.createtime >= :CreateTimeStart\n" +
  3384. " and pd.modeltype = -1) kcbc\n" +
  3385. " where kcbc.dataid = 1) glt\n" +
  3386. " on pdbc.kilncarbatchno = glt.kilncarbatchno\n" +
  3387. " and pdbc.barcode = glt.barcode) qd\n" +
  3388. " inner join tp_pc_productionline pcpl\n" +
  3389. " on pcpl.productionlineid = qd.productionlineid\n" +
  3390. " inner join tp_mst_kiln mstkiln\n" +
  3391. " on mstkiln.kilnid = qd.kilnid\n" +
  3392. " inner join tp_mst_goods mstgoods\n" +
  3393. " on mstgoods.goodsid = qd.goodsid\n" +
  3394. " inner join tp_mst_goodstype mstgoodstype\n" +
  3395. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  3396. " and mstgoodstype.accountid = mstgoods.accountid\n" +
  3397. " inner join tp_mst_goodstype mstgoodstype2\n" +
  3398. " on mstgoodstype2.goodstypecode =\n" +
  3399. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  3400. " and mstgoodstype.accountid = mstgoodstype2.accountid\n" +
  3401. " where 1=1\n";
  3402. selSql.Append(sqlString);
  3403. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  3404. {
  3405. //selSql.Append(" AND instr(','||:GoodsTypeIDS||',', ','||mstgoodstype.GOODSTYPECode||',') =1\n");
  3406. selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS) =1\n");
  3407. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  3408. }
  3409. sqlString =
  3410. " group by grouping sets((pcpl.productionlinename,\n" +
  3411. " mstkiln.kilncode,\n" +
  3412. " mstgoodstype2.goodstypename,\n" +
  3413. " mstgoodstype.goodstypename,\n" +
  3414. " mstgoods.goodscode),\n" +
  3415. " (pcpl.productionlinename,\n" +
  3416. " mstkiln.kilncode,\n" +
  3417. " mstgoodstype2.goodstypename),\n" +
  3418. " (pcpl.productionlinename,\n" +
  3419. " mstkiln.kilncode),\n" +
  3420. " pcpl.productionlinename)\n" +
  3421. " order by pcpl.productionlinename,\n" +
  3422. " mstkiln.kilncode,\n" +
  3423. " mstgoodstype2.goodstypename,\n" +
  3424. " mstgoodstype.goodstypename,\n" +
  3425. " mstgoods.goodscode\n" +
  3426. " ) qdgroup\n";
  3427. selSql.Append(sqlString);
  3428. return selSql.ToString();
  3429. }
  3430. /// <summary>
  3431. /// 获取RPT040104画面(产成品质量分析表-按登记时间)的查询sql
  3432. /// </summary>
  3433. /// <returns>sql</returns>
  3434. private static string GetRPT040104S1SQL(SUserInfo user, RPT040104_SE se, ref List<OracleParameter> parameters)
  3435. {
  3436. parameters.Add(new OracleParameter(":in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3437. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  3438. string sqlString = "select qdgroup.gid\n" +
  3439. " ,decode(qdgroup.gid, 7, '总计', qdgroup.productionlinename) productionlinename\n" +
  3440. " ,decode(qdgroup.gid\n" +
  3441. " ,3\n" +
  3442. " ,'合计[' || qdgroup.kilncode || ']'\n" +
  3443. " ,7\n" +
  3444. " ,'--'\n" +
  3445. " ,qdgroup.kilncode) kilncode\n" +
  3446. " ,decode(qdgroup.gid\n" +
  3447. " ,1\n" +
  3448. " ,'小计[' || qdgroup.goodstypename2 || ']'\n" +
  3449. " ,0\n" +
  3450. " ,qdgroup.goodstypename2\n" +
  3451. " ,'--') goodstypename2\n" +
  3452. " ,decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename\n" +
  3453. " ,decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode\n" +
  3454. " ,qdgroup.OutKilnCount\n" +
  3455. " ,qdgroup.GoodCount\n" +
  3456. " ,decode(qdgroup.OutKilnCount\n" +
  3457. " ,0\n" +
  3458. " ,to_number(null)\n" +
  3459. " ,round(qdgroup.GoodCount / qdgroup.OutKilnCount, 4)) GoodPercent\n" +
  3460. " ,qdgroup.SubstandardCount\n" +
  3461. " ,decode(qdgroup.OutKilnCount\n" +
  3462. " ,0\n" +
  3463. " ,to_number(null)\n" +
  3464. " ,round(qdgroup.SubstandardCount / qdgroup.OutKilnCount, 4)) SubstandardPercent\n" +
  3465. " ,qdgroup.GoodCount + qdgroup.BadCount Qualified\n" +
  3466. " ,decode(qdgroup.OutKilnCount\n" +
  3467. " ,0\n" +
  3468. " ,to_number(null)\n" +
  3469. " ,round((qdgroup.GoodCount + qdgroup.BadCount) /\n" +
  3470. " qdgroup.OutKilnCount\n" +
  3471. " ,4)) QualifiedPercent\n" +
  3472. " ,qdgroup.BadCount\n" +
  3473. " ,decode(qdgroup.OutKilnCount\n" +
  3474. " ,0\n" +
  3475. " ,to_number(null)\n" +
  3476. " ,round(qdgroup.BadCount / qdgroup.OutKilnCount, 4)) BadPercent\n" +
  3477. " ,qdgroup.ReFireCount\n" +
  3478. " ,decode(qdgroup.OutKilnCount\n" +
  3479. " ,0\n" +
  3480. " ,to_number(null)\n" +
  3481. " ,round(qdgroup.ReFireCount / qdgroup.OutKilnCount, 4)) ReFirePercent\n" +
  3482. " from (select grouping_id(pcpl.productionlinename\n" +
  3483. " ,mstkiln.kilncode\n" +
  3484. " ,mstgoodstype2.goodstypecode\n" +
  3485. " ,mstgoods.goodscode) gid\n" +
  3486. " ,pcpl.productionlinename\n" +
  3487. " ,mstkiln.kilncode\n" +
  3488. " ,mstgoodstype2.goodstypename goodstypename2\n" +
  3489. " ,mstgoodstype.goodstypename\n" +
  3490. " ,mstgoods.goodscode\n" +
  3491. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 0)), 0) OutKilnCount\n" +
  3492. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 5, 1, 0)), 0) BadCount\n" +
  3493. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 6, 1, 0)), 0) ReFireCount\n" +
  3494. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 7, 1, 0)), 0) SubstandardCount\n" +
  3495. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 5, -1, 6, -1, 7, -1, 0)), 0) GoodCount\n" +
  3496. " from (select 0 goodsleveltypeid -- 出窑数量\n" +
  3497. " ,pd.barcode\n" +
  3498. " ,pd.productionlineid\n" +
  3499. " ,pd.goodsid\n" +
  3500. " ,pd.kilnid\n" +
  3501. " ,pd.kilncarbatchno\n" +
  3502. " ,1 cc\n" +
  3503. " from tp_pm_productiondata pd\n" +
  3504. " where pd.valueflag = '1'\n" +
  3505. " and pd.procedureid = :in_rptSprocedureId\n" +
  3506. " and pd.accountid = :in_AccountID\n";
  3507. StringBuilder selSql = new StringBuilder(sqlString);
  3508. if (se.CreateTimeStart.HasValue)
  3509. {
  3510. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  3511. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3512. }
  3513. if (se.CreateTimeEnd.HasValue)
  3514. {
  3515. selSql.Append(" AND pd.createtime < :CreateTimeEnd\n");
  3516. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3517. }
  3518. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3519. {
  3520. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3521. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3522. }
  3523. if (se.ProductionLineID.HasValue)
  3524. {
  3525. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3526. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3527. }
  3528. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  3529. {
  3530. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  3531. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  3532. }
  3533. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  3534. {
  3535. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  3536. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  3537. }
  3538. if (se.KilnID.HasValue)
  3539. {
  3540. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3541. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3542. }
  3543. sqlString =
  3544. " union all\n" +
  3545. " select distinct pd.goodsleveltypeid\n" +
  3546. " ,pd.barcode\n" +
  3547. " ,pd.productionlineid\n" +
  3548. " ,pd.goodsid\n" +
  3549. " ,pd.kilnid\n" +
  3550. " ,pd.kilncarbatchno\n" +
  3551. " ,1 cc\n" +
  3552. " from tp_pm_productiondata pd\n" +
  3553. " where pd.valueflag = '1'\n" +
  3554. " and pd.modeltype = -1\n" +
  3555. " and pd.AccountID = :in_AccountID\n" +
  3556. " and length(pd.kilncarbatchno) > 0\n";
  3557. selSql.Append(sqlString);
  3558. if (se.CreateTimeStart.HasValue)
  3559. {
  3560. //selSql.Append(" AND pd.checktime >= :checktimeStart\n");
  3561. selSql.Append(" AND pd.createtime >= :checktimeStart\n");
  3562. parameters.Add(new OracleParameter(":checktimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3563. }
  3564. if (se.CreateTimeEnd.HasValue)
  3565. {
  3566. //selSql.Append(" AND pd.checktime < :checktimeEnd\n");
  3567. selSql.Append(" AND pd.createtime < :checktimeEnd\n");
  3568. parameters.Add(new OracleParameter(":checktimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3569. }
  3570. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3571. {
  3572. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3573. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3574. }
  3575. if (se.ProductionLineID.HasValue)
  3576. {
  3577. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3578. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3579. }
  3580. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  3581. {
  3582. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  3583. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  3584. }
  3585. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  3586. {
  3587. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  3588. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  3589. }
  3590. if (se.KilnID.HasValue)
  3591. {
  3592. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3593. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3594. }
  3595. sqlString =
  3596. " and exists\n" +
  3597. " (select 1\n" +
  3598. " from tp_pm_productiondata outpd\n" +
  3599. " where outpd.barcode = pd.barcode\n" +
  3600. " and outpd.procedureid = :in_rptSprocedureId\n" +
  3601. " and outpd.valueflag = '1'\n" +
  3602. " and outpd.kilncarbatchno = pd.kilncarbatchno)) ppcc\n" +
  3603. " inner join tp_pc_productionline pcpl\n" +
  3604. " on pcpl.productionlineid = ppcc.productionlineid\n" +
  3605. " inner join tp_mst_kiln mstkiln\n" +
  3606. " on mstkiln.kilnid = ppcc.kilnid\n" +
  3607. " inner join tp_mst_goods mstgoods\n" +
  3608. " on mstgoods.goodsid = ppcc.goodsid\n" +
  3609. " inner join tp_mst_goodstype mstgoodstype\n" +
  3610. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  3611. " and mstgoodstype.accountid = mstgoods.accountid\n" +
  3612. " inner join tp_mst_goodstype mstgoodstype2\n" +
  3613. " on mstgoodstype2.goodstypecode =\n" +
  3614. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  3615. " and mstgoodstype.accountid = mstgoodstype2.accountid\n";
  3616. // 产品类别
  3617. selSql.Append(sqlString);
  3618. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  3619. {
  3620. selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS)=1\n");
  3621. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  3622. }
  3623. sqlString =
  3624. " group by grouping sets((pcpl.productionlinename, mstkiln.kilncode, mstgoodstype2.goodstypecode, mstgoodstype2.goodstypename, mstgoodstype.goodstypecode, mstgoodstype.goodstypename, mstgoods.goodscode),(pcpl.productionlinename, mstkiln.kilncode, mstgoodstype2.goodstypecode, mstgoodstype2.goodstypename),(pcpl.productionlinename, mstkiln.kilncode),(pcpl.productionlinename))\n" +
  3625. " order by pcpl.productionlinename\n" +
  3626. " ,mstkiln.kilncode\n" +
  3627. " ,mstgoodstype2.goodstypecode\n" +
  3628. " ,mstgoodstype.goodstypecode\n" +
  3629. " ,mstgoods.goodscode) qdgroup\n";
  3630. selSql.Append(sqlString);
  3631. return selSql.ToString();
  3632. }
  3633. /// <summary>
  3634. /// 取得RPT040105画面(质量报表)的查询数据
  3635. /// </summary>
  3636. /// <param name="user">登录用户信息</param>
  3637. /// <param name="se">查询条件</param>
  3638. /// <returns>查询结果</returns>
  3639. public static ServiceResultEntity GetRPT040105SData(SUserInfo user, RPT040105_SE se)
  3640. {
  3641. IDBConnection conn = null;
  3642. try
  3643. {
  3644. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  3645. List<OracleParameter> parameters = new List<OracleParameter>();
  3646. string sqlString =
  3647. "SELECT substr(gt.goodstypecode, 1, 6) goodstypecode2, COUNT(*) barcodecount\n" +
  3648. " FROM tp_pm_groutingdailydetail gdd\n" +
  3649. " INNER JOIN tp_mst_goods g\n" +
  3650. " ON g.goodsid = gdd.goodsid\n" +
  3651. " INNER JOIN tp_mst_goodstype gt\n" +
  3652. " ON gt.goodstypeid = g.goodstypeid\n" +
  3653. " WHERE gdd.accountid = :accountid\n" +
  3654. " AND gdd.valueflag = '1'\n" +
  3655. " AND gdd.groutingdate >= :datebegin\n" +
  3656. " AND gdd.groutingdate <= :dateend\n" +
  3657. " AND gdd.groutingflag = '1'\n" +
  3658. " AND gdd.barcode IS NOT NULL\n" +
  3659. " GROUP BY GROUPING SETS(substr(gt.goodstypecode, 1, 6),())";
  3660. parameters.Add(new OracleParameter(":accountid", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3661. parameters.Add(new OracleParameter(":datebegin", OracleDbType.Date, se.CreateTimeStart.Value.Date, ParameterDirection.Input));
  3662. parameters.Add(new OracleParameter(":dateend", OracleDbType.Date, se.CreateTimeEnd.Value.Date, ParameterDirection.Input));
  3663. DataTable dataCount = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  3664. parameters.Clear();
  3665. //string sql = ReportModuleLogic.GetRPT040105SSQL(user, se, ref parameters);
  3666. string sql = ReportModuleLogic.GetRPT040105S1SQL(user, se, ref parameters);
  3667. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  3668. ServiceResultEntity sre = new ServiceResultEntity();
  3669. if (data == null || data.Rows.Count == 0)
  3670. {
  3671. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  3672. return sre;
  3673. }
  3674. data.Columns.Add("GCount", typeof(int));
  3675. //data.Columns.Add("OutGCount", typeof(string));
  3676. //data.Columns.Add("GoodGCount", typeof(string));
  3677. data.Columns.Add("OutGCount", typeof(decimal));
  3678. data.Columns.Add("GoodGCount", typeof(decimal));
  3679. foreach (DataRow item in data.Rows)
  3680. {
  3681. int gid = Convert.ToInt32(item["gid"]);
  3682. if (gid < 2)
  3683. {
  3684. continue;
  3685. }
  3686. int outKilnCount = Convert.ToInt32(item["OutKilnCount"]);
  3687. int goodCount = Convert.ToInt32(item["Qualified"]);
  3688. DataRow[] drs = null;
  3689. if (gid == 2)
  3690. {
  3691. drs = dataCount.Select("goodstypecode2 = '" + item["goodstypecode2"].ToString() + "'");
  3692. }
  3693. else if (gid == 3)
  3694. {
  3695. drs = dataCount.Select("goodstypecode2 is null");
  3696. }
  3697. if (drs != null && drs.Length > 0)
  3698. {
  3699. int barcodecount = Convert.ToInt32(drs[0]["barcodecount"]);
  3700. item["GCount"] = barcodecount;
  3701. //item["OutGCount"] = (outKilnCount * 1.0 / barcodecount).ToString("#,##0.00%");
  3702. //item["GoodGCount"] = (goodCount * 1.0 / barcodecount).ToString("#,##0.00%");
  3703. item["OutGCount"] = Math.Round(outKilnCount * 1.0 / barcodecount, 4);
  3704. item["GoodGCount"] = Math.Round(goodCount * 1.0 / barcodecount, 4);
  3705. }
  3706. else
  3707. {
  3708. item["GCount"] = 0;
  3709. //item["OutGCount"] = "#DIV/0!";
  3710. //item["GoodGCount"] = "#DIV/0!";
  3711. item["OutGCount"] = DBNull.Value;
  3712. item["GoodGCount"] = DBNull.Value;
  3713. }
  3714. }
  3715. sre.Data = new DataSet();
  3716. sre.Data.Tables.Add(data);
  3717. return sre;
  3718. }
  3719. catch (Exception ex)
  3720. {
  3721. throw ex;
  3722. }
  3723. finally
  3724. {
  3725. if (conn != null &&
  3726. conn.ConnState == ConnectionState.Open)
  3727. {
  3728. conn.Close();
  3729. }
  3730. }
  3731. }
  3732. /// <summary>
  3733. /// 获取RPT040105画面(质量报表)的查询sql
  3734. /// </summary>
  3735. /// <returns>sql</returns>
  3736. private static string GetRPT040105SSQL(SUserInfo user, RPT040105_SE se, ref List<OracleParameter> parameters)
  3737. {
  3738. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3739. parameters.Add(new OracleParameter(":OutProcedureIDS", OracleDbType.Varchar2, se.OutProcedureIDS, ParameterDirection.Input));
  3740. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  3741. // 2015-06-16 modify by chenxy
  3742. string sqlString = "\n" +
  3743. "select qdgroup.gid,\n" +
  3744. " decode(qdgroup.gid, 3, '总计', 0, qdgroup.productionlinename, '--') productionlinename,\n" +
  3745. " decode(qdgroup.gid, 1, '合计【'||qdgroup.kilncode||'】', 0, qdgroup.kilncode, '--') kilncode,\n" +
  3746. " decode(qdgroup.gid, 2, '合计【'||qdgroup.goodstypename2||'】', 0, qdgroup.goodstypename2, '--') goodstypename2,\n" +
  3747. " qdgroup.goodstypecode2,\n" +
  3748. " qdgroup.OutKilnCount,\n" +
  3749. " qdgroup.GoodCount,\n" +
  3750. " to_char((qdgroup.GoodCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' GoodPercent,\n" +
  3751. " qdgroup.SubstandardCount,\n" +
  3752. " to_char((qdgroup.SubstandardCount / qdgroup.OutKilnCount) * 100,\n" +
  3753. " '990.00') || '%' SubstandardPercent,\n" +
  3754. " qdgroup.GoodCount+qdgroup.BadCount Qualified,\n" +
  3755. " to_char(((qdgroup.GoodCount + qdgroup.BadCount) / qdgroup.OutKilnCount) * 100,\n" +
  3756. " '990.00') || '%' QualifiedPercent,\n" +
  3757. " qdgroup.BadCount,\n" +
  3758. " to_char((qdgroup.BadCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' BadPercent,\n" +
  3759. " qdgroup.ReFireCount,\n" +
  3760. " to_char((qdgroup.ReFireCount / qdgroup.OutKilnCount) * 100,\n" +
  3761. " '990.00') || '%' ReFirePercent\n" +
  3762. " from (select grouping_id(pcpl.productionlinename,\n" +
  3763. " mstkiln.kilncode,\n" +
  3764. " mstgoodstype2.goodstypecode) gid,\n" +
  3765. " pcpl.productionlinename,\n" +
  3766. " mstkiln.kilncode,\n" +
  3767. " mstgoodstype2.goodstypecode goodstypecode2,\n" +
  3768. " mstgoodstype2.goodstypename goodstypename2,\n" +
  3769. " sum(qd.OutKilnCount) OutKilnCount,\n" +
  3770. " sum(qd.GoodCount) GoodCount,\n" +
  3771. " sum(qd.SubstandardCount) SubstandardCount,\n" +
  3772. " sum(qd.BadCount) BadCount,\n" +
  3773. " sum(qd.ReFireCount) ReFireCount\n" +
  3774. " from (select --pdbc.barcode,\n" +
  3775. " pdbc.productionlineid,\n" +
  3776. " pdbc.goodsid,\n" +
  3777. " pdbc.kilnid,\n" +
  3778. " 1 OutKilnCount,\n" +
  3779. " case\n" +
  3780. " when glt.goodsleveltypeid in (5, 6, 7) then\n" +
  3781. " 0\n" +
  3782. " else\n" +
  3783. " 1\n" +
  3784. " end GoodCount,\n" +
  3785. " case\n" +
  3786. " when glt.goodsleveltypeid = 7 then\n" +
  3787. " 1\n" +
  3788. " else\n" +
  3789. " 0\n" +
  3790. " end SubstandardCount,\n" +
  3791. " case\n" +
  3792. " when glt.goodsleveltypeid = 6 then\n" +
  3793. " 1\n" +
  3794. " else\n" +
  3795. " 0\n" +
  3796. " end ReFireCount,\n" +
  3797. " case\n" +
  3798. " when glt.goodsleveltypeid = 5 then\n" +
  3799. " 1\n" +
  3800. " else\n" +
  3801. " 0\n" +
  3802. " end BadCount\n" +
  3803. " from (select distinct pd.barcode,\n" +
  3804. " pd.productionlineid,\n" +
  3805. " pd.goodsid,\n" +
  3806. " pd.kilnid,\n" +
  3807. " pd.kilncarbatchno\n" +
  3808. " from tp_pm_productiondata pd\n" +
  3809. " where pd.valueflag = '1'\n" +
  3810. " and (:in_rptSprocedureId is null or pd.procedureid = :in_rptSprocedureId) \n" +
  3811. " and (:OutProcedureIDS is null or instr(','||:OutProcedureIDS||',', ','||pd.procedureid||',') > 0) \n" +
  3812. " and pd.AccountID = :AccountID\n";
  3813. StringBuilder selSql = new StringBuilder(sqlString);
  3814. if (se.CreateTimeStart.HasValue)
  3815. {
  3816. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  3817. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3818. }
  3819. if (se.CreateTimeEnd.HasValue)
  3820. {
  3821. selSql.Append(" AND pd.createtime <= :CreateTimeEnd\n");
  3822. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3823. }
  3824. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3825. {
  3826. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3827. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3828. }
  3829. if (se.ProductionLineID.HasValue)
  3830. {
  3831. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3832. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3833. }
  3834. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  3835. {
  3836. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  3837. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  3838. }
  3839. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  3840. {
  3841. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  3842. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  3843. }
  3844. // 不控制权限
  3845. //selSql.Append(" AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 7 and up.UserID = :UserID and (up.PurviewID=-1 or up.PurviewID= pd.ProductionLineId))");
  3846. //parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  3847. if (se.KilnID.HasValue)
  3848. {
  3849. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3850. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3851. }
  3852. sqlString =
  3853. " ) pdbc\n" +
  3854. " left join (select kcbc.barcode, kcbc.kilncarbatchno, kcbc.goodsleveltypeid\n" +
  3855. " from (select pd.barcode,\n" +
  3856. " pd.kilncarbatchno,\n" +
  3857. " pd.goodsleveltypeid,\n" +
  3858. " pd.productiondataid,\n" +
  3859. " ROW_NUMBER() OVER(PARTITION BY pd.barcode, pd.kilncarbatchno ORDER BY pd.productiondataid desc) AS dataid\n" +
  3860. " from tp_pm_productiondata pd\n" +
  3861. " where pd.valueflag = '1'\n" +
  3862. " and pd.AccountID = :AccountID\n" +
  3863. " and length(pd.kilncarbatchno) > 0\n" +
  3864. " AND pd.createtime >= :CreateTimeStart\n" +
  3865. " and pd.modeltype = -1) kcbc\n" +
  3866. " where kcbc.dataid = 1) glt\n" +
  3867. " on pdbc.kilncarbatchno = glt.kilncarbatchno\n" +
  3868. " and pdbc.barcode = glt.barcode) qd\n" +
  3869. " inner join tp_pc_productionline pcpl\n" +
  3870. " on pcpl.productionlineid = qd.productionlineid\n" +
  3871. " inner join tp_mst_kiln mstkiln\n" +
  3872. " on mstkiln.kilnid = qd.kilnid\n" +
  3873. " inner join tp_mst_goods mstgoods\n" +
  3874. " on mstgoods.goodsid = qd.goodsid\n" +
  3875. " inner join tp_mst_goodstype mstgoodstype\n" +
  3876. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  3877. " inner join tp_mst_goodstype mstgoodstype2\n" +
  3878. " on mstgoodstype2.goodstypecode =\n" +
  3879. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  3880. " and mstgoodstype.accountid = mstgoodstype2.accountid\n" +
  3881. " where 1=1\n";
  3882. selSql.Append(sqlString);
  3883. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  3884. {
  3885. selSql.Append(" AND instr(','||:GoodsTypeIDS||',', ','||mstgoods.GOODSTYPEId||',') > 0\n");
  3886. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  3887. }
  3888. sqlString =
  3889. " group by grouping sets((pcpl.productionlinename,\n" +
  3890. " mstkiln.kilncode,\n" +
  3891. " mstgoodstype2.goodstypecode,\n" +
  3892. " mstgoodstype2.goodstypename),\n" +
  3893. " (pcpl.productionlinename,\n" +
  3894. " mstgoodstype2.goodstypecode,\n" +
  3895. " mstgoodstype2.goodstypename),\n" +
  3896. " (pcpl.productionlinename,\n" +
  3897. " mstkiln.kilncode),\n" +
  3898. " pcpl.productionlinename)\n" +
  3899. " order by pcpl.productionlinename,\n" +
  3900. " mstkiln.kilncode,\n" +
  3901. " mstgoodstype2.goodstypename\n" +
  3902. " ) qdgroup\n";
  3903. selSql.Append(sqlString);
  3904. return selSql.ToString();
  3905. }
  3906. /// <summary>
  3907. /// 获取RPT040105画面(质量报表-按登记时间)的查询sql
  3908. /// </summary>
  3909. /// <returns>sql</returns>
  3910. private static string GetRPT040105S1SQL(SUserInfo user, RPT040105_SE se, ref List<OracleParameter> parameters)
  3911. {
  3912. parameters.Add(new OracleParameter(":in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3913. parameters.Add(new OracleParameter(":in_OutProcedureIDS", OracleDbType.Varchar2, se.OutProcedureIDS, ParameterDirection.Input));
  3914. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  3915. string sqlString = "select qdgroup.gid\n" +
  3916. " ,decode(qdgroup.gid, 3, '总计', qdgroup.productionlinename) productionlinename\n" +
  3917. " ,decode(qdgroup.gid\n" +
  3918. " ,1\n" +
  3919. " ,'合计[' || qdgroup.kilncode || ']'\n" +
  3920. " ,0\n" +
  3921. " ,qdgroup.kilncode\n" +
  3922. " ,'--') kilncode\n" +
  3923. " ,decode(qdgroup.gid\n" +
  3924. " ,2\n" +
  3925. " ,'合计[' || qdgroup.goodstypename2 || ']'\n" +
  3926. " ,0\n" +
  3927. " ,qdgroup.goodstypename2\n" +
  3928. " ,'--') goodstypename2\n" +
  3929. " ,qdgroup.goodstypecode2\n" +
  3930. //" ,decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename\n" +
  3931. //" ,decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode\n" +
  3932. " ,qdgroup.OutKilnCount\n" +
  3933. " ,qdgroup.GoodCount\n" +
  3934. " ,decode(qdgroup.OutKilnCount\n" +
  3935. " ,0\n" +
  3936. " ,to_number(null)\n" +
  3937. " ,round(qdgroup.GoodCount / qdgroup.OutKilnCount, 4)) GoodPercent\n" +
  3938. " ,qdgroup.SubstandardCount\n" +
  3939. " ,decode(qdgroup.OutKilnCount\n" +
  3940. " ,0\n" +
  3941. " ,to_number(null)\n" +
  3942. " ,round(qdgroup.SubstandardCount / qdgroup.OutKilnCount, 4)) SubstandardPercent\n" +
  3943. " ,qdgroup.GoodCount + qdgroup.BadCount Qualified\n" +
  3944. " ,decode(qdgroup.OutKilnCount\n" +
  3945. " ,0\n" +
  3946. " ,to_number(null)\n" +
  3947. " ,round((qdgroup.GoodCount + qdgroup.BadCount) /\n" +
  3948. " qdgroup.OutKilnCount\n" +
  3949. " ,4)) QualifiedPercent\n" +
  3950. " ,qdgroup.BadCount\n" +
  3951. " ,decode(qdgroup.OutKilnCount\n" +
  3952. " ,0\n" +
  3953. " ,to_number(null)\n" +
  3954. " ,round(qdgroup.BadCount / qdgroup.OutKilnCount, 4)) BadPercent\n" +
  3955. " ,qdgroup.ReFireCount\n" +
  3956. " ,decode(qdgroup.OutKilnCount\n" +
  3957. " ,0\n" +
  3958. " ,to_number(null)\n" +
  3959. " ,round(qdgroup.ReFireCount / qdgroup.OutKilnCount, 4)) ReFirePercent\n" +
  3960. " from (select grouping_id(pcpl.productionlinename\n" +
  3961. " ,mstkiln.kilncode\n" +
  3962. " ,mstgoodstype2.goodstypecode) gid\n" +
  3963. " ,pcpl.productionlinename\n" +
  3964. " ,mstkiln.kilncode\n" +
  3965. " ,mstgoodstype2.goodstypename goodstypename2\n" +
  3966. " ,mstgoodstype2.goodstypecode goodstypecode2\n" +
  3967. //" ,mstgoodstype.goodstypename\n" +
  3968. //" ,mstgoods.goodscode\n" +
  3969. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 0)), 0) OutKilnCount\n" +
  3970. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 5, 1, 0)), 0) BadCount\n" +
  3971. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 6, 1, 0)), 0) ReFireCount\n" +
  3972. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 7, 1, 0)), 0) SubstandardCount\n" +
  3973. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 5, -1, 6, -1, 7, -1, 0)), 0) GoodCount\n" +
  3974. " from (select 0 goodsleveltypeid -- 出窑数量\n" +
  3975. " ,pd.barcode\n" +
  3976. " ,pd.productionlineid\n" +
  3977. " ,pd.goodsid\n" +
  3978. " ,pd.kilnid\n" +
  3979. " ,pd.kilncarbatchno\n" +
  3980. " ,1 cc\n" +
  3981. " from tp_pm_productiondata pd\n" +
  3982. " where pd.valueflag = '1'\n" +
  3983. " and (:in_rptSprocedureId is null or pd.procedureid = :in_rptSprocedureId)\n" +
  3984. " and (:in_OutProcedureIDS is null or instr(','||:in_OutProcedureIDS||',', ','||pd.procedureid||',') > 0)\n" +
  3985. " and pd.accountid = :in_AccountID\n";
  3986. StringBuilder selSql = new StringBuilder(sqlString);
  3987. if (se.CreateTimeStart.HasValue)
  3988. {
  3989. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  3990. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3991. }
  3992. if (se.CreateTimeEnd.HasValue)
  3993. {
  3994. selSql.Append(" AND pd.createtime < :CreateTimeEnd\n");
  3995. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3996. }
  3997. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3998. {
  3999. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  4000. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  4001. }
  4002. if (se.ProductionLineID.HasValue)
  4003. {
  4004. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  4005. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  4006. }
  4007. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  4008. {
  4009. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  4010. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  4011. }
  4012. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  4013. {
  4014. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  4015. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  4016. }
  4017. if (se.KilnID.HasValue)
  4018. {
  4019. selSql.Append(" AND pd.KilnID = :KilnID\n");
  4020. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  4021. }
  4022. sqlString =
  4023. " union all\n" +
  4024. " select distinct pd.goodsleveltypeid\n" +
  4025. " ,pd.barcode\n" +
  4026. " ,pd.productionlineid\n" +
  4027. " ,pd.goodsid\n" +
  4028. " ,pd.kilnid\n" +
  4029. " ,pd.kilncarbatchno\n" +
  4030. " ,1 cc\n" +
  4031. " from tp_pm_productiondata pd\n" +
  4032. " where pd.valueflag = '1'\n" +
  4033. " and pd.modeltype = -1\n" +
  4034. " and pd.AccountID = :in_AccountID\n" +
  4035. " and length(pd.kilncarbatchno) > 0\n";
  4036. selSql.Append(sqlString);
  4037. if (se.CreateTimeStart.HasValue)
  4038. {
  4039. //selSql.Append(" AND pd.checktime >= :checktimeStart\n");
  4040. selSql.Append(" AND pd.createtime >= :checktimeStart\n");
  4041. parameters.Add(new OracleParameter(":checktimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  4042. }
  4043. if (se.CreateTimeEnd.HasValue)
  4044. {
  4045. //selSql.Append(" AND pd.checktime < :checktimeEnd\n");
  4046. selSql.Append(" AND pd.createtime < :checktimeEnd\n");
  4047. parameters.Add(new OracleParameter(":checktimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  4048. }
  4049. if (!string.IsNullOrEmpty(se.GoodsIDS))
  4050. {
  4051. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  4052. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  4053. }
  4054. if (se.ProductionLineID.HasValue)
  4055. {
  4056. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  4057. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  4058. }
  4059. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  4060. {
  4061. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  4062. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  4063. }
  4064. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  4065. {
  4066. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  4067. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  4068. }
  4069. if (se.KilnID.HasValue)
  4070. {
  4071. selSql.Append(" AND pd.KilnID = :KilnID\n");
  4072. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  4073. }
  4074. sqlString =
  4075. " and exists\n" +
  4076. " (select 1\n" +
  4077. " from tp_pm_productiondata outpd\n" +
  4078. " where outpd.barcode = pd.barcode\n" +
  4079. //" and outpd.procedureid = :in_rptSprocedureId\n" +
  4080. " and (:in_rptSprocedureId is null or outpd.procedureid = :in_rptSprocedureId)\n" +
  4081. " and (:in_OutProcedureIDS is null or instr(','||:in_OutProcedureIDS||',', ','||outpd.procedureid||',') > 0)\n" +
  4082. " and outpd.valueflag = '1'\n" +
  4083. " and outpd.kilncarbatchno = pd.kilncarbatchno)) ppcc\n" +
  4084. " inner join tp_pc_productionline pcpl\n" +
  4085. " on pcpl.productionlineid = ppcc.productionlineid\n" +
  4086. " inner join tp_mst_kiln mstkiln\n" +
  4087. " on mstkiln.kilnid = ppcc.kilnid\n" +
  4088. " inner join tp_mst_goods mstgoods\n" +
  4089. " on mstgoods.goodsid = ppcc.goodsid\n" +
  4090. " inner join tp_mst_goodstype mstgoodstype\n" +
  4091. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  4092. " and mstgoodstype.accountid = mstgoods.accountid\n" +
  4093. " inner join tp_mst_goodstype mstgoodstype2\n" +
  4094. " on mstgoodstype2.goodstypecode =\n" +
  4095. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  4096. " and mstgoodstype.accountid = mstgoodstype2.accountid\n";
  4097. // 产品类别
  4098. selSql.Append(sqlString);
  4099. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  4100. {
  4101. selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS)=1\n");
  4102. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  4103. }
  4104. sqlString =
  4105. " group by grouping sets((pcpl.productionlinename, mstkiln.kilncode, mstgoodstype2.goodstypename,mstgoodstype2.goodstypecode),(pcpl.productionlinename, mstgoodstype2.goodstypename,mstgoodstype2.goodstypecode),(pcpl.productionlinename, mstkiln.kilncode),(pcpl.productionlinename))\n" +
  4106. " order by pcpl.productionlinename\n" +
  4107. " ,mstkiln.kilncode\n" +
  4108. " ,mstgoodstype2.goodstypecode\n" +
  4109. " ) qdgroup\n";
  4110. selSql.Append(sqlString);
  4111. return selSql.ToString();
  4112. }
  4113. /// <summary>
  4114. /// 取得RPT040106画面(缺陷报表)的查询数据
  4115. /// </summary>
  4116. /// <param name="user">登录用户信息</param>
  4117. /// <param name="se">查询条件</param>
  4118. /// <returns>查询结果</returns>
  4119. public static ServiceResultEntity GetRPT040106SData(SUserInfo user, RPT040106_SE se)
  4120. {
  4121. IDBConnection conn = null;
  4122. try
  4123. {
  4124. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  4125. string sqlString = null;
  4126. OracleParameter[] parameters = null;
  4127. if (se.OutKilnNumByGoodsType)
  4128. {
  4129. sqlString = "SELECT Defect.productionlinename\n" +
  4130. " ,Defect.procedurename\n" +
  4131. " ,Defect.Defectcode\n" +
  4132. " ,Defect.Defectname\n" +
  4133. " ,Defect.goodstypename2\n" +
  4134. " ,Defect.DefectCount\n" +
  4135. " ,OUT.outNum OutKilnCount\n" +
  4136. " ,decode(OUT.outNum,\n" +
  4137. " 0,\n" +
  4138. " to_number(NULL),\n" +
  4139. " ROUND(Defect.DefectCount / OUT.outNum, 4)) DefectPercent\n" +
  4140. " FROM (SELECT tp_pc_productionline.productionlinename\n" +
  4141. " ,tp_pc_procedure.procedurename\n" +
  4142. " ,TP_MST_DefectType.Defecttypename\n" +
  4143. " ,TP_MST_Defect.Defectcode\n" +
  4144. " ,TP_MST_Defect.Defectname\n" +
  4145. " ,goodstype2.goodstypename goodstypename2\n" +
  4146. " ,goodstype2.goodstypecode goodstypecode2\n" +
  4147. " --,COUNT(DISTINCT TP_PM_Defect.Barcode) DefectCount\n" +
  4148. " ,COUNT(TP_PM_Defect.Barcode) DefectCount\n" +
  4149. " FROM TP_PM_Defect\n" +
  4150. " LEFT JOIN tp_pc_procedure\n" +
  4151. " ON TP_PM_Defect.ProcedureID = tp_pc_procedure.ProcedureID\n" +
  4152. " LEFT JOIN tp_pc_productionline\n" +
  4153. " ON TP_PM_Defect.Productionlineid =\n" +
  4154. " tp_pc_productionline.Productionlineid\n" +
  4155. " LEFT JOIN TP_MST_Goods\n" +
  4156. " ON TP_PM_Defect.Goodsid = TP_MST_Goods.Goodsid\n" +
  4157. " LEFT JOIN TP_MST_GoodsType\n" +
  4158. " ON TP_MST_Goods.GoodsTypeID = TP_MST_GoodsType.GoodsTypeID\n" +
  4159. " LEFT JOIN TP_MST_GoodsType goodstype2\n" +
  4160. " ON goodstype2.goodstypecode =\n" +
  4161. " substr(TP_MST_GoodsType.goodstypecode, 0, 6)\n" +
  4162. " AND TP_MST_GoodsType.accountid = goodstype2.accountid\n" +
  4163. " LEFT JOIN TP_MST_Defect\n" +
  4164. " ON TP_PM_Defect.DefectID = TP_MST_Defect.DefectID\n" +
  4165. " LEFT JOIN TP_MST_DefectType\n" +
  4166. " ON TP_MST_Defect.DefectTypeID = TP_MST_DefectType.DefectTypeID\n" +
  4167. " --LEFT JOIN TP_PM_ProductionData\n" +
  4168. " -- ON TP_PM_ProductionData.ProductionDataID =\n" +
  4169. " -- TP_PM_Defect.ProductionDataID\n" +
  4170. " WHERE TP_PM_Defect.valueflag = '1'\n" +
  4171. " --AND tp_pc_procedure.ModelType = -1\n" +
  4172. " AND TP_PM_Defect.AccountID = :AccountID\n" +
  4173. " AND (:createtimebegin is null or TP_PM_Defect.createtime >= :createtimebegin)\n" +
  4174. " AND (:createtimeend is null or TP_PM_Defect.createtime <= :createtimeend)\n" +
  4175. " AND (:procedureids is null or instr(','||:procedureids||',', ','||TP_PM_Defect.ProcedureID||',') > 0)\n" +
  4176. " AND (:DefectCode is null or instr(TP_MST_Defect.Defectcode, :DefectCode) > 0)\n" +
  4177. " AND (:DefectName is null or instr(TP_MST_Defect.Defectname, :DefectName) > 0)\n" +
  4178. " GROUP BY tp_pc_productionline.productionlinename\n" +
  4179. " ,tp_pc_procedure.procedurename\n" +
  4180. " ,TP_MST_DefectType.Defecttypename\n" +
  4181. " ,TP_MST_Defect.Defectcode\n" +
  4182. " ,TP_MST_Defect.Defectname\n" +
  4183. " ,goodstype2.goodstypecode\n" +
  4184. " ,goodstype2.goodstypename) Defect\n" +
  4185. " LEFT JOIN ( SELECT gt2.goodstypecode goodstypecode2, COUNT(pd.barcode) outNum\n" +
  4186. " FROM tp_pm_productiondata pd\n" +
  4187. " LEFT JOIN tp_mst_goods g on g.goodsid = pd.goodsid\n" +
  4188. " LEFT JOIN tp_mst_goodstype gt on g.goodstypeid = gt.goodstypeid\n" +
  4189. " LEFT JOIN tp_mst_goodstype gt2 on gt2.AccountID = :AccountID and gt2.goodstypecode = substr(gt.goodstypecode, 0, 6)\n" +
  4190. " WHERE pd.valueflag = '1'\n" +
  4191. " AND pd.procedureid = :procedureid\n" +
  4192. " AND pd.AccountID = :AccountID\n" +
  4193. " AND (:createtimebegin is null or pd.createtime >= :createtimebegin)\n" +
  4194. " AND (:createtimeend is null or pd.createtime <= :createtimeend)\n" +
  4195. " GROUP BY gt2.goodstypecode) OUT \n" +
  4196. " ON OUT.goodstypecode2 = Defect.goodstypecode2 \n";
  4197. parameters = new OracleParameter[]
  4198. {
  4199. new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  4200. new OracleParameter(":createtimebegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  4201. new OracleParameter(":createtimeend", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  4202. new OracleParameter(":procedureids", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input),
  4203. new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input),
  4204. new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input),
  4205. //new OracleParameter(":OutKilnCount", OracleDbType.Int32, outKilnCount, ParameterDirection.Input),
  4206. new OracleParameter(":procedureid", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input),
  4207. };
  4208. }
  4209. else
  4210. {
  4211. sqlString = "SELECT COUNT(pd.barcode) \n" +
  4212. " FROM tp_pm_productiondata pd\n" +
  4213. " WHERE pd.valueflag = '1'\n" +
  4214. " AND pd.procedureid = :procedureid\n" +
  4215. " AND pd.AccountID = :AccountID\n" +
  4216. " AND (:createtimebegin is null or pd.createtime >= :createtimebegin)\n" +
  4217. " AND (:createtimeend is null or pd.createtime <= :createtimeend)";
  4218. parameters = new OracleParameter[]
  4219. {
  4220. new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  4221. new OracleParameter(":procedureid", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input),
  4222. new OracleParameter(":createtimebegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  4223. new OracleParameter(":createtimeend", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  4224. };
  4225. int outKilnCount = Convert.ToInt32(conn.GetSqlResultToStr(sqlString, parameters));
  4226. sqlString = "SELECT Defect.productionlinename\n" +
  4227. " ,Defect.procedurename\n" +
  4228. " ,Defect.Defectcode\n" +
  4229. " ,Defect.Defectname\n" +
  4230. " ,Defect.goodstypename2\n" +
  4231. " ,Defect.DefectCount\n" +
  4232. " ,:OutKilnCount OutKilnCount\n" +
  4233. " ,decode(:OutKilnCount,\n" +
  4234. " 0,\n" +
  4235. " to_number(NULL),\n" +
  4236. " ROUND(Defect.DefectCount / :OutKilnCount, 4)) DefectPercent\n" +
  4237. " FROM (SELECT tp_pc_productionline.productionlinename\n" +
  4238. " ,tp_pc_procedure.procedurename\n" +
  4239. " ,TP_MST_DefectType.Defecttypename\n" +
  4240. " ,TP_MST_Defect.Defectcode\n" +
  4241. " ,TP_MST_Defect.Defectname\n" +
  4242. " ,goodstype2.goodstypename goodstypename2\n" +
  4243. " ,:OutKilnCount OutKilnCount\n" +
  4244. " --,COUNT(DISTINCT TP_PM_Defect.Barcode) DefectCount\n" +
  4245. " ,COUNT(TP_PM_Defect.Barcode) DefectCount\n" +
  4246. " FROM TP_PM_Defect\n" +
  4247. " LEFT JOIN tp_pc_procedure\n" +
  4248. " ON TP_PM_Defect.ProcedureID = tp_pc_procedure.ProcedureID\n" +
  4249. " LEFT JOIN tp_pc_productionline\n" +
  4250. " ON TP_PM_Defect.Productionlineid =\n" +
  4251. " tp_pc_productionline.Productionlineid\n" +
  4252. " LEFT JOIN TP_MST_Goods\n" +
  4253. " ON TP_PM_Defect.Goodsid = TP_MST_Goods.Goodsid\n" +
  4254. " LEFT JOIN TP_MST_GoodsType\n" +
  4255. " ON TP_MST_Goods.GoodsTypeID = TP_MST_GoodsType.GoodsTypeID\n" +
  4256. " LEFT JOIN TP_MST_GoodsType goodstype2\n" +
  4257. " ON goodstype2.goodstypecode =\n" +
  4258. " substr(TP_MST_GoodsType.goodstypecode, 0, 6)\n" +
  4259. " AND TP_MST_GoodsType.accountid = goodstype2.accountid\n" +
  4260. " LEFT JOIN TP_MST_Defect\n" +
  4261. " ON TP_PM_Defect.DefectID = TP_MST_Defect.DefectID\n" +
  4262. " LEFT JOIN TP_MST_DefectType\n" +
  4263. " ON TP_MST_Defect.DefectTypeID = TP_MST_DefectType.DefectTypeID\n" +
  4264. " --LEFT JOIN TP_PM_ProductionData\n" +
  4265. " -- ON TP_PM_ProductionData.ProductionDataID =\n" +
  4266. " -- TP_PM_Defect.ProductionDataID\n" +
  4267. " WHERE TP_PM_Defect.valueflag = '1'\n" +
  4268. " --AND tp_pc_procedure.ModelType = -1\n" +
  4269. " AND TP_PM_Defect.AccountID = :AccountID\n" +
  4270. " AND (:createtimebegin is null or TP_PM_Defect.createtime >= :createtimebegin)\n" +
  4271. " AND (:createtimeend is null or TP_PM_Defect.createtime <= :createtimeend)\n" +
  4272. " AND (:procedureids is null or instr(','||:procedureids||',', ','||TP_PM_Defect.ProcedureID||',') > 0)\n" +
  4273. " AND (:DefectCode is null or instr(TP_MST_Defect.Defectcode, :DefectCode) > 0)\n" +
  4274. " AND (:DefectName is null or instr(TP_MST_Defect.Defectname, :DefectName) > 0)\n" +
  4275. " GROUP BY tp_pc_productionline.productionlinename\n" +
  4276. " ,tp_pc_procedure.procedurename\n" +
  4277. " ,TP_MST_DefectType.Defecttypename\n" +
  4278. " ,TP_MST_Defect.Defectcode\n" +
  4279. " ,TP_MST_Defect.Defectname\n" +
  4280. " ,goodstype2.goodstypename) Defect";
  4281. parameters = new OracleParameter[]
  4282. {
  4283. new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  4284. new OracleParameter(":createtimebegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  4285. new OracleParameter(":createtimeend", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  4286. new OracleParameter(":procedureids", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input),
  4287. new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input),
  4288. new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input),
  4289. new OracleParameter(":OutKilnCount", OracleDbType.Int32, outKilnCount, ParameterDirection.Input),
  4290. };
  4291. }
  4292. DataTable data = conn.GetSqlResultToDt(sqlString, parameters);
  4293. ServiceResultEntity sre = new ServiceResultEntity();
  4294. if (data == null || data.Rows.Count == 0)
  4295. {
  4296. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4297. return sre;
  4298. }
  4299. sre.Data = new DataSet();
  4300. sre.Data.Tables.Add(data);
  4301. return sre;
  4302. }
  4303. catch (Exception ex)
  4304. {
  4305. throw ex;
  4306. }
  4307. finally
  4308. {
  4309. if (conn != null &&
  4310. conn.ConnState == ConnectionState.Open)
  4311. {
  4312. conn.Close();
  4313. }
  4314. }
  4315. }
  4316. /// <summary>
  4317. /// 取得RPT040107画面(注浆产品工序分析表)的查询数据
  4318. /// </summary>
  4319. /// <param name="user">登录用户信息</param>
  4320. /// <param name="se">查询条件</param>
  4321. /// <returns>查询结果</returns>
  4322. public static ServiceResultEntity GetRPT040107SData(SUserInfo user, RPT040107_SE se)
  4323. {
  4324. IDBConnection conn = null;
  4325. try
  4326. {
  4327. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  4328. List<OracleParameter> parameters = new List<OracleParameter>();
  4329. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  4330. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  4331. string sqlString =
  4332. "SELECT LISTAGG('''' || p.procedureid || ''' AS ' || 'P' || p.procedureid,\n" +
  4333. " ',') WITHIN GROUP(ORDER BY p.displayno, p.pid) pivotcol\n" +
  4334. " ,LISTAGG('sum(pd.P' || p.procedureid || '_BC) AS \"' ||\n" +
  4335. " p.procedurename || '\"',\n" +
  4336. " ',') WITHIN GROUP(ORDER BY p.displayno, p.pid) groupsum\n" +
  4337. " FROM (SELECT to_char(p.procedureid) procedureid\n" +
  4338. " ,to_char(p.procedurename) procedurename\n" +
  4339. " ,p.displayno\n" +
  4340. " ,p.productionlineid plid\n" +
  4341. " ,p.procedureid pid\n" +
  4342. " FROM tp_pc_procedure p\n" +
  4343. " WHERE p.valueflag = '1'\n" +
  4344. " AND p.modeltype <> -1\n" +
  4345. " AND p.accountid = :AccountID\n" +
  4346. " UNION ALL\n" +
  4347. " SELECT to_char(p.procedureid) || 'S'\n" +
  4348. " ,to_char(p.procedurename) || '(不合格)'\n" +
  4349. " ,p.displayno\n" +
  4350. " ,p.productionlineid plid\n" +
  4351. " ,p.procedureid pid\n" +
  4352. " FROM tp_pc_procedure p\n" +
  4353. " WHERE p.valueflag = '1'\n" +
  4354. " AND p.modeltype = -1\n" +
  4355. " AND p.accountid = :AccountID) p" +
  4356. " WHERE exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 7 and up.UserID = :UserID and (up.PurviewID = -1 or up.PurviewID=p.plid)) \n" +
  4357. " AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 9 and up.UserID = :UserID and (up.PurviewID = -1 or up.PurviewID=p.pid)) \n";
  4358. // 生产线
  4359. if (se.ProductionLineID.HasValue)
  4360. {
  4361. sqlString = sqlString + " AND p.plid = :ProductionLineID ";
  4362. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  4363. }
  4364. // 生产工序
  4365. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  4366. {
  4367. sqlString = sqlString + " AND instr(:procedureids, ','||p.pid||',')>0 ";
  4368. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  4369. }
  4370. DataTable cols = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  4371. ServiceResultEntity sre = new ServiceResultEntity();
  4372. if (cols == null || cols.Rows.Count == 0)
  4373. {
  4374. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4375. return sre;
  4376. }
  4377. string pivotcol = cols.Rows[0]["pivotcol"].ToString();
  4378. string groupsum = cols.Rows[0]["groupsum"].ToString();
  4379. if (string.IsNullOrEmpty(pivotcol) || string.IsNullOrEmpty(groupsum))
  4380. {
  4381. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4382. return sre;
  4383. }
  4384. parameters.Clear();
  4385. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  4386. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  4387. sqlString =
  4388. "WITH pd_data AS\n" +
  4389. " (SELECT DISTINCT pd.goodsid pdgoodsid\n" +
  4390. " ,pd.groutingdailydetailid\n" +
  4391. " ,decode(pd.MODELTYPE,\n" +
  4392. " -1,\n" +
  4393. " to_char(pd.procedureid) || 'S',\n" +
  4394. " to_char(pd.procedureid)) procedureid\n" +
  4395. " FROM tp_pm_productiondata pd\n" +
  4396. " LEFT JOIN tp_mst_goods goods\n" +
  4397. " ON goods.goodsid = pd.goodsid\n" +
  4398. " LEFT JOIN tp_mst_goodstype gt\n" +
  4399. " ON gt.goodstypeid = goods.goodstypeid\n" +
  4400. " WHERE pd.valueflag = '1'\n" +
  4401. " AND (pd.MODELTYPE <> -1 OR pd.goodsleveltypeid IN (6, 7))\n" +
  4402. " AND pd.accountid = :AccountID\n" +
  4403. (se.Specialrepairflag ? " AND ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" : "") +
  4404. " AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 7 and up.UserID = :UserID and (up.PurviewID = -1 or up.PurviewID=pd.ProductionLineID)) \n" +
  4405. " AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 9 and up.UserID = :UserID and (up.PurviewID = -1 or up.PurviewID=pd.procedureid)) \n";
  4406. // 生产线
  4407. if (se.ProductionLineID.HasValue)
  4408. {
  4409. sqlString = sqlString + " AND pd.productionlineid = :ProductionLineID ";
  4410. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  4411. }
  4412. // 生产工序
  4413. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  4414. {
  4415. sqlString = sqlString + " AND instr(:procedureids, ','||pd.procedureid||',')>0 ";
  4416. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  4417. }
  4418. // 产品型号
  4419. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  4420. {
  4421. sqlString = sqlString + " AND instr(gt.GOODSTYPECode, :GoodsTypeCode)=1 ";
  4422. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  4423. }
  4424. // 产品编码
  4425. if (!string.IsNullOrEmpty(se.GoodsCode))
  4426. {
  4427. sqlString = sqlString + " AND instr(goods.GOODSCode, :GoodsCode) > 0 ";
  4428. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  4429. }
  4430. // 注浆时间
  4431. if (se.GTimeStart.HasValue)
  4432. {
  4433. sqlString = sqlString + " AND pd.GROUTINGDATE >=:GTimeStart ";
  4434. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  4435. }
  4436. if (se.GTimeEnd.HasValue)
  4437. {
  4438. sqlString = sqlString + " AND pd.GROUTINGDATE <= :GTimeEnd ";
  4439. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  4440. }
  4441. sqlString +=
  4442. " ),\n" +
  4443. "pivot_data AS\n" +
  4444. " (SELECT *\n" +
  4445. " FROM pd_data\n" +
  4446. " PIVOT(COUNT(groutingdailydetailid) bc\n" +
  4447. " FOR procedureid IN(" + pivotcol + ")))\n" +
  4448. "SELECT decode(grouping_id(groutdetail.goodstypename2, groutdetail.goodscode),\n" +
  4449. " 3,\n" +
  4450. " '合计',\n" +
  4451. " 1,\n" +
  4452. " '小计【' || groutdetail.goodstypename2 || '】',\n" +
  4453. " groutdetail.goodstypename2) \"产量类别\"\n" +
  4454. " ,decode(grouping_id(groutdetail.goodstypename2, groutdetail.goodscode),\n" +
  4455. " 0,\n" +
  4456. " groutdetail.goodscode,\n" +
  4457. " '--') \"产品编码\"\n" +
  4458. " ,SUM(groutdetail.groutcount) \"注浆数量\"\n" +
  4459. " ,SUM(groutdetail.barcodecount) \"绑条码数量\"\n" +
  4460. " ,SUM(groutdetail.scrapcount) \"开模损坯\"\n" +
  4461. " ," + groupsum + "\n" +
  4462. " FROM (SELECT gdd.goodsid, gt2.goodstypename goodstypename2, goods.goodscode\n" +
  4463. " ,COUNT(gdd.groutingdailydetailid) AS groutcount\n" +
  4464. " ,SUM(decode(gdd.barcode, NULL, 0, 1)) AS barcodecount\n" +
  4465. " ,SUM(decode(gdd.scrapflag, '1', 1, 0)) AS scrapcount\n" +
  4466. " FROM tp_pm_groutingdailydetail gdd\n" +
  4467. " LEFT JOIN tp_mst_goods goods\n" +
  4468. " ON goods.goodsid = gdd.goodsid\n" +
  4469. " LEFT JOIN tp_mst_goodstype gt\n" +
  4470. " ON gt.goodstypeid = goods.goodstypeid\n" +
  4471. " LEFT JOIN tp_mst_goodstype gt2\n" +
  4472. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  4473. " AND gt2.accountid = gt.accountid\n" +
  4474. " WHERE gdd.valueflag = '1'\n" +
  4475. " AND gdd.accountid = :AccountID\n";
  4476. // 产品型号
  4477. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  4478. {
  4479. sqlString = sqlString + " AND instr(gt.GOODSTYPECode, :GoodsTypeCode)=1 ";
  4480. }
  4481. // 产品编码
  4482. if (!string.IsNullOrEmpty(se.GoodsCode))
  4483. {
  4484. sqlString = sqlString + " AND instr(goods.GOODSCode, :GoodsCode) > 0 ";
  4485. }
  4486. // 注浆时间
  4487. if (se.GTimeStart.HasValue)
  4488. {
  4489. sqlString = sqlString + " AND gdd.GROUTINGDATE >=:GTimeStart ";
  4490. }
  4491. if (se.GTimeEnd.HasValue)
  4492. {
  4493. sqlString = sqlString + " AND gdd.GROUTINGDATE <= :GTimeEnd ";
  4494. }
  4495. sqlString +=
  4496. " AND gdd.groutingflag = '1'\n" +
  4497. " GROUP BY gdd.goodsid, gt2.goodstypename, goods.goodscode) groutdetail\n" +
  4498. " LEFT JOIN pivot_data pd\n" +
  4499. " ON pd.pdgoodsid = groutdetail.goodsid\n" +
  4500. " GROUP BY GROUPING SETS((groutdetail.goodstypename2, groutdetail.goodscode),(groutdetail.goodstypename2),())\n" +
  4501. " ORDER BY groutdetail.goodstypename2, groutdetail.goodscode";
  4502. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  4503. if (data == null || data.Rows.Count == 0)
  4504. {
  4505. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4506. return sre;
  4507. }
  4508. sre.Data = new DataSet();
  4509. sre.Data.Tables.Add(data);
  4510. return sre;
  4511. }
  4512. catch (Exception ex)
  4513. {
  4514. throw ex;
  4515. }
  4516. finally
  4517. {
  4518. if (conn != null &&
  4519. conn.ConnState == ConnectionState.Open)
  4520. {
  4521. conn.Close();
  4522. }
  4523. }
  4524. }
  4525. /// <summary>
  4526. /// 取得RPT040108画面(成型线产量分析表)的查询数据
  4527. /// </summary>
  4528. /// <param name="user">登录用户信息</param>
  4529. /// <param name="se">查询条件</param>
  4530. /// <returns>查询结果</returns>
  4531. public static ServiceResultEntity GetRPT040108SData(SUserInfo user, RPT040108_SE se)
  4532. {
  4533. IDBConnection conn = null;
  4534. try
  4535. {
  4536. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  4537. //string sqlString =
  4538. // "SELECT t.groutinglinecode\n" +
  4539. // " ,t.BuildingNo\n" +
  4540. // " ,t.FloorNo\n" +
  4541. // " ,t.GroutingLineNo\n" +
  4542. // " ,t.usercode\n" +
  4543. // " ,t.goodscode\n" +
  4544. // " ,t.GOODSSPECIFICATION\n" +
  4545. // " ,t.goodstypename\n" +
  4546. // //" ,round(AVG(t.MouldQuantity), 2) MouldQuantity\n" +
  4547. // " ,AVG(t.MouldQuantity) MouldQuantity\n" +
  4548. // " ,SUM(decode(t.gday, '01', t.c, 0)) c01\n" +
  4549. // " ,SUM(decode(t.dday, '01', t.d, 0)) d01\n" +
  4550. // " ,SUM(decode(t.gday, '02', t.c, 0)) c02\n" +
  4551. // " ,SUM(decode(t.dday, '02', t.d, 0)) d02\n" +
  4552. // " ,SUM(decode(t.gday, '03', t.c, 0)) c03\n" +
  4553. // " ,SUM(decode(t.dday, '03', t.d, 0)) d03\n" +
  4554. // " ,SUM(decode(t.gday, '04', t.c, 0)) c04\n" +
  4555. // " ,SUM(decode(t.dday, '04', t.d, 0)) d04\n" +
  4556. // " ,SUM(decode(t.gday, '05', t.c, 0)) c05\n" +
  4557. // " ,SUM(decode(t.dday, '05', t.d, 0)) d05\n" +
  4558. // " ,SUM(decode(t.gday, '06', t.c, 0)) c06\n" +
  4559. // " ,SUM(decode(t.dday, '06', t.d, 0)) d06\n" +
  4560. // " ,SUM(decode(t.gday, '07', t.c, 0)) c07\n" +
  4561. // " ,SUM(decode(t.dday, '07', t.d, 0)) d07\n" +
  4562. // " ,SUM(decode(t.gday, '08', t.c, 0)) c08\n" +
  4563. // " ,SUM(decode(t.dday, '08', t.d, 0)) d08\n" +
  4564. // " ,SUM(decode(t.gday, '09', t.c, 0)) c09\n" +
  4565. // " ,SUM(decode(t.dday, '09', t.d, 0)) d09\n" +
  4566. // " ,SUM(decode(t.gday, '10', t.c, 0)) c10\n" +
  4567. // " ,SUM(decode(t.dday, '10', t.d, 0)) d10\n" +
  4568. // " ,SUM(decode(t.gday, '11', t.c, 0)) c11\n" +
  4569. // " ,SUM(decode(t.dday, '11', t.d, 0)) d11\n" +
  4570. // " ,SUM(decode(t.gday, '12', t.c, 0)) c12\n" +
  4571. // " ,SUM(decode(t.dday, '12', t.d, 0)) d12\n" +
  4572. // " ,SUM(decode(t.gday, '13', t.c, 0)) c13\n" +
  4573. // " ,SUM(decode(t.dday, '13', t.d, 0)) d13\n" +
  4574. // " ,SUM(decode(t.gday, '14', t.c, 0)) c14\n" +
  4575. // " ,SUM(decode(t.dday, '14', t.d, 0)) d14\n" +
  4576. // " ,SUM(decode(t.gday, '15', t.c, 0)) c15\n" +
  4577. // " ,SUM(decode(t.dday, '15', t.d, 0)) d15\n" +
  4578. // " ,SUM(decode(t.gday, '16', t.c, 0)) c16\n" +
  4579. // " ,SUM(decode(t.dday, '16', t.d, 0)) d16\n" +
  4580. // " ,SUM(decode(t.gday, '17', t.c, 0)) c17\n" +
  4581. // " ,SUM(decode(t.dday, '17', t.d, 0)) d17\n" +
  4582. // " ,SUM(decode(t.gday, '18', t.c, 0)) c18\n" +
  4583. // " ,SUM(decode(t.dday, '18', t.d, 0)) d18\n" +
  4584. // " ,SUM(decode(t.gday, '19', t.c, 0)) c19\n" +
  4585. // " ,SUM(decode(t.dday, '19', t.d, 0)) d19\n" +
  4586. // " ,SUM(decode(t.gday, '20', t.c, 0)) c20\n" +
  4587. // " ,SUM(decode(t.dday, '20', t.d, 0)) d20\n" +
  4588. // " ,SUM(decode(t.gday, '21', t.c, 0)) c21\n" +
  4589. // " ,SUM(decode(t.dday, '21', t.d, 0)) d21\n" +
  4590. // " ,SUM(decode(t.gday, '22', t.c, 0)) c22\n" +
  4591. // " ,SUM(decode(t.dday, '22', t.d, 0)) d22\n" +
  4592. // " ,SUM(decode(t.gday, '23', t.c, 0)) c23\n" +
  4593. // " ,SUM(decode(t.dday, '23', t.d, 0)) d23\n" +
  4594. // " ,SUM(decode(t.gday, '24', t.c, 0)) c24\n" +
  4595. // " ,SUM(decode(t.dday, '24', t.d, 0)) d24\n" +
  4596. // " ,SUM(decode(t.gday, '25', t.c, 0)) c25\n" +
  4597. // " ,SUM(decode(t.dday, '25', t.d, 0)) d25\n" +
  4598. // " ,SUM(decode(t.gday, '26', t.c, 0)) c26\n" +
  4599. // " ,SUM(decode(t.dday, '26', t.d, 0)) d26\n" +
  4600. // " ,SUM(decode(t.gday, '27', t.c, 0)) c27\n" +
  4601. // " ,SUM(decode(t.dday, '27', t.d, 0)) d27\n" +
  4602. // " ,SUM(decode(t.gday, '28', t.c, 0)) c28\n" +
  4603. // " ,SUM(decode(t.dday, '28', t.d, 0)) d28\n" +
  4604. // " ,SUM(decode(t.gday, '29', t.c, 0)) c29\n" +
  4605. // " ,SUM(decode(t.dday, '29', t.d, 0)) d29\n" +
  4606. // " ,SUM(decode(t.gday, '30', t.c, 0)) c30\n" +
  4607. // " ,SUM(decode(t.dday, '30', t.d, 0)) d30\n" +
  4608. // " ,SUM(decode(t.gday, '31', t.c, 0)) c31\n" +
  4609. // " ,SUM(decode(t.dday, '31', t.d, 0)) d31\n" +
  4610. // " FROM (SELECT gd.groutinglinecode\n" +
  4611. // " ,gl.BuildingNo\n" +
  4612. // " ,gl.FloorNo\n" +
  4613. // " ,gl.GroutingLineNo\n" +
  4614. // " ,gd.usercode\n" +
  4615. // " ,gdd.goodscode\n" +
  4616. // " ,g.GOODSSPECIFICATION\n" +
  4617. // " ,gt.goodstypename\n" +
  4618. // //" ,gd.MouldQuantity\n" +
  4619. // " ,gl.MouldQuantity\n" +
  4620. // " ,to_char(gd.groutingdate, 'dd') AS gday\n" +
  4621. // " ,to_char(gdd.delivertime, 'dd') AS dday\n" +
  4622. // " , CASE\n" +
  4623. // " WHEN gd.groutingdate >= :GDateBegin AND\n" +
  4624. // " gd.groutingdate <= :GDateEnd AND\n" +
  4625. // " gdd.GroutingFlag = '1' AND gdd.ScrapFlag = '0' THEN\n" +
  4626. // " 1\n" +
  4627. // " ELSE\n" +
  4628. // " 0\n" +
  4629. // " END c -- 成坯量\n" +
  4630. // " , CASE\n" +
  4631. // " WHEN gdd.delivertime >= :GDateBegin AND\n" +
  4632. // " gdd.delivertime <= :GDateEnd AND\n" +
  4633. // " gdd.deliverflag = '1' THEN\n" +
  4634. // " 1\n" +
  4635. // " ELSE\n" +
  4636. // " 0\n" +
  4637. // " END d -- 交坯量\n" +
  4638. // " FROM TP_PM_GroutingDaily gd\n" +
  4639. // " INNER JOIN TP_PM_GroutingDailyDetail gdd\n" +
  4640. // " ON gdd.groutingdailyid = gd.groutingdailyid\n" +
  4641. // " INNER JOIN TP_PC_GroutingLine gl \n" +
  4642. // " ON gl.groutinglineid = gd.groutinglineid\n" +
  4643. // " INNER JOIN TP_MST_Goods g\n" +
  4644. // " ON g.goodsid = gdd.goodsid\n" +
  4645. // " INNER JOIN TP_MST_GOODSTYPE gt\n" +
  4646. // " ON gt.goodstypeid = g.goodstypeid\n" +
  4647. // " WHERE gd.accountid = :AccountID\n" +
  4648. // " AND ((gd.groutingdate >= :GDateBegin AND\n" +
  4649. // " gd.groutingdate <= :GDateEnd) OR\n" +
  4650. // " (gdd.delivertime >= :GDateBegin AND\n" +
  4651. // " gdd.delivertime <= :GDateEnd))\n" +
  4652. // " AND (:groutinglinecode is null or instr(gd.groutinglinecode, :groutinglinecode) > 0)\n" +
  4653. // " AND (:groutingusercode is null or instr(gdd.usercode, :groutingusercode) > 0)\n" +
  4654. // " AND (:goodscode is null or instr(gdd.goodscode, :goodscode) > 0)\n" +
  4655. // " AND (:goodstypecode is null or instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  4656. // " ) t\n" +
  4657. // " GROUP BY t.groutinglinecode\n" +
  4658. // " ,t.BuildingNo\n" +
  4659. // " ,t.FloorNo\n" +
  4660. // " ,t.GroutingLineNo\n" +
  4661. // " ,t.usercode\n" +
  4662. // " ,t.goodscode\n" +
  4663. // " ,t.GOODSSPECIFICATION\n" +
  4664. // " ,t.goodstypename\n" +
  4665. // " ORDER BY t.groutinglinecode, t.usercode, t.goodscode";
  4666. string sqlString = "select nvl(t.groutinglinecode, '--') groutinglinecode\n" +
  4667. " ,nvl(t.BuildingNo, '--') BuildingNo\n" +
  4668. " ,nvl(t.FloorNo, '--') FloorNo\n" +
  4669. " ,nvl(t.GroutingLineNo, '--') GroutingLineNo\n" +
  4670. " ,nvl(t.usercode, '--') usercode\n" +
  4671. " ,nvl2(t.groutinglinecode\n" +
  4672. " ,t.goodscode\n" +
  4673. " ,nvl2(t.goodscode, '小计[' || t.goodscode || ']', '合计')) goodscode\n" +
  4674. " ,nvl2(t.goodscode, t.GOODSSPECIFICATION, '--') GOODSSPECIFICATION\n" +
  4675. " ,nvl2(t.goodscode, t.goodstypename, '--') goodstypename\n" +
  4676. " ,nvl2(t.groutinglinecode, avg(t.MouldQuantity), null) MouldQuantity\n" +
  4677. " ,sum(decode(t.gday, '01', t.c, 0)) c01\n" +
  4678. " ,sum(decode(t.dday, '01', t.d, 0)) d01\n" +
  4679. " ,sum(decode(t.gday, '02', t.c, 0)) c02\n" +
  4680. " ,sum(decode(t.dday, '02', t.d, 0)) d02\n" +
  4681. " ,sum(decode(t.gday, '03', t.c, 0)) c03\n" +
  4682. " ,sum(decode(t.dday, '03', t.d, 0)) d03\n" +
  4683. " ,sum(decode(t.gday, '04', t.c, 0)) c04\n" +
  4684. " ,sum(decode(t.dday, '04', t.d, 0)) d04\n" +
  4685. " ,sum(decode(t.gday, '05', t.c, 0)) c05\n" +
  4686. " ,sum(decode(t.dday, '05', t.d, 0)) d05\n" +
  4687. " ,sum(decode(t.gday, '06', t.c, 0)) c06\n" +
  4688. " ,sum(decode(t.dday, '06', t.d, 0)) d06\n" +
  4689. " ,sum(decode(t.gday, '07', t.c, 0)) c07\n" +
  4690. " ,sum(decode(t.dday, '07', t.d, 0)) d07\n" +
  4691. " ,sum(decode(t.gday, '08', t.c, 0)) c08\n" +
  4692. " ,sum(decode(t.dday, '08', t.d, 0)) d08\n" +
  4693. " ,sum(decode(t.gday, '09', t.c, 0)) c09\n" +
  4694. " ,sum(decode(t.dday, '09', t.d, 0)) d09\n" +
  4695. " ,sum(decode(t.gday, '10', t.c, 0)) c10\n" +
  4696. " ,sum(decode(t.dday, '10', t.d, 0)) d10\n" +
  4697. " ,sum(decode(t.gday, '11', t.c, 0)) c11\n" +
  4698. " ,sum(decode(t.dday, '11', t.d, 0)) d11\n" +
  4699. " ,sum(decode(t.gday, '12', t.c, 0)) c12\n" +
  4700. " ,sum(decode(t.dday, '12', t.d, 0)) d12\n" +
  4701. " ,sum(decode(t.gday, '13', t.c, 0)) c13\n" +
  4702. " ,sum(decode(t.dday, '13', t.d, 0)) d13\n" +
  4703. " ,sum(decode(t.gday, '14', t.c, 0)) c14\n" +
  4704. " ,sum(decode(t.dday, '14', t.d, 0)) d14\n" +
  4705. " ,sum(decode(t.gday, '15', t.c, 0)) c15\n" +
  4706. " ,sum(decode(t.dday, '15', t.d, 0)) d15\n" +
  4707. " ,sum(decode(t.gday, '16', t.c, 0)) c16\n" +
  4708. " ,sum(decode(t.dday, '16', t.d, 0)) d16\n" +
  4709. " ,sum(decode(t.gday, '17', t.c, 0)) c17\n" +
  4710. " ,sum(decode(t.dday, '17', t.d, 0)) d17\n" +
  4711. " ,sum(decode(t.gday, '18', t.c, 0)) c18\n" +
  4712. " ,sum(decode(t.dday, '18', t.d, 0)) d18\n" +
  4713. " ,sum(decode(t.gday, '19', t.c, 0)) c19\n" +
  4714. " ,sum(decode(t.dday, '19', t.d, 0)) d19\n" +
  4715. " ,sum(decode(t.gday, '20', t.c, 0)) c20\n" +
  4716. " ,sum(decode(t.dday, '20', t.d, 0)) d20\n" +
  4717. " ,sum(decode(t.gday, '21', t.c, 0)) c21\n" +
  4718. " ,sum(decode(t.dday, '21', t.d, 0)) d21\n" +
  4719. " ,sum(decode(t.gday, '22', t.c, 0)) c22\n" +
  4720. " ,sum(decode(t.dday, '22', t.d, 0)) d22\n" +
  4721. " ,sum(decode(t.gday, '23', t.c, 0)) c23\n" +
  4722. " ,sum(decode(t.dday, '23', t.d, 0)) d23\n" +
  4723. " ,sum(decode(t.gday, '24', t.c, 0)) c24\n" +
  4724. " ,sum(decode(t.dday, '24', t.d, 0)) d24\n" +
  4725. " ,sum(decode(t.gday, '25', t.c, 0)) c25\n" +
  4726. " ,sum(decode(t.dday, '25', t.d, 0)) d25\n" +
  4727. " ,sum(decode(t.gday, '26', t.c, 0)) c26\n" +
  4728. " ,sum(decode(t.dday, '26', t.d, 0)) d26\n" +
  4729. " ,sum(decode(t.gday, '27', t.c, 0)) c27\n" +
  4730. " ,sum(decode(t.dday, '27', t.d, 0)) d27\n" +
  4731. " ,sum(decode(t.gday, '28', t.c, 0)) c28\n" +
  4732. " ,sum(decode(t.dday, '28', t.d, 0)) d28\n" +
  4733. " ,sum(decode(t.gday, '29', t.c, 0)) c29\n" +
  4734. " ,sum(decode(t.dday, '29', t.d, 0)) d29\n" +
  4735. " ,sum(decode(t.gday, '30', t.c, 0)) c30\n" +
  4736. " ,sum(decode(t.dday, '30', t.d, 0)) d30\n" +
  4737. " ,sum(decode(t.gday, '31', t.c, 0)) c31\n" +
  4738. " ,sum(decode(t.dday, '31', t.d, 0)) d31\n" +
  4739. " from (select gd.groutinglinecode\n" +
  4740. " ,gl.BuildingNo\n" +
  4741. " ,gl.FloorNo\n" +
  4742. " ,gl.GroutingLineNo\n" +
  4743. " ,gd.usercode\n" +
  4744. " ,gdd.goodscode\n" +
  4745. " ,g.GOODSSPECIFICATION\n" +
  4746. " ,gt.goodstypename\n" +
  4747. " ,gl.MouldQuantity\n" +
  4748. " ,to_char(gd.groutingdate, 'dd') as gday\n" +
  4749. " ,to_char(gdd.delivertime, 'dd') as dday\n" +
  4750. " ,case\n" +
  4751. " when gd.groutingdate >= :GDateBegin and\n" +
  4752. " gd.groutingdate <= :GDateEnd and\n" +
  4753. " gdd.GroutingFlag = '1' and\n" +
  4754. " gdd.ScrapFlag = '0' then\n" +
  4755. " 1\n" +
  4756. " else\n" +
  4757. " 0\n" +
  4758. " end c -- 成坯量\n" +
  4759. " ,case\n" +
  4760. " when gdd.delivertime >= :GDateBegin and\n" +
  4761. " gdd.delivertime <= :GDateEnd and\n" +
  4762. " gdd.deliverflag = '1' then\n" +
  4763. " 1\n" +
  4764. " else\n" +
  4765. " 0\n" +
  4766. " end d -- 交坯量\n" +
  4767. " from TP_PM_GroutingDaily gd\n" +
  4768. " inner join TP_PM_GroutingDailyDetail gdd\n" +
  4769. " on gdd.groutingdailyid = gd.groutingdailyid\n" +
  4770. " inner join TP_PC_GroutingLine gl\n" +
  4771. " on gl.groutinglineid = gd.groutinglineid\n" +
  4772. " inner join TP_MST_Goods g\n" +
  4773. " on g.goodsid = gdd.goodsid\n" +
  4774. " inner join TP_MST_GOODSTYPE gt\n" +
  4775. " on gt.goodstypeid = g.goodstypeid\n" +
  4776. " where gd.accountid = :AccountID\n" +
  4777. " and ((gd.groutingdate >= :GDateBegin and\n" +
  4778. " gd.groutingdate <= :GDateEnd) or\n" +
  4779. " (gdd.delivertime >= :GDateBegin and\n" +
  4780. " gdd.delivertime <= :GDateEnd))\n" +
  4781. " and (:groutinglinecode is null or\n" +
  4782. " instr(gd.groutinglinecode, :groutinglinecode) > 0)\n" +
  4783. " and (:groutingusercode is null or\n" +
  4784. " instr(gdd.usercode, :groutingusercode) > 0)\n" +
  4785. " and (:goodscode is null or instr(gdd.goodscode, :goodscode) > 0)\n" +
  4786. " and (:goodstypecode is null or\n" +
  4787. " instr(gt.goodstypecode, :goodstypecode) = 1)) t\n" +
  4788. " group by grouping sets((t.groutinglinecode, t.BuildingNo, t.FloorNo, t.GroutingLineNo, t.usercode, t.goodscode, t.GOODSSPECIFICATION, t.goodstypename),(t.goodscode, t.GOODSSPECIFICATION, t.goodstypename),())\n" +
  4789. " order by t.goodscode, t.groutinglinecode, t.usercode";
  4790. List<OracleParameter> parameters = new List<OracleParameter>();
  4791. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  4792. parameters.Add(new OracleParameter(":GDateBegin", OracleDbType.Date, se.GDateBegin, ParameterDirection.Input));
  4793. parameters.Add(new OracleParameter(":GDateEnd", OracleDbType.Date, se.GDateEnd, ParameterDirection.Input));
  4794. parameters.Add(new OracleParameter(":groutinglinecode", OracleDbType.Varchar2, se.GroutingLineCode, ParameterDirection.Input));
  4795. parameters.Add(new OracleParameter(":groutingusercode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  4796. parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  4797. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  4798. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  4799. ServiceResultEntity sre = new ServiceResultEntity();
  4800. if (data == null || data.Rows.Count == 0)
  4801. {
  4802. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4803. return sre;
  4804. }
  4805. sre.Data = new DataSet();
  4806. sre.Data.Tables.Add(data);
  4807. return sre;
  4808. }
  4809. catch (Exception ex)
  4810. {
  4811. throw ex;
  4812. }
  4813. finally
  4814. {
  4815. if (conn != null &&
  4816. conn.ConnState == ConnectionState.Open)
  4817. {
  4818. conn.Close();
  4819. }
  4820. }
  4821. }
  4822. /// <summary>
  4823. /// 取得RPT040109画面(整体质量分析表)的查询数据
  4824. /// </summary>
  4825. /// <param name="user">登录用户信息</param>
  4826. /// <param name="se">查询条件</param>
  4827. /// <returns>查询结果</returns>
  4828. public static ServiceResultEntity GetRPT040109SData(SUserInfo user, RPT040109_SE se)
  4829. {
  4830. IDBTransaction conn = null;
  4831. try
  4832. {
  4833. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  4834. conn.Connect();
  4835. OracleParameter[] parameters = new OracleParameter[]
  4836. {
  4837. new OracleParameter("in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  4838. new OracleParameter("in_DateBegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  4839. new OracleParameter("in_DateEnd", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  4840. new OracleParameter("in_OutKilnProcedureID", OracleDbType.Int32, se.RptSProcedureID , ParameterDirection.Input),
  4841. new OracleParameter("in_KilnID", OracleDbType.Int32, se.KilnID , ParameterDirection.Input),
  4842. new OracleParameter("out_data1", OracleDbType.RefCursor, null , ParameterDirection.Output),
  4843. new OracleParameter("out_data2", OracleDbType.RefCursor, null , ParameterDirection.Output),
  4844. new OracleParameter("out_data3", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4845. new OracleParameter("out_data4", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4846. new OracleParameter("out_data21", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4847. new OracleParameter("out_data31", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4848. new OracleParameter("out_data32", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4849. new OracleParameter("out_table1", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4850. new OracleParameter("out_table2", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4851. new OracleParameter("out_table3", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4852. new OracleParameter("out_table4", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4853. new OracleParameter("in_HasUserGroup", OracleDbType.Int32, (se.HasUserGroup?1:0), ParameterDirection.Input),
  4854. };
  4855. //out_data1 -- 质量整体情况
  4856. //out_data2 -- 各缺陷类型成品率
  4857. //out_data3 -- 各缺陷类型缺陷率
  4858. //out_data4 -- 产品质量排行榜
  4859. //out_data21 -- 各缺陷类型成品率-总成品率
  4860. //out_data31 -- 各缺陷类型缺陷率-总缺陷率
  4861. //out_data32 -- 各缺陷类型缺陷率-分缺陷率
  4862. //out_table1 -- 缺陷类别
  4863. //out_table2 -- 工号分组
  4864. //out_table3 -- 缺陷扣罚
  4865. //out_table4 -- 缺陷
  4866. //DataSet data = conn.ExecStoredProcedure("PRO_RPT_OverallQualityAnalysis", parameters);
  4867. DataSet data = conn.ExecStoredProcedure("PRO_RPT_OverallQualityA_UserG", parameters);
  4868. ServiceResultEntity sre = new ServiceResultEntity();
  4869. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  4870. {
  4871. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4872. return sre;
  4873. }
  4874. data.Tables[0].TableName = "TQ";
  4875. data.Tables[1].TableName = "FR";
  4876. data.Tables[2].TableName = "DR";
  4877. data.Tables[3].TableName = "DL";
  4878. data.Tables[4].TableName = "FR1";
  4879. data.Tables[5].TableName = "DR1";
  4880. data.Tables[6].TableName = "DR2";
  4881. data.Tables[7].TableName = "DT";
  4882. data.Tables[8].TableName = "WG";
  4883. data.Tables[9].TableName = "DF";
  4884. data.Tables[10].TableName = "D";
  4885. DataTable dtFR = data.Tables["FR"];
  4886. DataTable dtFRClone = dtFR.Clone();
  4887. for (int i = 0; i < dtFR.Columns.Count; i++)
  4888. {
  4889. dtFRClone.Columns[i].DataType = typeof(string);
  4890. }
  4891. foreach (DataRow item in dtFR.Rows)
  4892. {
  4893. item["goodstypename2"] = item["goodstypename2"] + "缺陷数";
  4894. dtFRClone.Rows.Add(item.ItemArray);
  4895. }
  4896. // 增加大小件成品率(%) modify by chenxy 2018-05-03 begin
  4897. //DataRow drFR = dtFRClone.NewRow();
  4898. //drFR["goodstypename2"] = "成品率(%)";
  4899. //foreach (DataRow row in data.Tables["FR1"].Rows)
  4900. //{
  4901. // string tid = row["tid"].ToString();
  4902. // string overRate = (row["OverRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["OverRate"]).ToString("#,##0.00%"));
  4903. // foreach (DataColumn col in dtFRClone.Columns)
  4904. // {
  4905. // if (col.ColumnName.StartsWith(tid))
  4906. // {
  4907. // drFR[col.ColumnName] = overRate;
  4908. // }
  4909. // }
  4910. //}
  4911. //dtFRClone.Rows.Add(drFR);
  4912. Dictionary<string, DataRow> drFRs = new Dictionary<string, DataRow>();
  4913. foreach (DataRow row in data.Tables["FR1"].Rows)
  4914. {
  4915. string tcode = row["goodstypecode2"].ToString();
  4916. DataRow drFR = null;
  4917. if (drFRs.ContainsKey(tcode))
  4918. {
  4919. drFR = drFRs[tcode];
  4920. }
  4921. else
  4922. {
  4923. drFR = dtFRClone.NewRow();
  4924. drFRs.Add(tcode, drFR);
  4925. drFR["goodstypename2"] = row["goodstypeName2"] + "成品率(%)";
  4926. }
  4927. string tid = row["tid"].ToString();
  4928. string overRate = (row["OverRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["OverRate"]).ToString("#,##0.00%"));
  4929. foreach (DataColumn col in dtFRClone.Columns)
  4930. {
  4931. if (col.ColumnName.StartsWith(tid))
  4932. {
  4933. drFR[col.ColumnName] = overRate;
  4934. }
  4935. }
  4936. }
  4937. foreach (DataRow item in drFRs.Values)
  4938. {
  4939. dtFRClone.Rows.Add(item);
  4940. }
  4941. // 增加大小件成品率(%) modify by chenxy 2018-05-03 end
  4942. data.Tables.Remove(dtFR);
  4943. data.Tables.Remove(data.Tables["FR1"]);
  4944. data.Tables.Add(dtFRClone);
  4945. DataTable dtDR = data.Tables["DR"];
  4946. DataTable dtDRClone = dtDR.Clone();
  4947. for (int i = 0; i < dtDR.Columns.Count; i++)
  4948. {
  4949. dtDRClone.Columns[i].DataType = typeof(string);
  4950. }
  4951. foreach (DataRow item in dtDR.Rows)
  4952. {
  4953. item["goodstypename2"] = item["goodstypename2"] + "缺陷数";
  4954. dtDRClone.Rows.Add(item.ItemArray);
  4955. }
  4956. // 增加大小件缺陷率(%) modify by chenxy 2018-05-03 begin
  4957. //DataRow drDR = dtDRClone.NewRow();
  4958. //drDR["goodstypename2"] = "缺陷率(%)";
  4959. //foreach (DataRow row in data.Tables["DR2"].Rows)
  4960. //{
  4961. // string tid = row["tdfid"].ToString();
  4962. // string defectRate = (row["DefectRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["DefectRate"]).ToString("#,##0.00%"));
  4963. // drDR[tid] = defectRate;
  4964. //}
  4965. //dtDRClone.Rows.Add(drDR);
  4966. Dictionary<string, DataRow> drDRs = new Dictionary<string, DataRow>();
  4967. foreach (DataRow row in data.Tables["DR2"].Rows)
  4968. {
  4969. string tcode = row["goodstypecode2"].ToString();
  4970. DataRow drDR = null;
  4971. if (drDRs.ContainsKey(tcode))
  4972. {
  4973. drDR = drDRs[tcode];
  4974. }
  4975. else
  4976. {
  4977. drDR = dtDRClone.NewRow();
  4978. drDRs.Add(tcode, drDR);
  4979. drDR["goodstypename2"] = row["goodstypeName2"] + "缺陷率(%)";
  4980. }
  4981. string tid = row["tdfid"].ToString();
  4982. string defectRate = (row["DefectRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["DefectRate"]).ToString("#,##0.00%"));
  4983. drDR[tid] = defectRate;
  4984. }
  4985. foreach (DataRow item in drDRs.Values)
  4986. {
  4987. dtDRClone.Rows.Add(item);
  4988. }
  4989. // 增加大小件成品率(%) modify by chenxy 2018-05-03 end
  4990. data.Tables.Remove(dtDR);
  4991. data.Tables.Remove(data.Tables["DR2"]);
  4992. data.Tables.Add(dtDRClone);
  4993. conn.Commit();
  4994. sre.Data = data;
  4995. return sre;
  4996. }
  4997. catch (Exception ex)
  4998. {
  4999. throw ex;
  5000. }
  5001. finally
  5002. {
  5003. if (conn != null &&
  5004. conn.ConnState == ConnectionState.Open)
  5005. {
  5006. conn.Disconnect();
  5007. }
  5008. }
  5009. }
  5010. /// <summary>
  5011. /// 取得RPT040110画面(产成品逐日出窑数值分析表)的查询数据
  5012. /// </summary>
  5013. /// <param name="user">登录用户信息</param>
  5014. /// <param name="se">查询条件</param>
  5015. /// <returns>查询结果</returns>
  5016. public static ServiceResultEntity GetRPT040110SData(SUserInfo user, RPT040110_SE se)
  5017. {
  5018. IDBTransaction conn = null;
  5019. try
  5020. {
  5021. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  5022. conn.Connect();
  5023. OracleParameter[] parameters = new OracleParameter[]
  5024. {
  5025. new OracleParameter("in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  5026. new OracleParameter("in_DateBegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  5027. new OracleParameter("in_DateEnd", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  5028. new OracleParameter("in_OutKilnProcedureID", OracleDbType.Int32, se.RptSProcedureID , ParameterDirection.Input),
  5029. new OracleParameter("in_KilnID", OracleDbType.Int32, se.KilnID , ParameterDirection.Input),
  5030. new OracleParameter("out_data1", OracleDbType.RefCursor, null , ParameterDirection.Output),
  5031. };
  5032. DataSet data = null;
  5033. if (se.IsShowG)
  5034. {
  5035. data = conn.ExecStoredProcedure("PRO_RPT_OverallQualityDetail_G", parameters);
  5036. }
  5037. else
  5038. {
  5039. data = conn.ExecStoredProcedure("PRO_RPT_OverallQualityDetail", parameters);
  5040. }
  5041. ServiceResultEntity sre = new ServiceResultEntity();
  5042. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  5043. {
  5044. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5045. return sre;
  5046. }
  5047. conn.Commit();
  5048. sre.Data = data;
  5049. return sre;
  5050. }
  5051. catch (Exception ex)
  5052. {
  5053. throw ex;
  5054. }
  5055. finally
  5056. {
  5057. if (conn != null &&
  5058. conn.ConnState == ConnectionState.Open)
  5059. {
  5060. conn.Disconnect();
  5061. }
  5062. }
  5063. }
  5064. #endregion 分析报表
  5065. #region 汇总报表
  5066. /// <summary>
  5067. /// 取得RPT030101_1画面(产品产量汇总表)的汇总信息查询数据
  5068. /// </summary>
  5069. /// <param name="user">登录用户信息</param>
  5070. /// <param name="se">查询条件</param>
  5071. /// <returns>查询结果</returns>
  5072. public static ServiceResultEntity GetRPT030101SData(SUserInfo user, RPT030101_SE se)
  5073. {
  5074. IDBConnection conn = null;
  5075. try
  5076. {
  5077. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  5078. List<OracleParameter> parameters = new List<OracleParameter>();
  5079. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030101SSQL(user, se, ref parameters));
  5080. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  5081. ServiceResultEntity sre = new ServiceResultEntity();
  5082. if (data == null || data.Rows.Count == 0)
  5083. {
  5084. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5085. return sre;
  5086. }
  5087. sre.Data = new DataSet();
  5088. sre.Data.Tables.Add(data);
  5089. return sre;
  5090. }
  5091. catch (Exception ex)
  5092. {
  5093. throw ex;
  5094. }
  5095. finally
  5096. {
  5097. if (conn != null &&
  5098. conn.ConnState == ConnectionState.Open)
  5099. {
  5100. conn.Close();
  5101. }
  5102. }
  5103. }
  5104. /// <summary>
  5105. /// 获取RPT030101_1画面(产品产量汇总表)的汇总信息查询sql
  5106. /// </summary>
  5107. /// <returns>sql</returns>
  5108. private static string GetRPT030101SSQL(SUserInfo user, RPT030101_SE se, ref List<OracleParameter> parameters)
  5109. {
  5110. //string selSql = "";
  5111. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  5112. /*
  5113. selSql = selSql +
  5114. "select " +
  5115. " decode(t.ProductionLineName,'合计','合计',decode(t.GoodsCode,'小计','--',t.OrganizationName)) OrganizationName, " +
  5116. " decode(t.Procedureid,'--','--',decode(t.GoodsCode,'小计','--',t.ProductionLineName)) ProductionLineName, " +
  5117. " decode(t.GoodsCode,'小计','--',t.Procedureid) Procedureid, " +
  5118. " decode(t.GoodsCode,'小计','--',t.ProcedureName) ProcedureName, " +
  5119. " decode(t.GoodsCode,'小计','小计',t.GoodsTypeName) GoodsTypeName, " +
  5120. " decode(t.GoodsTypeName,'小计','--',t.GoodsId) GoodsId, " +
  5121. " decode(t.ProductionLineName,'合计','--',decode(t.GoodsId,null,'--',t.GoodsCode)) GoodsCode, " +
  5122. " decode(t.GoodsCode,'小计','--',t.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  5123. " decode(t.GoodsCode,'小计','--',t.Dictionaryvalue) Dictionaryvalue, " +
  5124. " decode(t.GoodsCode,'小计','--',g.goodsname) goodsname, " +
  5125. " decode(t.GoodsCode,'小计','--',g.GOODSMODEL) GOODSMODEL, " +
  5126. " t.产量 " +
  5127. "from " +
  5128. "( " +
  5129. " select " +
  5130. " decode(grouping(TP_MST_Organization.OrganizationName),1,'总计',TP_MST_Organization.OrganizationName) OrganizationName, " +
  5131. " decode(grouping(TP_MST_Organization.OrganizationName),1,'--', " +
  5132. " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'合计',TP_PM_ProductionData.ProductionLineName)) ProductionLineName, " +
  5133. " decode(grouping(TP_PM_ProductionData.Procedureid),1,'--',TP_PM_ProductionData.Procedureid) Procedureid, " +
  5134. " decode(grouping(TP_PM_ProductionData.ProcedureName),1,'--',TP_PM_ProductionData.ProcedureName) ProcedureName, " +
  5135. " decode(grouping(TP_MST_GOODSTYPE.GoodsTypeName),1,'--',TP_MST_GOODSTYPE.GoodsTypeName) GoodsTypeName, " +
  5136. " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'--', " +
  5137. " decode(grouping(TP_PM_ProductionData.GoodsCode),1,'小计',TP_PM_ProductionData.GoodsCode)) GoodsCode, " +
  5138. " decode(grouping(TP_PM_ProductionData.GoodsId),1,null,TP_PM_ProductionData.GoodsId) GoodsId, " +
  5139. " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  5140. " decode(grouping(TP_MST_DATADICTIONARY.DICTIONARYVALUE),1,'--',TP_MST_DATADICTIONARY.Dictionaryvalue) Dictionaryvalue, " +
  5141. " count(BarCode) as 产量 " +
  5142. " from TP_PM_ProductionData " +
  5143. " left join TP_MST_Goods on TP_MST_Goods.GoodsID=TP_PM_ProductionData.GoodsID " +
  5144. " left join TP_MST_GoodsType on TP_MST_GoodsType.GoodsTypeID=TP_MST_Goods.GoodsTypeID " +
  5145. " left join TP_MST_Organization on TP_MST_Organization.OrganizationID=TP_PM_ProductionData.OrganizationID " +
  5146. " left join TP_MST_DATADICTIONARY on TP_MST_DATADICTIONARY.DICTIONARYID=TP_MST_Goods.GLAZETYPEID " +
  5147. " Where 1=1 and TP_PM_ProductionData.ValueFlag = 1 " +
  5148. // 公坯、干补不算交坯工序的质量。
  5149. (se.ProductionFlag == "1" ? " and ((TP_PM_ProductionData.modeltype <> 5) or (TP_PM_ProductionData.modeltype = 5 and (TP_PM_ProductionData.IsPublicBody = '0' or TP_PM_ProductionData.SpecialRepairFlag = '0'))) \n" : "") +
  5150. " and TP_PM_ProductionData.AccountID=:AccountID ";
  5151. if (!string.IsNullOrEmpty(se.GoodsIDS))
  5152. {
  5153. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  5154. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  5155. }
  5156. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  5157. {
  5158. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
  5159. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPEcode,:GoodsTypeIDS)=1 ";
  5160. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  5161. }
  5162. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  5163. {
  5164. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  5165. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  5166. }
  5167. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  5168. {
  5169. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_ProductionData.ProcedureId||',')>0 ";
  5170. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  5171. }
  5172. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  5173. {
  5174. selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||TP_MST_Organization.OrganizationId||',')>0 ";
  5175. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  5176. }
  5177. if (se.AccountDateStart.HasValue)
  5178. {
  5179. selSql = selSql + " AND TP_PM_ProductionData.CREATETIME >= :AccountDateStart ";
  5180. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  5181. }
  5182. if (se.AccountDateEnd.HasValue)
  5183. {
  5184. selSql = selSql + " AND TP_PM_ProductionData.CREATETIME <= :AccountDateEnd ";
  5185. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  5186. }
  5187. selSql = selSql +
  5188. "group by " +
  5189. " rollup(TP_MST_Organization.OrganizationName, " +
  5190. " TP_PM_ProductionData.ProductionLineName, " +
  5191. " TP_PM_ProductionData.Procedureid, " +
  5192. " TP_PM_ProductionData.ProcedureName, " +
  5193. " TP_MST_GOODSTYPE.GoodsTypeName, " +
  5194. " TP_PM_ProductionData.GoodsCode, " +
  5195. " TP_PM_ProductionData.GoodsId, " +
  5196. " TP_MST_Goods.GOODSSPECIFICATION, " +
  5197. " TP_MST_DATADICTIONARY.Dictionaryvalue) " +
  5198. " order by " +
  5199. " TP_MST_Organization.OrganizationName, " +
  5200. " TP_PM_ProductionData.ProductionLineName, " +
  5201. " TP_PM_ProductionData.Procedureid, " +
  5202. " TP_PM_ProductionData.ProcedureName, " +
  5203. " TP_MST_GOODSTYPE.GoodsTypeName " +
  5204. ") t \n" +
  5205. // 增加 产品型号
  5206. "left join tp_mst_goods g on g.goodsid = t.goodsid \n" +
  5207. "where 1=1 " +
  5208. "and (t.DICTIONARYVALUE!='--' ) " +
  5209. "or (t.GoodsTypeName='--' and t.ProductionLineName='合计') " +
  5210. "or (t.GoodsTypeName='--' and t.OrganizationName='总计') " +
  5211. "or (t.GoodsCode='小计' and t.GoodsTypeName!='--')";
  5212. */
  5213. string selSql =
  5214. "select t.gid\n" +
  5215. " ,decode(t.gid, 15, '总计', t.ProductionLineName) ProductionLineName\n" +
  5216. " ,t.OrganizationID\n" +
  5217. " --,t.OrganizationCode\n" +
  5218. " ,decode(t.gid\n" +
  5219. " ,7\n" +
  5220. " ,'合计[' || t.OrganizationName || ']'\n" +
  5221. " ,15\n" +
  5222. " ,'--'\n" +
  5223. " ,t.OrganizationName) OrganizationName\n" +
  5224. " ,t.Procedureid\n" +
  5225. " ,decode(t.gid\n" +
  5226. " ,3\n" +
  5227. " ,'小计[' || t.ProcedureName || ']'\n" +
  5228. " ,0\n" +
  5229. " ,t.ProcedureName\n" +
  5230. " ,1\n" +
  5231. " ,t.ProcedureName\n" +
  5232. " ,'--') ProcedureName\n" +
  5233. " ,t.GoodsTypeID\n" +
  5234. " ,decode(t.gid\n" +
  5235. " ,1\n" +
  5236. " ,'小计[' || t.GoodsTypeName || ']'\n" +
  5237. " ,0\n" +
  5238. " ,t.GoodsTypeName\n" +
  5239. " ,'--') GoodsTypeName\n" +
  5240. " --,t.GoodsId\n" +
  5241. " ,decode(t.gid, 0, to_char(t.GoodsId), '--') GoodsId\n" +
  5242. " ,decode(t.gid, 0, t.GoodsCode, '--') GoodsCode\n" +
  5243. " ,decode(t.gid, 0, t.GOODSSPECIFICATION, '--') GOODSSPECIFICATION\n" +
  5244. " ,decode(t.gid, 0, t.Dictionaryvalue, '--') Dictionaryvalue\n" +
  5245. " ,t.pfcount as 产量\n" +
  5246. " from (select grouping_id(org.OrganizationID\n" +
  5247. " ,p.Procedureid\n" +
  5248. " ,gt.goodstypeid\n" +
  5249. " ,g.GoodsId) as gid\n" +
  5250. " ,pd.ProductionLineName\n" +
  5251. " ,org.OrganizationID\n" +
  5252. " --,org.OrganizationCode\n" +
  5253. " ,org.OrganizationName\n" +
  5254. " ,p.Procedureid\n" +
  5255. " ,p.ProcedureName\n" +
  5256. " ,gt.GoodsTypeID\n" +
  5257. " ,gt.GoodsTypeName\n" +
  5258. " ,g.GoodsId\n" +
  5259. " ,g.GoodsCode\n" +
  5260. " ,g.GOODSSPECIFICATION\n" +
  5261. " ,d.Dictionaryvalue\n" +
  5262. " ,count(BarCode) as pfcount" +
  5263. " from TP_PM_ProductionData pd\n" +
  5264. " inner join tp_pc_Procedure p\n" +
  5265. " on p.Procedureid = pd.Procedureid\n" +
  5266. " inner join TP_MST_Goods g\n" +
  5267. " on g.GoodsID = pd.GoodsID\n" +
  5268. " inner join TP_MST_GoodsType gt\n" +
  5269. " on gt.GoodsTypeID = g.GoodsTypeID\n" +
  5270. " inner join TP_MST_Organization org\n" +
  5271. " on org.OrganizationID = pd.OrganizationID\n" +
  5272. " inner join TP_MST_DATADICTIONARY d\n" +
  5273. " on d.DICTIONARYID = g.GLAZETYPEID\n" +
  5274. " where pd.ValueFlag = '1'\n" +
  5275. " and pd.AccountID = :AccountID\n";
  5276. // 公坯、干补不算交坯工序的质量。
  5277. if (se.ProductionFlag == "1")
  5278. {
  5279. selSql += " and ((pd.modeltype <> 5) or (pd.modeltype = 5 and (pd.IsPublicBody = '0' or pd.SpecialRepairFlag = '0'))) \n";
  5280. }
  5281. if (!string.IsNullOrEmpty(se.GoodsIDS))
  5282. {
  5283. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||g.GoodsId||',')>0 ";
  5284. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  5285. }
  5286. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  5287. {
  5288. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
  5289. selSql = selSql + " AND instr(gt.GOODSTYPEcode,:GoodsTypeIDS)=1 ";
  5290. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  5291. }
  5292. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  5293. {
  5294. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pd.ProductionLineId||',')>0 ";
  5295. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  5296. }
  5297. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  5298. {
  5299. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||p.ProcedureId||',')>0 ";
  5300. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  5301. }
  5302. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  5303. {
  5304. selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||org.OrganizationId||',')>0 ";
  5305. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  5306. }
  5307. if (se.AccountDateStart.HasValue)
  5308. {
  5309. selSql = selSql + " AND pd.CREATETIME >= :AccountDateStart ";
  5310. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  5311. }
  5312. if (se.AccountDateEnd.HasValue)
  5313. {
  5314. selSql = selSql + " AND pd.CREATETIME <= :AccountDateEnd ";
  5315. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  5316. }
  5317. selSql +=
  5318. " group by grouping sets((pd.ProductionLineName, org.OrganizationID, org.organizationcode, org.OrganizationName, p.Procedureid, p.ProcedureName, p.displayno, gt.GoodsTypeID, gt.goodstypecode, gt.GoodsTypeName, g.GoodsId, g.GoodsCode, g.GOODSSPECIFICATION, d.Dictionaryvalue),(pd.ProductionLineName, org.OrganizationID, org.organizationcode, org.OrganizationName, p.Procedureid, p.ProcedureName, p.displayno, gt.GoodsTypeID, gt.goodstypecode, gt.GoodsTypeName),(pd.ProductionLineName, org.OrganizationID, org.organizationcode, org.OrganizationName, p.Procedureid, p.ProcedureName, p.displayno),(pd.ProductionLineName, org.OrganizationID, org.organizationcode, org.OrganizationName),())\n" +
  5319. " order by org.organizationcode\n" +
  5320. " ,p.displayno\n" +
  5321. " ,gt.goodstypecode\n" +
  5322. " ,g.goodscode) t";
  5323. return selSql;
  5324. }
  5325. /// <summary>
  5326. /// 取得RPT030101_1画面(产品产量汇总表)的明细信息查询数据
  5327. /// </summary>
  5328. /// <param name="user">登录用户信息</param>
  5329. /// <param name="se">查询条件</param>
  5330. /// <returns>查询结果</returns>
  5331. public static ServiceResultEntity GetRPT030101IData(SUserInfo user, RPT030101_SE se)
  5332. {
  5333. IDBConnection conn = null;
  5334. try
  5335. {
  5336. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  5337. List<OracleParameter> parameters = new List<OracleParameter>();
  5338. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030101ISQL(user, se, ref parameters));
  5339. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  5340. ServiceResultEntity sre = new ServiceResultEntity();
  5341. if (data == null || data.Rows.Count == 0)
  5342. {
  5343. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5344. return sre;
  5345. }
  5346. sre.Data = new DataSet();
  5347. sre.Data.Tables.Add(data);
  5348. return sre;
  5349. }
  5350. catch (Exception ex)
  5351. {
  5352. throw ex;
  5353. }
  5354. finally
  5355. {
  5356. if (conn != null &&
  5357. conn.ConnState == ConnectionState.Open)
  5358. {
  5359. conn.Close();
  5360. }
  5361. }
  5362. }
  5363. /// <summary>
  5364. /// 获取RPT030101_1画面(产品产量汇总表)的明细信息查询sql
  5365. /// </summary>
  5366. /// <returns>sql</returns>
  5367. private static string GetRPT030101ISQL(SUserInfo user, RPT030101_SE se, ref List<OracleParameter> parameters)
  5368. {
  5369. //string selSql = "";
  5370. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  5371. /*
  5372. selSql = selSql +
  5373. "select " +
  5374. "decode(ProductionLineName,'合计','合计',decode(temp.BarCode,'小计','--',OrganizationName)) OrganizationName, " +
  5375. "decode(ProcedureName,'--','--',decode(temp.barcode,'小计','--',temp.ProductionLineName)) ProductionLineName, " +
  5376. "decode(temp.BarCode,'小计','--',temp.ProcedureName) ProcedureName, " +
  5377. "decode(temp.BarCode,'小计','--',temp.GoodsTypeName) GoodsTypeName, " +
  5378. "decode(temp.BarCode,'小计','小计',temp.GoodsCode) GoodsCode, " +
  5379. "decode(ProductionLineName,'合计','--',decode(temp.usercode,'--','--',temp.Barcode)) BarCode, " +
  5380. "decode(temp.UserCode,'小计','--',temp.UserCode) UserCode, " +
  5381. "decode(GOODSSPECIFICATION,'小计','--',GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  5382. "decode(DICTIONARYVALUE,'小计','--',Dictionaryvalue) Dictionaryvalue, " +
  5383. "产量, " +
  5384. "replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName " +
  5385. "from " +
  5386. "( " +
  5387. " select " +
  5388. " decode(grouping(TP_MST_Organization.OrganizationName),1,'总计',TP_MST_Organization.OrganizationName) OrganizationName, " +
  5389. " decode(grouping(TP_MST_Organization.OrganizationName),1,'--', " +
  5390. " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'合计',TP_PM_ProductionData.ProductionLineName)) ProductionLineName, " +
  5391. " decode(grouping(TP_PM_ProductionData.ProcedureName),1,'--',TP_PM_ProductionData.ProcedureName) ProcedureName, " +
  5392. " decode(grouping(TP_MST_GOODSTYPE.GoodsTypeName),1,'--',TP_MST_GOODSTYPE.GoodsTypeName) GoodsTypeName, " +
  5393. " decode(grouping(TP_PM_ProductionData.GoodsCode),1,'--',TP_PM_ProductionData.GoodsCode) GoodsCode, " +
  5394. " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'--', " +
  5395. " decode(grouping(TP_PM_ProductionData.BarCode),1,'小计',TP_PM_ProductionData.BarCode)) BarCode, " +
  5396. " decode(grouping(TP_PM_ProductionData.UserCode),1,'--',TP_PM_ProductionData.UserCode) UserCode, " +
  5397. " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  5398. " decode(grouping(TP_MST_DATADICTIONARY.Dictionaryvalue),1,'--',TP_MST_DATADICTIONARY.Dictionaryvalue) Dictionaryvalue, " +
  5399. " count(BarCode) as 产量 " +
  5400. " from TP_PM_ProductionData " +
  5401. " left join TP_MST_Goods on TP_MST_Goods.GoodsID=TP_PM_ProductionData.GoodsID " +
  5402. " left join TP_MST_GoodsType on TP_MST_GoodsType.GoodsTypeID=TP_MST_Goods.GoodsTypeID " +
  5403. " left join TP_MST_Organization on TP_MST_Organization.OrganizationID=TP_PM_ProductionData.OrganizationID " +
  5404. " left join TP_MST_DATADICTIONARY on TP_MST_DATADICTIONARY.DICTIONARYID=TP_MST_Goods.GLAZETYPEID " +
  5405. " Where 1=1 " +
  5406. " and TP_PM_ProductionData.ValueFlag = 1 " +
  5407. // 公坯、干补不算交坯工序的质量。
  5408. " and ((TP_PM_ProductionData.modeltype <> 5) or (TP_PM_ProductionData.modeltype = 5 and TP_PM_ProductionData.IsPublicBody = '0' and TP_PM_ProductionData.SpecialRepairFlag = '0')) \n" +
  5409. " and TP_PM_ProductionData.AccountID=:AccountID ";
  5410. if (!string.IsNullOrEmpty(se.GoodsIDS))
  5411. {
  5412. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  5413. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  5414. }
  5415. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  5416. {
  5417. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
  5418. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)>0 ";
  5419. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  5420. }
  5421. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  5422. {
  5423. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  5424. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  5425. }
  5426. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  5427. {
  5428. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_ProductionData.ProcedureId||',')>0 ";
  5429. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  5430. }
  5431. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  5432. {
  5433. selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||TP_MST_Organization.OrganizationId||',')>0 ";
  5434. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  5435. }
  5436. if (se.AccountDateStart.HasValue)
  5437. {
  5438. selSql = selSql + " AND TP_PM_ProductionData.AccountDate >= :AccountDateStart ";
  5439. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  5440. }
  5441. if (se.AccountDateEnd.HasValue)
  5442. {
  5443. selSql = selSql + " AND TP_PM_ProductionData.AccountDate <= :AccountDateEnd ";
  5444. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  5445. }
  5446. selSql = selSql +
  5447. "group by " +
  5448. " rollup(TP_MST_Organization.OrganizationName, " +
  5449. " TP_PM_ProductionData.ProductionLineName, " +
  5450. " TP_PM_ProductionData.ProcedureName, " +
  5451. " TP_MST_GOODSTYPE.GoodsTypeName, " +
  5452. " TP_PM_ProductionData.GoodsCode, " +
  5453. " TP_PM_ProductionData.BarCode, " +
  5454. " TP_PM_ProductionData.UserCode, " +
  5455. " TP_MST_Goods.GOODSSPECIFICATION, " +
  5456. " TP_MST_DATADICTIONARY.Dictionaryvalue" +
  5457. " ) " +
  5458. " order by " +
  5459. " TP_MST_Organization.OrganizationName, " +
  5460. " TP_PM_ProductionData.ProductionLineName, " +
  5461. " TP_PM_ProductionData.ProcedureName, " +
  5462. " TP_MST_GOODSTYPE.GoodsTypeName " +
  5463. ") temp inner join TP_PM_GroutingDailyDetail on temp.barcode=TP_PM_GroutingDailyDetail.barcode " +
  5464. " inner join tp_mst_logo on TP_PM_GroutingDailyDetail.logoid=tp_mst_logo.logoid " +
  5465. "where 1=1 " +
  5466. "and (temp.DICTIONARYVALUE!='--') " +
  5467. "or (temp.GoodsTypeName='--' and temp.ProductionLineName='合计') " +
  5468. "or (temp.GoodsTypeName='--' and temp.OrganizationName='总计') " +
  5469. "or (temp.BarCode='小计' and temp.GoodsCode!='--')";
  5470. */
  5471. string selSql =
  5472. " select " +
  5473. " TP_MST_Organization.OrganizationName, " +
  5474. " TP_PM_ProductionData.ProductionLineName, " +
  5475. " TP_PM_ProductionData.ProcedureName, " +
  5476. " TP_MST_GOODSTYPE.GoodsTypeName, " +
  5477. " TP_PM_ProductionData.GoodsCode, " +
  5478. " TP_MST_Goods.GoodsName, " +
  5479. " TP_MST_Goods.GoodsModel, " +
  5480. " TP_PM_ProductionData.BarCode, " +
  5481. " TP_PM_ProductionData.UserCode, " +
  5482. " TP_MST_Goods.GOODSSPECIFICATION, " +
  5483. " TP_MST_DATADICTIONARY.Dictionaryvalue, " +
  5484. " TP_PM_ProductionData.CREATETIME, " +
  5485. " TP_PM_ProductionData.KILNcarCODE, " +
  5486. " TP_PM_ProductionData.KILNCODE, " +
  5487. " cu.usercode createusercode, " +
  5488. " cu.username CreateUserName, " +
  5489. " gdd.glazingroom," +
  5490. " decode(tp_mst_logo.logoid,null,'',TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']') as LogoCodeName " +
  5491. " from TP_PM_ProductionData " +
  5492. " left join TP_MST_Goods on TP_MST_Goods.GoodsID=TP_PM_ProductionData.GoodsID " +
  5493. " left join TP_MST_GoodsType on TP_MST_GoodsType.GoodsTypeID=TP_MST_Goods.GoodsTypeID " +
  5494. " left join TP_MST_Organization on TP_MST_Organization.OrganizationID=TP_PM_ProductionData.OrganizationID " +
  5495. " left join TP_MST_DATADICTIONARY on TP_MST_DATADICTIONARY.DICTIONARYID=TP_MST_Goods.GLAZETYPEID " +
  5496. " left join tp_mst_logo on TP_PM_ProductionData.logoid=tp_mst_logo.logoid " +
  5497. " left join tp_mst_user cu on TP_PM_ProductionData.createuserid=cu.userid " +
  5498. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  5499. " ON gdd.Groutingdailydetailid = TP_PM_ProductionData.Groutingdailydetailid\n" +
  5500. " Where TP_PM_ProductionData.ValueFlag = '1' " +
  5501. // 公坯、干补不算交坯工序的质量。
  5502. " 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" +
  5503. " and TP_PM_ProductionData.AccountID=:AccountID ";
  5504. if (!string.IsNullOrEmpty(se.GoodsIDS))
  5505. {
  5506. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  5507. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  5508. }
  5509. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  5510. {
  5511. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
  5512. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)>0 ";
  5513. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  5514. }
  5515. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  5516. {
  5517. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  5518. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  5519. }
  5520. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  5521. {
  5522. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_ProductionData.ProcedureId||',')>0 ";
  5523. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  5524. }
  5525. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  5526. {
  5527. selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||TP_MST_Organization.OrganizationId||',')>0 ";
  5528. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  5529. }
  5530. if (se.AccountDateStart.HasValue)
  5531. {
  5532. selSql = selSql + " AND TP_PM_ProductionData.CREATETIME >= :AccountDateStart ";
  5533. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  5534. }
  5535. if (se.AccountDateEnd.HasValue)
  5536. {
  5537. selSql = selSql + " AND TP_PM_ProductionData.CREATETIME <= :AccountDateEnd ";
  5538. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  5539. }
  5540. return selSql;
  5541. }
  5542. /// <summary>
  5543. /// 取得RPT030102_1画面(产品损坯汇总表)的汇总信息查询数据
  5544. /// </summary>
  5545. /// <param name="user">登录用户信息</param>
  5546. /// <param name="se">查询条件</param>
  5547. /// <returns>查询结果</returns>
  5548. public static ServiceResultEntity GetRPT030102SData(SUserInfo user, RPT030102_SE se)
  5549. {
  5550. IDBConnection conn = null;
  5551. try
  5552. {
  5553. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  5554. List<OracleParameter> parameters = new List<OracleParameter>();
  5555. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030102SSQL(user, se, ref parameters));
  5556. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  5557. ServiceResultEntity sre = new ServiceResultEntity();
  5558. if (data == null || data.Rows.Count == 0)
  5559. {
  5560. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5561. return sre;
  5562. }
  5563. sre.Data = new DataSet();
  5564. sre.Data.Tables.Add(data);
  5565. return sre;
  5566. }
  5567. catch (Exception ex)
  5568. {
  5569. throw ex;
  5570. }
  5571. finally
  5572. {
  5573. if (conn != null &&
  5574. conn.ConnState == ConnectionState.Open)
  5575. {
  5576. conn.Close();
  5577. }
  5578. }
  5579. }
  5580. /// <summary>
  5581. /// 获取RPT030102_1画面(产品损坯汇总表)的汇总信息查询sql
  5582. /// </summary>
  5583. /// <returns>sql</returns>
  5584. private static string GetRPT030102SSQL(SUserInfo user, RPT030102_SE se, ref List<OracleParameter> parameters)
  5585. {
  5586. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  5587. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  5588. string sqlString = "SELECT decode(ts.gid,\n" +
  5589. " 7,\n" +
  5590. " '总计',\n" +
  5591. " 3,\n" +
  5592. " '合计【' || ts.zrprocedurename || '】',\n" +
  5593. " 0,\n" +
  5594. " ts.zrprocedurename,\n" +
  5595. " '--') zrprocedurename\n" +
  5596. " ,decode(ts.gid,\n" +
  5597. " 1,\n" +
  5598. " '小计【' || ts.goodstypename2 || '】',\n" +
  5599. " 0,\n" +
  5600. " ts.goodstypename2,\n" +
  5601. " '--') goodstypename2\n" +
  5602. " ,decode(ts.gid, 0, ts.zrusercode, '--') zrusercode\n" +
  5603. " ,decode(ts.gid, 0, ts.goodscode, '--') goodscode\n" +
  5604. " ,decode(ts.gid, 0, ts.GOODSMODEL, '--') GOODSMODEL\n" +
  5605. " ,ts.productionlineid\n" +
  5606. " ,ts.zrprocedureid\n" +
  5607. " ,ts.goodstypecode2\n" +
  5608. " ,ts.zruserid\n" +
  5609. " ,ts.goodsid\n" +
  5610. " ,ts.barcount\n" +
  5611. " FROM (SELECT grouping_id(t.zrprocedureid, t.goodstypecode2, t.zruserid) gid\n" +
  5612. " ,t.productionlineid\n" +
  5613. " ,t.productionlinename\n" +
  5614. " ,t.displayno\n" +
  5615. " ,t.zrprocedureid\n" +
  5616. " ,t.zrprocedurename\n" +
  5617. " ,t.goodstypecode2\n" +
  5618. " ,t.goodstypename2\n" +
  5619. " ,t.zruserid\n" +
  5620. " ,t.zrusercode\n" +
  5621. " ,t.goodsid\n" +
  5622. " ,t.goodscode\n" +
  5623. " ,t.GOODSMODEL\n" +
  5624. " ,COUNT(t.barcode) barcount\n" +
  5625. " FROM (SELECT sp.productionlineid\n" +
  5626. " ,pline.productionlinename\n" +
  5627. " ,nvl(zp.displayno, -1) displayno\n" +
  5628. " ,zp.procedureid zrprocedureid\n" +
  5629. " ,zp.procedurename zrprocedurename\n" +
  5630. " ,sr.userid zruserid\n" +
  5631. " ,sr.usercode zrusercode\n" +
  5632. " ,gt2.goodstypecode goodstypecode2\n" +
  5633. " ,gt2.goodstypename goodstypename2\n" +
  5634. " ,g.goodsid\n" +
  5635. " ,g.goodscode\n" +
  5636. " ,g.GOODSMODEL\n" +
  5637. " ,sp.barcode\n" +
  5638. " FROM tp_pm_scrapproduct sp\n" +
  5639. " LEFT JOIN TP_PM_ResponProcedure rp\n" +
  5640. " ON rp.scrapproductid = sp.scrapproductid\n" +
  5641. " LEFT JOIN (SELECT DISTINCT t.ScrapProductID\n" +
  5642. " ,t.ResponProcedureID\n" +
  5643. " ,t.userid\n" +
  5644. " ,t.usercode\n" +
  5645. " FROM TP_PM_ScrapResponsible t) sr\n" +
  5646. " ON sr.scrapproductid = sp.scrapproductid\n" +
  5647. // wangx 2016-06-20
  5648. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  5649. " ON rp.barcode = gdd.barcode\n" +
  5650. // wangx 2016-06-20 end
  5651. " LEFT JOIN tp_pc_productionline pline\n" +
  5652. " ON pline.productionlineid = sp.productionlineid\n" +
  5653. " LEFT JOIN tp_pc_procedure zp\n" +
  5654. " ON zp.procedureid = rp.procedureid\n" +
  5655. " LEFT JOIN tp_mst_user cu\n" +
  5656. " ON cu.userid = sp.createuserid\n" +
  5657. " LEFT JOIN tp_mst_user au\n" +
  5658. " ON au.userid = sp.auditor\n" +
  5659. " LEFT JOIN tp_mst_goods g\n" +
  5660. " ON g.goodsid = sp.goodsid\n" +
  5661. " LEFT JOIN tp_mst_goodstype gt\n" +
  5662. " ON gt.goodstypeid = g.goodstypeid\n" +
  5663. " LEFT JOIN tp_mst_goodstype gt2\n" +
  5664. " ON gt2.accountid = gt.accountid\n" +
  5665. " AND gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  5666. " WHERE sp.valueflag = '1'\n" +
  5667. " AND sp.AuditStatus = '1'\n" +
  5668. // 生产线
  5669. //" 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))" +
  5670. // 完成工序
  5671. //" 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))" +
  5672. // 责任工序
  5673. //" 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)))" +
  5674. " AND sp.accountid = :AccountID\n" +
  5675. (se.SpecialRepairFlag ? " AND sp.GoodsLevelTypeID in (8,9) -- 8损坯、9干补\n" : " AND sp.GoodsLevelTypeID = 8 -- 8损坯、9干补\n") +
  5676. (se.ReFireFlag ? " " : " AND sp.IsReFire <> '6'\n") +
  5677. " AND sp.ScrapType = '0'\n" +
  5678. " AND (:ProductionLineID IS NULL OR\n" +
  5679. " sp.ProductionLineID = :ProductionLineID)\n" +
  5680. " AND (:GoodsTypeCode IS NULL OR\n" +
  5681. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  5682. " AND (:GoodsCode IS NULL OR\n" +
  5683. " instr(g.GoodsCode, :GoodsCode) > 0)\n" +
  5684. " AND (:ProcedureIDS IS NULL OR\n" +
  5685. " instr(:ProcedureIDS, ',' || sp.ProcedureID || ',') > 0)\n" +
  5686. " AND (:ResponProcedureIDS IS NULL OR\n" +
  5687. " instr(:ResponProcedureIDS,\n" +
  5688. " ',' || rp.ProcedureID || ',') > 0)\n" +
  5689. " AND (:ResponUserIDS IS NULL OR\n" +
  5690. " instr(:ResponUserIDS, ',' || sr.userid || ',') > 0)\n" +
  5691. // 损坯时间
  5692. " AND (:ScrapDateStart IS NULL OR\n" +
  5693. " sp.CreateTime >= :ScrapDateStart)\n" +
  5694. " AND (:ScrapDateEnd IS NULL OR\n" +
  5695. " sp.CreateTime <= :ScrapDateEnd)\n" +
  5696. // 审核时间
  5697. " AND (:AuditDateStart IS NULL OR\n" +
  5698. " sp.AuditDate >= :AuditDateStart)\n" +
  5699. " AND (:AuditDateEnd IS NULL OR\n" +
  5700. " sp.AuditDate <= :AuditDateEnd)\n" +
  5701. // 完成时间
  5702. " AND (:CTimeStart IS NULL OR\n" +
  5703. " sp.CreateTime >= :CTimeStart)\n" +
  5704. " AND (:CTimeEnd IS NULL OR\n" +
  5705. " sp.CreateTime <= :CTimeEnd)\n" +
  5706. // 交坯时间
  5707. " AND (:DTimeStart IS NULL OR\n" +
  5708. " gdd.DeliverTime >= :DTimeStart)\n" +
  5709. " AND (:DTimeEnd IS NULL OR\n" +
  5710. " gdd.DeliverTime <= :DTimeEnd)\n" +
  5711. // 注浆时间
  5712. " AND (:GTimeStart IS NULL OR\n" +
  5713. " gdd.GroutingDate >= :GTimeStart)\n" +
  5714. " AND (:GTimeEnd IS NULL OR\n" +
  5715. " gdd.GroutingDate <= :GTimeEnd)\n" +
  5716. " AND (:CreatUser IS NULL OR\n" +
  5717. " instr(cu.UserCode, :CreatUser) > 0)\n" +
  5718. " AND (:AuditUser IS NULL OR\n" +
  5719. " instr(au.UserCode, :AuditUser) > 0)) t\n" +
  5720. " 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" +
  5721. " ORDER BY t.displayno, t.goodstypecode2, t.zrusercode, t.goodscode) ts";
  5722. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  5723. if (string.IsNullOrEmpty(se.ProcedureIDS))
  5724. {
  5725. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5726. }
  5727. else
  5728. {
  5729. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  5730. }
  5731. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  5732. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  5733. if (string.IsNullOrEmpty(se.ResponProcedureIDS))
  5734. {
  5735. parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5736. }
  5737. else
  5738. {
  5739. parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, "," + se.ResponProcedureIDS + ",", ParameterDirection.Input));
  5740. }
  5741. if (string.IsNullOrEmpty(se.ResponUserIDS))
  5742. {
  5743. parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5744. }
  5745. else
  5746. {
  5747. parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, "," + se.ResponUserIDS + ",", ParameterDirection.Input));
  5748. }
  5749. parameters.Add(new OracleParameter(":CreatUser", OracleDbType.Varchar2, se.CreatUser, ParameterDirection.Input));
  5750. parameters.Add(new OracleParameter(":AuditUser", OracleDbType.Varchar2, se.AuditUser, ParameterDirection.Input));
  5751. parameters.Add(new OracleParameter(":ScrapDateStart", OracleDbType.Date, se.ScrapDateStart, ParameterDirection.Input));
  5752. parameters.Add(new OracleParameter(":ScrapDateEnd", OracleDbType.Date, se.ScrapDateEnd, ParameterDirection.Input));
  5753. parameters.Add(new OracleParameter(":CTimeStart", OracleDbType.Date, se.CTimeStart, ParameterDirection.Input));
  5754. parameters.Add(new OracleParameter(":CTimeEnd", OracleDbType.Date, se.CTimeEnd, ParameterDirection.Input));
  5755. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart, ParameterDirection.Input));
  5756. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd, ParameterDirection.Input));
  5757. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart, ParameterDirection.Input));
  5758. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd, ParameterDirection.Input));
  5759. parameters.Add(new OracleParameter(":AuditDateStart", OracleDbType.Date, se.AuditTimeStart, ParameterDirection.Input));
  5760. parameters.Add(new OracleParameter(":AuditDateEnd", OracleDbType.Date, se.AuditTimeEnd, ParameterDirection.Input));
  5761. return sqlString;
  5762. }
  5763. /// <summary>
  5764. /// 取得RPT030102_1画面(产品损坯汇总表)的明细信息查询数据
  5765. /// </summary>
  5766. /// <param name="user">登录用户信息</param>
  5767. /// <param name="se">查询条件</param>
  5768. /// <returns>查询结果</returns>
  5769. public static ServiceResultEntity GetRPT030102IData(SUserInfo user, RPT030102_SE se)
  5770. {
  5771. IDBConnection conn = null;
  5772. try
  5773. {
  5774. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  5775. List<OracleParameter> parameters = new List<OracleParameter>();
  5776. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030102ISQL(user, se, ref parameters));
  5777. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  5778. ServiceResultEntity sre = new ServiceResultEntity();
  5779. if (data == null || data.Rows.Count == 0)
  5780. {
  5781. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5782. return sre;
  5783. }
  5784. sre.Data = new DataSet();
  5785. sre.Data.Tables.Add(data);
  5786. return sre;
  5787. }
  5788. catch (Exception ex)
  5789. {
  5790. throw ex;
  5791. }
  5792. finally
  5793. {
  5794. if (conn != null &&
  5795. conn.ConnState == ConnectionState.Open)
  5796. {
  5797. conn.Close();
  5798. }
  5799. }
  5800. }
  5801. /// <summary>
  5802. /// 获取RPT030102_1画面(产品损坯汇总表)的明细信息查询sql
  5803. /// </summary>
  5804. /// <returns>sql</returns>
  5805. private static string GetRPT030102ISQL(SUserInfo user, RPT030102_SE se, ref List<OracleParameter> parameters)
  5806. {
  5807. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  5808. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  5809. string sqlString =
  5810. "SELECT pline.productionlinename\n" +
  5811. " ,p.procedurename\n" +
  5812. " ,zp.procedurename zrprocedurename\n" +
  5813. " ,sr.usercode zrusercode\n" +
  5814. " ,sr.StaffNames zrStaffNames\n" +
  5815. " ,gt2.goodstypecode goodstypecode2\n" +
  5816. " ,gt2.goodstypename goodstypename2\n" +
  5817. " ,gt.goodstypename\n" +
  5818. " ,g.goodscode\n" +
  5819. " ,g.GOODSMODEL\n" +
  5820. " ,sp.barcode\n" +
  5821. " ,sp.createtime Scrapdate\n" +
  5822. " ,sp.Rreason\n" +
  5823. " ,sp.GroutingUserCode\n" +
  5824. " ,sp.GroutingLineCode\n" +
  5825. " ,sp.GroutingMouldCode\n" +
  5826. " ,sp.GroutingDate\n" +
  5827. " ,sp.GroutingNum\n" +
  5828. " ,cu.usercode CreateUserCode\n" +
  5829. " ,au.usercode AuditorCode\n" +
  5830. " ,sp.auditdate\n" +
  5831. " ,gdd.DeliverTime\n" +
  5832. " ,gdd.ISPUBLICBODY\n" +
  5833. " ,gdd.SPECIALREPAIRFLAG\n" +
  5834. " ,lg.logoname\n" +
  5835. " ,sp.CreateTime\n" +
  5836. " ,sp.Remarks\n" +
  5837. " FROM tp_pm_scrapproduct sp\n" +
  5838. " LEFT JOIN TP_PM_ResponProcedure rp\n" +
  5839. " ON rp.scrapproductid = sp.scrapproductid\n" +
  5840. " LEFT JOIN (SELECT DISTINCT t.ScrapProductID\n" +
  5841. " ,t.ResponProcedureID\n" +
  5842. " ,t.userid\n" +
  5843. " ,t.usercode\n" +
  5844. " ,LISTAGG(to_char(s.StaffName), ',') WITHIN GROUP(ORDER BY s.staffcode) over(partition by t.ScrapProductID) AS StaffNames\n" +
  5845. " FROM TP_PM_ScrapResponsible t\n" +
  5846. " LEFT JOIN TP_HR_Staff s \n" +
  5847. " ON s.StaffID = t.StaffID \n" +
  5848. " ) sr\n" +
  5849. " ON sr.scrapproductid = sp.scrapproductid\n" +
  5850. // wangx 2016-06-20
  5851. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  5852. " ON sp.barcode = gdd.barcode\n" +
  5853. // wangx 2016-06-20 end
  5854. " LEFT JOIN TP_mst_logo lg\n" +
  5855. " ON lg.logoid = gdd.logoid\n" +
  5856. " LEFT JOIN tp_pc_productionline pline\n" +
  5857. " ON pline.productionlineid = sp.productionlineid\n" +
  5858. " LEFT JOIN tp_pc_procedure p\n" +
  5859. " ON p.procedureid = sp.procedureid\n" +
  5860. " LEFT JOIN tp_pc_procedure zp\n" +
  5861. " ON zp.procedureid = rp.procedureid\n" +
  5862. " LEFT JOIN tp_mst_user cu\n" +
  5863. " ON cu.userid = sp.createuserid\n" +
  5864. " LEFT JOIN tp_mst_user au\n" +
  5865. " ON au.userid = sp.auditor\n" +
  5866. " LEFT JOIN tp_mst_goods g\n" +
  5867. " ON g.goodsid = sp.goodsid\n" +
  5868. " LEFT JOIN tp_mst_goodstype gt\n" +
  5869. " ON gt.goodstypeid = g.goodstypeid\n" +
  5870. " LEFT JOIN tp_mst_goodstype gt2\n" +
  5871. " ON gt2.accountid = gt.accountid\n" +
  5872. " AND gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  5873. " WHERE sp.valueflag = '1'\n" +
  5874. " AND sp.AuditStatus = '1'\n" +
  5875. " AND sp.accountid = :accountid\n" +
  5876. // 生产线
  5877. //" 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))" +
  5878. // 完成工序
  5879. //" 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))" +
  5880. // 责任工序
  5881. //" 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)))" +
  5882. //" AND sp.GoodsLevelTypeID = 8 -- 8损坯、9干补\n" +
  5883. (se.SpecialRepairFlag ? " AND sp.GoodsLevelTypeID in (8,9) -- 8损坯、9干补\n" : " AND sp.GoodsLevelTypeID = 8 -- 8损坯、9干补\n") +
  5884. (se.ReFireFlag ? " " : " AND sp.IsReFire <> '6'\n") +
  5885. " AND sp.ScrapType = '0'\n" +
  5886. " AND (:ProductionLineID IS NULL OR\n" +
  5887. " sp.ProductionLineID = :ProductionLineID)\n" +
  5888. " AND (:GoodsTypeCode IS NULL OR\n" +
  5889. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  5890. " AND (:GoodsCode IS NULL OR instr(g.GoodsCode, :GoodsCode) > 0)\n" +
  5891. " AND (:ProcedureIDS IS NULL OR\n" +
  5892. " instr(:ProcedureIDS, ',' || sp.ProcedureID || ',') > 0)\n" +
  5893. " AND (:ResponProcedureIDS IS NULL OR\n" +
  5894. " instr(:ResponProcedureIDS, ',' || rp.ProcedureID || ',') > 0)\n" +
  5895. " AND (:ResponUserIDS IS NULL OR\n" +
  5896. " instr(:ResponUserIDS, ',' || sr.userid || ',') > 0)\n" +
  5897. // 损坯时间
  5898. " AND (:ScrapDateStart IS NULL OR sp.CreateTime >= :ScrapDateStart)\n" +
  5899. " AND (:ScrapDateEnd IS NULL OR sp.CreateTime <= :ScrapDateEnd)\n" +
  5900. // 审核时间
  5901. " AND (:AuditDateStart IS NULL OR sp.AuditDate >= :AuditDateStart)\n" +
  5902. " AND (:AuditDateEnd IS NULL OR sp.AuditDate <= :AuditDateEnd)\n" +
  5903. // 完成时间
  5904. " AND (:CTimeStart IS NULL OR\n" +
  5905. " sp.CreateTime >= :CTimeStart)\n" +
  5906. " AND (:CTimeEnd IS NULL OR\n" +
  5907. " sp.CreateTime <= :CTimeEnd)\n" +
  5908. // 交坯时间
  5909. " AND (:DTimeStart IS NULL OR\n" +
  5910. " gdd.DeliverTime >= :DTimeStart)\n" +
  5911. " AND (:DTimeEnd IS NULL OR\n" +
  5912. " gdd.DeliverTime <= :DTimeEnd)\n" +
  5913. // 注浆时间
  5914. " AND (:GTimeStart IS NULL OR\n" +
  5915. " gdd.GroutingDate >= :GTimeStart)\n" +
  5916. " AND (:GTimeEnd IS NULL OR\n" +
  5917. " gdd.GroutingDate <= :GTimeEnd)\n" +
  5918. " AND (:CreatUser IS NULL OR instr(cu.UserCode, :CreatUser) > 0)\n" +
  5919. " AND (:AuditUser IS NULL OR instr(au.UserCode, :AuditUser) > 0)\n" +
  5920. " AND (:GoodsID IS NULL OR sp.goodsid = :GoodsID)\n" +
  5921. " AND (:ResponProcedureID IS NULL OR rp.procedureid = :ResponProcedureID)\n" +
  5922. " AND (:ResponUserID IS NULL OR sr.userid = :ResponUserID)\n" +
  5923. " AND (:RPF = 1 OR rp.procedureid is null)\n" +
  5924. " AND (:RUF = 1 OR sr.userid is null)\n" +
  5925. " ORDER BY pline.productionlinename, nvl(zp.displayno, -1), sp.barcode";
  5926. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  5927. if (string.IsNullOrEmpty(se.ProcedureIDS))
  5928. {
  5929. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5930. }
  5931. else
  5932. {
  5933. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  5934. }
  5935. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  5936. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  5937. if (string.IsNullOrEmpty(se.ResponProcedureIDS))
  5938. {
  5939. parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5940. }
  5941. else
  5942. {
  5943. parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, "," + se.ResponProcedureIDS + ",", ParameterDirection.Input));
  5944. }
  5945. if (string.IsNullOrEmpty(se.ResponUserIDS))
  5946. {
  5947. parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5948. }
  5949. else
  5950. {
  5951. parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, "," + se.ResponUserIDS + ",", ParameterDirection.Input));
  5952. }
  5953. parameters.Add(new OracleParameter(":CreatUser", OracleDbType.Varchar2, se.CreatUser, ParameterDirection.Input));
  5954. parameters.Add(new OracleParameter(":AuditUser", OracleDbType.Varchar2, se.AuditUser, ParameterDirection.Input));
  5955. parameters.Add(new OracleParameter(":ScrapDateStart", OracleDbType.Date, se.ScrapDateStart, ParameterDirection.Input));
  5956. parameters.Add(new OracleParameter(":ScrapDateEnd", OracleDbType.Date, se.ScrapDateEnd, ParameterDirection.Input));
  5957. parameters.Add(new OracleParameter(":AuditDateStart", OracleDbType.Date, se.AuditTimeStart, ParameterDirection.Input));
  5958. parameters.Add(new OracleParameter(":AuditDateEnd", OracleDbType.Date, se.AuditTimeEnd, ParameterDirection.Input));
  5959. parameters.Add(new OracleParameter(":CTimeStart", OracleDbType.Date, se.CTimeStart, ParameterDirection.Input));
  5960. parameters.Add(new OracleParameter(":CTimeEnd", OracleDbType.Date, se.CTimeEnd, ParameterDirection.Input));
  5961. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart, ParameterDirection.Input));
  5962. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd, ParameterDirection.Input));
  5963. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart, ParameterDirection.Input));
  5964. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd, ParameterDirection.Input));
  5965. parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  5966. if (se.ResponProcedureID == "")
  5967. {
  5968. parameters.Add(new OracleParameter(":RPF", OracleDbType.Int32, 0, ParameterDirection.Input));
  5969. parameters.Add(new OracleParameter(":ResponProcedureID", OracleDbType.Int32, null, ParameterDirection.Input));
  5970. }
  5971. else
  5972. {
  5973. parameters.Add(new OracleParameter(":RPF", OracleDbType.Int32, 1, ParameterDirection.Input));
  5974. parameters.Add(new OracleParameter(":ResponProcedureID", OracleDbType.Int32, se.ResponProcedureID, ParameterDirection.Input));
  5975. }
  5976. if (se.ResponUserID == "")
  5977. {
  5978. parameters.Add(new OracleParameter(":RUF", OracleDbType.Int32, 0, ParameterDirection.Input));
  5979. parameters.Add(new OracleParameter(":ResponUserID", OracleDbType.Int32, null, ParameterDirection.Input));
  5980. }
  5981. else
  5982. {
  5983. parameters.Add(new OracleParameter(":RUF", OracleDbType.Int32, 1, ParameterDirection.Input));
  5984. parameters.Add(new OracleParameter(":ResponUserID", OracleDbType.Int32, se.ResponUserID, ParameterDirection.Input));
  5985. }
  5986. return sqlString;
  5987. }
  5988. /// <summary>
  5989. /// 取得RPT030103_1画面(出窑数量汇总表)的汇总信息查询数据
  5990. /// </summary>
  5991. /// <param name="user">登录用户信息</param>
  5992. /// <param name="se">查询条件</param>
  5993. /// <returns>查询结果</returns>
  5994. public static ServiceResultEntity GetRPT030103SData(SUserInfo user, RPT030103_SE se)
  5995. {
  5996. IDBConnection conn = null;
  5997. try
  5998. {
  5999. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6000. List<OracleParameter> parameters = new List<OracleParameter>();
  6001. string sql = ReportModuleLogic.GetRPT030103SSQL(user, se, ref parameters);
  6002. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  6003. ServiceResultEntity sre = new ServiceResultEntity();
  6004. if (data == null || data.Rows.Count == 0)
  6005. {
  6006. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6007. return sre;
  6008. }
  6009. sre.Data = new DataSet();
  6010. sre.Data.Tables.Add(data);
  6011. return sre;
  6012. }
  6013. catch (Exception ex)
  6014. {
  6015. throw ex;
  6016. }
  6017. finally
  6018. {
  6019. if (conn != null &&
  6020. conn.ConnState == ConnectionState.Open)
  6021. {
  6022. conn.Close();
  6023. }
  6024. }
  6025. }
  6026. /// <summary>
  6027. /// 获取RPT030103_1画面(出窑数量汇总表)的汇总信息查询sql
  6028. /// </summary>
  6029. /// <returns>sql</returns>
  6030. private static string GetRPT030103SSQL(SUserInfo user, RPT030103_SE se, ref List<OracleParameter> parameters)
  6031. {
  6032. string selSql = "";
  6033. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6034. parameters.Add(new OracleParameter(":rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  6035. selSql = selSql +
  6036. "SELECT pdata.Procedureid Procedureid " +
  6037. " ,decode(gid, 3, '合计', 1, '小计【'||pdata.Procedurename||'】', pdata.Procedurename) Procedurename " +
  6038. " ,decode(gid, 0, to_char(pdata.Userid), '--') Userid " +
  6039. " ,decode(gid, 0, pdata.Usercode, '--') Usercode " +
  6040. " ,decode(gid, 0, to_char(pdata.KilnID), '--') Kilnid " +
  6041. " ,decode(gid, 0, pdata.Kilncode, '--') Kilncode " +
  6042. " ,decode(gid, 0, pdata.goodstypename, '--') goodstypename " +
  6043. " ,decode(gid, 0, to_char(pdata.Goodsid), '--') Goodsid " +
  6044. " ,decode(gid, 0, pdata.Goodscode, '--') Goodscode " +
  6045. " ,OutKilnCount " +
  6046. " FROM (SELECT grouping_id(pdata.Procedureid, " +
  6047. " pdata.Userid ) gid " +
  6048. " ,pdata.Procedureid " +
  6049. " ,pdata.Procedurename " +
  6050. " ,pdata.Userid " +
  6051. " ,pdata.Usercode " +
  6052. " ,pdata.Kilnid " +
  6053. " ,pdata.Kilncode " +
  6054. " ,pdata.goodstypename " +
  6055. " ,pdata.Goodsid " +
  6056. " ,pdata.Goodscode " +
  6057. " ,COUNT(pdata.Barcode) AS OutKilnCount " +
  6058. " FROM (SELECT DISTINCT " +
  6059. //" decode(grouping(TP_PM_ProductionData.Procedureid),1,'--',TP_PM_ProductionData.Procedureid) Procedureid, " +
  6060. //" decode(grouping(TP_PM_ProductionData.Procedurename),1,'合计', TP_PM_ProductionData.Procedurename) Procedurename, " +
  6061. //" decode(grouping(TP_PM_ProductionData.Userid),1,'--', TP_PM_ProductionData.Userid) Userid, " +
  6062. //" decode(grouping(TP_PM_ProductionData.Usercode),1,'--', TP_PM_ProductionData.Usercode) Usercode, " +
  6063. //" decode(grouping(temp.Kilncode),1,'--', temp.KilnID) Kilnid, " +
  6064. //" decode(grouping(temp.Kilncode),1,'--', temp.Kilncode) Kilncode, " +
  6065. //" decode(grouping(tp_mst_goodstype.goodstypename),1,'--', tp_mst_goodstype.goodstypename) goodstypename, " +
  6066. //" decode(grouping(TP_PM_ProductionData.Goodsid),1,'--', TP_PM_ProductionData.Goodsid) Goodsid, " +
  6067. //" decode(grouping(TP_PM_ProductionData.Goodscode),1,'--', TP_PM_ProductionData.Goodscode) Goodscode, " +
  6068. "TP_PM_ProductionData.Procedureid,pcp.Procedurename, " +
  6069. //"TP_PM_ProductionData.Userid,TP_PM_ProductionData.Usercode, " +
  6070. (se.DisPUserCode ? " TP_PM_ProductionData.userid, TP_PM_ProductionData.usercode, \n" : " null userid, null usercode, \n") +
  6071. "temp.Kilnid,temp.Kilncode,tp_mst_goodstype.goodstypename, " +
  6072. "TP_PM_ProductionData.Goodsid,TP_PM_ProductionData.Goodscode, TP_PM_ProductionData.barcode " +
  6073. " from TP_PM_ProductionData " +
  6074. " inner join tp_mst_goods on tp_mst_goods.goodsid=TP_PM_ProductionData.Goodsid " +
  6075. " inner join tp_mst_goodstype on tp_mst_goodstype.goodstypeid=tp_mst_goods.goodstypeid " +
  6076. " inner join TP_MST_RptTProcedure on TP_MST_RptTProcedure.Procedureid=TP_PM_ProductionData.Procedureid " +
  6077. " inner join TP_MST_RptProcedure on TP_MST_RptProcedure.Rptprocedureid=TP_MST_RptTProcedure.Rptprocedureid " +
  6078. " inner join tp_pc_procedure pcp on pcp.procedureid=TP_PM_ProductionData.Procedureid " +
  6079. " inner join " +
  6080. " ( " +
  6081. " 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 " +
  6082. " from TP_PM_ProductionData " +
  6083. " inner join TP_MST_RptSProcedure on TP_MST_RptSProcedure.Procedureid=TP_PM_ProductionData.Procedureid ";
  6084. if (se.DTimeStart.HasValue || se.DTimeEnd.HasValue)
  6085. {
  6086. selSql += " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=TP_PM_ProductionData.groutingdailydetailid ";
  6087. }
  6088. selSql +=
  6089. " where TP_PM_ProductionData.Accountid=:AccountID " +
  6090. " and TP_PM_ProductionData.Valueflag='1' " +
  6091. // 数据重复 modify by chenxy begin
  6092. // " and TP_MST_RptSProcedure.Rptprocedureid=:rptProcedureId " +
  6093. // 数据重复 modify by chenxy end
  6094. " and TP_MST_RptSProcedure.Procedureid=:rptSprocedureId ";
  6095. //if (se.CreateTimeStart.HasValue)
  6096. //{
  6097. // selSql = selSql + " AND TP_PM_ProductionData.CreateTime >= :CreateTimeStart ";
  6098. // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6099. //}
  6100. //if (se.CreateTimeEnd.HasValue)
  6101. //{
  6102. // selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :CreateTimeEnd ";
  6103. // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6104. //}
  6105. if (se.OutTimeStart.HasValue)
  6106. {
  6107. selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:OutTimeStart ";
  6108. parameters.Add(new OracleParameter(":OutTimeStart", OracleDbType.Date, se.OutTimeStart.Value, ParameterDirection.Input));
  6109. }
  6110. if (se.OutTimeEnd.HasValue)
  6111. {
  6112. selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :OutTimeEnd ";
  6113. parameters.Add(new OracleParameter(":OutTimeEnd", OracleDbType.Date, se.OutTimeEnd.Value, ParameterDirection.Input));
  6114. }
  6115. if (se.GTimeStart.HasValue)
  6116. {
  6117. selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE >=:GTimeStart ";
  6118. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  6119. }
  6120. if (se.GTimeEnd.HasValue)
  6121. {
  6122. selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE <= :GTimeEnd ";
  6123. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  6124. }
  6125. if (se.DTimeStart.HasValue)
  6126. {
  6127. selSql = selSql + " AND gdd.DELIVERTIME >=:DTimeStart ";
  6128. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
  6129. }
  6130. if (se.DTimeEnd.HasValue)
  6131. {
  6132. selSql = selSql + " AND gdd.DELIVERTIME <= :DTimeEnd ";
  6133. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
  6134. }
  6135. if (se.Specialrepairflag)
  6136. {
  6137. selSql = selSql +
  6138. " ) temp " +
  6139. " on TP_PM_ProductionData.Barcode=temp.barcode " +
  6140. " " +
  6141. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
  6142. " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
  6143. " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
  6144. " FROM TP_PM_ProductionData pp\n" +
  6145. " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
  6146. " AND pp.createtime < temp.createtime\n" +
  6147. " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
  6148. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
  6149. " where " +
  6150. // 公坯、干补不算交坯工序的质量。
  6151. // " 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" +
  6152. // modify wangx 2015-12-3
  6153. " ((TP_PM_ProductionData.modeltype <> 5) or (TP_PM_ProductionData.modeltype = 5 and TP_PM_ProductionData.SpecialRepairFlag = '0')) \n" +
  6154. " and TP_PM_ProductionData.Valueflag='1' " +
  6155. " and TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId ";
  6156. parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  6157. }
  6158. else
  6159. {
  6160. selSql = selSql +
  6161. " ) temp " +
  6162. " on TP_PM_ProductionData.Barcode=temp.barcode " +
  6163. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
  6164. " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
  6165. " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
  6166. " FROM TP_PM_ProductionData pp\n" +
  6167. " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
  6168. " AND pp.createtime < temp.createtime\n" +
  6169. " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
  6170. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
  6171. " where TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId " +
  6172. " and TP_PM_ProductionData.Valueflag='1' ";
  6173. parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  6174. }
  6175. if (se.CreateTimeStart.HasValue)
  6176. {
  6177. selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:CreateTimeStart ";
  6178. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6179. }
  6180. if (se.CreateTimeEnd.HasValue)
  6181. {
  6182. selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :CreateTimeEnd ";
  6183. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6184. }
  6185. if (!string.IsNullOrEmpty(se.GoodsIDS))
  6186. {
  6187. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  6188. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  6189. }
  6190. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  6191. {
  6192. // selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1 ";
  6193. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1 ";
  6194. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  6195. }
  6196. if (se.ProductionLineID.HasValue)
  6197. {
  6198. selSql = selSql + " AND instr(','||:productionLineId||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  6199. parameters.Add(new OracleParameter(":productionLineId", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  6200. }
  6201. //else
  6202. //{
  6203. // selSql = selSql + " AND TP_PM_ProductionData.ProductionLineId in(Select PurviewID from TP_MST_UserPurview where PurviewType= 7 and UserID = :UserID) ";
  6204. //}
  6205. 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))";
  6206. 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))";
  6207. parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  6208. if (!string.IsNullOrEmpty(se.RptTProcedureIDS))
  6209. {
  6210. selSql = selSql + " AND instr(','||:rptTprocedureId||',',','||TP_MST_RptTProcedure.ProcedureId||',')>0 ";
  6211. parameters.Add(new OracleParameter(":rptTprocedureId", OracleDbType.NVarchar2, se.RptTProcedureIDS, ParameterDirection.Input));
  6212. }
  6213. if (!string.IsNullOrEmpty(se.UserIDS))
  6214. {
  6215. selSql = selSql + " AND instr(','||:userIDS||',',','||TP_PM_ProductionData.Userid||',')>0 ";
  6216. parameters.Add(new OracleParameter(":userIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6217. }
  6218. if (se.KilnID.HasValue)
  6219. {
  6220. selSql = selSql + " AND temp.KilnID=:KilnID ";
  6221. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6222. }
  6223. if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
  6224. {
  6225. selSql = selSql + " AND instr(TP_PM_ProductionData.GroutingUserCode, :GroutingUserCode) > 0";
  6226. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  6227. }
  6228. selSql = selSql + " order by pcp.displayno, TP_PM_ProductionData.Usercode, temp.Kilncode,tp_mst_goodstype.goodstypename,TP_PM_ProductionData.Goodscode ) pdata" +
  6229. " 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),()) " +
  6230. ") pdata"
  6231. ;
  6232. return selSql;
  6233. }
  6234. /// <summary>
  6235. /// 取得RPT030103_1画面(出窑数量汇总表)的明细信息查询数据
  6236. /// </summary>
  6237. /// <param name="user">登录用户信息</param>
  6238. /// <param name="se">查询条件</param>
  6239. /// <returns>查询结果</returns>
  6240. public static ServiceResultEntity GetRPT030103IData(SUserInfo user, RPT030103_SE se)
  6241. {
  6242. IDBConnection conn = null;
  6243. try
  6244. {
  6245. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6246. List<OracleParameter> parameters = new List<OracleParameter>();
  6247. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030103ISQL(user, se, ref parameters));
  6248. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  6249. ServiceResultEntity sre = new ServiceResultEntity();
  6250. if (data == null || data.Rows.Count == 0)
  6251. {
  6252. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6253. return sre;
  6254. }
  6255. sre.Data = new DataSet();
  6256. sre.Data.Tables.Add(data);
  6257. return sre;
  6258. }
  6259. catch (Exception ex)
  6260. {
  6261. throw ex;
  6262. }
  6263. finally
  6264. {
  6265. if (conn != null &&
  6266. conn.ConnState == ConnectionState.Open)
  6267. {
  6268. conn.Close();
  6269. }
  6270. }
  6271. }
  6272. /// <summary>
  6273. /// 获取RPT030103_1画面(出窑数量汇总表)的明细信息查询sql
  6274. /// </summary>
  6275. /// <returns>sql</returns>
  6276. private static string GetRPT030103ISQL(SUserInfo user, RPT030103_SE se, ref List<OracleParameter> parameters)
  6277. {
  6278. string selSql = "";
  6279. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6280. parameters.Add(new OracleParameter(":rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  6281. selSql = selSql +
  6282. "select distinct " +
  6283. "TP_PM_ProductionData.Barcode, " +
  6284. //"TP_PM_ProductionData.UserCode, " +
  6285. (se.DisPUserCode ? " TP_PM_ProductionData.userid, TP_PM_ProductionData.usercode, cu.usercode Cusercode, \n" : " null userid, null usercode, null Cusercode, \n") +
  6286. "pcp.ProcedureName, " +
  6287. "tp_mst_goodstype.goodstypename, " +
  6288. "TP_PM_ProductionData.Goodscode, " +
  6289. "TP_PM_ProductionData.GroutingUserCode, " +
  6290. "TP_PM_ProductionData.GroutingLineCode, " +
  6291. "TP_PM_ProductionData.GroutingMouldCode, " +
  6292. // 多次干补 重复条码
  6293. //"TP_PM_ProductionData.Createtime OverDate, " +
  6294. "temp.Kilnid, " +
  6295. "temp.Kilncode, " +
  6296. "temp.Kilncarcode, " +
  6297. "temp.Createtime, " +
  6298. "temp.DELIVERTIME DDate, " +
  6299. "temp.GROUTINGDATE GDate, " +
  6300. "replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName " +
  6301. "from TP_PM_ProductionData " +
  6302. "inner join tp_mst_goods on tp_mst_goods.goodsid=TP_PM_ProductionData.Goodsid " +
  6303. "inner join tp_mst_goodstype on tp_mst_goodstype.goodstypeid=tp_mst_goods.goodstypeid " +
  6304. "inner join TP_MST_RptTProcedure on TP_MST_RptTProcedure.Procedureid=TP_PM_ProductionData.Procedureid " +
  6305. "inner join TP_MST_RptProcedure on TP_MST_RptProcedure.Rptprocedureid=TP_MST_RptTProcedure.Rptprocedureid " +
  6306. " inner join tp_pc_procedure pcp on pcp.procedureid=TP_PM_ProductionData.Procedureid " +
  6307. "left join TP_MST_logo on TP_PM_ProductionData.logoid=TP_MST_logo.logoid " +
  6308. "left join TP_MST_User cu on TP_PM_ProductionData.createuserid=cu.userid " +
  6309. "inner join " +
  6310. "( " +
  6311. " select " +
  6312. " TP_PM_ProductionData.Barcode, " +
  6313. " TP_PM_ProductionData.Kilncode, " +
  6314. " TP_PM_ProductionData.Kilncarcode, " +
  6315. " TP_PM_ProductionData.Createtime, " +
  6316. " TP_PM_ProductionData.KilnID " +
  6317. " ,gdd.DELIVERTIME " +
  6318. " ,TP_PM_ProductionData.GROUTINGDATE " +
  6319. " ,TP_PM_ProductionData.KilnCarID " +
  6320. " from TP_PM_ProductionData " +
  6321. " inner join TP_MST_RptSProcedure on TP_MST_RptSProcedure.Procedureid=TP_PM_ProductionData.Procedureid " +
  6322. //if (se.DTimeStart.HasValue || se.DTimeEnd.HasValue)
  6323. //{
  6324. // selSql += " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=TP_PM_ProductionData.groutingdailydetailid ";
  6325. //}
  6326. " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=TP_PM_ProductionData.groutingdailydetailid " +
  6327. // selSql +=
  6328. " where TP_PM_ProductionData.Accountid=:AccountID " +
  6329. " and TP_PM_ProductionData.Valueflag='1' " +
  6330. // 数据重复 modify by chenxy begin
  6331. " and TP_MST_RptSProcedure.Rptprocedureid=:rptProcedureId " +
  6332. // 数据重复 modify by chenxy end
  6333. " and TP_MST_RptSProcedure.Procedureid=:rptSprocedureId ";
  6334. if (se.OutTimeStart.HasValue)
  6335. {
  6336. selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:OutTimeStart ";
  6337. parameters.Add(new OracleParameter(":OutTimeStart", OracleDbType.Date, se.OutTimeStart.Value, ParameterDirection.Input));
  6338. }
  6339. if (se.OutTimeEnd.HasValue)
  6340. {
  6341. selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :OutTimeEnd ";
  6342. parameters.Add(new OracleParameter(":OutTimeEnd", OracleDbType.Date, se.OutTimeEnd.Value, ParameterDirection.Input));
  6343. }
  6344. if (se.GTimeStart.HasValue)
  6345. {
  6346. selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE >=:GTimeStart ";
  6347. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  6348. }
  6349. if (se.GTimeEnd.HasValue)
  6350. {
  6351. selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE <= :GTimeEnd ";
  6352. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  6353. }
  6354. if (se.DTimeStart.HasValue)
  6355. {
  6356. selSql = selSql + " AND gdd.DELIVERTIME >=:DTimeStart ";
  6357. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
  6358. }
  6359. if (se.DTimeEnd.HasValue)
  6360. {
  6361. selSql = selSql + " AND gdd.DELIVERTIME <= :DTimeEnd ";
  6362. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
  6363. }
  6364. if (se.Specialrepairflag)
  6365. {
  6366. selSql = selSql +
  6367. ") temp " +
  6368. "on TP_PM_ProductionData.Barcode=temp.barcode " +
  6369. " " +
  6370. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
  6371. " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
  6372. " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
  6373. " FROM TP_PM_ProductionData pp\n" +
  6374. " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
  6375. " AND pp.createtime < temp.createtime\n" +
  6376. " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
  6377. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
  6378. "where " + // 公坯、干补不算交坯工序的质量。
  6379. //" 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" +
  6380. // modify wangx 2015-12-3
  6381. " ((TP_PM_ProductionData.modeltype <> 5) or (TP_PM_ProductionData.modeltype = 5 and TP_PM_ProductionData.SpecialRepairFlag = '0')) \n" +
  6382. " and TP_PM_ProductionData.Valueflag='1' " +
  6383. " and TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId ";
  6384. parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  6385. }
  6386. else
  6387. {
  6388. selSql = selSql +
  6389. ") temp " +
  6390. "on TP_PM_ProductionData.Barcode=temp.barcode " +
  6391. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
  6392. " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
  6393. " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
  6394. " FROM TP_PM_ProductionData pp\n" +
  6395. " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
  6396. " AND pp.createtime < temp.createtime\n" +
  6397. " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
  6398. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
  6399. " where TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId " +
  6400. " and TP_PM_ProductionData.Valueflag='1' ";
  6401. parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  6402. }
  6403. if (se.CreateTimeStart.HasValue)
  6404. {
  6405. selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:CreateTimeStart ";
  6406. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6407. }
  6408. if (se.CreateTimeEnd.HasValue)
  6409. {
  6410. selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :CreateTimeEnd ";
  6411. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6412. }
  6413. if (!string.IsNullOrEmpty(se.GoodsIDS))
  6414. {
  6415. selSql = selSql + " AND instr(',' || :GoodsIDS ||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  6416. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  6417. }
  6418. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  6419. {
  6420. //selSql = selSql + " AND instr(',' || :GoodsTypeIDS ||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1 ";
  6421. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1 ";
  6422. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  6423. }
  6424. if (se.ProductionLineID.HasValue)
  6425. {
  6426. selSql = selSql + " AND instr(',' || :productionLineId ||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  6427. parameters.Add(new OracleParameter(":productionLineId", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  6428. }
  6429. if (!string.IsNullOrEmpty(se.RptTProcedureIDS))
  6430. {
  6431. selSql = selSql + " AND instr(',' || :rptTprocedureIDS ||',',','||TP_MST_RptTProcedure.ProcedureId||',')>0 ";
  6432. parameters.Add(new OracleParameter(":rptTprocedureIDS", OracleDbType.NVarchar2, se.RptTProcedureIDS, ParameterDirection.Input));
  6433. }
  6434. if (!string.IsNullOrEmpty(se.UserIDS))
  6435. {
  6436. selSql = selSql + " AND instr(',' || :UserIDS ||',',','||TP_PM_ProductionData.Userid||',')>0 ";
  6437. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6438. }
  6439. if (se.KilnID.HasValue)
  6440. {
  6441. selSql = selSql + " AND temp.KilnID=:KilnID ";
  6442. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6443. }
  6444. if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
  6445. {
  6446. selSql = selSql + " AND instr(TP_PM_ProductionData.GroutingUserCode, :GroutingUserCode) > 0";
  6447. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  6448. }
  6449. selSql = selSql + " order by pcp.Procedurename,temp.Kilncode,temp.Kilncarcode, " +
  6450. (se.DisPUserCode ? " TP_PM_ProductionData.usercode, \n" : "") +
  6451. " TP_PM_ProductionData.Goodscode,TP_PM_ProductionData.Barcode ";
  6452. return selSql;
  6453. }
  6454. /// <summary>
  6455. /// 取得RPT030104_1画面(窑车产量汇总表)的窑炉汇总信息查询数据
  6456. /// </summary>
  6457. /// <param name="user">登录用户信息</param>
  6458. /// <param name="se">查询条件</param>
  6459. /// <returns>查询结果</returns>
  6460. public static ServiceResultEntity GetRPT030104SData(SUserInfo user, RPT030104_SE se)
  6461. {
  6462. IDBConnection conn = null;
  6463. try
  6464. {
  6465. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6466. List<OracleParameter> parameters = new List<OracleParameter>();
  6467. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030104SSQL(user, se, ref parameters));
  6468. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  6469. ServiceResultEntity sre = new ServiceResultEntity();
  6470. if (data == null || data.Rows.Count == 0)
  6471. {
  6472. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6473. return sre;
  6474. }
  6475. sre.Data = new DataSet();
  6476. sre.Data.Tables.Add(data);
  6477. return sre;
  6478. }
  6479. catch (Exception ex)
  6480. {
  6481. throw ex;
  6482. }
  6483. finally
  6484. {
  6485. if (conn != null &&
  6486. conn.ConnState == ConnectionState.Open)
  6487. {
  6488. conn.Close();
  6489. }
  6490. }
  6491. }
  6492. /// <summary>
  6493. /// 获取RPT030104_1画面(窑车产量汇总表)的窑炉汇总查询sql
  6494. /// </summary>
  6495. /// <returns>sql</returns>
  6496. private static string GetRPT030104SSQL(SUserInfo user, RPT030104_SE se, ref List<OracleParameter> parameters)
  6497. {
  6498. string selSql = "";
  6499. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6500. parameters.Add(new OracleParameter(":ProcedureModelTypeID", OracleDbType.Int32, se.ProcedureModelTypeID, ParameterDirection.Input));
  6501. selSql = "select " +
  6502. "decode(Createtime,'小计',decode(Proceduremodeltypename,'总计','总计','--'),Proceduremodeltypename) Proceduremodeltypename, " +
  6503. "decode(usercode,'合计',decode(Kilncode,'--','--','合计'),decode(createtime,'小计','--',Kilncode)) Kilncode, " +
  6504. "decode(Createtime,'小计',decode(usercode,'合计','--','小计'),Usercode) Usercode, " +
  6505. "decode(Kilncarcode,'--','--',Createtime) Createtime, " +
  6506. "Kilncarcode, " +
  6507. "Remarks, " +
  6508. "KilnCarCount " +
  6509. " from " +
  6510. " ( " +
  6511. " select " +
  6512. " decode(grouping(TP_SYS_ProcedureModelType.Proceduremodeltypename),1,'总计',TP_SYS_ProcedureModelType.Proceduremodeltypename) Proceduremodeltypename, " +
  6513. " decode(grouping(TP_MST_Kiln.Kilncode),1,'--',TP_MST_Kiln.Kilncode) Kilncode, " +
  6514. " decode(grouping(TP_PM_KilnCarData.Usercode),1,'合计',TP_PM_KilnCarData.Usercode) Usercode, " +
  6515. " decode(grouping(TP_MST_KilnCar.Kilncarcode),1,'--',TP_MST_KilnCar.Kilncarcode) Kilncarcode, " +
  6516. " decode(grouping(TP_PM_KilnCarData.Remarks),1,'--',TP_PM_KilnCarData.Remarks) Remarks, " +
  6517. " decode(grouping(TP_PM_KilnCarData.Createtime),1,'小计',TP_PM_KilnCarData.Createtime) Createtime, " +
  6518. " count(TP_PM_KilnCarData.Kilncarid) as KilnCarCount " +
  6519. " from " +
  6520. " ( " +
  6521. " select " +
  6522. " to_char(TP_PM_KilnCarData.Createtime,'yyyy-mm-dd hh24:mi') Createtime, " +
  6523. " TP_PM_KilnCarData.Modeltype, " +
  6524. " TP_PM_KilnCarData.Kilncarid, " +
  6525. " TP_PM_KilnCarData.Kilnid, " +
  6526. " TP_PM_KilnCarData.Userid, " +
  6527. " TP_PM_KilnCarData.Remarks, " +
  6528. " TP_PM_KilnCarData.Accountid, " +
  6529. " TP_PM_KilnCarData.Usercode " +
  6530. " from TP_PM_KilnCarData " +
  6531. " left join TP_MST_KilnCar kc on kc.kilncarid = TP_PM_KilnCarData.Kilncarid " +
  6532. " where TP_PM_KilnCarData.Accountid=:AccountID " +
  6533. " and TP_PM_KilnCarData.Valueflag=1 " +
  6534. " and TP_PM_KilnCarData.Modeltype=:ProcedureModelTypeID ";
  6535. if (se.KilnID.HasValue)
  6536. {
  6537. selSql = selSql + " AND TP_PM_KilnCarData.KilnID=:KilnID ";
  6538. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6539. }
  6540. //if (se.KilnCarID.HasValue)
  6541. //{
  6542. // selSql = selSql + " AND TP_PM_KilnCarData.KilnCarID=:KilnCarID";
  6543. // parameters.Add(new OracleParameter(":KilnCarID", OracleDbType.Int32, se.KilnCarID, ParameterDirection.Input));
  6544. //}
  6545. if (!string.IsNullOrEmpty(se.KilnCarCode))
  6546. {
  6547. selSql = selSql + " AND instr(kc.KilnCarCode, :KilnCarCode ) > 0";
  6548. parameters.Add(new OracleParameter(":KilnCarCode", OracleDbType.NVarchar2, se.KilnCarCode, ParameterDirection.Input));
  6549. }
  6550. if (se.KilnCarNumBegin.HasValue && se.KilnCarNumEnd.HasValue && se.KilnCarNumBegin.Value > se.KilnCarNumEnd.Value)
  6551. {
  6552. selSql = selSql + " AND (kc.KilnCarNum >= :KilnCarNumBegin or kc.KilnCarNum <= :KilnCarNumEnd)";
  6553. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6554. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6555. }
  6556. else
  6557. {
  6558. if (se.KilnCarNumBegin.HasValue)
  6559. {
  6560. selSql = selSql + " AND kc.KilnCarNum >= :KilnCarNumBegin ";
  6561. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6562. }
  6563. if (se.KilnCarNumEnd.HasValue)
  6564. {
  6565. selSql = selSql + " AND kc.KilnCarNum <= :KilnCarNumEnd ";
  6566. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6567. }
  6568. }
  6569. if (se.CreateTimeStart.HasValue)
  6570. {
  6571. selSql = selSql + " AND TP_PM_KilnCarData.CreateTime>=:CreateTimeStart ";
  6572. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6573. }
  6574. if (se.CreateTimeEnd.HasValue)
  6575. {
  6576. selSql = selSql + " AND TP_PM_KilnCarData.CreateTime<= :CreateTimeEnd";
  6577. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6578. }
  6579. selSql = selSql +
  6580. " ) TP_PM_KilnCarData " +
  6581. "inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.Proceduremodeltypeid=TP_PM_KilnCarData.Modeltype " +
  6582. "inner join TP_MST_KilnCar on TP_MST_KilnCar.Kilncarid=TP_PM_KilnCarData.Kilncarid " +
  6583. "inner join TP_MST_Kiln on TP_MST_Kiln.Kilnid=TP_PM_KilnCarData.Kilnid " +
  6584. "where 1=1";
  6585. if (!string.IsNullOrEmpty(se.UserIDS))
  6586. {
  6587. selSql = selSql + " AND instr(','||:UserIDS||',',','||TP_PM_KilnCarData.UserID||',')>0";
  6588. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6589. }
  6590. selSql = selSql + "group by rollup( " +
  6591. " TP_SYS_ProcedureModelType.Proceduremodeltypename, " +
  6592. " TP_MST_Kiln.Kilncode, " +
  6593. " TP_PM_KilnCarData.Usercode, " +
  6594. " TP_PM_KilnCarData.Createtime, " +
  6595. " TP_PM_KilnCarData.Remarks, " +
  6596. " TP_MST_KilnCar.Kilncarcode " +
  6597. " ) " +
  6598. " ) temp " +
  6599. " where (Kilncarcode !='--' ) " +
  6600. " or " +
  6601. " (Remarks='--' and Usercode='合计' and kilncode!='--') " +
  6602. " or (Remarks='--' and Proceduremodeltypename='总计') " +
  6603. " or (Remarks='--' and createtime='小计' and kilncode!='--')";
  6604. return selSql;
  6605. }
  6606. /// <summary>
  6607. /// 取得RPT030104_1画面(窑车产量汇总表)的窑车产量汇总信息查询数据
  6608. /// </summary>
  6609. /// <param name="user">登录用户信息</param>
  6610. /// <param name="se">查询条件</param>
  6611. /// <returns>查询结果</returns>
  6612. public static ServiceResultEntity GetRPT030104IData(SUserInfo user, RPT030104_SE se)
  6613. {
  6614. IDBConnection conn = null;
  6615. try
  6616. {
  6617. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6618. List<OracleParameter> parameters = new List<OracleParameter>();
  6619. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030104ISQL(user, se, ref parameters));
  6620. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  6621. ServiceResultEntity sre = new ServiceResultEntity();
  6622. if (data == null || data.Rows.Count == 0)
  6623. {
  6624. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6625. return sre;
  6626. }
  6627. sre.Data = new DataSet();
  6628. sre.Data.Tables.Add(data);
  6629. return sre;
  6630. }
  6631. catch (Exception ex)
  6632. {
  6633. throw ex;
  6634. }
  6635. finally
  6636. {
  6637. if (conn != null &&
  6638. conn.ConnState == ConnectionState.Open)
  6639. {
  6640. conn.Close();
  6641. }
  6642. }
  6643. }
  6644. /// <summary>
  6645. /// 获取查询sql
  6646. /// </summary>
  6647. /// <returns>sql</returns>
  6648. private static string GetRPT030104ISQL(SUserInfo user, RPT030104_SE se, ref List<OracleParameter> parameters)
  6649. {
  6650. string selSql = "";
  6651. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6652. parameters.Add(new OracleParameter(":ProcedureModelTypeID", OracleDbType.Int32, se.ProcedureModelTypeID, ParameterDirection.Input));
  6653. selSql = selSql +
  6654. "SELECT " +
  6655. "decode(createtime,'小计',decode(proceduremodeltypename,'总计','总计','--'),proceduremodeltypename) proceduremodeltypename, " +
  6656. "decode(createtime,'小计','--',kilncode) kilncode, " +
  6657. "decode(kilncarcode,'合计',decode(usercode,'--','--','合计'),decode(createtime,'小计','--',usercode)) usercode, " +
  6658. "decode(createtime,'小计',decode(kilncarcode,'合计','--','小计'),kilncarcode) kilncarcode, " +
  6659. "decode(goodscode,'--','--',createtime) createtime, " +
  6660. "GOODSTYPENAME, " +
  6661. "Goodscode, " +
  6662. "GOODSSPECIFICATION, " +
  6663. "GoodsCount " +
  6664. "from " +
  6665. "( " +
  6666. " SELECT " +
  6667. " decode(grouping(TP_SYS_ProcedureModelType.Proceduremodeltypename),1,'总计',TP_SYS_ProcedureModelType.Proceduremodeltypename) Proceduremodeltypename, " +
  6668. " decode(grouping(TP_PM_ProductionData.Kilncode),1,'--',TP_PM_ProductionData.Kilncode) Kilncode, " +
  6669. " decode(grouping(TP_PM_ProductionData.Usercode),1,'--',TP_PM_ProductionData.Usercode) Usercode, " +
  6670. " decode(grouping(TP_MST_KilnCar.Kilncarcode),1,'合计',TP_MST_KilnCar.Kilncarcode) Kilncarcode, " +
  6671. " decode(grouping(TP_PM_ProductionData.CreateTime),1,'小计',TP_PM_ProductionData.CreateTime) CreateTime, " +
  6672. " decode(grouping(TP_MST_Goods.Goodscode),1,'--',TP_MST_Goods.Goodscode) Goodscode, " +
  6673. " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  6674. " decode(grouping(TP_MST_GOODSTYPE.GOODSTYPENAME),1,'--',TP_MST_GOODSTYPE.GOODSTYPENAME) GOODSTYPENAME, " +
  6675. " count(TP_MST_Goods.Goodscode) as GoodsCount " +
  6676. " from " +
  6677. " ( " +
  6678. " SELECT TP_PM_ProductionData.Modeltype, " +
  6679. " TP_PM_ProductionData.Goodsid, " +
  6680. " TP_PM_ProductionData.KilnCarID, " +
  6681. " TP_PM_ProductionData.Kilncode, " +
  6682. //" TP_PM_ProductionData.Usercode, " +
  6683. " kcd.Usercode, " +
  6684. " to_char(kcd.CreateTime,'yyyy-mm-dd hh24:mi') CreateTime " +
  6685. " from TP_PM_ProductionData " +
  6686. " left join TP_PM_KilnCarData kcd on kcd.KilnCarBatchNo = TP_PM_ProductionData.KilnCarBatchNo and kcd.ProcedureID = TP_PM_ProductionData.ProcedureID " +
  6687. " where " +
  6688. " TP_PM_ProductionData.Accountid=:AccountID " +
  6689. " and TP_PM_ProductionData.Valueflag=1 " +
  6690. " and TP_PM_ProductionData.Modeltype= :ProcedureModelTypeID ";
  6691. if (se.KilnID.HasValue)
  6692. {
  6693. selSql = selSql + " AND TP_PM_ProductionData.KilnID=:KilnID ";
  6694. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6695. }
  6696. //if (se.KilnCarID.HasValue)
  6697. //{
  6698. // selSql = selSql + " AND TP_PM_ProductionData.KilnCarID=:KilnCarID";
  6699. // parameters.Add(new OracleParameter(":KilnCarID", OracleDbType.Int32, se.KilnCarID, ParameterDirection.Input));
  6700. //}
  6701. if (!string.IsNullOrEmpty(se.GoodsIDS))
  6702. {
  6703. selSql = selSql + " AND instr(','||:goodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  6704. parameters.Add(new OracleParameter(":goodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  6705. }
  6706. if (!string.IsNullOrEmpty(se.UserIDS))
  6707. {
  6708. //selSql = selSql + " AND instr(','||:UserIDS||',',','||TP_PM_ProductionData.UserID||',')>0 ";
  6709. selSql = selSql + " AND instr(','||:UserIDS||',',','||kcd.UserID||',')>0 ";
  6710. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6711. }
  6712. if (se.CreateTimeStart.HasValue)
  6713. {
  6714. //selSql = selSql + " AND TP_PM_ProductionData.CreateTime>= :CreateTimeStart ";
  6715. selSql = selSql + " AND kcd.CreateTime>= :CreateTimeStart ";
  6716. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6717. }
  6718. if (se.CreateTimeEnd.HasValue)
  6719. {
  6720. //selSql = selSql + " AND TP_PM_ProductionData.CreateTime<= :CreateTimeEnd ";
  6721. selSql = selSql + " AND kcd.CreateTime<= :CreateTimeEnd ";
  6722. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6723. }
  6724. selSql = selSql +
  6725. " ) TP_PM_ProductionData " +
  6726. " inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.Proceduremodeltypeid=TP_PM_ProductionData.Modeltype " +
  6727. " inner join TP_MST_Goods on TP_MST_Goods.Goodsid=TP_PM_ProductionData.Goodsid " +
  6728. " inner join TP_MST_GOODSTYPE on TP_MST_GOODSTYPE.GOODSTYPEID=TP_MST_Goods.Goodstypeid " +
  6729. " inner join TP_MST_KilnCar on TP_MST_KilnCar.Kilncarid=TP_PM_ProductionData.KilnCarID " +
  6730. " where 1=1 ";
  6731. if (!string.IsNullOrEmpty(se.KilnCarCode))
  6732. {
  6733. selSql = selSql + " AND instr(TP_MST_KilnCar.KilnCarCode, :KilnCarCode ) > 0";
  6734. parameters.Add(new OracleParameter(":KilnCarCode", OracleDbType.NVarchar2, se.KilnCarCode, ParameterDirection.Input));
  6735. }
  6736. if (se.KilnCarNumBegin.HasValue && se.KilnCarNumEnd.HasValue && se.KilnCarNumBegin.Value > se.KilnCarNumEnd.Value)
  6737. {
  6738. selSql = selSql + " AND (TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin or TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd)";
  6739. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6740. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6741. }
  6742. else
  6743. {
  6744. if (se.KilnCarNumBegin.HasValue)
  6745. {
  6746. selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin ";
  6747. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6748. }
  6749. if (se.KilnCarNumEnd.HasValue)
  6750. {
  6751. selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd ";
  6752. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6753. }
  6754. }
  6755. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  6756. {
  6757. //selSql = selSql + " AND instr(','||:goodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1";
  6758. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:goodsTypeIDS)=1";
  6759. parameters.Add(new OracleParameter(":goodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  6760. }
  6761. selSql = selSql +
  6762. " group by rollup( " +
  6763. " TP_SYS_ProcedureModelType.Proceduremodeltypename, " +
  6764. " TP_PM_ProductionData.Kilncode, " +
  6765. " TP_PM_ProductionData.Usercode, " +
  6766. " TP_MST_KilnCar.Kilncarcode, " +
  6767. " TP_PM_ProductionData.CreateTime, " +
  6768. " TP_MST_GOODSTYPE.GOODSTYPENAME, " +
  6769. " TP_MST_Goods.GOODSSPECIFICATION, " +
  6770. " TP_MST_Goods.Goodscode " +
  6771. " ) " +
  6772. ") temp " +
  6773. "where 1=1 and " +
  6774. " (Goodscode !='--' ) or " +
  6775. " (Goodscode='--' and Usercode='合计' and kilncode!='--') or " +
  6776. " (Goodscode='--' and Proceduremodeltypename='总计') or " +
  6777. " (Goodscode='--' and createtime='小计' and usercode!='--')";
  6778. return selSql;
  6779. }
  6780. /// <summary>
  6781. /// 取得RPT030104_1画面(窑车产量汇总表)的窑车产量明细信息查询数据
  6782. /// </summary>
  6783. /// <param name="user">登录用户信息</param>
  6784. /// <param name="se">查询条件</param>
  6785. /// <returns>查询结果</returns>
  6786. public static ServiceResultEntity GetRPT030104UData(SUserInfo user, RPT030104_SE se)
  6787. {
  6788. IDBConnection conn = null;
  6789. try
  6790. {
  6791. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6792. List<OracleParameter> parameters = new List<OracleParameter>();
  6793. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030104USQL(user, se, ref parameters));
  6794. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  6795. ServiceResultEntity sre = new ServiceResultEntity();
  6796. if (data == null || data.Rows.Count == 0)
  6797. {
  6798. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6799. return sre;
  6800. }
  6801. sre.Data = new DataSet();
  6802. sre.Data.Tables.Add(data);
  6803. return sre;
  6804. }
  6805. catch (Exception ex)
  6806. {
  6807. throw ex;
  6808. }
  6809. finally
  6810. {
  6811. if (conn != null &&
  6812. conn.ConnState == ConnectionState.Open)
  6813. {
  6814. conn.Close();
  6815. }
  6816. }
  6817. }
  6818. /// <summary>
  6819. /// 获取RPT030104_1画面(窑车产量汇总表)的窑车产量明细查询sql
  6820. /// </summary>
  6821. /// <returns>sql</returns>
  6822. private static string GetRPT030104USQL(SUserInfo user, RPT030104_SE se, ref List<OracleParameter> parameters)
  6823. {
  6824. string selSql = "";
  6825. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6826. parameters.Add(new OracleParameter(":ProcedureModelTypeID", OracleDbType.Int32, se.ProcedureModelTypeID, ParameterDirection.Input));
  6827. selSql = selSql +
  6828. "select " +
  6829. "decode(createtime,'小计',decode(proceduremodeltypename,'总计','总计','--'),proceduremodeltypename) proceduremodeltypename, " +
  6830. "decode(createtime,'小计','--',kilncode) kilncode, " +
  6831. "decode(kilncarcode,'合计',decode(usercode,'--','--','合计'),decode(createtime,'小计','--',usercode)) usercode, " +
  6832. "decode(createtime,'小计',decode(kilncarcode,'合计','--','小计'),kilncarcode) kilncarcode, " +
  6833. "decode(goodscode,'--','--',createtime) createtime, " +
  6834. "GOODSTYPENAME, " +
  6835. "Goodscode, " +
  6836. "GOODSSPECIFICATION, " +
  6837. "Barcode, " +
  6838. "BarcodeCount, " +
  6839. "LogoCodeName " +
  6840. "from " +
  6841. " ( " +
  6842. " select " +
  6843. " decode(grouping(TP_SYS_ProcedureModelType.Proceduremodeltypename),1,'总计',TP_SYS_ProcedureModelType.Proceduremodeltypename) Proceduremodeltypename, " +
  6844. " decode(grouping(TP_PM_ProductionData.Kilncode),1,'--',TP_PM_ProductionData.Kilncode) Kilncode, " +
  6845. " decode(grouping(TP_PM_ProductionData.Usercode),1,'--',TP_PM_ProductionData.Usercode) Usercode, " +
  6846. " decode(grouping(TP_MST_KilnCar.Kilncarcode),1,'合计',TP_MST_KilnCar.Kilncarcode) Kilncarcode, " +
  6847. " decode(grouping(TP_PM_ProductionData.CreateTime),1,'小计',TP_PM_ProductionData.CreateTime) CreateTime, " +
  6848. " decode(grouping(TP_MST_GOODSTYPE.GOODSTYPENAME),1,'--',TP_MST_GOODSTYPE.GOODSTYPENAME) GOODSTYPENAME, " +
  6849. " decode(grouping(TP_MST_Goods.Goodscode),1,'--',TP_MST_Goods.Goodscode) Goodscode, " +
  6850. " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  6851. " decode(grouping(TP_PM_ProductionData.Barcode),1,'--',TP_PM_ProductionData.Barcode) Barcode, " +
  6852. " decode(grouping(TP_PM_ProductionData.LogoCodeName),1,'--',TP_PM_ProductionData.LogoCodeName) LogoCodeName, " +
  6853. " count(TP_PM_ProductionData.Barcode) as BarcodeCount " +
  6854. " from " +
  6855. " ( " +
  6856. " select TP_PM_ProductionData.logoid," +
  6857. " TP_PM_ProductionData.Modeltype, " +
  6858. " TP_PM_ProductionData.Goodsid, " +
  6859. " TP_PM_ProductionData.KilnCarID, " +
  6860. " TP_PM_ProductionData.Kilncode, " +
  6861. " TP_PM_ProductionData.Barcode, " +
  6862. " TP_PM_ProductionData.Usercode, " +
  6863. " replace((Logoname||'['||Logocode||']'),'[]','') as LogoCodeName, " +
  6864. " to_char(TP_PM_ProductionData.CreateTime,'yyyy-mm-dd hh24:mi') CreateTime " +
  6865. " from TP_PM_ProductionData inner join TP_MST_Logo on TP_PM_ProductionData.logoid=TP_MST_Logo.logoid" +
  6866. " left join TP_PM_KilnCarData kcd on kcd.KilnCarBatchNo = TP_PM_ProductionData.KilnCarBatchNo and kcd.ProcedureID = TP_PM_ProductionData.ProcedureID " +
  6867. " where " +
  6868. " TP_PM_ProductionData.Accountid=:AccountID " +
  6869. " and TP_PM_ProductionData.Valueflag=1 " +
  6870. " and TP_PM_ProductionData.Modeltype=:ProcedureModelTypeID ";
  6871. if (se.KilnID.HasValue)
  6872. {
  6873. selSql = selSql + " AND TP_PM_ProductionData.KilnID=:KilnID ";
  6874. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6875. }
  6876. //if (se.KilnCarID.HasValue)
  6877. //{
  6878. // selSql = selSql + " AND TP_PM_ProductionData.KilnCarID=:KilnCarID ";
  6879. // parameters.Add(new OracleParameter(":KilnCarID", OracleDbType.Int32, se.KilnCarID, ParameterDirection.Input));
  6880. //}
  6881. if (!string.IsNullOrEmpty(se.GoodsIDS))
  6882. {
  6883. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  6884. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  6885. }
  6886. if (!string.IsNullOrEmpty(se.UserIDS))
  6887. {
  6888. selSql = selSql + " AND instr(','||:UserIDS||',',','||kcd.UserID||',')>0 ";
  6889. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6890. }
  6891. if (se.CreateTimeStart.HasValue)
  6892. {
  6893. selSql = selSql + " AND kcd.CreateTime>= :CreateTimeStart ";
  6894. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6895. }
  6896. if (se.CreateTimeEnd.HasValue)
  6897. {
  6898. selSql = selSql + " AND kcd.CreateTime<= :CreateTimeEnd ";
  6899. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6900. }
  6901. selSql = selSql +
  6902. " ) TP_PM_ProductionData " +
  6903. " inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.Proceduremodeltypeid=TP_PM_ProductionData.Modeltype " +
  6904. " inner join TP_MST_Goods on TP_MST_Goods.Goodsid=TP_PM_ProductionData.Goodsid " +
  6905. " inner join TP_MST_GOODSTYPE on TP_MST_GOODSTYPE.GOODSTYPEID=TP_MST_Goods.Goodstypeid " +
  6906. " inner join TP_MST_KilnCar on TP_MST_KilnCar.Kilncarid=TP_PM_ProductionData.KilnCarID " +
  6907. " where 1=1";
  6908. if (!string.IsNullOrEmpty(se.KilnCarCode))
  6909. {
  6910. selSql = selSql + " AND instr(TP_MST_KilnCar.KilnCarCode, :KilnCarCode ) > 0";
  6911. parameters.Add(new OracleParameter(":KilnCarCode", OracleDbType.NVarchar2, se.KilnCarCode, ParameterDirection.Input));
  6912. }
  6913. if (se.KilnCarNumBegin.HasValue && se.KilnCarNumEnd.HasValue && se.KilnCarNumBegin.Value > se.KilnCarNumEnd.Value)
  6914. {
  6915. selSql = selSql + " AND (TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin or TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd)";
  6916. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6917. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6918. }
  6919. else
  6920. {
  6921. if (se.KilnCarNumBegin.HasValue)
  6922. {
  6923. selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin ";
  6924. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6925. }
  6926. if (se.KilnCarNumEnd.HasValue)
  6927. {
  6928. selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd ";
  6929. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6930. }
  6931. }
  6932. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  6933. {
  6934. //selSql = selSql + " AND instr(','||:goodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1 ";
  6935. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:goodsTypeIDS)=1 ";
  6936. parameters.Add(new OracleParameter(":goodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  6937. }
  6938. selSql = selSql +
  6939. " group by rollup( " +
  6940. " TP_SYS_ProcedureModelType.Proceduremodeltypename, " +
  6941. " TP_PM_ProductionData.Kilncode, " +
  6942. " TP_PM_ProductionData.Usercode, " +
  6943. " TP_MST_KilnCar.Kilncarcode, " +
  6944. " TP_PM_ProductionData.CreateTime, " +
  6945. " TP_MST_GOODSTYPE.GOODSTYPENAME, " +
  6946. " TP_MST_Goods.Goodscode, " +
  6947. " TP_MST_Goods.GOODSSPECIFICATION, " +
  6948. " TP_PM_ProductionData.Barcode, " +
  6949. " TP_PM_ProductionData.LogoCodeName " +
  6950. " ) " +
  6951. " ) temp " +
  6952. "where 1=1 and " +
  6953. "(Barcode !='--' and LogoCodeName!='--') or " +
  6954. "(Barcode='--' and Usercode='合计' and kilncode!='--') or " +
  6955. "(Barcode='--' and Proceduremodeltypename='总计' ) or " +
  6956. "(Barcode='--' and createtime='小计' and temp.usercode!='--')";
  6957. return selSql;
  6958. }
  6959. #region 工序交接数量汇总表
  6960. /// <summary>
  6961. /// 取得RPT030107画面(工序交接数量汇总表)的汇总信息查询数据
  6962. /// </summary>
  6963. /// <param name="user">登录用户信息</param>
  6964. /// <param name="se">查询条件</param>
  6965. /// <returns>查询结果</returns>
  6966. public static ServiceResultEntity GetRPT030107SData(SUserInfo user, RPT030107_SE se)
  6967. {
  6968. IDBConnection conn = null;
  6969. try
  6970. {
  6971. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6972. List<OracleParameter> parameters = new List<OracleParameter>();
  6973. string sql = ReportModuleLogic.GetRPT030107SSQL(user, se, ref parameters);
  6974. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  6975. ServiceResultEntity sre = new ServiceResultEntity();
  6976. if (data == null || data.Rows.Count == 0)
  6977. {
  6978. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6979. return sre;
  6980. }
  6981. sre.Data = new DataSet();
  6982. sre.Data.Tables.Add(data);
  6983. return sre;
  6984. }
  6985. catch (Exception ex)
  6986. {
  6987. throw ex;
  6988. }
  6989. finally
  6990. {
  6991. if (conn != null &&
  6992. conn.ConnState == ConnectionState.Open)
  6993. {
  6994. conn.Close();
  6995. }
  6996. }
  6997. }
  6998. /// <summary>
  6999. /// 获取RPT030107画面(工序交接数量汇总表)的汇总信息查询sql
  7000. /// </summary>
  7001. /// <returns>sql</returns>
  7002. private static string GetRPT030107SSQL(SUserInfo user, RPT030107_SE se, ref List<OracleParameter> parameters)
  7003. {
  7004. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7005. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  7006. string sqlString =
  7007. "SELECT p.procedureid\n" +
  7008. " ,decode(gid,\n" +
  7009. " 7,\n" +
  7010. " '总计',\n" +
  7011. " 3,\n" +
  7012. " '合计【' || p.procedurename || '】',\n" +
  7013. " 1,\n" +
  7014. " '--',\n" +
  7015. " p.procedurename) procedurename\n" +
  7016. " ,decode(gid,\n" +
  7017. " 7,\n" +
  7018. " '--',\n" +
  7019. " 3,\n" +
  7020. " '--',\n" +
  7021. " 1,\n" +
  7022. " '小计【' || p.goodstypename2 || '】',\n" +
  7023. " p.goodstypename2) goodstypename2\n" +
  7024. " ,p.goodstypecode2 \n" +
  7025. " ,decode(gid, 0, p.userid, '--') userid\n" +
  7026. " ,decode(gid, 0, p.usercode, '--') usercode\n" +
  7027. " ,decode(gid, 0, p.goodsid, '--') goodsid\n" +
  7028. " ,decode(gid, 0, p.goodscode, '--') goodscode\n" +
  7029. " ,decode(gid, 0, p.goodstypename, '--') goodstypename\n" +
  7030. " ,p.overcount\n" +
  7031. " FROM (SELECT grouping_id(pdata.Procedureid,pdata.goodstypename2, pdata.Userid) gid\n" +
  7032. " ,pdata.productionlineid\n" +
  7033. " ,pdata.procedureid\n" +
  7034. " ,to_char(pdata.procedurename) procedurename\n" +
  7035. " ,to_char(pdata.userid) userid\n" +
  7036. " ,pdata.usercode\n" +
  7037. " ,to_char(pdata.goodsid) goodsid\n" +
  7038. " ,pdata.goodscode\n" +
  7039. " ,pdata.goodstypename\n" +
  7040. " ,pdata.goodstypecode2\n" +
  7041. " ,pdata.goodstypename2\n" +
  7042. " ,COUNT(pdata.barcode) overcount\n" +
  7043. " FROM (SELECT distinct pd.barcode,pcp.displayno\n" +
  7044. " ,pd.productionlineid\n" +
  7045. " ,pd.procedureid\n" +
  7046. " ,pcp.procedurename\n" +
  7047. (se.DisPUserCode ? " ,pd.userid, pd.usercode \n" : " ,null userid, null usercode \n") +
  7048. //" ,pd.userid\n" +
  7049. //" ,pd.usercode\n" +
  7050. " ,t_over.goodsid\n" +
  7051. " ,t_over.goodscode\n" +
  7052. " ,t_over.goodstypename\n" +
  7053. " ,t_over.goodstypecode2\n" +
  7054. " ,t_over.goodstypename2\n" +
  7055. " FROM tp_pm_productiondata pd\n" +
  7056. " LEFT JOIN tp_pc_procedure pcp\n" +
  7057. " ON pcp.procedureid = pd.procedureid\n" +
  7058. " INNER JOIN (SELECT DISTINCT pd.barcode\n" +
  7059. " ,pd.productiondataid\n" +
  7060. " ,goods.goodsid\n" +
  7061. " ,goods.goodscode\n" +
  7062. " ,gt.goodstypename\n" +
  7063. " ,gt2.goodstypename goodstypename2\n" +
  7064. " ,gt2.goodstypecode goodstypecode2\n" +
  7065. " FROM tp_pm_productiondata pd\n" +
  7066. " LEFT JOIN tp_mst_goods goods\n" +
  7067. " ON goods.goodsid = pd.goodsid\n" +
  7068. " LEFT JOIN tp_mst_goodstype gt\n" +
  7069. " ON goods.goodstypeid = gt.goodstypeid\n" +
  7070. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7071. " ON gt2.goodstypecode = substr(gt.goodstypecode,1,6)\n" +
  7072. " AND gt2.accountid = gt.accountid\n" +
  7073. " --LEFT JOIN tp_pc_procedure pcp\n" +
  7074. " -- ON pcp.procedureid = pd.procedureid\n" +
  7075. ((se.DTimeStart.HasValue || se.DTimeEnd.HasValue) ? " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=pd.groutingdailydetailid \n" : "") +
  7076. " WHERE pd.valueflag = '1'\n" +
  7077. " 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))" +
  7078. " AND pd.accountid = :AccountID\n";
  7079. // 生产线
  7080. if (se.ProductionLineID.HasValue)
  7081. {
  7082. sqlString = sqlString + " AND pd.productionlineid = :productionlineid ";
  7083. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  7084. }
  7085. // 成型工号
  7086. if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
  7087. {
  7088. sqlString = sqlString + " AND instr(pd.GroutingUserCode, :GroutingUserCode) > 0";
  7089. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  7090. }
  7091. // 产品型号
  7092. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  7093. {
  7094. sqlString = sqlString + " AND instr(gt.GOODSTYPECode, :GoodsTypeCode)=1 ";
  7095. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7096. }
  7097. // 产品编码
  7098. if (!string.IsNullOrEmpty(se.GoodsCode))
  7099. {
  7100. sqlString = sqlString + " AND instr(goods.GOODSCode, :GoodsCode) > 0 ";
  7101. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7102. }
  7103. // 交接工序
  7104. if (!string.IsNullOrEmpty(se.OverProcedureIDS))
  7105. {
  7106. sqlString = sqlString + " AND instr(:overprocedureids, ','||pd.procedureid||',')>0 ";
  7107. parameters.Add(new OracleParameter(":overprocedureids", OracleDbType.Varchar2, "," + se.OverProcedureIDS + ",", ParameterDirection.Input));
  7108. }
  7109. // 交接工号
  7110. if (!string.IsNullOrEmpty(se.OverUserIDS))
  7111. {
  7112. sqlString = sqlString + " AND instr(:overuserids, ','||pd.userid||',')>0 ";
  7113. parameters.Add(new OracleParameter(":overuserids", OracleDbType.Varchar2, "," + se.OverUserIDS + ",", ParameterDirection.Input));
  7114. }
  7115. // 交接时间
  7116. if (se.OverTimeStart.HasValue)
  7117. {
  7118. sqlString = sqlString + " AND pd.CreateTime >=:OverTimeStart ";
  7119. parameters.Add(new OracleParameter(":OverTimeStart", OracleDbType.Date, se.OverTimeStart.Value, ParameterDirection.Input));
  7120. }
  7121. if (se.OverTimeEnd.HasValue)
  7122. {
  7123. sqlString = sqlString + " AND pd.CreateTime <= :OverTimeEnd ";
  7124. parameters.Add(new OracleParameter(":OverTimeEnd", OracleDbType.Date, se.OverTimeEnd.Value, ParameterDirection.Input));
  7125. }
  7126. // 注浆时间
  7127. if (se.GTimeStart.HasValue)
  7128. {
  7129. sqlString = sqlString + " AND pd.GROUTINGDATE >=:GTimeStart ";
  7130. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  7131. }
  7132. if (se.GTimeEnd.HasValue)
  7133. {
  7134. sqlString = sqlString + " AND pd.GROUTINGDATE <= :GTimeEnd ";
  7135. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  7136. }
  7137. // 交坯时间
  7138. if (se.DTimeStart.HasValue)
  7139. {
  7140. sqlString = sqlString + " AND gdd.DELIVERTIME >=:DTimeStart ";
  7141. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
  7142. }
  7143. if (se.DTimeEnd.HasValue)
  7144. {
  7145. sqlString = sqlString + " AND gdd.DELIVERTIME <= :DTimeEnd ";
  7146. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
  7147. }
  7148. sqlString = sqlString +
  7149. " ) t_over\n" +
  7150. " ON pd.barcode = t_over.barcode\n" +
  7151. // 交接工序在生产工序后
  7152. " AND pd.productiondataid <= t_over.productiondataid\n" +
  7153. " WHERE pd.valueflag = '1'\n" +
  7154. " AND pd.accountid = :AccountID\n" +
  7155. (se.Specialrepairflag ? " AND ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" : "") +
  7156. " 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))";
  7157. // 生产工序
  7158. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  7159. {
  7160. sqlString = sqlString + " AND instr(:procedureids, ','||pd.procedureid||',')>0 ";
  7161. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  7162. }
  7163. // 生产工号
  7164. if (!string.IsNullOrEmpty(se.UserIDS))
  7165. {
  7166. sqlString = sqlString + " AND instr(:userids, ','||pd.userid||',')>0 ";
  7167. parameters.Add(new OracleParameter(":userids", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
  7168. }
  7169. // 生产时间
  7170. if (se.PTimeStart.HasValue)
  7171. {
  7172. sqlString = sqlString + " AND pd.CreateTime >=:PTimeStart ";
  7173. parameters.Add(new OracleParameter(":PTimeStart", OracleDbType.Date, se.PTimeStart.Value, ParameterDirection.Input));
  7174. }
  7175. if (se.PTimeEnd.HasValue)
  7176. {
  7177. sqlString = sqlString + " AND pd.CreateTime <= :PTimeEnd ";
  7178. parameters.Add(new OracleParameter(":PTimeEnd", OracleDbType.Date, se.PTimeEnd.Value, ParameterDirection.Input));
  7179. }
  7180. sqlString = sqlString +
  7181. "\n ) pdata\n" +
  7182. " 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" +
  7183. " ORDER BY pdata.displayno\n" +
  7184. " ,pdata.goodstypename2\n" +
  7185. " ,pdata.usercode\n" +
  7186. " ,pdata.goodstypename\n" +
  7187. " ,pdata.goodscode) p";
  7188. return sqlString;
  7189. }
  7190. /// <summary>
  7191. /// 取得RPT030107画面(工序交接数量汇总表)的明细信息查询数据
  7192. /// </summary>
  7193. /// <param name="user">登录用户信息</param>
  7194. /// <param name="se">查询条件</param>
  7195. /// <returns>查询结果</returns>
  7196. public static ServiceResultEntity GetRPT030107IData(SUserInfo user, RPT030107_SE se)
  7197. {
  7198. IDBConnection conn = null;
  7199. try
  7200. {
  7201. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7202. List<OracleParameter> parameters = new List<OracleParameter>();
  7203. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030107ISQL(user, se, ref parameters));
  7204. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  7205. ServiceResultEntity sre = new ServiceResultEntity();
  7206. if (data == null || data.Rows.Count == 0)
  7207. {
  7208. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7209. return sre;
  7210. }
  7211. sre.Data = new DataSet();
  7212. sre.Data.Tables.Add(data);
  7213. return sre;
  7214. }
  7215. catch (Exception ex)
  7216. {
  7217. throw ex;
  7218. }
  7219. finally
  7220. {
  7221. if (conn != null &&
  7222. conn.ConnState == ConnectionState.Open)
  7223. {
  7224. conn.Close();
  7225. }
  7226. }
  7227. }
  7228. /// <summary>
  7229. /// 获取RPT030107画面(工序交接数量汇总表)的明细信息查询sql
  7230. /// </summary>
  7231. /// <returns>sql</returns>
  7232. private static string GetRPT030107ISQL(SUserInfo user, RPT030107_SE se, ref List<OracleParameter> parameters)
  7233. {
  7234. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7235. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  7236. string sqlString =
  7237. "SELECT distinct pcp.procedurename,pcp.displayno\n" +
  7238. (se.DisPUserCode ? " ,pd.userid, pd.usercode \n" : " ,null userid, null usercode \n") +
  7239. //" ,pd.usercode\n" +
  7240. " ,t_over.barcode\n" +
  7241. " ,t_over.goodscode\n" +
  7242. " ,t_over.goodstypename\n" +
  7243. " ,t_over.goodstypename2\n" +
  7244. //" ,pd.createtime ptime\n" +
  7245. //" ,t_over.overprocedurename\n" +
  7246. //" ,t_over.overusercode\n" +
  7247. //" ,t_over.overtime\n" +
  7248. " ,t_over.groutingusercode\n" +
  7249. " ,pd.groutinglinecode\n" +
  7250. " ,pd.groutingmouldcode\n" +
  7251. " ,t_over.groutingdate Gdate\n" +
  7252. " ,t_over.DELIVERTIME Ddate\n" +
  7253. " ,decode(logo.logoid, null, '', logo.Logoname||'['||logo.Logocode||']') as LogoCodeName " +
  7254. " FROM tp_pm_productiondata pd\n" +
  7255. " LEFT JOIN tp_pc_procedure pcp\n" +
  7256. " ON pcp.procedureid = pd.procedureid\n" +
  7257. " LEFT JOIN TP_MST_logo logo\n" +
  7258. " ON logo.logoid = pd.logoid\n" +
  7259. " INNER JOIN (SELECT DISTINCT pd.barcode\n" +
  7260. " ,pd.productiondataid\n" +
  7261. " ,goods.goodsid\n" +
  7262. " ,goods.goodscode\n" +
  7263. " ,gt.goodstypename\n" +
  7264. " ,gt2.goodstypename goodstypename2\n" +
  7265. //" ,pcp.procedurename overprocedurename\n" +
  7266. //" ,pd.usercode overusercode\n" +
  7267. //" ,pd.createtime overtime\n" +
  7268. " ,pd.groutingusercode\n" +
  7269. " ,pd.groutingdate\n" +
  7270. " ,gdd.DELIVERTIME\n" +
  7271. " FROM tp_pm_productiondata pd\n" +
  7272. " LEFT JOIN tp_mst_goods goods\n" +
  7273. " ON goods.goodsid = pd.goodsid\n" +
  7274. " LEFT JOIN tp_mst_goodstype gt\n" +
  7275. " ON goods.goodstypeid = gt.goodstypeid\n" +
  7276. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7277. " ON gt2.goodstypecode = substr(gt.goodstypecode,1,6)\n" +
  7278. " AND gt2.accountid = gt.accountid\n" +
  7279. " LEFT JOIN tp_pc_procedure pcp\n" +
  7280. " ON pcp.procedureid = pd.procedureid\n" +
  7281. " INNER JOIN tp_pm_groutingdailydetail gdd\n" +
  7282. " ON gdd.groutingdailydetailid = pd.groutingdailydetailid\n" +
  7283. " WHERE pd.valueflag = '1'\n" +
  7284. " 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))" +
  7285. " AND pd.accountid = :AccountID\n";
  7286. // 生产线
  7287. if (se.ProductionLineID.HasValue)
  7288. {
  7289. sqlString = sqlString + " AND pd.productionlineid = :productionlineid ";
  7290. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  7291. }
  7292. // 成型工号
  7293. if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
  7294. {
  7295. sqlString = sqlString + " AND instr(pd.GroutingUserCode, :GroutingUserCode) > 0";
  7296. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  7297. }
  7298. // 产品型号
  7299. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  7300. {
  7301. sqlString = sqlString + " AND instr(gt.GOODSTYPECode, :GoodsTypeCode)=1 ";
  7302. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7303. }
  7304. if (!string.IsNullOrEmpty(se.GoodsID))
  7305. {
  7306. sqlString = sqlString + " AND pd.goodsid = :GoodsID ";
  7307. parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  7308. }
  7309. // 产品编码
  7310. if (!string.IsNullOrEmpty(se.GoodsCode))
  7311. {
  7312. sqlString = sqlString + " AND instr(goods.GOODSCode, :GoodsCode) > 0 ";
  7313. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7314. }
  7315. // 交接工序
  7316. if (!string.IsNullOrEmpty(se.OverProcedureIDS))
  7317. {
  7318. sqlString = sqlString + " AND instr(:overprocedureids, ','||pd.procedureid||',')>0 ";
  7319. parameters.Add(new OracleParameter(":overprocedureids", OracleDbType.Varchar2, "," + se.OverProcedureIDS + ",", ParameterDirection.Input));
  7320. }
  7321. // 交接工号
  7322. if (!string.IsNullOrEmpty(se.OverUserIDS))
  7323. {
  7324. sqlString = sqlString + " AND instr(:overuserids, ','||pd.userid||',')>0 ";
  7325. parameters.Add(new OracleParameter(":overuserids", OracleDbType.Varchar2, "," + se.OverUserIDS + ",", ParameterDirection.Input));
  7326. }
  7327. // 交接时间
  7328. if (se.OverTimeStart.HasValue)
  7329. {
  7330. sqlString = sqlString + " AND pd.CreateTime >=:OverTimeStart ";
  7331. parameters.Add(new OracleParameter(":OverTimeStart", OracleDbType.Date, se.OverTimeStart.Value, ParameterDirection.Input));
  7332. }
  7333. if (se.OverTimeEnd.HasValue)
  7334. {
  7335. sqlString = sqlString + " AND pd.CreateTime <= :OverTimeEnd ";
  7336. parameters.Add(new OracleParameter(":OverTimeEnd", OracleDbType.Date, se.OverTimeEnd.Value, ParameterDirection.Input));
  7337. }
  7338. // 注浆时间
  7339. if (se.GTimeStart.HasValue)
  7340. {
  7341. sqlString = sqlString + " AND pd.GROUTINGDATE >=:GTimeStart ";
  7342. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  7343. }
  7344. if (se.GTimeEnd.HasValue)
  7345. {
  7346. sqlString = sqlString + " AND pd.GROUTINGDATE <= :GTimeEnd ";
  7347. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  7348. }
  7349. // 交坯时间
  7350. if (se.DTimeStart.HasValue)
  7351. {
  7352. sqlString = sqlString + " AND gdd.DELIVERTIME >=:DTimeStart ";
  7353. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
  7354. }
  7355. if (se.DTimeEnd.HasValue)
  7356. {
  7357. sqlString = sqlString + " AND gdd.DELIVERTIME <= :DTimeEnd ";
  7358. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
  7359. }
  7360. sqlString = sqlString +
  7361. " ) t_over\n" +
  7362. " ON pd.barcode = t_over.barcode\n" +
  7363. // 交接工序在生产工序后
  7364. " AND pd.productiondataid <= t_over.productiondataid\n" +
  7365. " WHERE pd.valueflag = '1'\n" +
  7366. " AND pd.accountid = :AccountID\n" +
  7367. (se.Specialrepairflag ? " AND ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" : "") +
  7368. " 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))";
  7369. // 生产工序
  7370. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  7371. {
  7372. sqlString = sqlString + " AND instr(:procedureids, ','||pd.procedureid||',')>0 ";
  7373. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  7374. }
  7375. // 生产工号
  7376. if (!string.IsNullOrEmpty(se.UserIDS))
  7377. {
  7378. sqlString = sqlString + " AND instr(:userids, ','||pd.userid||',')>0 ";
  7379. parameters.Add(new OracleParameter(":userids", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
  7380. }
  7381. // 生产时间
  7382. if (se.PTimeStart.HasValue)
  7383. {
  7384. sqlString = sqlString + " AND pd.CreateTime >=:PTimeStart ";
  7385. parameters.Add(new OracleParameter(":PTimeStart", OracleDbType.Date, se.PTimeStart.Value, ParameterDirection.Input));
  7386. }
  7387. if (se.PTimeEnd.HasValue)
  7388. {
  7389. sqlString = sqlString + " AND pd.CreateTime <= :PTimeEnd ";
  7390. parameters.Add(new OracleParameter(":PTimeEnd", OracleDbType.Date, se.PTimeEnd.Value, ParameterDirection.Input));
  7391. }
  7392. sqlString = sqlString +
  7393. "\n ORDER BY pcp.displayno\n" +
  7394. " ,t_over.goodstypename2\n" +
  7395. (se.DisPUserCode ? " ,pd.usercode\n" : "") +
  7396. " ,t_over.goodstypename\n" +
  7397. " ,t_over.goodscode\n";
  7398. return sqlString;
  7399. }
  7400. #endregion
  7401. /// <summary>
  7402. /// 取得RPT030108画面(成型信息汇总表)的查询数据
  7403. /// </summary>
  7404. /// <param name="user">登录用户信息</param>
  7405. /// <param name="se">查询条件</param>
  7406. /// <returns>查询结果</returns>
  7407. public static ServiceResultEntity GetRPT030108SData(SUserInfo user, RPT030108_SE se)
  7408. {
  7409. IDBConnection conn = null;
  7410. try
  7411. {
  7412. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7413. List<OracleParameter> parameters = new List<OracleParameter>();
  7414. string sqlString = "SELECT decode(g.gid,\n" +
  7415. " 7,\n" +
  7416. " '总计',\n" +
  7417. " 3,\n" +
  7418. " '合计【' || g.goodstypename2 || '】',\n" +
  7419. " 0,\n" +
  7420. " g.goodstypename2,\n" +
  7421. " '--') goodstypename2\n" +
  7422. " ,decode(g.gid, 0, g.goodstypename, '--') goodstypename\n" +
  7423. " ,decode(g.gid,\n" +
  7424. " 1,\n" +
  7425. " '小计【' || g.goodscode || '】',\n" +
  7426. " 0,\n" +
  7427. " g.goodscode,\n" +
  7428. " '--') goodscode\n" +
  7429. " ,decode(g.gid, 0, g.usercode, '--') usercode\n" +
  7430. " ,decode(g.gid, 0, g.MONITORName, '--') MONITORName\n" +
  7431. " ,g.groutingcount\n" +
  7432. " ,g.barcodecount\n" +
  7433. " ,g.scrapcount\n" +
  7434. " ,g.barscrapcount\n" +
  7435. " ,g.delivercount\n" +
  7436. " ,g.barcodecount - g.barscrapcount - g.delivercount incount\n" +
  7437. " FROM (SELECT grouping_id(gdd.goodstypename2, gdd.goodscode, gdd.usercode) gid\n" +
  7438. " ,gdd.goodstypename2\n" +
  7439. " ,gdd.goodstypename\n" +
  7440. " ,gdd.goodscode\n" +
  7441. " ,gdd.usercode\n" +
  7442. " ,gdd.MONITORName\n" +
  7443. " ,SUM(groutingcount) groutingcount\n" +
  7444. " ,SUM(barcodecount) barcodecount\n" +
  7445. " ,SUM(scrapcount) scrapcount\n" +
  7446. " ,SUM(barscrapcount) barscrapcount\n" +
  7447. " ,SUM(delivercount) delivercount\n" +
  7448. " FROM (SELECT gt2.goodstypename goodstypename2\n" +
  7449. " ,gdd.usercode\n" +
  7450. " ,mu.usercode as MONITORName\n" +
  7451. " ,goods.goodscode\n" +
  7452. " ,gt.goodstypename\n" +
  7453. " , CASE\n" +
  7454. " WHEN gdd.groutingdate >= :gdatabegin AND\n" +
  7455. " gdd.groutingdate <= :gdataend THEN\n" +
  7456. " 1\n" +
  7457. " ELSE\n" +
  7458. " 0\n" +
  7459. " END groutingcount\n" +
  7460. " , CASE\n" +
  7461. " WHEN gdd.groutingdate >= :gdatabegin AND\n" +
  7462. " gdd.groutingdate <= :gdataend AND\n" +
  7463. " gdd.barcode IS NOT NULL THEN\n" +
  7464. " 1\n" +
  7465. " ELSE\n" +
  7466. " 0\n" +
  7467. " END barcodecount\n" +
  7468. " , CASE\n" +
  7469. " WHEN gdd.scraptime >= :sdatabegin AND\n" +
  7470. " gdd.scraptime <= :sdataend AND\n" +
  7471. " gdd.scrapflag = '1' THEN\n" +
  7472. " 1\n" +
  7473. " ELSE\n" +
  7474. " 0\n" +
  7475. " END scrapcount\n" +
  7476. " , CASE\n" +
  7477. " WHEN gdd.scraptime >= :sdatabegin AND\n" +
  7478. " gdd.scraptime <= :sdataend AND\n" +
  7479. " gdd.barcode IS NOT NULL AND gdd.scrapflag = '1' THEN\n" +
  7480. " 1\n" +
  7481. " ELSE\n" +
  7482. " 0\n" +
  7483. " END barscrapcount\n" +
  7484. " , CASE\n" +
  7485. " WHEN gdd.delivertime >= :ddatabegin AND\n" +
  7486. " gdd.delivertime <= :ddataend AND\n" +
  7487. " gdd.deliverflag = '1' THEN\n" +
  7488. " 1\n" +
  7489. " ELSE\n" +
  7490. " 0\n" +
  7491. " END delivercount\n" +
  7492. " FROM tp_pm_groutingdailydetail gdd\n" +
  7493. " LEFT JOIN tp_mst_goods goods\n" +
  7494. " ON goods.goodsid = gdd.goodsid\n" +
  7495. // 成型线
  7496. " LEFT JOIN tp_pc_groutingline gl" +
  7497. " ON gl.groutinglineid = GDD.GroutingLineID" +
  7498. // 成型班长
  7499. " LEFT JOIN tp_mst_user mu" +
  7500. " ON mu.userid = gl.MONITORID " +
  7501. " LEFT JOIN tp_mst_goodstype gt\n" +
  7502. " ON gt.goodstypeid = goods.goodstypeid\n" +
  7503. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7504. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  7505. " AND gt2.accountid = gt.accountid\n" +
  7506. " WHERE gdd.valueflag = '1'\n" +
  7507. " AND gdd.groutingflag = '1'\n" +
  7508. " AND gdd.accountid = :accountid\n" +
  7509. " AND ((gdd.groutingdate >= :gdatabegin AND\n" +
  7510. " gdd.groutingdate <= :gdataend) OR\n" +
  7511. " (gdd.scraptime >= :sdatabegin AND\n" +
  7512. " gdd.scraptime <= :sdataend) OR\n" +
  7513. " (gdd.delivertime >= :ddatabegin AND\n" +
  7514. " gdd.delivertime <= :ddataend))\n" +
  7515. " AND (:usercode IS NULL OR\n" +
  7516. " instr(gdd.usercode, :usercode) > 0)\n" +
  7517. " AND (:GoodsCode IS NULL OR\n" +
  7518. " instr(goods.GoodsCode, :GoodsCode) > 0)\n" +
  7519. " AND (:goodstypecode IS NULL OR\n" +
  7520. " instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  7521. " ORDER BY gt2.goodstypename\n" +
  7522. " ,gt.goodstypename\n" +
  7523. " ,goods.goodscode\n" +
  7524. " ,gdd.usercode) gdd\n" +
  7525. " GROUP BY GROUPING SETS((gdd.goodstypename2, gdd.goodstypename, gdd.goodscode, gdd.usercode,gdd.MONITORName),(gdd.goodstypename2, gdd.goodstypename, gdd.goodscode),(gdd.goodstypename2),())\n" +
  7526. " ORDER BY gdd.goodstypename2\n" +
  7527. " ,gdd.goodstypename\n" +
  7528. " ,gdd.goodscode\n" +
  7529. " ,gdd.usercode) g";
  7530. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7531. parameters.Add(new OracleParameter(":gdatabegin", OracleDbType.Date, se.GTimeStart, ParameterDirection.Input));
  7532. parameters.Add(new OracleParameter(":gdataend", OracleDbType.Date, se.GTimeEnd, ParameterDirection.Input));
  7533. parameters.Add(new OracleParameter(":sdatabegin", OracleDbType.Date, se.STimeStart, ParameterDirection.Input));
  7534. parameters.Add(new OracleParameter(":sdataend", OracleDbType.Date, se.STimeEnd, ParameterDirection.Input));
  7535. parameters.Add(new OracleParameter(":ddatabegin", OracleDbType.Date, se.DTimeStart, ParameterDirection.Input));
  7536. parameters.Add(new OracleParameter(":ddataend", OracleDbType.Date, se.DTimeEnd, ParameterDirection.Input));
  7537. parameters.Add(new OracleParameter(":usercode", OracleDbType.Varchar2, se.UserCode, ParameterDirection.Input));
  7538. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7539. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7540. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  7541. ServiceResultEntity sre = new ServiceResultEntity();
  7542. if (data == null || data.Rows.Count == 0)
  7543. {
  7544. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7545. return sre;
  7546. }
  7547. sre.Data = new DataSet();
  7548. sre.Data.Tables.Add(data);
  7549. return sre;
  7550. }
  7551. catch (Exception ex)
  7552. {
  7553. throw ex;
  7554. }
  7555. finally
  7556. {
  7557. if (conn != null &&
  7558. conn.ConnState == ConnectionState.Open)
  7559. {
  7560. conn.Close();
  7561. }
  7562. }
  7563. }
  7564. #region 撤销产品汇总表
  7565. /// <summary>
  7566. /// 取得RPT030109画面(撤销产品汇总表)的汇总信息查询数据
  7567. /// </summary>
  7568. /// <param name="user">登录用户信息</param>
  7569. /// <param name="se">查询条件</param>
  7570. /// <returns>查询结果</returns>
  7571. public static ServiceResultEntity GetRPT030109SData(SUserInfo user, RPT030109_SE se)
  7572. {
  7573. IDBConnection conn = null;
  7574. try
  7575. {
  7576. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7577. List<OracleParameter> parameters = new List<OracleParameter>();
  7578. string sql = ReportModuleLogic.GetRPT030109SSQL(user, se, ref parameters);
  7579. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  7580. ServiceResultEntity sre = new ServiceResultEntity();
  7581. if (data == null || data.Rows.Count == 0)
  7582. {
  7583. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7584. return sre;
  7585. }
  7586. sre.Data = new DataSet();
  7587. sre.Data.Tables.Add(data);
  7588. return sre;
  7589. }
  7590. catch (Exception ex)
  7591. {
  7592. throw ex;
  7593. }
  7594. finally
  7595. {
  7596. if (conn != null &&
  7597. conn.ConnState == ConnectionState.Open)
  7598. {
  7599. conn.Close();
  7600. }
  7601. }
  7602. }
  7603. /// <summary>
  7604. /// 获取RPT030109画面(撤销产品汇总表)的汇总信息查询sql
  7605. /// </summary>
  7606. /// <returns>sql</returns>
  7607. private static string GetRPT030109SSQL(SUserInfo user, RPT030109_SE se, ref List<OracleParameter> parameters)
  7608. {
  7609. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7610. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  7611. string sqlString =
  7612. "SELECT decode(p.gid,\n" +
  7613. " 7,\n" +
  7614. " '总计',\n" +
  7615. " 3,\n" +
  7616. " '合计【' || p.procedurename || '】',\n" +
  7617. " 0,\n" +
  7618. " p.procedurename,\n" +
  7619. " '--') procedurename\n" +
  7620. " ,decode(p.gid,\n" +
  7621. " 1,\n" +
  7622. " '小计【' || p.goodstypename2 || '】',\n" +
  7623. " 0,\n" +
  7624. " p.goodstypename2,\n" +
  7625. " '--') goodstypename2\n" +
  7626. " ,decode(p.gid, 0, p.goodstypename, '--') goodstypename\n" +
  7627. " ,decode(p.gid, 0, p.goodscode, '--') goodscode\n" +
  7628. " ,decode(p.gid, 0, p.usercode, '--') usercode\n" +
  7629. " ,p.codecount\n" +
  7630. " ,p.productionlineid\n" +
  7631. " ,p.procedureid\n" +
  7632. " ,p.goodstypecode2\n" +
  7633. " ,p.goodsid\n" +
  7634. " ,p.userid\n" +
  7635. " FROM (SELECT grouping_id(pd.procedureid, gt2.goodstypecode, pd.userid) gid\n" +
  7636. " ,pd.productionlineid\n" +
  7637. " ,pd.procedureid\n" +
  7638. " ,p.procedurename\n" +
  7639. " ,p.displayno\n" +
  7640. " ,gt2.goodstypecode goodstypecode2\n" +
  7641. " ,gt2.goodstypename goodstypename2\n" +
  7642. " ,gt.goodstypecode\n" +
  7643. " ,gt.goodstypename\n" +
  7644. " ,goods.goodsid\n" +
  7645. " ,goods.goodscode\n" +
  7646. " ,pd.userid\n" +
  7647. " ,pd.usercode\n" +
  7648. " ,COUNT(*) codecount\n" +
  7649. " FROM tp_pm_productiondata pd\n" +
  7650. " LEFT JOIN tp_pc_procedure p\n" +
  7651. " ON p.procedureid = pd.procedureid\n" +
  7652. " LEFT JOIN tp_mst_goods goods\n" +
  7653. " ON goods.goodsid = pd.goodsid\n" +
  7654. " LEFT JOIN tp_mst_goodstype gt\n" +
  7655. " ON gt.goodstypeid = goods.goodstypeid\n" +
  7656. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7657. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  7658. " AND gt2.accountid = gt.accountid\n" +
  7659. " WHERE pd.valueflag = '0'\n" +
  7660. " AND pd.accountid = :accountid\n" +
  7661. " 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))" +
  7662. " AND exists (Select 1 from TP_MST_UserPurview up where up.PurviewType= 9 and up.UserID = :UserID and (up.PurviewID=-1 or up.PurviewID=pd.procedureid))" +
  7663. " AND (:productionlineid IS NULL OR\n" +
  7664. " pd.productionlineid = :productionlineid)\n" +
  7665. " AND (:procedureids IS NULL OR\n" +
  7666. " instr(:procedureids, ',' || pd.procedureid || ',') > 0)\n" +
  7667. " AND (:goodstypecode IS NULL OR\n" +
  7668. " instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  7669. " AND (:goodscode IS NULL OR\n" +
  7670. " instr(goods.goodscode, :goodscode) > 0)\n" +
  7671. " AND (:PUserIDS IS NULL OR\n" +
  7672. " instr(:PUserIDS, ',' || pd.userid || ',') > 0)\n" +
  7673. " AND (:backusercode IS NULL OR\n" +
  7674. " instr(pd.BACKOUTUSERCODE, :backusercode) > 0)\n" +
  7675. " AND (:ptimebegin IS NULL OR pd.createtime >= :ptimebegin)\n" +
  7676. " AND (:ptimeend IS NULL OR pd.createtime <= :ptimeend)\n" +
  7677. " AND (:backtimebegin IS NULL OR pd.backouttime >= :backtimebegin)\n" +
  7678. " AND (:backtimeend IS NULL OR pd.backouttime <= :backtimeend)\n" +
  7679. " 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" +
  7680. " ORDER BY p.displayno\n" +
  7681. " ,gt2.goodstypecode\n" +
  7682. " ,gt.goodstypecode\n" +
  7683. " ,goods.goodscode\n" +
  7684. " ,pd.usercode) p";
  7685. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  7686. if (string.IsNullOrEmpty(se.ProcedureIDS))
  7687. {
  7688. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, null, ParameterDirection.Input));
  7689. }
  7690. else
  7691. {
  7692. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  7693. }
  7694. if (string.IsNullOrEmpty(se.UserIDS))
  7695. {
  7696. parameters.Add(new OracleParameter(":PUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  7697. }
  7698. else
  7699. {
  7700. parameters.Add(new OracleParameter(":PUserIDS", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
  7701. }
  7702. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7703. parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7704. parameters.Add(new OracleParameter(":backusercode", OracleDbType.Varchar2, se.BackUserCode, ParameterDirection.Input));
  7705. parameters.Add(new OracleParameter(":ptimebegin", OracleDbType.Date, se.PTimeStart, ParameterDirection.Input));
  7706. parameters.Add(new OracleParameter(":ptimeend", OracleDbType.Date, se.PTimeEnd, ParameterDirection.Input));
  7707. parameters.Add(new OracleParameter(":backtimebegin", OracleDbType.Date, se.BackTimeStart, ParameterDirection.Input));
  7708. parameters.Add(new OracleParameter(":backtimeend", OracleDbType.Date, se.BackTimeEnd, ParameterDirection.Input));
  7709. return sqlString;
  7710. }
  7711. /// <summary>
  7712. /// 取得RPT030109画面(撤销产品汇总表)的明细信息查询数据
  7713. /// </summary>
  7714. /// <param name="user">登录用户信息</param>
  7715. /// <param name="se">查询条件</param>
  7716. /// <returns>查询结果</returns>
  7717. public static ServiceResultEntity GetRPT030109IData(SUserInfo user, RPT030109_SE se)
  7718. {
  7719. IDBConnection conn = null;
  7720. try
  7721. {
  7722. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7723. List<OracleParameter> parameters = new List<OracleParameter>();
  7724. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030109ISQL(user, se, ref parameters));
  7725. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  7726. ServiceResultEntity sre = new ServiceResultEntity();
  7727. if (data == null || data.Rows.Count == 0)
  7728. {
  7729. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7730. return sre;
  7731. }
  7732. sre.Data = new DataSet();
  7733. sre.Data.Tables.Add(data);
  7734. return sre;
  7735. }
  7736. catch (Exception ex)
  7737. {
  7738. throw ex;
  7739. }
  7740. finally
  7741. {
  7742. if (conn != null &&
  7743. conn.ConnState == ConnectionState.Open)
  7744. {
  7745. conn.Close();
  7746. }
  7747. }
  7748. }
  7749. /// <summary>
  7750. /// 获取RPT030109画面(撤销产品汇总表)的明细信息查询sql
  7751. /// </summary>
  7752. /// <returns>sql</returns>
  7753. private static string GetRPT030109ISQL(SUserInfo user, RPT030109_SE se, ref List<OracleParameter> parameters)
  7754. {
  7755. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7756. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  7757. string sqlString =
  7758. "SELECT p.procedurename\n" +
  7759. " ,gt2.goodstypename goodstypename2\n" +
  7760. " ,gt.goodstypename\n" +
  7761. " ,goods.goodscode\n" +
  7762. " ,pd.barcode\n" +
  7763. " ,pd.usercode\n" +
  7764. " ,pd.createtime ptime\n" +
  7765. " ,pd.backoutusercode busercode\n" +
  7766. " ,pd.backouttime btime\n" +
  7767. " ,pd.groutingusercode\n" +
  7768. " ,pd.groutinglinecode\n" +
  7769. " ,pd.groutingmouldcode\n" +
  7770. " ,pd.groutingdate GDate\n" +
  7771. " FROM tp_pm_productiondata pd\n" +
  7772. " LEFT JOIN tp_pc_procedure p\n" +
  7773. " ON p.procedureid = pd.procedureid\n" +
  7774. " LEFT JOIN tp_mst_goods goods\n" +
  7775. " ON goods.goodsid = pd.goodsid\n" +
  7776. " LEFT JOIN tp_mst_goodstype gt\n" +
  7777. " ON gt.goodstypeid = goods.goodstypeid\n" +
  7778. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7779. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  7780. " AND gt2.accountid = gt.accountid\n" +
  7781. " WHERE pd.valueflag = '0'\n" +
  7782. " AND pd.accountid = :accountid\n" +
  7783. " 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))" +
  7784. " 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))" +
  7785. " AND (:productionlineid IS NULL OR\n" +
  7786. " pd.productionlineid = :productionlineid)\n" +
  7787. " AND (:procedureids IS NULL OR\n" +
  7788. " instr(:procedureids, ',' || pd.procedureid || ',') > 0)\n" +
  7789. " AND (:goodstypecode IS NULL OR\n" +
  7790. " instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  7791. " AND (:goodscode IS NULL OR instr(goods.goodscode, :goodscode) > 0)\n" +
  7792. " AND (:PUserIDS IS NULL OR\n" +
  7793. " instr(:PUserIDS, ',' || pd.userid || ',') > 0)\n" +
  7794. " AND (:backusercode IS NULL OR instr(pd.BACKOUTUSERCODE, :backusercode) > 0)\n" +
  7795. " AND (:ptimebegin IS NULL OR pd.createtime >= :ptimebegin)\n" +
  7796. " AND (:ptimeend IS NULL OR pd.createtime <= :ptimeend)\n" +
  7797. " AND (:backtimebegin IS NULL OR pd.backouttime >= :backtimebegin)\n" +
  7798. " AND (:backtimeend IS NULL OR pd.backouttime <= :backtimeend)\n" +
  7799. " AND (:puserid IS NULL OR pd.userid = :puserid)\n" +
  7800. " AND (:goodsid IS NULL OR pd.goodsid = :goodsid)\n" +
  7801. " AND (:procedureid IS NULL OR pd.procedureid = :procedureid)\n" +
  7802. " ORDER BY p.displayno\n" +
  7803. " ,gt2.goodstypename\n" +
  7804. " ,gt.goodstypename\n" +
  7805. " ,goods.goodscode\n" +
  7806. " ,pd.usercode\n" +
  7807. " ,pd.barcode\n" +
  7808. " ,pd.backoutusercode\n" +
  7809. " ,pd.backouttime";
  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. parameters.Add(new OracleParameter(":puserid", OracleDbType.Int32, se.UserID, ParameterDirection.Input));
  7835. parameters.Add(new OracleParameter(":goodsid", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  7836. parameters.Add(new OracleParameter(":procedureid", OracleDbType.Int32, se.ProcedureID, ParameterDirection.Input));
  7837. return sqlString;
  7838. }
  7839. #endregion
  7840. /// <summary>
  7841. /// 工序收发存汇总表(初始化数据)
  7842. /// </summary>
  7843. /// <param name="user"></param>
  7844. /// <returns></returns>
  7845. public static ServiceResultEntity GetRPT030111IData(SUserInfo user)
  7846. {
  7847. IDBConnection conn = null;
  7848. try
  7849. {
  7850. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7851. OracleParameter[] parameters = new OracleParameter[]
  7852. {
  7853. new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  7854. };
  7855. string sqlString =
  7856. "SELECT t.ptid, t.name\n" +
  7857. " FROM tp_mst_rpt_transfer t\n" +
  7858. " WHERE t.AccountID = :AccountID\n" +
  7859. " AND t.valueflag = '1'\n" +
  7860. " ORDER BY t.displayno desc";
  7861. DataSet data = conn.GetSqlResultToDs(sqlString, parameters);
  7862. ServiceResultEntity sre = new ServiceResultEntity();
  7863. //if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  7864. //{
  7865. // sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7866. // return sre;
  7867. //}
  7868. sre.Data = data;
  7869. return sre;
  7870. }
  7871. catch (Exception ex)
  7872. {
  7873. throw ex;
  7874. }
  7875. finally
  7876. {
  7877. if (conn != null &&
  7878. conn.ConnState == ConnectionState.Open)
  7879. {
  7880. conn.Close();
  7881. }
  7882. }
  7883. }
  7884. /// <summary>
  7885. /// 工序收发存汇总表
  7886. /// </summary>
  7887. /// <param name="user"></param>
  7888. /// <param name="se"></param>
  7889. /// <returns></returns>
  7890. public static ServiceResultEntity GetRPT030111SData(SUserInfo user, RPT030111_SE se)
  7891. {
  7892. IDBTransaction conn = null;
  7893. try
  7894. {
  7895. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  7896. conn.Connect();
  7897. OracleParameter[] parameters = new OracleParameter[]
  7898. {
  7899. new OracleParameter("in_accountid", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  7900. new OracleParameter("in_ptid", OracleDbType.Int32, se.PTID, ParameterDirection.Input),
  7901. //new OracleParameter("in_datetimeinit", OracleDbType.Date, se.GTimeInit, ParameterDirection.Input),
  7902. new OracleParameter("in_datetimebegin", OracleDbType.Date, se.GTimeStart , ParameterDirection.Input),
  7903. new OracleParameter("in_datetimeend", OracleDbType.Date, se.GTimeEnd , ParameterDirection.Input),
  7904. new OracleParameter("in_goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode , ParameterDirection.Input),
  7905. new OracleParameter("in_goodscode", OracleDbType.Varchar2, se.GoodsCode , ParameterDirection.Input),
  7906. new OracleParameter("out_data", OracleDbType.RefCursor, null, ParameterDirection.Output),
  7907. };
  7908. DataSet data = conn.ExecStoredProcedure("pro_rpt_gettransfers_sum_c", parameters);
  7909. ServiceResultEntity sre = new ServiceResultEntity();
  7910. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  7911. {
  7912. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7913. return sre;
  7914. }
  7915. //StringBuilder intdids = new StringBuilder();
  7916. //foreach (DataRow row in data.Tables[0].Rows)
  7917. //{
  7918. // if (intdids.Length > 0)
  7919. // {
  7920. // intdids.Append(", ");
  7921. // }
  7922. // intdids.Append(row["tdid"] + " AS \"" + row["name"] + "\"\n");
  7923. //}
  7924. //string sqlString =
  7925. // "WITH ttm AS\n" +
  7926. // " (SELECT *\n" +
  7927. // " FROM TMP_RPT_TECDEP_D\n" +
  7928. // " pivot(SUM(m)\n" +
  7929. // " FOR intdid IN(" + intdids + ")))\n" +
  7930. // "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" +
  7931. // " FROM TMP_RPT_TECDEP_T t\n" +
  7932. // " LEFT JOIN ttm m\n" +
  7933. // " ON m.goodsid = t.goodsid\n" +
  7934. // " AND m.outtdid = t.tecdepid\n" +
  7935. // " ORDER BY t.goodscode, t.displayno";
  7936. //data = conn.GetSqlResultToDs(sqlString);
  7937. //if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  7938. //{
  7939. // sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7940. // return sre;
  7941. //}
  7942. conn.Commit();
  7943. sre.Data = data;
  7944. return sre;
  7945. }
  7946. catch (Exception ex)
  7947. {
  7948. throw ex;
  7949. }
  7950. finally
  7951. {
  7952. if (conn != null &&
  7953. conn.ConnState == ConnectionState.Open)
  7954. {
  7955. conn.Disconnect();
  7956. }
  7957. }
  7958. }
  7959. #endregion 汇总报表
  7960. #region 公共函数
  7961. /// <summary>
  7962. /// 取得报表的查询数据源统计工序数据
  7963. /// </summary>
  7964. /// <param name="user">登录用户信息</param>
  7965. /// <param name="se">查询条件</param>
  7966. /// <returns>查询结果</returns>
  7967. public static ServiceResultEntity GetRptSourceProcedureModule(SUserInfo user, int? RptProcedureID)
  7968. {
  7969. IDBConnection conn = null;
  7970. try
  7971. {
  7972. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7973. OracleParameter[] paras = new OracleParameter[]{
  7974. new OracleParameter("in_rptProcedureId",OracleDbType.Int32,RptProcedureID,ParameterDirection.Input),
  7975. new OracleParameter("out_rptSResult",OracleDbType.RefCursor, ParameterDirection.Output),
  7976. new OracleParameter("out_rptTresult",OracleDbType.RefCursor, ParameterDirection.Output),
  7977. };
  7978. DataSet data = conn.ExecStoredProcedure("PRO_MST_GetRptProcedureBYID", paras);
  7979. ServiceResultEntity sre = new ServiceResultEntity();
  7980. if (data == null || data.Tables.Count == 0)
  7981. {
  7982. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7983. return sre;
  7984. }
  7985. sre.Data = new DataSet();
  7986. sre.Data = data;
  7987. return sre;
  7988. }
  7989. catch (Exception ex)
  7990. {
  7991. throw ex;
  7992. }
  7993. finally
  7994. {
  7995. if (conn != null &&
  7996. conn.ConnState == ConnectionState.Open)
  7997. {
  7998. conn.Close();
  7999. }
  8000. }
  8001. }
  8002. /// <summary>
  8003. /// 取得报表数据源数据
  8004. /// </summary>
  8005. /// <param name="user">登录用户信息</param>
  8006. /// <returns>查询结果</returns>
  8007. public static ServiceResultEntity GetRptProcedureModule(SUserInfo user)
  8008. {
  8009. IDBConnection conn = null;
  8010. try
  8011. {
  8012. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8013. string selSql = " select "
  8014. + " TP_MST_RptProcedure.Rptprocedureid,"
  8015. + " TP_MST_RptProcedure.Rptprocedurecode,"
  8016. + " TP_MST_RptProcedure.Rptprocedurename,"
  8017. + " TP_MST_RptProcedure.Rptproceduretype,"
  8018. + " decode(TP_MST_RptProcedure.Rptproceduretype,'A0001','出窑统计','质量统计') RptproceduretypeName,"
  8019. + " (select wm_concat(s.procedureid) sprocedureid from tp_mst_rptsprocedure s where s.rptprocedureid = TP_MST_RptProcedure.Rptprocedureid) sprocedureid,"
  8020. + " (select wm_concat(t.procedureid) tprocedureid from tp_mst_rpttprocedure t where t.rptprocedureid = TP_MST_RptProcedure.Rptprocedureid) tprocedureid,"
  8021. + " TP_MST_RptProcedure.Optimestamp "
  8022. + " from TP_MST_RptProcedure "
  8023. + " where TP_MST_RptProcedure.ValueFlag=1 "
  8024. + " and TP_MST_RptProcedure.AccountID=:accountID order by TP_MST_RptProcedure.displayno";
  8025. List<OracleParameter> parameters = new List<OracleParameter>();
  8026. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8027. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8028. ServiceResultEntity sre = new ServiceResultEntity();
  8029. if (data == null || data.Rows.Count == 0)
  8030. {
  8031. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8032. return sre;
  8033. }
  8034. sre.Data = new DataSet();
  8035. sre.Data.Tables.Add(data);
  8036. return sre;
  8037. }
  8038. catch (Exception ex)
  8039. {
  8040. throw ex;
  8041. }
  8042. finally
  8043. {
  8044. if (conn != null &&
  8045. conn.ConnState == ConnectionState.Open)
  8046. {
  8047. conn.Close();
  8048. }
  8049. }
  8050. }
  8051. /// <summary>
  8052. /// 取得窑炉数据
  8053. /// </summary>
  8054. /// <param name="user">登录用户信息</param>
  8055. /// <param name="pValue">使用标识条件</param>
  8056. /// <returns>查询结果</returns>
  8057. public static ServiceResultEntity GetKilnData(SUserInfo user, byte pValue)
  8058. {
  8059. IDBConnection conn = null;
  8060. try
  8061. {
  8062. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8063. string selSql = string.Empty;
  8064. List<OracleParameter> parameters = new List<OracleParameter>();
  8065. //根据帐套查询数据
  8066. if (pValue.ToString() == Constant.INT_IS_ONE.ToString())
  8067. {
  8068. selSql = "Select KilnID,KilnCode,KilnName,KilnType,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,UpdateUserID,OPTimeStamp "
  8069. + "from TP_MST_Kiln where AccountID = :AccountID";
  8070. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8071. }
  8072. //根据帐套和标识查询数据
  8073. else if (pValue.ToString() == Constant.INT_IS_ZERO.ToString())
  8074. {
  8075. selSql = "Select KilnID,KilnCode,KilnName,KilnType,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,UpdateUserID,OPTimeStamp "
  8076. + "from TP_MST_Kiln where valueflag = :valueflag and AccountID = :AccountID";
  8077. parameters.Add(new OracleParameter(":valueflag", OracleDbType.NVarchar2, Constant.INT_IS_ONE.ToString(), ParameterDirection.Input));
  8078. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8079. }
  8080. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8081. ServiceResultEntity sre = new ServiceResultEntity();
  8082. if (data == null || data.Rows.Count == 0)
  8083. {
  8084. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8085. return sre;
  8086. }
  8087. sre.Data = new DataSet();
  8088. sre.Data.Tables.Add(data);
  8089. return sre;
  8090. }
  8091. catch (Exception ex)
  8092. {
  8093. throw ex;
  8094. }
  8095. finally
  8096. {
  8097. if (conn != null &&
  8098. conn.ConnState == ConnectionState.Open)
  8099. {
  8100. conn.Close();
  8101. }
  8102. }
  8103. }
  8104. /// <summary>
  8105. /// 取得窑车数据
  8106. /// </summary>
  8107. /// <param name="user">登录用户信息</param>
  8108. /// <returns>查询结果</returns>
  8109. public static ServiceResultEntity GetAllKilnCarInfo(SUserInfo user)
  8110. {
  8111. IDBConnection conn = null;
  8112. try
  8113. {
  8114. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8115. string selSql = String.Empty;
  8116. List<OracleParameter> parameters = new List<OracleParameter>();
  8117. //获取窑车管理的数据
  8118. selSql = "Select KilnCarID,KilnID,KilnCarCode,KilnCarName,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,UpdateUserID,OPTimeStamp "
  8119. + "from TP_MST_KilnCar where AccountID = :AccountID";
  8120. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8121. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8122. ServiceResultEntity sre = new ServiceResultEntity();
  8123. if (data == null || data.Rows.Count == 0)
  8124. {
  8125. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8126. return sre;
  8127. }
  8128. sre.Data = new DataSet();
  8129. sre.Data.Tables.Add(data);
  8130. return sre;
  8131. }
  8132. catch (Exception ex)
  8133. {
  8134. throw ex;
  8135. }
  8136. finally
  8137. {
  8138. if (conn != null &&
  8139. conn.ConnState == ConnectionState.Open)
  8140. {
  8141. conn.Close();
  8142. }
  8143. }
  8144. }
  8145. /// <summary>
  8146. /// 取得生产线所有的工序
  8147. /// </summary>
  8148. /// <param name="user">登录用户信息</param>
  8149. /// <returns>查询结果</returns>
  8150. public static ServiceResultEntity GetRptProductionLineProcedures(SUserInfo user, int? RptProductionLineID)
  8151. {
  8152. IDBConnection conn = null;
  8153. try
  8154. {
  8155. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8156. string selSql = "select "
  8157. + " tp_pc_procedure.procedureid, "
  8158. + " tp_pc_procedure.Procedurename "
  8159. + " from "
  8160. + " ( "
  8161. + " select TP_PM_ProductionData.Procedureid "
  8162. + " from TP_PM_ProductionData "
  8163. + " where TP_PM_ProductionData.accountid = :accountID "
  8164. + " and TP_PM_ProductionData.productionlineid = :ProductionLineID "
  8165. + " group by TP_PM_ProductionData.Procedureid "
  8166. + " order by TP_PM_ProductionData.Procedureid "
  8167. + " )temp left join tp_pc_procedure "
  8168. + " on tp_pc_procedure.procedureid=temp.procedureid ";
  8169. List<OracleParameter> parameters = new List<OracleParameter>();
  8170. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8171. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, RptProductionLineID, ParameterDirection.Input));
  8172. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8173. ServiceResultEntity sre = new ServiceResultEntity();
  8174. if (data == null || data.Rows.Count == 0)
  8175. {
  8176. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8177. return sre;
  8178. }
  8179. sre.Data = new DataSet();
  8180. sre.Data.Tables.Add(data);
  8181. return sre;
  8182. }
  8183. catch (Exception ex)
  8184. {
  8185. throw ex;
  8186. }
  8187. finally
  8188. {
  8189. if (conn != null &&
  8190. conn.ConnState == ConnectionState.Open)
  8191. {
  8192. conn.Close();
  8193. }
  8194. }
  8195. }
  8196. /// <summary>
  8197. /// 取得数据字典数据
  8198. /// </summary>
  8199. /// <param name="Pvalue">显示停用标识</param>
  8200. /// <param name="dictionaryType">字典类别</param>
  8201. /// <param name="user">登录用户信息</param>
  8202. /// <returns>查询结果</returns>
  8203. public static ServiceResultEntity GetRptDictionaryData(byte Pvalue, string dictionaryType, SUserInfo user)
  8204. {
  8205. IDBConnection conn = null;
  8206. try
  8207. {
  8208. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8209. string selSql = String.Empty;
  8210. List<OracleParameter> parameters = new List<OracleParameter>();
  8211. //根据帐套获得数据字典管理的数据
  8212. if (Pvalue.ToString() == Constant.INT_IS_ONE.ToString())
  8213. {
  8214. selSql = "Select DictionaryID,DictionaryType,DictionaryValue,DisplayNo,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,"
  8215. + "UpdateUserID,OPTimeStamp from TP_MST_DataDictionary where DictionaryType = :DictionaryType and AccountID = :AccountID";
  8216. parameters.Add(new OracleParameter(":DictionaryType", OracleDbType.NVarchar2, dictionaryType, ParameterDirection.Input));
  8217. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8218. }
  8219. //根据帐套,标识获得数据字典管理的数据
  8220. else if (Pvalue.ToString() == Constant.INT_IS_ZERO.ToString())
  8221. {
  8222. selSql = "Select DictionaryID,DictionaryType,DictionaryValue,DisplayNo,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,"
  8223. + "UpdateUserID,OPTimeStamp from TP_MST_DataDictionary where valueflag = :valueflag and DictionaryType = :DictionaryType and AccountID = :AccountID";
  8224. parameters.Add(new OracleParameter(":valueflag", OracleDbType.Int32, Constant.INT_IS_ONE, ParameterDirection.Input));
  8225. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8226. parameters.Add(new OracleParameter(":DictionaryType", OracleDbType.NVarchar2, dictionaryType, ParameterDirection.Input));
  8227. }
  8228. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8229. ServiceResultEntity sre = new ServiceResultEntity();
  8230. if (data == null || data.Rows.Count == 0)
  8231. {
  8232. //sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8233. return sre;
  8234. }
  8235. sre.Data = new DataSet();
  8236. sre.Data.Tables.Add(data);
  8237. return sre;
  8238. }
  8239. catch (Exception ex)
  8240. {
  8241. throw ex;
  8242. }
  8243. finally
  8244. {
  8245. if (conn != null &&
  8246. conn.ConnState == ConnectionState.Open)
  8247. {
  8248. conn.Close();
  8249. }
  8250. }
  8251. }
  8252. #endregion 公共函数
  8253. #endregion 统一使用Se模式rviceResultEntity类
  8254. /// <summary>
  8255. /// 获取注浆次数报表
  8256. /// </summary>
  8257. /// <param name="groutingLineEntity"></param>
  8258. /// <param name="user"></param>
  8259. /// <returns></returns>
  8260. public static ServiceResultEntity GetGroutingCount(GroutingLineEntity groutingLineEntity, SUserInfo user)
  8261. {
  8262. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8263. try
  8264. {
  8265. con.Open();
  8266. OracleParameter[] paras = new OracleParameter[]{
  8267. new OracleParameter("BuildingNo",OracleDbType.NVarchar2,
  8268. groutingLineEntity.BUILDINGNO,ParameterDirection.Input),
  8269. new OracleParameter("FloorNo",OracleDbType.NVarchar2,
  8270. groutingLineEntity.FLOORNO,ParameterDirection.Input),
  8271. new OracleParameter("GroutingLineNo",OracleDbType.NVarchar2,
  8272. groutingLineEntity.GROUTINGLINENO,ParameterDirection.Input),
  8273. new OracleParameter("GroutingLineCode",OracleDbType.NVarchar2,
  8274. groutingLineEntity.GROUTINGLINECODE,ParameterDirection.Input),
  8275. new OracleParameter("GroutingLineName",OracleDbType.NVarchar2,
  8276. groutingLineEntity.GROUTINGLINENAME,ParameterDirection.Input),
  8277. new OracleParameter("GMouldTypeID",OracleDbType.Int32,
  8278. groutingLineEntity.MOULDTYPEID,ParameterDirection.Input),
  8279. new OracleParameter("remarks",OracleDbType.NVarchar2,
  8280. groutingLineEntity.REMARKS,ParameterDirection.Input),
  8281. new OracleParameter("AccountID",OracleDbType.Int32,
  8282. user.AccountID,ParameterDirection.Input),
  8283. new OracleParameter("UserId",OracleDbType.Int32,
  8284. user.UserID,ParameterDirection.Input),
  8285. new OracleParameter("PurviewType",OracleDbType.Int32,
  8286. groutingLineEntity.Purview,ParameterDirection.Input),
  8287. new OracleParameter("rs_result",OracleDbType.RefCursor,
  8288. ParameterDirection.Output),
  8289. new OracleParameter("UserCode",OracleDbType.NVarchar2,
  8290. groutingLineEntity.USERCODE,ParameterDirection.Input),
  8291. };
  8292. //调用获取符合条件的成型线信息
  8293. DataSet ds = con.ExecStoredProcedure("PRO_RPT_GetGroutingCount", paras);
  8294. ServiceResultEntity sre = new ServiceResultEntity();
  8295. if (ds == null || ds.Tables[0].Rows.Count == 0)
  8296. {
  8297. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8298. return sre;
  8299. }
  8300. sre.Data = new DataSet();
  8301. //DataTable dt=ds.Tables[0];
  8302. sre.Data.Tables.Add(ds.Tables[0].Copy());
  8303. return sre;
  8304. }
  8305. catch (Exception ex)
  8306. {
  8307. throw ex;
  8308. }
  8309. finally
  8310. {
  8311. if (con.ConnState == ConnectionState.Open)
  8312. {
  8313. con.Close();
  8314. }
  8315. }
  8316. }
  8317. #region 在产产品汇总表
  8318. /// <summary>
  8319. /// 取得RPT030105(在产产品汇总表)的汇总信息查询数据
  8320. /// </summary>
  8321. /// <param name="user">登录用户信息</param>
  8322. /// <param name="se">查询条件</param>
  8323. /// <returns>查询结果</returns>
  8324. public static ServiceResultEntity GetRPT030105Data(SUserInfo user, RPT030105_SE se)
  8325. {
  8326. IDBConnection conn = null;
  8327. try
  8328. {
  8329. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8330. List<OracleParameter> parameters = new List<OracleParameter>();
  8331. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030105SQL(user, se, ref parameters));
  8332. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  8333. ServiceResultEntity sre = new ServiceResultEntity();
  8334. if (data == null || data.Rows.Count == 0)
  8335. {
  8336. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8337. return sre;
  8338. }
  8339. sre.Data = new DataSet();
  8340. sre.Data.Tables.Add(data);
  8341. return sre;
  8342. }
  8343. catch (Exception ex)
  8344. {
  8345. throw ex;
  8346. }
  8347. finally
  8348. {
  8349. if (conn != null &&
  8350. conn.ConnState == ConnectionState.Open)
  8351. {
  8352. conn.Close();
  8353. }
  8354. }
  8355. }
  8356. /// <summary>
  8357. /// 获取RPT030105画面(产品产量汇总表)的汇总信息查询sql
  8358. /// </summary>
  8359. /// <returns>sql</returns>
  8360. private static string GetRPT030105SQL(SUserInfo user, RPT030105_SE se, ref List<OracleParameter> parameters)
  8361. {
  8362. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8363. //"select " +
  8364. //" ProcedureID," +
  8365. //" procedurecode, " +
  8366. //" decode(Usercode, '小计', '--', procedurename) procedurename, " +
  8367. //" productionlineid, " +
  8368. //" productionlinecode, " +
  8369. //" decode(Usercode, '小计', '--', productionlinename) productionlinename, " +
  8370. //" decode(ProcedureID,'总计','总计',Usercode) Usercode, " +
  8371. //" subGoodsTypecode, " +
  8372. //" decode(usercode,'小计',decode(subGoodsTypecode,'001001','大件','小件'),Goodscode)Goodscode, " +
  8373. //" Goodstypename, " +
  8374. //" InCount " +
  8375. #region
  8376. /*
  8377. "select " +
  8378. " ProcedureID," +
  8379. " procedurecode, " +
  8380. " decode(productionlinename, '总计', '--', procedurename) procedurename, " +
  8381. " productionlineid, " +
  8382. " productionlinecode, " +
  8383. " productionlinename, " +
  8384. " decode(productionlinename, '--', '--', Usercode) Usercode, " +
  8385. " decode(productionlinename, '--', null, UserID) UserID, " +
  8386. " subGoodsTypecode, " +
  8387. " Goodsid," +
  8388. " Goodscode, " +
  8389. " Goodstypename, " +
  8390. " InCount from (" +
  8391. "select " +
  8392. " ProcedureID," +
  8393. " procedurecode, " +
  8394. " decode(usercode,'合计','合计', decode(usercode,'小计','--',decode(usercode,'--','--',procedurename))) procedurename, " +
  8395. " productionlineid, " +
  8396. " productionlinecode, " +
  8397. " decode(ProcedureID,'总计','总计',decode(usercode,'小计','--',productionlinename)) productionlinename, " +
  8398. " decode(ProcedureID,'总计','--',Usercode) Usercode, " +
  8399. " decode(ProcedureID,'总计',null,Userid) Userid, " +
  8400. " subGoodsTypecode, " +
  8401. " Goodsid," +
  8402. " Goodscode, " +
  8403. " decode(usercode,'小计','小计',Goodstypename)Goodstypename, " +
  8404. " InCount " +
  8405. "from " +
  8406. "(" +
  8407. " select " +
  8408. " ProcedureID, " +
  8409. " procedurecode, " +
  8410. " procedurename, " +
  8411. " productionlineid, " +
  8412. " productionlinecode, " +
  8413. " productionlinename, " +
  8414. " decode(procedurecode,'--','合计',Usercode) Usercode, " +
  8415. " decode(procedurecode,'--',null,Userid) Userid, " +
  8416. " subGoodsTypecode," +
  8417. " Goodsid," +
  8418. " Goodscode," +
  8419. " Goodstypename, " +
  8420. " InCount " +
  8421. " from ( select " +
  8422. " decode(grouping(tp_pc_procedure.ProcedureID),1,'总计',tp_pc_procedure.ProcedureID) ProcedureID," +
  8423. " decode(grouping(tp_pc_procedure.procedurecode),1,'--',tp_pc_procedure.procedurecode) procedurecode, " +
  8424. " decode(grouping(tp_pc_procedure.procedurename),1,'--',tp_pc_procedure.procedurename) procedurename, " +
  8425. " decode(grouping(tp_pm_inproduction.productionlineid),1,'--',tp_pm_inproduction.productionlineid) productionlineid, " +
  8426. " decode(grouping(tp_pm_inproduction.productionlinecode),1,'--',tp_pm_inproduction.productionlinecode) productionlinecode, " +
  8427. " decode(grouping(tp_pm_inproduction.productionlinename),1,'--',tp_pm_inproduction.productionlinename) productionlinename, " +
  8428. " decode(grouping(TP_MST_User.Usercode),1,'小计',TP_MST_User.Usercode) Usercode," +
  8429. " decode(grouping(TP_MST_User.Userid),1,null,TP_MST_User.Userid) Userid," +
  8430. " decode(grouping(substr(TP_MST_GoodsType.Goodstypecode,0,6)),1,'--',substr(TP_MST_GoodsType.Goodstypecode,0,6)) subGoodsTypecode," +
  8431. " decode(grouping(TP_MST_Goods.Goodscode),1,'--',TP_MST_Goods.Goodscode) Goodscode," +
  8432. " decode(grouping(TP_MST_Goods.Goodsid),1,'--',TP_MST_Goods.Goodsid) Goodsid," +
  8433. " decode(grouping(TP_MST_GoodsType.Goodstypename),1,'--',TP_MST_GoodsType.Goodstypename) Goodstypename," +
  8434. " count(barcode) as InCount " +
  8435. " from tp_pm_inproduction " +
  8436. " left join tp_pc_procedure" +
  8437. " on tp_pm_inproduction.FlowProcedureID=tp_pc_procedure.ProcedureID" +
  8438. " 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" +
  8439. " Where 1=1 " +
  8440. " and tp_pm_inproduction.AccountID=:AccountID and tp_pm_inproduction.valueflag=1";
  8441. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  8442. {
  8443. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1";
  8444. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1";
  8445. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  8446. }
  8447. if (!string.IsNullOrEmpty(se.LineIDS))
  8448. {
  8449. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||tp_pm_inproduction.ProductionLineId||',')>0 ";
  8450. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  8451. }
  8452. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  8453. {
  8454. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||tp_pm_inproduction.FlowProcedureId||',')>0 ";
  8455. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  8456. }
  8457. if (!string.IsNullOrEmpty(se.GoodsCode))
  8458. {
  8459. selSql = selSql + " AND instr(','||:GoodsCode||',',','||tp_pm_inproduction.goodsCode||',')>0 ";
  8460. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  8461. }
  8462. selSql = selSql +
  8463. "group by " +
  8464. " rollup(tp_pc_procedure.ProcedureID, " +
  8465. " tp_pc_procedure.procedurecode, " +
  8466. " tp_pc_procedure.procedurename, " +
  8467. " tp_pm_inproduction.productionlineid, " +
  8468. " tp_pm_inproduction.productionlinecode, " +
  8469. " tp_pm_inproduction.productionlinename, " +
  8470. " substr(TP_MST_GoodsType.Goodstypecode,0,6), " +
  8471. " TP_MST_User.Usercode," +
  8472. " TP_MST_Goods.Goodscode, " +
  8473. " TP_MST_User.UserID," +
  8474. " TP_MST_Goods.GoodsID, " +
  8475. " TP_MST_GoodsType.Goodstypename)) temp ) temp2 " +
  8476. "where 1=1 " +
  8477. "and (Goodstypename!='--')" +
  8478. "or (Goodstypename='--' and UserCode='小计' and subGoodsTypecode!='--') " +
  8479. "or (Goodstypename='--' and UserCode='合计') " +
  8480. "or (Goodstypename='--' and UserCode='总计') )";
  8481. */
  8482. #endregion
  8483. string sqlString = "select t.productionlineid\n" +
  8484. " ,t.productionlinecode\n" +
  8485. " ,decode(gid\n" +
  8486. " ,15\n" +
  8487. " ,'总计【' || t.productionlinename || '】'\n" +
  8488. " ,t.productionlinename) productionlinename\n" +
  8489. " ,t.ProcedureID\n" +
  8490. " ,t.procedurecode\n" +
  8491. " ,decode(gid, 3, '合计【' || t.procedurename || '】', t.procedurename) procedurename\n" +
  8492. " ,t.Goodstypeid2\n" +
  8493. " ,t.Goodstypecode2\n" +
  8494. " ,decode(gid, 1, '小计【' || t.Goodstypename2 || '】', t.Goodstypename2) Goodstypename2\n" +
  8495. " ,t.Goodsid\n" +
  8496. " ,t.Goodscode\n" +
  8497. " ,t.InCount\n" +
  8498. " from (select grouping_id(inp.productionlineid\n" +
  8499. " ,inp.ProcedureID\n" +
  8500. " ,gt2.Goodstypeid\n" +
  8501. " ,inp.Goodsid) gid\n" +
  8502. " ,inp.productionlineid\n" +
  8503. " ,pline.productionlinecode\n" +
  8504. " ,pline.productionlinename\n" +
  8505. " ,inp.ProcedureID\n" +
  8506. " ,p.procedurecode\n" +
  8507. " ,p.procedurename\n" +
  8508. " ,gt2.GoodstypeID GoodstypeID2\n" +
  8509. " ,gt2.Goodstypecode Goodstypecode2\n" +
  8510. " ,gt2.Goodstypename Goodstypename2\n" +
  8511. " ,inp.Goodsid\n" +
  8512. " ,g.Goodscode\n" +
  8513. " ,count(barcode) as InCount\n" +
  8514. " from tp_pm_inproduction inp\n" +
  8515. " inner join tp_pc_procedure p\n" +
  8516. " on inp.ProcedureID = p.ProcedureID\n" +
  8517. " inner join tp_pc_productionline pline\n" +
  8518. " on pline.productionlineid = inp.productionlineid\n" +
  8519. " inner join TP_MST_User u\n" +
  8520. " on inp.userid = u.Userid\n" +
  8521. " inner join TP_MST_Goods g\n" +
  8522. " on inp.goodsid = g.Goodsid\n" +
  8523. " inner join TP_MST_GoodsType gt\n" +
  8524. " on g.GoodsTypeID = gt.GoodsTypeID\n" +
  8525. " inner join TP_MST_GoodsType gt2\n" +
  8526. " on gt.accountid = gt2.accountid\n" +
  8527. " and substr(gt.Goodstypecode, 0, 6) = gt2.Goodstypecode\n" +
  8528. " where inp.AccountID = 1\n" +
  8529. " and inp.valueflag = '1'\n";
  8530. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  8531. {
  8532. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1";
  8533. sqlString += " AND instr(gt.GOODSTYPECode,:GoodsTypeIDS)=1";
  8534. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  8535. }
  8536. if (!string.IsNullOrEmpty(se.LineIDS))
  8537. {
  8538. sqlString += " AND instr(','||:ProductionLineIDS||',',','||inp.ProductionLineId||',')>0 ";
  8539. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  8540. }
  8541. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  8542. {
  8543. sqlString += " AND instr(','||:ProcedureIDS||',',','||inp.ProcedureId||',')>0 ";
  8544. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  8545. }
  8546. if (!string.IsNullOrEmpty(se.GoodsCode))
  8547. {
  8548. sqlString += " AND instr(','||:GoodsCode||',',','||inp.goodsCode||',')>0 ";
  8549. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  8550. }
  8551. 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";
  8552. return sqlString;
  8553. }
  8554. /// <summary>
  8555. /// 取得RPT030105(在产产品汇总表)的汇总信息查询数据
  8556. /// </summary>
  8557. /// <param name="user">登录用户信息</param>
  8558. /// <param name="se">查询条件</param>
  8559. /// <returns>查询结果</returns>
  8560. public static ServiceResultEntity GetRPT030105IData(SUserInfo user, RPT030105_SE se)
  8561. {
  8562. IDBConnection conn = null;
  8563. try
  8564. {
  8565. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8566. List<OracleParameter> parameters = new List<OracleParameter>();
  8567. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030105ISQL(user, se, ref parameters));
  8568. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8569. if (se != null)
  8570. {
  8571. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  8572. {
  8573. //sql.Append(" AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1");
  8574. sql.Append(" AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1");
  8575. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  8576. }
  8577. if (!string.IsNullOrEmpty(se.LineIDS))
  8578. {
  8579. sql.Append(" AND instr(','||:ProductionLineIDS||',',','||tp_pm_inproduction.ProductionLineId||',')>0 ");
  8580. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  8581. }
  8582. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  8583. {
  8584. sql.Append(" AND instr(','||:ProcedureIDS||',',','||tp_pm_inproduction.FlowProcedureId||',')>0 ");
  8585. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  8586. }
  8587. if (!string.IsNullOrEmpty(se.GoodsCode))
  8588. {
  8589. sql.Append(" AND instr(','||:GoodsCode||',',','||tp_pm_inproduction.goodsCode||',')>0 ");
  8590. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  8591. }
  8592. // 总单点击查询用
  8593. if (se.GoodsID.HasValue)
  8594. {
  8595. sql.Append(" AND tp_pm_inproduction.Goodsid = :GoodsID ");
  8596. parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  8597. }
  8598. if (se.UserID.HasValue)
  8599. {
  8600. sql.Append(" AND A.userid = :userid ");
  8601. parameters.Add(new OracleParameter(":userid", OracleDbType.Int32, se.UserID, ParameterDirection.Input));
  8602. }
  8603. }
  8604. sql.Append(" order by TP_PM_InProduction.UpdateTime desc");
  8605. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  8606. ServiceResultEntity sre = new ServiceResultEntity();
  8607. if (data == null || data.Rows.Count == 0)
  8608. {
  8609. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8610. return sre;
  8611. }
  8612. sre.Data = new DataSet();
  8613. sre.Data.Tables.Add(data);
  8614. return sre;
  8615. }
  8616. catch (Exception ex)
  8617. {
  8618. throw ex;
  8619. }
  8620. finally
  8621. {
  8622. if (conn != null &&
  8623. conn.ConnState == ConnectionState.Open)
  8624. {
  8625. conn.Close();
  8626. }
  8627. }
  8628. }
  8629. /// <summary>
  8630. /// 获取RPT030105画面(产品产量汇总表)的汇总信息查询sql
  8631. /// </summary>
  8632. /// <returns>sql</returns>
  8633. private static string GetRPT030105ISQL(SUserInfo user, RPT030105_SE se, ref List<OracleParameter> parameters)
  8634. {
  8635. string selSql =
  8636. "SELECT " +
  8637. " TP_PM_InProduction.BarCode, " +
  8638. " TP_PM_InProduction.GoodsID,TP_PM_InProduction.GoodsCode, " +
  8639. " TP_PM_InProduction.GoodsName, " +
  8640. " TP_PM_InProduction.Userid,A.USERNAME as UserName,A.USERCode as UserCode, " +
  8641. " TP_PM_InProduction.ProductionLineID, " +
  8642. " TP_PM_InProduction.ProductionLineCode, " +
  8643. " TP_PM_InProduction.ProductionLineName, " +
  8644. " TP_PM_InProduction.ModelType, " +
  8645. " decode(TP_PM_InProduction.inscrapflag , '1', '待审核的报废品' , '正常') as inscrapflag, " +
  8646. //" decode(TP_PM_InProduction.IsPublicBody, '1', '是' , '否') as IsPublicBody, " +
  8647. //" decode(TP_PM_InProduction.IsReFire, '1', '是' , '否') as IsReFire, " +
  8648. " TP_PM_InProduction.IsPublicBody, " +
  8649. " decode(TP_PM_InProduction.IsReFire, '6', '1' , '0') as IsReFire, " +
  8650. " decode(TP_PM_InProduction.CanManyTimes, '1', '能' , '不能') as CanManyTimes, " +
  8651. " decode(TP_PM_InProduction.ProcedureModel, '1', '计件模型' , '检验模型') as ProcedureModel, " +
  8652. " TP_PM_InProduction.GroutingDailyID, " +
  8653. " TP_PM_InProduction.GroutingDailyDetailID, " +
  8654. " TP_PM_InProduction.GroutingDate, " +
  8655. " TP_PM_InProduction.GroutingLineID, " +
  8656. " TP_PM_InProduction.GroutingLineCode, " +
  8657. " TP_PM_InProduction.GroutingLineName, " +
  8658. " TP_PM_InProduction.ProcedureID CompleteProcedureID, " +
  8659. " D.ProcedureName as CompleteProcedureName, " +
  8660. " TP_PM_InProduction.GMouldTypeID, " +
  8661. " TP_MST_GMouldType.GMOULDTYPENAME as GMouldTypeName, " +
  8662. " TP_PM_InProduction.GroutingLineDetailID, " +
  8663. " TP_PM_InProduction.GroutingMouldCode, " +
  8664. " TP_PM_InProduction.SPECIALREPAIRFLAG, " +
  8665. " TP_PM_InProduction.GROUTINGUSERCODE, " +
  8666. " TP_PM_GroutingDailyDetail.GROUTINGCOUNT, " +
  8667. " TP_PM_InProduction.Remarks, " +
  8668. " TP_PM_GroutingDailyDetail.glazingroom," +
  8669. " TP_PM_InProduction.GoodsLevelID,TP_MST_GoodsLevel.GOODSLEVELNAME, " +
  8670. " TP_PM_InProduction.GoodsLevelTypeID,TP_SYS_GoodsLevelType.GOODSLEVELTYPENAME, " +
  8671. " TP_PM_InProduction.AccountID,TP_PM_InProduction.ValueFlag, " +
  8672. " TP_PM_InProduction.CreateTime,TP_PM_InProduction.CreateUserID,B.USERNAME as CreateUserName, " +
  8673. " TP_PM_InProduction.PROCEDURETIME AS UpdateTime,TP_PM_InProduction.UpdateUserID,C.USERNAME as UpdateUserName, " +
  8674. " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName " +
  8675. "FROM TP_PM_InProduction " +
  8676. " inner join TP_MST_User A on A.UserID=TP_PM_InProduction.Userid " +
  8677. " inner join TP_MST_User B on B.UserID=TP_PM_InProduction.CreateUserID " +
  8678. " inner join TP_MST_User C on C.UserID=TP_PM_InProduction.UpdateUserID " +
  8679. " inner join TP_PC_Procedure D on D.PROCEDUREID=TP_PM_InProduction.ProcedureID " +
  8680. " inner join TP_MST_GMouldType on TP_MST_GMouldType.GMouldTypeID=TP_PM_InProduction.GMouldTypeID " +
  8681. " inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.ProcedureModelTypeID=TP_PM_InProduction.ModelType " +
  8682. " inner join TP_PM_GroutingDaily on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_InProduction.GroutingDailyID " +
  8683. " inner join TP_PM_GroutingDailyDetail on TP_PM_GroutingDailyDetail.Groutingdailydetailid=TP_PM_InProduction.GroutingDailyDetailID " +
  8684. " inner join TP_PC_GroutingLineDetail on TP_PC_GroutingLineDetail.Groutinglinedetailid=TP_PM_InProduction.GroutingLineDetailID " +
  8685. " inner join TP_MST_Account on TP_MST_Account.Accountid=TP_PM_InProduction.Accountid " +
  8686. " left join TP_MST_GoodsLevel on TP_MST_GoodsLevel.GoodsLevelID=TP_PM_InProduction.GoodsLevelID " +
  8687. " left join TP_SYS_GoodsLevelType on TP_SYS_GoodsLevelType.GoodsLevelTypeID=TP_PM_InProduction.GoodsLevelTypeID " +
  8688. " left join TP_MST_Logo on TP_PM_InProduction.logoid=TP_MST_Logo.logoid " +
  8689. " left join TP_MST_Goods on tp_pm_inproduction.goodsid=TP_MST_Goods.Goodsid " +
  8690. " left join TP_MST_GoodsType on TP_MST_Goods.GoodsTypeID=TP_MST_GoodsType.GoodsTypeID" +
  8691. " Where 1=1 and TP_PM_InProduction.ValueFlag = 1 " +
  8692. " and TP_PM_InProduction.AccountID=:AccountID ";
  8693. return selSql;
  8694. }
  8695. #endregion
  8696. /// <summary>
  8697. /// 取得RPT030106(成检缺陷汇总表)的汇总信息查询数据
  8698. /// </summary>
  8699. /// <param name="user">登录用户信息</param>
  8700. /// <param name="se">查询条件</param>
  8701. /// <returns>查询结果</returns>
  8702. public static ServiceResultEntity GetRPT030106Data(SUserInfo user, RPT030106_SE se)
  8703. {
  8704. IDBConnection conn = null;
  8705. try
  8706. {
  8707. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8708. List<OracleParameter> parameters = new List<OracleParameter>();
  8709. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106SQL(user, se, ref parameters));
  8710. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  8711. ServiceResultEntity sre = new ServiceResultEntity();
  8712. if (data == null || data.Rows.Count == 0)
  8713. {
  8714. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8715. return sre;
  8716. }
  8717. sre.Data = new DataSet();
  8718. sre.Data.Tables.Add(data);
  8719. return sre;
  8720. }
  8721. catch (Exception ex)
  8722. {
  8723. throw ex;
  8724. }
  8725. finally
  8726. {
  8727. if (conn != null &&
  8728. conn.ConnState == ConnectionState.Open)
  8729. {
  8730. conn.Close();
  8731. }
  8732. }
  8733. }
  8734. /// <summary>
  8735. /// 获取RPT030106画面(成检缺陷汇总表)的汇总信息查询sql
  8736. /// </summary>
  8737. /// <returns>sql</returns>
  8738. private static string GetRPT030106SQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
  8739. {
  8740. #region
  8741. //string selSql = "";
  8742. //parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8743. //selSql = selSql +
  8744. // "select " +
  8745. // " DefectProcedureID," +
  8746. // " DefectProcedureCode, " +
  8747. // " decode(DefectProcedureID, '总计', '--', decode(DefectCode, '小计', decode(DefectProcedureName, '', '', '--'), DefectProcedureName)) DefectProcedureName," +
  8748. // " ProductionLineID, " +
  8749. // " ProductionLineCode," +
  8750. // " decode(DefectProcedureID, '总计', '总计', decode(DefectCode, '小计', '--', ProductionLineName)) ProductionLineName, " +
  8751. // " ProcedureID, " +
  8752. // " ProcedureCode," +
  8753. // " decode(DefectCode, '小计', '--', ProcedureName) ProcedureName," +
  8754. // " DefectCode, " +
  8755. // " DefectName, " +
  8756. // " DefectTypeName, " +
  8757. // " Userid," +
  8758. // " Usercode," +
  8759. // " Username," +
  8760. // " Goodstypename," +
  8761. // " Goodsid," +
  8762. // " Goodscode," +
  8763. // " Goodsname," +
  8764. // " InCount from (" +
  8765. // "select " +
  8766. // " DefectProcedureID," +
  8767. // " DefectProcedureCode, " +
  8768. // " decode(DefectProcedureCode, '--', '合计', DefectProcedureName) DefectProcedureName, " +
  8769. // " ProductionLineID, " +
  8770. // " ProductionLineCode, " +
  8771. // " ProductionLineName, " +
  8772. // " ProcedureID, " +
  8773. // " ProcedureCode, " +
  8774. // " ProcedureName, " +
  8775. // " decode(DefectName, '--', decode(DefectCode, '--', '--', '小计'), DefectCode) DefectCode, " +
  8776. // " DefectName, " +
  8777. // " DefectTypeName, " +
  8778. // " Userid, " +
  8779. // " Usercode, " +
  8780. // " Username, " +
  8781. // " Goodstypename, " +
  8782. // " Goodsid, " +
  8783. // " Goodscode, " +
  8784. // " Goodsname, " +
  8785. // " InCount " +
  8786. // "from " +
  8787. // "(" +
  8788. // " select " +
  8789. // " decode(grouping(TP_PM_Defect.DefectProcedureID),1,'总计',TP_PM_Defect.DefectProcedureID) DefectProcedureID, " +
  8790. // " decode(grouping(TP_PM_Defect.DefectProcedureCode),1,'--',TP_PM_Defect.DefectProcedureCode) DefectProcedureCode, " +
  8791. // " decode(grouping(TP_PM_Defect.DefectProcedureName),1,'--',TP_PM_Defect.DefectProcedureName) DefectProcedureName, " +
  8792. // " decode(grouping(TP_PM_Defect.ProductionLineID),1,'--',TP_PM_Defect.ProductionLineID) ProductionLineID, " +
  8793. // " decode(grouping(TP_PM_Defect.ProductionLineCode),1,'--',TP_PM_Defect.ProductionLineCode) ProductionLineCode, " +
  8794. // " decode(grouping(TP_PM_Defect.ProductionLineName),1,'--',TP_PM_Defect.ProductionLineName) ProductionLineName, " +
  8795. // " decode(grouping(TP_PM_Defect.ProcedureID),1,'--',TP_PM_Defect.ProcedureID) ProcedureID, " +
  8796. // " decode(grouping(TP_PM_Defect.ProcedureCode),1,'--',TP_PM_Defect.ProcedureCode) ProcedureCode," +
  8797. // " decode(grouping(TP_PM_Defect.ProcedureName),1,'--',TP_PM_Defect.ProcedureName) ProcedureName," +
  8798. // " decode(grouping(TP_PM_Defect.DefectCode),1,'--',TP_PM_Defect.DefectCode) DefectCode, " +
  8799. // " decode(grouping(TP_PM_Defect.DefectName),1,'--',TP_PM_Defect.DefectName) DefectName, " +
  8800. // " decode(grouping(TP_MST_DefectType.DefectTypeName),1,'--',TP_MST_DefectType.DefectTypeName) DefectTypeName, " +
  8801. // " decode(grouping(TP_PM_Defect.Userid),1,'--',TP_PM_Defect.Userid) Userid, " +
  8802. // " decode(grouping(TP_PM_Defect.Usercode),1,'--',TP_PM_Defect.Usercode) Usercode, " +
  8803. // " decode(grouping(TP_PM_Defect.Username),1,'--',TP_PM_Defect.Username) Username, " +
  8804. // " decode(grouping(TP_MST_GoodsType.Goodstypename),1,'--',TP_MST_GoodsType.Goodstypename) Goodstypename, " +
  8805. // " decode(grouping(TP_PM_Defect.Goodsid),1,'--',TP_PM_Defect.Goodsid) Goodsid, " +
  8806. // " decode(grouping(TP_PM_Defect.Goodscode),1,'--',TP_PM_Defect.Goodscode) Goodscode, " +
  8807. // " decode(grouping(TP_PM_Defect.Goodsname),1,'--',TP_PM_Defect.Goodscode) Goodsname, " +
  8808. // " count(TP_PM_Defect.barcode) as InCount " +
  8809. // " from TP_PM_Defect " +
  8810. // " left join tp_pc_procedure on TP_PM_Defect.ProcedureID=tp_pc_procedure.ProcedureID " +
  8811. // " left join TP_MST_Goods on TP_PM_Defect.Goodsid=TP_MST_Goods.Goodsid" +
  8812. // " left join TP_MST_GoodsType on TP_MST_Goods.GoodsTypeID = TP_MST_GoodsType.GoodsTypeID" +
  8813. // " left join TP_MST_Defect on TP_PM_Defect.DefectID=TP_MST_Defect.DefectID" +
  8814. // " left join TP_MST_DefectType on TP_MST_Defect.DefectTypeID=TP_MST_DefectType.DefectTypeID" +
  8815. // " left join TP_PM_ProductionData on TP_PM_ProductionData.ProductionDataID=TP_PM_Defect.ProductionDataID" +
  8816. // " Where TP_PM_Defect.valueflag=1 and tp_pc_procedure.ModelType=-1" +
  8817. // " and TP_PM_Defect.AccountID=:AccountID ";
  8818. //if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  8819. //{
  8820. // selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeCode)=1 ";
  8821. // parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  8822. //}
  8823. //if (!string.IsNullOrEmpty(se.LineIDS))
  8824. //{
  8825. // selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_Defect.ProductionLineId||',')>0 ";
  8826. // parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  8827. //}
  8828. //if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  8829. //{
  8830. // //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  8831. // selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 ) ";
  8832. // parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  8833. //}
  8834. //else
  8835. //{
  8836. // // modify by chenxy :没有选择时,应全查询出来。
  8837. // //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  8838. //}
  8839. //if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  8840. //{
  8841. // selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_Defect.ProcedureID||',')>0 ";
  8842. // parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  8843. //}
  8844. //if (!string.IsNullOrEmpty(se.KilnCode))
  8845. //{
  8846. // selSql = selSql + " AND instr(tp_pm_productiondata.KilnCode,:KilnCode) >0 ";
  8847. // parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  8848. //}
  8849. //if (!string.IsNullOrEmpty(se.GoodsIDS))
  8850. //{
  8851. // selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_Defect.Goodsid||',')>0 ";
  8852. // parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  8853. //}
  8854. //if (!string.IsNullOrEmpty(se.GoodsCode))
  8855. //{
  8856. // selSql = selSql + " AND instr(TP_PM_Defect.goodsCode,:GoodsCode) >0 ";
  8857. // parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  8858. //}
  8859. //if (!string.IsNullOrEmpty(se.DefectUserCode))
  8860. //{
  8861. // selSql = selSql + " AND instr(TP_PM_Defect.DefectUserCode,:DefectUserCode) >0 ";
  8862. // parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  8863. //}
  8864. //if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  8865. //{
  8866. // selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||TP_MST_DefectType.DefectTypeID||',')>0 ";
  8867. // parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  8868. //}
  8869. //if (!string.IsNullOrEmpty(se.DefectCode))
  8870. //{
  8871. // selSql = selSql + " AND instr(TP_PM_Defect.DefectCode,:DefectCode) >0 ";
  8872. // parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  8873. //}
  8874. //if (!string.IsNullOrEmpty(se.DefectName))
  8875. //{
  8876. // selSql = selSql + " AND instr(TP_PM_Defect.DefectName,:DefectName) >0";
  8877. // parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  8878. //}
  8879. //if (!string.IsNullOrEmpty(se.CheckUserCode))
  8880. //{
  8881. // selSql = selSql + " AND instr(TP_PM_Defect.UserCode,:UserCode) >0";
  8882. // parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  8883. //}
  8884. //if (se.CreateTimeStart.HasValue)
  8885. //{
  8886. // selSql = selSql + " AND TP_PM_Defect.CreateTime>= :CreateTimeStart ";
  8887. // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  8888. //}
  8889. //if (se.CreateTimeEnd.HasValue)
  8890. //{
  8891. // selSql = selSql + " AND TP_PM_Defect.CreateTime<= :CreateTimeEnd ";
  8892. // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  8893. //}
  8894. //selSql = selSql +
  8895. // "group by " +
  8896. // " rollup(TP_PM_Defect.DefectProcedureID, " +
  8897. // " TP_PM_Defect.DefectProcedureCode, " +
  8898. // " TP_PM_Defect.DefectProcedureName, " +
  8899. // " TP_PM_Defect.ProductionLineID, " +
  8900. // " TP_PM_Defect.ProductionLineCode, " +
  8901. // " TP_PM_Defect.ProductionLineName, " +
  8902. // " TP_PM_Defect.ProcedureID, " +
  8903. // " TP_PM_Defect.ProcedureCode," +
  8904. // " TP_PM_Defect.ProcedureName, " +
  8905. // " TP_PM_Defect.DefectCode, " +
  8906. // " TP_PM_Defect.DefectName, " +
  8907. // " TP_MST_DefectType.DefectTypeName, " +
  8908. // " TP_PM_Defect.Userid, " +
  8909. // " TP_PM_Defect.Usercode, " +
  8910. // " TP_PM_Defect.Username, " +
  8911. // " TP_MST_GoodsType.Goodstypename, " +
  8912. // " TP_PM_Defect.Goodsid, " +
  8913. // " TP_PM_Defect.Goodscode, " +
  8914. // " TP_PM_Defect.Goodsname " +
  8915. // " )) temp ) temp2 " +
  8916. // "where 1=1 " +
  8917. // "and ((Goodsname!='--' )" +
  8918. // "or (Goodsname='--' and defectcode='小计')" +
  8919. // "or (Goodsname='--' and DefectProcedurename='合计') " +
  8920. // "or (Goodsname='--' and DefectProcedureID='总计'))";
  8921. //////----------------------
  8922. ////if (!string.IsNullOrEmpty(se.CompleteProcedureIDS))
  8923. ////{
  8924. //// selSql = selSql + @" AND exists(select 1 from tp_pm_productiondata where (instr(','||:CompleteProcedureIDS||',',','||ProcedureID||',')>0 ";
  8925. //// parameters.Add(new OracleParameter(":CompleteProcedureIDS", OracleDbType.NVarchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  8926. //// selSql = selSql + " AND TP_PM_ProductionData.CreateTime>= :CompleteCreateTimeStart ";
  8927. //// parameters.Add(new OracleParameter(":CompleteCreateTimeStart", OracleDbType.Date, se.CompleteCreateTimeStart.Value, ParameterDirection.Input));
  8928. //// selSql = selSql + " AND TP_PM_ProductionData.CreateTime<= :CompleteCreateTimeEnd )) ";
  8929. //// parameters.Add(new OracleParameter(":CompleteCreateTimeEnd", OracleDbType.Date, se.CompleteCreateTimeEnd.Value, ParameterDirection.Input));
  8930. ////}
  8931. //////----------------------
  8932. //return selSql;
  8933. #endregion
  8934. string selSql =
  8935. "SELECT t.ProductionLineID\n" +
  8936. " ,t.ProductionLineCode\n" +
  8937. " ,decode(t.gid, 31, '总计', 0, t.ProductionLineName, '--') ProductionLineName\n" +
  8938. " ,t.ProcedureID\n" +
  8939. " ,t.ProcedureCode\n" +
  8940. " ,decode(t.gid, 0, t.ProcedureName, '--') ProcedureName\n" +
  8941. " ,t.DefectProcedureID\n" +
  8942. " ,t.DefectProcedureCode\n" +
  8943. " ,decode(t.gid,\n" +
  8944. " 7,\n" +
  8945. " '合计【' || t.DefectProcedureName || '】',\n" +
  8946. " 0,\n" +
  8947. " t.DefectProcedureName,\n" +
  8948. " '--') DefectProcedureName\n" +
  8949. " ,decode(t.gid, 0, t.DefectCode, '--') DefectCode\n" +
  8950. " ,decode(t.gid,\n" +
  8951. " 3,\n" +
  8952. " '小计【[' || t.DefectCode || ']' || t.DefectName || '】',\n" +
  8953. " 0,\n" +
  8954. " t.DefectName,\n" +
  8955. " '--') DefectName\n" +
  8956. " ,decode(t.gid, 0, t.DefectTypeName, '--') DefectTypeName\n" +
  8957. " --,decode(t.gid, 0, t.Userid, '--') Userid\n" +
  8958. " ,t.Userid\n" +
  8959. " ,decode(t.gid, 0, t.Usercode, '--') Usercode\n" +
  8960. " ,decode(t.gid, 0, t.Username, '--') Username\n" +
  8961. " ,decode(t.gid, 0, t.Goodstypename, '--') Goodstypename\n" +
  8962. " --,decode(t.gid, 0, t.Goodsid, '--') Goodsid\n" +
  8963. " ,t.Goodsid\n" +
  8964. " ,decode(t.gid, 0, t.Goodscode, '--') Goodscode\n" +
  8965. " ,decode(t.gid, 0, t.Goodsname, '--') Goodsname\n" +
  8966. " ,t.InCount\n" +
  8967. " FROM (SELECT grouping_id(pmd.ProductionLineID,\n" +
  8968. " pmd.DefectProcedureID,\n" +
  8969. " pmd.DefectCode,\n" +
  8970. " pmd.userid,\n" +
  8971. " pmd.goodsid) gid\n" +
  8972. " ,pmd.ProductionLineID\n" +
  8973. " ,pmd.ProductionLineCode\n" +
  8974. " ,pmd.ProductionLineName\n" +
  8975. " ,pmd.ProcedureID\n" +
  8976. " ,pmd.ProcedureCode\n" +
  8977. " ,pmd.ProcedureName\n" +
  8978. " ,pmd.DefectProcedureID\n" +
  8979. " ,pmd.DefectProcedureCode\n" +
  8980. " ,pmd.DefectProcedureName\n" +
  8981. " ,pmd.DefectCode\n" +
  8982. " ,pmd.DefectName\n" +
  8983. " ,dt.DefectTypeName\n" +
  8984. " ,pmd.Userid\n" +
  8985. " ,pmd.Usercode\n" +
  8986. " ,pmd.Username\n" +
  8987. " ,gt.Goodstypename\n" +
  8988. " ,pmd.Goodsid\n" +
  8989. " ,pmd.Goodscode\n" +
  8990. " ,pmd.Goodsname\n" +
  8991. " ,COUNT(pmd.barcode) InCount\n" +
  8992. " FROM tp_pm_defect pmd\n" +
  8993. " LEFT JOIN TP_MST_Goods g\n" +
  8994. " ON pmd.Goodsid = g.Goodsid\n" +
  8995. " LEFT JOIN TP_MST_GoodsType gt\n" +
  8996. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  8997. " LEFT JOIN TP_MST_Defect mstd\n" +
  8998. " ON pmd.DefectID = mstd.DefectID\n" +
  8999. " LEFT JOIN TP_MST_DefectType dt\n" +
  9000. " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
  9001. " INNER JOIN tp_pm_productiondata pd\n" +
  9002. " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
  9003. " -- 交接工序\n" +
  9004. " INNER JOIN tp_pm_productiondata hopd\n" +
  9005. " ON hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  9006. " AND hopd.valueflag = '1'\n" +
  9007. " AND hopd.barcode = pd.barcode\n" +
  9008. " AND hopd.kilncarbatchno = pd.kilncarbatchno\n" +
  9009. " WHERE pmd.valueflag = '1'\n" +
  9010. " AND pd.ModelType = -1\n" +
  9011. " AND pmd.AccountID = :AccountID\n";
  9012. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  9013. parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
  9014. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  9015. {
  9016. selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
  9017. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  9018. }
  9019. if (!string.IsNullOrEmpty(se.LineIDS))
  9020. {
  9021. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
  9022. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  9023. }
  9024. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  9025. {
  9026. //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  9027. selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
  9028. parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  9029. }
  9030. else
  9031. {
  9032. // modify by chenxy :没有选择时,应全查询出来。
  9033. //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  9034. }
  9035. if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  9036. {
  9037. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
  9038. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  9039. }
  9040. if (!string.IsNullOrEmpty(se.KilnCode))
  9041. {
  9042. selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
  9043. parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  9044. }
  9045. if (!string.IsNullOrEmpty(se.GoodsIDS))
  9046. {
  9047. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
  9048. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  9049. }
  9050. if (!string.IsNullOrEmpty(se.GoodsCode))
  9051. {
  9052. selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
  9053. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  9054. }
  9055. if (!string.IsNullOrEmpty(se.DefectUserCode))
  9056. {
  9057. selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
  9058. parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  9059. }
  9060. if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  9061. {
  9062. selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
  9063. parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  9064. }
  9065. if (!string.IsNullOrEmpty(se.DefectCode))
  9066. {
  9067. selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
  9068. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  9069. }
  9070. if (!string.IsNullOrEmpty(se.DefectName))
  9071. {
  9072. selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
  9073. parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  9074. }
  9075. if (!string.IsNullOrEmpty(se.CheckUserCode))
  9076. {
  9077. selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
  9078. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  9079. }
  9080. if (se.CreateTimeStart.HasValue)
  9081. {
  9082. selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
  9083. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9084. }
  9085. if (se.CreateTimeEnd.HasValue)
  9086. {
  9087. selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
  9088. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9089. }
  9090. // 交接时间
  9091. if (se.HandOverTimeStart.HasValue)
  9092. {
  9093. selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
  9094. parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
  9095. }
  9096. if (se.HandOverTimeEnd.HasValue)
  9097. {
  9098. selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
  9099. parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
  9100. }
  9101. selSql = selSql +
  9102. " 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" +
  9103. " ORDER BY pmd.ProductionLineCode\n" +
  9104. " ,pmd.ProcedureCode\n" +
  9105. " ,pmd.DefectProcedureCode\n" +
  9106. " ,pmd.DefectCode\n" +
  9107. " ,pmd.Usercode\n" +
  9108. " ,pmd.Goodscode) t";
  9109. return selSql;
  9110. }
  9111. /// <summary>
  9112. /// 取得RPT030106(成检缺陷汇总表-明细)的汇总信息查询数据
  9113. /// </summary>
  9114. /// <param name="user">登录用户信息</param>
  9115. /// <param name="se">查询条件</param>
  9116. /// <returns>查询结果</returns>
  9117. public static ServiceResultEntity GetRPT030106IData(SUserInfo user, RPT030106_SE se)
  9118. {
  9119. IDBConnection conn = null;
  9120. try
  9121. {
  9122. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  9123. List<OracleParameter> parameters = new List<OracleParameter>();
  9124. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106ISQL(user, se, ref parameters));
  9125. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  9126. ServiceResultEntity sre = new ServiceResultEntity();
  9127. if (data == null || data.Rows.Count == 0)
  9128. {
  9129. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  9130. return sre;
  9131. }
  9132. sre.Data = new DataSet();
  9133. sre.Data.Tables.Add(data);
  9134. return sre;
  9135. }
  9136. catch (Exception ex)
  9137. {
  9138. throw ex;
  9139. }
  9140. finally
  9141. {
  9142. if (conn != null &&
  9143. conn.ConnState == ConnectionState.Open)
  9144. {
  9145. conn.Close();
  9146. }
  9147. }
  9148. }
  9149. /// <summary>
  9150. /// 获取RPT030106画面(成检缺陷汇总表-明细)的汇总信息查询sql
  9151. /// </summary>
  9152. /// <returns>sql</returns>
  9153. private static string GetRPT030106ISQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
  9154. {
  9155. // string selSql = @"select
  9156. // tp_pm_defect.productionlinename,
  9157. // tp_pm_defect.procedurename,
  9158. // tp_pm_defect.DefectProcedureCode,
  9159. // tp_pm_defect.DefectProcedureName,
  9160. // tp_pm_defect.DefectUserCode,
  9161. // tp_pm_defect.defectusername,
  9162. // tp_mst_defectType.DefectTypeName,
  9163. // TP_MST_Defect.Remarks DefectRemarks,
  9164. // tp_pm_defect.defectcode,
  9165. // tp_pm_defect.defectname,
  9166. // tp_pm_defect.UserCode,
  9167. // tp_pm_defect.username,
  9168. // tp_mst_goodstype.Goodstypename,
  9169. // tp_pm_defect.goodscode,
  9170. // tp_pm_defect.barcode,
  9171. // tp_pm_productiondata.groutingdate,
  9172. // tp_pm_productiondata.groutingnum,
  9173. // tp_pm_productiondata.groutingMouldCode,
  9174. // tp_pm_productiondata.KilnCarCode,
  9175. // tp_pm_productiondata.Procedureid,
  9176. // decode(TP_PM_ProductionData.Goodsleveltypeid, '4', '正品' , '5','副品','6','重烧','7','次品','') as Goodsleveltype,
  9177. // tp_pm_defect.DefectPositionCode,
  9178. // tp_pm_defect.DefectPositionName,
  9179. // tp_pm_productiondata.GroutingUserCode,
  9180. // --replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName
  9181. // decode(TP_MST_Logo.Logocode, null, null,TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']')) as LogoCodeName
  9182. // ,TP_PM_Defect.CreateTime
  9183. // ,(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
  9184. // ,TP_MST_DefectFine.DefectFineCode
  9185. // ,TP_PM_Defect.DefectDeductionNum
  9186. // from tp_pm_defect
  9187. // left join TP_MST_Goods
  9188. // on TP_PM_Defect.Goodsid=TP_MST_Goods.Goodsid
  9189. // left join TP_MST_GoodsType
  9190. // on TP_MST_Goods.GoodsTypeID = TP_MST_GoodsType.GoodsTypeID
  9191. // left join TP_MST_Defect
  9192. // on TP_PM_Defect.DefectID=TP_MST_Defect.DefectID
  9193. // left join TP_MST_DefectType
  9194. // on TP_MST_Defect.DefectTypeID=TP_MST_DefectType.DefectTypeID
  9195. // inner join tp_pm_productiondata
  9196. // on tp_pm_defect.ProductionDataID=tp_pm_productiondata.ProductionDataID
  9197. // left join TP_MST_DefectFine
  9198. // on tp_pm_defect.DefectFine=TP_MST_DefectFine.DefectFineID
  9199. // left join tp_mst_logo
  9200. // on tp_pm_productiondata.logoid=tp_mst_logo.logoid";
  9201. // 质量登记改判时,缺陷的登记时间是当前时间,不是交接或前次登记时间。
  9202. // 追加交接时间,改判标识。
  9203. string selSql =
  9204. "SELECT pmd.productionlinename\n" +
  9205. " ,pmd.procedurename\n" +
  9206. " ,pmd.DefectProcedureCode\n" +
  9207. " ,pmd.DefectProcedureName\n" +
  9208. " ,pmd.DefectUserCode\n" +
  9209. " ,pmd.defectusername\n" +
  9210. " ,dt.DefectTypeName\n" +
  9211. " ,mstd.Remarks DefectRemarks\n" +
  9212. " ,pmd.defectcode\n" +
  9213. " ,d.alldefectcode\n" +
  9214. " ,pmd.defectname\n" +
  9215. " ,pmd.UserCode\n" +
  9216. " ,pmd.username\n" +
  9217. " ,gt.Goodstypename\n" +
  9218. " ,pmd.goodscode\n" +
  9219. " ,pmd.barcode\n" +
  9220. " ,pd.groutingdate\n" +
  9221. " ,pd.groutingnum\n" +
  9222. " ,pd.groutingMouldCode\n" +
  9223. " ,pd.groutingLineCode\n" +
  9224. " ,pd.KilnCarCode\n" +
  9225. " ,pd.Procedureid\n" +
  9226. " ,gl.goodslevelname Goodsleveltype\n" +
  9227. " ,pmd.DefectPositionCode\n" +
  9228. " ,pmd.DefectPositionName\n" +
  9229. " ,pd.GroutingUserCode\n" +
  9230. " , CASE\n" +
  9231. " WHEN logo.logoid IS NULL THEN\n" +
  9232. " NULL\n" +
  9233. " ELSE\n" +
  9234. " logo.Logoname || '[' || logo.Logocode || ']'\n" +
  9235. " END AS LogoCodeName\n" +
  9236. " ,pmd.CreateTime\n" +
  9237. " ,mstdf.DefectFineCode\n" +
  9238. " ,pmd.DefectDeductionNum\n" +
  9239. //" ,to_char(pmd.DefectDeductionNum, '990.00') DefectDeductionNum\n" +
  9240. " ,hopd.createtime handovertime\n" +
  9241. " ,(SELECT listagg(to_char(pduc.UserCode), ',') within GROUP(ORDER BY pduc.ProductionDataID) AS WorkUserCodes\n" +
  9242. " FROM tp_pm_ProductionData pduc\n" +
  9243. " WHERE pduc.barcode = pmd.barcode\n" +
  9244. " AND pduc.valueflag = '1') AS WorkUserCodes\n" +
  9245. " ,(SELECT listagg(to_char(u.UserCode), ',') within GROUP(ORDER BY pdcu.ProductionDataID) AS CreateUserCodes\n" +
  9246. " FROM tp_pm_ProductionData pdcu\n" +
  9247. " Left join tp_mst_user u on u.userid = pdcu.createuserid\n" +
  9248. " WHERE pdcu.barcode = pmd.barcode\n" +
  9249. " AND pdcu.valueflag = '1') AS CreateUserCodes\n" +
  9250. " , CASE\n" +
  9251. " WHEN EXISTS (SELECT 1\n" +
  9252. " FROM tp_pm_ProductionData pdud\n" +
  9253. " WHERE pdud.barcode = pmd.barcode\n" +
  9254. " AND pdud.modeltype = -1\n" +
  9255. " AND pdud.procedureid = pd.procedureid\n" +
  9256. " AND pdud.kilncarbatchno = pd.kilncarbatchno\n" +
  9257. " AND pdud.valueflag = '0') THEN\n" +
  9258. " 1\n" +
  9259. " ELSE\n" +
  9260. " 0\n" +
  9261. " END AS undoflag\n" +
  9262. " , CASE\n" +
  9263. " WHEN EXISTS (SELECT 1\n" +
  9264. " FROM tp_pm_semicheck sc\n" +
  9265. " WHERE sc.barcode = pmd.barcode\n" +
  9266. " AND sc.SEMICHECKTYPE = 1\n" +
  9267. " AND sc.valueflag = '1') THEN\n" +
  9268. " 1\n" +
  9269. " ELSE\n" +
  9270. " 0\n" +
  9271. " END reworkflag" +
  9272. " ,gdd.glazingroom" +
  9273. " FROM tp_pm_defect pmd\n" +
  9274. " LEFT JOIN TP_MST_Goods g\n" +
  9275. " ON pmd.Goodsid = g.Goodsid\n" +
  9276. " LEFT JOIN TP_MST_GoodsType gt\n" +
  9277. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  9278. " LEFT JOIN TP_MST_Defect mstd\n" +
  9279. " ON pmd.DefectID = mstd.DefectID\n" +
  9280. " LEFT JOIN TP_MST_DefectType dt\n" +
  9281. " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
  9282. " INNER JOIN tp_pm_productiondata pd\n" +
  9283. " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
  9284. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  9285. " ON gdd.Groutingdailydetailid = pd.Groutingdailydetailid\n" +
  9286. " LEFT JOIN tp_mst_goodslevel gl\n" +
  9287. " ON pd.goodslevelid = gl.goodslevelid\n" +
  9288. "-- 交接工序\n" +
  9289. " INNER JOIN tp_pm_productiondata hopd\n" +
  9290. " ON hopd.kilncarbatchno = pd.kilncarbatchno\n " +
  9291. " AND hopd.barcode = pd.barcode\n" +
  9292. " AND hopd.valueflag = '1'\n" +
  9293. " AND hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  9294. " LEFT JOIN TP_MST_DefectFine mstdf\n" +
  9295. " ON pmd.DefectFine = mstdf.DefectFineID\n" +
  9296. " LEFT JOIN tp_mst_logo logo\n" +
  9297. " ON pd.logoid = logo.logoid\n" +
  9298. " LEFT JOIN (SELECT def.barcode, wmsys.wm_concat( to_char(def.defectcode)) alldefectcode\n" +
  9299. " FROM tp_pm_defect def\n" +
  9300. " WHERE def.valueflag = '1'\n" +
  9301. //def.createtime
  9302. " group by def.barcode ) d\n" +
  9303. " ON d.barcode = pmd.barcode\n" +
  9304. " WHERE pmd.valueflag = '1' \n" +
  9305. " AND pd.ModelType = -1\n" +
  9306. " AND pmd.AccountID = :AccountID\n";
  9307. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  9308. parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
  9309. //selSql = selSql +
  9310. // " Where TP_PM_Defect.valueflag='1' and tp_pm_productiondata.ModelType=-1" +
  9311. // " and TP_PM_Defect.AccountID=:AccountID ";
  9312. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  9313. {
  9314. selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
  9315. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  9316. }
  9317. if (!string.IsNullOrEmpty(se.LineIDS))
  9318. {
  9319. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
  9320. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  9321. }
  9322. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  9323. {
  9324. //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  9325. selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
  9326. parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  9327. }
  9328. else
  9329. {
  9330. // modify by chenxy :没有选择时,应全查询出来。
  9331. //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  9332. }
  9333. if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  9334. {
  9335. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
  9336. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  9337. }
  9338. if (!string.IsNullOrEmpty(se.KilnCode))
  9339. {
  9340. selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
  9341. parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  9342. }
  9343. if (!string.IsNullOrEmpty(se.GoodsIDS))
  9344. {
  9345. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
  9346. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  9347. }
  9348. if (!string.IsNullOrEmpty(se.GoodsCode))
  9349. {
  9350. selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
  9351. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  9352. }
  9353. if (!string.IsNullOrEmpty(se.GoodsCodeS2D))
  9354. {
  9355. selSql = selSql + " AND pmd.goodsCode = :GoodsCodeS2D ";
  9356. parameters.Add(new OracleParameter(":GoodsCodeS2D", OracleDbType.NVarchar2, se.GoodsCodeS2D, ParameterDirection.Input));
  9357. }
  9358. if (!string.IsNullOrEmpty(se.DefectUserCode))
  9359. {
  9360. selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
  9361. parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  9362. }
  9363. if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  9364. {
  9365. selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
  9366. parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  9367. }
  9368. if (!string.IsNullOrEmpty(se.DefectCode))
  9369. {
  9370. selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
  9371. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  9372. }
  9373. if (!string.IsNullOrEmpty(se.DefectCodeS2D))
  9374. {
  9375. selSql = selSql + " AND pmd.DefectCode = :DefectCodeS2D ";
  9376. parameters.Add(new OracleParameter(":DefectCodeS2D", OracleDbType.NVarchar2, se.DefectCodeS2D, ParameterDirection.Input));
  9377. }
  9378. if (!string.IsNullOrEmpty(se.DefectName))
  9379. {
  9380. selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
  9381. parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  9382. }
  9383. if (!string.IsNullOrEmpty(se.CheckUserCode))
  9384. {
  9385. selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
  9386. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  9387. }
  9388. if (!string.IsNullOrEmpty(se.CheckUserCodeS2D))
  9389. {
  9390. selSql = selSql + " AND pmd.UserCode = :CheckUserCodeS2D ";
  9391. parameters.Add(new OracleParameter(":CheckUserCodeS2D", OracleDbType.NVarchar2, se.CheckUserCodeS2D, ParameterDirection.Input));
  9392. }
  9393. // 登记时间(缺陷)
  9394. if (se.CreateTimeStart.HasValue)
  9395. {
  9396. selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
  9397. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9398. }
  9399. if (se.CreateTimeEnd.HasValue)
  9400. {
  9401. selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
  9402. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9403. }
  9404. // 交接时间
  9405. if (se.HandOverTimeStart.HasValue)
  9406. {
  9407. selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
  9408. parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
  9409. }
  9410. if (se.HandOverTimeEnd.HasValue)
  9411. {
  9412. selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
  9413. parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
  9414. }
  9415. //if (!string.IsNullOrEmpty(se.PurViewUserCodeIDS))
  9416. //{
  9417. // selSql = selSql + " AND instr(','||:PurViewUserCodeIDS||',',','||TP_PM_Defect.DefectUserID||',')>0 ";
  9418. // parameters.Add(new OracleParameter(":PurViewUserCodeIDS", OracleDbType.NVarchar2, se.PurViewUserCodeIDS, ParameterDirection.Input));
  9419. //}
  9420. ////----------------------
  9421. //if (!string.IsNullOrEmpty(se.CompleteProcedureIDS))
  9422. //{
  9423. // selSql = selSql + @" AND exists(select 1 from tp_pm_productiondata where (instr(','||:CompleteProcedureIDS||',',','||ProcedureID||',')>0 ";
  9424. // parameters.Add(new OracleParameter(":CompleteProcedureIDS", OracleDbType.NVarchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  9425. // selSql = selSql + " AND TP_PM_ProductionData.CreateTime>= :CompleteCreateTimeStart ";
  9426. // parameters.Add(new OracleParameter(":CompleteCreateTimeStart", OracleDbType.Date, se.CompleteCreateTimeStart.Value, ParameterDirection.Input));
  9427. // selSql = selSql + " AND TP_PM_ProductionData.CreateTime<= :CompleteCreateTimeEnd )) ";
  9428. // parameters.Add(new OracleParameter(":CompleteCreateTimeEnd", OracleDbType.Date, se.CompleteCreateTimeEnd.Value, ParameterDirection.Input));
  9429. //}
  9430. ////----------------------
  9431. selSql = selSql + " order by pmd.productionlinename,pmd.procedurename,pmd.defectprocedurename,pmd.defectusercode ";
  9432. return selSql;
  9433. }
  9434. /// <summary>
  9435. /// 取得RPT030106(成检缺陷汇总表-缺陷登记明细)的汇总信息查询数据
  9436. /// </summary>
  9437. /// <param name="user">登录用户信息</param>
  9438. /// <param name="se">查询条件</param>
  9439. /// <returns>查询结果</returns>
  9440. public static ServiceResultEntity GetRPT030106DData(SUserInfo user, RPT030106_SE se)
  9441. {
  9442. IDBConnection conn = null;
  9443. try
  9444. {
  9445. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  9446. List<OracleParameter> parameters = new List<OracleParameter>();
  9447. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106DSQL(user, se, ref parameters));
  9448. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  9449. ServiceResultEntity sre = new ServiceResultEntity();
  9450. if (data == null || data.Rows.Count == 0)
  9451. {
  9452. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  9453. return sre;
  9454. }
  9455. sre.Data = new DataSet();
  9456. sre.Data.Tables.Add(data);
  9457. return sre;
  9458. }
  9459. catch (Exception ex)
  9460. {
  9461. throw ex;
  9462. }
  9463. finally
  9464. {
  9465. if (conn != null &&
  9466. conn.ConnState == ConnectionState.Open)
  9467. {
  9468. conn.Close();
  9469. }
  9470. }
  9471. }
  9472. /// <summary>
  9473. /// 获取RPT030106画面(成检缺陷汇总表-缺陷登记明细)的汇总信息查询sql
  9474. /// </summary>
  9475. /// <returns>sql</returns>
  9476. private static string GetRPT030106DSQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
  9477. {
  9478. // 质量登记改判时,缺陷的登记时间是当前时间,不是交接或前次登记时间。
  9479. // 追加交接时间,改判标识。
  9480. string selSql =
  9481. "SELECT pmd.productionlinename\n" +
  9482. " ,pmd.procedurename\n" +
  9483. " ,pmd.DefectProcedureCode\n" +
  9484. " ,pmd.DefectProcedureName\n" +
  9485. " ,pmd.DefectUserCode\n" +
  9486. " ,pmd.defectusername\n" +
  9487. " ,jobs.jobsname defectjobsname\n" +
  9488. " ,dt.DefectTypeName\n" +
  9489. " ,mstd.Remarks DefectRemarks\n" +
  9490. " ,pd.Remarks barcodeRemarks\n" +
  9491. " ,pmd.defectcode\n" +
  9492. " ,d.alldefectcode\n" +
  9493. " ,pmd.defectname\n" +
  9494. " ,pmd.UserCode\n" +
  9495. " ,pmd.username\n" +
  9496. " ,gt.Goodstypename\n" +
  9497. " ,pmd.goodscode\n" +
  9498. " ,pmd.barcode\n" +
  9499. " ,pd.groutingdate\n" +
  9500. " ,pd.groutingnum\n" +
  9501. " ,pd.groutingMouldCode\n" +
  9502. " ,pd.GroutingLineCode\n" +
  9503. " ,pd.KilnCarCode\n" +
  9504. " ,pd.Procedureid\n" +
  9505. " ,gl.goodslevelname Goodsleveltype\n" +
  9506. " ,pmd.DefectPositionCode\n" +
  9507. " ,pmd.DefectPositionName\n" +
  9508. " ,pd.GroutingUserCode\n" +
  9509. " , CASE\n" +
  9510. " WHEN logo.logoid IS NULL THEN\n" +
  9511. " NULL\n" +
  9512. " ELSE\n" +
  9513. " logo.Logoname || '[' || logo.Logocode || ']'\n" +
  9514. " END AS LogoCodeName\n" +
  9515. //" ,pmd.CreateTime\n" +
  9516. " ,pd.CheckTime pdchecktime\n" +
  9517. " ,pmd.CheckTime\n" +
  9518. " ,mstdf.DefectFineCode\n" +
  9519. " ,pmd.DefectDeductionNum\n" +
  9520. //" ,to_char(pmd.DefectDeductionNum, '990.00') DefectDeductionNum\n" +
  9521. " ,hopd.createtime handovertime\n" +
  9522. " ,(SELECT listagg(to_char(pduc.UserCode), ',') within GROUP(ORDER BY pduc.ProductionDataID) AS WorkUserCodes\n" +
  9523. " FROM tp_pm_ProductionData pduc\n" +
  9524. " WHERE pduc.barcode = pmd.barcode\n" +
  9525. " AND pduc.valueflag = '1') AS WorkUserCodes\n" +
  9526. " ,(SELECT listagg(to_char(u.UserCode), ',') within GROUP(ORDER BY pdcu.ProductionDataID) AS CreateUserCodes\n" +
  9527. " FROM tp_pm_ProductionData pdcu\n" +
  9528. " Left join tp_mst_user u on u.userid = pdcu.createuserid\n" +
  9529. " WHERE pdcu.barcode = pmd.barcode\n" +
  9530. " AND pdcu.valueflag = '1') AS CreateUserCodes\n" +
  9531. " ,(SELECT listagg(to_char(s.StaffName), ',') within GROUP(ORDER BY s.Staffid) AS DefectStaffNames\n" +
  9532. " FROM TP_PM_DefectResponsible dr\n" +
  9533. " Left join TP_HR_Staff s on s.Staffid = dr.Staffid\n" +
  9534. " WHERE dr.ProductionDefectID = pmd.ProductionDefectID --dr pdcu.valueflag = '1'\n" +
  9535. " ) AS DefectStaffNames\n" +
  9536. " , CASE\n" +
  9537. " WHEN pd.isrefire <> '0' THEN\n" +
  9538. " (select listagg(to_char(d.defectname || '[' || d.defectpositionname || ']')\n" +
  9539. " ,',') within group(order by d.productiondefectid) bsqx\n" +
  9540. " from tp_pm_productiondata p\n" +
  9541. " inner join tp_pm_defect d\n" +
  9542. " on d.productiondataid = p.productiondataid\n" +
  9543. " where p.valueflag = '1'\n" +
  9544. " and d.valueflag = '1'\n" +
  9545. " and p.barcode = pd.barcode\n" +
  9546. " and p.modeltype = -1\n" +
  9547. " and p.isrefire = '0')\n" +
  9548. " ELSE\n" +
  9549. " null\n" +
  9550. " END AS bsqx\n" +
  9551. " , CASE\n" +
  9552. " WHEN EXISTS (SELECT 1\n" +
  9553. " FROM tp_pm_ProductionData pdud\n" +
  9554. " WHERE pdud.barcode = pmd.barcode\n" +
  9555. " AND pdud.modeltype = -1\n" +
  9556. " AND pdud.procedureid = pd.procedureid\n" +
  9557. " AND pdud.kilncarbatchno = pd.kilncarbatchno\n" +
  9558. " AND pdud.valueflag = '0') THEN\n" +
  9559. " 1\n" +
  9560. " ELSE\n" +
  9561. " 0\n" +
  9562. " END AS undoflag\n" +
  9563. " FROM tp_pm_defect pmd\n" +
  9564. " LEFT JOIN TP_PC_Procedure p\n" +
  9565. " ON p.procedureid = pmd.procedureid\n" +
  9566. " LEFT JOIN TP_PC_Procedure pdd\n" +
  9567. " ON pdd.procedureid = pmd.defectprocedureid\n" +
  9568. " LEFT JOIN TP_MST_Goods g\n" +
  9569. " ON pmd.Goodsid = g.Goodsid\n" +
  9570. " LEFT JOIN TP_MST_GoodsType gt\n" +
  9571. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  9572. " LEFT JOIN TP_MST_Defect mstd\n" +
  9573. " ON pmd.DefectID = mstd.DefectID\n" +
  9574. " LEFT JOIN TP_MST_Jobs jobs\n" +
  9575. " ON jobs.jobsid = pmd.Defectjobs\n" +
  9576. " LEFT JOIN TP_MST_DefectType dt\n" +
  9577. " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
  9578. " INNER JOIN tp_pm_productiondata pd\n" +
  9579. " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
  9580. " LEFT JOIN tp_mst_goodslevel gl\n" +
  9581. " ON pd.goodslevelid = gl.goodslevelid\n" +
  9582. //"-- 交接工序\n" +
  9583. //" INNER JOIN tp_pm_productiondata hopd\n" +
  9584. //" ON hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  9585. //" AND hopd.valueflag = '1'\n" +
  9586. //" AND hopd.barcode = pd.barcode\n" +
  9587. //" AND hopd.kilncarbatchno = pd.kilncarbatchno\n" +
  9588. " INNER JOIN tp_pm_productiondata hopd\n" +
  9589. " ON hopd.kilncarbatchno = pd.kilncarbatchno\n " +
  9590. " AND hopd.barcode = pd.barcode\n" +
  9591. " AND hopd.valueflag = '1'\n" +
  9592. " AND hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  9593. " LEFT JOIN TP_MST_DefectFine mstdf\n" +
  9594. " ON pmd.DefectFine = mstdf.DefectFineID\n" +
  9595. " LEFT JOIN tp_mst_logo logo\n" +
  9596. " ON pd.logoid = logo.logoid\n" +
  9597. " LEFT JOIN (SELECT def.barcode, wmsys.wm_concat( to_char(def.defectcode)) alldefectcode\n" +
  9598. " FROM tp_pm_defect def\n" +
  9599. " WHERE def.valueflag = '1'\n" +
  9600. //def.createtime
  9601. " group by def.barcode ) d\n" +
  9602. " ON d.barcode = pmd.barcode\n" +
  9603. " WHERE pmd.valueflag = '1' \n" +
  9604. " AND pd.ModelType = -1\n" +
  9605. " AND pmd.AccountID = :AccountID\n";
  9606. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  9607. parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
  9608. //selSql = selSql +
  9609. // " Where TP_PM_Defect.valueflag='1' and tp_pm_productiondata.ModelType=-1" +
  9610. // " and TP_PM_Defect.AccountID=:AccountID ";
  9611. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  9612. {
  9613. selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
  9614. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  9615. }
  9616. if (!string.IsNullOrEmpty(se.LineIDS))
  9617. {
  9618. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
  9619. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  9620. }
  9621. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  9622. {
  9623. //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  9624. selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
  9625. parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  9626. }
  9627. else
  9628. {
  9629. // modify by chenxy :没有选择时,应全查询出来。
  9630. //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  9631. }
  9632. if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  9633. {
  9634. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
  9635. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  9636. }
  9637. if (!string.IsNullOrEmpty(se.KilnCode))
  9638. {
  9639. selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
  9640. parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  9641. }
  9642. if (!string.IsNullOrEmpty(se.GoodsIDS))
  9643. {
  9644. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
  9645. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  9646. }
  9647. if (!string.IsNullOrEmpty(se.GoodsCode))
  9648. {
  9649. selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
  9650. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  9651. }
  9652. if (!string.IsNullOrEmpty(se.GoodsCodeS2D))
  9653. {
  9654. selSql = selSql + " AND pmd.goodsCode = :GoodsCodeS2D ";
  9655. parameters.Add(new OracleParameter(":GoodsCodeS2D", OracleDbType.NVarchar2, se.GoodsCodeS2D, ParameterDirection.Input));
  9656. }
  9657. if (!string.IsNullOrEmpty(se.DefectUserCode))
  9658. {
  9659. selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
  9660. parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  9661. }
  9662. if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  9663. {
  9664. selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
  9665. parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  9666. }
  9667. if (!string.IsNullOrEmpty(se.DefectCode))
  9668. {
  9669. selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
  9670. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  9671. }
  9672. if (!string.IsNullOrEmpty(se.DefectCodeS2D))
  9673. {
  9674. selSql = selSql + " AND pmd.DefectCode = :DefectCodeS2D ";
  9675. parameters.Add(new OracleParameter(":DefectCodeS2D", OracleDbType.NVarchar2, se.DefectCodeS2D, ParameterDirection.Input));
  9676. }
  9677. if (!string.IsNullOrEmpty(se.DefectName))
  9678. {
  9679. selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
  9680. parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  9681. }
  9682. if (!string.IsNullOrEmpty(se.CheckUserCode))
  9683. {
  9684. selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
  9685. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  9686. }
  9687. if (!string.IsNullOrEmpty(se.CheckUserCodeS2D))
  9688. {
  9689. selSql = selSql + " AND pmd.UserCode = :CheckUserCodeS2D ";
  9690. parameters.Add(new OracleParameter(":CheckUserCodeS2D", OracleDbType.NVarchar2, se.CheckUserCodeS2D, ParameterDirection.Input));
  9691. }
  9692. //if (se.CreateTimeStart.HasValue)
  9693. //{
  9694. // selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
  9695. // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9696. //}
  9697. //if (se.CreateTimeEnd.HasValue)
  9698. //{
  9699. // selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
  9700. // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9701. //}
  9702. // 登记时间(第一次成检)
  9703. if (se.CreateTimeStart.HasValue)
  9704. {
  9705. selSql = selSql + " AND pd.checktime>= :CreateTimeStart ";
  9706. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9707. }
  9708. if (se.CreateTimeEnd.HasValue)
  9709. {
  9710. selSql = selSql + " AND pd.checktime<= :CreateTimeEnd ";
  9711. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9712. }
  9713. // 缺陷登记时间
  9714. if (se.CheckTimeStart.HasValue)
  9715. {
  9716. selSql = selSql + " AND pmd.checktime>= :CheckTimeStart ";
  9717. parameters.Add(new OracleParameter(":CheckTimeStart", OracleDbType.Date, se.CheckTimeStart.Value, ParameterDirection.Input));
  9718. }
  9719. if (se.CheckTimeEnd.HasValue)
  9720. {
  9721. selSql = selSql + " AND pmd.checktime<= :CheckTimeEnd ";
  9722. parameters.Add(new OracleParameter(":CheckTimeEnd", OracleDbType.Date, se.CheckTimeEnd.Value, ParameterDirection.Input));
  9723. }
  9724. // 交接时间
  9725. if (se.HandOverTimeStart.HasValue)
  9726. {
  9727. selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
  9728. parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
  9729. }
  9730. if (se.HandOverTimeEnd.HasValue)
  9731. {
  9732. selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
  9733. parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
  9734. }
  9735. //selSql = selSql + " order by pmd.productionlinename,pmd.procedurename,pmd.defectprocedurename,pmd.defectusercode ";
  9736. selSql = selSql + " order by pmd.productionlinename,p.DISPLAYNO,pdd.DISPLAYNO,dt.DISPLAYNO,mstd.DISPLAYNO,pmd.defectusercode,pmd.barcode ";
  9737. return selSql;
  9738. }
  9739. /// <summary>
  9740. /// 取得RPT030106(成检缺陷汇总表-生产工序信息)的汇总信息查询数据
  9741. /// </summary>
  9742. /// <param name="user">登录用户信息</param>
  9743. /// <param name="se">查询条件</param>
  9744. /// <returns>查询结果</returns>
  9745. public static ServiceResultEntity GetRPT030106ProData(SUserInfo user, RPT030106_SE se)
  9746. {
  9747. IDBConnection conn = null;
  9748. try
  9749. {
  9750. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  9751. List<OracleParameter> parameters = new List<OracleParameter>();
  9752. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106ProSQL(user, se, ref parameters));
  9753. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  9754. ServiceResultEntity sre = new ServiceResultEntity();
  9755. if (data == null || data.Rows.Count == 0)
  9756. {
  9757. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  9758. return sre;
  9759. }
  9760. sre.Data = new DataSet();
  9761. sre.Data.Tables.Add(data);
  9762. return sre;
  9763. }
  9764. catch (Exception ex)
  9765. {
  9766. throw ex;
  9767. }
  9768. finally
  9769. {
  9770. if (conn != null &&
  9771. conn.ConnState == ConnectionState.Open)
  9772. {
  9773. conn.Close();
  9774. }
  9775. }
  9776. }
  9777. /// <summary>
  9778. /// 获取RPT030106画面(成检缺陷汇总表-生产工序信息)的汇总信息查询sql
  9779. /// </summary>
  9780. /// <returns>sql</returns>
  9781. private static string GetRPT030106ProSQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
  9782. {
  9783. // 质量登记改判时,缺陷的登记时间是当前时间,不是交接或前次登记时间。
  9784. // 追加交接时间,改判标识。
  9785. string selSql =
  9786. //"SELECT pmd.productionlinename\n" +
  9787. //" ,pmd.procedurename\n" +
  9788. //" ,pmd.DefectProcedureCode\n" +
  9789. //" ,pmd.DefectProcedureName\n" +
  9790. //" ,pmd.DefectUserCode\n" +
  9791. //" ,pmd.defectusername\n" +
  9792. //" ,jobs.jobsname defectjobsname\n" +
  9793. //" ,dt.DefectTypeName\n" +
  9794. //" ,mstd.Remarks DefectRemarks\n" +
  9795. //" ,pd.Remarks barcodeRemarks\n" +
  9796. //" ,pmd.defectcode\n" +
  9797. //" ,d.alldefectcode\n" +
  9798. //" ,pmd.defectname\n" +
  9799. //" ,pmd.UserCode\n" +
  9800. //" ,pmd.username\n" +
  9801. //" ,gt.Goodstypename\n" +
  9802. //" ,pmd.goodscode\n" +
  9803. //" ,pmd.barcode\n" +
  9804. //" ,pd.groutingdate\n" +
  9805. //" ,pd.groutingnum\n" +
  9806. //" ,pd.groutingMouldCode\n" +
  9807. //" ,pd.GroutingLineCode\n" +
  9808. //" ,pd.KilnCarCode\n" +
  9809. //" ,pd.Procedureid\n" +
  9810. //" ,gl.goodslevelname Goodsleveltype\n" +
  9811. //" ,pmd.DefectPositionCode\n" +
  9812. //" ,pmd.DefectPositionName\n" +
  9813. //" ,pd.GroutingUserCode\n" +
  9814. //" , CASE\n" +
  9815. //" WHEN logo.logoid IS NULL THEN\n" +
  9816. //" NULL\n" +
  9817. //" ELSE\n" +
  9818. //" logo.Logoname || '[' || logo.Logocode || ']'\n" +
  9819. //" END AS LogoCodeName\n" +
  9820. ////" ,pmd.CreateTime\n" +
  9821. //" ,pd.CheckTime pdchecktime\n" +
  9822. //" ,pmd.CheckTime\n" +
  9823. //" ,mstdf.DefectFineCode\n" +
  9824. //" ,pmd.DefectDeductionNum\n" +
  9825. ////" ,to_char(pmd.DefectDeductionNum, '990.00') DefectDeductionNum\n" +
  9826. //" ,hopd.createtime handovertime\n" +
  9827. //" ,(SELECT listagg(to_char(pduc.UserCode), ',') within GROUP(ORDER BY pduc.ProductionDataID) AS WorkUserCodes\n" +
  9828. //" FROM tp_pm_ProductionData pduc\n" +
  9829. //" WHERE pduc.barcode = pmd.barcode\n" +
  9830. //" AND pduc.valueflag = '1') AS WorkUserCodes\n" +
  9831. //" ,(SELECT listagg(to_char(u.UserCode), ',') within GROUP(ORDER BY pdcu.ProductionDataID) AS CreateUserCodes\n" +
  9832. //" FROM tp_pm_ProductionData pdcu\n" +
  9833. //" Left join tp_mst_user u on u.userid = pdcu.createuserid\n" +
  9834. //" WHERE pdcu.barcode = pmd.barcode\n" +
  9835. //" AND pdcu.valueflag = '1') AS CreateUserCodes\n" +
  9836. //" , CASE\n" +
  9837. //" WHEN EXISTS (SELECT 1\n" +
  9838. //" FROM tp_pm_ProductionData pdud\n" +
  9839. //" WHERE pdud.barcode = pmd.barcode\n" +
  9840. //" AND pdud.modeltype = -1\n" +
  9841. //" AND pdud.procedureid = pd.procedureid\n" +
  9842. //" AND pdud.kilncarbatchno = pd.kilncarbatchno\n" +
  9843. //" AND pdud.valueflag = '0') THEN\n" +
  9844. //" 1\n" +
  9845. //" ELSE\n" +
  9846. //" 0\n" +
  9847. //" END AS undoflag\n" +
  9848. "SELECT pmd.goodscode\n" +
  9849. " ,pmd.barcode\n" +
  9850. " ,pmd.defectcode\n" +
  9851. " ,pmd.defectname\n" +
  9852. " ,pmd.DefectPositionCode\n" +
  9853. " ,pmd.DefectPositionName\n" +
  9854. " ,gl.goodslevelname Goodsleveltype\n" +
  9855. " , CASE\n" +
  9856. " WHEN logo.logoid IS NULL THEN\n" +
  9857. " NULL\n" +
  9858. " ELSE\n" +
  9859. " logo.Logoname || '[' || logo.Logocode || ']'\n" +
  9860. " END AS LogoCodeName\n" +
  9861. //" ,pmd.CreateTime\n" +
  9862. " ,pd.CheckTime pdchecktime\n" +
  9863. " ,pmd.CheckTime\n" +
  9864. " ,proddata.CheckTime protime\n" +
  9865. " ,proddata.UserCode prousercode\n" +
  9866. " ,proddata.PROCEDURENAME proname\n" +
  9867. " ,pd.KILNCARCODE KILNCARCODE\n" +
  9868. " FROM tp_pm_defect pmd\n" +
  9869. " INNER JOIN tp_pm_productiondata proddata\n" +
  9870. " ON proddata.barcode = pmd.barcode\n " +
  9871. //" AND proddata.ProcedureID in ('" + se.CompleteProcedureIDS + "')\n" +
  9872. " AND (instr(','||:ProProcedureIDS||',',','||proddata.ProcedureID||',')>0 )\n" +
  9873. " AND proddata.valueflag = '1'\n" +
  9874. " INNER JOIN tp_pm_productiondata pd\n" +
  9875. " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
  9876. " LEFT JOIN TP_PC_Procedure p\n" +
  9877. " ON p.procedureid = pmd.procedureid\n" +
  9878. " LEFT JOIN TP_PC_Procedure pdd\n" +
  9879. " ON pdd.procedureid = pmd.defectprocedureid\n" +
  9880. " LEFT JOIN TP_MST_Goods g\n" +
  9881. " ON pmd.Goodsid = g.Goodsid\n" +
  9882. " LEFT JOIN TP_MST_GoodsType gt\n" +
  9883. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  9884. " LEFT JOIN TP_MST_Defect mstd\n" +
  9885. " ON pmd.DefectID = mstd.DefectID\n" +
  9886. " LEFT JOIN TP_MST_Jobs jobs\n" +
  9887. " ON jobs.jobsid = pmd.Defectjobs\n" +
  9888. " LEFT JOIN TP_MST_DefectType dt\n" +
  9889. " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
  9890. " LEFT JOIN tp_mst_goodslevel gl\n" +
  9891. " ON pd.goodslevelid = gl.goodslevelid\n" +
  9892. "-- 交接工序\n" +
  9893. " INNER JOIN tp_pm_productiondata hopd\n" +
  9894. " ON hopd.kilncarbatchno = pd.kilncarbatchno\n " +
  9895. " AND hopd.barcode = pd.barcode\n" +
  9896. " AND hopd.valueflag = '1'\n" +
  9897. " AND hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  9898. " LEFT JOIN TP_MST_DefectFine mstdf\n" +
  9899. " ON pmd.DefectFine = mstdf.DefectFineID\n" +
  9900. " LEFT JOIN tp_mst_logo logo\n" +
  9901. " ON pd.logoid = logo.logoid\n" +
  9902. //" LEFT JOIN (SELECT def.barcode, wmsys.wm_concat( to_char(def.defectcode)) alldefectcode\n" +
  9903. //" FROM tp_pm_defect def\n" +
  9904. //" WHERE def.valueflag = '1'\n" +
  9905. ////def.createtime
  9906. //" group by def.barcode ) d\n" +
  9907. //" ON d.barcode = pmd.barcode\n" +
  9908. " WHERE pmd.valueflag = '1' \n" +
  9909. " AND pd.ModelType = -1\n" +
  9910. " AND pmd.AccountID = :AccountID\n";
  9911. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  9912. parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
  9913. parameters.Add(new OracleParameter(":ProProcedureIDS", OracleDbType.Varchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  9914. //selSql = selSql +
  9915. // " Where TP_PM_Defect.valueflag='1' and tp_pm_productiondata.ModelType=-1" +
  9916. // " and TP_PM_Defect.AccountID=:AccountID ";
  9917. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  9918. {
  9919. selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
  9920. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  9921. }
  9922. if (!string.IsNullOrEmpty(se.LineIDS))
  9923. {
  9924. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
  9925. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  9926. }
  9927. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  9928. {
  9929. //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  9930. selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
  9931. parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  9932. }
  9933. else
  9934. {
  9935. // modify by chenxy :没有选择时,应全查询出来。
  9936. //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  9937. }
  9938. if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  9939. {
  9940. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
  9941. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  9942. }
  9943. if (!string.IsNullOrEmpty(se.KilnCode))
  9944. {
  9945. selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
  9946. parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  9947. }
  9948. if (!string.IsNullOrEmpty(se.GoodsIDS))
  9949. {
  9950. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
  9951. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  9952. }
  9953. if (!string.IsNullOrEmpty(se.GoodsCode))
  9954. {
  9955. selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
  9956. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  9957. }
  9958. if (!string.IsNullOrEmpty(se.GoodsCodeS2D))
  9959. {
  9960. selSql = selSql + " AND pmd.goodsCode = :GoodsCodeS2D ";
  9961. parameters.Add(new OracleParameter(":GoodsCodeS2D", OracleDbType.NVarchar2, se.GoodsCodeS2D, ParameterDirection.Input));
  9962. }
  9963. if (!string.IsNullOrEmpty(se.DefectUserCode))
  9964. {
  9965. selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
  9966. parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  9967. }
  9968. if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  9969. {
  9970. selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
  9971. parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  9972. }
  9973. if (!string.IsNullOrEmpty(se.DefectCode))
  9974. {
  9975. selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
  9976. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  9977. }
  9978. if (!string.IsNullOrEmpty(se.DefectCodeS2D))
  9979. {
  9980. selSql = selSql + " AND pmd.DefectCode = :DefectCodeS2D ";
  9981. parameters.Add(new OracleParameter(":DefectCodeS2D", OracleDbType.NVarchar2, se.DefectCodeS2D, ParameterDirection.Input));
  9982. }
  9983. if (!string.IsNullOrEmpty(se.DefectName))
  9984. {
  9985. selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
  9986. parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  9987. }
  9988. if (!string.IsNullOrEmpty(se.CheckUserCode))
  9989. {
  9990. selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
  9991. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  9992. }
  9993. if (!string.IsNullOrEmpty(se.CheckUserCodeS2D))
  9994. {
  9995. selSql = selSql + " AND pmd.UserCode = :CheckUserCodeS2D ";
  9996. parameters.Add(new OracleParameter(":CheckUserCodeS2D", OracleDbType.NVarchar2, se.CheckUserCodeS2D, ParameterDirection.Input));
  9997. }
  9998. //if (se.CreateTimeStart.HasValue)
  9999. //{
  10000. // selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
  10001. // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  10002. //}
  10003. //if (se.CreateTimeEnd.HasValue)
  10004. //{
  10005. // selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
  10006. // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  10007. //}
  10008. // 成检登记时间
  10009. if (se.CreateTimeStart.HasValue)
  10010. {
  10011. selSql = selSql + " AND pd.checktime>= :CreateTimeStart ";
  10012. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  10013. }
  10014. if (se.CreateTimeEnd.HasValue)
  10015. {
  10016. selSql = selSql + " AND pd.checktime<= :CreateTimeEnd ";
  10017. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  10018. }
  10019. // 缺陷登记时间
  10020. if (se.CheckTimeStart.HasValue)
  10021. {
  10022. selSql = selSql + " AND pmd.checktime>= :CheckTimeStart ";
  10023. parameters.Add(new OracleParameter(":CheckTimeStart", OracleDbType.Date, se.CheckTimeStart.Value, ParameterDirection.Input));
  10024. }
  10025. if (se.CheckTimeEnd.HasValue)
  10026. {
  10027. selSql = selSql + " AND pmd.checktime<= :CheckTimeEnd ";
  10028. parameters.Add(new OracleParameter(":CheckTimeEnd", OracleDbType.Date, se.CheckTimeEnd.Value, ParameterDirection.Input));
  10029. }
  10030. // 交接时间
  10031. if (se.HandOverTimeStart.HasValue)
  10032. {
  10033. selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
  10034. parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
  10035. }
  10036. if (se.HandOverTimeEnd.HasValue)
  10037. {
  10038. selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
  10039. parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
  10040. }
  10041. //selSql = selSql + " order by pmd.productionlinename,p.DISPLAYNO,pdd.DISPLAYNO,dt.DISPLAYNO,mstd.DISPLAYNO,pmd.defectusercode,pmd.barcode ";
  10042. selSql = selSql + " order by proddata.CheckTime ";
  10043. return selSql;
  10044. }
  10045. /// <summary>
  10046. /// 窑车状态主表查询
  10047. /// </summary>
  10048. /// <param name="kilnCode">窑炉编码</param>
  10049. /// <param name="kilnCarCode">窑车编码</param>
  10050. /// <param name="sUserInfo">用户基本信息</param>
  10051. /// <returns></returns>
  10052. public static ServiceResultEntity GetKilnCarStatusByCode(string kilnCode, string kilnCarCode, SUserInfo sUserInfo)
  10053. {
  10054. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10055. try
  10056. {
  10057. con.Open();
  10058. OracleParameter[] paras = new OracleParameter[]{
  10059. new OracleParameter("in_AccountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  10060. new OracleParameter("in_KilnCode",OracleDbType.Varchar2,kilnCode,ParameterDirection.Input),
  10061. new OracleParameter("in_KilnCarCode",OracleDbType.Varchar2,kilnCarCode,ParameterDirection.Input),
  10062. new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  10063. };
  10064. DataSet dsSearchReport = con.ExecStoredProcedure("PRO_RPT_GetKilnCarStatus", paras);
  10065. ServiceResultEntity sre = new ServiceResultEntity();
  10066. if (dsSearchReport == null || dsSearchReport.Tables[0].Rows.Count == 0)
  10067. {
  10068. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10069. return sre;
  10070. }
  10071. sre.Data = new DataSet();
  10072. sre.Data.Tables.Add(dsSearchReport.Tables[0].Copy());
  10073. return sre;
  10074. }
  10075. catch (Exception ex)
  10076. {
  10077. throw ex;
  10078. }
  10079. finally
  10080. {
  10081. if (con != null &&
  10082. con.ConnState == ConnectionState.Open)
  10083. {
  10084. con.Close();
  10085. }
  10086. }
  10087. }
  10088. /// <summary>
  10089. /// 窑车状态明细表查询
  10090. /// </summary>
  10091. /// <param name="kilnCarCode">窑车编码</param>
  10092. /// <param name="sUserInfo">用户基本信息</param>
  10093. /// <returns></returns>
  10094. public static ServiceResultEntity GetKilnCarStatusDetailByCode(string kilnCarCode, SUserInfo sUserInfo)
  10095. {
  10096. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10097. try
  10098. {
  10099. con.Open();
  10100. OracleParameter[] paras = new OracleParameter[]{
  10101. new OracleParameter("in_AccountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  10102. new OracleParameter("in_KilnCarCode",OracleDbType.Varchar2,kilnCarCode,ParameterDirection.Input),
  10103. new OracleParameter("out_KilnCarData",OracleDbType.RefCursor, ParameterDirection.Output),
  10104. new OracleParameter("out_KilnCarGoods",OracleDbType.RefCursor, ParameterDirection.Output),
  10105. };
  10106. DataSet dsSearchReport = con.ExecStoredProcedure("PRO_RPT_GetKilnCarData", paras);
  10107. ServiceResultEntity sre = new ServiceResultEntity();
  10108. if (dsSearchReport == null || dsSearchReport.Tables[0].Rows.Count == 0)
  10109. {
  10110. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10111. return sre;
  10112. }
  10113. sre.Data = new DataSet();
  10114. sre.Data.Tables.Add(dsSearchReport.Tables[0].Copy());//生产数据
  10115. sre.Data.Tables.Add(dsSearchReport.Tables[1].Copy());//窑车产品
  10116. return sre;
  10117. }
  10118. catch (Exception ex)
  10119. {
  10120. throw ex;
  10121. }
  10122. finally
  10123. {
  10124. if (con != null &&
  10125. con.ConnState == ConnectionState.Open)
  10126. {
  10127. con.Close();
  10128. }
  10129. }
  10130. }
  10131. /// <summary>
  10132. /// 取得RPT010201_1画面(工序漏扫明细表)的查询数据
  10133. /// </summary>
  10134. /// <param name="user">登录用户信息</param>
  10135. /// <param name="se">查询条件</param>
  10136. /// <returns>查询结果</returns>
  10137. public static ServiceResultEntity GetRPT080101SData(SUserInfo user, RPT010201_SE se)
  10138. {
  10139. IDBConnection conn = null;
  10140. try
  10141. {
  10142. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10143. List<OracleParameter> parameters = new List<OracleParameter>();
  10144. parameters.Clear();
  10145. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080101SSQL(user, se, ref parameters));
  10146. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  10147. ServiceResultEntity sre = new ServiceResultEntity();
  10148. if (data == null || data.Rows.Count == 0)
  10149. {
  10150. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10151. return sre;
  10152. }
  10153. sre.Data = new DataSet();
  10154. sre.Data.Tables.Add(data);
  10155. return sre;
  10156. }
  10157. catch (Exception ex)
  10158. {
  10159. throw ex;
  10160. }
  10161. finally
  10162. {
  10163. if (conn != null &&
  10164. conn.ConnState == ConnectionState.Open)
  10165. {
  10166. conn.Close();
  10167. }
  10168. }
  10169. }
  10170. /// <summary>
  10171. /// 获取RPT010201_1画面(工序漏扫明细表)的查询sql
  10172. /// </summary>
  10173. /// <returns>sql</returns>
  10174. private static string GetRPT080101SSQL(SUserInfo user, RPT010201_SE se, ref List<OracleParameter> parameters)
  10175. {
  10176. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  10177. #region
  10178. #endregion
  10179. string sql = @"
  10180. select gd.groutinglinecode,
  10181. gd.groutingmouldcode,
  10182. gd.mouldcode,
  10183. gd.usercode,
  10184. gs.goodscode,
  10185. gs.goodsname,
  10186. gs.goodsspecification,
  10187. gms.gmouldstatusname, -- 模具状态
  10188. --gs.goodsmodel,
  10189. gd.groutingcount, -- 注浆次数
  10190. --gd.groutingnum,
  10191. gd.scrapnum, -- 开模损坯数
  10192. gd.deliverpnum, -- 交坯数
  10193. gd.mingroutingdate, -- 开始注浆时间
  10194. gd.maxgroutingdate, -- 最后注浆时间
  10195. gld.beginuseddate, -- 开始使用时间
  10196. gld.enduseddate, -- 结束使用时间
  10197. zl.OutKilnCount, -- 质量登记数
  10198. zl.GoodCount, -- 正品数
  10199. zl.SubstandardCount, -- 副品数
  10200. zl.ReFireCount, -- 重烧数
  10201. zl.BadCount -- 次品数
  10202. from (select gdd.groutinglinecode,
  10203. gdd.groutingmouldcode,
  10204. gdd.mouldcode,
  10205. gdd.goodsid,
  10206. gdd.groutinglinedetailid,
  10207. wmsys.wm_concat(distinct to_char(gdd.usercode)) usercode,
  10208. max(gdd.groutingcount) groutingcount,
  10209. sum(decode(gdd.groutingflag, '1', 1, 0)) groutingnum,
  10210. sum(decode(gdd.scrapflag, '1', 1, 0)) scrapnum,
  10211. sum(decode(gdd.deliverflag, '1', 1, 0)) deliverpnum,
  10212. min(gdd.groutingdate) mingroutingdate,
  10213. max(gdd.groutingdate) maxgroutingdate
  10214. from tp_pm_groutingdailydetail gdd
  10215. where gdd.groutingflag = '1'
  10216. and gdd.AccountID = :AccountID
  10217. ";
  10218. // 成型线编码
  10219. if (!string.IsNullOrEmpty(se.groutinglinecode))
  10220. {
  10221. //sql = sql + " and gdd.groutinglinecode=:groutinglinecode";
  10222. sql = sql + " and instr(gdd.groutinglinecode,:groutinglinecode)>0";
  10223. parameters.Add(new OracleParameter(":groutinglinecode", OracleDbType.NVarchar2, se.groutinglinecode, ParameterDirection.Input));
  10224. }
  10225. // 模具编码
  10226. if (!string.IsNullOrEmpty(se.groutingmouldcode))
  10227. {
  10228. //sql = sql + " and gdd.groutingmouldcode=:groutingmouldcode";
  10229. sql = sql + " and instr(gdd.groutingmouldcode,:groutingmouldcode)>0";
  10230. parameters.Add(new OracleParameter(":groutingmouldcode", OracleDbType.NVarchar2, se.groutingmouldcode, ParameterDirection.Input));
  10231. }
  10232. sql = sql + @"
  10233. group by gdd.groutinglinecode,
  10234. gdd.groutingmouldcode,
  10235. gdd.mouldcode,
  10236. gdd.goodsid,
  10237. gdd.groutinglinedetailid) gd
  10238. left join (select pdbc.mouldcode,
  10239. sum(1) OutKilnCount,
  10240. sum(case
  10241. when defect.defectprocedureid is not null and
  10242. glt.goodsleveltypeid in (5, 6, 7) then
  10243. 0
  10244. else
  10245. 1
  10246. end) GoodCount,
  10247. sum(case
  10248. when defect.defectprocedureid is not null and
  10249. glt.goodsleveltypeid = 7 then
  10250. 1
  10251. else
  10252. 0
  10253. end) SubstandardCount,
  10254. sum(case
  10255. when defect.defectprocedureid is not null and
  10256. glt.goodsleveltypeid = 6 then
  10257. 1
  10258. else
  10259. 0
  10260. end) ReFireCount,
  10261. sum(case
  10262. when defect.defectprocedureid is not null and
  10263. glt.goodsleveltypeid = 5 then
  10264. 1
  10265. else
  10266. 0
  10267. end) BadCount
  10268. from (select distinct pd.barcode,
  10269. pd.mouldcode,
  10270. pd.kilncarbatchno
  10271. from tp_pm_productiondata pd
  10272. where pd.valueflag = '1'";
  10273. // 开始注浆--开始
  10274. if (se.beginCreateTime.HasValue)
  10275. {
  10276. sql = sql + " and pd.createtime>=:groutingDateStart ";
  10277. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  10278. }
  10279. //--and pd.createtime > 查询条件。开始注浆日期开始
  10280. // --and pd.procedureid = :in_rptSprocedureId
  10281. sql = sql + @"
  10282. and pd.procedureid = 11
  10283. and pd.AccountID = 1) pdbc
  10284. left join (select kcbc.barcode,
  10285. kcbc.kilncarbatchno,
  10286. kcbc.goodsleveltypeid,
  10287. kcbc.productiondataid
  10288. from (select pd.barcode,
  10289. pd.kilncarbatchno,
  10290. pd.goodsleveltypeid,
  10291. pd.productiondataid,
  10292. ROW_NUMBER() OVER(PARTITION BY pd.barcode, pd.kilncarbatchno ORDER BY pd.productiondataid desc) AS dataid
  10293. from tp_pm_productiondata pd
  10294. where pd.valueflag = '1'
  10295. --and pd.AccountID = :AccountID
  10296. and pd.AccountID = :AccountID";
  10297. //--and pd.createtime > 查询条件。开始注浆日期开始
  10298. // 开始注浆--开始
  10299. if (se.beginCreateTime.HasValue)
  10300. {
  10301. sql = sql + " and pd.createtime>=:groutingDateStart ";
  10302. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  10303. }
  10304. sql = sql + @" and length(pd.kilncarbatchno) > 0
  10305. and pd.modeltype = -1) kcbc
  10306. where kcbc.dataid = 1) glt
  10307. on pdbc.kilncarbatchno = glt.kilncarbatchno
  10308. and pdbc.barcode = glt.barcode
  10309. left join (select distinct productiondataid, defectprocedureid
  10310. from tp_pm_defect def
  10311. where def.valueflag = '1'";
  10312. //--and pd.createtime > 查询条件。开始注浆日期开始
  10313. // 开始注浆--开始
  10314. if (se.beginCreateTime.HasValue)
  10315. {
  10316. sql = sql + " and def.createtime>=:groutingDateStart ";
  10317. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  10318. }
  10319. sql = sql + @"
  10320. and def.AccountID = :AccountID) defect
  10321. on defect.productiondataid = glt.productiondataid
  10322. group by pdbc.mouldcode) zl
  10323. on zl.mouldcode = gd.mouldcode
  10324. left join tp_mst_goods gs
  10325. on gs.goodsid = gd.goodsid
  10326. left join tp_pc_groutinglinedetail gld
  10327. on gld.groutinglinedetailid = gd.groutinglinedetailid
  10328. and gld.mouldcode = gd.mouldcode
  10329. left join tp_sys_gmouldstatus gms
  10330. on gms.gmouldstatusid = gld.gmouldstatus
  10331. where 1=1
  10332. ";
  10333. // 产品编码
  10334. if (!string.IsNullOrEmpty(se.goodscode))
  10335. {
  10336. //sql = sql + " and gs.goodscode=:goodscode";
  10337. sql = sql + " and instr(gs.goodscode,:goodscode)>0";
  10338. parameters.Add(new OracleParameter(":goodscode", OracleDbType.NVarchar2, se.goodscode, ParameterDirection.Input));
  10339. }
  10340. // 成型工号
  10341. if (!string.IsNullOrEmpty(se.groutingUserCode))
  10342. {
  10343. //sql = sql + " and gd.usercode=:usercode";
  10344. sql = sql + " and instr(gd.usercode,:usercode)>0";
  10345. parameters.Add(new OracleParameter(":usercode", OracleDbType.NVarchar2, se.groutingUserCode, ParameterDirection.Input));
  10346. }
  10347. // 开始注浆--开始
  10348. if (se.beginCreateTime.HasValue)
  10349. {
  10350. sql = sql + " and gd.mingroutingdate>=:CreateTimeStart ";
  10351. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  10352. }
  10353. // 开始注浆--结束
  10354. if (se.endCreateTime.HasValue)
  10355. {
  10356. sql = sql + " and gd.mingroutingdate<=:CreateTimeEnd ";
  10357. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.endCreateTime.Value, ParameterDirection.Input));
  10358. }
  10359. // 结束注浆--开始
  10360. if (se.beginCreateTime2.HasValue)
  10361. {
  10362. sql = sql + " and gd.maxgroutingdate>=:CreateTimeotherStart2 ";
  10363. parameters.Add(new OracleParameter(":CreateTimeotherStart2", OracleDbType.Date, se.beginCreateTime2.Value, ParameterDirection.Input));
  10364. }
  10365. // 结束注浆--结束
  10366. if (se.endCreateTime2.HasValue)
  10367. {
  10368. sql = sql + " and gd.maxgroutingdate<=:CreateTimeotherEnd2";
  10369. parameters.Add(new OracleParameter(":CreateTimeotherEnd2", OracleDbType.Date, se.endCreateTime2.Value, ParameterDirection.Input));
  10370. }
  10371. // 模具状态
  10372. if (!string.IsNullOrEmpty(se.gmouldstatus))
  10373. {
  10374. sql = sql + " and gms.gmouldstatusid=:gmouldstatus";
  10375. parameters.Add(new OracleParameter(":gmouldstatus", OracleDbType.NVarchar2, se.gmouldstatus, ParameterDirection.Input));
  10376. }
  10377. sql = sql + " order by groutinglinecode,groutingmouldcode";
  10378. return sql;
  10379. }
  10380. #region 工资产量统计
  10381. /// <summary>
  10382. /// 取得RPT080102画面(成型工产量)的查询数据
  10383. /// </summary>
  10384. /// <param name="user">登录用户信息</param>
  10385. /// <param name="se">查询条件</param>
  10386. /// <returns>查询结果</returns>
  10387. public static ServiceResultEntity GetRPT080102SData(SUserInfo user, RPT080102_SE se)
  10388. {
  10389. IDBTransaction conn = null;
  10390. try
  10391. {
  10392. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  10393. conn.Connect();
  10394. OracleParameter[] paras = new OracleParameter[]{
  10395. new OracleParameter("in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  10396. new OracleParameter("in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
  10397. new OracleParameter("in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
  10398. new OracleParameter("in_deliverprocess",OracleDbType.Varchar2,se.DeliverProcedureIDS,ParameterDirection.Input),
  10399. new OracleParameter("in_IntoKilnProcess",OracleDbType.Varchar2,se.IntoProcedureIDS,ParameterDirection.Input),
  10400. new OracleParameter("in_OutKilnProcess",OracleDbType.Varchar2,se.OutProcedureIDS,ParameterDirection.Input),
  10401. new OracleParameter("in_QualityProcess",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
  10402. new OracleParameter("in_DefectFine",OracleDbType.Varchar2,se.DefectFineIDS,ParameterDirection.Input),
  10403. new OracleParameter("in_Impurity",OracleDbType.Varchar2,se.DefectIDS,ParameterDirection.Input),
  10404. new OracleParameter("out_Production",OracleDbType.RefCursor, ParameterDirection.Output),
  10405. new OracleParameter("out_Deliver",OracleDbType.RefCursor,ParameterDirection.Output),
  10406. new OracleParameter("out_Repair",OracleDbType.RefCursor,ParameterDirection.Output),
  10407. };
  10408. conn.IsCommandTimeout = false;
  10409. DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetDeliver_Production", paras);
  10410. ServiceResultEntity sre = new ServiceResultEntity();
  10411. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  10412. {
  10413. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10414. return sre;
  10415. }
  10416. sre.Data = new DataSet();
  10417. sre.Data = data;
  10418. conn.Commit();
  10419. return sre;
  10420. }
  10421. catch (Exception ex)
  10422. {
  10423. throw ex;
  10424. }
  10425. finally
  10426. {
  10427. if (conn != null &&
  10428. conn.ConnState == ConnectionState.Open)
  10429. {
  10430. conn.Disconnect();
  10431. }
  10432. }
  10433. }
  10434. /// <summary>
  10435. /// 取得RPT080103画面(烧成前工序产量明细表)的查询数据
  10436. /// </summary>
  10437. /// <param name="user">登录用户信息</param>
  10438. /// <param name="se">查询条件</param>
  10439. /// <returns>查询结果</returns>
  10440. public static ServiceResultEntity GetRPT080103SData(SUserInfo user, RPT080103_SE se)
  10441. {
  10442. IDBTransaction conn = null;
  10443. try
  10444. {
  10445. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  10446. conn.Connect();
  10447. OracleParameter[] paras = new OracleParameter[]{
  10448. new OracleParameter("in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  10449. new OracleParameter("in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
  10450. new OracleParameter("in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
  10451. new OracleParameter("in_Process",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
  10452. new OracleParameter("in_HandOverProcess",OracleDbType.Varchar2,se.HandOverProcedureIDS,ParameterDirection.Input),
  10453. new OracleParameter("in_OutKilnProcess",OracleDbType.Varchar2,se.OutProcedureIDS,ParameterDirection.Input),
  10454. new OracleParameter("in_QualityProcess",OracleDbType.Varchar2,se.QualityProcedureIDS,ParameterDirection.Input),
  10455. new OracleParameter("in_Defect1",OracleDbType.Varchar2,se.DefectIDS,ParameterDirection.Input),
  10456. new OracleParameter("in_Defect2",OracleDbType.Varchar2,se.DefectIDS2,ParameterDirection.Input),
  10457. new OracleParameter("out_Production",OracleDbType.RefCursor, ParameterDirection.Output),
  10458. };
  10459. conn.IsCommandTimeout = false;
  10460. //DataSet data = null;
  10461. //if (se.ProcedureIDS.Contains(","))
  10462. //{
  10463. // data = conn.ExecStoredProcedure("PRO_RPT_GetStandardProduction2", paras);
  10464. //}
  10465. //else
  10466. //{
  10467. // data = conn.ExecStoredProcedure("PRO_RPT_GetStandardProduction", paras);
  10468. //}
  10469. DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetStandard_Production", paras);
  10470. ServiceResultEntity sre = new ServiceResultEntity();
  10471. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  10472. {
  10473. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10474. return sre;
  10475. }
  10476. sre.Data = new DataSet();
  10477. sre.Data = data;
  10478. conn.Commit();
  10479. return sre;
  10480. }
  10481. catch (Exception ex)
  10482. {
  10483. throw ex;
  10484. }
  10485. finally
  10486. {
  10487. if (conn != null &&
  10488. conn.ConnState == ConnectionState.Open)
  10489. {
  10490. conn.Disconnect();
  10491. }
  10492. }
  10493. }
  10494. /// <summary>
  10495. /// 取得RPT080104画面(烧成工序产量明细表)的查询数据
  10496. /// </summary>
  10497. /// <param name="user">登录用户信息</param>
  10498. /// <param name="se">查询条件</param>
  10499. /// <returns>查询结果</returns>
  10500. public static ServiceResultEntity GetRPT080104SData(SUserInfo user, RPT080103_SE se)
  10501. {
  10502. IDBTransaction conn = null;
  10503. try
  10504. {
  10505. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  10506. conn.Connect();
  10507. OracleParameter[] paras = new OracleParameter[]{
  10508. new OracleParameter("in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  10509. new OracleParameter("in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
  10510. new OracleParameter("in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
  10511. new OracleParameter("in_Process",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
  10512. new OracleParameter("in_OutKilnProcess",OracleDbType.Varchar2,se.OutProcedureIDS,ParameterDirection.Input),
  10513. new OracleParameter("in_QualityProcess",OracleDbType.Varchar2,se.QualityProcedureIDS,ParameterDirection.Input),
  10514. new OracleParameter("in_Defect1",OracleDbType.Varchar2,se.DefectIDS,ParameterDirection.Input),
  10515. new OracleParameter("in_Defect2",OracleDbType.Varchar2,se.DefectIDS2,ParameterDirection.Input),
  10516. new OracleParameter("out_Production",OracleDbType.RefCursor, ParameterDirection.Output),
  10517. };
  10518. conn.IsCommandTimeout = false;
  10519. DataSet data = null;
  10520. if (se.ProcedureIDS.Contains(","))
  10521. {
  10522. data = conn.ExecStoredProcedure("PRO_RPT_GetKilnProduction2", paras);
  10523. }
  10524. else
  10525. {
  10526. data = conn.ExecStoredProcedure("PRO_RPT_GetKilnProduction", paras);
  10527. }
  10528. ServiceResultEntity sre = new ServiceResultEntity();
  10529. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  10530. {
  10531. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10532. return sre;
  10533. }
  10534. sre.Data = data;
  10535. //string sqlString =
  10536. //"SELECT kk.procedurename\n" +
  10537. //" ,kk.usercode\n" +
  10538. //" ,kk.kilncode\n" +
  10539. //" ,kk.kdate\n" +
  10540. //" ,COUNT(*) kcount\n" +
  10541. //" FROM (SELECT k.usercode\n" +
  10542. //" ,kiln.kilncode\n" +
  10543. //" ,p.procedurename\n" +
  10544. //" ,trunc(k.createtime) kdate\n" +
  10545. //" FROM tp_pm_kilncardata k\n" +
  10546. //" LEFT JOIN tp_mst_kiln kiln\n" +
  10547. //" ON kiln.kilnid = k.kilnid\n" +
  10548. //" LEFT JOIN tp_pc_procedure p\n" +
  10549. //" ON p.procedureid = k.procedureid\n" +
  10550. //" WHERE k.valueflag = '1'\n" +
  10551. //" AND k.AccountID = :in_AccountID\n" +
  10552. //" AND k.createtime >= :in_BeginDate\n" +
  10553. //" AND k.createtime <= :in_EndDate\n" +
  10554. //" AND instr(','|| :procedureids ||',', ','|| k.procedureid ||',' ) > 0) kk\n" +
  10555. //" GROUP BY kk.procedurename, kk.usercode, kk.kilncode, kk.kdate\n" +
  10556. //" ORDER BY kk.procedurename, kk.usercode, kk.kilncode, kk.kdate";
  10557. string sqlString = "WITH kilnData AS\n" +
  10558. " (SELECT k.usercode\n" +
  10559. " ,kiln.kilncode\n" +
  10560. " ,p.procedurename\n" +
  10561. " ,trunc(k.createtime) kdate\n" +
  10562. " ,k.userid\n" +
  10563. " ,k.procedureid\n" +
  10564. " ,k.kilnid\n" +
  10565. " ,k.KILNCARBATCHNO\n" +
  10566. " FROM tp_pm_kilncardata k\n" +
  10567. " LEFT JOIN tp_mst_kiln kiln\n" +
  10568. " ON kiln.kilnid = k.kilnid\n" +
  10569. " LEFT JOIN tp_pc_procedure p\n" +
  10570. " ON p.procedureid = k.procedureid\n" +
  10571. " WHERE k.valueflag = '1'\n" +
  10572. " AND k.AccountID = :in_AccountID\n" +
  10573. " AND k.createtime >= :in_BeginDate\n" +
  10574. " AND k.createtime <= :in_EndDate\n" +
  10575. " AND instr(',' || :procedureids || ',', ',' || k.procedureid || ',') > 0)\n" +
  10576. "SELECT kd.procedurename\n" +
  10577. " ,kd.usercode\n" +
  10578. " ,kd.kilncode\n" +
  10579. " ,kd.kdate\n" +
  10580. " ,kd.kcount\n" +
  10581. " ,kpd.kpcount\n" +
  10582. " FROM (SELECT kk.procedurename\n" +
  10583. " ,kk.usercode\n" +
  10584. " ,kk.kilncode\n" +
  10585. " ,kk.kdate\n" +
  10586. " ,kk.procedureid\n" +
  10587. " ,kk.userid\n" +
  10588. " ,kk.kilnid\n" +
  10589. " ,COUNT(*) kcount\n" +
  10590. " FROM kilnData kk\n" +
  10591. " GROUP BY kk.procedurename\n" +
  10592. " ,kk.usercode\n" +
  10593. " ,kk.kilncode\n" +
  10594. " ,kk.kdate\n" +
  10595. " ,kk.procedureid\n" +
  10596. " ,kk.userid\n" +
  10597. " ,kk.kilnid) kd\n" +
  10598. " LEFT JOIN (SELECT kk.kdate\n" +
  10599. " ,kk.procedureid\n" +
  10600. " ,kk.userid\n" +
  10601. " ,kk.kilnid\n" +
  10602. " ,COUNT(*) kpcount\n" +
  10603. " FROM kilnData kk\n" +
  10604. " INNER JOIN tp_pm_productiondata pd\n" +
  10605. " ON pd.valueflag = '1'\n" +
  10606. " AND pd.procedureid = kk.procedureid\n" +
  10607. " AND pd.kilnid = kk.kilnid\n" +
  10608. " AND pd.KILNCARBATCHNO = kk.KILNCARBATCHNO\n" +
  10609. " GROUP BY kk.kdate, kk.procedureid, kk.userid, kk.kilnid) kpd\n" +
  10610. " ON kpd.kdate = kd.kdate\n" +
  10611. " AND kpd.procedureid = kd.procedureid\n" +
  10612. " AND kpd.userid = kd.userid\n" +
  10613. " AND kpd.kilnid = kd.kilnid\n" +
  10614. " ORDER BY kd.procedurename, kd.usercode, kd.kilncode, kd.kdate";
  10615. OracleParameter[] parascount = new OracleParameter[]{
  10616. new OracleParameter(":in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  10617. new OracleParameter(":in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
  10618. new OracleParameter(":in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
  10619. new OracleParameter(":procedureids",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
  10620. };
  10621. DataTable dt = conn.GetSqlResultToDt(sqlString, parascount);
  10622. if (dt != null)
  10623. {
  10624. sre.Data.Tables.Add(dt);
  10625. }
  10626. conn.Commit();
  10627. return sre;
  10628. }
  10629. catch (Exception ex)
  10630. {
  10631. throw ex;
  10632. }
  10633. finally
  10634. {
  10635. if (conn != null &&
  10636. conn.ConnState == ConnectionState.Open)
  10637. {
  10638. conn.Disconnect();
  10639. }
  10640. }
  10641. }
  10642. #endregion
  10643. /// <summary>
  10644. /// 使用存储过程PRO_PM_GetProductionData获取生产工序计件数据
  10645. /// </summary>
  10646. /// <param name="searchEntity">生产数据实体类</param>
  10647. /// <param name="user">用户基本信息</param>
  10648. /// <returns>DataTable</returns>
  10649. public static DataTable GetProductionData(SearchProductionDataEntity searchEntity, SUserInfo user)
  10650. {
  10651. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10652. string procsql = "PRO_RPT_GetProductionData";
  10653. try
  10654. {
  10655. IDataParameter[] paras = new OracleParameter[]
  10656. {
  10657. new OracleParameter("in_procedureList",OracleDbType.Varchar2, searchEntity.ProcedureIDS, ParameterDirection.Input),
  10658. new OracleParameter("in_LineID", OracleDbType.Int32,searchEntity.ProductionLineID, ParameterDirection.Input),
  10659. new OracleParameter("in_barCode", OracleDbType.Varchar2,searchEntity.BarCode, ParameterDirection.Input),
  10660. new OracleParameter("in_goodsCode", OracleDbType.Varchar2,searchEntity.GoodsCode, ParameterDirection.Input),
  10661. new OracleParameter("in_goodsName", OracleDbType.Varchar2,searchEntity.GoodsName, ParameterDirection.Input),
  10662. new OracleParameter("in_userCode", OracleDbType.Varchar2,searchEntity.UserCode, ParameterDirection.Input),
  10663. new OracleParameter("in_organizationID", OracleDbType.Int32,searchEntity.OrganizationID, ParameterDirection.Input),
  10664. new OracleParameter("in_remarks", OracleDbType.Varchar2,searchEntity.Remarks, ParameterDirection.Input),
  10665. new OracleParameter("in_isReworked", OracleDbType.Varchar2,searchEntity.IsRework, ParameterDirection.Input),
  10666. new OracleParameter("in_begindate", OracleDbType.Date,searchEntity.BeginDate, ParameterDirection.Input),
  10667. new OracleParameter("in_enddate", OracleDbType.Date,searchEntity.EndDate, ParameterDirection.Input),
  10668. new OracleParameter("in_accountID", OracleDbType.Int32,user.AccountID, ParameterDirection.Input),
  10669. new OracleParameter("in_userID", OracleDbType.Int32,user.UserID, ParameterDirection.Input),
  10670. new OracleParameter("in_kilnCode", OracleDbType.Varchar2,searchEntity.KilnCode, ParameterDirection.Input),
  10671. new OracleParameter("in_kilnCarCode", OracleDbType.Varchar2,searchEntity.KilnCarCode, ParameterDirection.Input),
  10672. new OracleParameter("in_kilnCarPosition", OracleDbType.Int32,searchEntity.KilnCarPosition, ParameterDirection.Input),
  10673. new OracleParameter("in_currentUserID", OracleDbType.Int32,user.UserID, ParameterDirection.Input),
  10674. new OracleParameter("out_result", OracleDbType.RefCursor, ParameterDirection.Output),
  10675. new OracleParameter("in_goodsTypeCode", OracleDbType.Varchar2,searchEntity.GoodsTypeCode, ParameterDirection.Input),
  10676. };
  10677. oracleConn.Open();
  10678. DataSet returnDs = oracleConn.ExecStoredProcedure(procsql, paras);
  10679. if (returnDs != null && returnDs.Tables.Count > 0)
  10680. {
  10681. return returnDs.Tables[0];
  10682. }
  10683. else
  10684. {
  10685. return null;
  10686. }
  10687. }
  10688. catch (Exception ex)
  10689. {
  10690. throw ex;
  10691. }
  10692. finally
  10693. {
  10694. if (oracleConn.ConnState == ConnectionState.Open)
  10695. {
  10696. oracleConn.Close();
  10697. }
  10698. }
  10699. }
  10700. /// <summary>
  10701. /// 取得RPT080106(温湿计明细)的汇总信息查询数据
  10702. /// </summary>
  10703. /// <param name="user">登录用户信息</param>
  10704. /// <param name="se">查询条件</param>
  10705. /// <returns>查询结果</returns>
  10706. public static ServiceResultEntity GetRPT080106IData(SUserInfo user, CelsiusRecordEntity se)
  10707. {
  10708. IDBConnection conn = null;
  10709. try
  10710. {
  10711. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10712. List<OracleParameter> parameters = new List<OracleParameter>();
  10713. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080106ISQL(user, se, ref parameters));
  10714. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  10715. ServiceResultEntity sre = new ServiceResultEntity();
  10716. if (data == null || data.Rows.Count == 0)
  10717. {
  10718. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10719. return sre;
  10720. }
  10721. sre.Data = new DataSet();
  10722. sre.Data.Tables.Add(data);
  10723. return sre;
  10724. }
  10725. catch (Exception ex)
  10726. {
  10727. throw ex;
  10728. }
  10729. finally
  10730. {
  10731. if (conn != null &&
  10732. conn.ConnState == ConnectionState.Open)
  10733. {
  10734. conn.Close();
  10735. }
  10736. }
  10737. }
  10738. /// <summary>
  10739. /// 取得RPT080106(温湿计明细)的汇总信息查询数据sql
  10740. /// </summary>
  10741. /// <returns>sql</returns>
  10742. private static string GetRPT080106ISQL(SUserInfo user, CelsiusRecordEntity se, ref List<OracleParameter> parameters)
  10743. {
  10744. string selSql = @"Select cr.*,t.*,to_char(cr.RecordDate,'mm-dd hh24:mi') as RecordDateStr from TP_PM_CelsiusRecord cr
  10745. Left join TP_MST_User u On cr.ThermometerID = u.UserId
  10746. Inner join TP_MST_Thermometer t On cr.ThermometerID = t.ThermometerID
  10747. Where cr.AccountID =:AccountID and cr.ValueFlag = '1' ";
  10748. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  10749. if (!string.IsNullOrEmpty(se.ThermometerIDS))
  10750. {
  10751. selSql = selSql + " AND instr(','||:ThermometerIDS||',',','||cr.ThermometerID||',')>0 ";
  10752. parameters.Add(new OracleParameter(":ThermometerIDS", OracleDbType.NVarchar2, se.ThermometerIDS, ParameterDirection.Input));
  10753. }
  10754. if (!string.IsNullOrEmpty(se.Remarks))
  10755. {
  10756. selSql = selSql + " AND instr(cr.Remarks,:Remarks) >0 ";
  10757. parameters.Add(new OracleParameter(":Remarks", OracleDbType.NVarchar2, se.Remarks, ParameterDirection.Input));
  10758. }
  10759. if (se.RecordDate.HasValue)
  10760. {
  10761. selSql = selSql + " AND cr.CreateTime>= :CreateTimeStart ";
  10762. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.RecordDate.Value, ParameterDirection.Input));
  10763. }
  10764. if (se.RecordDateEnd.HasValue)
  10765. {
  10766. selSql = selSql + " AND cr.CreateTime<= :CreateTimeEnd ";
  10767. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.RecordDateEnd.Value, ParameterDirection.Input));
  10768. }
  10769. selSql +=
  10770. // 温湿计查看权限
  10771. " AND EXISTS (SELECT UP.PurviewID" +
  10772. " FROM TP_MST_UserPurview UP" +
  10773. " WHERE UP.PurviewType = '" + (int)Constant.PurviewType.ViewCelsius + "'" +
  10774. " AND (UP.PurviewID = -1 OR UP.PurviewID = CR.ThermometerID)" +
  10775. " AND UP.UserId = :UPUserId)";
  10776. parameters.Add(new OracleParameter(":UPUserId", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  10777. selSql = selSql + " order by RecordDate asc";
  10778. return selSql;
  10779. }
  10780. /// <summary>
  10781. /// 取得RPT030110画面(半检登记汇总表)的汇总信息查询数据
  10782. /// </summary>
  10783. /// <param name="user">登录用户信息</param>
  10784. /// <param name="se">查询条件</param>
  10785. /// <returns>查询结果</returns>
  10786. public static ServiceResultEntity GetRPT030110Data(SUserInfo user, SemiCheckEntity se)
  10787. {
  10788. IDBConnection conn = null;
  10789. try
  10790. {
  10791. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10792. List<OracleParameter> parameters = new List<OracleParameter>();
  10793. string sql = ReportModuleLogic.GetRPT030110SSQL(user, se, ref parameters);
  10794. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  10795. ServiceResultEntity sre = new ServiceResultEntity();
  10796. if (data == null || data.Rows.Count == 0)
  10797. {
  10798. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10799. return sre;
  10800. }
  10801. sre.Data = new DataSet();
  10802. sre.Data.Tables.Add(data);
  10803. return sre;
  10804. }
  10805. catch (Exception ex)
  10806. {
  10807. throw ex;
  10808. }
  10809. finally
  10810. {
  10811. if (conn != null &&
  10812. conn.ConnState == ConnectionState.Open)
  10813. {
  10814. conn.Close();
  10815. }
  10816. }
  10817. }
  10818. /// <summary>
  10819. /// 获取RPT030110画面(半检登记汇总表)的汇总信息查询sql
  10820. /// </summary>
  10821. /// <returns>sql</returns>
  10822. private static string GetRPT030110SSQL(SUserInfo user, SemiCheckEntity se, ref List<OracleParameter> parameters)
  10823. {
  10824. parameters.Add(new OracleParameter(":accountid", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  10825. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  10826. #region
  10827. // string sqlString = @"
  10828. // SELECT t.reworkprocedureid -- 返工工序id
  10829. // ,decode(gid,
  10830. // 7,
  10831. // '总计',
  10832. // 3,
  10833. // '合计【' || t.reworkprocedurename || '】',
  10834. // 0,
  10835. // t.reworkprocedurename,
  10836. // '--') reworkprocedurename -- 返工工序
  10837. // ,t.goodstypecode2 -- 产品二级类别
  10838. // ,decode(gid,
  10839. // 1,
  10840. // '小计【' || t.goodstypename2 || '】',
  10841. // 0,
  10842. // t.goodstypename2,
  10843. // '--') goodstypename2 -- 产品二级类别
  10844. // ,t.reworkuserid -- 返工工号id
  10845. // ,decode(gid, 0, t.reworkusercode, '--') reworkusercode -- 返工工号
  10846. // ,t.goodsid -- 产品id
  10847. // ,decode(gid, 0, t.goodscode, '--') goodscode -- 产品编码
  10848. // ,decode(gid, 0, t.goodstypename, '--') goodstypename -- 产品类别
  10849. // ,t.reworkcount -- 返工数
  10850. // ,t.badcount -- 不合格数
  10851. // ,t.regoodcount -- 复检合格数
  10852. // ,t.rebadcount -- 复检不合格数
  10853. // ,t.renocount -- 未复检
  10854. // --,t.renocountsum -- 待返工
  10855. // ,(SELECT COUNT(*)
  10856. // FROM tp_pm_semicheck sci
  10857. // WHERE sci.valueflag = '1'
  10858. // AND sci.backoutflag = '0'
  10859. // AND sci.semichecktype = 1
  10860. // AND sci.resemichecktype = 0
  10861. // AND (t.reworkprocedureid is null or sci.reworkprocedureid = t.reworkprocedureid)
  10862. // AND (t.goodsid is null or sci.goodsid = t.goodsid)
  10863. // AND (t.reworkuserid is null or sci.reworkuserid = t.reworkuserid)) AS renocountsum
  10864. // FROM (SELECT grouping_id(sc.reworkprocedureid, gt2.goodstypecode, g.goodsid) gid
  10865. // ,sc.reworkprocedureid
  10866. // ,rp.procedurename reworkprocedurename
  10867. // ,gt2.goodstypecode goodstypecode2
  10868. // ,gt2.goodstypename goodstypename2
  10869. // ,sc.reworkuserid
  10870. // ,sc.reworkusercode
  10871. // ,g.goodsid
  10872. // ,g.goodscode
  10873. // ,gt.goodstypename
  10874. // , SUM(CASE
  10875. // WHEN sc.semichecktype = 1 THEN
  10876. // 1
  10877. // ELSE
  10878. // 0
  10879. // END) reworkcount
  10880. // , SUM(CASE
  10881. // WHEN sc.semichecktype = 2 THEN
  10882. // 1
  10883. // ELSE
  10884. // 0
  10885. // END) badcount
  10886. // , SUM(CASE
  10887. // WHEN sc.semichecktype = 1 AND sc.resemichecktype = 0 THEN
  10888. // 1
  10889. // ELSE
  10890. // 0
  10891. // END) renocount
  10892. // , SUM(CASE
  10893. // WHEN sc.semichecktype = 1 AND sc.resemichecktype = 1 THEN
  10894. // 1
  10895. // ELSE
  10896. // 0
  10897. // END) regoodcount
  10898. // , SUM(CASE
  10899. // WHEN sc.semichecktype = 1 AND sc.resemichecktype = 2 THEN
  10900. // 1
  10901. // ELSE
  10902. // 0
  10903. // END) rebadcount
  10904. // --,(select count(*) from tp_pm_semicheck sci where sci.valueflag = '1' and sci.backoutflag = '0' and sci.semichecktype = 1
  10905. // -- and sci.resemichecktype = 0 and sci.reworkprocedureid = sc.reworkprocedureid and sci.reworkuserid = sc.reworkuserid and sci.goodsid = g.goodsid) as renocountsum
  10906. // --FROM tp_pm_semicheck sc
  10907. // FROM (SELECT semicheckid
  10908. // ,barcode
  10909. // ,productionlineid
  10910. // ,procedureid
  10911. // ,proceduretime
  10912. // ,proceduremodel
  10913. // ,modeltype
  10914. // ,organizationid
  10915. // ,goodsid
  10916. // ,goodscode
  10917. // ,userid
  10918. // ,usercode
  10919. // ,productiondataid
  10920. // ,logoid
  10921. // ,ispublicbody
  10922. // ,specialrepairflag
  10923. // ,goodslevelid
  10924. // ,goodsleveltypeid
  10925. // ,groutingdailyid
  10926. // ,groutingdailydetailid
  10927. // ,groutinglineid
  10928. // ,groutinglinecode
  10929. // ,groutinglinename
  10930. // ,gmouldtypeid
  10931. // ,canmanytimes
  10932. // ,groutinglinedetailid
  10933. // ,groutingdate
  10934. // ,groutingmouldcode
  10935. // ,mouldcode
  10936. // ,groutinguserid
  10937. // ,groutingusercode
  10938. // ,groutingnum
  10939. // ,semichecktype
  10940. // ,semicheckuserid
  10941. // ,semicheckusercode
  10942. // ,semichecktime
  10943. // ,reworkprocedureid
  10944. // ,reworkprocedurecode
  10945. // ,reworkuserid
  10946. // ,reworkusercode
  10947. // ,resemichecktype
  10948. // ,resemicheckuserid
  10949. // ,resemicheckusercode
  10950. // ,resemichecktime
  10951. // ,backoutflag
  10952. // ,backouttime
  10953. // ,backoutuserid
  10954. // ,backoutusercode
  10955. // ,remarks
  10956. // ,createtime
  10957. // ,createuserid
  10958. // ,updateuserid
  10959. // FROM tp_pm_semicheck sc
  10960. // WHERE sc.accountid = :accountid
  10961. // AND sc.valueflag = '1'
  10962. // AND sc.semichecktype = 1
  10963. // AND sc.backoutflag = '0'
  10964. // UNION ALL
  10965. // SELECT DISTINCT sc.semicheckid
  10966. // ,sc.barcode
  10967. // ,sc.productionlineid
  10968. // ,sc.procedureid
  10969. // ,sc.proceduretime
  10970. // ,sc.proceduremodel
  10971. // ,sc.modeltype
  10972. // ,sc.organizationid
  10973. // ,sc.goodsid
  10974. // ,sc.goodscode
  10975. // ,sc.userid
  10976. // ,sc.usercode
  10977. // ,sc.productiondataid
  10978. // ,sc.logoid
  10979. // ,sc.ispublicbody
  10980. // ,sc.specialrepairflag
  10981. // ,sc.goodslevelid
  10982. // ,sc.goodsleveltypeid
  10983. // ,sc.groutingdailyid
  10984. // ,sc.groutingdailydetailid
  10985. // ,sc.groutinglineid
  10986. // ,sc.groutinglinecode
  10987. // ,sc.groutinglinename
  10988. // ,sc.gmouldtypeid
  10989. // ,sc.canmanytimes
  10990. // ,sc.groutinglinedetailid
  10991. // ,sc.groutingdate
  10992. // ,sc.groutingmouldcode
  10993. // ,sc.mouldcode
  10994. // ,sc.groutinguserid
  10995. // ,sc.groutingusercode
  10996. // ,sc.groutingnum
  10997. // ,sc.semichecktype
  10998. // ,sc.semicheckuserid
  10999. // ,sc.semicheckusercode
  11000. // ,sc.semichecktime
  11001. // --,sc.reworkprocedureid
  11002. // --,sc.reworkprocedurecode
  11003. // --,sc.reworkuserid
  11004. // --,sc.reworkusercode
  11005. // ,scd.defectprocedureid
  11006. // ,scdp.procedurename
  11007. // ,scd.defectuserid
  11008. // ,scd.defectusercode
  11009. // ,sc.resemichecktype
  11010. // ,sc.resemicheckuserid
  11011. // ,sc.resemicheckusercode
  11012. // ,sc.resemichecktime
  11013. // ,sc.backoutflag
  11014. // ,sc.backouttime
  11015. // ,sc.backoutuserid
  11016. // ,sc.backoutusercode
  11017. // ,sc.remarks
  11018. // ,sc.createtime
  11019. // ,sc.createuserid
  11020. // ,sc.updateuserid
  11021. // FROM tp_pm_semicheck sc
  11022. // LEFT JOIN TP_PM_SemiCheckDefect scd
  11023. // ON sc.semicheckid = scd.semicheckid
  11024. // LEFT JOIN tp_pc_procedure scdp
  11025. // ON scdp.procedureid = scd.defectprocedureid
  11026. // WHERE sc.accountid = :accountid
  11027. // AND sc.valueflag = '1'
  11028. // AND sc.semichecktype = 2
  11029. // AND sc.backoutflag = '0'
  11030. // ) sc
  11031. // LEFT JOIN tp_pc_procedure rp
  11032. // ON rp.procedureid = sc.reworkprocedureid
  11033. // INNER JOIN tp_mst_goods g
  11034. // ON g.goodsid = sc.goodsid
  11035. // INNER JOIN tp_mst_goodstype gt
  11036. // ON gt.goodstypeid = g.goodstypeid
  11037. // INNER JOIN tp_mst_goodstype gt2
  11038. // ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)
  11039. // AND gt2.accountid = gt.accountid
  11040. // INNER join TP_PM_GroutingDailyDetail GroutingDailyDetail
  11041. // ON GroutingDailyDetail.GroutingDailyDetailID=sc.GroutingDailyDetailID
  11042. // 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))";
  11043. #endregion
  11044. string sqlString = "SELECT t.reworkprocedureid -- 返工工序id\n" +
  11045. " ,decode(gid,\n" +
  11046. " 7,\n" +
  11047. " '总计',\n" +
  11048. " 3,\n" +
  11049. " '合计【' || t.reworkprocedurename || '】',\n" +
  11050. " 0,\n" +
  11051. " t.reworkprocedurename,\n" +
  11052. " '--') reworkprocedurename -- 返工工序\n" +
  11053. " ,t.goodstypecode2 -- 产品二级类别\n" +
  11054. " ,decode(gid,\n" +
  11055. " 1,\n" +
  11056. " '小计【' || t.goodstypename2 || '】',\n" +
  11057. " 0,\n" +
  11058. " t.goodstypename2,\n" +
  11059. " '--') goodstypename2 -- 产品二级类别\n" +
  11060. " ,t.reworkuserid -- 返工工号id\n" +
  11061. " ,decode(gid, 0, t.reworkusercode, '--') reworkusercode -- 返工工号\n" +
  11062. " ,t.goodsid -- 产品id\n" +
  11063. " ,decode(gid, 0, t.goodscode, '--') goodscode -- 产品编码\n" +
  11064. " ,decode(gid, 0, t.goodstypename, '--') goodstypename -- 产品类别\n" +
  11065. " ,t.reworkcount -- 返工数\n" +
  11066. " ,t.badcount -- 不合格数\n" +
  11067. " ,t.regoodcount -- 复检合格数\n" +
  11068. " ,t.rebadcount -- 复检不合格数\n" +
  11069. " ,t.renocount -- 未复检\n" +
  11070. " ,t.renocountsum -- 待返工\n" +
  11071. " FROM (SELECT grouping_id(sct.reworkprocedureid,\n" +
  11072. " sct.goodstypecode2,\n" +
  11073. " sct.goodsid) gid\n" +
  11074. " ,sct.displayno\n" +
  11075. " ,sct.reworkprocedureid\n" +
  11076. " ,sct.reworkprocedurename\n" +
  11077. " ,sct.goodstypecode2\n" +
  11078. " ,sct.goodstypename2\n" +
  11079. " ,sct.reworkuserid\n" +
  11080. " ,sct.reworkusercode\n" +
  11081. " ,sct.goodsid\n" +
  11082. " ,sct.goodscode\n" +
  11083. " ,sct.goodstypename\n" +
  11084. " ,SUM(sct.reworkcount) reworkcount\n" +
  11085. " ,SUM(sct. badcount) badcount\n" +
  11086. " ,SUM(sct. renocount) renocount\n" +
  11087. " ,SUM(sct.regoodcount) regoodcount\n" +
  11088. " ,SUM(sct.rebadcount) rebadcount\n" +
  11089. " ,SUM(sct.renocountsum) renocountsum\n" +
  11090. " FROM (SELECT rp.displayno\n" +
  11091. " ,sc.reworkprocedureid\n" +
  11092. " ,rp.procedurename reworkprocedurename\n" +
  11093. " ,gt2.goodstypecode goodstypecode2\n" +
  11094. " ,gt2.goodstypename goodstypename2\n" +
  11095. " ,sc.reworkuserid\n" +
  11096. " ,sc.reworkusercode\n" +
  11097. " ,g.goodsid\n" +
  11098. " ,g.goodscode\n" +
  11099. " ,gt.goodstypename\n" +
  11100. " , SUM(CASE\n" +
  11101. " WHEN sc.semichecktype = 1 THEN\n" +
  11102. " 1\n" +
  11103. " ELSE\n" +
  11104. " 0\n" +
  11105. " END) reworkcount\n" +
  11106. " , SUM(CASE\n" +
  11107. " WHEN sc.semichecktype = 2 THEN\n" +
  11108. " 1\n" +
  11109. " ELSE\n" +
  11110. " 0\n" +
  11111. " END) badcount\n" +
  11112. " , SUM(CASE\n" +
  11113. " WHEN sc.semichecktype = 1 AND sc.resemichecktype = 0 THEN\n" +
  11114. " 1\n" +
  11115. " ELSE\n" +
  11116. " 0\n" +
  11117. " END) renocount\n" +
  11118. " , SUM(CASE\n" +
  11119. " WHEN sc.semichecktype = 1 AND sc.resemichecktype = 1 THEN\n" +
  11120. " 1\n" +
  11121. " ELSE\n" +
  11122. " 0\n" +
  11123. " END) regoodcount\n" +
  11124. " , SUM(CASE\n" +
  11125. " WHEN sc.semichecktype = 1 AND sc.resemichecktype = 2 THEN\n" +
  11126. " 1\n" +
  11127. " ELSE\n" +
  11128. " 0\n" +
  11129. " END) rebadcount\n" +
  11130. " ,(SELECT COUNT(*)\n" +
  11131. " FROM tp_pm_semicheck sci\n" +
  11132. " WHERE sci.valueflag = '1'\n" +
  11133. " AND sci.backoutflag = '0'\n" +
  11134. " AND sci.semichecktype = 1\n" +
  11135. " AND sci.resemichecktype = 0\n" +
  11136. " AND sci.accountid = :accountid\n" +
  11137. " AND sci.reworkprocedureid = sc.reworkprocedureid\n" +
  11138. " AND sci.reworkuserid = sc.reworkuserid\n" +
  11139. " AND sci.goodsid = g.goodsid) AS renocountsum\n" +
  11140. " FROM (SELECT semicheckid\n" +
  11141. " ,barcode\n" +
  11142. " ,productionlineid\n" +
  11143. " ,procedureid\n" +
  11144. " ,proceduretime\n" +
  11145. " ,proceduremodel\n" +
  11146. " ,modeltype\n" +
  11147. " ,organizationid\n" +
  11148. " ,goodsid\n" +
  11149. " ,goodscode\n" +
  11150. " ,userid\n" +
  11151. " ,usercode\n" +
  11152. " ,productiondataid\n" +
  11153. " ,logoid\n" +
  11154. " ,ispublicbody\n" +
  11155. " ,specialrepairflag\n" +
  11156. " ,goodslevelid\n" +
  11157. " ,goodsleveltypeid\n" +
  11158. " ,groutingdailyid\n" +
  11159. " ,groutingdailydetailid\n" +
  11160. " ,groutinglineid\n" +
  11161. " ,groutinglinecode\n" +
  11162. " ,groutinglinename\n" +
  11163. " ,gmouldtypeid\n" +
  11164. " ,canmanytimes\n" +
  11165. " ,groutinglinedetailid\n" +
  11166. " ,groutingdate\n" +
  11167. " ,groutingmouldcode\n" +
  11168. " ,mouldcode\n" +
  11169. " ,groutinguserid\n" +
  11170. " ,groutingusercode\n" +
  11171. " ,groutingnum\n" +
  11172. " ,semichecktype\n" +
  11173. " ,semicheckuserid\n" +
  11174. " ,semicheckusercode\n" +
  11175. " ,semichecktime\n" +
  11176. " ,reworkprocedureid\n" +
  11177. " ,reworkprocedurecode\n" +
  11178. " ,reworkuserid\n" +
  11179. " ,reworkusercode\n" +
  11180. " ,resemichecktype\n" +
  11181. " ,resemicheckuserid\n" +
  11182. " ,resemicheckusercode\n" +
  11183. " ,resemichecktime\n" +
  11184. " ,backoutflag\n" +
  11185. " ,backouttime\n" +
  11186. " ,backoutuserid\n" +
  11187. " ,backoutusercode\n" +
  11188. " ,remarks\n" +
  11189. " ,createtime\n" +
  11190. " ,createuserid\n" +
  11191. " ,updateuserid\n" +
  11192. " FROM tp_pm_semicheck sc\n" +
  11193. " WHERE sc.accountid = :accountid\n" +
  11194. " AND sc.valueflag = '1'\n" +
  11195. " AND sc.semichecktype = 1\n" +
  11196. " AND sc.backoutflag = '0'\n" +
  11197. " UNION ALL\n" +
  11198. " SELECT DISTINCT sc.semicheckid\n" +
  11199. " ,sc.barcode\n" +
  11200. " ,sc.productionlineid\n" +
  11201. " ,sc.procedureid\n" +
  11202. " ,sc.proceduretime\n" +
  11203. " ,sc.proceduremodel\n" +
  11204. " ,sc.modeltype\n" +
  11205. " ,sc.organizationid\n" +
  11206. " ,sc.goodsid\n" +
  11207. " ,sc.goodscode\n" +
  11208. " ,sc.userid\n" +
  11209. " ,sc.usercode\n" +
  11210. " ,sc.productiondataid\n" +
  11211. " ,sc.logoid\n" +
  11212. " ,sc.ispublicbody\n" +
  11213. " ,sc.specialrepairflag\n" +
  11214. " ,sc.goodslevelid\n" +
  11215. " ,sc.goodsleveltypeid\n" +
  11216. " ,sc.groutingdailyid\n" +
  11217. " ,sc.groutingdailydetailid\n" +
  11218. " ,sc.groutinglineid\n" +
  11219. " ,sc.groutinglinecode\n" +
  11220. " ,sc.groutinglinename\n" +
  11221. " ,sc.gmouldtypeid\n" +
  11222. " ,sc.canmanytimes\n" +
  11223. " ,sc.groutinglinedetailid\n" +
  11224. " ,sc.groutingdate\n" +
  11225. " ,sc.groutingmouldcode\n" +
  11226. " ,sc.mouldcode\n" +
  11227. " ,sc.groutinguserid\n" +
  11228. " ,sc.groutingusercode\n" +
  11229. " ,sc.groutingnum\n" +
  11230. " ,sc.semichecktype\n" +
  11231. " ,sc.semicheckuserid\n" +
  11232. " ,sc.semicheckusercode\n" +
  11233. " ,sc.semichecktime\n" +
  11234. " --,sc.reworkprocedureid\n" +
  11235. " --,sc.reworkprocedurecode\n" +
  11236. " --,sc.reworkuserid\n" +
  11237. " --,sc.reworkusercode\n" +
  11238. " ,scd.defectprocedureid\n" +
  11239. " ,scdp.procedurename\n" +
  11240. " ,scd.defectuserid\n" +
  11241. " ,scd.defectusercode\n" +
  11242. " ,sc.resemichecktype\n" +
  11243. " ,sc.resemicheckuserid\n" +
  11244. " ,sc.resemicheckusercode\n" +
  11245. " ,sc.resemichecktime\n" +
  11246. " ,sc.backoutflag\n" +
  11247. " ,sc.backouttime\n" +
  11248. " ,sc.backoutuserid\n" +
  11249. " ,sc.backoutusercode\n" +
  11250. " ,sc.remarks\n" +
  11251. " ,sc.createtime\n" +
  11252. " ,sc.createuserid\n" +
  11253. " ,sc.updateuserid\n" +
  11254. " FROM tp_pm_semicheck sc\n" +
  11255. " LEFT JOIN TP_PM_SemiCheckDefect scd\n" +
  11256. " ON sc.semicheckid = scd.semicheckid\n" +
  11257. " AND scd.valueflag='1'\n" +
  11258. " LEFT JOIN tp_pc_procedure scdp\n" +
  11259. " ON scdp.procedureid = scd.defectprocedureid\n" +
  11260. " WHERE sc.accountid = :accountid\n" +
  11261. " AND sc.valueflag = '1'\n" +
  11262. " AND sc.semichecktype = 2\n" +
  11263. " AND sc.backoutflag = '0') sc\n" +
  11264. " LEFT JOIN tp_pc_procedure rp\n" +
  11265. " ON rp.procedureid = sc.reworkprocedureid\n" +
  11266. " INNER JOIN tp_mst_goods g\n" +
  11267. " ON g.goodsid = sc.goodsid\n" +
  11268. " INNER JOIN tp_mst_goodstype gt\n" +
  11269. " ON gt.goodstypeid = g.goodstypeid\n" +
  11270. " INNER JOIN tp_mst_goodstype gt2\n" +
  11271. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  11272. " AND gt2.accountid = gt.accountid\n" +
  11273. " INNER JOIN TP_PM_GroutingDailyDetail GroutingDailyDetail\n" +
  11274. " ON GroutingDailyDetail.GroutingDailyDetailID =\n" +
  11275. " sc.GroutingDailyDetailID\n" //+
  11276. //" WHERE EXISTS (SELECT 1\n" +
  11277. //" FROM TP_MST_UserPurview up\n" +
  11278. //" WHERE up.PurviewType = 9\n" +
  11279. //" AND up.UserID = :UserID\n" +
  11280. //" AND (up.PurviewID = -1 OR\n" +
  11281. //" up.PurviewID = sc.procedureid))\n"
  11282. ;
  11283. // 完成工序集
  11284. if (!string.IsNullOrEmpty(se.CProcedureIDS))
  11285. {
  11286. sqlString += " AND instr(','||:procedureids||',', ',' || sc.procedureid || ',') > 0";
  11287. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, se.CProcedureIDS, ParameterDirection.Input));
  11288. }
  11289. // 完成时间起始
  11290. if (se.CDateTimeStart.HasValue)
  11291. {
  11292. sqlString = sqlString + " AND sc.ProcedureTime >= :CDateTimeStart ";
  11293. parameters.Add(new OracleParameter(":CDateTimeStart", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11294. }
  11295. // 完成时间结束
  11296. if (se.CDateTimeEnd.HasValue)
  11297. {
  11298. sqlString = sqlString + " AND sc.ProcedureTime <= :CDateTimeEnd ";
  11299. parameters.Add(new OracleParameter(":CDateTimeEnd", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11300. }
  11301. // 完成工号
  11302. if (!string.IsNullOrEmpty(se.CUserCode))
  11303. {
  11304. sqlString = sqlString + " AND instr(sc.UserCode,:UserCode)>0";
  11305. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CUserCode, ParameterDirection.Input));
  11306. }
  11307. // 产品类别
  11308. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  11309. {
  11310. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 ";
  11311. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  11312. }
  11313. // 产品编码
  11314. if (!string.IsNullOrEmpty(se.GoodsCode))
  11315. {
  11316. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0";
  11317. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  11318. }
  11319. // 成型工号
  11320. if (!string.IsNullOrEmpty(se.GroutingUserCode))
  11321. {
  11322. sqlString = sqlString + " AND instr(sc.GroutingUserCode,:GroutingUserCode)>0";
  11323. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.NVarchar2, se.GroutingUserCode, ParameterDirection.Input));
  11324. }
  11325. // 注浆时间起始
  11326. if (se.GroutingDateTimeStart.HasValue)
  11327. {
  11328. sqlString = sqlString + " AND sc.GroutingDate >= :GroutingDateTimeStart ";
  11329. parameters.Add(new OracleParameter(":GroutingDateTimeStart", OracleDbType.Date, se.GroutingDateTimeStart.Value, ParameterDirection.Input));
  11330. }
  11331. // 注浆时间结束
  11332. if (se.GroutingDateTimeEnd.HasValue)
  11333. {
  11334. sqlString = sqlString + " AND sc.GroutingDate <= :GroutingDateTimeEnd ";
  11335. parameters.Add(new OracleParameter(":GroutingDateTimeEnd", OracleDbType.Date, se.GroutingDateTimeEnd.Value, ParameterDirection.Input));
  11336. }
  11337. // 交坯时间起始
  11338. if (se.DeliveryDateTimeStart.HasValue)
  11339. {
  11340. sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime >= :DeliveryDateTimeStart ";
  11341. parameters.Add(new OracleParameter(":DeliveryDateTimeStart", OracleDbType.Date, se.DeliveryDateTimeStart.Value, ParameterDirection.Input));
  11342. }
  11343. // 交坯时间结束
  11344. if (se.DeliveryDateTimeEnd.HasValue)
  11345. {
  11346. sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime <= :DeliveryDateTimeEnd ";
  11347. parameters.Add(new OracleParameter(":DeliveryDateTimeEnd", OracleDbType.Date, se.DeliveryDateTimeEnd.Value, ParameterDirection.Input));
  11348. }
  11349. // 半检状态
  11350. if (!string.IsNullOrEmpty(se.SemiCheckType))
  11351. {
  11352. sqlString = sqlString + " AND instr(','||:SemiCheckType||',',','||sc.SemiCheckType||',')>0 ";
  11353. parameters.Add(new OracleParameter(":SemiCheckType", OracleDbType.NVarchar2, se.SemiCheckType, ParameterDirection.Input));
  11354. }
  11355. // 半检时间起始
  11356. if (se.SemiCheckDateTimeStart.HasValue)
  11357. {
  11358. sqlString = sqlString + " AND sc.SemiCheckTime >= :SemiCheckDateTimeStart ";
  11359. parameters.Add(new OracleParameter(":SemiCheckDateTimeStart", OracleDbType.Date, se.SemiCheckDateTimeStart.Value, ParameterDirection.Input));
  11360. }
  11361. // 半检时间结束
  11362. if (se.SemiCheckDateTimeEnd.HasValue)
  11363. {
  11364. sqlString = sqlString + " AND sc.SemiCheckTime <= :SemiCheckDateTimeEnd ";
  11365. parameters.Add(new OracleParameter(":SemiCheckDateTimeEnd", OracleDbType.Date, se.SemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  11366. }
  11367. // 半检工号
  11368. if (!string.IsNullOrEmpty(se.SemiCheckUserCode))
  11369. {
  11370. sqlString = sqlString + " AND instr(sc.SemiCheckUserCode,:SemiCheckUserCode)>0";
  11371. parameters.Add(new OracleParameter(":SemiCheckUserCode", OracleDbType.NVarchar2, se.SemiCheckUserCode, ParameterDirection.Input));
  11372. }
  11373. // 返工工序
  11374. if (!string.IsNullOrEmpty(se.RProcedureIDS))
  11375. {
  11376. sqlString = sqlString + " AND instr(','||:RProcedureIDS||',',','||sc.ReworkProcedureID||',')>0 ";
  11377. parameters.Add(new OracleParameter(":RProcedureIDS", OracleDbType.NVarchar2, se.RProcedureIDS, ParameterDirection.Input));
  11378. }
  11379. // 返工工号
  11380. if (!string.IsNullOrEmpty(se.ReworkUserCode))
  11381. {
  11382. sqlString = sqlString + " AND instr(sc.ReworkUserCode,:ReworkUserCode)>0";
  11383. parameters.Add(new OracleParameter(":ReworkUserCode", OracleDbType.NVarchar2, se.ReworkUserCode, ParameterDirection.Input));
  11384. }
  11385. // 复检状态
  11386. if (!string.IsNullOrEmpty(se.ReSemiCheckType))
  11387. {
  11388. sqlString = sqlString + " AND instr(','||:ReSemiCheckType||',',','||sc.ReSemiCheckType||',')>0 ";
  11389. parameters.Add(new OracleParameter(":ReSemiCheckType", OracleDbType.NVarchar2, se.ReSemiCheckType, ParameterDirection.Input));
  11390. }
  11391. // 复检时间起始
  11392. if (se.ReSemiCheckDateTimeStart.HasValue)
  11393. {
  11394. sqlString = sqlString + " AND sc.ReSemiCheckTime >= :ReSemiCheckDateTimeStart ";
  11395. parameters.Add(new OracleParameter(":ReSemiCheckDateTimeStart", OracleDbType.Date, se.ReSemiCheckDateTimeStart.Value, ParameterDirection.Input));
  11396. }
  11397. // 复检时间结束
  11398. if (se.ReSemiCheckDateTimeEnd.HasValue)
  11399. {
  11400. sqlString = sqlString + " AND sc.ReSemiCheckTime <= :ReSemiCheckDateTimeEnd ";
  11401. parameters.Add(new OracleParameter(":ReSemiCheckDateTimeEnd", OracleDbType.Date, se.ReSemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  11402. }
  11403. // 复检工号
  11404. if (!string.IsNullOrEmpty(se.ReSemiCheckUserCode))
  11405. {
  11406. sqlString = sqlString + " AND instr(sc.ReSemiCheckUserCode,:ReSemiCheckUserCode)>0";
  11407. parameters.Add(new OracleParameter(":ReSemiCheckUserCode", OracleDbType.NVarchar2, se.ReSemiCheckUserCode, ParameterDirection.Input));
  11408. }
  11409. // 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),())
  11410. // ORDER BY rp.displayno
  11411. // ,gt2.goodstypename
  11412. // ,sc.reworkusercode
  11413. // ,g.goodscode
  11414. // ,gt.goodstypename, gid) t
  11415. // ";
  11416. sqlString = sqlString +
  11417. " GROUP BY rp.displayno\n" +
  11418. " ,sc.reworkprocedureid\n" +
  11419. " ,rp.procedurename\n" +
  11420. " ,gt2.goodstypecode\n" +
  11421. " ,gt2.goodstypename\n" +
  11422. " ,sc.reworkuserid\n" +
  11423. " ,sc.reworkusercode\n" +
  11424. " ,g.goodsid\n" +
  11425. " ,g.goodscode\n" +
  11426. " ,gt.goodstypename) sct\n" +
  11427. " 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" +
  11428. " ORDER BY sct.displayno\n" +
  11429. " ,sct.goodstypename\n" +
  11430. " ,sct.reworkusercode\n" +
  11431. " ,sct.goodscode\n" +
  11432. " ,sct.goodstypename\n" +
  11433. " ,gid) t";
  11434. return sqlString;
  11435. }
  11436. /// <summary>
  11437. /// 取得RPT080107(半检登记明细)的信息查询数据
  11438. /// </summary>
  11439. /// <param name="user">登录用户信息</param>
  11440. /// <param name="se">查询条件</param>
  11441. /// <returns>查询结果</returns>
  11442. public static ServiceResultEntity GetRPT080107IData(SUserInfo user, SemiCheckEntity se)
  11443. {
  11444. IDBConnection conn = null;
  11445. try
  11446. {
  11447. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  11448. List<OracleParameter> parameters = new List<OracleParameter>();
  11449. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080107ISQL(user, se, ref parameters));
  11450. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  11451. ServiceResultEntity sre = new ServiceResultEntity();
  11452. if (data == null || data.Rows.Count == 0)
  11453. {
  11454. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  11455. return sre;
  11456. }
  11457. sre.Data = new DataSet();
  11458. sre.Data.Tables.Add(data);
  11459. return sre;
  11460. }
  11461. catch (Exception ex)
  11462. {
  11463. throw ex;
  11464. }
  11465. finally
  11466. {
  11467. if (conn != null &&
  11468. conn.ConnState == ConnectionState.Open)
  11469. {
  11470. conn.Close();
  11471. }
  11472. }
  11473. }
  11474. //xuwei add 2019-10-14
  11475. /// <summary>
  11476. /// 取得RPT080108(半检返修登记明细)的信息查询数据
  11477. /// </summary>
  11478. /// <param name="user">登录用户信息</param>
  11479. /// <param name="se">查询条件</param>
  11480. /// <returns>查询结果</returns>
  11481. public static ServiceResultEntity GetRPT080108IData(SUserInfo user, SemiCheckEntity se)
  11482. {
  11483. IDBConnection conn = null;
  11484. try
  11485. {
  11486. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  11487. List<OracleParameter> parameters = new List<OracleParameter>();
  11488. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080108ISQL(user, se, ref parameters));
  11489. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  11490. ServiceResultEntity sre = new ServiceResultEntity();
  11491. if (data == null || data.Rows.Count == 0)
  11492. {
  11493. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  11494. return sre;
  11495. }
  11496. sre.Data = new DataSet();
  11497. sre.Data.Tables.Add(data);
  11498. return sre;
  11499. }
  11500. catch (Exception ex)
  11501. {
  11502. throw ex;
  11503. }
  11504. finally
  11505. {
  11506. if (conn != null &&
  11507. conn.ConnState == ConnectionState.Open)
  11508. {
  11509. conn.Close();
  11510. }
  11511. }
  11512. }
  11513. /// <summary>
  11514. /// 获取RPT080108画面(半检返修登记明细)的汇总信息查询sql
  11515. /// </summary>
  11516. /// <returns>sql</returns>
  11517. private static string GetRPT080108ISQL(SUserInfo user, SemiCheckEntity se, ref List<OracleParameter> parameters)
  11518. {
  11519. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  11520. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  11521. string sqlString = @"
  11522. SELECT
  11523. sr.SEMIREWORKID ,--AS SEMIREWORKID,
  11524. p.PROCEDURECODE ,--AS 完成工序编码,
  11525. p.PROCEDURENAME ,--AS 完成工序,
  11526. sr.PROCEDURETIME ,--AS 完成时间,
  11527. sr.USERCODE ,--完成工号,
  11528. gt2.GOODSTYPENAME AS GOODSTYPENAME2,--AS 产品二级类别,
  11529. gt.GOODSTYPENAME ,--AS 产品类别,
  11530. g.GOODSCODE ,--AS 产品编码,
  11531. g.GOODSNAME,--AS 产品名称,
  11532. sr.BARCODE ,--AS 产品条码,
  11533. sr.SEMIREWORKUSERCODE ,--AS 半检工号,
  11534. sr.SEMIREWORKTIME ,--AS 半检时间,
  11535. pr.PROCEDURECODE AS REWORKPCODE,--AS 返修工序编码,
  11536. pr.PROCEDURENAME AS REWORKPNAME,--AS 返修工序,
  11537. sr.BACKOUTFLAG ,--AS 撤销标识,
  11538. sr.BACKOUTUSERCODE ,--AS 撤销工号,
  11539. sr.BACKOUTTIME ,--AS 撤销时间,
  11540. sr.GROUTINGUSERCODE ,--AS 成型工号,
  11541. sr.GROUTINGLINECODE ,--AS 成型线编码,
  11542. sr.GROUTINGMOULDCODE ,--AS 模具编号,
  11543. sr.GROUTINGDATE ,--AS 注浆时间,
  11544. gd.DELIVERTIME ,--AS 交坯时间,
  11545. l.LOGONAME ,--AS 商标,
  11546. srd.DEFECTCODE ,--AS 缺陷编码,
  11547. srd.DEFECTNAME ,--AS 缺陷名称,
  11548. srd.DEFECTPOSITIONCODE ,--AS 位置编码,
  11549. srd.DEFECTPOSITIONNAME ,--AS 缺陷位置,
  11550. pd.PROCEDURECODE AS DEFECTPCODE,--AS 责任工序编码,
  11551. pd.PROCEDURENAME AS DEFECTPNAME,--AS 责任工序,
  11552. srd.DEFECTUSERCODE ,--AS 责任工号,
  11553. inpp.PROCEDURENAME CurrPROCEDURENAME --AS 当前工序
  11554. FROM
  11555. TP_PM_SEMIREWORK sr
  11556. LEFT JOIN TP_PM_SEMIREWORKDEFECT srd ON sr.SEMIREWORKID = srd.SEMIREWORKID
  11557. LEFT JOIN TP_PC_PROCEDURE p ON p.PROCEDUREID = sr.PROCEDUREID
  11558. LEFT JOIN TP_PC_PROCEDURE pr ON pr.PROCEDUREID = sr.REWORKPROCEDUREID
  11559. LEFT JOIN TP_PC_PROCEDURE pd ON pd.PROCEDUREID = srd.DEFECTPROCEDUREID
  11560. LEFT JOIN TP_MST_GOODS g ON sr.GOODSID = g.GOODSID
  11561. LEFT JOIN TP_MST_GOODSTYPE gt ON g.GOODSTYPEID = gt.GOODSTYPEID
  11562. LEFT JOIN TP_MST_GOODSTYPE gt2 ON gt2.ACCOUNTID = gt.ACCOUNTID
  11563. AND gt2.GOODSTYPECODE = substr( gt.GOODSTYPECODE, 1, 6 )
  11564. LEFT JOIN TP_PM_GROUTINGDAILYDETAIL gd ON gd.GROUTINGDAILYDETAILID = sr.GROUTINGDAILYDETAILID
  11565. LEFT JOIN TP_MST_LOGO l ON gd.LOGOID = l.LOGOID
  11566. LEFT JOIN TP_PM_INPRODUCTION inp ON inp.BARCODE = sr.BARCODE
  11567. LEFT JOIN TP_PC_PROCEDURE inpp ON inp.PROCEDUREID = inpp.PROCEDUREID
  11568. WHERE
  11569. sr.VALUEFLAG = '1'
  11570. AND srd.VALUEFLAG = '1'
  11571. AND sr.AccountID=:AccountID
  11572. ";
  11573. //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))
  11574. // 完成工序
  11575. if (!string.IsNullOrEmpty(se.CProcedureIDS))
  11576. {
  11577. sqlString = sqlString + " AND instr(','||:CProcedureIDS||',',','||p.PROCEDURECODE||',')>0 ";
  11578. parameters.Add(new OracleParameter(":CProcedureIDS", OracleDbType.NVarchar2, se.CProcedureIDS, ParameterDirection.Input));
  11579. }
  11580. // 完成时间起始
  11581. if (se.CDateTimeStart.HasValue)
  11582. {
  11583. sqlString = sqlString + " AND sr.ProcedureTime >= :CDateTimeStart ";
  11584. parameters.Add(new OracleParameter(":CDateTimeStart", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11585. }
  11586. // 完成时间结束
  11587. if (se.CDateTimeEnd.HasValue)
  11588. {
  11589. sqlString = sqlString + " AND sr.ProcedureTime <= :CDateTimeEnd ";
  11590. parameters.Add(new OracleParameter(":CDateTimeEnd", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11591. }
  11592. // 完成工号
  11593. if (!string.IsNullOrEmpty(se.CUserCode))
  11594. {
  11595. sqlString = sqlString + " AND instr(','||:UserCode||',' , ','||sr.UserCode||',')>0";
  11596. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CUserCode, ParameterDirection.Input));
  11597. }
  11598. // 产品类别
  11599. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  11600. {
  11601. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 ";
  11602. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  11603. }
  11604. // 产品编码
  11605. if (!string.IsNullOrEmpty(se.GoodsCode))
  11606. {
  11607. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0";
  11608. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  11609. }
  11610. // 成型工号
  11611. if (!string.IsNullOrEmpty(se.GroutingUserCode))
  11612. {
  11613. sqlString = sqlString + " AND instr(','||:GroutingUserCode||',' , ','||sr.GroutingUserCode||',')>0";
  11614. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.NVarchar2, se.GroutingUserCode, ParameterDirection.Input));
  11615. }
  11616. // 注浆时间起始
  11617. if (se.GroutingDateTimeStart.HasValue)
  11618. {
  11619. sqlString = sqlString + " AND sr.GroutingDate >= :GroutingDateTimeStart ";
  11620. parameters.Add(new OracleParameter(":GroutingDateTimeStart", OracleDbType.Date, se.GroutingDateTimeStart.Value, ParameterDirection.Input));
  11621. }
  11622. // 注浆时间结束
  11623. if (se.GroutingDateTimeEnd.HasValue)
  11624. {
  11625. sqlString = sqlString + " AND sr.GroutingDate <= :GroutingDateTimeEnd ";
  11626. parameters.Add(new OracleParameter(":GroutingDateTimeEnd", OracleDbType.Date, se.GroutingDateTimeEnd.Value, ParameterDirection.Input));
  11627. }
  11628. // 交坯时间起始
  11629. if (se.DeliveryDateTimeStart.HasValue)
  11630. {
  11631. sqlString = sqlString + " AND gd.DeliverTime >= :DeliveryDateTimeStart ";
  11632. parameters.Add(new OracleParameter(":DeliveryDateTimeStart", OracleDbType.Date, se.DeliveryDateTimeStart.Value, ParameterDirection.Input));
  11633. }
  11634. // 交坯时间结束
  11635. if (se.DeliveryDateTimeEnd.HasValue)
  11636. {
  11637. sqlString = sqlString + " AND gd.DeliverTime <= :DeliveryDateTimeEnd ";
  11638. parameters.Add(new OracleParameter(":DeliveryDateTimeEnd", OracleDbType.Date, se.DeliveryDateTimeEnd.Value, ParameterDirection.Input));
  11639. }
  11640. // 半检时间起始
  11641. if (se.SemiCheckDateTimeStart.HasValue)
  11642. {
  11643. sqlString = sqlString + " AND sr.SEMIREWORKTIME >= :SemiCheckDateTimeStart ";
  11644. parameters.Add(new OracleParameter(":SemiCheckDateTimeStart", OracleDbType.Date, se.SemiCheckDateTimeStart.Value, ParameterDirection.Input));
  11645. }
  11646. // 半检时间结束
  11647. if (se.SemiCheckDateTimeEnd.HasValue)
  11648. {
  11649. sqlString = sqlString + " AND sr.SEMIREWORKTIME <= :SemiCheckDateTimeEnd ";
  11650. parameters.Add(new OracleParameter(":SemiCheckDateTimeEnd", OracleDbType.Date, se.SemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  11651. }
  11652. // 半检工号
  11653. if (!string.IsNullOrEmpty(se.SemiCheckUserCode))
  11654. {
  11655. sqlString = sqlString + " AND instr(','||:SemiCheckUserCode||',' , ','||sr.SEMIREWORKUSERCODE||',')>0";
  11656. parameters.Add(new OracleParameter(":SemiCheckUserCode", OracleDbType.NVarchar2, se.SemiCheckUserCode, ParameterDirection.Input));
  11657. }
  11658. // 返修工序
  11659. if (!string.IsNullOrEmpty(se.RProcedureIDS))
  11660. {
  11661. sqlString = sqlString + " AND instr(','||:RProcedureIDS||',',','||pr.PROCEDUREID||',')>0 ";
  11662. parameters.Add(new OracleParameter(":RProcedureIDS", OracleDbType.NVarchar2, se.RProcedureIDS, ParameterDirection.Input));
  11663. }
  11664. // 返修工号
  11665. if (!string.IsNullOrEmpty(se.ReworkUserCode))
  11666. {
  11667. sqlString = sqlString + " AND instr(sr.ReworkUserCode,:ReworkUserCode)>0";
  11668. parameters.Add(new OracleParameter(":ReworkUserCode", OracleDbType.NVarchar2, se.ReworkUserCode, ParameterDirection.Input));
  11669. }
  11670. // 撤销标识
  11671. if (!string.IsNullOrEmpty(se.BackOutFlag))
  11672. {
  11673. sqlString = sqlString + " AND instr(','||:BackOutFlag||',',','||sr.BackOutFlag||',')>0 ";
  11674. parameters.Add(new OracleParameter(":BackOutFlag", OracleDbType.NVarchar2, se.BackOutFlag, ParameterDirection.Input));
  11675. }
  11676. // 撤销时间起始
  11677. if (se.BackOutTimeStart.HasValue)
  11678. {
  11679. sqlString = sqlString + " AND sr.BackOutTime >= :BackOutTimeStart ";
  11680. parameters.Add(new OracleParameter(":BackOutTimeStart", OracleDbType.Date, se.BackOutTimeStart.Value, ParameterDirection.Input));
  11681. }
  11682. // 撤销时间结束
  11683. if (se.BackOutTimeEnd.HasValue)
  11684. {
  11685. sqlString = sqlString + " AND sr.BackOutTime <= :BackOutTimeEnd ";
  11686. parameters.Add(new OracleParameter(":BackOutTimeEnd", OracleDbType.Date, se.BackOutTimeEnd.Value, ParameterDirection.Input));
  11687. }
  11688. // 撤销工号
  11689. if (!string.IsNullOrEmpty(se.BackOutUserCode))
  11690. {
  11691. sqlString = sqlString + " AND instr(','||:BackOutUserCode||',' , ','||sr.BackOutUserCode||',')>0";
  11692. parameters.Add(new OracleParameter(":BackOutUserCode", OracleDbType.NVarchar2, se.BackOutUserCode, ParameterDirection.Input));
  11693. }
  11694. // 产品条码
  11695. if (!string.IsNullOrEmpty(se.BarCode))
  11696. {
  11697. sqlString = sqlString + " AND instr(sr.BarCode,:BarCode)>0";
  11698. parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.BarCode, ParameterDirection.Input));
  11699. }
  11700. // 缺陷编码
  11701. if (!string.IsNullOrEmpty(se.DefectCode))
  11702. {
  11703. sqlString = sqlString + " AND instr(srd.DefectCode,:DefectCode)>0";
  11704. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  11705. }
  11706. // 缺陷位置集
  11707. if (!string.IsNullOrEmpty(se.DefectPositionIDS))
  11708. {
  11709. sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||srd.DefectPositionID||',')>0 ";
  11710. parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectPositionIDS, ParameterDirection.Input));
  11711. }
  11712. // 责任工序集
  11713. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  11714. {
  11715. sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||pd.PROCEDUREID||',')>0 ";
  11716. parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  11717. }
  11718. // 责任工号
  11719. if (!string.IsNullOrEmpty(se.DefectUser))
  11720. {
  11721. sqlString = sqlString + " AND instr(srd.DEFECTUSERCODE,:DefectUser)>0";
  11722. parameters.Add(new OracleParameter(":DefectUser", OracleDbType.NVarchar2, se.DefectUser, ParameterDirection.Input));
  11723. }
  11724. // 只显示最后一条半检记录
  11725. if (se.SemiCheckType == "1")
  11726. {
  11727. // 撤销的记录全显示,未撤销的记录只显示最后一条
  11728. sqlString += " and (sr.backoutflag = '1' or not exists (select sw.semireworkid\n" +
  11729. " from TP_PM_SEMIREWORK sw\n" +
  11730. " where sw.barcode = sr.barcode\n" +
  11731. " and sw.valueflag = '1'\n" +
  11732. " and (sw.backoutflag = '0')\n" +
  11733. " and sw.semireworkid > sr.semireworkid) )";
  11734. }
  11735. return sqlString;
  11736. }
  11737. //xuwei end
  11738. //xuwei add 2019-10-21
  11739. /// <summary>
  11740. /// 统计当前工号,当日,按产品编码分组统计半检返修数据数量
  11741. /// </summary>
  11742. /// <param name="user">用户</param>
  11743. /// <param name="dataStr">统计日期</param>
  11744. /// <returns></returns>
  11745. public static ServiceResultEntity GetSemiReworkDayCount(SUserInfo user, string dateStr)
  11746. {
  11747. IDBConnection conn = null;
  11748. try
  11749. {
  11750. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  11751. string sqlStr = $@"
  11752. SELECT
  11753. nvl(sr.SEMIREWORKUSERCODE,'--') SEMIREWORKUSERCODE,--AS 半检工号,
  11754. nvl( g.GOODSCODE, '合计' ) GOODSCODE,--AS 产品编码,
  11755. nvl(g.GOODSNAME,'--') GOODSNAME,--AS 产口名称,
  11756. to_char(count( sr.SEMIREWORKID )) GOODSCOUNT --AS 返修数量
  11757. FROM
  11758. TP_PM_SEMIREWORK sr
  11759. LEFT JOIN TP_PM_SEMIREWORKDEFECT srd ON sr.SEMIREWORKID = srd.SEMIREWORKID
  11760. LEFT JOIN TP_MST_GOODS g ON sr.GOODSID = g.GOODSID
  11761. WHERE
  11762. sr.VALUEFLAG = '1'
  11763. AND sr.ACCOUNTID = '{user.AccountID}'
  11764. AND sr.SEMIREWORKUSERCODE = '{user.UserCode}'
  11765. AND to_date(to_char(sr.CREATETIME,'yyyy-mm-dd'),'yyyy-mm-dd') = to_date('{dateStr}','yyyy-mm-dd')
  11766. GROUP BY
  11767. grouping sets ( ( sr.SEMIREWORKUSERCODE, g.GOODSCODE, g.GOODSNAME ), ( ) )
  11768. ";
  11769. DataTable data = conn.GetSqlResultToDt(sqlStr);
  11770. ServiceResultEntity sre = new ServiceResultEntity();
  11771. //if (data == null || data.Rows.Count == 0)
  11772. //{
  11773. // sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  11774. // return sre;
  11775. //}
  11776. sre.Data = new DataSet();
  11777. sre.Data.Tables.Add(data);
  11778. return sre;
  11779. }
  11780. catch (Exception ex)
  11781. {
  11782. throw ex;
  11783. }
  11784. finally
  11785. {
  11786. if (conn != null &&
  11787. conn.ConnState == ConnectionState.Open)
  11788. {
  11789. conn.Close();
  11790. }
  11791. }
  11792. }
  11793. //xuwei end
  11794. /// <summary>
  11795. /// 获取RPT030110画面(半检登记汇总表)的汇总信息查询sql
  11796. /// </summary>
  11797. /// <returns>sql</returns>
  11798. private static string GetRPT080107ISQL(SUserInfo user, SemiCheckEntity se, ref List<OracleParameter> parameters)
  11799. {
  11800. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  11801. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  11802. string sqlString = @"
  11803. select
  11804. SemiCheck.SemiCheckID,
  11805. CProcedure.ProcedureName as CProcedureName,
  11806. SemiCheck.ProcedureTime,
  11807. SemiCheck.UserCode,
  11808. GoodsType2.GoodsTypeName as LevelGoodsTypeName,
  11809. GoodsType.GoodsTypeName,
  11810. Goods.GoodsCode,
  11811. SemiCheck.BarCode,
  11812. -- 复检后不显示半检状态
  11813. SemiCheckType.SemiCheckTypeName,
  11814. --decode(SemiCheck.ReSemiCheckType, 0, SemiCheckType.SemiCheckTypeName, '已复检') SemiCheckTypeName,
  11815. SemiCheck.SemiCheckUserCode,
  11816. SemiCheck.SemiCheckTime,
  11817. ReSemiCheckType.ReSemiCheckTypeName,
  11818. SemiCheck.ReSemiCheckUserCode,
  11819. SemiCheck.ReSemiCheckTime,
  11820. decode(SemiCheck.BackOutFlag,'0','正常','撤销') as BackOutFlag,
  11821. SemiCheck.BackOutUserCode,
  11822. SemiCheck.BackOutTime,
  11823. SemiCheck.GroutingUserCode,
  11824. SemiCheck.GroutingLineCode,
  11825. SemiCheck.GroutingMouldCode,
  11826. SemiCheck.GroutingDate,
  11827. GroutingDailyDetail.DeliverTime,
  11828. logo.logoName,
  11829. RProcedure.ProcedureName as RProcedureName,
  11830. SemiCheck.ReworkUserCode,
  11831. SemiCheckDefect.DefectCode,
  11832. SemiCheckDefect.DefectName as DefectName1,
  11833. concat(SemiCheckDefect.DefectCode||'->',SemiCheckDefect.DefectName) as DefectName,
  11834. SemiCheckDefect.DefectPositionName,
  11835. SemiCheckDefect.DefectPositionCode,
  11836. concat(SemiCheckDefect.DefectPositionCode||'->',SemiCheckDefect.DefectPositionName) as DefectPositionName,
  11837. Procedure.ProcedureName,
  11838. inpp.ProcedureName CurrProcedureName,
  11839. DefectUser.username as DefectUser
  11840. from TP_PM_SemiCheck SemiCheck
  11841. left join TP_PC_Procedure CProcedure
  11842. on SemiCheck.ProcedureID=CProcedure.ProcedureID
  11843. left join TP_MST_Goods Goods
  11844. on SemiCheck.GoodsID=Goods.GoodsID
  11845. left join TP_MST_GoodsType GoodsType
  11846. on Goods.GoodsTypeID=GoodsType.GoodsTypeID
  11847. left join TP_MST_GoodsType GoodsType2
  11848. on GoodsType2.accountid=GoodsType.accountid
  11849. and GoodsType2.GoodsTypecode=substr(GoodsType.GoodsTypecode,1,6)
  11850. left join TP_SYS_SemiCheckType SemiCheckType
  11851. on SemiCheck.SemiCheckType=SemiCheckType.SemiCheckTypeID
  11852. left join TP_SYS_ReSemiCheckType ReSemiCheckType
  11853. on SemiCheck.ReSemiCheckType=ReSemiCheckType.ReSemiCheckTypeID
  11854. left join TP_PM_GroutingDailyDetail GroutingDailyDetail
  11855. on GroutingDailyDetail.GroutingDailyDetailID=SemiCheck.GroutingDailyDetailID
  11856. left join TP_MST_Logo logo
  11857. on GroutingDailyDetail.LogoID=logo.LogoID
  11858. left join TP_PC_Procedure RProcedure
  11859. on SemiCheck.ReworkProcedureID=RProcedure.ProcedureID
  11860. left join TP_PM_SemiCheckDefect SemiCheckDefect
  11861. on SemiCheck.SemiCheckID=SemiCheckDefect.SemiCheckID
  11862. and SemiCheckDefect.ValueFlag='1'
  11863. left join TP_PC_Procedure Procedure
  11864. on SemiCheckDefect.DefectProcedureID=Procedure.ProcedureID
  11865. left join TP_MST_User DefectUser
  11866. on DefectUser.userid=SemiCheckDefect.DefectUserID
  11867. left join tp_pm_inproduction inp on inp.barcode = SemiCheck.barcode
  11868. left join TP_PC_Procedure inpp on inp.ProcedureID = inpp.ProcedureID
  11869. where SemiCheck.AccountID=:AccountID
  11870. ";
  11871. //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))
  11872. // 完成工序
  11873. if (!string.IsNullOrEmpty(se.CProcedureIDS))
  11874. {
  11875. sqlString = sqlString + " AND instr(','||:CProcedureIDS||',',','||SemiCheck.ProcedureID||',')>0 ";
  11876. parameters.Add(new OracleParameter(":CProcedureIDS", OracleDbType.NVarchar2, se.CProcedureIDS, ParameterDirection.Input));
  11877. }
  11878. // 完成时间起始
  11879. if (se.CDateTimeStart.HasValue)
  11880. {
  11881. sqlString = sqlString + " AND SemiCheck.ProcedureTime >= :CDateTimeStart ";
  11882. parameters.Add(new OracleParameter(":CDateTimeStart", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11883. }
  11884. // 完成时间结束
  11885. if (se.CDateTimeEnd.HasValue)
  11886. {
  11887. sqlString = sqlString + " AND SemiCheck.ProcedureTime <= :CDateTimeEnd ";
  11888. parameters.Add(new OracleParameter(":CDateTimeEnd", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11889. }
  11890. // 完成工号
  11891. if (!string.IsNullOrEmpty(se.CUserCode))
  11892. {
  11893. sqlString = sqlString + " AND instr(SemiCheck.UserCode,:UserCode)>0";
  11894. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CUserCode, ParameterDirection.Input));
  11895. }
  11896. // 产品类别
  11897. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  11898. {
  11899. sqlString = sqlString + " AND instr(GoodsType.GoodsTypeCode,:GoodsTypeCode)=1 ";
  11900. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  11901. }
  11902. // 产品编码
  11903. if (!string.IsNullOrEmpty(se.GoodsCode))
  11904. {
  11905. sqlString = sqlString + " AND instr(Goods.GoodsCode,:GoodsCode)>0";
  11906. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  11907. }
  11908. // 成型工号
  11909. if (!string.IsNullOrEmpty(se.GroutingUserCode))
  11910. {
  11911. sqlString = sqlString + " AND instr(SemiCheck.GroutingUserCode,:GroutingUserCode)>0";
  11912. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.NVarchar2, se.GroutingUserCode, ParameterDirection.Input));
  11913. }
  11914. // 注浆时间起始
  11915. if (se.GroutingDateTimeStart.HasValue)
  11916. {
  11917. sqlString = sqlString + " AND SemiCheck.GroutingDate >= :GroutingDateTimeStart ";
  11918. parameters.Add(new OracleParameter(":GroutingDateTimeStart", OracleDbType.Date, se.GroutingDateTimeStart.Value, ParameterDirection.Input));
  11919. }
  11920. // 注浆时间结束
  11921. if (se.GroutingDateTimeEnd.HasValue)
  11922. {
  11923. sqlString = sqlString + " AND SemiCheck.GroutingDate <= :GroutingDateTimeEnd ";
  11924. parameters.Add(new OracleParameter(":GroutingDateTimeEnd", OracleDbType.Date, se.GroutingDateTimeEnd.Value, ParameterDirection.Input));
  11925. }
  11926. // 交坯时间起始
  11927. if (se.DeliveryDateTimeStart.HasValue)
  11928. {
  11929. sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime >= :DeliveryDateTimeStart ";
  11930. parameters.Add(new OracleParameter(":DeliveryDateTimeStart", OracleDbType.Date, se.DeliveryDateTimeStart.Value, ParameterDirection.Input));
  11931. }
  11932. // 交坯时间结束
  11933. if (se.DeliveryDateTimeEnd.HasValue)
  11934. {
  11935. sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime <= :DeliveryDateTimeEnd ";
  11936. parameters.Add(new OracleParameter(":DeliveryDateTimeEnd", OracleDbType.Date, se.DeliveryDateTimeEnd.Value, ParameterDirection.Input));
  11937. }
  11938. // 半检状态
  11939. if (!string.IsNullOrEmpty(se.SemiCheckType))
  11940. {
  11941. sqlString = sqlString + " AND instr(','||:SemiCheckType||',',','||SemiCheck.SemiCheckType||',')>0 ";
  11942. parameters.Add(new OracleParameter(":SemiCheckType", OracleDbType.NVarchar2, se.SemiCheckType, ParameterDirection.Input));
  11943. }
  11944. // 半检时间起始
  11945. if (se.SemiCheckDateTimeStart.HasValue)
  11946. {
  11947. sqlString = sqlString + " AND SemiCheck.SemiCheckTime >= :SemiCheckDateTimeStart ";
  11948. parameters.Add(new OracleParameter(":SemiCheckDateTimeStart", OracleDbType.Date, se.SemiCheckDateTimeStart.Value, ParameterDirection.Input));
  11949. }
  11950. // 半检时间结束
  11951. if (se.SemiCheckDateTimeEnd.HasValue)
  11952. {
  11953. sqlString = sqlString + " AND SemiCheck.SemiCheckTime <= :SemiCheckDateTimeEnd ";
  11954. parameters.Add(new OracleParameter(":SemiCheckDateTimeEnd", OracleDbType.Date, se.SemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  11955. }
  11956. // 半检工号
  11957. if (!string.IsNullOrEmpty(se.SemiCheckUserCode))
  11958. {
  11959. sqlString = sqlString + " AND instr(SemiCheck.SemiCheckUserCode,:SemiCheckUserCode)>0";
  11960. parameters.Add(new OracleParameter(":SemiCheckUserCode", OracleDbType.NVarchar2, se.SemiCheckUserCode, ParameterDirection.Input));
  11961. }
  11962. // 返工工序
  11963. if (!string.IsNullOrEmpty(se.RProcedureIDS))
  11964. {
  11965. sqlString = sqlString + " AND instr(','||:RProcedureIDS||',',','||SemiCheck.ReworkProcedureID||',')>0 ";
  11966. parameters.Add(new OracleParameter(":RProcedureIDS", OracleDbType.NVarchar2, se.RProcedureIDS, ParameterDirection.Input));
  11967. }
  11968. // 返工工号
  11969. if (!string.IsNullOrEmpty(se.ReworkUserCode))
  11970. {
  11971. sqlString = sqlString + " AND instr(SemiCheck.ReworkUserCode,:ReworkUserCode)>0";
  11972. parameters.Add(new OracleParameter(":ReworkUserCode", OracleDbType.NVarchar2, se.ReworkUserCode, ParameterDirection.Input));
  11973. }
  11974. // 复检状态
  11975. if (!string.IsNullOrEmpty(se.ReSemiCheckType))
  11976. {
  11977. sqlString = sqlString + " AND instr(','||:ReSemiCheckType||',',','||SemiCheck.ReSemiCheckType||',')>0 ";
  11978. parameters.Add(new OracleParameter(":ReSemiCheckType", OracleDbType.NVarchar2, se.ReSemiCheckType, ParameterDirection.Input));
  11979. }
  11980. // 复检时间起始
  11981. if (se.ReSemiCheckDateTimeStart.HasValue)
  11982. {
  11983. sqlString = sqlString + " AND SemiCheck.ReSemiCheckTime >= :ReSemiCheckDateTimeStart ";
  11984. parameters.Add(new OracleParameter(":ReSemiCheckDateTimeStart", OracleDbType.Date, se.ReSemiCheckDateTimeStart.Value, ParameterDirection.Input));
  11985. }
  11986. // 复检时间结束
  11987. if (se.ReSemiCheckDateTimeEnd.HasValue)
  11988. {
  11989. sqlString = sqlString + " AND SemiCheck.ReSemiCheckTime <= :ReSemiCheckDateTimeEnd ";
  11990. parameters.Add(new OracleParameter(":ReSemiCheckDateTimeEnd", OracleDbType.Date, se.ReSemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  11991. }
  11992. // 复检工号
  11993. if (!string.IsNullOrEmpty(se.ReSemiCheckUserCode))
  11994. {
  11995. sqlString = sqlString + " AND instr(SemiCheck.ReSemiCheckUserCode,:ReSemiCheckUserCode)>0";
  11996. parameters.Add(new OracleParameter(":ReSemiCheckUserCode", OracleDbType.NVarchar2, se.ReSemiCheckUserCode, ParameterDirection.Input));
  11997. }
  11998. // 撤销标识
  11999. if (!string.IsNullOrEmpty(se.BackOutFlag))
  12000. {
  12001. sqlString = sqlString + " AND instr(','||:BackOutFlag||',',','||SemiCheck.BackOutFlag||',')>0 ";
  12002. parameters.Add(new OracleParameter(":BackOutFlag", OracleDbType.NVarchar2, se.BackOutFlag, ParameterDirection.Input));
  12003. }
  12004. // 撤销时间起始
  12005. if (se.BackOutTimeStart.HasValue)
  12006. {
  12007. sqlString = sqlString + " AND SemiCheck.BackOutTime >= :BackOutTimeStart ";
  12008. parameters.Add(new OracleParameter(":BackOutTimeStart", OracleDbType.Date, se.BackOutTimeStart.Value, ParameterDirection.Input));
  12009. }
  12010. // 撤销时间结束
  12011. if (se.BackOutTimeEnd.HasValue)
  12012. {
  12013. sqlString = sqlString + " AND SemiCheck.BackOutTime <= :BackOutTimeEnd ";
  12014. parameters.Add(new OracleParameter(":BackOutTimeEnd", OracleDbType.Date, se.BackOutTimeEnd.Value, ParameterDirection.Input));
  12015. }
  12016. // 撤销工号
  12017. if (!string.IsNullOrEmpty(se.BackOutUserCode))
  12018. {
  12019. sqlString = sqlString + " AND instr(SemiCheck.BackOutUserCode,:BackOutUserCode)>0";
  12020. parameters.Add(new OracleParameter(":BackOutUserCode", OracleDbType.NVarchar2, se.BackOutUserCode, ParameterDirection.Input));
  12021. }
  12022. // 产品条码
  12023. if (!string.IsNullOrEmpty(se.BarCode))
  12024. {
  12025. sqlString = sqlString + " AND instr(SemiCheck.BarCode,:BarCode)>0";
  12026. parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.BarCode, ParameterDirection.Input));
  12027. }
  12028. // 缺陷编码
  12029. if (!string.IsNullOrEmpty(se.DefectCode))
  12030. {
  12031. sqlString = sqlString + " AND instr(SemiCheckDefect.DefectCode,:DefectCode)>0";
  12032. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  12033. }
  12034. // 缺陷位置集
  12035. if (!string.IsNullOrEmpty(se.DefectPositionIDS))
  12036. {
  12037. sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||SemiCheckDefect.DefectPositionID||',')>0 ";
  12038. parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectPositionIDS, ParameterDirection.Input));
  12039. }
  12040. // 责任工序集
  12041. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  12042. {
  12043. sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||SemiCheckDefect.DefectPositionID||',')>0 ";
  12044. parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  12045. }
  12046. // 责任工号
  12047. if (!string.IsNullOrEmpty(se.DefectUser))
  12048. {
  12049. sqlString = sqlString + " AND instr(DefectUser.UserCode,:DefectUser)>0";
  12050. parameters.Add(new OracleParameter(":DefectUser", OracleDbType.NVarchar2, se.DefectUser, ParameterDirection.Input));
  12051. }
  12052. return sqlString;
  12053. }
  12054. /// <summary>
  12055. /// 取得F_RPT_030112画面(产成品交接汇总表)的汇总信息查询数据
  12056. /// </summary>
  12057. /// <param name="user">登录用户信息</param>
  12058. /// <param name="se">查询条件</param>
  12059. /// <returns>查询结果</returns>
  12060. public static ServiceResultEntity GetRPT0030112SData(SUserInfo user, SearchFinishedProductEntity se)
  12061. {
  12062. IDBConnection conn = null;
  12063. try
  12064. {
  12065. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12066. List<OracleParameter> parameters = new List<OracleParameter>();
  12067. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030112SSQL(user, se, ref parameters));
  12068. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  12069. ServiceResultEntity sre = new ServiceResultEntity();
  12070. if (data == null || data.Rows.Count == 0)
  12071. {
  12072. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12073. return sre;
  12074. }
  12075. sre.Data = new DataSet();
  12076. sre.Data.Tables.Add(data);
  12077. return sre;
  12078. }
  12079. catch (Exception ex)
  12080. {
  12081. throw ex;
  12082. }
  12083. finally
  12084. {
  12085. if (conn != null &&
  12086. conn.ConnState == ConnectionState.Open)
  12087. {
  12088. conn.Close();
  12089. }
  12090. }
  12091. }
  12092. /// <summary>
  12093. /// 获取RPT030112画面(产成品交接汇总表)的汇总信息查询sql
  12094. /// </summary>
  12095. /// <returns>sql</returns>
  12096. private static string GetRPT030112SSQL(SUserInfo user, SearchFinishedProductEntity se, ref List<OracleParameter> parameters)
  12097. {
  12098. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12099. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  12100. string sqlString = @"SELECT ts.gid
  12101. ,logoid
  12102. ,decode(ts.gid,
  12103. '23',
  12104. '总计【' || orderno || '】',
  12105. decode(ts.gid, '1', '--', '3', '--', orderno)) AS orderno
  12106. ,decode(ts.gid,
  12107. '3',
  12108. '合计【' || logoname || '】',
  12109. decode(ts.gid, '1', '--', logoname)) AS logoname
  12110. ,decode(ts.gid, '1', '小计【' || goodscode || '】', goodscode) AS goodscode
  12111. ,decode(ts.gid, '1', '--', goodsmodel) AS goodsmodel
  12112. ,GoodsSpecification
  12113. ,fhtime
  12114. ,COUNT
  12115. FROM (SELECT grouping_id(l.logoid,
  12116. o.orderno,
  12117. l.logoname,
  12118. g.goodscode,
  12119. to_char(f.fhtime, 'yyyy-mm-dd')) AS gid
  12120. ,decode(GROUPING(l.logoid), 1, '--', l.logoid) AS logoid
  12121. ,decode(GROUPING(o.orderno), 1, '--', o.orderno) AS orderno
  12122. ,decode(GROUPING(l.logoname), 1, '--', l.logoname) AS logoname
  12123. ,decode(GROUPING(g.goodscode), 1, '--', g.goodscode) AS goodscode
  12124. ,decode(GROUPING(g.goodscode), 1, '--', g.goodsmodel) AS goodsmodel
  12125. ,decode(GROUPING(g.GoodsSpecification), 1, '--', g.GoodsSpecification) AS GoodsSpecification
  12126. ,decode(GROUPING(to_char(f.fhtime, 'yyyy-mm-dd')),
  12127. 1,
  12128. '--',
  12129. to_char(f.fhtime, 'yyyy-mm-dd')) AS fhtime
  12130. ,COUNT(f.fhtime) AS COUNT
  12131. FROM tp_pm_finishedproduct F
  12132. LEFT JOIN TP_PM_Order O ON F.Fhorderid = O.Orderid
  12133. LEFT JOIN tp_mst_logo L ON F.LOGOID = L.LOGOID
  12134. LEFT JOIN tp_mst_goods G ON g.goodsid = f.goodsid
  12135. LEFT JOIN TP_MST_GoodsType gt ON g.GoodsTypeID = gt.GoodsTypeID
  12136. where f.fhtime is not null and f.AccountID=:AccountID ";
  12137. // 交接时间起始
  12138. if (se.FHTimeStart.HasValue)
  12139. {
  12140. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart ";
  12141. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, se.FHTimeStart.Value, ParameterDirection.Input));
  12142. }
  12143. // 交接时间结束
  12144. if (se.FHTimeEnd.HasValue)
  12145. {
  12146. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd ";
  12147. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, se.FHTimeEnd.Value, ParameterDirection.Input));
  12148. }
  12149. // 订单号
  12150. if (!string.IsNullOrEmpty(se.OrderNo))
  12151. {
  12152. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0";
  12153. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, se.OrderNo, ParameterDirection.Input));
  12154. }
  12155. // 产品类别编码
  12156. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  12157. {
  12158. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1";
  12159. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  12160. }
  12161. // 产品编码
  12162. if (!string.IsNullOrEmpty(se.GoodsCode))
  12163. {
  12164. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0";
  12165. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  12166. }
  12167. // 产品型号
  12168. if (!string.IsNullOrEmpty(se.GoodsModel))
  12169. {
  12170. sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0";
  12171. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, se.GoodsModel, ParameterDirection.Input));
  12172. }
  12173. // 产品商标ID集
  12174. if (!string.IsNullOrEmpty(se.LogoIDS))
  12175. {
  12176. sqlString += " AND instr(','||:LogoIDS||',', ',' || L.logoid || ',') > 0";
  12177. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, se.LogoIDS, ParameterDirection.Input));
  12178. }
  12179. // 交接工号
  12180. if (!string.IsNullOrEmpty(se.FHUserCode))
  12181. {
  12182. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0";
  12183. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, se.FHUserCode, ParameterDirection.Input));
  12184. }
  12185. sqlString = sqlString + @" GROUP BY rollup(o.orderno,l.logoid, l.logoname,g.goodscode,g.goodsmodel,g.GoodsSpecification,to_char(f.fhtime, 'yyyy-mm-dd'))
  12186. order by o.orderno,l.logoid, l.logoname,g.goodscode,to_char(f.fhtime, 'yyyy-mm-dd')
  12187. )ts
  12188. where ( logoid!='--' and orderno!='--' and logoname!='--' and goodscode!='--' and fhtime!='--')
  12189. or (goodscode!='--')
  12190. or(logoname!='')
  12191. or (orderno!='--') and ts.gid!='7'";
  12192. return sqlString;
  12193. }
  12194. /// <summary>
  12195. /// 取得F_RPT_030112画面(产成品交接汇总表)的汇总信息
  12196. /// </summary>
  12197. /// <param name="user">登录用户信息</param>
  12198. /// <param name="se">查询条件</param>
  12199. /// <returns>查询结果</returns>
  12200. public static ServiceResultEntity GetRPT0030112SumData(ClientRequestEntity cre, SUserInfo user)
  12201. {
  12202. IDBConnection conn = null;
  12203. try
  12204. {
  12205. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12206. List<OracleParameter> parameters = new List<OracleParameter>();
  12207. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12208. //string sqlString = "SELECT trunc(f.fhtime) fhtime, g.goodscode, COUNT(*) goodscount\n" +
  12209. string sqlString = "SELECT nvl2(o.orderno,\n" +
  12210. " nvl2(l.logoname,\n" +
  12211. " o.orderno,\n" +
  12212. " to_char('合计[') || o.orderno ||\n" +
  12213. " to_char(']')),\n" +
  12214. " '总计') orderno\n" +
  12215. " ,nvl2(l.logoname,\n" +
  12216. " nvl2(g.goodscode,\n" +
  12217. " l.logoname,\n" +
  12218. " to_char('小计[' || l.logoname || ']')),\n" +
  12219. " '--') logoname\n" +
  12220. " ,nvl(g.goodscode, '--') goodscode" +
  12221. " ,nvl(g.goodsmodel, '--') goodsmodel" +
  12222. " ,nvl(gdd.materialcode, '--') mcode" +
  12223. " ,f.logoid" +
  12224. " ,f.goodsid" +
  12225. " ,f.fhorderid" +
  12226. " ,COUNT(*) count" +
  12227. " FROM tp_pm_finishedproduct f\n" +
  12228. " inner JOIN tp_pm_groutingdailydetail gdd\n" +
  12229. " ON gdd.barcode = f.barcode\n" +
  12230. " LEFT JOIN tp_mst_logo l\n" +
  12231. " ON f.logoid = l.logoid\n" +
  12232. " LEFT JOIN TP_PM_Order O\n" +
  12233. " ON f.Fhorderid = O.Orderid\n" +
  12234. " LEFT JOIN tp_mst_goods G\n" +
  12235. " ON g.goodsid = f.goodsid\n" +
  12236. " LEFT JOIN TP_MST_GoodsType gt\n" +
  12237. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  12238. " WHERE f.fhtime IS NOT NULL\n" +
  12239. " AND f.AccountID = :AccountID\n";
  12240. // 交接时间起始
  12241. if (cre.Properties["FHTimeStart"] != null)
  12242. {
  12243. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
  12244. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, cre.Properties["FHTimeStart"], ParameterDirection.Input));
  12245. }
  12246. // 交接时间结束
  12247. if (cre.Properties["FHTimeEnd"] != null)
  12248. {
  12249. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd \n";
  12250. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, cre.Properties["FHTimeEnd"], ParameterDirection.Input));
  12251. }
  12252. // 订单号
  12253. if (!string.IsNullOrEmpty(cre.Properties["OrderNo"] as string))
  12254. {
  12255. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0 \n";
  12256. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, cre.Properties["OrderNo"], ParameterDirection.Input));
  12257. }
  12258. // 产品类别编码
  12259. if (!string.IsNullOrEmpty(cre.Properties["GoodsTypeCode"] as string))
  12260. {
  12261. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 \n";
  12262. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input));
  12263. }
  12264. // 产品编码
  12265. if (!string.IsNullOrEmpty(cre.Properties["GoodsCode"] as string))
  12266. {
  12267. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
  12268. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input));
  12269. }
  12270. // 产品型号
  12271. if (!string.IsNullOrEmpty(cre.Properties["GoodsModel"] as string))
  12272. {
  12273. sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0 \n";
  12274. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, cre.Properties["GoodsModel"], ParameterDirection.Input));
  12275. }
  12276. // 产品商标ID集
  12277. if (!string.IsNullOrEmpty(cre.Properties["LogoIDS"] as string))
  12278. {
  12279. sqlString += " AND instr(','||:LogoIDS||',', ',' || f.logoid || ',') > 0 \n";
  12280. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, cre.Properties["LogoIDS"], ParameterDirection.Input));
  12281. }
  12282. // 交接工号
  12283. if (!string.IsNullOrEmpty(cre.Properties["FHUserCode"] as string))
  12284. {
  12285. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0 \n";
  12286. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, cre.Properties["FHUserCode"], ParameterDirection.Input));
  12287. }
  12288. //sqlString += " group by trunc(f.fhtime), g.goodscode order by trunc(f.fhtime), g.goodscode";
  12289. 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),())";
  12290. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  12291. ServiceResultEntity sre = new ServiceResultEntity();
  12292. if (data == null || data.Rows.Count == 0)
  12293. {
  12294. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12295. return sre;
  12296. }
  12297. sre.Data = new DataSet();
  12298. sre.Data.Tables.Add(data);
  12299. return sre;
  12300. }
  12301. catch (Exception ex)
  12302. {
  12303. throw ex;
  12304. }
  12305. finally
  12306. {
  12307. if (conn != null &&
  12308. conn.ConnState == ConnectionState.Open)
  12309. {
  12310. conn.Close();
  12311. }
  12312. }
  12313. }
  12314. /// <summary>
  12315. /// 取得F_RPT_030112画面(产成品交接汇总表)的明细信息查询数据
  12316. /// </summary>
  12317. /// <param name="user">登录用户信息</param>
  12318. /// <param name="se">查询条件</param>
  12319. /// <returns>查询结果</returns>
  12320. public static ServiceResultEntity GetRPT0030112DetailSData(SUserInfo user, SearchFinishedProductEntity se)
  12321. {
  12322. IDBConnection conn = null;
  12323. try
  12324. {
  12325. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12326. List<OracleParameter> parameters = new List<OracleParameter>();
  12327. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT0030112DetailSData(user, se, ref parameters));
  12328. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  12329. ServiceResultEntity sre = new ServiceResultEntity();
  12330. if (data == null || data.Rows.Count == 0)
  12331. {
  12332. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12333. return sre;
  12334. }
  12335. sre.Data = new DataSet();
  12336. sre.Data.Tables.Add(data);
  12337. return sre;
  12338. }
  12339. catch (Exception ex)
  12340. {
  12341. throw ex;
  12342. }
  12343. finally
  12344. {
  12345. if (conn != null &&
  12346. conn.ConnState == ConnectionState.Open)
  12347. {
  12348. conn.Close();
  12349. }
  12350. }
  12351. }
  12352. private static string GetRPT0030112DetailSData(SUserInfo user, SearchFinishedProductEntity se, ref List<OracleParameter> parameters)
  12353. {
  12354. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12355. string sqlString = "SELECT O.ORDERNO,\n" +
  12356. " F.FHTIME,\n" +
  12357. " F.FHUSERCODE,\n" +
  12358. " F.BARCODE,\n" +
  12359. " F.GOODSCODE,\n" +
  12360. " L.LOGONAME,\n" +
  12361. " F.GROUTINGUSERCODE,\n" +
  12362. " F.GROUTINGLINECODE,\n" +
  12363. " F.GROUTINGMOULDCODE,\n" +
  12364. " F.GROUTINGDATE,\n" +
  12365. " G.DELIVERTIME,\n" +
  12366. " GOODS.goodsmodel,\n" +
  12367. //" (GOODS.MATERIALCODE || L.TAGCODE || G.ONLYCODE) AS FINISHEDBARCODE,\n" +
  12368. //" 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" +
  12369. " G.outlabelcode AS FINISHEDBARCODE,\n" +
  12370. " G.MATERIALCODE AS mcode,\n" +
  12371. " F.CREATETIME AS PRODUCTFINISHEDTIME\n" +
  12372. " FROM TP_PM_FINISHEDPRODUCT F\n" +
  12373. " LEFT JOIN TP_PM_ORDER O\n" +
  12374. " ON F.FHORDERID = O.ORDERID\n" +
  12375. " LEFT JOIN TP_MST_LOGO L\n" +
  12376. " ON F.LOGOID = L.LOGOID\n" +
  12377. " LEFT JOIN TP_PM_GROUTINGDAILYDETAIL G\n" +
  12378. " ON F.GROUTINGDAILYDETAILID = G.GROUTINGDAILYDETAILID\n" +
  12379. " LEFT JOIN TP_MST_GOODS GOODS\n" +
  12380. " ON F.GOODSID = GOODS.GOODSID\n" +
  12381. " LEFT JOIN TP_MST_GOODSTYPE GOODSTYPE\n" +
  12382. " ON GOODS.GOODSTYPEID = GOODSTYPE.GOODSTYPEID\n" +
  12383. " WHERE F.ACCOUNTID = :ACCOUNTID\n" +
  12384. " AND F.FHTIME IS NOT NULL";
  12385. // 交接时间起始
  12386. if (se.FHTimeStart.HasValue)
  12387. {
  12388. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart ";
  12389. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, se.FHTimeStart.Value, ParameterDirection.Input));
  12390. }
  12391. // 交接时间结束
  12392. if (se.FHTimeEnd.HasValue)
  12393. {
  12394. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd ";
  12395. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, se.FHTimeEnd.Value, ParameterDirection.Input));
  12396. }
  12397. // 订单号
  12398. if (!string.IsNullOrEmpty(se.OrderNo))
  12399. {
  12400. //sqlString = sqlString + " AND O.OrderNo=:OrderNo";
  12401. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0";
  12402. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, se.OrderNo, ParameterDirection.Input));
  12403. }
  12404. // 产品类别编码
  12405. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  12406. {
  12407. sqlString = sqlString + " AND instr(GoodsType.GoodsTypeCode,:GoodsTypeCode)=1";
  12408. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  12409. }
  12410. // 产品编码
  12411. if (!string.IsNullOrEmpty(se.GoodsCode))
  12412. {
  12413. sqlString = sqlString + " AND instr(Goods.GoodsCode,:GoodsCode)>0";
  12414. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  12415. }
  12416. // 产品型号
  12417. if (!string.IsNullOrEmpty(se.GoodsModel))
  12418. {
  12419. sqlString = sqlString + " AND instr(Goods.GoodsModel,:GoodsModel)>0";
  12420. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, se.GoodsModel, ParameterDirection.Input));
  12421. }
  12422. // 产品商标ID集
  12423. if (!string.IsNullOrEmpty(se.LogoIDS))
  12424. {
  12425. sqlString += " AND instr(','||:LogoIDS||',', ',' || L.logoid || ',') > 0";
  12426. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, se.LogoIDS, ParameterDirection.Input));
  12427. }
  12428. // 交接工号
  12429. if (!string.IsNullOrEmpty(se.FHUserCode))
  12430. {
  12431. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0";
  12432. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, se.FHUserCode, ParameterDirection.Input));
  12433. }
  12434. if (se.OrderID != null)
  12435. {
  12436. sqlString = sqlString + " AND F.fhorderid = :fhorderid";
  12437. parameters.Add(new OracleParameter(":fhorderid", OracleDbType.Int32, se.OrderID, ParameterDirection.Input));
  12438. }
  12439. if (se.GoodsID != null)
  12440. {
  12441. sqlString = sqlString + " AND F.GoodsID = :GoodsID";
  12442. parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  12443. }
  12444. if (se.LogoID != null)
  12445. {
  12446. sqlString = sqlString + " AND F.LogoID = :LogoID";
  12447. parameters.Add(new OracleParameter(":LogoID", OracleDbType.Int32, se.LogoID, ParameterDirection.Input));
  12448. }
  12449. return sqlString;
  12450. }
  12451. /// <summary>
  12452. /// 取得F_RPT_030112画面(产成品交接汇总表)的交接数量
  12453. /// </summary>
  12454. /// <param name="user">登录用户信息</param>
  12455. /// <param name="se">查询条件</param>
  12456. /// <returns>查询结果</returns>
  12457. public static ServiceResultEntity GetRPT0030112NData(ClientRequestEntity cre, SUserInfo user)
  12458. {
  12459. IDBConnection conn = null;
  12460. try
  12461. {
  12462. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12463. List<OracleParameter> parameters = new List<OracleParameter>();
  12464. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12465. //string sqlString = "SELECT trunc(f.fhtime) fhtime, g.goodscode, COUNT(*) goodscount\n" +
  12466. string sqlString = "SELECT nvl2(trunc(f.fhtime),\n" +
  12467. " nvl2(l.logoname,\n" +
  12468. " to_char(trunc(f.fhtime), 'yyyy-mm-dd'),\n" +
  12469. " to_char('合计[') || to_char(trunc(f.fhtime), 'yyyy-mm-dd') ||\n" +
  12470. " to_char(']')),\n" +
  12471. " '总计') fhtime\n" +
  12472. " ,nvl2(l.logoname,\n" +
  12473. " nvl2(g.goodscode,\n" +
  12474. " l.logoname,\n" +
  12475. " to_char('小计[' || l.logoname || ']')),\n" +
  12476. " '--') logoname\n" +
  12477. " ,nvl(g.goodscode, '--') goodscode" +
  12478. " ,nvl(g.goodsmodel, '--') goodsmodel" +
  12479. " ,nvl(gdd.materialcode, '--') mcode" +
  12480. " ,COUNT(*) goodscount" +
  12481. " FROM tp_pm_finishedproduct f\n" +
  12482. " inner JOIN tp_pm_groutingdailydetail gdd\n" +
  12483. " ON gdd.barcode = f.barcode\n" +
  12484. " LEFT JOIN tp_mst_logo l\n" +
  12485. " ON f.logoid = l.logoid\n" +
  12486. " LEFT JOIN TP_PM_Order O\n" +
  12487. " ON f.Fhorderid = O.Orderid\n" +
  12488. " LEFT JOIN tp_mst_goods G\n" +
  12489. " ON g.goodsid = f.goodsid\n" +
  12490. " LEFT JOIN TP_MST_GoodsType gt\n" +
  12491. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  12492. " WHERE f.fhtime IS NOT NULL\n" +
  12493. " AND f.AccountID = :AccountID\n";
  12494. // 交接时间起始
  12495. if (cre.Properties["FHTimeStart"] != null)
  12496. {
  12497. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
  12498. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, cre.Properties["FHTimeStart"], ParameterDirection.Input));
  12499. }
  12500. // 交接时间结束
  12501. if (cre.Properties["FHTimeEnd"] != null)
  12502. {
  12503. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd \n";
  12504. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, cre.Properties["FHTimeEnd"], ParameterDirection.Input));
  12505. }
  12506. // 订单号
  12507. if (!string.IsNullOrEmpty(cre.Properties["OrderNo"] as string))
  12508. {
  12509. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0 \n";
  12510. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, cre.Properties["OrderNo"], ParameterDirection.Input));
  12511. }
  12512. // 产品类别编码
  12513. if (!string.IsNullOrEmpty(cre.Properties["GoodsTypeCode"] as string))
  12514. {
  12515. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 \n";
  12516. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input));
  12517. }
  12518. // 产品编码
  12519. if (!string.IsNullOrEmpty(cre.Properties["GoodsCode"] as string))
  12520. {
  12521. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
  12522. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input));
  12523. }
  12524. // 产品型号
  12525. if (!string.IsNullOrEmpty(cre.Properties["GoodsModel"] as string))
  12526. {
  12527. sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0 \n";
  12528. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, cre.Properties["GoodsModel"], ParameterDirection.Input));
  12529. }
  12530. // 产品商标ID集
  12531. if (!string.IsNullOrEmpty(cre.Properties["LogoIDS"] as string))
  12532. {
  12533. sqlString += " AND instr(','||:LogoIDS||',', ',' || f.logoid || ',') > 0 \n";
  12534. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, cre.Properties["LogoIDS"], ParameterDirection.Input));
  12535. }
  12536. // 交接工号
  12537. if (!string.IsNullOrEmpty(cre.Properties["FHUserCode"] as string))
  12538. {
  12539. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0 \n";
  12540. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, cre.Properties["FHUserCode"], ParameterDirection.Input));
  12541. }
  12542. //sqlString += " group by trunc(f.fhtime), g.goodscode order by trunc(f.fhtime), g.goodscode";
  12543. sqlString += " GROUP BY GROUPING SETS((trunc(f.fhtime), l.logoname, g.goodscode,g.goodsmodel,gdd.materialcode),(trunc(f.fhtime), l.logoname),(trunc(f.fhtime)),())";
  12544. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  12545. ServiceResultEntity sre = new ServiceResultEntity();
  12546. if (data == null || data.Rows.Count == 0)
  12547. {
  12548. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12549. return sre;
  12550. }
  12551. sre.Data = new DataSet();
  12552. sre.Data.Tables.Add(data);
  12553. return sre;
  12554. }
  12555. catch (Exception ex)
  12556. {
  12557. throw ex;
  12558. }
  12559. finally
  12560. {
  12561. if (conn != null &&
  12562. conn.ConnState == ConnectionState.Open)
  12563. {
  12564. conn.Close();
  12565. }
  12566. }
  12567. }
  12568. /// <summary>
  12569. /// 取得F_RPT_030112画面(产成品交接汇总表)的型号数量
  12570. /// </summary>
  12571. /// <param name="user">登录用户信息</param>
  12572. /// <param name="se">查询条件</param>
  12573. /// <returns>查询结果</returns>
  12574. public static ServiceResultEntity GetRPT0030112GNData(ClientRequestEntity cre, SUserInfo user)
  12575. {
  12576. IDBConnection conn = null;
  12577. try
  12578. {
  12579. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12580. List<OracleParameter> parameters = new List<OracleParameter>();
  12581. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12582. //string sqlString = "SELECT trunc(f.fhtime) fhtime, g.goodscode, COUNT(*) goodscount\n" +
  12583. string sqlString = "SELECT --nvl2(trunc(f.fhtime),\n" +
  12584. //" nvl2(l.logoname,\n" +
  12585. //" to_char(trunc(f.fhtime), 'yyyy-mm-dd'),\n" +
  12586. //" to_char('合计[') || to_char(trunc(f.fhtime), 'yyyy-mm-dd') ||\n" +
  12587. //" to_char(']')),\n" +
  12588. //" '总计') fhtime\n" +
  12589. //" ,nvl2(l.logoname,\n" +
  12590. //" nvl2(g.goodscode,\n" +
  12591. //" l.logoname,\n" +
  12592. //" to_char('小计[' || l.logoname || ']')),\n" +
  12593. //" '--') logoname\n" +
  12594. " nvl(g.goodscode, '合计') goodscode" +
  12595. " ,nvl(g.goodsmodel, '--') goodsmodel" +
  12596. " ,nvl(gdd.materialcode, '--') mcode" +
  12597. " ,COUNT(*) goodscount" +
  12598. " FROM tp_pm_finishedproduct f\n" +
  12599. " inner JOIN tp_pm_groutingdailydetail gdd\n" +
  12600. " ON gdd.barcode = f.barcode\n" +
  12601. " LEFT JOIN tp_mst_logo l\n" +
  12602. " ON f.logoid = l.logoid\n" +
  12603. " LEFT JOIN TP_PM_Order O\n" +
  12604. " ON f.Fhorderid = O.Orderid\n" +
  12605. " LEFT JOIN tp_mst_goods G\n" +
  12606. " ON g.goodsid = f.goodsid\n" +
  12607. " LEFT JOIN TP_MST_GoodsType gt\n" +
  12608. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  12609. " WHERE f.fhtime IS NOT NULL\n" +
  12610. " AND f.AccountID = :AccountID\n";
  12611. // 交接时间起始
  12612. if (cre.Properties["FHTimeStart"] != null)
  12613. {
  12614. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
  12615. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, cre.Properties["FHTimeStart"], ParameterDirection.Input));
  12616. }
  12617. // 交接时间结束
  12618. if (cre.Properties["FHTimeEnd"] != null)
  12619. {
  12620. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd \n";
  12621. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, cre.Properties["FHTimeEnd"], ParameterDirection.Input));
  12622. }
  12623. // 订单号
  12624. if (!string.IsNullOrEmpty(cre.Properties["OrderNo"] as string))
  12625. {
  12626. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0 \n";
  12627. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, cre.Properties["OrderNo"], ParameterDirection.Input));
  12628. }
  12629. // 产品类别编码
  12630. if (!string.IsNullOrEmpty(cre.Properties["GoodsTypeCode"] as string))
  12631. {
  12632. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 \n";
  12633. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input));
  12634. }
  12635. // 产品编码
  12636. if (!string.IsNullOrEmpty(cre.Properties["GoodsCode"] as string))
  12637. {
  12638. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
  12639. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input));
  12640. }
  12641. // 产品型号
  12642. if (!string.IsNullOrEmpty(cre.Properties["GoodsModel"] as string))
  12643. {
  12644. sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0 \n";
  12645. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, cre.Properties["GoodsModel"], ParameterDirection.Input));
  12646. }
  12647. // 产品商标ID集
  12648. if (!string.IsNullOrEmpty(cre.Properties["LogoIDS"] as string))
  12649. {
  12650. sqlString += " AND instr(','||:LogoIDS||',', ',' || f.logoid || ',') > 0 \n";
  12651. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, cre.Properties["LogoIDS"], ParameterDirection.Input));
  12652. }
  12653. // 交接工号
  12654. if (!string.IsNullOrEmpty(cre.Properties["FHUserCode"] as string))
  12655. {
  12656. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0 \n";
  12657. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, cre.Properties["FHUserCode"], ParameterDirection.Input));
  12658. }
  12659. //sqlString += " group by trunc(f.fhtime), g.goodscode order by trunc(f.fhtime), g.goodscode";
  12660. sqlString += " GROUP BY GROUPING SETS((g.goodscode,g.goodsmodel,gdd.materialcode),())";
  12661. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  12662. ServiceResultEntity sre = new ServiceResultEntity();
  12663. if (data == null || data.Rows.Count == 0)
  12664. {
  12665. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12666. return sre;
  12667. }
  12668. sre.Data = new DataSet();
  12669. sre.Data.Tables.Add(data);
  12670. return sre;
  12671. }
  12672. catch (Exception ex)
  12673. {
  12674. throw ex;
  12675. }
  12676. finally
  12677. {
  12678. if (conn != null &&
  12679. conn.ConnState == ConnectionState.Open)
  12680. {
  12681. conn.Close();
  12682. }
  12683. }
  12684. }
  12685. /// <summary>
  12686. /// 取得PDA(产成品交接汇总表)的交接数量
  12687. /// </summary>
  12688. /// <param name="user">登录用户信息</param>
  12689. /// <param name="se">查询条件</param>
  12690. /// <returns>查询结果</returns>
  12691. public static ServiceResultEntity GetRPT0030112NPDAData(DateTime date, string goodscode, SUserInfo user)
  12692. {
  12693. IDBConnection conn = null;
  12694. try
  12695. {
  12696. DateTime dateStart = date;
  12697. DateTime dateEnd = dateStart.AddDays(1);
  12698. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12699. List<OracleParameter> parameters = new List<OracleParameter>();
  12700. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12701. string sqlString = "SELECT o.orderno, g.goodscode, COUNT(*) goodscount\n" +
  12702. " FROM tp_pm_finishedproduct f\n" +
  12703. " LEFT JOIN TP_PM_Order O\n" +
  12704. " ON f.Fhorderid = O.Orderid\n" +
  12705. " LEFT JOIN tp_mst_goods G\n" +
  12706. " ON g.goodsid = f.goodsid\n" +
  12707. " LEFT JOIN TP_MST_GoodsType gt\n" +
  12708. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  12709. " WHERE f.fhtime IS NOT NULL\n" +
  12710. " AND f.AccountID = :AccountID\n";
  12711. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
  12712. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, dateStart, ParameterDirection.Input));
  12713. sqlString = sqlString + " AND F.FHTime < :FHTimeEnd \n";
  12714. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, dateEnd, ParameterDirection.Input));
  12715. // 产品型号
  12716. if (!string.IsNullOrEmpty(goodscode))
  12717. {
  12718. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
  12719. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, goodscode, ParameterDirection.Input));
  12720. }
  12721. sqlString += " group by orderno, g.goodscode order by orderno, g.goodscode";
  12722. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  12723. ServiceResultEntity sre = new ServiceResultEntity();
  12724. if (data == null || data.Rows.Count == 0)
  12725. {
  12726. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12727. return sre;
  12728. }
  12729. sre.Data = new DataSet();
  12730. sre.Data.Tables.Add(data);
  12731. return sre;
  12732. }
  12733. catch (Exception ex)
  12734. {
  12735. throw ex;
  12736. }
  12737. finally
  12738. {
  12739. if (conn != null &&
  12740. conn.ConnState == ConnectionState.Open)
  12741. {
  12742. conn.Close();
  12743. }
  12744. }
  12745. }
  12746. /// <summary>
  12747. /// 获取在产品备份表
  12748. /// </summary>
  12749. /// <param name="cre"></param>
  12750. /// <param name="sUserInfo"></param>
  12751. /// <returns></returns>
  12752. public static ServiceResultEntity GetRPT010404Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  12753. {
  12754. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12755. try
  12756. {
  12757. ServiceResultEntity sre = new ServiceResultEntity();
  12758. string sqlString = "SELECT inpb.BackupMonth\n" +
  12759. " ,gdd.BarCode\n" +
  12760. //" ,inpb.GoodsID\n" +
  12761. " ,inpb.GoodsCode\n" +
  12762. " ,inpb.GoodsName\n" +
  12763. //" ,inpb.Userid\n" +
  12764. " ,worker.USERNAME AS UserName\n" +
  12765. " ,worker.USERCode AS UserCode\n" +
  12766. //" ,inpb.ProductionLineID\n" +
  12767. " ,inpb.ProductionLineCode\n" +
  12768. " ,inpb.ProductionLineName\n" +
  12769. //" ,inpb.ModelType\n" +
  12770. " ,decode(inpb.inscrapflag, '1', '待审核的报废品', '正常') AS inscrapflag\n" +
  12771. " ,inpb.IsPublicBody\n" +
  12772. " ,decode(inpb.IsReFire,'6','1','0') IsReFire\n" +
  12773. " ,inpb.IsReworkFlag\n" +
  12774. " ,decode(inpb.CanManyTimes, '1', '能', '不能') AS CanManyTimes\n" +
  12775. " ,decode(inpb.ProcedureModel, '1', '计件模型', '检验模型') AS ProcedureModel\n" +
  12776. //" ,inpb.GroutingDailyID\n" +
  12777. //" ,inpb.GroutingDailyDetailID\n" +
  12778. " ,inpb.GroutingDate\n" +
  12779. //" ,inpb.GroutingLineID\n" +
  12780. " ,inpb.GroutingLineCode\n" +
  12781. " ,inpb.GroutingLineName\n" +
  12782. //" ,inpb.ProcedureID CompleteProcedureID\n" +
  12783. " ,pro.ProcedureName AS CompleteProcedureName\n" +
  12784. //" ,inpb.GMouldTypeID\n" +
  12785. " ,gmt.GMOULDTYPENAME AS GMouldTypeName\n" +
  12786. //" ,inpb.GroutingLineDetailID\n" +
  12787. " ,inpb.GroutingMouldCode\n" +
  12788. " ,inpb.SPECIALREPAIRFLAG\n" +
  12789. " ,inpb.GROUTINGUSERCODE\n" +
  12790. " ,gdd.GROUTINGCOUNT\n" +
  12791. " ,gdd.delivertime\n" +
  12792. " ,inpb.proceduretime\n" +
  12793. " ,inpb.Remarks\n" +
  12794. //" ,inpb.GoodsLevelID\n" +
  12795. " ,mgl.GOODSLEVELNAME\n" +
  12796. //" ,inpb.GoodsLevelTypeID\n" +
  12797. " ,mglt.GOODSLEVELTYPENAME\n" +
  12798. " ,inpb.BackupTime\n" +
  12799. " ,REPLACE((logo.Logoname || '[' || logo.Logocode || ']'), '[]', '') AS LogoCodeName\n" +
  12800. //" ,(Goods.MaterialCode || logo.tagcode || gdd.onlycode) AS FinishedBarCode\n" +
  12801. " ,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" +
  12802. " FROM TP_PM_InProduction_BakByMonth inpb\n" +
  12803. " INNER JOIN TP_MST_User worker\n" +
  12804. " ON worker.UserID = inpb.Userid\n" +
  12805. " INNER JOIN TP_PC_Procedure pro\n" +
  12806. " ON pro.PROCEDUREID = inpb.ProcedureID\n" +
  12807. " INNER JOIN TP_MST_GMouldType gmt\n" +
  12808. " ON gmt.GMouldTypeID = inpb.GMouldTypeID\n" +
  12809. " INNER JOIN TP_SYS_ProcedureModelType pmt\n" +
  12810. " ON pmt.ProcedureModelTypeID = inpb.ModelType\n" +
  12811. //" INNER JOIN TP_PM_GroutingDaily gd\n" +
  12812. //" ON gd.GroutingDailyID = inpb.GroutingDailyID\n" +
  12813. " INNER JOIN TP_PM_GroutingDailyDetail gdd\n" +
  12814. " ON gdd.Groutingdailydetailid = inpb.GroutingDailyDetailID\n" +
  12815. //" INNER JOIN TP_PC_GroutingLineDetail gld\n" +
  12816. //" ON gld.Groutinglinedetailid = inpb.GroutingLineDetailID\n" +
  12817. " LEFT JOIN TP_MST_GoodsLevel mgl\n" +
  12818. " ON mgl.GoodsLevelID = inpb.GoodsLevelID\n" +
  12819. " LEFT JOIN TP_SYS_GoodsLevelType mglt\n" +
  12820. " ON mglt.GoodsLevelTypeID = inpb.GoodsLevelTypeID\n" +
  12821. " LEFT JOIN TP_MST_Logo logo\n" +
  12822. " ON inpb.logoid = logo.logoid\n" +
  12823. " LEFT JOIN TP_MST_Goods Goods\n" +
  12824. " ON inpb.GoodsID = Goods.GoodsID\n" +
  12825. " WHERE inpb.AccountID = :AccountID" +
  12826. " AND inpb.BackupMonth = :BackupMonth" +
  12827. " ORDER BY pro.displayno,inpb.proceduretime";
  12828. OracleParameter[] oracleParameter = new OracleParameter[]
  12829. {
  12830. new Oracle.ManagedDataAccess.Client.OracleParameter(":AccountID",sUserInfo.AccountID),
  12831. new Oracle.ManagedDataAccess.Client.OracleParameter(":BackupMonth",cre.Properties["BackupMonth"]),
  12832. };
  12833. oracleConn.Open();
  12834. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  12835. oracleConn.Close();
  12836. sre.Data = result;
  12837. return sre;
  12838. }
  12839. catch (Exception ex)
  12840. {
  12841. if (oracleConn.ConnState == ConnectionState.Open)
  12842. {
  12843. oracleConn.Close();
  12844. }
  12845. throw ex;
  12846. }
  12847. }
  12848. /// <summary>
  12849. /// 产成品单值明细表
  12850. /// </summary>
  12851. /// <param name="cre"></param>
  12852. /// <param name="sUserInfo"></param>
  12853. /// <returns></returns>
  12854. public static ServiceResultEntity GetRPT010405Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  12855. {
  12856. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12857. try
  12858. {
  12859. string sql =
  12860. "SELECT up.id, up.NAME\n" +
  12861. " FROM tp_mst_unitprice up\n" +
  12862. " WHERE up.accountid = :AccountID\n" +
  12863. " AND up.valueflag = '1'\n" +
  12864. " AND (:upname IS NULL OR instr(up.name, :upname) > 0)\n" +
  12865. " ORDER BY up.displayno";
  12866. OracleParameter[] opara = new OracleParameter[]
  12867. {
  12868. new Oracle.ManagedDataAccess.Client.OracleParameter(":AccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  12869. new Oracle.ManagedDataAccess.Client.OracleParameter(":upname", OracleDbType.NVarchar2,cre.Properties["UPName"], ParameterDirection.Input),
  12870. };
  12871. DataTable upTable = oracleConn.GetSqlResultToDt(sql, opara);
  12872. StringBuilder upNames = new StringBuilder();
  12873. StringBuilder upTotals = new StringBuilder();
  12874. StringBuilder upSUMs = new StringBuilder();
  12875. foreach (DataRow item in upTable.Rows)
  12876. {
  12877. upNames.AppendFormat(", u{0} AS \"{1}\"\n", item["ID"], item["Name"]);
  12878. upTotals.AppendFormat(",(u{0} * nvl(fpcount, 0)) AS \"总【{1}】\"\n", item["ID"], item["Name"]);
  12879. upSUMs.AppendFormat(",SUM(decode(up.upid, {0}, up.unitprice, 0)) u{0}\n", item["ID"]);
  12880. }
  12881. ServiceResultEntity sre = new ServiceResultEntity();
  12882. string sqlString = "SELECT gt2.goodstypename GoodsTypeName2\n" +
  12883. " ,g.goodscode\n" +
  12884. " ,g.materialcode\n" +
  12885. " ,lg.logoname\n" +
  12886. " ,nvl(fpcount, 0) fpcount\n" +
  12887. // " ,u1 AS \"单值1\"\n" +
  12888. //" ,u2 AS \"单值2\"\n" +
  12889. upNames +
  12890. //" ,(u1 * nvl(fpcount, 0)) AS \"总【1】\"\n" +
  12891. //" ,(u2 * nvl(fpcount, 0)) AS \"总【2】\"\n" +
  12892. upTotals +
  12893. " FROM (SELECT up.goodsid\n" +
  12894. " ,up.logoid\n" +
  12895. //" ,SUM(decode(up.upid, 1, up.unitprice, 0)) u1\n" +
  12896. //" ,SUM(decode(up.upid, 2, up.unitprice, 0)) u2\n" +
  12897. upSUMs +
  12898. " FROM TP_MST_UnitPriceGoods up\n" +
  12899. " WHERE up.accountid = :AccountID\n" +
  12900. " GROUP BY up.goodsid, up.logoid) upg\n" +
  12901. " LEFT JOIN (SELECT fp.goodsid, fp.logoid, COUNT(*) fpcount\n" +
  12902. " FROM tp_pm_finishedproduct fp\n" +
  12903. " WHERE fp.accountid = :AccountID\n" +
  12904. " AND fp.fhtime BETWEEN :DateBegin AND :DateEnd\n" +
  12905. " AND (:GoodsCode IS NULL OR\n" +
  12906. " instr(fp.goodscode, :GoodsCode) > 0)\n" +
  12907. " GROUP BY fp.goodsid, fp.logoid) fpp\n" +
  12908. " ON fpp.goodsid = upg.goodsid\n" +
  12909. " AND fpp.logoid = upg.logoid\n" +
  12910. " INNER JOIN tp_mst_logo lg\n" +
  12911. " ON lg.logoid = upg.logoid\n" +
  12912. " INNER JOIN tp_mst_goods g\n" +
  12913. " ON g.goodsid = upg.goodsid\n" +
  12914. " INNER JOIN tp_mst_goodstype gt\n" +
  12915. " ON gt.goodstypeid = g.goodstypeid\n" +
  12916. " INNER JOIN tp_mst_goodstype gt2\n" +
  12917. " ON gt2.accountid = :AccountID\n" +
  12918. " AND length(gt2.goodstypecode) = 6\n" +
  12919. " AND instr(gt.goodstypecode, gt2.goodstypecode) = 1\n" +
  12920. " WHERE (:GoodsTypeCode IS NULL OR\n" +
  12921. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  12922. " AND (:GoodsCode IS NULL OR instr(g.goodscode, :GoodsCode) > 0)\n" +
  12923. " AND (:logoname IS NULL OR instr(lg.logoname, :logoname) > 0)\n" +
  12924. " ORDER BY g.goodscode, lg.displayno";
  12925. OracleParameter[] oracleParameter = new OracleParameter[]
  12926. {
  12927. new Oracle.ManagedDataAccess.Client.OracleParameter(":AccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  12928. new Oracle.ManagedDataAccess.Client.OracleParameter(":DateBegin", OracleDbType.Date,cre.Properties["DateBegin"], ParameterDirection.Input),
  12929. new Oracle.ManagedDataAccess.Client.OracleParameter(":DateEnd", OracleDbType.Date,cre.Properties["DateEnd"], ParameterDirection.Input),
  12930. new Oracle.ManagedDataAccess.Client.OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2,cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  12931. new Oracle.ManagedDataAccess.Client.OracleParameter(":GoodsCode", OracleDbType.NVarchar2,cre.Properties["GoodsCode"], ParameterDirection.Input),
  12932. new Oracle.ManagedDataAccess.Client.OracleParameter(":logoname", OracleDbType.NVarchar2,cre.Properties["LogoName"], ParameterDirection.Input),
  12933. };
  12934. oracleConn.Open();
  12935. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  12936. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  12937. {
  12938. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12939. }
  12940. sre.Data = result;
  12941. oracleConn.Close();
  12942. return sre;
  12943. }
  12944. catch (Exception ex)
  12945. {
  12946. if (oracleConn.ConnState == ConnectionState.Open)
  12947. {
  12948. oracleConn.Close();
  12949. }
  12950. throw ex;
  12951. }
  12952. }
  12953. /// <summary>
  12954. /// 产成品单值明细表-单值名管理
  12955. /// </summary>
  12956. /// <param name="cre"></param>
  12957. /// <param name="sUserInfo"></param>
  12958. /// <returns></returns>
  12959. public static ServiceResultEntity GetRPT01040501Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  12960. {
  12961. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12962. try
  12963. {
  12964. ServiceResultEntity sre = new ServiceResultEntity();
  12965. string sqlString = "SELECT t.id, t.name, t.displayno, t.valueflag\n" +
  12966. " FROM TP_MST_UnitPrice t\n" +
  12967. " WHERE t.accountid = :accountid\n" +
  12968. " ORDER BY t.id";
  12969. OracleParameter[] oracleParameter = new OracleParameter[]
  12970. {
  12971. new Oracle.ManagedDataAccess.Client.OracleParameter(":AccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  12972. };
  12973. oracleConn.Open();
  12974. sre.Data = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  12975. oracleConn.Close();
  12976. return sre;
  12977. }
  12978. catch (Exception ex)
  12979. {
  12980. if (oracleConn.ConnState == ConnectionState.Open)
  12981. {
  12982. oracleConn.Close();
  12983. }
  12984. throw ex;
  12985. }
  12986. }
  12987. /// <summary>
  12988. /// 产成品单值明细表-单值名管理
  12989. /// </summary>
  12990. /// <param name="cre"></param>
  12991. /// <param name="sUserInfo"></param>
  12992. /// <returns></returns>
  12993. public static ServiceResultEntity SetRPT01040501Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  12994. {
  12995. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  12996. try
  12997. {
  12998. ServiceResultEntity sre = new ServiceResultEntity();
  12999. // 检验参数的有效性
  13000. if (cre.Data == null && cre.Data.Tables.Count == 0 ||
  13001. cre.Data.Tables[0].Rows.Count < Constant.INT_IS_ZERO)
  13002. {
  13003. return sre;
  13004. }
  13005. oracleTrConn.Connect();
  13006. foreach (DataRow dataRow in cre.Data.Tables[0].Rows)
  13007. {
  13008. // 新建
  13009. if (dataRow.RowState == DataRowState.Added)
  13010. {
  13011. #region 新增
  13012. string sqlString = "INSERT INTO TP_MST_UNITPRICE\n" +
  13013. " (NAME, displayno, accountid, valueflag, createuserid, updateuserid)\n" +
  13014. "VALUES\n" +
  13015. " (:NAME, nvl(:DisplayNo,0), :AccountID, :ValueFlag, :UserID, :UserID)";
  13016. OracleParameter[] oracleParameter = new OracleParameter[]
  13017. {
  13018. new OracleParameter(":NAME", OracleDbType.NVarchar2, dataRow["Name"],ParameterDirection.Input),
  13019. new OracleParameter(":DisplayNo",OracleDbType.Int32, dataRow["DisplayNo"], ParameterDirection.Input),
  13020. new OracleParameter(":AccountID",OracleDbType.Int32,sUserInfo.AccountID, ParameterDirection.Input),
  13021. new OracleParameter(":ValueFlag",OracleDbType.NVarchar2, dataRow["ValueFlag"],ParameterDirection.Input),
  13022. new OracleParameter(":UserID",OracleDbType.Int32,sUserInfo.UserID, ParameterDirection.Input),
  13023. };
  13024. oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  13025. #endregion
  13026. }
  13027. else if (dataRow.RowState == DataRowState.Modified)
  13028. {
  13029. #region 更新
  13030. string sqlUpdateString = "UPDATE TP_MST_UNITPRICE SET "
  13031. + " Name = :Name,"
  13032. + " DisplayNo = :DisplayNo,"
  13033. + " ValueFlag = :ValueFlag,"
  13034. + " UpdateUserID = :UserID"
  13035. + " WHERE ID = :ID";
  13036. OracleParameter[] oracleParameter = new OracleParameter[]
  13037. {
  13038. new OracleParameter(":ID",OracleDbType.Int32,dataRow["ID"], ParameterDirection.Input),
  13039. new OracleParameter(":Name", OracleDbType.NVarchar2, dataRow["Name"],ParameterDirection.Input),
  13040. new OracleParameter(":DisplayNo",OracleDbType.Int32, dataRow["DisplayNo"], ParameterDirection.Input),
  13041. new OracleParameter(":ValueFlag",OracleDbType.NVarchar2, dataRow["ValueFlag"],ParameterDirection.Input),
  13042. new OracleParameter(":UserID",OracleDbType.Int32,sUserInfo.UserID, ParameterDirection.Input),
  13043. };
  13044. oracleTrConn.ExecuteNonQuery(sqlUpdateString, oracleParameter);
  13045. #endregion
  13046. }
  13047. else if (dataRow.RowState == DataRowState.Deleted)
  13048. {
  13049. #region 删除
  13050. string sqlDeleteString = "DELETE TP_MST_UNITPRICE WHERE ID = :ID";
  13051. OracleParameter[] oracleParameter = new OracleParameter[]
  13052. {
  13053. new OracleParameter(":ID",OracleDbType.Int32,dataRow["ID"], ParameterDirection.Input),
  13054. };
  13055. oracleTrConn.ExecuteNonQuery(sqlDeleteString, oracleParameter);
  13056. #endregion
  13057. }
  13058. }
  13059. oracleTrConn.Commit();
  13060. oracleTrConn.Disconnect();
  13061. return sre;
  13062. }
  13063. catch (Exception ex)
  13064. {
  13065. if (oracleTrConn.ConnState == ConnectionState.Open)
  13066. {
  13067. oracleTrConn.Rollback();
  13068. oracleTrConn.Disconnect();
  13069. }
  13070. throw ex;
  13071. }
  13072. finally
  13073. {
  13074. if (oracleTrConn.ConnState == ConnectionState.Open)
  13075. {
  13076. oracleTrConn.Disconnect();
  13077. }
  13078. }
  13079. }
  13080. /// <summary>
  13081. /// 获取模具跟踪表
  13082. /// </summary>
  13083. /// <param name="cre"></param>
  13084. /// <param name="sUserInfo"></param>
  13085. /// <returns></returns>
  13086. public static ServiceResultEntity GetRPT020105Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13087. {
  13088. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13089. try
  13090. {
  13091. ServiceResultEntity sre = new ServiceResultEntity();
  13092. OracleParameter[] oracleParameter = new OracleParameter[]
  13093. {
  13094. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13095. new OracleParameter("in_MouldBarcode",OracleDbType.Varchar2, cre.Properties["MouldBarcode"], ParameterDirection.Input),
  13096. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13097. new OracleParameter("out_Tracking",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13098. };
  13099. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_GetMouldTracking", oracleParameter);
  13100. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13101. {
  13102. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13103. }
  13104. sre.Data = result;
  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 GetRPT030113Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13123. {
  13124. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13125. try
  13126. {
  13127. ServiceResultEntity sre = new ServiceResultEntity();
  13128. OracleParameter[] oracleParameter = new OracleParameter[]
  13129. {
  13130. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13131. new OracleParameter("in_YYYYMM",OracleDbType.Varchar2, cre.Properties["YYYYMM"], ParameterDirection.Input),
  13132. new OracleParameter("in_DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13133. new OracleParameter("in_DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13134. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13135. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13136. new OracleParameter("in_GoodsIDs",OracleDbType.Varchar2, cre.Properties["GoodsIDs"], ParameterDirection.Input),
  13137. new OracleParameter("in_GoodsID",OracleDbType.Int32, cre.Properties["GoodsID"], ParameterDirection.Input),
  13138. new OracleParameter("in_Type",OracleDbType.Int32, cre.Properties["Type"], ParameterDirection.Input),
  13139. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13140. };
  13141. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_GetMould_SUM", oracleParameter);
  13142. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13143. {
  13144. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13145. }
  13146. sre.Data = result;
  13147. oracleConn.Commit();
  13148. return sre;
  13149. }
  13150. catch (Exception ex)
  13151. {
  13152. if (oracleConn.ConnState == ConnectionState.Open)
  13153. {
  13154. oracleConn.Disconnect();
  13155. }
  13156. throw ex;
  13157. }
  13158. }
  13159. /// <summary>
  13160. /// 获取废弃产品汇总表
  13161. /// </summary>
  13162. /// <param name="cre"></param>
  13163. /// <param name="sUserInfo"></param>
  13164. /// <returns></returns>
  13165. public static ServiceResultEntity GetRPT030114Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13166. {
  13167. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13168. try
  13169. {
  13170. ServiceResultEntity sre = new ServiceResultEntity();
  13171. OracleParameter[] oracleParameter = new OracleParameter[]
  13172. {
  13173. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13174. new OracleParameter("in_DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13175. new OracleParameter("in_DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13176. new OracleParameter("in_scrapTypes",OracleDbType.Varchar2, cre.Properties["ScrapTypes"], ParameterDirection.Input),
  13177. new OracleParameter("in_ProcedureIDs",OracleDbType.Varchar2, cre.Properties["ProcedureIDs"], ParameterDirection.Input),
  13178. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13179. //new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13180. new OracleParameter("in_GoodsIDs",OracleDbType.Varchar2, cre.Properties["GoodsIDs"], ParameterDirection.Input),
  13181. new OracleParameter("in_GoodsID",OracleDbType.Int32, cre.Properties["GoodsID"], ParameterDirection.Input),
  13182. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13183. };
  13184. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_scrap_sum", oracleParameter);
  13185. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13186. {
  13187. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13188. }
  13189. sre.Data = result;
  13190. oracleConn.Commit();
  13191. return sre;
  13192. }
  13193. catch (Exception ex)
  13194. {
  13195. if (oracleConn.ConnState == ConnectionState.Open)
  13196. {
  13197. oracleConn.Disconnect();
  13198. }
  13199. throw ex;
  13200. }
  13201. }
  13202. /// <summary>
  13203. /// 获取废品损失汇总表
  13204. /// </summary>
  13205. /// <param name="cre"></param>
  13206. /// <param name="sUserInfo"></param>
  13207. /// <returns></returns>
  13208. public static ServiceResultEntity GetRPT030115Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13209. {
  13210. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13211. try
  13212. {
  13213. ServiceResultEntity sre = new ServiceResultEntity();
  13214. OracleParameter[] oracleParameter = new OracleParameter[]
  13215. {
  13216. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13217. new OracleParameter("in_ptid",OracleDbType.Int32, cre.Properties["PTID"], ParameterDirection.Input),
  13218. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13219. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13220. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13221. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13222. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13223. };
  13224. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_TECDEP_SCRAP_SUM", oracleParameter);
  13225. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13226. {
  13227. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13228. }
  13229. sre.Data = result;
  13230. oracleConn.Commit();
  13231. return sre;
  13232. }
  13233. catch (Exception ex)
  13234. {
  13235. if (oracleConn.ConnState == ConnectionState.Open)
  13236. {
  13237. oracleConn.Disconnect();
  13238. }
  13239. throw ex;
  13240. }
  13241. }
  13242. /// <summary>
  13243. /// 获取废品损失汇总-明细表
  13244. /// </summary>
  13245. /// <param name="cre"></param>
  13246. /// <param name="sUserInfo"></param>
  13247. /// <returns></returns>
  13248. public static ServiceResultEntity GetRPT030115DData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13249. {
  13250. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13251. try
  13252. {
  13253. ServiceResultEntity sre = new ServiceResultEntity();
  13254. OracleParameter[] oracleParameter = new OracleParameter[]
  13255. {
  13256. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13257. new OracleParameter("in_ptid",OracleDbType.Int32, cre.Properties["PTID"], ParameterDirection.Input),
  13258. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13259. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13260. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13261. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13262. new OracleParameter("in_GoodsID",OracleDbType.Varchar2, cre.Properties["GoodsID"], ParameterDirection.Input),
  13263. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13264. };
  13265. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_TECDEP_SCRAP_SUMDETAIL", oracleParameter);
  13266. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13267. {
  13268. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13269. }
  13270. sre.Data = result;
  13271. oracleConn.Commit();
  13272. return sre;
  13273. }
  13274. catch (Exception ex)
  13275. {
  13276. if (oracleConn.ConnState == ConnectionState.Open)
  13277. {
  13278. oracleConn.Disconnect();
  13279. }
  13280. throw ex;
  13281. }
  13282. }
  13283. /// <summary>
  13284. /// 获取废品损失汇总表-半成品损失汇总表
  13285. /// </summary>
  13286. /// <param name="cre"></param>
  13287. /// <param name="sUserInfo"></param>
  13288. /// <returns></returns>
  13289. public static ServiceResultEntity GetRPT030115SData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13290. {
  13291. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13292. try
  13293. {
  13294. ServiceResultEntity sre = new ServiceResultEntity();
  13295. OracleParameter[] oracleParameter = new OracleParameter[]
  13296. {
  13297. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13298. new OracleParameter("in_ptid",OracleDbType.Int32, cre.Properties["PTID"], ParameterDirection.Input),
  13299. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13300. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13301. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13302. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13303. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13304. };
  13305. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_TECDEP_SCRAP_SUM_semi", oracleParameter);
  13306. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13307. {
  13308. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13309. }
  13310. StringBuilder cols = new StringBuilder();
  13311. StringBuilder sumCols = new StringBuilder();
  13312. foreach (DataRow item in result.Tables[0].Rows)
  13313. {
  13314. cols.AppendFormat(", d{0} AS \"{1}\"\n", item["id"], item["name"]);
  13315. sumCols.AppendFormat(", SUM(decode(td1.id, {0}, g.d, 0)) d{0}\n", item["id"]);
  13316. }
  13317. string sqlString = "SELECT gid\n" +
  13318. " ,decode(gid, 3, '合计', 1, '小计[' || gt2name || ']', gt2name) gt2name\n" +
  13319. " ,decode(gid, 0, td2name, '--') td2name\n" +
  13320. " ,gg.gc\n" +
  13321. " ,case when gg.gc is not null and gg.gc > 0 then round(tt.d / gg.gc,4) else null end gcc\n" +
  13322. " ,d\n" +
  13323. " ,c\n" +
  13324. " ,d-c g\n" +
  13325. cols +
  13326. " FROM (SELECT grouping_id(t.tecdepid, td2.id) gid\n" +
  13327. " ,nvl(t.tecdepid, -1) gt2id\n" +
  13328. " ,t.tecdepname gt2name\n" +
  13329. " ,td2.name td2name\n" +
  13330. " ,td2.displayno td2displayno\n" +
  13331. " ,SUM(g.d) d\n" +
  13332. " ,SUM(g.c) c\n" +
  13333. sumCols +
  13334. " FROM TMP_RPT_TECDEP_G g\n" +
  13335. " INNER JOIN TMP_RPT_TECDEP_T t\n" +
  13336. " ON g.goodsid = t.goodsid\n" +
  13337. " INNER JOIN tmp_rpt_tecdep_s s1\n" +
  13338. " ON s1.procedureid = g.pid\n" +
  13339. " INNER JOIN tp_mst_tecdep td1\n" +
  13340. " ON td1.id = s1.intecdepid\n" +
  13341. " LEFT JOIN tmp_rpt_tecdep_s s2\n" +
  13342. " ON s2.procedureid = g.f\n" +
  13343. " LEFT JOIN tp_mst_tecdep td2\n" +
  13344. " ON td2.id = s2.intecdepid\n" +
  13345. " WHERE td1.technologyflag = '1' -- 半成品工艺\n" +
  13346. " AND (td2.id IS NULL OR td2.technologyflag = '1')\n" +
  13347. " GROUP BY GROUPING SETS((t.tecdepid, t.tecdepname, td2.id, td2.name, td2.displayno),(t.tecdepid, t.tecdepname),())\n" +
  13348. " ORDER BY t.tecdepname, td2.displayno) tt\n" +
  13349. " LEFT JOIN (SELECT --grouping_id(gt2.goodstypeid) gid,\n" +
  13350. " nvl(t.tecdepid, -1) gt2id, COUNT(*) gc\n" +
  13351. " FROM tp_pm_groutingdailydetail gdd\n" +
  13352. " INNER JOIN TMP_RPT_TECDEP_T t\n" +
  13353. " ON gdd.goodsid = t.goodsid\n" +
  13354. " WHERE gdd.accountid = :in_accountid\n" +
  13355. " AND gdd.valueflag = '1'\n" +
  13356. " AND gdd.groutingflag = '1'\n" +
  13357. " AND gdd.groutingdate BETWEEN :in_datetimebegin AND\n" +
  13358. " :in_datetimeend\n" +
  13359. " GROUP BY GROUPING SETS((t.tecdepid),())) gg\n" +
  13360. " ON gg.gt2id = tt.gt2id\n" +
  13361. " ORDER BY tt.gt2name, tt.gid, tt.td2displayno";
  13362. oracleParameter = new OracleParameter[]
  13363. {
  13364. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13365. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13366. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13367. };
  13368. result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13369. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13370. {
  13371. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13372. }
  13373. sre.Data = result;
  13374. oracleConn.Commit();
  13375. return sre;
  13376. }
  13377. catch (Exception ex)
  13378. {
  13379. if (oracleConn.ConnState == ConnectionState.Open)
  13380. {
  13381. oracleConn.Disconnect();
  13382. }
  13383. throw ex;
  13384. }
  13385. }
  13386. /// <summary>
  13387. /// 获取成型存坯汇总表-注浆产品存坯汇总表
  13388. /// </summary>
  13389. /// <param name="cre"></param>
  13390. /// <param name="sUserInfo"></param>
  13391. /// <returns></returns>
  13392. public static ServiceResultEntity GetRPT030116GoodsData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13393. {
  13394. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13395. try
  13396. {
  13397. ServiceResultEntity sre = new ServiceResultEntity();
  13398. /*
  13399. string sqlString =
  13400. "SELECT gdrd.goodsid\n" +
  13401. " ,gdrd.goodscode\n" +
  13402. //" ,gdrd.groutinglineid\n" +
  13403. //" ,gdrd.groutinglinecode\n" +
  13404. //" ,gdrd.userid\n" +
  13405. //" ,gdrd.usercode\n" +
  13406. " ,gdrd.gddc rdcount -- 存坯数\n" +
  13407. " ,rdd.gldcount -- 模具数\n" +
  13408. " , CASE\n" +
  13409. " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
  13410. " round(gdrd.gddc / rdd.gldcount, 2)\n" +
  13411. " ELSE\n" +
  13412. " NULL\n" +
  13413. " END rddays -- 存坯天数\n" +
  13414. " ,gdrd.reserveddays -- 应存天数\n" +
  13415. " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
  13416. " FROM (SELECT gdd.goodsid\n" +
  13417. " ,gdd.goodscode\n" +
  13418. //" ,gdd.groutinglineid\n" +
  13419. //" ,gdd.groutinglinecode\n" +
  13420. //" ,gdd.userid\n" +
  13421. //" ,gdd.usercode\n" +
  13422. " ,g.reserveddays\n" +
  13423. " ,COUNT(*) gddc\n" +
  13424. " FROM tp_pm_groutingdailydetail gdd\n" +
  13425. " INNER JOIN tp_mst_goods g\n" +
  13426. " ON g.goodsid = gdd.goodsid\n" +
  13427. " INNER JOIN tp_mst_goodstype gt\n" +
  13428. " ON g.goodstypeid = gt.goodstypeid\n" +
  13429. " WHERE gdd.accountid = :accountid\n" +
  13430. " AND gdd.valueflag = '1'\n" +
  13431. " AND gdd.groutingflag = '1'\n" +
  13432. " AND gdd.barcode IS NOT NULL\n" +
  13433. " AND gdd.scrapflag = '0'\n" +
  13434. " AND gdd.deliverflag = '0'\n" +
  13435. " AND (:LineCode IS NULL OR\n" +
  13436. " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13437. " AND (:UserCode IS NULL OR instr(gdd.UserCode, :UserCode) > 0)\n" +
  13438. " AND (:GoodsCode IS NULL OR instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13439. " AND (:GoodsTypeCode IS NULL OR\n" +
  13440. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13441. " AND (:DateBegin IS NULL OR\n" +
  13442. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
  13443. " GROUP BY gdd.goodsid\n" +
  13444. " ,gdd.goodscode\n" +
  13445. //" ,gdd.groutinglineid\n" +
  13446. //" ,gdd.groutinglinecode\n" +
  13447. //" ,gdd.userid\n" +
  13448. //" ,gdd.usercode\n" +
  13449. " ,g.reserveddays) gdrd\n" +
  13450. " LEFT JOIN (SELECT gld.goodsid\n" +
  13451. //" ,gld.groutinglineid\n" +
  13452. " ,COUNT(*) gldcount\n" +
  13453. " FROM tp_pc_groutinglinedetail gld\n" +
  13454. " INNER JOIN tp_pc_groutingline gl\n" +
  13455. " ON gl.groutinglineid = gld.groutinglineid\n" +
  13456. " WHERE gld.valueflag = '1'\n" +
  13457. " AND gld.gmouldstatus = 1\n" +
  13458. " AND gl.accountid = :accountid\n" +
  13459. " AND gl.valueflag = '1'\n" +
  13460. " AND gl.gmouldstatus = 1\n" +
  13461. " GROUP BY gld.goodsid\n" +
  13462. //" ,gld.groutinglineid\n" +
  13463. " ) rdd\n" +
  13464. " ON rdd.goodsid = gdrd.goodsid\n" +
  13465. //" AND rdd.groutinglineid = gdrd.groutinglineid\n" +
  13466. " ORDER BY gdrd.goodscode\n" +
  13467. //" ,gdrd.groutinglinecode, gdrd.usercode"
  13468. "";
  13469. */
  13470. string sqlString =
  13471. "SELECT grouping_id(t.goodstypecode2, t.goodsid) gid\n" +
  13472. " ,t.goodstypecode2\n" +
  13473. " ,decode(grouping_id(t.goodstypecode2, t.goodsid),\n" +
  13474. " 3,\n" +
  13475. " '总计',\n" +
  13476. " 1,\n" +
  13477. " '合计[' || t.goodstypename2 || ']',\n" +
  13478. " t.goodstypename2) goodstypename2\n" +
  13479. " ,t.goodstypename\n" +
  13480. " ,t.goodsid\n" +
  13481. " ,t.goodscode\n" +
  13482. //" ,t.groutinglineid\n" +
  13483. //" ,t.groutinglinecode\n" +
  13484. //" ,t.userid\n" +
  13485. //" ,t.usercode\n" +
  13486. " ,SUM(t.rdcount) rdcount\n" +
  13487. " ,t.gldcount -- 模具数\n" +
  13488. " ,t.rddays -- 存坯天数\n" +
  13489. " ,t.reserveddays -- 应存天数\n" +
  13490. " ,SUM(t.ProfitNum) ProfitNum\n" +
  13491. " FROM (SELECT gt2.goodstypecode goodstypecode2\n" +
  13492. " ,gt2.goodstypename goodstypename2\n" +
  13493. " ,gdrd.goodsid\n" +
  13494. " ,gdrd.goodscode\n" +
  13495. " ,gdrd.goodstypename\n" +
  13496. //" ,gdrd.groutinglineid\n" +
  13497. //" ,gdrd.groutinglinecode\n" +
  13498. //" ,gdrd.userid\n" +
  13499. //" ,gdrd.usercode\n" +
  13500. " ,gdrd.gddc rdcount -- 存坯数\n" +
  13501. " ,rdd.gldcount -- 模具数\n" +
  13502. " , CASE\n" +
  13503. " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
  13504. " round(gdrd.gddc / rdd.gldcount, 2)\n" +
  13505. " ELSE\n" +
  13506. " NULL\n" +
  13507. " END rddays -- 存坯天数\n" +
  13508. " ,gdrd.reserveddays -- 应存天数\n" +
  13509. // 盈亏坯数 = 存坯数-应存天数*模具数 存坯天数 = 存坯数/模具数
  13510. " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
  13511. " FROM (SELECT gdd.goodsid\n" +
  13512. " ,gdd.goodscode\n" +
  13513. //" ,gdd.groutinglineid\n" +
  13514. //" ,gdd.groutinglinecode\n" +
  13515. //" ,gdd.userid\n" +
  13516. //" ,gdd.usercode\n" +
  13517. " ,g.reserveddays\n" +
  13518. " ,substr(gt.goodstypecode, 1, 6) goodstypecode2\n" +
  13519. " ,gt.goodstypename\n" +
  13520. " ,COUNT(*) gddc\n" +
  13521. " FROM tp_pm_groutingdailydetail gdd\n" +
  13522. " INNER JOIN tp_mst_goods g\n" +
  13523. " ON g.goodsid = gdd.goodsid\n" +
  13524. " INNER JOIN tp_mst_goodstype gt\n" +
  13525. " ON g.goodstypeid = gt.goodstypeid\n" +
  13526. " WHERE gdd.accountid = :accountid\n" +
  13527. " AND gdd.valueflag = '1'\n" +
  13528. " AND gdd.groutingflag = '1'\n" +
  13529. " AND gdd.barcode IS NOT NULL\n" +
  13530. " AND gdd.scrapflag = '0'\n" +
  13531. " AND gdd.deliverflag = '0'\n" +
  13532. " AND (:LineCode IS NULL OR\n" +
  13533. " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13534. " AND (:UserCode IS NULL OR\n" +
  13535. " instr(gdd.UserCode, :UserCode) > 0)\n" +
  13536. " AND (:GoodsCode IS NULL OR\n" +
  13537. " instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13538. " AND (:GoodsTypeCode IS NULL OR\n" +
  13539. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13540. " AND (:DateBegin IS NULL OR\n" +
  13541. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
  13542. " GROUP BY gt.goodstypecode,gt.goodstypename\n" +
  13543. " ,gdd.goodsid\n" +
  13544. " ,gdd.goodscode\n" +
  13545. //" ,gdd.groutinglineid\n" +
  13546. //" ,gdd.groutinglinecode\n" +
  13547. //" ,gdd.userid\n" +
  13548. //" ,gdd.usercode\n" +
  13549. " ,g.reserveddays) gdrd\n" +
  13550. " LEFT JOIN (SELECT gld.goodsid\n" +
  13551. //" ,gld.groutinglineid\n" +
  13552. " ,COUNT(*) gldcount\n" +
  13553. " FROM tp_pc_groutinglinedetail gld\n" +
  13554. " INNER JOIN tp_pc_groutingline gl\n" +
  13555. " ON gl.groutinglineid = gld.groutinglineid\n" +
  13556. " WHERE gld.valueflag = '1'\n" +
  13557. " AND gld.gmouldstatus = 1\n" +
  13558. " AND gl.accountid = :accountid\n" +
  13559. " AND gl.valueflag = '1'\n" +
  13560. " AND gl.gmouldstatus = 1\n" +
  13561. " GROUP BY gld.goodsid\n" +
  13562. //" , gld.groutinglineid" +
  13563. " ) rdd\n" +
  13564. " ON rdd.goodsid = gdrd.goodsid\n" +
  13565. //" AND rdd.groutinglineid = gdrd.groutinglineid\n" +
  13566. " INNER JOIN tp_mst_goodstype gt2\n" +
  13567. " ON gt2.accountid = :accountid\n" +
  13568. " AND gt2.goodstypecode = gdrd.goodstypecode2\n" +
  13569. " ORDER BY gt2.goodstypecode\n" +
  13570. " ,gdrd.goodscode\n" +
  13571. //" ,gdrd.groutinglinecode\n" +
  13572. //" ,gdrd.usercode" +
  13573. " ) t\n" +
  13574. " GROUP BY GROUPING SETS((t.goodstypecode2, t.goodstypename2,t.goodstypename, t.goodsid, t.goodscode, t.gldcount, t.rddays, t.reserveddays),(t.goodstypecode2, t.goodstypename2),())";
  13575. OracleParameter[] oracleParameter = new OracleParameter[]
  13576. {
  13577. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13578. new OracleParameter(":DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13579. new OracleParameter(":DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13580. new OracleParameter(":GoodsTypeCode",OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13581. new OracleParameter(":GoodsCode",OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13582. new OracleParameter(":LineCode",OracleDbType.NVarchar2, cre.Properties["LineCode"], ParameterDirection.Input),
  13583. new OracleParameter(":UserCode",OracleDbType.NVarchar2, cre.Properties["UserCode"], ParameterDirection.Input),
  13584. };
  13585. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13586. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13587. {
  13588. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13589. }
  13590. sre.Data = result;
  13591. return sre;
  13592. }
  13593. catch (Exception ex)
  13594. {
  13595. if (oracleConn.ConnState == ConnectionState.Open)
  13596. {
  13597. oracleConn.Close();
  13598. }
  13599. throw ex;
  13600. }
  13601. }
  13602. /// <summary>
  13603. /// 获取成型存坯汇总表-成型工号存坯汇总表
  13604. /// </summary>
  13605. /// <param name="cre"></param>
  13606. /// <param name="sUserInfo"></param>
  13607. /// <returns></returns>
  13608. public static ServiceResultEntity GetRPT030116UserData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13609. {
  13610. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13611. try
  13612. {
  13613. ServiceResultEntity sre = new ServiceResultEntity();
  13614. /*
  13615. string sqlString =
  13616. "SELECT gdrd.goodsid\n" +
  13617. " ,gdrd.goodscode\n" +
  13618. " ,gdrd.groutinglineid\n" +
  13619. " ,gdrd.groutinglinecode\n" +
  13620. " ,gdrd.userid\n" +
  13621. " ,gdrd.usercode\n" +
  13622. " ,gdrd.gddc rdcount -- 存坯数\n" +
  13623. " ,rdd.gldcount -- 模具数\n" +
  13624. " , CASE\n" +
  13625. " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
  13626. " round(gdrd.gddc / rdd.gldcount, 2)\n" +
  13627. " ELSE\n" +
  13628. " NULL\n" +
  13629. " END rddays -- 存坯天数\n" +
  13630. " ,gdrd.reserveddays -- 应存天数\n" +
  13631. " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
  13632. " FROM (SELECT gdd.goodsid\n" +
  13633. " ,gdd.goodscode\n" +
  13634. " ,gdd.groutinglineid\n" +
  13635. " ,gdd.groutinglinecode\n" +
  13636. " ,gdd.userid\n" +
  13637. " ,gdd.usercode\n" +
  13638. " ,g.reserveddays\n" +
  13639. " ,COUNT(*) gddc\n" +
  13640. " FROM tp_pm_groutingdailydetail gdd\n" +
  13641. " INNER JOIN tp_mst_goods g\n" +
  13642. " ON g.goodsid = gdd.goodsid\n" +
  13643. " INNER JOIN tp_mst_goodstype gt\n" +
  13644. " ON g.goodstypeid = gt.goodstypeid\n" +
  13645. " WHERE gdd.accountid = :accountid\n" +
  13646. " AND gdd.valueflag = '1'\n" +
  13647. " AND gdd.groutingflag = '1'\n" +
  13648. " AND gdd.barcode IS NOT NULL\n" +
  13649. " AND gdd.scrapflag = '0'\n" +
  13650. " AND gdd.deliverflag = '0'\n" +
  13651. " AND (:LineCode IS NULL OR\n" +
  13652. " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13653. " AND (:UserCode IS NULL OR instr(gdd.UserCode, :UserCode) > 0)\n" +
  13654. " AND (:GoodsCode IS NULL OR instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13655. " AND (:GoodsTypeCode IS NULL OR\n" +
  13656. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13657. " AND (:DateBegin IS NULL OR\n" +
  13658. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
  13659. " GROUP BY gdd.goodsid\n" +
  13660. " ,gdd.goodscode\n" +
  13661. " ,gdd.groutinglineid\n" +
  13662. " ,gdd.groutinglinecode\n" +
  13663. " ,gdd.userid\n" +
  13664. " ,gdd.usercode\n" +
  13665. " ,g.reserveddays) gdrd\n" +
  13666. " LEFT JOIN (SELECT gld.goodsid\n" +
  13667. " ,gld.groutinglineid\n" +
  13668. " ,COUNT(*) gldcount\n" +
  13669. " FROM tp_pc_groutinglinedetail gld\n" +
  13670. " INNER JOIN tp_pc_groutingline gl\n" +
  13671. " ON gl.groutinglineid = gld.groutinglineid\n" +
  13672. " WHERE gld.valueflag = '1'\n" +
  13673. " AND gld.gmouldstatus = 1\n" +
  13674. " AND gl.accountid = :accountid\n" +
  13675. " AND gl.valueflag = '1'\n" +
  13676. " AND gl.gmouldstatus = 1\n" +
  13677. " GROUP BY gld.goodsid\n" +
  13678. " ,gld.groutinglineid\n" +
  13679. " ) rdd\n" +
  13680. " ON rdd.goodsid = gdrd.goodsid\n" +
  13681. " AND rdd.groutinglineid = gdrd.groutinglineid\n" +
  13682. " ORDER BY gdrd.goodscode\n" +
  13683. " ,gdrd.groutinglinecode, gdrd.usercode" +
  13684. "";
  13685. */
  13686. string sqlString =
  13687. "SELECT grouping_id(t.goodstypecode2, t.goodsid) gid\n" +
  13688. " ,t.goodstypecode2\n" +
  13689. " ,decode(grouping_id(t.goodstypecode2, t.goodsid),\n" +
  13690. " 3,\n" +
  13691. " '总计',\n" +
  13692. " 1,\n" +
  13693. " '合计[' || t.goodstypename2 || ']',\n" +
  13694. " t.goodstypename2) goodstypename2\n" +
  13695. " ,t.goodsid\n" +
  13696. " ,t.goodscode\n" +
  13697. " ,t.groutinglineid\n" +
  13698. " ,t.groutinglinecode\n" +
  13699. " ,t.userid\n" +
  13700. " ,t.usercode\n" +
  13701. " ,t.MONITORName\n" +
  13702. " ,SUM(t.rdcount) rdcount\n" +
  13703. " ,t.gldcount -- 模具数\n" +
  13704. " ,t.rddays -- 存坯天数\n" +
  13705. " ,t.reserveddays -- 应存天数\n" +
  13706. " ,SUM(t.ProfitNum) ProfitNum\n" +
  13707. " FROM (SELECT gt2.goodstypecode goodstypecode2\n" +
  13708. " ,gt2.goodstypename goodstypename2\n" +
  13709. " ,gdrd.goodsid\n" +
  13710. " ,gdrd.goodscode\n" +
  13711. " ,gdrd.groutinglineid\n" +
  13712. " ,gdrd.groutinglinecode\n" +
  13713. " ,gdrd.userid\n" +
  13714. " ,gdrd.usercode\n" +
  13715. " ,mu.username MONITORName\n" +
  13716. " ,gdrd.gddc rdcount -- 存坯数\n" +
  13717. " ,rdd.gldcount -- 模具数\n" +
  13718. " , CASE\n" +
  13719. " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
  13720. " round(gdrd.gddc / rdd.gldcount, 2)\n" +
  13721. " ELSE\n" +
  13722. " NULL\n" +
  13723. " END rddays -- 存坯天数\n" +
  13724. " ,gdrd.reserveddays -- 应存天数\n" +
  13725. " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
  13726. " FROM (SELECT gdd.goodsid\n" +
  13727. " ,gdd.goodscode\n" +
  13728. " ,gdd.groutinglineid\n" +
  13729. " ,gdd.groutinglinecode\n" +
  13730. " ,gdd.userid\n" +
  13731. " ,gdd.usercode\n" +
  13732. " ,g.reserveddays\n" +
  13733. " ,substr(gt.goodstypecode, 1, 6) goodstypecode2\n" +
  13734. " ,COUNT(*) gddc\n" +
  13735. " FROM tp_pm_groutingdailydetail gdd\n" +
  13736. " INNER JOIN tp_mst_goods g\n" +
  13737. " ON g.goodsid = gdd.goodsid\n" +
  13738. " INNER JOIN tp_mst_goodstype gt\n" +
  13739. " ON g.goodstypeid = gt.goodstypeid\n" +
  13740. " WHERE gdd.accountid = :accountid\n" +
  13741. " AND gdd.valueflag = '1'\n" +
  13742. " AND gdd.groutingflag = '1'\n" +
  13743. " AND gdd.barcode IS NOT NULL\n" +
  13744. " AND gdd.scrapflag = '0'\n" +
  13745. " AND gdd.deliverflag = '0'\n" +
  13746. " AND (:LineCode IS NULL OR\n" +
  13747. " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13748. " AND (:UserCode IS NULL OR\n" +
  13749. " instr(gdd.UserCode, :UserCode) > 0)\n" +
  13750. " AND (:GoodsCode IS NULL OR\n" +
  13751. " instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13752. " AND (:GoodsTypeCode IS NULL OR\n" +
  13753. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13754. " AND (:DateBegin IS NULL OR\n" +
  13755. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
  13756. " GROUP BY gt.goodstypecode\n" +
  13757. " ,gdd.goodsid\n" +
  13758. " ,gdd.goodscode\n" +
  13759. " ,gdd.groutinglineid\n" +
  13760. " ,gdd.groutinglinecode\n" +
  13761. " ,gdd.userid\n" +
  13762. " ,gdd.usercode\n" +
  13763. " ,g.reserveddays) gdrd\n" +
  13764. " LEFT JOIN (SELECT gld.goodsid\n" +
  13765. " ,gld.groutinglineid\n" +
  13766. " ,gl.MONITORID\n" +
  13767. " ,COUNT(*) gldcount\n" +
  13768. " FROM tp_pc_groutinglinedetail gld\n" +
  13769. " INNER JOIN tp_pc_groutingline gl\n" +
  13770. " ON gl.groutinglineid = gld.groutinglineid\n" +
  13771. " WHERE gld.valueflag = '1'\n" +
  13772. " AND gld.gmouldstatus = 1\n" +
  13773. " AND gl.accountid = :accountid\n" +
  13774. " AND gl.valueflag = '1'\n" +
  13775. " AND gl.gmouldstatus = 1\n" +
  13776. " GROUP BY gld.goodsid, gld.groutinglineid,gl.MONITORID) rdd\n" +
  13777. " ON rdd.goodsid = gdrd.goodsid\n" +
  13778. " AND rdd.groutinglineid = gdrd.groutinglineid\n" +
  13779. // 成型班长
  13780. " LEFT JOIN tp_mst_user mu\n" +
  13781. " ON mu.userid = rdd.MONITORID\n" +
  13782. " INNER JOIN tp_mst_goodstype gt2\n" +
  13783. " ON gt2.accountid = :accountid\n" +
  13784. " AND gt2.goodstypecode = gdrd.goodstypecode2\n" +
  13785. " ORDER BY gt2.goodstypecode\n" +
  13786. " ,gdrd.goodscode\n" +
  13787. " ,gdrd.groutinglinecode\n" +
  13788. " ,gdrd.usercode) t\n" +
  13789. " 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),())";
  13790. OracleParameter[] oracleParameter = new OracleParameter[]
  13791. {
  13792. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13793. new OracleParameter(":DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13794. new OracleParameter(":DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13795. new OracleParameter(":GoodsTypeCode",OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13796. new OracleParameter(":GoodsCode",OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13797. new OracleParameter(":LineCode",OracleDbType.NVarchar2, cre.Properties["LineCode"], ParameterDirection.Input),
  13798. new OracleParameter(":UserCode",OracleDbType.NVarchar2, cre.Properties["UserCode"], ParameterDirection.Input),
  13799. };
  13800. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13801. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13802. {
  13803. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13804. }
  13805. sre.Data = result;
  13806. return sre;
  13807. }
  13808. catch (Exception ex)
  13809. {
  13810. if (oracleConn.ConnState == ConnectionState.Open)
  13811. {
  13812. oracleConn.Close();
  13813. }
  13814. throw ex;
  13815. }
  13816. }
  13817. /// <summary>
  13818. /// 获取成型存坯汇总表-成型存坯明细表
  13819. /// </summary>
  13820. /// <param name="cre"></param>
  13821. /// <param name="sUserInfo"></param>
  13822. /// <returns></returns>
  13823. public static ServiceResultEntity GetRPT030116DData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13824. {
  13825. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13826. try
  13827. {
  13828. ServiceResultEntity sre = new ServiceResultEntity();
  13829. string sqlString = "SELECT gdd.barcode\n" +
  13830. //" ,gdd.groutinglineid\n" +
  13831. " ,gdd.groutinglinecode\n" +
  13832. " ,gdd.GroutingMouldCode\n" +
  13833. //" ,gdd.goodsid\n" +
  13834. " ,gdd.goodscode\n" +
  13835. //" ,gdd.userid\n" +
  13836. " ,gdd.usercode\n" +
  13837. " ,gdd.groutingdate\n" +
  13838. // 成型班长
  13839. " ,mu.username as MONITORName" +
  13840. " FROM tp_pm_groutingdailydetail gdd\n" +
  13841. " INNER JOIN tp_mst_goods g\n" +
  13842. " ON g.goodsid = gdd.goodsid\n" +
  13843. // 成型线
  13844. " LEFT JOIN tp_pc_groutingline gl" +
  13845. " ON gl.groutinglineid = GDD.GroutingLineID" +
  13846. // 成型班长
  13847. " LEFT JOIN tp_mst_user mu" +
  13848. " ON mu.userid = gl.MONITORID " +
  13849. " INNER JOIN tp_mst_goodstype gt\n" +
  13850. " ON g.goodstypeid = gt.goodstypeid\n" +
  13851. " WHERE gdd.accountid = :accountid\n" +
  13852. " AND gdd.valueflag = '1'\n" +
  13853. " AND gdd.groutingflag = '1'\n" +
  13854. " AND gdd.barcode IS NOT NULL\n" +
  13855. " AND gdd.scrapflag = '0'\n" +
  13856. " AND gdd.deliverflag = '0'\n" +
  13857. " AND (:LineID IS NULL OR gdd.groutinglineid = :LineID)\n" +
  13858. " AND (:UserID IS NULL OR gdd.UserID = :UserID)\n" +
  13859. " AND (:GoodsID IS NULL OR gdd.goodsid = :GoodsID)\n" +
  13860. " AND (:LineCode IS NULL OR instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13861. " AND (:UserCode IS NULL OR instr(gdd.UserCode, :UserCode) > 0)\n" +
  13862. " AND (:GoodsCode IS NULL OR instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13863. " AND (:GoodsTypeCode IS NULL OR\n" +
  13864. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13865. " AND (:DateBegin IS NULL OR\n" +
  13866. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)" +
  13867. " ORDER BY gdd.barcode\n" +
  13868. //" ,gdd.goodscode, gdrd.groutinglinecode, gdrd.usercode" +
  13869. "";
  13870. OracleParameter[] oracleParameter = new OracleParameter[]
  13871. {
  13872. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13873. new OracleParameter(":DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13874. new OracleParameter(":DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13875. new OracleParameter(":GoodsTypeCode",OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13876. new OracleParameter(":GoodsCode",OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13877. new OracleParameter(":LineCode",OracleDbType.NVarchar2, cre.Properties["LineCode"], ParameterDirection.Input),
  13878. new OracleParameter(":UserCode",OracleDbType.NVarchar2, cre.Properties["UserCode"], ParameterDirection.Input),
  13879. new OracleParameter(":GoodsID",OracleDbType.Int32, cre.Properties["GoodsID"], ParameterDirection.Input),
  13880. new OracleParameter(":LineID",OracleDbType.Int32, cre.Properties["LineID"], ParameterDirection.Input),
  13881. new OracleParameter(":UserID",OracleDbType.Int32, cre.Properties["UserID"], ParameterDirection.Input),
  13882. };
  13883. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13884. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13885. {
  13886. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13887. }
  13888. sre.Data = result;
  13889. return sre;
  13890. }
  13891. catch (Exception ex)
  13892. {
  13893. if (oracleConn.ConnState == ConnectionState.Open)
  13894. {
  13895. oracleConn.Close();
  13896. }
  13897. throw ex;
  13898. }
  13899. }
  13900. /// <summary>
  13901. /// 年度各工序月产量统计表
  13902. /// </summary>
  13903. /// <param name="cre"></param>
  13904. /// <param name="sUserInfo"></param>
  13905. /// <returns></returns>
  13906. public static ServiceResultEntity GetRPT030118Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13907. {
  13908. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13909. try
  13910. {
  13911. ServiceResultEntity sre = new ServiceResultEntity();
  13912. string sump = INIUtility.Read("ReportParameters", "RPT_030118", AppDomain.CurrentDomain.BaseDirectory + "Config.ini");
  13913. string sqlString = "select gt2.goodstypecode\n" +
  13914. " ,nvl2(gt2.goodstypename\n" +
  13915. " ,nvl2(t.procedureid\n" +
  13916. " ,gt2.goodstypename\n" +
  13917. " ,'小计[' || gt2.goodstypename || ']')\n" +
  13918. " ,'总计') goodstypename\n" +
  13919. " ,p.displayno\n" +
  13920. " ,decode(t.procedureid, null, '--', 0, '注浆', p.procedurename) procedurename\n" +
  13921. " ,sum(decode(t.mm, '12', t.pcount, 0)) m12\n" +
  13922. " ,sum(decode(t.mm, '01', t.pcount, 0)) m01\n" +
  13923. " ,sum(decode(t.mm, '02', t.pcount, 0)) m02\n" +
  13924. " ,sum(decode(t.mm, '03', t.pcount, 0)) m03\n" +
  13925. " ,sum(decode(t.mm, '04', t.pcount, 0)) m04\n" +
  13926. " ,sum(decode(t.mm, '05', t.pcount, 0)) m05\n" +
  13927. " ,sum(decode(t.mm, '06', t.pcount, 0)) m06\n" +
  13928. " ,sum(decode(t.mm, '07', t.pcount, 0)) m07\n" +
  13929. " ,sum(decode(t.mm, '08', t.pcount, 0)) m08\n" +
  13930. " ,sum(decode(t.mm, '09', t.pcount, 0)) m09\n" +
  13931. " ,sum(decode(t.mm, '10', t.pcount, 0)) m10\n" +
  13932. " ,sum(decode(t.mm, '11', t.pcount, 0)) m11\n" +
  13933. " ,sum(t.pcount) msum\n" +
  13934. " from (select --substr(gt.goodstypecode, 1, 6) gtcode2\n" +
  13935. " gt.goodstypecode\n" +
  13936. " ,0 procedureid\n" +
  13937. " ,to_char(pd.groutingdate, 'mm') mm\n" +
  13938. " ,count(*) pcount\n" +
  13939. " from tp_pm_groutingdailydetail pd\n" +
  13940. " inner join tp_mst_goods g\n" +
  13941. " on g.goodsid = pd.goodsid\n" +
  13942. " inner join tp_mst_goodstype gt\n" +
  13943. " on gt.goodstypeid = g.goodstypeid\n" +
  13944. " where pd.accountid = :accountid\n" +
  13945. " and pd.groutingflag = '1'\n" +
  13946. " and pd.groutingdate >= :begindate\n" +
  13947. " and pd.groutingdate < :enddate\n" +
  13948. " group by --substr(gt.goodstypecode, 1, 6)\n" +
  13949. " gt.goodstypecode\n" +
  13950. " ,to_char(pd.groutingdate, 'mm')\n" +
  13951. " union all\n" +
  13952. " select --substr(gt.goodstypecode, 1, 6) gtcode2\n" +
  13953. " gt.goodstypecode\n" +
  13954. " ,pd.procedureid\n" +
  13955. " ,to_char(pd.createtime, 'mm') mm\n" +
  13956. " ,count(*) pcount\n" +
  13957. " from tp_pm_productiondata pd\n" +
  13958. " inner join tp_mst_goods g\n" +
  13959. " on g.goodsid = pd.goodsid\n" +
  13960. " inner join tp_mst_goodstype gt\n" +
  13961. " on gt.goodstypeid = g.goodstypeid\n" +
  13962. " where pd.accountid = :accountid\n" +
  13963. " and pd.createtime >= :begindate\n" +
  13964. " and pd.createtime < :enddate\n" +
  13965. (string.IsNullOrWhiteSpace(sump) ? "" : " and pd.procedureid in (" + sump + ")\n") +
  13966. " group by --substr(gt.goodstypecode, 1, 6)\n" +
  13967. " gt.goodstypecode\n" +
  13968. " ,pd.procedureid\n" +
  13969. " ,to_char(pd.createtime, 'mm')" +
  13970. " union all\n" +
  13971. " select --substr(gt.goodstypecode, 1, 6) gtcode2\n" +
  13972. " gt.goodstypecode\n" +
  13973. " ,pd.procedureid\n" +
  13974. " ,to_char(pd.BACKOUTTIME, 'mm') mm\n" +
  13975. " ,count(*) pcount\n" +
  13976. " from tp_pm_productiondata pd\n" +
  13977. " inner join tp_mst_goods g\n" +
  13978. " on g.goodsid = pd.goodsid\n" +
  13979. " inner join tp_mst_goodstype gt\n" +
  13980. " on gt.goodstypeid = g.goodstypeid\n" +
  13981. " where pd.accountid = :accountid\n" +
  13982. " and pd.valueflag = '0'\n" +
  13983. " and pd.BACKOUTTIME >= :begindate\n" +
  13984. " and pd.BACKOUTTIME < :enddate\n" +
  13985. (string.IsNullOrWhiteSpace(sump) ? "" : " and pd.procedureid in (" + sump + ")\n") +
  13986. " group by --substr(gt.goodstypecode, 1, 6)\n" +
  13987. " gt.goodstypecode\n" +
  13988. " ,pd.procedureid\n" +
  13989. " ,to_char(pd.BACKOUTTIME, 'mm')) t\n" +
  13990. " inner join tp_mst_goodstype gt2\n" +
  13991. " on gt2.accountid = 1\n" +
  13992. " and gt2.goodstypecode = substr(t.goodstypecode, 1, 6) --t.gtcode2\n" +
  13993. " left join tp_pc_procedure p\n" +
  13994. " on p.procedureid = t.procedureid\n" +
  13995. " group by grouping sets((gt2.goodstypecode, gt2.goodstypename, p.displayno, p.procedurename, t.procedureid),(gt2.goodstypecode, gt2.goodstypename),())";
  13996. OracleParameter[] oracleParameter = new OracleParameter[]
  13997. {
  13998. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13999. new OracleParameter(":begindate",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  14000. new OracleParameter(":enddate",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  14001. };
  14002. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  14003. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14004. {
  14005. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14006. }
  14007. sre.Data = result;
  14008. return sre;
  14009. }
  14010. catch (Exception ex)
  14011. {
  14012. throw ex;
  14013. }
  14014. finally
  14015. {
  14016. oracleConn?.Close();
  14017. }
  14018. }
  14019. /// <summary>
  14020. /// 半检返修缺陷汇总表
  14021. /// </summary>
  14022. /// <param name="cre"></param>
  14023. /// <param name="sUserInfo"></param>
  14024. /// <returns></returns>
  14025. public static ServiceResultEntity GetRPT030119Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14026. {
  14027. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14028. try
  14029. {
  14030. ServiceResultEntity sre = new ServiceResultEntity();
  14031. string sqlString = "select dp.defectpositionid\n" +
  14032. " ,dp.defectpositioncode\n" +
  14033. " ,dp.defectpositionname\n" +
  14034. " ,'D_' || dp.defectpositionid colname\n" +
  14035. " from tp_mst_scdefectposition dp\n" +
  14036. " where dp.valueflag = '1'\n" +
  14037. " and dp.accountid = " + sUserInfo.AccountID + "\n";
  14038. if (!string.IsNullOrWhiteSpace(cre.Properties["defectpositionIDS"] + ""))
  14039. {
  14040. sqlString += " and instr(','||'"+ cre.Properties["defectpositionIDS"] + "'||',', ','||dp.defectpositionid||',') > 0 \n";
  14041. }
  14042. sqlString += " order by dp.displayno";
  14043. DataTable scdTable = oracleConn.GetSqlResultToDt(sqlString);
  14044. if (scdTable == null || scdTable.Rows.Count == 0)
  14045. {
  14046. return sre;
  14047. }
  14048. List<string> pivotFor = new List<string>();
  14049. foreach (DataRow item in scdTable.Rows)
  14050. {
  14051. pivotFor.Add($"{item["defectpositionid"]} as {item["colname"]}");
  14052. }
  14053. List<OracleParameter> oracleParameters = new List<OracleParameter>();
  14054. oracleParameters.Add(new OracleParameter(":accountid", sUserInfo.AccountID));
  14055. sqlString = "select *\n" +
  14056. " from (select srd.defectid\n" +
  14057. " ,scd.defectcode\n" +
  14058. " ,scd.defectname\n" +
  14059. " ,nvl(srd.defectpositionid, 0) defectpositionid\n" +
  14060. " ,count(srd.semireworkdefectid) cc\n" +
  14061. " from TP_PM_SEMIREWORKDEFECT srd\n" +
  14062. " inner join TP_PM_SEMIREWORK sr\n" +
  14063. " on sr.SEMIREWORKID = srd.SEMIREWORKID\n" +
  14064. " left join tp_mst_semicheckdefect scd\n" +
  14065. " on scd.defectid = srd.defectid\n" +
  14066. " left join tp_mst_scdefectposition scdp\n" +
  14067. " on scdp.defectpositionid = srd.defectpositionid\n" +
  14068. " left join TP_MST_GOODS g on g.GOODSID = sr.GOODSID\n" + //xuwei add 2019-11-29
  14069. " left join TP_MST_GOODSTYPE gt on g.GOODSTYPEID = gt.GOODSTYPEID\n" + //xuwei add 2019-11-29
  14070. " where srd.valueflag = '1'\n" +
  14071. " and sr.BACKOUTFLAG = '0'\n" +
  14072. " and sr.valueflag = '1'\n" +
  14073. " and sr.accountid = :accountid\n";
  14074. // 半检日期
  14075. if (cre.Properties["SemireWorkTimeBegin"] != null)
  14076. {
  14077. sqlString += " and sr.SEMIREWORKTIME >= :SemireWorkTimeBegin\n";
  14078. oracleParameters.Add(new OracleParameter(":SemireWorkTimeBegin", cre.Properties["SemireWorkTimeBegin"]));
  14079. }
  14080. if (cre.Properties["SemireWorkTimeEnd"] != null)
  14081. {
  14082. sqlString += " and sr.SEMIREWORKTIME < :SemireWorkTimeEnd\n";
  14083. oracleParameters.Add(new OracleParameter(":SemireWorkTimeEnd", cre.Properties["SemireWorkTimeEnd"]));
  14084. }
  14085. // 产品编码 GOODSCODE
  14086. if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSCODE"]+""))
  14087. {
  14088. sqlString += " and instr(','||:GOODSCODE||',' , ','||sr.GOODSCODE||',') > 0 \n";
  14089. oracleParameters.Add(new OracleParameter(":GOODSCODE", cre.Properties["GOODSCODE"]));
  14090. }
  14091. // 成型工号 GROUTINGUSERCODE
  14092. if (!string.IsNullOrWhiteSpace(cre.Properties["GROUTINGUSERCODE"] + ""))
  14093. {
  14094. //xuwei modify 2019-11-13
  14095. //sqlString += " and instr(sr.GROUTINGUSERCODE,:GROUTINGUSERCODE) > 0 \n";
  14096. sqlString += " and instr(','||:GROUTINGUSERCODE||',' , ','||sr.GROUTINGUSERCODE||',') > 0 \n";
  14097. //xuwei end
  14098. oracleParameters.Add(new OracleParameter(":GROUTINGUSERCODE", cre.Properties["GROUTINGUSERCODE"]));
  14099. }
  14100. // 半检工号 SEMIREWORKUSERCODE
  14101. if (!string.IsNullOrWhiteSpace(cre.Properties["SEMIREWORKUSERCODE"] + ""))
  14102. {
  14103. //xuwei modify 2019-11-13
  14104. //sqlString += " and instr(sr.SEMIREWORKUSERCODE,:SEMIREWORKUSERCODE) > 0 \n";
  14105. sqlString += " and instr(','||:SEMIREWORKUSERCODE||',' , ','||sr.SEMIREWORKUSERCODE||',') > 0 \n";
  14106. //xuwei end
  14107. oracleParameters.Add(new OracleParameter(":SEMIREWORKUSERCODE", cre.Properties["SEMIREWORKUSERCODE"]));
  14108. }
  14109. // 缺陷位置 scdp.defectpositionname
  14110. if (!string.IsNullOrWhiteSpace(cre.Properties["defectpositionname"] + ""))
  14111. {
  14112. sqlString += " and instr(scdp.defectpositionname,:defectpositionname) > 0 \n";
  14113. oracleParameters.Add(new OracleParameter(":defectpositionname", cre.Properties["defectpositionname"]));
  14114. }
  14115. if (!string.IsNullOrWhiteSpace(cre.Properties["defectpositionIDS"] + ""))
  14116. {
  14117. sqlString += " and instr(','||:defectpositionIDS||',', ','||srd.defectpositionid||',') > 0 \n";
  14118. oracleParameters.Add(new OracleParameter(":defectpositionIDS", cre.Properties["defectpositionIDS"]));
  14119. }
  14120. // 缺陷名称 scd.defectname
  14121. if (!string.IsNullOrWhiteSpace(cre.Properties["defectname"] + ""))
  14122. {
  14123. sqlString += " and instr(scd.defectname,:defectname) > 0 \n";
  14124. oracleParameters.Add(new OracleParameter(":defectname", cre.Properties["defectname"]));
  14125. }
  14126. // 缺陷编码 scd.defectcode
  14127. if (!string.IsNullOrWhiteSpace(cre.Properties["defectcode"] + ""))
  14128. {
  14129. sqlString += " and scd.defectcode = :defectcode \n";
  14130. oracleParameters.Add(new OracleParameter(":defectcode", cre.Properties["defectcode"]));
  14131. }
  14132. //产品类别ID xuwei add 2019-11-29 g.GOODSTYPEID
  14133. if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSTYPEID"] + ""))
  14134. {
  14135. sqlString += " and instr(','||:GOODSTYPEID||',' , ','||g.GOODSTYPEID||',') > 0 \n";
  14136. oracleParameters.Add(new OracleParameter(":GOODSTYPEID", cre.Properties["GOODSTYPEID"]));
  14137. }
  14138. //产品类别Code xuwei add 2019-11-29 g.GOODSTYPECODE
  14139. if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSTYPECODE"] + ""))
  14140. {
  14141. sqlString += " and instr(gt.GOODSTYPECODE , :GOODSTYPECODE) = 1 \n";
  14142. oracleParameters.Add(new OracleParameter(":GOODSTYPECODE", cre.Properties["GOODSTYPECODE"]));
  14143. }
  14144. //返修工序 xuwei add 2019-11-29 sr.REWORKPROCEDUREID
  14145. if (!string.IsNullOrWhiteSpace(cre.Properties["REWORKPROCEDUREID"] + ""))
  14146. {
  14147. sqlString += " and instr(','||:REWORKPROCEDUREID||',' , ','||sr.REWORKPROCEDUREID||',') > 0 \n";
  14148. oracleParameters.Add(new OracleParameter(":REWORKPROCEDUREID", cre.Properties["REWORKPROCEDUREID"]));
  14149. }
  14150. sqlString +=
  14151. " group by grouping sets((srd.defectid, scd.defectcode, scd.defectname, srd.defectpositionid),(srd.defectid, scd.defectcode, scd.defectname),(srd.defectpositionid),())) t\n" +
  14152. "pivot(sum(cc)\n" +
  14153. " for defectpositionid in("+string.Join(",", pivotFor) + ", 0 AS D_0))\n" +
  14154. " order by defectid";
  14155. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameters.ToArray());
  14156. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14157. {
  14158. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14159. return sre;
  14160. }
  14161. DataTable table = result.Tables[0];
  14162. DataRow dataRow = table.Rows[table.Rows.Count - 1];
  14163. dataRow["defectname"] = "合计";
  14164. foreach (DataRow item in scdTable.Rows)
  14165. {
  14166. string colname = item["colname"] + "";
  14167. if (table.Columns.Contains(colname))
  14168. {
  14169. if (dataRow[colname] == null || dataRow[colname] == DBNull.Value)
  14170. {
  14171. table.Columns.Remove(colname);
  14172. }
  14173. else
  14174. {
  14175. table.Columns[colname].Caption = item["defectpositionname"] + "";
  14176. }
  14177. }
  14178. }
  14179. table.Columns["D_0"].Caption = "合计";
  14180. sre.Data = result;
  14181. return sre;
  14182. }
  14183. catch (Exception ex)
  14184. {
  14185. throw ex;
  14186. }
  14187. finally
  14188. {
  14189. oracleConn?.Close();
  14190. }
  14191. }
  14192. /// <summary>
  14193. /// 模具注浆分析表
  14194. /// </summary>
  14195. /// <param name="cre"></param>
  14196. /// <param name="sUserInfo"></param>
  14197. /// <returns></returns>
  14198. public static ServiceResultEntity GetRPT040111Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14199. {
  14200. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  14201. try
  14202. {
  14203. ServiceResultEntity sre = new ServiceResultEntity();
  14204. OracleParameter[] oracleParameter = new OracleParameter[]
  14205. {
  14206. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14207. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["GroutingDateBegin"], ParameterDirection.Input),
  14208. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["GroutingDateEnd"], ParameterDirection.Input),
  14209. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  14210. new OracleParameter("in_MouldBarcode",OracleDbType.Varchar2, cre.Properties["MouldBarcode"], ParameterDirection.Input),
  14211. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  14212. };
  14213. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_Mould_Groutingnum_AN", oracleParameter);
  14214. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14215. {
  14216. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14217. }
  14218. sre.Data = result;
  14219. oracleConn.Commit();
  14220. return sre;
  14221. }
  14222. catch (Exception ex)
  14223. {
  14224. if (oracleConn.ConnState == ConnectionState.Open)
  14225. {
  14226. oracleConn.Disconnect();
  14227. }
  14228. throw ex;
  14229. }
  14230. }
  14231. /// <summary>
  14232. /// 成检产品预算分析表
  14233. /// </summary>
  14234. /// <param name="cre"></param>
  14235. /// <param name="sUserInfo"></param>
  14236. /// <returns></returns>
  14237. public static ServiceResultEntity GetRPT040112Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14238. {
  14239. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  14240. try
  14241. {
  14242. ServiceResultEntity sre = new ServiceResultEntity();
  14243. OracleParameter[] oracleParameter = new OracleParameter[]
  14244. {
  14245. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14246. new OracleParameter("in_InTimeBegin",OracleDbType.Date, cre.Properties["InTimeBegin"], ParameterDirection.Input),
  14247. new OracleParameter("in_InTimeEnd",OracleDbType.Date, cre.Properties["InTimeEnd"], ParameterDirection.Input),
  14248. new OracleParameter("in_OutTimeBegin",OracleDbType.Date, cre.Properties["OutTimeBegin"], ParameterDirection.Input),
  14249. new OracleParameter("in_OutTimeEnd",OracleDbType.Date, cre.Properties["OutTimeEnd"], ParameterDirection.Input),
  14250. new OracleParameter("in_KilnID",OracleDbType.Int32, cre.Properties["KilnID"], ParameterDirection.Input),
  14251. new OracleParameter("in_KilnCarNumBegin",OracleDbType.Int32, cre.Properties["KilnCarNumBegin"], ParameterDirection.Input),
  14252. new OracleParameter("in_KilnCarNumEnd",OracleDbType.Int32, cre.Properties["KilnCarNumEnd"], ParameterDirection.Input),
  14253. new OracleParameter("out_KilnInfo",OracleDbType.RefCursor, null, ParameterDirection.Output),
  14254. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  14255. };
  14256. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_ExpectFinishedProduct", oracleParameter);
  14257. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14258. {
  14259. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14260. }
  14261. sre.Data = result;
  14262. oracleConn.Commit();
  14263. return sre;
  14264. }
  14265. catch (Exception ex)
  14266. {
  14267. if (oracleConn.ConnState == ConnectionState.Open)
  14268. {
  14269. oracleConn.Disconnect();
  14270. }
  14271. throw ex;
  14272. }
  14273. }
  14274. /// <summary>
  14275. /// 成检产品预算分析表-设置
  14276. /// </summary>
  14277. /// <param name="cre"></param>
  14278. /// <param name="sUserInfo"></param>
  14279. /// <returns></returns>
  14280. public static ServiceResultEntity GetRPT04011201Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14281. {
  14282. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14283. try
  14284. {
  14285. ServiceResultEntity sre = new ServiceResultEntity();
  14286. string sqlString = "SELECT s.settingkey, s.procedureid, p.procedurecode, p.procedurename\n" +
  14287. " FROM tp_qco_prosetting s\n" +
  14288. " LEFT JOIN tp_pc_procedure p\n" +
  14289. " ON s.procedureid = p.procedureid\n" +
  14290. " WHERE s.accountid = :accountid";
  14291. OracleParameter[] oracleParameter = new OracleParameter[]
  14292. {
  14293. new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14294. };
  14295. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  14296. sqlString = "SELECT k.kilnid, k.kilncode, k.kilnname, k.turnoverinterval\n" +
  14297. " FROM tp_mst_kiln k\n" +
  14298. " WHERE k.accountid = :accountid\n" +
  14299. " AND k.valueflag = '1'";
  14300. DataTable dt = oracleConn.GetSqlResultToDt(sqlString, oracleParameter);
  14301. result.Tables.Add(dt);
  14302. sre.Data = result;
  14303. return sre;
  14304. }
  14305. catch (Exception ex)
  14306. {
  14307. if (oracleConn.ConnState == ConnectionState.Open)
  14308. {
  14309. oracleConn.Close();
  14310. }
  14311. throw ex;
  14312. }
  14313. }
  14314. /// <summary>
  14315. /// 成检产品预算分析表-设置
  14316. /// </summary>
  14317. /// <param name="cre"></param>
  14318. /// <param name="sUserInfo"></param>
  14319. /// <returns></returns>
  14320. public static ServiceResultEntity SetRPT04011201Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14321. {
  14322. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  14323. try
  14324. {
  14325. ServiceResultEntity sre = new ServiceResultEntity();
  14326. OracleParameter[] oracleParameter = null;
  14327. string sql = "update tp_qco_prosetting s set s.procedureid=:procedureid, s.procedurecode=:procedurecode\n" +
  14328. "where s.accountid=:accountid and s.settingkey=:settingkey";
  14329. foreach (DataRow item in cre.Data.Tables[0].Rows)
  14330. {
  14331. oracleParameter = new OracleParameter[]
  14332. {
  14333. new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14334. new OracleParameter("procedureid",OracleDbType.Int32, item["procedureid"], ParameterDirection.Input),
  14335. new OracleParameter("procedurecode",OracleDbType.NVarchar2, item["procedurecode"], ParameterDirection.Input),
  14336. new OracleParameter("settingkey",OracleDbType.NVarchar2, item["settingkey"], ParameterDirection.Input),
  14337. };
  14338. oracleConn.ExecuteNonQuery(sql, oracleParameter);
  14339. }
  14340. sql = "update tp_mst_kiln k set k.turnoverinterval=:turnoverinterval\n" +
  14341. "where k.accountid=:accountid and k.kilnid=:kilnid";
  14342. foreach (DataRow item in cre.Data.Tables[1].Rows)
  14343. {
  14344. oracleParameter = new OracleParameter[]
  14345. {
  14346. new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14347. new OracleParameter("turnoverinterval",OracleDbType.Int32, item["turnoverinterval"], ParameterDirection.Input),
  14348. new OracleParameter("kilnid",OracleDbType.Int32, item["kilnid"], ParameterDirection.Input),
  14349. };
  14350. oracleConn.ExecuteNonQuery(sql, oracleParameter);
  14351. }
  14352. oracleConn.Commit();
  14353. return sre;
  14354. }
  14355. catch (Exception ex)
  14356. {
  14357. if (oracleConn.ConnState == ConnectionState.Open)
  14358. {
  14359. oracleConn.Disconnect();
  14360. }
  14361. throw ex;
  14362. }
  14363. }
  14364. /// <summary>
  14365. /// 各工序质量表-恒洁三水
  14366. /// </summary>
  14367. /// <param name="cre"></param>
  14368. /// <param name="sUserInfo"></param>
  14369. /// <returns></returns>
  14370. public static ServiceResultEntity GetRPT040113Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14371. {
  14372. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14373. try
  14374. {
  14375. int p1ID = 11; // 成检交接工序
  14376. int p2ID = 12; // 成检登记工序
  14377. string gtcode2 = cre.Properties["gtcode2"] + "";
  14378. if (gtcode2 != "001001" && gtcode2 != "001002")
  14379. {
  14380. gtcode2 = "[ALL]";
  14381. }
  14382. // DEFECTDEDUCTIONNUM 缺陷扣除数 1,2,5
  14383. // goodsleveltypeid 次品 7
  14384. string sqlString = "select t.*\n" +
  14385. " ,gt.goodstypename\n" +
  14386. " ,nvl(outk.outkcount, 0) outkcount\n" +
  14387. " ,nvl(outk.outkcount, 0) - t.defectcount cc\n" +
  14388. " ,decode(nvl(outk.outkcount, 0)\n" +
  14389. " ,0\n" +
  14390. " ,to_number(null)\n" +
  14391. " ,round((nvl(outk.outkcount, 0) - t.defectcount) /\n" +
  14392. " nvl(outk.outkcount, 0)\n" +
  14393. " ,4)) ccp\n" +
  14394. " from (select 10 pcode\n" +
  14395. " ,'成型' pname\n" +
  14396. " ,gt2.goodstypecode gtcode2\n" +
  14397. " ,count(*) defectcount\n" +
  14398. " from tp_pm_defect dd\n" +
  14399. " inner join tp_pm_productiondata pd\n" +
  14400. " on dd.productiondataid = pd.productiondataid\n" +
  14401. " inner join tp_mst_goods g\n" +
  14402. " on dd.goodsid = g.goodsid\n" +
  14403. " inner join tp_mst_goodstype gt\n" +
  14404. " on gt.goodstypeid = g.goodstypeid\n" +
  14405. " inner join tp_mst_goodstype gt2\n" +
  14406. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14407. " where dd.valueflag = '1'\n" +
  14408. " and dd.accountid = :accountid\n" +
  14409. " and pd.goodsleveltypeid = 7\n" + // 次品
  14410. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14411. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14412. " and dd.procedureid = :p2ID\n" +
  14413. " and dd.checktime >= :timebegin\n" +
  14414. " and dd.checktime < :timeend\n" +
  14415. ////" -- 交坯、干补\n" +
  14416. //" and dd.defectprocedureid in (1, 17, 18)\n" +
  14417. " 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" +
  14418. " 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" +
  14419. " )\n" +
  14420. " group by gt2.goodstypecode\n" +
  14421. " union all\n" +
  14422. " select 20 pcode\n" +
  14423. " ,'改洗' pname\n" +
  14424. " ,gt2.goodstypecode gtcode2\n" +
  14425. " ,count(*) defectcount\n" +
  14426. " from tp_pm_defect dd\n" +
  14427. " inner join tp_pm_productiondata pd\n" +
  14428. " on dd.productiondataid = pd.productiondataid\n" +
  14429. " inner join tp_mst_goods g\n" +
  14430. " on dd.goodsid = g.goodsid\n" +
  14431. " inner join tp_mst_goodstype gt\n" +
  14432. " on gt.goodstypeid = g.goodstypeid\n" +
  14433. " inner join tp_mst_goodstype gt2\n" +
  14434. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14435. " where dd.valueflag = '1'\n" +
  14436. " and dd.accountid = :accountid\n" +
  14437. " and pd.goodsleveltypeid = 7\n" + // 次品
  14438. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14439. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14440. " and dd.procedureid = :p2ID\n" +
  14441. " and dd.checktime >= :timebegin\n" +
  14442. " and dd.checktime < :timeend\n" +
  14443. ////" -- 改洗、吹风\n" +
  14444. //" and dd.defectprocedureid in (2, 62)\n" +
  14445. ////" -- 除不平\n" +
  14446. //" and dd.defectid not in (91, 240)\n" +
  14447. " and ((gt2.goodstypecode='001001' and dd.defectid in (91,94,144,113,145,114,183))\n" +
  14448. " or (gt2.goodstypecode='001002' and dd.defectid in (91,93,94,144,113,145,114))\n" +
  14449. " )\n" +
  14450. " group by gt2.goodstypecode\n" +
  14451. " union all\n" +
  14452. " select 30 pcode\n" +
  14453. " ,'二检' pname\n" +
  14454. " ,gt2.goodstypecode gtcode2\n" +
  14455. " ,count(*) defectcount\n" +
  14456. " from tp_pm_defect dd\n" +
  14457. " inner join tp_pm_productiondata pd\n" +
  14458. " on dd.productiondataid = pd.productiondataid\n" +
  14459. " inner join tp_mst_goods g\n" +
  14460. " on dd.goodsid = g.goodsid\n" +
  14461. " inner join tp_mst_goodstype gt\n" +
  14462. " on gt.goodstypeid = g.goodstypeid\n" +
  14463. " inner join tp_mst_goodstype gt2\n" +
  14464. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14465. " where dd.valueflag = '1'\n" +
  14466. " and dd.accountid = :accountid\n" +
  14467. " and pd.goodsleveltypeid = 7\n" + // 次品
  14468. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14469. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14470. " and dd.procedureid = :p2ID\n" +
  14471. " and dd.checktime >= :timebegin\n" +
  14472. " and dd.checktime < :timeend\n" +
  14473. ////" -- 二检\n" +
  14474. //" and dd.defectprocedureid in (61)\n" +
  14475. " and ((gt2.goodstypecode='001001' and dd.defectid in (89,91,92,93,94,106,115,163,159,133,166,164))\n" +
  14476. " or (gt2.goodstypecode='001002' and dd.defectid in (89,91,92,93,94,106,115,163,133,192,166,164))\n" +
  14477. " )\n" +
  14478. " group by gt2.goodstypecode\n" +
  14479. " union all\n" +
  14480. " select 40 pcode\n" +
  14481. " ,'施釉' pname\n" +
  14482. " ,gt2.goodstypecode gtcode2\n" +
  14483. " ,count(*) defectcount\n" +
  14484. " from tp_pm_defect dd\n" +
  14485. " inner join tp_pm_productiondata pd\n" +
  14486. " on dd.productiondataid = pd.productiondataid\n" +
  14487. " inner join tp_mst_goods g\n" +
  14488. " on dd.goodsid = g.goodsid\n" +
  14489. " inner join tp_mst_goodstype gt\n" +
  14490. " on gt.goodstypeid = g.goodstypeid\n" +
  14491. " inner join tp_mst_goodstype gt2\n" +
  14492. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14493. " where dd.valueflag = '1'\n" +
  14494. " and dd.accountid = :accountid\n" +
  14495. " and pd.goodsleveltypeid = 7\n" + // 次品
  14496. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14497. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14498. " and dd.procedureid = :p2ID\n" +
  14499. " and dd.checktime >= :timebegin\n" +
  14500. " and dd.checktime < :timeend\n" +
  14501. ////" -- 施釉\n" +
  14502. //" and dd.defectprocedureid in (3, 4)\n" +
  14503. ////" -- 除铁、铜脏\n" +
  14504. //" and dd.defectid not in (827, 829, 398, 399, 830, 400)\n" +
  14505. " 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" +
  14506. " 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" +
  14507. " )\n" +
  14508. " group by gt2.goodstypecode\n" +
  14509. " union all\n" +
  14510. " select 50 pcode\n" +
  14511. " ,'刮登' pname\n" +
  14512. " ,gt2.goodstypecode gtcode2\n" +
  14513. " ,count(*) defectcount\n" +
  14514. " from tp_pm_defect dd\n" +
  14515. " inner join tp_pm_productiondata pd\n" +
  14516. " on dd.productiondataid = pd.productiondataid\n" +
  14517. " inner join tp_mst_goods g\n" +
  14518. " on dd.goodsid = g.goodsid\n" +
  14519. " inner join tp_mst_goodstype gt\n" +
  14520. " on gt.goodstypeid = g.goodstypeid\n" +
  14521. " inner join tp_mst_goodstype gt2\n" +
  14522. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14523. " where dd.valueflag = '1'\n" +
  14524. " and dd.accountid = :accountid\n" +
  14525. " and pd.goodsleveltypeid = 7\n" + // 次品
  14526. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14527. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14528. " and dd.procedureid = :p2ID\n" +
  14529. " and dd.checktime >= :timebegin\n" +
  14530. " and dd.checktime < :timeend\n" +
  14531. ////" -- 登窑、入窑、卸窑\n" +
  14532. //" and dd.defectprocedureid in (5, 9, 10)\n" +
  14533. " 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" +
  14534. " 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" +
  14535. " )\n" +
  14536. " group by gt2.goodstypecode\n" +
  14537. " union all\n" +
  14538. " select 60 pcode\n" +
  14539. " ,'烧成' pname\n" +
  14540. " ,gt2.goodstypecode gtcode2\n" +
  14541. " ,count(*) defectcount\n" +
  14542. " from tp_pm_defect dd\n" +
  14543. " inner join tp_pm_productiondata pd\n" +
  14544. " on dd.productiondataid = pd.productiondataid\n" +
  14545. " inner join tp_mst_goods g\n" +
  14546. " on dd.goodsid = g.goodsid\n" +
  14547. " inner join tp_mst_goodstype gt\n" +
  14548. " on gt.goodstypeid = g.goodstypeid\n" +
  14549. " inner join tp_mst_goodstype gt2\n" +
  14550. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14551. " where dd.valueflag = '1'\n" +
  14552. " and dd.accountid = :accountid\n" +
  14553. " and pd.goodsleveltypeid = 7\n" + // 次品
  14554. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14555. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14556. " and dd.procedureid = :p2ID\n" +
  14557. " and dd.checktime >= :timebegin\n" +
  14558. " and dd.checktime < :timeend\n" +
  14559. ////" -- 惊风、毛针孔、烧裂、窑脏、釉泡\n" +
  14560. //" and dd.defectid in (385\n" +
  14561. //" ,203\n" +
  14562. //" ,836\n" +
  14563. //" ,234\n" +
  14564. //" ,384\n" +
  14565. //" ,202\n" +
  14566. //" ,835\n" +
  14567. //" ,390\n" +
  14568. //" ,818\n" +
  14569. //" ,389\n" +
  14570. //" ,204\n" +
  14571. //" ,814\n" +
  14572. //" ,837\n" +
  14573. //" ,387)\n" +
  14574. " and dd.defectid in (234,385,386,387,388,389,390)\n" +
  14575. //" 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" +
  14576. //" 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" +
  14577. //" )\n" +
  14578. " group by gt2.goodstypecode\n" +
  14579. " union all\n" +
  14580. " select 70 pcode\n" +
  14581. " ,'杂锈点' pname\n" +
  14582. " ,gt2.goodstypecode gtcode2\n" +
  14583. " ,count(*) defectcount\n" +
  14584. " from tp_pm_defect dd\n" +
  14585. " inner join tp_pm_productiondata pd\n" +
  14586. " on dd.productiondataid = pd.productiondataid\n" +
  14587. " inner join tp_mst_goods g\n" +
  14588. " on dd.goodsid = g.goodsid\n" +
  14589. " inner join tp_mst_goodstype gt\n" +
  14590. " on gt.goodstypeid = g.goodstypeid\n" +
  14591. " inner join tp_mst_goodstype gt2\n" +
  14592. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14593. " where dd.valueflag = '1'\n" +
  14594. " and dd.accountid = :accountid\n" +
  14595. " and pd.goodsleveltypeid = 7\n" + // 次品
  14596. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14597. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14598. " and dd.procedureid = :p2ID\n" +
  14599. " and dd.checktime >= :timebegin\n" +
  14600. " and dd.checktime < :timeend\n" +
  14601. ////" -- 铁脏、铜脏、窑脏、釉脏\n" +
  14602. //" and dd.defectid in\n" +
  14603. //" (730, 818, 827, 829, 830, 389, 398, 399, 400, 170)\n" +
  14604. " and dd.defectid in (170,389,398,399)\n" +
  14605. //" 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" +
  14606. //" 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" +
  14607. //" )\n" +
  14608. " group by gt2.goodstypecode\n" +
  14609. " union all\n" +
  14610. " select 80 pcode\n" +
  14611. " ,'其他' pname\n" +
  14612. " ,gt2.goodstypecode gtcode2\n" +
  14613. " ,count(*) defectcount\n" +
  14614. " from tp_pm_defect dd\n" +
  14615. " inner join tp_pm_productiondata pd\n" +
  14616. " on dd.productiondataid = pd.productiondataid\n" +
  14617. " inner join tp_mst_goods g\n" +
  14618. " on dd.goodsid = g.goodsid\n" +
  14619. " inner join tp_mst_goodstype gt\n" +
  14620. " on gt.goodstypeid = g.goodstypeid\n" +
  14621. " inner join tp_mst_goodstype gt2\n" +
  14622. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14623. " where dd.valueflag = '1'\n" +
  14624. " and dd.accountid = :accountid\n" +
  14625. " and pd.goodsleveltypeid = 7\n" + // 次品
  14626. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14627. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14628. " and dd.procedureid = :p2ID\n" +
  14629. " and dd.checktime >= :timebegin\n" +
  14630. " and dd.checktime < :timeend\n" +
  14631. ////" -- 成检撞伤、炸坯、炸裂\n" +
  14632. //" and dd.defectid in (393, 180, 394, 395)\n" +
  14633. " and ((gt2.goodstypecode='001001' and dd.defectid in (402,393,395,396,397))\n" +
  14634. " or (gt2.goodstypecode='001002' and dd.defectid in (402,394,393,395,396,397))\n" +
  14635. " )\n" +
  14636. " group by gt2.goodstypecode) t\n" +
  14637. " left join (select gt2.goodstypecode gtcode2\n" +
  14638. " ,count(*) outkcount\n" +
  14639. " from tp_pm_productiondata pd\n" +
  14640. " inner join tp_mst_goods g\n" +
  14641. " on pd.goodsid = g.goodsid\n" +
  14642. " inner join tp_mst_goodstype gt\n" +
  14643. " on gt.goodstypeid = g.goodstypeid\n" +
  14644. " inner join tp_mst_goodstype gt2\n" +
  14645. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14646. " where pd.valueflag = '1'\n" +
  14647. " and pd.accountid = :accountid\n" +
  14648. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14649. " and pd.procedureid = :p1ID\n" +
  14650. " and pd.createtime >= :timebegin\n" +
  14651. " and pd.createtime < :timeend\n" +
  14652. " group by gt2.goodstypecode) outk\n" +
  14653. " on t.gtcode2 = outk.gtcode2\n" +
  14654. " inner join tp_mst_goodstype gt\n" +
  14655. " on gt.goodstypecode = t.gtcode2\n" +
  14656. " and gt.accountid = :accountid\n" +
  14657. " order by t.pcode, t.gtcode2";
  14658. OracleParameter[] oracleParameter = new OracleParameter[]
  14659. {
  14660. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14661. new OracleParameter(":p1ID",OracleDbType.Int32, p1ID, ParameterDirection.Input),
  14662. new OracleParameter(":p2ID",OracleDbType.Int32, p2ID, ParameterDirection.Input),
  14663. new OracleParameter(":timebegin",OracleDbType.Date, cre.Properties["timebegin"], ParameterDirection.Input),
  14664. new OracleParameter(":timeend",OracleDbType.Date, cre.Properties["timeend"], ParameterDirection.Input),
  14665. new OracleParameter(":gtcode2",OracleDbType.Varchar2, gtcode2, ParameterDirection.Input),
  14666. };
  14667. ServiceResultEntity sre = new ServiceResultEntity();
  14668. sre.Data = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  14669. if (sre.Data != null && sre.Data.Tables.Count > 0 && sre.Data.Tables[0].Rows.Count > 0)
  14670. {
  14671. sre.Data.Tables[0].TableName = "S";
  14672. cre.Properties["pcode"] = sre.Data.Tables[0].Rows[0]["pcode"];
  14673. cre.Properties["pname"] = sre.Data.Tables[0].Rows[0]["pname"];
  14674. cre.Properties["gtcode2"] = sre.Data.Tables[0].Rows[0]["gtcode2"];
  14675. ServiceResultEntity sre1 = GetRPT040113DData(cre, sUserInfo);
  14676. if (sre1 != null&& sre1.Data != null&& sre1.Data.Tables.Count > 0)
  14677. {
  14678. sre1.Data.Tables[0].TableName = "D";
  14679. sre.Data.Merge(sre1.Data.Tables[0]);
  14680. }
  14681. }
  14682. sqlString =
  14683. "select t.gtcode2\n" +
  14684. " ,nvl(t.gtname2, '合计') gtname2\n" +
  14685. " ,sum(t.outk) outk\n" +
  14686. " ,sum(t.cipin) cipin\n" +
  14687. " ,sum(t.outk) - sum(t.cipin) hege\n" +
  14688. " ,decode(sum(t.outk), 0, to_number(null), round(1 - (sum(t.cipin) / sum(t.outk)),4)) hegep\n" +
  14689. " from (select gt2.goodstypecode gtcode2\n" +
  14690. " ,gt2.goodstypename gtname2\n" +
  14691. " ,nvl(sum(decode(pd.procedureid, :p1ID, 1, 0)), 0) outk\n" +
  14692. " ,nvl(sum(case\n" +
  14693. " when pd.procedureid = :p2ID and\n" +
  14694. " pd.goodsleveltypeid in (6, 7) then\n" +
  14695. " 1\n" +
  14696. " else\n" +
  14697. " 0\n" +
  14698. " end)\n" +
  14699. " ,0) cipin\n" +
  14700. " from tp_pm_productiondata pd\n" +
  14701. " inner join tp_mst_goods g\n" +
  14702. " on pd.goodsid = g.goodsid\n" +
  14703. " inner join tp_mst_goodstype gt\n" +
  14704. " on g.goodstypeid = gt.goodstypeid\n" +
  14705. " inner join tp_mst_goodstype gt2\n" +
  14706. " on length(gt2.goodstypecode) = 6\n" +
  14707. " and gt2.accountid = gt.accountid\n" +
  14708. " and instr(gt.goodstypecode, gt2.goodstypecode) = 1\n" +
  14709. " where pd.valueflag = '1'\n" +
  14710. " and pd.accountid = :accountid\n" +
  14711. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14712. " and (pd.procedureid = :p1ID or pd.procedureid = :p2ID)\n" +
  14713. //" and pd.checktime > date '2018-01-01'\n" +
  14714. " and pd.checktime >= :timebegin\n" +
  14715. " and pd.checktime < :timeend\n" +
  14716. " group by gt2.goodstypecode, gt2.goodstypename) t\n" +
  14717. " group by grouping sets((t.gtcode2, t.gtname2),())";
  14718. oracleParameter = new OracleParameter[]
  14719. {
  14720. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14721. new OracleParameter(":p1ID",OracleDbType.Int32, p1ID, ParameterDirection.Input),
  14722. new OracleParameter(":p2ID",OracleDbType.Int32, p2ID, ParameterDirection.Input),
  14723. new OracleParameter(":timebegin",OracleDbType.Date, cre.Properties["timebegin"], ParameterDirection.Input),
  14724. new OracleParameter(":timeend",OracleDbType.Date, cre.Properties["timeend"], ParameterDirection.Input),
  14725. new OracleParameter(":gtcode2",OracleDbType.Varchar2, gtcode2, ParameterDirection.Input),
  14726. };
  14727. DataTable alldata = oracleConn.GetSqlResultToDt(sqlString, oracleParameter);
  14728. alldata.TableName = "A";
  14729. DataTable data = sre.Data.Tables[0];
  14730. foreach (DataRow item in alldata.Rows)
  14731. {
  14732. data.Rows.Add(99, "总计", item["gtcode2"], item["cipin"], item["gtname2"], item["outk"], item["hege"], item["hegep"]);
  14733. }
  14734. return sre;
  14735. }
  14736. catch (Exception ex)
  14737. {
  14738. if (oracleConn.ConnState == ConnectionState.Open)
  14739. {
  14740. oracleConn.Close();
  14741. }
  14742. throw ex;
  14743. }
  14744. }
  14745. /// <summary>
  14746. /// 各工序质量表-缺陷明细-恒洁三水
  14747. /// </summary>
  14748. /// <param name="cre"></param>
  14749. /// <param name="sUserInfo"></param>
  14750. /// <returns></returns>
  14751. public static ServiceResultEntity GetRPT040113DData(ClientRequestEntity cre, SUserInfo sUserInfo)
  14752. {
  14753. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14754. try
  14755. {
  14756. //int p1ID = 11; // 成检交接工序
  14757. int p2ID = 12; // 成检登记工序
  14758. int pcode = Convert.ToInt32(cre.Properties["pcode"]);
  14759. string sqlString =
  14760. "select :pcode pcode\n" +
  14761. " ,:pname pname\n" +
  14762. " ,gt2.goodstypecode gtcode2\n" +
  14763. " ,gt2.goodstypename gtname2\n" +
  14764. " ,dd.defectcode\n" +
  14765. " ,dd.defectname\n" +
  14766. " ,count(*) defectcount\n" +
  14767. " from tp_pm_defect dd\n" +
  14768. //"--inner join tp_mst_defect md on md.defectid=dd.defectid\n" +
  14769. " inner join tp_mst_goods g\n" +
  14770. " on dd.goodsid = g.goodsid\n" +
  14771. " inner join tp_pm_productiondata pd\n" +
  14772. " on dd.productiondataid = pd.productiondataid\n" +
  14773. " inner join tp_mst_goodstype gt\n" +
  14774. " on gt.goodstypeid = g.goodstypeid\n" +
  14775. " inner join tp_mst_goodstype gt2\n" +
  14776. " on gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  14777. " and gt2.accountid = :accountid\n" +
  14778. " where dd.valueflag = '1'\n" +
  14779. " and dd.accountid = :accountid\n" +
  14780. " and pd.goodsleveltypeid = 7\n" + // 次品
  14781. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14782. " and dd.procedureid = :p2ID\n" +
  14783. " and gt2.goodstypecode = :gtcode2\n" +
  14784. " and dd.checktime >= :timebegin\n" +
  14785. " and dd.checktime < :timeend\n";
  14786. switch (pcode)
  14787. {
  14788. case 10:
  14789. ////" -- 交坯、干补\n" +
  14790. //sqlString += " and dd.defectprocedureid in (1, 17, 18)\n";
  14791. sqlString +=
  14792. " 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" +
  14793. " 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" +
  14794. " )\n";
  14795. break;
  14796. case 20:
  14797. sqlString +=
  14798. ////" -- 改洗、吹风\n" +
  14799. //" and dd.defectprocedureid in (2, 62)\n" +
  14800. ////" -- 除不平\n" +
  14801. //" and dd.defectid not in (91, 240)\n";
  14802. " and ((gt2.goodstypecode='001001' and dd.defectid in (91,94,144,113,145,114,183))\n" +
  14803. " or (gt2.goodstypecode='001002' and dd.defectid in (91,93,94,144,113,145,114))\n" +
  14804. " )\n";
  14805. break;
  14806. case 30:
  14807. sqlString +=
  14808. ////" -- 二检\n" +
  14809. //" and dd.defectprocedureid in (61)\n";
  14810. " and ((gt2.goodstypecode='001001' and dd.defectid in (89,91,92,93,94,106,115,163,159,133,166,164))\n" +
  14811. " or (gt2.goodstypecode='001002' and dd.defectid in (89,91,92,93,94,106,115,163,133,192,166,164))\n" +
  14812. " )\n";
  14813. break;
  14814. case 40:
  14815. sqlString +=
  14816. ////" -- 施釉\n" +
  14817. //" and dd.defectprocedureid in (3, 4)\n" +
  14818. ////" -- 除铁、铜脏\n" +
  14819. //" and dd.defectid not in (827, 829, 398, 399, 830, 400)\n";
  14820. " 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" +
  14821. " 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" +
  14822. " )\n";
  14823. break;
  14824. case 50:
  14825. sqlString +=
  14826. ////" -- 登窑、入窑、卸窑\n" +
  14827. //" and dd.defectprocedureid in (5, 9, 10)\n";
  14828. " 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" +
  14829. " 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" +
  14830. " )\n";
  14831. break;
  14832. case 60:
  14833. sqlString +=
  14834. ////" -- 惊风、毛针孔、烧裂、窑脏、釉泡\n" +
  14835. //" and dd.defectid in (385\n" +
  14836. //" ,203\n" +
  14837. //" ,836\n" +
  14838. //" ,234\n" +
  14839. //" ,384\n" +
  14840. //" ,202\n" +
  14841. //" ,835\n" +
  14842. //" ,390\n" +
  14843. //" ,818\n" +
  14844. //" ,389\n" +
  14845. //" ,204\n" +
  14846. //" ,814\n" +
  14847. //" ,837\n" +
  14848. //" ,387)\n";
  14849. " and dd.defectid in (234,385,386,387,388,389,390)\n";
  14850. break;
  14851. case 70:
  14852. sqlString +=
  14853. ////" -- 铁脏、铜脏、窑脏、釉脏\n" +
  14854. //" and dd.defectid in\n" +
  14855. //" (730, 818, 827, 829, 830, 389, 398, 399, 400, 170)\n";
  14856. " and dd.defectid in (170,389,398,399)\n";
  14857. break;
  14858. case 80:
  14859. sqlString +=
  14860. ////" -- 成检撞伤、炸坯、炸裂\n" +
  14861. //" and dd.defectid in (393, 180, 394, 395)\n";
  14862. " and ((gt2.goodstypecode='001001' and dd.defectid in (402,393,395,396,397))\n" +
  14863. " or (gt2.goodstypecode='001002' and dd.defectid in (402,394,393,395,396,397))\n" +
  14864. " )\n";
  14865. break;
  14866. default:
  14867. break;
  14868. }
  14869. sqlString +=
  14870. " group by gt2.goodstypecode\n" +
  14871. " ,gt2.goodstypename\n" +
  14872. " ,dd.defectcode\n" +
  14873. " ,dd.defectname\n" +
  14874. " order by dd.defectcode";
  14875. OracleParameter[] oracleParameter = new OracleParameter[]
  14876. {
  14877. new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14878. //new OracleParameter("p1ID",OracleDbType.Int32, p1ID, ParameterDirection.Input),
  14879. new OracleParameter("p2ID",OracleDbType.Int32, p2ID, ParameterDirection.Input),
  14880. new OracleParameter("pcode",OracleDbType.Int32, pcode, ParameterDirection.Input),
  14881. new OracleParameter("pname",OracleDbType.NVarchar2, cre.Properties["pname"], ParameterDirection.Input),
  14882. new OracleParameter("gtcode2",OracleDbType.Varchar2, cre.Properties["gtcode2"], ParameterDirection.Input),
  14883. new OracleParameter("timebegin",OracleDbType.Date, cre.Properties["timebegin"], ParameterDirection.Input),
  14884. new OracleParameter("timeend",OracleDbType.Date, cre.Properties["timeend"], ParameterDirection.Input),
  14885. };
  14886. ServiceResultEntity sre = new ServiceResultEntity();
  14887. sre.Data = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  14888. return sre;
  14889. }
  14890. catch (Exception ex)
  14891. {
  14892. if (oracleConn.ConnState == ConnectionState.Open)
  14893. {
  14894. oracleConn.Close();
  14895. }
  14896. throw ex;
  14897. }
  14898. }
  14899. /// <summary>
  14900. /// 综合合格率分析表-半成品报废率分析表
  14901. /// </summary>
  14902. /// <param name="cre"></param>
  14903. /// <param name="sUserInfo"></param>
  14904. /// <returns></returns>
  14905. public static ServiceResultEntity GetRPT040114_1Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14906. {
  14907. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14908. try
  14909. {
  14910. ServiceResultEntity sre = new ServiceResultEntity();
  14911. List<OracleParameter> oracleParameters = new List<OracleParameter>();
  14912. oracleParameters.Add(new OracleParameter(":accountid", sUserInfo.AccountID));
  14913. string sqlString = "select g.goodscode\n" +
  14914. " ,tt.d_num\n" +
  14915. " ,tt.b_num\n" +
  14916. " ,tt.f_num\n" +
  14917. " ,tt.s_num\n" +
  14918. " ,decode(tt.d_num\n" +
  14919. " ,0\n" +
  14920. " ,to_number(null)\n" +
  14921. " ,round((tt.b_num + tt.f_num + tt.s_num) / tt.d_num,4)) sp_r\n" +
  14922. " from (select t.goodsid\n" +
  14923. " ,nvl(sum(decode(t.numtype, 'A', t.id_num, 0)), 0) d_num -- 交坯\n" +
  14924. " ,nvl(sum(decode(t.numtype, '2', t.id_num, 0)), 0) b_num -- 半检不合格数\n" +
  14925. " ,nvl(sum(decode(t.numtype, '3', t.id_num, 0)), 0) f_num -- 复检不合格数\n" +
  14926. " ,nvl(sum(decode(t.numtype, '0', t.id_num, 0)), 0) s_num -- 损坯数\n" +
  14927. " from (select gdd.goodsid\n" +
  14928. " ,'A' numtype\n" +
  14929. " ,count(gdd.groutingdailydetailid) id_num\n" +
  14930. " from tp_pm_groutingdailydetail gdd\n" +
  14931. " where gdd.groutingflag = '1'\n" +
  14932. " and gdd.valueflag = '1'\n" +
  14933. " and gdd.accountid = :accountid\n" +
  14934. " and gdd.deliverflag = '1'\n" +
  14935. " and gdd.delivertime >= :datebegin\n" +
  14936. " and gdd.delivertime < :dateend\n" +
  14937. " group by gdd.goodsid\n" +
  14938. " union all\n" +
  14939. " -- 半检不合格数 复检不合格数 损坯数\n" +
  14940. " select sp.goodsid\n" +
  14941. " ,sp.SCRAPTYPE numtype\n" +
  14942. " ,count(sp.scrapproductid) id_num\n" +
  14943. " from tp_pm_scrapproduct sp\n" +
  14944. " where sp.valueflag = '1'\n" +
  14945. " and sp.accountid = :accountid\n" +
  14946. " and sp.auditstatus = 1\n" +
  14947. " and sp.KILNID is null\n" +
  14948. " and sp.SCRAPTYPE <> '1'\n" +
  14949. " and sp.AUDITDATE >= :datebegin\n" +
  14950. " and sp.AUDITDATE < :dateend\n" +
  14951. " group by sp.goodsid, sp.SCRAPTYPE) t\n" +
  14952. " group by t.goodsid) tt\n" +
  14953. " inner join tp_mst_goods g\n" +
  14954. " on tt.goodsid = g.goodsid\n" +
  14955. " order by g.goodscode";
  14956. oracleParameters.Add(new OracleParameter(":datebegin", cre.Properties["datebegin"]));
  14957. oracleParameters.Add(new OracleParameter(":dateend", cre.Properties["dateend"]));
  14958. //// 产品编码 GOODSCODE
  14959. //if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSCODE"] + ""))
  14960. //{
  14961. // sqlString += " and instr(sr.GOODSCODE,:GOODSCODE) > 0 \n";
  14962. // oracleParameters.Add(new OracleParameter(":GOODSCODE", cre.Properties["GOODSCODE"]));
  14963. //}
  14964. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameters.ToArray());
  14965. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14966. {
  14967. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14968. return sre;
  14969. }
  14970. sre.Data = result;
  14971. return sre;
  14972. }
  14973. catch (Exception ex)
  14974. {
  14975. throw ex;
  14976. }
  14977. finally
  14978. {
  14979. oracleConn?.Close();
  14980. }
  14981. }
  14982. /// <summary>
  14983. /// 综合合格率分析表-综合优等率分析表
  14984. /// </summary>
  14985. /// <param name="cre"></param>
  14986. /// <param name="sUserInfo"></param>
  14987. /// <returns></returns>
  14988. public static ServiceResultEntity GetRPT040114_2Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14989. {
  14990. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14991. try
  14992. {
  14993. ServiceResultEntity sre = new ServiceResultEntity();
  14994. List<OracleParameter> oracleParameters = new List<OracleParameter>();
  14995. oracleParameters.Add(new OracleParameter(":accountid", sUserInfo.AccountID));
  14996. string sqlString = "\n" +
  14997. "select g.goodscode\n" +
  14998. " ,pp.b_out_num\n" +
  14999. " ,(pp.b_out_num - pp.b_bad_num) b_h_num\n" +
  15000. " ,(pp.c_out_num - pp.c_bad_num) c_h_num\n" +
  15001. " ,decode(pp.b_out_num\n" +
  15002. " ,0\n" +
  15003. " ,to_number(null)\n" +
  15004. " ,round((pp.b_out_num - pp.b_bad_num + pp.c_out_num - pp.c_bad_num) /\n" +
  15005. " pp.b_out_num,4)) zh_r\n" +
  15006. " from (select p.goodsid\n" +
  15007. " ,nvl(sum(decode(p.procedureid, 11, 1, 0)), 0) b_out_num -- 本烧出窑数\n" +
  15008. " ,nvl(sum(decode(p.procedureid, 12, 1, 0)), 0) b_bad_num -- 本烧不合格数\n" +
  15009. " ,nvl(sum(decode(p.procedureid, 58, 1, 0)), 0) c_out_num -- 重烧出窑数\n" +
  15010. " ,nvl(sum(decode(p.procedureid, 59, 1, 0)), 0) c_bad_num -- 重烧不合格数\n" +
  15011. " from tp_pm_productiondata p\n" +
  15012. " where p.valueflag = '1'\n" +
  15013. " and p.accountid = :accountid\n" +
  15014. " and (p.procedureid in (11, 58) or\n" +
  15015. " (p.procedureid in (12, 59) and p.goodsleveltypeid in (6, 7)))\n" +
  15016. " and p.createtime >= :datebegin\n" +
  15017. " and p.createtime < :dateend\n" +
  15018. " group by p.goodsid) pp\n" +
  15019. " inner join tp_mst_goods g\n" +
  15020. " on g.goodsid = pp.goodsid\n" +
  15021. " order by g.goodscode";
  15022. oracleParameters.Add(new OracleParameter(":datebegin", cre.Properties["datebegin"]));
  15023. oracleParameters.Add(new OracleParameter(":dateend", cre.Properties["dateend"]));
  15024. //// 产品编码 GOODSCODE
  15025. //if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSCODE"] + ""))
  15026. //{
  15027. // sqlString += " and instr(sr.GOODSCODE,:GOODSCODE) > 0 \n";
  15028. // oracleParameters.Add(new OracleParameter(":GOODSCODE", cre.Properties["GOODSCODE"]));
  15029. //}
  15030. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameters.ToArray());
  15031. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  15032. {
  15033. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  15034. return sre;
  15035. }
  15036. sre.Data = result;
  15037. return sre;
  15038. }
  15039. catch (Exception ex)
  15040. {
  15041. throw ex;
  15042. }
  15043. finally
  15044. {
  15045. oracleConn?.Close();
  15046. }
  15047. }
  15048. #region 产成品交接撤销汇总表
  15049. /// <summary>
  15050. /// 取得F_RPT_030117画面(产成品交接撤销汇总表)
  15051. /// </summary>
  15052. /// <param name="user">登录用户信息</param>
  15053. /// <param name="se">查询条件</param>
  15054. /// <returns>查询结果</returns>
  15055. public static ServiceResultEntity GetF_RPT_030117SearchTotalData(SearchFinishedProductEntity orderEntity, SUserInfo user)
  15056. {
  15057. IDBConnection conn = null;
  15058. try
  15059. {
  15060. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  15061. string sqlString = "SELECT TS.GID,\n" +
  15062. " DECODE(TS.GID, '3', '合计', DECODE(TS.GID, '1', '小计[' || CREATETIME || ']', CREATETIME)) AS CREATETIME,\n" +
  15063. " DECODE(TS.GID, '1', '--', GOODSMODEL) AS GOODSMODEL,\n" +
  15064. " GOODSCOUNT\n" +
  15065. " FROM (SELECT GROUPING_ID(TO_CHAR(F.CREATETIME, 'yyyy-mm-dd'), G.GOODSCODE) AS GID,\n" +
  15066. " DECODE(GROUPING(TO_CHAR(F.CREATETIME, 'yyyy-mm-dd')), 1, '--', TO_CHAR(F.CREATETIME, 'yyyy-mm-dd')) AS CREATETIME,\n" +
  15067. " DECODE(GROUPING(G.GOODSCODE), 1, '--', G.GOODSCODE) AS GOODSMODEL,\n" +
  15068. " COUNT(G.GOODSCODE) AS GOODSCOUNT\n" +
  15069. " FROM TP_PM_FHUNDO F\n" +
  15070. " LEFT JOIN TP_PM_GROUTINGDAILYDETAIL GDD\n" +
  15071. " ON F.GROUTINGDAILYDETAILID = GDD.GROUTINGDAILYDETAILID\n" +
  15072. " LEFT JOIN TP_MST_GOODS G\n" +
  15073. " ON G.GOODSID = GDD.GOODSID\n" +
  15074. " WHERE F.ACCOUNTID = :AccountID\n";
  15075. List<OracleParameter> parameters = new List<OracleParameter>();
  15076. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  15077. // 撤销时间
  15078. if (orderEntity.UndoTimeStart != null)
  15079. {
  15080. sqlString = sqlString + " AND F.CREATETIME BETWEEN :UndoTimeStart AND :UndoTimeEnd \n";
  15081. parameters.Add(new OracleParameter(":UndoTimeStart", OracleDbType.Date, orderEntity.UndoTimeStart, ParameterDirection.Input));
  15082. parameters.Add(new OracleParameter(":UndoTimeEnd", OracleDbType.Date, orderEntity.UndoTimeEnd, ParameterDirection.Input));
  15083. }
  15084. // 产品型号
  15085. if (!string.IsNullOrEmpty(orderEntity.GoodsModel))
  15086. {
  15087. sqlString = sqlString + " AND INSTR(g.GoodsCode,:GoodsCode)>0 \n";
  15088. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, orderEntity.GoodsModel, ParameterDirection.Input));
  15089. }
  15090. sqlString += " GROUP BY GROUPING SETS((TO_CHAR(F.CREATETIME, 'yyyy-mm-dd'), G.GOODSCODE),\n" +
  15091. " (TO_CHAR(F.CREATETIME, 'yyyy-mm-dd')),())\n" +
  15092. " ORDER BY TO_CHAR(F.CREATETIME, 'yyyy-mm-dd'), G.GOODSCODE) TS";
  15093. ServiceResultEntity sre = new ServiceResultEntity();
  15094. DataSet result = conn.GetSqlResultToDs(sqlString, parameters.ToArray());
  15095. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  15096. {
  15097. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  15098. }
  15099. sre.Data = result;
  15100. return sre;
  15101. }
  15102. catch (Exception ex)
  15103. {
  15104. throw ex;
  15105. }
  15106. finally
  15107. {
  15108. if (conn != null &&
  15109. conn.ConnState == ConnectionState.Open)
  15110. {
  15111. conn.Close();
  15112. }
  15113. }
  15114. }
  15115. /// <summary>
  15116. /// 取得F_RPT_030112画面(产成品交接汇总表)的明细信息查询数据
  15117. /// </summary>
  15118. /// <param name="user">登录用户信息</param>
  15119. /// <param name="se">查询条件</param>
  15120. /// <returns>查询结果</returns>
  15121. public static ServiceResultEntity GetF_RPT_030117SearchDetailSData(SearchFinishedProductEntity orderEntity, SUserInfo user)
  15122. {
  15123. IDBConnection conn = null;
  15124. try
  15125. {
  15126. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  15127. string sqlString = "SELECT O.ORDERNO,\n" +
  15128. " F.FHTIME,\n" +
  15129. " F.FHUSERCODE,\n" +
  15130. " GDD.BARCODE,\n" +
  15131. " GOODS.GOODSCODE,\n" +
  15132. " L.LOGONAME,\n" +
  15133. " GDD.USERCODE AS GROUTINGUSERCODE,\n" +
  15134. " GDD.GROUTINGLINECODE,\n" +
  15135. " GDD.GROUTINGMOULDCODE,\n" +
  15136. " GDD.GROUTINGDATE,\n" +
  15137. " TO_CHAR(GDD.DELIVERTIME, 'yyyy-mm-dd') AS DELIVERTIME,\n" +
  15138. //" (GOODS.MATERIALCODE || L.TAGCODE || GDD.ONLYCODE) AS FINISHEDBARCODE,\n" +
  15139. " 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" +
  15140. " TO_CHAR(F.CREATETIME, 'yyyy-mm-dd HH24:mi:ss') AS UNDOTIME,\n" +
  15141. " UNDOUSER.USERCODE AS UNDOUSERCODE\n" +
  15142. " FROM TP_PM_FHUNDO F\n" +
  15143. " LEFT JOIN TP_PM_GROUTINGDAILYDETAIL GDD\n" +
  15144. " ON F.GROUTINGDAILYDETAILID = GDD.GROUTINGDAILYDETAILID\n" +
  15145. " LEFT JOIN TP_PM_ORDER O\n" +
  15146. " ON F.FHORDERID = O.ORDERID\n" +
  15147. " LEFT JOIN TP_MST_LOGO L\n" +
  15148. " ON GDD.LOGOID = L.LOGOID\n" +
  15149. " LEFT JOIN TP_MST_GOODS GOODS\n" +
  15150. " ON GDD.GOODSID = GOODS.GOODSID\n" +
  15151. " LEFT JOIN TP_MST_USER UNDOUSER\n" +
  15152. " ON UNDOUSER.USERID = F.CREATEUSERID\n" +
  15153. " WHERE F.ACCOUNTID = :AccountID";
  15154. List<OracleParameter> parameters = new List<OracleParameter>();
  15155. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  15156. // 撤销时间
  15157. if (orderEntity.UndoTimeStart != null)
  15158. {
  15159. sqlString = sqlString + " AND F.CREATETIME BETWEEN :UndoTimeStart AND :UndoTimeEnd \n";
  15160. parameters.Add(new OracleParameter(":UndoTimeStart", OracleDbType.Date, orderEntity.UndoTimeStart, ParameterDirection.Input));
  15161. parameters.Add(new OracleParameter(":UndoTimeEnd", OracleDbType.Date, orderEntity.UndoTimeEnd, ParameterDirection.Input));
  15162. }
  15163. // 产品型号
  15164. if (!string.IsNullOrEmpty(orderEntity.GoodsModel))
  15165. {
  15166. sqlString = sqlString + " AND INSTR(GOODS.GoodsCode,:GoodsCode) > 0 \n";
  15167. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, orderEntity.GoodsModel, ParameterDirection.Input));
  15168. }
  15169. ServiceResultEntity sre = new ServiceResultEntity();
  15170. DataSet result = conn.GetSqlResultToDs(sqlString, parameters.ToArray());
  15171. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  15172. {
  15173. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  15174. }
  15175. sre.Data = result;
  15176. return sre;
  15177. }
  15178. catch (Exception ex)
  15179. {
  15180. throw ex;
  15181. }
  15182. finally
  15183. {
  15184. if (conn != null &&
  15185. conn.ConnState == ConnectionState.Open)
  15186. {
  15187. conn.Close();
  15188. }
  15189. }
  15190. }
  15191. #endregion
  15192. }
  15193. }