ReportModuleLogic.cs 780 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002
  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. parameters.Add(new OracleParameter(":checktimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3112. }
  3113. if (se.CreateTimeEnd.HasValue)
  3114. {
  3115. selSql.Append(" AND pd.checktime < :checktimeEnd\n");
  3116. parameters.Add(new OracleParameter(":checktimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3117. }
  3118. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3119. {
  3120. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3121. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3122. }
  3123. if (se.ProductionLineID.HasValue)
  3124. {
  3125. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3126. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3127. }
  3128. if (se.KilnID.HasValue)
  3129. {
  3130. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3131. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3132. }
  3133. sqlString =
  3134. " and exists\n" +
  3135. " (select 1\n" +
  3136. " from tp_pm_productiondata outpd\n" +
  3137. " where outpd.barcode = pd.barcode\n" +
  3138. " and outpd.procedureid = :in_rptSprocedureId\n" +
  3139. " and outpd.valueflag = '1'\n" +
  3140. " and outpd.kilncarbatchno = pd.kilncarbatchno)) ppd\n" +
  3141. " inner join tp_pm_defect dd\n" +
  3142. " on dd.productiondataid = ppd.productiondataid\n" +
  3143. //" --and dd.checktime >= in_DateBegin\n" +
  3144. //" --and dd.checktime <= in_DateEnd\n" +
  3145. " ) ppcc\n" +
  3146. " inner join tp_pm_productiondata pdata\n" +
  3147. " on pdata.barcode = ppcc.barcode\n" +
  3148. // 干补不算交坯工序的质量。
  3149. " and ((pdata.modeltype <> 5) or (pdata.modeltype = 5 and pdata.SpecialRepairFlag = '0')) \n" +
  3150. " and exists\n" +
  3151. " (select 1\n" +
  3152. " from tp_mst_rpttprocedure rptt\n" +
  3153. " where rptt.RPTPROCEDUREID = :in_rptProcedureId \n";
  3154. selSql.Append(sqlString);
  3155. if (!string.IsNullOrEmpty(se.RptTProcedureIDS))
  3156. {
  3157. selSql.Append(" AND instr(','||:rptTprocedureIDS||',', ','||rptt.procedureid||',') > 0\n");
  3158. parameters.Add(new OracleParameter(":rptTprocedureIDS", OracleDbType.NVarchar2, se.RptTProcedureIDS, ParameterDirection.Input));
  3159. }
  3160. sqlString =
  3161. " and rptt.procedureid = pdata.procedureid)\n" +
  3162. " and (ppcc.procedureid = 0 or ppcc.procedureid = pdata.procedureid)\n";
  3163. selSql.Append(sqlString);
  3164. if (!string.IsNullOrEmpty(se.UserIDS))
  3165. {
  3166. selSql.Append(" and instr(','||:userIDS||',', ','||pdata.Userid||',') > 0\n");
  3167. parameters.Add(new OracleParameter(":userIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  3168. }
  3169. sqlString =
  3170. " inner join tp_pc_productionline pcpl\n" +
  3171. " on pcpl.productionlineid = pdata.productionlineid\n" +
  3172. " inner join tp_pc_procedure pcp\n" +
  3173. " on pcp.procedureid = pdata.procedureid\n" +
  3174. " inner join tp_mst_kiln mstkiln\n" +
  3175. " on mstkiln.kilnid = ppcc.kilnid\n" +
  3176. " inner join tp_mst_goods mstgoods\n" +
  3177. " on mstgoods.goodsid = pdata.goodsid\n" +
  3178. " inner join tp_mst_goodstype mstgoodstype\n" +
  3179. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  3180. " and mstgoodstype.accountid = mstgoods.accountid\n" +
  3181. " inner join tp_mst_goodstype mstgoodstype2\n" +
  3182. " on mstgoodstype2.goodstypecode =\n" +
  3183. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  3184. " and mstgoodstype.accountid = mstgoodstype2.accountid\n";
  3185. // 产品类别
  3186. selSql.Append(sqlString);
  3187. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  3188. {
  3189. selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS)=1\n");
  3190. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  3191. }
  3192. sqlString =
  3193. " 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" +
  3194. " order by pcpl.productionlinename\n" +
  3195. " ,pcp.displayno\n" +
  3196. " ,pcp.procedurename\n" +
  3197. " ,mstkiln.kilncode\n" +
  3198. " ,mstgoodstype2.goodstypecode\n" +
  3199. " ,pdata.usercode\n" +
  3200. " ,mstgoodstype.goodstypecode\n" +
  3201. " ,mstgoods.goodscode) qdgroup";
  3202. selSql.Append(sqlString);
  3203. return selSql.ToString();
  3204. }
  3205. /// <summary>
  3206. /// 取得RPT040104画面(产成品质量分析表)的查询数据
  3207. /// </summary>
  3208. /// <param name="user">登录用户信息</param>
  3209. /// <param name="se">查询条件</param>
  3210. /// <returns>查询结果</returns>
  3211. public static ServiceResultEntity GetRPT040104SData(SUserInfo user, RPT040104_SE se)
  3212. {
  3213. IDBConnection conn = null;
  3214. try
  3215. {
  3216. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  3217. List<OracleParameter> parameters = new List<OracleParameter>();
  3218. //string sql = ReportModuleLogic.GetRPT040104SSQL(user, se, ref parameters);
  3219. string sql = ReportModuleLogic.GetRPT040104S1SQL(user, se, ref parameters);
  3220. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  3221. ServiceResultEntity sre = new ServiceResultEntity();
  3222. if (data == null || data.Rows.Count == 0)
  3223. {
  3224. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  3225. return sre;
  3226. }
  3227. sre.Data = new DataSet();
  3228. sre.Data.Tables.Add(data);
  3229. return sre;
  3230. }
  3231. catch (Exception ex)
  3232. {
  3233. throw ex;
  3234. }
  3235. finally
  3236. {
  3237. if (conn != null &&
  3238. conn.ConnState == ConnectionState.Open)
  3239. {
  3240. conn.Close();
  3241. }
  3242. }
  3243. }
  3244. /// <summary>
  3245. /// 获取RPT040104画面(产成品质量分析表)的查询sql
  3246. /// </summary>
  3247. /// <returns>sql</returns>
  3248. private static string GetRPT040104SSQL(SUserInfo user, RPT040104_SE se, ref List<OracleParameter> parameters)
  3249. {
  3250. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3251. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  3252. // 2015-06-16 modify by chenxy
  3253. string sqlString = "\n" +
  3254. "select qdgroup.gid,\n" +
  3255. " decode(qdgroup.gid, 7, '总计', 0, qdgroup.productionlinename, '--') productionlinename,\n" +
  3256. " decode(qdgroup.gid, 3, '合计', 0, qdgroup.kilncode, '--') kilncode,\n" +
  3257. " decode(qdgroup.gid, 1, '小计', 0, qdgroup.goodstypename2, '--') goodstypename2,\n" +
  3258. " decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename,\n" +
  3259. " decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode,\n" +
  3260. " qdgroup.OutKilnCount,\n" +
  3261. " qdgroup.GoodCount,\n" +
  3262. " to_char((qdgroup.GoodCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' GoodPercent,\n" +
  3263. " qdgroup.SubstandardCount,\n" +
  3264. " to_char((qdgroup.SubstandardCount / qdgroup.OutKilnCount) * 100,\n" +
  3265. " '990.00') || '%' SubstandardPercent,\n" +
  3266. " qdgroup.GoodCount+qdgroup.BadCount Qualified,\n" +
  3267. " to_char(((qdgroup.GoodCount + qdgroup.BadCount) / qdgroup.OutKilnCount) * 100,\n" +
  3268. " '990.00') || '%' QualifiedPercent,\n" +
  3269. " qdgroup.BadCount,\n" +
  3270. " to_char((qdgroup.BadCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' BadPercent,\n" +
  3271. " qdgroup.ReFireCount,\n" +
  3272. " to_char((qdgroup.ReFireCount / qdgroup.OutKilnCount) * 100,\n" +
  3273. " '990.00') || '%' ReFirePercent\n" +
  3274. " from (select grouping_id(pcpl.productionlinename,\n" +
  3275. " mstkiln.kilncode,\n" +
  3276. " mstgoodstype2.goodstypename,\n" +
  3277. " --mstgoodstype.goodstypename,\n" +
  3278. " mstgoods.goodscode) gid,\n" +
  3279. " pcpl.productionlinename,\n" +
  3280. " --qd.kilnid,\n" +
  3281. " mstkiln.kilncode,\n" +
  3282. " mstgoodstype2.goodstypename goodstypename2,\n" +
  3283. " mstgoodstype.goodstypename,\n" +
  3284. " mstgoods.goodscode,\n" +
  3285. " sum(qd.OutKilnCount) OutKilnCount,\n" +
  3286. " sum(qd.GoodCount) GoodCount,\n" +
  3287. " sum(qd.SubstandardCount) SubstandardCount,\n" +
  3288. " sum(qd.BadCount) BadCount,\n" +
  3289. " sum(qd.ReFireCount) ReFireCount\n" +
  3290. " from (select --pdbc.barcode,\n" +
  3291. " pdbc.productionlineid,\n" +
  3292. " pdbc.goodsid,\n" +
  3293. " pdbc.kilnid,\n" +
  3294. " --pdbc.kilncarid,\n" +
  3295. " --pdbc.kilncarbatchno,\n" +
  3296. " 1 OutKilnCount,\n" +
  3297. " case\n" +
  3298. " when glt.goodsleveltypeid in (5, 6, 7) then\n" +
  3299. " 0\n" +
  3300. " else\n" +
  3301. " 1\n" +
  3302. " end GoodCount,\n" +
  3303. " case\n" +
  3304. " when glt.goodsleveltypeid = 7 then\n" +
  3305. " 1\n" +
  3306. " else\n" +
  3307. " 0\n" +
  3308. " end SubstandardCount,\n" +
  3309. " case\n" +
  3310. " when glt.goodsleveltypeid = 6 then\n" +
  3311. " 1\n" +
  3312. " else\n" +
  3313. " 0\n" +
  3314. " end ReFireCount,\n" +
  3315. " case\n" +
  3316. " when glt.goodsleveltypeid = 5 then\n" +
  3317. " 1\n" +
  3318. " else\n" +
  3319. " 0\n" +
  3320. " end BadCount\n" +
  3321. " from (select distinct pd.barcode,\n" +
  3322. " pd.productionlineid,\n" +
  3323. " pd.goodsid,\n" +
  3324. " pd.kilnid,\n" +
  3325. " --pd.kilncarid,\n" +
  3326. " pd.kilncarbatchno\n" +
  3327. " from tp_pm_productiondata pd\n" +
  3328. " where pd.valueflag = '1'\n" +
  3329. " and pd.procedureid = :in_rptSprocedureId \n" +
  3330. " and pd.AccountID = :AccountID\n";
  3331. StringBuilder selSql = new StringBuilder(sqlString);
  3332. if (se.CreateTimeStart.HasValue)
  3333. {
  3334. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  3335. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3336. }
  3337. if (se.CreateTimeEnd.HasValue)
  3338. {
  3339. selSql.Append(" AND pd.createtime <= :CreateTimeEnd\n");
  3340. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3341. }
  3342. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3343. {
  3344. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3345. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3346. }
  3347. if (se.ProductionLineID.HasValue)
  3348. {
  3349. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3350. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3351. }
  3352. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  3353. {
  3354. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  3355. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  3356. }
  3357. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  3358. {
  3359. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  3360. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  3361. }
  3362. //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))");
  3363. //parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  3364. if (se.KilnID.HasValue)
  3365. {
  3366. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3367. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3368. }
  3369. sqlString =
  3370. " ) pdbc\n" +
  3371. " left join (select kcbc.barcode, kcbc.kilncarbatchno, kcbc.goodsleveltypeid\n" +
  3372. " from (select pd.barcode,\n" +
  3373. " pd.kilncarbatchno,\n" +
  3374. " pd.goodsleveltypeid,\n" +
  3375. " pd.productiondataid,\n" +
  3376. " ROW_NUMBER() OVER(PARTITION BY pd.barcode, pd.kilncarbatchno ORDER BY pd.productiondataid desc) AS dataid\n" +
  3377. " from tp_pm_productiondata pd\n" +
  3378. " where pd.valueflag = '1'\n" +
  3379. " and pd.AccountID = :AccountID\n" +
  3380. " and length(pd.kilncarbatchno) > 0\n" +
  3381. " AND pd.createtime >= :CreateTimeStart\n" +
  3382. " and pd.modeltype = -1) kcbc\n" +
  3383. " where kcbc.dataid = 1) glt\n" +
  3384. " on pdbc.kilncarbatchno = glt.kilncarbatchno\n" +
  3385. " and pdbc.barcode = glt.barcode) qd\n" +
  3386. " inner join tp_pc_productionline pcpl\n" +
  3387. " on pcpl.productionlineid = qd.productionlineid\n" +
  3388. " inner join tp_mst_kiln mstkiln\n" +
  3389. " on mstkiln.kilnid = qd.kilnid\n" +
  3390. " inner join tp_mst_goods mstgoods\n" +
  3391. " on mstgoods.goodsid = qd.goodsid\n" +
  3392. " inner join tp_mst_goodstype mstgoodstype\n" +
  3393. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  3394. " and mstgoodstype.accountid = mstgoods.accountid\n" +
  3395. " inner join tp_mst_goodstype mstgoodstype2\n" +
  3396. " on mstgoodstype2.goodstypecode =\n" +
  3397. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  3398. " and mstgoodstype.accountid = mstgoodstype2.accountid\n" +
  3399. " where 1=1\n";
  3400. selSql.Append(sqlString);
  3401. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  3402. {
  3403. //selSql.Append(" AND instr(','||:GoodsTypeIDS||',', ','||mstgoodstype.GOODSTYPECode||',') =1\n");
  3404. selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS) =1\n");
  3405. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  3406. }
  3407. sqlString =
  3408. " group by grouping sets((pcpl.productionlinename,\n" +
  3409. " mstkiln.kilncode,\n" +
  3410. " mstgoodstype2.goodstypename,\n" +
  3411. " mstgoodstype.goodstypename,\n" +
  3412. " mstgoods.goodscode),\n" +
  3413. " (pcpl.productionlinename,\n" +
  3414. " mstkiln.kilncode,\n" +
  3415. " mstgoodstype2.goodstypename),\n" +
  3416. " (pcpl.productionlinename,\n" +
  3417. " mstkiln.kilncode),\n" +
  3418. " pcpl.productionlinename)\n" +
  3419. " order by pcpl.productionlinename,\n" +
  3420. " mstkiln.kilncode,\n" +
  3421. " mstgoodstype2.goodstypename,\n" +
  3422. " mstgoodstype.goodstypename,\n" +
  3423. " mstgoods.goodscode\n" +
  3424. " ) qdgroup\n";
  3425. selSql.Append(sqlString);
  3426. return selSql.ToString();
  3427. }
  3428. /// <summary>
  3429. /// 获取RPT040104画面(产成品质量分析表-按登记时间)的查询sql
  3430. /// </summary>
  3431. /// <returns>sql</returns>
  3432. private static string GetRPT040104S1SQL(SUserInfo user, RPT040104_SE se, ref List<OracleParameter> parameters)
  3433. {
  3434. parameters.Add(new OracleParameter(":in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3435. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  3436. string sqlString = "select qdgroup.gid\n" +
  3437. " ,decode(qdgroup.gid, 7, '总计', qdgroup.productionlinename) productionlinename\n" +
  3438. " ,decode(qdgroup.gid\n" +
  3439. " ,3\n" +
  3440. " ,'合计[' || qdgroup.kilncode || ']'\n" +
  3441. " ,7\n" +
  3442. " ,'--'\n" +
  3443. " ,qdgroup.kilncode) kilncode\n" +
  3444. " ,decode(qdgroup.gid\n" +
  3445. " ,1\n" +
  3446. " ,'小计[' || qdgroup.goodstypename2 || ']'\n" +
  3447. " ,0\n" +
  3448. " ,qdgroup.goodstypename2\n" +
  3449. " ,'--') goodstypename2\n" +
  3450. " ,decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename\n" +
  3451. " ,decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode\n" +
  3452. " ,qdgroup.OutKilnCount\n" +
  3453. " ,qdgroup.GoodCount\n" +
  3454. " ,decode(qdgroup.OutKilnCount\n" +
  3455. " ,0\n" +
  3456. " ,to_number(null)\n" +
  3457. " ,round(qdgroup.GoodCount / qdgroup.OutKilnCount, 4)) GoodPercent\n" +
  3458. " ,qdgroup.SubstandardCount\n" +
  3459. " ,decode(qdgroup.OutKilnCount\n" +
  3460. " ,0\n" +
  3461. " ,to_number(null)\n" +
  3462. " ,round(qdgroup.SubstandardCount / qdgroup.OutKilnCount, 4)) SubstandardPercent\n" +
  3463. " ,qdgroup.GoodCount + qdgroup.BadCount Qualified\n" +
  3464. " ,decode(qdgroup.OutKilnCount\n" +
  3465. " ,0\n" +
  3466. " ,to_number(null)\n" +
  3467. " ,round((qdgroup.GoodCount + qdgroup.BadCount) /\n" +
  3468. " qdgroup.OutKilnCount\n" +
  3469. " ,4)) QualifiedPercent\n" +
  3470. " ,qdgroup.BadCount\n" +
  3471. " ,decode(qdgroup.OutKilnCount\n" +
  3472. " ,0\n" +
  3473. " ,to_number(null)\n" +
  3474. " ,round(qdgroup.BadCount / qdgroup.OutKilnCount, 4)) BadPercent\n" +
  3475. " ,qdgroup.ReFireCount\n" +
  3476. " ,decode(qdgroup.OutKilnCount\n" +
  3477. " ,0\n" +
  3478. " ,to_number(null)\n" +
  3479. " ,round(qdgroup.ReFireCount / qdgroup.OutKilnCount, 4)) ReFirePercent\n" +
  3480. " from (select grouping_id(pcpl.productionlinename\n" +
  3481. " ,mstkiln.kilncode\n" +
  3482. " ,mstgoodstype2.goodstypecode\n" +
  3483. " ,mstgoods.goodscode) gid\n" +
  3484. " ,pcpl.productionlinename\n" +
  3485. " ,mstkiln.kilncode\n" +
  3486. " ,mstgoodstype2.goodstypename goodstypename2\n" +
  3487. " ,mstgoodstype.goodstypename\n" +
  3488. " ,mstgoods.goodscode\n" +
  3489. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 0)), 0) OutKilnCount\n" +
  3490. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 5, 1, 0)), 0) BadCount\n" +
  3491. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 6, 1, 0)), 0) ReFireCount\n" +
  3492. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 7, 1, 0)), 0) SubstandardCount\n" +
  3493. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 5, -1, 6, -1, 7, -1, 0)), 0) GoodCount\n" +
  3494. " from (select 0 goodsleveltypeid -- 出窑数量\n" +
  3495. " ,pd.barcode\n" +
  3496. " ,pd.productionlineid\n" +
  3497. " ,pd.goodsid\n" +
  3498. " ,pd.kilnid\n" +
  3499. " ,pd.kilncarbatchno\n" +
  3500. " ,1 cc\n" +
  3501. " from tp_pm_productiondata pd\n" +
  3502. " where pd.valueflag = '1'\n" +
  3503. " and pd.procedureid = :in_rptSprocedureId\n" +
  3504. " and pd.accountid = :in_AccountID\n";
  3505. StringBuilder selSql = new StringBuilder(sqlString);
  3506. if (se.CreateTimeStart.HasValue)
  3507. {
  3508. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  3509. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3510. }
  3511. if (se.CreateTimeEnd.HasValue)
  3512. {
  3513. selSql.Append(" AND pd.createtime < :CreateTimeEnd\n");
  3514. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3515. }
  3516. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3517. {
  3518. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3519. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3520. }
  3521. if (se.ProductionLineID.HasValue)
  3522. {
  3523. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3524. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3525. }
  3526. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  3527. {
  3528. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  3529. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  3530. }
  3531. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  3532. {
  3533. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  3534. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  3535. }
  3536. if (se.KilnID.HasValue)
  3537. {
  3538. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3539. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3540. }
  3541. sqlString =
  3542. " union all\n" +
  3543. " select distinct pd.goodsleveltypeid\n" +
  3544. " ,pd.barcode\n" +
  3545. " ,pd.productionlineid\n" +
  3546. " ,pd.goodsid\n" +
  3547. " ,pd.kilnid\n" +
  3548. " ,pd.kilncarbatchno\n" +
  3549. " ,1 cc\n" +
  3550. " from tp_pm_productiondata pd\n" +
  3551. " where pd.valueflag = '1'\n" +
  3552. " and pd.modeltype = -1\n" +
  3553. " and pd.AccountID = :in_AccountID\n" +
  3554. " and length(pd.kilncarbatchno) > 0\n";
  3555. selSql.Append(sqlString);
  3556. if (se.CreateTimeStart.HasValue)
  3557. {
  3558. selSql.Append(" AND pd.checktime >= :checktimeStart\n");
  3559. parameters.Add(new OracleParameter(":checktimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3560. }
  3561. if (se.CreateTimeEnd.HasValue)
  3562. {
  3563. selSql.Append(" AND pd.checktime < :checktimeEnd\n");
  3564. parameters.Add(new OracleParameter(":checktimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3565. }
  3566. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3567. {
  3568. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3569. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3570. }
  3571. if (se.ProductionLineID.HasValue)
  3572. {
  3573. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3574. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3575. }
  3576. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  3577. {
  3578. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  3579. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  3580. }
  3581. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  3582. {
  3583. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  3584. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  3585. }
  3586. if (se.KilnID.HasValue)
  3587. {
  3588. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3589. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3590. }
  3591. sqlString =
  3592. " and exists\n" +
  3593. " (select 1\n" +
  3594. " from tp_pm_productiondata outpd\n" +
  3595. " where outpd.barcode = pd.barcode\n" +
  3596. " and outpd.procedureid = :in_rptSprocedureId\n" +
  3597. " and outpd.valueflag = '1'\n" +
  3598. " and outpd.kilncarbatchno = pd.kilncarbatchno)) ppcc\n" +
  3599. " inner join tp_pc_productionline pcpl\n" +
  3600. " on pcpl.productionlineid = ppcc.productionlineid\n" +
  3601. " inner join tp_mst_kiln mstkiln\n" +
  3602. " on mstkiln.kilnid = ppcc.kilnid\n" +
  3603. " inner join tp_mst_goods mstgoods\n" +
  3604. " on mstgoods.goodsid = ppcc.goodsid\n" +
  3605. " inner join tp_mst_goodstype mstgoodstype\n" +
  3606. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  3607. " and mstgoodstype.accountid = mstgoods.accountid\n" +
  3608. " inner join tp_mst_goodstype mstgoodstype2\n" +
  3609. " on mstgoodstype2.goodstypecode =\n" +
  3610. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  3611. " and mstgoodstype.accountid = mstgoodstype2.accountid\n";
  3612. // 产品类别
  3613. selSql.Append(sqlString);
  3614. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  3615. {
  3616. selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS)=1\n");
  3617. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  3618. }
  3619. sqlString =
  3620. " 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" +
  3621. " order by pcpl.productionlinename\n" +
  3622. " ,mstkiln.kilncode\n" +
  3623. " ,mstgoodstype2.goodstypecode\n" +
  3624. " ,mstgoodstype.goodstypecode\n" +
  3625. " ,mstgoods.goodscode) qdgroup\n";
  3626. selSql.Append(sqlString);
  3627. return selSql.ToString();
  3628. }
  3629. /// <summary>
  3630. /// 取得RPT040105画面(质量报表)的查询数据
  3631. /// </summary>
  3632. /// <param name="user">登录用户信息</param>
  3633. /// <param name="se">查询条件</param>
  3634. /// <returns>查询结果</returns>
  3635. public static ServiceResultEntity GetRPT040105SData(SUserInfo user, RPT040105_SE se)
  3636. {
  3637. IDBConnection conn = null;
  3638. try
  3639. {
  3640. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  3641. List<OracleParameter> parameters = new List<OracleParameter>();
  3642. string sqlString =
  3643. "SELECT substr(gt.goodstypecode, 1, 6) goodstypecode2, COUNT(*) barcodecount\n" +
  3644. " FROM tp_pm_groutingdailydetail gdd\n" +
  3645. " INNER JOIN tp_mst_goods g\n" +
  3646. " ON g.goodsid = gdd.goodsid\n" +
  3647. " INNER JOIN tp_mst_goodstype gt\n" +
  3648. " ON gt.goodstypeid = g.goodstypeid\n" +
  3649. " WHERE gdd.accountid = :accountid\n" +
  3650. " AND gdd.valueflag = '1'\n" +
  3651. " AND gdd.groutingdate >= :datebegin\n" +
  3652. " AND gdd.groutingdate <= :dateend\n" +
  3653. " AND gdd.groutingflag = '1'\n" +
  3654. " AND gdd.barcode IS NOT NULL\n" +
  3655. " GROUP BY GROUPING SETS(substr(gt.goodstypecode, 1, 6),())";
  3656. parameters.Add(new OracleParameter(":accountid", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3657. parameters.Add(new OracleParameter(":datebegin", OracleDbType.Date, se.CreateTimeStart.Value.Date, ParameterDirection.Input));
  3658. parameters.Add(new OracleParameter(":dateend", OracleDbType.Date, se.CreateTimeEnd.Value.Date, ParameterDirection.Input));
  3659. DataTable dataCount = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  3660. parameters.Clear();
  3661. //string sql = ReportModuleLogic.GetRPT040105SSQL(user, se, ref parameters);
  3662. string sql = ReportModuleLogic.GetRPT040105S1SQL(user, se, ref parameters);
  3663. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  3664. ServiceResultEntity sre = new ServiceResultEntity();
  3665. if (data == null || data.Rows.Count == 0)
  3666. {
  3667. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  3668. return sre;
  3669. }
  3670. data.Columns.Add("GCount", typeof(int));
  3671. //data.Columns.Add("OutGCount", typeof(string));
  3672. //data.Columns.Add("GoodGCount", typeof(string));
  3673. data.Columns.Add("OutGCount", typeof(decimal));
  3674. data.Columns.Add("GoodGCount", typeof(decimal));
  3675. foreach (DataRow item in data.Rows)
  3676. {
  3677. int gid = Convert.ToInt32(item["gid"]);
  3678. if (gid < 2)
  3679. {
  3680. continue;
  3681. }
  3682. int outKilnCount = Convert.ToInt32(item["OutKilnCount"]);
  3683. int goodCount = Convert.ToInt32(item["Qualified"]);
  3684. DataRow[] drs = null;
  3685. if (gid == 2)
  3686. {
  3687. drs = dataCount.Select("goodstypecode2 = '" + item["goodstypecode2"].ToString() + "'");
  3688. }
  3689. else if (gid == 3)
  3690. {
  3691. drs = dataCount.Select("goodstypecode2 is null");
  3692. }
  3693. if (drs != null && drs.Length > 0)
  3694. {
  3695. int barcodecount = Convert.ToInt32(drs[0]["barcodecount"]);
  3696. item["GCount"] = barcodecount;
  3697. //item["OutGCount"] = (outKilnCount * 1.0 / barcodecount).ToString("#,##0.00%");
  3698. //item["GoodGCount"] = (goodCount * 1.0 / barcodecount).ToString("#,##0.00%");
  3699. item["OutGCount"] = Math.Round(outKilnCount * 1.0 / barcodecount, 4);
  3700. item["GoodGCount"] = Math.Round(goodCount * 1.0 / barcodecount, 4);
  3701. }
  3702. else
  3703. {
  3704. item["GCount"] = 0;
  3705. //item["OutGCount"] = "#DIV/0!";
  3706. //item["GoodGCount"] = "#DIV/0!";
  3707. item["OutGCount"] = DBNull.Value;
  3708. item["GoodGCount"] = DBNull.Value;
  3709. }
  3710. }
  3711. sre.Data = new DataSet();
  3712. sre.Data.Tables.Add(data);
  3713. return sre;
  3714. }
  3715. catch (Exception ex)
  3716. {
  3717. throw ex;
  3718. }
  3719. finally
  3720. {
  3721. if (conn != null &&
  3722. conn.ConnState == ConnectionState.Open)
  3723. {
  3724. conn.Close();
  3725. }
  3726. }
  3727. }
  3728. /// <summary>
  3729. /// 获取RPT040105画面(质量报表)的查询sql
  3730. /// </summary>
  3731. /// <returns>sql</returns>
  3732. private static string GetRPT040105SSQL(SUserInfo user, RPT040105_SE se, ref List<OracleParameter> parameters)
  3733. {
  3734. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3735. parameters.Add(new OracleParameter(":OutProcedureIDS", OracleDbType.Varchar2, se.OutProcedureIDS, ParameterDirection.Input));
  3736. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  3737. // 2015-06-16 modify by chenxy
  3738. string sqlString = "\n" +
  3739. "select qdgroup.gid,\n" +
  3740. " decode(qdgroup.gid, 3, '总计', 0, qdgroup.productionlinename, '--') productionlinename,\n" +
  3741. " decode(qdgroup.gid, 1, '合计【'||qdgroup.kilncode||'】', 0, qdgroup.kilncode, '--') kilncode,\n" +
  3742. " decode(qdgroup.gid, 2, '合计【'||qdgroup.goodstypename2||'】', 0, qdgroup.goodstypename2, '--') goodstypename2,\n" +
  3743. " qdgroup.goodstypecode2,\n" +
  3744. " qdgroup.OutKilnCount,\n" +
  3745. " qdgroup.GoodCount,\n" +
  3746. " to_char((qdgroup.GoodCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' GoodPercent,\n" +
  3747. " qdgroup.SubstandardCount,\n" +
  3748. " to_char((qdgroup.SubstandardCount / qdgroup.OutKilnCount) * 100,\n" +
  3749. " '990.00') || '%' SubstandardPercent,\n" +
  3750. " qdgroup.GoodCount+qdgroup.BadCount Qualified,\n" +
  3751. " to_char(((qdgroup.GoodCount + qdgroup.BadCount) / qdgroup.OutKilnCount) * 100,\n" +
  3752. " '990.00') || '%' QualifiedPercent,\n" +
  3753. " qdgroup.BadCount,\n" +
  3754. " to_char((qdgroup.BadCount / qdgroup.OutKilnCount) * 100, '990.00') || '%' BadPercent,\n" +
  3755. " qdgroup.ReFireCount,\n" +
  3756. " to_char((qdgroup.ReFireCount / qdgroup.OutKilnCount) * 100,\n" +
  3757. " '990.00') || '%' ReFirePercent\n" +
  3758. " from (select grouping_id(pcpl.productionlinename,\n" +
  3759. " mstkiln.kilncode,\n" +
  3760. " mstgoodstype2.goodstypecode) gid,\n" +
  3761. " pcpl.productionlinename,\n" +
  3762. " mstkiln.kilncode,\n" +
  3763. " mstgoodstype2.goodstypecode goodstypecode2,\n" +
  3764. " mstgoodstype2.goodstypename goodstypename2,\n" +
  3765. " sum(qd.OutKilnCount) OutKilnCount,\n" +
  3766. " sum(qd.GoodCount) GoodCount,\n" +
  3767. " sum(qd.SubstandardCount) SubstandardCount,\n" +
  3768. " sum(qd.BadCount) BadCount,\n" +
  3769. " sum(qd.ReFireCount) ReFireCount\n" +
  3770. " from (select --pdbc.barcode,\n" +
  3771. " pdbc.productionlineid,\n" +
  3772. " pdbc.goodsid,\n" +
  3773. " pdbc.kilnid,\n" +
  3774. " 1 OutKilnCount,\n" +
  3775. " case\n" +
  3776. " when glt.goodsleveltypeid in (5, 6, 7) then\n" +
  3777. " 0\n" +
  3778. " else\n" +
  3779. " 1\n" +
  3780. " end GoodCount,\n" +
  3781. " case\n" +
  3782. " when glt.goodsleveltypeid = 7 then\n" +
  3783. " 1\n" +
  3784. " else\n" +
  3785. " 0\n" +
  3786. " end SubstandardCount,\n" +
  3787. " case\n" +
  3788. " when glt.goodsleveltypeid = 6 then\n" +
  3789. " 1\n" +
  3790. " else\n" +
  3791. " 0\n" +
  3792. " end ReFireCount,\n" +
  3793. " case\n" +
  3794. " when glt.goodsleveltypeid = 5 then\n" +
  3795. " 1\n" +
  3796. " else\n" +
  3797. " 0\n" +
  3798. " end BadCount\n" +
  3799. " from (select distinct pd.barcode,\n" +
  3800. " pd.productionlineid,\n" +
  3801. " pd.goodsid,\n" +
  3802. " pd.kilnid,\n" +
  3803. " pd.kilncarbatchno\n" +
  3804. " from tp_pm_productiondata pd\n" +
  3805. " where pd.valueflag = '1'\n" +
  3806. " and (:in_rptSprocedureId is null or pd.procedureid = :in_rptSprocedureId) \n" +
  3807. " and (:OutProcedureIDS is null or instr(','||:OutProcedureIDS||',', ','||pd.procedureid||',') > 0) \n" +
  3808. " and pd.AccountID = :AccountID\n";
  3809. StringBuilder selSql = new StringBuilder(sqlString);
  3810. if (se.CreateTimeStart.HasValue)
  3811. {
  3812. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  3813. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3814. }
  3815. if (se.CreateTimeEnd.HasValue)
  3816. {
  3817. selSql.Append(" AND pd.createtime <= :CreateTimeEnd\n");
  3818. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3819. }
  3820. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3821. {
  3822. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3823. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3824. }
  3825. if (se.ProductionLineID.HasValue)
  3826. {
  3827. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  3828. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  3829. }
  3830. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  3831. {
  3832. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  3833. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  3834. }
  3835. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  3836. {
  3837. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  3838. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  3839. }
  3840. // 不控制权限
  3841. //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))");
  3842. //parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  3843. if (se.KilnID.HasValue)
  3844. {
  3845. selSql.Append(" AND pd.KilnID = :KilnID\n");
  3846. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  3847. }
  3848. sqlString =
  3849. " ) pdbc\n" +
  3850. " left join (select kcbc.barcode, kcbc.kilncarbatchno, kcbc.goodsleveltypeid\n" +
  3851. " from (select pd.barcode,\n" +
  3852. " pd.kilncarbatchno,\n" +
  3853. " pd.goodsleveltypeid,\n" +
  3854. " pd.productiondataid,\n" +
  3855. " ROW_NUMBER() OVER(PARTITION BY pd.barcode, pd.kilncarbatchno ORDER BY pd.productiondataid desc) AS dataid\n" +
  3856. " from tp_pm_productiondata pd\n" +
  3857. " where pd.valueflag = '1'\n" +
  3858. " and pd.AccountID = :AccountID\n" +
  3859. " and length(pd.kilncarbatchno) > 0\n" +
  3860. " AND pd.createtime >= :CreateTimeStart\n" +
  3861. " and pd.modeltype = -1) kcbc\n" +
  3862. " where kcbc.dataid = 1) glt\n" +
  3863. " on pdbc.kilncarbatchno = glt.kilncarbatchno\n" +
  3864. " and pdbc.barcode = glt.barcode) qd\n" +
  3865. " inner join tp_pc_productionline pcpl\n" +
  3866. " on pcpl.productionlineid = qd.productionlineid\n" +
  3867. " inner join tp_mst_kiln mstkiln\n" +
  3868. " on mstkiln.kilnid = qd.kilnid\n" +
  3869. " inner join tp_mst_goods mstgoods\n" +
  3870. " on mstgoods.goodsid = qd.goodsid\n" +
  3871. " inner join tp_mst_goodstype mstgoodstype\n" +
  3872. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  3873. " inner join tp_mst_goodstype mstgoodstype2\n" +
  3874. " on mstgoodstype2.goodstypecode =\n" +
  3875. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  3876. " and mstgoodstype.accountid = mstgoodstype2.accountid\n" +
  3877. " where 1=1\n";
  3878. selSql.Append(sqlString);
  3879. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  3880. {
  3881. selSql.Append(" AND instr(','||:GoodsTypeIDS||',', ','||mstgoods.GOODSTYPEId||',') > 0\n");
  3882. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  3883. }
  3884. sqlString =
  3885. " group by grouping sets((pcpl.productionlinename,\n" +
  3886. " mstkiln.kilncode,\n" +
  3887. " mstgoodstype2.goodstypecode,\n" +
  3888. " mstgoodstype2.goodstypename),\n" +
  3889. " (pcpl.productionlinename,\n" +
  3890. " mstgoodstype2.goodstypecode,\n" +
  3891. " mstgoodstype2.goodstypename),\n" +
  3892. " (pcpl.productionlinename,\n" +
  3893. " mstkiln.kilncode),\n" +
  3894. " pcpl.productionlinename)\n" +
  3895. " order by pcpl.productionlinename,\n" +
  3896. " mstkiln.kilncode,\n" +
  3897. " mstgoodstype2.goodstypename\n" +
  3898. " ) qdgroup\n";
  3899. selSql.Append(sqlString);
  3900. return selSql.ToString();
  3901. }
  3902. /// <summary>
  3903. /// 获取RPT040105画面(质量报表-按登记时间)的查询sql
  3904. /// </summary>
  3905. /// <returns>sql</returns>
  3906. private static string GetRPT040105S1SQL(SUserInfo user, RPT040105_SE se, ref List<OracleParameter> parameters)
  3907. {
  3908. parameters.Add(new OracleParameter(":in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  3909. parameters.Add(new OracleParameter(":in_OutProcedureIDS", OracleDbType.Varchar2, se.OutProcedureIDS, ParameterDirection.Input));
  3910. parameters.Add(new OracleParameter(":in_rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  3911. string sqlString = "select qdgroup.gid\n" +
  3912. " ,decode(qdgroup.gid, 3, '总计', qdgroup.productionlinename) productionlinename\n" +
  3913. " ,decode(qdgroup.gid\n" +
  3914. " ,1\n" +
  3915. " ,'合计[' || qdgroup.kilncode || ']'\n" +
  3916. " ,0\n" +
  3917. " ,qdgroup.kilncode\n" +
  3918. " ,'--') kilncode\n" +
  3919. " ,decode(qdgroup.gid\n" +
  3920. " ,2\n" +
  3921. " ,'合计[' || qdgroup.goodstypename2 || ']'\n" +
  3922. " ,0\n" +
  3923. " ,qdgroup.goodstypename2\n" +
  3924. " ,'--') goodstypename2\n" +
  3925. " ,qdgroup.goodstypecode2\n" +
  3926. //" ,decode(qdgroup.gid, 0, qdgroup.goodstypename, '--') goodstypename\n" +
  3927. //" ,decode(qdgroup.gid, 0, qdgroup.goodscode, '--') goodscode\n" +
  3928. " ,qdgroup.OutKilnCount\n" +
  3929. " ,qdgroup.GoodCount\n" +
  3930. " ,decode(qdgroup.OutKilnCount\n" +
  3931. " ,0\n" +
  3932. " ,to_number(null)\n" +
  3933. " ,round(qdgroup.GoodCount / qdgroup.OutKilnCount, 4)) GoodPercent\n" +
  3934. " ,qdgroup.SubstandardCount\n" +
  3935. " ,decode(qdgroup.OutKilnCount\n" +
  3936. " ,0\n" +
  3937. " ,to_number(null)\n" +
  3938. " ,round(qdgroup.SubstandardCount / qdgroup.OutKilnCount, 4)) SubstandardPercent\n" +
  3939. " ,qdgroup.GoodCount + qdgroup.BadCount Qualified\n" +
  3940. " ,decode(qdgroup.OutKilnCount\n" +
  3941. " ,0\n" +
  3942. " ,to_number(null)\n" +
  3943. " ,round((qdgroup.GoodCount + qdgroup.BadCount) /\n" +
  3944. " qdgroup.OutKilnCount\n" +
  3945. " ,4)) QualifiedPercent\n" +
  3946. " ,qdgroup.BadCount\n" +
  3947. " ,decode(qdgroup.OutKilnCount\n" +
  3948. " ,0\n" +
  3949. " ,to_number(null)\n" +
  3950. " ,round(qdgroup.BadCount / qdgroup.OutKilnCount, 4)) BadPercent\n" +
  3951. " ,qdgroup.ReFireCount\n" +
  3952. " ,decode(qdgroup.OutKilnCount\n" +
  3953. " ,0\n" +
  3954. " ,to_number(null)\n" +
  3955. " ,round(qdgroup.ReFireCount / qdgroup.OutKilnCount, 4)) ReFirePercent\n" +
  3956. " from (select grouping_id(pcpl.productionlinename\n" +
  3957. " ,mstkiln.kilncode\n" +
  3958. " ,mstgoodstype2.goodstypecode) gid\n" +
  3959. " ,pcpl.productionlinename\n" +
  3960. " ,mstkiln.kilncode\n" +
  3961. " ,mstgoodstype2.goodstypename goodstypename2\n" +
  3962. " ,mstgoodstype2.goodstypecode goodstypecode2\n" +
  3963. //" ,mstgoodstype.goodstypename\n" +
  3964. //" ,mstgoods.goodscode\n" +
  3965. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 0)), 0) OutKilnCount\n" +
  3966. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 5, 1, 0)), 0) BadCount\n" +
  3967. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 6, 1, 0)), 0) ReFireCount\n" +
  3968. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 7, 1, 0)), 0) SubstandardCount\n" +
  3969. " ,nvl(sum(decode(ppcc.goodsleveltypeid, 0, 1, 5, -1, 6, -1, 7, -1, 0)), 0) GoodCount\n" +
  3970. " from (select 0 goodsleveltypeid -- 出窑数量\n" +
  3971. " ,pd.barcode\n" +
  3972. " ,pd.productionlineid\n" +
  3973. " ,pd.goodsid\n" +
  3974. " ,pd.kilnid\n" +
  3975. " ,pd.kilncarbatchno\n" +
  3976. " ,1 cc\n" +
  3977. " from tp_pm_productiondata pd\n" +
  3978. " where pd.valueflag = '1'\n" +
  3979. " and (:in_rptSprocedureId is null or pd.procedureid = :in_rptSprocedureId)\n" +
  3980. " and (:in_OutProcedureIDS is null or instr(','||:in_OutProcedureIDS||',', ','||pd.procedureid||',') > 0)\n" +
  3981. " and pd.accountid = :in_AccountID\n";
  3982. StringBuilder selSql = new StringBuilder(sqlString);
  3983. if (se.CreateTimeStart.HasValue)
  3984. {
  3985. selSql.Append(" AND pd.createtime >= :CreateTimeStart\n");
  3986. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  3987. }
  3988. if (se.CreateTimeEnd.HasValue)
  3989. {
  3990. selSql.Append(" AND pd.createtime < :CreateTimeEnd\n");
  3991. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  3992. }
  3993. if (!string.IsNullOrEmpty(se.GoodsIDS))
  3994. {
  3995. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  3996. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  3997. }
  3998. if (se.ProductionLineID.HasValue)
  3999. {
  4000. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  4001. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  4002. }
  4003. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  4004. {
  4005. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  4006. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  4007. }
  4008. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  4009. {
  4010. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  4011. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  4012. }
  4013. if (se.KilnID.HasValue)
  4014. {
  4015. selSql.Append(" AND pd.KilnID = :KilnID\n");
  4016. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  4017. }
  4018. sqlString =
  4019. " union all\n" +
  4020. " select distinct pd.goodsleveltypeid\n" +
  4021. " ,pd.barcode\n" +
  4022. " ,pd.productionlineid\n" +
  4023. " ,pd.goodsid\n" +
  4024. " ,pd.kilnid\n" +
  4025. " ,pd.kilncarbatchno\n" +
  4026. " ,1 cc\n" +
  4027. " from tp_pm_productiondata pd\n" +
  4028. " where pd.valueflag = '1'\n" +
  4029. " and pd.modeltype = -1\n" +
  4030. " and pd.AccountID = :in_AccountID\n" +
  4031. " and length(pd.kilncarbatchno) > 0\n";
  4032. selSql.Append(sqlString);
  4033. if (se.CreateTimeStart.HasValue)
  4034. {
  4035. selSql.Append(" AND pd.checktime >= :checktimeStart\n");
  4036. parameters.Add(new OracleParameter(":checktimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  4037. }
  4038. if (se.CreateTimeEnd.HasValue)
  4039. {
  4040. selSql.Append(" AND pd.checktime < :checktimeEnd\n");
  4041. parameters.Add(new OracleParameter(":checktimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  4042. }
  4043. if (!string.IsNullOrEmpty(se.GoodsIDS))
  4044. {
  4045. selSql.Append(" AND instr(','||:GoodsIDS||',', ','||pd.GoodsId||',') > 0\n");
  4046. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  4047. }
  4048. if (se.ProductionLineID.HasValue)
  4049. {
  4050. selSql.Append(" AND pd.ProductionLineId = :ProductionLineID\n");
  4051. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  4052. }
  4053. if (!string.IsNullOrEmpty(se.GroutingUserIDS))
  4054. {
  4055. selSql.Append(" AND instr(','||:GroutingUserIDS||',', ','||pd.groutinguserid||',') > 0\n");
  4056. parameters.Add(new OracleParameter(":GroutingUserIDS", OracleDbType.NVarchar2, se.GroutingUserIDS, ParameterDirection.Input));
  4057. }
  4058. if (!string.IsNullOrEmpty(se.GroutingLineIDS))
  4059. {
  4060. selSql.Append(" AND instr(','||:GroutingLineIDS||',', ','||pd.groutinglineid||',') > 0\n");
  4061. parameters.Add(new OracleParameter(":GroutingLineIDS", OracleDbType.NVarchar2, se.GroutingLineIDS, ParameterDirection.Input));
  4062. }
  4063. if (se.KilnID.HasValue)
  4064. {
  4065. selSql.Append(" AND pd.KilnID = :KilnID\n");
  4066. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  4067. }
  4068. sqlString =
  4069. " and exists\n" +
  4070. " (select 1\n" +
  4071. " from tp_pm_productiondata outpd\n" +
  4072. " where outpd.barcode = pd.barcode\n" +
  4073. //" and outpd.procedureid = :in_rptSprocedureId\n" +
  4074. " and (:in_rptSprocedureId is null or outpd.procedureid = :in_rptSprocedureId)\n" +
  4075. " and (:in_OutProcedureIDS is null or instr(','||:in_OutProcedureIDS||',', ','||outpd.procedureid||',') > 0)\n" +
  4076. " and outpd.valueflag = '1'\n" +
  4077. " and outpd.kilncarbatchno = pd.kilncarbatchno)) ppcc\n" +
  4078. " inner join tp_pc_productionline pcpl\n" +
  4079. " on pcpl.productionlineid = ppcc.productionlineid\n" +
  4080. " inner join tp_mst_kiln mstkiln\n" +
  4081. " on mstkiln.kilnid = ppcc.kilnid\n" +
  4082. " inner join tp_mst_goods mstgoods\n" +
  4083. " on mstgoods.goodsid = ppcc.goodsid\n" +
  4084. " inner join tp_mst_goodstype mstgoodstype\n" +
  4085. " on mstgoodstype.goodstypeid = mstgoods.goodstypeid\n" +
  4086. " and mstgoodstype.accountid = mstgoods.accountid\n" +
  4087. " inner join tp_mst_goodstype mstgoodstype2\n" +
  4088. " on mstgoodstype2.goodstypecode =\n" +
  4089. " substr(mstgoodstype.goodstypecode, 0, 6)\n" +
  4090. " and mstgoodstype.accountid = mstgoodstype2.accountid\n";
  4091. // 产品类别
  4092. selSql.Append(sqlString);
  4093. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  4094. {
  4095. selSql.Append(" AND instr(mstgoodstype.GOODSTYPECode,:GoodsTypeIDS)=1\n");
  4096. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  4097. }
  4098. sqlString =
  4099. " 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" +
  4100. " order by pcpl.productionlinename\n" +
  4101. " ,mstkiln.kilncode\n" +
  4102. " ,mstgoodstype2.goodstypecode\n" +
  4103. " ) qdgroup\n";
  4104. selSql.Append(sqlString);
  4105. return selSql.ToString();
  4106. }
  4107. /// <summary>
  4108. /// 取得RPT040106画面(缺陷报表)的查询数据
  4109. /// </summary>
  4110. /// <param name="user">登录用户信息</param>
  4111. /// <param name="se">查询条件</param>
  4112. /// <returns>查询结果</returns>
  4113. public static ServiceResultEntity GetRPT040106SData(SUserInfo user, RPT040106_SE se)
  4114. {
  4115. IDBConnection conn = null;
  4116. try
  4117. {
  4118. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  4119. string sqlString = null;
  4120. OracleParameter[] parameters = null;
  4121. if (se.OutKilnNumByGoodsType)
  4122. {
  4123. sqlString = "SELECT Defect.productionlinename\n" +
  4124. " ,Defect.procedurename\n" +
  4125. " ,Defect.Defectcode\n" +
  4126. " ,Defect.Defectname\n" +
  4127. " ,Defect.goodstypename2\n" +
  4128. " ,Defect.DefectCount\n" +
  4129. " ,OUT.outNum OutKilnCount\n" +
  4130. " ,decode(OUT.outNum,\n" +
  4131. " 0,\n" +
  4132. " to_number(NULL),\n" +
  4133. " ROUND(Defect.DefectCount / OUT.outNum, 4)) DefectPercent\n" +
  4134. " FROM (SELECT tp_pc_productionline.productionlinename\n" +
  4135. " ,tp_pc_procedure.procedurename\n" +
  4136. " ,TP_MST_DefectType.Defecttypename\n" +
  4137. " ,TP_MST_Defect.Defectcode\n" +
  4138. " ,TP_MST_Defect.Defectname\n" +
  4139. " ,goodstype2.goodstypename goodstypename2\n" +
  4140. " ,goodstype2.goodstypecode goodstypecode2\n" +
  4141. " --,COUNT(DISTINCT TP_PM_Defect.Barcode) DefectCount\n" +
  4142. " ,COUNT(TP_PM_Defect.Barcode) DefectCount\n" +
  4143. " FROM TP_PM_Defect\n" +
  4144. " LEFT JOIN tp_pc_procedure\n" +
  4145. " ON TP_PM_Defect.ProcedureID = tp_pc_procedure.ProcedureID\n" +
  4146. " LEFT JOIN tp_pc_productionline\n" +
  4147. " ON TP_PM_Defect.Productionlineid =\n" +
  4148. " tp_pc_productionline.Productionlineid\n" +
  4149. " LEFT JOIN TP_MST_Goods\n" +
  4150. " ON TP_PM_Defect.Goodsid = TP_MST_Goods.Goodsid\n" +
  4151. " LEFT JOIN TP_MST_GoodsType\n" +
  4152. " ON TP_MST_Goods.GoodsTypeID = TP_MST_GoodsType.GoodsTypeID\n" +
  4153. " LEFT JOIN TP_MST_GoodsType goodstype2\n" +
  4154. " ON goodstype2.goodstypecode =\n" +
  4155. " substr(TP_MST_GoodsType.goodstypecode, 0, 6)\n" +
  4156. " AND TP_MST_GoodsType.accountid = goodstype2.accountid\n" +
  4157. " LEFT JOIN TP_MST_Defect\n" +
  4158. " ON TP_PM_Defect.DefectID = TP_MST_Defect.DefectID\n" +
  4159. " LEFT JOIN TP_MST_DefectType\n" +
  4160. " ON TP_MST_Defect.DefectTypeID = TP_MST_DefectType.DefectTypeID\n" +
  4161. " --LEFT JOIN TP_PM_ProductionData\n" +
  4162. " -- ON TP_PM_ProductionData.ProductionDataID =\n" +
  4163. " -- TP_PM_Defect.ProductionDataID\n" +
  4164. " WHERE TP_PM_Defect.valueflag = '1'\n" +
  4165. " --AND tp_pc_procedure.ModelType = -1\n" +
  4166. " AND TP_PM_Defect.AccountID = :AccountID\n" +
  4167. " AND (:createtimebegin is null or TP_PM_Defect.createtime >= :createtimebegin)\n" +
  4168. " AND (:createtimeend is null or TP_PM_Defect.createtime <= :createtimeend)\n" +
  4169. " AND (:procedureids is null or instr(','||:procedureids||',', ','||TP_PM_Defect.ProcedureID||',') > 0)\n" +
  4170. " AND (:DefectCode is null or instr(TP_MST_Defect.Defectcode, :DefectCode) > 0)\n" +
  4171. " AND (:DefectName is null or instr(TP_MST_Defect.Defectname, :DefectName) > 0)\n" +
  4172. " GROUP BY tp_pc_productionline.productionlinename\n" +
  4173. " ,tp_pc_procedure.procedurename\n" +
  4174. " ,TP_MST_DefectType.Defecttypename\n" +
  4175. " ,TP_MST_Defect.Defectcode\n" +
  4176. " ,TP_MST_Defect.Defectname\n" +
  4177. " ,goodstype2.goodstypecode\n" +
  4178. " ,goodstype2.goodstypename) Defect\n" +
  4179. " LEFT JOIN ( SELECT gt2.goodstypecode goodstypecode2, COUNT(pd.barcode) outNum\n" +
  4180. " FROM tp_pm_productiondata pd\n" +
  4181. " LEFT JOIN tp_mst_goods g on g.goodsid = pd.goodsid\n" +
  4182. " LEFT JOIN tp_mst_goodstype gt on g.goodstypeid = gt.goodstypeid\n" +
  4183. " LEFT JOIN tp_mst_goodstype gt2 on gt2.AccountID = :AccountID and gt2.goodstypecode = substr(gt.goodstypecode, 0, 6)\n" +
  4184. " WHERE pd.valueflag = '1'\n" +
  4185. " AND pd.procedureid = :procedureid\n" +
  4186. " AND pd.AccountID = :AccountID\n" +
  4187. " AND (:createtimebegin is null or pd.createtime >= :createtimebegin)\n" +
  4188. " AND (:createtimeend is null or pd.createtime <= :createtimeend)\n" +
  4189. " GROUP BY gt2.goodstypecode) OUT \n" +
  4190. " ON OUT.goodstypecode2 = Defect.goodstypecode2 \n";
  4191. parameters = new OracleParameter[]
  4192. {
  4193. new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  4194. new OracleParameter(":createtimebegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  4195. new OracleParameter(":createtimeend", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  4196. new OracleParameter(":procedureids", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input),
  4197. new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input),
  4198. new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input),
  4199. //new OracleParameter(":OutKilnCount", OracleDbType.Int32, outKilnCount, ParameterDirection.Input),
  4200. new OracleParameter(":procedureid", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input),
  4201. };
  4202. }
  4203. else
  4204. {
  4205. sqlString = "SELECT COUNT(pd.barcode) \n" +
  4206. " FROM tp_pm_productiondata pd\n" +
  4207. " WHERE pd.valueflag = '1'\n" +
  4208. " AND pd.procedureid = :procedureid\n" +
  4209. " AND pd.AccountID = :AccountID\n" +
  4210. " AND (:createtimebegin is null or pd.createtime >= :createtimebegin)\n" +
  4211. " AND (:createtimeend is null or pd.createtime <= :createtimeend)";
  4212. parameters = new OracleParameter[]
  4213. {
  4214. new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  4215. new OracleParameter(":procedureid", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input),
  4216. new OracleParameter(":createtimebegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  4217. new OracleParameter(":createtimeend", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  4218. };
  4219. int outKilnCount = Convert.ToInt32(conn.GetSqlResultToStr(sqlString, parameters));
  4220. sqlString = "SELECT Defect.productionlinename\n" +
  4221. " ,Defect.procedurename\n" +
  4222. " ,Defect.Defectcode\n" +
  4223. " ,Defect.Defectname\n" +
  4224. " ,Defect.goodstypename2\n" +
  4225. " ,Defect.DefectCount\n" +
  4226. " ,:OutKilnCount OutKilnCount\n" +
  4227. " ,decode(:OutKilnCount,\n" +
  4228. " 0,\n" +
  4229. " to_number(NULL),\n" +
  4230. " ROUND(Defect.DefectCount / :OutKilnCount, 4)) DefectPercent\n" +
  4231. " FROM (SELECT tp_pc_productionline.productionlinename\n" +
  4232. " ,tp_pc_procedure.procedurename\n" +
  4233. " ,TP_MST_DefectType.Defecttypename\n" +
  4234. " ,TP_MST_Defect.Defectcode\n" +
  4235. " ,TP_MST_Defect.Defectname\n" +
  4236. " ,goodstype2.goodstypename goodstypename2\n" +
  4237. " ,:OutKilnCount OutKilnCount\n" +
  4238. " --,COUNT(DISTINCT TP_PM_Defect.Barcode) DefectCount\n" +
  4239. " ,COUNT(TP_PM_Defect.Barcode) DefectCount\n" +
  4240. " FROM TP_PM_Defect\n" +
  4241. " LEFT JOIN tp_pc_procedure\n" +
  4242. " ON TP_PM_Defect.ProcedureID = tp_pc_procedure.ProcedureID\n" +
  4243. " LEFT JOIN tp_pc_productionline\n" +
  4244. " ON TP_PM_Defect.Productionlineid =\n" +
  4245. " tp_pc_productionline.Productionlineid\n" +
  4246. " LEFT JOIN TP_MST_Goods\n" +
  4247. " ON TP_PM_Defect.Goodsid = TP_MST_Goods.Goodsid\n" +
  4248. " LEFT JOIN TP_MST_GoodsType\n" +
  4249. " ON TP_MST_Goods.GoodsTypeID = TP_MST_GoodsType.GoodsTypeID\n" +
  4250. " LEFT JOIN TP_MST_GoodsType goodstype2\n" +
  4251. " ON goodstype2.goodstypecode =\n" +
  4252. " substr(TP_MST_GoodsType.goodstypecode, 0, 6)\n" +
  4253. " AND TP_MST_GoodsType.accountid = goodstype2.accountid\n" +
  4254. " LEFT JOIN TP_MST_Defect\n" +
  4255. " ON TP_PM_Defect.DefectID = TP_MST_Defect.DefectID\n" +
  4256. " LEFT JOIN TP_MST_DefectType\n" +
  4257. " ON TP_MST_Defect.DefectTypeID = TP_MST_DefectType.DefectTypeID\n" +
  4258. " --LEFT JOIN TP_PM_ProductionData\n" +
  4259. " -- ON TP_PM_ProductionData.ProductionDataID =\n" +
  4260. " -- TP_PM_Defect.ProductionDataID\n" +
  4261. " WHERE TP_PM_Defect.valueflag = '1'\n" +
  4262. " --AND tp_pc_procedure.ModelType = -1\n" +
  4263. " AND TP_PM_Defect.AccountID = :AccountID\n" +
  4264. " AND (:createtimebegin is null or TP_PM_Defect.createtime >= :createtimebegin)\n" +
  4265. " AND (:createtimeend is null or TP_PM_Defect.createtime <= :createtimeend)\n" +
  4266. " AND (:procedureids is null or instr(','||:procedureids||',', ','||TP_PM_Defect.ProcedureID||',') > 0)\n" +
  4267. " AND (:DefectCode is null or instr(TP_MST_Defect.Defectcode, :DefectCode) > 0)\n" +
  4268. " AND (:DefectName is null or instr(TP_MST_Defect.Defectname, :DefectName) > 0)\n" +
  4269. " GROUP BY tp_pc_productionline.productionlinename\n" +
  4270. " ,tp_pc_procedure.procedurename\n" +
  4271. " ,TP_MST_DefectType.Defecttypename\n" +
  4272. " ,TP_MST_Defect.Defectcode\n" +
  4273. " ,TP_MST_Defect.Defectname\n" +
  4274. " ,goodstype2.goodstypename) Defect";
  4275. parameters = new OracleParameter[]
  4276. {
  4277. new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  4278. new OracleParameter(":createtimebegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  4279. new OracleParameter(":createtimeend", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  4280. new OracleParameter(":procedureids", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input),
  4281. new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input),
  4282. new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input),
  4283. new OracleParameter(":OutKilnCount", OracleDbType.Int32, outKilnCount, ParameterDirection.Input),
  4284. };
  4285. }
  4286. DataTable data = conn.GetSqlResultToDt(sqlString, parameters);
  4287. ServiceResultEntity sre = new ServiceResultEntity();
  4288. if (data == null || data.Rows.Count == 0)
  4289. {
  4290. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4291. return sre;
  4292. }
  4293. sre.Data = new DataSet();
  4294. sre.Data.Tables.Add(data);
  4295. return sre;
  4296. }
  4297. catch (Exception ex)
  4298. {
  4299. throw ex;
  4300. }
  4301. finally
  4302. {
  4303. if (conn != null &&
  4304. conn.ConnState == ConnectionState.Open)
  4305. {
  4306. conn.Close();
  4307. }
  4308. }
  4309. }
  4310. /// <summary>
  4311. /// 取得RPT040107画面(注浆产品工序分析表)的查询数据
  4312. /// </summary>
  4313. /// <param name="user">登录用户信息</param>
  4314. /// <param name="se">查询条件</param>
  4315. /// <returns>查询结果</returns>
  4316. public static ServiceResultEntity GetRPT040107SData(SUserInfo user, RPT040107_SE se)
  4317. {
  4318. IDBConnection conn = null;
  4319. try
  4320. {
  4321. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  4322. List<OracleParameter> parameters = new List<OracleParameter>();
  4323. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  4324. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  4325. string sqlString =
  4326. "SELECT LISTAGG('''' || p.procedureid || ''' AS ' || 'P' || p.procedureid,\n" +
  4327. " ',') WITHIN GROUP(ORDER BY p.displayno, p.pid) pivotcol\n" +
  4328. " ,LISTAGG('sum(pd.P' || p.procedureid || '_BC) AS \"' ||\n" +
  4329. " p.procedurename || '\"',\n" +
  4330. " ',') WITHIN GROUP(ORDER BY p.displayno, p.pid) groupsum\n" +
  4331. " FROM (SELECT to_char(p.procedureid) procedureid\n" +
  4332. " ,to_char(p.procedurename) procedurename\n" +
  4333. " ,p.displayno\n" +
  4334. " ,p.productionlineid plid\n" +
  4335. " ,p.procedureid pid\n" +
  4336. " FROM tp_pc_procedure p\n" +
  4337. " WHERE p.valueflag = '1'\n" +
  4338. " AND p.modeltype <> -1\n" +
  4339. " AND p.accountid = :AccountID\n" +
  4340. " UNION ALL\n" +
  4341. " SELECT to_char(p.procedureid) || 'S'\n" +
  4342. " ,to_char(p.procedurename) || '(不合格)'\n" +
  4343. " ,p.displayno\n" +
  4344. " ,p.productionlineid plid\n" +
  4345. " ,p.procedureid pid\n" +
  4346. " FROM tp_pc_procedure p\n" +
  4347. " WHERE p.valueflag = '1'\n" +
  4348. " AND p.modeltype = -1\n" +
  4349. " AND p.accountid = :AccountID) p" +
  4350. " 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" +
  4351. " 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";
  4352. // 生产线
  4353. if (se.ProductionLineID.HasValue)
  4354. {
  4355. sqlString = sqlString + " AND p.plid = :ProductionLineID ";
  4356. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  4357. }
  4358. // 生产工序
  4359. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  4360. {
  4361. sqlString = sqlString + " AND instr(:procedureids, ','||p.pid||',')>0 ";
  4362. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  4363. }
  4364. DataTable cols = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  4365. ServiceResultEntity sre = new ServiceResultEntity();
  4366. if (cols == null || cols.Rows.Count == 0)
  4367. {
  4368. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4369. return sre;
  4370. }
  4371. string pivotcol = cols.Rows[0]["pivotcol"].ToString();
  4372. string groupsum = cols.Rows[0]["groupsum"].ToString();
  4373. if (string.IsNullOrEmpty(pivotcol) || string.IsNullOrEmpty(groupsum))
  4374. {
  4375. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4376. return sre;
  4377. }
  4378. parameters.Clear();
  4379. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  4380. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  4381. sqlString =
  4382. "WITH pd_data AS\n" +
  4383. " (SELECT DISTINCT pd.goodsid pdgoodsid\n" +
  4384. " ,pd.groutingdailydetailid\n" +
  4385. " ,decode(pd.MODELTYPE,\n" +
  4386. " -1,\n" +
  4387. " to_char(pd.procedureid) || 'S',\n" +
  4388. " to_char(pd.procedureid)) procedureid\n" +
  4389. " FROM tp_pm_productiondata pd\n" +
  4390. " LEFT JOIN tp_mst_goods goods\n" +
  4391. " ON goods.goodsid = pd.goodsid\n" +
  4392. " LEFT JOIN tp_mst_goodstype gt\n" +
  4393. " ON gt.goodstypeid = goods.goodstypeid\n" +
  4394. " WHERE pd.valueflag = '1'\n" +
  4395. " AND (pd.MODELTYPE <> -1 OR pd.goodsleveltypeid IN (6, 7))\n" +
  4396. " AND pd.accountid = :AccountID\n" +
  4397. (se.Specialrepairflag ? " AND ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" : "") +
  4398. " 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" +
  4399. " 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";
  4400. // 生产线
  4401. if (se.ProductionLineID.HasValue)
  4402. {
  4403. sqlString = sqlString + " AND pd.productionlineid = :ProductionLineID ";
  4404. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  4405. }
  4406. // 生产工序
  4407. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  4408. {
  4409. sqlString = sqlString + " AND instr(:procedureids, ','||pd.procedureid||',')>0 ";
  4410. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  4411. }
  4412. // 产品型号
  4413. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  4414. {
  4415. sqlString = sqlString + " AND instr(gt.GOODSTYPECode, :GoodsTypeCode)=1 ";
  4416. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  4417. }
  4418. // 产品编码
  4419. if (!string.IsNullOrEmpty(se.GoodsCode))
  4420. {
  4421. sqlString = sqlString + " AND instr(goods.GOODSCode, :GoodsCode) > 0 ";
  4422. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  4423. }
  4424. // 注浆时间
  4425. if (se.GTimeStart.HasValue)
  4426. {
  4427. sqlString = sqlString + " AND pd.GROUTINGDATE >=:GTimeStart ";
  4428. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  4429. }
  4430. if (se.GTimeEnd.HasValue)
  4431. {
  4432. sqlString = sqlString + " AND pd.GROUTINGDATE <= :GTimeEnd ";
  4433. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  4434. }
  4435. sqlString +=
  4436. " ),\n" +
  4437. "pivot_data AS\n" +
  4438. " (SELECT *\n" +
  4439. " FROM pd_data\n" +
  4440. " PIVOT(COUNT(groutingdailydetailid) bc\n" +
  4441. " FOR procedureid IN(" + pivotcol + ")))\n" +
  4442. "SELECT decode(grouping_id(groutdetail.goodstypename2, groutdetail.goodscode),\n" +
  4443. " 3,\n" +
  4444. " '合计',\n" +
  4445. " 1,\n" +
  4446. " '小计【' || groutdetail.goodstypename2 || '】',\n" +
  4447. " groutdetail.goodstypename2) \"产量类别\"\n" +
  4448. " ,decode(grouping_id(groutdetail.goodstypename2, groutdetail.goodscode),\n" +
  4449. " 0,\n" +
  4450. " groutdetail.goodscode,\n" +
  4451. " '--') \"产品编码\"\n" +
  4452. " ,SUM(groutdetail.groutcount) \"注浆数量\"\n" +
  4453. " ,SUM(groutdetail.barcodecount) \"绑条码数量\"\n" +
  4454. " ,SUM(groutdetail.scrapcount) \"开模损坯\"\n" +
  4455. " ," + groupsum + "\n" +
  4456. " FROM (SELECT gdd.goodsid, gt2.goodstypename goodstypename2, goods.goodscode\n" +
  4457. " ,COUNT(gdd.groutingdailydetailid) AS groutcount\n" +
  4458. " ,SUM(decode(gdd.barcode, NULL, 0, 1)) AS barcodecount\n" +
  4459. " ,SUM(decode(gdd.scrapflag, '1', 1, 0)) AS scrapcount\n" +
  4460. " FROM tp_pm_groutingdailydetail gdd\n" +
  4461. " LEFT JOIN tp_mst_goods goods\n" +
  4462. " ON goods.goodsid = gdd.goodsid\n" +
  4463. " LEFT JOIN tp_mst_goodstype gt\n" +
  4464. " ON gt.goodstypeid = goods.goodstypeid\n" +
  4465. " LEFT JOIN tp_mst_goodstype gt2\n" +
  4466. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  4467. " AND gt2.accountid = gt.accountid\n" +
  4468. " WHERE gdd.valueflag = '1'\n" +
  4469. " AND gdd.accountid = :AccountID\n";
  4470. // 产品型号
  4471. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  4472. {
  4473. sqlString = sqlString + " AND instr(gt.GOODSTYPECode, :GoodsTypeCode)=1 ";
  4474. }
  4475. // 产品编码
  4476. if (!string.IsNullOrEmpty(se.GoodsCode))
  4477. {
  4478. sqlString = sqlString + " AND instr(goods.GOODSCode, :GoodsCode) > 0 ";
  4479. }
  4480. // 注浆时间
  4481. if (se.GTimeStart.HasValue)
  4482. {
  4483. sqlString = sqlString + " AND gdd.GROUTINGDATE >=:GTimeStart ";
  4484. }
  4485. if (se.GTimeEnd.HasValue)
  4486. {
  4487. sqlString = sqlString + " AND gdd.GROUTINGDATE <= :GTimeEnd ";
  4488. }
  4489. sqlString +=
  4490. " AND gdd.groutingflag = '1'\n" +
  4491. " GROUP BY gdd.goodsid, gt2.goodstypename, goods.goodscode) groutdetail\n" +
  4492. " LEFT JOIN pivot_data pd\n" +
  4493. " ON pd.pdgoodsid = groutdetail.goodsid\n" +
  4494. " GROUP BY GROUPING SETS((groutdetail.goodstypename2, groutdetail.goodscode),(groutdetail.goodstypename2),())\n" +
  4495. " ORDER BY groutdetail.goodstypename2, groutdetail.goodscode";
  4496. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  4497. if (data == null || data.Rows.Count == 0)
  4498. {
  4499. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4500. return sre;
  4501. }
  4502. sre.Data = new DataSet();
  4503. sre.Data.Tables.Add(data);
  4504. return sre;
  4505. }
  4506. catch (Exception ex)
  4507. {
  4508. throw ex;
  4509. }
  4510. finally
  4511. {
  4512. if (conn != null &&
  4513. conn.ConnState == ConnectionState.Open)
  4514. {
  4515. conn.Close();
  4516. }
  4517. }
  4518. }
  4519. /// <summary>
  4520. /// 取得RPT040108画面(成型线产量分析表)的查询数据
  4521. /// </summary>
  4522. /// <param name="user">登录用户信息</param>
  4523. /// <param name="se">查询条件</param>
  4524. /// <returns>查询结果</returns>
  4525. public static ServiceResultEntity GetRPT040108SData(SUserInfo user, RPT040108_SE se)
  4526. {
  4527. IDBConnection conn = null;
  4528. try
  4529. {
  4530. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  4531. //string sqlString =
  4532. // "SELECT t.groutinglinecode\n" +
  4533. // " ,t.BuildingNo\n" +
  4534. // " ,t.FloorNo\n" +
  4535. // " ,t.GroutingLineNo\n" +
  4536. // " ,t.usercode\n" +
  4537. // " ,t.goodscode\n" +
  4538. // " ,t.GOODSSPECIFICATION\n" +
  4539. // " ,t.goodstypename\n" +
  4540. // //" ,round(AVG(t.MouldQuantity), 2) MouldQuantity\n" +
  4541. // " ,AVG(t.MouldQuantity) MouldQuantity\n" +
  4542. // " ,SUM(decode(t.gday, '01', t.c, 0)) c01\n" +
  4543. // " ,SUM(decode(t.dday, '01', t.d, 0)) d01\n" +
  4544. // " ,SUM(decode(t.gday, '02', t.c, 0)) c02\n" +
  4545. // " ,SUM(decode(t.dday, '02', t.d, 0)) d02\n" +
  4546. // " ,SUM(decode(t.gday, '03', t.c, 0)) c03\n" +
  4547. // " ,SUM(decode(t.dday, '03', t.d, 0)) d03\n" +
  4548. // " ,SUM(decode(t.gday, '04', t.c, 0)) c04\n" +
  4549. // " ,SUM(decode(t.dday, '04', t.d, 0)) d04\n" +
  4550. // " ,SUM(decode(t.gday, '05', t.c, 0)) c05\n" +
  4551. // " ,SUM(decode(t.dday, '05', t.d, 0)) d05\n" +
  4552. // " ,SUM(decode(t.gday, '06', t.c, 0)) c06\n" +
  4553. // " ,SUM(decode(t.dday, '06', t.d, 0)) d06\n" +
  4554. // " ,SUM(decode(t.gday, '07', t.c, 0)) c07\n" +
  4555. // " ,SUM(decode(t.dday, '07', t.d, 0)) d07\n" +
  4556. // " ,SUM(decode(t.gday, '08', t.c, 0)) c08\n" +
  4557. // " ,SUM(decode(t.dday, '08', t.d, 0)) d08\n" +
  4558. // " ,SUM(decode(t.gday, '09', t.c, 0)) c09\n" +
  4559. // " ,SUM(decode(t.dday, '09', t.d, 0)) d09\n" +
  4560. // " ,SUM(decode(t.gday, '10', t.c, 0)) c10\n" +
  4561. // " ,SUM(decode(t.dday, '10', t.d, 0)) d10\n" +
  4562. // " ,SUM(decode(t.gday, '11', t.c, 0)) c11\n" +
  4563. // " ,SUM(decode(t.dday, '11', t.d, 0)) d11\n" +
  4564. // " ,SUM(decode(t.gday, '12', t.c, 0)) c12\n" +
  4565. // " ,SUM(decode(t.dday, '12', t.d, 0)) d12\n" +
  4566. // " ,SUM(decode(t.gday, '13', t.c, 0)) c13\n" +
  4567. // " ,SUM(decode(t.dday, '13', t.d, 0)) d13\n" +
  4568. // " ,SUM(decode(t.gday, '14', t.c, 0)) c14\n" +
  4569. // " ,SUM(decode(t.dday, '14', t.d, 0)) d14\n" +
  4570. // " ,SUM(decode(t.gday, '15', t.c, 0)) c15\n" +
  4571. // " ,SUM(decode(t.dday, '15', t.d, 0)) d15\n" +
  4572. // " ,SUM(decode(t.gday, '16', t.c, 0)) c16\n" +
  4573. // " ,SUM(decode(t.dday, '16', t.d, 0)) d16\n" +
  4574. // " ,SUM(decode(t.gday, '17', t.c, 0)) c17\n" +
  4575. // " ,SUM(decode(t.dday, '17', t.d, 0)) d17\n" +
  4576. // " ,SUM(decode(t.gday, '18', t.c, 0)) c18\n" +
  4577. // " ,SUM(decode(t.dday, '18', t.d, 0)) d18\n" +
  4578. // " ,SUM(decode(t.gday, '19', t.c, 0)) c19\n" +
  4579. // " ,SUM(decode(t.dday, '19', t.d, 0)) d19\n" +
  4580. // " ,SUM(decode(t.gday, '20', t.c, 0)) c20\n" +
  4581. // " ,SUM(decode(t.dday, '20', t.d, 0)) d20\n" +
  4582. // " ,SUM(decode(t.gday, '21', t.c, 0)) c21\n" +
  4583. // " ,SUM(decode(t.dday, '21', t.d, 0)) d21\n" +
  4584. // " ,SUM(decode(t.gday, '22', t.c, 0)) c22\n" +
  4585. // " ,SUM(decode(t.dday, '22', t.d, 0)) d22\n" +
  4586. // " ,SUM(decode(t.gday, '23', t.c, 0)) c23\n" +
  4587. // " ,SUM(decode(t.dday, '23', t.d, 0)) d23\n" +
  4588. // " ,SUM(decode(t.gday, '24', t.c, 0)) c24\n" +
  4589. // " ,SUM(decode(t.dday, '24', t.d, 0)) d24\n" +
  4590. // " ,SUM(decode(t.gday, '25', t.c, 0)) c25\n" +
  4591. // " ,SUM(decode(t.dday, '25', t.d, 0)) d25\n" +
  4592. // " ,SUM(decode(t.gday, '26', t.c, 0)) c26\n" +
  4593. // " ,SUM(decode(t.dday, '26', t.d, 0)) d26\n" +
  4594. // " ,SUM(decode(t.gday, '27', t.c, 0)) c27\n" +
  4595. // " ,SUM(decode(t.dday, '27', t.d, 0)) d27\n" +
  4596. // " ,SUM(decode(t.gday, '28', t.c, 0)) c28\n" +
  4597. // " ,SUM(decode(t.dday, '28', t.d, 0)) d28\n" +
  4598. // " ,SUM(decode(t.gday, '29', t.c, 0)) c29\n" +
  4599. // " ,SUM(decode(t.dday, '29', t.d, 0)) d29\n" +
  4600. // " ,SUM(decode(t.gday, '30', t.c, 0)) c30\n" +
  4601. // " ,SUM(decode(t.dday, '30', t.d, 0)) d30\n" +
  4602. // " ,SUM(decode(t.gday, '31', t.c, 0)) c31\n" +
  4603. // " ,SUM(decode(t.dday, '31', t.d, 0)) d31\n" +
  4604. // " FROM (SELECT gd.groutinglinecode\n" +
  4605. // " ,gl.BuildingNo\n" +
  4606. // " ,gl.FloorNo\n" +
  4607. // " ,gl.GroutingLineNo\n" +
  4608. // " ,gd.usercode\n" +
  4609. // " ,gdd.goodscode\n" +
  4610. // " ,g.GOODSSPECIFICATION\n" +
  4611. // " ,gt.goodstypename\n" +
  4612. // //" ,gd.MouldQuantity\n" +
  4613. // " ,gl.MouldQuantity\n" +
  4614. // " ,to_char(gd.groutingdate, 'dd') AS gday\n" +
  4615. // " ,to_char(gdd.delivertime, 'dd') AS dday\n" +
  4616. // " , CASE\n" +
  4617. // " WHEN gd.groutingdate >= :GDateBegin AND\n" +
  4618. // " gd.groutingdate <= :GDateEnd AND\n" +
  4619. // " gdd.GroutingFlag = '1' AND gdd.ScrapFlag = '0' THEN\n" +
  4620. // " 1\n" +
  4621. // " ELSE\n" +
  4622. // " 0\n" +
  4623. // " END c -- 成坯量\n" +
  4624. // " , CASE\n" +
  4625. // " WHEN gdd.delivertime >= :GDateBegin AND\n" +
  4626. // " gdd.delivertime <= :GDateEnd AND\n" +
  4627. // " gdd.deliverflag = '1' THEN\n" +
  4628. // " 1\n" +
  4629. // " ELSE\n" +
  4630. // " 0\n" +
  4631. // " END d -- 交坯量\n" +
  4632. // " FROM TP_PM_GroutingDaily gd\n" +
  4633. // " INNER JOIN TP_PM_GroutingDailyDetail gdd\n" +
  4634. // " ON gdd.groutingdailyid = gd.groutingdailyid\n" +
  4635. // " INNER JOIN TP_PC_GroutingLine gl \n" +
  4636. // " ON gl.groutinglineid = gd.groutinglineid\n" +
  4637. // " INNER JOIN TP_MST_Goods g\n" +
  4638. // " ON g.goodsid = gdd.goodsid\n" +
  4639. // " INNER JOIN TP_MST_GOODSTYPE gt\n" +
  4640. // " ON gt.goodstypeid = g.goodstypeid\n" +
  4641. // " WHERE gd.accountid = :AccountID\n" +
  4642. // " AND ((gd.groutingdate >= :GDateBegin AND\n" +
  4643. // " gd.groutingdate <= :GDateEnd) OR\n" +
  4644. // " (gdd.delivertime >= :GDateBegin AND\n" +
  4645. // " gdd.delivertime <= :GDateEnd))\n" +
  4646. // " AND (:groutinglinecode is null or instr(gd.groutinglinecode, :groutinglinecode) > 0)\n" +
  4647. // " AND (:groutingusercode is null or instr(gdd.usercode, :groutingusercode) > 0)\n" +
  4648. // " AND (:goodscode is null or instr(gdd.goodscode, :goodscode) > 0)\n" +
  4649. // " AND (:goodstypecode is null or instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  4650. // " ) t\n" +
  4651. // " GROUP BY t.groutinglinecode\n" +
  4652. // " ,t.BuildingNo\n" +
  4653. // " ,t.FloorNo\n" +
  4654. // " ,t.GroutingLineNo\n" +
  4655. // " ,t.usercode\n" +
  4656. // " ,t.goodscode\n" +
  4657. // " ,t.GOODSSPECIFICATION\n" +
  4658. // " ,t.goodstypename\n" +
  4659. // " ORDER BY t.groutinglinecode, t.usercode, t.goodscode";
  4660. string sqlString = "select nvl(t.groutinglinecode, '--') groutinglinecode\n" +
  4661. " ,nvl(t.BuildingNo, '--') BuildingNo\n" +
  4662. " ,nvl(t.FloorNo, '--') FloorNo\n" +
  4663. " ,nvl(t.GroutingLineNo, '--') GroutingLineNo\n" +
  4664. " ,nvl(t.usercode, '--') usercode\n" +
  4665. " ,nvl2(t.groutinglinecode\n" +
  4666. " ,t.goodscode\n" +
  4667. " ,nvl2(t.goodscode, '小计[' || t.goodscode || ']', '合计')) goodscode\n" +
  4668. " ,nvl2(t.goodscode, t.GOODSSPECIFICATION, '--') GOODSSPECIFICATION\n" +
  4669. " ,nvl2(t.goodscode, t.goodstypename, '--') goodstypename\n" +
  4670. " ,nvl2(t.groutinglinecode, avg(t.MouldQuantity), null) MouldQuantity\n" +
  4671. " ,sum(decode(t.gday, '01', t.c, 0)) c01\n" +
  4672. " ,sum(decode(t.dday, '01', t.d, 0)) d01\n" +
  4673. " ,sum(decode(t.gday, '02', t.c, 0)) c02\n" +
  4674. " ,sum(decode(t.dday, '02', t.d, 0)) d02\n" +
  4675. " ,sum(decode(t.gday, '03', t.c, 0)) c03\n" +
  4676. " ,sum(decode(t.dday, '03', t.d, 0)) d03\n" +
  4677. " ,sum(decode(t.gday, '04', t.c, 0)) c04\n" +
  4678. " ,sum(decode(t.dday, '04', t.d, 0)) d04\n" +
  4679. " ,sum(decode(t.gday, '05', t.c, 0)) c05\n" +
  4680. " ,sum(decode(t.dday, '05', t.d, 0)) d05\n" +
  4681. " ,sum(decode(t.gday, '06', t.c, 0)) c06\n" +
  4682. " ,sum(decode(t.dday, '06', t.d, 0)) d06\n" +
  4683. " ,sum(decode(t.gday, '07', t.c, 0)) c07\n" +
  4684. " ,sum(decode(t.dday, '07', t.d, 0)) d07\n" +
  4685. " ,sum(decode(t.gday, '08', t.c, 0)) c08\n" +
  4686. " ,sum(decode(t.dday, '08', t.d, 0)) d08\n" +
  4687. " ,sum(decode(t.gday, '09', t.c, 0)) c09\n" +
  4688. " ,sum(decode(t.dday, '09', t.d, 0)) d09\n" +
  4689. " ,sum(decode(t.gday, '10', t.c, 0)) c10\n" +
  4690. " ,sum(decode(t.dday, '10', t.d, 0)) d10\n" +
  4691. " ,sum(decode(t.gday, '11', t.c, 0)) c11\n" +
  4692. " ,sum(decode(t.dday, '11', t.d, 0)) d11\n" +
  4693. " ,sum(decode(t.gday, '12', t.c, 0)) c12\n" +
  4694. " ,sum(decode(t.dday, '12', t.d, 0)) d12\n" +
  4695. " ,sum(decode(t.gday, '13', t.c, 0)) c13\n" +
  4696. " ,sum(decode(t.dday, '13', t.d, 0)) d13\n" +
  4697. " ,sum(decode(t.gday, '14', t.c, 0)) c14\n" +
  4698. " ,sum(decode(t.dday, '14', t.d, 0)) d14\n" +
  4699. " ,sum(decode(t.gday, '15', t.c, 0)) c15\n" +
  4700. " ,sum(decode(t.dday, '15', t.d, 0)) d15\n" +
  4701. " ,sum(decode(t.gday, '16', t.c, 0)) c16\n" +
  4702. " ,sum(decode(t.dday, '16', t.d, 0)) d16\n" +
  4703. " ,sum(decode(t.gday, '17', t.c, 0)) c17\n" +
  4704. " ,sum(decode(t.dday, '17', t.d, 0)) d17\n" +
  4705. " ,sum(decode(t.gday, '18', t.c, 0)) c18\n" +
  4706. " ,sum(decode(t.dday, '18', t.d, 0)) d18\n" +
  4707. " ,sum(decode(t.gday, '19', t.c, 0)) c19\n" +
  4708. " ,sum(decode(t.dday, '19', t.d, 0)) d19\n" +
  4709. " ,sum(decode(t.gday, '20', t.c, 0)) c20\n" +
  4710. " ,sum(decode(t.dday, '20', t.d, 0)) d20\n" +
  4711. " ,sum(decode(t.gday, '21', t.c, 0)) c21\n" +
  4712. " ,sum(decode(t.dday, '21', t.d, 0)) d21\n" +
  4713. " ,sum(decode(t.gday, '22', t.c, 0)) c22\n" +
  4714. " ,sum(decode(t.dday, '22', t.d, 0)) d22\n" +
  4715. " ,sum(decode(t.gday, '23', t.c, 0)) c23\n" +
  4716. " ,sum(decode(t.dday, '23', t.d, 0)) d23\n" +
  4717. " ,sum(decode(t.gday, '24', t.c, 0)) c24\n" +
  4718. " ,sum(decode(t.dday, '24', t.d, 0)) d24\n" +
  4719. " ,sum(decode(t.gday, '25', t.c, 0)) c25\n" +
  4720. " ,sum(decode(t.dday, '25', t.d, 0)) d25\n" +
  4721. " ,sum(decode(t.gday, '26', t.c, 0)) c26\n" +
  4722. " ,sum(decode(t.dday, '26', t.d, 0)) d26\n" +
  4723. " ,sum(decode(t.gday, '27', t.c, 0)) c27\n" +
  4724. " ,sum(decode(t.dday, '27', t.d, 0)) d27\n" +
  4725. " ,sum(decode(t.gday, '28', t.c, 0)) c28\n" +
  4726. " ,sum(decode(t.dday, '28', t.d, 0)) d28\n" +
  4727. " ,sum(decode(t.gday, '29', t.c, 0)) c29\n" +
  4728. " ,sum(decode(t.dday, '29', t.d, 0)) d29\n" +
  4729. " ,sum(decode(t.gday, '30', t.c, 0)) c30\n" +
  4730. " ,sum(decode(t.dday, '30', t.d, 0)) d30\n" +
  4731. " ,sum(decode(t.gday, '31', t.c, 0)) c31\n" +
  4732. " ,sum(decode(t.dday, '31', t.d, 0)) d31\n" +
  4733. " from (select gd.groutinglinecode\n" +
  4734. " ,gl.BuildingNo\n" +
  4735. " ,gl.FloorNo\n" +
  4736. " ,gl.GroutingLineNo\n" +
  4737. " ,gd.usercode\n" +
  4738. " ,gdd.goodscode\n" +
  4739. " ,g.GOODSSPECIFICATION\n" +
  4740. " ,gt.goodstypename\n" +
  4741. " ,gl.MouldQuantity\n" +
  4742. " ,to_char(gd.groutingdate, 'dd') as gday\n" +
  4743. " ,to_char(gdd.delivertime, 'dd') as dday\n" +
  4744. " ,case\n" +
  4745. " when gd.groutingdate >= :GDateBegin and\n" +
  4746. " gd.groutingdate <= :GDateEnd and\n" +
  4747. " gdd.GroutingFlag = '1' and\n" +
  4748. " gdd.ScrapFlag = '0' then\n" +
  4749. " 1\n" +
  4750. " else\n" +
  4751. " 0\n" +
  4752. " end c -- 成坯量\n" +
  4753. " ,case\n" +
  4754. " when gdd.delivertime >= :GDateBegin and\n" +
  4755. " gdd.delivertime <= :GDateEnd and\n" +
  4756. " gdd.deliverflag = '1' then\n" +
  4757. " 1\n" +
  4758. " else\n" +
  4759. " 0\n" +
  4760. " end d -- 交坯量\n" +
  4761. " from TP_PM_GroutingDaily gd\n" +
  4762. " inner join TP_PM_GroutingDailyDetail gdd\n" +
  4763. " on gdd.groutingdailyid = gd.groutingdailyid\n" +
  4764. " inner join TP_PC_GroutingLine gl\n" +
  4765. " on gl.groutinglineid = gd.groutinglineid\n" +
  4766. " inner join TP_MST_Goods g\n" +
  4767. " on g.goodsid = gdd.goodsid\n" +
  4768. " inner join TP_MST_GOODSTYPE gt\n" +
  4769. " on gt.goodstypeid = g.goodstypeid\n" +
  4770. " where gd.accountid = :AccountID\n" +
  4771. " and ((gd.groutingdate >= :GDateBegin and\n" +
  4772. " gd.groutingdate <= :GDateEnd) or\n" +
  4773. " (gdd.delivertime >= :GDateBegin and\n" +
  4774. " gdd.delivertime <= :GDateEnd))\n" +
  4775. " and (:groutinglinecode is null or\n" +
  4776. " instr(gd.groutinglinecode, :groutinglinecode) > 0)\n" +
  4777. " and (:groutingusercode is null or\n" +
  4778. " instr(gdd.usercode, :groutingusercode) > 0)\n" +
  4779. " and (:goodscode is null or instr(gdd.goodscode, :goodscode) > 0)\n" +
  4780. " and (:goodstypecode is null or\n" +
  4781. " instr(gt.goodstypecode, :goodstypecode) = 1)) t\n" +
  4782. " 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" +
  4783. " order by t.goodscode, t.groutinglinecode, t.usercode";
  4784. List<OracleParameter> parameters = new List<OracleParameter>();
  4785. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  4786. parameters.Add(new OracleParameter(":GDateBegin", OracleDbType.Date, se.GDateBegin, ParameterDirection.Input));
  4787. parameters.Add(new OracleParameter(":GDateEnd", OracleDbType.Date, se.GDateEnd, ParameterDirection.Input));
  4788. parameters.Add(new OracleParameter(":groutinglinecode", OracleDbType.Varchar2, se.GroutingLineCode, ParameterDirection.Input));
  4789. parameters.Add(new OracleParameter(":groutingusercode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  4790. parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  4791. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  4792. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  4793. ServiceResultEntity sre = new ServiceResultEntity();
  4794. if (data == null || data.Rows.Count == 0)
  4795. {
  4796. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4797. return sre;
  4798. }
  4799. sre.Data = new DataSet();
  4800. sre.Data.Tables.Add(data);
  4801. return sre;
  4802. }
  4803. catch (Exception ex)
  4804. {
  4805. throw ex;
  4806. }
  4807. finally
  4808. {
  4809. if (conn != null &&
  4810. conn.ConnState == ConnectionState.Open)
  4811. {
  4812. conn.Close();
  4813. }
  4814. }
  4815. }
  4816. /// <summary>
  4817. /// 取得RPT040109画面(整体质量分析表)的查询数据
  4818. /// </summary>
  4819. /// <param name="user">登录用户信息</param>
  4820. /// <param name="se">查询条件</param>
  4821. /// <returns>查询结果</returns>
  4822. public static ServiceResultEntity GetRPT040109SData(SUserInfo user, RPT040109_SE se)
  4823. {
  4824. IDBTransaction conn = null;
  4825. try
  4826. {
  4827. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  4828. conn.Connect();
  4829. OracleParameter[] parameters = new OracleParameter[]
  4830. {
  4831. new OracleParameter("in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  4832. new OracleParameter("in_DateBegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  4833. new OracleParameter("in_DateEnd", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  4834. new OracleParameter("in_OutKilnProcedureID", OracleDbType.Int32, se.RptSProcedureID , ParameterDirection.Input),
  4835. new OracleParameter("in_KilnID", OracleDbType.Int32, se.KilnID , ParameterDirection.Input),
  4836. new OracleParameter("out_data1", OracleDbType.RefCursor, null , ParameterDirection.Output),
  4837. new OracleParameter("out_data2", OracleDbType.RefCursor, null , ParameterDirection.Output),
  4838. new OracleParameter("out_data3", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4839. new OracleParameter("out_data4", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4840. new OracleParameter("out_data21", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4841. new OracleParameter("out_data31", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4842. new OracleParameter("out_data32", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4843. new OracleParameter("out_table1", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4844. new OracleParameter("out_table2", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4845. new OracleParameter("out_table3", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4846. new OracleParameter("out_table4", OracleDbType.RefCursor, null, ParameterDirection.Output),
  4847. new OracleParameter("in_HasUserGroup", OracleDbType.Int32, (se.HasUserGroup?1:0), ParameterDirection.Input),
  4848. };
  4849. //out_data1 -- 质量整体情况
  4850. //out_data2 -- 各缺陷类型成品率
  4851. //out_data3 -- 各缺陷类型缺陷率
  4852. //out_data4 -- 产品质量排行榜
  4853. //out_data21 -- 各缺陷类型成品率-总成品率
  4854. //out_data31 -- 各缺陷类型缺陷率-总缺陷率
  4855. //out_data32 -- 各缺陷类型缺陷率-分缺陷率
  4856. //out_table1 -- 缺陷类别
  4857. //out_table2 -- 工号分组
  4858. //out_table3 -- 缺陷扣罚
  4859. //out_table4 -- 缺陷
  4860. //DataSet data = conn.ExecStoredProcedure("PRO_RPT_OverallQualityAnalysis", parameters);
  4861. DataSet data = conn.ExecStoredProcedure("PRO_RPT_OverallQualityA_UserG", parameters);
  4862. ServiceResultEntity sre = new ServiceResultEntity();
  4863. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  4864. {
  4865. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4866. return sre;
  4867. }
  4868. data.Tables[0].TableName = "TQ";
  4869. data.Tables[1].TableName = "FR";
  4870. data.Tables[2].TableName = "DR";
  4871. data.Tables[3].TableName = "DL";
  4872. data.Tables[4].TableName = "FR1";
  4873. data.Tables[5].TableName = "DR1";
  4874. data.Tables[6].TableName = "DR2";
  4875. data.Tables[7].TableName = "DT";
  4876. data.Tables[8].TableName = "WG";
  4877. data.Tables[9].TableName = "DF";
  4878. data.Tables[10].TableName = "D";
  4879. DataTable dtFR = data.Tables["FR"];
  4880. DataTable dtFRClone = dtFR.Clone();
  4881. for (int i = 0; i < dtFR.Columns.Count; i++)
  4882. {
  4883. dtFRClone.Columns[i].DataType = typeof(string);
  4884. }
  4885. foreach (DataRow item in dtFR.Rows)
  4886. {
  4887. item["goodstypename2"] = item["goodstypename2"] + "缺陷数";
  4888. dtFRClone.Rows.Add(item.ItemArray);
  4889. }
  4890. // 增加大小件成品率(%) modify by chenxy 2018-05-03 begin
  4891. //DataRow drFR = dtFRClone.NewRow();
  4892. //drFR["goodstypename2"] = "成品率(%)";
  4893. //foreach (DataRow row in data.Tables["FR1"].Rows)
  4894. //{
  4895. // string tid = row["tid"].ToString();
  4896. // string overRate = (row["OverRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["OverRate"]).ToString("#,##0.00%"));
  4897. // foreach (DataColumn col in dtFRClone.Columns)
  4898. // {
  4899. // if (col.ColumnName.StartsWith(tid))
  4900. // {
  4901. // drFR[col.ColumnName] = overRate;
  4902. // }
  4903. // }
  4904. //}
  4905. //dtFRClone.Rows.Add(drFR);
  4906. Dictionary<string, DataRow> drFRs = new Dictionary<string, DataRow>();
  4907. foreach (DataRow row in data.Tables["FR1"].Rows)
  4908. {
  4909. string tcode = row["goodstypecode2"].ToString();
  4910. DataRow drFR = null;
  4911. if (drFRs.ContainsKey(tcode))
  4912. {
  4913. drFR = drFRs[tcode];
  4914. }
  4915. else
  4916. {
  4917. drFR = dtFRClone.NewRow();
  4918. drFRs.Add(tcode, drFR);
  4919. drFR["goodstypename2"] = row["goodstypeName2"] + "成品率(%)";
  4920. }
  4921. string tid = row["tid"].ToString();
  4922. string overRate = (row["OverRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["OverRate"]).ToString("#,##0.00%"));
  4923. foreach (DataColumn col in dtFRClone.Columns)
  4924. {
  4925. if (col.ColumnName.StartsWith(tid))
  4926. {
  4927. drFR[col.ColumnName] = overRate;
  4928. }
  4929. }
  4930. }
  4931. foreach (DataRow item in drFRs.Values)
  4932. {
  4933. dtFRClone.Rows.Add(item);
  4934. }
  4935. // 增加大小件成品率(%) modify by chenxy 2018-05-03 end
  4936. data.Tables.Remove(dtFR);
  4937. data.Tables.Remove(data.Tables["FR1"]);
  4938. data.Tables.Add(dtFRClone);
  4939. DataTable dtDR = data.Tables["DR"];
  4940. DataTable dtDRClone = dtDR.Clone();
  4941. for (int i = 0; i < dtDR.Columns.Count; i++)
  4942. {
  4943. dtDRClone.Columns[i].DataType = typeof(string);
  4944. }
  4945. foreach (DataRow item in dtDR.Rows)
  4946. {
  4947. item["goodstypename2"] = item["goodstypename2"] + "缺陷数";
  4948. dtDRClone.Rows.Add(item.ItemArray);
  4949. }
  4950. // 增加大小件缺陷率(%) modify by chenxy 2018-05-03 begin
  4951. //DataRow drDR = dtDRClone.NewRow();
  4952. //drDR["goodstypename2"] = "缺陷率(%)";
  4953. //foreach (DataRow row in data.Tables["DR2"].Rows)
  4954. //{
  4955. // string tid = row["tdfid"].ToString();
  4956. // string defectRate = (row["DefectRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["DefectRate"]).ToString("#,##0.00%"));
  4957. // drDR[tid] = defectRate;
  4958. //}
  4959. //dtDRClone.Rows.Add(drDR);
  4960. Dictionary<string, DataRow> drDRs = new Dictionary<string, DataRow>();
  4961. foreach (DataRow row in data.Tables["DR2"].Rows)
  4962. {
  4963. string tcode = row["goodstypecode2"].ToString();
  4964. DataRow drDR = null;
  4965. if (drDRs.ContainsKey(tcode))
  4966. {
  4967. drDR = drDRs[tcode];
  4968. }
  4969. else
  4970. {
  4971. drDR = dtDRClone.NewRow();
  4972. drDRs.Add(tcode, drDR);
  4973. drDR["goodstypename2"] = row["goodstypeName2"] + "缺陷率(%)";
  4974. }
  4975. string tid = row["tdfid"].ToString();
  4976. string defectRate = (row["DefectRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["DefectRate"]).ToString("#,##0.00%"));
  4977. drDR[tid] = defectRate;
  4978. }
  4979. foreach (DataRow item in drDRs.Values)
  4980. {
  4981. dtDRClone.Rows.Add(item);
  4982. }
  4983. // 增加大小件成品率(%) modify by chenxy 2018-05-03 end
  4984. data.Tables.Remove(dtDR);
  4985. data.Tables.Remove(data.Tables["DR2"]);
  4986. data.Tables.Add(dtDRClone);
  4987. conn.Commit();
  4988. sre.Data = data;
  4989. return sre;
  4990. }
  4991. catch (Exception ex)
  4992. {
  4993. throw ex;
  4994. }
  4995. finally
  4996. {
  4997. if (conn != null &&
  4998. conn.ConnState == ConnectionState.Open)
  4999. {
  5000. conn.Disconnect();
  5001. }
  5002. }
  5003. }
  5004. /// <summary>
  5005. /// 取得RPT040110画面(产成品逐日出窑数值分析表)的查询数据
  5006. /// </summary>
  5007. /// <param name="user">登录用户信息</param>
  5008. /// <param name="se">查询条件</param>
  5009. /// <returns>查询结果</returns>
  5010. public static ServiceResultEntity GetRPT040110SData(SUserInfo user, RPT040110_SE se)
  5011. {
  5012. IDBTransaction conn = null;
  5013. try
  5014. {
  5015. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  5016. conn.Connect();
  5017. OracleParameter[] parameters = new OracleParameter[]
  5018. {
  5019. new OracleParameter("in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  5020. new OracleParameter("in_DateBegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  5021. new OracleParameter("in_DateEnd", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  5022. new OracleParameter("in_OutKilnProcedureID", OracleDbType.Int32, se.RptSProcedureID , ParameterDirection.Input),
  5023. new OracleParameter("in_KilnID", OracleDbType.Int32, se.KilnID , ParameterDirection.Input),
  5024. new OracleParameter("out_data1", OracleDbType.RefCursor, null , ParameterDirection.Output),
  5025. };
  5026. DataSet data = null;
  5027. if (se.IsShowG)
  5028. {
  5029. data = conn.ExecStoredProcedure("PRO_RPT_OverallQualityDetail_G", parameters);
  5030. }
  5031. else
  5032. {
  5033. data = conn.ExecStoredProcedure("PRO_RPT_OverallQualityDetail", parameters);
  5034. }
  5035. ServiceResultEntity sre = new ServiceResultEntity();
  5036. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  5037. {
  5038. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5039. return sre;
  5040. }
  5041. conn.Commit();
  5042. sre.Data = data;
  5043. return sre;
  5044. }
  5045. catch (Exception ex)
  5046. {
  5047. throw ex;
  5048. }
  5049. finally
  5050. {
  5051. if (conn != null &&
  5052. conn.ConnState == ConnectionState.Open)
  5053. {
  5054. conn.Disconnect();
  5055. }
  5056. }
  5057. }
  5058. #endregion 分析报表
  5059. #region 汇总报表
  5060. /// <summary>
  5061. /// 取得RPT030101_1画面(产品产量汇总表)的汇总信息查询数据
  5062. /// </summary>
  5063. /// <param name="user">登录用户信息</param>
  5064. /// <param name="se">查询条件</param>
  5065. /// <returns>查询结果</returns>
  5066. public static ServiceResultEntity GetRPT030101SData(SUserInfo user, RPT030101_SE se)
  5067. {
  5068. IDBConnection conn = null;
  5069. try
  5070. {
  5071. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  5072. List<OracleParameter> parameters = new List<OracleParameter>();
  5073. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030101SSQL(user, se, ref parameters));
  5074. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  5075. ServiceResultEntity sre = new ServiceResultEntity();
  5076. if (data == null || data.Rows.Count == 0)
  5077. {
  5078. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5079. return sre;
  5080. }
  5081. sre.Data = new DataSet();
  5082. sre.Data.Tables.Add(data);
  5083. return sre;
  5084. }
  5085. catch (Exception ex)
  5086. {
  5087. throw ex;
  5088. }
  5089. finally
  5090. {
  5091. if (conn != null &&
  5092. conn.ConnState == ConnectionState.Open)
  5093. {
  5094. conn.Close();
  5095. }
  5096. }
  5097. }
  5098. /// <summary>
  5099. /// 获取RPT030101_1画面(产品产量汇总表)的汇总信息查询sql
  5100. /// </summary>
  5101. /// <returns>sql</returns>
  5102. private static string GetRPT030101SSQL(SUserInfo user, RPT030101_SE se, ref List<OracleParameter> parameters)
  5103. {
  5104. //string selSql = "";
  5105. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  5106. /*
  5107. selSql = selSql +
  5108. "select " +
  5109. " decode(t.ProductionLineName,'合计','合计',decode(t.GoodsCode,'小计','--',t.OrganizationName)) OrganizationName, " +
  5110. " decode(t.Procedureid,'--','--',decode(t.GoodsCode,'小计','--',t.ProductionLineName)) ProductionLineName, " +
  5111. " decode(t.GoodsCode,'小计','--',t.Procedureid) Procedureid, " +
  5112. " decode(t.GoodsCode,'小计','--',t.ProcedureName) ProcedureName, " +
  5113. " decode(t.GoodsCode,'小计','小计',t.GoodsTypeName) GoodsTypeName, " +
  5114. " decode(t.GoodsTypeName,'小计','--',t.GoodsId) GoodsId, " +
  5115. " decode(t.ProductionLineName,'合计','--',decode(t.GoodsId,null,'--',t.GoodsCode)) GoodsCode, " +
  5116. " decode(t.GoodsCode,'小计','--',t.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  5117. " decode(t.GoodsCode,'小计','--',t.Dictionaryvalue) Dictionaryvalue, " +
  5118. " decode(t.GoodsCode,'小计','--',g.goodsname) goodsname, " +
  5119. " decode(t.GoodsCode,'小计','--',g.GOODSMODEL) GOODSMODEL, " +
  5120. " t.产量 " +
  5121. "from " +
  5122. "( " +
  5123. " select " +
  5124. " decode(grouping(TP_MST_Organization.OrganizationName),1,'总计',TP_MST_Organization.OrganizationName) OrganizationName, " +
  5125. " decode(grouping(TP_MST_Organization.OrganizationName),1,'--', " +
  5126. " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'合计',TP_PM_ProductionData.ProductionLineName)) ProductionLineName, " +
  5127. " decode(grouping(TP_PM_ProductionData.Procedureid),1,'--',TP_PM_ProductionData.Procedureid) Procedureid, " +
  5128. " decode(grouping(TP_PM_ProductionData.ProcedureName),1,'--',TP_PM_ProductionData.ProcedureName) ProcedureName, " +
  5129. " decode(grouping(TP_MST_GOODSTYPE.GoodsTypeName),1,'--',TP_MST_GOODSTYPE.GoodsTypeName) GoodsTypeName, " +
  5130. " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'--', " +
  5131. " decode(grouping(TP_PM_ProductionData.GoodsCode),1,'小计',TP_PM_ProductionData.GoodsCode)) GoodsCode, " +
  5132. " decode(grouping(TP_PM_ProductionData.GoodsId),1,null,TP_PM_ProductionData.GoodsId) GoodsId, " +
  5133. " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  5134. " decode(grouping(TP_MST_DATADICTIONARY.DICTIONARYVALUE),1,'--',TP_MST_DATADICTIONARY.Dictionaryvalue) Dictionaryvalue, " +
  5135. " count(BarCode) as 产量 " +
  5136. " from TP_PM_ProductionData " +
  5137. " left join TP_MST_Goods on TP_MST_Goods.GoodsID=TP_PM_ProductionData.GoodsID " +
  5138. " left join TP_MST_GoodsType on TP_MST_GoodsType.GoodsTypeID=TP_MST_Goods.GoodsTypeID " +
  5139. " left join TP_MST_Organization on TP_MST_Organization.OrganizationID=TP_PM_ProductionData.OrganizationID " +
  5140. " left join TP_MST_DATADICTIONARY on TP_MST_DATADICTIONARY.DICTIONARYID=TP_MST_Goods.GLAZETYPEID " +
  5141. " Where 1=1 and TP_PM_ProductionData.ValueFlag = 1 " +
  5142. // 公坯、干补不算交坯工序的质量。
  5143. (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" : "") +
  5144. " and TP_PM_ProductionData.AccountID=:AccountID ";
  5145. if (!string.IsNullOrEmpty(se.GoodsIDS))
  5146. {
  5147. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  5148. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  5149. }
  5150. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  5151. {
  5152. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
  5153. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPEcode,:GoodsTypeIDS)=1 ";
  5154. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  5155. }
  5156. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  5157. {
  5158. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  5159. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  5160. }
  5161. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  5162. {
  5163. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_ProductionData.ProcedureId||',')>0 ";
  5164. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  5165. }
  5166. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  5167. {
  5168. selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||TP_MST_Organization.OrganizationId||',')>0 ";
  5169. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  5170. }
  5171. if (se.AccountDateStart.HasValue)
  5172. {
  5173. selSql = selSql + " AND TP_PM_ProductionData.CREATETIME >= :AccountDateStart ";
  5174. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  5175. }
  5176. if (se.AccountDateEnd.HasValue)
  5177. {
  5178. selSql = selSql + " AND TP_PM_ProductionData.CREATETIME <= :AccountDateEnd ";
  5179. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  5180. }
  5181. selSql = selSql +
  5182. "group by " +
  5183. " rollup(TP_MST_Organization.OrganizationName, " +
  5184. " TP_PM_ProductionData.ProductionLineName, " +
  5185. " TP_PM_ProductionData.Procedureid, " +
  5186. " TP_PM_ProductionData.ProcedureName, " +
  5187. " TP_MST_GOODSTYPE.GoodsTypeName, " +
  5188. " TP_PM_ProductionData.GoodsCode, " +
  5189. " TP_PM_ProductionData.GoodsId, " +
  5190. " TP_MST_Goods.GOODSSPECIFICATION, " +
  5191. " TP_MST_DATADICTIONARY.Dictionaryvalue) " +
  5192. " order by " +
  5193. " TP_MST_Organization.OrganizationName, " +
  5194. " TP_PM_ProductionData.ProductionLineName, " +
  5195. " TP_PM_ProductionData.Procedureid, " +
  5196. " TP_PM_ProductionData.ProcedureName, " +
  5197. " TP_MST_GOODSTYPE.GoodsTypeName " +
  5198. ") t \n" +
  5199. // 增加 产品型号
  5200. "left join tp_mst_goods g on g.goodsid = t.goodsid \n" +
  5201. "where 1=1 " +
  5202. "and (t.DICTIONARYVALUE!='--' ) " +
  5203. "or (t.GoodsTypeName='--' and t.ProductionLineName='合计') " +
  5204. "or (t.GoodsTypeName='--' and t.OrganizationName='总计') " +
  5205. "or (t.GoodsCode='小计' and t.GoodsTypeName!='--')";
  5206. */
  5207. string selSql =
  5208. "select t.gid\n" +
  5209. " ,decode(t.gid, 15, '总计', t.ProductionLineName) ProductionLineName\n" +
  5210. " ,t.OrganizationID\n" +
  5211. " --,t.OrganizationCode\n" +
  5212. " ,decode(t.gid\n" +
  5213. " ,7\n" +
  5214. " ,'合计[' || t.OrganizationName || ']'\n" +
  5215. " ,15\n" +
  5216. " ,'--'\n" +
  5217. " ,t.OrganizationName) OrganizationName\n" +
  5218. " ,t.Procedureid\n" +
  5219. " ,decode(t.gid\n" +
  5220. " ,3\n" +
  5221. " ,'小计[' || t.ProcedureName || ']'\n" +
  5222. " ,0\n" +
  5223. " ,t.ProcedureName\n" +
  5224. " ,1\n" +
  5225. " ,t.ProcedureName\n" +
  5226. " ,'--') ProcedureName\n" +
  5227. " ,t.GoodsTypeID\n" +
  5228. " ,decode(t.gid\n" +
  5229. " ,1\n" +
  5230. " ,'小计[' || t.GoodsTypeName || ']'\n" +
  5231. " ,0\n" +
  5232. " ,t.GoodsTypeName\n" +
  5233. " ,'--') GoodsTypeName\n" +
  5234. " --,t.GoodsId\n" +
  5235. " ,decode(t.gid, 0, to_char(t.GoodsId), '--') GoodsId\n" +
  5236. " ,decode(t.gid, 0, t.GoodsCode, '--') GoodsCode\n" +
  5237. " ,decode(t.gid, 0, t.GOODSSPECIFICATION, '--') GOODSSPECIFICATION\n" +
  5238. " ,decode(t.gid, 0, t.Dictionaryvalue, '--') Dictionaryvalue\n" +
  5239. " ,t.pfcount as 产量\n" +
  5240. " from (select grouping_id(org.OrganizationID\n" +
  5241. " ,p.Procedureid\n" +
  5242. " ,gt.goodstypeid\n" +
  5243. " ,g.GoodsId) as gid\n" +
  5244. " ,pd.ProductionLineName\n" +
  5245. " ,org.OrganizationID\n" +
  5246. " --,org.OrganizationCode\n" +
  5247. " ,org.OrganizationName\n" +
  5248. " ,p.Procedureid\n" +
  5249. " ,p.ProcedureName\n" +
  5250. " ,gt.GoodsTypeID\n" +
  5251. " ,gt.GoodsTypeName\n" +
  5252. " ,g.GoodsId\n" +
  5253. " ,g.GoodsCode\n" +
  5254. " ,g.GOODSSPECIFICATION\n" +
  5255. " ,d.Dictionaryvalue\n" +
  5256. " ,count(BarCode) as pfcount" +
  5257. " from TP_PM_ProductionData pd\n" +
  5258. " inner join tp_pc_Procedure p\n" +
  5259. " on p.Procedureid = pd.Procedureid\n" +
  5260. " inner join TP_MST_Goods g\n" +
  5261. " on g.GoodsID = pd.GoodsID\n" +
  5262. " inner join TP_MST_GoodsType gt\n" +
  5263. " on gt.GoodsTypeID = g.GoodsTypeID\n" +
  5264. " inner join TP_MST_Organization org\n" +
  5265. " on org.OrganizationID = pd.OrganizationID\n" +
  5266. " inner join TP_MST_DATADICTIONARY d\n" +
  5267. " on d.DICTIONARYID = g.GLAZETYPEID\n" +
  5268. " where pd.ValueFlag = '1'\n" +
  5269. " and pd.AccountID = :AccountID\n";
  5270. // 公坯、干补不算交坯工序的质量。
  5271. if (se.ProductionFlag == "1")
  5272. {
  5273. selSql += " and ((pd.modeltype <> 5) or (pd.modeltype = 5 and (pd.IsPublicBody = '0' or pd.SpecialRepairFlag = '0'))) \n";
  5274. }
  5275. if (!string.IsNullOrEmpty(se.GoodsIDS))
  5276. {
  5277. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||g.GoodsId||',')>0 ";
  5278. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  5279. }
  5280. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  5281. {
  5282. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
  5283. selSql = selSql + " AND instr(gt.GOODSTYPEcode,:GoodsTypeIDS)=1 ";
  5284. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  5285. }
  5286. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  5287. {
  5288. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pd.ProductionLineId||',')>0 ";
  5289. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  5290. }
  5291. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  5292. {
  5293. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||p.ProcedureId||',')>0 ";
  5294. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  5295. }
  5296. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  5297. {
  5298. selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||org.OrganizationId||',')>0 ";
  5299. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  5300. }
  5301. if (se.AccountDateStart.HasValue)
  5302. {
  5303. selSql = selSql + " AND pd.CREATETIME >= :AccountDateStart ";
  5304. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  5305. }
  5306. if (se.AccountDateEnd.HasValue)
  5307. {
  5308. selSql = selSql + " AND pd.CREATETIME <= :AccountDateEnd ";
  5309. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  5310. }
  5311. selSql +=
  5312. " 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" +
  5313. " order by org.organizationcode\n" +
  5314. " ,p.displayno\n" +
  5315. " ,gt.goodstypecode\n" +
  5316. " ,g.goodscode) t";
  5317. return selSql;
  5318. }
  5319. /// <summary>
  5320. /// 取得RPT030101_1画面(产品产量汇总表)的明细信息查询数据
  5321. /// </summary>
  5322. /// <param name="user">登录用户信息</param>
  5323. /// <param name="se">查询条件</param>
  5324. /// <returns>查询结果</returns>
  5325. public static ServiceResultEntity GetRPT030101IData(SUserInfo user, RPT030101_SE se)
  5326. {
  5327. IDBConnection conn = null;
  5328. try
  5329. {
  5330. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  5331. List<OracleParameter> parameters = new List<OracleParameter>();
  5332. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030101ISQL(user, se, ref parameters));
  5333. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  5334. ServiceResultEntity sre = new ServiceResultEntity();
  5335. if (data == null || data.Rows.Count == 0)
  5336. {
  5337. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5338. return sre;
  5339. }
  5340. sre.Data = new DataSet();
  5341. sre.Data.Tables.Add(data);
  5342. return sre;
  5343. }
  5344. catch (Exception ex)
  5345. {
  5346. throw ex;
  5347. }
  5348. finally
  5349. {
  5350. if (conn != null &&
  5351. conn.ConnState == ConnectionState.Open)
  5352. {
  5353. conn.Close();
  5354. }
  5355. }
  5356. }
  5357. /// <summary>
  5358. /// 获取RPT030101_1画面(产品产量汇总表)的明细信息查询sql
  5359. /// </summary>
  5360. /// <returns>sql</returns>
  5361. private static string GetRPT030101ISQL(SUserInfo user, RPT030101_SE se, ref List<OracleParameter> parameters)
  5362. {
  5363. //string selSql = "";
  5364. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  5365. /*
  5366. selSql = selSql +
  5367. "select " +
  5368. "decode(ProductionLineName,'合计','合计',decode(temp.BarCode,'小计','--',OrganizationName)) OrganizationName, " +
  5369. "decode(ProcedureName,'--','--',decode(temp.barcode,'小计','--',temp.ProductionLineName)) ProductionLineName, " +
  5370. "decode(temp.BarCode,'小计','--',temp.ProcedureName) ProcedureName, " +
  5371. "decode(temp.BarCode,'小计','--',temp.GoodsTypeName) GoodsTypeName, " +
  5372. "decode(temp.BarCode,'小计','小计',temp.GoodsCode) GoodsCode, " +
  5373. "decode(ProductionLineName,'合计','--',decode(temp.usercode,'--','--',temp.Barcode)) BarCode, " +
  5374. "decode(temp.UserCode,'小计','--',temp.UserCode) UserCode, " +
  5375. "decode(GOODSSPECIFICATION,'小计','--',GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  5376. "decode(DICTIONARYVALUE,'小计','--',Dictionaryvalue) Dictionaryvalue, " +
  5377. "产量, " +
  5378. "replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName " +
  5379. "from " +
  5380. "( " +
  5381. " select " +
  5382. " decode(grouping(TP_MST_Organization.OrganizationName),1,'总计',TP_MST_Organization.OrganizationName) OrganizationName, " +
  5383. " decode(grouping(TP_MST_Organization.OrganizationName),1,'--', " +
  5384. " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'合计',TP_PM_ProductionData.ProductionLineName)) ProductionLineName, " +
  5385. " decode(grouping(TP_PM_ProductionData.ProcedureName),1,'--',TP_PM_ProductionData.ProcedureName) ProcedureName, " +
  5386. " decode(grouping(TP_MST_GOODSTYPE.GoodsTypeName),1,'--',TP_MST_GOODSTYPE.GoodsTypeName) GoodsTypeName, " +
  5387. " decode(grouping(TP_PM_ProductionData.GoodsCode),1,'--',TP_PM_ProductionData.GoodsCode) GoodsCode, " +
  5388. " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'--', " +
  5389. " decode(grouping(TP_PM_ProductionData.BarCode),1,'小计',TP_PM_ProductionData.BarCode)) BarCode, " +
  5390. " decode(grouping(TP_PM_ProductionData.UserCode),1,'--',TP_PM_ProductionData.UserCode) UserCode, " +
  5391. " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  5392. " decode(grouping(TP_MST_DATADICTIONARY.Dictionaryvalue),1,'--',TP_MST_DATADICTIONARY.Dictionaryvalue) Dictionaryvalue, " +
  5393. " count(BarCode) as 产量 " +
  5394. " from TP_PM_ProductionData " +
  5395. " left join TP_MST_Goods on TP_MST_Goods.GoodsID=TP_PM_ProductionData.GoodsID " +
  5396. " left join TP_MST_GoodsType on TP_MST_GoodsType.GoodsTypeID=TP_MST_Goods.GoodsTypeID " +
  5397. " left join TP_MST_Organization on TP_MST_Organization.OrganizationID=TP_PM_ProductionData.OrganizationID " +
  5398. " left join TP_MST_DATADICTIONARY on TP_MST_DATADICTIONARY.DICTIONARYID=TP_MST_Goods.GLAZETYPEID " +
  5399. " Where 1=1 " +
  5400. " and TP_PM_ProductionData.ValueFlag = 1 " +
  5401. // 公坯、干补不算交坯工序的质量。
  5402. " 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" +
  5403. " and TP_PM_ProductionData.AccountID=:AccountID ";
  5404. if (!string.IsNullOrEmpty(se.GoodsIDS))
  5405. {
  5406. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  5407. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  5408. }
  5409. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  5410. {
  5411. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
  5412. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)>0 ";
  5413. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  5414. }
  5415. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  5416. {
  5417. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  5418. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  5419. }
  5420. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  5421. {
  5422. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_ProductionData.ProcedureId||',')>0 ";
  5423. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  5424. }
  5425. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  5426. {
  5427. selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||TP_MST_Organization.OrganizationId||',')>0 ";
  5428. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  5429. }
  5430. if (se.AccountDateStart.HasValue)
  5431. {
  5432. selSql = selSql + " AND TP_PM_ProductionData.AccountDate >= :AccountDateStart ";
  5433. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  5434. }
  5435. if (se.AccountDateEnd.HasValue)
  5436. {
  5437. selSql = selSql + " AND TP_PM_ProductionData.AccountDate <= :AccountDateEnd ";
  5438. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  5439. }
  5440. selSql = selSql +
  5441. "group by " +
  5442. " rollup(TP_MST_Organization.OrganizationName, " +
  5443. " TP_PM_ProductionData.ProductionLineName, " +
  5444. " TP_PM_ProductionData.ProcedureName, " +
  5445. " TP_MST_GOODSTYPE.GoodsTypeName, " +
  5446. " TP_PM_ProductionData.GoodsCode, " +
  5447. " TP_PM_ProductionData.BarCode, " +
  5448. " TP_PM_ProductionData.UserCode, " +
  5449. " TP_MST_Goods.GOODSSPECIFICATION, " +
  5450. " TP_MST_DATADICTIONARY.Dictionaryvalue" +
  5451. " ) " +
  5452. " order by " +
  5453. " TP_MST_Organization.OrganizationName, " +
  5454. " TP_PM_ProductionData.ProductionLineName, " +
  5455. " TP_PM_ProductionData.ProcedureName, " +
  5456. " TP_MST_GOODSTYPE.GoodsTypeName " +
  5457. ") temp inner join TP_PM_GroutingDailyDetail on temp.barcode=TP_PM_GroutingDailyDetail.barcode " +
  5458. " inner join tp_mst_logo on TP_PM_GroutingDailyDetail.logoid=tp_mst_logo.logoid " +
  5459. "where 1=1 " +
  5460. "and (temp.DICTIONARYVALUE!='--') " +
  5461. "or (temp.GoodsTypeName='--' and temp.ProductionLineName='合计') " +
  5462. "or (temp.GoodsTypeName='--' and temp.OrganizationName='总计') " +
  5463. "or (temp.BarCode='小计' and temp.GoodsCode!='--')";
  5464. */
  5465. string selSql =
  5466. " select " +
  5467. " TP_MST_Organization.OrganizationName, " +
  5468. " TP_PM_ProductionData.ProductionLineName, " +
  5469. " TP_PM_ProductionData.ProcedureName, " +
  5470. " TP_MST_GOODSTYPE.GoodsTypeName, " +
  5471. " TP_PM_ProductionData.GoodsCode, " +
  5472. " TP_MST_Goods.GoodsName, " +
  5473. " TP_MST_Goods.GoodsModel, " +
  5474. " TP_PM_ProductionData.BarCode, " +
  5475. " TP_PM_ProductionData.UserCode, " +
  5476. " TP_MST_Goods.GOODSSPECIFICATION, " +
  5477. " TP_MST_DATADICTIONARY.Dictionaryvalue, " +
  5478. " TP_PM_ProductionData.CREATETIME, " +
  5479. " TP_PM_ProductionData.KILNcarCODE, " +
  5480. " TP_PM_ProductionData.KILNCODE, " +
  5481. " cu.usercode createusercode, " +
  5482. " cu.username CreateUserName, " +
  5483. " gdd.glazingroom," +
  5484. " decode(tp_mst_logo.logoid,null,'',TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']') as LogoCodeName " +
  5485. " from TP_PM_ProductionData " +
  5486. " left join TP_MST_Goods on TP_MST_Goods.GoodsID=TP_PM_ProductionData.GoodsID " +
  5487. " left join TP_MST_GoodsType on TP_MST_GoodsType.GoodsTypeID=TP_MST_Goods.GoodsTypeID " +
  5488. " left join TP_MST_Organization on TP_MST_Organization.OrganizationID=TP_PM_ProductionData.OrganizationID " +
  5489. " left join TP_MST_DATADICTIONARY on TP_MST_DATADICTIONARY.DICTIONARYID=TP_MST_Goods.GLAZETYPEID " +
  5490. " left join tp_mst_logo on TP_PM_ProductionData.logoid=tp_mst_logo.logoid " +
  5491. " left join tp_mst_user cu on TP_PM_ProductionData.createuserid=cu.userid " +
  5492. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  5493. " ON gdd.Groutingdailydetailid = TP_PM_ProductionData.Groutingdailydetailid\n" +
  5494. " Where TP_PM_ProductionData.ValueFlag = '1' " +
  5495. // 公坯、干补不算交坯工序的质量。
  5496. " 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" +
  5497. " and TP_PM_ProductionData.AccountID=:AccountID ";
  5498. if (!string.IsNullOrEmpty(se.GoodsIDS))
  5499. {
  5500. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  5501. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  5502. }
  5503. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  5504. {
  5505. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
  5506. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)>0 ";
  5507. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  5508. }
  5509. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  5510. {
  5511. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  5512. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  5513. }
  5514. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  5515. {
  5516. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_ProductionData.ProcedureId||',')>0 ";
  5517. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  5518. }
  5519. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  5520. {
  5521. selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||TP_MST_Organization.OrganizationId||',')>0 ";
  5522. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  5523. }
  5524. if (se.AccountDateStart.HasValue)
  5525. {
  5526. selSql = selSql + " AND TP_PM_ProductionData.CREATETIME >= :AccountDateStart ";
  5527. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  5528. }
  5529. if (se.AccountDateEnd.HasValue)
  5530. {
  5531. selSql = selSql + " AND TP_PM_ProductionData.CREATETIME <= :AccountDateEnd ";
  5532. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  5533. }
  5534. return selSql;
  5535. }
  5536. /// <summary>
  5537. /// 取得RPT030102_1画面(产品损坯汇总表)的汇总信息查询数据
  5538. /// </summary>
  5539. /// <param name="user">登录用户信息</param>
  5540. /// <param name="se">查询条件</param>
  5541. /// <returns>查询结果</returns>
  5542. public static ServiceResultEntity GetRPT030102SData(SUserInfo user, RPT030102_SE se)
  5543. {
  5544. IDBConnection conn = null;
  5545. try
  5546. {
  5547. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  5548. List<OracleParameter> parameters = new List<OracleParameter>();
  5549. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030102SSQL(user, se, ref parameters));
  5550. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  5551. ServiceResultEntity sre = new ServiceResultEntity();
  5552. if (data == null || data.Rows.Count == 0)
  5553. {
  5554. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5555. return sre;
  5556. }
  5557. sre.Data = new DataSet();
  5558. sre.Data.Tables.Add(data);
  5559. return sre;
  5560. }
  5561. catch (Exception ex)
  5562. {
  5563. throw ex;
  5564. }
  5565. finally
  5566. {
  5567. if (conn != null &&
  5568. conn.ConnState == ConnectionState.Open)
  5569. {
  5570. conn.Close();
  5571. }
  5572. }
  5573. }
  5574. /// <summary>
  5575. /// 获取RPT030102_1画面(产品损坯汇总表)的汇总信息查询sql
  5576. /// </summary>
  5577. /// <returns>sql</returns>
  5578. private static string GetRPT030102SSQL(SUserInfo user, RPT030102_SE se, ref List<OracleParameter> parameters)
  5579. {
  5580. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  5581. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  5582. string sqlString = "SELECT decode(ts.gid,\n" +
  5583. " 7,\n" +
  5584. " '总计',\n" +
  5585. " 3,\n" +
  5586. " '合计【' || ts.zrprocedurename || '】',\n" +
  5587. " 0,\n" +
  5588. " ts.zrprocedurename,\n" +
  5589. " '--') zrprocedurename\n" +
  5590. " ,decode(ts.gid,\n" +
  5591. " 1,\n" +
  5592. " '小计【' || ts.goodstypename2 || '】',\n" +
  5593. " 0,\n" +
  5594. " ts.goodstypename2,\n" +
  5595. " '--') goodstypename2\n" +
  5596. " ,decode(ts.gid, 0, ts.zrusercode, '--') zrusercode\n" +
  5597. " ,decode(ts.gid, 0, ts.goodscode, '--') goodscode\n" +
  5598. " ,decode(ts.gid, 0, ts.GOODSMODEL, '--') GOODSMODEL\n" +
  5599. " ,ts.productionlineid\n" +
  5600. " ,ts.zrprocedureid\n" +
  5601. " ,ts.goodstypecode2\n" +
  5602. " ,ts.zruserid\n" +
  5603. " ,ts.goodsid\n" +
  5604. " ,ts.barcount\n" +
  5605. " FROM (SELECT grouping_id(t.zrprocedureid, t.goodstypecode2, t.zruserid) gid\n" +
  5606. " ,t.productionlineid\n" +
  5607. " ,t.productionlinename\n" +
  5608. " ,t.displayno\n" +
  5609. " ,t.zrprocedureid\n" +
  5610. " ,t.zrprocedurename\n" +
  5611. " ,t.goodstypecode2\n" +
  5612. " ,t.goodstypename2\n" +
  5613. " ,t.zruserid\n" +
  5614. " ,t.zrusercode\n" +
  5615. " ,t.goodsid\n" +
  5616. " ,t.goodscode\n" +
  5617. " ,t.GOODSMODEL\n" +
  5618. " ,COUNT(t.barcode) barcount\n" +
  5619. " FROM (SELECT sp.productionlineid\n" +
  5620. " ,pline.productionlinename\n" +
  5621. " ,nvl(zp.displayno, -1) displayno\n" +
  5622. " ,zp.procedureid zrprocedureid\n" +
  5623. " ,zp.procedurename zrprocedurename\n" +
  5624. " ,sr.userid zruserid\n" +
  5625. " ,sr.usercode zrusercode\n" +
  5626. " ,gt2.goodstypecode goodstypecode2\n" +
  5627. " ,gt2.goodstypename goodstypename2\n" +
  5628. " ,g.goodsid\n" +
  5629. " ,g.goodscode\n" +
  5630. " ,g.GOODSMODEL\n" +
  5631. " ,sp.barcode\n" +
  5632. " FROM tp_pm_scrapproduct sp\n" +
  5633. " LEFT JOIN TP_PM_ResponProcedure rp\n" +
  5634. " ON rp.scrapproductid = sp.scrapproductid\n" +
  5635. " LEFT JOIN (SELECT DISTINCT t.ScrapProductID\n" +
  5636. " ,t.ResponProcedureID\n" +
  5637. " ,t.userid\n" +
  5638. " ,t.usercode\n" +
  5639. " FROM TP_PM_ScrapResponsible t) sr\n" +
  5640. " ON sr.scrapproductid = sp.scrapproductid\n" +
  5641. // wangx 2016-06-20
  5642. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  5643. " ON rp.barcode = gdd.barcode\n" +
  5644. // wangx 2016-06-20 end
  5645. " LEFT JOIN tp_pc_productionline pline\n" +
  5646. " ON pline.productionlineid = sp.productionlineid\n" +
  5647. " LEFT JOIN tp_pc_procedure zp\n" +
  5648. " ON zp.procedureid = rp.procedureid\n" +
  5649. " LEFT JOIN tp_mst_user cu\n" +
  5650. " ON cu.userid = sp.createuserid\n" +
  5651. " LEFT JOIN tp_mst_user au\n" +
  5652. " ON au.userid = sp.auditor\n" +
  5653. " LEFT JOIN tp_mst_goods g\n" +
  5654. " ON g.goodsid = sp.goodsid\n" +
  5655. " LEFT JOIN tp_mst_goodstype gt\n" +
  5656. " ON gt.goodstypeid = g.goodstypeid\n" +
  5657. " LEFT JOIN tp_mst_goodstype gt2\n" +
  5658. " ON gt2.accountid = gt.accountid\n" +
  5659. " AND gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  5660. " WHERE sp.valueflag = '1'\n" +
  5661. " AND sp.AuditStatus = '1'\n" +
  5662. // 生产线
  5663. //" 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))" +
  5664. // 完成工序
  5665. //" 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))" +
  5666. // 责任工序
  5667. //" 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)))" +
  5668. " AND sp.accountid = :AccountID\n" +
  5669. (se.SpecialRepairFlag ? " AND sp.GoodsLevelTypeID in (8,9) -- 8损坯、9干补\n" : " AND sp.GoodsLevelTypeID = 8 -- 8损坯、9干补\n") +
  5670. (se.ReFireFlag ? " " : " AND sp.IsReFire <> '6'\n") +
  5671. " AND sp.ScrapType = '0'\n" +
  5672. " AND (:ProductionLineID IS NULL OR\n" +
  5673. " sp.ProductionLineID = :ProductionLineID)\n" +
  5674. " AND (:GoodsTypeCode IS NULL OR\n" +
  5675. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  5676. " AND (:GoodsCode IS NULL OR\n" +
  5677. " instr(g.GoodsCode, :GoodsCode) > 0)\n" +
  5678. " AND (:ProcedureIDS IS NULL OR\n" +
  5679. " instr(:ProcedureIDS, ',' || sp.ProcedureID || ',') > 0)\n" +
  5680. " AND (:ResponProcedureIDS IS NULL OR\n" +
  5681. " instr(:ResponProcedureIDS,\n" +
  5682. " ',' || rp.ProcedureID || ',') > 0)\n" +
  5683. " AND (:ResponUserIDS IS NULL OR\n" +
  5684. " instr(:ResponUserIDS, ',' || sr.userid || ',') > 0)\n" +
  5685. // 损坯时间
  5686. " AND (:ScrapDateStart IS NULL OR\n" +
  5687. " sp.CreateTime >= :ScrapDateStart)\n" +
  5688. " AND (:ScrapDateEnd IS NULL OR\n" +
  5689. " sp.CreateTime <= :ScrapDateEnd)\n" +
  5690. // 审核时间
  5691. " AND (:AuditDateStart IS NULL OR\n" +
  5692. " sp.AuditDate >= :AuditDateStart)\n" +
  5693. " AND (:AuditDateEnd IS NULL OR\n" +
  5694. " sp.AuditDate <= :AuditDateEnd)\n" +
  5695. // 完成时间
  5696. " AND (:CTimeStart IS NULL OR\n" +
  5697. " sp.CreateTime >= :CTimeStart)\n" +
  5698. " AND (:CTimeEnd IS NULL OR\n" +
  5699. " sp.CreateTime <= :CTimeEnd)\n" +
  5700. // 交坯时间
  5701. " AND (:DTimeStart IS NULL OR\n" +
  5702. " gdd.DeliverTime >= :DTimeStart)\n" +
  5703. " AND (:DTimeEnd IS NULL OR\n" +
  5704. " gdd.DeliverTime <= :DTimeEnd)\n" +
  5705. // 注浆时间
  5706. " AND (:GTimeStart IS NULL OR\n" +
  5707. " gdd.GroutingDate >= :GTimeStart)\n" +
  5708. " AND (:GTimeEnd IS NULL OR\n" +
  5709. " gdd.GroutingDate <= :GTimeEnd)\n" +
  5710. " AND (:CreatUser IS NULL OR\n" +
  5711. " instr(cu.UserCode, :CreatUser) > 0)\n" +
  5712. " AND (:AuditUser IS NULL OR\n" +
  5713. " instr(au.UserCode, :AuditUser) > 0)) t\n" +
  5714. " 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" +
  5715. " ORDER BY t.displayno, t.goodstypecode2, t.zrusercode, t.goodscode) ts";
  5716. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  5717. if (string.IsNullOrEmpty(se.ProcedureIDS))
  5718. {
  5719. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5720. }
  5721. else
  5722. {
  5723. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  5724. }
  5725. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  5726. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  5727. if (string.IsNullOrEmpty(se.ResponProcedureIDS))
  5728. {
  5729. parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5730. }
  5731. else
  5732. {
  5733. parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, "," + se.ResponProcedureIDS + ",", ParameterDirection.Input));
  5734. }
  5735. if (string.IsNullOrEmpty(se.ResponUserIDS))
  5736. {
  5737. parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5738. }
  5739. else
  5740. {
  5741. parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, "," + se.ResponUserIDS + ",", ParameterDirection.Input));
  5742. }
  5743. parameters.Add(new OracleParameter(":CreatUser", OracleDbType.Varchar2, se.CreatUser, ParameterDirection.Input));
  5744. parameters.Add(new OracleParameter(":AuditUser", OracleDbType.Varchar2, se.AuditUser, ParameterDirection.Input));
  5745. parameters.Add(new OracleParameter(":ScrapDateStart", OracleDbType.Date, se.ScrapDateStart, ParameterDirection.Input));
  5746. parameters.Add(new OracleParameter(":ScrapDateEnd", OracleDbType.Date, se.ScrapDateEnd, ParameterDirection.Input));
  5747. parameters.Add(new OracleParameter(":CTimeStart", OracleDbType.Date, se.CTimeStart, ParameterDirection.Input));
  5748. parameters.Add(new OracleParameter(":CTimeEnd", OracleDbType.Date, se.CTimeEnd, ParameterDirection.Input));
  5749. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart, ParameterDirection.Input));
  5750. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd, ParameterDirection.Input));
  5751. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart, ParameterDirection.Input));
  5752. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd, ParameterDirection.Input));
  5753. parameters.Add(new OracleParameter(":AuditDateStart", OracleDbType.Date, se.AuditTimeStart, ParameterDirection.Input));
  5754. parameters.Add(new OracleParameter(":AuditDateEnd", OracleDbType.Date, se.AuditTimeEnd, ParameterDirection.Input));
  5755. return sqlString;
  5756. }
  5757. /// <summary>
  5758. /// 取得RPT030102_1画面(产品损坯汇总表)的明细信息查询数据
  5759. /// </summary>
  5760. /// <param name="user">登录用户信息</param>
  5761. /// <param name="se">查询条件</param>
  5762. /// <returns>查询结果</returns>
  5763. public static ServiceResultEntity GetRPT030102IData(SUserInfo user, RPT030102_SE se)
  5764. {
  5765. IDBConnection conn = null;
  5766. try
  5767. {
  5768. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  5769. List<OracleParameter> parameters = new List<OracleParameter>();
  5770. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030102ISQL(user, se, ref parameters));
  5771. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  5772. ServiceResultEntity sre = new ServiceResultEntity();
  5773. if (data == null || data.Rows.Count == 0)
  5774. {
  5775. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5776. return sre;
  5777. }
  5778. sre.Data = new DataSet();
  5779. sre.Data.Tables.Add(data);
  5780. return sre;
  5781. }
  5782. catch (Exception ex)
  5783. {
  5784. throw ex;
  5785. }
  5786. finally
  5787. {
  5788. if (conn != null &&
  5789. conn.ConnState == ConnectionState.Open)
  5790. {
  5791. conn.Close();
  5792. }
  5793. }
  5794. }
  5795. /// <summary>
  5796. /// 获取RPT030102_1画面(产品损坯汇总表)的明细信息查询sql
  5797. /// </summary>
  5798. /// <returns>sql</returns>
  5799. private static string GetRPT030102ISQL(SUserInfo user, RPT030102_SE se, ref List<OracleParameter> parameters)
  5800. {
  5801. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  5802. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  5803. string sqlString =
  5804. "SELECT pline.productionlinename\n" +
  5805. " ,p.procedurename\n" +
  5806. " ,zp.procedurename zrprocedurename\n" +
  5807. " ,sr.usercode zrusercode\n" +
  5808. " ,sr.StaffNames zrStaffNames\n" +
  5809. " ,gt2.goodstypecode goodstypecode2\n" +
  5810. " ,gt2.goodstypename goodstypename2\n" +
  5811. " ,gt.goodstypename\n" +
  5812. " ,g.goodscode\n" +
  5813. " ,g.GOODSMODEL\n" +
  5814. " ,sp.barcode\n" +
  5815. " ,sp.createtime Scrapdate\n" +
  5816. " ,sp.Rreason\n" +
  5817. " ,sp.GroutingUserCode\n" +
  5818. " ,sp.GroutingLineCode\n" +
  5819. " ,sp.GroutingMouldCode\n" +
  5820. " ,sp.GroutingDate\n" +
  5821. " ,sp.GroutingNum\n" +
  5822. " ,cu.usercode CreateUserCode\n" +
  5823. " ,au.usercode AuditorCode\n" +
  5824. " ,sp.auditdate\n" +
  5825. " ,gdd.DeliverTime\n" +
  5826. " ,gdd.ISPUBLICBODY\n" +
  5827. " ,gdd.SPECIALREPAIRFLAG\n" +
  5828. " ,lg.logoname\n" +
  5829. " ,sp.CreateTime\n" +
  5830. " ,sp.Remarks\n" +
  5831. " FROM tp_pm_scrapproduct sp\n" +
  5832. " LEFT JOIN TP_PM_ResponProcedure rp\n" +
  5833. " ON rp.scrapproductid = sp.scrapproductid\n" +
  5834. " LEFT JOIN (SELECT DISTINCT t.ScrapProductID\n" +
  5835. " ,t.ResponProcedureID\n" +
  5836. " ,t.userid\n" +
  5837. " ,t.usercode\n" +
  5838. " ,LISTAGG(to_char(s.StaffName), ',') WITHIN GROUP(ORDER BY s.staffcode) over(partition by t.ScrapProductID) AS StaffNames\n" +
  5839. " FROM TP_PM_ScrapResponsible t\n" +
  5840. " LEFT JOIN TP_HR_Staff s \n" +
  5841. " ON s.StaffID = t.StaffID \n" +
  5842. " ) sr\n" +
  5843. " ON sr.scrapproductid = sp.scrapproductid\n" +
  5844. // wangx 2016-06-20
  5845. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  5846. " ON sp.barcode = gdd.barcode\n" +
  5847. // wangx 2016-06-20 end
  5848. " LEFT JOIN TP_mst_logo lg\n" +
  5849. " ON lg.logoid = gdd.logoid\n" +
  5850. " LEFT JOIN tp_pc_productionline pline\n" +
  5851. " ON pline.productionlineid = sp.productionlineid\n" +
  5852. " LEFT JOIN tp_pc_procedure p\n" +
  5853. " ON p.procedureid = sp.procedureid\n" +
  5854. " LEFT JOIN tp_pc_procedure zp\n" +
  5855. " ON zp.procedureid = rp.procedureid\n" +
  5856. " LEFT JOIN tp_mst_user cu\n" +
  5857. " ON cu.userid = sp.createuserid\n" +
  5858. " LEFT JOIN tp_mst_user au\n" +
  5859. " ON au.userid = sp.auditor\n" +
  5860. " LEFT JOIN tp_mst_goods g\n" +
  5861. " ON g.goodsid = sp.goodsid\n" +
  5862. " LEFT JOIN tp_mst_goodstype gt\n" +
  5863. " ON gt.goodstypeid = g.goodstypeid\n" +
  5864. " LEFT JOIN tp_mst_goodstype gt2\n" +
  5865. " ON gt2.accountid = gt.accountid\n" +
  5866. " AND gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  5867. " WHERE sp.valueflag = '1'\n" +
  5868. " AND sp.AuditStatus = '1'\n" +
  5869. " AND sp.accountid = :accountid\n" +
  5870. // 生产线
  5871. //" 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))" +
  5872. // 完成工序
  5873. //" 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))" +
  5874. // 责任工序
  5875. //" 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)))" +
  5876. //" AND sp.GoodsLevelTypeID = 8 -- 8损坯、9干补\n" +
  5877. (se.SpecialRepairFlag ? " AND sp.GoodsLevelTypeID in (8,9) -- 8损坯、9干补\n" : " AND sp.GoodsLevelTypeID = 8 -- 8损坯、9干补\n") +
  5878. (se.ReFireFlag ? " " : " AND sp.IsReFire <> '6'\n") +
  5879. " AND sp.ScrapType = '0'\n" +
  5880. " AND (:ProductionLineID IS NULL OR\n" +
  5881. " sp.ProductionLineID = :ProductionLineID)\n" +
  5882. " AND (:GoodsTypeCode IS NULL OR\n" +
  5883. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  5884. " AND (:GoodsCode IS NULL OR instr(g.GoodsCode, :GoodsCode) > 0)\n" +
  5885. " AND (:ProcedureIDS IS NULL OR\n" +
  5886. " instr(:ProcedureIDS, ',' || sp.ProcedureID || ',') > 0)\n" +
  5887. " AND (:ResponProcedureIDS IS NULL OR\n" +
  5888. " instr(:ResponProcedureIDS, ',' || rp.ProcedureID || ',') > 0)\n" +
  5889. " AND (:ResponUserIDS IS NULL OR\n" +
  5890. " instr(:ResponUserIDS, ',' || sr.userid || ',') > 0)\n" +
  5891. // 损坯时间
  5892. " AND (:ScrapDateStart IS NULL OR sp.CreateTime >= :ScrapDateStart)\n" +
  5893. " AND (:ScrapDateEnd IS NULL OR sp.CreateTime <= :ScrapDateEnd)\n" +
  5894. // 审核时间
  5895. " AND (:AuditDateStart IS NULL OR sp.AuditDate >= :AuditDateStart)\n" +
  5896. " AND (:AuditDateEnd IS NULL OR sp.AuditDate <= :AuditDateEnd)\n" +
  5897. // 完成时间
  5898. " AND (:CTimeStart IS NULL OR\n" +
  5899. " sp.CreateTime >= :CTimeStart)\n" +
  5900. " AND (:CTimeEnd IS NULL OR\n" +
  5901. " sp.CreateTime <= :CTimeEnd)\n" +
  5902. // 交坯时间
  5903. " AND (:DTimeStart IS NULL OR\n" +
  5904. " gdd.DeliverTime >= :DTimeStart)\n" +
  5905. " AND (:DTimeEnd IS NULL OR\n" +
  5906. " gdd.DeliverTime <= :DTimeEnd)\n" +
  5907. // 注浆时间
  5908. " AND (:GTimeStart IS NULL OR\n" +
  5909. " gdd.GroutingDate >= :GTimeStart)\n" +
  5910. " AND (:GTimeEnd IS NULL OR\n" +
  5911. " gdd.GroutingDate <= :GTimeEnd)\n" +
  5912. " AND (:CreatUser IS NULL OR instr(cu.UserCode, :CreatUser) > 0)\n" +
  5913. " AND (:AuditUser IS NULL OR instr(au.UserCode, :AuditUser) > 0)\n" +
  5914. " AND (:GoodsID IS NULL OR sp.goodsid = :GoodsID)\n" +
  5915. " AND (:ResponProcedureID IS NULL OR rp.procedureid = :ResponProcedureID)\n" +
  5916. " AND (:ResponUserID IS NULL OR sr.userid = :ResponUserID)\n" +
  5917. " AND (:RPF = 1 OR rp.procedureid is null)\n" +
  5918. " AND (:RUF = 1 OR sr.userid is null)\n" +
  5919. " ORDER BY pline.productionlinename, nvl(zp.displayno, -1), sp.barcode";
  5920. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  5921. if (string.IsNullOrEmpty(se.ProcedureIDS))
  5922. {
  5923. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5924. }
  5925. else
  5926. {
  5927. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  5928. }
  5929. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  5930. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  5931. if (string.IsNullOrEmpty(se.ResponProcedureIDS))
  5932. {
  5933. parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5934. }
  5935. else
  5936. {
  5937. parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, "," + se.ResponProcedureIDS + ",", ParameterDirection.Input));
  5938. }
  5939. if (string.IsNullOrEmpty(se.ResponUserIDS))
  5940. {
  5941. parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5942. }
  5943. else
  5944. {
  5945. parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, "," + se.ResponUserIDS + ",", ParameterDirection.Input));
  5946. }
  5947. parameters.Add(new OracleParameter(":CreatUser", OracleDbType.Varchar2, se.CreatUser, ParameterDirection.Input));
  5948. parameters.Add(new OracleParameter(":AuditUser", OracleDbType.Varchar2, se.AuditUser, ParameterDirection.Input));
  5949. parameters.Add(new OracleParameter(":ScrapDateStart", OracleDbType.Date, se.ScrapDateStart, ParameterDirection.Input));
  5950. parameters.Add(new OracleParameter(":ScrapDateEnd", OracleDbType.Date, se.ScrapDateEnd, ParameterDirection.Input));
  5951. parameters.Add(new OracleParameter(":AuditDateStart", OracleDbType.Date, se.AuditTimeStart, ParameterDirection.Input));
  5952. parameters.Add(new OracleParameter(":AuditDateEnd", OracleDbType.Date, se.AuditTimeEnd, ParameterDirection.Input));
  5953. parameters.Add(new OracleParameter(":CTimeStart", OracleDbType.Date, se.CTimeStart, ParameterDirection.Input));
  5954. parameters.Add(new OracleParameter(":CTimeEnd", OracleDbType.Date, se.CTimeEnd, ParameterDirection.Input));
  5955. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart, ParameterDirection.Input));
  5956. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd, ParameterDirection.Input));
  5957. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart, ParameterDirection.Input));
  5958. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd, ParameterDirection.Input));
  5959. parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  5960. if (se.ResponProcedureID == "")
  5961. {
  5962. parameters.Add(new OracleParameter(":RPF", OracleDbType.Int32, 0, ParameterDirection.Input));
  5963. parameters.Add(new OracleParameter(":ResponProcedureID", OracleDbType.Int32, null, ParameterDirection.Input));
  5964. }
  5965. else
  5966. {
  5967. parameters.Add(new OracleParameter(":RPF", OracleDbType.Int32, 1, ParameterDirection.Input));
  5968. parameters.Add(new OracleParameter(":ResponProcedureID", OracleDbType.Int32, se.ResponProcedureID, ParameterDirection.Input));
  5969. }
  5970. if (se.ResponUserID == "")
  5971. {
  5972. parameters.Add(new OracleParameter(":RUF", OracleDbType.Int32, 0, ParameterDirection.Input));
  5973. parameters.Add(new OracleParameter(":ResponUserID", OracleDbType.Int32, null, ParameterDirection.Input));
  5974. }
  5975. else
  5976. {
  5977. parameters.Add(new OracleParameter(":RUF", OracleDbType.Int32, 1, ParameterDirection.Input));
  5978. parameters.Add(new OracleParameter(":ResponUserID", OracleDbType.Int32, se.ResponUserID, ParameterDirection.Input));
  5979. }
  5980. return sqlString;
  5981. }
  5982. /// <summary>
  5983. /// 取得RPT030103_1画面(出窑数量汇总表)的汇总信息查询数据
  5984. /// </summary>
  5985. /// <param name="user">登录用户信息</param>
  5986. /// <param name="se">查询条件</param>
  5987. /// <returns>查询结果</returns>
  5988. public static ServiceResultEntity GetRPT030103SData(SUserInfo user, RPT030103_SE se)
  5989. {
  5990. IDBConnection conn = null;
  5991. try
  5992. {
  5993. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  5994. List<OracleParameter> parameters = new List<OracleParameter>();
  5995. string sql = ReportModuleLogic.GetRPT030103SSQL(user, se, ref parameters);
  5996. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  5997. ServiceResultEntity sre = new ServiceResultEntity();
  5998. if (data == null || data.Rows.Count == 0)
  5999. {
  6000. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6001. return sre;
  6002. }
  6003. sre.Data = new DataSet();
  6004. sre.Data.Tables.Add(data);
  6005. return sre;
  6006. }
  6007. catch (Exception ex)
  6008. {
  6009. throw ex;
  6010. }
  6011. finally
  6012. {
  6013. if (conn != null &&
  6014. conn.ConnState == ConnectionState.Open)
  6015. {
  6016. conn.Close();
  6017. }
  6018. }
  6019. }
  6020. /// <summary>
  6021. /// 获取RPT030103_1画面(出窑数量汇总表)的汇总信息查询sql
  6022. /// </summary>
  6023. /// <returns>sql</returns>
  6024. private static string GetRPT030103SSQL(SUserInfo user, RPT030103_SE se, ref List<OracleParameter> parameters)
  6025. {
  6026. string selSql = "";
  6027. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6028. parameters.Add(new OracleParameter(":rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  6029. selSql = selSql +
  6030. "SELECT pdata.Procedureid Procedureid " +
  6031. " ,decode(gid, 3, '合计', 1, '小计【'||pdata.Procedurename||'】', pdata.Procedurename) Procedurename " +
  6032. " ,decode(gid, 0, to_char(pdata.Userid), '--') Userid " +
  6033. " ,decode(gid, 0, pdata.Usercode, '--') Usercode " +
  6034. " ,decode(gid, 0, to_char(pdata.KilnID), '--') Kilnid " +
  6035. " ,decode(gid, 0, pdata.Kilncode, '--') Kilncode " +
  6036. " ,decode(gid, 0, pdata.goodstypename, '--') goodstypename " +
  6037. " ,decode(gid, 0, to_char(pdata.Goodsid), '--') Goodsid " +
  6038. " ,decode(gid, 0, pdata.Goodscode, '--') Goodscode " +
  6039. " ,OutKilnCount " +
  6040. " FROM (SELECT grouping_id(pdata.Procedureid, " +
  6041. " pdata.Userid ) gid " +
  6042. " ,pdata.Procedureid " +
  6043. " ,pdata.Procedurename " +
  6044. " ,pdata.Userid " +
  6045. " ,pdata.Usercode " +
  6046. " ,pdata.Kilnid " +
  6047. " ,pdata.Kilncode " +
  6048. " ,pdata.goodstypename " +
  6049. " ,pdata.Goodsid " +
  6050. " ,pdata.Goodscode " +
  6051. " ,COUNT(pdata.Barcode) AS OutKilnCount " +
  6052. " FROM (SELECT DISTINCT " +
  6053. //" decode(grouping(TP_PM_ProductionData.Procedureid),1,'--',TP_PM_ProductionData.Procedureid) Procedureid, " +
  6054. //" decode(grouping(TP_PM_ProductionData.Procedurename),1,'合计', TP_PM_ProductionData.Procedurename) Procedurename, " +
  6055. //" decode(grouping(TP_PM_ProductionData.Userid),1,'--', TP_PM_ProductionData.Userid) Userid, " +
  6056. //" decode(grouping(TP_PM_ProductionData.Usercode),1,'--', TP_PM_ProductionData.Usercode) Usercode, " +
  6057. //" decode(grouping(temp.Kilncode),1,'--', temp.KilnID) Kilnid, " +
  6058. //" decode(grouping(temp.Kilncode),1,'--', temp.Kilncode) Kilncode, " +
  6059. //" decode(grouping(tp_mst_goodstype.goodstypename),1,'--', tp_mst_goodstype.goodstypename) goodstypename, " +
  6060. //" decode(grouping(TP_PM_ProductionData.Goodsid),1,'--', TP_PM_ProductionData.Goodsid) Goodsid, " +
  6061. //" decode(grouping(TP_PM_ProductionData.Goodscode),1,'--', TP_PM_ProductionData.Goodscode) Goodscode, " +
  6062. "TP_PM_ProductionData.Procedureid,pcp.Procedurename, " +
  6063. //"TP_PM_ProductionData.Userid,TP_PM_ProductionData.Usercode, " +
  6064. (se.DisPUserCode ? " TP_PM_ProductionData.userid, TP_PM_ProductionData.usercode, \n" : " null userid, null usercode, \n") +
  6065. "temp.Kilnid,temp.Kilncode,tp_mst_goodstype.goodstypename, " +
  6066. "TP_PM_ProductionData.Goodsid,TP_PM_ProductionData.Goodscode, TP_PM_ProductionData.barcode " +
  6067. " from TP_PM_ProductionData " +
  6068. " inner join tp_mst_goods on tp_mst_goods.goodsid=TP_PM_ProductionData.Goodsid " +
  6069. " inner join tp_mst_goodstype on tp_mst_goodstype.goodstypeid=tp_mst_goods.goodstypeid " +
  6070. " inner join TP_MST_RptTProcedure on TP_MST_RptTProcedure.Procedureid=TP_PM_ProductionData.Procedureid " +
  6071. " inner join TP_MST_RptProcedure on TP_MST_RptProcedure.Rptprocedureid=TP_MST_RptTProcedure.Rptprocedureid " +
  6072. " inner join tp_pc_procedure pcp on pcp.procedureid=TP_PM_ProductionData.Procedureid " +
  6073. " inner join " +
  6074. " ( " +
  6075. " 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 " +
  6076. " from TP_PM_ProductionData " +
  6077. " inner join TP_MST_RptSProcedure on TP_MST_RptSProcedure.Procedureid=TP_PM_ProductionData.Procedureid ";
  6078. if (se.DTimeStart.HasValue || se.DTimeEnd.HasValue)
  6079. {
  6080. selSql += " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=TP_PM_ProductionData.groutingdailydetailid ";
  6081. }
  6082. selSql +=
  6083. " where TP_PM_ProductionData.Accountid=:AccountID " +
  6084. " and TP_PM_ProductionData.Valueflag='1' " +
  6085. // 数据重复 modify by chenxy begin
  6086. // " and TP_MST_RptSProcedure.Rptprocedureid=:rptProcedureId " +
  6087. // 数据重复 modify by chenxy end
  6088. " and TP_MST_RptSProcedure.Procedureid=:rptSprocedureId ";
  6089. //if (se.CreateTimeStart.HasValue)
  6090. //{
  6091. // selSql = selSql + " AND TP_PM_ProductionData.CreateTime >= :CreateTimeStart ";
  6092. // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6093. //}
  6094. //if (se.CreateTimeEnd.HasValue)
  6095. //{
  6096. // selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :CreateTimeEnd ";
  6097. // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6098. //}
  6099. if (se.OutTimeStart.HasValue)
  6100. {
  6101. selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:OutTimeStart ";
  6102. parameters.Add(new OracleParameter(":OutTimeStart", OracleDbType.Date, se.OutTimeStart.Value, ParameterDirection.Input));
  6103. }
  6104. if (se.OutTimeEnd.HasValue)
  6105. {
  6106. selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :OutTimeEnd ";
  6107. parameters.Add(new OracleParameter(":OutTimeEnd", OracleDbType.Date, se.OutTimeEnd.Value, ParameterDirection.Input));
  6108. }
  6109. if (se.GTimeStart.HasValue)
  6110. {
  6111. selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE >=:GTimeStart ";
  6112. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  6113. }
  6114. if (se.GTimeEnd.HasValue)
  6115. {
  6116. selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE <= :GTimeEnd ";
  6117. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  6118. }
  6119. if (se.DTimeStart.HasValue)
  6120. {
  6121. selSql = selSql + " AND gdd.DELIVERTIME >=:DTimeStart ";
  6122. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
  6123. }
  6124. if (se.DTimeEnd.HasValue)
  6125. {
  6126. selSql = selSql + " AND gdd.DELIVERTIME <= :DTimeEnd ";
  6127. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
  6128. }
  6129. if (se.Specialrepairflag)
  6130. {
  6131. selSql = selSql +
  6132. " ) temp " +
  6133. " on TP_PM_ProductionData.Barcode=temp.barcode " +
  6134. " " +
  6135. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
  6136. " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
  6137. " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
  6138. " FROM TP_PM_ProductionData pp\n" +
  6139. " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
  6140. " AND pp.createtime < temp.createtime\n" +
  6141. " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
  6142. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
  6143. " where " +
  6144. // 公坯、干补不算交坯工序的质量。
  6145. // " 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" +
  6146. // modify wangx 2015-12-3
  6147. " ((TP_PM_ProductionData.modeltype <> 5) or (TP_PM_ProductionData.modeltype = 5 and TP_PM_ProductionData.SpecialRepairFlag = '0')) \n" +
  6148. " and TP_PM_ProductionData.Valueflag='1' " +
  6149. " and TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId ";
  6150. parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  6151. }
  6152. else
  6153. {
  6154. selSql = selSql +
  6155. " ) temp " +
  6156. " on TP_PM_ProductionData.Barcode=temp.barcode " +
  6157. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
  6158. " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
  6159. " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
  6160. " FROM TP_PM_ProductionData pp\n" +
  6161. " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
  6162. " AND pp.createtime < temp.createtime\n" +
  6163. " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
  6164. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
  6165. " where TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId " +
  6166. " and TP_PM_ProductionData.Valueflag='1' ";
  6167. parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  6168. }
  6169. if (se.CreateTimeStart.HasValue)
  6170. {
  6171. selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:CreateTimeStart ";
  6172. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6173. }
  6174. if (se.CreateTimeEnd.HasValue)
  6175. {
  6176. selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :CreateTimeEnd ";
  6177. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6178. }
  6179. if (!string.IsNullOrEmpty(se.GoodsIDS))
  6180. {
  6181. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  6182. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  6183. }
  6184. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  6185. {
  6186. // selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1 ";
  6187. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1 ";
  6188. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  6189. }
  6190. if (se.ProductionLineID.HasValue)
  6191. {
  6192. selSql = selSql + " AND instr(','||:productionLineId||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  6193. parameters.Add(new OracleParameter(":productionLineId", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  6194. }
  6195. //else
  6196. //{
  6197. // selSql = selSql + " AND TP_PM_ProductionData.ProductionLineId in(Select PurviewID from TP_MST_UserPurview where PurviewType= 7 and UserID = :UserID) ";
  6198. //}
  6199. 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))";
  6200. 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))";
  6201. parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  6202. if (!string.IsNullOrEmpty(se.RptTProcedureIDS))
  6203. {
  6204. selSql = selSql + " AND instr(','||:rptTprocedureId||',',','||TP_MST_RptTProcedure.ProcedureId||',')>0 ";
  6205. parameters.Add(new OracleParameter(":rptTprocedureId", OracleDbType.NVarchar2, se.RptTProcedureIDS, ParameterDirection.Input));
  6206. }
  6207. if (!string.IsNullOrEmpty(se.UserIDS))
  6208. {
  6209. selSql = selSql + " AND instr(','||:userIDS||',',','||TP_PM_ProductionData.Userid||',')>0 ";
  6210. parameters.Add(new OracleParameter(":userIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6211. }
  6212. if (se.KilnID.HasValue)
  6213. {
  6214. selSql = selSql + " AND temp.KilnID=:KilnID ";
  6215. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6216. }
  6217. if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
  6218. {
  6219. selSql = selSql + " AND instr(TP_PM_ProductionData.GroutingUserCode, :GroutingUserCode) > 0";
  6220. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  6221. }
  6222. selSql = selSql + " order by pcp.displayno, TP_PM_ProductionData.Usercode, temp.Kilncode,tp_mst_goodstype.goodstypename,TP_PM_ProductionData.Goodscode ) pdata" +
  6223. " 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),()) " +
  6224. ") pdata"
  6225. ;
  6226. return selSql;
  6227. }
  6228. /// <summary>
  6229. /// 取得RPT030103_1画面(出窑数量汇总表)的明细信息查询数据
  6230. /// </summary>
  6231. /// <param name="user">登录用户信息</param>
  6232. /// <param name="se">查询条件</param>
  6233. /// <returns>查询结果</returns>
  6234. public static ServiceResultEntity GetRPT030103IData(SUserInfo user, RPT030103_SE se)
  6235. {
  6236. IDBConnection conn = null;
  6237. try
  6238. {
  6239. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6240. List<OracleParameter> parameters = new List<OracleParameter>();
  6241. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030103ISQL(user, se, ref parameters));
  6242. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  6243. ServiceResultEntity sre = new ServiceResultEntity();
  6244. if (data == null || data.Rows.Count == 0)
  6245. {
  6246. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6247. return sre;
  6248. }
  6249. sre.Data = new DataSet();
  6250. sre.Data.Tables.Add(data);
  6251. return sre;
  6252. }
  6253. catch (Exception ex)
  6254. {
  6255. throw ex;
  6256. }
  6257. finally
  6258. {
  6259. if (conn != null &&
  6260. conn.ConnState == ConnectionState.Open)
  6261. {
  6262. conn.Close();
  6263. }
  6264. }
  6265. }
  6266. /// <summary>
  6267. /// 获取RPT030103_1画面(出窑数量汇总表)的明细信息查询sql
  6268. /// </summary>
  6269. /// <returns>sql</returns>
  6270. private static string GetRPT030103ISQL(SUserInfo user, RPT030103_SE se, ref List<OracleParameter> parameters)
  6271. {
  6272. string selSql = "";
  6273. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6274. parameters.Add(new OracleParameter(":rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  6275. selSql = selSql +
  6276. "select distinct " +
  6277. "TP_PM_ProductionData.Barcode, " +
  6278. //"TP_PM_ProductionData.UserCode, " +
  6279. (se.DisPUserCode ? " TP_PM_ProductionData.userid, TP_PM_ProductionData.usercode, cu.usercode Cusercode, \n" : " null userid, null usercode, null Cusercode, \n") +
  6280. "pcp.ProcedureName, " +
  6281. "tp_mst_goodstype.goodstypename, " +
  6282. "TP_PM_ProductionData.Goodscode, " +
  6283. "TP_PM_ProductionData.GroutingUserCode, " +
  6284. "TP_PM_ProductionData.GroutingLineCode, " +
  6285. "TP_PM_ProductionData.GroutingMouldCode, " +
  6286. // 多次干补 重复条码
  6287. //"TP_PM_ProductionData.Createtime OverDate, " +
  6288. "temp.Kilnid, " +
  6289. "temp.Kilncode, " +
  6290. "temp.Kilncarcode, " +
  6291. "temp.Createtime, " +
  6292. "temp.DELIVERTIME DDate, " +
  6293. "temp.GROUTINGDATE GDate, " +
  6294. "replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName " +
  6295. "from TP_PM_ProductionData " +
  6296. "inner join tp_mst_goods on tp_mst_goods.goodsid=TP_PM_ProductionData.Goodsid " +
  6297. "inner join tp_mst_goodstype on tp_mst_goodstype.goodstypeid=tp_mst_goods.goodstypeid " +
  6298. "inner join TP_MST_RptTProcedure on TP_MST_RptTProcedure.Procedureid=TP_PM_ProductionData.Procedureid " +
  6299. "inner join TP_MST_RptProcedure on TP_MST_RptProcedure.Rptprocedureid=TP_MST_RptTProcedure.Rptprocedureid " +
  6300. " inner join tp_pc_procedure pcp on pcp.procedureid=TP_PM_ProductionData.Procedureid " +
  6301. "left join TP_MST_logo on TP_PM_ProductionData.logoid=TP_MST_logo.logoid " +
  6302. "left join TP_MST_User cu on TP_PM_ProductionData.createuserid=cu.userid " +
  6303. "inner join " +
  6304. "( " +
  6305. " select " +
  6306. " TP_PM_ProductionData.Barcode, " +
  6307. " TP_PM_ProductionData.Kilncode, " +
  6308. " TP_PM_ProductionData.Kilncarcode, " +
  6309. " TP_PM_ProductionData.Createtime, " +
  6310. " TP_PM_ProductionData.KilnID " +
  6311. " ,gdd.DELIVERTIME " +
  6312. " ,TP_PM_ProductionData.GROUTINGDATE " +
  6313. " ,TP_PM_ProductionData.KilnCarID " +
  6314. " from TP_PM_ProductionData " +
  6315. " inner join TP_MST_RptSProcedure on TP_MST_RptSProcedure.Procedureid=TP_PM_ProductionData.Procedureid " +
  6316. //if (se.DTimeStart.HasValue || se.DTimeEnd.HasValue)
  6317. //{
  6318. // selSql += " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=TP_PM_ProductionData.groutingdailydetailid ";
  6319. //}
  6320. " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=TP_PM_ProductionData.groutingdailydetailid " +
  6321. // selSql +=
  6322. " where TP_PM_ProductionData.Accountid=:AccountID " +
  6323. " and TP_PM_ProductionData.Valueflag='1' " +
  6324. // 数据重复 modify by chenxy begin
  6325. " and TP_MST_RptSProcedure.Rptprocedureid=:rptProcedureId " +
  6326. // 数据重复 modify by chenxy end
  6327. " and TP_MST_RptSProcedure.Procedureid=:rptSprocedureId ";
  6328. if (se.OutTimeStart.HasValue)
  6329. {
  6330. selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:OutTimeStart ";
  6331. parameters.Add(new OracleParameter(":OutTimeStart", OracleDbType.Date, se.OutTimeStart.Value, ParameterDirection.Input));
  6332. }
  6333. if (se.OutTimeEnd.HasValue)
  6334. {
  6335. selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :OutTimeEnd ";
  6336. parameters.Add(new OracleParameter(":OutTimeEnd", OracleDbType.Date, se.OutTimeEnd.Value, ParameterDirection.Input));
  6337. }
  6338. if (se.GTimeStart.HasValue)
  6339. {
  6340. selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE >=:GTimeStart ";
  6341. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  6342. }
  6343. if (se.GTimeEnd.HasValue)
  6344. {
  6345. selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE <= :GTimeEnd ";
  6346. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  6347. }
  6348. if (se.DTimeStart.HasValue)
  6349. {
  6350. selSql = selSql + " AND gdd.DELIVERTIME >=:DTimeStart ";
  6351. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
  6352. }
  6353. if (se.DTimeEnd.HasValue)
  6354. {
  6355. selSql = selSql + " AND gdd.DELIVERTIME <= :DTimeEnd ";
  6356. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
  6357. }
  6358. if (se.Specialrepairflag)
  6359. {
  6360. selSql = selSql +
  6361. ") temp " +
  6362. "on TP_PM_ProductionData.Barcode=temp.barcode " +
  6363. " " +
  6364. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
  6365. " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
  6366. " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
  6367. " FROM TP_PM_ProductionData pp\n" +
  6368. " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
  6369. " AND pp.createtime < temp.createtime\n" +
  6370. " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
  6371. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
  6372. "where " + // 公坯、干补不算交坯工序的质量。
  6373. //" 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" +
  6374. // modify wangx 2015-12-3
  6375. " ((TP_PM_ProductionData.modeltype <> 5) or (TP_PM_ProductionData.modeltype = 5 and TP_PM_ProductionData.SpecialRepairFlag = '0')) \n" +
  6376. " and TP_PM_ProductionData.Valueflag='1' " +
  6377. " and TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId ";
  6378. parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  6379. }
  6380. else
  6381. {
  6382. selSql = selSql +
  6383. ") temp " +
  6384. "on TP_PM_ProductionData.Barcode=temp.barcode " +
  6385. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
  6386. " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
  6387. " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
  6388. " FROM TP_PM_ProductionData pp\n" +
  6389. " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
  6390. " AND pp.createtime < temp.createtime\n" +
  6391. " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
  6392. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
  6393. " where TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId " +
  6394. " and TP_PM_ProductionData.Valueflag='1' ";
  6395. parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  6396. }
  6397. if (se.CreateTimeStart.HasValue)
  6398. {
  6399. selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:CreateTimeStart ";
  6400. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6401. }
  6402. if (se.CreateTimeEnd.HasValue)
  6403. {
  6404. selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :CreateTimeEnd ";
  6405. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6406. }
  6407. if (!string.IsNullOrEmpty(se.GoodsIDS))
  6408. {
  6409. selSql = selSql + " AND instr(',' || :GoodsIDS ||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  6410. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  6411. }
  6412. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  6413. {
  6414. //selSql = selSql + " AND instr(',' || :GoodsTypeIDS ||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1 ";
  6415. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1 ";
  6416. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  6417. }
  6418. if (se.ProductionLineID.HasValue)
  6419. {
  6420. selSql = selSql + " AND instr(',' || :productionLineId ||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  6421. parameters.Add(new OracleParameter(":productionLineId", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  6422. }
  6423. if (!string.IsNullOrEmpty(se.RptTProcedureIDS))
  6424. {
  6425. selSql = selSql + " AND instr(',' || :rptTprocedureIDS ||',',','||TP_MST_RptTProcedure.ProcedureId||',')>0 ";
  6426. parameters.Add(new OracleParameter(":rptTprocedureIDS", OracleDbType.NVarchar2, se.RptTProcedureIDS, ParameterDirection.Input));
  6427. }
  6428. if (!string.IsNullOrEmpty(se.UserIDS))
  6429. {
  6430. selSql = selSql + " AND instr(',' || :UserIDS ||',',','||TP_PM_ProductionData.Userid||',')>0 ";
  6431. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6432. }
  6433. if (se.KilnID.HasValue)
  6434. {
  6435. selSql = selSql + " AND temp.KilnID=:KilnID ";
  6436. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6437. }
  6438. if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
  6439. {
  6440. selSql = selSql + " AND instr(TP_PM_ProductionData.GroutingUserCode, :GroutingUserCode) > 0";
  6441. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  6442. }
  6443. selSql = selSql + " order by pcp.Procedurename,temp.Kilncode,temp.Kilncarcode, " +
  6444. (se.DisPUserCode ? " TP_PM_ProductionData.usercode, \n" : "") +
  6445. " TP_PM_ProductionData.Goodscode,TP_PM_ProductionData.Barcode ";
  6446. return selSql;
  6447. }
  6448. /// <summary>
  6449. /// 取得RPT030104_1画面(窑车产量汇总表)的窑炉汇总信息查询数据
  6450. /// </summary>
  6451. /// <param name="user">登录用户信息</param>
  6452. /// <param name="se">查询条件</param>
  6453. /// <returns>查询结果</returns>
  6454. public static ServiceResultEntity GetRPT030104SData(SUserInfo user, RPT030104_SE se)
  6455. {
  6456. IDBConnection conn = null;
  6457. try
  6458. {
  6459. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6460. List<OracleParameter> parameters = new List<OracleParameter>();
  6461. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030104SSQL(user, se, ref parameters));
  6462. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  6463. ServiceResultEntity sre = new ServiceResultEntity();
  6464. if (data == null || data.Rows.Count == 0)
  6465. {
  6466. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6467. return sre;
  6468. }
  6469. sre.Data = new DataSet();
  6470. sre.Data.Tables.Add(data);
  6471. return sre;
  6472. }
  6473. catch (Exception ex)
  6474. {
  6475. throw ex;
  6476. }
  6477. finally
  6478. {
  6479. if (conn != null &&
  6480. conn.ConnState == ConnectionState.Open)
  6481. {
  6482. conn.Close();
  6483. }
  6484. }
  6485. }
  6486. /// <summary>
  6487. /// 获取RPT030104_1画面(窑车产量汇总表)的窑炉汇总查询sql
  6488. /// </summary>
  6489. /// <returns>sql</returns>
  6490. private static string GetRPT030104SSQL(SUserInfo user, RPT030104_SE se, ref List<OracleParameter> parameters)
  6491. {
  6492. string selSql = "";
  6493. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6494. parameters.Add(new OracleParameter(":ProcedureModelTypeID", OracleDbType.Int32, se.ProcedureModelTypeID, ParameterDirection.Input));
  6495. selSql = "select " +
  6496. "decode(Createtime,'小计',decode(Proceduremodeltypename,'总计','总计','--'),Proceduremodeltypename) Proceduremodeltypename, " +
  6497. "decode(usercode,'合计',decode(Kilncode,'--','--','合计'),decode(createtime,'小计','--',Kilncode)) Kilncode, " +
  6498. "decode(Createtime,'小计',decode(usercode,'合计','--','小计'),Usercode) Usercode, " +
  6499. "decode(Kilncarcode,'--','--',Createtime) Createtime, " +
  6500. "Kilncarcode, " +
  6501. "Remarks, " +
  6502. "KilnCarCount " +
  6503. " from " +
  6504. " ( " +
  6505. " select " +
  6506. " decode(grouping(TP_SYS_ProcedureModelType.Proceduremodeltypename),1,'总计',TP_SYS_ProcedureModelType.Proceduremodeltypename) Proceduremodeltypename, " +
  6507. " decode(grouping(TP_MST_Kiln.Kilncode),1,'--',TP_MST_Kiln.Kilncode) Kilncode, " +
  6508. " decode(grouping(TP_PM_KilnCarData.Usercode),1,'合计',TP_PM_KilnCarData.Usercode) Usercode, " +
  6509. " decode(grouping(TP_MST_KilnCar.Kilncarcode),1,'--',TP_MST_KilnCar.Kilncarcode) Kilncarcode, " +
  6510. " decode(grouping(TP_PM_KilnCarData.Remarks),1,'--',TP_PM_KilnCarData.Remarks) Remarks, " +
  6511. " decode(grouping(TP_PM_KilnCarData.Createtime),1,'小计',TP_PM_KilnCarData.Createtime) Createtime, " +
  6512. " count(TP_PM_KilnCarData.Kilncarid) as KilnCarCount " +
  6513. " from " +
  6514. " ( " +
  6515. " select " +
  6516. " to_char(TP_PM_KilnCarData.Createtime,'yyyy-mm-dd hh24:mi') Createtime, " +
  6517. " TP_PM_KilnCarData.Modeltype, " +
  6518. " TP_PM_KilnCarData.Kilncarid, " +
  6519. " TP_PM_KilnCarData.Kilnid, " +
  6520. " TP_PM_KilnCarData.Userid, " +
  6521. " TP_PM_KilnCarData.Remarks, " +
  6522. " TP_PM_KilnCarData.Accountid, " +
  6523. " TP_PM_KilnCarData.Usercode " +
  6524. " from TP_PM_KilnCarData " +
  6525. " left join TP_MST_KilnCar kc on kc.kilncarid = TP_PM_KilnCarData.Kilncarid " +
  6526. " where TP_PM_KilnCarData.Accountid=:AccountID " +
  6527. " and TP_PM_KilnCarData.Valueflag=1 " +
  6528. " and TP_PM_KilnCarData.Modeltype=:ProcedureModelTypeID ";
  6529. if (se.KilnID.HasValue)
  6530. {
  6531. selSql = selSql + " AND TP_PM_KilnCarData.KilnID=:KilnID ";
  6532. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6533. }
  6534. //if (se.KilnCarID.HasValue)
  6535. //{
  6536. // selSql = selSql + " AND TP_PM_KilnCarData.KilnCarID=:KilnCarID";
  6537. // parameters.Add(new OracleParameter(":KilnCarID", OracleDbType.Int32, se.KilnCarID, ParameterDirection.Input));
  6538. //}
  6539. if (!string.IsNullOrEmpty(se.KilnCarCode))
  6540. {
  6541. selSql = selSql + " AND instr(kc.KilnCarCode, :KilnCarCode ) > 0";
  6542. parameters.Add(new OracleParameter(":KilnCarCode", OracleDbType.NVarchar2, se.KilnCarCode, ParameterDirection.Input));
  6543. }
  6544. if (se.KilnCarNumBegin.HasValue && se.KilnCarNumEnd.HasValue && se.KilnCarNumBegin.Value > se.KilnCarNumEnd.Value)
  6545. {
  6546. selSql = selSql + " AND (kc.KilnCarNum >= :KilnCarNumBegin or kc.KilnCarNum <= :KilnCarNumEnd)";
  6547. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6548. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6549. }
  6550. else
  6551. {
  6552. if (se.KilnCarNumBegin.HasValue)
  6553. {
  6554. selSql = selSql + " AND kc.KilnCarNum >= :KilnCarNumBegin ";
  6555. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6556. }
  6557. if (se.KilnCarNumEnd.HasValue)
  6558. {
  6559. selSql = selSql + " AND kc.KilnCarNum <= :KilnCarNumEnd ";
  6560. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6561. }
  6562. }
  6563. if (se.CreateTimeStart.HasValue)
  6564. {
  6565. selSql = selSql + " AND TP_PM_KilnCarData.CreateTime>=:CreateTimeStart ";
  6566. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6567. }
  6568. if (se.CreateTimeEnd.HasValue)
  6569. {
  6570. selSql = selSql + " AND TP_PM_KilnCarData.CreateTime<= :CreateTimeEnd";
  6571. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6572. }
  6573. selSql = selSql +
  6574. " ) TP_PM_KilnCarData " +
  6575. "inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.Proceduremodeltypeid=TP_PM_KilnCarData.Modeltype " +
  6576. "inner join TP_MST_KilnCar on TP_MST_KilnCar.Kilncarid=TP_PM_KilnCarData.Kilncarid " +
  6577. "inner join TP_MST_Kiln on TP_MST_Kiln.Kilnid=TP_PM_KilnCarData.Kilnid " +
  6578. "where 1=1";
  6579. if (!string.IsNullOrEmpty(se.UserIDS))
  6580. {
  6581. selSql = selSql + " AND instr(','||:UserIDS||',',','||TP_PM_KilnCarData.UserID||',')>0";
  6582. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6583. }
  6584. selSql = selSql + "group by rollup( " +
  6585. " TP_SYS_ProcedureModelType.Proceduremodeltypename, " +
  6586. " TP_MST_Kiln.Kilncode, " +
  6587. " TP_PM_KilnCarData.Usercode, " +
  6588. " TP_PM_KilnCarData.Createtime, " +
  6589. " TP_PM_KilnCarData.Remarks, " +
  6590. " TP_MST_KilnCar.Kilncarcode " +
  6591. " ) " +
  6592. " ) temp " +
  6593. " where (Kilncarcode !='--' ) " +
  6594. " or " +
  6595. " (Remarks='--' and Usercode='合计' and kilncode!='--') " +
  6596. " or (Remarks='--' and Proceduremodeltypename='总计') " +
  6597. " or (Remarks='--' and createtime='小计' and kilncode!='--')";
  6598. return selSql;
  6599. }
  6600. /// <summary>
  6601. /// 取得RPT030104_1画面(窑车产量汇总表)的窑车产量汇总信息查询数据
  6602. /// </summary>
  6603. /// <param name="user">登录用户信息</param>
  6604. /// <param name="se">查询条件</param>
  6605. /// <returns>查询结果</returns>
  6606. public static ServiceResultEntity GetRPT030104IData(SUserInfo user, RPT030104_SE se)
  6607. {
  6608. IDBConnection conn = null;
  6609. try
  6610. {
  6611. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6612. List<OracleParameter> parameters = new List<OracleParameter>();
  6613. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030104ISQL(user, se, ref parameters));
  6614. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  6615. ServiceResultEntity sre = new ServiceResultEntity();
  6616. if (data == null || data.Rows.Count == 0)
  6617. {
  6618. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6619. return sre;
  6620. }
  6621. sre.Data = new DataSet();
  6622. sre.Data.Tables.Add(data);
  6623. return sre;
  6624. }
  6625. catch (Exception ex)
  6626. {
  6627. throw ex;
  6628. }
  6629. finally
  6630. {
  6631. if (conn != null &&
  6632. conn.ConnState == ConnectionState.Open)
  6633. {
  6634. conn.Close();
  6635. }
  6636. }
  6637. }
  6638. /// <summary>
  6639. /// 获取查询sql
  6640. /// </summary>
  6641. /// <returns>sql</returns>
  6642. private static string GetRPT030104ISQL(SUserInfo user, RPT030104_SE se, ref List<OracleParameter> parameters)
  6643. {
  6644. string selSql = "";
  6645. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6646. parameters.Add(new OracleParameter(":ProcedureModelTypeID", OracleDbType.Int32, se.ProcedureModelTypeID, ParameterDirection.Input));
  6647. selSql = selSql +
  6648. "SELECT " +
  6649. "decode(createtime,'小计',decode(proceduremodeltypename,'总计','总计','--'),proceduremodeltypename) proceduremodeltypename, " +
  6650. "decode(createtime,'小计','--',kilncode) kilncode, " +
  6651. "decode(kilncarcode,'合计',decode(usercode,'--','--','合计'),decode(createtime,'小计','--',usercode)) usercode, " +
  6652. "decode(createtime,'小计',decode(kilncarcode,'合计','--','小计'),kilncarcode) kilncarcode, " +
  6653. "decode(goodscode,'--','--',createtime) createtime, " +
  6654. "GOODSTYPENAME, " +
  6655. "Goodscode, " +
  6656. "GOODSSPECIFICATION, " +
  6657. "GoodsCount " +
  6658. "from " +
  6659. "( " +
  6660. " SELECT " +
  6661. " decode(grouping(TP_SYS_ProcedureModelType.Proceduremodeltypename),1,'总计',TP_SYS_ProcedureModelType.Proceduremodeltypename) Proceduremodeltypename, " +
  6662. " decode(grouping(TP_PM_ProductionData.Kilncode),1,'--',TP_PM_ProductionData.Kilncode) Kilncode, " +
  6663. " decode(grouping(TP_PM_ProductionData.Usercode),1,'--',TP_PM_ProductionData.Usercode) Usercode, " +
  6664. " decode(grouping(TP_MST_KilnCar.Kilncarcode),1,'合计',TP_MST_KilnCar.Kilncarcode) Kilncarcode, " +
  6665. " decode(grouping(TP_PM_ProductionData.CreateTime),1,'小计',TP_PM_ProductionData.CreateTime) CreateTime, " +
  6666. " decode(grouping(TP_MST_Goods.Goodscode),1,'--',TP_MST_Goods.Goodscode) Goodscode, " +
  6667. " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  6668. " decode(grouping(TP_MST_GOODSTYPE.GOODSTYPENAME),1,'--',TP_MST_GOODSTYPE.GOODSTYPENAME) GOODSTYPENAME, " +
  6669. " count(TP_MST_Goods.Goodscode) as GoodsCount " +
  6670. " from " +
  6671. " ( " +
  6672. " SELECT TP_PM_ProductionData.Modeltype, " +
  6673. " TP_PM_ProductionData.Goodsid, " +
  6674. " TP_PM_ProductionData.KilnCarID, " +
  6675. " TP_PM_ProductionData.Kilncode, " +
  6676. //" TP_PM_ProductionData.Usercode, " +
  6677. " kcd.Usercode, " +
  6678. " to_char(kcd.CreateTime,'yyyy-mm-dd hh24:mi') CreateTime " +
  6679. " from TP_PM_ProductionData " +
  6680. " left join TP_PM_KilnCarData kcd on kcd.KilnCarBatchNo = TP_PM_ProductionData.KilnCarBatchNo and kcd.ProcedureID = TP_PM_ProductionData.ProcedureID " +
  6681. " where " +
  6682. " TP_PM_ProductionData.Accountid=:AccountID " +
  6683. " and TP_PM_ProductionData.Valueflag=1 " +
  6684. " and TP_PM_ProductionData.Modeltype= :ProcedureModelTypeID ";
  6685. if (se.KilnID.HasValue)
  6686. {
  6687. selSql = selSql + " AND TP_PM_ProductionData.KilnID=:KilnID ";
  6688. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6689. }
  6690. //if (se.KilnCarID.HasValue)
  6691. //{
  6692. // selSql = selSql + " AND TP_PM_ProductionData.KilnCarID=:KilnCarID";
  6693. // parameters.Add(new OracleParameter(":KilnCarID", OracleDbType.Int32, se.KilnCarID, ParameterDirection.Input));
  6694. //}
  6695. if (!string.IsNullOrEmpty(se.GoodsIDS))
  6696. {
  6697. selSql = selSql + " AND instr(','||:goodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  6698. parameters.Add(new OracleParameter(":goodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  6699. }
  6700. if (!string.IsNullOrEmpty(se.UserIDS))
  6701. {
  6702. //selSql = selSql + " AND instr(','||:UserIDS||',',','||TP_PM_ProductionData.UserID||',')>0 ";
  6703. selSql = selSql + " AND instr(','||:UserIDS||',',','||kcd.UserID||',')>0 ";
  6704. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6705. }
  6706. if (se.CreateTimeStart.HasValue)
  6707. {
  6708. //selSql = selSql + " AND TP_PM_ProductionData.CreateTime>= :CreateTimeStart ";
  6709. selSql = selSql + " AND kcd.CreateTime>= :CreateTimeStart ";
  6710. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6711. }
  6712. if (se.CreateTimeEnd.HasValue)
  6713. {
  6714. //selSql = selSql + " AND TP_PM_ProductionData.CreateTime<= :CreateTimeEnd ";
  6715. selSql = selSql + " AND kcd.CreateTime<= :CreateTimeEnd ";
  6716. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6717. }
  6718. selSql = selSql +
  6719. " ) TP_PM_ProductionData " +
  6720. " inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.Proceduremodeltypeid=TP_PM_ProductionData.Modeltype " +
  6721. " inner join TP_MST_Goods on TP_MST_Goods.Goodsid=TP_PM_ProductionData.Goodsid " +
  6722. " inner join TP_MST_GOODSTYPE on TP_MST_GOODSTYPE.GOODSTYPEID=TP_MST_Goods.Goodstypeid " +
  6723. " inner join TP_MST_KilnCar on TP_MST_KilnCar.Kilncarid=TP_PM_ProductionData.KilnCarID " +
  6724. " where 1=1 ";
  6725. if (!string.IsNullOrEmpty(se.KilnCarCode))
  6726. {
  6727. selSql = selSql + " AND instr(TP_MST_KilnCar.KilnCarCode, :KilnCarCode ) > 0";
  6728. parameters.Add(new OracleParameter(":KilnCarCode", OracleDbType.NVarchar2, se.KilnCarCode, ParameterDirection.Input));
  6729. }
  6730. if (se.KilnCarNumBegin.HasValue && se.KilnCarNumEnd.HasValue && se.KilnCarNumBegin.Value > se.KilnCarNumEnd.Value)
  6731. {
  6732. selSql = selSql + " AND (TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin or TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd)";
  6733. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6734. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6735. }
  6736. else
  6737. {
  6738. if (se.KilnCarNumBegin.HasValue)
  6739. {
  6740. selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin ";
  6741. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6742. }
  6743. if (se.KilnCarNumEnd.HasValue)
  6744. {
  6745. selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd ";
  6746. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6747. }
  6748. }
  6749. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  6750. {
  6751. //selSql = selSql + " AND instr(','||:goodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1";
  6752. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:goodsTypeIDS)=1";
  6753. parameters.Add(new OracleParameter(":goodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  6754. }
  6755. selSql = selSql +
  6756. " group by rollup( " +
  6757. " TP_SYS_ProcedureModelType.Proceduremodeltypename, " +
  6758. " TP_PM_ProductionData.Kilncode, " +
  6759. " TP_PM_ProductionData.Usercode, " +
  6760. " TP_MST_KilnCar.Kilncarcode, " +
  6761. " TP_PM_ProductionData.CreateTime, " +
  6762. " TP_MST_GOODSTYPE.GOODSTYPENAME, " +
  6763. " TP_MST_Goods.GOODSSPECIFICATION, " +
  6764. " TP_MST_Goods.Goodscode " +
  6765. " ) " +
  6766. ") temp " +
  6767. "where 1=1 and " +
  6768. " (Goodscode !='--' ) or " +
  6769. " (Goodscode='--' and Usercode='合计' and kilncode!='--') or " +
  6770. " (Goodscode='--' and Proceduremodeltypename='总计') or " +
  6771. " (Goodscode='--' and createtime='小计' and usercode!='--')";
  6772. return selSql;
  6773. }
  6774. /// <summary>
  6775. /// 取得RPT030104_1画面(窑车产量汇总表)的窑车产量明细信息查询数据
  6776. /// </summary>
  6777. /// <param name="user">登录用户信息</param>
  6778. /// <param name="se">查询条件</param>
  6779. /// <returns>查询结果</returns>
  6780. public static ServiceResultEntity GetRPT030104UData(SUserInfo user, RPT030104_SE se)
  6781. {
  6782. IDBConnection conn = null;
  6783. try
  6784. {
  6785. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6786. List<OracleParameter> parameters = new List<OracleParameter>();
  6787. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030104USQL(user, se, ref parameters));
  6788. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  6789. ServiceResultEntity sre = new ServiceResultEntity();
  6790. if (data == null || data.Rows.Count == 0)
  6791. {
  6792. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6793. return sre;
  6794. }
  6795. sre.Data = new DataSet();
  6796. sre.Data.Tables.Add(data);
  6797. return sre;
  6798. }
  6799. catch (Exception ex)
  6800. {
  6801. throw ex;
  6802. }
  6803. finally
  6804. {
  6805. if (conn != null &&
  6806. conn.ConnState == ConnectionState.Open)
  6807. {
  6808. conn.Close();
  6809. }
  6810. }
  6811. }
  6812. /// <summary>
  6813. /// 获取RPT030104_1画面(窑车产量汇总表)的窑车产量明细查询sql
  6814. /// </summary>
  6815. /// <returns>sql</returns>
  6816. private static string GetRPT030104USQL(SUserInfo user, RPT030104_SE se, ref List<OracleParameter> parameters)
  6817. {
  6818. string selSql = "";
  6819. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6820. parameters.Add(new OracleParameter(":ProcedureModelTypeID", OracleDbType.Int32, se.ProcedureModelTypeID, ParameterDirection.Input));
  6821. selSql = selSql +
  6822. "select " +
  6823. "decode(createtime,'小计',decode(proceduremodeltypename,'总计','总计','--'),proceduremodeltypename) proceduremodeltypename, " +
  6824. "decode(createtime,'小计','--',kilncode) kilncode, " +
  6825. "decode(kilncarcode,'合计',decode(usercode,'--','--','合计'),decode(createtime,'小计','--',usercode)) usercode, " +
  6826. "decode(createtime,'小计',decode(kilncarcode,'合计','--','小计'),kilncarcode) kilncarcode, " +
  6827. "decode(goodscode,'--','--',createtime) createtime, " +
  6828. "GOODSTYPENAME, " +
  6829. "Goodscode, " +
  6830. "GOODSSPECIFICATION, " +
  6831. "Barcode, " +
  6832. "BarcodeCount, " +
  6833. "LogoCodeName " +
  6834. "from " +
  6835. " ( " +
  6836. " select " +
  6837. " decode(grouping(TP_SYS_ProcedureModelType.Proceduremodeltypename),1,'总计',TP_SYS_ProcedureModelType.Proceduremodeltypename) Proceduremodeltypename, " +
  6838. " decode(grouping(TP_PM_ProductionData.Kilncode),1,'--',TP_PM_ProductionData.Kilncode) Kilncode, " +
  6839. " decode(grouping(TP_PM_ProductionData.Usercode),1,'--',TP_PM_ProductionData.Usercode) Usercode, " +
  6840. " decode(grouping(TP_MST_KilnCar.Kilncarcode),1,'合计',TP_MST_KilnCar.Kilncarcode) Kilncarcode, " +
  6841. " decode(grouping(TP_PM_ProductionData.CreateTime),1,'小计',TP_PM_ProductionData.CreateTime) CreateTime, " +
  6842. " decode(grouping(TP_MST_GOODSTYPE.GOODSTYPENAME),1,'--',TP_MST_GOODSTYPE.GOODSTYPENAME) GOODSTYPENAME, " +
  6843. " decode(grouping(TP_MST_Goods.Goodscode),1,'--',TP_MST_Goods.Goodscode) Goodscode, " +
  6844. " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  6845. " decode(grouping(TP_PM_ProductionData.Barcode),1,'--',TP_PM_ProductionData.Barcode) Barcode, " +
  6846. " decode(grouping(TP_PM_ProductionData.LogoCodeName),1,'--',TP_PM_ProductionData.LogoCodeName) LogoCodeName, " +
  6847. " count(TP_PM_ProductionData.Barcode) as BarcodeCount " +
  6848. " from " +
  6849. " ( " +
  6850. " select TP_PM_ProductionData.logoid," +
  6851. " TP_PM_ProductionData.Modeltype, " +
  6852. " TP_PM_ProductionData.Goodsid, " +
  6853. " TP_PM_ProductionData.KilnCarID, " +
  6854. " TP_PM_ProductionData.Kilncode, " +
  6855. " TP_PM_ProductionData.Barcode, " +
  6856. " TP_PM_ProductionData.Usercode, " +
  6857. " replace((Logoname||'['||Logocode||']'),'[]','') as LogoCodeName, " +
  6858. " to_char(TP_PM_ProductionData.CreateTime,'yyyy-mm-dd hh24:mi') CreateTime " +
  6859. " from TP_PM_ProductionData inner join TP_MST_Logo on TP_PM_ProductionData.logoid=TP_MST_Logo.logoid" +
  6860. " left join TP_PM_KilnCarData kcd on kcd.KilnCarBatchNo = TP_PM_ProductionData.KilnCarBatchNo and kcd.ProcedureID = TP_PM_ProductionData.ProcedureID " +
  6861. " where " +
  6862. " TP_PM_ProductionData.Accountid=:AccountID " +
  6863. " and TP_PM_ProductionData.Valueflag=1 " +
  6864. " and TP_PM_ProductionData.Modeltype=:ProcedureModelTypeID ";
  6865. if (se.KilnID.HasValue)
  6866. {
  6867. selSql = selSql + " AND TP_PM_ProductionData.KilnID=:KilnID ";
  6868. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6869. }
  6870. //if (se.KilnCarID.HasValue)
  6871. //{
  6872. // selSql = selSql + " AND TP_PM_ProductionData.KilnCarID=:KilnCarID ";
  6873. // parameters.Add(new OracleParameter(":KilnCarID", OracleDbType.Int32, se.KilnCarID, ParameterDirection.Input));
  6874. //}
  6875. if (!string.IsNullOrEmpty(se.GoodsIDS))
  6876. {
  6877. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  6878. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  6879. }
  6880. if (!string.IsNullOrEmpty(se.UserIDS))
  6881. {
  6882. selSql = selSql + " AND instr(','||:UserIDS||',',','||kcd.UserID||',')>0 ";
  6883. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6884. }
  6885. if (se.CreateTimeStart.HasValue)
  6886. {
  6887. selSql = selSql + " AND kcd.CreateTime>= :CreateTimeStart ";
  6888. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6889. }
  6890. if (se.CreateTimeEnd.HasValue)
  6891. {
  6892. selSql = selSql + " AND kcd.CreateTime<= :CreateTimeEnd ";
  6893. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6894. }
  6895. selSql = selSql +
  6896. " ) TP_PM_ProductionData " +
  6897. " inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.Proceduremodeltypeid=TP_PM_ProductionData.Modeltype " +
  6898. " inner join TP_MST_Goods on TP_MST_Goods.Goodsid=TP_PM_ProductionData.Goodsid " +
  6899. " inner join TP_MST_GOODSTYPE on TP_MST_GOODSTYPE.GOODSTYPEID=TP_MST_Goods.Goodstypeid " +
  6900. " inner join TP_MST_KilnCar on TP_MST_KilnCar.Kilncarid=TP_PM_ProductionData.KilnCarID " +
  6901. " where 1=1";
  6902. if (!string.IsNullOrEmpty(se.KilnCarCode))
  6903. {
  6904. selSql = selSql + " AND instr(TP_MST_KilnCar.KilnCarCode, :KilnCarCode ) > 0";
  6905. parameters.Add(new OracleParameter(":KilnCarCode", OracleDbType.NVarchar2, se.KilnCarCode, ParameterDirection.Input));
  6906. }
  6907. if (se.KilnCarNumBegin.HasValue && se.KilnCarNumEnd.HasValue && se.KilnCarNumBegin.Value > se.KilnCarNumEnd.Value)
  6908. {
  6909. selSql = selSql + " AND (TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin or TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd)";
  6910. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6911. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6912. }
  6913. else
  6914. {
  6915. if (se.KilnCarNumBegin.HasValue)
  6916. {
  6917. selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin ";
  6918. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6919. }
  6920. if (se.KilnCarNumEnd.HasValue)
  6921. {
  6922. selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd ";
  6923. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6924. }
  6925. }
  6926. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  6927. {
  6928. //selSql = selSql + " AND instr(','||:goodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1 ";
  6929. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:goodsTypeIDS)=1 ";
  6930. parameters.Add(new OracleParameter(":goodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  6931. }
  6932. selSql = selSql +
  6933. " group by rollup( " +
  6934. " TP_SYS_ProcedureModelType.Proceduremodeltypename, " +
  6935. " TP_PM_ProductionData.Kilncode, " +
  6936. " TP_PM_ProductionData.Usercode, " +
  6937. " TP_MST_KilnCar.Kilncarcode, " +
  6938. " TP_PM_ProductionData.CreateTime, " +
  6939. " TP_MST_GOODSTYPE.GOODSTYPENAME, " +
  6940. " TP_MST_Goods.Goodscode, " +
  6941. " TP_MST_Goods.GOODSSPECIFICATION, " +
  6942. " TP_PM_ProductionData.Barcode, " +
  6943. " TP_PM_ProductionData.LogoCodeName " +
  6944. " ) " +
  6945. " ) temp " +
  6946. "where 1=1 and " +
  6947. "(Barcode !='--' and LogoCodeName!='--') or " +
  6948. "(Barcode='--' and Usercode='合计' and kilncode!='--') or " +
  6949. "(Barcode='--' and Proceduremodeltypename='总计' ) or " +
  6950. "(Barcode='--' and createtime='小计' and temp.usercode!='--')";
  6951. return selSql;
  6952. }
  6953. #region 工序交接数量汇总表
  6954. /// <summary>
  6955. /// 取得RPT030107画面(工序交接数量汇总表)的汇总信息查询数据
  6956. /// </summary>
  6957. /// <param name="user">登录用户信息</param>
  6958. /// <param name="se">查询条件</param>
  6959. /// <returns>查询结果</returns>
  6960. public static ServiceResultEntity GetRPT030107SData(SUserInfo user, RPT030107_SE se)
  6961. {
  6962. IDBConnection conn = null;
  6963. try
  6964. {
  6965. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6966. List<OracleParameter> parameters = new List<OracleParameter>();
  6967. string sql = ReportModuleLogic.GetRPT030107SSQL(user, se, ref parameters);
  6968. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  6969. ServiceResultEntity sre = new ServiceResultEntity();
  6970. if (data == null || data.Rows.Count == 0)
  6971. {
  6972. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6973. return sre;
  6974. }
  6975. sre.Data = new DataSet();
  6976. sre.Data.Tables.Add(data);
  6977. return sre;
  6978. }
  6979. catch (Exception ex)
  6980. {
  6981. throw ex;
  6982. }
  6983. finally
  6984. {
  6985. if (conn != null &&
  6986. conn.ConnState == ConnectionState.Open)
  6987. {
  6988. conn.Close();
  6989. }
  6990. }
  6991. }
  6992. /// <summary>
  6993. /// 获取RPT030107画面(工序交接数量汇总表)的汇总信息查询sql
  6994. /// </summary>
  6995. /// <returns>sql</returns>
  6996. private static string GetRPT030107SSQL(SUserInfo user, RPT030107_SE se, ref List<OracleParameter> parameters)
  6997. {
  6998. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6999. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  7000. string sqlString =
  7001. "SELECT p.procedureid\n" +
  7002. " ,decode(gid,\n" +
  7003. " 7,\n" +
  7004. " '总计',\n" +
  7005. " 3,\n" +
  7006. " '合计【' || p.procedurename || '】',\n" +
  7007. " 1,\n" +
  7008. " '--',\n" +
  7009. " p.procedurename) procedurename\n" +
  7010. " ,decode(gid,\n" +
  7011. " 7,\n" +
  7012. " '--',\n" +
  7013. " 3,\n" +
  7014. " '--',\n" +
  7015. " 1,\n" +
  7016. " '小计【' || p.goodstypename2 || '】',\n" +
  7017. " p.goodstypename2) goodstypename2\n" +
  7018. " ,p.goodstypecode2 \n" +
  7019. " ,decode(gid, 0, p.userid, '--') userid\n" +
  7020. " ,decode(gid, 0, p.usercode, '--') usercode\n" +
  7021. " ,decode(gid, 0, p.goodsid, '--') goodsid\n" +
  7022. " ,decode(gid, 0, p.goodscode, '--') goodscode\n" +
  7023. " ,decode(gid, 0, p.goodstypename, '--') goodstypename\n" +
  7024. " ,p.overcount\n" +
  7025. " FROM (SELECT grouping_id(pdata.Procedureid,pdata.goodstypename2, pdata.Userid) gid\n" +
  7026. " ,pdata.productionlineid\n" +
  7027. " ,pdata.procedureid\n" +
  7028. " ,to_char(pdata.procedurename) procedurename\n" +
  7029. " ,to_char(pdata.userid) userid\n" +
  7030. " ,pdata.usercode\n" +
  7031. " ,to_char(pdata.goodsid) goodsid\n" +
  7032. " ,pdata.goodscode\n" +
  7033. " ,pdata.goodstypename\n" +
  7034. " ,pdata.goodstypecode2\n" +
  7035. " ,pdata.goodstypename2\n" +
  7036. " ,COUNT(pdata.barcode) overcount\n" +
  7037. " FROM (SELECT distinct pd.barcode,pcp.displayno\n" +
  7038. " ,pd.productionlineid\n" +
  7039. " ,pd.procedureid\n" +
  7040. " ,pcp.procedurename\n" +
  7041. (se.DisPUserCode ? " ,pd.userid, pd.usercode \n" : " ,null userid, null usercode \n") +
  7042. //" ,pd.userid\n" +
  7043. //" ,pd.usercode\n" +
  7044. " ,t_over.goodsid\n" +
  7045. " ,t_over.goodscode\n" +
  7046. " ,t_over.goodstypename\n" +
  7047. " ,t_over.goodstypecode2\n" +
  7048. " ,t_over.goodstypename2\n" +
  7049. " FROM tp_pm_productiondata pd\n" +
  7050. " LEFT JOIN tp_pc_procedure pcp\n" +
  7051. " ON pcp.procedureid = pd.procedureid\n" +
  7052. " INNER JOIN (SELECT DISTINCT pd.barcode\n" +
  7053. " ,pd.productiondataid\n" +
  7054. " ,goods.goodsid\n" +
  7055. " ,goods.goodscode\n" +
  7056. " ,gt.goodstypename\n" +
  7057. " ,gt2.goodstypename goodstypename2\n" +
  7058. " ,gt2.goodstypecode goodstypecode2\n" +
  7059. " FROM tp_pm_productiondata pd\n" +
  7060. " LEFT JOIN tp_mst_goods goods\n" +
  7061. " ON goods.goodsid = pd.goodsid\n" +
  7062. " LEFT JOIN tp_mst_goodstype gt\n" +
  7063. " ON goods.goodstypeid = gt.goodstypeid\n" +
  7064. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7065. " ON gt2.goodstypecode = substr(gt.goodstypecode,1,6)\n" +
  7066. " AND gt2.accountid = gt.accountid\n" +
  7067. " --LEFT JOIN tp_pc_procedure pcp\n" +
  7068. " -- ON pcp.procedureid = pd.procedureid\n" +
  7069. ((se.DTimeStart.HasValue || se.DTimeEnd.HasValue) ? " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=pd.groutingdailydetailid \n" : "") +
  7070. " WHERE pd.valueflag = '1'\n" +
  7071. " 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))" +
  7072. " AND pd.accountid = :AccountID\n";
  7073. // 生产线
  7074. if (se.ProductionLineID.HasValue)
  7075. {
  7076. sqlString = sqlString + " AND pd.productionlineid = :productionlineid ";
  7077. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  7078. }
  7079. // 成型工号
  7080. if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
  7081. {
  7082. sqlString = sqlString + " AND instr(pd.GroutingUserCode, :GroutingUserCode) > 0";
  7083. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  7084. }
  7085. // 产品型号
  7086. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  7087. {
  7088. sqlString = sqlString + " AND instr(gt.GOODSTYPECode, :GoodsTypeCode)=1 ";
  7089. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7090. }
  7091. // 产品编码
  7092. if (!string.IsNullOrEmpty(se.GoodsCode))
  7093. {
  7094. sqlString = sqlString + " AND instr(goods.GOODSCode, :GoodsCode) > 0 ";
  7095. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7096. }
  7097. // 交接工序
  7098. if (!string.IsNullOrEmpty(se.OverProcedureIDS))
  7099. {
  7100. sqlString = sqlString + " AND instr(:overprocedureids, ','||pd.procedureid||',')>0 ";
  7101. parameters.Add(new OracleParameter(":overprocedureids", OracleDbType.Varchar2, "," + se.OverProcedureIDS + ",", ParameterDirection.Input));
  7102. }
  7103. // 交接工号
  7104. if (!string.IsNullOrEmpty(se.OverUserIDS))
  7105. {
  7106. sqlString = sqlString + " AND instr(:overuserids, ','||pd.userid||',')>0 ";
  7107. parameters.Add(new OracleParameter(":overuserids", OracleDbType.Varchar2, "," + se.OverUserIDS + ",", ParameterDirection.Input));
  7108. }
  7109. // 交接时间
  7110. if (se.OverTimeStart.HasValue)
  7111. {
  7112. sqlString = sqlString + " AND pd.CreateTime >=:OverTimeStart ";
  7113. parameters.Add(new OracleParameter(":OverTimeStart", OracleDbType.Date, se.OverTimeStart.Value, ParameterDirection.Input));
  7114. }
  7115. if (se.OverTimeEnd.HasValue)
  7116. {
  7117. sqlString = sqlString + " AND pd.CreateTime <= :OverTimeEnd ";
  7118. parameters.Add(new OracleParameter(":OverTimeEnd", OracleDbType.Date, se.OverTimeEnd.Value, ParameterDirection.Input));
  7119. }
  7120. // 注浆时间
  7121. if (se.GTimeStart.HasValue)
  7122. {
  7123. sqlString = sqlString + " AND pd.GROUTINGDATE >=:GTimeStart ";
  7124. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  7125. }
  7126. if (se.GTimeEnd.HasValue)
  7127. {
  7128. sqlString = sqlString + " AND pd.GROUTINGDATE <= :GTimeEnd ";
  7129. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  7130. }
  7131. // 交坯时间
  7132. if (se.DTimeStart.HasValue)
  7133. {
  7134. sqlString = sqlString + " AND gdd.DELIVERTIME >=:DTimeStart ";
  7135. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
  7136. }
  7137. if (se.DTimeEnd.HasValue)
  7138. {
  7139. sqlString = sqlString + " AND gdd.DELIVERTIME <= :DTimeEnd ";
  7140. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
  7141. }
  7142. sqlString = sqlString +
  7143. " ) t_over\n" +
  7144. " ON pd.barcode = t_over.barcode\n" +
  7145. // 交接工序在生产工序后
  7146. " AND pd.productiondataid <= t_over.productiondataid\n" +
  7147. " WHERE pd.valueflag = '1'\n" +
  7148. " AND pd.accountid = :AccountID\n" +
  7149. (se.Specialrepairflag ? " AND ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" : "") +
  7150. " 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))";
  7151. // 生产工序
  7152. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  7153. {
  7154. sqlString = sqlString + " AND instr(:procedureids, ','||pd.procedureid||',')>0 ";
  7155. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  7156. }
  7157. // 生产工号
  7158. if (!string.IsNullOrEmpty(se.UserIDS))
  7159. {
  7160. sqlString = sqlString + " AND instr(:userids, ','||pd.userid||',')>0 ";
  7161. parameters.Add(new OracleParameter(":userids", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
  7162. }
  7163. // 生产时间
  7164. if (se.PTimeStart.HasValue)
  7165. {
  7166. sqlString = sqlString + " AND pd.CreateTime >=:PTimeStart ";
  7167. parameters.Add(new OracleParameter(":PTimeStart", OracleDbType.Date, se.PTimeStart.Value, ParameterDirection.Input));
  7168. }
  7169. if (se.PTimeEnd.HasValue)
  7170. {
  7171. sqlString = sqlString + " AND pd.CreateTime <= :PTimeEnd ";
  7172. parameters.Add(new OracleParameter(":PTimeEnd", OracleDbType.Date, se.PTimeEnd.Value, ParameterDirection.Input));
  7173. }
  7174. sqlString = sqlString +
  7175. "\n ) pdata\n" +
  7176. " 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" +
  7177. " ORDER BY pdata.displayno\n" +
  7178. " ,pdata.goodstypename2\n" +
  7179. " ,pdata.usercode\n" +
  7180. " ,pdata.goodstypename\n" +
  7181. " ,pdata.goodscode) p";
  7182. return sqlString;
  7183. }
  7184. /// <summary>
  7185. /// 取得RPT030107画面(工序交接数量汇总表)的明细信息查询数据
  7186. /// </summary>
  7187. /// <param name="user">登录用户信息</param>
  7188. /// <param name="se">查询条件</param>
  7189. /// <returns>查询结果</returns>
  7190. public static ServiceResultEntity GetRPT030107IData(SUserInfo user, RPT030107_SE se)
  7191. {
  7192. IDBConnection conn = null;
  7193. try
  7194. {
  7195. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7196. List<OracleParameter> parameters = new List<OracleParameter>();
  7197. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030107ISQL(user, se, ref parameters));
  7198. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  7199. ServiceResultEntity sre = new ServiceResultEntity();
  7200. if (data == null || data.Rows.Count == 0)
  7201. {
  7202. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7203. return sre;
  7204. }
  7205. sre.Data = new DataSet();
  7206. sre.Data.Tables.Add(data);
  7207. return sre;
  7208. }
  7209. catch (Exception ex)
  7210. {
  7211. throw ex;
  7212. }
  7213. finally
  7214. {
  7215. if (conn != null &&
  7216. conn.ConnState == ConnectionState.Open)
  7217. {
  7218. conn.Close();
  7219. }
  7220. }
  7221. }
  7222. /// <summary>
  7223. /// 获取RPT030107画面(工序交接数量汇总表)的明细信息查询sql
  7224. /// </summary>
  7225. /// <returns>sql</returns>
  7226. private static string GetRPT030107ISQL(SUserInfo user, RPT030107_SE se, ref List<OracleParameter> parameters)
  7227. {
  7228. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7229. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  7230. string sqlString =
  7231. "SELECT distinct pcp.procedurename,pcp.displayno\n" +
  7232. (se.DisPUserCode ? " ,pd.userid, pd.usercode \n" : " ,null userid, null usercode \n") +
  7233. //" ,pd.usercode\n" +
  7234. " ,t_over.barcode\n" +
  7235. " ,t_over.goodscode\n" +
  7236. " ,t_over.goodstypename\n" +
  7237. " ,t_over.goodstypename2\n" +
  7238. //" ,pd.createtime ptime\n" +
  7239. //" ,t_over.overprocedurename\n" +
  7240. //" ,t_over.overusercode\n" +
  7241. //" ,t_over.overtime\n" +
  7242. " ,t_over.groutingusercode\n" +
  7243. " ,pd.groutinglinecode\n" +
  7244. " ,pd.groutingmouldcode\n" +
  7245. " ,t_over.groutingdate Gdate\n" +
  7246. " ,t_over.DELIVERTIME Ddate\n" +
  7247. " ,decode(logo.logoid, null, '', logo.Logoname||'['||logo.Logocode||']') as LogoCodeName " +
  7248. " FROM tp_pm_productiondata pd\n" +
  7249. " LEFT JOIN tp_pc_procedure pcp\n" +
  7250. " ON pcp.procedureid = pd.procedureid\n" +
  7251. " LEFT JOIN TP_MST_logo logo\n" +
  7252. " ON logo.logoid = pd.logoid\n" +
  7253. " INNER JOIN (SELECT DISTINCT pd.barcode\n" +
  7254. " ,pd.productiondataid\n" +
  7255. " ,goods.goodsid\n" +
  7256. " ,goods.goodscode\n" +
  7257. " ,gt.goodstypename\n" +
  7258. " ,gt2.goodstypename goodstypename2\n" +
  7259. //" ,pcp.procedurename overprocedurename\n" +
  7260. //" ,pd.usercode overusercode\n" +
  7261. //" ,pd.createtime overtime\n" +
  7262. " ,pd.groutingusercode\n" +
  7263. " ,pd.groutingdate\n" +
  7264. " ,gdd.DELIVERTIME\n" +
  7265. " FROM tp_pm_productiondata pd\n" +
  7266. " LEFT JOIN tp_mst_goods goods\n" +
  7267. " ON goods.goodsid = pd.goodsid\n" +
  7268. " LEFT JOIN tp_mst_goodstype gt\n" +
  7269. " ON goods.goodstypeid = gt.goodstypeid\n" +
  7270. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7271. " ON gt2.goodstypecode = substr(gt.goodstypecode,1,6)\n" +
  7272. " AND gt2.accountid = gt.accountid\n" +
  7273. " LEFT JOIN tp_pc_procedure pcp\n" +
  7274. " ON pcp.procedureid = pd.procedureid\n" +
  7275. " INNER JOIN tp_pm_groutingdailydetail gdd\n" +
  7276. " ON gdd.groutingdailydetailid = pd.groutingdailydetailid\n" +
  7277. " WHERE pd.valueflag = '1'\n" +
  7278. " 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))" +
  7279. " AND pd.accountid = :AccountID\n";
  7280. // 生产线
  7281. if (se.ProductionLineID.HasValue)
  7282. {
  7283. sqlString = sqlString + " AND pd.productionlineid = :productionlineid ";
  7284. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  7285. }
  7286. // 成型工号
  7287. if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
  7288. {
  7289. sqlString = sqlString + " AND instr(pd.GroutingUserCode, :GroutingUserCode) > 0";
  7290. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  7291. }
  7292. // 产品型号
  7293. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  7294. {
  7295. sqlString = sqlString + " AND instr(gt.GOODSTYPECode, :GoodsTypeCode)=1 ";
  7296. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7297. }
  7298. if (!string.IsNullOrEmpty(se.GoodsID))
  7299. {
  7300. sqlString = sqlString + " AND pd.goodsid = :GoodsID ";
  7301. parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  7302. }
  7303. // 产品编码
  7304. if (!string.IsNullOrEmpty(se.GoodsCode))
  7305. {
  7306. sqlString = sqlString + " AND instr(goods.GOODSCode, :GoodsCode) > 0 ";
  7307. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7308. }
  7309. // 交接工序
  7310. if (!string.IsNullOrEmpty(se.OverProcedureIDS))
  7311. {
  7312. sqlString = sqlString + " AND instr(:overprocedureids, ','||pd.procedureid||',')>0 ";
  7313. parameters.Add(new OracleParameter(":overprocedureids", OracleDbType.Varchar2, "," + se.OverProcedureIDS + ",", ParameterDirection.Input));
  7314. }
  7315. // 交接工号
  7316. if (!string.IsNullOrEmpty(se.OverUserIDS))
  7317. {
  7318. sqlString = sqlString + " AND instr(:overuserids, ','||pd.userid||',')>0 ";
  7319. parameters.Add(new OracleParameter(":overuserids", OracleDbType.Varchar2, "," + se.OverUserIDS + ",", ParameterDirection.Input));
  7320. }
  7321. // 交接时间
  7322. if (se.OverTimeStart.HasValue)
  7323. {
  7324. sqlString = sqlString + " AND pd.CreateTime >=:OverTimeStart ";
  7325. parameters.Add(new OracleParameter(":OverTimeStart", OracleDbType.Date, se.OverTimeStart.Value, ParameterDirection.Input));
  7326. }
  7327. if (se.OverTimeEnd.HasValue)
  7328. {
  7329. sqlString = sqlString + " AND pd.CreateTime <= :OverTimeEnd ";
  7330. parameters.Add(new OracleParameter(":OverTimeEnd", OracleDbType.Date, se.OverTimeEnd.Value, ParameterDirection.Input));
  7331. }
  7332. // 注浆时间
  7333. if (se.GTimeStart.HasValue)
  7334. {
  7335. sqlString = sqlString + " AND pd.GROUTINGDATE >=:GTimeStart ";
  7336. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  7337. }
  7338. if (se.GTimeEnd.HasValue)
  7339. {
  7340. sqlString = sqlString + " AND pd.GROUTINGDATE <= :GTimeEnd ";
  7341. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  7342. }
  7343. // 交坯时间
  7344. if (se.DTimeStart.HasValue)
  7345. {
  7346. sqlString = sqlString + " AND gdd.DELIVERTIME >=:DTimeStart ";
  7347. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
  7348. }
  7349. if (se.DTimeEnd.HasValue)
  7350. {
  7351. sqlString = sqlString + " AND gdd.DELIVERTIME <= :DTimeEnd ";
  7352. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
  7353. }
  7354. sqlString = sqlString +
  7355. " ) t_over\n" +
  7356. " ON pd.barcode = t_over.barcode\n" +
  7357. // 交接工序在生产工序后
  7358. " AND pd.productiondataid <= t_over.productiondataid\n" +
  7359. " WHERE pd.valueflag = '1'\n" +
  7360. " AND pd.accountid = :AccountID\n" +
  7361. (se.Specialrepairflag ? " AND ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" : "") +
  7362. " 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))";
  7363. // 生产工序
  7364. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  7365. {
  7366. sqlString = sqlString + " AND instr(:procedureids, ','||pd.procedureid||',')>0 ";
  7367. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  7368. }
  7369. // 生产工号
  7370. if (!string.IsNullOrEmpty(se.UserIDS))
  7371. {
  7372. sqlString = sqlString + " AND instr(:userids, ','||pd.userid||',')>0 ";
  7373. parameters.Add(new OracleParameter(":userids", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
  7374. }
  7375. // 生产时间
  7376. if (se.PTimeStart.HasValue)
  7377. {
  7378. sqlString = sqlString + " AND pd.CreateTime >=:PTimeStart ";
  7379. parameters.Add(new OracleParameter(":PTimeStart", OracleDbType.Date, se.PTimeStart.Value, ParameterDirection.Input));
  7380. }
  7381. if (se.PTimeEnd.HasValue)
  7382. {
  7383. sqlString = sqlString + " AND pd.CreateTime <= :PTimeEnd ";
  7384. parameters.Add(new OracleParameter(":PTimeEnd", OracleDbType.Date, se.PTimeEnd.Value, ParameterDirection.Input));
  7385. }
  7386. sqlString = sqlString +
  7387. "\n ORDER BY pcp.displayno\n" +
  7388. " ,t_over.goodstypename2\n" +
  7389. (se.DisPUserCode ? " ,pd.usercode\n" : "") +
  7390. " ,t_over.goodstypename\n" +
  7391. " ,t_over.goodscode\n";
  7392. return sqlString;
  7393. }
  7394. #endregion
  7395. /// <summary>
  7396. /// 取得RPT030108画面(成型信息汇总表)的查询数据
  7397. /// </summary>
  7398. /// <param name="user">登录用户信息</param>
  7399. /// <param name="se">查询条件</param>
  7400. /// <returns>查询结果</returns>
  7401. public static ServiceResultEntity GetRPT030108SData(SUserInfo user, RPT030108_SE se)
  7402. {
  7403. IDBConnection conn = null;
  7404. try
  7405. {
  7406. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7407. List<OracleParameter> parameters = new List<OracleParameter>();
  7408. string sqlString = "SELECT decode(g.gid,\n" +
  7409. " 7,\n" +
  7410. " '总计',\n" +
  7411. " 3,\n" +
  7412. " '合计【' || g.goodstypename2 || '】',\n" +
  7413. " 0,\n" +
  7414. " g.goodstypename2,\n" +
  7415. " '--') goodstypename2\n" +
  7416. " ,decode(g.gid, 0, g.goodstypename, '--') goodstypename\n" +
  7417. " ,decode(g.gid,\n" +
  7418. " 1,\n" +
  7419. " '小计【' || g.goodscode || '】',\n" +
  7420. " 0,\n" +
  7421. " g.goodscode,\n" +
  7422. " '--') goodscode\n" +
  7423. " ,decode(g.gid, 0, g.usercode, '--') usercode\n" +
  7424. " ,decode(g.gid, 0, g.MONITORName, '--') MONITORName\n" +
  7425. " ,g.groutingcount\n" +
  7426. " ,g.barcodecount\n" +
  7427. " ,g.scrapcount\n" +
  7428. " ,g.barscrapcount\n" +
  7429. " ,g.delivercount\n" +
  7430. " ,g.barcodecount - g.barscrapcount - g.delivercount incount\n" +
  7431. " FROM (SELECT grouping_id(gdd.goodstypename2, gdd.goodscode, gdd.usercode) gid\n" +
  7432. " ,gdd.goodstypename2\n" +
  7433. " ,gdd.goodstypename\n" +
  7434. " ,gdd.goodscode\n" +
  7435. " ,gdd.usercode\n" +
  7436. " ,gdd.MONITORName\n" +
  7437. " ,SUM(groutingcount) groutingcount\n" +
  7438. " ,SUM(barcodecount) barcodecount\n" +
  7439. " ,SUM(scrapcount) scrapcount\n" +
  7440. " ,SUM(barscrapcount) barscrapcount\n" +
  7441. " ,SUM(delivercount) delivercount\n" +
  7442. " FROM (SELECT gt2.goodstypename goodstypename2\n" +
  7443. " ,gdd.usercode\n" +
  7444. " ,mu.usercode as MONITORName\n" +
  7445. " ,goods.goodscode\n" +
  7446. " ,gt.goodstypename\n" +
  7447. " , CASE\n" +
  7448. " WHEN gdd.groutingdate >= :gdatabegin AND\n" +
  7449. " gdd.groutingdate <= :gdataend THEN\n" +
  7450. " 1\n" +
  7451. " ELSE\n" +
  7452. " 0\n" +
  7453. " END groutingcount\n" +
  7454. " , CASE\n" +
  7455. " WHEN gdd.groutingdate >= :gdatabegin AND\n" +
  7456. " gdd.groutingdate <= :gdataend AND\n" +
  7457. " gdd.barcode IS NOT NULL THEN\n" +
  7458. " 1\n" +
  7459. " ELSE\n" +
  7460. " 0\n" +
  7461. " END barcodecount\n" +
  7462. " , CASE\n" +
  7463. " WHEN gdd.scraptime >= :sdatabegin AND\n" +
  7464. " gdd.scraptime <= :sdataend AND\n" +
  7465. " gdd.scrapflag = '1' THEN\n" +
  7466. " 1\n" +
  7467. " ELSE\n" +
  7468. " 0\n" +
  7469. " END scrapcount\n" +
  7470. " , CASE\n" +
  7471. " WHEN gdd.scraptime >= :sdatabegin AND\n" +
  7472. " gdd.scraptime <= :sdataend AND\n" +
  7473. " gdd.barcode IS NOT NULL AND gdd.scrapflag = '1' THEN\n" +
  7474. " 1\n" +
  7475. " ELSE\n" +
  7476. " 0\n" +
  7477. " END barscrapcount\n" +
  7478. " , CASE\n" +
  7479. " WHEN gdd.delivertime >= :ddatabegin AND\n" +
  7480. " gdd.delivertime <= :ddataend AND\n" +
  7481. " gdd.deliverflag = '1' THEN\n" +
  7482. " 1\n" +
  7483. " ELSE\n" +
  7484. " 0\n" +
  7485. " END delivercount\n" +
  7486. " FROM tp_pm_groutingdailydetail gdd\n" +
  7487. " LEFT JOIN tp_mst_goods goods\n" +
  7488. " ON goods.goodsid = gdd.goodsid\n" +
  7489. // 成型线
  7490. " LEFT JOIN tp_pc_groutingline gl" +
  7491. " ON gl.groutinglineid = GDD.GroutingLineID" +
  7492. // 成型班长
  7493. " LEFT JOIN tp_mst_user mu" +
  7494. " ON mu.userid = gl.MONITORID " +
  7495. " LEFT JOIN tp_mst_goodstype gt\n" +
  7496. " ON gt.goodstypeid = goods.goodstypeid\n" +
  7497. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7498. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  7499. " AND gt2.accountid = gt.accountid\n" +
  7500. " WHERE gdd.valueflag = '1'\n" +
  7501. " AND gdd.groutingflag = '1'\n" +
  7502. " AND gdd.accountid = :accountid\n" +
  7503. " AND ((gdd.groutingdate >= :gdatabegin AND\n" +
  7504. " gdd.groutingdate <= :gdataend) OR\n" +
  7505. " (gdd.scraptime >= :sdatabegin AND\n" +
  7506. " gdd.scraptime <= :sdataend) OR\n" +
  7507. " (gdd.delivertime >= :ddatabegin AND\n" +
  7508. " gdd.delivertime <= :ddataend))\n" +
  7509. " AND (:usercode IS NULL OR\n" +
  7510. " instr(gdd.usercode, :usercode) > 0)\n" +
  7511. " AND (:GoodsCode IS NULL OR\n" +
  7512. " instr(goods.GoodsCode, :GoodsCode) > 0)\n" +
  7513. " AND (:goodstypecode IS NULL OR\n" +
  7514. " instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  7515. " ORDER BY gt2.goodstypename\n" +
  7516. " ,gt.goodstypename\n" +
  7517. " ,goods.goodscode\n" +
  7518. " ,gdd.usercode) gdd\n" +
  7519. " GROUP BY GROUPING SETS((gdd.goodstypename2, gdd.goodstypename, gdd.goodscode, gdd.usercode,gdd.MONITORName),(gdd.goodstypename2, gdd.goodstypename, gdd.goodscode),(gdd.goodstypename2),())\n" +
  7520. " ORDER BY gdd.goodstypename2\n" +
  7521. " ,gdd.goodstypename\n" +
  7522. " ,gdd.goodscode\n" +
  7523. " ,gdd.usercode) g";
  7524. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7525. parameters.Add(new OracleParameter(":gdatabegin", OracleDbType.Date, se.GTimeStart, ParameterDirection.Input));
  7526. parameters.Add(new OracleParameter(":gdataend", OracleDbType.Date, se.GTimeEnd, ParameterDirection.Input));
  7527. parameters.Add(new OracleParameter(":sdatabegin", OracleDbType.Date, se.STimeStart, ParameterDirection.Input));
  7528. parameters.Add(new OracleParameter(":sdataend", OracleDbType.Date, se.STimeEnd, ParameterDirection.Input));
  7529. parameters.Add(new OracleParameter(":ddatabegin", OracleDbType.Date, se.DTimeStart, ParameterDirection.Input));
  7530. parameters.Add(new OracleParameter(":ddataend", OracleDbType.Date, se.DTimeEnd, ParameterDirection.Input));
  7531. parameters.Add(new OracleParameter(":usercode", OracleDbType.Varchar2, se.UserCode, ParameterDirection.Input));
  7532. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7533. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7534. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  7535. ServiceResultEntity sre = new ServiceResultEntity();
  7536. if (data == null || data.Rows.Count == 0)
  7537. {
  7538. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7539. return sre;
  7540. }
  7541. sre.Data = new DataSet();
  7542. sre.Data.Tables.Add(data);
  7543. return sre;
  7544. }
  7545. catch (Exception ex)
  7546. {
  7547. throw ex;
  7548. }
  7549. finally
  7550. {
  7551. if (conn != null &&
  7552. conn.ConnState == ConnectionState.Open)
  7553. {
  7554. conn.Close();
  7555. }
  7556. }
  7557. }
  7558. #region 撤销产品汇总表
  7559. /// <summary>
  7560. /// 取得RPT030109画面(撤销产品汇总表)的汇总信息查询数据
  7561. /// </summary>
  7562. /// <param name="user">登录用户信息</param>
  7563. /// <param name="se">查询条件</param>
  7564. /// <returns>查询结果</returns>
  7565. public static ServiceResultEntity GetRPT030109SData(SUserInfo user, RPT030109_SE se)
  7566. {
  7567. IDBConnection conn = null;
  7568. try
  7569. {
  7570. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7571. List<OracleParameter> parameters = new List<OracleParameter>();
  7572. string sql = ReportModuleLogic.GetRPT030109SSQL(user, se, ref parameters);
  7573. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  7574. ServiceResultEntity sre = new ServiceResultEntity();
  7575. if (data == null || data.Rows.Count == 0)
  7576. {
  7577. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7578. return sre;
  7579. }
  7580. sre.Data = new DataSet();
  7581. sre.Data.Tables.Add(data);
  7582. return sre;
  7583. }
  7584. catch (Exception ex)
  7585. {
  7586. throw ex;
  7587. }
  7588. finally
  7589. {
  7590. if (conn != null &&
  7591. conn.ConnState == ConnectionState.Open)
  7592. {
  7593. conn.Close();
  7594. }
  7595. }
  7596. }
  7597. /// <summary>
  7598. /// 获取RPT030109画面(撤销产品汇总表)的汇总信息查询sql
  7599. /// </summary>
  7600. /// <returns>sql</returns>
  7601. private static string GetRPT030109SSQL(SUserInfo user, RPT030109_SE se, ref List<OracleParameter> parameters)
  7602. {
  7603. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7604. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  7605. string sqlString =
  7606. "SELECT decode(p.gid,\n" +
  7607. " 7,\n" +
  7608. " '总计',\n" +
  7609. " 3,\n" +
  7610. " '合计【' || p.procedurename || '】',\n" +
  7611. " 0,\n" +
  7612. " p.procedurename,\n" +
  7613. " '--') procedurename\n" +
  7614. " ,decode(p.gid,\n" +
  7615. " 1,\n" +
  7616. " '小计【' || p.goodstypename2 || '】',\n" +
  7617. " 0,\n" +
  7618. " p.goodstypename2,\n" +
  7619. " '--') goodstypename2\n" +
  7620. " ,decode(p.gid, 0, p.goodstypename, '--') goodstypename\n" +
  7621. " ,decode(p.gid, 0, p.goodscode, '--') goodscode\n" +
  7622. " ,decode(p.gid, 0, p.usercode, '--') usercode\n" +
  7623. " ,p.codecount\n" +
  7624. " ,p.productionlineid\n" +
  7625. " ,p.procedureid\n" +
  7626. " ,p.goodstypecode2\n" +
  7627. " ,p.goodsid\n" +
  7628. " ,p.userid\n" +
  7629. " FROM (SELECT grouping_id(pd.procedureid, gt2.goodstypecode, pd.userid) gid\n" +
  7630. " ,pd.productionlineid\n" +
  7631. " ,pd.procedureid\n" +
  7632. " ,p.procedurename\n" +
  7633. " ,p.displayno\n" +
  7634. " ,gt2.goodstypecode goodstypecode2\n" +
  7635. " ,gt2.goodstypename goodstypename2\n" +
  7636. " ,gt.goodstypecode\n" +
  7637. " ,gt.goodstypename\n" +
  7638. " ,goods.goodsid\n" +
  7639. " ,goods.goodscode\n" +
  7640. " ,pd.userid\n" +
  7641. " ,pd.usercode\n" +
  7642. " ,COUNT(*) codecount\n" +
  7643. " FROM tp_pm_productiondata pd\n" +
  7644. " LEFT JOIN tp_pc_procedure p\n" +
  7645. " ON p.procedureid = pd.procedureid\n" +
  7646. " LEFT JOIN tp_mst_goods goods\n" +
  7647. " ON goods.goodsid = pd.goodsid\n" +
  7648. " LEFT JOIN tp_mst_goodstype gt\n" +
  7649. " ON gt.goodstypeid = goods.goodstypeid\n" +
  7650. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7651. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  7652. " AND gt2.accountid = gt.accountid\n" +
  7653. " WHERE pd.valueflag = '0'\n" +
  7654. " AND pd.accountid = :accountid\n" +
  7655. " 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))" +
  7656. " 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))" +
  7657. " AND (:productionlineid IS NULL OR\n" +
  7658. " pd.productionlineid = :productionlineid)\n" +
  7659. " AND (:procedureids IS NULL OR\n" +
  7660. " instr(:procedureids, ',' || pd.procedureid || ',') > 0)\n" +
  7661. " AND (:goodstypecode IS NULL OR\n" +
  7662. " instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  7663. " AND (:goodscode IS NULL OR\n" +
  7664. " instr(goods.goodscode, :goodscode) > 0)\n" +
  7665. " AND (:PUserIDS IS NULL OR\n" +
  7666. " instr(:PUserIDS, ',' || pd.userid || ',') > 0)\n" +
  7667. " AND (:backusercode IS NULL OR\n" +
  7668. " instr(pd.BACKOUTUSERCODE, :backusercode) > 0)\n" +
  7669. " AND (:ptimebegin IS NULL OR pd.createtime >= :ptimebegin)\n" +
  7670. " AND (:ptimeend IS NULL OR pd.createtime <= :ptimeend)\n" +
  7671. " AND (:backtimebegin IS NULL OR pd.backouttime >= :backtimebegin)\n" +
  7672. " AND (:backtimeend IS NULL OR pd.backouttime <= :backtimeend)\n" +
  7673. " 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" +
  7674. " ORDER BY p.displayno\n" +
  7675. " ,gt2.goodstypecode\n" +
  7676. " ,gt.goodstypecode\n" +
  7677. " ,goods.goodscode\n" +
  7678. " ,pd.usercode) p";
  7679. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  7680. if (string.IsNullOrEmpty(se.ProcedureIDS))
  7681. {
  7682. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, null, ParameterDirection.Input));
  7683. }
  7684. else
  7685. {
  7686. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  7687. }
  7688. if (string.IsNullOrEmpty(se.UserIDS))
  7689. {
  7690. parameters.Add(new OracleParameter(":PUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  7691. }
  7692. else
  7693. {
  7694. parameters.Add(new OracleParameter(":PUserIDS", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
  7695. }
  7696. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7697. parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7698. parameters.Add(new OracleParameter(":backusercode", OracleDbType.Varchar2, se.BackUserCode, ParameterDirection.Input));
  7699. parameters.Add(new OracleParameter(":ptimebegin", OracleDbType.Date, se.PTimeStart, ParameterDirection.Input));
  7700. parameters.Add(new OracleParameter(":ptimeend", OracleDbType.Date, se.PTimeEnd, ParameterDirection.Input));
  7701. parameters.Add(new OracleParameter(":backtimebegin", OracleDbType.Date, se.BackTimeStart, ParameterDirection.Input));
  7702. parameters.Add(new OracleParameter(":backtimeend", OracleDbType.Date, se.BackTimeEnd, ParameterDirection.Input));
  7703. return sqlString;
  7704. }
  7705. /// <summary>
  7706. /// 取得RPT030109画面(撤销产品汇总表)的明细信息查询数据
  7707. /// </summary>
  7708. /// <param name="user">登录用户信息</param>
  7709. /// <param name="se">查询条件</param>
  7710. /// <returns>查询结果</returns>
  7711. public static ServiceResultEntity GetRPT030109IData(SUserInfo user, RPT030109_SE se)
  7712. {
  7713. IDBConnection conn = null;
  7714. try
  7715. {
  7716. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7717. List<OracleParameter> parameters = new List<OracleParameter>();
  7718. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030109ISQL(user, se, ref parameters));
  7719. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  7720. ServiceResultEntity sre = new ServiceResultEntity();
  7721. if (data == null || data.Rows.Count == 0)
  7722. {
  7723. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7724. return sre;
  7725. }
  7726. sre.Data = new DataSet();
  7727. sre.Data.Tables.Add(data);
  7728. return sre;
  7729. }
  7730. catch (Exception ex)
  7731. {
  7732. throw ex;
  7733. }
  7734. finally
  7735. {
  7736. if (conn != null &&
  7737. conn.ConnState == ConnectionState.Open)
  7738. {
  7739. conn.Close();
  7740. }
  7741. }
  7742. }
  7743. /// <summary>
  7744. /// 获取RPT030109画面(撤销产品汇总表)的明细信息查询sql
  7745. /// </summary>
  7746. /// <returns>sql</returns>
  7747. private static string GetRPT030109ISQL(SUserInfo user, RPT030109_SE se, ref List<OracleParameter> parameters)
  7748. {
  7749. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7750. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  7751. string sqlString =
  7752. "SELECT p.procedurename\n" +
  7753. " ,gt2.goodstypename goodstypename2\n" +
  7754. " ,gt.goodstypename\n" +
  7755. " ,goods.goodscode\n" +
  7756. " ,pd.barcode\n" +
  7757. " ,pd.usercode\n" +
  7758. " ,pd.createtime ptime\n" +
  7759. " ,pd.backoutusercode busercode\n" +
  7760. " ,pd.backouttime btime\n" +
  7761. " ,pd.groutingusercode\n" +
  7762. " ,pd.groutinglinecode\n" +
  7763. " ,pd.groutingmouldcode\n" +
  7764. " ,pd.groutingdate GDate\n" +
  7765. " FROM tp_pm_productiondata pd\n" +
  7766. " LEFT JOIN tp_pc_procedure p\n" +
  7767. " ON p.procedureid = pd.procedureid\n" +
  7768. " LEFT JOIN tp_mst_goods goods\n" +
  7769. " ON goods.goodsid = pd.goodsid\n" +
  7770. " LEFT JOIN tp_mst_goodstype gt\n" +
  7771. " ON gt.goodstypeid = goods.goodstypeid\n" +
  7772. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7773. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  7774. " AND gt2.accountid = gt.accountid\n" +
  7775. " WHERE pd.valueflag = '0'\n" +
  7776. " AND pd.accountid = :accountid\n" +
  7777. " 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))" +
  7778. " 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))" +
  7779. " AND (:productionlineid IS NULL OR\n" +
  7780. " pd.productionlineid = :productionlineid)\n" +
  7781. " AND (:procedureids IS NULL OR\n" +
  7782. " instr(:procedureids, ',' || pd.procedureid || ',') > 0)\n" +
  7783. " AND (:goodstypecode IS NULL OR\n" +
  7784. " instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  7785. " AND (:goodscode IS NULL OR instr(goods.goodscode, :goodscode) > 0)\n" +
  7786. " AND (:PUserIDS IS NULL OR\n" +
  7787. " instr(:PUserIDS, ',' || pd.userid || ',') > 0)\n" +
  7788. " AND (:backusercode IS NULL OR instr(pd.BACKOUTUSERCODE, :backusercode) > 0)\n" +
  7789. " AND (:ptimebegin IS NULL OR pd.createtime >= :ptimebegin)\n" +
  7790. " AND (:ptimeend IS NULL OR pd.createtime <= :ptimeend)\n" +
  7791. " AND (:backtimebegin IS NULL OR pd.backouttime >= :backtimebegin)\n" +
  7792. " AND (:backtimeend IS NULL OR pd.backouttime <= :backtimeend)\n" +
  7793. " AND (:puserid IS NULL OR pd.userid = :puserid)\n" +
  7794. " AND (:goodsid IS NULL OR pd.goodsid = :goodsid)\n" +
  7795. " AND (:procedureid IS NULL OR pd.procedureid = :procedureid)\n" +
  7796. " ORDER BY p.displayno\n" +
  7797. " ,gt2.goodstypename\n" +
  7798. " ,gt.goodstypename\n" +
  7799. " ,goods.goodscode\n" +
  7800. " ,pd.usercode\n" +
  7801. " ,pd.barcode\n" +
  7802. " ,pd.backoutusercode\n" +
  7803. " ,pd.backouttime";
  7804. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  7805. if (string.IsNullOrEmpty(se.ProcedureIDS))
  7806. {
  7807. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, null, ParameterDirection.Input));
  7808. }
  7809. else
  7810. {
  7811. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  7812. }
  7813. if (string.IsNullOrEmpty(se.UserIDS))
  7814. {
  7815. parameters.Add(new OracleParameter(":PUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  7816. }
  7817. else
  7818. {
  7819. parameters.Add(new OracleParameter(":PUserIDS", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
  7820. }
  7821. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7822. parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7823. parameters.Add(new OracleParameter(":backusercode", OracleDbType.Varchar2, se.BackUserCode, ParameterDirection.Input));
  7824. parameters.Add(new OracleParameter(":ptimebegin", OracleDbType.Date, se.PTimeStart, ParameterDirection.Input));
  7825. parameters.Add(new OracleParameter(":ptimeend", OracleDbType.Date, se.PTimeEnd, ParameterDirection.Input));
  7826. parameters.Add(new OracleParameter(":backtimebegin", OracleDbType.Date, se.BackTimeStart, ParameterDirection.Input));
  7827. parameters.Add(new OracleParameter(":backtimeend", OracleDbType.Date, se.BackTimeEnd, ParameterDirection.Input));
  7828. parameters.Add(new OracleParameter(":puserid", OracleDbType.Int32, se.UserID, ParameterDirection.Input));
  7829. parameters.Add(new OracleParameter(":goodsid", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  7830. parameters.Add(new OracleParameter(":procedureid", OracleDbType.Int32, se.ProcedureID, ParameterDirection.Input));
  7831. return sqlString;
  7832. }
  7833. #endregion
  7834. /// <summary>
  7835. /// 工序收发存汇总表(初始化数据)
  7836. /// </summary>
  7837. /// <param name="user"></param>
  7838. /// <returns></returns>
  7839. public static ServiceResultEntity GetRPT030111IData(SUserInfo user)
  7840. {
  7841. IDBConnection conn = null;
  7842. try
  7843. {
  7844. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7845. OracleParameter[] parameters = new OracleParameter[]
  7846. {
  7847. new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  7848. };
  7849. string sqlString =
  7850. "SELECT t.ptid, t.name\n" +
  7851. " FROM tp_mst_rpt_transfer t\n" +
  7852. " WHERE t.AccountID = :AccountID\n" +
  7853. " AND t.valueflag = '1'\n" +
  7854. " ORDER BY t.displayno desc";
  7855. DataSet data = conn.GetSqlResultToDs(sqlString, parameters);
  7856. ServiceResultEntity sre = new ServiceResultEntity();
  7857. //if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  7858. //{
  7859. // sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7860. // return sre;
  7861. //}
  7862. sre.Data = data;
  7863. return sre;
  7864. }
  7865. catch (Exception ex)
  7866. {
  7867. throw ex;
  7868. }
  7869. finally
  7870. {
  7871. if (conn != null &&
  7872. conn.ConnState == ConnectionState.Open)
  7873. {
  7874. conn.Close();
  7875. }
  7876. }
  7877. }
  7878. /// <summary>
  7879. /// 工序收发存汇总表
  7880. /// </summary>
  7881. /// <param name="user"></param>
  7882. /// <param name="se"></param>
  7883. /// <returns></returns>
  7884. public static ServiceResultEntity GetRPT030111SData(SUserInfo user, RPT030111_SE se)
  7885. {
  7886. IDBTransaction conn = null;
  7887. try
  7888. {
  7889. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  7890. conn.Connect();
  7891. OracleParameter[] parameters = new OracleParameter[]
  7892. {
  7893. new OracleParameter("in_accountid", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  7894. new OracleParameter("in_ptid", OracleDbType.Int32, se.PTID, ParameterDirection.Input),
  7895. //new OracleParameter("in_datetimeinit", OracleDbType.Date, se.GTimeInit, ParameterDirection.Input),
  7896. new OracleParameter("in_datetimebegin", OracleDbType.Date, se.GTimeStart , ParameterDirection.Input),
  7897. new OracleParameter("in_datetimeend", OracleDbType.Date, se.GTimeEnd , ParameterDirection.Input),
  7898. new OracleParameter("in_goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode , ParameterDirection.Input),
  7899. new OracleParameter("in_goodscode", OracleDbType.Varchar2, se.GoodsCode , ParameterDirection.Input),
  7900. new OracleParameter("out_data", OracleDbType.RefCursor, null, ParameterDirection.Output),
  7901. };
  7902. DataSet data = conn.ExecStoredProcedure("pro_rpt_gettransfers_sum_c", parameters);
  7903. ServiceResultEntity sre = new ServiceResultEntity();
  7904. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  7905. {
  7906. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7907. return sre;
  7908. }
  7909. //StringBuilder intdids = new StringBuilder();
  7910. //foreach (DataRow row in data.Tables[0].Rows)
  7911. //{
  7912. // if (intdids.Length > 0)
  7913. // {
  7914. // intdids.Append(", ");
  7915. // }
  7916. // intdids.Append(row["tdid"] + " AS \"" + row["name"] + "\"\n");
  7917. //}
  7918. //string sqlString =
  7919. // "WITH ttm AS\n" +
  7920. // " (SELECT *\n" +
  7921. // " FROM TMP_RPT_TECDEP_D\n" +
  7922. // " pivot(SUM(m)\n" +
  7923. // " FOR intdid IN(" + intdids + ")))\n" +
  7924. // "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" +
  7925. // " FROM TMP_RPT_TECDEP_T t\n" +
  7926. // " LEFT JOIN ttm m\n" +
  7927. // " ON m.goodsid = t.goodsid\n" +
  7928. // " AND m.outtdid = t.tecdepid\n" +
  7929. // " ORDER BY t.goodscode, t.displayno";
  7930. //data = conn.GetSqlResultToDs(sqlString);
  7931. //if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  7932. //{
  7933. // sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7934. // return sre;
  7935. //}
  7936. conn.Commit();
  7937. sre.Data = data;
  7938. return sre;
  7939. }
  7940. catch (Exception ex)
  7941. {
  7942. throw ex;
  7943. }
  7944. finally
  7945. {
  7946. if (conn != null &&
  7947. conn.ConnState == ConnectionState.Open)
  7948. {
  7949. conn.Disconnect();
  7950. }
  7951. }
  7952. }
  7953. #endregion 汇总报表
  7954. #region 公共函数
  7955. /// <summary>
  7956. /// 取得报表的查询数据源统计工序数据
  7957. /// </summary>
  7958. /// <param name="user">登录用户信息</param>
  7959. /// <param name="se">查询条件</param>
  7960. /// <returns>查询结果</returns>
  7961. public static ServiceResultEntity GetRptSourceProcedureModule(SUserInfo user, int? RptProcedureID)
  7962. {
  7963. IDBConnection conn = null;
  7964. try
  7965. {
  7966. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7967. OracleParameter[] paras = new OracleParameter[]{
  7968. new OracleParameter("in_rptProcedureId",OracleDbType.Int32,RptProcedureID,ParameterDirection.Input),
  7969. new OracleParameter("out_rptSResult",OracleDbType.RefCursor, ParameterDirection.Output),
  7970. new OracleParameter("out_rptTresult",OracleDbType.RefCursor, ParameterDirection.Output),
  7971. };
  7972. DataSet data = conn.ExecStoredProcedure("PRO_MST_GetRptProcedureBYID", paras);
  7973. ServiceResultEntity sre = new ServiceResultEntity();
  7974. if (data == null || data.Tables.Count == 0)
  7975. {
  7976. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7977. return sre;
  7978. }
  7979. sre.Data = new DataSet();
  7980. sre.Data = data;
  7981. return sre;
  7982. }
  7983. catch (Exception ex)
  7984. {
  7985. throw ex;
  7986. }
  7987. finally
  7988. {
  7989. if (conn != null &&
  7990. conn.ConnState == ConnectionState.Open)
  7991. {
  7992. conn.Close();
  7993. }
  7994. }
  7995. }
  7996. /// <summary>
  7997. /// 取得报表数据源数据
  7998. /// </summary>
  7999. /// <param name="user">登录用户信息</param>
  8000. /// <returns>查询结果</returns>
  8001. public static ServiceResultEntity GetRptProcedureModule(SUserInfo user)
  8002. {
  8003. IDBConnection conn = null;
  8004. try
  8005. {
  8006. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8007. string selSql = " select "
  8008. + " TP_MST_RptProcedure.Rptprocedureid,"
  8009. + " TP_MST_RptProcedure.Rptprocedurecode,"
  8010. + " TP_MST_RptProcedure.Rptprocedurename,"
  8011. + " TP_MST_RptProcedure.Rptproceduretype,"
  8012. + " decode(TP_MST_RptProcedure.Rptproceduretype,'A0001','出窑统计','质量统计') RptproceduretypeName,"
  8013. + " (select wm_concat(s.procedureid) sprocedureid from tp_mst_rptsprocedure s where s.rptprocedureid = TP_MST_RptProcedure.Rptprocedureid) sprocedureid,"
  8014. + " (select wm_concat(t.procedureid) tprocedureid from tp_mst_rpttprocedure t where t.rptprocedureid = TP_MST_RptProcedure.Rptprocedureid) tprocedureid,"
  8015. + " TP_MST_RptProcedure.Optimestamp "
  8016. + " from TP_MST_RptProcedure "
  8017. + " where TP_MST_RptProcedure.ValueFlag=1 "
  8018. + " and TP_MST_RptProcedure.AccountID=:accountID order by TP_MST_RptProcedure.displayno";
  8019. List<OracleParameter> parameters = new List<OracleParameter>();
  8020. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8021. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8022. ServiceResultEntity sre = new ServiceResultEntity();
  8023. if (data == null || data.Rows.Count == 0)
  8024. {
  8025. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8026. return sre;
  8027. }
  8028. sre.Data = new DataSet();
  8029. sre.Data.Tables.Add(data);
  8030. return sre;
  8031. }
  8032. catch (Exception ex)
  8033. {
  8034. throw ex;
  8035. }
  8036. finally
  8037. {
  8038. if (conn != null &&
  8039. conn.ConnState == ConnectionState.Open)
  8040. {
  8041. conn.Close();
  8042. }
  8043. }
  8044. }
  8045. /// <summary>
  8046. /// 取得窑炉数据
  8047. /// </summary>
  8048. /// <param name="user">登录用户信息</param>
  8049. /// <param name="pValue">使用标识条件</param>
  8050. /// <returns>查询结果</returns>
  8051. public static ServiceResultEntity GetKilnData(SUserInfo user, byte pValue)
  8052. {
  8053. IDBConnection conn = null;
  8054. try
  8055. {
  8056. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8057. string selSql = string.Empty;
  8058. List<OracleParameter> parameters = new List<OracleParameter>();
  8059. //根据帐套查询数据
  8060. if (pValue.ToString() == Constant.INT_IS_ONE.ToString())
  8061. {
  8062. selSql = "Select KilnID,KilnCode,KilnName,KilnType,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,UpdateUserID,OPTimeStamp "
  8063. + "from TP_MST_Kiln where AccountID = :AccountID";
  8064. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8065. }
  8066. //根据帐套和标识查询数据
  8067. else if (pValue.ToString() == Constant.INT_IS_ZERO.ToString())
  8068. {
  8069. selSql = "Select KilnID,KilnCode,KilnName,KilnType,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,UpdateUserID,OPTimeStamp "
  8070. + "from TP_MST_Kiln where valueflag = :valueflag and AccountID = :AccountID";
  8071. parameters.Add(new OracleParameter(":valueflag", OracleDbType.NVarchar2, Constant.INT_IS_ONE.ToString(), ParameterDirection.Input));
  8072. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8073. }
  8074. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8075. ServiceResultEntity sre = new ServiceResultEntity();
  8076. if (data == null || data.Rows.Count == 0)
  8077. {
  8078. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8079. return sre;
  8080. }
  8081. sre.Data = new DataSet();
  8082. sre.Data.Tables.Add(data);
  8083. return sre;
  8084. }
  8085. catch (Exception ex)
  8086. {
  8087. throw ex;
  8088. }
  8089. finally
  8090. {
  8091. if (conn != null &&
  8092. conn.ConnState == ConnectionState.Open)
  8093. {
  8094. conn.Close();
  8095. }
  8096. }
  8097. }
  8098. /// <summary>
  8099. /// 取得窑车数据
  8100. /// </summary>
  8101. /// <param name="user">登录用户信息</param>
  8102. /// <returns>查询结果</returns>
  8103. public static ServiceResultEntity GetAllKilnCarInfo(SUserInfo user)
  8104. {
  8105. IDBConnection conn = null;
  8106. try
  8107. {
  8108. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8109. string selSql = String.Empty;
  8110. List<OracleParameter> parameters = new List<OracleParameter>();
  8111. //获取窑车管理的数据
  8112. selSql = "Select KilnCarID,KilnID,KilnCarCode,KilnCarName,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,UpdateUserID,OPTimeStamp "
  8113. + "from TP_MST_KilnCar where AccountID = :AccountID";
  8114. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8115. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8116. ServiceResultEntity sre = new ServiceResultEntity();
  8117. if (data == null || data.Rows.Count == 0)
  8118. {
  8119. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8120. return sre;
  8121. }
  8122. sre.Data = new DataSet();
  8123. sre.Data.Tables.Add(data);
  8124. return sre;
  8125. }
  8126. catch (Exception ex)
  8127. {
  8128. throw ex;
  8129. }
  8130. finally
  8131. {
  8132. if (conn != null &&
  8133. conn.ConnState == ConnectionState.Open)
  8134. {
  8135. conn.Close();
  8136. }
  8137. }
  8138. }
  8139. /// <summary>
  8140. /// 取得生产线所有的工序
  8141. /// </summary>
  8142. /// <param name="user">登录用户信息</param>
  8143. /// <returns>查询结果</returns>
  8144. public static ServiceResultEntity GetRptProductionLineProcedures(SUserInfo user, int? RptProductionLineID)
  8145. {
  8146. IDBConnection conn = null;
  8147. try
  8148. {
  8149. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8150. string selSql = "select "
  8151. + " tp_pc_procedure.procedureid, "
  8152. + " tp_pc_procedure.Procedurename "
  8153. + " from "
  8154. + " ( "
  8155. + " select TP_PM_ProductionData.Procedureid "
  8156. + " from TP_PM_ProductionData "
  8157. + " where TP_PM_ProductionData.accountid = :accountID "
  8158. + " and TP_PM_ProductionData.productionlineid = :ProductionLineID "
  8159. + " group by TP_PM_ProductionData.Procedureid "
  8160. + " order by TP_PM_ProductionData.Procedureid "
  8161. + " )temp left join tp_pc_procedure "
  8162. + " on tp_pc_procedure.procedureid=temp.procedureid ";
  8163. List<OracleParameter> parameters = new List<OracleParameter>();
  8164. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8165. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, RptProductionLineID, ParameterDirection.Input));
  8166. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8167. ServiceResultEntity sre = new ServiceResultEntity();
  8168. if (data == null || data.Rows.Count == 0)
  8169. {
  8170. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8171. return sre;
  8172. }
  8173. sre.Data = new DataSet();
  8174. sre.Data.Tables.Add(data);
  8175. return sre;
  8176. }
  8177. catch (Exception ex)
  8178. {
  8179. throw ex;
  8180. }
  8181. finally
  8182. {
  8183. if (conn != null &&
  8184. conn.ConnState == ConnectionState.Open)
  8185. {
  8186. conn.Close();
  8187. }
  8188. }
  8189. }
  8190. /// <summary>
  8191. /// 取得数据字典数据
  8192. /// </summary>
  8193. /// <param name="Pvalue">显示停用标识</param>
  8194. /// <param name="dictionaryType">字典类别</param>
  8195. /// <param name="user">登录用户信息</param>
  8196. /// <returns>查询结果</returns>
  8197. public static ServiceResultEntity GetRptDictionaryData(byte Pvalue, string dictionaryType, SUserInfo user)
  8198. {
  8199. IDBConnection conn = null;
  8200. try
  8201. {
  8202. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8203. string selSql = String.Empty;
  8204. List<OracleParameter> parameters = new List<OracleParameter>();
  8205. //根据帐套获得数据字典管理的数据
  8206. if (Pvalue.ToString() == Constant.INT_IS_ONE.ToString())
  8207. {
  8208. selSql = "Select DictionaryID,DictionaryType,DictionaryValue,DisplayNo,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,"
  8209. + "UpdateUserID,OPTimeStamp from TP_MST_DataDictionary where DictionaryType = :DictionaryType and AccountID = :AccountID";
  8210. parameters.Add(new OracleParameter(":DictionaryType", OracleDbType.NVarchar2, dictionaryType, ParameterDirection.Input));
  8211. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8212. }
  8213. //根据帐套,标识获得数据字典管理的数据
  8214. else if (Pvalue.ToString() == Constant.INT_IS_ZERO.ToString())
  8215. {
  8216. selSql = "Select DictionaryID,DictionaryType,DictionaryValue,DisplayNo,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,"
  8217. + "UpdateUserID,OPTimeStamp from TP_MST_DataDictionary where valueflag = :valueflag and DictionaryType = :DictionaryType and AccountID = :AccountID";
  8218. parameters.Add(new OracleParameter(":valueflag", OracleDbType.Int32, Constant.INT_IS_ONE, ParameterDirection.Input));
  8219. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8220. parameters.Add(new OracleParameter(":DictionaryType", OracleDbType.NVarchar2, dictionaryType, ParameterDirection.Input));
  8221. }
  8222. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8223. ServiceResultEntity sre = new ServiceResultEntity();
  8224. if (data == null || data.Rows.Count == 0)
  8225. {
  8226. //sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8227. return sre;
  8228. }
  8229. sre.Data = new DataSet();
  8230. sre.Data.Tables.Add(data);
  8231. return sre;
  8232. }
  8233. catch (Exception ex)
  8234. {
  8235. throw ex;
  8236. }
  8237. finally
  8238. {
  8239. if (conn != null &&
  8240. conn.ConnState == ConnectionState.Open)
  8241. {
  8242. conn.Close();
  8243. }
  8244. }
  8245. }
  8246. #endregion 公共函数
  8247. #endregion 统一使用Se模式rviceResultEntity类
  8248. /// <summary>
  8249. /// 获取注浆次数报表
  8250. /// </summary>
  8251. /// <param name="groutingLineEntity"></param>
  8252. /// <param name="user"></param>
  8253. /// <returns></returns>
  8254. public static ServiceResultEntity GetGroutingCount(GroutingLineEntity groutingLineEntity, SUserInfo user)
  8255. {
  8256. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8257. try
  8258. {
  8259. con.Open();
  8260. OracleParameter[] paras = new OracleParameter[]{
  8261. new OracleParameter("BuildingNo",OracleDbType.NVarchar2,
  8262. groutingLineEntity.BUILDINGNO,ParameterDirection.Input),
  8263. new OracleParameter("FloorNo",OracleDbType.NVarchar2,
  8264. groutingLineEntity.FLOORNO,ParameterDirection.Input),
  8265. new OracleParameter("GroutingLineNo",OracleDbType.NVarchar2,
  8266. groutingLineEntity.GROUTINGLINENO,ParameterDirection.Input),
  8267. new OracleParameter("GroutingLineCode",OracleDbType.NVarchar2,
  8268. groutingLineEntity.GROUTINGLINECODE,ParameterDirection.Input),
  8269. new OracleParameter("GroutingLineName",OracleDbType.NVarchar2,
  8270. groutingLineEntity.GROUTINGLINENAME,ParameterDirection.Input),
  8271. new OracleParameter("GMouldTypeID",OracleDbType.Int32,
  8272. groutingLineEntity.MOULDTYPEID,ParameterDirection.Input),
  8273. new OracleParameter("remarks",OracleDbType.NVarchar2,
  8274. groutingLineEntity.REMARKS,ParameterDirection.Input),
  8275. new OracleParameter("AccountID",OracleDbType.Int32,
  8276. user.AccountID,ParameterDirection.Input),
  8277. new OracleParameter("UserId",OracleDbType.Int32,
  8278. user.UserID,ParameterDirection.Input),
  8279. new OracleParameter("PurviewType",OracleDbType.Int32,
  8280. groutingLineEntity.Purview,ParameterDirection.Input),
  8281. new OracleParameter("rs_result",OracleDbType.RefCursor,
  8282. ParameterDirection.Output),
  8283. new OracleParameter("UserCode",OracleDbType.NVarchar2,
  8284. groutingLineEntity.USERCODE,ParameterDirection.Input),
  8285. };
  8286. //调用获取符合条件的成型线信息
  8287. DataSet ds = con.ExecStoredProcedure("PRO_RPT_GetGroutingCount", paras);
  8288. ServiceResultEntity sre = new ServiceResultEntity();
  8289. if (ds == null || ds.Tables[0].Rows.Count == 0)
  8290. {
  8291. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8292. return sre;
  8293. }
  8294. sre.Data = new DataSet();
  8295. //DataTable dt=ds.Tables[0];
  8296. sre.Data.Tables.Add(ds.Tables[0].Copy());
  8297. return sre;
  8298. }
  8299. catch (Exception ex)
  8300. {
  8301. throw ex;
  8302. }
  8303. finally
  8304. {
  8305. if (con.ConnState == ConnectionState.Open)
  8306. {
  8307. con.Close();
  8308. }
  8309. }
  8310. }
  8311. #region 在产产品汇总表
  8312. /// <summary>
  8313. /// 取得RPT030105(在产产品汇总表)的汇总信息查询数据
  8314. /// </summary>
  8315. /// <param name="user">登录用户信息</param>
  8316. /// <param name="se">查询条件</param>
  8317. /// <returns>查询结果</returns>
  8318. public static ServiceResultEntity GetRPT030105Data(SUserInfo user, RPT030105_SE se)
  8319. {
  8320. IDBConnection conn = null;
  8321. try
  8322. {
  8323. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8324. List<OracleParameter> parameters = new List<OracleParameter>();
  8325. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030105SQL(user, se, ref parameters));
  8326. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  8327. ServiceResultEntity sre = new ServiceResultEntity();
  8328. if (data == null || data.Rows.Count == 0)
  8329. {
  8330. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8331. return sre;
  8332. }
  8333. sre.Data = new DataSet();
  8334. sre.Data.Tables.Add(data);
  8335. return sre;
  8336. }
  8337. catch (Exception ex)
  8338. {
  8339. throw ex;
  8340. }
  8341. finally
  8342. {
  8343. if (conn != null &&
  8344. conn.ConnState == ConnectionState.Open)
  8345. {
  8346. conn.Close();
  8347. }
  8348. }
  8349. }
  8350. /// <summary>
  8351. /// 获取RPT030105画面(产品产量汇总表)的汇总信息查询sql
  8352. /// </summary>
  8353. /// <returns>sql</returns>
  8354. private static string GetRPT030105SQL(SUserInfo user, RPT030105_SE se, ref List<OracleParameter> parameters)
  8355. {
  8356. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8357. //"select " +
  8358. //" ProcedureID," +
  8359. //" procedurecode, " +
  8360. //" decode(Usercode, '小计', '--', procedurename) procedurename, " +
  8361. //" productionlineid, " +
  8362. //" productionlinecode, " +
  8363. //" decode(Usercode, '小计', '--', productionlinename) productionlinename, " +
  8364. //" decode(ProcedureID,'总计','总计',Usercode) Usercode, " +
  8365. //" subGoodsTypecode, " +
  8366. //" decode(usercode,'小计',decode(subGoodsTypecode,'001001','大件','小件'),Goodscode)Goodscode, " +
  8367. //" Goodstypename, " +
  8368. //" InCount " +
  8369. #region
  8370. /*
  8371. "select " +
  8372. " ProcedureID," +
  8373. " procedurecode, " +
  8374. " decode(productionlinename, '总计', '--', procedurename) procedurename, " +
  8375. " productionlineid, " +
  8376. " productionlinecode, " +
  8377. " productionlinename, " +
  8378. " decode(productionlinename, '--', '--', Usercode) Usercode, " +
  8379. " decode(productionlinename, '--', null, UserID) UserID, " +
  8380. " subGoodsTypecode, " +
  8381. " Goodsid," +
  8382. " Goodscode, " +
  8383. " Goodstypename, " +
  8384. " InCount from (" +
  8385. "select " +
  8386. " ProcedureID," +
  8387. " procedurecode, " +
  8388. " decode(usercode,'合计','合计', decode(usercode,'小计','--',decode(usercode,'--','--',procedurename))) procedurename, " +
  8389. " productionlineid, " +
  8390. " productionlinecode, " +
  8391. " decode(ProcedureID,'总计','总计',decode(usercode,'小计','--',productionlinename)) productionlinename, " +
  8392. " decode(ProcedureID,'总计','--',Usercode) Usercode, " +
  8393. " decode(ProcedureID,'总计',null,Userid) Userid, " +
  8394. " subGoodsTypecode, " +
  8395. " Goodsid," +
  8396. " Goodscode, " +
  8397. " decode(usercode,'小计','小计',Goodstypename)Goodstypename, " +
  8398. " InCount " +
  8399. "from " +
  8400. "(" +
  8401. " select " +
  8402. " ProcedureID, " +
  8403. " procedurecode, " +
  8404. " procedurename, " +
  8405. " productionlineid, " +
  8406. " productionlinecode, " +
  8407. " productionlinename, " +
  8408. " decode(procedurecode,'--','合计',Usercode) Usercode, " +
  8409. " decode(procedurecode,'--',null,Userid) Userid, " +
  8410. " subGoodsTypecode," +
  8411. " Goodsid," +
  8412. " Goodscode," +
  8413. " Goodstypename, " +
  8414. " InCount " +
  8415. " from ( select " +
  8416. " decode(grouping(tp_pc_procedure.ProcedureID),1,'总计',tp_pc_procedure.ProcedureID) ProcedureID," +
  8417. " decode(grouping(tp_pc_procedure.procedurecode),1,'--',tp_pc_procedure.procedurecode) procedurecode, " +
  8418. " decode(grouping(tp_pc_procedure.procedurename),1,'--',tp_pc_procedure.procedurename) procedurename, " +
  8419. " decode(grouping(tp_pm_inproduction.productionlineid),1,'--',tp_pm_inproduction.productionlineid) productionlineid, " +
  8420. " decode(grouping(tp_pm_inproduction.productionlinecode),1,'--',tp_pm_inproduction.productionlinecode) productionlinecode, " +
  8421. " decode(grouping(tp_pm_inproduction.productionlinename),1,'--',tp_pm_inproduction.productionlinename) productionlinename, " +
  8422. " decode(grouping(TP_MST_User.Usercode),1,'小计',TP_MST_User.Usercode) Usercode," +
  8423. " decode(grouping(TP_MST_User.Userid),1,null,TP_MST_User.Userid) Userid," +
  8424. " decode(grouping(substr(TP_MST_GoodsType.Goodstypecode,0,6)),1,'--',substr(TP_MST_GoodsType.Goodstypecode,0,6)) subGoodsTypecode," +
  8425. " decode(grouping(TP_MST_Goods.Goodscode),1,'--',TP_MST_Goods.Goodscode) Goodscode," +
  8426. " decode(grouping(TP_MST_Goods.Goodsid),1,'--',TP_MST_Goods.Goodsid) Goodsid," +
  8427. " decode(grouping(TP_MST_GoodsType.Goodstypename),1,'--',TP_MST_GoodsType.Goodstypename) Goodstypename," +
  8428. " count(barcode) as InCount " +
  8429. " from tp_pm_inproduction " +
  8430. " left join tp_pc_procedure" +
  8431. " on tp_pm_inproduction.FlowProcedureID=tp_pc_procedure.ProcedureID" +
  8432. " 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" +
  8433. " Where 1=1 " +
  8434. " and tp_pm_inproduction.AccountID=:AccountID and tp_pm_inproduction.valueflag=1";
  8435. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  8436. {
  8437. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1";
  8438. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1";
  8439. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  8440. }
  8441. if (!string.IsNullOrEmpty(se.LineIDS))
  8442. {
  8443. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||tp_pm_inproduction.ProductionLineId||',')>0 ";
  8444. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  8445. }
  8446. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  8447. {
  8448. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||tp_pm_inproduction.FlowProcedureId||',')>0 ";
  8449. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  8450. }
  8451. if (!string.IsNullOrEmpty(se.GoodsCode))
  8452. {
  8453. selSql = selSql + " AND instr(','||:GoodsCode||',',','||tp_pm_inproduction.goodsCode||',')>0 ";
  8454. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  8455. }
  8456. selSql = selSql +
  8457. "group by " +
  8458. " rollup(tp_pc_procedure.ProcedureID, " +
  8459. " tp_pc_procedure.procedurecode, " +
  8460. " tp_pc_procedure.procedurename, " +
  8461. " tp_pm_inproduction.productionlineid, " +
  8462. " tp_pm_inproduction.productionlinecode, " +
  8463. " tp_pm_inproduction.productionlinename, " +
  8464. " substr(TP_MST_GoodsType.Goodstypecode,0,6), " +
  8465. " TP_MST_User.Usercode," +
  8466. " TP_MST_Goods.Goodscode, " +
  8467. " TP_MST_User.UserID," +
  8468. " TP_MST_Goods.GoodsID, " +
  8469. " TP_MST_GoodsType.Goodstypename)) temp ) temp2 " +
  8470. "where 1=1 " +
  8471. "and (Goodstypename!='--')" +
  8472. "or (Goodstypename='--' and UserCode='小计' and subGoodsTypecode!='--') " +
  8473. "or (Goodstypename='--' and UserCode='合计') " +
  8474. "or (Goodstypename='--' and UserCode='总计') )";
  8475. */
  8476. #endregion
  8477. string sqlString = "select t.productionlineid\n" +
  8478. " ,t.productionlinecode\n" +
  8479. " ,decode(gid\n" +
  8480. " ,15\n" +
  8481. " ,'总计【' || t.productionlinename || '】'\n" +
  8482. " ,t.productionlinename) productionlinename\n" +
  8483. " ,t.ProcedureID\n" +
  8484. " ,t.procedurecode\n" +
  8485. " ,decode(gid, 3, '合计【' || t.procedurename || '】', t.procedurename) procedurename\n" +
  8486. " ,t.Goodstypeid2\n" +
  8487. " ,t.Goodstypecode2\n" +
  8488. " ,decode(gid, 1, '小计【' || t.Goodstypename2 || '】', t.Goodstypename2) Goodstypename2\n" +
  8489. " ,t.Goodsid\n" +
  8490. " ,t.Goodscode\n" +
  8491. " ,t.InCount\n" +
  8492. " from (select grouping_id(inp.productionlineid\n" +
  8493. " ,inp.ProcedureID\n" +
  8494. " ,gt2.Goodstypeid\n" +
  8495. " ,inp.Goodsid) gid\n" +
  8496. " ,inp.productionlineid\n" +
  8497. " ,pline.productionlinecode\n" +
  8498. " ,pline.productionlinename\n" +
  8499. " ,inp.ProcedureID\n" +
  8500. " ,p.procedurecode\n" +
  8501. " ,p.procedurename\n" +
  8502. " ,gt2.GoodstypeID GoodstypeID2\n" +
  8503. " ,gt2.Goodstypecode Goodstypecode2\n" +
  8504. " ,gt2.Goodstypename Goodstypename2\n" +
  8505. " ,inp.Goodsid\n" +
  8506. " ,g.Goodscode\n" +
  8507. " ,count(barcode) as InCount\n" +
  8508. " from tp_pm_inproduction inp\n" +
  8509. " inner join tp_pc_procedure p\n" +
  8510. " on inp.ProcedureID = p.ProcedureID\n" +
  8511. " inner join tp_pc_productionline pline\n" +
  8512. " on pline.productionlineid = inp.productionlineid\n" +
  8513. " inner join TP_MST_User u\n" +
  8514. " on inp.userid = u.Userid\n" +
  8515. " inner join TP_MST_Goods g\n" +
  8516. " on inp.goodsid = g.Goodsid\n" +
  8517. " inner join TP_MST_GoodsType gt\n" +
  8518. " on g.GoodsTypeID = gt.GoodsTypeID\n" +
  8519. " inner join TP_MST_GoodsType gt2\n" +
  8520. " on gt.accountid = gt2.accountid\n" +
  8521. " and substr(gt.Goodstypecode, 0, 6) = gt2.Goodstypecode\n" +
  8522. " where inp.AccountID = 1\n" +
  8523. " and inp.valueflag = '1'\n";
  8524. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  8525. {
  8526. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1";
  8527. sqlString += " AND instr(gt.GOODSTYPECode,:GoodsTypeIDS)=1";
  8528. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  8529. }
  8530. if (!string.IsNullOrEmpty(se.LineIDS))
  8531. {
  8532. sqlString += " AND instr(','||:ProductionLineIDS||',',','||inp.ProductionLineId||',')>0 ";
  8533. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  8534. }
  8535. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  8536. {
  8537. sqlString += " AND instr(','||:ProcedureIDS||',',','||inp.ProcedureId||',')>0 ";
  8538. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  8539. }
  8540. if (!string.IsNullOrEmpty(se.GoodsCode))
  8541. {
  8542. sqlString += " AND instr(','||:GoodsCode||',',','||inp.goodsCode||',')>0 ";
  8543. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  8544. }
  8545. 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";
  8546. return sqlString;
  8547. }
  8548. /// <summary>
  8549. /// 取得RPT030105(在产产品汇总表)的汇总信息查询数据
  8550. /// </summary>
  8551. /// <param name="user">登录用户信息</param>
  8552. /// <param name="se">查询条件</param>
  8553. /// <returns>查询结果</returns>
  8554. public static ServiceResultEntity GetRPT030105IData(SUserInfo user, RPT030105_SE se)
  8555. {
  8556. IDBConnection conn = null;
  8557. try
  8558. {
  8559. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8560. List<OracleParameter> parameters = new List<OracleParameter>();
  8561. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030105ISQL(user, se, ref parameters));
  8562. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8563. if (se != null)
  8564. {
  8565. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  8566. {
  8567. //sql.Append(" AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1");
  8568. sql.Append(" AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1");
  8569. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  8570. }
  8571. if (!string.IsNullOrEmpty(se.LineIDS))
  8572. {
  8573. sql.Append(" AND instr(','||:ProductionLineIDS||',',','||tp_pm_inproduction.ProductionLineId||',')>0 ");
  8574. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  8575. }
  8576. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  8577. {
  8578. sql.Append(" AND instr(','||:ProcedureIDS||',',','||tp_pm_inproduction.FlowProcedureId||',')>0 ");
  8579. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  8580. }
  8581. if (!string.IsNullOrEmpty(se.GoodsCode))
  8582. {
  8583. sql.Append(" AND instr(','||:GoodsCode||',',','||tp_pm_inproduction.goodsCode||',')>0 ");
  8584. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  8585. }
  8586. // 总单点击查询用
  8587. if (se.GoodsID.HasValue)
  8588. {
  8589. sql.Append(" AND tp_pm_inproduction.Goodsid = :GoodsID ");
  8590. parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  8591. }
  8592. if (se.UserID.HasValue)
  8593. {
  8594. sql.Append(" AND A.userid = :userid ");
  8595. parameters.Add(new OracleParameter(":userid", OracleDbType.Int32, se.UserID, ParameterDirection.Input));
  8596. }
  8597. }
  8598. sql.Append(" order by TP_PM_InProduction.UpdateTime desc");
  8599. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  8600. ServiceResultEntity sre = new ServiceResultEntity();
  8601. if (data == null || data.Rows.Count == 0)
  8602. {
  8603. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8604. return sre;
  8605. }
  8606. sre.Data = new DataSet();
  8607. sre.Data.Tables.Add(data);
  8608. return sre;
  8609. }
  8610. catch (Exception ex)
  8611. {
  8612. throw ex;
  8613. }
  8614. finally
  8615. {
  8616. if (conn != null &&
  8617. conn.ConnState == ConnectionState.Open)
  8618. {
  8619. conn.Close();
  8620. }
  8621. }
  8622. }
  8623. /// <summary>
  8624. /// 获取RPT030105画面(产品产量汇总表)的汇总信息查询sql
  8625. /// </summary>
  8626. /// <returns>sql</returns>
  8627. private static string GetRPT030105ISQL(SUserInfo user, RPT030105_SE se, ref List<OracleParameter> parameters)
  8628. {
  8629. string selSql =
  8630. "SELECT " +
  8631. " TP_PM_InProduction.BarCode, " +
  8632. " TP_PM_InProduction.GoodsID,TP_PM_InProduction.GoodsCode, " +
  8633. " TP_PM_InProduction.GoodsName, " +
  8634. " TP_PM_InProduction.Userid,A.USERNAME as UserName,A.USERCode as UserCode, " +
  8635. " TP_PM_InProduction.ProductionLineID, " +
  8636. " TP_PM_InProduction.ProductionLineCode, " +
  8637. " TP_PM_InProduction.ProductionLineName, " +
  8638. " TP_PM_InProduction.ModelType, " +
  8639. " decode(TP_PM_InProduction.inscrapflag , '1', '待审核的报废品' , '正常') as inscrapflag, " +
  8640. //" decode(TP_PM_InProduction.IsPublicBody, '1', '是' , '否') as IsPublicBody, " +
  8641. //" decode(TP_PM_InProduction.IsReFire, '1', '是' , '否') as IsReFire, " +
  8642. " TP_PM_InProduction.IsPublicBody, " +
  8643. " decode(TP_PM_InProduction.IsReFire, '6', '1' , '0') as IsReFire, " +
  8644. " decode(TP_PM_InProduction.CanManyTimes, '1', '能' , '不能') as CanManyTimes, " +
  8645. " decode(TP_PM_InProduction.ProcedureModel, '1', '计件模型' , '检验模型') as ProcedureModel, " +
  8646. " TP_PM_InProduction.GroutingDailyID, " +
  8647. " TP_PM_InProduction.GroutingDailyDetailID, " +
  8648. " TP_PM_InProduction.GroutingDate, " +
  8649. " TP_PM_InProduction.GroutingLineID, " +
  8650. " TP_PM_InProduction.GroutingLineCode, " +
  8651. " TP_PM_InProduction.GroutingLineName, " +
  8652. " TP_PM_InProduction.ProcedureID CompleteProcedureID, " +
  8653. " D.ProcedureName as CompleteProcedureName, " +
  8654. " TP_PM_InProduction.GMouldTypeID, " +
  8655. " TP_MST_GMouldType.GMOULDTYPENAME as GMouldTypeName, " +
  8656. " TP_PM_InProduction.GroutingLineDetailID, " +
  8657. " TP_PM_InProduction.GroutingMouldCode, " +
  8658. " TP_PM_InProduction.SPECIALREPAIRFLAG, " +
  8659. " TP_PM_InProduction.GROUTINGUSERCODE, " +
  8660. " TP_PM_GroutingDailyDetail.GROUTINGCOUNT, " +
  8661. " TP_PM_InProduction.Remarks, " +
  8662. " TP_PM_GroutingDailyDetail.glazingroom," +
  8663. " TP_PM_InProduction.GoodsLevelID,TP_MST_GoodsLevel.GOODSLEVELNAME, " +
  8664. " TP_PM_InProduction.GoodsLevelTypeID,TP_SYS_GoodsLevelType.GOODSLEVELTYPENAME, " +
  8665. " TP_PM_InProduction.AccountID,TP_PM_InProduction.ValueFlag, " +
  8666. " TP_PM_InProduction.CreateTime,TP_PM_InProduction.CreateUserID,B.USERNAME as CreateUserName, " +
  8667. " TP_PM_InProduction.PROCEDURETIME AS UpdateTime,TP_PM_InProduction.UpdateUserID,C.USERNAME as UpdateUserName, " +
  8668. " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName " +
  8669. "FROM TP_PM_InProduction " +
  8670. " inner join TP_MST_User A on A.UserID=TP_PM_InProduction.Userid " +
  8671. " inner join TP_MST_User B on B.UserID=TP_PM_InProduction.CreateUserID " +
  8672. " inner join TP_MST_User C on C.UserID=TP_PM_InProduction.UpdateUserID " +
  8673. " inner join TP_PC_Procedure D on D.PROCEDUREID=TP_PM_InProduction.ProcedureID " +
  8674. " inner join TP_MST_GMouldType on TP_MST_GMouldType.GMouldTypeID=TP_PM_InProduction.GMouldTypeID " +
  8675. " inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.ProcedureModelTypeID=TP_PM_InProduction.ModelType " +
  8676. " inner join TP_PM_GroutingDaily on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_InProduction.GroutingDailyID " +
  8677. " inner join TP_PM_GroutingDailyDetail on TP_PM_GroutingDailyDetail.Groutingdailydetailid=TP_PM_InProduction.GroutingDailyDetailID " +
  8678. " inner join TP_PC_GroutingLineDetail on TP_PC_GroutingLineDetail.Groutinglinedetailid=TP_PM_InProduction.GroutingLineDetailID " +
  8679. " inner join TP_MST_Account on TP_MST_Account.Accountid=TP_PM_InProduction.Accountid " +
  8680. " left join TP_MST_GoodsLevel on TP_MST_GoodsLevel.GoodsLevelID=TP_PM_InProduction.GoodsLevelID " +
  8681. " left join TP_SYS_GoodsLevelType on TP_SYS_GoodsLevelType.GoodsLevelTypeID=TP_PM_InProduction.GoodsLevelTypeID " +
  8682. " left join TP_MST_Logo on TP_PM_InProduction.logoid=TP_MST_Logo.logoid " +
  8683. " left join TP_MST_Goods on tp_pm_inproduction.goodsid=TP_MST_Goods.Goodsid " +
  8684. " left join TP_MST_GoodsType on TP_MST_Goods.GoodsTypeID=TP_MST_GoodsType.GoodsTypeID" +
  8685. " Where 1=1 and TP_PM_InProduction.ValueFlag = 1 " +
  8686. " and TP_PM_InProduction.AccountID=:AccountID ";
  8687. return selSql;
  8688. }
  8689. #endregion
  8690. /// <summary>
  8691. /// 取得RPT030106(成检缺陷汇总表)的汇总信息查询数据
  8692. /// </summary>
  8693. /// <param name="user">登录用户信息</param>
  8694. /// <param name="se">查询条件</param>
  8695. /// <returns>查询结果</returns>
  8696. public static ServiceResultEntity GetRPT030106Data(SUserInfo user, RPT030106_SE se)
  8697. {
  8698. IDBConnection conn = null;
  8699. try
  8700. {
  8701. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8702. List<OracleParameter> parameters = new List<OracleParameter>();
  8703. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106SQL(user, se, ref parameters));
  8704. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  8705. ServiceResultEntity sre = new ServiceResultEntity();
  8706. if (data == null || data.Rows.Count == 0)
  8707. {
  8708. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8709. return sre;
  8710. }
  8711. sre.Data = new DataSet();
  8712. sre.Data.Tables.Add(data);
  8713. return sre;
  8714. }
  8715. catch (Exception ex)
  8716. {
  8717. throw ex;
  8718. }
  8719. finally
  8720. {
  8721. if (conn != null &&
  8722. conn.ConnState == ConnectionState.Open)
  8723. {
  8724. conn.Close();
  8725. }
  8726. }
  8727. }
  8728. /// <summary>
  8729. /// 获取RPT030106画面(成检缺陷汇总表)的汇总信息查询sql
  8730. /// </summary>
  8731. /// <returns>sql</returns>
  8732. private static string GetRPT030106SQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
  8733. {
  8734. #region
  8735. //string selSql = "";
  8736. //parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8737. //selSql = selSql +
  8738. // "select " +
  8739. // " DefectProcedureID," +
  8740. // " DefectProcedureCode, " +
  8741. // " decode(DefectProcedureID, '总计', '--', decode(DefectCode, '小计', decode(DefectProcedureName, '', '', '--'), DefectProcedureName)) DefectProcedureName," +
  8742. // " ProductionLineID, " +
  8743. // " ProductionLineCode," +
  8744. // " decode(DefectProcedureID, '总计', '总计', decode(DefectCode, '小计', '--', ProductionLineName)) ProductionLineName, " +
  8745. // " ProcedureID, " +
  8746. // " ProcedureCode," +
  8747. // " decode(DefectCode, '小计', '--', ProcedureName) ProcedureName," +
  8748. // " DefectCode, " +
  8749. // " DefectName, " +
  8750. // " DefectTypeName, " +
  8751. // " Userid," +
  8752. // " Usercode," +
  8753. // " Username," +
  8754. // " Goodstypename," +
  8755. // " Goodsid," +
  8756. // " Goodscode," +
  8757. // " Goodsname," +
  8758. // " InCount from (" +
  8759. // "select " +
  8760. // " DefectProcedureID," +
  8761. // " DefectProcedureCode, " +
  8762. // " decode(DefectProcedureCode, '--', '合计', DefectProcedureName) DefectProcedureName, " +
  8763. // " ProductionLineID, " +
  8764. // " ProductionLineCode, " +
  8765. // " ProductionLineName, " +
  8766. // " ProcedureID, " +
  8767. // " ProcedureCode, " +
  8768. // " ProcedureName, " +
  8769. // " decode(DefectName, '--', decode(DefectCode, '--', '--', '小计'), DefectCode) DefectCode, " +
  8770. // " DefectName, " +
  8771. // " DefectTypeName, " +
  8772. // " Userid, " +
  8773. // " Usercode, " +
  8774. // " Username, " +
  8775. // " Goodstypename, " +
  8776. // " Goodsid, " +
  8777. // " Goodscode, " +
  8778. // " Goodsname, " +
  8779. // " InCount " +
  8780. // "from " +
  8781. // "(" +
  8782. // " select " +
  8783. // " decode(grouping(TP_PM_Defect.DefectProcedureID),1,'总计',TP_PM_Defect.DefectProcedureID) DefectProcedureID, " +
  8784. // " decode(grouping(TP_PM_Defect.DefectProcedureCode),1,'--',TP_PM_Defect.DefectProcedureCode) DefectProcedureCode, " +
  8785. // " decode(grouping(TP_PM_Defect.DefectProcedureName),1,'--',TP_PM_Defect.DefectProcedureName) DefectProcedureName, " +
  8786. // " decode(grouping(TP_PM_Defect.ProductionLineID),1,'--',TP_PM_Defect.ProductionLineID) ProductionLineID, " +
  8787. // " decode(grouping(TP_PM_Defect.ProductionLineCode),1,'--',TP_PM_Defect.ProductionLineCode) ProductionLineCode, " +
  8788. // " decode(grouping(TP_PM_Defect.ProductionLineName),1,'--',TP_PM_Defect.ProductionLineName) ProductionLineName, " +
  8789. // " decode(grouping(TP_PM_Defect.ProcedureID),1,'--',TP_PM_Defect.ProcedureID) ProcedureID, " +
  8790. // " decode(grouping(TP_PM_Defect.ProcedureCode),1,'--',TP_PM_Defect.ProcedureCode) ProcedureCode," +
  8791. // " decode(grouping(TP_PM_Defect.ProcedureName),1,'--',TP_PM_Defect.ProcedureName) ProcedureName," +
  8792. // " decode(grouping(TP_PM_Defect.DefectCode),1,'--',TP_PM_Defect.DefectCode) DefectCode, " +
  8793. // " decode(grouping(TP_PM_Defect.DefectName),1,'--',TP_PM_Defect.DefectName) DefectName, " +
  8794. // " decode(grouping(TP_MST_DefectType.DefectTypeName),1,'--',TP_MST_DefectType.DefectTypeName) DefectTypeName, " +
  8795. // " decode(grouping(TP_PM_Defect.Userid),1,'--',TP_PM_Defect.Userid) Userid, " +
  8796. // " decode(grouping(TP_PM_Defect.Usercode),1,'--',TP_PM_Defect.Usercode) Usercode, " +
  8797. // " decode(grouping(TP_PM_Defect.Username),1,'--',TP_PM_Defect.Username) Username, " +
  8798. // " decode(grouping(TP_MST_GoodsType.Goodstypename),1,'--',TP_MST_GoodsType.Goodstypename) Goodstypename, " +
  8799. // " decode(grouping(TP_PM_Defect.Goodsid),1,'--',TP_PM_Defect.Goodsid) Goodsid, " +
  8800. // " decode(grouping(TP_PM_Defect.Goodscode),1,'--',TP_PM_Defect.Goodscode) Goodscode, " +
  8801. // " decode(grouping(TP_PM_Defect.Goodsname),1,'--',TP_PM_Defect.Goodscode) Goodsname, " +
  8802. // " count(TP_PM_Defect.barcode) as InCount " +
  8803. // " from TP_PM_Defect " +
  8804. // " left join tp_pc_procedure on TP_PM_Defect.ProcedureID=tp_pc_procedure.ProcedureID " +
  8805. // " left join TP_MST_Goods on TP_PM_Defect.Goodsid=TP_MST_Goods.Goodsid" +
  8806. // " left join TP_MST_GoodsType on TP_MST_Goods.GoodsTypeID = TP_MST_GoodsType.GoodsTypeID" +
  8807. // " left join TP_MST_Defect on TP_PM_Defect.DefectID=TP_MST_Defect.DefectID" +
  8808. // " left join TP_MST_DefectType on TP_MST_Defect.DefectTypeID=TP_MST_DefectType.DefectTypeID" +
  8809. // " left join TP_PM_ProductionData on TP_PM_ProductionData.ProductionDataID=TP_PM_Defect.ProductionDataID" +
  8810. // " Where TP_PM_Defect.valueflag=1 and tp_pc_procedure.ModelType=-1" +
  8811. // " and TP_PM_Defect.AccountID=:AccountID ";
  8812. //if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  8813. //{
  8814. // selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeCode)=1 ";
  8815. // parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  8816. //}
  8817. //if (!string.IsNullOrEmpty(se.LineIDS))
  8818. //{
  8819. // selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_Defect.ProductionLineId||',')>0 ";
  8820. // parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  8821. //}
  8822. //if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  8823. //{
  8824. // //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  8825. // selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 ) ";
  8826. // parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  8827. //}
  8828. //else
  8829. //{
  8830. // // modify by chenxy :没有选择时,应全查询出来。
  8831. // //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  8832. //}
  8833. //if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  8834. //{
  8835. // selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_Defect.ProcedureID||',')>0 ";
  8836. // parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  8837. //}
  8838. //if (!string.IsNullOrEmpty(se.KilnCode))
  8839. //{
  8840. // selSql = selSql + " AND instr(tp_pm_productiondata.KilnCode,:KilnCode) >0 ";
  8841. // parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  8842. //}
  8843. //if (!string.IsNullOrEmpty(se.GoodsIDS))
  8844. //{
  8845. // selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_Defect.Goodsid||',')>0 ";
  8846. // parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  8847. //}
  8848. //if (!string.IsNullOrEmpty(se.GoodsCode))
  8849. //{
  8850. // selSql = selSql + " AND instr(TP_PM_Defect.goodsCode,:GoodsCode) >0 ";
  8851. // parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  8852. //}
  8853. //if (!string.IsNullOrEmpty(se.DefectUserCode))
  8854. //{
  8855. // selSql = selSql + " AND instr(TP_PM_Defect.DefectUserCode,:DefectUserCode) >0 ";
  8856. // parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  8857. //}
  8858. //if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  8859. //{
  8860. // selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||TP_MST_DefectType.DefectTypeID||',')>0 ";
  8861. // parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  8862. //}
  8863. //if (!string.IsNullOrEmpty(se.DefectCode))
  8864. //{
  8865. // selSql = selSql + " AND instr(TP_PM_Defect.DefectCode,:DefectCode) >0 ";
  8866. // parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  8867. //}
  8868. //if (!string.IsNullOrEmpty(se.DefectName))
  8869. //{
  8870. // selSql = selSql + " AND instr(TP_PM_Defect.DefectName,:DefectName) >0";
  8871. // parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  8872. //}
  8873. //if (!string.IsNullOrEmpty(se.CheckUserCode))
  8874. //{
  8875. // selSql = selSql + " AND instr(TP_PM_Defect.UserCode,:UserCode) >0";
  8876. // parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  8877. //}
  8878. //if (se.CreateTimeStart.HasValue)
  8879. //{
  8880. // selSql = selSql + " AND TP_PM_Defect.CreateTime>= :CreateTimeStart ";
  8881. // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  8882. //}
  8883. //if (se.CreateTimeEnd.HasValue)
  8884. //{
  8885. // selSql = selSql + " AND TP_PM_Defect.CreateTime<= :CreateTimeEnd ";
  8886. // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  8887. //}
  8888. //selSql = selSql +
  8889. // "group by " +
  8890. // " rollup(TP_PM_Defect.DefectProcedureID, " +
  8891. // " TP_PM_Defect.DefectProcedureCode, " +
  8892. // " TP_PM_Defect.DefectProcedureName, " +
  8893. // " TP_PM_Defect.ProductionLineID, " +
  8894. // " TP_PM_Defect.ProductionLineCode, " +
  8895. // " TP_PM_Defect.ProductionLineName, " +
  8896. // " TP_PM_Defect.ProcedureID, " +
  8897. // " TP_PM_Defect.ProcedureCode," +
  8898. // " TP_PM_Defect.ProcedureName, " +
  8899. // " TP_PM_Defect.DefectCode, " +
  8900. // " TP_PM_Defect.DefectName, " +
  8901. // " TP_MST_DefectType.DefectTypeName, " +
  8902. // " TP_PM_Defect.Userid, " +
  8903. // " TP_PM_Defect.Usercode, " +
  8904. // " TP_PM_Defect.Username, " +
  8905. // " TP_MST_GoodsType.Goodstypename, " +
  8906. // " TP_PM_Defect.Goodsid, " +
  8907. // " TP_PM_Defect.Goodscode, " +
  8908. // " TP_PM_Defect.Goodsname " +
  8909. // " )) temp ) temp2 " +
  8910. // "where 1=1 " +
  8911. // "and ((Goodsname!='--' )" +
  8912. // "or (Goodsname='--' and defectcode='小计')" +
  8913. // "or (Goodsname='--' and DefectProcedurename='合计') " +
  8914. // "or (Goodsname='--' and DefectProcedureID='总计'))";
  8915. //////----------------------
  8916. ////if (!string.IsNullOrEmpty(se.CompleteProcedureIDS))
  8917. ////{
  8918. //// selSql = selSql + @" AND exists(select 1 from tp_pm_productiondata where (instr(','||:CompleteProcedureIDS||',',','||ProcedureID||',')>0 ";
  8919. //// parameters.Add(new OracleParameter(":CompleteProcedureIDS", OracleDbType.NVarchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  8920. //// selSql = selSql + " AND TP_PM_ProductionData.CreateTime>= :CompleteCreateTimeStart ";
  8921. //// parameters.Add(new OracleParameter(":CompleteCreateTimeStart", OracleDbType.Date, se.CompleteCreateTimeStart.Value, ParameterDirection.Input));
  8922. //// selSql = selSql + " AND TP_PM_ProductionData.CreateTime<= :CompleteCreateTimeEnd )) ";
  8923. //// parameters.Add(new OracleParameter(":CompleteCreateTimeEnd", OracleDbType.Date, se.CompleteCreateTimeEnd.Value, ParameterDirection.Input));
  8924. ////}
  8925. //////----------------------
  8926. //return selSql;
  8927. #endregion
  8928. string selSql =
  8929. "SELECT t.ProductionLineID\n" +
  8930. " ,t.ProductionLineCode\n" +
  8931. " ,decode(t.gid, 31, '总计', 0, t.ProductionLineName, '--') ProductionLineName\n" +
  8932. " ,t.ProcedureID\n" +
  8933. " ,t.ProcedureCode\n" +
  8934. " ,decode(t.gid, 0, t.ProcedureName, '--') ProcedureName\n" +
  8935. " ,t.DefectProcedureID\n" +
  8936. " ,t.DefectProcedureCode\n" +
  8937. " ,decode(t.gid,\n" +
  8938. " 7,\n" +
  8939. " '合计【' || t.DefectProcedureName || '】',\n" +
  8940. " 0,\n" +
  8941. " t.DefectProcedureName,\n" +
  8942. " '--') DefectProcedureName\n" +
  8943. " ,decode(t.gid, 0, t.DefectCode, '--') DefectCode\n" +
  8944. " ,decode(t.gid,\n" +
  8945. " 3,\n" +
  8946. " '小计【[' || t.DefectCode || ']' || t.DefectName || '】',\n" +
  8947. " 0,\n" +
  8948. " t.DefectName,\n" +
  8949. " '--') DefectName\n" +
  8950. " ,decode(t.gid, 0, t.DefectTypeName, '--') DefectTypeName\n" +
  8951. " --,decode(t.gid, 0, t.Userid, '--') Userid\n" +
  8952. " ,t.Userid\n" +
  8953. " ,decode(t.gid, 0, t.Usercode, '--') Usercode\n" +
  8954. " ,decode(t.gid, 0, t.Username, '--') Username\n" +
  8955. " ,decode(t.gid, 0, t.Goodstypename, '--') Goodstypename\n" +
  8956. " --,decode(t.gid, 0, t.Goodsid, '--') Goodsid\n" +
  8957. " ,t.Goodsid\n" +
  8958. " ,decode(t.gid, 0, t.Goodscode, '--') Goodscode\n" +
  8959. " ,decode(t.gid, 0, t.Goodsname, '--') Goodsname\n" +
  8960. " ,t.InCount\n" +
  8961. " FROM (SELECT grouping_id(pmd.ProductionLineID,\n" +
  8962. " pmd.DefectProcedureID,\n" +
  8963. " pmd.DefectCode,\n" +
  8964. " pmd.userid,\n" +
  8965. " pmd.goodsid) gid\n" +
  8966. " ,pmd.ProductionLineID\n" +
  8967. " ,pmd.ProductionLineCode\n" +
  8968. " ,pmd.ProductionLineName\n" +
  8969. " ,pmd.ProcedureID\n" +
  8970. " ,pmd.ProcedureCode\n" +
  8971. " ,pmd.ProcedureName\n" +
  8972. " ,pmd.DefectProcedureID\n" +
  8973. " ,pmd.DefectProcedureCode\n" +
  8974. " ,pmd.DefectProcedureName\n" +
  8975. " ,pmd.DefectCode\n" +
  8976. " ,pmd.DefectName\n" +
  8977. " ,dt.DefectTypeName\n" +
  8978. " ,pmd.Userid\n" +
  8979. " ,pmd.Usercode\n" +
  8980. " ,pmd.Username\n" +
  8981. " ,gt.Goodstypename\n" +
  8982. " ,pmd.Goodsid\n" +
  8983. " ,pmd.Goodscode\n" +
  8984. " ,pmd.Goodsname\n" +
  8985. " ,COUNT(pmd.barcode) InCount\n" +
  8986. " FROM tp_pm_defect pmd\n" +
  8987. " LEFT JOIN TP_MST_Goods g\n" +
  8988. " ON pmd.Goodsid = g.Goodsid\n" +
  8989. " LEFT JOIN TP_MST_GoodsType gt\n" +
  8990. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  8991. " LEFT JOIN TP_MST_Defect mstd\n" +
  8992. " ON pmd.DefectID = mstd.DefectID\n" +
  8993. " LEFT JOIN TP_MST_DefectType dt\n" +
  8994. " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
  8995. " INNER JOIN tp_pm_productiondata pd\n" +
  8996. " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
  8997. " -- 交接工序\n" +
  8998. " INNER JOIN tp_pm_productiondata hopd\n" +
  8999. " ON hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  9000. " AND hopd.valueflag = '1'\n" +
  9001. " AND hopd.barcode = pd.barcode\n" +
  9002. " AND hopd.kilncarbatchno = pd.kilncarbatchno\n" +
  9003. " WHERE pmd.valueflag = '1'\n" +
  9004. " AND pd.ModelType = -1\n" +
  9005. " AND pmd.AccountID = :AccountID\n";
  9006. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  9007. parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
  9008. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  9009. {
  9010. selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
  9011. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  9012. }
  9013. if (!string.IsNullOrEmpty(se.LineIDS))
  9014. {
  9015. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
  9016. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  9017. }
  9018. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  9019. {
  9020. //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  9021. selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
  9022. parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  9023. }
  9024. else
  9025. {
  9026. // modify by chenxy :没有选择时,应全查询出来。
  9027. //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  9028. }
  9029. if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  9030. {
  9031. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
  9032. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  9033. }
  9034. if (!string.IsNullOrEmpty(se.KilnCode))
  9035. {
  9036. selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
  9037. parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  9038. }
  9039. if (!string.IsNullOrEmpty(se.GoodsIDS))
  9040. {
  9041. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
  9042. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  9043. }
  9044. if (!string.IsNullOrEmpty(se.GoodsCode))
  9045. {
  9046. selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
  9047. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  9048. }
  9049. if (!string.IsNullOrEmpty(se.DefectUserCode))
  9050. {
  9051. selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
  9052. parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  9053. }
  9054. if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  9055. {
  9056. selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
  9057. parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  9058. }
  9059. if (!string.IsNullOrEmpty(se.DefectCode))
  9060. {
  9061. selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
  9062. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  9063. }
  9064. if (!string.IsNullOrEmpty(se.DefectName))
  9065. {
  9066. selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
  9067. parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  9068. }
  9069. if (!string.IsNullOrEmpty(se.CheckUserCode))
  9070. {
  9071. selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
  9072. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  9073. }
  9074. if (se.CreateTimeStart.HasValue)
  9075. {
  9076. selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
  9077. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9078. }
  9079. if (se.CreateTimeEnd.HasValue)
  9080. {
  9081. selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
  9082. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9083. }
  9084. // 交接时间
  9085. if (se.HandOverTimeStart.HasValue)
  9086. {
  9087. selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
  9088. parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
  9089. }
  9090. if (se.HandOverTimeEnd.HasValue)
  9091. {
  9092. selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
  9093. parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
  9094. }
  9095. selSql = selSql +
  9096. " 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" +
  9097. " ORDER BY pmd.ProductionLineCode\n" +
  9098. " ,pmd.ProcedureCode\n" +
  9099. " ,pmd.DefectProcedureCode\n" +
  9100. " ,pmd.DefectCode\n" +
  9101. " ,pmd.Usercode\n" +
  9102. " ,pmd.Goodscode) t";
  9103. return selSql;
  9104. }
  9105. /// <summary>
  9106. /// 取得RPT030106(成检缺陷汇总表-明细)的汇总信息查询数据
  9107. /// </summary>
  9108. /// <param name="user">登录用户信息</param>
  9109. /// <param name="se">查询条件</param>
  9110. /// <returns>查询结果</returns>
  9111. public static ServiceResultEntity GetRPT030106IData(SUserInfo user, RPT030106_SE se)
  9112. {
  9113. IDBConnection conn = null;
  9114. try
  9115. {
  9116. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  9117. List<OracleParameter> parameters = new List<OracleParameter>();
  9118. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106ISQL(user, se, ref parameters));
  9119. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  9120. ServiceResultEntity sre = new ServiceResultEntity();
  9121. if (data == null || data.Rows.Count == 0)
  9122. {
  9123. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  9124. return sre;
  9125. }
  9126. sre.Data = new DataSet();
  9127. sre.Data.Tables.Add(data);
  9128. return sre;
  9129. }
  9130. catch (Exception ex)
  9131. {
  9132. throw ex;
  9133. }
  9134. finally
  9135. {
  9136. if (conn != null &&
  9137. conn.ConnState == ConnectionState.Open)
  9138. {
  9139. conn.Close();
  9140. }
  9141. }
  9142. }
  9143. /// <summary>
  9144. /// 获取RPT030106画面(成检缺陷汇总表-明细)的汇总信息查询sql
  9145. /// </summary>
  9146. /// <returns>sql</returns>
  9147. private static string GetRPT030106ISQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
  9148. {
  9149. // string selSql = @"select
  9150. // tp_pm_defect.productionlinename,
  9151. // tp_pm_defect.procedurename,
  9152. // tp_pm_defect.DefectProcedureCode,
  9153. // tp_pm_defect.DefectProcedureName,
  9154. // tp_pm_defect.DefectUserCode,
  9155. // tp_pm_defect.defectusername,
  9156. // tp_mst_defectType.DefectTypeName,
  9157. // TP_MST_Defect.Remarks DefectRemarks,
  9158. // tp_pm_defect.defectcode,
  9159. // tp_pm_defect.defectname,
  9160. // tp_pm_defect.UserCode,
  9161. // tp_pm_defect.username,
  9162. // tp_mst_goodstype.Goodstypename,
  9163. // tp_pm_defect.goodscode,
  9164. // tp_pm_defect.barcode,
  9165. // tp_pm_productiondata.groutingdate,
  9166. // tp_pm_productiondata.groutingnum,
  9167. // tp_pm_productiondata.groutingMouldCode,
  9168. // tp_pm_productiondata.KilnCarCode,
  9169. // tp_pm_productiondata.Procedureid,
  9170. // decode(TP_PM_ProductionData.Goodsleveltypeid, '4', '正品' , '5','副品','6','重烧','7','次品','') as Goodsleveltype,
  9171. // tp_pm_defect.DefectPositionCode,
  9172. // tp_pm_defect.DefectPositionName,
  9173. // tp_pm_productiondata.GroutingUserCode,
  9174. // --replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName
  9175. // decode(TP_MST_Logo.Logocode, null, null,TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']')) as LogoCodeName
  9176. // ,TP_PM_Defect.CreateTime
  9177. // ,(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
  9178. // ,TP_MST_DefectFine.DefectFineCode
  9179. // ,TP_PM_Defect.DefectDeductionNum
  9180. // from tp_pm_defect
  9181. // left join TP_MST_Goods
  9182. // on TP_PM_Defect.Goodsid=TP_MST_Goods.Goodsid
  9183. // left join TP_MST_GoodsType
  9184. // on TP_MST_Goods.GoodsTypeID = TP_MST_GoodsType.GoodsTypeID
  9185. // left join TP_MST_Defect
  9186. // on TP_PM_Defect.DefectID=TP_MST_Defect.DefectID
  9187. // left join TP_MST_DefectType
  9188. // on TP_MST_Defect.DefectTypeID=TP_MST_DefectType.DefectTypeID
  9189. // inner join tp_pm_productiondata
  9190. // on tp_pm_defect.ProductionDataID=tp_pm_productiondata.ProductionDataID
  9191. // left join TP_MST_DefectFine
  9192. // on tp_pm_defect.DefectFine=TP_MST_DefectFine.DefectFineID
  9193. // left join tp_mst_logo
  9194. // on tp_pm_productiondata.logoid=tp_mst_logo.logoid";
  9195. // 质量登记改判时,缺陷的登记时间是当前时间,不是交接或前次登记时间。
  9196. // 追加交接时间,改判标识。
  9197. string selSql =
  9198. "SELECT pmd.productionlinename\n" +
  9199. " ,pmd.procedurename\n" +
  9200. " ,pmd.DefectProcedureCode\n" +
  9201. " ,pmd.DefectProcedureName\n" +
  9202. " ,pmd.DefectUserCode\n" +
  9203. " ,pmd.defectusername\n" +
  9204. " ,dt.DefectTypeName\n" +
  9205. " ,mstd.Remarks DefectRemarks\n" +
  9206. " ,pmd.defectcode\n" +
  9207. " ,d.alldefectcode\n" +
  9208. " ,pmd.defectname\n" +
  9209. " ,pmd.UserCode\n" +
  9210. " ,pmd.username\n" +
  9211. " ,gt.Goodstypename\n" +
  9212. " ,pmd.goodscode\n" +
  9213. " ,pmd.barcode\n" +
  9214. " ,pd.groutingdate\n" +
  9215. " ,pd.groutingnum\n" +
  9216. " ,pd.groutingMouldCode\n" +
  9217. " ,pd.groutingLineCode\n" +
  9218. " ,pd.KilnCarCode\n" +
  9219. " ,pd.Procedureid\n" +
  9220. " ,gl.goodslevelname Goodsleveltype\n" +
  9221. " ,pmd.DefectPositionCode\n" +
  9222. " ,pmd.DefectPositionName\n" +
  9223. " ,pd.GroutingUserCode\n" +
  9224. " , CASE\n" +
  9225. " WHEN logo.logoid IS NULL THEN\n" +
  9226. " NULL\n" +
  9227. " ELSE\n" +
  9228. " logo.Logoname || '[' || logo.Logocode || ']'\n" +
  9229. " END AS LogoCodeName\n" +
  9230. " ,pmd.CreateTime\n" +
  9231. " ,mstdf.DefectFineCode\n" +
  9232. " ,pmd.DefectDeductionNum\n" +
  9233. //" ,to_char(pmd.DefectDeductionNum, '990.00') DefectDeductionNum\n" +
  9234. " ,hopd.createtime handovertime\n" +
  9235. " ,(SELECT listagg(to_char(pduc.UserCode), ',') within GROUP(ORDER BY pduc.ProductionDataID) AS WorkUserCodes\n" +
  9236. " FROM tp_pm_ProductionData pduc\n" +
  9237. " WHERE pduc.barcode = pmd.barcode\n" +
  9238. " AND pduc.valueflag = '1') AS WorkUserCodes\n" +
  9239. " ,(SELECT listagg(to_char(u.UserCode), ',') within GROUP(ORDER BY pdcu.ProductionDataID) AS CreateUserCodes\n" +
  9240. " FROM tp_pm_ProductionData pdcu\n" +
  9241. " Left join tp_mst_user u on u.userid = pdcu.createuserid\n" +
  9242. " WHERE pdcu.barcode = pmd.barcode\n" +
  9243. " AND pdcu.valueflag = '1') AS CreateUserCodes\n" +
  9244. " , CASE\n" +
  9245. " WHEN EXISTS (SELECT 1\n" +
  9246. " FROM tp_pm_ProductionData pdud\n" +
  9247. " WHERE pdud.barcode = pmd.barcode\n" +
  9248. " AND pdud.modeltype = -1\n" +
  9249. " AND pdud.procedureid = pd.procedureid\n" +
  9250. " AND pdud.kilncarbatchno = pd.kilncarbatchno\n" +
  9251. " AND pdud.valueflag = '0') THEN\n" +
  9252. " 1\n" +
  9253. " ELSE\n" +
  9254. " 0\n" +
  9255. " END AS undoflag\n" +
  9256. " , CASE\n" +
  9257. " WHEN EXISTS (SELECT 1\n" +
  9258. " FROM tp_pm_semicheck sc\n" +
  9259. " WHERE sc.barcode = pmd.barcode\n" +
  9260. " AND sc.SEMICHECKTYPE = 1\n" +
  9261. " AND sc.valueflag = '1') THEN\n" +
  9262. " 1\n" +
  9263. " ELSE\n" +
  9264. " 0\n" +
  9265. " END reworkflag" +
  9266. " ,gdd.glazingroom" +
  9267. " FROM tp_pm_defect pmd\n" +
  9268. " LEFT JOIN TP_MST_Goods g\n" +
  9269. " ON pmd.Goodsid = g.Goodsid\n" +
  9270. " LEFT JOIN TP_MST_GoodsType gt\n" +
  9271. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  9272. " LEFT JOIN TP_MST_Defect mstd\n" +
  9273. " ON pmd.DefectID = mstd.DefectID\n" +
  9274. " LEFT JOIN TP_MST_DefectType dt\n" +
  9275. " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
  9276. " INNER JOIN tp_pm_productiondata pd\n" +
  9277. " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
  9278. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  9279. " ON gdd.Groutingdailydetailid = pd.Groutingdailydetailid\n" +
  9280. " LEFT JOIN tp_mst_goodslevel gl\n" +
  9281. " ON pd.goodslevelid = gl.goodslevelid\n" +
  9282. "-- 交接工序\n" +
  9283. " INNER JOIN tp_pm_productiondata hopd\n" +
  9284. " ON hopd.kilncarbatchno = pd.kilncarbatchno\n " +
  9285. " AND hopd.barcode = pd.barcode\n" +
  9286. " AND hopd.valueflag = '1'\n" +
  9287. " AND hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  9288. " LEFT JOIN TP_MST_DefectFine mstdf\n" +
  9289. " ON pmd.DefectFine = mstdf.DefectFineID\n" +
  9290. " LEFT JOIN tp_mst_logo logo\n" +
  9291. " ON pd.logoid = logo.logoid\n" +
  9292. " LEFT JOIN (SELECT def.barcode, wmsys.wm_concat( to_char(def.defectcode)) alldefectcode\n" +
  9293. " FROM tp_pm_defect def\n" +
  9294. " WHERE def.valueflag = '1'\n" +
  9295. //def.createtime
  9296. " group by def.barcode ) d\n" +
  9297. " ON d.barcode = pmd.barcode\n" +
  9298. " WHERE pmd.valueflag = '1' \n" +
  9299. " AND pd.ModelType = -1\n" +
  9300. " AND pmd.AccountID = :AccountID\n";
  9301. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  9302. parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
  9303. //selSql = selSql +
  9304. // " Where TP_PM_Defect.valueflag='1' and tp_pm_productiondata.ModelType=-1" +
  9305. // " and TP_PM_Defect.AccountID=:AccountID ";
  9306. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  9307. {
  9308. selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
  9309. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  9310. }
  9311. if (!string.IsNullOrEmpty(se.LineIDS))
  9312. {
  9313. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
  9314. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  9315. }
  9316. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  9317. {
  9318. //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  9319. selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
  9320. parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  9321. }
  9322. else
  9323. {
  9324. // modify by chenxy :没有选择时,应全查询出来。
  9325. //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  9326. }
  9327. if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  9328. {
  9329. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
  9330. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  9331. }
  9332. if (!string.IsNullOrEmpty(se.KilnCode))
  9333. {
  9334. selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
  9335. parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  9336. }
  9337. if (!string.IsNullOrEmpty(se.GoodsIDS))
  9338. {
  9339. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
  9340. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  9341. }
  9342. if (!string.IsNullOrEmpty(se.GoodsCode))
  9343. {
  9344. selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
  9345. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  9346. }
  9347. if (!string.IsNullOrEmpty(se.GoodsCodeS2D))
  9348. {
  9349. selSql = selSql + " AND pmd.goodsCode = :GoodsCodeS2D ";
  9350. parameters.Add(new OracleParameter(":GoodsCodeS2D", OracleDbType.NVarchar2, se.GoodsCodeS2D, ParameterDirection.Input));
  9351. }
  9352. if (!string.IsNullOrEmpty(se.DefectUserCode))
  9353. {
  9354. selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
  9355. parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  9356. }
  9357. if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  9358. {
  9359. selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
  9360. parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  9361. }
  9362. if (!string.IsNullOrEmpty(se.DefectCode))
  9363. {
  9364. selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
  9365. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  9366. }
  9367. if (!string.IsNullOrEmpty(se.DefectCodeS2D))
  9368. {
  9369. selSql = selSql + " AND pmd.DefectCode = :DefectCodeS2D ";
  9370. parameters.Add(new OracleParameter(":DefectCodeS2D", OracleDbType.NVarchar2, se.DefectCodeS2D, ParameterDirection.Input));
  9371. }
  9372. if (!string.IsNullOrEmpty(se.DefectName))
  9373. {
  9374. selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
  9375. parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  9376. }
  9377. if (!string.IsNullOrEmpty(se.CheckUserCode))
  9378. {
  9379. selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
  9380. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  9381. }
  9382. if (!string.IsNullOrEmpty(se.CheckUserCodeS2D))
  9383. {
  9384. selSql = selSql + " AND pmd.UserCode = :CheckUserCodeS2D ";
  9385. parameters.Add(new OracleParameter(":CheckUserCodeS2D", OracleDbType.NVarchar2, se.CheckUserCodeS2D, ParameterDirection.Input));
  9386. }
  9387. if (se.CreateTimeStart.HasValue)
  9388. {
  9389. selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
  9390. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9391. }
  9392. if (se.CreateTimeEnd.HasValue)
  9393. {
  9394. selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
  9395. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9396. }
  9397. // 交接时间
  9398. if (se.HandOverTimeStart.HasValue)
  9399. {
  9400. selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
  9401. parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
  9402. }
  9403. if (se.HandOverTimeEnd.HasValue)
  9404. {
  9405. selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
  9406. parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
  9407. }
  9408. //if (!string.IsNullOrEmpty(se.PurViewUserCodeIDS))
  9409. //{
  9410. // selSql = selSql + " AND instr(','||:PurViewUserCodeIDS||',',','||TP_PM_Defect.DefectUserID||',')>0 ";
  9411. // parameters.Add(new OracleParameter(":PurViewUserCodeIDS", OracleDbType.NVarchar2, se.PurViewUserCodeIDS, ParameterDirection.Input));
  9412. //}
  9413. ////----------------------
  9414. //if (!string.IsNullOrEmpty(se.CompleteProcedureIDS))
  9415. //{
  9416. // selSql = selSql + @" AND exists(select 1 from tp_pm_productiondata where (instr(','||:CompleteProcedureIDS||',',','||ProcedureID||',')>0 ";
  9417. // parameters.Add(new OracleParameter(":CompleteProcedureIDS", OracleDbType.NVarchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  9418. // selSql = selSql + " AND TP_PM_ProductionData.CreateTime>= :CompleteCreateTimeStart ";
  9419. // parameters.Add(new OracleParameter(":CompleteCreateTimeStart", OracleDbType.Date, se.CompleteCreateTimeStart.Value, ParameterDirection.Input));
  9420. // selSql = selSql + " AND TP_PM_ProductionData.CreateTime<= :CompleteCreateTimeEnd )) ";
  9421. // parameters.Add(new OracleParameter(":CompleteCreateTimeEnd", OracleDbType.Date, se.CompleteCreateTimeEnd.Value, ParameterDirection.Input));
  9422. //}
  9423. ////----------------------
  9424. selSql = selSql + " order by pmd.productionlinename,pmd.procedurename,pmd.defectprocedurename,pmd.defectusercode ";
  9425. return selSql;
  9426. }
  9427. /// <summary>
  9428. /// 取得RPT030106(成检缺陷汇总表-缺陷登记明细)的汇总信息查询数据
  9429. /// </summary>
  9430. /// <param name="user">登录用户信息</param>
  9431. /// <param name="se">查询条件</param>
  9432. /// <returns>查询结果</returns>
  9433. public static ServiceResultEntity GetRPT030106DData(SUserInfo user, RPT030106_SE se)
  9434. {
  9435. IDBConnection conn = null;
  9436. try
  9437. {
  9438. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  9439. List<OracleParameter> parameters = new List<OracleParameter>();
  9440. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106DSQL(user, se, ref parameters));
  9441. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  9442. ServiceResultEntity sre = new ServiceResultEntity();
  9443. if (data == null || data.Rows.Count == 0)
  9444. {
  9445. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  9446. return sre;
  9447. }
  9448. sre.Data = new DataSet();
  9449. sre.Data.Tables.Add(data);
  9450. return sre;
  9451. }
  9452. catch (Exception ex)
  9453. {
  9454. throw ex;
  9455. }
  9456. finally
  9457. {
  9458. if (conn != null &&
  9459. conn.ConnState == ConnectionState.Open)
  9460. {
  9461. conn.Close();
  9462. }
  9463. }
  9464. }
  9465. /// <summary>
  9466. /// 获取RPT030106画面(成检缺陷汇总表-缺陷登记明细)的汇总信息查询sql
  9467. /// </summary>
  9468. /// <returns>sql</returns>
  9469. private static string GetRPT030106DSQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
  9470. {
  9471. // 质量登记改判时,缺陷的登记时间是当前时间,不是交接或前次登记时间。
  9472. // 追加交接时间,改判标识。
  9473. string selSql =
  9474. "SELECT pmd.productionlinename\n" +
  9475. " ,pmd.procedurename\n" +
  9476. " ,pmd.DefectProcedureCode\n" +
  9477. " ,pmd.DefectProcedureName\n" +
  9478. " ,pmd.DefectUserCode\n" +
  9479. " ,pmd.defectusername\n" +
  9480. " ,jobs.jobsname defectjobsname\n" +
  9481. " ,dt.DefectTypeName\n" +
  9482. " ,mstd.Remarks DefectRemarks\n" +
  9483. " ,pd.Remarks barcodeRemarks\n" +
  9484. " ,pmd.defectcode\n" +
  9485. " ,d.alldefectcode\n" +
  9486. " ,pmd.defectname\n" +
  9487. " ,pmd.UserCode\n" +
  9488. " ,pmd.username\n" +
  9489. " ,gt.Goodstypename\n" +
  9490. " ,pmd.goodscode\n" +
  9491. " ,pmd.barcode\n" +
  9492. " ,pd.groutingdate\n" +
  9493. " ,pd.groutingnum\n" +
  9494. " ,pd.groutingMouldCode\n" +
  9495. " ,pd.GroutingLineCode\n" +
  9496. " ,pd.KilnCarCode\n" +
  9497. " ,pd.Procedureid\n" +
  9498. " ,gl.goodslevelname Goodsleveltype\n" +
  9499. " ,pmd.DefectPositionCode\n" +
  9500. " ,pmd.DefectPositionName\n" +
  9501. " ,pd.GroutingUserCode\n" +
  9502. " , CASE\n" +
  9503. " WHEN logo.logoid IS NULL THEN\n" +
  9504. " NULL\n" +
  9505. " ELSE\n" +
  9506. " logo.Logoname || '[' || logo.Logocode || ']'\n" +
  9507. " END AS LogoCodeName\n" +
  9508. //" ,pmd.CreateTime\n" +
  9509. " ,pd.CheckTime pdchecktime\n" +
  9510. " ,pmd.CheckTime\n" +
  9511. " ,mstdf.DefectFineCode\n" +
  9512. " ,pmd.DefectDeductionNum\n" +
  9513. //" ,to_char(pmd.DefectDeductionNum, '990.00') DefectDeductionNum\n" +
  9514. " ,hopd.createtime handovertime\n" +
  9515. " ,(SELECT listagg(to_char(pduc.UserCode), ',') within GROUP(ORDER BY pduc.ProductionDataID) AS WorkUserCodes\n" +
  9516. " FROM tp_pm_ProductionData pduc\n" +
  9517. " WHERE pduc.barcode = pmd.barcode\n" +
  9518. " AND pduc.valueflag = '1') AS WorkUserCodes\n" +
  9519. " ,(SELECT listagg(to_char(u.UserCode), ',') within GROUP(ORDER BY pdcu.ProductionDataID) AS CreateUserCodes\n" +
  9520. " FROM tp_pm_ProductionData pdcu\n" +
  9521. " Left join tp_mst_user u on u.userid = pdcu.createuserid\n" +
  9522. " WHERE pdcu.barcode = pmd.barcode\n" +
  9523. " AND pdcu.valueflag = '1') AS CreateUserCodes\n" +
  9524. " ,(SELECT listagg(to_char(s.StaffName), ',') within GROUP(ORDER BY s.Staffid) AS DefectStaffNames\n" +
  9525. " FROM TP_PM_DefectResponsible dr\n" +
  9526. " Left join TP_HR_Staff s on s.Staffid = dr.Staffid\n" +
  9527. " WHERE dr.ProductionDefectID = pmd.ProductionDefectID --dr pdcu.valueflag = '1'\n" +
  9528. " ) AS DefectStaffNames\n" +
  9529. " , CASE\n" +
  9530. " WHEN pd.isrefire <> '0' THEN\n" +
  9531. " (select listagg(to_char(d.defectname || '[' || d.defectpositionname || ']')\n" +
  9532. " ,',') within group(order by d.productiondefectid) bsqx\n" +
  9533. " from tp_pm_productiondata p\n" +
  9534. " inner join tp_pm_defect d\n" +
  9535. " on d.productiondataid = p.productiondataid\n" +
  9536. " where p.valueflag = '1'\n" +
  9537. " and d.valueflag = '1'\n" +
  9538. " and p.barcode = pd.barcode\n" +
  9539. " and p.modeltype = -1\n" +
  9540. " and p.isrefire = '0')\n" +
  9541. " ELSE\n" +
  9542. " null\n" +
  9543. " END AS bsqx\n" +
  9544. " , CASE\n" +
  9545. " WHEN EXISTS (SELECT 1\n" +
  9546. " FROM tp_pm_ProductionData pdud\n" +
  9547. " WHERE pdud.barcode = pmd.barcode\n" +
  9548. " AND pdud.modeltype = -1\n" +
  9549. " AND pdud.procedureid = pd.procedureid\n" +
  9550. " AND pdud.kilncarbatchno = pd.kilncarbatchno\n" +
  9551. " AND pdud.valueflag = '0') THEN\n" +
  9552. " 1\n" +
  9553. " ELSE\n" +
  9554. " 0\n" +
  9555. " END AS undoflag\n" +
  9556. " FROM tp_pm_defect pmd\n" +
  9557. " LEFT JOIN TP_PC_Procedure p\n" +
  9558. " ON p.procedureid = pmd.procedureid\n" +
  9559. " LEFT JOIN TP_PC_Procedure pdd\n" +
  9560. " ON pdd.procedureid = pmd.defectprocedureid\n" +
  9561. " LEFT JOIN TP_MST_Goods g\n" +
  9562. " ON pmd.Goodsid = g.Goodsid\n" +
  9563. " LEFT JOIN TP_MST_GoodsType gt\n" +
  9564. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  9565. " LEFT JOIN TP_MST_Defect mstd\n" +
  9566. " ON pmd.DefectID = mstd.DefectID\n" +
  9567. " LEFT JOIN TP_MST_Jobs jobs\n" +
  9568. " ON jobs.jobsid = pmd.Defectjobs\n" +
  9569. " LEFT JOIN TP_MST_DefectType dt\n" +
  9570. " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
  9571. " INNER JOIN tp_pm_productiondata pd\n" +
  9572. " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
  9573. " LEFT JOIN tp_mst_goodslevel gl\n" +
  9574. " ON pd.goodslevelid = gl.goodslevelid\n" +
  9575. //"-- 交接工序\n" +
  9576. //" INNER JOIN tp_pm_productiondata hopd\n" +
  9577. //" ON hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  9578. //" AND hopd.valueflag = '1'\n" +
  9579. //" AND hopd.barcode = pd.barcode\n" +
  9580. //" AND hopd.kilncarbatchno = pd.kilncarbatchno\n" +
  9581. " INNER JOIN tp_pm_productiondata hopd\n" +
  9582. " ON hopd.kilncarbatchno = pd.kilncarbatchno\n " +
  9583. " AND hopd.barcode = pd.barcode\n" +
  9584. " AND hopd.valueflag = '1'\n" +
  9585. " AND hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  9586. " LEFT JOIN TP_MST_DefectFine mstdf\n" +
  9587. " ON pmd.DefectFine = mstdf.DefectFineID\n" +
  9588. " LEFT JOIN tp_mst_logo logo\n" +
  9589. " ON pd.logoid = logo.logoid\n" +
  9590. " LEFT JOIN (SELECT def.barcode, wmsys.wm_concat( to_char(def.defectcode)) alldefectcode\n" +
  9591. " FROM tp_pm_defect def\n" +
  9592. " WHERE def.valueflag = '1'\n" +
  9593. //def.createtime
  9594. " group by def.barcode ) d\n" +
  9595. " ON d.barcode = pmd.barcode\n" +
  9596. " WHERE pmd.valueflag = '1' \n" +
  9597. " AND pd.ModelType = -1\n" +
  9598. " AND pmd.AccountID = :AccountID\n";
  9599. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  9600. parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
  9601. //selSql = selSql +
  9602. // " Where TP_PM_Defect.valueflag='1' and tp_pm_productiondata.ModelType=-1" +
  9603. // " and TP_PM_Defect.AccountID=:AccountID ";
  9604. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  9605. {
  9606. selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
  9607. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  9608. }
  9609. if (!string.IsNullOrEmpty(se.LineIDS))
  9610. {
  9611. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
  9612. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  9613. }
  9614. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  9615. {
  9616. //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  9617. selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
  9618. parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  9619. }
  9620. else
  9621. {
  9622. // modify by chenxy :没有选择时,应全查询出来。
  9623. //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  9624. }
  9625. if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  9626. {
  9627. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
  9628. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  9629. }
  9630. if (!string.IsNullOrEmpty(se.KilnCode))
  9631. {
  9632. selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
  9633. parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  9634. }
  9635. if (!string.IsNullOrEmpty(se.GoodsIDS))
  9636. {
  9637. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
  9638. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  9639. }
  9640. if (!string.IsNullOrEmpty(se.GoodsCode))
  9641. {
  9642. selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
  9643. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  9644. }
  9645. if (!string.IsNullOrEmpty(se.GoodsCodeS2D))
  9646. {
  9647. selSql = selSql + " AND pmd.goodsCode = :GoodsCodeS2D ";
  9648. parameters.Add(new OracleParameter(":GoodsCodeS2D", OracleDbType.NVarchar2, se.GoodsCodeS2D, ParameterDirection.Input));
  9649. }
  9650. if (!string.IsNullOrEmpty(se.DefectUserCode))
  9651. {
  9652. selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
  9653. parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  9654. }
  9655. if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  9656. {
  9657. selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
  9658. parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  9659. }
  9660. if (!string.IsNullOrEmpty(se.DefectCode))
  9661. {
  9662. selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
  9663. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  9664. }
  9665. if (!string.IsNullOrEmpty(se.DefectCodeS2D))
  9666. {
  9667. selSql = selSql + " AND pmd.DefectCode = :DefectCodeS2D ";
  9668. parameters.Add(new OracleParameter(":DefectCodeS2D", OracleDbType.NVarchar2, se.DefectCodeS2D, ParameterDirection.Input));
  9669. }
  9670. if (!string.IsNullOrEmpty(se.DefectName))
  9671. {
  9672. selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
  9673. parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  9674. }
  9675. if (!string.IsNullOrEmpty(se.CheckUserCode))
  9676. {
  9677. selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
  9678. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  9679. }
  9680. if (!string.IsNullOrEmpty(se.CheckUserCodeS2D))
  9681. {
  9682. selSql = selSql + " AND pmd.UserCode = :CheckUserCodeS2D ";
  9683. parameters.Add(new OracleParameter(":CheckUserCodeS2D", OracleDbType.NVarchar2, se.CheckUserCodeS2D, ParameterDirection.Input));
  9684. }
  9685. //if (se.CreateTimeStart.HasValue)
  9686. //{
  9687. // selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
  9688. // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9689. //}
  9690. //if (se.CreateTimeEnd.HasValue)
  9691. //{
  9692. // selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
  9693. // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9694. //}
  9695. // 成检登记时间
  9696. if (se.CreateTimeStart.HasValue)
  9697. {
  9698. selSql = selSql + " AND pd.checktime>= :CreateTimeStart ";
  9699. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9700. }
  9701. if (se.CreateTimeEnd.HasValue)
  9702. {
  9703. selSql = selSql + " AND pd.checktime<= :CreateTimeEnd ";
  9704. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9705. }
  9706. // 缺陷登记时间
  9707. if (se.CheckTimeStart.HasValue)
  9708. {
  9709. selSql = selSql + " AND pmd.checktime>= :CheckTimeStart ";
  9710. parameters.Add(new OracleParameter(":CheckTimeStart", OracleDbType.Date, se.CheckTimeStart.Value, ParameterDirection.Input));
  9711. }
  9712. if (se.CheckTimeEnd.HasValue)
  9713. {
  9714. selSql = selSql + " AND pmd.checktime<= :CheckTimeEnd ";
  9715. parameters.Add(new OracleParameter(":CheckTimeEnd", OracleDbType.Date, se.CheckTimeEnd.Value, ParameterDirection.Input));
  9716. }
  9717. // 交接时间
  9718. if (se.HandOverTimeStart.HasValue)
  9719. {
  9720. selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
  9721. parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
  9722. }
  9723. if (se.HandOverTimeEnd.HasValue)
  9724. {
  9725. selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
  9726. parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
  9727. }
  9728. //selSql = selSql + " order by pmd.productionlinename,pmd.procedurename,pmd.defectprocedurename,pmd.defectusercode ";
  9729. selSql = selSql + " order by pmd.productionlinename,p.DISPLAYNO,pdd.DISPLAYNO,dt.DISPLAYNO,mstd.DISPLAYNO,pmd.defectusercode,pmd.barcode ";
  9730. return selSql;
  9731. }
  9732. /// <summary>
  9733. /// 取得RPT030106(成检缺陷汇总表-生产工序信息)的汇总信息查询数据
  9734. /// </summary>
  9735. /// <param name="user">登录用户信息</param>
  9736. /// <param name="se">查询条件</param>
  9737. /// <returns>查询结果</returns>
  9738. public static ServiceResultEntity GetRPT030106ProData(SUserInfo user, RPT030106_SE se)
  9739. {
  9740. IDBConnection conn = null;
  9741. try
  9742. {
  9743. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  9744. List<OracleParameter> parameters = new List<OracleParameter>();
  9745. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106ProSQL(user, se, ref parameters));
  9746. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  9747. ServiceResultEntity sre = new ServiceResultEntity();
  9748. if (data == null || data.Rows.Count == 0)
  9749. {
  9750. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  9751. return sre;
  9752. }
  9753. sre.Data = new DataSet();
  9754. sre.Data.Tables.Add(data);
  9755. return sre;
  9756. }
  9757. catch (Exception ex)
  9758. {
  9759. throw ex;
  9760. }
  9761. finally
  9762. {
  9763. if (conn != null &&
  9764. conn.ConnState == ConnectionState.Open)
  9765. {
  9766. conn.Close();
  9767. }
  9768. }
  9769. }
  9770. /// <summary>
  9771. /// 获取RPT030106画面(成检缺陷汇总表-生产工序信息)的汇总信息查询sql
  9772. /// </summary>
  9773. /// <returns>sql</returns>
  9774. private static string GetRPT030106ProSQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
  9775. {
  9776. // 质量登记改判时,缺陷的登记时间是当前时间,不是交接或前次登记时间。
  9777. // 追加交接时间,改判标识。
  9778. string selSql =
  9779. //"SELECT pmd.productionlinename\n" +
  9780. //" ,pmd.procedurename\n" +
  9781. //" ,pmd.DefectProcedureCode\n" +
  9782. //" ,pmd.DefectProcedureName\n" +
  9783. //" ,pmd.DefectUserCode\n" +
  9784. //" ,pmd.defectusername\n" +
  9785. //" ,jobs.jobsname defectjobsname\n" +
  9786. //" ,dt.DefectTypeName\n" +
  9787. //" ,mstd.Remarks DefectRemarks\n" +
  9788. //" ,pd.Remarks barcodeRemarks\n" +
  9789. //" ,pmd.defectcode\n" +
  9790. //" ,d.alldefectcode\n" +
  9791. //" ,pmd.defectname\n" +
  9792. //" ,pmd.UserCode\n" +
  9793. //" ,pmd.username\n" +
  9794. //" ,gt.Goodstypename\n" +
  9795. //" ,pmd.goodscode\n" +
  9796. //" ,pmd.barcode\n" +
  9797. //" ,pd.groutingdate\n" +
  9798. //" ,pd.groutingnum\n" +
  9799. //" ,pd.groutingMouldCode\n" +
  9800. //" ,pd.GroutingLineCode\n" +
  9801. //" ,pd.KilnCarCode\n" +
  9802. //" ,pd.Procedureid\n" +
  9803. //" ,gl.goodslevelname Goodsleveltype\n" +
  9804. //" ,pmd.DefectPositionCode\n" +
  9805. //" ,pmd.DefectPositionName\n" +
  9806. //" ,pd.GroutingUserCode\n" +
  9807. //" , CASE\n" +
  9808. //" WHEN logo.logoid IS NULL THEN\n" +
  9809. //" NULL\n" +
  9810. //" ELSE\n" +
  9811. //" logo.Logoname || '[' || logo.Logocode || ']'\n" +
  9812. //" END AS LogoCodeName\n" +
  9813. ////" ,pmd.CreateTime\n" +
  9814. //" ,pd.CheckTime pdchecktime\n" +
  9815. //" ,pmd.CheckTime\n" +
  9816. //" ,mstdf.DefectFineCode\n" +
  9817. //" ,pmd.DefectDeductionNum\n" +
  9818. ////" ,to_char(pmd.DefectDeductionNum, '990.00') DefectDeductionNum\n" +
  9819. //" ,hopd.createtime handovertime\n" +
  9820. //" ,(SELECT listagg(to_char(pduc.UserCode), ',') within GROUP(ORDER BY pduc.ProductionDataID) AS WorkUserCodes\n" +
  9821. //" FROM tp_pm_ProductionData pduc\n" +
  9822. //" WHERE pduc.barcode = pmd.barcode\n" +
  9823. //" AND pduc.valueflag = '1') AS WorkUserCodes\n" +
  9824. //" ,(SELECT listagg(to_char(u.UserCode), ',') within GROUP(ORDER BY pdcu.ProductionDataID) AS CreateUserCodes\n" +
  9825. //" FROM tp_pm_ProductionData pdcu\n" +
  9826. //" Left join tp_mst_user u on u.userid = pdcu.createuserid\n" +
  9827. //" WHERE pdcu.barcode = pmd.barcode\n" +
  9828. //" AND pdcu.valueflag = '1') AS CreateUserCodes\n" +
  9829. //" , CASE\n" +
  9830. //" WHEN EXISTS (SELECT 1\n" +
  9831. //" FROM tp_pm_ProductionData pdud\n" +
  9832. //" WHERE pdud.barcode = pmd.barcode\n" +
  9833. //" AND pdud.modeltype = -1\n" +
  9834. //" AND pdud.procedureid = pd.procedureid\n" +
  9835. //" AND pdud.kilncarbatchno = pd.kilncarbatchno\n" +
  9836. //" AND pdud.valueflag = '0') THEN\n" +
  9837. //" 1\n" +
  9838. //" ELSE\n" +
  9839. //" 0\n" +
  9840. //" END AS undoflag\n" +
  9841. "SELECT pmd.goodscode\n" +
  9842. " ,pmd.barcode\n" +
  9843. " ,pmd.defectcode\n" +
  9844. " ,pmd.defectname\n" +
  9845. " ,pmd.DefectPositionCode\n" +
  9846. " ,pmd.DefectPositionName\n" +
  9847. " ,gl.goodslevelname Goodsleveltype\n" +
  9848. " , CASE\n" +
  9849. " WHEN logo.logoid IS NULL THEN\n" +
  9850. " NULL\n" +
  9851. " ELSE\n" +
  9852. " logo.Logoname || '[' || logo.Logocode || ']'\n" +
  9853. " END AS LogoCodeName\n" +
  9854. //" ,pmd.CreateTime\n" +
  9855. " ,pd.CheckTime pdchecktime\n" +
  9856. " ,pmd.CheckTime\n" +
  9857. " ,proddata.CheckTime protime\n" +
  9858. " ,proddata.UserCode prousercode\n" +
  9859. " ,proddata.PROCEDURENAME proname\n" +
  9860. " ,pd.KILNCARCODE KILNCARCODE\n" +
  9861. " FROM tp_pm_defect pmd\n" +
  9862. " INNER JOIN tp_pm_productiondata proddata\n" +
  9863. " ON proddata.barcode = pmd.barcode\n " +
  9864. //" AND proddata.ProcedureID in ('" + se.CompleteProcedureIDS + "')\n" +
  9865. " AND (instr(','||:ProProcedureIDS||',',','||proddata.ProcedureID||',')>0 )\n" +
  9866. " AND proddata.valueflag = '1'\n" +
  9867. " INNER JOIN tp_pm_productiondata pd\n" +
  9868. " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
  9869. " LEFT JOIN TP_PC_Procedure p\n" +
  9870. " ON p.procedureid = pmd.procedureid\n" +
  9871. " LEFT JOIN TP_PC_Procedure pdd\n" +
  9872. " ON pdd.procedureid = pmd.defectprocedureid\n" +
  9873. " LEFT JOIN TP_MST_Goods g\n" +
  9874. " ON pmd.Goodsid = g.Goodsid\n" +
  9875. " LEFT JOIN TP_MST_GoodsType gt\n" +
  9876. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  9877. " LEFT JOIN TP_MST_Defect mstd\n" +
  9878. " ON pmd.DefectID = mstd.DefectID\n" +
  9879. " LEFT JOIN TP_MST_Jobs jobs\n" +
  9880. " ON jobs.jobsid = pmd.Defectjobs\n" +
  9881. " LEFT JOIN TP_MST_DefectType dt\n" +
  9882. " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
  9883. " LEFT JOIN tp_mst_goodslevel gl\n" +
  9884. " ON pd.goodslevelid = gl.goodslevelid\n" +
  9885. "-- 交接工序\n" +
  9886. " INNER JOIN tp_pm_productiondata hopd\n" +
  9887. " ON hopd.kilncarbatchno = pd.kilncarbatchno\n " +
  9888. " AND hopd.barcode = pd.barcode\n" +
  9889. " AND hopd.valueflag = '1'\n" +
  9890. " AND hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  9891. " LEFT JOIN TP_MST_DefectFine mstdf\n" +
  9892. " ON pmd.DefectFine = mstdf.DefectFineID\n" +
  9893. " LEFT JOIN tp_mst_logo logo\n" +
  9894. " ON pd.logoid = logo.logoid\n" +
  9895. //" LEFT JOIN (SELECT def.barcode, wmsys.wm_concat( to_char(def.defectcode)) alldefectcode\n" +
  9896. //" FROM tp_pm_defect def\n" +
  9897. //" WHERE def.valueflag = '1'\n" +
  9898. ////def.createtime
  9899. //" group by def.barcode ) d\n" +
  9900. //" ON d.barcode = pmd.barcode\n" +
  9901. " WHERE pmd.valueflag = '1' \n" +
  9902. " AND pd.ModelType = -1\n" +
  9903. " AND pmd.AccountID = :AccountID\n";
  9904. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  9905. parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
  9906. parameters.Add(new OracleParameter(":ProProcedureIDS", OracleDbType.Varchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  9907. //selSql = selSql +
  9908. // " Where TP_PM_Defect.valueflag='1' and tp_pm_productiondata.ModelType=-1" +
  9909. // " and TP_PM_Defect.AccountID=:AccountID ";
  9910. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  9911. {
  9912. selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
  9913. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  9914. }
  9915. if (!string.IsNullOrEmpty(se.LineIDS))
  9916. {
  9917. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
  9918. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  9919. }
  9920. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  9921. {
  9922. //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  9923. selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
  9924. parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  9925. }
  9926. else
  9927. {
  9928. // modify by chenxy :没有选择时,应全查询出来。
  9929. //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  9930. }
  9931. if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  9932. {
  9933. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
  9934. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  9935. }
  9936. if (!string.IsNullOrEmpty(se.KilnCode))
  9937. {
  9938. selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
  9939. parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  9940. }
  9941. if (!string.IsNullOrEmpty(se.GoodsIDS))
  9942. {
  9943. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
  9944. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  9945. }
  9946. if (!string.IsNullOrEmpty(se.GoodsCode))
  9947. {
  9948. selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
  9949. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  9950. }
  9951. if (!string.IsNullOrEmpty(se.GoodsCodeS2D))
  9952. {
  9953. selSql = selSql + " AND pmd.goodsCode = :GoodsCodeS2D ";
  9954. parameters.Add(new OracleParameter(":GoodsCodeS2D", OracleDbType.NVarchar2, se.GoodsCodeS2D, ParameterDirection.Input));
  9955. }
  9956. if (!string.IsNullOrEmpty(se.DefectUserCode))
  9957. {
  9958. selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
  9959. parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  9960. }
  9961. if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  9962. {
  9963. selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
  9964. parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  9965. }
  9966. if (!string.IsNullOrEmpty(se.DefectCode))
  9967. {
  9968. selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
  9969. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  9970. }
  9971. if (!string.IsNullOrEmpty(se.DefectCodeS2D))
  9972. {
  9973. selSql = selSql + " AND pmd.DefectCode = :DefectCodeS2D ";
  9974. parameters.Add(new OracleParameter(":DefectCodeS2D", OracleDbType.NVarchar2, se.DefectCodeS2D, ParameterDirection.Input));
  9975. }
  9976. if (!string.IsNullOrEmpty(se.DefectName))
  9977. {
  9978. selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
  9979. parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  9980. }
  9981. if (!string.IsNullOrEmpty(se.CheckUserCode))
  9982. {
  9983. selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
  9984. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  9985. }
  9986. if (!string.IsNullOrEmpty(se.CheckUserCodeS2D))
  9987. {
  9988. selSql = selSql + " AND pmd.UserCode = :CheckUserCodeS2D ";
  9989. parameters.Add(new OracleParameter(":CheckUserCodeS2D", OracleDbType.NVarchar2, se.CheckUserCodeS2D, ParameterDirection.Input));
  9990. }
  9991. //if (se.CreateTimeStart.HasValue)
  9992. //{
  9993. // selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
  9994. // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9995. //}
  9996. //if (se.CreateTimeEnd.HasValue)
  9997. //{
  9998. // selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
  9999. // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  10000. //}
  10001. // 成检登记时间
  10002. if (se.CreateTimeStart.HasValue)
  10003. {
  10004. selSql = selSql + " AND pd.checktime>= :CreateTimeStart ";
  10005. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  10006. }
  10007. if (se.CreateTimeEnd.HasValue)
  10008. {
  10009. selSql = selSql + " AND pd.checktime<= :CreateTimeEnd ";
  10010. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  10011. }
  10012. // 缺陷登记时间
  10013. if (se.CheckTimeStart.HasValue)
  10014. {
  10015. selSql = selSql + " AND pmd.checktime>= :CheckTimeStart ";
  10016. parameters.Add(new OracleParameter(":CheckTimeStart", OracleDbType.Date, se.CheckTimeStart.Value, ParameterDirection.Input));
  10017. }
  10018. if (se.CheckTimeEnd.HasValue)
  10019. {
  10020. selSql = selSql + " AND pmd.checktime<= :CheckTimeEnd ";
  10021. parameters.Add(new OracleParameter(":CheckTimeEnd", OracleDbType.Date, se.CheckTimeEnd.Value, ParameterDirection.Input));
  10022. }
  10023. // 交接时间
  10024. if (se.HandOverTimeStart.HasValue)
  10025. {
  10026. selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
  10027. parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
  10028. }
  10029. if (se.HandOverTimeEnd.HasValue)
  10030. {
  10031. selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
  10032. parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
  10033. }
  10034. //selSql = selSql + " order by pmd.productionlinename,p.DISPLAYNO,pdd.DISPLAYNO,dt.DISPLAYNO,mstd.DISPLAYNO,pmd.defectusercode,pmd.barcode ";
  10035. selSql = selSql + " order by proddata.CheckTime ";
  10036. return selSql;
  10037. }
  10038. /// <summary>
  10039. /// 窑车状态主表查询
  10040. /// </summary>
  10041. /// <param name="kilnCode">窑炉编码</param>
  10042. /// <param name="kilnCarCode">窑车编码</param>
  10043. /// <param name="sUserInfo">用户基本信息</param>
  10044. /// <returns></returns>
  10045. public static ServiceResultEntity GetKilnCarStatusByCode(string kilnCode, string kilnCarCode, SUserInfo sUserInfo)
  10046. {
  10047. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10048. try
  10049. {
  10050. con.Open();
  10051. OracleParameter[] paras = new OracleParameter[]{
  10052. new OracleParameter("in_AccountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  10053. new OracleParameter("in_KilnCode",OracleDbType.Varchar2,kilnCode,ParameterDirection.Input),
  10054. new OracleParameter("in_KilnCarCode",OracleDbType.Varchar2,kilnCarCode,ParameterDirection.Input),
  10055. new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  10056. };
  10057. DataSet dsSearchReport = con.ExecStoredProcedure("PRO_RPT_GetKilnCarStatus", paras);
  10058. ServiceResultEntity sre = new ServiceResultEntity();
  10059. if (dsSearchReport == null || dsSearchReport.Tables[0].Rows.Count == 0)
  10060. {
  10061. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10062. return sre;
  10063. }
  10064. sre.Data = new DataSet();
  10065. sre.Data.Tables.Add(dsSearchReport.Tables[0].Copy());
  10066. return sre;
  10067. }
  10068. catch (Exception ex)
  10069. {
  10070. throw ex;
  10071. }
  10072. finally
  10073. {
  10074. if (con != null &&
  10075. con.ConnState == ConnectionState.Open)
  10076. {
  10077. con.Close();
  10078. }
  10079. }
  10080. }
  10081. /// <summary>
  10082. /// 窑车状态明细表查询
  10083. /// </summary>
  10084. /// <param name="kilnCarCode">窑车编码</param>
  10085. /// <param name="sUserInfo">用户基本信息</param>
  10086. /// <returns></returns>
  10087. public static ServiceResultEntity GetKilnCarStatusDetailByCode(string kilnCarCode, SUserInfo sUserInfo)
  10088. {
  10089. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10090. try
  10091. {
  10092. con.Open();
  10093. OracleParameter[] paras = new OracleParameter[]{
  10094. new OracleParameter("in_AccountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  10095. new OracleParameter("in_KilnCarCode",OracleDbType.Varchar2,kilnCarCode,ParameterDirection.Input),
  10096. new OracleParameter("out_KilnCarData",OracleDbType.RefCursor, ParameterDirection.Output),
  10097. new OracleParameter("out_KilnCarGoods",OracleDbType.RefCursor, ParameterDirection.Output),
  10098. };
  10099. DataSet dsSearchReport = con.ExecStoredProcedure("PRO_RPT_GetKilnCarData", paras);
  10100. ServiceResultEntity sre = new ServiceResultEntity();
  10101. if (dsSearchReport == null || dsSearchReport.Tables[0].Rows.Count == 0)
  10102. {
  10103. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10104. return sre;
  10105. }
  10106. sre.Data = new DataSet();
  10107. sre.Data.Tables.Add(dsSearchReport.Tables[0].Copy());//生产数据
  10108. sre.Data.Tables.Add(dsSearchReport.Tables[1].Copy());//窑车产品
  10109. return sre;
  10110. }
  10111. catch (Exception ex)
  10112. {
  10113. throw ex;
  10114. }
  10115. finally
  10116. {
  10117. if (con != null &&
  10118. con.ConnState == ConnectionState.Open)
  10119. {
  10120. con.Close();
  10121. }
  10122. }
  10123. }
  10124. /// <summary>
  10125. /// 取得RPT010201_1画面(工序漏扫明细表)的查询数据
  10126. /// </summary>
  10127. /// <param name="user">登录用户信息</param>
  10128. /// <param name="se">查询条件</param>
  10129. /// <returns>查询结果</returns>
  10130. public static ServiceResultEntity GetRPT080101SData(SUserInfo user, RPT010201_SE se)
  10131. {
  10132. IDBConnection conn = null;
  10133. try
  10134. {
  10135. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10136. List<OracleParameter> parameters = new List<OracleParameter>();
  10137. parameters.Clear();
  10138. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080101SSQL(user, se, ref parameters));
  10139. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  10140. ServiceResultEntity sre = new ServiceResultEntity();
  10141. if (data == null || data.Rows.Count == 0)
  10142. {
  10143. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10144. return sre;
  10145. }
  10146. sre.Data = new DataSet();
  10147. sre.Data.Tables.Add(data);
  10148. return sre;
  10149. }
  10150. catch (Exception ex)
  10151. {
  10152. throw ex;
  10153. }
  10154. finally
  10155. {
  10156. if (conn != null &&
  10157. conn.ConnState == ConnectionState.Open)
  10158. {
  10159. conn.Close();
  10160. }
  10161. }
  10162. }
  10163. /// <summary>
  10164. /// 获取RPT010201_1画面(工序漏扫明细表)的查询sql
  10165. /// </summary>
  10166. /// <returns>sql</returns>
  10167. private static string GetRPT080101SSQL(SUserInfo user, RPT010201_SE se, ref List<OracleParameter> parameters)
  10168. {
  10169. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  10170. #region
  10171. #endregion
  10172. string sql = @"
  10173. select gd.groutinglinecode,
  10174. gd.groutingmouldcode,
  10175. gd.mouldcode,
  10176. gd.usercode,
  10177. gs.goodscode,
  10178. gs.goodsname,
  10179. gs.goodsspecification,
  10180. gms.gmouldstatusname, -- 模具状态
  10181. --gs.goodsmodel,
  10182. gd.groutingcount, -- 注浆次数
  10183. --gd.groutingnum,
  10184. gd.scrapnum, -- 开模损坯数
  10185. gd.deliverpnum, -- 交坯数
  10186. gd.mingroutingdate, -- 开始注浆时间
  10187. gd.maxgroutingdate, -- 最后注浆时间
  10188. gld.beginuseddate, -- 开始使用时间
  10189. gld.enduseddate, -- 结束使用时间
  10190. zl.OutKilnCount, -- 质量登记数
  10191. zl.GoodCount, -- 正品数
  10192. zl.SubstandardCount, -- 副品数
  10193. zl.ReFireCount, -- 重烧数
  10194. zl.BadCount -- 次品数
  10195. from (select gdd.groutinglinecode,
  10196. gdd.groutingmouldcode,
  10197. gdd.mouldcode,
  10198. gdd.goodsid,
  10199. gdd.groutinglinedetailid,
  10200. wmsys.wm_concat(distinct to_char(gdd.usercode)) usercode,
  10201. max(gdd.groutingcount) groutingcount,
  10202. sum(decode(gdd.groutingflag, '1', 1, 0)) groutingnum,
  10203. sum(decode(gdd.scrapflag, '1', 1, 0)) scrapnum,
  10204. sum(decode(gdd.deliverflag, '1', 1, 0)) deliverpnum,
  10205. min(gdd.groutingdate) mingroutingdate,
  10206. max(gdd.groutingdate) maxgroutingdate
  10207. from tp_pm_groutingdailydetail gdd
  10208. where gdd.groutingflag = '1'
  10209. and gdd.AccountID = :AccountID
  10210. ";
  10211. // 成型线编码
  10212. if (!string.IsNullOrEmpty(se.groutinglinecode))
  10213. {
  10214. //sql = sql + " and gdd.groutinglinecode=:groutinglinecode";
  10215. sql = sql + " and instr(gdd.groutinglinecode,:groutinglinecode)>0";
  10216. parameters.Add(new OracleParameter(":groutinglinecode", OracleDbType.NVarchar2, se.groutinglinecode, ParameterDirection.Input));
  10217. }
  10218. // 模具编码
  10219. if (!string.IsNullOrEmpty(se.groutingmouldcode))
  10220. {
  10221. //sql = sql + " and gdd.groutingmouldcode=:groutingmouldcode";
  10222. sql = sql + " and instr(gdd.groutingmouldcode,:groutingmouldcode)>0";
  10223. parameters.Add(new OracleParameter(":groutingmouldcode", OracleDbType.NVarchar2, se.groutingmouldcode, ParameterDirection.Input));
  10224. }
  10225. sql = sql + @"
  10226. group by gdd.groutinglinecode,
  10227. gdd.groutingmouldcode,
  10228. gdd.mouldcode,
  10229. gdd.goodsid,
  10230. gdd.groutinglinedetailid) gd
  10231. left join (select pdbc.mouldcode,
  10232. sum(1) OutKilnCount,
  10233. sum(case
  10234. when defect.defectprocedureid is not null and
  10235. glt.goodsleveltypeid in (5, 6, 7) then
  10236. 0
  10237. else
  10238. 1
  10239. end) GoodCount,
  10240. sum(case
  10241. when defect.defectprocedureid is not null and
  10242. glt.goodsleveltypeid = 7 then
  10243. 1
  10244. else
  10245. 0
  10246. end) SubstandardCount,
  10247. sum(case
  10248. when defect.defectprocedureid is not null and
  10249. glt.goodsleveltypeid = 6 then
  10250. 1
  10251. else
  10252. 0
  10253. end) ReFireCount,
  10254. sum(case
  10255. when defect.defectprocedureid is not null and
  10256. glt.goodsleveltypeid = 5 then
  10257. 1
  10258. else
  10259. 0
  10260. end) BadCount
  10261. from (select distinct pd.barcode,
  10262. pd.mouldcode,
  10263. pd.kilncarbatchno
  10264. from tp_pm_productiondata pd
  10265. where pd.valueflag = '1'";
  10266. // 开始注浆--开始
  10267. if (se.beginCreateTime.HasValue)
  10268. {
  10269. sql = sql + " and pd.createtime>=:groutingDateStart ";
  10270. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  10271. }
  10272. //--and pd.createtime > 查询条件。开始注浆日期开始
  10273. // --and pd.procedureid = :in_rptSprocedureId
  10274. sql = sql + @"
  10275. and pd.procedureid = 11
  10276. and pd.AccountID = 1) pdbc
  10277. left join (select kcbc.barcode,
  10278. kcbc.kilncarbatchno,
  10279. kcbc.goodsleveltypeid,
  10280. kcbc.productiondataid
  10281. from (select pd.barcode,
  10282. pd.kilncarbatchno,
  10283. pd.goodsleveltypeid,
  10284. pd.productiondataid,
  10285. ROW_NUMBER() OVER(PARTITION BY pd.barcode, pd.kilncarbatchno ORDER BY pd.productiondataid desc) AS dataid
  10286. from tp_pm_productiondata pd
  10287. where pd.valueflag = '1'
  10288. --and pd.AccountID = :AccountID
  10289. and pd.AccountID = :AccountID";
  10290. //--and pd.createtime > 查询条件。开始注浆日期开始
  10291. // 开始注浆--开始
  10292. if (se.beginCreateTime.HasValue)
  10293. {
  10294. sql = sql + " and pd.createtime>=:groutingDateStart ";
  10295. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  10296. }
  10297. sql = sql + @" and length(pd.kilncarbatchno) > 0
  10298. and pd.modeltype = -1) kcbc
  10299. where kcbc.dataid = 1) glt
  10300. on pdbc.kilncarbatchno = glt.kilncarbatchno
  10301. and pdbc.barcode = glt.barcode
  10302. left join (select distinct productiondataid, defectprocedureid
  10303. from tp_pm_defect def
  10304. where def.valueflag = '1'";
  10305. //--and pd.createtime > 查询条件。开始注浆日期开始
  10306. // 开始注浆--开始
  10307. if (se.beginCreateTime.HasValue)
  10308. {
  10309. sql = sql + " and def.createtime>=:groutingDateStart ";
  10310. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  10311. }
  10312. sql = sql + @"
  10313. and def.AccountID = :AccountID) defect
  10314. on defect.productiondataid = glt.productiondataid
  10315. group by pdbc.mouldcode) zl
  10316. on zl.mouldcode = gd.mouldcode
  10317. left join tp_mst_goods gs
  10318. on gs.goodsid = gd.goodsid
  10319. left join tp_pc_groutinglinedetail gld
  10320. on gld.groutinglinedetailid = gd.groutinglinedetailid
  10321. and gld.mouldcode = gd.mouldcode
  10322. left join tp_sys_gmouldstatus gms
  10323. on gms.gmouldstatusid = gld.gmouldstatus
  10324. where 1=1
  10325. ";
  10326. // 产品编码
  10327. if (!string.IsNullOrEmpty(se.goodscode))
  10328. {
  10329. //sql = sql + " and gs.goodscode=:goodscode";
  10330. sql = sql + " and instr(gs.goodscode,:goodscode)>0";
  10331. parameters.Add(new OracleParameter(":goodscode", OracleDbType.NVarchar2, se.goodscode, ParameterDirection.Input));
  10332. }
  10333. // 成型工号
  10334. if (!string.IsNullOrEmpty(se.groutingUserCode))
  10335. {
  10336. //sql = sql + " and gd.usercode=:usercode";
  10337. sql = sql + " and instr(gd.usercode,:usercode)>0";
  10338. parameters.Add(new OracleParameter(":usercode", OracleDbType.NVarchar2, se.groutingUserCode, ParameterDirection.Input));
  10339. }
  10340. // 开始注浆--开始
  10341. if (se.beginCreateTime.HasValue)
  10342. {
  10343. sql = sql + " and gd.mingroutingdate>=:CreateTimeStart ";
  10344. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  10345. }
  10346. // 开始注浆--结束
  10347. if (se.endCreateTime.HasValue)
  10348. {
  10349. sql = sql + " and gd.mingroutingdate<=:CreateTimeEnd ";
  10350. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.endCreateTime.Value, ParameterDirection.Input));
  10351. }
  10352. // 结束注浆--开始
  10353. if (se.beginCreateTime2.HasValue)
  10354. {
  10355. sql = sql + " and gd.maxgroutingdate>=:CreateTimeotherStart2 ";
  10356. parameters.Add(new OracleParameter(":CreateTimeotherStart2", OracleDbType.Date, se.beginCreateTime2.Value, ParameterDirection.Input));
  10357. }
  10358. // 结束注浆--结束
  10359. if (se.endCreateTime2.HasValue)
  10360. {
  10361. sql = sql + " and gd.maxgroutingdate<=:CreateTimeotherEnd2";
  10362. parameters.Add(new OracleParameter(":CreateTimeotherEnd2", OracleDbType.Date, se.endCreateTime2.Value, ParameterDirection.Input));
  10363. }
  10364. // 模具状态
  10365. if (!string.IsNullOrEmpty(se.gmouldstatus))
  10366. {
  10367. sql = sql + " and gms.gmouldstatusid=:gmouldstatus";
  10368. parameters.Add(new OracleParameter(":gmouldstatus", OracleDbType.NVarchar2, se.gmouldstatus, ParameterDirection.Input));
  10369. }
  10370. sql = sql + " order by groutinglinecode,groutingmouldcode";
  10371. return sql;
  10372. }
  10373. #region 工资产量统计
  10374. /// <summary>
  10375. /// 取得RPT080102画面(成型工产量)的查询数据
  10376. /// </summary>
  10377. /// <param name="user">登录用户信息</param>
  10378. /// <param name="se">查询条件</param>
  10379. /// <returns>查询结果</returns>
  10380. public static ServiceResultEntity GetRPT080102SData(SUserInfo user, RPT080102_SE se)
  10381. {
  10382. IDBTransaction conn = null;
  10383. try
  10384. {
  10385. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  10386. conn.Connect();
  10387. OracleParameter[] paras = new OracleParameter[]{
  10388. new OracleParameter("in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  10389. new OracleParameter("in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
  10390. new OracleParameter("in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
  10391. new OracleParameter("in_deliverprocess",OracleDbType.Varchar2,se.DeliverProcedureIDS,ParameterDirection.Input),
  10392. new OracleParameter("in_IntoKilnProcess",OracleDbType.Varchar2,se.IntoProcedureIDS,ParameterDirection.Input),
  10393. new OracleParameter("in_OutKilnProcess",OracleDbType.Varchar2,se.OutProcedureIDS,ParameterDirection.Input),
  10394. new OracleParameter("in_QualityProcess",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
  10395. new OracleParameter("in_DefectFine",OracleDbType.Varchar2,se.DefectFineIDS,ParameterDirection.Input),
  10396. new OracleParameter("in_Impurity",OracleDbType.Varchar2,se.DefectIDS,ParameterDirection.Input),
  10397. new OracleParameter("out_Production",OracleDbType.RefCursor, ParameterDirection.Output),
  10398. new OracleParameter("out_Deliver",OracleDbType.RefCursor,ParameterDirection.Output),
  10399. new OracleParameter("out_Repair",OracleDbType.RefCursor,ParameterDirection.Output),
  10400. };
  10401. conn.IsCommandTimeout = false;
  10402. DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetDeliver_Production", paras);
  10403. ServiceResultEntity sre = new ServiceResultEntity();
  10404. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  10405. {
  10406. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10407. return sre;
  10408. }
  10409. sre.Data = new DataSet();
  10410. sre.Data = data;
  10411. conn.Commit();
  10412. return sre;
  10413. }
  10414. catch (Exception ex)
  10415. {
  10416. throw ex;
  10417. }
  10418. finally
  10419. {
  10420. if (conn != null &&
  10421. conn.ConnState == ConnectionState.Open)
  10422. {
  10423. conn.Disconnect();
  10424. }
  10425. }
  10426. }
  10427. /// <summary>
  10428. /// 取得RPT080103画面(烧成前工序产量明细表)的查询数据
  10429. /// </summary>
  10430. /// <param name="user">登录用户信息</param>
  10431. /// <param name="se">查询条件</param>
  10432. /// <returns>查询结果</returns>
  10433. public static ServiceResultEntity GetRPT080103SData(SUserInfo user, RPT080103_SE se)
  10434. {
  10435. IDBTransaction conn = null;
  10436. try
  10437. {
  10438. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  10439. conn.Connect();
  10440. OracleParameter[] paras = new OracleParameter[]{
  10441. new OracleParameter("in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  10442. new OracleParameter("in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
  10443. new OracleParameter("in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
  10444. new OracleParameter("in_Process",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
  10445. new OracleParameter("in_HandOverProcess",OracleDbType.Varchar2,se.HandOverProcedureIDS,ParameterDirection.Input),
  10446. new OracleParameter("in_OutKilnProcess",OracleDbType.Varchar2,se.OutProcedureIDS,ParameterDirection.Input),
  10447. new OracleParameter("in_QualityProcess",OracleDbType.Varchar2,se.QualityProcedureIDS,ParameterDirection.Input),
  10448. new OracleParameter("in_Defect1",OracleDbType.Varchar2,se.DefectIDS,ParameterDirection.Input),
  10449. new OracleParameter("in_Defect2",OracleDbType.Varchar2,se.DefectIDS2,ParameterDirection.Input),
  10450. new OracleParameter("out_Production",OracleDbType.RefCursor, ParameterDirection.Output),
  10451. };
  10452. conn.IsCommandTimeout = false;
  10453. //DataSet data = null;
  10454. //if (se.ProcedureIDS.Contains(","))
  10455. //{
  10456. // data = conn.ExecStoredProcedure("PRO_RPT_GetStandardProduction2", paras);
  10457. //}
  10458. //else
  10459. //{
  10460. // data = conn.ExecStoredProcedure("PRO_RPT_GetStandardProduction", paras);
  10461. //}
  10462. DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetStandard_Production", paras);
  10463. ServiceResultEntity sre = new ServiceResultEntity();
  10464. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  10465. {
  10466. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10467. return sre;
  10468. }
  10469. sre.Data = new DataSet();
  10470. sre.Data = data;
  10471. conn.Commit();
  10472. return sre;
  10473. }
  10474. catch (Exception ex)
  10475. {
  10476. throw ex;
  10477. }
  10478. finally
  10479. {
  10480. if (conn != null &&
  10481. conn.ConnState == ConnectionState.Open)
  10482. {
  10483. conn.Disconnect();
  10484. }
  10485. }
  10486. }
  10487. /// <summary>
  10488. /// 取得RPT080104画面(烧成工序产量明细表)的查询数据
  10489. /// </summary>
  10490. /// <param name="user">登录用户信息</param>
  10491. /// <param name="se">查询条件</param>
  10492. /// <returns>查询结果</returns>
  10493. public static ServiceResultEntity GetRPT080104SData(SUserInfo user, RPT080103_SE se)
  10494. {
  10495. IDBTransaction conn = null;
  10496. try
  10497. {
  10498. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  10499. conn.Connect();
  10500. OracleParameter[] paras = new OracleParameter[]{
  10501. new OracleParameter("in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  10502. new OracleParameter("in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
  10503. new OracleParameter("in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
  10504. new OracleParameter("in_Process",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
  10505. new OracleParameter("in_OutKilnProcess",OracleDbType.Varchar2,se.OutProcedureIDS,ParameterDirection.Input),
  10506. new OracleParameter("in_QualityProcess",OracleDbType.Varchar2,se.QualityProcedureIDS,ParameterDirection.Input),
  10507. new OracleParameter("in_Defect1",OracleDbType.Varchar2,se.DefectIDS,ParameterDirection.Input),
  10508. new OracleParameter("in_Defect2",OracleDbType.Varchar2,se.DefectIDS2,ParameterDirection.Input),
  10509. new OracleParameter("out_Production",OracleDbType.RefCursor, ParameterDirection.Output),
  10510. };
  10511. conn.IsCommandTimeout = false;
  10512. DataSet data = null;
  10513. if (se.ProcedureIDS.Contains(","))
  10514. {
  10515. data = conn.ExecStoredProcedure("PRO_RPT_GetKilnProduction2", paras);
  10516. }
  10517. else
  10518. {
  10519. data = conn.ExecStoredProcedure("PRO_RPT_GetKilnProduction", paras);
  10520. }
  10521. ServiceResultEntity sre = new ServiceResultEntity();
  10522. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  10523. {
  10524. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10525. return sre;
  10526. }
  10527. sre.Data = data;
  10528. //string sqlString =
  10529. //"SELECT kk.procedurename\n" +
  10530. //" ,kk.usercode\n" +
  10531. //" ,kk.kilncode\n" +
  10532. //" ,kk.kdate\n" +
  10533. //" ,COUNT(*) kcount\n" +
  10534. //" FROM (SELECT k.usercode\n" +
  10535. //" ,kiln.kilncode\n" +
  10536. //" ,p.procedurename\n" +
  10537. //" ,trunc(k.createtime) kdate\n" +
  10538. //" FROM tp_pm_kilncardata k\n" +
  10539. //" LEFT JOIN tp_mst_kiln kiln\n" +
  10540. //" ON kiln.kilnid = k.kilnid\n" +
  10541. //" LEFT JOIN tp_pc_procedure p\n" +
  10542. //" ON p.procedureid = k.procedureid\n" +
  10543. //" WHERE k.valueflag = '1'\n" +
  10544. //" AND k.AccountID = :in_AccountID\n" +
  10545. //" AND k.createtime >= :in_BeginDate\n" +
  10546. //" AND k.createtime <= :in_EndDate\n" +
  10547. //" AND instr(','|| :procedureids ||',', ','|| k.procedureid ||',' ) > 0) kk\n" +
  10548. //" GROUP BY kk.procedurename, kk.usercode, kk.kilncode, kk.kdate\n" +
  10549. //" ORDER BY kk.procedurename, kk.usercode, kk.kilncode, kk.kdate";
  10550. string sqlString = "WITH kilnData AS\n" +
  10551. " (SELECT k.usercode\n" +
  10552. " ,kiln.kilncode\n" +
  10553. " ,p.procedurename\n" +
  10554. " ,trunc(k.createtime) kdate\n" +
  10555. " ,k.userid\n" +
  10556. " ,k.procedureid\n" +
  10557. " ,k.kilnid\n" +
  10558. " ,k.KILNCARBATCHNO\n" +
  10559. " FROM tp_pm_kilncardata k\n" +
  10560. " LEFT JOIN tp_mst_kiln kiln\n" +
  10561. " ON kiln.kilnid = k.kilnid\n" +
  10562. " LEFT JOIN tp_pc_procedure p\n" +
  10563. " ON p.procedureid = k.procedureid\n" +
  10564. " WHERE k.valueflag = '1'\n" +
  10565. " AND k.AccountID = :in_AccountID\n" +
  10566. " AND k.createtime >= :in_BeginDate\n" +
  10567. " AND k.createtime <= :in_EndDate\n" +
  10568. " AND instr(',' || :procedureids || ',', ',' || k.procedureid || ',') > 0)\n" +
  10569. "SELECT kd.procedurename\n" +
  10570. " ,kd.usercode\n" +
  10571. " ,kd.kilncode\n" +
  10572. " ,kd.kdate\n" +
  10573. " ,kd.kcount\n" +
  10574. " ,kpd.kpcount\n" +
  10575. " FROM (SELECT kk.procedurename\n" +
  10576. " ,kk.usercode\n" +
  10577. " ,kk.kilncode\n" +
  10578. " ,kk.kdate\n" +
  10579. " ,kk.procedureid\n" +
  10580. " ,kk.userid\n" +
  10581. " ,kk.kilnid\n" +
  10582. " ,COUNT(*) kcount\n" +
  10583. " FROM kilnData kk\n" +
  10584. " GROUP BY kk.procedurename\n" +
  10585. " ,kk.usercode\n" +
  10586. " ,kk.kilncode\n" +
  10587. " ,kk.kdate\n" +
  10588. " ,kk.procedureid\n" +
  10589. " ,kk.userid\n" +
  10590. " ,kk.kilnid) kd\n" +
  10591. " LEFT JOIN (SELECT kk.kdate\n" +
  10592. " ,kk.procedureid\n" +
  10593. " ,kk.userid\n" +
  10594. " ,kk.kilnid\n" +
  10595. " ,COUNT(*) kpcount\n" +
  10596. " FROM kilnData kk\n" +
  10597. " INNER JOIN tp_pm_productiondata pd\n" +
  10598. " ON pd.valueflag = '1'\n" +
  10599. " AND pd.procedureid = kk.procedureid\n" +
  10600. " AND pd.kilnid = kk.kilnid\n" +
  10601. " AND pd.KILNCARBATCHNO = kk.KILNCARBATCHNO\n" +
  10602. " GROUP BY kk.kdate, kk.procedureid, kk.userid, kk.kilnid) kpd\n" +
  10603. " ON kpd.kdate = kd.kdate\n" +
  10604. " AND kpd.procedureid = kd.procedureid\n" +
  10605. " AND kpd.userid = kd.userid\n" +
  10606. " AND kpd.kilnid = kd.kilnid\n" +
  10607. " ORDER BY kd.procedurename, kd.usercode, kd.kilncode, kd.kdate";
  10608. OracleParameter[] parascount = new OracleParameter[]{
  10609. new OracleParameter(":in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  10610. new OracleParameter(":in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
  10611. new OracleParameter(":in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
  10612. new OracleParameter(":procedureids",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
  10613. };
  10614. DataTable dt = conn.GetSqlResultToDt(sqlString, parascount);
  10615. if (dt != null)
  10616. {
  10617. sre.Data.Tables.Add(dt);
  10618. }
  10619. conn.Commit();
  10620. return sre;
  10621. }
  10622. catch (Exception ex)
  10623. {
  10624. throw ex;
  10625. }
  10626. finally
  10627. {
  10628. if (conn != null &&
  10629. conn.ConnState == ConnectionState.Open)
  10630. {
  10631. conn.Disconnect();
  10632. }
  10633. }
  10634. }
  10635. #endregion
  10636. /// <summary>
  10637. /// 使用存储过程PRO_PM_GetProductionData获取生产工序计件数据
  10638. /// </summary>
  10639. /// <param name="searchEntity">生产数据实体类</param>
  10640. /// <param name="user">用户基本信息</param>
  10641. /// <returns>DataTable</returns>
  10642. public static DataTable GetProductionData(SearchProductionDataEntity searchEntity, SUserInfo user)
  10643. {
  10644. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10645. string procsql = "PRO_RPT_GetProductionData";
  10646. try
  10647. {
  10648. IDataParameter[] paras = new OracleParameter[]
  10649. {
  10650. new OracleParameter("in_procedureList",OracleDbType.Varchar2, searchEntity.ProcedureIDS, ParameterDirection.Input),
  10651. new OracleParameter("in_LineID", OracleDbType.Int32,searchEntity.ProductionLineID, ParameterDirection.Input),
  10652. new OracleParameter("in_barCode", OracleDbType.Varchar2,searchEntity.BarCode, ParameterDirection.Input),
  10653. new OracleParameter("in_goodsCode", OracleDbType.Varchar2,searchEntity.GoodsCode, ParameterDirection.Input),
  10654. new OracleParameter("in_goodsName", OracleDbType.Varchar2,searchEntity.GoodsName, ParameterDirection.Input),
  10655. new OracleParameter("in_userCode", OracleDbType.Varchar2,searchEntity.UserCode, ParameterDirection.Input),
  10656. new OracleParameter("in_organizationID", OracleDbType.Int32,searchEntity.OrganizationID, ParameterDirection.Input),
  10657. new OracleParameter("in_remarks", OracleDbType.Varchar2,searchEntity.Remarks, ParameterDirection.Input),
  10658. new OracleParameter("in_isReworked", OracleDbType.Varchar2,searchEntity.IsRework, ParameterDirection.Input),
  10659. new OracleParameter("in_begindate", OracleDbType.Date,searchEntity.BeginDate, ParameterDirection.Input),
  10660. new OracleParameter("in_enddate", OracleDbType.Date,searchEntity.EndDate, ParameterDirection.Input),
  10661. new OracleParameter("in_accountID", OracleDbType.Int32,user.AccountID, ParameterDirection.Input),
  10662. new OracleParameter("in_userID", OracleDbType.Int32,user.UserID, ParameterDirection.Input),
  10663. new OracleParameter("in_kilnCode", OracleDbType.Varchar2,searchEntity.KilnCode, ParameterDirection.Input),
  10664. new OracleParameter("in_kilnCarCode", OracleDbType.Varchar2,searchEntity.KilnCarCode, ParameterDirection.Input),
  10665. new OracleParameter("in_kilnCarPosition", OracleDbType.Int32,searchEntity.KilnCarPosition, ParameterDirection.Input),
  10666. new OracleParameter("in_currentUserID", OracleDbType.Int32,user.UserID, ParameterDirection.Input),
  10667. new OracleParameter("out_result", OracleDbType.RefCursor, ParameterDirection.Output),
  10668. new OracleParameter("in_goodsTypeCode", OracleDbType.Varchar2,searchEntity.GoodsTypeCode, ParameterDirection.Input),
  10669. };
  10670. oracleConn.Open();
  10671. DataSet returnDs = oracleConn.ExecStoredProcedure(procsql, paras);
  10672. if (returnDs != null && returnDs.Tables.Count > 0)
  10673. {
  10674. return returnDs.Tables[0];
  10675. }
  10676. else
  10677. {
  10678. return null;
  10679. }
  10680. }
  10681. catch (Exception ex)
  10682. {
  10683. throw ex;
  10684. }
  10685. finally
  10686. {
  10687. if (oracleConn.ConnState == ConnectionState.Open)
  10688. {
  10689. oracleConn.Close();
  10690. }
  10691. }
  10692. }
  10693. /// <summary>
  10694. /// 取得RPT080106(温湿计明细)的汇总信息查询数据
  10695. /// </summary>
  10696. /// <param name="user">登录用户信息</param>
  10697. /// <param name="se">查询条件</param>
  10698. /// <returns>查询结果</returns>
  10699. public static ServiceResultEntity GetRPT080106IData(SUserInfo user, CelsiusRecordEntity se)
  10700. {
  10701. IDBConnection conn = null;
  10702. try
  10703. {
  10704. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10705. List<OracleParameter> parameters = new List<OracleParameter>();
  10706. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080106ISQL(user, se, ref parameters));
  10707. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  10708. ServiceResultEntity sre = new ServiceResultEntity();
  10709. if (data == null || data.Rows.Count == 0)
  10710. {
  10711. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10712. return sre;
  10713. }
  10714. sre.Data = new DataSet();
  10715. sre.Data.Tables.Add(data);
  10716. return sre;
  10717. }
  10718. catch (Exception ex)
  10719. {
  10720. throw ex;
  10721. }
  10722. finally
  10723. {
  10724. if (conn != null &&
  10725. conn.ConnState == ConnectionState.Open)
  10726. {
  10727. conn.Close();
  10728. }
  10729. }
  10730. }
  10731. /// <summary>
  10732. /// 取得RPT080106(温湿计明细)的汇总信息查询数据sql
  10733. /// </summary>
  10734. /// <returns>sql</returns>
  10735. private static string GetRPT080106ISQL(SUserInfo user, CelsiusRecordEntity se, ref List<OracleParameter> parameters)
  10736. {
  10737. string selSql = @"Select cr.*,t.*,to_char(cr.RecordDate,'mm-dd hh24:mi') as RecordDateStr from TP_PM_CelsiusRecord cr
  10738. Left join TP_MST_User u On cr.ThermometerID = u.UserId
  10739. Inner join TP_MST_Thermometer t On cr.ThermometerID = t.ThermometerID
  10740. Where cr.AccountID =:AccountID and cr.ValueFlag = '1' ";
  10741. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  10742. if (!string.IsNullOrEmpty(se.ThermometerIDS))
  10743. {
  10744. selSql = selSql + " AND instr(','||:ThermometerIDS||',',','||cr.ThermometerID||',')>0 ";
  10745. parameters.Add(new OracleParameter(":ThermometerIDS", OracleDbType.NVarchar2, se.ThermometerIDS, ParameterDirection.Input));
  10746. }
  10747. if (!string.IsNullOrEmpty(se.Remarks))
  10748. {
  10749. selSql = selSql + " AND instr(cr.Remarks,:Remarks) >0 ";
  10750. parameters.Add(new OracleParameter(":Remarks", OracleDbType.NVarchar2, se.Remarks, ParameterDirection.Input));
  10751. }
  10752. if (se.RecordDate.HasValue)
  10753. {
  10754. selSql = selSql + " AND cr.CreateTime>= :CreateTimeStart ";
  10755. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.RecordDate.Value, ParameterDirection.Input));
  10756. }
  10757. if (se.RecordDateEnd.HasValue)
  10758. {
  10759. selSql = selSql + " AND cr.CreateTime<= :CreateTimeEnd ";
  10760. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.RecordDateEnd.Value, ParameterDirection.Input));
  10761. }
  10762. selSql +=
  10763. // 温湿计查看权限
  10764. " AND EXISTS (SELECT UP.PurviewID" +
  10765. " FROM TP_MST_UserPurview UP" +
  10766. " WHERE UP.PurviewType = '" + (int)Constant.PurviewType.ViewCelsius + "'" +
  10767. " AND (UP.PurviewID = -1 OR UP.PurviewID = CR.ThermometerID)" +
  10768. " AND UP.UserId = :UPUserId)";
  10769. parameters.Add(new OracleParameter(":UPUserId", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  10770. selSql = selSql + " order by RecordDate asc";
  10771. return selSql;
  10772. }
  10773. /// <summary>
  10774. /// 取得RPT030110画面(半检登记汇总表)的汇总信息查询数据
  10775. /// </summary>
  10776. /// <param name="user">登录用户信息</param>
  10777. /// <param name="se">查询条件</param>
  10778. /// <returns>查询结果</returns>
  10779. public static ServiceResultEntity GetRPT030110Data(SUserInfo user, SemiCheckEntity se)
  10780. {
  10781. IDBConnection conn = null;
  10782. try
  10783. {
  10784. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10785. List<OracleParameter> parameters = new List<OracleParameter>();
  10786. string sql = ReportModuleLogic.GetRPT030110SSQL(user, se, ref parameters);
  10787. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  10788. ServiceResultEntity sre = new ServiceResultEntity();
  10789. if (data == null || data.Rows.Count == 0)
  10790. {
  10791. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10792. return sre;
  10793. }
  10794. sre.Data = new DataSet();
  10795. sre.Data.Tables.Add(data);
  10796. return sre;
  10797. }
  10798. catch (Exception ex)
  10799. {
  10800. throw ex;
  10801. }
  10802. finally
  10803. {
  10804. if (conn != null &&
  10805. conn.ConnState == ConnectionState.Open)
  10806. {
  10807. conn.Close();
  10808. }
  10809. }
  10810. }
  10811. /// <summary>
  10812. /// 获取RPT030110画面(半检登记汇总表)的汇总信息查询sql
  10813. /// </summary>
  10814. /// <returns>sql</returns>
  10815. private static string GetRPT030110SSQL(SUserInfo user, SemiCheckEntity se, ref List<OracleParameter> parameters)
  10816. {
  10817. parameters.Add(new OracleParameter(":accountid", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  10818. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  10819. #region
  10820. // string sqlString = @"
  10821. // SELECT t.reworkprocedureid -- 返工工序id
  10822. // ,decode(gid,
  10823. // 7,
  10824. // '总计',
  10825. // 3,
  10826. // '合计【' || t.reworkprocedurename || '】',
  10827. // 0,
  10828. // t.reworkprocedurename,
  10829. // '--') reworkprocedurename -- 返工工序
  10830. // ,t.goodstypecode2 -- 产品二级类别
  10831. // ,decode(gid,
  10832. // 1,
  10833. // '小计【' || t.goodstypename2 || '】',
  10834. // 0,
  10835. // t.goodstypename2,
  10836. // '--') goodstypename2 -- 产品二级类别
  10837. // ,t.reworkuserid -- 返工工号id
  10838. // ,decode(gid, 0, t.reworkusercode, '--') reworkusercode -- 返工工号
  10839. // ,t.goodsid -- 产品id
  10840. // ,decode(gid, 0, t.goodscode, '--') goodscode -- 产品编码
  10841. // ,decode(gid, 0, t.goodstypename, '--') goodstypename -- 产品类别
  10842. // ,t.reworkcount -- 返工数
  10843. // ,t.badcount -- 不合格数
  10844. // ,t.regoodcount -- 复检合格数
  10845. // ,t.rebadcount -- 复检不合格数
  10846. // ,t.renocount -- 未复检
  10847. // --,t.renocountsum -- 待返工
  10848. // ,(SELECT COUNT(*)
  10849. // FROM tp_pm_semicheck sci
  10850. // WHERE sci.valueflag = '1'
  10851. // AND sci.backoutflag = '0'
  10852. // AND sci.semichecktype = 1
  10853. // AND sci.resemichecktype = 0
  10854. // AND (t.reworkprocedureid is null or sci.reworkprocedureid = t.reworkprocedureid)
  10855. // AND (t.goodsid is null or sci.goodsid = t.goodsid)
  10856. // AND (t.reworkuserid is null or sci.reworkuserid = t.reworkuserid)) AS renocountsum
  10857. // FROM (SELECT grouping_id(sc.reworkprocedureid, gt2.goodstypecode, g.goodsid) gid
  10858. // ,sc.reworkprocedureid
  10859. // ,rp.procedurename reworkprocedurename
  10860. // ,gt2.goodstypecode goodstypecode2
  10861. // ,gt2.goodstypename goodstypename2
  10862. // ,sc.reworkuserid
  10863. // ,sc.reworkusercode
  10864. // ,g.goodsid
  10865. // ,g.goodscode
  10866. // ,gt.goodstypename
  10867. // , SUM(CASE
  10868. // WHEN sc.semichecktype = 1 THEN
  10869. // 1
  10870. // ELSE
  10871. // 0
  10872. // END) reworkcount
  10873. // , SUM(CASE
  10874. // WHEN sc.semichecktype = 2 THEN
  10875. // 1
  10876. // ELSE
  10877. // 0
  10878. // END) badcount
  10879. // , SUM(CASE
  10880. // WHEN sc.semichecktype = 1 AND sc.resemichecktype = 0 THEN
  10881. // 1
  10882. // ELSE
  10883. // 0
  10884. // END) renocount
  10885. // , SUM(CASE
  10886. // WHEN sc.semichecktype = 1 AND sc.resemichecktype = 1 THEN
  10887. // 1
  10888. // ELSE
  10889. // 0
  10890. // END) regoodcount
  10891. // , SUM(CASE
  10892. // WHEN sc.semichecktype = 1 AND sc.resemichecktype = 2 THEN
  10893. // 1
  10894. // ELSE
  10895. // 0
  10896. // END) rebadcount
  10897. // --,(select count(*) from tp_pm_semicheck sci where sci.valueflag = '1' and sci.backoutflag = '0' and sci.semichecktype = 1
  10898. // -- and sci.resemichecktype = 0 and sci.reworkprocedureid = sc.reworkprocedureid and sci.reworkuserid = sc.reworkuserid and sci.goodsid = g.goodsid) as renocountsum
  10899. // --FROM tp_pm_semicheck sc
  10900. // FROM (SELECT semicheckid
  10901. // ,barcode
  10902. // ,productionlineid
  10903. // ,procedureid
  10904. // ,proceduretime
  10905. // ,proceduremodel
  10906. // ,modeltype
  10907. // ,organizationid
  10908. // ,goodsid
  10909. // ,goodscode
  10910. // ,userid
  10911. // ,usercode
  10912. // ,productiondataid
  10913. // ,logoid
  10914. // ,ispublicbody
  10915. // ,specialrepairflag
  10916. // ,goodslevelid
  10917. // ,goodsleveltypeid
  10918. // ,groutingdailyid
  10919. // ,groutingdailydetailid
  10920. // ,groutinglineid
  10921. // ,groutinglinecode
  10922. // ,groutinglinename
  10923. // ,gmouldtypeid
  10924. // ,canmanytimes
  10925. // ,groutinglinedetailid
  10926. // ,groutingdate
  10927. // ,groutingmouldcode
  10928. // ,mouldcode
  10929. // ,groutinguserid
  10930. // ,groutingusercode
  10931. // ,groutingnum
  10932. // ,semichecktype
  10933. // ,semicheckuserid
  10934. // ,semicheckusercode
  10935. // ,semichecktime
  10936. // ,reworkprocedureid
  10937. // ,reworkprocedurecode
  10938. // ,reworkuserid
  10939. // ,reworkusercode
  10940. // ,resemichecktype
  10941. // ,resemicheckuserid
  10942. // ,resemicheckusercode
  10943. // ,resemichecktime
  10944. // ,backoutflag
  10945. // ,backouttime
  10946. // ,backoutuserid
  10947. // ,backoutusercode
  10948. // ,remarks
  10949. // ,createtime
  10950. // ,createuserid
  10951. // ,updateuserid
  10952. // FROM tp_pm_semicheck sc
  10953. // WHERE sc.accountid = :accountid
  10954. // AND sc.valueflag = '1'
  10955. // AND sc.semichecktype = 1
  10956. // AND sc.backoutflag = '0'
  10957. // UNION ALL
  10958. // SELECT DISTINCT sc.semicheckid
  10959. // ,sc.barcode
  10960. // ,sc.productionlineid
  10961. // ,sc.procedureid
  10962. // ,sc.proceduretime
  10963. // ,sc.proceduremodel
  10964. // ,sc.modeltype
  10965. // ,sc.organizationid
  10966. // ,sc.goodsid
  10967. // ,sc.goodscode
  10968. // ,sc.userid
  10969. // ,sc.usercode
  10970. // ,sc.productiondataid
  10971. // ,sc.logoid
  10972. // ,sc.ispublicbody
  10973. // ,sc.specialrepairflag
  10974. // ,sc.goodslevelid
  10975. // ,sc.goodsleveltypeid
  10976. // ,sc.groutingdailyid
  10977. // ,sc.groutingdailydetailid
  10978. // ,sc.groutinglineid
  10979. // ,sc.groutinglinecode
  10980. // ,sc.groutinglinename
  10981. // ,sc.gmouldtypeid
  10982. // ,sc.canmanytimes
  10983. // ,sc.groutinglinedetailid
  10984. // ,sc.groutingdate
  10985. // ,sc.groutingmouldcode
  10986. // ,sc.mouldcode
  10987. // ,sc.groutinguserid
  10988. // ,sc.groutingusercode
  10989. // ,sc.groutingnum
  10990. // ,sc.semichecktype
  10991. // ,sc.semicheckuserid
  10992. // ,sc.semicheckusercode
  10993. // ,sc.semichecktime
  10994. // --,sc.reworkprocedureid
  10995. // --,sc.reworkprocedurecode
  10996. // --,sc.reworkuserid
  10997. // --,sc.reworkusercode
  10998. // ,scd.defectprocedureid
  10999. // ,scdp.procedurename
  11000. // ,scd.defectuserid
  11001. // ,scd.defectusercode
  11002. // ,sc.resemichecktype
  11003. // ,sc.resemicheckuserid
  11004. // ,sc.resemicheckusercode
  11005. // ,sc.resemichecktime
  11006. // ,sc.backoutflag
  11007. // ,sc.backouttime
  11008. // ,sc.backoutuserid
  11009. // ,sc.backoutusercode
  11010. // ,sc.remarks
  11011. // ,sc.createtime
  11012. // ,sc.createuserid
  11013. // ,sc.updateuserid
  11014. // FROM tp_pm_semicheck sc
  11015. // LEFT JOIN TP_PM_SemiCheckDefect scd
  11016. // ON sc.semicheckid = scd.semicheckid
  11017. // LEFT JOIN tp_pc_procedure scdp
  11018. // ON scdp.procedureid = scd.defectprocedureid
  11019. // WHERE sc.accountid = :accountid
  11020. // AND sc.valueflag = '1'
  11021. // AND sc.semichecktype = 2
  11022. // AND sc.backoutflag = '0'
  11023. // ) sc
  11024. // LEFT JOIN tp_pc_procedure rp
  11025. // ON rp.procedureid = sc.reworkprocedureid
  11026. // INNER JOIN tp_mst_goods g
  11027. // ON g.goodsid = sc.goodsid
  11028. // INNER JOIN tp_mst_goodstype gt
  11029. // ON gt.goodstypeid = g.goodstypeid
  11030. // INNER JOIN tp_mst_goodstype gt2
  11031. // ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)
  11032. // AND gt2.accountid = gt.accountid
  11033. // INNER join TP_PM_GroutingDailyDetail GroutingDailyDetail
  11034. // ON GroutingDailyDetail.GroutingDailyDetailID=sc.GroutingDailyDetailID
  11035. // 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))";
  11036. #endregion
  11037. string sqlString = "SELECT t.reworkprocedureid -- 返工工序id\n" +
  11038. " ,decode(gid,\n" +
  11039. " 7,\n" +
  11040. " '总计',\n" +
  11041. " 3,\n" +
  11042. " '合计【' || t.reworkprocedurename || '】',\n" +
  11043. " 0,\n" +
  11044. " t.reworkprocedurename,\n" +
  11045. " '--') reworkprocedurename -- 返工工序\n" +
  11046. " ,t.goodstypecode2 -- 产品二级类别\n" +
  11047. " ,decode(gid,\n" +
  11048. " 1,\n" +
  11049. " '小计【' || t.goodstypename2 || '】',\n" +
  11050. " 0,\n" +
  11051. " t.goodstypename2,\n" +
  11052. " '--') goodstypename2 -- 产品二级类别\n" +
  11053. " ,t.reworkuserid -- 返工工号id\n" +
  11054. " ,decode(gid, 0, t.reworkusercode, '--') reworkusercode -- 返工工号\n" +
  11055. " ,t.goodsid -- 产品id\n" +
  11056. " ,decode(gid, 0, t.goodscode, '--') goodscode -- 产品编码\n" +
  11057. " ,decode(gid, 0, t.goodstypename, '--') goodstypename -- 产品类别\n" +
  11058. " ,t.reworkcount -- 返工数\n" +
  11059. " ,t.badcount -- 不合格数\n" +
  11060. " ,t.regoodcount -- 复检合格数\n" +
  11061. " ,t.rebadcount -- 复检不合格数\n" +
  11062. " ,t.renocount -- 未复检\n" +
  11063. " ,t.renocountsum -- 待返工\n" +
  11064. " FROM (SELECT grouping_id(sct.reworkprocedureid,\n" +
  11065. " sct.goodstypecode2,\n" +
  11066. " sct.goodsid) gid\n" +
  11067. " ,sct.displayno\n" +
  11068. " ,sct.reworkprocedureid\n" +
  11069. " ,sct.reworkprocedurename\n" +
  11070. " ,sct.goodstypecode2\n" +
  11071. " ,sct.goodstypename2\n" +
  11072. " ,sct.reworkuserid\n" +
  11073. " ,sct.reworkusercode\n" +
  11074. " ,sct.goodsid\n" +
  11075. " ,sct.goodscode\n" +
  11076. " ,sct.goodstypename\n" +
  11077. " ,SUM(sct.reworkcount) reworkcount\n" +
  11078. " ,SUM(sct. badcount) badcount\n" +
  11079. " ,SUM(sct. renocount) renocount\n" +
  11080. " ,SUM(sct.regoodcount) regoodcount\n" +
  11081. " ,SUM(sct.rebadcount) rebadcount\n" +
  11082. " ,SUM(sct.renocountsum) renocountsum\n" +
  11083. " FROM (SELECT rp.displayno\n" +
  11084. " ,sc.reworkprocedureid\n" +
  11085. " ,rp.procedurename reworkprocedurename\n" +
  11086. " ,gt2.goodstypecode goodstypecode2\n" +
  11087. " ,gt2.goodstypename goodstypename2\n" +
  11088. " ,sc.reworkuserid\n" +
  11089. " ,sc.reworkusercode\n" +
  11090. " ,g.goodsid\n" +
  11091. " ,g.goodscode\n" +
  11092. " ,gt.goodstypename\n" +
  11093. " , SUM(CASE\n" +
  11094. " WHEN sc.semichecktype = 1 THEN\n" +
  11095. " 1\n" +
  11096. " ELSE\n" +
  11097. " 0\n" +
  11098. " END) reworkcount\n" +
  11099. " , SUM(CASE\n" +
  11100. " WHEN sc.semichecktype = 2 THEN\n" +
  11101. " 1\n" +
  11102. " ELSE\n" +
  11103. " 0\n" +
  11104. " END) badcount\n" +
  11105. " , SUM(CASE\n" +
  11106. " WHEN sc.semichecktype = 1 AND sc.resemichecktype = 0 THEN\n" +
  11107. " 1\n" +
  11108. " ELSE\n" +
  11109. " 0\n" +
  11110. " END) renocount\n" +
  11111. " , SUM(CASE\n" +
  11112. " WHEN sc.semichecktype = 1 AND sc.resemichecktype = 1 THEN\n" +
  11113. " 1\n" +
  11114. " ELSE\n" +
  11115. " 0\n" +
  11116. " END) regoodcount\n" +
  11117. " , SUM(CASE\n" +
  11118. " WHEN sc.semichecktype = 1 AND sc.resemichecktype = 2 THEN\n" +
  11119. " 1\n" +
  11120. " ELSE\n" +
  11121. " 0\n" +
  11122. " END) rebadcount\n" +
  11123. " ,(SELECT COUNT(*)\n" +
  11124. " FROM tp_pm_semicheck sci\n" +
  11125. " WHERE sci.valueflag = '1'\n" +
  11126. " AND sci.backoutflag = '0'\n" +
  11127. " AND sci.semichecktype = 1\n" +
  11128. " AND sci.resemichecktype = 0\n" +
  11129. " AND sci.accountid = :accountid\n" +
  11130. " AND sci.reworkprocedureid = sc.reworkprocedureid\n" +
  11131. " AND sci.reworkuserid = sc.reworkuserid\n" +
  11132. " AND sci.goodsid = g.goodsid) AS renocountsum\n" +
  11133. " FROM (SELECT semicheckid\n" +
  11134. " ,barcode\n" +
  11135. " ,productionlineid\n" +
  11136. " ,procedureid\n" +
  11137. " ,proceduretime\n" +
  11138. " ,proceduremodel\n" +
  11139. " ,modeltype\n" +
  11140. " ,organizationid\n" +
  11141. " ,goodsid\n" +
  11142. " ,goodscode\n" +
  11143. " ,userid\n" +
  11144. " ,usercode\n" +
  11145. " ,productiondataid\n" +
  11146. " ,logoid\n" +
  11147. " ,ispublicbody\n" +
  11148. " ,specialrepairflag\n" +
  11149. " ,goodslevelid\n" +
  11150. " ,goodsleveltypeid\n" +
  11151. " ,groutingdailyid\n" +
  11152. " ,groutingdailydetailid\n" +
  11153. " ,groutinglineid\n" +
  11154. " ,groutinglinecode\n" +
  11155. " ,groutinglinename\n" +
  11156. " ,gmouldtypeid\n" +
  11157. " ,canmanytimes\n" +
  11158. " ,groutinglinedetailid\n" +
  11159. " ,groutingdate\n" +
  11160. " ,groutingmouldcode\n" +
  11161. " ,mouldcode\n" +
  11162. " ,groutinguserid\n" +
  11163. " ,groutingusercode\n" +
  11164. " ,groutingnum\n" +
  11165. " ,semichecktype\n" +
  11166. " ,semicheckuserid\n" +
  11167. " ,semicheckusercode\n" +
  11168. " ,semichecktime\n" +
  11169. " ,reworkprocedureid\n" +
  11170. " ,reworkprocedurecode\n" +
  11171. " ,reworkuserid\n" +
  11172. " ,reworkusercode\n" +
  11173. " ,resemichecktype\n" +
  11174. " ,resemicheckuserid\n" +
  11175. " ,resemicheckusercode\n" +
  11176. " ,resemichecktime\n" +
  11177. " ,backoutflag\n" +
  11178. " ,backouttime\n" +
  11179. " ,backoutuserid\n" +
  11180. " ,backoutusercode\n" +
  11181. " ,remarks\n" +
  11182. " ,createtime\n" +
  11183. " ,createuserid\n" +
  11184. " ,updateuserid\n" +
  11185. " FROM tp_pm_semicheck sc\n" +
  11186. " WHERE sc.accountid = :accountid\n" +
  11187. " AND sc.valueflag = '1'\n" +
  11188. " AND sc.semichecktype = 1\n" +
  11189. " AND sc.backoutflag = '0'\n" +
  11190. " UNION ALL\n" +
  11191. " SELECT DISTINCT sc.semicheckid\n" +
  11192. " ,sc.barcode\n" +
  11193. " ,sc.productionlineid\n" +
  11194. " ,sc.procedureid\n" +
  11195. " ,sc.proceduretime\n" +
  11196. " ,sc.proceduremodel\n" +
  11197. " ,sc.modeltype\n" +
  11198. " ,sc.organizationid\n" +
  11199. " ,sc.goodsid\n" +
  11200. " ,sc.goodscode\n" +
  11201. " ,sc.userid\n" +
  11202. " ,sc.usercode\n" +
  11203. " ,sc.productiondataid\n" +
  11204. " ,sc.logoid\n" +
  11205. " ,sc.ispublicbody\n" +
  11206. " ,sc.specialrepairflag\n" +
  11207. " ,sc.goodslevelid\n" +
  11208. " ,sc.goodsleveltypeid\n" +
  11209. " ,sc.groutingdailyid\n" +
  11210. " ,sc.groutingdailydetailid\n" +
  11211. " ,sc.groutinglineid\n" +
  11212. " ,sc.groutinglinecode\n" +
  11213. " ,sc.groutinglinename\n" +
  11214. " ,sc.gmouldtypeid\n" +
  11215. " ,sc.canmanytimes\n" +
  11216. " ,sc.groutinglinedetailid\n" +
  11217. " ,sc.groutingdate\n" +
  11218. " ,sc.groutingmouldcode\n" +
  11219. " ,sc.mouldcode\n" +
  11220. " ,sc.groutinguserid\n" +
  11221. " ,sc.groutingusercode\n" +
  11222. " ,sc.groutingnum\n" +
  11223. " ,sc.semichecktype\n" +
  11224. " ,sc.semicheckuserid\n" +
  11225. " ,sc.semicheckusercode\n" +
  11226. " ,sc.semichecktime\n" +
  11227. " --,sc.reworkprocedureid\n" +
  11228. " --,sc.reworkprocedurecode\n" +
  11229. " --,sc.reworkuserid\n" +
  11230. " --,sc.reworkusercode\n" +
  11231. " ,scd.defectprocedureid\n" +
  11232. " ,scdp.procedurename\n" +
  11233. " ,scd.defectuserid\n" +
  11234. " ,scd.defectusercode\n" +
  11235. " ,sc.resemichecktype\n" +
  11236. " ,sc.resemicheckuserid\n" +
  11237. " ,sc.resemicheckusercode\n" +
  11238. " ,sc.resemichecktime\n" +
  11239. " ,sc.backoutflag\n" +
  11240. " ,sc.backouttime\n" +
  11241. " ,sc.backoutuserid\n" +
  11242. " ,sc.backoutusercode\n" +
  11243. " ,sc.remarks\n" +
  11244. " ,sc.createtime\n" +
  11245. " ,sc.createuserid\n" +
  11246. " ,sc.updateuserid\n" +
  11247. " FROM tp_pm_semicheck sc\n" +
  11248. " LEFT JOIN TP_PM_SemiCheckDefect scd\n" +
  11249. " ON sc.semicheckid = scd.semicheckid\n" +
  11250. " AND scd.valueflag='1'\n" +
  11251. " LEFT JOIN tp_pc_procedure scdp\n" +
  11252. " ON scdp.procedureid = scd.defectprocedureid\n" +
  11253. " WHERE sc.accountid = :accountid\n" +
  11254. " AND sc.valueflag = '1'\n" +
  11255. " AND sc.semichecktype = 2\n" +
  11256. " AND sc.backoutflag = '0') sc\n" +
  11257. " LEFT JOIN tp_pc_procedure rp\n" +
  11258. " ON rp.procedureid = sc.reworkprocedureid\n" +
  11259. " INNER JOIN tp_mst_goods g\n" +
  11260. " ON g.goodsid = sc.goodsid\n" +
  11261. " INNER JOIN tp_mst_goodstype gt\n" +
  11262. " ON gt.goodstypeid = g.goodstypeid\n" +
  11263. " INNER JOIN tp_mst_goodstype gt2\n" +
  11264. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  11265. " AND gt2.accountid = gt.accountid\n" +
  11266. " INNER JOIN TP_PM_GroutingDailyDetail GroutingDailyDetail\n" +
  11267. " ON GroutingDailyDetail.GroutingDailyDetailID =\n" +
  11268. " sc.GroutingDailyDetailID\n" //+
  11269. //" WHERE EXISTS (SELECT 1\n" +
  11270. //" FROM TP_MST_UserPurview up\n" +
  11271. //" WHERE up.PurviewType = 9\n" +
  11272. //" AND up.UserID = :UserID\n" +
  11273. //" AND (up.PurviewID = -1 OR\n" +
  11274. //" up.PurviewID = sc.procedureid))\n"
  11275. ;
  11276. // 完成工序集
  11277. if (!string.IsNullOrEmpty(se.CProcedureIDS))
  11278. {
  11279. sqlString += " AND instr(','||:procedureids||',', ',' || sc.procedureid || ',') > 0";
  11280. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, se.CProcedureIDS, ParameterDirection.Input));
  11281. }
  11282. // 完成时间起始
  11283. if (se.CDateTimeStart.HasValue)
  11284. {
  11285. sqlString = sqlString + " AND sc.ProcedureTime >= :CDateTimeStart ";
  11286. parameters.Add(new OracleParameter(":CDateTimeStart", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11287. }
  11288. // 完成时间结束
  11289. if (se.CDateTimeEnd.HasValue)
  11290. {
  11291. sqlString = sqlString + " AND sc.ProcedureTime <= :CDateTimeEnd ";
  11292. parameters.Add(new OracleParameter(":CDateTimeEnd", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11293. }
  11294. // 完成工号
  11295. if (!string.IsNullOrEmpty(se.CUserCode))
  11296. {
  11297. sqlString = sqlString + " AND instr(sc.UserCode,:UserCode)>0";
  11298. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CUserCode, ParameterDirection.Input));
  11299. }
  11300. // 产品类别
  11301. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  11302. {
  11303. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 ";
  11304. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  11305. }
  11306. // 产品编码
  11307. if (!string.IsNullOrEmpty(se.GoodsCode))
  11308. {
  11309. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0";
  11310. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  11311. }
  11312. // 成型工号
  11313. if (!string.IsNullOrEmpty(se.GroutingUserCode))
  11314. {
  11315. sqlString = sqlString + " AND instr(sc.GroutingUserCode,:GroutingUserCode)>0";
  11316. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.NVarchar2, se.GroutingUserCode, ParameterDirection.Input));
  11317. }
  11318. // 注浆时间起始
  11319. if (se.GroutingDateTimeStart.HasValue)
  11320. {
  11321. sqlString = sqlString + " AND sc.GroutingDate >= :GroutingDateTimeStart ";
  11322. parameters.Add(new OracleParameter(":GroutingDateTimeStart", OracleDbType.Date, se.GroutingDateTimeStart.Value, ParameterDirection.Input));
  11323. }
  11324. // 注浆时间结束
  11325. if (se.GroutingDateTimeEnd.HasValue)
  11326. {
  11327. sqlString = sqlString + " AND sc.GroutingDate <= :GroutingDateTimeEnd ";
  11328. parameters.Add(new OracleParameter(":GroutingDateTimeEnd", OracleDbType.Date, se.GroutingDateTimeEnd.Value, ParameterDirection.Input));
  11329. }
  11330. // 交坯时间起始
  11331. if (se.DeliveryDateTimeStart.HasValue)
  11332. {
  11333. sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime >= :DeliveryDateTimeStart ";
  11334. parameters.Add(new OracleParameter(":DeliveryDateTimeStart", OracleDbType.Date, se.DeliveryDateTimeStart.Value, ParameterDirection.Input));
  11335. }
  11336. // 交坯时间结束
  11337. if (se.DeliveryDateTimeEnd.HasValue)
  11338. {
  11339. sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime <= :DeliveryDateTimeEnd ";
  11340. parameters.Add(new OracleParameter(":DeliveryDateTimeEnd", OracleDbType.Date, se.DeliveryDateTimeEnd.Value, ParameterDirection.Input));
  11341. }
  11342. // 半检状态
  11343. if (!string.IsNullOrEmpty(se.SemiCheckType))
  11344. {
  11345. sqlString = sqlString + " AND instr(','||:SemiCheckType||',',','||sc.SemiCheckType||',')>0 ";
  11346. parameters.Add(new OracleParameter(":SemiCheckType", OracleDbType.NVarchar2, se.SemiCheckType, ParameterDirection.Input));
  11347. }
  11348. // 半检时间起始
  11349. if (se.SemiCheckDateTimeStart.HasValue)
  11350. {
  11351. sqlString = sqlString + " AND sc.SemiCheckTime >= :SemiCheckDateTimeStart ";
  11352. parameters.Add(new OracleParameter(":SemiCheckDateTimeStart", OracleDbType.Date, se.SemiCheckDateTimeStart.Value, ParameterDirection.Input));
  11353. }
  11354. // 半检时间结束
  11355. if (se.SemiCheckDateTimeEnd.HasValue)
  11356. {
  11357. sqlString = sqlString + " AND sc.SemiCheckTime <= :SemiCheckDateTimeEnd ";
  11358. parameters.Add(new OracleParameter(":SemiCheckDateTimeEnd", OracleDbType.Date, se.SemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  11359. }
  11360. // 半检工号
  11361. if (!string.IsNullOrEmpty(se.SemiCheckUserCode))
  11362. {
  11363. sqlString = sqlString + " AND instr(sc.SemiCheckUserCode,:SemiCheckUserCode)>0";
  11364. parameters.Add(new OracleParameter(":SemiCheckUserCode", OracleDbType.NVarchar2, se.SemiCheckUserCode, ParameterDirection.Input));
  11365. }
  11366. // 返工工序
  11367. if (!string.IsNullOrEmpty(se.RProcedureIDS))
  11368. {
  11369. sqlString = sqlString + " AND instr(','||:RProcedureIDS||',',','||sc.ReworkProcedureID||',')>0 ";
  11370. parameters.Add(new OracleParameter(":RProcedureIDS", OracleDbType.NVarchar2, se.RProcedureIDS, ParameterDirection.Input));
  11371. }
  11372. // 返工工号
  11373. if (!string.IsNullOrEmpty(se.ReworkUserCode))
  11374. {
  11375. sqlString = sqlString + " AND instr(sc.ReworkUserCode,:ReworkUserCode)>0";
  11376. parameters.Add(new OracleParameter(":ReworkUserCode", OracleDbType.NVarchar2, se.ReworkUserCode, ParameterDirection.Input));
  11377. }
  11378. // 复检状态
  11379. if (!string.IsNullOrEmpty(se.ReSemiCheckType))
  11380. {
  11381. sqlString = sqlString + " AND instr(','||:ReSemiCheckType||',',','||sc.ReSemiCheckType||',')>0 ";
  11382. parameters.Add(new OracleParameter(":ReSemiCheckType", OracleDbType.NVarchar2, se.ReSemiCheckType, ParameterDirection.Input));
  11383. }
  11384. // 复检时间起始
  11385. if (se.ReSemiCheckDateTimeStart.HasValue)
  11386. {
  11387. sqlString = sqlString + " AND sc.ReSemiCheckTime >= :ReSemiCheckDateTimeStart ";
  11388. parameters.Add(new OracleParameter(":ReSemiCheckDateTimeStart", OracleDbType.Date, se.ReSemiCheckDateTimeStart.Value, ParameterDirection.Input));
  11389. }
  11390. // 复检时间结束
  11391. if (se.ReSemiCheckDateTimeEnd.HasValue)
  11392. {
  11393. sqlString = sqlString + " AND sc.ReSemiCheckTime <= :ReSemiCheckDateTimeEnd ";
  11394. parameters.Add(new OracleParameter(":ReSemiCheckDateTimeEnd", OracleDbType.Date, se.ReSemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  11395. }
  11396. // 复检工号
  11397. if (!string.IsNullOrEmpty(se.ReSemiCheckUserCode))
  11398. {
  11399. sqlString = sqlString + " AND instr(sc.ReSemiCheckUserCode,:ReSemiCheckUserCode)>0";
  11400. parameters.Add(new OracleParameter(":ReSemiCheckUserCode", OracleDbType.NVarchar2, se.ReSemiCheckUserCode, ParameterDirection.Input));
  11401. }
  11402. // 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),())
  11403. // ORDER BY rp.displayno
  11404. // ,gt2.goodstypename
  11405. // ,sc.reworkusercode
  11406. // ,g.goodscode
  11407. // ,gt.goodstypename, gid) t
  11408. // ";
  11409. sqlString = sqlString +
  11410. " GROUP BY rp.displayno\n" +
  11411. " ,sc.reworkprocedureid\n" +
  11412. " ,rp.procedurename\n" +
  11413. " ,gt2.goodstypecode\n" +
  11414. " ,gt2.goodstypename\n" +
  11415. " ,sc.reworkuserid\n" +
  11416. " ,sc.reworkusercode\n" +
  11417. " ,g.goodsid\n" +
  11418. " ,g.goodscode\n" +
  11419. " ,gt.goodstypename) sct\n" +
  11420. " 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" +
  11421. " ORDER BY sct.displayno\n" +
  11422. " ,sct.goodstypename\n" +
  11423. " ,sct.reworkusercode\n" +
  11424. " ,sct.goodscode\n" +
  11425. " ,sct.goodstypename\n" +
  11426. " ,gid) t";
  11427. return sqlString;
  11428. }
  11429. /// <summary>
  11430. /// 取得RPT080107(半检登记明细)的信息查询数据
  11431. /// </summary>
  11432. /// <param name="user">登录用户信息</param>
  11433. /// <param name="se">查询条件</param>
  11434. /// <returns>查询结果</returns>
  11435. public static ServiceResultEntity GetRPT080107IData(SUserInfo user, SemiCheckEntity se)
  11436. {
  11437. IDBConnection conn = null;
  11438. try
  11439. {
  11440. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  11441. List<OracleParameter> parameters = new List<OracleParameter>();
  11442. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080107ISQL(user, se, ref parameters));
  11443. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  11444. ServiceResultEntity sre = new ServiceResultEntity();
  11445. if (data == null || data.Rows.Count == 0)
  11446. {
  11447. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  11448. return sre;
  11449. }
  11450. sre.Data = new DataSet();
  11451. sre.Data.Tables.Add(data);
  11452. return sre;
  11453. }
  11454. catch (Exception ex)
  11455. {
  11456. throw ex;
  11457. }
  11458. finally
  11459. {
  11460. if (conn != null &&
  11461. conn.ConnState == ConnectionState.Open)
  11462. {
  11463. conn.Close();
  11464. }
  11465. }
  11466. }
  11467. //xuwei add 2019-10-14
  11468. /// <summary>
  11469. /// 取得RPT080108(半检返修登记明细)的信息查询数据
  11470. /// </summary>
  11471. /// <param name="user">登录用户信息</param>
  11472. /// <param name="se">查询条件</param>
  11473. /// <returns>查询结果</returns>
  11474. public static ServiceResultEntity GetRPT080108IData(SUserInfo user, SemiCheckEntity se)
  11475. {
  11476. IDBConnection conn = null;
  11477. try
  11478. {
  11479. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  11480. List<OracleParameter> parameters = new List<OracleParameter>();
  11481. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080108ISQL(user, se, ref parameters));
  11482. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  11483. ServiceResultEntity sre = new ServiceResultEntity();
  11484. if (data == null || data.Rows.Count == 0)
  11485. {
  11486. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  11487. return sre;
  11488. }
  11489. sre.Data = new DataSet();
  11490. sre.Data.Tables.Add(data);
  11491. return sre;
  11492. }
  11493. catch (Exception ex)
  11494. {
  11495. throw ex;
  11496. }
  11497. finally
  11498. {
  11499. if (conn != null &&
  11500. conn.ConnState == ConnectionState.Open)
  11501. {
  11502. conn.Close();
  11503. }
  11504. }
  11505. }
  11506. /// <summary>
  11507. /// 获取RPT080108画面(半检返修登记明细)的汇总信息查询sql
  11508. /// </summary>
  11509. /// <returns>sql</returns>
  11510. private static string GetRPT080108ISQL(SUserInfo user, SemiCheckEntity se, ref List<OracleParameter> parameters)
  11511. {
  11512. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  11513. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  11514. string sqlString = @"
  11515. SELECT
  11516. sr.SEMIREWORKID ,--AS SEMIREWORKID,
  11517. p.PROCEDURECODE ,--AS 完成工序编码,
  11518. p.PROCEDURENAME ,--AS 完成工序,
  11519. sr.PROCEDURETIME ,--AS 完成时间,
  11520. sr.USERCODE ,--完成工号,
  11521. gt2.GOODSTYPENAME AS GOODSTYPENAME2,--AS 产品二级类别,
  11522. gt.GOODSTYPENAME ,--AS 产品类别,
  11523. g.GOODSCODE ,--AS 产品编码,
  11524. g.GOODSNAME,--AS 产品名称,
  11525. sr.BARCODE ,--AS 产品条码,
  11526. sr.SEMIREWORKUSERCODE ,--AS 半检工号,
  11527. sr.SEMIREWORKTIME ,--AS 半检时间,
  11528. pr.PROCEDURECODE AS REWORKPCODE,--AS 返修工序编码,
  11529. pr.PROCEDURENAME AS REWORKPNAME,--AS 返修工序,
  11530. sr.BACKOUTFLAG ,--AS 撤销标识,
  11531. sr.BACKOUTUSERCODE ,--AS 撤销工号,
  11532. sr.BACKOUTTIME ,--AS 撤销时间,
  11533. sr.GROUTINGUSERCODE ,--AS 成型工号,
  11534. sr.GROUTINGLINECODE ,--AS 成型线编码,
  11535. sr.GROUTINGMOULDCODE ,--AS 模具编号,
  11536. sr.GROUTINGDATE ,--AS 注浆时间,
  11537. gd.DELIVERTIME ,--AS 交坯时间,
  11538. l.LOGONAME ,--AS 商标,
  11539. srd.DEFECTCODE ,--AS 缺陷编码,
  11540. srd.DEFECTNAME ,--AS 缺陷名称,
  11541. srd.DEFECTPOSITIONCODE ,--AS 位置编码,
  11542. srd.DEFECTPOSITIONNAME ,--AS 缺陷位置,
  11543. pd.PROCEDURECODE AS DEFECTPCODE,--AS 责任工序编码,
  11544. pd.PROCEDURENAME AS DEFECTPNAME,--AS 责任工序,
  11545. srd.DEFECTUSERCODE ,--AS 责任工号,
  11546. inpp.PROCEDURENAME CurrPROCEDURENAME --AS 当前工序
  11547. FROM
  11548. TP_PM_SEMIREWORK sr
  11549. LEFT JOIN TP_PM_SEMIREWORKDEFECT srd ON sr.SEMIREWORKID = srd.SEMIREWORKID
  11550. LEFT JOIN TP_PC_PROCEDURE p ON p.PROCEDUREID = sr.PROCEDUREID
  11551. LEFT JOIN TP_PC_PROCEDURE pr ON pr.PROCEDUREID = sr.REWORKPROCEDUREID
  11552. LEFT JOIN TP_PC_PROCEDURE pd ON pd.PROCEDUREID = srd.DEFECTPROCEDUREID
  11553. LEFT JOIN TP_MST_GOODS g ON sr.GOODSID = g.GOODSID
  11554. LEFT JOIN TP_MST_GOODSTYPE gt ON g.GOODSTYPEID = gt.GOODSTYPEID
  11555. LEFT JOIN TP_MST_GOODSTYPE gt2 ON gt2.ACCOUNTID = gt.ACCOUNTID
  11556. AND gt2.GOODSTYPECODE = substr( gt.GOODSTYPECODE, 1, 6 )
  11557. LEFT JOIN TP_PM_GROUTINGDAILYDETAIL gd ON gd.GROUTINGDAILYDETAILID = sr.GROUTINGDAILYDETAILID
  11558. LEFT JOIN TP_MST_LOGO l ON gd.LOGOID = l.LOGOID
  11559. LEFT JOIN TP_PM_INPRODUCTION inp ON inp.BARCODE = sr.BARCODE
  11560. LEFT JOIN TP_PC_PROCEDURE inpp ON inp.PROCEDUREID = inpp.PROCEDUREID
  11561. WHERE
  11562. sr.VALUEFLAG = '1'
  11563. AND srd.VALUEFLAG = '1'
  11564. AND sr.AccountID=:AccountID
  11565. ";
  11566. //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))
  11567. // 完成工序
  11568. if (!string.IsNullOrEmpty(se.CProcedureIDS))
  11569. {
  11570. sqlString = sqlString + " AND instr(','||:CProcedureIDS||',',','||p.PROCEDURECODE||',')>0 ";
  11571. parameters.Add(new OracleParameter(":CProcedureIDS", OracleDbType.NVarchar2, se.CProcedureIDS, ParameterDirection.Input));
  11572. }
  11573. // 完成时间起始
  11574. if (se.CDateTimeStart.HasValue)
  11575. {
  11576. sqlString = sqlString + " AND sr.ProcedureTime >= :CDateTimeStart ";
  11577. parameters.Add(new OracleParameter(":CDateTimeStart", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11578. }
  11579. // 完成时间结束
  11580. if (se.CDateTimeEnd.HasValue)
  11581. {
  11582. sqlString = sqlString + " AND sr.ProcedureTime <= :CDateTimeEnd ";
  11583. parameters.Add(new OracleParameter(":CDateTimeEnd", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11584. }
  11585. // 完成工号
  11586. if (!string.IsNullOrEmpty(se.CUserCode))
  11587. {
  11588. sqlString = sqlString + " AND instr(','||:UserCode||',' , ','||sr.UserCode||',')>0";
  11589. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CUserCode, ParameterDirection.Input));
  11590. }
  11591. // 产品类别
  11592. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  11593. {
  11594. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 ";
  11595. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  11596. }
  11597. // 产品编码
  11598. if (!string.IsNullOrEmpty(se.GoodsCode))
  11599. {
  11600. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0";
  11601. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  11602. }
  11603. // 成型工号
  11604. if (!string.IsNullOrEmpty(se.GroutingUserCode))
  11605. {
  11606. sqlString = sqlString + " AND instr(','||:GroutingUserCode||',' , ','||sr.GroutingUserCode||',')>0";
  11607. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.NVarchar2, se.GroutingUserCode, ParameterDirection.Input));
  11608. }
  11609. // 注浆时间起始
  11610. if (se.GroutingDateTimeStart.HasValue)
  11611. {
  11612. sqlString = sqlString + " AND sr.GroutingDate >= :GroutingDateTimeStart ";
  11613. parameters.Add(new OracleParameter(":GroutingDateTimeStart", OracleDbType.Date, se.GroutingDateTimeStart.Value, ParameterDirection.Input));
  11614. }
  11615. // 注浆时间结束
  11616. if (se.GroutingDateTimeEnd.HasValue)
  11617. {
  11618. sqlString = sqlString + " AND sr.GroutingDate <= :GroutingDateTimeEnd ";
  11619. parameters.Add(new OracleParameter(":GroutingDateTimeEnd", OracleDbType.Date, se.GroutingDateTimeEnd.Value, ParameterDirection.Input));
  11620. }
  11621. // 交坯时间起始
  11622. if (se.DeliveryDateTimeStart.HasValue)
  11623. {
  11624. sqlString = sqlString + " AND gd.DeliverTime >= :DeliveryDateTimeStart ";
  11625. parameters.Add(new OracleParameter(":DeliveryDateTimeStart", OracleDbType.Date, se.DeliveryDateTimeStart.Value, ParameterDirection.Input));
  11626. }
  11627. // 交坯时间结束
  11628. if (se.DeliveryDateTimeEnd.HasValue)
  11629. {
  11630. sqlString = sqlString + " AND gd.DeliverTime <= :DeliveryDateTimeEnd ";
  11631. parameters.Add(new OracleParameter(":DeliveryDateTimeEnd", OracleDbType.Date, se.DeliveryDateTimeEnd.Value, ParameterDirection.Input));
  11632. }
  11633. // 半检时间起始
  11634. if (se.SemiCheckDateTimeStart.HasValue)
  11635. {
  11636. sqlString = sqlString + " AND sr.SEMIREWORKTIME >= :SemiCheckDateTimeStart ";
  11637. parameters.Add(new OracleParameter(":SemiCheckDateTimeStart", OracleDbType.Date, se.SemiCheckDateTimeStart.Value, ParameterDirection.Input));
  11638. }
  11639. // 半检时间结束
  11640. if (se.SemiCheckDateTimeEnd.HasValue)
  11641. {
  11642. sqlString = sqlString + " AND sr.SEMIREWORKTIME <= :SemiCheckDateTimeEnd ";
  11643. parameters.Add(new OracleParameter(":SemiCheckDateTimeEnd", OracleDbType.Date, se.SemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  11644. }
  11645. // 半检工号
  11646. if (!string.IsNullOrEmpty(se.SemiCheckUserCode))
  11647. {
  11648. sqlString = sqlString + " AND instr(','||:SemiCheckUserCode||',' , ','||sr.SEMIREWORKUSERCODE||',')>0";
  11649. parameters.Add(new OracleParameter(":SemiCheckUserCode", OracleDbType.NVarchar2, se.SemiCheckUserCode, ParameterDirection.Input));
  11650. }
  11651. // 返修工序
  11652. if (!string.IsNullOrEmpty(se.RProcedureIDS))
  11653. {
  11654. sqlString = sqlString + " AND instr(','||:RProcedureIDS||',',','||pr.PROCEDUREID||',')>0 ";
  11655. parameters.Add(new OracleParameter(":RProcedureIDS", OracleDbType.NVarchar2, se.RProcedureIDS, ParameterDirection.Input));
  11656. }
  11657. // 返修工号
  11658. if (!string.IsNullOrEmpty(se.ReworkUserCode))
  11659. {
  11660. sqlString = sqlString + " AND instr(sr.ReworkUserCode,:ReworkUserCode)>0";
  11661. parameters.Add(new OracleParameter(":ReworkUserCode", OracleDbType.NVarchar2, se.ReworkUserCode, ParameterDirection.Input));
  11662. }
  11663. // 撤销标识
  11664. if (!string.IsNullOrEmpty(se.BackOutFlag))
  11665. {
  11666. sqlString = sqlString + " AND instr(','||:BackOutFlag||',',','||sr.BackOutFlag||',')>0 ";
  11667. parameters.Add(new OracleParameter(":BackOutFlag", OracleDbType.NVarchar2, se.BackOutFlag, ParameterDirection.Input));
  11668. }
  11669. // 撤销时间起始
  11670. if (se.BackOutTimeStart.HasValue)
  11671. {
  11672. sqlString = sqlString + " AND sr.BackOutTime >= :BackOutTimeStart ";
  11673. parameters.Add(new OracleParameter(":BackOutTimeStart", OracleDbType.Date, se.BackOutTimeStart.Value, ParameterDirection.Input));
  11674. }
  11675. // 撤销时间结束
  11676. if (se.BackOutTimeEnd.HasValue)
  11677. {
  11678. sqlString = sqlString + " AND sr.BackOutTime <= :BackOutTimeEnd ";
  11679. parameters.Add(new OracleParameter(":BackOutTimeEnd", OracleDbType.Date, se.BackOutTimeEnd.Value, ParameterDirection.Input));
  11680. }
  11681. // 撤销工号
  11682. if (!string.IsNullOrEmpty(se.BackOutUserCode))
  11683. {
  11684. sqlString = sqlString + " AND instr(','||:BackOutUserCode||',' , ','||sr.BackOutUserCode||',')>0";
  11685. parameters.Add(new OracleParameter(":BackOutUserCode", OracleDbType.NVarchar2, se.BackOutUserCode, ParameterDirection.Input));
  11686. }
  11687. // 产品条码
  11688. if (!string.IsNullOrEmpty(se.BarCode))
  11689. {
  11690. sqlString = sqlString + " AND instr(sr.BarCode,:BarCode)>0";
  11691. parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.BarCode, ParameterDirection.Input));
  11692. }
  11693. // 缺陷编码
  11694. if (!string.IsNullOrEmpty(se.DefectCode))
  11695. {
  11696. sqlString = sqlString + " AND instr(srd.DefectCode,:DefectCode)>0";
  11697. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  11698. }
  11699. // 缺陷位置集
  11700. if (!string.IsNullOrEmpty(se.DefectPositionIDS))
  11701. {
  11702. sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||srd.DefectPositionID||',')>0 ";
  11703. parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectPositionIDS, ParameterDirection.Input));
  11704. }
  11705. // 责任工序集
  11706. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  11707. {
  11708. sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||pd.PROCEDUREID||',')>0 ";
  11709. parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  11710. }
  11711. // 责任工号
  11712. if (!string.IsNullOrEmpty(se.DefectUser))
  11713. {
  11714. sqlString = sqlString + " AND instr(srd.DEFECTUSERCODE,:DefectUser)>0";
  11715. parameters.Add(new OracleParameter(":DefectUser", OracleDbType.NVarchar2, se.DefectUser, ParameterDirection.Input));
  11716. }
  11717. // 只显示最后一条半检记录
  11718. if (se.SemiCheckType == "1")
  11719. {
  11720. // 撤销的记录全显示,未撤销的记录只显示最后一条
  11721. sqlString += " and (sr.backoutflag = '1' or not exists (select sw.semireworkid\n" +
  11722. " from TP_PM_SEMIREWORK sw\n" +
  11723. " where sw.barcode = sr.barcode\n" +
  11724. " and sw.valueflag = '1'\n" +
  11725. " and (sw.backoutflag = '0')\n" +
  11726. " and sw.semireworkid > sr.semireworkid) )";
  11727. }
  11728. return sqlString;
  11729. }
  11730. //xuwei end
  11731. //xuwei add 2019-10-21
  11732. /// <summary>
  11733. /// 统计当前工号,当日,按产品编码分组统计半检返修数据数量
  11734. /// </summary>
  11735. /// <param name="user">用户</param>
  11736. /// <param name="dataStr">统计日期</param>
  11737. /// <returns></returns>
  11738. public static ServiceResultEntity GetSemiReworkDayCount(SUserInfo user, string dateStr)
  11739. {
  11740. IDBConnection conn = null;
  11741. try
  11742. {
  11743. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  11744. string sqlStr = $@"
  11745. SELECT
  11746. nvl(sr.SEMIREWORKUSERCODE,'--') SEMIREWORKUSERCODE,--AS 半检工号,
  11747. nvl( g.GOODSCODE, '合计' ) GOODSCODE,--AS 产品编码,
  11748. nvl(g.GOODSNAME,'--') GOODSNAME,--AS 产口名称,
  11749. to_char(count( sr.SEMIREWORKID )) GOODSCOUNT --AS 返修数量
  11750. FROM
  11751. TP_PM_SEMIREWORK sr
  11752. LEFT JOIN TP_PM_SEMIREWORKDEFECT srd ON sr.SEMIREWORKID = srd.SEMIREWORKID
  11753. LEFT JOIN TP_MST_GOODS g ON sr.GOODSID = g.GOODSID
  11754. WHERE
  11755. sr.VALUEFLAG = '1'
  11756. AND sr.ACCOUNTID = '{user.AccountID}'
  11757. AND sr.SEMIREWORKUSERCODE = '{user.UserCode}'
  11758. AND to_date(to_char(sr.CREATETIME,'yyyy-mm-dd'),'yyyy-mm-dd') = to_date('{dateStr}','yyyy-mm-dd')
  11759. GROUP BY
  11760. grouping sets ( ( sr.SEMIREWORKUSERCODE, g.GOODSCODE, g.GOODSNAME ), ( ) )
  11761. ";
  11762. DataTable data = conn.GetSqlResultToDt(sqlStr);
  11763. ServiceResultEntity sre = new ServiceResultEntity();
  11764. //if (data == null || data.Rows.Count == 0)
  11765. //{
  11766. // sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  11767. // return sre;
  11768. //}
  11769. sre.Data = new DataSet();
  11770. sre.Data.Tables.Add(data);
  11771. return sre;
  11772. }
  11773. catch (Exception ex)
  11774. {
  11775. throw ex;
  11776. }
  11777. finally
  11778. {
  11779. if (conn != null &&
  11780. conn.ConnState == ConnectionState.Open)
  11781. {
  11782. conn.Close();
  11783. }
  11784. }
  11785. }
  11786. //xuwei end
  11787. /// <summary>
  11788. /// 获取RPT030110画面(半检登记汇总表)的汇总信息查询sql
  11789. /// </summary>
  11790. /// <returns>sql</returns>
  11791. private static string GetRPT080107ISQL(SUserInfo user, SemiCheckEntity se, ref List<OracleParameter> parameters)
  11792. {
  11793. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  11794. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  11795. string sqlString = @"
  11796. select
  11797. SemiCheck.SemiCheckID,
  11798. CProcedure.ProcedureName as CProcedureName,
  11799. SemiCheck.ProcedureTime,
  11800. SemiCheck.UserCode,
  11801. GoodsType2.GoodsTypeName as LevelGoodsTypeName,
  11802. GoodsType.GoodsTypeName,
  11803. Goods.GoodsCode,
  11804. SemiCheck.BarCode,
  11805. -- 复检后不显示半检状态
  11806. SemiCheckType.SemiCheckTypeName,
  11807. --decode(SemiCheck.ReSemiCheckType, 0, SemiCheckType.SemiCheckTypeName, '已复检') SemiCheckTypeName,
  11808. SemiCheck.SemiCheckUserCode,
  11809. SemiCheck.SemiCheckTime,
  11810. ReSemiCheckType.ReSemiCheckTypeName,
  11811. SemiCheck.ReSemiCheckUserCode,
  11812. SemiCheck.ReSemiCheckTime,
  11813. decode(SemiCheck.BackOutFlag,'0','正常','撤销') as BackOutFlag,
  11814. SemiCheck.BackOutUserCode,
  11815. SemiCheck.BackOutTime,
  11816. SemiCheck.GroutingUserCode,
  11817. SemiCheck.GroutingLineCode,
  11818. SemiCheck.GroutingMouldCode,
  11819. SemiCheck.GroutingDate,
  11820. GroutingDailyDetail.DeliverTime,
  11821. logo.logoName,
  11822. RProcedure.ProcedureName as RProcedureName,
  11823. SemiCheck.ReworkUserCode,
  11824. SemiCheckDefect.DefectCode,
  11825. SemiCheckDefect.DefectName as DefectName1,
  11826. concat(SemiCheckDefect.DefectCode||'->',SemiCheckDefect.DefectName) as DefectName,
  11827. SemiCheckDefect.DefectPositionName,
  11828. SemiCheckDefect.DefectPositionCode,
  11829. concat(SemiCheckDefect.DefectPositionCode||'->',SemiCheckDefect.DefectPositionName) as DefectPositionName,
  11830. Procedure.ProcedureName,
  11831. inpp.ProcedureName CurrProcedureName,
  11832. DefectUser.username as DefectUser
  11833. from TP_PM_SemiCheck SemiCheck
  11834. left join TP_PC_Procedure CProcedure
  11835. on SemiCheck.ProcedureID=CProcedure.ProcedureID
  11836. left join TP_MST_Goods Goods
  11837. on SemiCheck.GoodsID=Goods.GoodsID
  11838. left join TP_MST_GoodsType GoodsType
  11839. on Goods.GoodsTypeID=GoodsType.GoodsTypeID
  11840. left join TP_MST_GoodsType GoodsType2
  11841. on GoodsType2.accountid=GoodsType.accountid
  11842. and GoodsType2.GoodsTypecode=substr(GoodsType.GoodsTypecode,1,6)
  11843. left join TP_SYS_SemiCheckType SemiCheckType
  11844. on SemiCheck.SemiCheckType=SemiCheckType.SemiCheckTypeID
  11845. left join TP_SYS_ReSemiCheckType ReSemiCheckType
  11846. on SemiCheck.ReSemiCheckType=ReSemiCheckType.ReSemiCheckTypeID
  11847. left join TP_PM_GroutingDailyDetail GroutingDailyDetail
  11848. on GroutingDailyDetail.GroutingDailyDetailID=SemiCheck.GroutingDailyDetailID
  11849. left join TP_MST_Logo logo
  11850. on GroutingDailyDetail.LogoID=logo.LogoID
  11851. left join TP_PC_Procedure RProcedure
  11852. on SemiCheck.ReworkProcedureID=RProcedure.ProcedureID
  11853. left join TP_PM_SemiCheckDefect SemiCheckDefect
  11854. on SemiCheck.SemiCheckID=SemiCheckDefect.SemiCheckID
  11855. and SemiCheckDefect.ValueFlag='1'
  11856. left join TP_PC_Procedure Procedure
  11857. on SemiCheckDefect.DefectProcedureID=Procedure.ProcedureID
  11858. left join TP_MST_User DefectUser
  11859. on DefectUser.userid=SemiCheckDefect.DefectUserID
  11860. left join tp_pm_inproduction inp on inp.barcode = SemiCheck.barcode
  11861. left join TP_PC_Procedure inpp on inp.ProcedureID = inpp.ProcedureID
  11862. where SemiCheck.AccountID=:AccountID
  11863. ";
  11864. //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))
  11865. // 完成工序
  11866. if (!string.IsNullOrEmpty(se.CProcedureIDS))
  11867. {
  11868. sqlString = sqlString + " AND instr(','||:CProcedureIDS||',',','||SemiCheck.ProcedureID||',')>0 ";
  11869. parameters.Add(new OracleParameter(":CProcedureIDS", OracleDbType.NVarchar2, se.CProcedureIDS, ParameterDirection.Input));
  11870. }
  11871. // 完成时间起始
  11872. if (se.CDateTimeStart.HasValue)
  11873. {
  11874. sqlString = sqlString + " AND SemiCheck.ProcedureTime >= :CDateTimeStart ";
  11875. parameters.Add(new OracleParameter(":CDateTimeStart", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11876. }
  11877. // 完成时间结束
  11878. if (se.CDateTimeEnd.HasValue)
  11879. {
  11880. sqlString = sqlString + " AND SemiCheck.ProcedureTime <= :CDateTimeEnd ";
  11881. parameters.Add(new OracleParameter(":CDateTimeEnd", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11882. }
  11883. // 完成工号
  11884. if (!string.IsNullOrEmpty(se.CUserCode))
  11885. {
  11886. sqlString = sqlString + " AND instr(SemiCheck.UserCode,:UserCode)>0";
  11887. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CUserCode, ParameterDirection.Input));
  11888. }
  11889. // 产品类别
  11890. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  11891. {
  11892. sqlString = sqlString + " AND instr(GoodsType.GoodsTypeCode,:GoodsTypeCode)=1 ";
  11893. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  11894. }
  11895. // 产品编码
  11896. if (!string.IsNullOrEmpty(se.GoodsCode))
  11897. {
  11898. sqlString = sqlString + " AND instr(Goods.GoodsCode,:GoodsCode)>0";
  11899. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  11900. }
  11901. // 成型工号
  11902. if (!string.IsNullOrEmpty(se.GroutingUserCode))
  11903. {
  11904. sqlString = sqlString + " AND instr(SemiCheck.GroutingUserCode,:GroutingUserCode)>0";
  11905. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.NVarchar2, se.GroutingUserCode, ParameterDirection.Input));
  11906. }
  11907. // 注浆时间起始
  11908. if (se.GroutingDateTimeStart.HasValue)
  11909. {
  11910. sqlString = sqlString + " AND SemiCheck.GroutingDate >= :GroutingDateTimeStart ";
  11911. parameters.Add(new OracleParameter(":GroutingDateTimeStart", OracleDbType.Date, se.GroutingDateTimeStart.Value, ParameterDirection.Input));
  11912. }
  11913. // 注浆时间结束
  11914. if (se.GroutingDateTimeEnd.HasValue)
  11915. {
  11916. sqlString = sqlString + " AND SemiCheck.GroutingDate <= :GroutingDateTimeEnd ";
  11917. parameters.Add(new OracleParameter(":GroutingDateTimeEnd", OracleDbType.Date, se.GroutingDateTimeEnd.Value, ParameterDirection.Input));
  11918. }
  11919. // 交坯时间起始
  11920. if (se.DeliveryDateTimeStart.HasValue)
  11921. {
  11922. sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime >= :DeliveryDateTimeStart ";
  11923. parameters.Add(new OracleParameter(":DeliveryDateTimeStart", OracleDbType.Date, se.DeliveryDateTimeStart.Value, ParameterDirection.Input));
  11924. }
  11925. // 交坯时间结束
  11926. if (se.DeliveryDateTimeEnd.HasValue)
  11927. {
  11928. sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime <= :DeliveryDateTimeEnd ";
  11929. parameters.Add(new OracleParameter(":DeliveryDateTimeEnd", OracleDbType.Date, se.DeliveryDateTimeEnd.Value, ParameterDirection.Input));
  11930. }
  11931. // 半检状态
  11932. if (!string.IsNullOrEmpty(se.SemiCheckType))
  11933. {
  11934. sqlString = sqlString + " AND instr(','||:SemiCheckType||',',','||SemiCheck.SemiCheckType||',')>0 ";
  11935. parameters.Add(new OracleParameter(":SemiCheckType", OracleDbType.NVarchar2, se.SemiCheckType, ParameterDirection.Input));
  11936. }
  11937. // 半检时间起始
  11938. if (se.SemiCheckDateTimeStart.HasValue)
  11939. {
  11940. sqlString = sqlString + " AND SemiCheck.SemiCheckTime >= :SemiCheckDateTimeStart ";
  11941. parameters.Add(new OracleParameter(":SemiCheckDateTimeStart", OracleDbType.Date, se.SemiCheckDateTimeStart.Value, ParameterDirection.Input));
  11942. }
  11943. // 半检时间结束
  11944. if (se.SemiCheckDateTimeEnd.HasValue)
  11945. {
  11946. sqlString = sqlString + " AND SemiCheck.SemiCheckTime <= :SemiCheckDateTimeEnd ";
  11947. parameters.Add(new OracleParameter(":SemiCheckDateTimeEnd", OracleDbType.Date, se.SemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  11948. }
  11949. // 半检工号
  11950. if (!string.IsNullOrEmpty(se.SemiCheckUserCode))
  11951. {
  11952. sqlString = sqlString + " AND instr(SemiCheck.SemiCheckUserCode,:SemiCheckUserCode)>0";
  11953. parameters.Add(new OracleParameter(":SemiCheckUserCode", OracleDbType.NVarchar2, se.SemiCheckUserCode, ParameterDirection.Input));
  11954. }
  11955. // 返工工序
  11956. if (!string.IsNullOrEmpty(se.RProcedureIDS))
  11957. {
  11958. sqlString = sqlString + " AND instr(','||:RProcedureIDS||',',','||SemiCheck.ReworkProcedureID||',')>0 ";
  11959. parameters.Add(new OracleParameter(":RProcedureIDS", OracleDbType.NVarchar2, se.RProcedureIDS, ParameterDirection.Input));
  11960. }
  11961. // 返工工号
  11962. if (!string.IsNullOrEmpty(se.ReworkUserCode))
  11963. {
  11964. sqlString = sqlString + " AND instr(SemiCheck.ReworkUserCode,:ReworkUserCode)>0";
  11965. parameters.Add(new OracleParameter(":ReworkUserCode", OracleDbType.NVarchar2, se.ReworkUserCode, ParameterDirection.Input));
  11966. }
  11967. // 复检状态
  11968. if (!string.IsNullOrEmpty(se.ReSemiCheckType))
  11969. {
  11970. sqlString = sqlString + " AND instr(','||:ReSemiCheckType||',',','||SemiCheck.ReSemiCheckType||',')>0 ";
  11971. parameters.Add(new OracleParameter(":ReSemiCheckType", OracleDbType.NVarchar2, se.ReSemiCheckType, ParameterDirection.Input));
  11972. }
  11973. // 复检时间起始
  11974. if (se.ReSemiCheckDateTimeStart.HasValue)
  11975. {
  11976. sqlString = sqlString + " AND SemiCheck.ReSemiCheckTime >= :ReSemiCheckDateTimeStart ";
  11977. parameters.Add(new OracleParameter(":ReSemiCheckDateTimeStart", OracleDbType.Date, se.ReSemiCheckDateTimeStart.Value, ParameterDirection.Input));
  11978. }
  11979. // 复检时间结束
  11980. if (se.ReSemiCheckDateTimeEnd.HasValue)
  11981. {
  11982. sqlString = sqlString + " AND SemiCheck.ReSemiCheckTime <= :ReSemiCheckDateTimeEnd ";
  11983. parameters.Add(new OracleParameter(":ReSemiCheckDateTimeEnd", OracleDbType.Date, se.ReSemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  11984. }
  11985. // 复检工号
  11986. if (!string.IsNullOrEmpty(se.ReSemiCheckUserCode))
  11987. {
  11988. sqlString = sqlString + " AND instr(SemiCheck.ReSemiCheckUserCode,:ReSemiCheckUserCode)>0";
  11989. parameters.Add(new OracleParameter(":ReSemiCheckUserCode", OracleDbType.NVarchar2, se.ReSemiCheckUserCode, ParameterDirection.Input));
  11990. }
  11991. // 撤销标识
  11992. if (!string.IsNullOrEmpty(se.BackOutFlag))
  11993. {
  11994. sqlString = sqlString + " AND instr(','||:BackOutFlag||',',','||SemiCheck.BackOutFlag||',')>0 ";
  11995. parameters.Add(new OracleParameter(":BackOutFlag", OracleDbType.NVarchar2, se.BackOutFlag, ParameterDirection.Input));
  11996. }
  11997. // 撤销时间起始
  11998. if (se.BackOutTimeStart.HasValue)
  11999. {
  12000. sqlString = sqlString + " AND SemiCheck.BackOutTime >= :BackOutTimeStart ";
  12001. parameters.Add(new OracleParameter(":BackOutTimeStart", OracleDbType.Date, se.BackOutTimeStart.Value, ParameterDirection.Input));
  12002. }
  12003. // 撤销时间结束
  12004. if (se.BackOutTimeEnd.HasValue)
  12005. {
  12006. sqlString = sqlString + " AND SemiCheck.BackOutTime <= :BackOutTimeEnd ";
  12007. parameters.Add(new OracleParameter(":BackOutTimeEnd", OracleDbType.Date, se.BackOutTimeEnd.Value, ParameterDirection.Input));
  12008. }
  12009. // 撤销工号
  12010. if (!string.IsNullOrEmpty(se.BackOutUserCode))
  12011. {
  12012. sqlString = sqlString + " AND instr(SemiCheck.BackOutUserCode,:BackOutUserCode)>0";
  12013. parameters.Add(new OracleParameter(":BackOutUserCode", OracleDbType.NVarchar2, se.BackOutUserCode, ParameterDirection.Input));
  12014. }
  12015. // 产品条码
  12016. if (!string.IsNullOrEmpty(se.BarCode))
  12017. {
  12018. sqlString = sqlString + " AND instr(SemiCheck.BarCode,:BarCode)>0";
  12019. parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.BarCode, ParameterDirection.Input));
  12020. }
  12021. // 缺陷编码
  12022. if (!string.IsNullOrEmpty(se.DefectCode))
  12023. {
  12024. sqlString = sqlString + " AND instr(SemiCheckDefect.DefectCode,:DefectCode)>0";
  12025. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  12026. }
  12027. // 缺陷位置集
  12028. if (!string.IsNullOrEmpty(se.DefectPositionIDS))
  12029. {
  12030. sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||SemiCheckDefect.DefectPositionID||',')>0 ";
  12031. parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectPositionIDS, ParameterDirection.Input));
  12032. }
  12033. // 责任工序集
  12034. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  12035. {
  12036. sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||SemiCheckDefect.DefectPositionID||',')>0 ";
  12037. parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  12038. }
  12039. // 责任工号
  12040. if (!string.IsNullOrEmpty(se.DefectUser))
  12041. {
  12042. sqlString = sqlString + " AND instr(DefectUser.UserCode,:DefectUser)>0";
  12043. parameters.Add(new OracleParameter(":DefectUser", OracleDbType.NVarchar2, se.DefectUser, ParameterDirection.Input));
  12044. }
  12045. return sqlString;
  12046. }
  12047. /// <summary>
  12048. /// 取得F_RPT_030112画面(产成品交接汇总表)的汇总信息查询数据
  12049. /// </summary>
  12050. /// <param name="user">登录用户信息</param>
  12051. /// <param name="se">查询条件</param>
  12052. /// <returns>查询结果</returns>
  12053. public static ServiceResultEntity GetRPT0030112SData(SUserInfo user, SearchFinishedProductEntity se)
  12054. {
  12055. IDBConnection conn = null;
  12056. try
  12057. {
  12058. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12059. List<OracleParameter> parameters = new List<OracleParameter>();
  12060. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030112SSQL(user, se, ref parameters));
  12061. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  12062. ServiceResultEntity sre = new ServiceResultEntity();
  12063. if (data == null || data.Rows.Count == 0)
  12064. {
  12065. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12066. return sre;
  12067. }
  12068. sre.Data = new DataSet();
  12069. sre.Data.Tables.Add(data);
  12070. return sre;
  12071. }
  12072. catch (Exception ex)
  12073. {
  12074. throw ex;
  12075. }
  12076. finally
  12077. {
  12078. if (conn != null &&
  12079. conn.ConnState == ConnectionState.Open)
  12080. {
  12081. conn.Close();
  12082. }
  12083. }
  12084. }
  12085. /// <summary>
  12086. /// 获取RPT030112画面(产成品交接汇总表)的汇总信息查询sql
  12087. /// </summary>
  12088. /// <returns>sql</returns>
  12089. private static string GetRPT030112SSQL(SUserInfo user, SearchFinishedProductEntity se, ref List<OracleParameter> parameters)
  12090. {
  12091. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12092. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  12093. string sqlString = @"SELECT ts.gid
  12094. ,logoid
  12095. ,decode(ts.gid,
  12096. '23',
  12097. '总计【' || orderno || '】',
  12098. decode(ts.gid, '1', '--', '3', '--', orderno)) AS orderno
  12099. ,decode(ts.gid,
  12100. '3',
  12101. '合计【' || logoname || '】',
  12102. decode(ts.gid, '1', '--', logoname)) AS logoname
  12103. ,decode(ts.gid, '1', '小计【' || goodscode || '】', goodscode) AS goodscode
  12104. ,decode(ts.gid, '1', '--', goodsmodel) AS goodsmodel
  12105. ,GoodsSpecification
  12106. ,fhtime
  12107. ,COUNT
  12108. FROM (SELECT grouping_id(l.logoid,
  12109. o.orderno,
  12110. l.logoname,
  12111. g.goodscode,
  12112. to_char(f.fhtime, 'yyyy-mm-dd')) AS gid
  12113. ,decode(GROUPING(l.logoid), 1, '--', l.logoid) AS logoid
  12114. ,decode(GROUPING(o.orderno), 1, '--', o.orderno) AS orderno
  12115. ,decode(GROUPING(l.logoname), 1, '--', l.logoname) AS logoname
  12116. ,decode(GROUPING(g.goodscode), 1, '--', g.goodscode) AS goodscode
  12117. ,decode(GROUPING(g.goodscode), 1, '--', g.goodsmodel) AS goodsmodel
  12118. ,decode(GROUPING(g.GoodsSpecification), 1, '--', g.GoodsSpecification) AS GoodsSpecification
  12119. ,decode(GROUPING(to_char(f.fhtime, 'yyyy-mm-dd')),
  12120. 1,
  12121. '--',
  12122. to_char(f.fhtime, 'yyyy-mm-dd')) AS fhtime
  12123. ,COUNT(f.fhtime) AS COUNT
  12124. FROM tp_pm_finishedproduct F
  12125. LEFT JOIN TP_PM_Order O ON F.Fhorderid = O.Orderid
  12126. LEFT JOIN tp_mst_logo L ON F.LOGOID = L.LOGOID
  12127. LEFT JOIN tp_mst_goods G ON g.goodsid = f.goodsid
  12128. LEFT JOIN TP_MST_GoodsType gt ON g.GoodsTypeID = gt.GoodsTypeID
  12129. where f.fhtime is not null and f.AccountID=:AccountID ";
  12130. // 交接时间起始
  12131. if (se.FHTimeStart.HasValue)
  12132. {
  12133. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart ";
  12134. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, se.FHTimeStart.Value, ParameterDirection.Input));
  12135. }
  12136. // 交接时间结束
  12137. if (se.FHTimeEnd.HasValue)
  12138. {
  12139. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd ";
  12140. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, se.FHTimeEnd.Value, ParameterDirection.Input));
  12141. }
  12142. // 订单号
  12143. if (!string.IsNullOrEmpty(se.OrderNo))
  12144. {
  12145. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0";
  12146. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, se.OrderNo, ParameterDirection.Input));
  12147. }
  12148. // 产品类别编码
  12149. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  12150. {
  12151. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1";
  12152. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  12153. }
  12154. // 产品编码
  12155. if (!string.IsNullOrEmpty(se.GoodsCode))
  12156. {
  12157. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0";
  12158. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  12159. }
  12160. // 产品型号
  12161. if (!string.IsNullOrEmpty(se.GoodsModel))
  12162. {
  12163. sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0";
  12164. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, se.GoodsModel, ParameterDirection.Input));
  12165. }
  12166. // 产品商标ID集
  12167. if (!string.IsNullOrEmpty(se.LogoIDS))
  12168. {
  12169. sqlString += " AND instr(','||:LogoIDS||',', ',' || L.logoid || ',') > 0";
  12170. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, se.LogoIDS, ParameterDirection.Input));
  12171. }
  12172. // 交接工号
  12173. if (!string.IsNullOrEmpty(se.FHUserCode))
  12174. {
  12175. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0";
  12176. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, se.FHUserCode, ParameterDirection.Input));
  12177. }
  12178. sqlString = sqlString + @" GROUP BY rollup(o.orderno,l.logoid, l.logoname,g.goodscode,g.goodsmodel,g.GoodsSpecification,to_char(f.fhtime, 'yyyy-mm-dd'))
  12179. order by o.orderno,l.logoid, l.logoname,g.goodscode,to_char(f.fhtime, 'yyyy-mm-dd')
  12180. )ts
  12181. where ( logoid!='--' and orderno!='--' and logoname!='--' and goodscode!='--' and fhtime!='--')
  12182. or (goodscode!='--')
  12183. or(logoname!='')
  12184. or (orderno!='--') and ts.gid!='7'";
  12185. return sqlString;
  12186. }
  12187. /// <summary>
  12188. /// 取得F_RPT_030112画面(产成品交接汇总表)的汇总信息
  12189. /// </summary>
  12190. /// <param name="user">登录用户信息</param>
  12191. /// <param name="se">查询条件</param>
  12192. /// <returns>查询结果</returns>
  12193. public static ServiceResultEntity GetRPT0030112SumData(ClientRequestEntity cre, SUserInfo user)
  12194. {
  12195. IDBConnection conn = null;
  12196. try
  12197. {
  12198. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12199. List<OracleParameter> parameters = new List<OracleParameter>();
  12200. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12201. //string sqlString = "SELECT trunc(f.fhtime) fhtime, g.goodscode, COUNT(*) goodscount\n" +
  12202. string sqlString = "SELECT nvl2(o.orderno,\n" +
  12203. " nvl2(l.logoname,\n" +
  12204. " o.orderno,\n" +
  12205. " to_char('合计[') || o.orderno ||\n" +
  12206. " to_char(']')),\n" +
  12207. " '总计') orderno\n" +
  12208. " ,nvl2(l.logoname,\n" +
  12209. " nvl2(g.goodscode,\n" +
  12210. " l.logoname,\n" +
  12211. " to_char('小计[' || l.logoname || ']')),\n" +
  12212. " '--') logoname\n" +
  12213. " ,nvl(g.goodscode, '--') goodscode" +
  12214. " ,nvl(g.goodsmodel, '--') goodsmodel" +
  12215. " ,nvl(gdd.materialcode, '--') mcode" +
  12216. " ,f.logoid" +
  12217. " ,f.goodsid" +
  12218. " ,f.fhorderid" +
  12219. " ,COUNT(*) count" +
  12220. " FROM tp_pm_finishedproduct f\n" +
  12221. " inner JOIN tp_pm_groutingdailydetail gdd\n" +
  12222. " ON gdd.barcode = f.barcode\n" +
  12223. " LEFT JOIN tp_mst_logo l\n" +
  12224. " ON f.logoid = l.logoid\n" +
  12225. " LEFT JOIN TP_PM_Order O\n" +
  12226. " ON f.Fhorderid = O.Orderid\n" +
  12227. " LEFT JOIN tp_mst_goods G\n" +
  12228. " ON g.goodsid = f.goodsid\n" +
  12229. " LEFT JOIN TP_MST_GoodsType gt\n" +
  12230. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  12231. " WHERE f.fhtime IS NOT NULL\n" +
  12232. " AND f.AccountID = :AccountID\n";
  12233. // 交接时间起始
  12234. if (cre.Properties["FHTimeStart"] != null)
  12235. {
  12236. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
  12237. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, cre.Properties["FHTimeStart"], ParameterDirection.Input));
  12238. }
  12239. // 交接时间结束
  12240. if (cre.Properties["FHTimeEnd"] != null)
  12241. {
  12242. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd \n";
  12243. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, cre.Properties["FHTimeEnd"], ParameterDirection.Input));
  12244. }
  12245. // 订单号
  12246. if (!string.IsNullOrEmpty(cre.Properties["OrderNo"] as string))
  12247. {
  12248. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0 \n";
  12249. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, cre.Properties["OrderNo"], ParameterDirection.Input));
  12250. }
  12251. // 产品类别编码
  12252. if (!string.IsNullOrEmpty(cre.Properties["GoodsTypeCode"] as string))
  12253. {
  12254. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 \n";
  12255. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input));
  12256. }
  12257. // 产品编码
  12258. if (!string.IsNullOrEmpty(cre.Properties["GoodsCode"] as string))
  12259. {
  12260. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
  12261. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input));
  12262. }
  12263. // 产品型号
  12264. if (!string.IsNullOrEmpty(cre.Properties["GoodsModel"] as string))
  12265. {
  12266. sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0 \n";
  12267. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, cre.Properties["GoodsModel"], ParameterDirection.Input));
  12268. }
  12269. // 产品商标ID集
  12270. if (!string.IsNullOrEmpty(cre.Properties["LogoIDS"] as string))
  12271. {
  12272. sqlString += " AND instr(','||:LogoIDS||',', ',' || f.logoid || ',') > 0 \n";
  12273. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, cre.Properties["LogoIDS"], ParameterDirection.Input));
  12274. }
  12275. // 交接工号
  12276. if (!string.IsNullOrEmpty(cre.Properties["FHUserCode"] as string))
  12277. {
  12278. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0 \n";
  12279. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, cre.Properties["FHUserCode"], ParameterDirection.Input));
  12280. }
  12281. //sqlString += " group by trunc(f.fhtime), g.goodscode order by trunc(f.fhtime), g.goodscode";
  12282. 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),())";
  12283. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  12284. ServiceResultEntity sre = new ServiceResultEntity();
  12285. if (data == null || data.Rows.Count == 0)
  12286. {
  12287. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12288. return sre;
  12289. }
  12290. sre.Data = new DataSet();
  12291. sre.Data.Tables.Add(data);
  12292. return sre;
  12293. }
  12294. catch (Exception ex)
  12295. {
  12296. throw ex;
  12297. }
  12298. finally
  12299. {
  12300. if (conn != null &&
  12301. conn.ConnState == ConnectionState.Open)
  12302. {
  12303. conn.Close();
  12304. }
  12305. }
  12306. }
  12307. /// <summary>
  12308. /// 取得F_RPT_030112画面(产成品交接汇总表)的明细信息查询数据
  12309. /// </summary>
  12310. /// <param name="user">登录用户信息</param>
  12311. /// <param name="se">查询条件</param>
  12312. /// <returns>查询结果</returns>
  12313. public static ServiceResultEntity GetRPT0030112DetailSData(SUserInfo user, SearchFinishedProductEntity se)
  12314. {
  12315. IDBConnection conn = null;
  12316. try
  12317. {
  12318. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12319. List<OracleParameter> parameters = new List<OracleParameter>();
  12320. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT0030112DetailSData(user, se, ref parameters));
  12321. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  12322. ServiceResultEntity sre = new ServiceResultEntity();
  12323. if (data == null || data.Rows.Count == 0)
  12324. {
  12325. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12326. return sre;
  12327. }
  12328. sre.Data = new DataSet();
  12329. sre.Data.Tables.Add(data);
  12330. return sre;
  12331. }
  12332. catch (Exception ex)
  12333. {
  12334. throw ex;
  12335. }
  12336. finally
  12337. {
  12338. if (conn != null &&
  12339. conn.ConnState == ConnectionState.Open)
  12340. {
  12341. conn.Close();
  12342. }
  12343. }
  12344. }
  12345. private static string GetRPT0030112DetailSData(SUserInfo user, SearchFinishedProductEntity se, ref List<OracleParameter> parameters)
  12346. {
  12347. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12348. string sqlString = "SELECT O.ORDERNO,\n" +
  12349. " F.FHTIME,\n" +
  12350. " F.FHUSERCODE,\n" +
  12351. " F.BARCODE,\n" +
  12352. " F.GOODSCODE,\n" +
  12353. " L.LOGONAME,\n" +
  12354. " F.GROUTINGUSERCODE,\n" +
  12355. " F.GROUTINGLINECODE,\n" +
  12356. " F.GROUTINGMOULDCODE,\n" +
  12357. " F.GROUTINGDATE,\n" +
  12358. " G.DELIVERTIME,\n" +
  12359. " GOODS.goodsmodel,\n" +
  12360. //" (GOODS.MATERIALCODE || L.TAGCODE || G.ONLYCODE) AS FINISHEDBARCODE,\n" +
  12361. //" 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" +
  12362. " G.outlabelcode AS FINISHEDBARCODE,\n" +
  12363. " G.MATERIALCODE AS mcode,\n" +
  12364. " F.CREATETIME AS PRODUCTFINISHEDTIME\n" +
  12365. " FROM TP_PM_FINISHEDPRODUCT F\n" +
  12366. " LEFT JOIN TP_PM_ORDER O\n" +
  12367. " ON F.FHORDERID = O.ORDERID\n" +
  12368. " LEFT JOIN TP_MST_LOGO L\n" +
  12369. " ON F.LOGOID = L.LOGOID\n" +
  12370. " LEFT JOIN TP_PM_GROUTINGDAILYDETAIL G\n" +
  12371. " ON F.GROUTINGDAILYDETAILID = G.GROUTINGDAILYDETAILID\n" +
  12372. " LEFT JOIN TP_MST_GOODS GOODS\n" +
  12373. " ON F.GOODSID = GOODS.GOODSID\n" +
  12374. " LEFT JOIN TP_MST_GOODSTYPE GOODSTYPE\n" +
  12375. " ON GOODS.GOODSTYPEID = GOODSTYPE.GOODSTYPEID\n" +
  12376. " WHERE F.ACCOUNTID = :ACCOUNTID\n" +
  12377. " AND F.FHTIME IS NOT NULL";
  12378. // 交接时间起始
  12379. if (se.FHTimeStart.HasValue)
  12380. {
  12381. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart ";
  12382. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, se.FHTimeStart.Value, ParameterDirection.Input));
  12383. }
  12384. // 交接时间结束
  12385. if (se.FHTimeEnd.HasValue)
  12386. {
  12387. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd ";
  12388. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, se.FHTimeEnd.Value, ParameterDirection.Input));
  12389. }
  12390. // 订单号
  12391. if (!string.IsNullOrEmpty(se.OrderNo))
  12392. {
  12393. //sqlString = sqlString + " AND O.OrderNo=:OrderNo";
  12394. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0";
  12395. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, se.OrderNo, ParameterDirection.Input));
  12396. }
  12397. // 产品类别编码
  12398. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  12399. {
  12400. sqlString = sqlString + " AND instr(GoodsType.GoodsTypeCode,:GoodsTypeCode)=1";
  12401. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  12402. }
  12403. // 产品编码
  12404. if (!string.IsNullOrEmpty(se.GoodsCode))
  12405. {
  12406. sqlString = sqlString + " AND instr(Goods.GoodsCode,:GoodsCode)>0";
  12407. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  12408. }
  12409. // 产品型号
  12410. if (!string.IsNullOrEmpty(se.GoodsModel))
  12411. {
  12412. sqlString = sqlString + " AND instr(Goods.GoodsModel,:GoodsModel)>0";
  12413. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, se.GoodsModel, ParameterDirection.Input));
  12414. }
  12415. // 产品商标ID集
  12416. if (!string.IsNullOrEmpty(se.LogoIDS))
  12417. {
  12418. sqlString += " AND instr(','||:LogoIDS||',', ',' || L.logoid || ',') > 0";
  12419. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, se.LogoIDS, ParameterDirection.Input));
  12420. }
  12421. // 交接工号
  12422. if (!string.IsNullOrEmpty(se.FHUserCode))
  12423. {
  12424. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0";
  12425. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, se.FHUserCode, ParameterDirection.Input));
  12426. }
  12427. if (se.OrderID != null)
  12428. {
  12429. sqlString = sqlString + " AND F.fhorderid = :fhorderid";
  12430. parameters.Add(new OracleParameter(":fhorderid", OracleDbType.Int32, se.OrderID, ParameterDirection.Input));
  12431. }
  12432. if (se.GoodsID != null)
  12433. {
  12434. sqlString = sqlString + " AND F.GoodsID = :GoodsID";
  12435. parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  12436. }
  12437. if (se.LogoID != null)
  12438. {
  12439. sqlString = sqlString + " AND F.LogoID = :LogoID";
  12440. parameters.Add(new OracleParameter(":LogoID", OracleDbType.Int32, se.LogoID, ParameterDirection.Input));
  12441. }
  12442. return sqlString;
  12443. }
  12444. /// <summary>
  12445. /// 取得F_RPT_030112画面(产成品交接汇总表)的交接数量
  12446. /// </summary>
  12447. /// <param name="user">登录用户信息</param>
  12448. /// <param name="se">查询条件</param>
  12449. /// <returns>查询结果</returns>
  12450. public static ServiceResultEntity GetRPT0030112NData(ClientRequestEntity cre, SUserInfo user)
  12451. {
  12452. IDBConnection conn = null;
  12453. try
  12454. {
  12455. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12456. List<OracleParameter> parameters = new List<OracleParameter>();
  12457. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12458. //string sqlString = "SELECT trunc(f.fhtime) fhtime, g.goodscode, COUNT(*) goodscount\n" +
  12459. string sqlString = "SELECT nvl2(trunc(f.fhtime),\n" +
  12460. " nvl2(l.logoname,\n" +
  12461. " to_char(trunc(f.fhtime), 'yyyy-mm-dd'),\n" +
  12462. " to_char('合计[') || to_char(trunc(f.fhtime), 'yyyy-mm-dd') ||\n" +
  12463. " to_char(']')),\n" +
  12464. " '总计') fhtime\n" +
  12465. " ,nvl2(l.logoname,\n" +
  12466. " nvl2(g.goodscode,\n" +
  12467. " l.logoname,\n" +
  12468. " to_char('小计[' || l.logoname || ']')),\n" +
  12469. " '--') logoname\n" +
  12470. " ,nvl(g.goodscode, '--') goodscode" +
  12471. " ,nvl(g.goodsmodel, '--') goodsmodel" +
  12472. " ,nvl(gdd.materialcode, '--') mcode" +
  12473. " ,COUNT(*) goodscount" +
  12474. " FROM tp_pm_finishedproduct f\n" +
  12475. " inner JOIN tp_pm_groutingdailydetail gdd\n" +
  12476. " ON gdd.barcode = f.barcode\n" +
  12477. " LEFT JOIN tp_mst_logo l\n" +
  12478. " ON f.logoid = l.logoid\n" +
  12479. " LEFT JOIN TP_PM_Order O\n" +
  12480. " ON f.Fhorderid = O.Orderid\n" +
  12481. " LEFT JOIN tp_mst_goods G\n" +
  12482. " ON g.goodsid = f.goodsid\n" +
  12483. " LEFT JOIN TP_MST_GoodsType gt\n" +
  12484. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  12485. " WHERE f.fhtime IS NOT NULL\n" +
  12486. " AND f.AccountID = :AccountID\n";
  12487. // 交接时间起始
  12488. if (cre.Properties["FHTimeStart"] != null)
  12489. {
  12490. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
  12491. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, cre.Properties["FHTimeStart"], ParameterDirection.Input));
  12492. }
  12493. // 交接时间结束
  12494. if (cre.Properties["FHTimeEnd"] != null)
  12495. {
  12496. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd \n";
  12497. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, cre.Properties["FHTimeEnd"], ParameterDirection.Input));
  12498. }
  12499. // 订单号
  12500. if (!string.IsNullOrEmpty(cre.Properties["OrderNo"] as string))
  12501. {
  12502. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0 \n";
  12503. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, cre.Properties["OrderNo"], ParameterDirection.Input));
  12504. }
  12505. // 产品类别编码
  12506. if (!string.IsNullOrEmpty(cre.Properties["GoodsTypeCode"] as string))
  12507. {
  12508. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 \n";
  12509. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input));
  12510. }
  12511. // 产品编码
  12512. if (!string.IsNullOrEmpty(cre.Properties["GoodsCode"] as string))
  12513. {
  12514. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
  12515. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input));
  12516. }
  12517. // 产品型号
  12518. if (!string.IsNullOrEmpty(cre.Properties["GoodsModel"] as string))
  12519. {
  12520. sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0 \n";
  12521. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, cre.Properties["GoodsModel"], ParameterDirection.Input));
  12522. }
  12523. // 产品商标ID集
  12524. if (!string.IsNullOrEmpty(cre.Properties["LogoIDS"] as string))
  12525. {
  12526. sqlString += " AND instr(','||:LogoIDS||',', ',' || f.logoid || ',') > 0 \n";
  12527. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, cre.Properties["LogoIDS"], ParameterDirection.Input));
  12528. }
  12529. // 交接工号
  12530. if (!string.IsNullOrEmpty(cre.Properties["FHUserCode"] as string))
  12531. {
  12532. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0 \n";
  12533. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, cre.Properties["FHUserCode"], ParameterDirection.Input));
  12534. }
  12535. //sqlString += " group by trunc(f.fhtime), g.goodscode order by trunc(f.fhtime), g.goodscode";
  12536. sqlString += " GROUP BY GROUPING SETS((trunc(f.fhtime), l.logoname, g.goodscode,g.goodsmodel,gdd.materialcode),(trunc(f.fhtime), l.logoname),(trunc(f.fhtime)),())";
  12537. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  12538. ServiceResultEntity sre = new ServiceResultEntity();
  12539. if (data == null || data.Rows.Count == 0)
  12540. {
  12541. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12542. return sre;
  12543. }
  12544. sre.Data = new DataSet();
  12545. sre.Data.Tables.Add(data);
  12546. return sre;
  12547. }
  12548. catch (Exception ex)
  12549. {
  12550. throw ex;
  12551. }
  12552. finally
  12553. {
  12554. if (conn != null &&
  12555. conn.ConnState == ConnectionState.Open)
  12556. {
  12557. conn.Close();
  12558. }
  12559. }
  12560. }
  12561. /// <summary>
  12562. /// 取得F_RPT_030112画面(产成品交接汇总表)的型号数量
  12563. /// </summary>
  12564. /// <param name="user">登录用户信息</param>
  12565. /// <param name="se">查询条件</param>
  12566. /// <returns>查询结果</returns>
  12567. public static ServiceResultEntity GetRPT0030112GNData(ClientRequestEntity cre, SUserInfo user)
  12568. {
  12569. IDBConnection conn = null;
  12570. try
  12571. {
  12572. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12573. List<OracleParameter> parameters = new List<OracleParameter>();
  12574. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12575. //string sqlString = "SELECT trunc(f.fhtime) fhtime, g.goodscode, COUNT(*) goodscount\n" +
  12576. string sqlString = "SELECT --nvl2(trunc(f.fhtime),\n" +
  12577. //" nvl2(l.logoname,\n" +
  12578. //" to_char(trunc(f.fhtime), 'yyyy-mm-dd'),\n" +
  12579. //" to_char('合计[') || to_char(trunc(f.fhtime), 'yyyy-mm-dd') ||\n" +
  12580. //" to_char(']')),\n" +
  12581. //" '总计') fhtime\n" +
  12582. //" ,nvl2(l.logoname,\n" +
  12583. //" nvl2(g.goodscode,\n" +
  12584. //" l.logoname,\n" +
  12585. //" to_char('小计[' || l.logoname || ']')),\n" +
  12586. //" '--') logoname\n" +
  12587. " nvl(g.goodscode, '合计') goodscode" +
  12588. " ,nvl(g.goodsmodel, '--') goodsmodel" +
  12589. " ,nvl(gdd.materialcode, '--') mcode" +
  12590. " ,COUNT(*) goodscount" +
  12591. " FROM tp_pm_finishedproduct f\n" +
  12592. " inner JOIN tp_pm_groutingdailydetail gdd\n" +
  12593. " ON gdd.barcode = f.barcode\n" +
  12594. " LEFT JOIN tp_mst_logo l\n" +
  12595. " ON f.logoid = l.logoid\n" +
  12596. " LEFT JOIN TP_PM_Order O\n" +
  12597. " ON f.Fhorderid = O.Orderid\n" +
  12598. " LEFT JOIN tp_mst_goods G\n" +
  12599. " ON g.goodsid = f.goodsid\n" +
  12600. " LEFT JOIN TP_MST_GoodsType gt\n" +
  12601. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  12602. " WHERE f.fhtime IS NOT NULL\n" +
  12603. " AND f.AccountID = :AccountID\n";
  12604. // 交接时间起始
  12605. if (cre.Properties["FHTimeStart"] != null)
  12606. {
  12607. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
  12608. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, cre.Properties["FHTimeStart"], ParameterDirection.Input));
  12609. }
  12610. // 交接时间结束
  12611. if (cre.Properties["FHTimeEnd"] != null)
  12612. {
  12613. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd \n";
  12614. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, cre.Properties["FHTimeEnd"], ParameterDirection.Input));
  12615. }
  12616. // 订单号
  12617. if (!string.IsNullOrEmpty(cre.Properties["OrderNo"] as string))
  12618. {
  12619. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0 \n";
  12620. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, cre.Properties["OrderNo"], ParameterDirection.Input));
  12621. }
  12622. // 产品类别编码
  12623. if (!string.IsNullOrEmpty(cre.Properties["GoodsTypeCode"] as string))
  12624. {
  12625. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 \n";
  12626. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input));
  12627. }
  12628. // 产品编码
  12629. if (!string.IsNullOrEmpty(cre.Properties["GoodsCode"] as string))
  12630. {
  12631. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
  12632. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input));
  12633. }
  12634. // 产品型号
  12635. if (!string.IsNullOrEmpty(cre.Properties["GoodsModel"] as string))
  12636. {
  12637. sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0 \n";
  12638. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, cre.Properties["GoodsModel"], ParameterDirection.Input));
  12639. }
  12640. // 产品商标ID集
  12641. if (!string.IsNullOrEmpty(cre.Properties["LogoIDS"] as string))
  12642. {
  12643. sqlString += " AND instr(','||:LogoIDS||',', ',' || f.logoid || ',') > 0 \n";
  12644. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, cre.Properties["LogoIDS"], ParameterDirection.Input));
  12645. }
  12646. // 交接工号
  12647. if (!string.IsNullOrEmpty(cre.Properties["FHUserCode"] as string))
  12648. {
  12649. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0 \n";
  12650. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, cre.Properties["FHUserCode"], ParameterDirection.Input));
  12651. }
  12652. //sqlString += " group by trunc(f.fhtime), g.goodscode order by trunc(f.fhtime), g.goodscode";
  12653. sqlString += " GROUP BY GROUPING SETS((g.goodscode,g.goodsmodel,gdd.materialcode),())";
  12654. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  12655. ServiceResultEntity sre = new ServiceResultEntity();
  12656. if (data == null || data.Rows.Count == 0)
  12657. {
  12658. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12659. return sre;
  12660. }
  12661. sre.Data = new DataSet();
  12662. sre.Data.Tables.Add(data);
  12663. return sre;
  12664. }
  12665. catch (Exception ex)
  12666. {
  12667. throw ex;
  12668. }
  12669. finally
  12670. {
  12671. if (conn != null &&
  12672. conn.ConnState == ConnectionState.Open)
  12673. {
  12674. conn.Close();
  12675. }
  12676. }
  12677. }
  12678. /// <summary>
  12679. /// 取得PDA(产成品交接汇总表)的交接数量
  12680. /// </summary>
  12681. /// <param name="user">登录用户信息</param>
  12682. /// <param name="se">查询条件</param>
  12683. /// <returns>查询结果</returns>
  12684. public static ServiceResultEntity GetRPT0030112NPDAData(DateTime date, string goodscode, SUserInfo user)
  12685. {
  12686. IDBConnection conn = null;
  12687. try
  12688. {
  12689. DateTime dateStart = date;
  12690. DateTime dateEnd = dateStart.AddDays(1);
  12691. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12692. List<OracleParameter> parameters = new List<OracleParameter>();
  12693. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12694. string sqlString = "SELECT o.orderno, g.goodscode, COUNT(*) goodscount\n" +
  12695. " FROM tp_pm_finishedproduct f\n" +
  12696. " LEFT JOIN TP_PM_Order O\n" +
  12697. " ON f.Fhorderid = O.Orderid\n" +
  12698. " LEFT JOIN tp_mst_goods G\n" +
  12699. " ON g.goodsid = f.goodsid\n" +
  12700. " LEFT JOIN TP_MST_GoodsType gt\n" +
  12701. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  12702. " WHERE f.fhtime IS NOT NULL\n" +
  12703. " AND f.AccountID = :AccountID\n";
  12704. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
  12705. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, dateStart, ParameterDirection.Input));
  12706. sqlString = sqlString + " AND F.FHTime < :FHTimeEnd \n";
  12707. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, dateEnd, ParameterDirection.Input));
  12708. // 产品型号
  12709. if (!string.IsNullOrEmpty(goodscode))
  12710. {
  12711. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
  12712. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, goodscode, ParameterDirection.Input));
  12713. }
  12714. sqlString += " group by orderno, g.goodscode order by orderno, g.goodscode";
  12715. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  12716. ServiceResultEntity sre = new ServiceResultEntity();
  12717. if (data == null || data.Rows.Count == 0)
  12718. {
  12719. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12720. return sre;
  12721. }
  12722. sre.Data = new DataSet();
  12723. sre.Data.Tables.Add(data);
  12724. return sre;
  12725. }
  12726. catch (Exception ex)
  12727. {
  12728. throw ex;
  12729. }
  12730. finally
  12731. {
  12732. if (conn != null &&
  12733. conn.ConnState == ConnectionState.Open)
  12734. {
  12735. conn.Close();
  12736. }
  12737. }
  12738. }
  12739. /// <summary>
  12740. /// 获取在产品备份表
  12741. /// </summary>
  12742. /// <param name="cre"></param>
  12743. /// <param name="sUserInfo"></param>
  12744. /// <returns></returns>
  12745. public static ServiceResultEntity GetRPT010404Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  12746. {
  12747. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12748. try
  12749. {
  12750. ServiceResultEntity sre = new ServiceResultEntity();
  12751. string sqlString = "SELECT inpb.BackupMonth\n" +
  12752. " ,gdd.BarCode\n" +
  12753. //" ,inpb.GoodsID\n" +
  12754. " ,inpb.GoodsCode\n" +
  12755. " ,inpb.GoodsName\n" +
  12756. //" ,inpb.Userid\n" +
  12757. " ,worker.USERNAME AS UserName\n" +
  12758. " ,worker.USERCode AS UserCode\n" +
  12759. //" ,inpb.ProductionLineID\n" +
  12760. " ,inpb.ProductionLineCode\n" +
  12761. " ,inpb.ProductionLineName\n" +
  12762. //" ,inpb.ModelType\n" +
  12763. " ,decode(inpb.inscrapflag, '1', '待审核的报废品', '正常') AS inscrapflag\n" +
  12764. " ,inpb.IsPublicBody\n" +
  12765. " ,decode(inpb.IsReFire,'6','1','0') IsReFire\n" +
  12766. " ,inpb.IsReworkFlag\n" +
  12767. " ,decode(inpb.CanManyTimes, '1', '能', '不能') AS CanManyTimes\n" +
  12768. " ,decode(inpb.ProcedureModel, '1', '计件模型', '检验模型') AS ProcedureModel\n" +
  12769. //" ,inpb.GroutingDailyID\n" +
  12770. //" ,inpb.GroutingDailyDetailID\n" +
  12771. " ,inpb.GroutingDate\n" +
  12772. //" ,inpb.GroutingLineID\n" +
  12773. " ,inpb.GroutingLineCode\n" +
  12774. " ,inpb.GroutingLineName\n" +
  12775. //" ,inpb.ProcedureID CompleteProcedureID\n" +
  12776. " ,pro.ProcedureName AS CompleteProcedureName\n" +
  12777. //" ,inpb.GMouldTypeID\n" +
  12778. " ,gmt.GMOULDTYPENAME AS GMouldTypeName\n" +
  12779. //" ,inpb.GroutingLineDetailID\n" +
  12780. " ,inpb.GroutingMouldCode\n" +
  12781. " ,inpb.SPECIALREPAIRFLAG\n" +
  12782. " ,inpb.GROUTINGUSERCODE\n" +
  12783. " ,gdd.GROUTINGCOUNT\n" +
  12784. " ,gdd.delivertime\n" +
  12785. " ,inpb.proceduretime\n" +
  12786. " ,inpb.Remarks\n" +
  12787. //" ,inpb.GoodsLevelID\n" +
  12788. " ,mgl.GOODSLEVELNAME\n" +
  12789. //" ,inpb.GoodsLevelTypeID\n" +
  12790. " ,mglt.GOODSLEVELTYPENAME\n" +
  12791. " ,inpb.BackupTime\n" +
  12792. " ,REPLACE((logo.Logoname || '[' || logo.Logocode || ']'), '[]', '') AS LogoCodeName\n" +
  12793. //" ,(Goods.MaterialCode || logo.tagcode || gdd.onlycode) AS FinishedBarCode\n" +
  12794. " ,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" +
  12795. " FROM TP_PM_InProduction_BakByMonth inpb\n" +
  12796. " INNER JOIN TP_MST_User worker\n" +
  12797. " ON worker.UserID = inpb.Userid\n" +
  12798. " INNER JOIN TP_PC_Procedure pro\n" +
  12799. " ON pro.PROCEDUREID = inpb.ProcedureID\n" +
  12800. " INNER JOIN TP_MST_GMouldType gmt\n" +
  12801. " ON gmt.GMouldTypeID = inpb.GMouldTypeID\n" +
  12802. " INNER JOIN TP_SYS_ProcedureModelType pmt\n" +
  12803. " ON pmt.ProcedureModelTypeID = inpb.ModelType\n" +
  12804. //" INNER JOIN TP_PM_GroutingDaily gd\n" +
  12805. //" ON gd.GroutingDailyID = inpb.GroutingDailyID\n" +
  12806. " INNER JOIN TP_PM_GroutingDailyDetail gdd\n" +
  12807. " ON gdd.Groutingdailydetailid = inpb.GroutingDailyDetailID\n" +
  12808. //" INNER JOIN TP_PC_GroutingLineDetail gld\n" +
  12809. //" ON gld.Groutinglinedetailid = inpb.GroutingLineDetailID\n" +
  12810. " LEFT JOIN TP_MST_GoodsLevel mgl\n" +
  12811. " ON mgl.GoodsLevelID = inpb.GoodsLevelID\n" +
  12812. " LEFT JOIN TP_SYS_GoodsLevelType mglt\n" +
  12813. " ON mglt.GoodsLevelTypeID = inpb.GoodsLevelTypeID\n" +
  12814. " LEFT JOIN TP_MST_Logo logo\n" +
  12815. " ON inpb.logoid = logo.logoid\n" +
  12816. " LEFT JOIN TP_MST_Goods Goods\n" +
  12817. " ON inpb.GoodsID = Goods.GoodsID\n" +
  12818. " WHERE inpb.AccountID = :AccountID" +
  12819. " AND inpb.BackupMonth = :BackupMonth" +
  12820. " ORDER BY pro.displayno,inpb.proceduretime";
  12821. OracleParameter[] oracleParameter = new OracleParameter[]
  12822. {
  12823. new Oracle.ManagedDataAccess.Client.OracleParameter(":AccountID",sUserInfo.AccountID),
  12824. new Oracle.ManagedDataAccess.Client.OracleParameter(":BackupMonth",cre.Properties["BackupMonth"]),
  12825. };
  12826. oracleConn.Open();
  12827. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  12828. oracleConn.Close();
  12829. sre.Data = result;
  12830. return sre;
  12831. }
  12832. catch (Exception ex)
  12833. {
  12834. if (oracleConn.ConnState == ConnectionState.Open)
  12835. {
  12836. oracleConn.Close();
  12837. }
  12838. throw ex;
  12839. }
  12840. }
  12841. /// <summary>
  12842. /// 产成品单值明细表
  12843. /// </summary>
  12844. /// <param name="cre"></param>
  12845. /// <param name="sUserInfo"></param>
  12846. /// <returns></returns>
  12847. public static ServiceResultEntity GetRPT010405Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  12848. {
  12849. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12850. try
  12851. {
  12852. string sql =
  12853. "SELECT up.id, up.NAME\n" +
  12854. " FROM tp_mst_unitprice up\n" +
  12855. " WHERE up.accountid = :AccountID\n" +
  12856. " AND up.valueflag = '1'\n" +
  12857. " AND (:upname IS NULL OR instr(up.name, :upname) > 0)\n" +
  12858. " ORDER BY up.displayno";
  12859. OracleParameter[] opara = new OracleParameter[]
  12860. {
  12861. new Oracle.ManagedDataAccess.Client.OracleParameter(":AccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  12862. new Oracle.ManagedDataAccess.Client.OracleParameter(":upname", OracleDbType.NVarchar2,cre.Properties["UPName"], ParameterDirection.Input),
  12863. };
  12864. DataTable upTable = oracleConn.GetSqlResultToDt(sql, opara);
  12865. StringBuilder upNames = new StringBuilder();
  12866. StringBuilder upTotals = new StringBuilder();
  12867. StringBuilder upSUMs = new StringBuilder();
  12868. foreach (DataRow item in upTable.Rows)
  12869. {
  12870. upNames.AppendFormat(", u{0} AS \"{1}\"\n", item["ID"], item["Name"]);
  12871. upTotals.AppendFormat(",(u{0} * nvl(fpcount, 0)) AS \"总【{1}】\"\n", item["ID"], item["Name"]);
  12872. upSUMs.AppendFormat(",SUM(decode(up.upid, {0}, up.unitprice, 0)) u{0}\n", item["ID"]);
  12873. }
  12874. ServiceResultEntity sre = new ServiceResultEntity();
  12875. string sqlString = "SELECT gt2.goodstypename GoodsTypeName2\n" +
  12876. " ,g.goodscode\n" +
  12877. " ,g.materialcode\n" +
  12878. " ,lg.logoname\n" +
  12879. " ,nvl(fpcount, 0) fpcount\n" +
  12880. // " ,u1 AS \"单值1\"\n" +
  12881. //" ,u2 AS \"单值2\"\n" +
  12882. upNames +
  12883. //" ,(u1 * nvl(fpcount, 0)) AS \"总【1】\"\n" +
  12884. //" ,(u2 * nvl(fpcount, 0)) AS \"总【2】\"\n" +
  12885. upTotals +
  12886. " FROM (SELECT up.goodsid\n" +
  12887. " ,up.logoid\n" +
  12888. //" ,SUM(decode(up.upid, 1, up.unitprice, 0)) u1\n" +
  12889. //" ,SUM(decode(up.upid, 2, up.unitprice, 0)) u2\n" +
  12890. upSUMs +
  12891. " FROM TP_MST_UnitPriceGoods up\n" +
  12892. " WHERE up.accountid = :AccountID\n" +
  12893. " GROUP BY up.goodsid, up.logoid) upg\n" +
  12894. " LEFT JOIN (SELECT fp.goodsid, fp.logoid, COUNT(*) fpcount\n" +
  12895. " FROM tp_pm_finishedproduct fp\n" +
  12896. " WHERE fp.accountid = :AccountID\n" +
  12897. " AND fp.fhtime BETWEEN :DateBegin AND :DateEnd\n" +
  12898. " AND (:GoodsCode IS NULL OR\n" +
  12899. " instr(fp.goodscode, :GoodsCode) > 0)\n" +
  12900. " GROUP BY fp.goodsid, fp.logoid) fpp\n" +
  12901. " ON fpp.goodsid = upg.goodsid\n" +
  12902. " AND fpp.logoid = upg.logoid\n" +
  12903. " INNER JOIN tp_mst_logo lg\n" +
  12904. " ON lg.logoid = upg.logoid\n" +
  12905. " INNER JOIN tp_mst_goods g\n" +
  12906. " ON g.goodsid = upg.goodsid\n" +
  12907. " INNER JOIN tp_mst_goodstype gt\n" +
  12908. " ON gt.goodstypeid = g.goodstypeid\n" +
  12909. " INNER JOIN tp_mst_goodstype gt2\n" +
  12910. " ON gt2.accountid = :AccountID\n" +
  12911. " AND length(gt2.goodstypecode) = 6\n" +
  12912. " AND instr(gt.goodstypecode, gt2.goodstypecode) = 1\n" +
  12913. " WHERE (:GoodsTypeCode IS NULL OR\n" +
  12914. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  12915. " AND (:GoodsCode IS NULL OR instr(g.goodscode, :GoodsCode) > 0)\n" +
  12916. " AND (:logoname IS NULL OR instr(lg.logoname, :logoname) > 0)\n" +
  12917. " ORDER BY g.goodscode, lg.displayno";
  12918. OracleParameter[] oracleParameter = new OracleParameter[]
  12919. {
  12920. new Oracle.ManagedDataAccess.Client.OracleParameter(":AccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  12921. new Oracle.ManagedDataAccess.Client.OracleParameter(":DateBegin", OracleDbType.Date,cre.Properties["DateBegin"], ParameterDirection.Input),
  12922. new Oracle.ManagedDataAccess.Client.OracleParameter(":DateEnd", OracleDbType.Date,cre.Properties["DateEnd"], ParameterDirection.Input),
  12923. new Oracle.ManagedDataAccess.Client.OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2,cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  12924. new Oracle.ManagedDataAccess.Client.OracleParameter(":GoodsCode", OracleDbType.NVarchar2,cre.Properties["GoodsCode"], ParameterDirection.Input),
  12925. new Oracle.ManagedDataAccess.Client.OracleParameter(":logoname", OracleDbType.NVarchar2,cre.Properties["LogoName"], ParameterDirection.Input),
  12926. };
  12927. oracleConn.Open();
  12928. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  12929. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  12930. {
  12931. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12932. }
  12933. sre.Data = result;
  12934. oracleConn.Close();
  12935. return sre;
  12936. }
  12937. catch (Exception ex)
  12938. {
  12939. if (oracleConn.ConnState == ConnectionState.Open)
  12940. {
  12941. oracleConn.Close();
  12942. }
  12943. throw ex;
  12944. }
  12945. }
  12946. /// <summary>
  12947. /// 产成品单值明细表-单值名管理
  12948. /// </summary>
  12949. /// <param name="cre"></param>
  12950. /// <param name="sUserInfo"></param>
  12951. /// <returns></returns>
  12952. public static ServiceResultEntity GetRPT01040501Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  12953. {
  12954. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12955. try
  12956. {
  12957. ServiceResultEntity sre = new ServiceResultEntity();
  12958. string sqlString = "SELECT t.id, t.name, t.displayno, t.valueflag\n" +
  12959. " FROM TP_MST_UnitPrice t\n" +
  12960. " WHERE t.accountid = :accountid\n" +
  12961. " ORDER BY t.id";
  12962. OracleParameter[] oracleParameter = new OracleParameter[]
  12963. {
  12964. new Oracle.ManagedDataAccess.Client.OracleParameter(":AccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  12965. };
  12966. oracleConn.Open();
  12967. sre.Data = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  12968. oracleConn.Close();
  12969. return sre;
  12970. }
  12971. catch (Exception ex)
  12972. {
  12973. if (oracleConn.ConnState == ConnectionState.Open)
  12974. {
  12975. oracleConn.Close();
  12976. }
  12977. throw ex;
  12978. }
  12979. }
  12980. /// <summary>
  12981. /// 产成品单值明细表-单值名管理
  12982. /// </summary>
  12983. /// <param name="cre"></param>
  12984. /// <param name="sUserInfo"></param>
  12985. /// <returns></returns>
  12986. public static ServiceResultEntity SetRPT01040501Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  12987. {
  12988. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  12989. try
  12990. {
  12991. ServiceResultEntity sre = new ServiceResultEntity();
  12992. // 检验参数的有效性
  12993. if (cre.Data == null && cre.Data.Tables.Count == 0 ||
  12994. cre.Data.Tables[0].Rows.Count < Constant.INT_IS_ZERO)
  12995. {
  12996. return sre;
  12997. }
  12998. oracleTrConn.Connect();
  12999. foreach (DataRow dataRow in cre.Data.Tables[0].Rows)
  13000. {
  13001. // 新建
  13002. if (dataRow.RowState == DataRowState.Added)
  13003. {
  13004. #region 新增
  13005. string sqlString = "INSERT INTO TP_MST_UNITPRICE\n" +
  13006. " (NAME, displayno, accountid, valueflag, createuserid, updateuserid)\n" +
  13007. "VALUES\n" +
  13008. " (:NAME, nvl(:DisplayNo,0), :AccountID, :ValueFlag, :UserID, :UserID)";
  13009. OracleParameter[] oracleParameter = new OracleParameter[]
  13010. {
  13011. new OracleParameter(":NAME", OracleDbType.NVarchar2, dataRow["Name"],ParameterDirection.Input),
  13012. new OracleParameter(":DisplayNo",OracleDbType.Int32, dataRow["DisplayNo"], ParameterDirection.Input),
  13013. new OracleParameter(":AccountID",OracleDbType.Int32,sUserInfo.AccountID, ParameterDirection.Input),
  13014. new OracleParameter(":ValueFlag",OracleDbType.NVarchar2, dataRow["ValueFlag"],ParameterDirection.Input),
  13015. new OracleParameter(":UserID",OracleDbType.Int32,sUserInfo.UserID, ParameterDirection.Input),
  13016. };
  13017. oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  13018. #endregion
  13019. }
  13020. else if (dataRow.RowState == DataRowState.Modified)
  13021. {
  13022. #region 更新
  13023. string sqlUpdateString = "UPDATE TP_MST_UNITPRICE SET "
  13024. + " Name = :Name,"
  13025. + " DisplayNo = :DisplayNo,"
  13026. + " ValueFlag = :ValueFlag,"
  13027. + " UpdateUserID = :UserID"
  13028. + " WHERE ID = :ID";
  13029. OracleParameter[] oracleParameter = new OracleParameter[]
  13030. {
  13031. new OracleParameter(":ID",OracleDbType.Int32,dataRow["ID"], ParameterDirection.Input),
  13032. new OracleParameter(":Name", OracleDbType.NVarchar2, dataRow["Name"],ParameterDirection.Input),
  13033. new OracleParameter(":DisplayNo",OracleDbType.Int32, dataRow["DisplayNo"], ParameterDirection.Input),
  13034. new OracleParameter(":ValueFlag",OracleDbType.NVarchar2, dataRow["ValueFlag"],ParameterDirection.Input),
  13035. new OracleParameter(":UserID",OracleDbType.Int32,sUserInfo.UserID, ParameterDirection.Input),
  13036. };
  13037. oracleTrConn.ExecuteNonQuery(sqlUpdateString, oracleParameter);
  13038. #endregion
  13039. }
  13040. else if (dataRow.RowState == DataRowState.Deleted)
  13041. {
  13042. #region 删除
  13043. string sqlDeleteString = "DELETE TP_MST_UNITPRICE WHERE ID = :ID";
  13044. OracleParameter[] oracleParameter = new OracleParameter[]
  13045. {
  13046. new OracleParameter(":ID",OracleDbType.Int32,dataRow["ID"], ParameterDirection.Input),
  13047. };
  13048. oracleTrConn.ExecuteNonQuery(sqlDeleteString, oracleParameter);
  13049. #endregion
  13050. }
  13051. }
  13052. oracleTrConn.Commit();
  13053. oracleTrConn.Disconnect();
  13054. return sre;
  13055. }
  13056. catch (Exception ex)
  13057. {
  13058. if (oracleTrConn.ConnState == ConnectionState.Open)
  13059. {
  13060. oracleTrConn.Rollback();
  13061. oracleTrConn.Disconnect();
  13062. }
  13063. throw ex;
  13064. }
  13065. finally
  13066. {
  13067. if (oracleTrConn.ConnState == ConnectionState.Open)
  13068. {
  13069. oracleTrConn.Disconnect();
  13070. }
  13071. }
  13072. }
  13073. /// <summary>
  13074. /// 获取模具跟踪表
  13075. /// </summary>
  13076. /// <param name="cre"></param>
  13077. /// <param name="sUserInfo"></param>
  13078. /// <returns></returns>
  13079. public static ServiceResultEntity GetRPT020105Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13080. {
  13081. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13082. try
  13083. {
  13084. ServiceResultEntity sre = new ServiceResultEntity();
  13085. OracleParameter[] oracleParameter = new OracleParameter[]
  13086. {
  13087. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13088. new OracleParameter("in_MouldBarcode",OracleDbType.Varchar2, cre.Properties["MouldBarcode"], ParameterDirection.Input),
  13089. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13090. new OracleParameter("out_Tracking",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13091. };
  13092. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_GetMouldTracking", oracleParameter);
  13093. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13094. {
  13095. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13096. }
  13097. sre.Data = result;
  13098. return sre;
  13099. }
  13100. catch (Exception ex)
  13101. {
  13102. if (oracleConn.ConnState == ConnectionState.Open)
  13103. {
  13104. oracleConn.Close();
  13105. }
  13106. throw ex;
  13107. }
  13108. }
  13109. /// <summary>
  13110. /// 获取模具收发存汇总表
  13111. /// </summary>
  13112. /// <param name="cre"></param>
  13113. /// <param name="sUserInfo"></param>
  13114. /// <returns></returns>
  13115. public static ServiceResultEntity GetRPT030113Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13116. {
  13117. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13118. try
  13119. {
  13120. ServiceResultEntity sre = new ServiceResultEntity();
  13121. OracleParameter[] oracleParameter = new OracleParameter[]
  13122. {
  13123. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13124. new OracleParameter("in_YYYYMM",OracleDbType.Varchar2, cre.Properties["YYYYMM"], ParameterDirection.Input),
  13125. new OracleParameter("in_DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13126. new OracleParameter("in_DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13127. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13128. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13129. new OracleParameter("in_GoodsIDs",OracleDbType.Varchar2, cre.Properties["GoodsIDs"], ParameterDirection.Input),
  13130. new OracleParameter("in_GoodsID",OracleDbType.Int32, cre.Properties["GoodsID"], ParameterDirection.Input),
  13131. new OracleParameter("in_Type",OracleDbType.Int32, cre.Properties["Type"], ParameterDirection.Input),
  13132. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13133. };
  13134. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_GetMould_SUM", oracleParameter);
  13135. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13136. {
  13137. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13138. }
  13139. sre.Data = result;
  13140. oracleConn.Commit();
  13141. return sre;
  13142. }
  13143. catch (Exception ex)
  13144. {
  13145. if (oracleConn.ConnState == ConnectionState.Open)
  13146. {
  13147. oracleConn.Disconnect();
  13148. }
  13149. throw ex;
  13150. }
  13151. }
  13152. /// <summary>
  13153. /// 获取废弃产品汇总表
  13154. /// </summary>
  13155. /// <param name="cre"></param>
  13156. /// <param name="sUserInfo"></param>
  13157. /// <returns></returns>
  13158. public static ServiceResultEntity GetRPT030114Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13159. {
  13160. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13161. try
  13162. {
  13163. ServiceResultEntity sre = new ServiceResultEntity();
  13164. OracleParameter[] oracleParameter = new OracleParameter[]
  13165. {
  13166. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13167. new OracleParameter("in_DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13168. new OracleParameter("in_DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13169. new OracleParameter("in_scrapTypes",OracleDbType.Varchar2, cre.Properties["ScrapTypes"], ParameterDirection.Input),
  13170. new OracleParameter("in_ProcedureIDs",OracleDbType.Varchar2, cre.Properties["ProcedureIDs"], ParameterDirection.Input),
  13171. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13172. //new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13173. new OracleParameter("in_GoodsIDs",OracleDbType.Varchar2, cre.Properties["GoodsIDs"], ParameterDirection.Input),
  13174. new OracleParameter("in_GoodsID",OracleDbType.Int32, cre.Properties["GoodsID"], ParameterDirection.Input),
  13175. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13176. };
  13177. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_scrap_sum", oracleParameter);
  13178. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13179. {
  13180. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13181. }
  13182. sre.Data = result;
  13183. oracleConn.Commit();
  13184. return sre;
  13185. }
  13186. catch (Exception ex)
  13187. {
  13188. if (oracleConn.ConnState == ConnectionState.Open)
  13189. {
  13190. oracleConn.Disconnect();
  13191. }
  13192. throw ex;
  13193. }
  13194. }
  13195. /// <summary>
  13196. /// 获取废品损失汇总表
  13197. /// </summary>
  13198. /// <param name="cre"></param>
  13199. /// <param name="sUserInfo"></param>
  13200. /// <returns></returns>
  13201. public static ServiceResultEntity GetRPT030115Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13202. {
  13203. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13204. try
  13205. {
  13206. ServiceResultEntity sre = new ServiceResultEntity();
  13207. OracleParameter[] oracleParameter = new OracleParameter[]
  13208. {
  13209. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13210. new OracleParameter("in_ptid",OracleDbType.Int32, cre.Properties["PTID"], ParameterDirection.Input),
  13211. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13212. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13213. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13214. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13215. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13216. };
  13217. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_TECDEP_SCRAP_SUM", oracleParameter);
  13218. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13219. {
  13220. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13221. }
  13222. sre.Data = result;
  13223. oracleConn.Commit();
  13224. return sre;
  13225. }
  13226. catch (Exception ex)
  13227. {
  13228. if (oracleConn.ConnState == ConnectionState.Open)
  13229. {
  13230. oracleConn.Disconnect();
  13231. }
  13232. throw ex;
  13233. }
  13234. }
  13235. /// <summary>
  13236. /// 获取废品损失汇总-明细表
  13237. /// </summary>
  13238. /// <param name="cre"></param>
  13239. /// <param name="sUserInfo"></param>
  13240. /// <returns></returns>
  13241. public static ServiceResultEntity GetRPT030115DData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13242. {
  13243. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13244. try
  13245. {
  13246. ServiceResultEntity sre = new ServiceResultEntity();
  13247. OracleParameter[] oracleParameter = new OracleParameter[]
  13248. {
  13249. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13250. new OracleParameter("in_ptid",OracleDbType.Int32, cre.Properties["PTID"], ParameterDirection.Input),
  13251. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13252. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13253. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13254. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13255. new OracleParameter("in_GoodsID",OracleDbType.Varchar2, cre.Properties["GoodsID"], ParameterDirection.Input),
  13256. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13257. };
  13258. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_TECDEP_SCRAP_SUMDETAIL", oracleParameter);
  13259. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13260. {
  13261. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13262. }
  13263. sre.Data = result;
  13264. oracleConn.Commit();
  13265. return sre;
  13266. }
  13267. catch (Exception ex)
  13268. {
  13269. if (oracleConn.ConnState == ConnectionState.Open)
  13270. {
  13271. oracleConn.Disconnect();
  13272. }
  13273. throw ex;
  13274. }
  13275. }
  13276. /// <summary>
  13277. /// 获取废品损失汇总表-半成品损失汇总表
  13278. /// </summary>
  13279. /// <param name="cre"></param>
  13280. /// <param name="sUserInfo"></param>
  13281. /// <returns></returns>
  13282. public static ServiceResultEntity GetRPT030115SData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13283. {
  13284. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13285. try
  13286. {
  13287. ServiceResultEntity sre = new ServiceResultEntity();
  13288. OracleParameter[] oracleParameter = new OracleParameter[]
  13289. {
  13290. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13291. new OracleParameter("in_ptid",OracleDbType.Int32, cre.Properties["PTID"], ParameterDirection.Input),
  13292. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13293. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13294. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13295. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13296. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13297. };
  13298. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_TECDEP_SCRAP_SUM_semi", oracleParameter);
  13299. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13300. {
  13301. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13302. }
  13303. StringBuilder cols = new StringBuilder();
  13304. StringBuilder sumCols = new StringBuilder();
  13305. foreach (DataRow item in result.Tables[0].Rows)
  13306. {
  13307. cols.AppendFormat(", d{0} AS \"{1}\"\n", item["id"], item["name"]);
  13308. sumCols.AppendFormat(", SUM(decode(td1.id, {0}, g.d, 0)) d{0}\n", item["id"]);
  13309. }
  13310. string sqlString = "SELECT gid\n" +
  13311. " ,decode(gid, 3, '合计', 1, '小计[' || gt2name || ']', gt2name) gt2name\n" +
  13312. " ,decode(gid, 0, td2name, '--') td2name\n" +
  13313. " ,gg.gc\n" +
  13314. " ,case when gg.gc is not null and gg.gc > 0 then round(tt.d / gg.gc,4) else null end gcc\n" +
  13315. " ,d\n" +
  13316. " ,c\n" +
  13317. " ,d-c g\n" +
  13318. cols +
  13319. " FROM (SELECT grouping_id(t.tecdepid, td2.id) gid\n" +
  13320. " ,nvl(t.tecdepid, -1) gt2id\n" +
  13321. " ,t.tecdepname gt2name\n" +
  13322. " ,td2.name td2name\n" +
  13323. " ,td2.displayno td2displayno\n" +
  13324. " ,SUM(g.d) d\n" +
  13325. " ,SUM(g.c) c\n" +
  13326. sumCols +
  13327. " FROM TMP_RPT_TECDEP_G g\n" +
  13328. " INNER JOIN TMP_RPT_TECDEP_T t\n" +
  13329. " ON g.goodsid = t.goodsid\n" +
  13330. " INNER JOIN tmp_rpt_tecdep_s s1\n" +
  13331. " ON s1.procedureid = g.pid\n" +
  13332. " INNER JOIN tp_mst_tecdep td1\n" +
  13333. " ON td1.id = s1.intecdepid\n" +
  13334. " LEFT JOIN tmp_rpt_tecdep_s s2\n" +
  13335. " ON s2.procedureid = g.f\n" +
  13336. " LEFT JOIN tp_mst_tecdep td2\n" +
  13337. " ON td2.id = s2.intecdepid\n" +
  13338. " WHERE td1.technologyflag = '1' -- 半成品工艺\n" +
  13339. " AND (td2.id IS NULL OR td2.technologyflag = '1')\n" +
  13340. " GROUP BY GROUPING SETS((t.tecdepid, t.tecdepname, td2.id, td2.name, td2.displayno),(t.tecdepid, t.tecdepname),())\n" +
  13341. " ORDER BY t.tecdepname, td2.displayno) tt\n" +
  13342. " LEFT JOIN (SELECT --grouping_id(gt2.goodstypeid) gid,\n" +
  13343. " nvl(t.tecdepid, -1) gt2id, COUNT(*) gc\n" +
  13344. " FROM tp_pm_groutingdailydetail gdd\n" +
  13345. " INNER JOIN TMP_RPT_TECDEP_T t\n" +
  13346. " ON gdd.goodsid = t.goodsid\n" +
  13347. " WHERE gdd.accountid = :in_accountid\n" +
  13348. " AND gdd.valueflag = '1'\n" +
  13349. " AND gdd.groutingflag = '1'\n" +
  13350. " AND gdd.groutingdate BETWEEN :in_datetimebegin AND\n" +
  13351. " :in_datetimeend\n" +
  13352. " GROUP BY GROUPING SETS((t.tecdepid),())) gg\n" +
  13353. " ON gg.gt2id = tt.gt2id\n" +
  13354. " ORDER BY tt.gt2name, tt.gid, tt.td2displayno";
  13355. oracleParameter = new OracleParameter[]
  13356. {
  13357. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13358. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13359. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13360. };
  13361. result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13362. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13363. {
  13364. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13365. }
  13366. sre.Data = result;
  13367. oracleConn.Commit();
  13368. return sre;
  13369. }
  13370. catch (Exception ex)
  13371. {
  13372. if (oracleConn.ConnState == ConnectionState.Open)
  13373. {
  13374. oracleConn.Disconnect();
  13375. }
  13376. throw ex;
  13377. }
  13378. }
  13379. /// <summary>
  13380. /// 获取成型存坯汇总表-注浆产品存坯汇总表
  13381. /// </summary>
  13382. /// <param name="cre"></param>
  13383. /// <param name="sUserInfo"></param>
  13384. /// <returns></returns>
  13385. public static ServiceResultEntity GetRPT030116GoodsData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13386. {
  13387. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13388. try
  13389. {
  13390. ServiceResultEntity sre = new ServiceResultEntity();
  13391. /*
  13392. string sqlString =
  13393. "SELECT gdrd.goodsid\n" +
  13394. " ,gdrd.goodscode\n" +
  13395. //" ,gdrd.groutinglineid\n" +
  13396. //" ,gdrd.groutinglinecode\n" +
  13397. //" ,gdrd.userid\n" +
  13398. //" ,gdrd.usercode\n" +
  13399. " ,gdrd.gddc rdcount -- 存坯数\n" +
  13400. " ,rdd.gldcount -- 模具数\n" +
  13401. " , CASE\n" +
  13402. " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
  13403. " round(gdrd.gddc / rdd.gldcount, 2)\n" +
  13404. " ELSE\n" +
  13405. " NULL\n" +
  13406. " END rddays -- 存坯天数\n" +
  13407. " ,gdrd.reserveddays -- 应存天数\n" +
  13408. " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
  13409. " FROM (SELECT gdd.goodsid\n" +
  13410. " ,gdd.goodscode\n" +
  13411. //" ,gdd.groutinglineid\n" +
  13412. //" ,gdd.groutinglinecode\n" +
  13413. //" ,gdd.userid\n" +
  13414. //" ,gdd.usercode\n" +
  13415. " ,g.reserveddays\n" +
  13416. " ,COUNT(*) gddc\n" +
  13417. " FROM tp_pm_groutingdailydetail gdd\n" +
  13418. " INNER JOIN tp_mst_goods g\n" +
  13419. " ON g.goodsid = gdd.goodsid\n" +
  13420. " INNER JOIN tp_mst_goodstype gt\n" +
  13421. " ON g.goodstypeid = gt.goodstypeid\n" +
  13422. " WHERE gdd.accountid = :accountid\n" +
  13423. " AND gdd.valueflag = '1'\n" +
  13424. " AND gdd.groutingflag = '1'\n" +
  13425. " AND gdd.barcode IS NOT NULL\n" +
  13426. " AND gdd.scrapflag = '0'\n" +
  13427. " AND gdd.deliverflag = '0'\n" +
  13428. " AND (:LineCode IS NULL OR\n" +
  13429. " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13430. " AND (:UserCode IS NULL OR instr(gdd.UserCode, :UserCode) > 0)\n" +
  13431. " AND (:GoodsCode IS NULL OR instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13432. " AND (:GoodsTypeCode IS NULL OR\n" +
  13433. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13434. " AND (:DateBegin IS NULL OR\n" +
  13435. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
  13436. " GROUP BY gdd.goodsid\n" +
  13437. " ,gdd.goodscode\n" +
  13438. //" ,gdd.groutinglineid\n" +
  13439. //" ,gdd.groutinglinecode\n" +
  13440. //" ,gdd.userid\n" +
  13441. //" ,gdd.usercode\n" +
  13442. " ,g.reserveddays) gdrd\n" +
  13443. " LEFT JOIN (SELECT gld.goodsid\n" +
  13444. //" ,gld.groutinglineid\n" +
  13445. " ,COUNT(*) gldcount\n" +
  13446. " FROM tp_pc_groutinglinedetail gld\n" +
  13447. " INNER JOIN tp_pc_groutingline gl\n" +
  13448. " ON gl.groutinglineid = gld.groutinglineid\n" +
  13449. " WHERE gld.valueflag = '1'\n" +
  13450. " AND gld.gmouldstatus = 1\n" +
  13451. " AND gl.accountid = :accountid\n" +
  13452. " AND gl.valueflag = '1'\n" +
  13453. " AND gl.gmouldstatus = 1\n" +
  13454. " GROUP BY gld.goodsid\n" +
  13455. //" ,gld.groutinglineid\n" +
  13456. " ) rdd\n" +
  13457. " ON rdd.goodsid = gdrd.goodsid\n" +
  13458. //" AND rdd.groutinglineid = gdrd.groutinglineid\n" +
  13459. " ORDER BY gdrd.goodscode\n" +
  13460. //" ,gdrd.groutinglinecode, gdrd.usercode"
  13461. "";
  13462. */
  13463. string sqlString =
  13464. "SELECT grouping_id(t.goodstypecode2, t.goodsid) gid\n" +
  13465. " ,t.goodstypecode2\n" +
  13466. " ,decode(grouping_id(t.goodstypecode2, t.goodsid),\n" +
  13467. " 3,\n" +
  13468. " '总计',\n" +
  13469. " 1,\n" +
  13470. " '合计[' || t.goodstypename2 || ']',\n" +
  13471. " t.goodstypename2) goodstypename2\n" +
  13472. " ,t.goodstypename\n" +
  13473. " ,t.goodsid\n" +
  13474. " ,t.goodscode\n" +
  13475. //" ,t.groutinglineid\n" +
  13476. //" ,t.groutinglinecode\n" +
  13477. //" ,t.userid\n" +
  13478. //" ,t.usercode\n" +
  13479. " ,SUM(t.rdcount) rdcount\n" +
  13480. " ,t.gldcount -- 模具数\n" +
  13481. " ,t.rddays -- 存坯天数\n" +
  13482. " ,t.reserveddays -- 应存天数\n" +
  13483. " ,SUM(t.ProfitNum) ProfitNum\n" +
  13484. " FROM (SELECT gt2.goodstypecode goodstypecode2\n" +
  13485. " ,gt2.goodstypename goodstypename2\n" +
  13486. " ,gdrd.goodsid\n" +
  13487. " ,gdrd.goodscode\n" +
  13488. " ,gdrd.goodstypename\n" +
  13489. //" ,gdrd.groutinglineid\n" +
  13490. //" ,gdrd.groutinglinecode\n" +
  13491. //" ,gdrd.userid\n" +
  13492. //" ,gdrd.usercode\n" +
  13493. " ,gdrd.gddc rdcount -- 存坯数\n" +
  13494. " ,rdd.gldcount -- 模具数\n" +
  13495. " , CASE\n" +
  13496. " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
  13497. " round(gdrd.gddc / rdd.gldcount, 2)\n" +
  13498. " ELSE\n" +
  13499. " NULL\n" +
  13500. " END rddays -- 存坯天数\n" +
  13501. " ,gdrd.reserveddays -- 应存天数\n" +
  13502. // 盈亏坯数 = 存坯数-应存天数*模具数 存坯天数 = 存坯数/模具数
  13503. " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
  13504. " FROM (SELECT gdd.goodsid\n" +
  13505. " ,gdd.goodscode\n" +
  13506. //" ,gdd.groutinglineid\n" +
  13507. //" ,gdd.groutinglinecode\n" +
  13508. //" ,gdd.userid\n" +
  13509. //" ,gdd.usercode\n" +
  13510. " ,g.reserveddays\n" +
  13511. " ,substr(gt.goodstypecode, 1, 6) goodstypecode2\n" +
  13512. " ,gt.goodstypename\n" +
  13513. " ,COUNT(*) gddc\n" +
  13514. " FROM tp_pm_groutingdailydetail gdd\n" +
  13515. " INNER JOIN tp_mst_goods g\n" +
  13516. " ON g.goodsid = gdd.goodsid\n" +
  13517. " INNER JOIN tp_mst_goodstype gt\n" +
  13518. " ON g.goodstypeid = gt.goodstypeid\n" +
  13519. " WHERE gdd.accountid = :accountid\n" +
  13520. " AND gdd.valueflag = '1'\n" +
  13521. " AND gdd.groutingflag = '1'\n" +
  13522. " AND gdd.barcode IS NOT NULL\n" +
  13523. " AND gdd.scrapflag = '0'\n" +
  13524. " AND gdd.deliverflag = '0'\n" +
  13525. " AND (:LineCode IS NULL OR\n" +
  13526. " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13527. " AND (:UserCode IS NULL OR\n" +
  13528. " instr(gdd.UserCode, :UserCode) > 0)\n" +
  13529. " AND (:GoodsCode IS NULL OR\n" +
  13530. " instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13531. " AND (:GoodsTypeCode IS NULL OR\n" +
  13532. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13533. " AND (:DateBegin IS NULL OR\n" +
  13534. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
  13535. " GROUP BY gt.goodstypecode,gt.goodstypename\n" +
  13536. " ,gdd.goodsid\n" +
  13537. " ,gdd.goodscode\n" +
  13538. //" ,gdd.groutinglineid\n" +
  13539. //" ,gdd.groutinglinecode\n" +
  13540. //" ,gdd.userid\n" +
  13541. //" ,gdd.usercode\n" +
  13542. " ,g.reserveddays) gdrd\n" +
  13543. " LEFT JOIN (SELECT gld.goodsid\n" +
  13544. //" ,gld.groutinglineid\n" +
  13545. " ,COUNT(*) gldcount\n" +
  13546. " FROM tp_pc_groutinglinedetail gld\n" +
  13547. " INNER JOIN tp_pc_groutingline gl\n" +
  13548. " ON gl.groutinglineid = gld.groutinglineid\n" +
  13549. " WHERE gld.valueflag = '1'\n" +
  13550. " AND gld.gmouldstatus = 1\n" +
  13551. " AND gl.accountid = :accountid\n" +
  13552. " AND gl.valueflag = '1'\n" +
  13553. " AND gl.gmouldstatus = 1\n" +
  13554. " GROUP BY gld.goodsid\n" +
  13555. //" , gld.groutinglineid" +
  13556. " ) rdd\n" +
  13557. " ON rdd.goodsid = gdrd.goodsid\n" +
  13558. //" AND rdd.groutinglineid = gdrd.groutinglineid\n" +
  13559. " INNER JOIN tp_mst_goodstype gt2\n" +
  13560. " ON gt2.accountid = :accountid\n" +
  13561. " AND gt2.goodstypecode = gdrd.goodstypecode2\n" +
  13562. " ORDER BY gt2.goodstypecode\n" +
  13563. " ,gdrd.goodscode\n" +
  13564. //" ,gdrd.groutinglinecode\n" +
  13565. //" ,gdrd.usercode" +
  13566. " ) t\n" +
  13567. " GROUP BY GROUPING SETS((t.goodstypecode2, t.goodstypename2,t.goodstypename, t.goodsid, t.goodscode, t.gldcount, t.rddays, t.reserveddays),(t.goodstypecode2, t.goodstypename2),())";
  13568. OracleParameter[] oracleParameter = new OracleParameter[]
  13569. {
  13570. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13571. new OracleParameter(":DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13572. new OracleParameter(":DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13573. new OracleParameter(":GoodsTypeCode",OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13574. new OracleParameter(":GoodsCode",OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13575. new OracleParameter(":LineCode",OracleDbType.NVarchar2, cre.Properties["LineCode"], ParameterDirection.Input),
  13576. new OracleParameter(":UserCode",OracleDbType.NVarchar2, cre.Properties["UserCode"], ParameterDirection.Input),
  13577. };
  13578. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13579. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13580. {
  13581. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13582. }
  13583. sre.Data = result;
  13584. return sre;
  13585. }
  13586. catch (Exception ex)
  13587. {
  13588. if (oracleConn.ConnState == ConnectionState.Open)
  13589. {
  13590. oracleConn.Close();
  13591. }
  13592. throw ex;
  13593. }
  13594. }
  13595. /// <summary>
  13596. /// 获取成型存坯汇总表-成型工号存坯汇总表
  13597. /// </summary>
  13598. /// <param name="cre"></param>
  13599. /// <param name="sUserInfo"></param>
  13600. /// <returns></returns>
  13601. public static ServiceResultEntity GetRPT030116UserData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13602. {
  13603. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13604. try
  13605. {
  13606. ServiceResultEntity sre = new ServiceResultEntity();
  13607. /*
  13608. string sqlString =
  13609. "SELECT gdrd.goodsid\n" +
  13610. " ,gdrd.goodscode\n" +
  13611. " ,gdrd.groutinglineid\n" +
  13612. " ,gdrd.groutinglinecode\n" +
  13613. " ,gdrd.userid\n" +
  13614. " ,gdrd.usercode\n" +
  13615. " ,gdrd.gddc rdcount -- 存坯数\n" +
  13616. " ,rdd.gldcount -- 模具数\n" +
  13617. " , CASE\n" +
  13618. " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
  13619. " round(gdrd.gddc / rdd.gldcount, 2)\n" +
  13620. " ELSE\n" +
  13621. " NULL\n" +
  13622. " END rddays -- 存坯天数\n" +
  13623. " ,gdrd.reserveddays -- 应存天数\n" +
  13624. " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
  13625. " FROM (SELECT gdd.goodsid\n" +
  13626. " ,gdd.goodscode\n" +
  13627. " ,gdd.groutinglineid\n" +
  13628. " ,gdd.groutinglinecode\n" +
  13629. " ,gdd.userid\n" +
  13630. " ,gdd.usercode\n" +
  13631. " ,g.reserveddays\n" +
  13632. " ,COUNT(*) gddc\n" +
  13633. " FROM tp_pm_groutingdailydetail gdd\n" +
  13634. " INNER JOIN tp_mst_goods g\n" +
  13635. " ON g.goodsid = gdd.goodsid\n" +
  13636. " INNER JOIN tp_mst_goodstype gt\n" +
  13637. " ON g.goodstypeid = gt.goodstypeid\n" +
  13638. " WHERE gdd.accountid = :accountid\n" +
  13639. " AND gdd.valueflag = '1'\n" +
  13640. " AND gdd.groutingflag = '1'\n" +
  13641. " AND gdd.barcode IS NOT NULL\n" +
  13642. " AND gdd.scrapflag = '0'\n" +
  13643. " AND gdd.deliverflag = '0'\n" +
  13644. " AND (:LineCode IS NULL OR\n" +
  13645. " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13646. " AND (:UserCode IS NULL OR instr(gdd.UserCode, :UserCode) > 0)\n" +
  13647. " AND (:GoodsCode IS NULL OR instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13648. " AND (:GoodsTypeCode IS NULL OR\n" +
  13649. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13650. " AND (:DateBegin IS NULL OR\n" +
  13651. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
  13652. " GROUP BY gdd.goodsid\n" +
  13653. " ,gdd.goodscode\n" +
  13654. " ,gdd.groutinglineid\n" +
  13655. " ,gdd.groutinglinecode\n" +
  13656. " ,gdd.userid\n" +
  13657. " ,gdd.usercode\n" +
  13658. " ,g.reserveddays) gdrd\n" +
  13659. " LEFT JOIN (SELECT gld.goodsid\n" +
  13660. " ,gld.groutinglineid\n" +
  13661. " ,COUNT(*) gldcount\n" +
  13662. " FROM tp_pc_groutinglinedetail gld\n" +
  13663. " INNER JOIN tp_pc_groutingline gl\n" +
  13664. " ON gl.groutinglineid = gld.groutinglineid\n" +
  13665. " WHERE gld.valueflag = '1'\n" +
  13666. " AND gld.gmouldstatus = 1\n" +
  13667. " AND gl.accountid = :accountid\n" +
  13668. " AND gl.valueflag = '1'\n" +
  13669. " AND gl.gmouldstatus = 1\n" +
  13670. " GROUP BY gld.goodsid\n" +
  13671. " ,gld.groutinglineid\n" +
  13672. " ) rdd\n" +
  13673. " ON rdd.goodsid = gdrd.goodsid\n" +
  13674. " AND rdd.groutinglineid = gdrd.groutinglineid\n" +
  13675. " ORDER BY gdrd.goodscode\n" +
  13676. " ,gdrd.groutinglinecode, gdrd.usercode" +
  13677. "";
  13678. */
  13679. string sqlString =
  13680. "SELECT grouping_id(t.goodstypecode2, t.goodsid) gid\n" +
  13681. " ,t.goodstypecode2\n" +
  13682. " ,decode(grouping_id(t.goodstypecode2, t.goodsid),\n" +
  13683. " 3,\n" +
  13684. " '总计',\n" +
  13685. " 1,\n" +
  13686. " '合计[' || t.goodstypename2 || ']',\n" +
  13687. " t.goodstypename2) goodstypename2\n" +
  13688. " ,t.goodsid\n" +
  13689. " ,t.goodscode\n" +
  13690. " ,t.groutinglineid\n" +
  13691. " ,t.groutinglinecode\n" +
  13692. " ,t.userid\n" +
  13693. " ,t.usercode\n" +
  13694. " ,t.MONITORName\n" +
  13695. " ,SUM(t.rdcount) rdcount\n" +
  13696. " ,t.gldcount -- 模具数\n" +
  13697. " ,t.rddays -- 存坯天数\n" +
  13698. " ,t.reserveddays -- 应存天数\n" +
  13699. " ,SUM(t.ProfitNum) ProfitNum\n" +
  13700. " FROM (SELECT gt2.goodstypecode goodstypecode2\n" +
  13701. " ,gt2.goodstypename goodstypename2\n" +
  13702. " ,gdrd.goodsid\n" +
  13703. " ,gdrd.goodscode\n" +
  13704. " ,gdrd.groutinglineid\n" +
  13705. " ,gdrd.groutinglinecode\n" +
  13706. " ,gdrd.userid\n" +
  13707. " ,gdrd.usercode\n" +
  13708. " ,mu.username MONITORName\n" +
  13709. " ,gdrd.gddc rdcount -- 存坯数\n" +
  13710. " ,rdd.gldcount -- 模具数\n" +
  13711. " , CASE\n" +
  13712. " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
  13713. " round(gdrd.gddc / rdd.gldcount, 2)\n" +
  13714. " ELSE\n" +
  13715. " NULL\n" +
  13716. " END rddays -- 存坯天数\n" +
  13717. " ,gdrd.reserveddays -- 应存天数\n" +
  13718. " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
  13719. " FROM (SELECT gdd.goodsid\n" +
  13720. " ,gdd.goodscode\n" +
  13721. " ,gdd.groutinglineid\n" +
  13722. " ,gdd.groutinglinecode\n" +
  13723. " ,gdd.userid\n" +
  13724. " ,gdd.usercode\n" +
  13725. " ,g.reserveddays\n" +
  13726. " ,substr(gt.goodstypecode, 1, 6) goodstypecode2\n" +
  13727. " ,COUNT(*) gddc\n" +
  13728. " FROM tp_pm_groutingdailydetail gdd\n" +
  13729. " INNER JOIN tp_mst_goods g\n" +
  13730. " ON g.goodsid = gdd.goodsid\n" +
  13731. " INNER JOIN tp_mst_goodstype gt\n" +
  13732. " ON g.goodstypeid = gt.goodstypeid\n" +
  13733. " WHERE gdd.accountid = :accountid\n" +
  13734. " AND gdd.valueflag = '1'\n" +
  13735. " AND gdd.groutingflag = '1'\n" +
  13736. " AND gdd.barcode IS NOT NULL\n" +
  13737. " AND gdd.scrapflag = '0'\n" +
  13738. " AND gdd.deliverflag = '0'\n" +
  13739. " AND (:LineCode IS NULL OR\n" +
  13740. " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13741. " AND (:UserCode IS NULL OR\n" +
  13742. " instr(gdd.UserCode, :UserCode) > 0)\n" +
  13743. " AND (:GoodsCode IS NULL OR\n" +
  13744. " instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13745. " AND (:GoodsTypeCode IS NULL OR\n" +
  13746. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13747. " AND (:DateBegin IS NULL OR\n" +
  13748. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
  13749. " GROUP BY gt.goodstypecode\n" +
  13750. " ,gdd.goodsid\n" +
  13751. " ,gdd.goodscode\n" +
  13752. " ,gdd.groutinglineid\n" +
  13753. " ,gdd.groutinglinecode\n" +
  13754. " ,gdd.userid\n" +
  13755. " ,gdd.usercode\n" +
  13756. " ,g.reserveddays) gdrd\n" +
  13757. " LEFT JOIN (SELECT gld.goodsid\n" +
  13758. " ,gld.groutinglineid\n" +
  13759. " ,gl.MONITORID\n" +
  13760. " ,COUNT(*) gldcount\n" +
  13761. " FROM tp_pc_groutinglinedetail gld\n" +
  13762. " INNER JOIN tp_pc_groutingline gl\n" +
  13763. " ON gl.groutinglineid = gld.groutinglineid\n" +
  13764. " WHERE gld.valueflag = '1'\n" +
  13765. " AND gld.gmouldstatus = 1\n" +
  13766. " AND gl.accountid = :accountid\n" +
  13767. " AND gl.valueflag = '1'\n" +
  13768. " AND gl.gmouldstatus = 1\n" +
  13769. " GROUP BY gld.goodsid, gld.groutinglineid,gl.MONITORID) rdd\n" +
  13770. " ON rdd.goodsid = gdrd.goodsid\n" +
  13771. " AND rdd.groutinglineid = gdrd.groutinglineid\n" +
  13772. // 成型班长
  13773. " LEFT JOIN tp_mst_user mu\n" +
  13774. " ON mu.userid = rdd.MONITORID\n" +
  13775. " INNER JOIN tp_mst_goodstype gt2\n" +
  13776. " ON gt2.accountid = :accountid\n" +
  13777. " AND gt2.goodstypecode = gdrd.goodstypecode2\n" +
  13778. " ORDER BY gt2.goodstypecode\n" +
  13779. " ,gdrd.goodscode\n" +
  13780. " ,gdrd.groutinglinecode\n" +
  13781. " ,gdrd.usercode) t\n" +
  13782. " 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),())";
  13783. OracleParameter[] oracleParameter = new OracleParameter[]
  13784. {
  13785. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13786. new OracleParameter(":DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13787. new OracleParameter(":DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13788. new OracleParameter(":GoodsTypeCode",OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13789. new OracleParameter(":GoodsCode",OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13790. new OracleParameter(":LineCode",OracleDbType.NVarchar2, cre.Properties["LineCode"], ParameterDirection.Input),
  13791. new OracleParameter(":UserCode",OracleDbType.NVarchar2, cre.Properties["UserCode"], ParameterDirection.Input),
  13792. };
  13793. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13794. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13795. {
  13796. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13797. }
  13798. sre.Data = result;
  13799. return sre;
  13800. }
  13801. catch (Exception ex)
  13802. {
  13803. if (oracleConn.ConnState == ConnectionState.Open)
  13804. {
  13805. oracleConn.Close();
  13806. }
  13807. throw ex;
  13808. }
  13809. }
  13810. /// <summary>
  13811. /// 获取成型存坯汇总表-成型存坯明细表
  13812. /// </summary>
  13813. /// <param name="cre"></param>
  13814. /// <param name="sUserInfo"></param>
  13815. /// <returns></returns>
  13816. public static ServiceResultEntity GetRPT030116DData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13817. {
  13818. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13819. try
  13820. {
  13821. ServiceResultEntity sre = new ServiceResultEntity();
  13822. string sqlString = "SELECT gdd.barcode\n" +
  13823. //" ,gdd.groutinglineid\n" +
  13824. " ,gdd.groutinglinecode\n" +
  13825. " ,gdd.GroutingMouldCode\n" +
  13826. //" ,gdd.goodsid\n" +
  13827. " ,gdd.goodscode\n" +
  13828. //" ,gdd.userid\n" +
  13829. " ,gdd.usercode\n" +
  13830. " ,gdd.groutingdate\n" +
  13831. // 成型班长
  13832. " ,mu.username as MONITORName" +
  13833. " FROM tp_pm_groutingdailydetail gdd\n" +
  13834. " INNER JOIN tp_mst_goods g\n" +
  13835. " ON g.goodsid = gdd.goodsid\n" +
  13836. // 成型线
  13837. " LEFT JOIN tp_pc_groutingline gl" +
  13838. " ON gl.groutinglineid = GDD.GroutingLineID" +
  13839. // 成型班长
  13840. " LEFT JOIN tp_mst_user mu" +
  13841. " ON mu.userid = gl.MONITORID " +
  13842. " INNER JOIN tp_mst_goodstype gt\n" +
  13843. " ON g.goodstypeid = gt.goodstypeid\n" +
  13844. " WHERE gdd.accountid = :accountid\n" +
  13845. " AND gdd.valueflag = '1'\n" +
  13846. " AND gdd.groutingflag = '1'\n" +
  13847. " AND gdd.barcode IS NOT NULL\n" +
  13848. " AND gdd.scrapflag = '0'\n" +
  13849. " AND gdd.deliverflag = '0'\n" +
  13850. " AND (:LineID IS NULL OR gdd.groutinglineid = :LineID)\n" +
  13851. " AND (:UserID IS NULL OR gdd.UserID = :UserID)\n" +
  13852. " AND (:GoodsID IS NULL OR gdd.goodsid = :GoodsID)\n" +
  13853. " AND (:LineCode IS NULL OR instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13854. " AND (:UserCode IS NULL OR instr(gdd.UserCode, :UserCode) > 0)\n" +
  13855. " AND (:GoodsCode IS NULL OR instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13856. " AND (:GoodsTypeCode IS NULL OR\n" +
  13857. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13858. " AND (:DateBegin IS NULL OR\n" +
  13859. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)" +
  13860. " ORDER BY gdd.barcode\n" +
  13861. //" ,gdd.goodscode, gdrd.groutinglinecode, gdrd.usercode" +
  13862. "";
  13863. OracleParameter[] oracleParameter = new OracleParameter[]
  13864. {
  13865. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13866. new OracleParameter(":DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13867. new OracleParameter(":DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13868. new OracleParameter(":GoodsTypeCode",OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13869. new OracleParameter(":GoodsCode",OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13870. new OracleParameter(":LineCode",OracleDbType.NVarchar2, cre.Properties["LineCode"], ParameterDirection.Input),
  13871. new OracleParameter(":UserCode",OracleDbType.NVarchar2, cre.Properties["UserCode"], ParameterDirection.Input),
  13872. new OracleParameter(":GoodsID",OracleDbType.Int32, cre.Properties["GoodsID"], ParameterDirection.Input),
  13873. new OracleParameter(":LineID",OracleDbType.Int32, cre.Properties["LineID"], ParameterDirection.Input),
  13874. new OracleParameter(":UserID",OracleDbType.Int32, cre.Properties["UserID"], ParameterDirection.Input),
  13875. };
  13876. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13877. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13878. {
  13879. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13880. }
  13881. sre.Data = result;
  13882. return sre;
  13883. }
  13884. catch (Exception ex)
  13885. {
  13886. if (oracleConn.ConnState == ConnectionState.Open)
  13887. {
  13888. oracleConn.Close();
  13889. }
  13890. throw ex;
  13891. }
  13892. }
  13893. /// <summary>
  13894. /// 年度各工序月产量统计表
  13895. /// </summary>
  13896. /// <param name="cre"></param>
  13897. /// <param name="sUserInfo"></param>
  13898. /// <returns></returns>
  13899. public static ServiceResultEntity GetRPT030118Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13900. {
  13901. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13902. try
  13903. {
  13904. ServiceResultEntity sre = new ServiceResultEntity();
  13905. string sump = INIUtility.Read("ReportParameters", "RPT_030118", AppDomain.CurrentDomain.BaseDirectory + "Config.ini");
  13906. string sqlString = "select gt2.goodstypecode\n" +
  13907. " ,nvl2(gt2.goodstypename\n" +
  13908. " ,nvl2(t.procedureid\n" +
  13909. " ,gt2.goodstypename\n" +
  13910. " ,'小计[' || gt2.goodstypename || ']')\n" +
  13911. " ,'总计') goodstypename\n" +
  13912. " ,p.displayno\n" +
  13913. " ,decode(t.procedureid, null, '--', 0, '注浆', p.procedurename) procedurename\n" +
  13914. " ,sum(decode(t.mm, '12', t.pcount, 0)) m12\n" +
  13915. " ,sum(decode(t.mm, '01', t.pcount, 0)) m01\n" +
  13916. " ,sum(decode(t.mm, '02', t.pcount, 0)) m02\n" +
  13917. " ,sum(decode(t.mm, '03', t.pcount, 0)) m03\n" +
  13918. " ,sum(decode(t.mm, '04', t.pcount, 0)) m04\n" +
  13919. " ,sum(decode(t.mm, '05', t.pcount, 0)) m05\n" +
  13920. " ,sum(decode(t.mm, '06', t.pcount, 0)) m06\n" +
  13921. " ,sum(decode(t.mm, '07', t.pcount, 0)) m07\n" +
  13922. " ,sum(decode(t.mm, '08', t.pcount, 0)) m08\n" +
  13923. " ,sum(decode(t.mm, '09', t.pcount, 0)) m09\n" +
  13924. " ,sum(decode(t.mm, '10', t.pcount, 0)) m10\n" +
  13925. " ,sum(decode(t.mm, '11', t.pcount, 0)) m11\n" +
  13926. " ,sum(t.pcount) msum\n" +
  13927. " from (select --substr(gt.goodstypecode, 1, 6) gtcode2\n" +
  13928. " gt.goodstypecode\n" +
  13929. " ,0 procedureid\n" +
  13930. " ,to_char(pd.groutingdate, 'mm') mm\n" +
  13931. " ,count(*) pcount\n" +
  13932. " from tp_pm_groutingdailydetail pd\n" +
  13933. " inner join tp_mst_goods g\n" +
  13934. " on g.goodsid = pd.goodsid\n" +
  13935. " inner join tp_mst_goodstype gt\n" +
  13936. " on gt.goodstypeid = g.goodstypeid\n" +
  13937. " where pd.accountid = :accountid\n" +
  13938. " and pd.groutingflag = '1'\n" +
  13939. " and pd.groutingdate >= :begindate\n" +
  13940. " and pd.groutingdate < :enddate\n" +
  13941. " group by --substr(gt.goodstypecode, 1, 6)\n" +
  13942. " gt.goodstypecode\n" +
  13943. " ,to_char(pd.groutingdate, 'mm')\n" +
  13944. " union all\n" +
  13945. " select --substr(gt.goodstypecode, 1, 6) gtcode2\n" +
  13946. " gt.goodstypecode\n" +
  13947. " ,pd.procedureid\n" +
  13948. " ,to_char(pd.createtime, 'mm') mm\n" +
  13949. " ,count(*) pcount\n" +
  13950. " from tp_pm_productiondata pd\n" +
  13951. " inner join tp_mst_goods g\n" +
  13952. " on g.goodsid = pd.goodsid\n" +
  13953. " inner join tp_mst_goodstype gt\n" +
  13954. " on gt.goodstypeid = g.goodstypeid\n" +
  13955. " where pd.accountid = :accountid\n" +
  13956. " and pd.createtime >= :begindate\n" +
  13957. " and pd.createtime < :enddate\n" +
  13958. (string.IsNullOrWhiteSpace(sump) ? "" : " and pd.procedureid in (" + sump + ")\n") +
  13959. " group by --substr(gt.goodstypecode, 1, 6)\n" +
  13960. " gt.goodstypecode\n" +
  13961. " ,pd.procedureid\n" +
  13962. " ,to_char(pd.createtime, 'mm')" +
  13963. " union all\n" +
  13964. " select --substr(gt.goodstypecode, 1, 6) gtcode2\n" +
  13965. " gt.goodstypecode\n" +
  13966. " ,pd.procedureid\n" +
  13967. " ,to_char(pd.BACKOUTTIME, 'mm') mm\n" +
  13968. " ,count(*) pcount\n" +
  13969. " from tp_pm_productiondata pd\n" +
  13970. " inner join tp_mst_goods g\n" +
  13971. " on g.goodsid = pd.goodsid\n" +
  13972. " inner join tp_mst_goodstype gt\n" +
  13973. " on gt.goodstypeid = g.goodstypeid\n" +
  13974. " where pd.accountid = :accountid\n" +
  13975. " and pd.valueflag = '0'\n" +
  13976. " and pd.BACKOUTTIME >= :begindate\n" +
  13977. " and pd.BACKOUTTIME < :enddate\n" +
  13978. (string.IsNullOrWhiteSpace(sump) ? "" : " and pd.procedureid in (" + sump + ")\n") +
  13979. " group by --substr(gt.goodstypecode, 1, 6)\n" +
  13980. " gt.goodstypecode\n" +
  13981. " ,pd.procedureid\n" +
  13982. " ,to_char(pd.BACKOUTTIME, 'mm')) t\n" +
  13983. " inner join tp_mst_goodstype gt2\n" +
  13984. " on gt2.accountid = 1\n" +
  13985. " and gt2.goodstypecode = substr(t.goodstypecode, 1, 6) --t.gtcode2\n" +
  13986. " left join tp_pc_procedure p\n" +
  13987. " on p.procedureid = t.procedureid\n" +
  13988. " group by grouping sets((gt2.goodstypecode, gt2.goodstypename, p.displayno, p.procedurename, t.procedureid),(gt2.goodstypecode, gt2.goodstypename),())";
  13989. OracleParameter[] oracleParameter = new OracleParameter[]
  13990. {
  13991. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13992. new OracleParameter(":begindate",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13993. new OracleParameter(":enddate",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13994. };
  13995. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13996. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13997. {
  13998. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13999. }
  14000. sre.Data = result;
  14001. return sre;
  14002. }
  14003. catch (Exception ex)
  14004. {
  14005. throw ex;
  14006. }
  14007. finally
  14008. {
  14009. oracleConn?.Close();
  14010. }
  14011. }
  14012. /// <summary>
  14013. /// 半检返修缺陷汇总表
  14014. /// </summary>
  14015. /// <param name="cre"></param>
  14016. /// <param name="sUserInfo"></param>
  14017. /// <returns></returns>
  14018. public static ServiceResultEntity GetRPT030119Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14019. {
  14020. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14021. try
  14022. {
  14023. ServiceResultEntity sre = new ServiceResultEntity();
  14024. string sqlString = "select dp.defectpositionid\n" +
  14025. " ,dp.defectpositioncode\n" +
  14026. " ,dp.defectpositionname\n" +
  14027. " ,'D_' || dp.defectpositionid colname\n" +
  14028. " from tp_mst_scdefectposition dp\n" +
  14029. " where dp.valueflag = '1'\n" +
  14030. " and dp.accountid = " + sUserInfo.AccountID + "\n";
  14031. if (!string.IsNullOrWhiteSpace(cre.Properties["defectpositionIDS"] + ""))
  14032. {
  14033. sqlString += " and instr(','||'"+ cre.Properties["defectpositionIDS"] + "'||',', ','||dp.defectpositionid||',') > 0 \n";
  14034. }
  14035. sqlString += " order by dp.displayno";
  14036. DataTable scdTable = oracleConn.GetSqlResultToDt(sqlString);
  14037. if (scdTable == null || scdTable.Rows.Count == 0)
  14038. {
  14039. return sre;
  14040. }
  14041. List<string> pivotFor = new List<string>();
  14042. foreach (DataRow item in scdTable.Rows)
  14043. {
  14044. pivotFor.Add($"{item["defectpositionid"]} as {item["colname"]}");
  14045. }
  14046. List<OracleParameter> oracleParameters = new List<OracleParameter>();
  14047. oracleParameters.Add(new OracleParameter(":accountid", sUserInfo.AccountID));
  14048. sqlString = "select *\n" +
  14049. " from (select srd.defectid\n" +
  14050. " ,scd.defectcode\n" +
  14051. " ,scd.defectname\n" +
  14052. " ,nvl(srd.defectpositionid, 0) defectpositionid\n" +
  14053. " ,count(srd.semireworkdefectid) cc\n" +
  14054. " from TP_PM_SEMIREWORKDEFECT srd\n" +
  14055. " inner join TP_PM_SEMIREWORK sr\n" +
  14056. " on sr.SEMIREWORKID = srd.SEMIREWORKID\n" +
  14057. " left join tp_mst_semicheckdefect scd\n" +
  14058. " on scd.defectid = srd.defectid\n" +
  14059. " left join tp_mst_scdefectposition scdp\n" +
  14060. " on scdp.defectpositionid = srd.defectpositionid\n" +
  14061. " left join TP_MST_GOODS g on g.GOODSID = sr.GOODSID\n" + //xuwei add 2019-11-29
  14062. " left join TP_MST_GOODSTYPE gt on g.GOODSTYPEID = gt.GOODSTYPEID\n" + //xuwei add 2019-11-29
  14063. " where srd.valueflag = '1'\n" +
  14064. " and sr.BACKOUTFLAG = '0'\n" +
  14065. " and sr.valueflag = '1'\n" +
  14066. " and sr.accountid = :accountid\n";
  14067. // 半检日期
  14068. if (cre.Properties["SemireWorkTimeBegin"] != null)
  14069. {
  14070. sqlString += " and sr.SEMIREWORKTIME >= :SemireWorkTimeBegin\n";
  14071. oracleParameters.Add(new OracleParameter(":SemireWorkTimeBegin", cre.Properties["SemireWorkTimeBegin"]));
  14072. }
  14073. if (cre.Properties["SemireWorkTimeEnd"] != null)
  14074. {
  14075. sqlString += " and sr.SEMIREWORKTIME < :SemireWorkTimeEnd\n";
  14076. oracleParameters.Add(new OracleParameter(":SemireWorkTimeEnd", cre.Properties["SemireWorkTimeEnd"]));
  14077. }
  14078. // 产品编码 GOODSCODE
  14079. if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSCODE"]+""))
  14080. {
  14081. sqlString += " and instr(','||:GOODSCODE||',' , ','||sr.GOODSCODE||',') > 0 \n";
  14082. oracleParameters.Add(new OracleParameter(":GOODSCODE", cre.Properties["GOODSCODE"]));
  14083. }
  14084. // 成型工号 GROUTINGUSERCODE
  14085. if (!string.IsNullOrWhiteSpace(cre.Properties["GROUTINGUSERCODE"] + ""))
  14086. {
  14087. //xuwei modify 2019-11-13
  14088. //sqlString += " and instr(sr.GROUTINGUSERCODE,:GROUTINGUSERCODE) > 0 \n";
  14089. sqlString += " and instr(','||:GROUTINGUSERCODE||',' , ','||sr.GROUTINGUSERCODE||',') > 0 \n";
  14090. //xuwei end
  14091. oracleParameters.Add(new OracleParameter(":GROUTINGUSERCODE", cre.Properties["GROUTINGUSERCODE"]));
  14092. }
  14093. // 半检工号 SEMIREWORKUSERCODE
  14094. if (!string.IsNullOrWhiteSpace(cre.Properties["SEMIREWORKUSERCODE"] + ""))
  14095. {
  14096. //xuwei modify 2019-11-13
  14097. //sqlString += " and instr(sr.SEMIREWORKUSERCODE,:SEMIREWORKUSERCODE) > 0 \n";
  14098. sqlString += " and instr(','||:SEMIREWORKUSERCODE||',' , ','||sr.SEMIREWORKUSERCODE||',') > 0 \n";
  14099. //xuwei end
  14100. oracleParameters.Add(new OracleParameter(":SEMIREWORKUSERCODE", cre.Properties["SEMIREWORKUSERCODE"]));
  14101. }
  14102. // 缺陷位置 scdp.defectpositionname
  14103. if (!string.IsNullOrWhiteSpace(cre.Properties["defectpositionname"] + ""))
  14104. {
  14105. sqlString += " and instr(scdp.defectpositionname,:defectpositionname) > 0 \n";
  14106. oracleParameters.Add(new OracleParameter(":defectpositionname", cre.Properties["defectpositionname"]));
  14107. }
  14108. if (!string.IsNullOrWhiteSpace(cre.Properties["defectpositionIDS"] + ""))
  14109. {
  14110. sqlString += " and instr(','||:defectpositionIDS||',', ','||srd.defectpositionid||',') > 0 \n";
  14111. oracleParameters.Add(new OracleParameter(":defectpositionIDS", cre.Properties["defectpositionIDS"]));
  14112. }
  14113. // 缺陷名称 scd.defectname
  14114. if (!string.IsNullOrWhiteSpace(cre.Properties["defectname"] + ""))
  14115. {
  14116. sqlString += " and instr(scd.defectname,:defectname) > 0 \n";
  14117. oracleParameters.Add(new OracleParameter(":defectname", cre.Properties["defectname"]));
  14118. }
  14119. // 缺陷编码 scd.defectcode
  14120. if (!string.IsNullOrWhiteSpace(cre.Properties["defectcode"] + ""))
  14121. {
  14122. sqlString += " and scd.defectcode = :defectcode \n";
  14123. oracleParameters.Add(new OracleParameter(":defectcode", cre.Properties["defectcode"]));
  14124. }
  14125. //产品类别ID xuwei add 2019-11-29 g.GOODSTYPEID
  14126. if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSTYPEID"] + ""))
  14127. {
  14128. sqlString += " and instr(','||:GOODSTYPEID||',' , ','||g.GOODSTYPEID||',') > 0 \n";
  14129. oracleParameters.Add(new OracleParameter(":GOODSTYPEID", cre.Properties["GOODSTYPEID"]));
  14130. }
  14131. //产品类别Code xuwei add 2019-11-29 g.GOODSTYPECODE
  14132. if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSTYPECODE"] + ""))
  14133. {
  14134. sqlString += " and instr(gt.GOODSTYPECODE , :GOODSTYPECODE) = 1 \n";
  14135. oracleParameters.Add(new OracleParameter(":GOODSTYPECODE", cre.Properties["GOODSTYPECODE"]));
  14136. }
  14137. //返修工序 xuwei add 2019-11-29 sr.REWORKPROCEDUREID
  14138. if (!string.IsNullOrWhiteSpace(cre.Properties["REWORKPROCEDUREID"] + ""))
  14139. {
  14140. sqlString += " and instr(','||:REWORKPROCEDUREID||',' , ','||sr.REWORKPROCEDUREID||',') > 0 \n";
  14141. oracleParameters.Add(new OracleParameter(":REWORKPROCEDUREID", cre.Properties["REWORKPROCEDUREID"]));
  14142. }
  14143. sqlString +=
  14144. " group by grouping sets((srd.defectid, scd.defectcode, scd.defectname, srd.defectpositionid),(srd.defectid, scd.defectcode, scd.defectname),(srd.defectpositionid),())) t\n" +
  14145. "pivot(sum(cc)\n" +
  14146. " for defectpositionid in("+string.Join(",", pivotFor) + ", 0 AS D_0))\n" +
  14147. " order by defectid";
  14148. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameters.ToArray());
  14149. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14150. {
  14151. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14152. return sre;
  14153. }
  14154. DataTable table = result.Tables[0];
  14155. DataRow dataRow = table.Rows[table.Rows.Count - 1];
  14156. dataRow["defectname"] = "合计";
  14157. foreach (DataRow item in scdTable.Rows)
  14158. {
  14159. string colname = item["colname"] + "";
  14160. if (table.Columns.Contains(colname))
  14161. {
  14162. if (dataRow[colname] == null || dataRow[colname] == DBNull.Value)
  14163. {
  14164. table.Columns.Remove(colname);
  14165. }
  14166. else
  14167. {
  14168. table.Columns[colname].Caption = item["defectpositionname"] + "";
  14169. }
  14170. }
  14171. }
  14172. table.Columns["D_0"].Caption = "合计";
  14173. sre.Data = result;
  14174. return sre;
  14175. }
  14176. catch (Exception ex)
  14177. {
  14178. throw ex;
  14179. }
  14180. finally
  14181. {
  14182. oracleConn?.Close();
  14183. }
  14184. }
  14185. /// <summary>
  14186. /// 模具注浆分析表
  14187. /// </summary>
  14188. /// <param name="cre"></param>
  14189. /// <param name="sUserInfo"></param>
  14190. /// <returns></returns>
  14191. public static ServiceResultEntity GetRPT040111Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14192. {
  14193. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  14194. try
  14195. {
  14196. ServiceResultEntity sre = new ServiceResultEntity();
  14197. OracleParameter[] oracleParameter = new OracleParameter[]
  14198. {
  14199. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14200. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["GroutingDateBegin"], ParameterDirection.Input),
  14201. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["GroutingDateEnd"], ParameterDirection.Input),
  14202. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  14203. new OracleParameter("in_MouldBarcode",OracleDbType.Varchar2, cre.Properties["MouldBarcode"], ParameterDirection.Input),
  14204. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  14205. };
  14206. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_Mould_Groutingnum_AN", oracleParameter);
  14207. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14208. {
  14209. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14210. }
  14211. sre.Data = result;
  14212. oracleConn.Commit();
  14213. return sre;
  14214. }
  14215. catch (Exception ex)
  14216. {
  14217. if (oracleConn.ConnState == ConnectionState.Open)
  14218. {
  14219. oracleConn.Disconnect();
  14220. }
  14221. throw ex;
  14222. }
  14223. }
  14224. /// <summary>
  14225. /// 成检产品预算分析表
  14226. /// </summary>
  14227. /// <param name="cre"></param>
  14228. /// <param name="sUserInfo"></param>
  14229. /// <returns></returns>
  14230. public static ServiceResultEntity GetRPT040112Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14231. {
  14232. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  14233. try
  14234. {
  14235. ServiceResultEntity sre = new ServiceResultEntity();
  14236. OracleParameter[] oracleParameter = new OracleParameter[]
  14237. {
  14238. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14239. new OracleParameter("in_InTimeBegin",OracleDbType.Date, cre.Properties["InTimeBegin"], ParameterDirection.Input),
  14240. new OracleParameter("in_InTimeEnd",OracleDbType.Date, cre.Properties["InTimeEnd"], ParameterDirection.Input),
  14241. new OracleParameter("in_OutTimeBegin",OracleDbType.Date, cre.Properties["OutTimeBegin"], ParameterDirection.Input),
  14242. new OracleParameter("in_OutTimeEnd",OracleDbType.Date, cre.Properties["OutTimeEnd"], ParameterDirection.Input),
  14243. new OracleParameter("in_KilnID",OracleDbType.Int32, cre.Properties["KilnID"], ParameterDirection.Input),
  14244. new OracleParameter("in_KilnCarNumBegin",OracleDbType.Int32, cre.Properties["KilnCarNumBegin"], ParameterDirection.Input),
  14245. new OracleParameter("in_KilnCarNumEnd",OracleDbType.Int32, cre.Properties["KilnCarNumEnd"], ParameterDirection.Input),
  14246. new OracleParameter("out_KilnInfo",OracleDbType.RefCursor, null, ParameterDirection.Output),
  14247. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  14248. };
  14249. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_ExpectFinishedProduct", oracleParameter);
  14250. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14251. {
  14252. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14253. }
  14254. sre.Data = result;
  14255. oracleConn.Commit();
  14256. return sre;
  14257. }
  14258. catch (Exception ex)
  14259. {
  14260. if (oracleConn.ConnState == ConnectionState.Open)
  14261. {
  14262. oracleConn.Disconnect();
  14263. }
  14264. throw ex;
  14265. }
  14266. }
  14267. /// <summary>
  14268. /// 成检产品预算分析表-设置
  14269. /// </summary>
  14270. /// <param name="cre"></param>
  14271. /// <param name="sUserInfo"></param>
  14272. /// <returns></returns>
  14273. public static ServiceResultEntity GetRPT04011201Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14274. {
  14275. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14276. try
  14277. {
  14278. ServiceResultEntity sre = new ServiceResultEntity();
  14279. string sqlString = "SELECT s.settingkey, s.procedureid, p.procedurecode, p.procedurename\n" +
  14280. " FROM tp_qco_prosetting s\n" +
  14281. " LEFT JOIN tp_pc_procedure p\n" +
  14282. " ON s.procedureid = p.procedureid\n" +
  14283. " WHERE s.accountid = :accountid";
  14284. OracleParameter[] oracleParameter = new OracleParameter[]
  14285. {
  14286. new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14287. };
  14288. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  14289. sqlString = "SELECT k.kilnid, k.kilncode, k.kilnname, k.turnoverinterval\n" +
  14290. " FROM tp_mst_kiln k\n" +
  14291. " WHERE k.accountid = :accountid\n" +
  14292. " AND k.valueflag = '1'";
  14293. DataTable dt = oracleConn.GetSqlResultToDt(sqlString, oracleParameter);
  14294. result.Tables.Add(dt);
  14295. sre.Data = result;
  14296. return sre;
  14297. }
  14298. catch (Exception ex)
  14299. {
  14300. if (oracleConn.ConnState == ConnectionState.Open)
  14301. {
  14302. oracleConn.Close();
  14303. }
  14304. throw ex;
  14305. }
  14306. }
  14307. /// <summary>
  14308. /// 成检产品预算分析表-设置
  14309. /// </summary>
  14310. /// <param name="cre"></param>
  14311. /// <param name="sUserInfo"></param>
  14312. /// <returns></returns>
  14313. public static ServiceResultEntity SetRPT04011201Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14314. {
  14315. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  14316. try
  14317. {
  14318. ServiceResultEntity sre = new ServiceResultEntity();
  14319. OracleParameter[] oracleParameter = null;
  14320. string sql = "update tp_qco_prosetting s set s.procedureid=:procedureid, s.procedurecode=:procedurecode\n" +
  14321. "where s.accountid=:accountid and s.settingkey=:settingkey";
  14322. foreach (DataRow item in cre.Data.Tables[0].Rows)
  14323. {
  14324. oracleParameter = new OracleParameter[]
  14325. {
  14326. new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14327. new OracleParameter("procedureid",OracleDbType.Int32, item["procedureid"], ParameterDirection.Input),
  14328. new OracleParameter("procedurecode",OracleDbType.NVarchar2, item["procedurecode"], ParameterDirection.Input),
  14329. new OracleParameter("settingkey",OracleDbType.NVarchar2, item["settingkey"], ParameterDirection.Input),
  14330. };
  14331. oracleConn.ExecuteNonQuery(sql, oracleParameter);
  14332. }
  14333. sql = "update tp_mst_kiln k set k.turnoverinterval=:turnoverinterval\n" +
  14334. "where k.accountid=:accountid and k.kilnid=:kilnid";
  14335. foreach (DataRow item in cre.Data.Tables[1].Rows)
  14336. {
  14337. oracleParameter = new OracleParameter[]
  14338. {
  14339. new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14340. new OracleParameter("turnoverinterval",OracleDbType.Int32, item["turnoverinterval"], ParameterDirection.Input),
  14341. new OracleParameter("kilnid",OracleDbType.Int32, item["kilnid"], ParameterDirection.Input),
  14342. };
  14343. oracleConn.ExecuteNonQuery(sql, oracleParameter);
  14344. }
  14345. oracleConn.Commit();
  14346. return sre;
  14347. }
  14348. catch (Exception ex)
  14349. {
  14350. if (oracleConn.ConnState == ConnectionState.Open)
  14351. {
  14352. oracleConn.Disconnect();
  14353. }
  14354. throw ex;
  14355. }
  14356. }
  14357. /// <summary>
  14358. /// 各工序质量表-恒洁三水
  14359. /// </summary>
  14360. /// <param name="cre"></param>
  14361. /// <param name="sUserInfo"></param>
  14362. /// <returns></returns>
  14363. public static ServiceResultEntity GetRPT040113Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14364. {
  14365. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14366. try
  14367. {
  14368. int p1ID = 11; // 成检交接工序
  14369. int p2ID = 12; // 成检登记工序
  14370. string gtcode2 = cre.Properties["gtcode2"] + "";
  14371. if (gtcode2 != "001001" && gtcode2 != "001002")
  14372. {
  14373. gtcode2 = "[ALL]";
  14374. }
  14375. // DEFECTDEDUCTIONNUM 缺陷扣除数 1,2,5
  14376. // goodsleveltypeid 次品 7
  14377. string sqlString = "select t.*\n" +
  14378. " ,gt.goodstypename\n" +
  14379. " ,nvl(outk.outkcount, 0) outkcount\n" +
  14380. " ,nvl(outk.outkcount, 0) - t.defectcount cc\n" +
  14381. " ,decode(nvl(outk.outkcount, 0)\n" +
  14382. " ,0\n" +
  14383. " ,to_number(null)\n" +
  14384. " ,round((nvl(outk.outkcount, 0) - t.defectcount) /\n" +
  14385. " nvl(outk.outkcount, 0)\n" +
  14386. " ,4)) ccp\n" +
  14387. " from (select 10 pcode\n" +
  14388. " ,'成型' pname\n" +
  14389. " ,gt2.goodstypecode gtcode2\n" +
  14390. " ,count(*) defectcount\n" +
  14391. " from tp_pm_defect dd\n" +
  14392. " inner join tp_pm_productiondata pd\n" +
  14393. " on dd.productiondataid = pd.productiondataid\n" +
  14394. " inner join tp_mst_goods g\n" +
  14395. " on dd.goodsid = g.goodsid\n" +
  14396. " inner join tp_mst_goodstype gt\n" +
  14397. " on gt.goodstypeid = g.goodstypeid\n" +
  14398. " inner join tp_mst_goodstype gt2\n" +
  14399. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14400. " where dd.valueflag = '1'\n" +
  14401. " and dd.accountid = :accountid\n" +
  14402. " and pd.goodsleveltypeid = 7\n" + // 次品
  14403. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14404. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14405. " and dd.procedureid = :p2ID\n" +
  14406. " and dd.checktime >= :timebegin\n" +
  14407. " and dd.checktime < :timeend\n" +
  14408. ////" -- 交坯、干补\n" +
  14409. //" and dd.defectprocedureid in (1, 17, 18)\n" +
  14410. " 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" +
  14411. " 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" +
  14412. " )\n" +
  14413. " group by gt2.goodstypecode\n" +
  14414. " union all\n" +
  14415. " select 20 pcode\n" +
  14416. " ,'改洗' pname\n" +
  14417. " ,gt2.goodstypecode gtcode2\n" +
  14418. " ,count(*) defectcount\n" +
  14419. " from tp_pm_defect dd\n" +
  14420. " inner join tp_pm_productiondata pd\n" +
  14421. " on dd.productiondataid = pd.productiondataid\n" +
  14422. " inner join tp_mst_goods g\n" +
  14423. " on dd.goodsid = g.goodsid\n" +
  14424. " inner join tp_mst_goodstype gt\n" +
  14425. " on gt.goodstypeid = g.goodstypeid\n" +
  14426. " inner join tp_mst_goodstype gt2\n" +
  14427. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14428. " where dd.valueflag = '1'\n" +
  14429. " and dd.accountid = :accountid\n" +
  14430. " and pd.goodsleveltypeid = 7\n" + // 次品
  14431. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14432. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14433. " and dd.procedureid = :p2ID\n" +
  14434. " and dd.checktime >= :timebegin\n" +
  14435. " and dd.checktime < :timeend\n" +
  14436. ////" -- 改洗、吹风\n" +
  14437. //" and dd.defectprocedureid in (2, 62)\n" +
  14438. ////" -- 除不平\n" +
  14439. //" and dd.defectid not in (91, 240)\n" +
  14440. " and ((gt2.goodstypecode='001001' and dd.defectid in (91,94,144,113,145,114,183))\n" +
  14441. " or (gt2.goodstypecode='001002' and dd.defectid in (91,93,94,144,113,145,114))\n" +
  14442. " )\n" +
  14443. " group by gt2.goodstypecode\n" +
  14444. " union all\n" +
  14445. " select 30 pcode\n" +
  14446. " ,'二检' pname\n" +
  14447. " ,gt2.goodstypecode gtcode2\n" +
  14448. " ,count(*) defectcount\n" +
  14449. " from tp_pm_defect dd\n" +
  14450. " inner join tp_pm_productiondata pd\n" +
  14451. " on dd.productiondataid = pd.productiondataid\n" +
  14452. " inner join tp_mst_goods g\n" +
  14453. " on dd.goodsid = g.goodsid\n" +
  14454. " inner join tp_mst_goodstype gt\n" +
  14455. " on gt.goodstypeid = g.goodstypeid\n" +
  14456. " inner join tp_mst_goodstype gt2\n" +
  14457. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14458. " where dd.valueflag = '1'\n" +
  14459. " and dd.accountid = :accountid\n" +
  14460. " and pd.goodsleveltypeid = 7\n" + // 次品
  14461. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14462. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14463. " and dd.procedureid = :p2ID\n" +
  14464. " and dd.checktime >= :timebegin\n" +
  14465. " and dd.checktime < :timeend\n" +
  14466. ////" -- 二检\n" +
  14467. //" and dd.defectprocedureid in (61)\n" +
  14468. " and ((gt2.goodstypecode='001001' and dd.defectid in (89,91,92,93,94,106,115,163,159,133,166,164))\n" +
  14469. " or (gt2.goodstypecode='001002' and dd.defectid in (89,91,92,93,94,106,115,163,133,192,166,164))\n" +
  14470. " )\n" +
  14471. " group by gt2.goodstypecode\n" +
  14472. " union all\n" +
  14473. " select 40 pcode\n" +
  14474. " ,'施釉' pname\n" +
  14475. " ,gt2.goodstypecode gtcode2\n" +
  14476. " ,count(*) defectcount\n" +
  14477. " from tp_pm_defect dd\n" +
  14478. " inner join tp_pm_productiondata pd\n" +
  14479. " on dd.productiondataid = pd.productiondataid\n" +
  14480. " inner join tp_mst_goods g\n" +
  14481. " on dd.goodsid = g.goodsid\n" +
  14482. " inner join tp_mst_goodstype gt\n" +
  14483. " on gt.goodstypeid = g.goodstypeid\n" +
  14484. " inner join tp_mst_goodstype gt2\n" +
  14485. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14486. " where dd.valueflag = '1'\n" +
  14487. " and dd.accountid = :accountid\n" +
  14488. " and pd.goodsleveltypeid = 7\n" + // 次品
  14489. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14490. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14491. " and dd.procedureid = :p2ID\n" +
  14492. " and dd.checktime >= :timebegin\n" +
  14493. " and dd.checktime < :timeend\n" +
  14494. ////" -- 施釉\n" +
  14495. //" and dd.defectprocedureid in (3, 4)\n" +
  14496. ////" -- 除铁、铜脏\n" +
  14497. //" and dd.defectid not in (827, 829, 398, 399, 830, 400)\n" +
  14498. " 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" +
  14499. " 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" +
  14500. " )\n" +
  14501. " group by gt2.goodstypecode\n" +
  14502. " union all\n" +
  14503. " select 50 pcode\n" +
  14504. " ,'刮登' pname\n" +
  14505. " ,gt2.goodstypecode gtcode2\n" +
  14506. " ,count(*) defectcount\n" +
  14507. " from tp_pm_defect dd\n" +
  14508. " inner join tp_pm_productiondata pd\n" +
  14509. " on dd.productiondataid = pd.productiondataid\n" +
  14510. " inner join tp_mst_goods g\n" +
  14511. " on dd.goodsid = g.goodsid\n" +
  14512. " inner join tp_mst_goodstype gt\n" +
  14513. " on gt.goodstypeid = g.goodstypeid\n" +
  14514. " inner join tp_mst_goodstype gt2\n" +
  14515. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14516. " where dd.valueflag = '1'\n" +
  14517. " and dd.accountid = :accountid\n" +
  14518. " and pd.goodsleveltypeid = 7\n" + // 次品
  14519. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14520. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14521. " and dd.procedureid = :p2ID\n" +
  14522. " and dd.checktime >= :timebegin\n" +
  14523. " and dd.checktime < :timeend\n" +
  14524. ////" -- 登窑、入窑、卸窑\n" +
  14525. //" and dd.defectprocedureid in (5, 9, 10)\n" +
  14526. " 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" +
  14527. " 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" +
  14528. " )\n" +
  14529. " group by gt2.goodstypecode\n" +
  14530. " union all\n" +
  14531. " select 60 pcode\n" +
  14532. " ,'烧成' pname\n" +
  14533. " ,gt2.goodstypecode gtcode2\n" +
  14534. " ,count(*) defectcount\n" +
  14535. " from tp_pm_defect dd\n" +
  14536. " inner join tp_pm_productiondata pd\n" +
  14537. " on dd.productiondataid = pd.productiondataid\n" +
  14538. " inner join tp_mst_goods g\n" +
  14539. " on dd.goodsid = g.goodsid\n" +
  14540. " inner join tp_mst_goodstype gt\n" +
  14541. " on gt.goodstypeid = g.goodstypeid\n" +
  14542. " inner join tp_mst_goodstype gt2\n" +
  14543. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14544. " where dd.valueflag = '1'\n" +
  14545. " and dd.accountid = :accountid\n" +
  14546. " and pd.goodsleveltypeid = 7\n" + // 次品
  14547. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14548. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14549. " and dd.procedureid = :p2ID\n" +
  14550. " and dd.checktime >= :timebegin\n" +
  14551. " and dd.checktime < :timeend\n" +
  14552. ////" -- 惊风、毛针孔、烧裂、窑脏、釉泡\n" +
  14553. //" and dd.defectid in (385\n" +
  14554. //" ,203\n" +
  14555. //" ,836\n" +
  14556. //" ,234\n" +
  14557. //" ,384\n" +
  14558. //" ,202\n" +
  14559. //" ,835\n" +
  14560. //" ,390\n" +
  14561. //" ,818\n" +
  14562. //" ,389\n" +
  14563. //" ,204\n" +
  14564. //" ,814\n" +
  14565. //" ,837\n" +
  14566. //" ,387)\n" +
  14567. " and dd.defectid in (234,385,386,387,388,389,390)\n" +
  14568. //" 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" +
  14569. //" 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" +
  14570. //" )\n" +
  14571. " group by gt2.goodstypecode\n" +
  14572. " union all\n" +
  14573. " select 70 pcode\n" +
  14574. " ,'杂锈点' pname\n" +
  14575. " ,gt2.goodstypecode gtcode2\n" +
  14576. " ,count(*) defectcount\n" +
  14577. " from tp_pm_defect dd\n" +
  14578. " inner join tp_pm_productiondata pd\n" +
  14579. " on dd.productiondataid = pd.productiondataid\n" +
  14580. " inner join tp_mst_goods g\n" +
  14581. " on dd.goodsid = g.goodsid\n" +
  14582. " inner join tp_mst_goodstype gt\n" +
  14583. " on gt.goodstypeid = g.goodstypeid\n" +
  14584. " inner join tp_mst_goodstype gt2\n" +
  14585. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14586. " where dd.valueflag = '1'\n" +
  14587. " and dd.accountid = :accountid\n" +
  14588. " and pd.goodsleveltypeid = 7\n" + // 次品
  14589. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14590. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14591. " and dd.procedureid = :p2ID\n" +
  14592. " and dd.checktime >= :timebegin\n" +
  14593. " and dd.checktime < :timeend\n" +
  14594. ////" -- 铁脏、铜脏、窑脏、釉脏\n" +
  14595. //" and dd.defectid in\n" +
  14596. //" (730, 818, 827, 829, 830, 389, 398, 399, 400, 170)\n" +
  14597. " and dd.defectid in (170,389,398,399)\n" +
  14598. //" 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" +
  14599. //" 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" +
  14600. //" )\n" +
  14601. " group by gt2.goodstypecode\n" +
  14602. " union all\n" +
  14603. " select 80 pcode\n" +
  14604. " ,'其他' pname\n" +
  14605. " ,gt2.goodstypecode gtcode2\n" +
  14606. " ,count(*) defectcount\n" +
  14607. " from tp_pm_defect dd\n" +
  14608. " inner join tp_pm_productiondata pd\n" +
  14609. " on dd.productiondataid = pd.productiondataid\n" +
  14610. " inner join tp_mst_goods g\n" +
  14611. " on dd.goodsid = g.goodsid\n" +
  14612. " inner join tp_mst_goodstype gt\n" +
  14613. " on gt.goodstypeid = g.goodstypeid\n" +
  14614. " inner join tp_mst_goodstype gt2\n" +
  14615. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14616. " where dd.valueflag = '1'\n" +
  14617. " and dd.accountid = :accountid\n" +
  14618. " and pd.goodsleveltypeid = 7\n" + // 次品
  14619. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14620. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14621. " and dd.procedureid = :p2ID\n" +
  14622. " and dd.checktime >= :timebegin\n" +
  14623. " and dd.checktime < :timeend\n" +
  14624. ////" -- 成检撞伤、炸坯、炸裂\n" +
  14625. //" and dd.defectid in (393, 180, 394, 395)\n" +
  14626. " and ((gt2.goodstypecode='001001' and dd.defectid in (402,393,395,396,397))\n" +
  14627. " or (gt2.goodstypecode='001002' and dd.defectid in (402,394,393,395,396,397))\n" +
  14628. " )\n" +
  14629. " group by gt2.goodstypecode) t\n" +
  14630. " left join (select gt2.goodstypecode gtcode2\n" +
  14631. " ,count(*) outkcount\n" +
  14632. " from tp_pm_productiondata pd\n" +
  14633. " inner join tp_mst_goods g\n" +
  14634. " on pd.goodsid = g.goodsid\n" +
  14635. " inner join tp_mst_goodstype gt\n" +
  14636. " on gt.goodstypeid = g.goodstypeid\n" +
  14637. " inner join tp_mst_goodstype gt2\n" +
  14638. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14639. " where pd.valueflag = '1'\n" +
  14640. " and pd.accountid = :accountid\n" +
  14641. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14642. " and pd.procedureid = :p1ID\n" +
  14643. " and pd.createtime >= :timebegin\n" +
  14644. " and pd.createtime < :timeend\n" +
  14645. " group by gt2.goodstypecode) outk\n" +
  14646. " on t.gtcode2 = outk.gtcode2\n" +
  14647. " inner join tp_mst_goodstype gt\n" +
  14648. " on gt.goodstypecode = t.gtcode2\n" +
  14649. " and gt.accountid = :accountid\n" +
  14650. " order by t.pcode, t.gtcode2";
  14651. OracleParameter[] oracleParameter = new OracleParameter[]
  14652. {
  14653. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14654. new OracleParameter(":p1ID",OracleDbType.Int32, p1ID, ParameterDirection.Input),
  14655. new OracleParameter(":p2ID",OracleDbType.Int32, p2ID, ParameterDirection.Input),
  14656. new OracleParameter(":timebegin",OracleDbType.Date, cre.Properties["timebegin"], ParameterDirection.Input),
  14657. new OracleParameter(":timeend",OracleDbType.Date, cre.Properties["timeend"], ParameterDirection.Input),
  14658. new OracleParameter(":gtcode2",OracleDbType.Varchar2, gtcode2, ParameterDirection.Input),
  14659. };
  14660. ServiceResultEntity sre = new ServiceResultEntity();
  14661. sre.Data = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  14662. if (sre.Data != null && sre.Data.Tables.Count > 0 && sre.Data.Tables[0].Rows.Count > 0)
  14663. {
  14664. sre.Data.Tables[0].TableName = "S";
  14665. cre.Properties["pcode"] = sre.Data.Tables[0].Rows[0]["pcode"];
  14666. cre.Properties["pname"] = sre.Data.Tables[0].Rows[0]["pname"];
  14667. cre.Properties["gtcode2"] = sre.Data.Tables[0].Rows[0]["gtcode2"];
  14668. ServiceResultEntity sre1 = GetRPT040113DData(cre, sUserInfo);
  14669. if (sre1 != null&& sre1.Data != null&& sre1.Data.Tables.Count > 0)
  14670. {
  14671. sre1.Data.Tables[0].TableName = "D";
  14672. sre.Data.Merge(sre1.Data.Tables[0]);
  14673. }
  14674. }
  14675. sqlString =
  14676. "select t.gtcode2\n" +
  14677. " ,nvl(t.gtname2, '合计') gtname2\n" +
  14678. " ,sum(t.outk) outk\n" +
  14679. " ,sum(t.cipin) cipin\n" +
  14680. " ,sum(t.outk) - sum(t.cipin) hege\n" +
  14681. " ,decode(sum(t.outk), 0, to_number(null), round(1 - (sum(t.cipin) / sum(t.outk)),4)) hegep\n" +
  14682. " from (select gt2.goodstypecode gtcode2\n" +
  14683. " ,gt2.goodstypename gtname2\n" +
  14684. " ,nvl(sum(decode(pd.procedureid, :p1ID, 1, 0)), 0) outk\n" +
  14685. " ,nvl(sum(case\n" +
  14686. " when pd.procedureid = :p2ID and\n" +
  14687. " pd.goodsleveltypeid in (6, 7) then\n" +
  14688. " 1\n" +
  14689. " else\n" +
  14690. " 0\n" +
  14691. " end)\n" +
  14692. " ,0) cipin\n" +
  14693. " from tp_pm_productiondata pd\n" +
  14694. " inner join tp_mst_goods g\n" +
  14695. " on pd.goodsid = g.goodsid\n" +
  14696. " inner join tp_mst_goodstype gt\n" +
  14697. " on g.goodstypeid = gt.goodstypeid\n" +
  14698. " inner join tp_mst_goodstype gt2\n" +
  14699. " on length(gt2.goodstypecode) = 6\n" +
  14700. " and gt2.accountid = gt.accountid\n" +
  14701. " and instr(gt.goodstypecode, gt2.goodstypecode) = 1\n" +
  14702. " where pd.valueflag = '1'\n" +
  14703. " and pd.accountid = :accountid\n" +
  14704. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14705. " and (pd.procedureid = :p1ID or pd.procedureid = :p2ID)\n" +
  14706. //" and pd.checktime > date '2018-01-01'\n" +
  14707. " and pd.checktime >= :timebegin\n" +
  14708. " and pd.checktime < :timeend\n" +
  14709. " group by gt2.goodstypecode, gt2.goodstypename) t\n" +
  14710. " group by grouping sets((t.gtcode2, t.gtname2),())";
  14711. oracleParameter = new OracleParameter[]
  14712. {
  14713. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14714. new OracleParameter(":p1ID",OracleDbType.Int32, p1ID, ParameterDirection.Input),
  14715. new OracleParameter(":p2ID",OracleDbType.Int32, p2ID, ParameterDirection.Input),
  14716. new OracleParameter(":timebegin",OracleDbType.Date, cre.Properties["timebegin"], ParameterDirection.Input),
  14717. new OracleParameter(":timeend",OracleDbType.Date, cre.Properties["timeend"], ParameterDirection.Input),
  14718. new OracleParameter(":gtcode2",OracleDbType.Varchar2, gtcode2, ParameterDirection.Input),
  14719. };
  14720. DataTable alldata = oracleConn.GetSqlResultToDt(sqlString, oracleParameter);
  14721. alldata.TableName = "A";
  14722. DataTable data = sre.Data.Tables[0];
  14723. foreach (DataRow item in alldata.Rows)
  14724. {
  14725. data.Rows.Add(99, "总计", item["gtcode2"], item["cipin"], item["gtname2"], item["outk"], item["hege"], item["hegep"]);
  14726. }
  14727. return sre;
  14728. }
  14729. catch (Exception ex)
  14730. {
  14731. if (oracleConn.ConnState == ConnectionState.Open)
  14732. {
  14733. oracleConn.Close();
  14734. }
  14735. throw ex;
  14736. }
  14737. }
  14738. /// <summary>
  14739. /// 各工序质量表-缺陷明细-恒洁三水
  14740. /// </summary>
  14741. /// <param name="cre"></param>
  14742. /// <param name="sUserInfo"></param>
  14743. /// <returns></returns>
  14744. public static ServiceResultEntity GetRPT040113DData(ClientRequestEntity cre, SUserInfo sUserInfo)
  14745. {
  14746. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14747. try
  14748. {
  14749. //int p1ID = 11; // 成检交接工序
  14750. int p2ID = 12; // 成检登记工序
  14751. int pcode = Convert.ToInt32(cre.Properties["pcode"]);
  14752. string sqlString =
  14753. "select :pcode pcode\n" +
  14754. " ,:pname pname\n" +
  14755. " ,gt2.goodstypecode gtcode2\n" +
  14756. " ,gt2.goodstypename gtname2\n" +
  14757. " ,dd.defectcode\n" +
  14758. " ,dd.defectname\n" +
  14759. " ,count(*) defectcount\n" +
  14760. " from tp_pm_defect dd\n" +
  14761. //"--inner join tp_mst_defect md on md.defectid=dd.defectid\n" +
  14762. " inner join tp_mst_goods g\n" +
  14763. " on dd.goodsid = g.goodsid\n" +
  14764. " inner join tp_pm_productiondata pd\n" +
  14765. " on dd.productiondataid = pd.productiondataid\n" +
  14766. " inner join tp_mst_goodstype gt\n" +
  14767. " on gt.goodstypeid = g.goodstypeid\n" +
  14768. " inner join tp_mst_goodstype gt2\n" +
  14769. " on gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  14770. " and gt2.accountid = :accountid\n" +
  14771. " where dd.valueflag = '1'\n" +
  14772. " and dd.accountid = :accountid\n" +
  14773. " and pd.goodsleveltypeid = 7\n" + // 次品
  14774. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14775. " and dd.procedureid = :p2ID\n" +
  14776. " and gt2.goodstypecode = :gtcode2\n" +
  14777. " and dd.checktime >= :timebegin\n" +
  14778. " and dd.checktime < :timeend\n";
  14779. switch (pcode)
  14780. {
  14781. case 10:
  14782. ////" -- 交坯、干补\n" +
  14783. //sqlString += " and dd.defectprocedureid in (1, 17, 18)\n";
  14784. sqlString +=
  14785. " 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" +
  14786. " 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" +
  14787. " )\n";
  14788. break;
  14789. case 20:
  14790. sqlString +=
  14791. ////" -- 改洗、吹风\n" +
  14792. //" and dd.defectprocedureid in (2, 62)\n" +
  14793. ////" -- 除不平\n" +
  14794. //" and dd.defectid not in (91, 240)\n";
  14795. " and ((gt2.goodstypecode='001001' and dd.defectid in (91,94,144,113,145,114,183))\n" +
  14796. " or (gt2.goodstypecode='001002' and dd.defectid in (91,93,94,144,113,145,114))\n" +
  14797. " )\n";
  14798. break;
  14799. case 30:
  14800. sqlString +=
  14801. ////" -- 二检\n" +
  14802. //" and dd.defectprocedureid in (61)\n";
  14803. " and ((gt2.goodstypecode='001001' and dd.defectid in (89,91,92,93,94,106,115,163,159,133,166,164))\n" +
  14804. " or (gt2.goodstypecode='001002' and dd.defectid in (89,91,92,93,94,106,115,163,133,192,166,164))\n" +
  14805. " )\n";
  14806. break;
  14807. case 40:
  14808. sqlString +=
  14809. ////" -- 施釉\n" +
  14810. //" and dd.defectprocedureid in (3, 4)\n" +
  14811. ////" -- 除铁、铜脏\n" +
  14812. //" and dd.defectid not in (827, 829, 398, 399, 830, 400)\n";
  14813. " 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" +
  14814. " 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" +
  14815. " )\n";
  14816. break;
  14817. case 50:
  14818. sqlString +=
  14819. ////" -- 登窑、入窑、卸窑\n" +
  14820. //" and dd.defectprocedureid in (5, 9, 10)\n";
  14821. " 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" +
  14822. " 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" +
  14823. " )\n";
  14824. break;
  14825. case 60:
  14826. sqlString +=
  14827. ////" -- 惊风、毛针孔、烧裂、窑脏、釉泡\n" +
  14828. //" and dd.defectid in (385\n" +
  14829. //" ,203\n" +
  14830. //" ,836\n" +
  14831. //" ,234\n" +
  14832. //" ,384\n" +
  14833. //" ,202\n" +
  14834. //" ,835\n" +
  14835. //" ,390\n" +
  14836. //" ,818\n" +
  14837. //" ,389\n" +
  14838. //" ,204\n" +
  14839. //" ,814\n" +
  14840. //" ,837\n" +
  14841. //" ,387)\n";
  14842. " and dd.defectid in (234,385,386,387,388,389,390)\n";
  14843. break;
  14844. case 70:
  14845. sqlString +=
  14846. ////" -- 铁脏、铜脏、窑脏、釉脏\n" +
  14847. //" and dd.defectid in\n" +
  14848. //" (730, 818, 827, 829, 830, 389, 398, 399, 400, 170)\n";
  14849. " and dd.defectid in (170,389,398,399)\n";
  14850. break;
  14851. case 80:
  14852. sqlString +=
  14853. ////" -- 成检撞伤、炸坯、炸裂\n" +
  14854. //" and dd.defectid in (393, 180, 394, 395)\n";
  14855. " and ((gt2.goodstypecode='001001' and dd.defectid in (402,393,395,396,397))\n" +
  14856. " or (gt2.goodstypecode='001002' and dd.defectid in (402,394,393,395,396,397))\n" +
  14857. " )\n";
  14858. break;
  14859. default:
  14860. break;
  14861. }
  14862. sqlString +=
  14863. " group by gt2.goodstypecode\n" +
  14864. " ,gt2.goodstypename\n" +
  14865. " ,dd.defectcode\n" +
  14866. " ,dd.defectname\n" +
  14867. " order by dd.defectcode";
  14868. OracleParameter[] oracleParameter = new OracleParameter[]
  14869. {
  14870. new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14871. //new OracleParameter("p1ID",OracleDbType.Int32, p1ID, ParameterDirection.Input),
  14872. new OracleParameter("p2ID",OracleDbType.Int32, p2ID, ParameterDirection.Input),
  14873. new OracleParameter("pcode",OracleDbType.Int32, pcode, ParameterDirection.Input),
  14874. new OracleParameter("pname",OracleDbType.NVarchar2, cre.Properties["pname"], ParameterDirection.Input),
  14875. new OracleParameter("gtcode2",OracleDbType.Varchar2, cre.Properties["gtcode2"], ParameterDirection.Input),
  14876. new OracleParameter("timebegin",OracleDbType.Date, cre.Properties["timebegin"], ParameterDirection.Input),
  14877. new OracleParameter("timeend",OracleDbType.Date, cre.Properties["timeend"], ParameterDirection.Input),
  14878. };
  14879. ServiceResultEntity sre = new ServiceResultEntity();
  14880. sre.Data = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  14881. return sre;
  14882. }
  14883. catch (Exception ex)
  14884. {
  14885. if (oracleConn.ConnState == ConnectionState.Open)
  14886. {
  14887. oracleConn.Close();
  14888. }
  14889. throw ex;
  14890. }
  14891. }
  14892. /// <summary>
  14893. /// 综合合格率分析表-半成品报废率分析表
  14894. /// </summary>
  14895. /// <param name="cre"></param>
  14896. /// <param name="sUserInfo"></param>
  14897. /// <returns></returns>
  14898. public static ServiceResultEntity GetRPT040114_1Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14899. {
  14900. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14901. try
  14902. {
  14903. ServiceResultEntity sre = new ServiceResultEntity();
  14904. List<OracleParameter> oracleParameters = new List<OracleParameter>();
  14905. oracleParameters.Add(new OracleParameter(":accountid", sUserInfo.AccountID));
  14906. string sqlString = "select g.goodscode\n" +
  14907. " ,tt.d_num\n" +
  14908. " ,tt.b_num\n" +
  14909. " ,tt.f_num\n" +
  14910. " ,tt.s_num\n" +
  14911. " ,decode(tt.d_num\n" +
  14912. " ,0\n" +
  14913. " ,to_number(null)\n" +
  14914. " ,round((tt.b_num + tt.f_num + tt.s_num) / tt.d_num,4)) sp_r\n" +
  14915. " from (select t.goodsid\n" +
  14916. " ,nvl(sum(decode(t.numtype, 'A', t.id_num, 0)), 0) d_num -- 交坯\n" +
  14917. " ,nvl(sum(decode(t.numtype, '2', t.id_num, 0)), 0) b_num -- 半检不合格数\n" +
  14918. " ,nvl(sum(decode(t.numtype, '3', t.id_num, 0)), 0) f_num -- 复检不合格数\n" +
  14919. " ,nvl(sum(decode(t.numtype, '0', t.id_num, 0)), 0) s_num -- 损坯数\n" +
  14920. " from (select gdd.goodsid\n" +
  14921. " ,'A' numtype\n" +
  14922. " ,count(gdd.groutingdailydetailid) id_num\n" +
  14923. " from tp_pm_groutingdailydetail gdd\n" +
  14924. " where gdd.groutingflag = '1'\n" +
  14925. " and gdd.valueflag = '1'\n" +
  14926. " and gdd.accountid = :accountid\n" +
  14927. " and gdd.deliverflag = '1'\n" +
  14928. " and gdd.delivertime >= :datebegin\n" +
  14929. " and gdd.delivertime < :dateend\n" +
  14930. " group by gdd.goodsid\n" +
  14931. " union all\n" +
  14932. " -- 半检不合格数 复检不合格数 损坯数\n" +
  14933. " select sp.goodsid\n" +
  14934. " ,sp.SCRAPTYPE numtype\n" +
  14935. " ,count(sp.scrapproductid) id_num\n" +
  14936. " from tp_pm_scrapproduct sp\n" +
  14937. " where sp.valueflag = '1'\n" +
  14938. " and sp.accountid = :accountid\n" +
  14939. " and sp.auditstatus = 1\n" +
  14940. " and sp.KILNID is null\n" +
  14941. " and sp.SCRAPTYPE <> '1'\n" +
  14942. " and sp.AUDITDATE >= :datebegin\n" +
  14943. " and sp.AUDITDATE < :dateend\n" +
  14944. " group by sp.goodsid, sp.SCRAPTYPE) t\n" +
  14945. " group by t.goodsid) tt\n" +
  14946. " inner join tp_mst_goods g\n" +
  14947. " on tt.goodsid = g.goodsid\n" +
  14948. " order by g.goodscode";
  14949. oracleParameters.Add(new OracleParameter(":datebegin", cre.Properties["datebegin"]));
  14950. oracleParameters.Add(new OracleParameter(":dateend", cre.Properties["dateend"]));
  14951. //// 产品编码 GOODSCODE
  14952. //if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSCODE"] + ""))
  14953. //{
  14954. // sqlString += " and instr(sr.GOODSCODE,:GOODSCODE) > 0 \n";
  14955. // oracleParameters.Add(new OracleParameter(":GOODSCODE", cre.Properties["GOODSCODE"]));
  14956. //}
  14957. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameters.ToArray());
  14958. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14959. {
  14960. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14961. return sre;
  14962. }
  14963. sre.Data = result;
  14964. return sre;
  14965. }
  14966. catch (Exception ex)
  14967. {
  14968. throw ex;
  14969. }
  14970. finally
  14971. {
  14972. oracleConn?.Close();
  14973. }
  14974. }
  14975. /// <summary>
  14976. /// 综合合格率分析表-综合优等率分析表
  14977. /// </summary>
  14978. /// <param name="cre"></param>
  14979. /// <param name="sUserInfo"></param>
  14980. /// <returns></returns>
  14981. public static ServiceResultEntity GetRPT040114_2Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14982. {
  14983. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14984. try
  14985. {
  14986. ServiceResultEntity sre = new ServiceResultEntity();
  14987. List<OracleParameter> oracleParameters = new List<OracleParameter>();
  14988. oracleParameters.Add(new OracleParameter(":accountid", sUserInfo.AccountID));
  14989. string sqlString = "\n" +
  14990. "select g.goodscode\n" +
  14991. " ,pp.b_out_num\n" +
  14992. " ,(pp.b_out_num - pp.b_bad_num) b_h_num\n" +
  14993. " ,(pp.c_out_num - pp.c_bad_num) c_h_num\n" +
  14994. " ,decode(pp.b_out_num\n" +
  14995. " ,0\n" +
  14996. " ,to_number(null)\n" +
  14997. " ,round((pp.b_out_num - pp.b_bad_num + pp.c_out_num - pp.c_bad_num) /\n" +
  14998. " pp.b_out_num,4)) zh_r\n" +
  14999. " from (select p.goodsid\n" +
  15000. " ,nvl(sum(decode(p.procedureid, 11, 1, 0)), 0) b_out_num -- 本烧出窑数\n" +
  15001. " ,nvl(sum(decode(p.procedureid, 12, 1, 0)), 0) b_bad_num -- 本烧不合格数\n" +
  15002. " ,nvl(sum(decode(p.procedureid, 58, 1, 0)), 0) c_out_num -- 重烧出窑数\n" +
  15003. " ,nvl(sum(decode(p.procedureid, 59, 1, 0)), 0) c_bad_num -- 重烧不合格数\n" +
  15004. " from tp_pm_productiondata p\n" +
  15005. " where p.valueflag = '1'\n" +
  15006. " and p.accountid = :accountid\n" +
  15007. " and (p.procedureid in (11, 58) or\n" +
  15008. " (p.procedureid in (12, 59) and p.goodsleveltypeid in (6, 7)))\n" +
  15009. " and p.createtime >= :datebegin\n" +
  15010. " and p.createtime < :dateend\n" +
  15011. " group by p.goodsid) pp\n" +
  15012. " inner join tp_mst_goods g\n" +
  15013. " on g.goodsid = pp.goodsid\n" +
  15014. " order by g.goodscode";
  15015. oracleParameters.Add(new OracleParameter(":datebegin", cre.Properties["datebegin"]));
  15016. oracleParameters.Add(new OracleParameter(":dateend", cre.Properties["dateend"]));
  15017. //// 产品编码 GOODSCODE
  15018. //if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSCODE"] + ""))
  15019. //{
  15020. // sqlString += " and instr(sr.GOODSCODE,:GOODSCODE) > 0 \n";
  15021. // oracleParameters.Add(new OracleParameter(":GOODSCODE", cre.Properties["GOODSCODE"]));
  15022. //}
  15023. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameters.ToArray());
  15024. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  15025. {
  15026. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  15027. return sre;
  15028. }
  15029. sre.Data = result;
  15030. return sre;
  15031. }
  15032. catch (Exception ex)
  15033. {
  15034. throw ex;
  15035. }
  15036. finally
  15037. {
  15038. oracleConn?.Close();
  15039. }
  15040. }
  15041. #region 产成品交接撤销汇总表
  15042. /// <summary>
  15043. /// 取得F_RPT_030117画面(产成品交接撤销汇总表)
  15044. /// </summary>
  15045. /// <param name="user">登录用户信息</param>
  15046. /// <param name="se">查询条件</param>
  15047. /// <returns>查询结果</returns>
  15048. public static ServiceResultEntity GetF_RPT_030117SearchTotalData(SearchFinishedProductEntity orderEntity, SUserInfo user)
  15049. {
  15050. IDBConnection conn = null;
  15051. try
  15052. {
  15053. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  15054. string sqlString = "SELECT TS.GID,\n" +
  15055. " DECODE(TS.GID, '3', '合计', DECODE(TS.GID, '1', '小计[' || CREATETIME || ']', CREATETIME)) AS CREATETIME,\n" +
  15056. " DECODE(TS.GID, '1', '--', GOODSMODEL) AS GOODSMODEL,\n" +
  15057. " GOODSCOUNT\n" +
  15058. " FROM (SELECT GROUPING_ID(TO_CHAR(F.CREATETIME, 'yyyy-mm-dd'), G.GOODSCODE) AS GID,\n" +
  15059. " DECODE(GROUPING(TO_CHAR(F.CREATETIME, 'yyyy-mm-dd')), 1, '--', TO_CHAR(F.CREATETIME, 'yyyy-mm-dd')) AS CREATETIME,\n" +
  15060. " DECODE(GROUPING(G.GOODSCODE), 1, '--', G.GOODSCODE) AS GOODSMODEL,\n" +
  15061. " COUNT(G.GOODSCODE) AS GOODSCOUNT\n" +
  15062. " FROM TP_PM_FHUNDO F\n" +
  15063. " LEFT JOIN TP_PM_GROUTINGDAILYDETAIL GDD\n" +
  15064. " ON F.GROUTINGDAILYDETAILID = GDD.GROUTINGDAILYDETAILID\n" +
  15065. " LEFT JOIN TP_MST_GOODS G\n" +
  15066. " ON G.GOODSID = GDD.GOODSID\n" +
  15067. " WHERE F.ACCOUNTID = :AccountID\n";
  15068. List<OracleParameter> parameters = new List<OracleParameter>();
  15069. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  15070. // 撤销时间
  15071. if (orderEntity.UndoTimeStart != null)
  15072. {
  15073. sqlString = sqlString + " AND F.CREATETIME BETWEEN :UndoTimeStart AND :UndoTimeEnd \n";
  15074. parameters.Add(new OracleParameter(":UndoTimeStart", OracleDbType.Date, orderEntity.UndoTimeStart, ParameterDirection.Input));
  15075. parameters.Add(new OracleParameter(":UndoTimeEnd", OracleDbType.Date, orderEntity.UndoTimeEnd, ParameterDirection.Input));
  15076. }
  15077. // 产品型号
  15078. if (!string.IsNullOrEmpty(orderEntity.GoodsModel))
  15079. {
  15080. sqlString = sqlString + " AND INSTR(g.GoodsCode,:GoodsCode)>0 \n";
  15081. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, orderEntity.GoodsModel, ParameterDirection.Input));
  15082. }
  15083. sqlString += " GROUP BY GROUPING SETS((TO_CHAR(F.CREATETIME, 'yyyy-mm-dd'), G.GOODSCODE),\n" +
  15084. " (TO_CHAR(F.CREATETIME, 'yyyy-mm-dd')),())\n" +
  15085. " ORDER BY TO_CHAR(F.CREATETIME, 'yyyy-mm-dd'), G.GOODSCODE) TS";
  15086. ServiceResultEntity sre = new ServiceResultEntity();
  15087. DataSet result = conn.GetSqlResultToDs(sqlString, parameters.ToArray());
  15088. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  15089. {
  15090. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  15091. }
  15092. sre.Data = result;
  15093. return sre;
  15094. }
  15095. catch (Exception ex)
  15096. {
  15097. throw ex;
  15098. }
  15099. finally
  15100. {
  15101. if (conn != null &&
  15102. conn.ConnState == ConnectionState.Open)
  15103. {
  15104. conn.Close();
  15105. }
  15106. }
  15107. }
  15108. /// <summary>
  15109. /// 取得F_RPT_030112画面(产成品交接汇总表)的明细信息查询数据
  15110. /// </summary>
  15111. /// <param name="user">登录用户信息</param>
  15112. /// <param name="se">查询条件</param>
  15113. /// <returns>查询结果</returns>
  15114. public static ServiceResultEntity GetF_RPT_030117SearchDetailSData(SearchFinishedProductEntity orderEntity, SUserInfo user)
  15115. {
  15116. IDBConnection conn = null;
  15117. try
  15118. {
  15119. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  15120. string sqlString = "SELECT O.ORDERNO,\n" +
  15121. " F.FHTIME,\n" +
  15122. " F.FHUSERCODE,\n" +
  15123. " GDD.BARCODE,\n" +
  15124. " GOODS.GOODSCODE,\n" +
  15125. " L.LOGONAME,\n" +
  15126. " GDD.USERCODE AS GROUTINGUSERCODE,\n" +
  15127. " GDD.GROUTINGLINECODE,\n" +
  15128. " GDD.GROUTINGMOULDCODE,\n" +
  15129. " GDD.GROUTINGDATE,\n" +
  15130. " TO_CHAR(GDD.DELIVERTIME, 'yyyy-mm-dd') AS DELIVERTIME,\n" +
  15131. //" (GOODS.MATERIALCODE || L.TAGCODE || GDD.ONLYCODE) AS FINISHEDBARCODE,\n" +
  15132. " 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" +
  15133. " TO_CHAR(F.CREATETIME, 'yyyy-mm-dd HH24:mi:ss') AS UNDOTIME,\n" +
  15134. " UNDOUSER.USERCODE AS UNDOUSERCODE\n" +
  15135. " FROM TP_PM_FHUNDO F\n" +
  15136. " LEFT JOIN TP_PM_GROUTINGDAILYDETAIL GDD\n" +
  15137. " ON F.GROUTINGDAILYDETAILID = GDD.GROUTINGDAILYDETAILID\n" +
  15138. " LEFT JOIN TP_PM_ORDER O\n" +
  15139. " ON F.FHORDERID = O.ORDERID\n" +
  15140. " LEFT JOIN TP_MST_LOGO L\n" +
  15141. " ON GDD.LOGOID = L.LOGOID\n" +
  15142. " LEFT JOIN TP_MST_GOODS GOODS\n" +
  15143. " ON GDD.GOODSID = GOODS.GOODSID\n" +
  15144. " LEFT JOIN TP_MST_USER UNDOUSER\n" +
  15145. " ON UNDOUSER.USERID = F.CREATEUSERID\n" +
  15146. " WHERE F.ACCOUNTID = :AccountID";
  15147. List<OracleParameter> parameters = new List<OracleParameter>();
  15148. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  15149. // 撤销时间
  15150. if (orderEntity.UndoTimeStart != null)
  15151. {
  15152. sqlString = sqlString + " AND F.CREATETIME BETWEEN :UndoTimeStart AND :UndoTimeEnd \n";
  15153. parameters.Add(new OracleParameter(":UndoTimeStart", OracleDbType.Date, orderEntity.UndoTimeStart, ParameterDirection.Input));
  15154. parameters.Add(new OracleParameter(":UndoTimeEnd", OracleDbType.Date, orderEntity.UndoTimeEnd, ParameterDirection.Input));
  15155. }
  15156. // 产品型号
  15157. if (!string.IsNullOrEmpty(orderEntity.GoodsModel))
  15158. {
  15159. sqlString = sqlString + " AND INSTR(GOODS.GoodsCode,:GoodsCode) > 0 \n";
  15160. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, orderEntity.GoodsModel, ParameterDirection.Input));
  15161. }
  15162. ServiceResultEntity sre = new ServiceResultEntity();
  15163. DataSet result = conn.GetSqlResultToDs(sqlString, parameters.ToArray());
  15164. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  15165. {
  15166. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  15167. }
  15168. sre.Data = result;
  15169. return sre;
  15170. }
  15171. catch (Exception ex)
  15172. {
  15173. throw ex;
  15174. }
  15175. finally
  15176. {
  15177. if (conn != null &&
  15178. conn.ConnState == ConnectionState.Open)
  15179. {
  15180. conn.Close();
  15181. }
  15182. }
  15183. }
  15184. #endregion
  15185. }
  15186. }