ReportModuleLogic.cs 780 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000
  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. };
  4848. //out_data1 -- 质量整体情况
  4849. //out_data2 -- 各缺陷类型成品率
  4850. //out_data3 -- 各缺陷类型缺陷率
  4851. //out_data4 -- 产品质量排行榜
  4852. //out_data21 -- 各缺陷类型成品率-总成品率
  4853. //out_data31 -- 各缺陷类型缺陷率-总缺陷率
  4854. //out_data32 -- 各缺陷类型缺陷率-分缺陷率
  4855. //out_table1 -- 缺陷类别
  4856. //out_table2 -- 工号分组
  4857. //out_table3 -- 缺陷扣罚
  4858. //out_table4 -- 缺陷
  4859. DataSet data = conn.ExecStoredProcedure("PRO_RPT_OverallQualityAnalysis", parameters);
  4860. ServiceResultEntity sre = new ServiceResultEntity();
  4861. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  4862. {
  4863. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  4864. return sre;
  4865. }
  4866. data.Tables[0].TableName = "TQ";
  4867. data.Tables[1].TableName = "FR";
  4868. data.Tables[2].TableName = "DR";
  4869. data.Tables[3].TableName = "DL";
  4870. data.Tables[4].TableName = "FR1";
  4871. data.Tables[5].TableName = "DR1";
  4872. data.Tables[6].TableName = "DR2";
  4873. data.Tables[7].TableName = "DT";
  4874. data.Tables[8].TableName = "WG";
  4875. data.Tables[9].TableName = "DF";
  4876. data.Tables[10].TableName = "D";
  4877. DataTable dtFR = data.Tables["FR"];
  4878. DataTable dtFRClone = dtFR.Clone();
  4879. for (int i = 0; i < dtFR.Columns.Count; i++)
  4880. {
  4881. dtFRClone.Columns[i].DataType = typeof(string);
  4882. }
  4883. foreach (DataRow item in dtFR.Rows)
  4884. {
  4885. item["goodstypename2"] = item["goodstypename2"] + "缺陷数";
  4886. dtFRClone.Rows.Add(item.ItemArray);
  4887. }
  4888. // 增加大小件成品率(%) modify by chenxy 2018-05-03 begin
  4889. //DataRow drFR = dtFRClone.NewRow();
  4890. //drFR["goodstypename2"] = "成品率(%)";
  4891. //foreach (DataRow row in data.Tables["FR1"].Rows)
  4892. //{
  4893. // string tid = row["tid"].ToString();
  4894. // string overRate = (row["OverRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["OverRate"]).ToString("#,##0.00%"));
  4895. // foreach (DataColumn col in dtFRClone.Columns)
  4896. // {
  4897. // if (col.ColumnName.StartsWith(tid))
  4898. // {
  4899. // drFR[col.ColumnName] = overRate;
  4900. // }
  4901. // }
  4902. //}
  4903. //dtFRClone.Rows.Add(drFR);
  4904. Dictionary<string, DataRow> drFRs = new Dictionary<string, DataRow>();
  4905. foreach (DataRow row in data.Tables["FR1"].Rows)
  4906. {
  4907. string tcode = row["goodstypecode2"].ToString();
  4908. DataRow drFR = null;
  4909. if (drFRs.ContainsKey(tcode))
  4910. {
  4911. drFR = drFRs[tcode];
  4912. }
  4913. else
  4914. {
  4915. drFR = dtFRClone.NewRow();
  4916. drFRs.Add(tcode, drFR);
  4917. drFR["goodstypename2"] = row["goodstypeName2"] + "成品率(%)";
  4918. }
  4919. string tid = row["tid"].ToString();
  4920. string overRate = (row["OverRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["OverRate"]).ToString("#,##0.00%"));
  4921. foreach (DataColumn col in dtFRClone.Columns)
  4922. {
  4923. if (col.ColumnName.StartsWith(tid))
  4924. {
  4925. drFR[col.ColumnName] = overRate;
  4926. }
  4927. }
  4928. }
  4929. foreach (DataRow item in drFRs.Values)
  4930. {
  4931. dtFRClone.Rows.Add(item);
  4932. }
  4933. // 增加大小件成品率(%) modify by chenxy 2018-05-03 end
  4934. data.Tables.Remove(dtFR);
  4935. data.Tables.Remove(data.Tables["FR1"]);
  4936. data.Tables.Add(dtFRClone);
  4937. DataTable dtDR = data.Tables["DR"];
  4938. DataTable dtDRClone = dtDR.Clone();
  4939. for (int i = 0; i < dtDR.Columns.Count; i++)
  4940. {
  4941. dtDRClone.Columns[i].DataType = typeof(string);
  4942. }
  4943. foreach (DataRow item in dtDR.Rows)
  4944. {
  4945. item["goodstypename2"] = item["goodstypename2"] + "缺陷数";
  4946. dtDRClone.Rows.Add(item.ItemArray);
  4947. }
  4948. // 增加大小件缺陷率(%) modify by chenxy 2018-05-03 begin
  4949. //DataRow drDR = dtDRClone.NewRow();
  4950. //drDR["goodstypename2"] = "缺陷率(%)";
  4951. //foreach (DataRow row in data.Tables["DR2"].Rows)
  4952. //{
  4953. // string tid = row["tdfid"].ToString();
  4954. // string defectRate = (row["DefectRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["DefectRate"]).ToString("#,##0.00%"));
  4955. // drDR[tid] = defectRate;
  4956. //}
  4957. //dtDRClone.Rows.Add(drDR);
  4958. Dictionary<string, DataRow> drDRs = new Dictionary<string, DataRow>();
  4959. foreach (DataRow row in data.Tables["DR2"].Rows)
  4960. {
  4961. string tcode = row["goodstypecode2"].ToString();
  4962. DataRow drDR = null;
  4963. if (drDRs.ContainsKey(tcode))
  4964. {
  4965. drDR = drDRs[tcode];
  4966. }
  4967. else
  4968. {
  4969. drDR = dtDRClone.NewRow();
  4970. drDRs.Add(tcode, drDR);
  4971. drDR["goodstypename2"] = row["goodstypeName2"] + "缺陷率(%)";
  4972. }
  4973. string tid = row["tdfid"].ToString();
  4974. string defectRate = (row["DefectRate"] == DBNull.Value ? Constant.DIV0 : Convert.ToDecimal(row["DefectRate"]).ToString("#,##0.00%"));
  4975. drDR[tid] = defectRate;
  4976. }
  4977. foreach (DataRow item in drDRs.Values)
  4978. {
  4979. dtDRClone.Rows.Add(item);
  4980. }
  4981. // 增加大小件成品率(%) modify by chenxy 2018-05-03 end
  4982. data.Tables.Remove(dtDR);
  4983. data.Tables.Remove(data.Tables["DR2"]);
  4984. data.Tables.Add(dtDRClone);
  4985. conn.Commit();
  4986. sre.Data = data;
  4987. return sre;
  4988. }
  4989. catch (Exception ex)
  4990. {
  4991. throw ex;
  4992. }
  4993. finally
  4994. {
  4995. if (conn != null &&
  4996. conn.ConnState == ConnectionState.Open)
  4997. {
  4998. conn.Disconnect();
  4999. }
  5000. }
  5001. }
  5002. /// <summary>
  5003. /// 取得RPT040110画面(产成品逐日出窑数值分析表)的查询数据
  5004. /// </summary>
  5005. /// <param name="user">登录用户信息</param>
  5006. /// <param name="se">查询条件</param>
  5007. /// <returns>查询结果</returns>
  5008. public static ServiceResultEntity GetRPT040110SData(SUserInfo user, RPT040110_SE se)
  5009. {
  5010. IDBTransaction conn = null;
  5011. try
  5012. {
  5013. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  5014. conn.Connect();
  5015. OracleParameter[] parameters = new OracleParameter[]
  5016. {
  5017. new OracleParameter("in_AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  5018. new OracleParameter("in_DateBegin", OracleDbType.Date, se.CreateTimeStart, ParameterDirection.Input),
  5019. new OracleParameter("in_DateEnd", OracleDbType.Date, se.CreateTimeEnd, ParameterDirection.Input),
  5020. new OracleParameter("in_OutKilnProcedureID", OracleDbType.Int32, se.RptSProcedureID , ParameterDirection.Input),
  5021. new OracleParameter("in_KilnID", OracleDbType.Int32, se.KilnID , ParameterDirection.Input),
  5022. new OracleParameter("out_data1", OracleDbType.RefCursor, null , ParameterDirection.Output),
  5023. };
  5024. DataSet data = null;
  5025. if (se.IsShowG)
  5026. {
  5027. data = conn.ExecStoredProcedure("PRO_RPT_OverallQualityDetail_G", parameters);
  5028. }
  5029. else
  5030. {
  5031. data = conn.ExecStoredProcedure("PRO_RPT_OverallQualityDetail", parameters);
  5032. }
  5033. ServiceResultEntity sre = new ServiceResultEntity();
  5034. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  5035. {
  5036. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5037. return sre;
  5038. }
  5039. conn.Commit();
  5040. sre.Data = data;
  5041. return sre;
  5042. }
  5043. catch (Exception ex)
  5044. {
  5045. throw ex;
  5046. }
  5047. finally
  5048. {
  5049. if (conn != null &&
  5050. conn.ConnState == ConnectionState.Open)
  5051. {
  5052. conn.Disconnect();
  5053. }
  5054. }
  5055. }
  5056. #endregion 分析报表
  5057. #region 汇总报表
  5058. /// <summary>
  5059. /// 取得RPT030101_1画面(产品产量汇总表)的汇总信息查询数据
  5060. /// </summary>
  5061. /// <param name="user">登录用户信息</param>
  5062. /// <param name="se">查询条件</param>
  5063. /// <returns>查询结果</returns>
  5064. public static ServiceResultEntity GetRPT030101SData(SUserInfo user, RPT030101_SE se)
  5065. {
  5066. IDBConnection conn = null;
  5067. try
  5068. {
  5069. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  5070. List<OracleParameter> parameters = new List<OracleParameter>();
  5071. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030101SSQL(user, se, ref parameters));
  5072. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  5073. ServiceResultEntity sre = new ServiceResultEntity();
  5074. if (data == null || data.Rows.Count == 0)
  5075. {
  5076. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5077. return sre;
  5078. }
  5079. sre.Data = new DataSet();
  5080. sre.Data.Tables.Add(data);
  5081. return sre;
  5082. }
  5083. catch (Exception ex)
  5084. {
  5085. throw ex;
  5086. }
  5087. finally
  5088. {
  5089. if (conn != null &&
  5090. conn.ConnState == ConnectionState.Open)
  5091. {
  5092. conn.Close();
  5093. }
  5094. }
  5095. }
  5096. /// <summary>
  5097. /// 获取RPT030101_1画面(产品产量汇总表)的汇总信息查询sql
  5098. /// </summary>
  5099. /// <returns>sql</returns>
  5100. private static string GetRPT030101SSQL(SUserInfo user, RPT030101_SE se, ref List<OracleParameter> parameters)
  5101. {
  5102. //string selSql = "";
  5103. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  5104. /*
  5105. selSql = selSql +
  5106. "select " +
  5107. " decode(t.ProductionLineName,'合计','合计',decode(t.GoodsCode,'小计','--',t.OrganizationName)) OrganizationName, " +
  5108. " decode(t.Procedureid,'--','--',decode(t.GoodsCode,'小计','--',t.ProductionLineName)) ProductionLineName, " +
  5109. " decode(t.GoodsCode,'小计','--',t.Procedureid) Procedureid, " +
  5110. " decode(t.GoodsCode,'小计','--',t.ProcedureName) ProcedureName, " +
  5111. " decode(t.GoodsCode,'小计','小计',t.GoodsTypeName) GoodsTypeName, " +
  5112. " decode(t.GoodsTypeName,'小计','--',t.GoodsId) GoodsId, " +
  5113. " decode(t.ProductionLineName,'合计','--',decode(t.GoodsId,null,'--',t.GoodsCode)) GoodsCode, " +
  5114. " decode(t.GoodsCode,'小计','--',t.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  5115. " decode(t.GoodsCode,'小计','--',t.Dictionaryvalue) Dictionaryvalue, " +
  5116. " decode(t.GoodsCode,'小计','--',g.goodsname) goodsname, " +
  5117. " decode(t.GoodsCode,'小计','--',g.GOODSMODEL) GOODSMODEL, " +
  5118. " t.产量 " +
  5119. "from " +
  5120. "( " +
  5121. " select " +
  5122. " decode(grouping(TP_MST_Organization.OrganizationName),1,'总计',TP_MST_Organization.OrganizationName) OrganizationName, " +
  5123. " decode(grouping(TP_MST_Organization.OrganizationName),1,'--', " +
  5124. " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'合计',TP_PM_ProductionData.ProductionLineName)) ProductionLineName, " +
  5125. " decode(grouping(TP_PM_ProductionData.Procedureid),1,'--',TP_PM_ProductionData.Procedureid) Procedureid, " +
  5126. " decode(grouping(TP_PM_ProductionData.ProcedureName),1,'--',TP_PM_ProductionData.ProcedureName) ProcedureName, " +
  5127. " decode(grouping(TP_MST_GOODSTYPE.GoodsTypeName),1,'--',TP_MST_GOODSTYPE.GoodsTypeName) GoodsTypeName, " +
  5128. " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'--', " +
  5129. " decode(grouping(TP_PM_ProductionData.GoodsCode),1,'小计',TP_PM_ProductionData.GoodsCode)) GoodsCode, " +
  5130. " decode(grouping(TP_PM_ProductionData.GoodsId),1,null,TP_PM_ProductionData.GoodsId) GoodsId, " +
  5131. " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  5132. " decode(grouping(TP_MST_DATADICTIONARY.DICTIONARYVALUE),1,'--',TP_MST_DATADICTIONARY.Dictionaryvalue) Dictionaryvalue, " +
  5133. " count(BarCode) as 产量 " +
  5134. " from TP_PM_ProductionData " +
  5135. " left join TP_MST_Goods on TP_MST_Goods.GoodsID=TP_PM_ProductionData.GoodsID " +
  5136. " left join TP_MST_GoodsType on TP_MST_GoodsType.GoodsTypeID=TP_MST_Goods.GoodsTypeID " +
  5137. " left join TP_MST_Organization on TP_MST_Organization.OrganizationID=TP_PM_ProductionData.OrganizationID " +
  5138. " left join TP_MST_DATADICTIONARY on TP_MST_DATADICTIONARY.DICTIONARYID=TP_MST_Goods.GLAZETYPEID " +
  5139. " Where 1=1 and TP_PM_ProductionData.ValueFlag = 1 " +
  5140. // 公坯、干补不算交坯工序的质量。
  5141. (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" : "") +
  5142. " and TP_PM_ProductionData.AccountID=:AccountID ";
  5143. if (!string.IsNullOrEmpty(se.GoodsIDS))
  5144. {
  5145. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  5146. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  5147. }
  5148. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  5149. {
  5150. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
  5151. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPEcode,:GoodsTypeIDS)=1 ";
  5152. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  5153. }
  5154. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  5155. {
  5156. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  5157. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  5158. }
  5159. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  5160. {
  5161. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_ProductionData.ProcedureId||',')>0 ";
  5162. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  5163. }
  5164. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  5165. {
  5166. selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||TP_MST_Organization.OrganizationId||',')>0 ";
  5167. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  5168. }
  5169. if (se.AccountDateStart.HasValue)
  5170. {
  5171. selSql = selSql + " AND TP_PM_ProductionData.CREATETIME >= :AccountDateStart ";
  5172. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  5173. }
  5174. if (se.AccountDateEnd.HasValue)
  5175. {
  5176. selSql = selSql + " AND TP_PM_ProductionData.CREATETIME <= :AccountDateEnd ";
  5177. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  5178. }
  5179. selSql = selSql +
  5180. "group by " +
  5181. " rollup(TP_MST_Organization.OrganizationName, " +
  5182. " TP_PM_ProductionData.ProductionLineName, " +
  5183. " TP_PM_ProductionData.Procedureid, " +
  5184. " TP_PM_ProductionData.ProcedureName, " +
  5185. " TP_MST_GOODSTYPE.GoodsTypeName, " +
  5186. " TP_PM_ProductionData.GoodsCode, " +
  5187. " TP_PM_ProductionData.GoodsId, " +
  5188. " TP_MST_Goods.GOODSSPECIFICATION, " +
  5189. " TP_MST_DATADICTIONARY.Dictionaryvalue) " +
  5190. " order by " +
  5191. " TP_MST_Organization.OrganizationName, " +
  5192. " TP_PM_ProductionData.ProductionLineName, " +
  5193. " TP_PM_ProductionData.Procedureid, " +
  5194. " TP_PM_ProductionData.ProcedureName, " +
  5195. " TP_MST_GOODSTYPE.GoodsTypeName " +
  5196. ") t \n" +
  5197. // 增加 产品型号
  5198. "left join tp_mst_goods g on g.goodsid = t.goodsid \n" +
  5199. "where 1=1 " +
  5200. "and (t.DICTIONARYVALUE!='--' ) " +
  5201. "or (t.GoodsTypeName='--' and t.ProductionLineName='合计') " +
  5202. "or (t.GoodsTypeName='--' and t.OrganizationName='总计') " +
  5203. "or (t.GoodsCode='小计' and t.GoodsTypeName!='--')";
  5204. */
  5205. string selSql =
  5206. "select t.gid\n" +
  5207. " ,decode(t.gid, 15, '总计', t.ProductionLineName) ProductionLineName\n" +
  5208. " ,t.OrganizationID\n" +
  5209. " --,t.OrganizationCode\n" +
  5210. " ,decode(t.gid\n" +
  5211. " ,7\n" +
  5212. " ,'合计[' || t.OrganizationName || ']'\n" +
  5213. " ,15\n" +
  5214. " ,'--'\n" +
  5215. " ,t.OrganizationName) OrganizationName\n" +
  5216. " ,t.Procedureid\n" +
  5217. " ,decode(t.gid\n" +
  5218. " ,3\n" +
  5219. " ,'小计[' || t.ProcedureName || ']'\n" +
  5220. " ,0\n" +
  5221. " ,t.ProcedureName\n" +
  5222. " ,1\n" +
  5223. " ,t.ProcedureName\n" +
  5224. " ,'--') ProcedureName\n" +
  5225. " ,t.GoodsTypeID\n" +
  5226. " ,decode(t.gid\n" +
  5227. " ,1\n" +
  5228. " ,'小计[' || t.GoodsTypeName || ']'\n" +
  5229. " ,0\n" +
  5230. " ,t.GoodsTypeName\n" +
  5231. " ,'--') GoodsTypeName\n" +
  5232. " --,t.GoodsId\n" +
  5233. " ,decode(t.gid, 0, to_char(t.GoodsId), '--') GoodsId\n" +
  5234. " ,decode(t.gid, 0, t.GoodsCode, '--') GoodsCode\n" +
  5235. " ,decode(t.gid, 0, t.GOODSSPECIFICATION, '--') GOODSSPECIFICATION\n" +
  5236. " ,decode(t.gid, 0, t.Dictionaryvalue, '--') Dictionaryvalue\n" +
  5237. " ,t.pfcount as 产量\n" +
  5238. " from (select grouping_id(org.OrganizationID\n" +
  5239. " ,p.Procedureid\n" +
  5240. " ,gt.goodstypeid\n" +
  5241. " ,g.GoodsId) as gid\n" +
  5242. " ,pd.ProductionLineName\n" +
  5243. " ,org.OrganizationID\n" +
  5244. " --,org.OrganizationCode\n" +
  5245. " ,org.OrganizationName\n" +
  5246. " ,p.Procedureid\n" +
  5247. " ,p.ProcedureName\n" +
  5248. " ,gt.GoodsTypeID\n" +
  5249. " ,gt.GoodsTypeName\n" +
  5250. " ,g.GoodsId\n" +
  5251. " ,g.GoodsCode\n" +
  5252. " ,g.GOODSSPECIFICATION\n" +
  5253. " ,d.Dictionaryvalue\n" +
  5254. " ,count(BarCode) as pfcount" +
  5255. " from TP_PM_ProductionData pd\n" +
  5256. " inner join tp_pc_Procedure p\n" +
  5257. " on p.Procedureid = pd.Procedureid\n" +
  5258. " inner join TP_MST_Goods g\n" +
  5259. " on g.GoodsID = pd.GoodsID\n" +
  5260. " inner join TP_MST_GoodsType gt\n" +
  5261. " on gt.GoodsTypeID = g.GoodsTypeID\n" +
  5262. " inner join TP_MST_Organization org\n" +
  5263. " on org.OrganizationID = pd.OrganizationID\n" +
  5264. " inner join TP_MST_DATADICTIONARY d\n" +
  5265. " on d.DICTIONARYID = g.GLAZETYPEID\n" +
  5266. " where pd.ValueFlag = '1'\n" +
  5267. " and pd.AccountID = :AccountID\n";
  5268. // 公坯、干补不算交坯工序的质量。
  5269. if (se.ProductionFlag == "1")
  5270. {
  5271. selSql += " and ((pd.modeltype <> 5) or (pd.modeltype = 5 and (pd.IsPublicBody = '0' or pd.SpecialRepairFlag = '0'))) \n";
  5272. }
  5273. if (!string.IsNullOrEmpty(se.GoodsIDS))
  5274. {
  5275. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||g.GoodsId||',')>0 ";
  5276. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  5277. }
  5278. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  5279. {
  5280. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
  5281. selSql = selSql + " AND instr(gt.GOODSTYPEcode,:GoodsTypeIDS)=1 ";
  5282. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  5283. }
  5284. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  5285. {
  5286. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pd.ProductionLineId||',')>0 ";
  5287. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  5288. }
  5289. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  5290. {
  5291. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||p.ProcedureId||',')>0 ";
  5292. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  5293. }
  5294. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  5295. {
  5296. selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||org.OrganizationId||',')>0 ";
  5297. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  5298. }
  5299. if (se.AccountDateStart.HasValue)
  5300. {
  5301. selSql = selSql + " AND pd.CREATETIME >= :AccountDateStart ";
  5302. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  5303. }
  5304. if (se.AccountDateEnd.HasValue)
  5305. {
  5306. selSql = selSql + " AND pd.CREATETIME <= :AccountDateEnd ";
  5307. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  5308. }
  5309. selSql +=
  5310. " 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" +
  5311. " order by org.organizationcode\n" +
  5312. " ,p.displayno\n" +
  5313. " ,gt.goodstypecode\n" +
  5314. " ,g.goodscode) t";
  5315. return selSql;
  5316. }
  5317. /// <summary>
  5318. /// 取得RPT030101_1画面(产品产量汇总表)的明细信息查询数据
  5319. /// </summary>
  5320. /// <param name="user">登录用户信息</param>
  5321. /// <param name="se">查询条件</param>
  5322. /// <returns>查询结果</returns>
  5323. public static ServiceResultEntity GetRPT030101IData(SUserInfo user, RPT030101_SE se)
  5324. {
  5325. IDBConnection conn = null;
  5326. try
  5327. {
  5328. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  5329. List<OracleParameter> parameters = new List<OracleParameter>();
  5330. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030101ISQL(user, se, ref parameters));
  5331. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  5332. ServiceResultEntity sre = new ServiceResultEntity();
  5333. if (data == null || data.Rows.Count == 0)
  5334. {
  5335. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5336. return sre;
  5337. }
  5338. sre.Data = new DataSet();
  5339. sre.Data.Tables.Add(data);
  5340. return sre;
  5341. }
  5342. catch (Exception ex)
  5343. {
  5344. throw ex;
  5345. }
  5346. finally
  5347. {
  5348. if (conn != null &&
  5349. conn.ConnState == ConnectionState.Open)
  5350. {
  5351. conn.Close();
  5352. }
  5353. }
  5354. }
  5355. /// <summary>
  5356. /// 获取RPT030101_1画面(产品产量汇总表)的明细信息查询sql
  5357. /// </summary>
  5358. /// <returns>sql</returns>
  5359. private static string GetRPT030101ISQL(SUserInfo user, RPT030101_SE se, ref List<OracleParameter> parameters)
  5360. {
  5361. //string selSql = "";
  5362. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  5363. /*
  5364. selSql = selSql +
  5365. "select " +
  5366. "decode(ProductionLineName,'合计','合计',decode(temp.BarCode,'小计','--',OrganizationName)) OrganizationName, " +
  5367. "decode(ProcedureName,'--','--',decode(temp.barcode,'小计','--',temp.ProductionLineName)) ProductionLineName, " +
  5368. "decode(temp.BarCode,'小计','--',temp.ProcedureName) ProcedureName, " +
  5369. "decode(temp.BarCode,'小计','--',temp.GoodsTypeName) GoodsTypeName, " +
  5370. "decode(temp.BarCode,'小计','小计',temp.GoodsCode) GoodsCode, " +
  5371. "decode(ProductionLineName,'合计','--',decode(temp.usercode,'--','--',temp.Barcode)) BarCode, " +
  5372. "decode(temp.UserCode,'小计','--',temp.UserCode) UserCode, " +
  5373. "decode(GOODSSPECIFICATION,'小计','--',GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  5374. "decode(DICTIONARYVALUE,'小计','--',Dictionaryvalue) Dictionaryvalue, " +
  5375. "产量, " +
  5376. "replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName " +
  5377. "from " +
  5378. "( " +
  5379. " select " +
  5380. " decode(grouping(TP_MST_Organization.OrganizationName),1,'总计',TP_MST_Organization.OrganizationName) OrganizationName, " +
  5381. " decode(grouping(TP_MST_Organization.OrganizationName),1,'--', " +
  5382. " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'合计',TP_PM_ProductionData.ProductionLineName)) ProductionLineName, " +
  5383. " decode(grouping(TP_PM_ProductionData.ProcedureName),1,'--',TP_PM_ProductionData.ProcedureName) ProcedureName, " +
  5384. " decode(grouping(TP_MST_GOODSTYPE.GoodsTypeName),1,'--',TP_MST_GOODSTYPE.GoodsTypeName) GoodsTypeName, " +
  5385. " decode(grouping(TP_PM_ProductionData.GoodsCode),1,'--',TP_PM_ProductionData.GoodsCode) GoodsCode, " +
  5386. " decode(grouping(TP_PM_ProductionData.ProductionLineName),1,'--', " +
  5387. " decode(grouping(TP_PM_ProductionData.BarCode),1,'小计',TP_PM_ProductionData.BarCode)) BarCode, " +
  5388. " decode(grouping(TP_PM_ProductionData.UserCode),1,'--',TP_PM_ProductionData.UserCode) UserCode, " +
  5389. " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  5390. " decode(grouping(TP_MST_DATADICTIONARY.Dictionaryvalue),1,'--',TP_MST_DATADICTIONARY.Dictionaryvalue) Dictionaryvalue, " +
  5391. " count(BarCode) as 产量 " +
  5392. " from TP_PM_ProductionData " +
  5393. " left join TP_MST_Goods on TP_MST_Goods.GoodsID=TP_PM_ProductionData.GoodsID " +
  5394. " left join TP_MST_GoodsType on TP_MST_GoodsType.GoodsTypeID=TP_MST_Goods.GoodsTypeID " +
  5395. " left join TP_MST_Organization on TP_MST_Organization.OrganizationID=TP_PM_ProductionData.OrganizationID " +
  5396. " left join TP_MST_DATADICTIONARY on TP_MST_DATADICTIONARY.DICTIONARYID=TP_MST_Goods.GLAZETYPEID " +
  5397. " Where 1=1 " +
  5398. " and TP_PM_ProductionData.ValueFlag = 1 " +
  5399. // 公坯、干补不算交坯工序的质量。
  5400. " 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" +
  5401. " and TP_PM_ProductionData.AccountID=:AccountID ";
  5402. if (!string.IsNullOrEmpty(se.GoodsIDS))
  5403. {
  5404. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  5405. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  5406. }
  5407. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  5408. {
  5409. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
  5410. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)>0 ";
  5411. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  5412. }
  5413. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  5414. {
  5415. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  5416. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  5417. }
  5418. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  5419. {
  5420. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_ProductionData.ProcedureId||',')>0 ";
  5421. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  5422. }
  5423. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  5424. {
  5425. selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||TP_MST_Organization.OrganizationId||',')>0 ";
  5426. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  5427. }
  5428. if (se.AccountDateStart.HasValue)
  5429. {
  5430. selSql = selSql + " AND TP_PM_ProductionData.AccountDate >= :AccountDateStart ";
  5431. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  5432. }
  5433. if (se.AccountDateEnd.HasValue)
  5434. {
  5435. selSql = selSql + " AND TP_PM_ProductionData.AccountDate <= :AccountDateEnd ";
  5436. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  5437. }
  5438. selSql = selSql +
  5439. "group by " +
  5440. " rollup(TP_MST_Organization.OrganizationName, " +
  5441. " TP_PM_ProductionData.ProductionLineName, " +
  5442. " TP_PM_ProductionData.ProcedureName, " +
  5443. " TP_MST_GOODSTYPE.GoodsTypeName, " +
  5444. " TP_PM_ProductionData.GoodsCode, " +
  5445. " TP_PM_ProductionData.BarCode, " +
  5446. " TP_PM_ProductionData.UserCode, " +
  5447. " TP_MST_Goods.GOODSSPECIFICATION, " +
  5448. " TP_MST_DATADICTIONARY.Dictionaryvalue" +
  5449. " ) " +
  5450. " order by " +
  5451. " TP_MST_Organization.OrganizationName, " +
  5452. " TP_PM_ProductionData.ProductionLineName, " +
  5453. " TP_PM_ProductionData.ProcedureName, " +
  5454. " TP_MST_GOODSTYPE.GoodsTypeName " +
  5455. ") temp inner join TP_PM_GroutingDailyDetail on temp.barcode=TP_PM_GroutingDailyDetail.barcode " +
  5456. " inner join tp_mst_logo on TP_PM_GroutingDailyDetail.logoid=tp_mst_logo.logoid " +
  5457. "where 1=1 " +
  5458. "and (temp.DICTIONARYVALUE!='--') " +
  5459. "or (temp.GoodsTypeName='--' and temp.ProductionLineName='合计') " +
  5460. "or (temp.GoodsTypeName='--' and temp.OrganizationName='总计') " +
  5461. "or (temp.BarCode='小计' and temp.GoodsCode!='--')";
  5462. */
  5463. string selSql =
  5464. " select " +
  5465. " TP_MST_Organization.OrganizationName, " +
  5466. " TP_PM_ProductionData.ProductionLineName, " +
  5467. " TP_PM_ProductionData.ProcedureName, " +
  5468. " TP_MST_GOODSTYPE.GoodsTypeName, " +
  5469. " TP_PM_ProductionData.GoodsCode, " +
  5470. " TP_MST_Goods.GoodsName, " +
  5471. " TP_MST_Goods.GoodsModel, " +
  5472. " TP_PM_ProductionData.BarCode, " +
  5473. " TP_PM_ProductionData.UserCode, " +
  5474. " TP_MST_Goods.GOODSSPECIFICATION, " +
  5475. " TP_MST_DATADICTIONARY.Dictionaryvalue, " +
  5476. " TP_PM_ProductionData.CREATETIME, " +
  5477. " TP_PM_ProductionData.KILNcarCODE, " +
  5478. " TP_PM_ProductionData.KILNCODE, " +
  5479. " cu.usercode createusercode, " +
  5480. " cu.username CreateUserName, " +
  5481. " gdd.glazingroom," +
  5482. " decode(tp_mst_logo.logoid,null,'',TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']') as LogoCodeName " +
  5483. " from TP_PM_ProductionData " +
  5484. " left join TP_MST_Goods on TP_MST_Goods.GoodsID=TP_PM_ProductionData.GoodsID " +
  5485. " left join TP_MST_GoodsType on TP_MST_GoodsType.GoodsTypeID=TP_MST_Goods.GoodsTypeID " +
  5486. " left join TP_MST_Organization on TP_MST_Organization.OrganizationID=TP_PM_ProductionData.OrganizationID " +
  5487. " left join TP_MST_DATADICTIONARY on TP_MST_DATADICTIONARY.DICTIONARYID=TP_MST_Goods.GLAZETYPEID " +
  5488. " left join tp_mst_logo on TP_PM_ProductionData.logoid=tp_mst_logo.logoid " +
  5489. " left join tp_mst_user cu on TP_PM_ProductionData.createuserid=cu.userid " +
  5490. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  5491. " ON gdd.Groutingdailydetailid = TP_PM_ProductionData.Groutingdailydetailid\n" +
  5492. " Where TP_PM_ProductionData.ValueFlag = '1' " +
  5493. // 公坯、干补不算交坯工序的质量。
  5494. " 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" +
  5495. " and TP_PM_ProductionData.AccountID=:AccountID ";
  5496. if (!string.IsNullOrEmpty(se.GoodsIDS))
  5497. {
  5498. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  5499. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  5500. }
  5501. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  5502. {
  5503. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPEId||',')>0 ";
  5504. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)>0 ";
  5505. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  5506. }
  5507. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  5508. {
  5509. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  5510. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  5511. }
  5512. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  5513. {
  5514. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_ProductionData.ProcedureId||',')>0 ";
  5515. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  5516. }
  5517. if (!string.IsNullOrEmpty(se.OrganizationIDS))
  5518. {
  5519. selSql = selSql + " AND instr(','||:OrganizationIDS||',',','||TP_MST_Organization.OrganizationId||',')>0 ";
  5520. parameters.Add(new OracleParameter(":OrganizationIDS", OracleDbType.NVarchar2, se.OrganizationIDS, ParameterDirection.Input));
  5521. }
  5522. if (se.AccountDateStart.HasValue)
  5523. {
  5524. selSql = selSql + " AND TP_PM_ProductionData.CREATETIME >= :AccountDateStart ";
  5525. parameters.Add(new OracleParameter(":AccountDateStart", OracleDbType.Date, se.AccountDateStart.Value, ParameterDirection.Input));
  5526. }
  5527. if (se.AccountDateEnd.HasValue)
  5528. {
  5529. selSql = selSql + " AND TP_PM_ProductionData.CREATETIME <= :AccountDateEnd ";
  5530. parameters.Add(new OracleParameter(":AccountDateEnd", OracleDbType.Date, se.AccountDateEnd.Value, ParameterDirection.Input));
  5531. }
  5532. return selSql;
  5533. }
  5534. /// <summary>
  5535. /// 取得RPT030102_1画面(产品损坯汇总表)的汇总信息查询数据
  5536. /// </summary>
  5537. /// <param name="user">登录用户信息</param>
  5538. /// <param name="se">查询条件</param>
  5539. /// <returns>查询结果</returns>
  5540. public static ServiceResultEntity GetRPT030102SData(SUserInfo user, RPT030102_SE se)
  5541. {
  5542. IDBConnection conn = null;
  5543. try
  5544. {
  5545. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  5546. List<OracleParameter> parameters = new List<OracleParameter>();
  5547. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030102SSQL(user, se, ref parameters));
  5548. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  5549. ServiceResultEntity sre = new ServiceResultEntity();
  5550. if (data == null || data.Rows.Count == 0)
  5551. {
  5552. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5553. return sre;
  5554. }
  5555. sre.Data = new DataSet();
  5556. sre.Data.Tables.Add(data);
  5557. return sre;
  5558. }
  5559. catch (Exception ex)
  5560. {
  5561. throw ex;
  5562. }
  5563. finally
  5564. {
  5565. if (conn != null &&
  5566. conn.ConnState == ConnectionState.Open)
  5567. {
  5568. conn.Close();
  5569. }
  5570. }
  5571. }
  5572. /// <summary>
  5573. /// 获取RPT030102_1画面(产品损坯汇总表)的汇总信息查询sql
  5574. /// </summary>
  5575. /// <returns>sql</returns>
  5576. private static string GetRPT030102SSQL(SUserInfo user, RPT030102_SE se, ref List<OracleParameter> parameters)
  5577. {
  5578. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  5579. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  5580. string sqlString = "SELECT decode(ts.gid,\n" +
  5581. " 7,\n" +
  5582. " '总计',\n" +
  5583. " 3,\n" +
  5584. " '合计【' || ts.zrprocedurename || '】',\n" +
  5585. " 0,\n" +
  5586. " ts.zrprocedurename,\n" +
  5587. " '--') zrprocedurename\n" +
  5588. " ,decode(ts.gid,\n" +
  5589. " 1,\n" +
  5590. " '小计【' || ts.goodstypename2 || '】',\n" +
  5591. " 0,\n" +
  5592. " ts.goodstypename2,\n" +
  5593. " '--') goodstypename2\n" +
  5594. " ,decode(ts.gid, 0, ts.zrusercode, '--') zrusercode\n" +
  5595. " ,decode(ts.gid, 0, ts.goodscode, '--') goodscode\n" +
  5596. " ,decode(ts.gid, 0, ts.GOODSMODEL, '--') GOODSMODEL\n" +
  5597. " ,ts.productionlineid\n" +
  5598. " ,ts.zrprocedureid\n" +
  5599. " ,ts.goodstypecode2\n" +
  5600. " ,ts.zruserid\n" +
  5601. " ,ts.goodsid\n" +
  5602. " ,ts.barcount\n" +
  5603. " FROM (SELECT grouping_id(t.zrprocedureid, t.goodstypecode2, t.zruserid) gid\n" +
  5604. " ,t.productionlineid\n" +
  5605. " ,t.productionlinename\n" +
  5606. " ,t.displayno\n" +
  5607. " ,t.zrprocedureid\n" +
  5608. " ,t.zrprocedurename\n" +
  5609. " ,t.goodstypecode2\n" +
  5610. " ,t.goodstypename2\n" +
  5611. " ,t.zruserid\n" +
  5612. " ,t.zrusercode\n" +
  5613. " ,t.goodsid\n" +
  5614. " ,t.goodscode\n" +
  5615. " ,t.GOODSMODEL\n" +
  5616. " ,COUNT(t.barcode) barcount\n" +
  5617. " FROM (SELECT sp.productionlineid\n" +
  5618. " ,pline.productionlinename\n" +
  5619. " ,nvl(zp.displayno, -1) displayno\n" +
  5620. " ,zp.procedureid zrprocedureid\n" +
  5621. " ,zp.procedurename zrprocedurename\n" +
  5622. " ,sr.userid zruserid\n" +
  5623. " ,sr.usercode zrusercode\n" +
  5624. " ,gt2.goodstypecode goodstypecode2\n" +
  5625. " ,gt2.goodstypename goodstypename2\n" +
  5626. " ,g.goodsid\n" +
  5627. " ,g.goodscode\n" +
  5628. " ,g.GOODSMODEL\n" +
  5629. " ,sp.barcode\n" +
  5630. " FROM tp_pm_scrapproduct sp\n" +
  5631. " LEFT JOIN TP_PM_ResponProcedure rp\n" +
  5632. " ON rp.scrapproductid = sp.scrapproductid\n" +
  5633. " LEFT JOIN (SELECT DISTINCT t.ScrapProductID\n" +
  5634. " ,t.ResponProcedureID\n" +
  5635. " ,t.userid\n" +
  5636. " ,t.usercode\n" +
  5637. " FROM TP_PM_ScrapResponsible t) sr\n" +
  5638. " ON sr.scrapproductid = sp.scrapproductid\n" +
  5639. // wangx 2016-06-20
  5640. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  5641. " ON rp.barcode = gdd.barcode\n" +
  5642. // wangx 2016-06-20 end
  5643. " LEFT JOIN tp_pc_productionline pline\n" +
  5644. " ON pline.productionlineid = sp.productionlineid\n" +
  5645. " LEFT JOIN tp_pc_procedure zp\n" +
  5646. " ON zp.procedureid = rp.procedureid\n" +
  5647. " LEFT JOIN tp_mst_user cu\n" +
  5648. " ON cu.userid = sp.createuserid\n" +
  5649. " LEFT JOIN tp_mst_user au\n" +
  5650. " ON au.userid = sp.auditor\n" +
  5651. " LEFT JOIN tp_mst_goods g\n" +
  5652. " ON g.goodsid = sp.goodsid\n" +
  5653. " LEFT JOIN tp_mst_goodstype gt\n" +
  5654. " ON gt.goodstypeid = g.goodstypeid\n" +
  5655. " LEFT JOIN tp_mst_goodstype gt2\n" +
  5656. " ON gt2.accountid = gt.accountid\n" +
  5657. " AND gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  5658. " WHERE sp.valueflag = '1'\n" +
  5659. " AND sp.AuditStatus = '1'\n" +
  5660. // 生产线
  5661. //" 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))" +
  5662. // 完成工序
  5663. //" 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))" +
  5664. // 责任工序
  5665. //" 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)))" +
  5666. " AND sp.accountid = :AccountID\n" +
  5667. (se.SpecialRepairFlag ? " AND sp.GoodsLevelTypeID in (8,9) -- 8损坯、9干补\n" : " AND sp.GoodsLevelTypeID = 8 -- 8损坯、9干补\n") +
  5668. (se.ReFireFlag ? " " : " AND sp.IsReFire <> '6'\n") +
  5669. " AND sp.ScrapType = '0'\n" +
  5670. " AND (:ProductionLineID IS NULL OR\n" +
  5671. " sp.ProductionLineID = :ProductionLineID)\n" +
  5672. " AND (:GoodsTypeCode IS NULL OR\n" +
  5673. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  5674. " AND (:GoodsCode IS NULL OR\n" +
  5675. " instr(g.GoodsCode, :GoodsCode) > 0)\n" +
  5676. " AND (:ProcedureIDS IS NULL OR\n" +
  5677. " instr(:ProcedureIDS, ',' || sp.ProcedureID || ',') > 0)\n" +
  5678. " AND (:ResponProcedureIDS IS NULL OR\n" +
  5679. " instr(:ResponProcedureIDS,\n" +
  5680. " ',' || rp.ProcedureID || ',') > 0)\n" +
  5681. " AND (:ResponUserIDS IS NULL OR\n" +
  5682. " instr(:ResponUserIDS, ',' || sr.userid || ',') > 0)\n" +
  5683. // 损坯时间
  5684. " AND (:ScrapDateStart IS NULL OR\n" +
  5685. " sp.CreateTime >= :ScrapDateStart)\n" +
  5686. " AND (:ScrapDateEnd IS NULL OR\n" +
  5687. " sp.CreateTime <= :ScrapDateEnd)\n" +
  5688. // 审核时间
  5689. " AND (:AuditDateStart IS NULL OR\n" +
  5690. " sp.AuditDate >= :AuditDateStart)\n" +
  5691. " AND (:AuditDateEnd IS NULL OR\n" +
  5692. " sp.AuditDate <= :AuditDateEnd)\n" +
  5693. // 完成时间
  5694. " AND (:CTimeStart IS NULL OR\n" +
  5695. " sp.CreateTime >= :CTimeStart)\n" +
  5696. " AND (:CTimeEnd IS NULL OR\n" +
  5697. " sp.CreateTime <= :CTimeEnd)\n" +
  5698. // 交坯时间
  5699. " AND (:DTimeStart IS NULL OR\n" +
  5700. " gdd.DeliverTime >= :DTimeStart)\n" +
  5701. " AND (:DTimeEnd IS NULL OR\n" +
  5702. " gdd.DeliverTime <= :DTimeEnd)\n" +
  5703. // 注浆时间
  5704. " AND (:GTimeStart IS NULL OR\n" +
  5705. " gdd.GroutingDate >= :GTimeStart)\n" +
  5706. " AND (:GTimeEnd IS NULL OR\n" +
  5707. " gdd.GroutingDate <= :GTimeEnd)\n" +
  5708. " AND (:CreatUser IS NULL OR\n" +
  5709. " instr(cu.UserCode, :CreatUser) > 0)\n" +
  5710. " AND (:AuditUser IS NULL OR\n" +
  5711. " instr(au.UserCode, :AuditUser) > 0)) t\n" +
  5712. " 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" +
  5713. " ORDER BY t.displayno, t.goodstypecode2, t.zrusercode, t.goodscode) ts";
  5714. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  5715. if (string.IsNullOrEmpty(se.ProcedureIDS))
  5716. {
  5717. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5718. }
  5719. else
  5720. {
  5721. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  5722. }
  5723. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  5724. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  5725. if (string.IsNullOrEmpty(se.ResponProcedureIDS))
  5726. {
  5727. parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5728. }
  5729. else
  5730. {
  5731. parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, "," + se.ResponProcedureIDS + ",", ParameterDirection.Input));
  5732. }
  5733. if (string.IsNullOrEmpty(se.ResponUserIDS))
  5734. {
  5735. parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5736. }
  5737. else
  5738. {
  5739. parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, "," + se.ResponUserIDS + ",", ParameterDirection.Input));
  5740. }
  5741. parameters.Add(new OracleParameter(":CreatUser", OracleDbType.Varchar2, se.CreatUser, ParameterDirection.Input));
  5742. parameters.Add(new OracleParameter(":AuditUser", OracleDbType.Varchar2, se.AuditUser, ParameterDirection.Input));
  5743. parameters.Add(new OracleParameter(":ScrapDateStart", OracleDbType.Date, se.ScrapDateStart, ParameterDirection.Input));
  5744. parameters.Add(new OracleParameter(":ScrapDateEnd", OracleDbType.Date, se.ScrapDateEnd, ParameterDirection.Input));
  5745. parameters.Add(new OracleParameter(":CTimeStart", OracleDbType.Date, se.CTimeStart, ParameterDirection.Input));
  5746. parameters.Add(new OracleParameter(":CTimeEnd", OracleDbType.Date, se.CTimeEnd, ParameterDirection.Input));
  5747. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart, ParameterDirection.Input));
  5748. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd, ParameterDirection.Input));
  5749. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart, ParameterDirection.Input));
  5750. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd, ParameterDirection.Input));
  5751. parameters.Add(new OracleParameter(":AuditDateStart", OracleDbType.Date, se.AuditTimeStart, ParameterDirection.Input));
  5752. parameters.Add(new OracleParameter(":AuditDateEnd", OracleDbType.Date, se.AuditTimeEnd, ParameterDirection.Input));
  5753. return sqlString;
  5754. }
  5755. /// <summary>
  5756. /// 取得RPT030102_1画面(产品损坯汇总表)的明细信息查询数据
  5757. /// </summary>
  5758. /// <param name="user">登录用户信息</param>
  5759. /// <param name="se">查询条件</param>
  5760. /// <returns>查询结果</returns>
  5761. public static ServiceResultEntity GetRPT030102IData(SUserInfo user, RPT030102_SE se)
  5762. {
  5763. IDBConnection conn = null;
  5764. try
  5765. {
  5766. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  5767. List<OracleParameter> parameters = new List<OracleParameter>();
  5768. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030102ISQL(user, se, ref parameters));
  5769. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  5770. ServiceResultEntity sre = new ServiceResultEntity();
  5771. if (data == null || data.Rows.Count == 0)
  5772. {
  5773. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5774. return sre;
  5775. }
  5776. sre.Data = new DataSet();
  5777. sre.Data.Tables.Add(data);
  5778. return sre;
  5779. }
  5780. catch (Exception ex)
  5781. {
  5782. throw ex;
  5783. }
  5784. finally
  5785. {
  5786. if (conn != null &&
  5787. conn.ConnState == ConnectionState.Open)
  5788. {
  5789. conn.Close();
  5790. }
  5791. }
  5792. }
  5793. /// <summary>
  5794. /// 获取RPT030102_1画面(产品损坯汇总表)的明细信息查询sql
  5795. /// </summary>
  5796. /// <returns>sql</returns>
  5797. private static string GetRPT030102ISQL(SUserInfo user, RPT030102_SE se, ref List<OracleParameter> parameters)
  5798. {
  5799. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  5800. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  5801. string sqlString =
  5802. "SELECT pline.productionlinename\n" +
  5803. " ,p.procedurename\n" +
  5804. " ,zp.procedurename zrprocedurename\n" +
  5805. " ,sr.usercode zrusercode\n" +
  5806. " ,sr.StaffNames zrStaffNames\n" +
  5807. " ,gt2.goodstypecode goodstypecode2\n" +
  5808. " ,gt2.goodstypename goodstypename2\n" +
  5809. " ,gt.goodstypename\n" +
  5810. " ,g.goodscode\n" +
  5811. " ,g.GOODSMODEL\n" +
  5812. " ,sp.barcode\n" +
  5813. " ,sp.createtime Scrapdate\n" +
  5814. " ,sp.Rreason\n" +
  5815. " ,sp.GroutingUserCode\n" +
  5816. " ,sp.GroutingLineCode\n" +
  5817. " ,sp.GroutingMouldCode\n" +
  5818. " ,sp.GroutingDate\n" +
  5819. " ,sp.GroutingNum\n" +
  5820. " ,cu.usercode CreateUserCode\n" +
  5821. " ,au.usercode AuditorCode\n" +
  5822. " ,sp.auditdate\n" +
  5823. " ,gdd.DeliverTime\n" +
  5824. " ,gdd.ISPUBLICBODY\n" +
  5825. " ,gdd.SPECIALREPAIRFLAG\n" +
  5826. " ,lg.logoname\n" +
  5827. " ,sp.CreateTime\n" +
  5828. " ,sp.Remarks\n" +
  5829. " FROM tp_pm_scrapproduct sp\n" +
  5830. " LEFT JOIN TP_PM_ResponProcedure rp\n" +
  5831. " ON rp.scrapproductid = sp.scrapproductid\n" +
  5832. " LEFT JOIN (SELECT DISTINCT t.ScrapProductID\n" +
  5833. " ,t.ResponProcedureID\n" +
  5834. " ,t.userid\n" +
  5835. " ,t.usercode\n" +
  5836. " ,LISTAGG(to_char(s.StaffName), ',') WITHIN GROUP(ORDER BY s.staffcode) over(partition by t.ScrapProductID) AS StaffNames\n" +
  5837. " FROM TP_PM_ScrapResponsible t\n" +
  5838. " LEFT JOIN TP_HR_Staff s \n" +
  5839. " ON s.StaffID = t.StaffID \n" +
  5840. " ) sr\n" +
  5841. " ON sr.scrapproductid = sp.scrapproductid\n" +
  5842. // wangx 2016-06-20
  5843. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  5844. " ON sp.barcode = gdd.barcode\n" +
  5845. // wangx 2016-06-20 end
  5846. " LEFT JOIN TP_mst_logo lg\n" +
  5847. " ON lg.logoid = gdd.logoid\n" +
  5848. " LEFT JOIN tp_pc_productionline pline\n" +
  5849. " ON pline.productionlineid = sp.productionlineid\n" +
  5850. " LEFT JOIN tp_pc_procedure p\n" +
  5851. " ON p.procedureid = sp.procedureid\n" +
  5852. " LEFT JOIN tp_pc_procedure zp\n" +
  5853. " ON zp.procedureid = rp.procedureid\n" +
  5854. " LEFT JOIN tp_mst_user cu\n" +
  5855. " ON cu.userid = sp.createuserid\n" +
  5856. " LEFT JOIN tp_mst_user au\n" +
  5857. " ON au.userid = sp.auditor\n" +
  5858. " LEFT JOIN tp_mst_goods g\n" +
  5859. " ON g.goodsid = sp.goodsid\n" +
  5860. " LEFT JOIN tp_mst_goodstype gt\n" +
  5861. " ON gt.goodstypeid = g.goodstypeid\n" +
  5862. " LEFT JOIN tp_mst_goodstype gt2\n" +
  5863. " ON gt2.accountid = gt.accountid\n" +
  5864. " AND gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  5865. " WHERE sp.valueflag = '1'\n" +
  5866. " AND sp.AuditStatus = '1'\n" +
  5867. " AND sp.accountid = :accountid\n" +
  5868. // 生产线
  5869. //" 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))" +
  5870. // 完成工序
  5871. //" 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))" +
  5872. // 责任工序
  5873. //" 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)))" +
  5874. //" AND sp.GoodsLevelTypeID = 8 -- 8损坯、9干补\n" +
  5875. (se.SpecialRepairFlag ? " AND sp.GoodsLevelTypeID in (8,9) -- 8损坯、9干补\n" : " AND sp.GoodsLevelTypeID = 8 -- 8损坯、9干补\n") +
  5876. (se.ReFireFlag ? " " : " AND sp.IsReFire <> '6'\n") +
  5877. " AND sp.ScrapType = '0'\n" +
  5878. " AND (:ProductionLineID IS NULL OR\n" +
  5879. " sp.ProductionLineID = :ProductionLineID)\n" +
  5880. " AND (:GoodsTypeCode IS NULL OR\n" +
  5881. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  5882. " AND (:GoodsCode IS NULL OR instr(g.GoodsCode, :GoodsCode) > 0)\n" +
  5883. " AND (:ProcedureIDS IS NULL OR\n" +
  5884. " instr(:ProcedureIDS, ',' || sp.ProcedureID || ',') > 0)\n" +
  5885. " AND (:ResponProcedureIDS IS NULL OR\n" +
  5886. " instr(:ResponProcedureIDS, ',' || rp.ProcedureID || ',') > 0)\n" +
  5887. " AND (:ResponUserIDS IS NULL OR\n" +
  5888. " instr(:ResponUserIDS, ',' || sr.userid || ',') > 0)\n" +
  5889. // 损坯时间
  5890. " AND (:ScrapDateStart IS NULL OR sp.CreateTime >= :ScrapDateStart)\n" +
  5891. " AND (:ScrapDateEnd IS NULL OR sp.CreateTime <= :ScrapDateEnd)\n" +
  5892. // 审核时间
  5893. " AND (:AuditDateStart IS NULL OR sp.AuditDate >= :AuditDateStart)\n" +
  5894. " AND (:AuditDateEnd IS NULL OR sp.AuditDate <= :AuditDateEnd)\n" +
  5895. // 完成时间
  5896. " AND (:CTimeStart IS NULL OR\n" +
  5897. " sp.CreateTime >= :CTimeStart)\n" +
  5898. " AND (:CTimeEnd IS NULL OR\n" +
  5899. " sp.CreateTime <= :CTimeEnd)\n" +
  5900. // 交坯时间
  5901. " AND (:DTimeStart IS NULL OR\n" +
  5902. " gdd.DeliverTime >= :DTimeStart)\n" +
  5903. " AND (:DTimeEnd IS NULL OR\n" +
  5904. " gdd.DeliverTime <= :DTimeEnd)\n" +
  5905. // 注浆时间
  5906. " AND (:GTimeStart IS NULL OR\n" +
  5907. " gdd.GroutingDate >= :GTimeStart)\n" +
  5908. " AND (:GTimeEnd IS NULL OR\n" +
  5909. " gdd.GroutingDate <= :GTimeEnd)\n" +
  5910. " AND (:CreatUser IS NULL OR instr(cu.UserCode, :CreatUser) > 0)\n" +
  5911. " AND (:AuditUser IS NULL OR instr(au.UserCode, :AuditUser) > 0)\n" +
  5912. " AND (:GoodsID IS NULL OR sp.goodsid = :GoodsID)\n" +
  5913. " AND (:ResponProcedureID IS NULL OR rp.procedureid = :ResponProcedureID)\n" +
  5914. " AND (:ResponUserID IS NULL OR sr.userid = :ResponUserID)\n" +
  5915. " AND (:RPF = 1 OR rp.procedureid is null)\n" +
  5916. " AND (:RUF = 1 OR sr.userid is null)\n" +
  5917. " ORDER BY pline.productionlinename, nvl(zp.displayno, -1), sp.barcode";
  5918. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  5919. if (string.IsNullOrEmpty(se.ProcedureIDS))
  5920. {
  5921. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5922. }
  5923. else
  5924. {
  5925. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  5926. }
  5927. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  5928. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  5929. if (string.IsNullOrEmpty(se.ResponProcedureIDS))
  5930. {
  5931. parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5932. }
  5933. else
  5934. {
  5935. parameters.Add(new OracleParameter(":ResponProcedureIDS", OracleDbType.Varchar2, "," + se.ResponProcedureIDS + ",", ParameterDirection.Input));
  5936. }
  5937. if (string.IsNullOrEmpty(se.ResponUserIDS))
  5938. {
  5939. parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  5940. }
  5941. else
  5942. {
  5943. parameters.Add(new OracleParameter(":ResponUserIDS", OracleDbType.Varchar2, "," + se.ResponUserIDS + ",", ParameterDirection.Input));
  5944. }
  5945. parameters.Add(new OracleParameter(":CreatUser", OracleDbType.Varchar2, se.CreatUser, ParameterDirection.Input));
  5946. parameters.Add(new OracleParameter(":AuditUser", OracleDbType.Varchar2, se.AuditUser, ParameterDirection.Input));
  5947. parameters.Add(new OracleParameter(":ScrapDateStart", OracleDbType.Date, se.ScrapDateStart, ParameterDirection.Input));
  5948. parameters.Add(new OracleParameter(":ScrapDateEnd", OracleDbType.Date, se.ScrapDateEnd, ParameterDirection.Input));
  5949. parameters.Add(new OracleParameter(":AuditDateStart", OracleDbType.Date, se.AuditTimeStart, ParameterDirection.Input));
  5950. parameters.Add(new OracleParameter(":AuditDateEnd", OracleDbType.Date, se.AuditTimeEnd, ParameterDirection.Input));
  5951. parameters.Add(new OracleParameter(":CTimeStart", OracleDbType.Date, se.CTimeStart, ParameterDirection.Input));
  5952. parameters.Add(new OracleParameter(":CTimeEnd", OracleDbType.Date, se.CTimeEnd, ParameterDirection.Input));
  5953. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart, ParameterDirection.Input));
  5954. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd, ParameterDirection.Input));
  5955. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart, ParameterDirection.Input));
  5956. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd, ParameterDirection.Input));
  5957. parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  5958. if (se.ResponProcedureID == "")
  5959. {
  5960. parameters.Add(new OracleParameter(":RPF", OracleDbType.Int32, 0, ParameterDirection.Input));
  5961. parameters.Add(new OracleParameter(":ResponProcedureID", OracleDbType.Int32, null, ParameterDirection.Input));
  5962. }
  5963. else
  5964. {
  5965. parameters.Add(new OracleParameter(":RPF", OracleDbType.Int32, 1, ParameterDirection.Input));
  5966. parameters.Add(new OracleParameter(":ResponProcedureID", OracleDbType.Int32, se.ResponProcedureID, ParameterDirection.Input));
  5967. }
  5968. if (se.ResponUserID == "")
  5969. {
  5970. parameters.Add(new OracleParameter(":RUF", OracleDbType.Int32, 0, ParameterDirection.Input));
  5971. parameters.Add(new OracleParameter(":ResponUserID", OracleDbType.Int32, null, ParameterDirection.Input));
  5972. }
  5973. else
  5974. {
  5975. parameters.Add(new OracleParameter(":RUF", OracleDbType.Int32, 1, ParameterDirection.Input));
  5976. parameters.Add(new OracleParameter(":ResponUserID", OracleDbType.Int32, se.ResponUserID, ParameterDirection.Input));
  5977. }
  5978. return sqlString;
  5979. }
  5980. /// <summary>
  5981. /// 取得RPT030103_1画面(出窑数量汇总表)的汇总信息查询数据
  5982. /// </summary>
  5983. /// <param name="user">登录用户信息</param>
  5984. /// <param name="se">查询条件</param>
  5985. /// <returns>查询结果</returns>
  5986. public static ServiceResultEntity GetRPT030103SData(SUserInfo user, RPT030103_SE se)
  5987. {
  5988. IDBConnection conn = null;
  5989. try
  5990. {
  5991. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  5992. List<OracleParameter> parameters = new List<OracleParameter>();
  5993. string sql = ReportModuleLogic.GetRPT030103SSQL(user, se, ref parameters);
  5994. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  5995. ServiceResultEntity sre = new ServiceResultEntity();
  5996. if (data == null || data.Rows.Count == 0)
  5997. {
  5998. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  5999. return sre;
  6000. }
  6001. sre.Data = new DataSet();
  6002. sre.Data.Tables.Add(data);
  6003. return sre;
  6004. }
  6005. catch (Exception ex)
  6006. {
  6007. throw ex;
  6008. }
  6009. finally
  6010. {
  6011. if (conn != null &&
  6012. conn.ConnState == ConnectionState.Open)
  6013. {
  6014. conn.Close();
  6015. }
  6016. }
  6017. }
  6018. /// <summary>
  6019. /// 获取RPT030103_1画面(出窑数量汇总表)的汇总信息查询sql
  6020. /// </summary>
  6021. /// <returns>sql</returns>
  6022. private static string GetRPT030103SSQL(SUserInfo user, RPT030103_SE se, ref List<OracleParameter> parameters)
  6023. {
  6024. string selSql = "";
  6025. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6026. parameters.Add(new OracleParameter(":rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  6027. selSql = selSql +
  6028. "SELECT pdata.Procedureid Procedureid " +
  6029. " ,decode(gid, 3, '合计', 1, '小计【'||pdata.Procedurename||'】', pdata.Procedurename) Procedurename " +
  6030. " ,decode(gid, 0, to_char(pdata.Userid), '--') Userid " +
  6031. " ,decode(gid, 0, pdata.Usercode, '--') Usercode " +
  6032. " ,decode(gid, 0, to_char(pdata.KilnID), '--') Kilnid " +
  6033. " ,decode(gid, 0, pdata.Kilncode, '--') Kilncode " +
  6034. " ,decode(gid, 0, pdata.goodstypename, '--') goodstypename " +
  6035. " ,decode(gid, 0, to_char(pdata.Goodsid), '--') Goodsid " +
  6036. " ,decode(gid, 0, pdata.Goodscode, '--') Goodscode " +
  6037. " ,OutKilnCount " +
  6038. " FROM (SELECT grouping_id(pdata.Procedureid, " +
  6039. " pdata.Userid ) gid " +
  6040. " ,pdata.Procedureid " +
  6041. " ,pdata.Procedurename " +
  6042. " ,pdata.Userid " +
  6043. " ,pdata.Usercode " +
  6044. " ,pdata.Kilnid " +
  6045. " ,pdata.Kilncode " +
  6046. " ,pdata.goodstypename " +
  6047. " ,pdata.Goodsid " +
  6048. " ,pdata.Goodscode " +
  6049. " ,COUNT(pdata.Barcode) AS OutKilnCount " +
  6050. " FROM (SELECT DISTINCT " +
  6051. //" decode(grouping(TP_PM_ProductionData.Procedureid),1,'--',TP_PM_ProductionData.Procedureid) Procedureid, " +
  6052. //" decode(grouping(TP_PM_ProductionData.Procedurename),1,'合计', TP_PM_ProductionData.Procedurename) Procedurename, " +
  6053. //" decode(grouping(TP_PM_ProductionData.Userid),1,'--', TP_PM_ProductionData.Userid) Userid, " +
  6054. //" decode(grouping(TP_PM_ProductionData.Usercode),1,'--', TP_PM_ProductionData.Usercode) Usercode, " +
  6055. //" decode(grouping(temp.Kilncode),1,'--', temp.KilnID) Kilnid, " +
  6056. //" decode(grouping(temp.Kilncode),1,'--', temp.Kilncode) Kilncode, " +
  6057. //" decode(grouping(tp_mst_goodstype.goodstypename),1,'--', tp_mst_goodstype.goodstypename) goodstypename, " +
  6058. //" decode(grouping(TP_PM_ProductionData.Goodsid),1,'--', TP_PM_ProductionData.Goodsid) Goodsid, " +
  6059. //" decode(grouping(TP_PM_ProductionData.Goodscode),1,'--', TP_PM_ProductionData.Goodscode) Goodscode, " +
  6060. "TP_PM_ProductionData.Procedureid,pcp.Procedurename, " +
  6061. //"TP_PM_ProductionData.Userid,TP_PM_ProductionData.Usercode, " +
  6062. (se.DisPUserCode ? " TP_PM_ProductionData.userid, TP_PM_ProductionData.usercode, \n" : " null userid, null usercode, \n") +
  6063. "temp.Kilnid,temp.Kilncode,tp_mst_goodstype.goodstypename, " +
  6064. "TP_PM_ProductionData.Goodsid,TP_PM_ProductionData.Goodscode, TP_PM_ProductionData.barcode " +
  6065. " from TP_PM_ProductionData " +
  6066. " inner join tp_mst_goods on tp_mst_goods.goodsid=TP_PM_ProductionData.Goodsid " +
  6067. " inner join tp_mst_goodstype on tp_mst_goodstype.goodstypeid=tp_mst_goods.goodstypeid " +
  6068. " inner join TP_MST_RptTProcedure on TP_MST_RptTProcedure.Procedureid=TP_PM_ProductionData.Procedureid " +
  6069. " inner join TP_MST_RptProcedure on TP_MST_RptProcedure.Rptprocedureid=TP_MST_RptTProcedure.Rptprocedureid " +
  6070. " inner join tp_pc_procedure pcp on pcp.procedureid=TP_PM_ProductionData.Procedureid " +
  6071. " inner join " +
  6072. " ( " +
  6073. " 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 " +
  6074. " from TP_PM_ProductionData " +
  6075. " inner join TP_MST_RptSProcedure on TP_MST_RptSProcedure.Procedureid=TP_PM_ProductionData.Procedureid ";
  6076. if (se.DTimeStart.HasValue || se.DTimeEnd.HasValue)
  6077. {
  6078. selSql += " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=TP_PM_ProductionData.groutingdailydetailid ";
  6079. }
  6080. selSql +=
  6081. " where TP_PM_ProductionData.Accountid=:AccountID " +
  6082. " and TP_PM_ProductionData.Valueflag='1' " +
  6083. // 数据重复 modify by chenxy begin
  6084. // " and TP_MST_RptSProcedure.Rptprocedureid=:rptProcedureId " +
  6085. // 数据重复 modify by chenxy end
  6086. " and TP_MST_RptSProcedure.Procedureid=:rptSprocedureId ";
  6087. //if (se.CreateTimeStart.HasValue)
  6088. //{
  6089. // selSql = selSql + " AND TP_PM_ProductionData.CreateTime >= :CreateTimeStart ";
  6090. // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6091. //}
  6092. //if (se.CreateTimeEnd.HasValue)
  6093. //{
  6094. // selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :CreateTimeEnd ";
  6095. // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6096. //}
  6097. if (se.OutTimeStart.HasValue)
  6098. {
  6099. selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:OutTimeStart ";
  6100. parameters.Add(new OracleParameter(":OutTimeStart", OracleDbType.Date, se.OutTimeStart.Value, ParameterDirection.Input));
  6101. }
  6102. if (se.OutTimeEnd.HasValue)
  6103. {
  6104. selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :OutTimeEnd ";
  6105. parameters.Add(new OracleParameter(":OutTimeEnd", OracleDbType.Date, se.OutTimeEnd.Value, ParameterDirection.Input));
  6106. }
  6107. if (se.GTimeStart.HasValue)
  6108. {
  6109. selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE >=:GTimeStart ";
  6110. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  6111. }
  6112. if (se.GTimeEnd.HasValue)
  6113. {
  6114. selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE <= :GTimeEnd ";
  6115. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  6116. }
  6117. if (se.DTimeStart.HasValue)
  6118. {
  6119. selSql = selSql + " AND gdd.DELIVERTIME >=:DTimeStart ";
  6120. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
  6121. }
  6122. if (se.DTimeEnd.HasValue)
  6123. {
  6124. selSql = selSql + " AND gdd.DELIVERTIME <= :DTimeEnd ";
  6125. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
  6126. }
  6127. if (se.Specialrepairflag)
  6128. {
  6129. selSql = selSql +
  6130. " ) temp " +
  6131. " on TP_PM_ProductionData.Barcode=temp.barcode " +
  6132. " " +
  6133. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
  6134. " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
  6135. " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
  6136. " FROM TP_PM_ProductionData pp\n" +
  6137. " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
  6138. " AND pp.createtime < temp.createtime\n" +
  6139. " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
  6140. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
  6141. " where " +
  6142. // 公坯、干补不算交坯工序的质量。
  6143. // " 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" +
  6144. // modify wangx 2015-12-3
  6145. " ((TP_PM_ProductionData.modeltype <> 5) or (TP_PM_ProductionData.modeltype = 5 and TP_PM_ProductionData.SpecialRepairFlag = '0')) \n" +
  6146. " and TP_PM_ProductionData.Valueflag='1' " +
  6147. " and TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId ";
  6148. parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  6149. }
  6150. else
  6151. {
  6152. selSql = selSql +
  6153. " ) temp " +
  6154. " on TP_PM_ProductionData.Barcode=temp.barcode " +
  6155. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
  6156. " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
  6157. " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
  6158. " FROM TP_PM_ProductionData pp\n" +
  6159. " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
  6160. " AND pp.createtime < temp.createtime\n" +
  6161. " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
  6162. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
  6163. " where TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId " +
  6164. " and TP_PM_ProductionData.Valueflag='1' ";
  6165. parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  6166. }
  6167. if (se.CreateTimeStart.HasValue)
  6168. {
  6169. selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:CreateTimeStart ";
  6170. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6171. }
  6172. if (se.CreateTimeEnd.HasValue)
  6173. {
  6174. selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :CreateTimeEnd ";
  6175. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6176. }
  6177. if (!string.IsNullOrEmpty(se.GoodsIDS))
  6178. {
  6179. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  6180. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  6181. }
  6182. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  6183. {
  6184. // selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1 ";
  6185. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1 ";
  6186. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  6187. }
  6188. if (se.ProductionLineID.HasValue)
  6189. {
  6190. selSql = selSql + " AND instr(','||:productionLineId||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  6191. parameters.Add(new OracleParameter(":productionLineId", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  6192. }
  6193. //else
  6194. //{
  6195. // selSql = selSql + " AND TP_PM_ProductionData.ProductionLineId in(Select PurviewID from TP_MST_UserPurview where PurviewType= 7 and UserID = :UserID) ";
  6196. //}
  6197. 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))";
  6198. 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))";
  6199. parameters.Add(new OracleParameter(":UserID", OracleDbType.NVarchar2, user.UserID, ParameterDirection.Input));
  6200. if (!string.IsNullOrEmpty(se.RptTProcedureIDS))
  6201. {
  6202. selSql = selSql + " AND instr(','||:rptTprocedureId||',',','||TP_MST_RptTProcedure.ProcedureId||',')>0 ";
  6203. parameters.Add(new OracleParameter(":rptTprocedureId", OracleDbType.NVarchar2, se.RptTProcedureIDS, ParameterDirection.Input));
  6204. }
  6205. if (!string.IsNullOrEmpty(se.UserIDS))
  6206. {
  6207. selSql = selSql + " AND instr(','||:userIDS||',',','||TP_PM_ProductionData.Userid||',')>0 ";
  6208. parameters.Add(new OracleParameter(":userIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6209. }
  6210. if (se.KilnID.HasValue)
  6211. {
  6212. selSql = selSql + " AND temp.KilnID=:KilnID ";
  6213. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6214. }
  6215. if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
  6216. {
  6217. selSql = selSql + " AND instr(TP_PM_ProductionData.GroutingUserCode, :GroutingUserCode) > 0";
  6218. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  6219. }
  6220. selSql = selSql + " order by pcp.displayno, TP_PM_ProductionData.Usercode, temp.Kilncode,tp_mst_goodstype.goodstypename,TP_PM_ProductionData.Goodscode ) pdata" +
  6221. " 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),()) " +
  6222. ") pdata"
  6223. ;
  6224. return selSql;
  6225. }
  6226. /// <summary>
  6227. /// 取得RPT030103_1画面(出窑数量汇总表)的明细信息查询数据
  6228. /// </summary>
  6229. /// <param name="user">登录用户信息</param>
  6230. /// <param name="se">查询条件</param>
  6231. /// <returns>查询结果</returns>
  6232. public static ServiceResultEntity GetRPT030103IData(SUserInfo user, RPT030103_SE se)
  6233. {
  6234. IDBConnection conn = null;
  6235. try
  6236. {
  6237. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6238. List<OracleParameter> parameters = new List<OracleParameter>();
  6239. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030103ISQL(user, se, ref parameters));
  6240. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  6241. ServiceResultEntity sre = new ServiceResultEntity();
  6242. if (data == null || data.Rows.Count == 0)
  6243. {
  6244. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6245. return sre;
  6246. }
  6247. sre.Data = new DataSet();
  6248. sre.Data.Tables.Add(data);
  6249. return sre;
  6250. }
  6251. catch (Exception ex)
  6252. {
  6253. throw ex;
  6254. }
  6255. finally
  6256. {
  6257. if (conn != null &&
  6258. conn.ConnState == ConnectionState.Open)
  6259. {
  6260. conn.Close();
  6261. }
  6262. }
  6263. }
  6264. /// <summary>
  6265. /// 获取RPT030103_1画面(出窑数量汇总表)的明细信息查询sql
  6266. /// </summary>
  6267. /// <returns>sql</returns>
  6268. private static string GetRPT030103ISQL(SUserInfo user, RPT030103_SE se, ref List<OracleParameter> parameters)
  6269. {
  6270. string selSql = "";
  6271. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6272. parameters.Add(new OracleParameter(":rptSprocedureId", OracleDbType.Int32, se.RptSProcedureID, ParameterDirection.Input));
  6273. selSql = selSql +
  6274. "select distinct " +
  6275. "TP_PM_ProductionData.Barcode, " +
  6276. //"TP_PM_ProductionData.UserCode, " +
  6277. (se.DisPUserCode ? " TP_PM_ProductionData.userid, TP_PM_ProductionData.usercode, cu.usercode Cusercode, \n" : " null userid, null usercode, null Cusercode, \n") +
  6278. "pcp.ProcedureName, " +
  6279. "tp_mst_goodstype.goodstypename, " +
  6280. "TP_PM_ProductionData.Goodscode, " +
  6281. "TP_PM_ProductionData.GroutingUserCode, " +
  6282. "TP_PM_ProductionData.GroutingLineCode, " +
  6283. "TP_PM_ProductionData.GroutingMouldCode, " +
  6284. // 多次干补 重复条码
  6285. //"TP_PM_ProductionData.Createtime OverDate, " +
  6286. "temp.Kilnid, " +
  6287. "temp.Kilncode, " +
  6288. "temp.Kilncarcode, " +
  6289. "temp.Createtime, " +
  6290. "temp.DELIVERTIME DDate, " +
  6291. "temp.GROUTINGDATE GDate, " +
  6292. "replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName " +
  6293. "from TP_PM_ProductionData " +
  6294. "inner join tp_mst_goods on tp_mst_goods.goodsid=TP_PM_ProductionData.Goodsid " +
  6295. "inner join tp_mst_goodstype on tp_mst_goodstype.goodstypeid=tp_mst_goods.goodstypeid " +
  6296. "inner join TP_MST_RptTProcedure on TP_MST_RptTProcedure.Procedureid=TP_PM_ProductionData.Procedureid " +
  6297. "inner join TP_MST_RptProcedure on TP_MST_RptProcedure.Rptprocedureid=TP_MST_RptTProcedure.Rptprocedureid " +
  6298. " inner join tp_pc_procedure pcp on pcp.procedureid=TP_PM_ProductionData.Procedureid " +
  6299. "left join TP_MST_logo on TP_PM_ProductionData.logoid=TP_MST_logo.logoid " +
  6300. "left join TP_MST_User cu on TP_PM_ProductionData.createuserid=cu.userid " +
  6301. "inner join " +
  6302. "( " +
  6303. " select " +
  6304. " TP_PM_ProductionData.Barcode, " +
  6305. " TP_PM_ProductionData.Kilncode, " +
  6306. " TP_PM_ProductionData.Kilncarcode, " +
  6307. " TP_PM_ProductionData.Createtime, " +
  6308. " TP_PM_ProductionData.KilnID " +
  6309. " ,gdd.DELIVERTIME " +
  6310. " ,TP_PM_ProductionData.GROUTINGDATE " +
  6311. " ,TP_PM_ProductionData.KilnCarID " +
  6312. " from TP_PM_ProductionData " +
  6313. " inner join TP_MST_RptSProcedure on TP_MST_RptSProcedure.Procedureid=TP_PM_ProductionData.Procedureid " +
  6314. //if (se.DTimeStart.HasValue || se.DTimeEnd.HasValue)
  6315. //{
  6316. // selSql += " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=TP_PM_ProductionData.groutingdailydetailid ";
  6317. //}
  6318. " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=TP_PM_ProductionData.groutingdailydetailid " +
  6319. // selSql +=
  6320. " where TP_PM_ProductionData.Accountid=:AccountID " +
  6321. " and TP_PM_ProductionData.Valueflag='1' " +
  6322. // 数据重复 modify by chenxy begin
  6323. " and TP_MST_RptSProcedure.Rptprocedureid=:rptProcedureId " +
  6324. // 数据重复 modify by chenxy end
  6325. " and TP_MST_RptSProcedure.Procedureid=:rptSprocedureId ";
  6326. if (se.OutTimeStart.HasValue)
  6327. {
  6328. selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:OutTimeStart ";
  6329. parameters.Add(new OracleParameter(":OutTimeStart", OracleDbType.Date, se.OutTimeStart.Value, ParameterDirection.Input));
  6330. }
  6331. if (se.OutTimeEnd.HasValue)
  6332. {
  6333. selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :OutTimeEnd ";
  6334. parameters.Add(new OracleParameter(":OutTimeEnd", OracleDbType.Date, se.OutTimeEnd.Value, ParameterDirection.Input));
  6335. }
  6336. if (se.GTimeStart.HasValue)
  6337. {
  6338. selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE >=:GTimeStart ";
  6339. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  6340. }
  6341. if (se.GTimeEnd.HasValue)
  6342. {
  6343. selSql = selSql + " AND TP_PM_ProductionData.GROUTINGDATE <= :GTimeEnd ";
  6344. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  6345. }
  6346. if (se.DTimeStart.HasValue)
  6347. {
  6348. selSql = selSql + " AND gdd.DELIVERTIME >=:DTimeStart ";
  6349. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
  6350. }
  6351. if (se.DTimeEnd.HasValue)
  6352. {
  6353. selSql = selSql + " AND gdd.DELIVERTIME <= :DTimeEnd ";
  6354. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
  6355. }
  6356. if (se.Specialrepairflag)
  6357. {
  6358. selSql = selSql +
  6359. ") temp " +
  6360. "on TP_PM_ProductionData.Barcode=temp.barcode " +
  6361. " " +
  6362. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
  6363. " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
  6364. " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
  6365. " FROM TP_PM_ProductionData pp\n" +
  6366. " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
  6367. " AND pp.createtime < temp.createtime\n" +
  6368. " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
  6369. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
  6370. "where " + // 公坯、干补不算交坯工序的质量。
  6371. //" 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" +
  6372. // modify wangx 2015-12-3
  6373. " ((TP_PM_ProductionData.modeltype <> 5) or (TP_PM_ProductionData.modeltype = 5 and TP_PM_ProductionData.SpecialRepairFlag = '0')) \n" +
  6374. " and TP_PM_ProductionData.Valueflag='1' " +
  6375. " and TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId ";
  6376. parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  6377. }
  6378. else
  6379. {
  6380. selSql = selSql +
  6381. ") temp " +
  6382. "on TP_PM_ProductionData.Barcode=temp.barcode " +
  6383. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 begin
  6384. " and TP_PM_ProductionData.createtime <= temp.createtime\n" +
  6385. " and (TP_PM_ProductionData.MODELTYPE = 8 or (not exists (SELECT 1\n" +
  6386. " FROM TP_PM_ProductionData pp\n" +
  6387. " WHERE pp.barcode = temp.barcode and pp.createtime > TP_PM_ProductionData.createtime\n" +
  6388. " AND pp.createtime < temp.createtime\n" +
  6389. " AND pp.procedureid = TP_PM_ProductionData.Procedureid)))\n" +
  6390. // 重烧交接等工序重复统计的问题 by chenxy 2016-10-08 end
  6391. " where TP_MST_RptProcedure.Rptprocedureid=:rptProcedureId " +
  6392. " and TP_PM_ProductionData.Valueflag='1' ";
  6393. parameters.Add(new OracleParameter(":rptProcedureId", OracleDbType.Int32, se.RptProcedureID, ParameterDirection.Input));
  6394. }
  6395. if (se.CreateTimeStart.HasValue)
  6396. {
  6397. selSql = selSql + " AND TP_PM_ProductionData.CreateTime >=:CreateTimeStart ";
  6398. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6399. }
  6400. if (se.CreateTimeEnd.HasValue)
  6401. {
  6402. selSql = selSql + " AND TP_PM_ProductionData.CreateTime <= :CreateTimeEnd ";
  6403. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6404. }
  6405. if (!string.IsNullOrEmpty(se.GoodsIDS))
  6406. {
  6407. selSql = selSql + " AND instr(',' || :GoodsIDS ||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  6408. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  6409. }
  6410. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  6411. {
  6412. //selSql = selSql + " AND instr(',' || :GoodsTypeIDS ||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1 ";
  6413. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1 ";
  6414. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  6415. }
  6416. if (se.ProductionLineID.HasValue)
  6417. {
  6418. selSql = selSql + " AND instr(',' || :productionLineId ||',',','||TP_PM_ProductionData.ProductionLineId||',')>0 ";
  6419. parameters.Add(new OracleParameter(":productionLineId", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  6420. }
  6421. if (!string.IsNullOrEmpty(se.RptTProcedureIDS))
  6422. {
  6423. selSql = selSql + " AND instr(',' || :rptTprocedureIDS ||',',','||TP_MST_RptTProcedure.ProcedureId||',')>0 ";
  6424. parameters.Add(new OracleParameter(":rptTprocedureIDS", OracleDbType.NVarchar2, se.RptTProcedureIDS, ParameterDirection.Input));
  6425. }
  6426. if (!string.IsNullOrEmpty(se.UserIDS))
  6427. {
  6428. selSql = selSql + " AND instr(',' || :UserIDS ||',',','||TP_PM_ProductionData.Userid||',')>0 ";
  6429. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6430. }
  6431. if (se.KilnID.HasValue)
  6432. {
  6433. selSql = selSql + " AND temp.KilnID=:KilnID ";
  6434. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6435. }
  6436. if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
  6437. {
  6438. selSql = selSql + " AND instr(TP_PM_ProductionData.GroutingUserCode, :GroutingUserCode) > 0";
  6439. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  6440. }
  6441. selSql = selSql + " order by pcp.Procedurename,temp.Kilncode,temp.Kilncarcode, " +
  6442. (se.DisPUserCode ? " TP_PM_ProductionData.usercode, \n" : "") +
  6443. " TP_PM_ProductionData.Goodscode,TP_PM_ProductionData.Barcode ";
  6444. return selSql;
  6445. }
  6446. /// <summary>
  6447. /// 取得RPT030104_1画面(窑车产量汇总表)的窑炉汇总信息查询数据
  6448. /// </summary>
  6449. /// <param name="user">登录用户信息</param>
  6450. /// <param name="se">查询条件</param>
  6451. /// <returns>查询结果</returns>
  6452. public static ServiceResultEntity GetRPT030104SData(SUserInfo user, RPT030104_SE se)
  6453. {
  6454. IDBConnection conn = null;
  6455. try
  6456. {
  6457. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6458. List<OracleParameter> parameters = new List<OracleParameter>();
  6459. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030104SSQL(user, se, ref parameters));
  6460. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  6461. ServiceResultEntity sre = new ServiceResultEntity();
  6462. if (data == null || data.Rows.Count == 0)
  6463. {
  6464. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6465. return sre;
  6466. }
  6467. sre.Data = new DataSet();
  6468. sre.Data.Tables.Add(data);
  6469. return sre;
  6470. }
  6471. catch (Exception ex)
  6472. {
  6473. throw ex;
  6474. }
  6475. finally
  6476. {
  6477. if (conn != null &&
  6478. conn.ConnState == ConnectionState.Open)
  6479. {
  6480. conn.Close();
  6481. }
  6482. }
  6483. }
  6484. /// <summary>
  6485. /// 获取RPT030104_1画面(窑车产量汇总表)的窑炉汇总查询sql
  6486. /// </summary>
  6487. /// <returns>sql</returns>
  6488. private static string GetRPT030104SSQL(SUserInfo user, RPT030104_SE se, ref List<OracleParameter> parameters)
  6489. {
  6490. string selSql = "";
  6491. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6492. parameters.Add(new OracleParameter(":ProcedureModelTypeID", OracleDbType.Int32, se.ProcedureModelTypeID, ParameterDirection.Input));
  6493. selSql = "select " +
  6494. "decode(Createtime,'小计',decode(Proceduremodeltypename,'总计','总计','--'),Proceduremodeltypename) Proceduremodeltypename, " +
  6495. "decode(usercode,'合计',decode(Kilncode,'--','--','合计'),decode(createtime,'小计','--',Kilncode)) Kilncode, " +
  6496. "decode(Createtime,'小计',decode(usercode,'合计','--','小计'),Usercode) Usercode, " +
  6497. "decode(Kilncarcode,'--','--',Createtime) Createtime, " +
  6498. "Kilncarcode, " +
  6499. "Remarks, " +
  6500. "KilnCarCount " +
  6501. " from " +
  6502. " ( " +
  6503. " select " +
  6504. " decode(grouping(TP_SYS_ProcedureModelType.Proceduremodeltypename),1,'总计',TP_SYS_ProcedureModelType.Proceduremodeltypename) Proceduremodeltypename, " +
  6505. " decode(grouping(TP_MST_Kiln.Kilncode),1,'--',TP_MST_Kiln.Kilncode) Kilncode, " +
  6506. " decode(grouping(TP_PM_KilnCarData.Usercode),1,'合计',TP_PM_KilnCarData.Usercode) Usercode, " +
  6507. " decode(grouping(TP_MST_KilnCar.Kilncarcode),1,'--',TP_MST_KilnCar.Kilncarcode) Kilncarcode, " +
  6508. " decode(grouping(TP_PM_KilnCarData.Remarks),1,'--',TP_PM_KilnCarData.Remarks) Remarks, " +
  6509. " decode(grouping(TP_PM_KilnCarData.Createtime),1,'小计',TP_PM_KilnCarData.Createtime) Createtime, " +
  6510. " count(TP_PM_KilnCarData.Kilncarid) as KilnCarCount " +
  6511. " from " +
  6512. " ( " +
  6513. " select " +
  6514. " to_char(TP_PM_KilnCarData.Createtime,'yyyy-mm-dd hh24:mi') Createtime, " +
  6515. " TP_PM_KilnCarData.Modeltype, " +
  6516. " TP_PM_KilnCarData.Kilncarid, " +
  6517. " TP_PM_KilnCarData.Kilnid, " +
  6518. " TP_PM_KilnCarData.Userid, " +
  6519. " TP_PM_KilnCarData.Remarks, " +
  6520. " TP_PM_KilnCarData.Accountid, " +
  6521. " TP_PM_KilnCarData.Usercode " +
  6522. " from TP_PM_KilnCarData " +
  6523. " left join TP_MST_KilnCar kc on kc.kilncarid = TP_PM_KilnCarData.Kilncarid " +
  6524. " where TP_PM_KilnCarData.Accountid=:AccountID " +
  6525. " and TP_PM_KilnCarData.Valueflag=1 " +
  6526. " and TP_PM_KilnCarData.Modeltype=:ProcedureModelTypeID ";
  6527. if (se.KilnID.HasValue)
  6528. {
  6529. selSql = selSql + " AND TP_PM_KilnCarData.KilnID=:KilnID ";
  6530. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6531. }
  6532. //if (se.KilnCarID.HasValue)
  6533. //{
  6534. // selSql = selSql + " AND TP_PM_KilnCarData.KilnCarID=:KilnCarID";
  6535. // parameters.Add(new OracleParameter(":KilnCarID", OracleDbType.Int32, se.KilnCarID, ParameterDirection.Input));
  6536. //}
  6537. if (!string.IsNullOrEmpty(se.KilnCarCode))
  6538. {
  6539. selSql = selSql + " AND instr(kc.KilnCarCode, :KilnCarCode ) > 0";
  6540. parameters.Add(new OracleParameter(":KilnCarCode", OracleDbType.NVarchar2, se.KilnCarCode, ParameterDirection.Input));
  6541. }
  6542. if (se.KilnCarNumBegin.HasValue && se.KilnCarNumEnd.HasValue && se.KilnCarNumBegin.Value > se.KilnCarNumEnd.Value)
  6543. {
  6544. selSql = selSql + " AND (kc.KilnCarNum >= :KilnCarNumBegin or kc.KilnCarNum <= :KilnCarNumEnd)";
  6545. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6546. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6547. }
  6548. else
  6549. {
  6550. if (se.KilnCarNumBegin.HasValue)
  6551. {
  6552. selSql = selSql + " AND kc.KilnCarNum >= :KilnCarNumBegin ";
  6553. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6554. }
  6555. if (se.KilnCarNumEnd.HasValue)
  6556. {
  6557. selSql = selSql + " AND kc.KilnCarNum <= :KilnCarNumEnd ";
  6558. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6559. }
  6560. }
  6561. if (se.CreateTimeStart.HasValue)
  6562. {
  6563. selSql = selSql + " AND TP_PM_KilnCarData.CreateTime>=:CreateTimeStart ";
  6564. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6565. }
  6566. if (se.CreateTimeEnd.HasValue)
  6567. {
  6568. selSql = selSql + " AND TP_PM_KilnCarData.CreateTime<= :CreateTimeEnd";
  6569. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6570. }
  6571. selSql = selSql +
  6572. " ) TP_PM_KilnCarData " +
  6573. "inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.Proceduremodeltypeid=TP_PM_KilnCarData.Modeltype " +
  6574. "inner join TP_MST_KilnCar on TP_MST_KilnCar.Kilncarid=TP_PM_KilnCarData.Kilncarid " +
  6575. "inner join TP_MST_Kiln on TP_MST_Kiln.Kilnid=TP_PM_KilnCarData.Kilnid " +
  6576. "where 1=1";
  6577. if (!string.IsNullOrEmpty(se.UserIDS))
  6578. {
  6579. selSql = selSql + " AND instr(','||:UserIDS||',',','||TP_PM_KilnCarData.UserID||',')>0";
  6580. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6581. }
  6582. selSql = selSql + "group by rollup( " +
  6583. " TP_SYS_ProcedureModelType.Proceduremodeltypename, " +
  6584. " TP_MST_Kiln.Kilncode, " +
  6585. " TP_PM_KilnCarData.Usercode, " +
  6586. " TP_PM_KilnCarData.Createtime, " +
  6587. " TP_PM_KilnCarData.Remarks, " +
  6588. " TP_MST_KilnCar.Kilncarcode " +
  6589. " ) " +
  6590. " ) temp " +
  6591. " where (Kilncarcode !='--' ) " +
  6592. " or " +
  6593. " (Remarks='--' and Usercode='合计' and kilncode!='--') " +
  6594. " or (Remarks='--' and Proceduremodeltypename='总计') " +
  6595. " or (Remarks='--' and createtime='小计' and kilncode!='--')";
  6596. return selSql;
  6597. }
  6598. /// <summary>
  6599. /// 取得RPT030104_1画面(窑车产量汇总表)的窑车产量汇总信息查询数据
  6600. /// </summary>
  6601. /// <param name="user">登录用户信息</param>
  6602. /// <param name="se">查询条件</param>
  6603. /// <returns>查询结果</returns>
  6604. public static ServiceResultEntity GetRPT030104IData(SUserInfo user, RPT030104_SE se)
  6605. {
  6606. IDBConnection conn = null;
  6607. try
  6608. {
  6609. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6610. List<OracleParameter> parameters = new List<OracleParameter>();
  6611. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030104ISQL(user, se, ref parameters));
  6612. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  6613. ServiceResultEntity sre = new ServiceResultEntity();
  6614. if (data == null || data.Rows.Count == 0)
  6615. {
  6616. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6617. return sre;
  6618. }
  6619. sre.Data = new DataSet();
  6620. sre.Data.Tables.Add(data);
  6621. return sre;
  6622. }
  6623. catch (Exception ex)
  6624. {
  6625. throw ex;
  6626. }
  6627. finally
  6628. {
  6629. if (conn != null &&
  6630. conn.ConnState == ConnectionState.Open)
  6631. {
  6632. conn.Close();
  6633. }
  6634. }
  6635. }
  6636. /// <summary>
  6637. /// 获取查询sql
  6638. /// </summary>
  6639. /// <returns>sql</returns>
  6640. private static string GetRPT030104ISQL(SUserInfo user, RPT030104_SE se, ref List<OracleParameter> parameters)
  6641. {
  6642. string selSql = "";
  6643. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6644. parameters.Add(new OracleParameter(":ProcedureModelTypeID", OracleDbType.Int32, se.ProcedureModelTypeID, ParameterDirection.Input));
  6645. selSql = selSql +
  6646. "SELECT " +
  6647. "decode(createtime,'小计',decode(proceduremodeltypename,'总计','总计','--'),proceduremodeltypename) proceduremodeltypename, " +
  6648. "decode(createtime,'小计','--',kilncode) kilncode, " +
  6649. "decode(kilncarcode,'合计',decode(usercode,'--','--','合计'),decode(createtime,'小计','--',usercode)) usercode, " +
  6650. "decode(createtime,'小计',decode(kilncarcode,'合计','--','小计'),kilncarcode) kilncarcode, " +
  6651. "decode(goodscode,'--','--',createtime) createtime, " +
  6652. "GOODSTYPENAME, " +
  6653. "Goodscode, " +
  6654. "GOODSSPECIFICATION, " +
  6655. "GoodsCount " +
  6656. "from " +
  6657. "( " +
  6658. " SELECT " +
  6659. " decode(grouping(TP_SYS_ProcedureModelType.Proceduremodeltypename),1,'总计',TP_SYS_ProcedureModelType.Proceduremodeltypename) Proceduremodeltypename, " +
  6660. " decode(grouping(TP_PM_ProductionData.Kilncode),1,'--',TP_PM_ProductionData.Kilncode) Kilncode, " +
  6661. " decode(grouping(TP_PM_ProductionData.Usercode),1,'--',TP_PM_ProductionData.Usercode) Usercode, " +
  6662. " decode(grouping(TP_MST_KilnCar.Kilncarcode),1,'合计',TP_MST_KilnCar.Kilncarcode) Kilncarcode, " +
  6663. " decode(grouping(TP_PM_ProductionData.CreateTime),1,'小计',TP_PM_ProductionData.CreateTime) CreateTime, " +
  6664. " decode(grouping(TP_MST_Goods.Goodscode),1,'--',TP_MST_Goods.Goodscode) Goodscode, " +
  6665. " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  6666. " decode(grouping(TP_MST_GOODSTYPE.GOODSTYPENAME),1,'--',TP_MST_GOODSTYPE.GOODSTYPENAME) GOODSTYPENAME, " +
  6667. " count(TP_MST_Goods.Goodscode) as GoodsCount " +
  6668. " from " +
  6669. " ( " +
  6670. " SELECT TP_PM_ProductionData.Modeltype, " +
  6671. " TP_PM_ProductionData.Goodsid, " +
  6672. " TP_PM_ProductionData.KilnCarID, " +
  6673. " TP_PM_ProductionData.Kilncode, " +
  6674. //" TP_PM_ProductionData.Usercode, " +
  6675. " kcd.Usercode, " +
  6676. " to_char(kcd.CreateTime,'yyyy-mm-dd hh24:mi') CreateTime " +
  6677. " from TP_PM_ProductionData " +
  6678. " left join TP_PM_KilnCarData kcd on kcd.KilnCarBatchNo = TP_PM_ProductionData.KilnCarBatchNo and kcd.ProcedureID = TP_PM_ProductionData.ProcedureID " +
  6679. " where " +
  6680. " TP_PM_ProductionData.Accountid=:AccountID " +
  6681. " and TP_PM_ProductionData.Valueflag=1 " +
  6682. " and TP_PM_ProductionData.Modeltype= :ProcedureModelTypeID ";
  6683. if (se.KilnID.HasValue)
  6684. {
  6685. selSql = selSql + " AND TP_PM_ProductionData.KilnID=:KilnID ";
  6686. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6687. }
  6688. //if (se.KilnCarID.HasValue)
  6689. //{
  6690. // selSql = selSql + " AND TP_PM_ProductionData.KilnCarID=:KilnCarID";
  6691. // parameters.Add(new OracleParameter(":KilnCarID", OracleDbType.Int32, se.KilnCarID, ParameterDirection.Input));
  6692. //}
  6693. if (!string.IsNullOrEmpty(se.GoodsIDS))
  6694. {
  6695. selSql = selSql + " AND instr(','||:goodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  6696. parameters.Add(new OracleParameter(":goodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  6697. }
  6698. if (!string.IsNullOrEmpty(se.UserIDS))
  6699. {
  6700. //selSql = selSql + " AND instr(','||:UserIDS||',',','||TP_PM_ProductionData.UserID||',')>0 ";
  6701. selSql = selSql + " AND instr(','||:UserIDS||',',','||kcd.UserID||',')>0 ";
  6702. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6703. }
  6704. if (se.CreateTimeStart.HasValue)
  6705. {
  6706. //selSql = selSql + " AND TP_PM_ProductionData.CreateTime>= :CreateTimeStart ";
  6707. selSql = selSql + " AND kcd.CreateTime>= :CreateTimeStart ";
  6708. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6709. }
  6710. if (se.CreateTimeEnd.HasValue)
  6711. {
  6712. //selSql = selSql + " AND TP_PM_ProductionData.CreateTime<= :CreateTimeEnd ";
  6713. selSql = selSql + " AND kcd.CreateTime<= :CreateTimeEnd ";
  6714. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6715. }
  6716. selSql = selSql +
  6717. " ) TP_PM_ProductionData " +
  6718. " inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.Proceduremodeltypeid=TP_PM_ProductionData.Modeltype " +
  6719. " inner join TP_MST_Goods on TP_MST_Goods.Goodsid=TP_PM_ProductionData.Goodsid " +
  6720. " inner join TP_MST_GOODSTYPE on TP_MST_GOODSTYPE.GOODSTYPEID=TP_MST_Goods.Goodstypeid " +
  6721. " inner join TP_MST_KilnCar on TP_MST_KilnCar.Kilncarid=TP_PM_ProductionData.KilnCarID " +
  6722. " where 1=1 ";
  6723. if (!string.IsNullOrEmpty(se.KilnCarCode))
  6724. {
  6725. selSql = selSql + " AND instr(TP_MST_KilnCar.KilnCarCode, :KilnCarCode ) > 0";
  6726. parameters.Add(new OracleParameter(":KilnCarCode", OracleDbType.NVarchar2, se.KilnCarCode, ParameterDirection.Input));
  6727. }
  6728. if (se.KilnCarNumBegin.HasValue && se.KilnCarNumEnd.HasValue && se.KilnCarNumBegin.Value > se.KilnCarNumEnd.Value)
  6729. {
  6730. selSql = selSql + " AND (TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin or TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd)";
  6731. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6732. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6733. }
  6734. else
  6735. {
  6736. if (se.KilnCarNumBegin.HasValue)
  6737. {
  6738. selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin ";
  6739. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6740. }
  6741. if (se.KilnCarNumEnd.HasValue)
  6742. {
  6743. selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd ";
  6744. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6745. }
  6746. }
  6747. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  6748. {
  6749. //selSql = selSql + " AND instr(','||:goodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1";
  6750. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:goodsTypeIDS)=1";
  6751. parameters.Add(new OracleParameter(":goodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  6752. }
  6753. selSql = selSql +
  6754. " group by rollup( " +
  6755. " TP_SYS_ProcedureModelType.Proceduremodeltypename, " +
  6756. " TP_PM_ProductionData.Kilncode, " +
  6757. " TP_PM_ProductionData.Usercode, " +
  6758. " TP_MST_KilnCar.Kilncarcode, " +
  6759. " TP_PM_ProductionData.CreateTime, " +
  6760. " TP_MST_GOODSTYPE.GOODSTYPENAME, " +
  6761. " TP_MST_Goods.GOODSSPECIFICATION, " +
  6762. " TP_MST_Goods.Goodscode " +
  6763. " ) " +
  6764. ") temp " +
  6765. "where 1=1 and " +
  6766. " (Goodscode !='--' ) or " +
  6767. " (Goodscode='--' and Usercode='合计' and kilncode!='--') or " +
  6768. " (Goodscode='--' and Proceduremodeltypename='总计') or " +
  6769. " (Goodscode='--' and createtime='小计' and usercode!='--')";
  6770. return selSql;
  6771. }
  6772. /// <summary>
  6773. /// 取得RPT030104_1画面(窑车产量汇总表)的窑车产量明细信息查询数据
  6774. /// </summary>
  6775. /// <param name="user">登录用户信息</param>
  6776. /// <param name="se">查询条件</param>
  6777. /// <returns>查询结果</returns>
  6778. public static ServiceResultEntity GetRPT030104UData(SUserInfo user, RPT030104_SE se)
  6779. {
  6780. IDBConnection conn = null;
  6781. try
  6782. {
  6783. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6784. List<OracleParameter> parameters = new List<OracleParameter>();
  6785. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030104USQL(user, se, ref parameters));
  6786. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  6787. ServiceResultEntity sre = new ServiceResultEntity();
  6788. if (data == null || data.Rows.Count == 0)
  6789. {
  6790. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6791. return sre;
  6792. }
  6793. sre.Data = new DataSet();
  6794. sre.Data.Tables.Add(data);
  6795. return sre;
  6796. }
  6797. catch (Exception ex)
  6798. {
  6799. throw ex;
  6800. }
  6801. finally
  6802. {
  6803. if (conn != null &&
  6804. conn.ConnState == ConnectionState.Open)
  6805. {
  6806. conn.Close();
  6807. }
  6808. }
  6809. }
  6810. /// <summary>
  6811. /// 获取RPT030104_1画面(窑车产量汇总表)的窑车产量明细查询sql
  6812. /// </summary>
  6813. /// <returns>sql</returns>
  6814. private static string GetRPT030104USQL(SUserInfo user, RPT030104_SE se, ref List<OracleParameter> parameters)
  6815. {
  6816. string selSql = "";
  6817. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6818. parameters.Add(new OracleParameter(":ProcedureModelTypeID", OracleDbType.Int32, se.ProcedureModelTypeID, ParameterDirection.Input));
  6819. selSql = selSql +
  6820. "select " +
  6821. "decode(createtime,'小计',decode(proceduremodeltypename,'总计','总计','--'),proceduremodeltypename) proceduremodeltypename, " +
  6822. "decode(createtime,'小计','--',kilncode) kilncode, " +
  6823. "decode(kilncarcode,'合计',decode(usercode,'--','--','合计'),decode(createtime,'小计','--',usercode)) usercode, " +
  6824. "decode(createtime,'小计',decode(kilncarcode,'合计','--','小计'),kilncarcode) kilncarcode, " +
  6825. "decode(goodscode,'--','--',createtime) createtime, " +
  6826. "GOODSTYPENAME, " +
  6827. "Goodscode, " +
  6828. "GOODSSPECIFICATION, " +
  6829. "Barcode, " +
  6830. "BarcodeCount, " +
  6831. "LogoCodeName " +
  6832. "from " +
  6833. " ( " +
  6834. " select " +
  6835. " decode(grouping(TP_SYS_ProcedureModelType.Proceduremodeltypename),1,'总计',TP_SYS_ProcedureModelType.Proceduremodeltypename) Proceduremodeltypename, " +
  6836. " decode(grouping(TP_PM_ProductionData.Kilncode),1,'--',TP_PM_ProductionData.Kilncode) Kilncode, " +
  6837. " decode(grouping(TP_PM_ProductionData.Usercode),1,'--',TP_PM_ProductionData.Usercode) Usercode, " +
  6838. " decode(grouping(TP_MST_KilnCar.Kilncarcode),1,'合计',TP_MST_KilnCar.Kilncarcode) Kilncarcode, " +
  6839. " decode(grouping(TP_PM_ProductionData.CreateTime),1,'小计',TP_PM_ProductionData.CreateTime) CreateTime, " +
  6840. " decode(grouping(TP_MST_GOODSTYPE.GOODSTYPENAME),1,'--',TP_MST_GOODSTYPE.GOODSTYPENAME) GOODSTYPENAME, " +
  6841. " decode(grouping(TP_MST_Goods.Goodscode),1,'--',TP_MST_Goods.Goodscode) Goodscode, " +
  6842. " decode(grouping(TP_MST_Goods.GOODSSPECIFICATION),1,'--',TP_MST_Goods.GOODSSPECIFICATION) GOODSSPECIFICATION, " +
  6843. " decode(grouping(TP_PM_ProductionData.Barcode),1,'--',TP_PM_ProductionData.Barcode) Barcode, " +
  6844. " decode(grouping(TP_PM_ProductionData.LogoCodeName),1,'--',TP_PM_ProductionData.LogoCodeName) LogoCodeName, " +
  6845. " count(TP_PM_ProductionData.Barcode) as BarcodeCount " +
  6846. " from " +
  6847. " ( " +
  6848. " select TP_PM_ProductionData.logoid," +
  6849. " TP_PM_ProductionData.Modeltype, " +
  6850. " TP_PM_ProductionData.Goodsid, " +
  6851. " TP_PM_ProductionData.KilnCarID, " +
  6852. " TP_PM_ProductionData.Kilncode, " +
  6853. " TP_PM_ProductionData.Barcode, " +
  6854. " TP_PM_ProductionData.Usercode, " +
  6855. " replace((Logoname||'['||Logocode||']'),'[]','') as LogoCodeName, " +
  6856. " to_char(TP_PM_ProductionData.CreateTime,'yyyy-mm-dd hh24:mi') CreateTime " +
  6857. " from TP_PM_ProductionData inner join TP_MST_Logo on TP_PM_ProductionData.logoid=TP_MST_Logo.logoid" +
  6858. " left join TP_PM_KilnCarData kcd on kcd.KilnCarBatchNo = TP_PM_ProductionData.KilnCarBatchNo and kcd.ProcedureID = TP_PM_ProductionData.ProcedureID " +
  6859. " where " +
  6860. " TP_PM_ProductionData.Accountid=:AccountID " +
  6861. " and TP_PM_ProductionData.Valueflag=1 " +
  6862. " and TP_PM_ProductionData.Modeltype=:ProcedureModelTypeID ";
  6863. if (se.KilnID.HasValue)
  6864. {
  6865. selSql = selSql + " AND TP_PM_ProductionData.KilnID=:KilnID ";
  6866. parameters.Add(new OracleParameter(":KilnID", OracleDbType.Int32, se.KilnID, ParameterDirection.Input));
  6867. }
  6868. //if (se.KilnCarID.HasValue)
  6869. //{
  6870. // selSql = selSql + " AND TP_PM_ProductionData.KilnCarID=:KilnCarID ";
  6871. // parameters.Add(new OracleParameter(":KilnCarID", OracleDbType.Int32, se.KilnCarID, ParameterDirection.Input));
  6872. //}
  6873. if (!string.IsNullOrEmpty(se.GoodsIDS))
  6874. {
  6875. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_ProductionData.GoodsId||',')>0 ";
  6876. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  6877. }
  6878. if (!string.IsNullOrEmpty(se.UserIDS))
  6879. {
  6880. selSql = selSql + " AND instr(','||:UserIDS||',',','||kcd.UserID||',')>0 ";
  6881. parameters.Add(new OracleParameter(":UserIDS", OracleDbType.NVarchar2, se.UserIDS, ParameterDirection.Input));
  6882. }
  6883. if (se.CreateTimeStart.HasValue)
  6884. {
  6885. selSql = selSql + " AND kcd.CreateTime>= :CreateTimeStart ";
  6886. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  6887. }
  6888. if (se.CreateTimeEnd.HasValue)
  6889. {
  6890. selSql = selSql + " AND kcd.CreateTime<= :CreateTimeEnd ";
  6891. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  6892. }
  6893. selSql = selSql +
  6894. " ) TP_PM_ProductionData " +
  6895. " inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.Proceduremodeltypeid=TP_PM_ProductionData.Modeltype " +
  6896. " inner join TP_MST_Goods on TP_MST_Goods.Goodsid=TP_PM_ProductionData.Goodsid " +
  6897. " inner join TP_MST_GOODSTYPE on TP_MST_GOODSTYPE.GOODSTYPEID=TP_MST_Goods.Goodstypeid " +
  6898. " inner join TP_MST_KilnCar on TP_MST_KilnCar.Kilncarid=TP_PM_ProductionData.KilnCarID " +
  6899. " where 1=1";
  6900. if (!string.IsNullOrEmpty(se.KilnCarCode))
  6901. {
  6902. selSql = selSql + " AND instr(TP_MST_KilnCar.KilnCarCode, :KilnCarCode ) > 0";
  6903. parameters.Add(new OracleParameter(":KilnCarCode", OracleDbType.NVarchar2, se.KilnCarCode, ParameterDirection.Input));
  6904. }
  6905. if (se.KilnCarNumBegin.HasValue && se.KilnCarNumEnd.HasValue && se.KilnCarNumBegin.Value > se.KilnCarNumEnd.Value)
  6906. {
  6907. selSql = selSql + " AND (TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin or TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd)";
  6908. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6909. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6910. }
  6911. else
  6912. {
  6913. if (se.KilnCarNumBegin.HasValue)
  6914. {
  6915. selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum >= :KilnCarNumBegin ";
  6916. parameters.Add(new OracleParameter(":KilnCarNumBegin", OracleDbType.Int32, se.KilnCarNumBegin, ParameterDirection.Input));
  6917. }
  6918. if (se.KilnCarNumEnd.HasValue)
  6919. {
  6920. selSql = selSql + " AND TP_MST_KilnCar.KilnCarNum <= :KilnCarNumEnd ";
  6921. parameters.Add(new OracleParameter(":KilnCarNumEnd", OracleDbType.Int32, se.KilnCarNumEnd, ParameterDirection.Input));
  6922. }
  6923. }
  6924. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  6925. {
  6926. //selSql = selSql + " AND instr(','||:goodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1 ";
  6927. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:goodsTypeIDS)=1 ";
  6928. parameters.Add(new OracleParameter(":goodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  6929. }
  6930. selSql = selSql +
  6931. " group by rollup( " +
  6932. " TP_SYS_ProcedureModelType.Proceduremodeltypename, " +
  6933. " TP_PM_ProductionData.Kilncode, " +
  6934. " TP_PM_ProductionData.Usercode, " +
  6935. " TP_MST_KilnCar.Kilncarcode, " +
  6936. " TP_PM_ProductionData.CreateTime, " +
  6937. " TP_MST_GOODSTYPE.GOODSTYPENAME, " +
  6938. " TP_MST_Goods.Goodscode, " +
  6939. " TP_MST_Goods.GOODSSPECIFICATION, " +
  6940. " TP_PM_ProductionData.Barcode, " +
  6941. " TP_PM_ProductionData.LogoCodeName " +
  6942. " ) " +
  6943. " ) temp " +
  6944. "where 1=1 and " +
  6945. "(Barcode !='--' and LogoCodeName!='--') or " +
  6946. "(Barcode='--' and Usercode='合计' and kilncode!='--') or " +
  6947. "(Barcode='--' and Proceduremodeltypename='总计' ) or " +
  6948. "(Barcode='--' and createtime='小计' and temp.usercode!='--')";
  6949. return selSql;
  6950. }
  6951. #region 工序交接数量汇总表
  6952. /// <summary>
  6953. /// 取得RPT030107画面(工序交接数量汇总表)的汇总信息查询数据
  6954. /// </summary>
  6955. /// <param name="user">登录用户信息</param>
  6956. /// <param name="se">查询条件</param>
  6957. /// <returns>查询结果</returns>
  6958. public static ServiceResultEntity GetRPT030107SData(SUserInfo user, RPT030107_SE se)
  6959. {
  6960. IDBConnection conn = null;
  6961. try
  6962. {
  6963. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  6964. List<OracleParameter> parameters = new List<OracleParameter>();
  6965. string sql = ReportModuleLogic.GetRPT030107SSQL(user, se, ref parameters);
  6966. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  6967. ServiceResultEntity sre = new ServiceResultEntity();
  6968. if (data == null || data.Rows.Count == 0)
  6969. {
  6970. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  6971. return sre;
  6972. }
  6973. sre.Data = new DataSet();
  6974. sre.Data.Tables.Add(data);
  6975. return sre;
  6976. }
  6977. catch (Exception ex)
  6978. {
  6979. throw ex;
  6980. }
  6981. finally
  6982. {
  6983. if (conn != null &&
  6984. conn.ConnState == ConnectionState.Open)
  6985. {
  6986. conn.Close();
  6987. }
  6988. }
  6989. }
  6990. /// <summary>
  6991. /// 获取RPT030107画面(工序交接数量汇总表)的汇总信息查询sql
  6992. /// </summary>
  6993. /// <returns>sql</returns>
  6994. private static string GetRPT030107SSQL(SUserInfo user, RPT030107_SE se, ref List<OracleParameter> parameters)
  6995. {
  6996. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  6997. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  6998. string sqlString =
  6999. "SELECT p.procedureid\n" +
  7000. " ,decode(gid,\n" +
  7001. " 7,\n" +
  7002. " '总计',\n" +
  7003. " 3,\n" +
  7004. " '合计【' || p.procedurename || '】',\n" +
  7005. " 1,\n" +
  7006. " '--',\n" +
  7007. " p.procedurename) procedurename\n" +
  7008. " ,decode(gid,\n" +
  7009. " 7,\n" +
  7010. " '--',\n" +
  7011. " 3,\n" +
  7012. " '--',\n" +
  7013. " 1,\n" +
  7014. " '小计【' || p.goodstypename2 || '】',\n" +
  7015. " p.goodstypename2) goodstypename2\n" +
  7016. " ,p.goodstypecode2 \n" +
  7017. " ,decode(gid, 0, p.userid, '--') userid\n" +
  7018. " ,decode(gid, 0, p.usercode, '--') usercode\n" +
  7019. " ,decode(gid, 0, p.goodsid, '--') goodsid\n" +
  7020. " ,decode(gid, 0, p.goodscode, '--') goodscode\n" +
  7021. " ,decode(gid, 0, p.goodstypename, '--') goodstypename\n" +
  7022. " ,p.overcount\n" +
  7023. " FROM (SELECT grouping_id(pdata.Procedureid,pdata.goodstypename2, pdata.Userid) gid\n" +
  7024. " ,pdata.productionlineid\n" +
  7025. " ,pdata.procedureid\n" +
  7026. " ,to_char(pdata.procedurename) procedurename\n" +
  7027. " ,to_char(pdata.userid) userid\n" +
  7028. " ,pdata.usercode\n" +
  7029. " ,to_char(pdata.goodsid) goodsid\n" +
  7030. " ,pdata.goodscode\n" +
  7031. " ,pdata.goodstypename\n" +
  7032. " ,pdata.goodstypecode2\n" +
  7033. " ,pdata.goodstypename2\n" +
  7034. " ,COUNT(pdata.barcode) overcount\n" +
  7035. " FROM (SELECT distinct pd.barcode,pcp.displayno\n" +
  7036. " ,pd.productionlineid\n" +
  7037. " ,pd.procedureid\n" +
  7038. " ,pcp.procedurename\n" +
  7039. (se.DisPUserCode ? " ,pd.userid, pd.usercode \n" : " ,null userid, null usercode \n") +
  7040. //" ,pd.userid\n" +
  7041. //" ,pd.usercode\n" +
  7042. " ,t_over.goodsid\n" +
  7043. " ,t_over.goodscode\n" +
  7044. " ,t_over.goodstypename\n" +
  7045. " ,t_over.goodstypecode2\n" +
  7046. " ,t_over.goodstypename2\n" +
  7047. " FROM tp_pm_productiondata pd\n" +
  7048. " LEFT JOIN tp_pc_procedure pcp\n" +
  7049. " ON pcp.procedureid = pd.procedureid\n" +
  7050. " INNER JOIN (SELECT DISTINCT pd.barcode\n" +
  7051. " ,pd.productiondataid\n" +
  7052. " ,goods.goodsid\n" +
  7053. " ,goods.goodscode\n" +
  7054. " ,gt.goodstypename\n" +
  7055. " ,gt2.goodstypename goodstypename2\n" +
  7056. " ,gt2.goodstypecode goodstypecode2\n" +
  7057. " FROM tp_pm_productiondata pd\n" +
  7058. " LEFT JOIN tp_mst_goods goods\n" +
  7059. " ON goods.goodsid = pd.goodsid\n" +
  7060. " LEFT JOIN tp_mst_goodstype gt\n" +
  7061. " ON goods.goodstypeid = gt.goodstypeid\n" +
  7062. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7063. " ON gt2.goodstypecode = substr(gt.goodstypecode,1,6)\n" +
  7064. " AND gt2.accountid = gt.accountid\n" +
  7065. " --LEFT JOIN tp_pc_procedure pcp\n" +
  7066. " -- ON pcp.procedureid = pd.procedureid\n" +
  7067. ((se.DTimeStart.HasValue || se.DTimeEnd.HasValue) ? " inner join tp_pm_groutingdailydetail gdd on gdd.groutingdailydetailid=pd.groutingdailydetailid \n" : "") +
  7068. " WHERE pd.valueflag = '1'\n" +
  7069. " 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))" +
  7070. " AND pd.accountid = :AccountID\n";
  7071. // 生产线
  7072. if (se.ProductionLineID.HasValue)
  7073. {
  7074. sqlString = sqlString + " AND pd.productionlineid = :productionlineid ";
  7075. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  7076. }
  7077. // 成型工号
  7078. if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
  7079. {
  7080. sqlString = sqlString + " AND instr(pd.GroutingUserCode, :GroutingUserCode) > 0";
  7081. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  7082. }
  7083. // 产品型号
  7084. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  7085. {
  7086. sqlString = sqlString + " AND instr(gt.GOODSTYPECode, :GoodsTypeCode)=1 ";
  7087. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7088. }
  7089. // 产品编码
  7090. if (!string.IsNullOrEmpty(se.GoodsCode))
  7091. {
  7092. sqlString = sqlString + " AND instr(goods.GOODSCode, :GoodsCode) > 0 ";
  7093. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7094. }
  7095. // 交接工序
  7096. if (!string.IsNullOrEmpty(se.OverProcedureIDS))
  7097. {
  7098. sqlString = sqlString + " AND instr(:overprocedureids, ','||pd.procedureid||',')>0 ";
  7099. parameters.Add(new OracleParameter(":overprocedureids", OracleDbType.Varchar2, "," + se.OverProcedureIDS + ",", ParameterDirection.Input));
  7100. }
  7101. // 交接工号
  7102. if (!string.IsNullOrEmpty(se.OverUserIDS))
  7103. {
  7104. sqlString = sqlString + " AND instr(:overuserids, ','||pd.userid||',')>0 ";
  7105. parameters.Add(new OracleParameter(":overuserids", OracleDbType.Varchar2, "," + se.OverUserIDS + ",", ParameterDirection.Input));
  7106. }
  7107. // 交接时间
  7108. if (se.OverTimeStart.HasValue)
  7109. {
  7110. sqlString = sqlString + " AND pd.CreateTime >=:OverTimeStart ";
  7111. parameters.Add(new OracleParameter(":OverTimeStart", OracleDbType.Date, se.OverTimeStart.Value, ParameterDirection.Input));
  7112. }
  7113. if (se.OverTimeEnd.HasValue)
  7114. {
  7115. sqlString = sqlString + " AND pd.CreateTime <= :OverTimeEnd ";
  7116. parameters.Add(new OracleParameter(":OverTimeEnd", OracleDbType.Date, se.OverTimeEnd.Value, ParameterDirection.Input));
  7117. }
  7118. // 注浆时间
  7119. if (se.GTimeStart.HasValue)
  7120. {
  7121. sqlString = sqlString + " AND pd.GROUTINGDATE >=:GTimeStart ";
  7122. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  7123. }
  7124. if (se.GTimeEnd.HasValue)
  7125. {
  7126. sqlString = sqlString + " AND pd.GROUTINGDATE <= :GTimeEnd ";
  7127. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  7128. }
  7129. // 交坯时间
  7130. if (se.DTimeStart.HasValue)
  7131. {
  7132. sqlString = sqlString + " AND gdd.DELIVERTIME >=:DTimeStart ";
  7133. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
  7134. }
  7135. if (se.DTimeEnd.HasValue)
  7136. {
  7137. sqlString = sqlString + " AND gdd.DELIVERTIME <= :DTimeEnd ";
  7138. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
  7139. }
  7140. sqlString = sqlString +
  7141. " ) t_over\n" +
  7142. " ON pd.barcode = t_over.barcode\n" +
  7143. // 交接工序在生产工序后
  7144. " AND pd.productiondataid <= t_over.productiondataid\n" +
  7145. " WHERE pd.valueflag = '1'\n" +
  7146. " AND pd.accountid = :AccountID\n" +
  7147. (se.Specialrepairflag ? " AND ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" : "") +
  7148. " 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))";
  7149. // 生产工序
  7150. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  7151. {
  7152. sqlString = sqlString + " AND instr(:procedureids, ','||pd.procedureid||',')>0 ";
  7153. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  7154. }
  7155. // 生产工号
  7156. if (!string.IsNullOrEmpty(se.UserIDS))
  7157. {
  7158. sqlString = sqlString + " AND instr(:userids, ','||pd.userid||',')>0 ";
  7159. parameters.Add(new OracleParameter(":userids", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
  7160. }
  7161. // 生产时间
  7162. if (se.PTimeStart.HasValue)
  7163. {
  7164. sqlString = sqlString + " AND pd.CreateTime >=:PTimeStart ";
  7165. parameters.Add(new OracleParameter(":PTimeStart", OracleDbType.Date, se.PTimeStart.Value, ParameterDirection.Input));
  7166. }
  7167. if (se.PTimeEnd.HasValue)
  7168. {
  7169. sqlString = sqlString + " AND pd.CreateTime <= :PTimeEnd ";
  7170. parameters.Add(new OracleParameter(":PTimeEnd", OracleDbType.Date, se.PTimeEnd.Value, ParameterDirection.Input));
  7171. }
  7172. sqlString = sqlString +
  7173. "\n ) pdata\n" +
  7174. " 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" +
  7175. " ORDER BY pdata.displayno\n" +
  7176. " ,pdata.goodstypename2\n" +
  7177. " ,pdata.usercode\n" +
  7178. " ,pdata.goodstypename\n" +
  7179. " ,pdata.goodscode) p";
  7180. return sqlString;
  7181. }
  7182. /// <summary>
  7183. /// 取得RPT030107画面(工序交接数量汇总表)的明细信息查询数据
  7184. /// </summary>
  7185. /// <param name="user">登录用户信息</param>
  7186. /// <param name="se">查询条件</param>
  7187. /// <returns>查询结果</returns>
  7188. public static ServiceResultEntity GetRPT030107IData(SUserInfo user, RPT030107_SE se)
  7189. {
  7190. IDBConnection conn = null;
  7191. try
  7192. {
  7193. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7194. List<OracleParameter> parameters = new List<OracleParameter>();
  7195. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030107ISQL(user, se, ref parameters));
  7196. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  7197. ServiceResultEntity sre = new ServiceResultEntity();
  7198. if (data == null || data.Rows.Count == 0)
  7199. {
  7200. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7201. return sre;
  7202. }
  7203. sre.Data = new DataSet();
  7204. sre.Data.Tables.Add(data);
  7205. return sre;
  7206. }
  7207. catch (Exception ex)
  7208. {
  7209. throw ex;
  7210. }
  7211. finally
  7212. {
  7213. if (conn != null &&
  7214. conn.ConnState == ConnectionState.Open)
  7215. {
  7216. conn.Close();
  7217. }
  7218. }
  7219. }
  7220. /// <summary>
  7221. /// 获取RPT030107画面(工序交接数量汇总表)的明细信息查询sql
  7222. /// </summary>
  7223. /// <returns>sql</returns>
  7224. private static string GetRPT030107ISQL(SUserInfo user, RPT030107_SE se, ref List<OracleParameter> parameters)
  7225. {
  7226. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7227. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  7228. string sqlString =
  7229. "SELECT distinct pcp.procedurename,pcp.displayno\n" +
  7230. (se.DisPUserCode ? " ,pd.userid, pd.usercode \n" : " ,null userid, null usercode \n") +
  7231. //" ,pd.usercode\n" +
  7232. " ,t_over.barcode\n" +
  7233. " ,t_over.goodscode\n" +
  7234. " ,t_over.goodstypename\n" +
  7235. " ,t_over.goodstypename2\n" +
  7236. //" ,pd.createtime ptime\n" +
  7237. //" ,t_over.overprocedurename\n" +
  7238. //" ,t_over.overusercode\n" +
  7239. //" ,t_over.overtime\n" +
  7240. " ,t_over.groutingusercode\n" +
  7241. " ,pd.groutinglinecode\n" +
  7242. " ,pd.groutingmouldcode\n" +
  7243. " ,t_over.groutingdate Gdate\n" +
  7244. " ,t_over.DELIVERTIME Ddate\n" +
  7245. " ,decode(logo.logoid, null, '', logo.Logoname||'['||logo.Logocode||']') as LogoCodeName " +
  7246. " FROM tp_pm_productiondata pd\n" +
  7247. " LEFT JOIN tp_pc_procedure pcp\n" +
  7248. " ON pcp.procedureid = pd.procedureid\n" +
  7249. " LEFT JOIN TP_MST_logo logo\n" +
  7250. " ON logo.logoid = pd.logoid\n" +
  7251. " INNER JOIN (SELECT DISTINCT pd.barcode\n" +
  7252. " ,pd.productiondataid\n" +
  7253. " ,goods.goodsid\n" +
  7254. " ,goods.goodscode\n" +
  7255. " ,gt.goodstypename\n" +
  7256. " ,gt2.goodstypename goodstypename2\n" +
  7257. //" ,pcp.procedurename overprocedurename\n" +
  7258. //" ,pd.usercode overusercode\n" +
  7259. //" ,pd.createtime overtime\n" +
  7260. " ,pd.groutingusercode\n" +
  7261. " ,pd.groutingdate\n" +
  7262. " ,gdd.DELIVERTIME\n" +
  7263. " FROM tp_pm_productiondata pd\n" +
  7264. " LEFT JOIN tp_mst_goods goods\n" +
  7265. " ON goods.goodsid = pd.goodsid\n" +
  7266. " LEFT JOIN tp_mst_goodstype gt\n" +
  7267. " ON goods.goodstypeid = gt.goodstypeid\n" +
  7268. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7269. " ON gt2.goodstypecode = substr(gt.goodstypecode,1,6)\n" +
  7270. " AND gt2.accountid = gt.accountid\n" +
  7271. " LEFT JOIN tp_pc_procedure pcp\n" +
  7272. " ON pcp.procedureid = pd.procedureid\n" +
  7273. " INNER JOIN tp_pm_groutingdailydetail gdd\n" +
  7274. " ON gdd.groutingdailydetailid = pd.groutingdailydetailid\n" +
  7275. " WHERE pd.valueflag = '1'\n" +
  7276. " 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))" +
  7277. " AND pd.accountid = :AccountID\n";
  7278. // 生产线
  7279. if (se.ProductionLineID.HasValue)
  7280. {
  7281. sqlString = sqlString + " AND pd.productionlineid = :productionlineid ";
  7282. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID.Value, ParameterDirection.Input));
  7283. }
  7284. // 成型工号
  7285. if (!string.IsNullOrWhiteSpace(se.GroutingUserCode))
  7286. {
  7287. sqlString = sqlString + " AND instr(pd.GroutingUserCode, :GroutingUserCode) > 0";
  7288. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.Varchar2, se.GroutingUserCode, ParameterDirection.Input));
  7289. }
  7290. // 产品型号
  7291. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  7292. {
  7293. sqlString = sqlString + " AND instr(gt.GOODSTYPECode, :GoodsTypeCode)=1 ";
  7294. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7295. }
  7296. if (!string.IsNullOrEmpty(se.GoodsID))
  7297. {
  7298. sqlString = sqlString + " AND pd.goodsid = :GoodsID ";
  7299. parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  7300. }
  7301. // 产品编码
  7302. if (!string.IsNullOrEmpty(se.GoodsCode))
  7303. {
  7304. sqlString = sqlString + " AND instr(goods.GOODSCode, :GoodsCode) > 0 ";
  7305. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7306. }
  7307. // 交接工序
  7308. if (!string.IsNullOrEmpty(se.OverProcedureIDS))
  7309. {
  7310. sqlString = sqlString + " AND instr(:overprocedureids, ','||pd.procedureid||',')>0 ";
  7311. parameters.Add(new OracleParameter(":overprocedureids", OracleDbType.Varchar2, "," + se.OverProcedureIDS + ",", ParameterDirection.Input));
  7312. }
  7313. // 交接工号
  7314. if (!string.IsNullOrEmpty(se.OverUserIDS))
  7315. {
  7316. sqlString = sqlString + " AND instr(:overuserids, ','||pd.userid||',')>0 ";
  7317. parameters.Add(new OracleParameter(":overuserids", OracleDbType.Varchar2, "," + se.OverUserIDS + ",", ParameterDirection.Input));
  7318. }
  7319. // 交接时间
  7320. if (se.OverTimeStart.HasValue)
  7321. {
  7322. sqlString = sqlString + " AND pd.CreateTime >=:OverTimeStart ";
  7323. parameters.Add(new OracleParameter(":OverTimeStart", OracleDbType.Date, se.OverTimeStart.Value, ParameterDirection.Input));
  7324. }
  7325. if (se.OverTimeEnd.HasValue)
  7326. {
  7327. sqlString = sqlString + " AND pd.CreateTime <= :OverTimeEnd ";
  7328. parameters.Add(new OracleParameter(":OverTimeEnd", OracleDbType.Date, se.OverTimeEnd.Value, ParameterDirection.Input));
  7329. }
  7330. // 注浆时间
  7331. if (se.GTimeStart.HasValue)
  7332. {
  7333. sqlString = sqlString + " AND pd.GROUTINGDATE >=:GTimeStart ";
  7334. parameters.Add(new OracleParameter(":GTimeStart", OracleDbType.Date, se.GTimeStart.Value, ParameterDirection.Input));
  7335. }
  7336. if (se.GTimeEnd.HasValue)
  7337. {
  7338. sqlString = sqlString + " AND pd.GROUTINGDATE <= :GTimeEnd ";
  7339. parameters.Add(new OracleParameter(":GTimeEnd", OracleDbType.Date, se.GTimeEnd.Value, ParameterDirection.Input));
  7340. }
  7341. // 交坯时间
  7342. if (se.DTimeStart.HasValue)
  7343. {
  7344. sqlString = sqlString + " AND gdd.DELIVERTIME >=:DTimeStart ";
  7345. parameters.Add(new OracleParameter(":DTimeStart", OracleDbType.Date, se.DTimeStart.Value, ParameterDirection.Input));
  7346. }
  7347. if (se.DTimeEnd.HasValue)
  7348. {
  7349. sqlString = sqlString + " AND gdd.DELIVERTIME <= :DTimeEnd ";
  7350. parameters.Add(new OracleParameter(":DTimeEnd", OracleDbType.Date, se.DTimeEnd.Value, ParameterDirection.Input));
  7351. }
  7352. sqlString = sqlString +
  7353. " ) t_over\n" +
  7354. " ON pd.barcode = t_over.barcode\n" +
  7355. // 交接工序在生产工序后
  7356. " AND pd.productiondataid <= t_over.productiondataid\n" +
  7357. " WHERE pd.valueflag = '1'\n" +
  7358. " AND pd.accountid = :AccountID\n" +
  7359. (se.Specialrepairflag ? " AND ((pd.modeltype <> 5) or (pd.modeltype = 5 and pd.SpecialRepairFlag = '0')) \n" : "") +
  7360. " 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))";
  7361. // 生产工序
  7362. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  7363. {
  7364. sqlString = sqlString + " AND instr(:procedureids, ','||pd.procedureid||',')>0 ";
  7365. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  7366. }
  7367. // 生产工号
  7368. if (!string.IsNullOrEmpty(se.UserIDS))
  7369. {
  7370. sqlString = sqlString + " AND instr(:userids, ','||pd.userid||',')>0 ";
  7371. parameters.Add(new OracleParameter(":userids", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
  7372. }
  7373. // 生产时间
  7374. if (se.PTimeStart.HasValue)
  7375. {
  7376. sqlString = sqlString + " AND pd.CreateTime >=:PTimeStart ";
  7377. parameters.Add(new OracleParameter(":PTimeStart", OracleDbType.Date, se.PTimeStart.Value, ParameterDirection.Input));
  7378. }
  7379. if (se.PTimeEnd.HasValue)
  7380. {
  7381. sqlString = sqlString + " AND pd.CreateTime <= :PTimeEnd ";
  7382. parameters.Add(new OracleParameter(":PTimeEnd", OracleDbType.Date, se.PTimeEnd.Value, ParameterDirection.Input));
  7383. }
  7384. sqlString = sqlString +
  7385. "\n ORDER BY pcp.displayno\n" +
  7386. " ,t_over.goodstypename2\n" +
  7387. (se.DisPUserCode ? " ,pd.usercode\n" : "") +
  7388. " ,t_over.goodstypename\n" +
  7389. " ,t_over.goodscode\n";
  7390. return sqlString;
  7391. }
  7392. #endregion
  7393. /// <summary>
  7394. /// 取得RPT030108画面(成型信息汇总表)的查询数据
  7395. /// </summary>
  7396. /// <param name="user">登录用户信息</param>
  7397. /// <param name="se">查询条件</param>
  7398. /// <returns>查询结果</returns>
  7399. public static ServiceResultEntity GetRPT030108SData(SUserInfo user, RPT030108_SE se)
  7400. {
  7401. IDBConnection conn = null;
  7402. try
  7403. {
  7404. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7405. List<OracleParameter> parameters = new List<OracleParameter>();
  7406. string sqlString = "SELECT decode(g.gid,\n" +
  7407. " 7,\n" +
  7408. " '总计',\n" +
  7409. " 3,\n" +
  7410. " '合计【' || g.goodstypename2 || '】',\n" +
  7411. " 0,\n" +
  7412. " g.goodstypename2,\n" +
  7413. " '--') goodstypename2\n" +
  7414. " ,decode(g.gid, 0, g.goodstypename, '--') goodstypename\n" +
  7415. " ,decode(g.gid,\n" +
  7416. " 1,\n" +
  7417. " '小计【' || g.goodscode || '】',\n" +
  7418. " 0,\n" +
  7419. " g.goodscode,\n" +
  7420. " '--') goodscode\n" +
  7421. " ,decode(g.gid, 0, g.usercode, '--') usercode\n" +
  7422. " ,decode(g.gid, 0, g.MONITORName, '--') MONITORName\n" +
  7423. " ,g.groutingcount\n" +
  7424. " ,g.barcodecount\n" +
  7425. " ,g.scrapcount\n" +
  7426. " ,g.barscrapcount\n" +
  7427. " ,g.delivercount\n" +
  7428. " ,g.barcodecount - g.barscrapcount - g.delivercount incount\n" +
  7429. " FROM (SELECT grouping_id(gdd.goodstypename2, gdd.goodscode, gdd.usercode) gid\n" +
  7430. " ,gdd.goodstypename2\n" +
  7431. " ,gdd.goodstypename\n" +
  7432. " ,gdd.goodscode\n" +
  7433. " ,gdd.usercode\n" +
  7434. " ,gdd.MONITORName\n" +
  7435. " ,SUM(groutingcount) groutingcount\n" +
  7436. " ,SUM(barcodecount) barcodecount\n" +
  7437. " ,SUM(scrapcount) scrapcount\n" +
  7438. " ,SUM(barscrapcount) barscrapcount\n" +
  7439. " ,SUM(delivercount) delivercount\n" +
  7440. " FROM (SELECT gt2.goodstypename goodstypename2\n" +
  7441. " ,gdd.usercode\n" +
  7442. " ,mu.usercode as MONITORName\n" +
  7443. " ,goods.goodscode\n" +
  7444. " ,gt.goodstypename\n" +
  7445. " , CASE\n" +
  7446. " WHEN gdd.groutingdate >= :gdatabegin AND\n" +
  7447. " gdd.groutingdate <= :gdataend THEN\n" +
  7448. " 1\n" +
  7449. " ELSE\n" +
  7450. " 0\n" +
  7451. " END groutingcount\n" +
  7452. " , CASE\n" +
  7453. " WHEN gdd.groutingdate >= :gdatabegin AND\n" +
  7454. " gdd.groutingdate <= :gdataend AND\n" +
  7455. " gdd.barcode IS NOT NULL THEN\n" +
  7456. " 1\n" +
  7457. " ELSE\n" +
  7458. " 0\n" +
  7459. " END barcodecount\n" +
  7460. " , CASE\n" +
  7461. " WHEN gdd.scraptime >= :sdatabegin AND\n" +
  7462. " gdd.scraptime <= :sdataend AND\n" +
  7463. " gdd.scrapflag = '1' THEN\n" +
  7464. " 1\n" +
  7465. " ELSE\n" +
  7466. " 0\n" +
  7467. " END scrapcount\n" +
  7468. " , CASE\n" +
  7469. " WHEN gdd.scraptime >= :sdatabegin AND\n" +
  7470. " gdd.scraptime <= :sdataend AND\n" +
  7471. " gdd.barcode IS NOT NULL AND gdd.scrapflag = '1' THEN\n" +
  7472. " 1\n" +
  7473. " ELSE\n" +
  7474. " 0\n" +
  7475. " END barscrapcount\n" +
  7476. " , CASE\n" +
  7477. " WHEN gdd.delivertime >= :ddatabegin AND\n" +
  7478. " gdd.delivertime <= :ddataend AND\n" +
  7479. " gdd.deliverflag = '1' THEN\n" +
  7480. " 1\n" +
  7481. " ELSE\n" +
  7482. " 0\n" +
  7483. " END delivercount\n" +
  7484. " FROM tp_pm_groutingdailydetail gdd\n" +
  7485. " LEFT JOIN tp_mst_goods goods\n" +
  7486. " ON goods.goodsid = gdd.goodsid\n" +
  7487. // 成型线
  7488. " LEFT JOIN tp_pc_groutingline gl" +
  7489. " ON gl.groutinglineid = GDD.GroutingLineID" +
  7490. // 成型班长
  7491. " LEFT JOIN tp_mst_user mu" +
  7492. " ON mu.userid = gl.MONITORID " +
  7493. " LEFT JOIN tp_mst_goodstype gt\n" +
  7494. " ON gt.goodstypeid = goods.goodstypeid\n" +
  7495. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7496. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  7497. " AND gt2.accountid = gt.accountid\n" +
  7498. " WHERE gdd.valueflag = '1'\n" +
  7499. " AND gdd.groutingflag = '1'\n" +
  7500. " AND gdd.accountid = :accountid\n" +
  7501. " AND ((gdd.groutingdate >= :gdatabegin AND\n" +
  7502. " gdd.groutingdate <= :gdataend) OR\n" +
  7503. " (gdd.scraptime >= :sdatabegin AND\n" +
  7504. " gdd.scraptime <= :sdataend) OR\n" +
  7505. " (gdd.delivertime >= :ddatabegin AND\n" +
  7506. " gdd.delivertime <= :ddataend))\n" +
  7507. " AND (:usercode IS NULL OR\n" +
  7508. " instr(gdd.usercode, :usercode) > 0)\n" +
  7509. " AND (:GoodsCode IS NULL OR\n" +
  7510. " instr(goods.GoodsCode, :GoodsCode) > 0)\n" +
  7511. " AND (:goodstypecode IS NULL OR\n" +
  7512. " instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  7513. " ORDER BY gt2.goodstypename\n" +
  7514. " ,gt.goodstypename\n" +
  7515. " ,goods.goodscode\n" +
  7516. " ,gdd.usercode) gdd\n" +
  7517. " GROUP BY GROUPING SETS((gdd.goodstypename2, gdd.goodstypename, gdd.goodscode, gdd.usercode,gdd.MONITORName),(gdd.goodstypename2, gdd.goodstypename, gdd.goodscode),(gdd.goodstypename2),())\n" +
  7518. " ORDER BY gdd.goodstypename2\n" +
  7519. " ,gdd.goodstypename\n" +
  7520. " ,gdd.goodscode\n" +
  7521. " ,gdd.usercode) g";
  7522. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7523. parameters.Add(new OracleParameter(":gdatabegin", OracleDbType.Date, se.GTimeStart, ParameterDirection.Input));
  7524. parameters.Add(new OracleParameter(":gdataend", OracleDbType.Date, se.GTimeEnd, ParameterDirection.Input));
  7525. parameters.Add(new OracleParameter(":sdatabegin", OracleDbType.Date, se.STimeStart, ParameterDirection.Input));
  7526. parameters.Add(new OracleParameter(":sdataend", OracleDbType.Date, se.STimeEnd, ParameterDirection.Input));
  7527. parameters.Add(new OracleParameter(":ddatabegin", OracleDbType.Date, se.DTimeStart, ParameterDirection.Input));
  7528. parameters.Add(new OracleParameter(":ddataend", OracleDbType.Date, se.DTimeEnd, ParameterDirection.Input));
  7529. parameters.Add(new OracleParameter(":usercode", OracleDbType.Varchar2, se.UserCode, ParameterDirection.Input));
  7530. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7531. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7532. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  7533. ServiceResultEntity sre = new ServiceResultEntity();
  7534. if (data == null || data.Rows.Count == 0)
  7535. {
  7536. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7537. return sre;
  7538. }
  7539. sre.Data = new DataSet();
  7540. sre.Data.Tables.Add(data);
  7541. return sre;
  7542. }
  7543. catch (Exception ex)
  7544. {
  7545. throw ex;
  7546. }
  7547. finally
  7548. {
  7549. if (conn != null &&
  7550. conn.ConnState == ConnectionState.Open)
  7551. {
  7552. conn.Close();
  7553. }
  7554. }
  7555. }
  7556. #region 撤销产品汇总表
  7557. /// <summary>
  7558. /// 取得RPT030109画面(撤销产品汇总表)的汇总信息查询数据
  7559. /// </summary>
  7560. /// <param name="user">登录用户信息</param>
  7561. /// <param name="se">查询条件</param>
  7562. /// <returns>查询结果</returns>
  7563. public static ServiceResultEntity GetRPT030109SData(SUserInfo user, RPT030109_SE se)
  7564. {
  7565. IDBConnection conn = null;
  7566. try
  7567. {
  7568. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7569. List<OracleParameter> parameters = new List<OracleParameter>();
  7570. string sql = ReportModuleLogic.GetRPT030109SSQL(user, se, ref parameters);
  7571. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  7572. ServiceResultEntity sre = new ServiceResultEntity();
  7573. if (data == null || data.Rows.Count == 0)
  7574. {
  7575. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7576. return sre;
  7577. }
  7578. sre.Data = new DataSet();
  7579. sre.Data.Tables.Add(data);
  7580. return sre;
  7581. }
  7582. catch (Exception ex)
  7583. {
  7584. throw ex;
  7585. }
  7586. finally
  7587. {
  7588. if (conn != null &&
  7589. conn.ConnState == ConnectionState.Open)
  7590. {
  7591. conn.Close();
  7592. }
  7593. }
  7594. }
  7595. /// <summary>
  7596. /// 获取RPT030109画面(撤销产品汇总表)的汇总信息查询sql
  7597. /// </summary>
  7598. /// <returns>sql</returns>
  7599. private static string GetRPT030109SSQL(SUserInfo user, RPT030109_SE se, ref List<OracleParameter> parameters)
  7600. {
  7601. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7602. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  7603. string sqlString =
  7604. "SELECT decode(p.gid,\n" +
  7605. " 7,\n" +
  7606. " '总计',\n" +
  7607. " 3,\n" +
  7608. " '合计【' || p.procedurename || '】',\n" +
  7609. " 0,\n" +
  7610. " p.procedurename,\n" +
  7611. " '--') procedurename\n" +
  7612. " ,decode(p.gid,\n" +
  7613. " 1,\n" +
  7614. " '小计【' || p.goodstypename2 || '】',\n" +
  7615. " 0,\n" +
  7616. " p.goodstypename2,\n" +
  7617. " '--') goodstypename2\n" +
  7618. " ,decode(p.gid, 0, p.goodstypename, '--') goodstypename\n" +
  7619. " ,decode(p.gid, 0, p.goodscode, '--') goodscode\n" +
  7620. " ,decode(p.gid, 0, p.usercode, '--') usercode\n" +
  7621. " ,p.codecount\n" +
  7622. " ,p.productionlineid\n" +
  7623. " ,p.procedureid\n" +
  7624. " ,p.goodstypecode2\n" +
  7625. " ,p.goodsid\n" +
  7626. " ,p.userid\n" +
  7627. " FROM (SELECT grouping_id(pd.procedureid, gt2.goodstypecode, pd.userid) gid\n" +
  7628. " ,pd.productionlineid\n" +
  7629. " ,pd.procedureid\n" +
  7630. " ,p.procedurename\n" +
  7631. " ,p.displayno\n" +
  7632. " ,gt2.goodstypecode goodstypecode2\n" +
  7633. " ,gt2.goodstypename goodstypename2\n" +
  7634. " ,gt.goodstypecode\n" +
  7635. " ,gt.goodstypename\n" +
  7636. " ,goods.goodsid\n" +
  7637. " ,goods.goodscode\n" +
  7638. " ,pd.userid\n" +
  7639. " ,pd.usercode\n" +
  7640. " ,COUNT(*) codecount\n" +
  7641. " FROM tp_pm_productiondata pd\n" +
  7642. " LEFT JOIN tp_pc_procedure p\n" +
  7643. " ON p.procedureid = pd.procedureid\n" +
  7644. " LEFT JOIN tp_mst_goods goods\n" +
  7645. " ON goods.goodsid = pd.goodsid\n" +
  7646. " LEFT JOIN tp_mst_goodstype gt\n" +
  7647. " ON gt.goodstypeid = goods.goodstypeid\n" +
  7648. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7649. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  7650. " AND gt2.accountid = gt.accountid\n" +
  7651. " WHERE pd.valueflag = '0'\n" +
  7652. " AND pd.accountid = :accountid\n" +
  7653. " 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))" +
  7654. " 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))" +
  7655. " AND (:productionlineid IS NULL OR\n" +
  7656. " pd.productionlineid = :productionlineid)\n" +
  7657. " AND (:procedureids IS NULL OR\n" +
  7658. " instr(:procedureids, ',' || pd.procedureid || ',') > 0)\n" +
  7659. " AND (:goodstypecode IS NULL OR\n" +
  7660. " instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  7661. " AND (:goodscode IS NULL OR\n" +
  7662. " instr(goods.goodscode, :goodscode) > 0)\n" +
  7663. " AND (:PUserIDS IS NULL OR\n" +
  7664. " instr(:PUserIDS, ',' || pd.userid || ',') > 0)\n" +
  7665. " AND (:backusercode IS NULL OR\n" +
  7666. " instr(pd.BACKOUTUSERCODE, :backusercode) > 0)\n" +
  7667. " AND (:ptimebegin IS NULL OR pd.createtime >= :ptimebegin)\n" +
  7668. " AND (:ptimeend IS NULL OR pd.createtime <= :ptimeend)\n" +
  7669. " AND (:backtimebegin IS NULL OR pd.backouttime >= :backtimebegin)\n" +
  7670. " AND (:backtimeend IS NULL OR pd.backouttime <= :backtimeend)\n" +
  7671. " 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" +
  7672. " ORDER BY p.displayno\n" +
  7673. " ,gt2.goodstypecode\n" +
  7674. " ,gt.goodstypecode\n" +
  7675. " ,goods.goodscode\n" +
  7676. " ,pd.usercode) p";
  7677. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  7678. if (string.IsNullOrEmpty(se.ProcedureIDS))
  7679. {
  7680. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, null, ParameterDirection.Input));
  7681. }
  7682. else
  7683. {
  7684. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  7685. }
  7686. if (string.IsNullOrEmpty(se.UserIDS))
  7687. {
  7688. parameters.Add(new OracleParameter(":PUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  7689. }
  7690. else
  7691. {
  7692. parameters.Add(new OracleParameter(":PUserIDS", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
  7693. }
  7694. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7695. parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7696. parameters.Add(new OracleParameter(":backusercode", OracleDbType.Varchar2, se.BackUserCode, ParameterDirection.Input));
  7697. parameters.Add(new OracleParameter(":ptimebegin", OracleDbType.Date, se.PTimeStart, ParameterDirection.Input));
  7698. parameters.Add(new OracleParameter(":ptimeend", OracleDbType.Date, se.PTimeEnd, ParameterDirection.Input));
  7699. parameters.Add(new OracleParameter(":backtimebegin", OracleDbType.Date, se.BackTimeStart, ParameterDirection.Input));
  7700. parameters.Add(new OracleParameter(":backtimeend", OracleDbType.Date, se.BackTimeEnd, ParameterDirection.Input));
  7701. return sqlString;
  7702. }
  7703. /// <summary>
  7704. /// 取得RPT030109画面(撤销产品汇总表)的明细信息查询数据
  7705. /// </summary>
  7706. /// <param name="user">登录用户信息</param>
  7707. /// <param name="se">查询条件</param>
  7708. /// <returns>查询结果</returns>
  7709. public static ServiceResultEntity GetRPT030109IData(SUserInfo user, RPT030109_SE se)
  7710. {
  7711. IDBConnection conn = null;
  7712. try
  7713. {
  7714. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7715. List<OracleParameter> parameters = new List<OracleParameter>();
  7716. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030109ISQL(user, se, ref parameters));
  7717. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  7718. ServiceResultEntity sre = new ServiceResultEntity();
  7719. if (data == null || data.Rows.Count == 0)
  7720. {
  7721. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7722. return sre;
  7723. }
  7724. sre.Data = new DataSet();
  7725. sre.Data.Tables.Add(data);
  7726. return sre;
  7727. }
  7728. catch (Exception ex)
  7729. {
  7730. throw ex;
  7731. }
  7732. finally
  7733. {
  7734. if (conn != null &&
  7735. conn.ConnState == ConnectionState.Open)
  7736. {
  7737. conn.Close();
  7738. }
  7739. }
  7740. }
  7741. /// <summary>
  7742. /// 获取RPT030109画面(撤销产品汇总表)的明细信息查询sql
  7743. /// </summary>
  7744. /// <returns>sql</returns>
  7745. private static string GetRPT030109ISQL(SUserInfo user, RPT030109_SE se, ref List<OracleParameter> parameters)
  7746. {
  7747. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  7748. parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  7749. string sqlString =
  7750. "SELECT p.procedurename\n" +
  7751. " ,gt2.goodstypename goodstypename2\n" +
  7752. " ,gt.goodstypename\n" +
  7753. " ,goods.goodscode\n" +
  7754. " ,pd.barcode\n" +
  7755. " ,pd.usercode\n" +
  7756. " ,pd.createtime ptime\n" +
  7757. " ,pd.backoutusercode busercode\n" +
  7758. " ,pd.backouttime btime\n" +
  7759. " ,pd.groutingusercode\n" +
  7760. " ,pd.groutinglinecode\n" +
  7761. " ,pd.groutingmouldcode\n" +
  7762. " ,pd.groutingdate GDate\n" +
  7763. " FROM tp_pm_productiondata pd\n" +
  7764. " LEFT JOIN tp_pc_procedure p\n" +
  7765. " ON p.procedureid = pd.procedureid\n" +
  7766. " LEFT JOIN tp_mst_goods goods\n" +
  7767. " ON goods.goodsid = pd.goodsid\n" +
  7768. " LEFT JOIN tp_mst_goodstype gt\n" +
  7769. " ON gt.goodstypeid = goods.goodstypeid\n" +
  7770. " LEFT JOIN tp_mst_goodstype gt2\n" +
  7771. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  7772. " AND gt2.accountid = gt.accountid\n" +
  7773. " WHERE pd.valueflag = '0'\n" +
  7774. " AND pd.accountid = :accountid\n" +
  7775. " 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))" +
  7776. " 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))" +
  7777. " AND (:productionlineid IS NULL OR\n" +
  7778. " pd.productionlineid = :productionlineid)\n" +
  7779. " AND (:procedureids IS NULL OR\n" +
  7780. " instr(:procedureids, ',' || pd.procedureid || ',') > 0)\n" +
  7781. " AND (:goodstypecode IS NULL OR\n" +
  7782. " instr(gt.goodstypecode, :goodstypecode) = 1)\n" +
  7783. " AND (:goodscode IS NULL OR instr(goods.goodscode, :goodscode) > 0)\n" +
  7784. " AND (:PUserIDS IS NULL OR\n" +
  7785. " instr(:PUserIDS, ',' || pd.userid || ',') > 0)\n" +
  7786. " AND (:backusercode IS NULL OR instr(pd.BACKOUTUSERCODE, :backusercode) > 0)\n" +
  7787. " AND (:ptimebegin IS NULL OR pd.createtime >= :ptimebegin)\n" +
  7788. " AND (:ptimeend IS NULL OR pd.createtime <= :ptimeend)\n" +
  7789. " AND (:backtimebegin IS NULL OR pd.backouttime >= :backtimebegin)\n" +
  7790. " AND (:backtimeend IS NULL OR pd.backouttime <= :backtimeend)\n" +
  7791. " AND (:puserid IS NULL OR pd.userid = :puserid)\n" +
  7792. " AND (:goodsid IS NULL OR pd.goodsid = :goodsid)\n" +
  7793. " AND (:procedureid IS NULL OR pd.procedureid = :procedureid)\n" +
  7794. " ORDER BY p.displayno\n" +
  7795. " ,gt2.goodstypename\n" +
  7796. " ,gt.goodstypename\n" +
  7797. " ,goods.goodscode\n" +
  7798. " ,pd.usercode\n" +
  7799. " ,pd.barcode\n" +
  7800. " ,pd.backoutusercode\n" +
  7801. " ,pd.backouttime";
  7802. parameters.Add(new OracleParameter(":productionlineid", OracleDbType.Int32, se.ProductionLineID, ParameterDirection.Input));
  7803. if (string.IsNullOrEmpty(se.ProcedureIDS))
  7804. {
  7805. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, null, ParameterDirection.Input));
  7806. }
  7807. else
  7808. {
  7809. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, "," + se.ProcedureIDS + ",", ParameterDirection.Input));
  7810. }
  7811. if (string.IsNullOrEmpty(se.UserIDS))
  7812. {
  7813. parameters.Add(new OracleParameter(":PUserIDS", OracleDbType.Varchar2, null, ParameterDirection.Input));
  7814. }
  7815. else
  7816. {
  7817. parameters.Add(new OracleParameter(":PUserIDS", OracleDbType.Varchar2, "," + se.UserIDS + ",", ParameterDirection.Input));
  7818. }
  7819. parameters.Add(new OracleParameter(":goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode, ParameterDirection.Input));
  7820. parameters.Add(new OracleParameter(":goodscode", OracleDbType.Varchar2, se.GoodsCode, ParameterDirection.Input));
  7821. parameters.Add(new OracleParameter(":backusercode", OracleDbType.Varchar2, se.BackUserCode, ParameterDirection.Input));
  7822. parameters.Add(new OracleParameter(":ptimebegin", OracleDbType.Date, se.PTimeStart, ParameterDirection.Input));
  7823. parameters.Add(new OracleParameter(":ptimeend", OracleDbType.Date, se.PTimeEnd, ParameterDirection.Input));
  7824. parameters.Add(new OracleParameter(":backtimebegin", OracleDbType.Date, se.BackTimeStart, ParameterDirection.Input));
  7825. parameters.Add(new OracleParameter(":backtimeend", OracleDbType.Date, se.BackTimeEnd, ParameterDirection.Input));
  7826. parameters.Add(new OracleParameter(":puserid", OracleDbType.Int32, se.UserID, ParameterDirection.Input));
  7827. parameters.Add(new OracleParameter(":goodsid", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  7828. parameters.Add(new OracleParameter(":procedureid", OracleDbType.Int32, se.ProcedureID, ParameterDirection.Input));
  7829. return sqlString;
  7830. }
  7831. #endregion
  7832. /// <summary>
  7833. /// 工序收发存汇总表(初始化数据)
  7834. /// </summary>
  7835. /// <param name="user"></param>
  7836. /// <returns></returns>
  7837. public static ServiceResultEntity GetRPT030111IData(SUserInfo user)
  7838. {
  7839. IDBConnection conn = null;
  7840. try
  7841. {
  7842. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7843. OracleParameter[] parameters = new OracleParameter[]
  7844. {
  7845. new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  7846. };
  7847. string sqlString =
  7848. "SELECT t.ptid, t.name\n" +
  7849. " FROM tp_mst_rpt_transfer t\n" +
  7850. " WHERE t.AccountID = :AccountID\n" +
  7851. " AND t.valueflag = '1'\n" +
  7852. " ORDER BY t.displayno desc";
  7853. DataSet data = conn.GetSqlResultToDs(sqlString, parameters);
  7854. ServiceResultEntity sre = new ServiceResultEntity();
  7855. //if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  7856. //{
  7857. // sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7858. // return sre;
  7859. //}
  7860. sre.Data = data;
  7861. return sre;
  7862. }
  7863. catch (Exception ex)
  7864. {
  7865. throw ex;
  7866. }
  7867. finally
  7868. {
  7869. if (conn != null &&
  7870. conn.ConnState == ConnectionState.Open)
  7871. {
  7872. conn.Close();
  7873. }
  7874. }
  7875. }
  7876. /// <summary>
  7877. /// 工序收发存汇总表
  7878. /// </summary>
  7879. /// <param name="user"></param>
  7880. /// <param name="se"></param>
  7881. /// <returns></returns>
  7882. public static ServiceResultEntity GetRPT030111SData(SUserInfo user, RPT030111_SE se)
  7883. {
  7884. IDBTransaction conn = null;
  7885. try
  7886. {
  7887. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  7888. conn.Connect();
  7889. OracleParameter[] parameters = new OracleParameter[]
  7890. {
  7891. new OracleParameter("in_accountid", OracleDbType.Int32, user.AccountID, ParameterDirection.Input),
  7892. new OracleParameter("in_ptid", OracleDbType.Int32, se.PTID, ParameterDirection.Input),
  7893. //new OracleParameter("in_datetimeinit", OracleDbType.Date, se.GTimeInit, ParameterDirection.Input),
  7894. new OracleParameter("in_datetimebegin", OracleDbType.Date, se.GTimeStart , ParameterDirection.Input),
  7895. new OracleParameter("in_datetimeend", OracleDbType.Date, se.GTimeEnd , ParameterDirection.Input),
  7896. new OracleParameter("in_goodstypecode", OracleDbType.Varchar2, se.GoodsTypeCode , ParameterDirection.Input),
  7897. new OracleParameter("in_goodscode", OracleDbType.Varchar2, se.GoodsCode , ParameterDirection.Input),
  7898. new OracleParameter("out_data", OracleDbType.RefCursor, null, ParameterDirection.Output),
  7899. };
  7900. DataSet data = conn.ExecStoredProcedure("pro_rpt_gettransfers_sum_c", parameters);
  7901. ServiceResultEntity sre = new ServiceResultEntity();
  7902. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  7903. {
  7904. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7905. return sre;
  7906. }
  7907. //StringBuilder intdids = new StringBuilder();
  7908. //foreach (DataRow row in data.Tables[0].Rows)
  7909. //{
  7910. // if (intdids.Length > 0)
  7911. // {
  7912. // intdids.Append(", ");
  7913. // }
  7914. // intdids.Append(row["tdid"] + " AS \"" + row["name"] + "\"\n");
  7915. //}
  7916. //string sqlString =
  7917. // "WITH ttm AS\n" +
  7918. // " (SELECT *\n" +
  7919. // " FROM TMP_RPT_TECDEP_D\n" +
  7920. // " pivot(SUM(m)\n" +
  7921. // " FOR intdid IN(" + intdids + ")))\n" +
  7922. // "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" +
  7923. // " FROM TMP_RPT_TECDEP_T t\n" +
  7924. // " LEFT JOIN ttm m\n" +
  7925. // " ON m.goodsid = t.goodsid\n" +
  7926. // " AND m.outtdid = t.tecdepid\n" +
  7927. // " ORDER BY t.goodscode, t.displayno";
  7928. //data = conn.GetSqlResultToDs(sqlString);
  7929. //if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  7930. //{
  7931. // sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7932. // return sre;
  7933. //}
  7934. conn.Commit();
  7935. sre.Data = data;
  7936. return sre;
  7937. }
  7938. catch (Exception ex)
  7939. {
  7940. throw ex;
  7941. }
  7942. finally
  7943. {
  7944. if (conn != null &&
  7945. conn.ConnState == ConnectionState.Open)
  7946. {
  7947. conn.Disconnect();
  7948. }
  7949. }
  7950. }
  7951. #endregion 汇总报表
  7952. #region 公共函数
  7953. /// <summary>
  7954. /// 取得报表的查询数据源统计工序数据
  7955. /// </summary>
  7956. /// <param name="user">登录用户信息</param>
  7957. /// <param name="se">查询条件</param>
  7958. /// <returns>查询结果</returns>
  7959. public static ServiceResultEntity GetRptSourceProcedureModule(SUserInfo user, int? RptProcedureID)
  7960. {
  7961. IDBConnection conn = null;
  7962. try
  7963. {
  7964. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  7965. OracleParameter[] paras = new OracleParameter[]{
  7966. new OracleParameter("in_rptProcedureId",OracleDbType.Int32,RptProcedureID,ParameterDirection.Input),
  7967. new OracleParameter("out_rptSResult",OracleDbType.RefCursor, ParameterDirection.Output),
  7968. new OracleParameter("out_rptTresult",OracleDbType.RefCursor, ParameterDirection.Output),
  7969. };
  7970. DataSet data = conn.ExecStoredProcedure("PRO_MST_GetRptProcedureBYID", paras);
  7971. ServiceResultEntity sre = new ServiceResultEntity();
  7972. if (data == null || data.Tables.Count == 0)
  7973. {
  7974. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  7975. return sre;
  7976. }
  7977. sre.Data = new DataSet();
  7978. sre.Data = data;
  7979. return sre;
  7980. }
  7981. catch (Exception ex)
  7982. {
  7983. throw ex;
  7984. }
  7985. finally
  7986. {
  7987. if (conn != null &&
  7988. conn.ConnState == ConnectionState.Open)
  7989. {
  7990. conn.Close();
  7991. }
  7992. }
  7993. }
  7994. /// <summary>
  7995. /// 取得报表数据源数据
  7996. /// </summary>
  7997. /// <param name="user">登录用户信息</param>
  7998. /// <returns>查询结果</returns>
  7999. public static ServiceResultEntity GetRptProcedureModule(SUserInfo user)
  8000. {
  8001. IDBConnection conn = null;
  8002. try
  8003. {
  8004. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8005. string selSql = " select "
  8006. + " TP_MST_RptProcedure.Rptprocedureid,"
  8007. + " TP_MST_RptProcedure.Rptprocedurecode,"
  8008. + " TP_MST_RptProcedure.Rptprocedurename,"
  8009. + " TP_MST_RptProcedure.Rptproceduretype,"
  8010. + " decode(TP_MST_RptProcedure.Rptproceduretype,'A0001','出窑统计','质量统计') RptproceduretypeName,"
  8011. + " (select wm_concat(s.procedureid) sprocedureid from tp_mst_rptsprocedure s where s.rptprocedureid = TP_MST_RptProcedure.Rptprocedureid) sprocedureid,"
  8012. + " (select wm_concat(t.procedureid) tprocedureid from tp_mst_rpttprocedure t where t.rptprocedureid = TP_MST_RptProcedure.Rptprocedureid) tprocedureid,"
  8013. + " TP_MST_RptProcedure.Optimestamp "
  8014. + " from TP_MST_RptProcedure "
  8015. + " where TP_MST_RptProcedure.ValueFlag=1 "
  8016. + " and TP_MST_RptProcedure.AccountID=:accountID order by TP_MST_RptProcedure.displayno";
  8017. List<OracleParameter> parameters = new List<OracleParameter>();
  8018. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8019. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8020. ServiceResultEntity sre = new ServiceResultEntity();
  8021. if (data == null || data.Rows.Count == 0)
  8022. {
  8023. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8024. return sre;
  8025. }
  8026. sre.Data = new DataSet();
  8027. sre.Data.Tables.Add(data);
  8028. return sre;
  8029. }
  8030. catch (Exception ex)
  8031. {
  8032. throw ex;
  8033. }
  8034. finally
  8035. {
  8036. if (conn != null &&
  8037. conn.ConnState == ConnectionState.Open)
  8038. {
  8039. conn.Close();
  8040. }
  8041. }
  8042. }
  8043. /// <summary>
  8044. /// 取得窑炉数据
  8045. /// </summary>
  8046. /// <param name="user">登录用户信息</param>
  8047. /// <param name="pValue">使用标识条件</param>
  8048. /// <returns>查询结果</returns>
  8049. public static ServiceResultEntity GetKilnData(SUserInfo user, byte pValue)
  8050. {
  8051. IDBConnection conn = null;
  8052. try
  8053. {
  8054. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8055. string selSql = string.Empty;
  8056. List<OracleParameter> parameters = new List<OracleParameter>();
  8057. //根据帐套查询数据
  8058. if (pValue.ToString() == Constant.INT_IS_ONE.ToString())
  8059. {
  8060. selSql = "Select KilnID,KilnCode,KilnName,KilnType,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,UpdateUserID,OPTimeStamp "
  8061. + "from TP_MST_Kiln where AccountID = :AccountID";
  8062. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8063. }
  8064. //根据帐套和标识查询数据
  8065. else if (pValue.ToString() == Constant.INT_IS_ZERO.ToString())
  8066. {
  8067. selSql = "Select KilnID,KilnCode,KilnName,KilnType,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,UpdateUserID,OPTimeStamp "
  8068. + "from TP_MST_Kiln where valueflag = :valueflag and AccountID = :AccountID";
  8069. parameters.Add(new OracleParameter(":valueflag", OracleDbType.NVarchar2, Constant.INT_IS_ONE.ToString(), ParameterDirection.Input));
  8070. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8071. }
  8072. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8073. ServiceResultEntity sre = new ServiceResultEntity();
  8074. if (data == null || data.Rows.Count == 0)
  8075. {
  8076. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8077. return sre;
  8078. }
  8079. sre.Data = new DataSet();
  8080. sre.Data.Tables.Add(data);
  8081. return sre;
  8082. }
  8083. catch (Exception ex)
  8084. {
  8085. throw ex;
  8086. }
  8087. finally
  8088. {
  8089. if (conn != null &&
  8090. conn.ConnState == ConnectionState.Open)
  8091. {
  8092. conn.Close();
  8093. }
  8094. }
  8095. }
  8096. /// <summary>
  8097. /// 取得窑车数据
  8098. /// </summary>
  8099. /// <param name="user">登录用户信息</param>
  8100. /// <returns>查询结果</returns>
  8101. public static ServiceResultEntity GetAllKilnCarInfo(SUserInfo user)
  8102. {
  8103. IDBConnection conn = null;
  8104. try
  8105. {
  8106. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8107. string selSql = String.Empty;
  8108. List<OracleParameter> parameters = new List<OracleParameter>();
  8109. //获取窑车管理的数据
  8110. selSql = "Select KilnCarID,KilnID,KilnCarCode,KilnCarName,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,UpdateUserID,OPTimeStamp "
  8111. + "from TP_MST_KilnCar where AccountID = :AccountID";
  8112. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8113. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8114. ServiceResultEntity sre = new ServiceResultEntity();
  8115. if (data == null || data.Rows.Count == 0)
  8116. {
  8117. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8118. return sre;
  8119. }
  8120. sre.Data = new DataSet();
  8121. sre.Data.Tables.Add(data);
  8122. return sre;
  8123. }
  8124. catch (Exception ex)
  8125. {
  8126. throw ex;
  8127. }
  8128. finally
  8129. {
  8130. if (conn != null &&
  8131. conn.ConnState == ConnectionState.Open)
  8132. {
  8133. conn.Close();
  8134. }
  8135. }
  8136. }
  8137. /// <summary>
  8138. /// 取得生产线所有的工序
  8139. /// </summary>
  8140. /// <param name="user">登录用户信息</param>
  8141. /// <returns>查询结果</returns>
  8142. public static ServiceResultEntity GetRptProductionLineProcedures(SUserInfo user, int? RptProductionLineID)
  8143. {
  8144. IDBConnection conn = null;
  8145. try
  8146. {
  8147. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8148. string selSql = "select "
  8149. + " tp_pc_procedure.procedureid, "
  8150. + " tp_pc_procedure.Procedurename "
  8151. + " from "
  8152. + " ( "
  8153. + " select TP_PM_ProductionData.Procedureid "
  8154. + " from TP_PM_ProductionData "
  8155. + " where TP_PM_ProductionData.accountid = :accountID "
  8156. + " and TP_PM_ProductionData.productionlineid = :ProductionLineID "
  8157. + " group by TP_PM_ProductionData.Procedureid "
  8158. + " order by TP_PM_ProductionData.Procedureid "
  8159. + " )temp left join tp_pc_procedure "
  8160. + " on tp_pc_procedure.procedureid=temp.procedureid ";
  8161. List<OracleParameter> parameters = new List<OracleParameter>();
  8162. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8163. parameters.Add(new OracleParameter(":ProductionLineID", OracleDbType.Int32, RptProductionLineID, ParameterDirection.Input));
  8164. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8165. ServiceResultEntity sre = new ServiceResultEntity();
  8166. if (data == null || data.Rows.Count == 0)
  8167. {
  8168. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8169. return sre;
  8170. }
  8171. sre.Data = new DataSet();
  8172. sre.Data.Tables.Add(data);
  8173. return sre;
  8174. }
  8175. catch (Exception ex)
  8176. {
  8177. throw ex;
  8178. }
  8179. finally
  8180. {
  8181. if (conn != null &&
  8182. conn.ConnState == ConnectionState.Open)
  8183. {
  8184. conn.Close();
  8185. }
  8186. }
  8187. }
  8188. /// <summary>
  8189. /// 取得数据字典数据
  8190. /// </summary>
  8191. /// <param name="Pvalue">显示停用标识</param>
  8192. /// <param name="dictionaryType">字典类别</param>
  8193. /// <param name="user">登录用户信息</param>
  8194. /// <returns>查询结果</returns>
  8195. public static ServiceResultEntity GetRptDictionaryData(byte Pvalue, string dictionaryType, SUserInfo user)
  8196. {
  8197. IDBConnection conn = null;
  8198. try
  8199. {
  8200. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8201. string selSql = String.Empty;
  8202. List<OracleParameter> parameters = new List<OracleParameter>();
  8203. //根据帐套获得数据字典管理的数据
  8204. if (Pvalue.ToString() == Constant.INT_IS_ONE.ToString())
  8205. {
  8206. selSql = "Select DictionaryID,DictionaryType,DictionaryValue,DisplayNo,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,"
  8207. + "UpdateUserID,OPTimeStamp from TP_MST_DataDictionary where DictionaryType = :DictionaryType and AccountID = :AccountID";
  8208. parameters.Add(new OracleParameter(":DictionaryType", OracleDbType.NVarchar2, dictionaryType, ParameterDirection.Input));
  8209. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8210. }
  8211. //根据帐套,标识获得数据字典管理的数据
  8212. else if (Pvalue.ToString() == Constant.INT_IS_ZERO.ToString())
  8213. {
  8214. selSql = "Select DictionaryID,DictionaryType,DictionaryValue,DisplayNo,Remarks,AccountID,ValueFlag,CreateTime,CreateUserID,UpdateTime,"
  8215. + "UpdateUserID,OPTimeStamp from TP_MST_DataDictionary where valueflag = :valueflag and DictionaryType = :DictionaryType and AccountID = :AccountID";
  8216. parameters.Add(new OracleParameter(":valueflag", OracleDbType.Int32, Constant.INT_IS_ONE, ParameterDirection.Input));
  8217. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8218. parameters.Add(new OracleParameter(":DictionaryType", OracleDbType.NVarchar2, dictionaryType, ParameterDirection.Input));
  8219. }
  8220. DataTable data = conn.GetSqlResultToDt(selSql.ToString(), parameters.ToArray());
  8221. ServiceResultEntity sre = new ServiceResultEntity();
  8222. if (data == null || data.Rows.Count == 0)
  8223. {
  8224. //sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8225. return sre;
  8226. }
  8227. sre.Data = new DataSet();
  8228. sre.Data.Tables.Add(data);
  8229. return sre;
  8230. }
  8231. catch (Exception ex)
  8232. {
  8233. throw ex;
  8234. }
  8235. finally
  8236. {
  8237. if (conn != null &&
  8238. conn.ConnState == ConnectionState.Open)
  8239. {
  8240. conn.Close();
  8241. }
  8242. }
  8243. }
  8244. #endregion 公共函数
  8245. #endregion 统一使用Se模式rviceResultEntity类
  8246. /// <summary>
  8247. /// 获取注浆次数报表
  8248. /// </summary>
  8249. /// <param name="groutingLineEntity"></param>
  8250. /// <param name="user"></param>
  8251. /// <returns></returns>
  8252. public static ServiceResultEntity GetGroutingCount(GroutingLineEntity groutingLineEntity, SUserInfo user)
  8253. {
  8254. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8255. try
  8256. {
  8257. con.Open();
  8258. OracleParameter[] paras = new OracleParameter[]{
  8259. new OracleParameter("BuildingNo",OracleDbType.NVarchar2,
  8260. groutingLineEntity.BUILDINGNO,ParameterDirection.Input),
  8261. new OracleParameter("FloorNo",OracleDbType.NVarchar2,
  8262. groutingLineEntity.FLOORNO,ParameterDirection.Input),
  8263. new OracleParameter("GroutingLineNo",OracleDbType.NVarchar2,
  8264. groutingLineEntity.GROUTINGLINENO,ParameterDirection.Input),
  8265. new OracleParameter("GroutingLineCode",OracleDbType.NVarchar2,
  8266. groutingLineEntity.GROUTINGLINECODE,ParameterDirection.Input),
  8267. new OracleParameter("GroutingLineName",OracleDbType.NVarchar2,
  8268. groutingLineEntity.GROUTINGLINENAME,ParameterDirection.Input),
  8269. new OracleParameter("GMouldTypeID",OracleDbType.Int32,
  8270. groutingLineEntity.MOULDTYPEID,ParameterDirection.Input),
  8271. new OracleParameter("remarks",OracleDbType.NVarchar2,
  8272. groutingLineEntity.REMARKS,ParameterDirection.Input),
  8273. new OracleParameter("AccountID",OracleDbType.Int32,
  8274. user.AccountID,ParameterDirection.Input),
  8275. new OracleParameter("UserId",OracleDbType.Int32,
  8276. user.UserID,ParameterDirection.Input),
  8277. new OracleParameter("PurviewType",OracleDbType.Int32,
  8278. groutingLineEntity.Purview,ParameterDirection.Input),
  8279. new OracleParameter("rs_result",OracleDbType.RefCursor,
  8280. ParameterDirection.Output),
  8281. new OracleParameter("UserCode",OracleDbType.NVarchar2,
  8282. groutingLineEntity.USERCODE,ParameterDirection.Input),
  8283. };
  8284. //调用获取符合条件的成型线信息
  8285. DataSet ds = con.ExecStoredProcedure("PRO_RPT_GetGroutingCount", paras);
  8286. ServiceResultEntity sre = new ServiceResultEntity();
  8287. if (ds == null || ds.Tables[0].Rows.Count == 0)
  8288. {
  8289. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8290. return sre;
  8291. }
  8292. sre.Data = new DataSet();
  8293. //DataTable dt=ds.Tables[0];
  8294. sre.Data.Tables.Add(ds.Tables[0].Copy());
  8295. return sre;
  8296. }
  8297. catch (Exception ex)
  8298. {
  8299. throw ex;
  8300. }
  8301. finally
  8302. {
  8303. if (con.ConnState == ConnectionState.Open)
  8304. {
  8305. con.Close();
  8306. }
  8307. }
  8308. }
  8309. #region 在产产品汇总表
  8310. /// <summary>
  8311. /// 取得RPT030105(在产产品汇总表)的汇总信息查询数据
  8312. /// </summary>
  8313. /// <param name="user">登录用户信息</param>
  8314. /// <param name="se">查询条件</param>
  8315. /// <returns>查询结果</returns>
  8316. public static ServiceResultEntity GetRPT030105Data(SUserInfo user, RPT030105_SE se)
  8317. {
  8318. IDBConnection conn = null;
  8319. try
  8320. {
  8321. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8322. List<OracleParameter> parameters = new List<OracleParameter>();
  8323. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030105SQL(user, se, ref parameters));
  8324. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  8325. ServiceResultEntity sre = new ServiceResultEntity();
  8326. if (data == null || data.Rows.Count == 0)
  8327. {
  8328. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8329. return sre;
  8330. }
  8331. sre.Data = new DataSet();
  8332. sre.Data.Tables.Add(data);
  8333. return sre;
  8334. }
  8335. catch (Exception ex)
  8336. {
  8337. throw ex;
  8338. }
  8339. finally
  8340. {
  8341. if (conn != null &&
  8342. conn.ConnState == ConnectionState.Open)
  8343. {
  8344. conn.Close();
  8345. }
  8346. }
  8347. }
  8348. /// <summary>
  8349. /// 获取RPT030105画面(产品产量汇总表)的汇总信息查询sql
  8350. /// </summary>
  8351. /// <returns>sql</returns>
  8352. private static string GetRPT030105SQL(SUserInfo user, RPT030105_SE se, ref List<OracleParameter> parameters)
  8353. {
  8354. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8355. //"select " +
  8356. //" ProcedureID," +
  8357. //" procedurecode, " +
  8358. //" decode(Usercode, '小计', '--', procedurename) procedurename, " +
  8359. //" productionlineid, " +
  8360. //" productionlinecode, " +
  8361. //" decode(Usercode, '小计', '--', productionlinename) productionlinename, " +
  8362. //" decode(ProcedureID,'总计','总计',Usercode) Usercode, " +
  8363. //" subGoodsTypecode, " +
  8364. //" decode(usercode,'小计',decode(subGoodsTypecode,'001001','大件','小件'),Goodscode)Goodscode, " +
  8365. //" Goodstypename, " +
  8366. //" InCount " +
  8367. #region
  8368. /*
  8369. "select " +
  8370. " ProcedureID," +
  8371. " procedurecode, " +
  8372. " decode(productionlinename, '总计', '--', procedurename) procedurename, " +
  8373. " productionlineid, " +
  8374. " productionlinecode, " +
  8375. " productionlinename, " +
  8376. " decode(productionlinename, '--', '--', Usercode) Usercode, " +
  8377. " decode(productionlinename, '--', null, UserID) UserID, " +
  8378. " subGoodsTypecode, " +
  8379. " Goodsid," +
  8380. " Goodscode, " +
  8381. " Goodstypename, " +
  8382. " InCount from (" +
  8383. "select " +
  8384. " ProcedureID," +
  8385. " procedurecode, " +
  8386. " decode(usercode,'合计','合计', decode(usercode,'小计','--',decode(usercode,'--','--',procedurename))) procedurename, " +
  8387. " productionlineid, " +
  8388. " productionlinecode, " +
  8389. " decode(ProcedureID,'总计','总计',decode(usercode,'小计','--',productionlinename)) productionlinename, " +
  8390. " decode(ProcedureID,'总计','--',Usercode) Usercode, " +
  8391. " decode(ProcedureID,'总计',null,Userid) Userid, " +
  8392. " subGoodsTypecode, " +
  8393. " Goodsid," +
  8394. " Goodscode, " +
  8395. " decode(usercode,'小计','小计',Goodstypename)Goodstypename, " +
  8396. " InCount " +
  8397. "from " +
  8398. "(" +
  8399. " select " +
  8400. " ProcedureID, " +
  8401. " procedurecode, " +
  8402. " procedurename, " +
  8403. " productionlineid, " +
  8404. " productionlinecode, " +
  8405. " productionlinename, " +
  8406. " decode(procedurecode,'--','合计',Usercode) Usercode, " +
  8407. " decode(procedurecode,'--',null,Userid) Userid, " +
  8408. " subGoodsTypecode," +
  8409. " Goodsid," +
  8410. " Goodscode," +
  8411. " Goodstypename, " +
  8412. " InCount " +
  8413. " from ( select " +
  8414. " decode(grouping(tp_pc_procedure.ProcedureID),1,'总计',tp_pc_procedure.ProcedureID) ProcedureID," +
  8415. " decode(grouping(tp_pc_procedure.procedurecode),1,'--',tp_pc_procedure.procedurecode) procedurecode, " +
  8416. " decode(grouping(tp_pc_procedure.procedurename),1,'--',tp_pc_procedure.procedurename) procedurename, " +
  8417. " decode(grouping(tp_pm_inproduction.productionlineid),1,'--',tp_pm_inproduction.productionlineid) productionlineid, " +
  8418. " decode(grouping(tp_pm_inproduction.productionlinecode),1,'--',tp_pm_inproduction.productionlinecode) productionlinecode, " +
  8419. " decode(grouping(tp_pm_inproduction.productionlinename),1,'--',tp_pm_inproduction.productionlinename) productionlinename, " +
  8420. " decode(grouping(TP_MST_User.Usercode),1,'小计',TP_MST_User.Usercode) Usercode," +
  8421. " decode(grouping(TP_MST_User.Userid),1,null,TP_MST_User.Userid) Userid," +
  8422. " decode(grouping(substr(TP_MST_GoodsType.Goodstypecode,0,6)),1,'--',substr(TP_MST_GoodsType.Goodstypecode,0,6)) subGoodsTypecode," +
  8423. " decode(grouping(TP_MST_Goods.Goodscode),1,'--',TP_MST_Goods.Goodscode) Goodscode," +
  8424. " decode(grouping(TP_MST_Goods.Goodsid),1,'--',TP_MST_Goods.Goodsid) Goodsid," +
  8425. " decode(grouping(TP_MST_GoodsType.Goodstypename),1,'--',TP_MST_GoodsType.Goodstypename) Goodstypename," +
  8426. " count(barcode) as InCount " +
  8427. " from tp_pm_inproduction " +
  8428. " left join tp_pc_procedure" +
  8429. " on tp_pm_inproduction.FlowProcedureID=tp_pc_procedure.ProcedureID" +
  8430. " 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" +
  8431. " Where 1=1 " +
  8432. " and tp_pm_inproduction.AccountID=:AccountID and tp_pm_inproduction.valueflag=1";
  8433. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  8434. {
  8435. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1";
  8436. selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1";
  8437. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  8438. }
  8439. if (!string.IsNullOrEmpty(se.LineIDS))
  8440. {
  8441. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||tp_pm_inproduction.ProductionLineId||',')>0 ";
  8442. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  8443. }
  8444. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  8445. {
  8446. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||tp_pm_inproduction.FlowProcedureId||',')>0 ";
  8447. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  8448. }
  8449. if (!string.IsNullOrEmpty(se.GoodsCode))
  8450. {
  8451. selSql = selSql + " AND instr(','||:GoodsCode||',',','||tp_pm_inproduction.goodsCode||',')>0 ";
  8452. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  8453. }
  8454. selSql = selSql +
  8455. "group by " +
  8456. " rollup(tp_pc_procedure.ProcedureID, " +
  8457. " tp_pc_procedure.procedurecode, " +
  8458. " tp_pc_procedure.procedurename, " +
  8459. " tp_pm_inproduction.productionlineid, " +
  8460. " tp_pm_inproduction.productionlinecode, " +
  8461. " tp_pm_inproduction.productionlinename, " +
  8462. " substr(TP_MST_GoodsType.Goodstypecode,0,6), " +
  8463. " TP_MST_User.Usercode," +
  8464. " TP_MST_Goods.Goodscode, " +
  8465. " TP_MST_User.UserID," +
  8466. " TP_MST_Goods.GoodsID, " +
  8467. " TP_MST_GoodsType.Goodstypename)) temp ) temp2 " +
  8468. "where 1=1 " +
  8469. "and (Goodstypename!='--')" +
  8470. "or (Goodstypename='--' and UserCode='小计' and subGoodsTypecode!='--') " +
  8471. "or (Goodstypename='--' and UserCode='合计') " +
  8472. "or (Goodstypename='--' and UserCode='总计') )";
  8473. */
  8474. #endregion
  8475. string sqlString = "select t.productionlineid\n" +
  8476. " ,t.productionlinecode\n" +
  8477. " ,decode(gid\n" +
  8478. " ,15\n" +
  8479. " ,'总计【' || t.productionlinename || '】'\n" +
  8480. " ,t.productionlinename) productionlinename\n" +
  8481. " ,t.ProcedureID\n" +
  8482. " ,t.procedurecode\n" +
  8483. " ,decode(gid, 3, '合计【' || t.procedurename || '】', t.procedurename) procedurename\n" +
  8484. " ,t.Goodstypeid2\n" +
  8485. " ,t.Goodstypecode2\n" +
  8486. " ,decode(gid, 1, '小计【' || t.Goodstypename2 || '】', t.Goodstypename2) Goodstypename2\n" +
  8487. " ,t.Goodsid\n" +
  8488. " ,t.Goodscode\n" +
  8489. " ,t.InCount\n" +
  8490. " from (select grouping_id(inp.productionlineid\n" +
  8491. " ,inp.ProcedureID\n" +
  8492. " ,gt2.Goodstypeid\n" +
  8493. " ,inp.Goodsid) gid\n" +
  8494. " ,inp.productionlineid\n" +
  8495. " ,pline.productionlinecode\n" +
  8496. " ,pline.productionlinename\n" +
  8497. " ,inp.ProcedureID\n" +
  8498. " ,p.procedurecode\n" +
  8499. " ,p.procedurename\n" +
  8500. " ,gt2.GoodstypeID GoodstypeID2\n" +
  8501. " ,gt2.Goodstypecode Goodstypecode2\n" +
  8502. " ,gt2.Goodstypename Goodstypename2\n" +
  8503. " ,inp.Goodsid\n" +
  8504. " ,g.Goodscode\n" +
  8505. " ,count(barcode) as InCount\n" +
  8506. " from tp_pm_inproduction inp\n" +
  8507. " inner join tp_pc_procedure p\n" +
  8508. " on inp.ProcedureID = p.ProcedureID\n" +
  8509. " inner join tp_pc_productionline pline\n" +
  8510. " on pline.productionlineid = inp.productionlineid\n" +
  8511. " inner join TP_MST_User u\n" +
  8512. " on inp.userid = u.Userid\n" +
  8513. " inner join TP_MST_Goods g\n" +
  8514. " on inp.goodsid = g.Goodsid\n" +
  8515. " inner join TP_MST_GoodsType gt\n" +
  8516. " on g.GoodsTypeID = gt.GoodsTypeID\n" +
  8517. " inner join TP_MST_GoodsType gt2\n" +
  8518. " on gt.accountid = gt2.accountid\n" +
  8519. " and substr(gt.Goodstypecode, 0, 6) = gt2.Goodstypecode\n" +
  8520. " where inp.AccountID = 1\n" +
  8521. " and inp.valueflag = '1'\n";
  8522. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  8523. {
  8524. //selSql = selSql + " AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1";
  8525. sqlString += " AND instr(gt.GOODSTYPECode,:GoodsTypeIDS)=1";
  8526. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  8527. }
  8528. if (!string.IsNullOrEmpty(se.LineIDS))
  8529. {
  8530. sqlString += " AND instr(','||:ProductionLineIDS||',',','||inp.ProductionLineId||',')>0 ";
  8531. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  8532. }
  8533. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  8534. {
  8535. sqlString += " AND instr(','||:ProcedureIDS||',',','||inp.ProcedureId||',')>0 ";
  8536. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  8537. }
  8538. if (!string.IsNullOrEmpty(se.GoodsCode))
  8539. {
  8540. sqlString += " AND instr(','||:GoodsCode||',',','||inp.goodsCode||',')>0 ";
  8541. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  8542. }
  8543. 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";
  8544. return sqlString;
  8545. }
  8546. /// <summary>
  8547. /// 取得RPT030105(在产产品汇总表)的汇总信息查询数据
  8548. /// </summary>
  8549. /// <param name="user">登录用户信息</param>
  8550. /// <param name="se">查询条件</param>
  8551. /// <returns>查询结果</returns>
  8552. public static ServiceResultEntity GetRPT030105IData(SUserInfo user, RPT030105_SE se)
  8553. {
  8554. IDBConnection conn = null;
  8555. try
  8556. {
  8557. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8558. List<OracleParameter> parameters = new List<OracleParameter>();
  8559. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030105ISQL(user, se, ref parameters));
  8560. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8561. if (se != null)
  8562. {
  8563. if (!string.IsNullOrEmpty(se.GoodsTypeIDS))
  8564. {
  8565. //sql.Append(" AND instr(','||:GoodsTypeIDS||',',','||TP_MST_GOODSTYPE.GOODSTYPECode||',')=1");
  8566. sql.Append(" AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeIDS)=1");
  8567. parameters.Add(new OracleParameter(":GoodsTypeIDS", OracleDbType.NVarchar2, se.GoodsTypeIDS, ParameterDirection.Input));
  8568. }
  8569. if (!string.IsNullOrEmpty(se.LineIDS))
  8570. {
  8571. sql.Append(" AND instr(','||:ProductionLineIDS||',',','||tp_pm_inproduction.ProductionLineId||',')>0 ");
  8572. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  8573. }
  8574. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  8575. {
  8576. sql.Append(" AND instr(','||:ProcedureIDS||',',','||tp_pm_inproduction.FlowProcedureId||',')>0 ");
  8577. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  8578. }
  8579. if (!string.IsNullOrEmpty(se.GoodsCode))
  8580. {
  8581. sql.Append(" AND instr(','||:GoodsCode||',',','||tp_pm_inproduction.goodsCode||',')>0 ");
  8582. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  8583. }
  8584. // 总单点击查询用
  8585. if (se.GoodsID.HasValue)
  8586. {
  8587. sql.Append(" AND tp_pm_inproduction.Goodsid = :GoodsID ");
  8588. parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  8589. }
  8590. if (se.UserID.HasValue)
  8591. {
  8592. sql.Append(" AND A.userid = :userid ");
  8593. parameters.Add(new OracleParameter(":userid", OracleDbType.Int32, se.UserID, ParameterDirection.Input));
  8594. }
  8595. }
  8596. sql.Append(" order by TP_PM_InProduction.UpdateTime desc");
  8597. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  8598. ServiceResultEntity sre = new ServiceResultEntity();
  8599. if (data == null || data.Rows.Count == 0)
  8600. {
  8601. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8602. return sre;
  8603. }
  8604. sre.Data = new DataSet();
  8605. sre.Data.Tables.Add(data);
  8606. return sre;
  8607. }
  8608. catch (Exception ex)
  8609. {
  8610. throw ex;
  8611. }
  8612. finally
  8613. {
  8614. if (conn != null &&
  8615. conn.ConnState == ConnectionState.Open)
  8616. {
  8617. conn.Close();
  8618. }
  8619. }
  8620. }
  8621. /// <summary>
  8622. /// 获取RPT030105画面(产品产量汇总表)的汇总信息查询sql
  8623. /// </summary>
  8624. /// <returns>sql</returns>
  8625. private static string GetRPT030105ISQL(SUserInfo user, RPT030105_SE se, ref List<OracleParameter> parameters)
  8626. {
  8627. string selSql =
  8628. "SELECT " +
  8629. " TP_PM_InProduction.BarCode, " +
  8630. " TP_PM_InProduction.GoodsID,TP_PM_InProduction.GoodsCode, " +
  8631. " TP_PM_InProduction.GoodsName, " +
  8632. " TP_PM_InProduction.Userid,A.USERNAME as UserName,A.USERCode as UserCode, " +
  8633. " TP_PM_InProduction.ProductionLineID, " +
  8634. " TP_PM_InProduction.ProductionLineCode, " +
  8635. " TP_PM_InProduction.ProductionLineName, " +
  8636. " TP_PM_InProduction.ModelType, " +
  8637. " decode(TP_PM_InProduction.inscrapflag , '1', '待审核的报废品' , '正常') as inscrapflag, " +
  8638. //" decode(TP_PM_InProduction.IsPublicBody, '1', '是' , '否') as IsPublicBody, " +
  8639. //" decode(TP_PM_InProduction.IsReFire, '1', '是' , '否') as IsReFire, " +
  8640. " TP_PM_InProduction.IsPublicBody, " +
  8641. " decode(TP_PM_InProduction.IsReFire, '6', '1' , '0') as IsReFire, " +
  8642. " decode(TP_PM_InProduction.CanManyTimes, '1', '能' , '不能') as CanManyTimes, " +
  8643. " decode(TP_PM_InProduction.ProcedureModel, '1', '计件模型' , '检验模型') as ProcedureModel, " +
  8644. " TP_PM_InProduction.GroutingDailyID, " +
  8645. " TP_PM_InProduction.GroutingDailyDetailID, " +
  8646. " TP_PM_InProduction.GroutingDate, " +
  8647. " TP_PM_InProduction.GroutingLineID, " +
  8648. " TP_PM_InProduction.GroutingLineCode, " +
  8649. " TP_PM_InProduction.GroutingLineName, " +
  8650. " TP_PM_InProduction.ProcedureID CompleteProcedureID, " +
  8651. " D.ProcedureName as CompleteProcedureName, " +
  8652. " TP_PM_InProduction.GMouldTypeID, " +
  8653. " TP_MST_GMouldType.GMOULDTYPENAME as GMouldTypeName, " +
  8654. " TP_PM_InProduction.GroutingLineDetailID, " +
  8655. " TP_PM_InProduction.GroutingMouldCode, " +
  8656. " TP_PM_InProduction.SPECIALREPAIRFLAG, " +
  8657. " TP_PM_InProduction.GROUTINGUSERCODE, " +
  8658. " TP_PM_GroutingDailyDetail.GROUTINGCOUNT, " +
  8659. " TP_PM_InProduction.Remarks, " +
  8660. " TP_PM_GroutingDailyDetail.glazingroom," +
  8661. " TP_PM_InProduction.GoodsLevelID,TP_MST_GoodsLevel.GOODSLEVELNAME, " +
  8662. " TP_PM_InProduction.GoodsLevelTypeID,TP_SYS_GoodsLevelType.GOODSLEVELTYPENAME, " +
  8663. " TP_PM_InProduction.AccountID,TP_PM_InProduction.ValueFlag, " +
  8664. " TP_PM_InProduction.CreateTime,TP_PM_InProduction.CreateUserID,B.USERNAME as CreateUserName, " +
  8665. " TP_PM_InProduction.PROCEDURETIME AS UpdateTime,TP_PM_InProduction.UpdateUserID,C.USERNAME as UpdateUserName, " +
  8666. " replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName " +
  8667. "FROM TP_PM_InProduction " +
  8668. " inner join TP_MST_User A on A.UserID=TP_PM_InProduction.Userid " +
  8669. " inner join TP_MST_User B on B.UserID=TP_PM_InProduction.CreateUserID " +
  8670. " inner join TP_MST_User C on C.UserID=TP_PM_InProduction.UpdateUserID " +
  8671. " inner join TP_PC_Procedure D on D.PROCEDUREID=TP_PM_InProduction.ProcedureID " +
  8672. " inner join TP_MST_GMouldType on TP_MST_GMouldType.GMouldTypeID=TP_PM_InProduction.GMouldTypeID " +
  8673. " inner join TP_SYS_ProcedureModelType on TP_SYS_ProcedureModelType.ProcedureModelTypeID=TP_PM_InProduction.ModelType " +
  8674. " inner join TP_PM_GroutingDaily on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_InProduction.GroutingDailyID " +
  8675. " inner join TP_PM_GroutingDailyDetail on TP_PM_GroutingDailyDetail.Groutingdailydetailid=TP_PM_InProduction.GroutingDailyDetailID " +
  8676. " inner join TP_PC_GroutingLineDetail on TP_PC_GroutingLineDetail.Groutinglinedetailid=TP_PM_InProduction.GroutingLineDetailID " +
  8677. " inner join TP_MST_Account on TP_MST_Account.Accountid=TP_PM_InProduction.Accountid " +
  8678. " left join TP_MST_GoodsLevel on TP_MST_GoodsLevel.GoodsLevelID=TP_PM_InProduction.GoodsLevelID " +
  8679. " left join TP_SYS_GoodsLevelType on TP_SYS_GoodsLevelType.GoodsLevelTypeID=TP_PM_InProduction.GoodsLevelTypeID " +
  8680. " left join TP_MST_Logo on TP_PM_InProduction.logoid=TP_MST_Logo.logoid " +
  8681. " left join TP_MST_Goods on tp_pm_inproduction.goodsid=TP_MST_Goods.Goodsid " +
  8682. " left join TP_MST_GoodsType on TP_MST_Goods.GoodsTypeID=TP_MST_GoodsType.GoodsTypeID" +
  8683. " Where 1=1 and TP_PM_InProduction.ValueFlag = 1 " +
  8684. " and TP_PM_InProduction.AccountID=:AccountID ";
  8685. return selSql;
  8686. }
  8687. #endregion
  8688. /// <summary>
  8689. /// 取得RPT030106(成检缺陷汇总表)的汇总信息查询数据
  8690. /// </summary>
  8691. /// <param name="user">登录用户信息</param>
  8692. /// <param name="se">查询条件</param>
  8693. /// <returns>查询结果</returns>
  8694. public static ServiceResultEntity GetRPT030106Data(SUserInfo user, RPT030106_SE se)
  8695. {
  8696. IDBConnection conn = null;
  8697. try
  8698. {
  8699. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  8700. List<OracleParameter> parameters = new List<OracleParameter>();
  8701. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106SQL(user, se, ref parameters));
  8702. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  8703. ServiceResultEntity sre = new ServiceResultEntity();
  8704. if (data == null || data.Rows.Count == 0)
  8705. {
  8706. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  8707. return sre;
  8708. }
  8709. sre.Data = new DataSet();
  8710. sre.Data.Tables.Add(data);
  8711. return sre;
  8712. }
  8713. catch (Exception ex)
  8714. {
  8715. throw ex;
  8716. }
  8717. finally
  8718. {
  8719. if (conn != null &&
  8720. conn.ConnState == ConnectionState.Open)
  8721. {
  8722. conn.Close();
  8723. }
  8724. }
  8725. }
  8726. /// <summary>
  8727. /// 获取RPT030106画面(成检缺陷汇总表)的汇总信息查询sql
  8728. /// </summary>
  8729. /// <returns>sql</returns>
  8730. private static string GetRPT030106SQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
  8731. {
  8732. #region
  8733. //string selSql = "";
  8734. //parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  8735. //selSql = selSql +
  8736. // "select " +
  8737. // " DefectProcedureID," +
  8738. // " DefectProcedureCode, " +
  8739. // " decode(DefectProcedureID, '总计', '--', decode(DefectCode, '小计', decode(DefectProcedureName, '', '', '--'), DefectProcedureName)) DefectProcedureName," +
  8740. // " ProductionLineID, " +
  8741. // " ProductionLineCode," +
  8742. // " decode(DefectProcedureID, '总计', '总计', decode(DefectCode, '小计', '--', ProductionLineName)) ProductionLineName, " +
  8743. // " ProcedureID, " +
  8744. // " ProcedureCode," +
  8745. // " decode(DefectCode, '小计', '--', ProcedureName) ProcedureName," +
  8746. // " DefectCode, " +
  8747. // " DefectName, " +
  8748. // " DefectTypeName, " +
  8749. // " Userid," +
  8750. // " Usercode," +
  8751. // " Username," +
  8752. // " Goodstypename," +
  8753. // " Goodsid," +
  8754. // " Goodscode," +
  8755. // " Goodsname," +
  8756. // " InCount from (" +
  8757. // "select " +
  8758. // " DefectProcedureID," +
  8759. // " DefectProcedureCode, " +
  8760. // " decode(DefectProcedureCode, '--', '合计', DefectProcedureName) DefectProcedureName, " +
  8761. // " ProductionLineID, " +
  8762. // " ProductionLineCode, " +
  8763. // " ProductionLineName, " +
  8764. // " ProcedureID, " +
  8765. // " ProcedureCode, " +
  8766. // " ProcedureName, " +
  8767. // " decode(DefectName, '--', decode(DefectCode, '--', '--', '小计'), DefectCode) DefectCode, " +
  8768. // " DefectName, " +
  8769. // " DefectTypeName, " +
  8770. // " Userid, " +
  8771. // " Usercode, " +
  8772. // " Username, " +
  8773. // " Goodstypename, " +
  8774. // " Goodsid, " +
  8775. // " Goodscode, " +
  8776. // " Goodsname, " +
  8777. // " InCount " +
  8778. // "from " +
  8779. // "(" +
  8780. // " select " +
  8781. // " decode(grouping(TP_PM_Defect.DefectProcedureID),1,'总计',TP_PM_Defect.DefectProcedureID) DefectProcedureID, " +
  8782. // " decode(grouping(TP_PM_Defect.DefectProcedureCode),1,'--',TP_PM_Defect.DefectProcedureCode) DefectProcedureCode, " +
  8783. // " decode(grouping(TP_PM_Defect.DefectProcedureName),1,'--',TP_PM_Defect.DefectProcedureName) DefectProcedureName, " +
  8784. // " decode(grouping(TP_PM_Defect.ProductionLineID),1,'--',TP_PM_Defect.ProductionLineID) ProductionLineID, " +
  8785. // " decode(grouping(TP_PM_Defect.ProductionLineCode),1,'--',TP_PM_Defect.ProductionLineCode) ProductionLineCode, " +
  8786. // " decode(grouping(TP_PM_Defect.ProductionLineName),1,'--',TP_PM_Defect.ProductionLineName) ProductionLineName, " +
  8787. // " decode(grouping(TP_PM_Defect.ProcedureID),1,'--',TP_PM_Defect.ProcedureID) ProcedureID, " +
  8788. // " decode(grouping(TP_PM_Defect.ProcedureCode),1,'--',TP_PM_Defect.ProcedureCode) ProcedureCode," +
  8789. // " decode(grouping(TP_PM_Defect.ProcedureName),1,'--',TP_PM_Defect.ProcedureName) ProcedureName," +
  8790. // " decode(grouping(TP_PM_Defect.DefectCode),1,'--',TP_PM_Defect.DefectCode) DefectCode, " +
  8791. // " decode(grouping(TP_PM_Defect.DefectName),1,'--',TP_PM_Defect.DefectName) DefectName, " +
  8792. // " decode(grouping(TP_MST_DefectType.DefectTypeName),1,'--',TP_MST_DefectType.DefectTypeName) DefectTypeName, " +
  8793. // " decode(grouping(TP_PM_Defect.Userid),1,'--',TP_PM_Defect.Userid) Userid, " +
  8794. // " decode(grouping(TP_PM_Defect.Usercode),1,'--',TP_PM_Defect.Usercode) Usercode, " +
  8795. // " decode(grouping(TP_PM_Defect.Username),1,'--',TP_PM_Defect.Username) Username, " +
  8796. // " decode(grouping(TP_MST_GoodsType.Goodstypename),1,'--',TP_MST_GoodsType.Goodstypename) Goodstypename, " +
  8797. // " decode(grouping(TP_PM_Defect.Goodsid),1,'--',TP_PM_Defect.Goodsid) Goodsid, " +
  8798. // " decode(grouping(TP_PM_Defect.Goodscode),1,'--',TP_PM_Defect.Goodscode) Goodscode, " +
  8799. // " decode(grouping(TP_PM_Defect.Goodsname),1,'--',TP_PM_Defect.Goodscode) Goodsname, " +
  8800. // " count(TP_PM_Defect.barcode) as InCount " +
  8801. // " from TP_PM_Defect " +
  8802. // " left join tp_pc_procedure on TP_PM_Defect.ProcedureID=tp_pc_procedure.ProcedureID " +
  8803. // " left join TP_MST_Goods on TP_PM_Defect.Goodsid=TP_MST_Goods.Goodsid" +
  8804. // " left join TP_MST_GoodsType on TP_MST_Goods.GoodsTypeID = TP_MST_GoodsType.GoodsTypeID" +
  8805. // " left join TP_MST_Defect on TP_PM_Defect.DefectID=TP_MST_Defect.DefectID" +
  8806. // " left join TP_MST_DefectType on TP_MST_Defect.DefectTypeID=TP_MST_DefectType.DefectTypeID" +
  8807. // " left join TP_PM_ProductionData on TP_PM_ProductionData.ProductionDataID=TP_PM_Defect.ProductionDataID" +
  8808. // " Where TP_PM_Defect.valueflag=1 and tp_pc_procedure.ModelType=-1" +
  8809. // " and TP_PM_Defect.AccountID=:AccountID ";
  8810. //if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  8811. //{
  8812. // selSql = selSql + " AND instr(TP_MST_GOODSTYPE.GOODSTYPECode,:GoodsTypeCode)=1 ";
  8813. // parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  8814. //}
  8815. //if (!string.IsNullOrEmpty(se.LineIDS))
  8816. //{
  8817. // selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||TP_PM_Defect.ProductionLineId||',')>0 ";
  8818. // parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  8819. //}
  8820. //if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  8821. //{
  8822. // //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  8823. // selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 ) ";
  8824. // parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  8825. //}
  8826. //else
  8827. //{
  8828. // // modify by chenxy :没有选择时,应全查询出来。
  8829. // //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  8830. //}
  8831. //if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  8832. //{
  8833. // selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||TP_PM_Defect.ProcedureID||',')>0 ";
  8834. // parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  8835. //}
  8836. //if (!string.IsNullOrEmpty(se.KilnCode))
  8837. //{
  8838. // selSql = selSql + " AND instr(tp_pm_productiondata.KilnCode,:KilnCode) >0 ";
  8839. // parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  8840. //}
  8841. //if (!string.IsNullOrEmpty(se.GoodsIDS))
  8842. //{
  8843. // selSql = selSql + " AND instr(','||:GoodsIDS||',',','||TP_PM_Defect.Goodsid||',')>0 ";
  8844. // parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  8845. //}
  8846. //if (!string.IsNullOrEmpty(se.GoodsCode))
  8847. //{
  8848. // selSql = selSql + " AND instr(TP_PM_Defect.goodsCode,:GoodsCode) >0 ";
  8849. // parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  8850. //}
  8851. //if (!string.IsNullOrEmpty(se.DefectUserCode))
  8852. //{
  8853. // selSql = selSql + " AND instr(TP_PM_Defect.DefectUserCode,:DefectUserCode) >0 ";
  8854. // parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  8855. //}
  8856. //if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  8857. //{
  8858. // selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||TP_MST_DefectType.DefectTypeID||',')>0 ";
  8859. // parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  8860. //}
  8861. //if (!string.IsNullOrEmpty(se.DefectCode))
  8862. //{
  8863. // selSql = selSql + " AND instr(TP_PM_Defect.DefectCode,:DefectCode) >0 ";
  8864. // parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  8865. //}
  8866. //if (!string.IsNullOrEmpty(se.DefectName))
  8867. //{
  8868. // selSql = selSql + " AND instr(TP_PM_Defect.DefectName,:DefectName) >0";
  8869. // parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  8870. //}
  8871. //if (!string.IsNullOrEmpty(se.CheckUserCode))
  8872. //{
  8873. // selSql = selSql + " AND instr(TP_PM_Defect.UserCode,:UserCode) >0";
  8874. // parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  8875. //}
  8876. //if (se.CreateTimeStart.HasValue)
  8877. //{
  8878. // selSql = selSql + " AND TP_PM_Defect.CreateTime>= :CreateTimeStart ";
  8879. // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  8880. //}
  8881. //if (se.CreateTimeEnd.HasValue)
  8882. //{
  8883. // selSql = selSql + " AND TP_PM_Defect.CreateTime<= :CreateTimeEnd ";
  8884. // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  8885. //}
  8886. //selSql = selSql +
  8887. // "group by " +
  8888. // " rollup(TP_PM_Defect.DefectProcedureID, " +
  8889. // " TP_PM_Defect.DefectProcedureCode, " +
  8890. // " TP_PM_Defect.DefectProcedureName, " +
  8891. // " TP_PM_Defect.ProductionLineID, " +
  8892. // " TP_PM_Defect.ProductionLineCode, " +
  8893. // " TP_PM_Defect.ProductionLineName, " +
  8894. // " TP_PM_Defect.ProcedureID, " +
  8895. // " TP_PM_Defect.ProcedureCode," +
  8896. // " TP_PM_Defect.ProcedureName, " +
  8897. // " TP_PM_Defect.DefectCode, " +
  8898. // " TP_PM_Defect.DefectName, " +
  8899. // " TP_MST_DefectType.DefectTypeName, " +
  8900. // " TP_PM_Defect.Userid, " +
  8901. // " TP_PM_Defect.Usercode, " +
  8902. // " TP_PM_Defect.Username, " +
  8903. // " TP_MST_GoodsType.Goodstypename, " +
  8904. // " TP_PM_Defect.Goodsid, " +
  8905. // " TP_PM_Defect.Goodscode, " +
  8906. // " TP_PM_Defect.Goodsname " +
  8907. // " )) temp ) temp2 " +
  8908. // "where 1=1 " +
  8909. // "and ((Goodsname!='--' )" +
  8910. // "or (Goodsname='--' and defectcode='小计')" +
  8911. // "or (Goodsname='--' and DefectProcedurename='合计') " +
  8912. // "or (Goodsname='--' and DefectProcedureID='总计'))";
  8913. //////----------------------
  8914. ////if (!string.IsNullOrEmpty(se.CompleteProcedureIDS))
  8915. ////{
  8916. //// selSql = selSql + @" AND exists(select 1 from tp_pm_productiondata where (instr(','||:CompleteProcedureIDS||',',','||ProcedureID||',')>0 ";
  8917. //// parameters.Add(new OracleParameter(":CompleteProcedureIDS", OracleDbType.NVarchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  8918. //// selSql = selSql + " AND TP_PM_ProductionData.CreateTime>= :CompleteCreateTimeStart ";
  8919. //// parameters.Add(new OracleParameter(":CompleteCreateTimeStart", OracleDbType.Date, se.CompleteCreateTimeStart.Value, ParameterDirection.Input));
  8920. //// selSql = selSql + " AND TP_PM_ProductionData.CreateTime<= :CompleteCreateTimeEnd )) ";
  8921. //// parameters.Add(new OracleParameter(":CompleteCreateTimeEnd", OracleDbType.Date, se.CompleteCreateTimeEnd.Value, ParameterDirection.Input));
  8922. ////}
  8923. //////----------------------
  8924. //return selSql;
  8925. #endregion
  8926. string selSql =
  8927. "SELECT t.ProductionLineID\n" +
  8928. " ,t.ProductionLineCode\n" +
  8929. " ,decode(t.gid, 31, '总计', 0, t.ProductionLineName, '--') ProductionLineName\n" +
  8930. " ,t.ProcedureID\n" +
  8931. " ,t.ProcedureCode\n" +
  8932. " ,decode(t.gid, 0, t.ProcedureName, '--') ProcedureName\n" +
  8933. " ,t.DefectProcedureID\n" +
  8934. " ,t.DefectProcedureCode\n" +
  8935. " ,decode(t.gid,\n" +
  8936. " 7,\n" +
  8937. " '合计【' || t.DefectProcedureName || '】',\n" +
  8938. " 0,\n" +
  8939. " t.DefectProcedureName,\n" +
  8940. " '--') DefectProcedureName\n" +
  8941. " ,decode(t.gid, 0, t.DefectCode, '--') DefectCode\n" +
  8942. " ,decode(t.gid,\n" +
  8943. " 3,\n" +
  8944. " '小计【[' || t.DefectCode || ']' || t.DefectName || '】',\n" +
  8945. " 0,\n" +
  8946. " t.DefectName,\n" +
  8947. " '--') DefectName\n" +
  8948. " ,decode(t.gid, 0, t.DefectTypeName, '--') DefectTypeName\n" +
  8949. " --,decode(t.gid, 0, t.Userid, '--') Userid\n" +
  8950. " ,t.Userid\n" +
  8951. " ,decode(t.gid, 0, t.Usercode, '--') Usercode\n" +
  8952. " ,decode(t.gid, 0, t.Username, '--') Username\n" +
  8953. " ,decode(t.gid, 0, t.Goodstypename, '--') Goodstypename\n" +
  8954. " --,decode(t.gid, 0, t.Goodsid, '--') Goodsid\n" +
  8955. " ,t.Goodsid\n" +
  8956. " ,decode(t.gid, 0, t.Goodscode, '--') Goodscode\n" +
  8957. " ,decode(t.gid, 0, t.Goodsname, '--') Goodsname\n" +
  8958. " ,t.InCount\n" +
  8959. " FROM (SELECT grouping_id(pmd.ProductionLineID,\n" +
  8960. " pmd.DefectProcedureID,\n" +
  8961. " pmd.DefectCode,\n" +
  8962. " pmd.userid,\n" +
  8963. " pmd.goodsid) gid\n" +
  8964. " ,pmd.ProductionLineID\n" +
  8965. " ,pmd.ProductionLineCode\n" +
  8966. " ,pmd.ProductionLineName\n" +
  8967. " ,pmd.ProcedureID\n" +
  8968. " ,pmd.ProcedureCode\n" +
  8969. " ,pmd.ProcedureName\n" +
  8970. " ,pmd.DefectProcedureID\n" +
  8971. " ,pmd.DefectProcedureCode\n" +
  8972. " ,pmd.DefectProcedureName\n" +
  8973. " ,pmd.DefectCode\n" +
  8974. " ,pmd.DefectName\n" +
  8975. " ,dt.DefectTypeName\n" +
  8976. " ,pmd.Userid\n" +
  8977. " ,pmd.Usercode\n" +
  8978. " ,pmd.Username\n" +
  8979. " ,gt.Goodstypename\n" +
  8980. " ,pmd.Goodsid\n" +
  8981. " ,pmd.Goodscode\n" +
  8982. " ,pmd.Goodsname\n" +
  8983. " ,COUNT(pmd.barcode) InCount\n" +
  8984. " FROM tp_pm_defect pmd\n" +
  8985. " LEFT JOIN TP_MST_Goods g\n" +
  8986. " ON pmd.Goodsid = g.Goodsid\n" +
  8987. " LEFT JOIN TP_MST_GoodsType gt\n" +
  8988. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  8989. " LEFT JOIN TP_MST_Defect mstd\n" +
  8990. " ON pmd.DefectID = mstd.DefectID\n" +
  8991. " LEFT JOIN TP_MST_DefectType dt\n" +
  8992. " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
  8993. " INNER JOIN tp_pm_productiondata pd\n" +
  8994. " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
  8995. " -- 交接工序\n" +
  8996. " INNER JOIN tp_pm_productiondata hopd\n" +
  8997. " ON hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  8998. " AND hopd.valueflag = '1'\n" +
  8999. " AND hopd.barcode = pd.barcode\n" +
  9000. " AND hopd.kilncarbatchno = pd.kilncarbatchno\n" +
  9001. " WHERE pmd.valueflag = '1'\n" +
  9002. " AND pd.ModelType = -1\n" +
  9003. " AND pmd.AccountID = :AccountID\n";
  9004. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  9005. parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
  9006. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  9007. {
  9008. selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
  9009. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  9010. }
  9011. if (!string.IsNullOrEmpty(se.LineIDS))
  9012. {
  9013. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
  9014. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  9015. }
  9016. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  9017. {
  9018. //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  9019. selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
  9020. parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  9021. }
  9022. else
  9023. {
  9024. // modify by chenxy :没有选择时,应全查询出来。
  9025. //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  9026. }
  9027. if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  9028. {
  9029. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
  9030. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  9031. }
  9032. if (!string.IsNullOrEmpty(se.KilnCode))
  9033. {
  9034. selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
  9035. parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  9036. }
  9037. if (!string.IsNullOrEmpty(se.GoodsIDS))
  9038. {
  9039. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
  9040. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  9041. }
  9042. if (!string.IsNullOrEmpty(se.GoodsCode))
  9043. {
  9044. selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
  9045. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  9046. }
  9047. if (!string.IsNullOrEmpty(se.DefectUserCode))
  9048. {
  9049. selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
  9050. parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  9051. }
  9052. if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  9053. {
  9054. selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
  9055. parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  9056. }
  9057. if (!string.IsNullOrEmpty(se.DefectCode))
  9058. {
  9059. selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
  9060. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  9061. }
  9062. if (!string.IsNullOrEmpty(se.DefectName))
  9063. {
  9064. selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
  9065. parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  9066. }
  9067. if (!string.IsNullOrEmpty(se.CheckUserCode))
  9068. {
  9069. selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
  9070. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  9071. }
  9072. if (se.CreateTimeStart.HasValue)
  9073. {
  9074. selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
  9075. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9076. }
  9077. if (se.CreateTimeEnd.HasValue)
  9078. {
  9079. selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
  9080. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9081. }
  9082. // 交接时间
  9083. if (se.HandOverTimeStart.HasValue)
  9084. {
  9085. selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
  9086. parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
  9087. }
  9088. if (se.HandOverTimeEnd.HasValue)
  9089. {
  9090. selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
  9091. parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
  9092. }
  9093. selSql = selSql +
  9094. " 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" +
  9095. " ORDER BY pmd.ProductionLineCode\n" +
  9096. " ,pmd.ProcedureCode\n" +
  9097. " ,pmd.DefectProcedureCode\n" +
  9098. " ,pmd.DefectCode\n" +
  9099. " ,pmd.Usercode\n" +
  9100. " ,pmd.Goodscode) t";
  9101. return selSql;
  9102. }
  9103. /// <summary>
  9104. /// 取得RPT030106(成检缺陷汇总表-明细)的汇总信息查询数据
  9105. /// </summary>
  9106. /// <param name="user">登录用户信息</param>
  9107. /// <param name="se">查询条件</param>
  9108. /// <returns>查询结果</returns>
  9109. public static ServiceResultEntity GetRPT030106IData(SUserInfo user, RPT030106_SE se)
  9110. {
  9111. IDBConnection conn = null;
  9112. try
  9113. {
  9114. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  9115. List<OracleParameter> parameters = new List<OracleParameter>();
  9116. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106ISQL(user, se, ref parameters));
  9117. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  9118. ServiceResultEntity sre = new ServiceResultEntity();
  9119. if (data == null || data.Rows.Count == 0)
  9120. {
  9121. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  9122. return sre;
  9123. }
  9124. sre.Data = new DataSet();
  9125. sre.Data.Tables.Add(data);
  9126. return sre;
  9127. }
  9128. catch (Exception ex)
  9129. {
  9130. throw ex;
  9131. }
  9132. finally
  9133. {
  9134. if (conn != null &&
  9135. conn.ConnState == ConnectionState.Open)
  9136. {
  9137. conn.Close();
  9138. }
  9139. }
  9140. }
  9141. /// <summary>
  9142. /// 获取RPT030106画面(成检缺陷汇总表-明细)的汇总信息查询sql
  9143. /// </summary>
  9144. /// <returns>sql</returns>
  9145. private static string GetRPT030106ISQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
  9146. {
  9147. // string selSql = @"select
  9148. // tp_pm_defect.productionlinename,
  9149. // tp_pm_defect.procedurename,
  9150. // tp_pm_defect.DefectProcedureCode,
  9151. // tp_pm_defect.DefectProcedureName,
  9152. // tp_pm_defect.DefectUserCode,
  9153. // tp_pm_defect.defectusername,
  9154. // tp_mst_defectType.DefectTypeName,
  9155. // TP_MST_Defect.Remarks DefectRemarks,
  9156. // tp_pm_defect.defectcode,
  9157. // tp_pm_defect.defectname,
  9158. // tp_pm_defect.UserCode,
  9159. // tp_pm_defect.username,
  9160. // tp_mst_goodstype.Goodstypename,
  9161. // tp_pm_defect.goodscode,
  9162. // tp_pm_defect.barcode,
  9163. // tp_pm_productiondata.groutingdate,
  9164. // tp_pm_productiondata.groutingnum,
  9165. // tp_pm_productiondata.groutingMouldCode,
  9166. // tp_pm_productiondata.KilnCarCode,
  9167. // tp_pm_productiondata.Procedureid,
  9168. // decode(TP_PM_ProductionData.Goodsleveltypeid, '4', '正品' , '5','副品','6','重烧','7','次品','') as Goodsleveltype,
  9169. // tp_pm_defect.DefectPositionCode,
  9170. // tp_pm_defect.DefectPositionName,
  9171. // tp_pm_productiondata.GroutingUserCode,
  9172. // --replace((TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']'),'[]','') as LogoCodeName
  9173. // decode(TP_MST_Logo.Logocode, null, null,TP_MST_Logo.Logoname||'['||TP_MST_Logo.Logocode||']')) as LogoCodeName
  9174. // ,TP_PM_Defect.CreateTime
  9175. // ,(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
  9176. // ,TP_MST_DefectFine.DefectFineCode
  9177. // ,TP_PM_Defect.DefectDeductionNum
  9178. // from tp_pm_defect
  9179. // left join TP_MST_Goods
  9180. // on TP_PM_Defect.Goodsid=TP_MST_Goods.Goodsid
  9181. // left join TP_MST_GoodsType
  9182. // on TP_MST_Goods.GoodsTypeID = TP_MST_GoodsType.GoodsTypeID
  9183. // left join TP_MST_Defect
  9184. // on TP_PM_Defect.DefectID=TP_MST_Defect.DefectID
  9185. // left join TP_MST_DefectType
  9186. // on TP_MST_Defect.DefectTypeID=TP_MST_DefectType.DefectTypeID
  9187. // inner join tp_pm_productiondata
  9188. // on tp_pm_defect.ProductionDataID=tp_pm_productiondata.ProductionDataID
  9189. // left join TP_MST_DefectFine
  9190. // on tp_pm_defect.DefectFine=TP_MST_DefectFine.DefectFineID
  9191. // left join tp_mst_logo
  9192. // on tp_pm_productiondata.logoid=tp_mst_logo.logoid";
  9193. // 质量登记改判时,缺陷的登记时间是当前时间,不是交接或前次登记时间。
  9194. // 追加交接时间,改判标识。
  9195. string selSql =
  9196. "SELECT pmd.productionlinename\n" +
  9197. " ,pmd.procedurename\n" +
  9198. " ,pmd.DefectProcedureCode\n" +
  9199. " ,pmd.DefectProcedureName\n" +
  9200. " ,pmd.DefectUserCode\n" +
  9201. " ,pmd.defectusername\n" +
  9202. " ,dt.DefectTypeName\n" +
  9203. " ,mstd.Remarks DefectRemarks\n" +
  9204. " ,pmd.defectcode\n" +
  9205. " ,d.alldefectcode\n" +
  9206. " ,pmd.defectname\n" +
  9207. " ,pmd.UserCode\n" +
  9208. " ,pmd.username\n" +
  9209. " ,gt.Goodstypename\n" +
  9210. " ,pmd.goodscode\n" +
  9211. " ,pmd.barcode\n" +
  9212. " ,pd.groutingdate\n" +
  9213. " ,pd.groutingnum\n" +
  9214. " ,pd.groutingMouldCode\n" +
  9215. " ,pd.groutingLineCode\n" +
  9216. " ,pd.KilnCarCode\n" +
  9217. " ,pd.Procedureid\n" +
  9218. " ,gl.goodslevelname Goodsleveltype\n" +
  9219. " ,pmd.DefectPositionCode\n" +
  9220. " ,pmd.DefectPositionName\n" +
  9221. " ,pd.GroutingUserCode\n" +
  9222. " , CASE\n" +
  9223. " WHEN logo.logoid IS NULL THEN\n" +
  9224. " NULL\n" +
  9225. " ELSE\n" +
  9226. " logo.Logoname || '[' || logo.Logocode || ']'\n" +
  9227. " END AS LogoCodeName\n" +
  9228. " ,pmd.CreateTime\n" +
  9229. " ,mstdf.DefectFineCode\n" +
  9230. " ,pmd.DefectDeductionNum\n" +
  9231. //" ,to_char(pmd.DefectDeductionNum, '990.00') DefectDeductionNum\n" +
  9232. " ,hopd.createtime handovertime\n" +
  9233. " ,(SELECT listagg(to_char(pduc.UserCode), ',') within GROUP(ORDER BY pduc.ProductionDataID) AS WorkUserCodes\n" +
  9234. " FROM tp_pm_ProductionData pduc\n" +
  9235. " WHERE pduc.barcode = pmd.barcode\n" +
  9236. " AND pduc.valueflag = '1') AS WorkUserCodes\n" +
  9237. " ,(SELECT listagg(to_char(u.UserCode), ',') within GROUP(ORDER BY pdcu.ProductionDataID) AS CreateUserCodes\n" +
  9238. " FROM tp_pm_ProductionData pdcu\n" +
  9239. " Left join tp_mst_user u on u.userid = pdcu.createuserid\n" +
  9240. " WHERE pdcu.barcode = pmd.barcode\n" +
  9241. " AND pdcu.valueflag = '1') AS CreateUserCodes\n" +
  9242. " , CASE\n" +
  9243. " WHEN EXISTS (SELECT 1\n" +
  9244. " FROM tp_pm_ProductionData pdud\n" +
  9245. " WHERE pdud.barcode = pmd.barcode\n" +
  9246. " AND pdud.modeltype = -1\n" +
  9247. " AND pdud.procedureid = pd.procedureid\n" +
  9248. " AND pdud.kilncarbatchno = pd.kilncarbatchno\n" +
  9249. " AND pdud.valueflag = '0') THEN\n" +
  9250. " 1\n" +
  9251. " ELSE\n" +
  9252. " 0\n" +
  9253. " END AS undoflag\n" +
  9254. " , CASE\n" +
  9255. " WHEN EXISTS (SELECT 1\n" +
  9256. " FROM tp_pm_semicheck sc\n" +
  9257. " WHERE sc.barcode = pmd.barcode\n" +
  9258. " AND sc.SEMICHECKTYPE = 1\n" +
  9259. " AND sc.valueflag = '1') THEN\n" +
  9260. " 1\n" +
  9261. " ELSE\n" +
  9262. " 0\n" +
  9263. " END reworkflag" +
  9264. " ,gdd.glazingroom" +
  9265. " FROM tp_pm_defect pmd\n" +
  9266. " LEFT JOIN TP_MST_Goods g\n" +
  9267. " ON pmd.Goodsid = g.Goodsid\n" +
  9268. " LEFT JOIN TP_MST_GoodsType gt\n" +
  9269. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  9270. " LEFT JOIN TP_MST_Defect mstd\n" +
  9271. " ON pmd.DefectID = mstd.DefectID\n" +
  9272. " LEFT JOIN TP_MST_DefectType dt\n" +
  9273. " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
  9274. " INNER JOIN tp_pm_productiondata pd\n" +
  9275. " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
  9276. " LEFT JOIN TP_PM_GroutingDailyDetail gdd\n" +
  9277. " ON gdd.Groutingdailydetailid = pd.Groutingdailydetailid\n" +
  9278. " LEFT JOIN tp_mst_goodslevel gl\n" +
  9279. " ON pd.goodslevelid = gl.goodslevelid\n" +
  9280. "-- 交接工序\n" +
  9281. " INNER JOIN tp_pm_productiondata hopd\n" +
  9282. " ON hopd.kilncarbatchno = pd.kilncarbatchno\n " +
  9283. " AND hopd.barcode = pd.barcode\n" +
  9284. " AND hopd.valueflag = '1'\n" +
  9285. " AND hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  9286. " LEFT JOIN TP_MST_DefectFine mstdf\n" +
  9287. " ON pmd.DefectFine = mstdf.DefectFineID\n" +
  9288. " LEFT JOIN tp_mst_logo logo\n" +
  9289. " ON pd.logoid = logo.logoid\n" +
  9290. " LEFT JOIN (SELECT def.barcode, wmsys.wm_concat( to_char(def.defectcode)) alldefectcode\n" +
  9291. " FROM tp_pm_defect def\n" +
  9292. " WHERE def.valueflag = '1'\n" +
  9293. //def.createtime
  9294. " group by def.barcode ) d\n" +
  9295. " ON d.barcode = pmd.barcode\n" +
  9296. " WHERE pmd.valueflag = '1' \n" +
  9297. " AND pd.ModelType = -1\n" +
  9298. " AND pmd.AccountID = :AccountID\n";
  9299. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  9300. parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
  9301. //selSql = selSql +
  9302. // " Where TP_PM_Defect.valueflag='1' and tp_pm_productiondata.ModelType=-1" +
  9303. // " and TP_PM_Defect.AccountID=:AccountID ";
  9304. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  9305. {
  9306. selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
  9307. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  9308. }
  9309. if (!string.IsNullOrEmpty(se.LineIDS))
  9310. {
  9311. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
  9312. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  9313. }
  9314. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  9315. {
  9316. //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  9317. selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
  9318. parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  9319. }
  9320. else
  9321. {
  9322. // modify by chenxy :没有选择时,应全查询出来。
  9323. //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  9324. }
  9325. if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  9326. {
  9327. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
  9328. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  9329. }
  9330. if (!string.IsNullOrEmpty(se.KilnCode))
  9331. {
  9332. selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
  9333. parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  9334. }
  9335. if (!string.IsNullOrEmpty(se.GoodsIDS))
  9336. {
  9337. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
  9338. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  9339. }
  9340. if (!string.IsNullOrEmpty(se.GoodsCode))
  9341. {
  9342. selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
  9343. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  9344. }
  9345. if (!string.IsNullOrEmpty(se.GoodsCodeS2D))
  9346. {
  9347. selSql = selSql + " AND pmd.goodsCode = :GoodsCodeS2D ";
  9348. parameters.Add(new OracleParameter(":GoodsCodeS2D", OracleDbType.NVarchar2, se.GoodsCodeS2D, ParameterDirection.Input));
  9349. }
  9350. if (!string.IsNullOrEmpty(se.DefectUserCode))
  9351. {
  9352. selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
  9353. parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  9354. }
  9355. if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  9356. {
  9357. selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
  9358. parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  9359. }
  9360. if (!string.IsNullOrEmpty(se.DefectCode))
  9361. {
  9362. selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
  9363. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  9364. }
  9365. if (!string.IsNullOrEmpty(se.DefectCodeS2D))
  9366. {
  9367. selSql = selSql + " AND pmd.DefectCode = :DefectCodeS2D ";
  9368. parameters.Add(new OracleParameter(":DefectCodeS2D", OracleDbType.NVarchar2, se.DefectCodeS2D, ParameterDirection.Input));
  9369. }
  9370. if (!string.IsNullOrEmpty(se.DefectName))
  9371. {
  9372. selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
  9373. parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  9374. }
  9375. if (!string.IsNullOrEmpty(se.CheckUserCode))
  9376. {
  9377. selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
  9378. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  9379. }
  9380. if (!string.IsNullOrEmpty(se.CheckUserCodeS2D))
  9381. {
  9382. selSql = selSql + " AND pmd.UserCode = :CheckUserCodeS2D ";
  9383. parameters.Add(new OracleParameter(":CheckUserCodeS2D", OracleDbType.NVarchar2, se.CheckUserCodeS2D, ParameterDirection.Input));
  9384. }
  9385. if (se.CreateTimeStart.HasValue)
  9386. {
  9387. selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
  9388. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9389. }
  9390. if (se.CreateTimeEnd.HasValue)
  9391. {
  9392. selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
  9393. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9394. }
  9395. // 交接时间
  9396. if (se.HandOverTimeStart.HasValue)
  9397. {
  9398. selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
  9399. parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
  9400. }
  9401. if (se.HandOverTimeEnd.HasValue)
  9402. {
  9403. selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
  9404. parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
  9405. }
  9406. //if (!string.IsNullOrEmpty(se.PurViewUserCodeIDS))
  9407. //{
  9408. // selSql = selSql + " AND instr(','||:PurViewUserCodeIDS||',',','||TP_PM_Defect.DefectUserID||',')>0 ";
  9409. // parameters.Add(new OracleParameter(":PurViewUserCodeIDS", OracleDbType.NVarchar2, se.PurViewUserCodeIDS, ParameterDirection.Input));
  9410. //}
  9411. ////----------------------
  9412. //if (!string.IsNullOrEmpty(se.CompleteProcedureIDS))
  9413. //{
  9414. // selSql = selSql + @" AND exists(select 1 from tp_pm_productiondata where (instr(','||:CompleteProcedureIDS||',',','||ProcedureID||',')>0 ";
  9415. // parameters.Add(new OracleParameter(":CompleteProcedureIDS", OracleDbType.NVarchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  9416. // selSql = selSql + " AND TP_PM_ProductionData.CreateTime>= :CompleteCreateTimeStart ";
  9417. // parameters.Add(new OracleParameter(":CompleteCreateTimeStart", OracleDbType.Date, se.CompleteCreateTimeStart.Value, ParameterDirection.Input));
  9418. // selSql = selSql + " AND TP_PM_ProductionData.CreateTime<= :CompleteCreateTimeEnd )) ";
  9419. // parameters.Add(new OracleParameter(":CompleteCreateTimeEnd", OracleDbType.Date, se.CompleteCreateTimeEnd.Value, ParameterDirection.Input));
  9420. //}
  9421. ////----------------------
  9422. selSql = selSql + " order by pmd.productionlinename,pmd.procedurename,pmd.defectprocedurename,pmd.defectusercode ";
  9423. return selSql;
  9424. }
  9425. /// <summary>
  9426. /// 取得RPT030106(成检缺陷汇总表-缺陷登记明细)的汇总信息查询数据
  9427. /// </summary>
  9428. /// <param name="user">登录用户信息</param>
  9429. /// <param name="se">查询条件</param>
  9430. /// <returns>查询结果</returns>
  9431. public static ServiceResultEntity GetRPT030106DData(SUserInfo user, RPT030106_SE se)
  9432. {
  9433. IDBConnection conn = null;
  9434. try
  9435. {
  9436. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  9437. List<OracleParameter> parameters = new List<OracleParameter>();
  9438. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106DSQL(user, se, ref parameters));
  9439. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  9440. ServiceResultEntity sre = new ServiceResultEntity();
  9441. if (data == null || data.Rows.Count == 0)
  9442. {
  9443. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  9444. return sre;
  9445. }
  9446. sre.Data = new DataSet();
  9447. sre.Data.Tables.Add(data);
  9448. return sre;
  9449. }
  9450. catch (Exception ex)
  9451. {
  9452. throw ex;
  9453. }
  9454. finally
  9455. {
  9456. if (conn != null &&
  9457. conn.ConnState == ConnectionState.Open)
  9458. {
  9459. conn.Close();
  9460. }
  9461. }
  9462. }
  9463. /// <summary>
  9464. /// 获取RPT030106画面(成检缺陷汇总表-缺陷登记明细)的汇总信息查询sql
  9465. /// </summary>
  9466. /// <returns>sql</returns>
  9467. private static string GetRPT030106DSQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
  9468. {
  9469. // 质量登记改判时,缺陷的登记时间是当前时间,不是交接或前次登记时间。
  9470. // 追加交接时间,改判标识。
  9471. string selSql =
  9472. "SELECT pmd.productionlinename\n" +
  9473. " ,pmd.procedurename\n" +
  9474. " ,pmd.DefectProcedureCode\n" +
  9475. " ,pmd.DefectProcedureName\n" +
  9476. " ,pmd.DefectUserCode\n" +
  9477. " ,pmd.defectusername\n" +
  9478. " ,jobs.jobsname defectjobsname\n" +
  9479. " ,dt.DefectTypeName\n" +
  9480. " ,mstd.Remarks DefectRemarks\n" +
  9481. " ,pd.Remarks barcodeRemarks\n" +
  9482. " ,pmd.defectcode\n" +
  9483. " ,d.alldefectcode\n" +
  9484. " ,pmd.defectname\n" +
  9485. " ,pmd.UserCode\n" +
  9486. " ,pmd.username\n" +
  9487. " ,gt.Goodstypename\n" +
  9488. " ,pmd.goodscode\n" +
  9489. " ,pmd.barcode\n" +
  9490. " ,pd.groutingdate\n" +
  9491. " ,pd.groutingnum\n" +
  9492. " ,pd.groutingMouldCode\n" +
  9493. " ,pd.GroutingLineCode\n" +
  9494. " ,pd.KilnCarCode\n" +
  9495. " ,pd.Procedureid\n" +
  9496. " ,gl.goodslevelname Goodsleveltype\n" +
  9497. " ,pmd.DefectPositionCode\n" +
  9498. " ,pmd.DefectPositionName\n" +
  9499. " ,pd.GroutingUserCode\n" +
  9500. " , CASE\n" +
  9501. " WHEN logo.logoid IS NULL THEN\n" +
  9502. " NULL\n" +
  9503. " ELSE\n" +
  9504. " logo.Logoname || '[' || logo.Logocode || ']'\n" +
  9505. " END AS LogoCodeName\n" +
  9506. //" ,pmd.CreateTime\n" +
  9507. " ,pd.CheckTime pdchecktime\n" +
  9508. " ,pmd.CheckTime\n" +
  9509. " ,mstdf.DefectFineCode\n" +
  9510. " ,pmd.DefectDeductionNum\n" +
  9511. //" ,to_char(pmd.DefectDeductionNum, '990.00') DefectDeductionNum\n" +
  9512. " ,hopd.createtime handovertime\n" +
  9513. " ,(SELECT listagg(to_char(pduc.UserCode), ',') within GROUP(ORDER BY pduc.ProductionDataID) AS WorkUserCodes\n" +
  9514. " FROM tp_pm_ProductionData pduc\n" +
  9515. " WHERE pduc.barcode = pmd.barcode\n" +
  9516. " AND pduc.valueflag = '1') AS WorkUserCodes\n" +
  9517. " ,(SELECT listagg(to_char(u.UserCode), ',') within GROUP(ORDER BY pdcu.ProductionDataID) AS CreateUserCodes\n" +
  9518. " FROM tp_pm_ProductionData pdcu\n" +
  9519. " Left join tp_mst_user u on u.userid = pdcu.createuserid\n" +
  9520. " WHERE pdcu.barcode = pmd.barcode\n" +
  9521. " AND pdcu.valueflag = '1') AS CreateUserCodes\n" +
  9522. " ,(SELECT listagg(to_char(s.StaffName), ',') within GROUP(ORDER BY s.Staffid) AS DefectStaffNames\n" +
  9523. " FROM TP_PM_DefectResponsible dr\n" +
  9524. " Left join TP_HR_Staff s on s.Staffid = dr.Staffid\n" +
  9525. " WHERE dr.ProductionDefectID = pmd.ProductionDefectID --dr pdcu.valueflag = '1'\n" +
  9526. " ) AS DefectStaffNames\n" +
  9527. " , CASE\n" +
  9528. " WHEN pd.isrefire <> '0' THEN\n" +
  9529. " (select listagg(to_char(d.defectname || '[' || d.defectpositionname || ']')\n" +
  9530. " ,',') within group(order by d.productiondefectid) bsqx\n" +
  9531. " from tp_pm_productiondata p\n" +
  9532. " inner join tp_pm_defect d\n" +
  9533. " on d.productiondataid = p.productiondataid\n" +
  9534. " where p.valueflag = '1'\n" +
  9535. " and d.valueflag = '1'\n" +
  9536. " and p.barcode = pd.barcode\n" +
  9537. " and p.modeltype = -1\n" +
  9538. " and p.isrefire = '0')\n" +
  9539. " ELSE\n" +
  9540. " null\n" +
  9541. " END AS bsqx\n" +
  9542. " , CASE\n" +
  9543. " WHEN EXISTS (SELECT 1\n" +
  9544. " FROM tp_pm_ProductionData pdud\n" +
  9545. " WHERE pdud.barcode = pmd.barcode\n" +
  9546. " AND pdud.modeltype = -1\n" +
  9547. " AND pdud.procedureid = pd.procedureid\n" +
  9548. " AND pdud.kilncarbatchno = pd.kilncarbatchno\n" +
  9549. " AND pdud.valueflag = '0') THEN\n" +
  9550. " 1\n" +
  9551. " ELSE\n" +
  9552. " 0\n" +
  9553. " END AS undoflag\n" +
  9554. " FROM tp_pm_defect pmd\n" +
  9555. " LEFT JOIN TP_PC_Procedure p\n" +
  9556. " ON p.procedureid = pmd.procedureid\n" +
  9557. " LEFT JOIN TP_PC_Procedure pdd\n" +
  9558. " ON pdd.procedureid = pmd.defectprocedureid\n" +
  9559. " LEFT JOIN TP_MST_Goods g\n" +
  9560. " ON pmd.Goodsid = g.Goodsid\n" +
  9561. " LEFT JOIN TP_MST_GoodsType gt\n" +
  9562. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  9563. " LEFT JOIN TP_MST_Defect mstd\n" +
  9564. " ON pmd.DefectID = mstd.DefectID\n" +
  9565. " LEFT JOIN TP_MST_Jobs jobs\n" +
  9566. " ON jobs.jobsid = pmd.Defectjobs\n" +
  9567. " LEFT JOIN TP_MST_DefectType dt\n" +
  9568. " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
  9569. " INNER JOIN tp_pm_productiondata pd\n" +
  9570. " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
  9571. " LEFT JOIN tp_mst_goodslevel gl\n" +
  9572. " ON pd.goodslevelid = gl.goodslevelid\n" +
  9573. //"-- 交接工序\n" +
  9574. //" INNER JOIN tp_pm_productiondata hopd\n" +
  9575. //" ON hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  9576. //" AND hopd.valueflag = '1'\n" +
  9577. //" AND hopd.barcode = pd.barcode\n" +
  9578. //" AND hopd.kilncarbatchno = pd.kilncarbatchno\n" +
  9579. " INNER JOIN tp_pm_productiondata hopd\n" +
  9580. " ON hopd.kilncarbatchno = pd.kilncarbatchno\n " +
  9581. " AND hopd.barcode = pd.barcode\n" +
  9582. " AND hopd.valueflag = '1'\n" +
  9583. " AND hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  9584. " LEFT JOIN TP_MST_DefectFine mstdf\n" +
  9585. " ON pmd.DefectFine = mstdf.DefectFineID\n" +
  9586. " LEFT JOIN tp_mst_logo logo\n" +
  9587. " ON pd.logoid = logo.logoid\n" +
  9588. " LEFT JOIN (SELECT def.barcode, wmsys.wm_concat( to_char(def.defectcode)) alldefectcode\n" +
  9589. " FROM tp_pm_defect def\n" +
  9590. " WHERE def.valueflag = '1'\n" +
  9591. //def.createtime
  9592. " group by def.barcode ) d\n" +
  9593. " ON d.barcode = pmd.barcode\n" +
  9594. " WHERE pmd.valueflag = '1' \n" +
  9595. " AND pd.ModelType = -1\n" +
  9596. " AND pmd.AccountID = :AccountID\n";
  9597. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  9598. parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
  9599. //selSql = selSql +
  9600. // " Where TP_PM_Defect.valueflag='1' and tp_pm_productiondata.ModelType=-1" +
  9601. // " and TP_PM_Defect.AccountID=:AccountID ";
  9602. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  9603. {
  9604. selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
  9605. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  9606. }
  9607. if (!string.IsNullOrEmpty(se.LineIDS))
  9608. {
  9609. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
  9610. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  9611. }
  9612. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  9613. {
  9614. //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  9615. selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
  9616. parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  9617. }
  9618. else
  9619. {
  9620. // modify by chenxy :没有选择时,应全查询出来。
  9621. //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  9622. }
  9623. if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  9624. {
  9625. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
  9626. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  9627. }
  9628. if (!string.IsNullOrEmpty(se.KilnCode))
  9629. {
  9630. selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
  9631. parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  9632. }
  9633. if (!string.IsNullOrEmpty(se.GoodsIDS))
  9634. {
  9635. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
  9636. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  9637. }
  9638. if (!string.IsNullOrEmpty(se.GoodsCode))
  9639. {
  9640. selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
  9641. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  9642. }
  9643. if (!string.IsNullOrEmpty(se.GoodsCodeS2D))
  9644. {
  9645. selSql = selSql + " AND pmd.goodsCode = :GoodsCodeS2D ";
  9646. parameters.Add(new OracleParameter(":GoodsCodeS2D", OracleDbType.NVarchar2, se.GoodsCodeS2D, ParameterDirection.Input));
  9647. }
  9648. if (!string.IsNullOrEmpty(se.DefectUserCode))
  9649. {
  9650. selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
  9651. parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  9652. }
  9653. if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  9654. {
  9655. selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
  9656. parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  9657. }
  9658. if (!string.IsNullOrEmpty(se.DefectCode))
  9659. {
  9660. selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
  9661. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  9662. }
  9663. if (!string.IsNullOrEmpty(se.DefectCodeS2D))
  9664. {
  9665. selSql = selSql + " AND pmd.DefectCode = :DefectCodeS2D ";
  9666. parameters.Add(new OracleParameter(":DefectCodeS2D", OracleDbType.NVarchar2, se.DefectCodeS2D, ParameterDirection.Input));
  9667. }
  9668. if (!string.IsNullOrEmpty(se.DefectName))
  9669. {
  9670. selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
  9671. parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  9672. }
  9673. if (!string.IsNullOrEmpty(se.CheckUserCode))
  9674. {
  9675. selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
  9676. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  9677. }
  9678. if (!string.IsNullOrEmpty(se.CheckUserCodeS2D))
  9679. {
  9680. selSql = selSql + " AND pmd.UserCode = :CheckUserCodeS2D ";
  9681. parameters.Add(new OracleParameter(":CheckUserCodeS2D", OracleDbType.NVarchar2, se.CheckUserCodeS2D, ParameterDirection.Input));
  9682. }
  9683. //if (se.CreateTimeStart.HasValue)
  9684. //{
  9685. // selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
  9686. // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9687. //}
  9688. //if (se.CreateTimeEnd.HasValue)
  9689. //{
  9690. // selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
  9691. // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9692. //}
  9693. // 成检登记时间
  9694. if (se.CreateTimeStart.HasValue)
  9695. {
  9696. selSql = selSql + " AND pd.checktime>= :CreateTimeStart ";
  9697. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9698. }
  9699. if (se.CreateTimeEnd.HasValue)
  9700. {
  9701. selSql = selSql + " AND pd.checktime<= :CreateTimeEnd ";
  9702. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9703. }
  9704. // 缺陷登记时间
  9705. if (se.CheckTimeStart.HasValue)
  9706. {
  9707. selSql = selSql + " AND pmd.checktime>= :CheckTimeStart ";
  9708. parameters.Add(new OracleParameter(":CheckTimeStart", OracleDbType.Date, se.CheckTimeStart.Value, ParameterDirection.Input));
  9709. }
  9710. if (se.CheckTimeEnd.HasValue)
  9711. {
  9712. selSql = selSql + " AND pmd.checktime<= :CheckTimeEnd ";
  9713. parameters.Add(new OracleParameter(":CheckTimeEnd", OracleDbType.Date, se.CheckTimeEnd.Value, ParameterDirection.Input));
  9714. }
  9715. // 交接时间
  9716. if (se.HandOverTimeStart.HasValue)
  9717. {
  9718. selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
  9719. parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
  9720. }
  9721. if (se.HandOverTimeEnd.HasValue)
  9722. {
  9723. selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
  9724. parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
  9725. }
  9726. //selSql = selSql + " order by pmd.productionlinename,pmd.procedurename,pmd.defectprocedurename,pmd.defectusercode ";
  9727. selSql = selSql + " order by pmd.productionlinename,p.DISPLAYNO,pdd.DISPLAYNO,dt.DISPLAYNO,mstd.DISPLAYNO,pmd.defectusercode,pmd.barcode ";
  9728. return selSql;
  9729. }
  9730. /// <summary>
  9731. /// 取得RPT030106(成检缺陷汇总表-生产工序信息)的汇总信息查询数据
  9732. /// </summary>
  9733. /// <param name="user">登录用户信息</param>
  9734. /// <param name="se">查询条件</param>
  9735. /// <returns>查询结果</returns>
  9736. public static ServiceResultEntity GetRPT030106ProData(SUserInfo user, RPT030106_SE se)
  9737. {
  9738. IDBConnection conn = null;
  9739. try
  9740. {
  9741. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  9742. List<OracleParameter> parameters = new List<OracleParameter>();
  9743. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030106ProSQL(user, se, ref parameters));
  9744. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  9745. ServiceResultEntity sre = new ServiceResultEntity();
  9746. if (data == null || data.Rows.Count == 0)
  9747. {
  9748. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  9749. return sre;
  9750. }
  9751. sre.Data = new DataSet();
  9752. sre.Data.Tables.Add(data);
  9753. return sre;
  9754. }
  9755. catch (Exception ex)
  9756. {
  9757. throw ex;
  9758. }
  9759. finally
  9760. {
  9761. if (conn != null &&
  9762. conn.ConnState == ConnectionState.Open)
  9763. {
  9764. conn.Close();
  9765. }
  9766. }
  9767. }
  9768. /// <summary>
  9769. /// 获取RPT030106画面(成检缺陷汇总表-生产工序信息)的汇总信息查询sql
  9770. /// </summary>
  9771. /// <returns>sql</returns>
  9772. private static string GetRPT030106ProSQL(SUserInfo user, RPT030106_SE se, ref List<OracleParameter> parameters)
  9773. {
  9774. // 质量登记改判时,缺陷的登记时间是当前时间,不是交接或前次登记时间。
  9775. // 追加交接时间,改判标识。
  9776. string selSql =
  9777. //"SELECT pmd.productionlinename\n" +
  9778. //" ,pmd.procedurename\n" +
  9779. //" ,pmd.DefectProcedureCode\n" +
  9780. //" ,pmd.DefectProcedureName\n" +
  9781. //" ,pmd.DefectUserCode\n" +
  9782. //" ,pmd.defectusername\n" +
  9783. //" ,jobs.jobsname defectjobsname\n" +
  9784. //" ,dt.DefectTypeName\n" +
  9785. //" ,mstd.Remarks DefectRemarks\n" +
  9786. //" ,pd.Remarks barcodeRemarks\n" +
  9787. //" ,pmd.defectcode\n" +
  9788. //" ,d.alldefectcode\n" +
  9789. //" ,pmd.defectname\n" +
  9790. //" ,pmd.UserCode\n" +
  9791. //" ,pmd.username\n" +
  9792. //" ,gt.Goodstypename\n" +
  9793. //" ,pmd.goodscode\n" +
  9794. //" ,pmd.barcode\n" +
  9795. //" ,pd.groutingdate\n" +
  9796. //" ,pd.groutingnum\n" +
  9797. //" ,pd.groutingMouldCode\n" +
  9798. //" ,pd.GroutingLineCode\n" +
  9799. //" ,pd.KilnCarCode\n" +
  9800. //" ,pd.Procedureid\n" +
  9801. //" ,gl.goodslevelname Goodsleveltype\n" +
  9802. //" ,pmd.DefectPositionCode\n" +
  9803. //" ,pmd.DefectPositionName\n" +
  9804. //" ,pd.GroutingUserCode\n" +
  9805. //" , CASE\n" +
  9806. //" WHEN logo.logoid IS NULL THEN\n" +
  9807. //" NULL\n" +
  9808. //" ELSE\n" +
  9809. //" logo.Logoname || '[' || logo.Logocode || ']'\n" +
  9810. //" END AS LogoCodeName\n" +
  9811. ////" ,pmd.CreateTime\n" +
  9812. //" ,pd.CheckTime pdchecktime\n" +
  9813. //" ,pmd.CheckTime\n" +
  9814. //" ,mstdf.DefectFineCode\n" +
  9815. //" ,pmd.DefectDeductionNum\n" +
  9816. ////" ,to_char(pmd.DefectDeductionNum, '990.00') DefectDeductionNum\n" +
  9817. //" ,hopd.createtime handovertime\n" +
  9818. //" ,(SELECT listagg(to_char(pduc.UserCode), ',') within GROUP(ORDER BY pduc.ProductionDataID) AS WorkUserCodes\n" +
  9819. //" FROM tp_pm_ProductionData pduc\n" +
  9820. //" WHERE pduc.barcode = pmd.barcode\n" +
  9821. //" AND pduc.valueflag = '1') AS WorkUserCodes\n" +
  9822. //" ,(SELECT listagg(to_char(u.UserCode), ',') within GROUP(ORDER BY pdcu.ProductionDataID) AS CreateUserCodes\n" +
  9823. //" FROM tp_pm_ProductionData pdcu\n" +
  9824. //" Left join tp_mst_user u on u.userid = pdcu.createuserid\n" +
  9825. //" WHERE pdcu.barcode = pmd.barcode\n" +
  9826. //" AND pdcu.valueflag = '1') AS CreateUserCodes\n" +
  9827. //" , CASE\n" +
  9828. //" WHEN EXISTS (SELECT 1\n" +
  9829. //" FROM tp_pm_ProductionData pdud\n" +
  9830. //" WHERE pdud.barcode = pmd.barcode\n" +
  9831. //" AND pdud.modeltype = -1\n" +
  9832. //" AND pdud.procedureid = pd.procedureid\n" +
  9833. //" AND pdud.kilncarbatchno = pd.kilncarbatchno\n" +
  9834. //" AND pdud.valueflag = '0') THEN\n" +
  9835. //" 1\n" +
  9836. //" ELSE\n" +
  9837. //" 0\n" +
  9838. //" END AS undoflag\n" +
  9839. "SELECT pmd.goodscode\n" +
  9840. " ,pmd.barcode\n" +
  9841. " ,pmd.defectcode\n" +
  9842. " ,pmd.defectname\n" +
  9843. " ,pmd.DefectPositionCode\n" +
  9844. " ,pmd.DefectPositionName\n" +
  9845. " ,gl.goodslevelname Goodsleveltype\n" +
  9846. " , CASE\n" +
  9847. " WHEN logo.logoid IS NULL THEN\n" +
  9848. " NULL\n" +
  9849. " ELSE\n" +
  9850. " logo.Logoname || '[' || logo.Logocode || ']'\n" +
  9851. " END AS LogoCodeName\n" +
  9852. //" ,pmd.CreateTime\n" +
  9853. " ,pd.CheckTime pdchecktime\n" +
  9854. " ,pmd.CheckTime\n" +
  9855. " ,proddata.CheckTime protime\n" +
  9856. " ,proddata.UserCode prousercode\n" +
  9857. " ,proddata.PROCEDURENAME proname\n" +
  9858. " ,pd.KILNCARCODE KILNCARCODE\n" +
  9859. " FROM tp_pm_defect pmd\n" +
  9860. " INNER JOIN tp_pm_productiondata proddata\n" +
  9861. " ON proddata.barcode = pmd.barcode\n " +
  9862. //" AND proddata.ProcedureID in ('" + se.CompleteProcedureIDS + "')\n" +
  9863. " AND (instr(','||:ProProcedureIDS||',',','||proddata.ProcedureID||',')>0 )\n" +
  9864. " AND proddata.valueflag = '1'\n" +
  9865. " INNER JOIN tp_pm_productiondata pd\n" +
  9866. " ON pmd.ProductionDataID = pd.ProductionDataID\n" +
  9867. " LEFT JOIN TP_PC_Procedure p\n" +
  9868. " ON p.procedureid = pmd.procedureid\n" +
  9869. " LEFT JOIN TP_PC_Procedure pdd\n" +
  9870. " ON pdd.procedureid = pmd.defectprocedureid\n" +
  9871. " LEFT JOIN TP_MST_Goods g\n" +
  9872. " ON pmd.Goodsid = g.Goodsid\n" +
  9873. " LEFT JOIN TP_MST_GoodsType gt\n" +
  9874. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  9875. " LEFT JOIN TP_MST_Defect mstd\n" +
  9876. " ON pmd.DefectID = mstd.DefectID\n" +
  9877. " LEFT JOIN TP_MST_Jobs jobs\n" +
  9878. " ON jobs.jobsid = pmd.Defectjobs\n" +
  9879. " LEFT JOIN TP_MST_DefectType dt\n" +
  9880. " ON mstd.DefectTypeID = dt.DefectTypeID\n" +
  9881. " LEFT JOIN tp_mst_goodslevel gl\n" +
  9882. " ON pd.goodslevelid = gl.goodslevelid\n" +
  9883. "-- 交接工序\n" +
  9884. " INNER JOIN tp_pm_productiondata hopd\n" +
  9885. " ON hopd.kilncarbatchno = pd.kilncarbatchno\n " +
  9886. " AND hopd.barcode = pd.barcode\n" +
  9887. " AND hopd.valueflag = '1'\n" +
  9888. " AND hopd.procedureid = (select procedureid from tp_mst_rptsprocedure t where t.rptprocedureid = :HandOverProcedureID) \n" +
  9889. " LEFT JOIN TP_MST_DefectFine mstdf\n" +
  9890. " ON pmd.DefectFine = mstdf.DefectFineID\n" +
  9891. " LEFT JOIN tp_mst_logo logo\n" +
  9892. " ON pd.logoid = logo.logoid\n" +
  9893. //" LEFT JOIN (SELECT def.barcode, wmsys.wm_concat( to_char(def.defectcode)) alldefectcode\n" +
  9894. //" FROM tp_pm_defect def\n" +
  9895. //" WHERE def.valueflag = '1'\n" +
  9896. ////def.createtime
  9897. //" group by def.barcode ) d\n" +
  9898. //" ON d.barcode = pmd.barcode\n" +
  9899. " WHERE pmd.valueflag = '1' \n" +
  9900. " AND pd.ModelType = -1\n" +
  9901. " AND pmd.AccountID = :AccountID\n";
  9902. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  9903. parameters.Add(new OracleParameter(":HandOverProcedureID", OracleDbType.Int32, se.HandOverProcedureID, ParameterDirection.Input));
  9904. parameters.Add(new OracleParameter(":ProProcedureIDS", OracleDbType.Varchar2, se.CompleteProcedureIDS, ParameterDirection.Input));
  9905. //selSql = selSql +
  9906. // " Where TP_PM_Defect.valueflag='1' and tp_pm_productiondata.ModelType=-1" +
  9907. // " and TP_PM_Defect.AccountID=:AccountID ";
  9908. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  9909. {
  9910. selSql = selSql + " AND instr(gt.GOODSTYPECode,:GoodsTypeCode)=1 ";
  9911. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  9912. }
  9913. if (!string.IsNullOrEmpty(se.LineIDS))
  9914. {
  9915. selSql = selSql + " AND instr(','||:ProductionLineIDS||',',','||pmd.ProductionLineId||',')>0 ";
  9916. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.LineIDS, ParameterDirection.Input));
  9917. }
  9918. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  9919. {
  9920. //selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||TP_PM_Defect.DefectProcedureID||',')>0 or TP_PM_Defect.DefectProcedureID is null ) ";
  9921. selSql = selSql + " AND (instr(','||:DefectProcedureIDS||',',','||pmd.DefectProcedureID||',')>0 ) ";
  9922. parameters.Add(new OracleParameter(":DefectProcedureIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  9923. }
  9924. else
  9925. {
  9926. // modify by chenxy :没有选择时,应全查询出来。
  9927. //selSql = selSql + " AND TP_PM_Defect.DefectProcedureID is null ";//因为有无责任工序
  9928. }
  9929. if (!string.IsNullOrEmpty(se.CheckProcedureIDS))
  9930. {
  9931. selSql = selSql + " AND instr(','||:ProcedureIDS||',',','||pmd.ProcedureID||',')>0 ";
  9932. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.CheckProcedureIDS, ParameterDirection.Input));
  9933. }
  9934. if (!string.IsNullOrEmpty(se.KilnCode))
  9935. {
  9936. selSql = selSql + " AND instr(pd.KilnCode,:KilnCode) >0 ";
  9937. parameters.Add(new OracleParameter(":KilnCode", OracleDbType.NVarchar2, se.KilnCode, ParameterDirection.Input));
  9938. }
  9939. if (!string.IsNullOrEmpty(se.GoodsIDS))
  9940. {
  9941. selSql = selSql + " AND instr(','||:GoodsIDS||',',','||pmd.Goodsid||',')>0 ";
  9942. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, se.GoodsIDS, ParameterDirection.Input));
  9943. }
  9944. if (!string.IsNullOrEmpty(se.GoodsCode))
  9945. {
  9946. selSql = selSql + " AND instr(pmd.goodsCode,:GoodsCode) >0 ";
  9947. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  9948. }
  9949. if (!string.IsNullOrEmpty(se.GoodsCodeS2D))
  9950. {
  9951. selSql = selSql + " AND pmd.goodsCode = :GoodsCodeS2D ";
  9952. parameters.Add(new OracleParameter(":GoodsCodeS2D", OracleDbType.NVarchar2, se.GoodsCodeS2D, ParameterDirection.Input));
  9953. }
  9954. if (!string.IsNullOrEmpty(se.DefectUserCode))
  9955. {
  9956. selSql = selSql + " AND instr(pmd.DefectUserCode,:DefectUserCode) >0 ";
  9957. parameters.Add(new OracleParameter(":DefectUserCode", OracleDbType.NVarchar2, se.DefectUserCode, ParameterDirection.Input));
  9958. }
  9959. if (!string.IsNullOrEmpty(se.DefectTypeIDS))
  9960. {
  9961. selSql = selSql + " AND instr(','||:DefectTypeIDS||',',','||dt.DefectTypeID||',')>0 ";
  9962. parameters.Add(new OracleParameter(":DefectTypeIDS", OracleDbType.NVarchar2, se.DefectTypeIDS, ParameterDirection.Input));
  9963. }
  9964. if (!string.IsNullOrEmpty(se.DefectCode))
  9965. {
  9966. selSql = selSql + " AND instr(pmd.DefectCode,:DefectCode) >0 ";
  9967. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  9968. }
  9969. if (!string.IsNullOrEmpty(se.DefectCodeS2D))
  9970. {
  9971. selSql = selSql + " AND pmd.DefectCode = :DefectCodeS2D ";
  9972. parameters.Add(new OracleParameter(":DefectCodeS2D", OracleDbType.NVarchar2, se.DefectCodeS2D, ParameterDirection.Input));
  9973. }
  9974. if (!string.IsNullOrEmpty(se.DefectName))
  9975. {
  9976. selSql = selSql + " AND instr(pmd.DefectName,:DefectName) >0 ";
  9977. parameters.Add(new OracleParameter(":DefectName", OracleDbType.NVarchar2, se.DefectName, ParameterDirection.Input));
  9978. }
  9979. if (!string.IsNullOrEmpty(se.CheckUserCode))
  9980. {
  9981. selSql = selSql + " AND instr(pmd.UserCode,:UserCode) >0";
  9982. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CheckUserCode, ParameterDirection.Input));
  9983. }
  9984. if (!string.IsNullOrEmpty(se.CheckUserCodeS2D))
  9985. {
  9986. selSql = selSql + " AND pmd.UserCode = :CheckUserCodeS2D ";
  9987. parameters.Add(new OracleParameter(":CheckUserCodeS2D", OracleDbType.NVarchar2, se.CheckUserCodeS2D, ParameterDirection.Input));
  9988. }
  9989. //if (se.CreateTimeStart.HasValue)
  9990. //{
  9991. // selSql = selSql + " AND pmd.CreateTime>= :CreateTimeStart ";
  9992. // parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  9993. //}
  9994. //if (se.CreateTimeEnd.HasValue)
  9995. //{
  9996. // selSql = selSql + " AND pmd.CreateTime<= :CreateTimeEnd ";
  9997. // parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  9998. //}
  9999. // 成检登记时间
  10000. if (se.CreateTimeStart.HasValue)
  10001. {
  10002. selSql = selSql + " AND pd.checktime>= :CreateTimeStart ";
  10003. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.CreateTimeStart.Value, ParameterDirection.Input));
  10004. }
  10005. if (se.CreateTimeEnd.HasValue)
  10006. {
  10007. selSql = selSql + " AND pd.checktime<= :CreateTimeEnd ";
  10008. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.CreateTimeEnd.Value, ParameterDirection.Input));
  10009. }
  10010. // 缺陷登记时间
  10011. if (se.CheckTimeStart.HasValue)
  10012. {
  10013. selSql = selSql + " AND pmd.checktime>= :CheckTimeStart ";
  10014. parameters.Add(new OracleParameter(":CheckTimeStart", OracleDbType.Date, se.CheckTimeStart.Value, ParameterDirection.Input));
  10015. }
  10016. if (se.CheckTimeEnd.HasValue)
  10017. {
  10018. selSql = selSql + " AND pmd.checktime<= :CheckTimeEnd ";
  10019. parameters.Add(new OracleParameter(":CheckTimeEnd", OracleDbType.Date, se.CheckTimeEnd.Value, ParameterDirection.Input));
  10020. }
  10021. // 交接时间
  10022. if (se.HandOverTimeStart.HasValue)
  10023. {
  10024. selSql = selSql + " AND hopd.CreateTime>= :HandOverTimeStart ";
  10025. parameters.Add(new OracleParameter(":HandOverTimeStart", OracleDbType.Date, se.HandOverTimeStart.Value, ParameterDirection.Input));
  10026. }
  10027. if (se.HandOverTimeEnd.HasValue)
  10028. {
  10029. selSql = selSql + " AND hopd.CreateTime<= :HandOverTimeEnd ";
  10030. parameters.Add(new OracleParameter(":HandOverTimeEnd", OracleDbType.Date, se.HandOverTimeEnd.Value, ParameterDirection.Input));
  10031. }
  10032. //selSql = selSql + " order by pmd.productionlinename,p.DISPLAYNO,pdd.DISPLAYNO,dt.DISPLAYNO,mstd.DISPLAYNO,pmd.defectusercode,pmd.barcode ";
  10033. selSql = selSql + " order by proddata.CheckTime ";
  10034. return selSql;
  10035. }
  10036. /// <summary>
  10037. /// 窑车状态主表查询
  10038. /// </summary>
  10039. /// <param name="kilnCode">窑炉编码</param>
  10040. /// <param name="kilnCarCode">窑车编码</param>
  10041. /// <param name="sUserInfo">用户基本信息</param>
  10042. /// <returns></returns>
  10043. public static ServiceResultEntity GetKilnCarStatusByCode(string kilnCode, string kilnCarCode, SUserInfo sUserInfo)
  10044. {
  10045. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10046. try
  10047. {
  10048. con.Open();
  10049. OracleParameter[] paras = new OracleParameter[]{
  10050. new OracleParameter("in_AccountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  10051. new OracleParameter("in_KilnCode",OracleDbType.Varchar2,kilnCode,ParameterDirection.Input),
  10052. new OracleParameter("in_KilnCarCode",OracleDbType.Varchar2,kilnCarCode,ParameterDirection.Input),
  10053. new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  10054. };
  10055. DataSet dsSearchReport = con.ExecStoredProcedure("PRO_RPT_GetKilnCarStatus", paras);
  10056. ServiceResultEntity sre = new ServiceResultEntity();
  10057. if (dsSearchReport == null || dsSearchReport.Tables[0].Rows.Count == 0)
  10058. {
  10059. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10060. return sre;
  10061. }
  10062. sre.Data = new DataSet();
  10063. sre.Data.Tables.Add(dsSearchReport.Tables[0].Copy());
  10064. return sre;
  10065. }
  10066. catch (Exception ex)
  10067. {
  10068. throw ex;
  10069. }
  10070. finally
  10071. {
  10072. if (con != null &&
  10073. con.ConnState == ConnectionState.Open)
  10074. {
  10075. con.Close();
  10076. }
  10077. }
  10078. }
  10079. /// <summary>
  10080. /// 窑车状态明细表查询
  10081. /// </summary>
  10082. /// <param name="kilnCarCode">窑车编码</param>
  10083. /// <param name="sUserInfo">用户基本信息</param>
  10084. /// <returns></returns>
  10085. public static ServiceResultEntity GetKilnCarStatusDetailByCode(string kilnCarCode, SUserInfo sUserInfo)
  10086. {
  10087. IDBConnection con = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10088. try
  10089. {
  10090. con.Open();
  10091. OracleParameter[] paras = new OracleParameter[]{
  10092. new OracleParameter("in_AccountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  10093. new OracleParameter("in_KilnCarCode",OracleDbType.Varchar2,kilnCarCode,ParameterDirection.Input),
  10094. new OracleParameter("out_KilnCarData",OracleDbType.RefCursor, ParameterDirection.Output),
  10095. new OracleParameter("out_KilnCarGoods",OracleDbType.RefCursor, ParameterDirection.Output),
  10096. };
  10097. DataSet dsSearchReport = con.ExecStoredProcedure("PRO_RPT_GetKilnCarData", paras);
  10098. ServiceResultEntity sre = new ServiceResultEntity();
  10099. if (dsSearchReport == null || dsSearchReport.Tables[0].Rows.Count == 0)
  10100. {
  10101. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10102. return sre;
  10103. }
  10104. sre.Data = new DataSet();
  10105. sre.Data.Tables.Add(dsSearchReport.Tables[0].Copy());//生产数据
  10106. sre.Data.Tables.Add(dsSearchReport.Tables[1].Copy());//窑车产品
  10107. return sre;
  10108. }
  10109. catch (Exception ex)
  10110. {
  10111. throw ex;
  10112. }
  10113. finally
  10114. {
  10115. if (con != null &&
  10116. con.ConnState == ConnectionState.Open)
  10117. {
  10118. con.Close();
  10119. }
  10120. }
  10121. }
  10122. /// <summary>
  10123. /// 取得RPT010201_1画面(工序漏扫明细表)的查询数据
  10124. /// </summary>
  10125. /// <param name="user">登录用户信息</param>
  10126. /// <param name="se">查询条件</param>
  10127. /// <returns>查询结果</returns>
  10128. public static ServiceResultEntity GetRPT080101SData(SUserInfo user, RPT010201_SE se)
  10129. {
  10130. IDBConnection conn = null;
  10131. try
  10132. {
  10133. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10134. List<OracleParameter> parameters = new List<OracleParameter>();
  10135. parameters.Clear();
  10136. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080101SSQL(user, se, ref parameters));
  10137. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  10138. ServiceResultEntity sre = new ServiceResultEntity();
  10139. if (data == null || data.Rows.Count == 0)
  10140. {
  10141. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10142. return sre;
  10143. }
  10144. sre.Data = new DataSet();
  10145. sre.Data.Tables.Add(data);
  10146. return sre;
  10147. }
  10148. catch (Exception ex)
  10149. {
  10150. throw ex;
  10151. }
  10152. finally
  10153. {
  10154. if (conn != null &&
  10155. conn.ConnState == ConnectionState.Open)
  10156. {
  10157. conn.Close();
  10158. }
  10159. }
  10160. }
  10161. /// <summary>
  10162. /// 获取RPT010201_1画面(工序漏扫明细表)的查询sql
  10163. /// </summary>
  10164. /// <returns>sql</returns>
  10165. private static string GetRPT080101SSQL(SUserInfo user, RPT010201_SE se, ref List<OracleParameter> parameters)
  10166. {
  10167. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  10168. #region
  10169. #endregion
  10170. string sql = @"
  10171. select gd.groutinglinecode,
  10172. gd.groutingmouldcode,
  10173. gd.mouldcode,
  10174. gd.usercode,
  10175. gs.goodscode,
  10176. gs.goodsname,
  10177. gs.goodsspecification,
  10178. gms.gmouldstatusname, -- 模具状态
  10179. --gs.goodsmodel,
  10180. gd.groutingcount, -- 注浆次数
  10181. --gd.groutingnum,
  10182. gd.scrapnum, -- 开模损坯数
  10183. gd.deliverpnum, -- 交坯数
  10184. gd.mingroutingdate, -- 开始注浆时间
  10185. gd.maxgroutingdate, -- 最后注浆时间
  10186. gld.beginuseddate, -- 开始使用时间
  10187. gld.enduseddate, -- 结束使用时间
  10188. zl.OutKilnCount, -- 质量登记数
  10189. zl.GoodCount, -- 正品数
  10190. zl.SubstandardCount, -- 副品数
  10191. zl.ReFireCount, -- 重烧数
  10192. zl.BadCount -- 次品数
  10193. from (select gdd.groutinglinecode,
  10194. gdd.groutingmouldcode,
  10195. gdd.mouldcode,
  10196. gdd.goodsid,
  10197. gdd.groutinglinedetailid,
  10198. wmsys.wm_concat(distinct to_char(gdd.usercode)) usercode,
  10199. max(gdd.groutingcount) groutingcount,
  10200. sum(decode(gdd.groutingflag, '1', 1, 0)) groutingnum,
  10201. sum(decode(gdd.scrapflag, '1', 1, 0)) scrapnum,
  10202. sum(decode(gdd.deliverflag, '1', 1, 0)) deliverpnum,
  10203. min(gdd.groutingdate) mingroutingdate,
  10204. max(gdd.groutingdate) maxgroutingdate
  10205. from tp_pm_groutingdailydetail gdd
  10206. where gdd.groutingflag = '1'
  10207. and gdd.AccountID = :AccountID
  10208. ";
  10209. // 成型线编码
  10210. if (!string.IsNullOrEmpty(se.groutinglinecode))
  10211. {
  10212. //sql = sql + " and gdd.groutinglinecode=:groutinglinecode";
  10213. sql = sql + " and instr(gdd.groutinglinecode,:groutinglinecode)>0";
  10214. parameters.Add(new OracleParameter(":groutinglinecode", OracleDbType.NVarchar2, se.groutinglinecode, ParameterDirection.Input));
  10215. }
  10216. // 模具编码
  10217. if (!string.IsNullOrEmpty(se.groutingmouldcode))
  10218. {
  10219. //sql = sql + " and gdd.groutingmouldcode=:groutingmouldcode";
  10220. sql = sql + " and instr(gdd.groutingmouldcode,:groutingmouldcode)>0";
  10221. parameters.Add(new OracleParameter(":groutingmouldcode", OracleDbType.NVarchar2, se.groutingmouldcode, ParameterDirection.Input));
  10222. }
  10223. sql = sql + @"
  10224. group by gdd.groutinglinecode,
  10225. gdd.groutingmouldcode,
  10226. gdd.mouldcode,
  10227. gdd.goodsid,
  10228. gdd.groutinglinedetailid) gd
  10229. left join (select pdbc.mouldcode,
  10230. sum(1) OutKilnCount,
  10231. sum(case
  10232. when defect.defectprocedureid is not null and
  10233. glt.goodsleveltypeid in (5, 6, 7) then
  10234. 0
  10235. else
  10236. 1
  10237. end) GoodCount,
  10238. sum(case
  10239. when defect.defectprocedureid is not null and
  10240. glt.goodsleveltypeid = 7 then
  10241. 1
  10242. else
  10243. 0
  10244. end) SubstandardCount,
  10245. sum(case
  10246. when defect.defectprocedureid is not null and
  10247. glt.goodsleveltypeid = 6 then
  10248. 1
  10249. else
  10250. 0
  10251. end) ReFireCount,
  10252. sum(case
  10253. when defect.defectprocedureid is not null and
  10254. glt.goodsleveltypeid = 5 then
  10255. 1
  10256. else
  10257. 0
  10258. end) BadCount
  10259. from (select distinct pd.barcode,
  10260. pd.mouldcode,
  10261. pd.kilncarbatchno
  10262. from tp_pm_productiondata pd
  10263. where pd.valueflag = '1'";
  10264. // 开始注浆--开始
  10265. if (se.beginCreateTime.HasValue)
  10266. {
  10267. sql = sql + " and pd.createtime>=:groutingDateStart ";
  10268. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  10269. }
  10270. //--and pd.createtime > 查询条件。开始注浆日期开始
  10271. // --and pd.procedureid = :in_rptSprocedureId
  10272. sql = sql + @"
  10273. and pd.procedureid = 11
  10274. and pd.AccountID = 1) pdbc
  10275. left join (select kcbc.barcode,
  10276. kcbc.kilncarbatchno,
  10277. kcbc.goodsleveltypeid,
  10278. kcbc.productiondataid
  10279. from (select pd.barcode,
  10280. pd.kilncarbatchno,
  10281. pd.goodsleveltypeid,
  10282. pd.productiondataid,
  10283. ROW_NUMBER() OVER(PARTITION BY pd.barcode, pd.kilncarbatchno ORDER BY pd.productiondataid desc) AS dataid
  10284. from tp_pm_productiondata pd
  10285. where pd.valueflag = '1'
  10286. --and pd.AccountID = :AccountID
  10287. and pd.AccountID = :AccountID";
  10288. //--and pd.createtime > 查询条件。开始注浆日期开始
  10289. // 开始注浆--开始
  10290. if (se.beginCreateTime.HasValue)
  10291. {
  10292. sql = sql + " and pd.createtime>=:groutingDateStart ";
  10293. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  10294. }
  10295. sql = sql + @" and length(pd.kilncarbatchno) > 0
  10296. and pd.modeltype = -1) kcbc
  10297. where kcbc.dataid = 1) glt
  10298. on pdbc.kilncarbatchno = glt.kilncarbatchno
  10299. and pdbc.barcode = glt.barcode
  10300. left join (select distinct productiondataid, defectprocedureid
  10301. from tp_pm_defect def
  10302. where def.valueflag = '1'";
  10303. //--and pd.createtime > 查询条件。开始注浆日期开始
  10304. // 开始注浆--开始
  10305. if (se.beginCreateTime.HasValue)
  10306. {
  10307. sql = sql + " and def.createtime>=:groutingDateStart ";
  10308. parameters.Add(new OracleParameter(":groutingDateStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  10309. }
  10310. sql = sql + @"
  10311. and def.AccountID = :AccountID) defect
  10312. on defect.productiondataid = glt.productiondataid
  10313. group by pdbc.mouldcode) zl
  10314. on zl.mouldcode = gd.mouldcode
  10315. left join tp_mst_goods gs
  10316. on gs.goodsid = gd.goodsid
  10317. left join tp_pc_groutinglinedetail gld
  10318. on gld.groutinglinedetailid = gd.groutinglinedetailid
  10319. and gld.mouldcode = gd.mouldcode
  10320. left join tp_sys_gmouldstatus gms
  10321. on gms.gmouldstatusid = gld.gmouldstatus
  10322. where 1=1
  10323. ";
  10324. // 产品编码
  10325. if (!string.IsNullOrEmpty(se.goodscode))
  10326. {
  10327. //sql = sql + " and gs.goodscode=:goodscode";
  10328. sql = sql + " and instr(gs.goodscode,:goodscode)>0";
  10329. parameters.Add(new OracleParameter(":goodscode", OracleDbType.NVarchar2, se.goodscode, ParameterDirection.Input));
  10330. }
  10331. // 成型工号
  10332. if (!string.IsNullOrEmpty(se.groutingUserCode))
  10333. {
  10334. //sql = sql + " and gd.usercode=:usercode";
  10335. sql = sql + " and instr(gd.usercode,:usercode)>0";
  10336. parameters.Add(new OracleParameter(":usercode", OracleDbType.NVarchar2, se.groutingUserCode, ParameterDirection.Input));
  10337. }
  10338. // 开始注浆--开始
  10339. if (se.beginCreateTime.HasValue)
  10340. {
  10341. sql = sql + " and gd.mingroutingdate>=:CreateTimeStart ";
  10342. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.beginCreateTime.Value, ParameterDirection.Input));
  10343. }
  10344. // 开始注浆--结束
  10345. if (se.endCreateTime.HasValue)
  10346. {
  10347. sql = sql + " and gd.mingroutingdate<=:CreateTimeEnd ";
  10348. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.endCreateTime.Value, ParameterDirection.Input));
  10349. }
  10350. // 结束注浆--开始
  10351. if (se.beginCreateTime2.HasValue)
  10352. {
  10353. sql = sql + " and gd.maxgroutingdate>=:CreateTimeotherStart2 ";
  10354. parameters.Add(new OracleParameter(":CreateTimeotherStart2", OracleDbType.Date, se.beginCreateTime2.Value, ParameterDirection.Input));
  10355. }
  10356. // 结束注浆--结束
  10357. if (se.endCreateTime2.HasValue)
  10358. {
  10359. sql = sql + " and gd.maxgroutingdate<=:CreateTimeotherEnd2";
  10360. parameters.Add(new OracleParameter(":CreateTimeotherEnd2", OracleDbType.Date, se.endCreateTime2.Value, ParameterDirection.Input));
  10361. }
  10362. // 模具状态
  10363. if (!string.IsNullOrEmpty(se.gmouldstatus))
  10364. {
  10365. sql = sql + " and gms.gmouldstatusid=:gmouldstatus";
  10366. parameters.Add(new OracleParameter(":gmouldstatus", OracleDbType.NVarchar2, se.gmouldstatus, ParameterDirection.Input));
  10367. }
  10368. sql = sql + " order by groutinglinecode,groutingmouldcode";
  10369. return sql;
  10370. }
  10371. #region 工资产量统计
  10372. /// <summary>
  10373. /// 取得RPT080102画面(成型工产量)的查询数据
  10374. /// </summary>
  10375. /// <param name="user">登录用户信息</param>
  10376. /// <param name="se">查询条件</param>
  10377. /// <returns>查询结果</returns>
  10378. public static ServiceResultEntity GetRPT080102SData(SUserInfo user, RPT080102_SE se)
  10379. {
  10380. IDBTransaction conn = null;
  10381. try
  10382. {
  10383. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  10384. conn.Connect();
  10385. OracleParameter[] paras = new OracleParameter[]{
  10386. new OracleParameter("in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  10387. new OracleParameter("in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
  10388. new OracleParameter("in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
  10389. new OracleParameter("in_deliverprocess",OracleDbType.Varchar2,se.DeliverProcedureIDS,ParameterDirection.Input),
  10390. new OracleParameter("in_IntoKilnProcess",OracleDbType.Varchar2,se.IntoProcedureIDS,ParameterDirection.Input),
  10391. new OracleParameter("in_OutKilnProcess",OracleDbType.Varchar2,se.OutProcedureIDS,ParameterDirection.Input),
  10392. new OracleParameter("in_QualityProcess",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
  10393. new OracleParameter("in_DefectFine",OracleDbType.Varchar2,se.DefectFineIDS,ParameterDirection.Input),
  10394. new OracleParameter("in_Impurity",OracleDbType.Varchar2,se.DefectIDS,ParameterDirection.Input),
  10395. new OracleParameter("out_Production",OracleDbType.RefCursor, ParameterDirection.Output),
  10396. new OracleParameter("out_Deliver",OracleDbType.RefCursor,ParameterDirection.Output),
  10397. new OracleParameter("out_Repair",OracleDbType.RefCursor,ParameterDirection.Output),
  10398. };
  10399. conn.IsCommandTimeout = false;
  10400. DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetDeliver_Production", paras);
  10401. ServiceResultEntity sre = new ServiceResultEntity();
  10402. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  10403. {
  10404. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10405. return sre;
  10406. }
  10407. sre.Data = new DataSet();
  10408. sre.Data = data;
  10409. conn.Commit();
  10410. return sre;
  10411. }
  10412. catch (Exception ex)
  10413. {
  10414. throw ex;
  10415. }
  10416. finally
  10417. {
  10418. if (conn != null &&
  10419. conn.ConnState == ConnectionState.Open)
  10420. {
  10421. conn.Disconnect();
  10422. }
  10423. }
  10424. }
  10425. /// <summary>
  10426. /// 取得RPT080103画面(烧成前工序产量明细表)的查询数据
  10427. /// </summary>
  10428. /// <param name="user">登录用户信息</param>
  10429. /// <param name="se">查询条件</param>
  10430. /// <returns>查询结果</returns>
  10431. public static ServiceResultEntity GetRPT080103SData(SUserInfo user, RPT080103_SE se)
  10432. {
  10433. IDBTransaction conn = null;
  10434. try
  10435. {
  10436. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  10437. conn.Connect();
  10438. OracleParameter[] paras = new OracleParameter[]{
  10439. new OracleParameter("in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  10440. new OracleParameter("in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
  10441. new OracleParameter("in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
  10442. new OracleParameter("in_Process",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
  10443. new OracleParameter("in_HandOverProcess",OracleDbType.Varchar2,se.HandOverProcedureIDS,ParameterDirection.Input),
  10444. new OracleParameter("in_OutKilnProcess",OracleDbType.Varchar2,se.OutProcedureIDS,ParameterDirection.Input),
  10445. new OracleParameter("in_QualityProcess",OracleDbType.Varchar2,se.QualityProcedureIDS,ParameterDirection.Input),
  10446. new OracleParameter("in_Defect1",OracleDbType.Varchar2,se.DefectIDS,ParameterDirection.Input),
  10447. new OracleParameter("in_Defect2",OracleDbType.Varchar2,se.DefectIDS2,ParameterDirection.Input),
  10448. new OracleParameter("out_Production",OracleDbType.RefCursor, ParameterDirection.Output),
  10449. };
  10450. conn.IsCommandTimeout = false;
  10451. //DataSet data = null;
  10452. //if (se.ProcedureIDS.Contains(","))
  10453. //{
  10454. // data = conn.ExecStoredProcedure("PRO_RPT_GetStandardProduction2", paras);
  10455. //}
  10456. //else
  10457. //{
  10458. // data = conn.ExecStoredProcedure("PRO_RPT_GetStandardProduction", paras);
  10459. //}
  10460. DataSet data = conn.ExecStoredProcedure("PRO_RPT_GetStandard_Production", paras);
  10461. ServiceResultEntity sre = new ServiceResultEntity();
  10462. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  10463. {
  10464. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10465. return sre;
  10466. }
  10467. sre.Data = new DataSet();
  10468. sre.Data = data;
  10469. conn.Commit();
  10470. return sre;
  10471. }
  10472. catch (Exception ex)
  10473. {
  10474. throw ex;
  10475. }
  10476. finally
  10477. {
  10478. if (conn != null &&
  10479. conn.ConnState == ConnectionState.Open)
  10480. {
  10481. conn.Disconnect();
  10482. }
  10483. }
  10484. }
  10485. /// <summary>
  10486. /// 取得RPT080104画面(烧成工序产量明细表)的查询数据
  10487. /// </summary>
  10488. /// <param name="user">登录用户信息</param>
  10489. /// <param name="se">查询条件</param>
  10490. /// <returns>查询结果</returns>
  10491. public static ServiceResultEntity GetRPT080104SData(SUserInfo user, RPT080103_SE se)
  10492. {
  10493. IDBTransaction conn = null;
  10494. try
  10495. {
  10496. conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  10497. conn.Connect();
  10498. OracleParameter[] paras = new OracleParameter[]{
  10499. new OracleParameter("in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  10500. new OracleParameter("in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
  10501. new OracleParameter("in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
  10502. new OracleParameter("in_Process",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
  10503. new OracleParameter("in_OutKilnProcess",OracleDbType.Varchar2,se.OutProcedureIDS,ParameterDirection.Input),
  10504. new OracleParameter("in_QualityProcess",OracleDbType.Varchar2,se.QualityProcedureIDS,ParameterDirection.Input),
  10505. new OracleParameter("in_Defect1",OracleDbType.Varchar2,se.DefectIDS,ParameterDirection.Input),
  10506. new OracleParameter("in_Defect2",OracleDbType.Varchar2,se.DefectIDS2,ParameterDirection.Input),
  10507. new OracleParameter("out_Production",OracleDbType.RefCursor, ParameterDirection.Output),
  10508. };
  10509. conn.IsCommandTimeout = false;
  10510. DataSet data = null;
  10511. if (se.ProcedureIDS.Contains(","))
  10512. {
  10513. data = conn.ExecStoredProcedure("PRO_RPT_GetKilnProduction2", paras);
  10514. }
  10515. else
  10516. {
  10517. data = conn.ExecStoredProcedure("PRO_RPT_GetKilnProduction", paras);
  10518. }
  10519. ServiceResultEntity sre = new ServiceResultEntity();
  10520. if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
  10521. {
  10522. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10523. return sre;
  10524. }
  10525. sre.Data = data;
  10526. //string sqlString =
  10527. //"SELECT kk.procedurename\n" +
  10528. //" ,kk.usercode\n" +
  10529. //" ,kk.kilncode\n" +
  10530. //" ,kk.kdate\n" +
  10531. //" ,COUNT(*) kcount\n" +
  10532. //" FROM (SELECT k.usercode\n" +
  10533. //" ,kiln.kilncode\n" +
  10534. //" ,p.procedurename\n" +
  10535. //" ,trunc(k.createtime) kdate\n" +
  10536. //" FROM tp_pm_kilncardata k\n" +
  10537. //" LEFT JOIN tp_mst_kiln kiln\n" +
  10538. //" ON kiln.kilnid = k.kilnid\n" +
  10539. //" LEFT JOIN tp_pc_procedure p\n" +
  10540. //" ON p.procedureid = k.procedureid\n" +
  10541. //" WHERE k.valueflag = '1'\n" +
  10542. //" AND k.AccountID = :in_AccountID\n" +
  10543. //" AND k.createtime >= :in_BeginDate\n" +
  10544. //" AND k.createtime <= :in_EndDate\n" +
  10545. //" AND instr(','|| :procedureids ||',', ','|| k.procedureid ||',' ) > 0) kk\n" +
  10546. //" GROUP BY kk.procedurename, kk.usercode, kk.kilncode, kk.kdate\n" +
  10547. //" ORDER BY kk.procedurename, kk.usercode, kk.kilncode, kk.kdate";
  10548. string sqlString = "WITH kilnData AS\n" +
  10549. " (SELECT k.usercode\n" +
  10550. " ,kiln.kilncode\n" +
  10551. " ,p.procedurename\n" +
  10552. " ,trunc(k.createtime) kdate\n" +
  10553. " ,k.userid\n" +
  10554. " ,k.procedureid\n" +
  10555. " ,k.kilnid\n" +
  10556. " ,k.KILNCARBATCHNO\n" +
  10557. " FROM tp_pm_kilncardata k\n" +
  10558. " LEFT JOIN tp_mst_kiln kiln\n" +
  10559. " ON kiln.kilnid = k.kilnid\n" +
  10560. " LEFT JOIN tp_pc_procedure p\n" +
  10561. " ON p.procedureid = k.procedureid\n" +
  10562. " WHERE k.valueflag = '1'\n" +
  10563. " AND k.AccountID = :in_AccountID\n" +
  10564. " AND k.createtime >= :in_BeginDate\n" +
  10565. " AND k.createtime <= :in_EndDate\n" +
  10566. " AND instr(',' || :procedureids || ',', ',' || k.procedureid || ',') > 0)\n" +
  10567. "SELECT kd.procedurename\n" +
  10568. " ,kd.usercode\n" +
  10569. " ,kd.kilncode\n" +
  10570. " ,kd.kdate\n" +
  10571. " ,kd.kcount\n" +
  10572. " ,kpd.kpcount\n" +
  10573. " FROM (SELECT kk.procedurename\n" +
  10574. " ,kk.usercode\n" +
  10575. " ,kk.kilncode\n" +
  10576. " ,kk.kdate\n" +
  10577. " ,kk.procedureid\n" +
  10578. " ,kk.userid\n" +
  10579. " ,kk.kilnid\n" +
  10580. " ,COUNT(*) kcount\n" +
  10581. " FROM kilnData kk\n" +
  10582. " GROUP BY kk.procedurename\n" +
  10583. " ,kk.usercode\n" +
  10584. " ,kk.kilncode\n" +
  10585. " ,kk.kdate\n" +
  10586. " ,kk.procedureid\n" +
  10587. " ,kk.userid\n" +
  10588. " ,kk.kilnid) kd\n" +
  10589. " LEFT JOIN (SELECT kk.kdate\n" +
  10590. " ,kk.procedureid\n" +
  10591. " ,kk.userid\n" +
  10592. " ,kk.kilnid\n" +
  10593. " ,COUNT(*) kpcount\n" +
  10594. " FROM kilnData kk\n" +
  10595. " INNER JOIN tp_pm_productiondata pd\n" +
  10596. " ON pd.valueflag = '1'\n" +
  10597. " AND pd.procedureid = kk.procedureid\n" +
  10598. " AND pd.kilnid = kk.kilnid\n" +
  10599. " AND pd.KILNCARBATCHNO = kk.KILNCARBATCHNO\n" +
  10600. " GROUP BY kk.kdate, kk.procedureid, kk.userid, kk.kilnid) kpd\n" +
  10601. " ON kpd.kdate = kd.kdate\n" +
  10602. " AND kpd.procedureid = kd.procedureid\n" +
  10603. " AND kpd.userid = kd.userid\n" +
  10604. " AND kpd.kilnid = kd.kilnid\n" +
  10605. " ORDER BY kd.procedurename, kd.usercode, kd.kilncode, kd.kdate";
  10606. OracleParameter[] parascount = new OracleParameter[]{
  10607. new OracleParameter(":in_AccountID",OracleDbType.Int32,user.AccountID,ParameterDirection.Input),
  10608. new OracleParameter(":in_BeginDate",OracleDbType.Date,se.startDateTime,ParameterDirection.Input),
  10609. new OracleParameter(":in_EndDate",OracleDbType.Date,se.endDateTime,ParameterDirection.Input),
  10610. new OracleParameter(":procedureids",OracleDbType.Varchar2,se.ProcedureIDS,ParameterDirection.Input),
  10611. };
  10612. DataTable dt = conn.GetSqlResultToDt(sqlString, parascount);
  10613. if (dt != null)
  10614. {
  10615. sre.Data.Tables.Add(dt);
  10616. }
  10617. conn.Commit();
  10618. return sre;
  10619. }
  10620. catch (Exception ex)
  10621. {
  10622. throw ex;
  10623. }
  10624. finally
  10625. {
  10626. if (conn != null &&
  10627. conn.ConnState == ConnectionState.Open)
  10628. {
  10629. conn.Disconnect();
  10630. }
  10631. }
  10632. }
  10633. #endregion
  10634. /// <summary>
  10635. /// 使用存储过程PRO_PM_GetProductionData获取生产工序计件数据
  10636. /// </summary>
  10637. /// <param name="searchEntity">生产数据实体类</param>
  10638. /// <param name="user">用户基本信息</param>
  10639. /// <returns>DataTable</returns>
  10640. public static DataTable GetProductionData(SearchProductionDataEntity searchEntity, SUserInfo user)
  10641. {
  10642. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10643. string procsql = "PRO_RPT_GetProductionData";
  10644. try
  10645. {
  10646. IDataParameter[] paras = new OracleParameter[]
  10647. {
  10648. new OracleParameter("in_procedureList",OracleDbType.Varchar2, searchEntity.ProcedureIDS, ParameterDirection.Input),
  10649. new OracleParameter("in_LineID", OracleDbType.Int32,searchEntity.ProductionLineID, ParameterDirection.Input),
  10650. new OracleParameter("in_barCode", OracleDbType.Varchar2,searchEntity.BarCode, ParameterDirection.Input),
  10651. new OracleParameter("in_goodsCode", OracleDbType.Varchar2,searchEntity.GoodsCode, ParameterDirection.Input),
  10652. new OracleParameter("in_goodsName", OracleDbType.Varchar2,searchEntity.GoodsName, ParameterDirection.Input),
  10653. new OracleParameter("in_userCode", OracleDbType.Varchar2,searchEntity.UserCode, ParameterDirection.Input),
  10654. new OracleParameter("in_organizationID", OracleDbType.Int32,searchEntity.OrganizationID, ParameterDirection.Input),
  10655. new OracleParameter("in_remarks", OracleDbType.Varchar2,searchEntity.Remarks, ParameterDirection.Input),
  10656. new OracleParameter("in_isReworked", OracleDbType.Varchar2,searchEntity.IsRework, ParameterDirection.Input),
  10657. new OracleParameter("in_begindate", OracleDbType.Date,searchEntity.BeginDate, ParameterDirection.Input),
  10658. new OracleParameter("in_enddate", OracleDbType.Date,searchEntity.EndDate, ParameterDirection.Input),
  10659. new OracleParameter("in_accountID", OracleDbType.Int32,user.AccountID, ParameterDirection.Input),
  10660. new OracleParameter("in_userID", OracleDbType.Int32,user.UserID, ParameterDirection.Input),
  10661. new OracleParameter("in_kilnCode", OracleDbType.Varchar2,searchEntity.KilnCode, ParameterDirection.Input),
  10662. new OracleParameter("in_kilnCarCode", OracleDbType.Varchar2,searchEntity.KilnCarCode, ParameterDirection.Input),
  10663. new OracleParameter("in_kilnCarPosition", OracleDbType.Int32,searchEntity.KilnCarPosition, ParameterDirection.Input),
  10664. new OracleParameter("in_currentUserID", OracleDbType.Int32,user.UserID, ParameterDirection.Input),
  10665. new OracleParameter("out_result", OracleDbType.RefCursor, ParameterDirection.Output),
  10666. new OracleParameter("in_goodsTypeCode", OracleDbType.Varchar2,searchEntity.GoodsTypeCode, ParameterDirection.Input),
  10667. };
  10668. oracleConn.Open();
  10669. DataSet returnDs = oracleConn.ExecStoredProcedure(procsql, paras);
  10670. if (returnDs != null && returnDs.Tables.Count > 0)
  10671. {
  10672. return returnDs.Tables[0];
  10673. }
  10674. else
  10675. {
  10676. return null;
  10677. }
  10678. }
  10679. catch (Exception ex)
  10680. {
  10681. throw ex;
  10682. }
  10683. finally
  10684. {
  10685. if (oracleConn.ConnState == ConnectionState.Open)
  10686. {
  10687. oracleConn.Close();
  10688. }
  10689. }
  10690. }
  10691. /// <summary>
  10692. /// 取得RPT080106(温湿计明细)的汇总信息查询数据
  10693. /// </summary>
  10694. /// <param name="user">登录用户信息</param>
  10695. /// <param name="se">查询条件</param>
  10696. /// <returns>查询结果</returns>
  10697. public static ServiceResultEntity GetRPT080106IData(SUserInfo user, CelsiusRecordEntity se)
  10698. {
  10699. IDBConnection conn = null;
  10700. try
  10701. {
  10702. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10703. List<OracleParameter> parameters = new List<OracleParameter>();
  10704. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080106ISQL(user, se, ref parameters));
  10705. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  10706. ServiceResultEntity sre = new ServiceResultEntity();
  10707. if (data == null || data.Rows.Count == 0)
  10708. {
  10709. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10710. return sre;
  10711. }
  10712. sre.Data = new DataSet();
  10713. sre.Data.Tables.Add(data);
  10714. return sre;
  10715. }
  10716. catch (Exception ex)
  10717. {
  10718. throw ex;
  10719. }
  10720. finally
  10721. {
  10722. if (conn != null &&
  10723. conn.ConnState == ConnectionState.Open)
  10724. {
  10725. conn.Close();
  10726. }
  10727. }
  10728. }
  10729. /// <summary>
  10730. /// 取得RPT080106(温湿计明细)的汇总信息查询数据sql
  10731. /// </summary>
  10732. /// <returns>sql</returns>
  10733. private static string GetRPT080106ISQL(SUserInfo user, CelsiusRecordEntity se, ref List<OracleParameter> parameters)
  10734. {
  10735. string selSql = @"Select cr.*,t.*,to_char(cr.RecordDate,'mm-dd hh24:mi') as RecordDateStr from TP_PM_CelsiusRecord cr
  10736. Left join TP_MST_User u On cr.ThermometerID = u.UserId
  10737. Inner join TP_MST_Thermometer t On cr.ThermometerID = t.ThermometerID
  10738. Where cr.AccountID =:AccountID and cr.ValueFlag = '1' ";
  10739. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  10740. if (!string.IsNullOrEmpty(se.ThermometerIDS))
  10741. {
  10742. selSql = selSql + " AND instr(','||:ThermometerIDS||',',','||cr.ThermometerID||',')>0 ";
  10743. parameters.Add(new OracleParameter(":ThermometerIDS", OracleDbType.NVarchar2, se.ThermometerIDS, ParameterDirection.Input));
  10744. }
  10745. if (!string.IsNullOrEmpty(se.Remarks))
  10746. {
  10747. selSql = selSql + " AND instr(cr.Remarks,:Remarks) >0 ";
  10748. parameters.Add(new OracleParameter(":Remarks", OracleDbType.NVarchar2, se.Remarks, ParameterDirection.Input));
  10749. }
  10750. if (se.RecordDate.HasValue)
  10751. {
  10752. selSql = selSql + " AND cr.CreateTime>= :CreateTimeStart ";
  10753. parameters.Add(new OracleParameter(":CreateTimeStart", OracleDbType.Date, se.RecordDate.Value, ParameterDirection.Input));
  10754. }
  10755. if (se.RecordDateEnd.HasValue)
  10756. {
  10757. selSql = selSql + " AND cr.CreateTime<= :CreateTimeEnd ";
  10758. parameters.Add(new OracleParameter(":CreateTimeEnd", OracleDbType.Date, se.RecordDateEnd.Value, ParameterDirection.Input));
  10759. }
  10760. selSql +=
  10761. // 温湿计查看权限
  10762. " AND EXISTS (SELECT UP.PurviewID" +
  10763. " FROM TP_MST_UserPurview UP" +
  10764. " WHERE UP.PurviewType = '" + (int)Constant.PurviewType.ViewCelsius + "'" +
  10765. " AND (UP.PurviewID = -1 OR UP.PurviewID = CR.ThermometerID)" +
  10766. " AND UP.UserId = :UPUserId)";
  10767. parameters.Add(new OracleParameter(":UPUserId", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  10768. selSql = selSql + " order by RecordDate asc";
  10769. return selSql;
  10770. }
  10771. /// <summary>
  10772. /// 取得RPT030110画面(半检登记汇总表)的汇总信息查询数据
  10773. /// </summary>
  10774. /// <param name="user">登录用户信息</param>
  10775. /// <param name="se">查询条件</param>
  10776. /// <returns>查询结果</returns>
  10777. public static ServiceResultEntity GetRPT030110Data(SUserInfo user, SemiCheckEntity se)
  10778. {
  10779. IDBConnection conn = null;
  10780. try
  10781. {
  10782. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  10783. List<OracleParameter> parameters = new List<OracleParameter>();
  10784. string sql = ReportModuleLogic.GetRPT030110SSQL(user, se, ref parameters);
  10785. DataTable data = conn.GetSqlResultToDt(sql, parameters.ToArray());
  10786. ServiceResultEntity sre = new ServiceResultEntity();
  10787. if (data == null || data.Rows.Count == 0)
  10788. {
  10789. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  10790. return sre;
  10791. }
  10792. sre.Data = new DataSet();
  10793. sre.Data.Tables.Add(data);
  10794. return sre;
  10795. }
  10796. catch (Exception ex)
  10797. {
  10798. throw ex;
  10799. }
  10800. finally
  10801. {
  10802. if (conn != null &&
  10803. conn.ConnState == ConnectionState.Open)
  10804. {
  10805. conn.Close();
  10806. }
  10807. }
  10808. }
  10809. /// <summary>
  10810. /// 获取RPT030110画面(半检登记汇总表)的汇总信息查询sql
  10811. /// </summary>
  10812. /// <returns>sql</returns>
  10813. private static string GetRPT030110SSQL(SUserInfo user, SemiCheckEntity se, ref List<OracleParameter> parameters)
  10814. {
  10815. parameters.Add(new OracleParameter(":accountid", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  10816. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  10817. #region
  10818. // string sqlString = @"
  10819. // SELECT t.reworkprocedureid -- 返工工序id
  10820. // ,decode(gid,
  10821. // 7,
  10822. // '总计',
  10823. // 3,
  10824. // '合计【' || t.reworkprocedurename || '】',
  10825. // 0,
  10826. // t.reworkprocedurename,
  10827. // '--') reworkprocedurename -- 返工工序
  10828. // ,t.goodstypecode2 -- 产品二级类别
  10829. // ,decode(gid,
  10830. // 1,
  10831. // '小计【' || t.goodstypename2 || '】',
  10832. // 0,
  10833. // t.goodstypename2,
  10834. // '--') goodstypename2 -- 产品二级类别
  10835. // ,t.reworkuserid -- 返工工号id
  10836. // ,decode(gid, 0, t.reworkusercode, '--') reworkusercode -- 返工工号
  10837. // ,t.goodsid -- 产品id
  10838. // ,decode(gid, 0, t.goodscode, '--') goodscode -- 产品编码
  10839. // ,decode(gid, 0, t.goodstypename, '--') goodstypename -- 产品类别
  10840. // ,t.reworkcount -- 返工数
  10841. // ,t.badcount -- 不合格数
  10842. // ,t.regoodcount -- 复检合格数
  10843. // ,t.rebadcount -- 复检不合格数
  10844. // ,t.renocount -- 未复检
  10845. // --,t.renocountsum -- 待返工
  10846. // ,(SELECT COUNT(*)
  10847. // FROM tp_pm_semicheck sci
  10848. // WHERE sci.valueflag = '1'
  10849. // AND sci.backoutflag = '0'
  10850. // AND sci.semichecktype = 1
  10851. // AND sci.resemichecktype = 0
  10852. // AND (t.reworkprocedureid is null or sci.reworkprocedureid = t.reworkprocedureid)
  10853. // AND (t.goodsid is null or sci.goodsid = t.goodsid)
  10854. // AND (t.reworkuserid is null or sci.reworkuserid = t.reworkuserid)) AS renocountsum
  10855. // FROM (SELECT grouping_id(sc.reworkprocedureid, gt2.goodstypecode, g.goodsid) gid
  10856. // ,sc.reworkprocedureid
  10857. // ,rp.procedurename reworkprocedurename
  10858. // ,gt2.goodstypecode goodstypecode2
  10859. // ,gt2.goodstypename goodstypename2
  10860. // ,sc.reworkuserid
  10861. // ,sc.reworkusercode
  10862. // ,g.goodsid
  10863. // ,g.goodscode
  10864. // ,gt.goodstypename
  10865. // , SUM(CASE
  10866. // WHEN sc.semichecktype = 1 THEN
  10867. // 1
  10868. // ELSE
  10869. // 0
  10870. // END) reworkcount
  10871. // , SUM(CASE
  10872. // WHEN sc.semichecktype = 2 THEN
  10873. // 1
  10874. // ELSE
  10875. // 0
  10876. // END) badcount
  10877. // , SUM(CASE
  10878. // WHEN sc.semichecktype = 1 AND sc.resemichecktype = 0 THEN
  10879. // 1
  10880. // ELSE
  10881. // 0
  10882. // END) renocount
  10883. // , SUM(CASE
  10884. // WHEN sc.semichecktype = 1 AND sc.resemichecktype = 1 THEN
  10885. // 1
  10886. // ELSE
  10887. // 0
  10888. // END) regoodcount
  10889. // , SUM(CASE
  10890. // WHEN sc.semichecktype = 1 AND sc.resemichecktype = 2 THEN
  10891. // 1
  10892. // ELSE
  10893. // 0
  10894. // END) rebadcount
  10895. // --,(select count(*) from tp_pm_semicheck sci where sci.valueflag = '1' and sci.backoutflag = '0' and sci.semichecktype = 1
  10896. // -- and sci.resemichecktype = 0 and sci.reworkprocedureid = sc.reworkprocedureid and sci.reworkuserid = sc.reworkuserid and sci.goodsid = g.goodsid) as renocountsum
  10897. // --FROM tp_pm_semicheck sc
  10898. // FROM (SELECT semicheckid
  10899. // ,barcode
  10900. // ,productionlineid
  10901. // ,procedureid
  10902. // ,proceduretime
  10903. // ,proceduremodel
  10904. // ,modeltype
  10905. // ,organizationid
  10906. // ,goodsid
  10907. // ,goodscode
  10908. // ,userid
  10909. // ,usercode
  10910. // ,productiondataid
  10911. // ,logoid
  10912. // ,ispublicbody
  10913. // ,specialrepairflag
  10914. // ,goodslevelid
  10915. // ,goodsleveltypeid
  10916. // ,groutingdailyid
  10917. // ,groutingdailydetailid
  10918. // ,groutinglineid
  10919. // ,groutinglinecode
  10920. // ,groutinglinename
  10921. // ,gmouldtypeid
  10922. // ,canmanytimes
  10923. // ,groutinglinedetailid
  10924. // ,groutingdate
  10925. // ,groutingmouldcode
  10926. // ,mouldcode
  10927. // ,groutinguserid
  10928. // ,groutingusercode
  10929. // ,groutingnum
  10930. // ,semichecktype
  10931. // ,semicheckuserid
  10932. // ,semicheckusercode
  10933. // ,semichecktime
  10934. // ,reworkprocedureid
  10935. // ,reworkprocedurecode
  10936. // ,reworkuserid
  10937. // ,reworkusercode
  10938. // ,resemichecktype
  10939. // ,resemicheckuserid
  10940. // ,resemicheckusercode
  10941. // ,resemichecktime
  10942. // ,backoutflag
  10943. // ,backouttime
  10944. // ,backoutuserid
  10945. // ,backoutusercode
  10946. // ,remarks
  10947. // ,createtime
  10948. // ,createuserid
  10949. // ,updateuserid
  10950. // FROM tp_pm_semicheck sc
  10951. // WHERE sc.accountid = :accountid
  10952. // AND sc.valueflag = '1'
  10953. // AND sc.semichecktype = 1
  10954. // AND sc.backoutflag = '0'
  10955. // UNION ALL
  10956. // SELECT DISTINCT sc.semicheckid
  10957. // ,sc.barcode
  10958. // ,sc.productionlineid
  10959. // ,sc.procedureid
  10960. // ,sc.proceduretime
  10961. // ,sc.proceduremodel
  10962. // ,sc.modeltype
  10963. // ,sc.organizationid
  10964. // ,sc.goodsid
  10965. // ,sc.goodscode
  10966. // ,sc.userid
  10967. // ,sc.usercode
  10968. // ,sc.productiondataid
  10969. // ,sc.logoid
  10970. // ,sc.ispublicbody
  10971. // ,sc.specialrepairflag
  10972. // ,sc.goodslevelid
  10973. // ,sc.goodsleveltypeid
  10974. // ,sc.groutingdailyid
  10975. // ,sc.groutingdailydetailid
  10976. // ,sc.groutinglineid
  10977. // ,sc.groutinglinecode
  10978. // ,sc.groutinglinename
  10979. // ,sc.gmouldtypeid
  10980. // ,sc.canmanytimes
  10981. // ,sc.groutinglinedetailid
  10982. // ,sc.groutingdate
  10983. // ,sc.groutingmouldcode
  10984. // ,sc.mouldcode
  10985. // ,sc.groutinguserid
  10986. // ,sc.groutingusercode
  10987. // ,sc.groutingnum
  10988. // ,sc.semichecktype
  10989. // ,sc.semicheckuserid
  10990. // ,sc.semicheckusercode
  10991. // ,sc.semichecktime
  10992. // --,sc.reworkprocedureid
  10993. // --,sc.reworkprocedurecode
  10994. // --,sc.reworkuserid
  10995. // --,sc.reworkusercode
  10996. // ,scd.defectprocedureid
  10997. // ,scdp.procedurename
  10998. // ,scd.defectuserid
  10999. // ,scd.defectusercode
  11000. // ,sc.resemichecktype
  11001. // ,sc.resemicheckuserid
  11002. // ,sc.resemicheckusercode
  11003. // ,sc.resemichecktime
  11004. // ,sc.backoutflag
  11005. // ,sc.backouttime
  11006. // ,sc.backoutuserid
  11007. // ,sc.backoutusercode
  11008. // ,sc.remarks
  11009. // ,sc.createtime
  11010. // ,sc.createuserid
  11011. // ,sc.updateuserid
  11012. // FROM tp_pm_semicheck sc
  11013. // LEFT JOIN TP_PM_SemiCheckDefect scd
  11014. // ON sc.semicheckid = scd.semicheckid
  11015. // LEFT JOIN tp_pc_procedure scdp
  11016. // ON scdp.procedureid = scd.defectprocedureid
  11017. // WHERE sc.accountid = :accountid
  11018. // AND sc.valueflag = '1'
  11019. // AND sc.semichecktype = 2
  11020. // AND sc.backoutflag = '0'
  11021. // ) sc
  11022. // LEFT JOIN tp_pc_procedure rp
  11023. // ON rp.procedureid = sc.reworkprocedureid
  11024. // INNER JOIN tp_mst_goods g
  11025. // ON g.goodsid = sc.goodsid
  11026. // INNER JOIN tp_mst_goodstype gt
  11027. // ON gt.goodstypeid = g.goodstypeid
  11028. // INNER JOIN tp_mst_goodstype gt2
  11029. // ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)
  11030. // AND gt2.accountid = gt.accountid
  11031. // INNER join TP_PM_GroutingDailyDetail GroutingDailyDetail
  11032. // ON GroutingDailyDetail.GroutingDailyDetailID=sc.GroutingDailyDetailID
  11033. // 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))";
  11034. #endregion
  11035. string sqlString = "SELECT t.reworkprocedureid -- 返工工序id\n" +
  11036. " ,decode(gid,\n" +
  11037. " 7,\n" +
  11038. " '总计',\n" +
  11039. " 3,\n" +
  11040. " '合计【' || t.reworkprocedurename || '】',\n" +
  11041. " 0,\n" +
  11042. " t.reworkprocedurename,\n" +
  11043. " '--') reworkprocedurename -- 返工工序\n" +
  11044. " ,t.goodstypecode2 -- 产品二级类别\n" +
  11045. " ,decode(gid,\n" +
  11046. " 1,\n" +
  11047. " '小计【' || t.goodstypename2 || '】',\n" +
  11048. " 0,\n" +
  11049. " t.goodstypename2,\n" +
  11050. " '--') goodstypename2 -- 产品二级类别\n" +
  11051. " ,t.reworkuserid -- 返工工号id\n" +
  11052. " ,decode(gid, 0, t.reworkusercode, '--') reworkusercode -- 返工工号\n" +
  11053. " ,t.goodsid -- 产品id\n" +
  11054. " ,decode(gid, 0, t.goodscode, '--') goodscode -- 产品编码\n" +
  11055. " ,decode(gid, 0, t.goodstypename, '--') goodstypename -- 产品类别\n" +
  11056. " ,t.reworkcount -- 返工数\n" +
  11057. " ,t.badcount -- 不合格数\n" +
  11058. " ,t.regoodcount -- 复检合格数\n" +
  11059. " ,t.rebadcount -- 复检不合格数\n" +
  11060. " ,t.renocount -- 未复检\n" +
  11061. " ,t.renocountsum -- 待返工\n" +
  11062. " FROM (SELECT grouping_id(sct.reworkprocedureid,\n" +
  11063. " sct.goodstypecode2,\n" +
  11064. " sct.goodsid) gid\n" +
  11065. " ,sct.displayno\n" +
  11066. " ,sct.reworkprocedureid\n" +
  11067. " ,sct.reworkprocedurename\n" +
  11068. " ,sct.goodstypecode2\n" +
  11069. " ,sct.goodstypename2\n" +
  11070. " ,sct.reworkuserid\n" +
  11071. " ,sct.reworkusercode\n" +
  11072. " ,sct.goodsid\n" +
  11073. " ,sct.goodscode\n" +
  11074. " ,sct.goodstypename\n" +
  11075. " ,SUM(sct.reworkcount) reworkcount\n" +
  11076. " ,SUM(sct. badcount) badcount\n" +
  11077. " ,SUM(sct. renocount) renocount\n" +
  11078. " ,SUM(sct.regoodcount) regoodcount\n" +
  11079. " ,SUM(sct.rebadcount) rebadcount\n" +
  11080. " ,SUM(sct.renocountsum) renocountsum\n" +
  11081. " FROM (SELECT rp.displayno\n" +
  11082. " ,sc.reworkprocedureid\n" +
  11083. " ,rp.procedurename reworkprocedurename\n" +
  11084. " ,gt2.goodstypecode goodstypecode2\n" +
  11085. " ,gt2.goodstypename goodstypename2\n" +
  11086. " ,sc.reworkuserid\n" +
  11087. " ,sc.reworkusercode\n" +
  11088. " ,g.goodsid\n" +
  11089. " ,g.goodscode\n" +
  11090. " ,gt.goodstypename\n" +
  11091. " , SUM(CASE\n" +
  11092. " WHEN sc.semichecktype = 1 THEN\n" +
  11093. " 1\n" +
  11094. " ELSE\n" +
  11095. " 0\n" +
  11096. " END) reworkcount\n" +
  11097. " , SUM(CASE\n" +
  11098. " WHEN sc.semichecktype = 2 THEN\n" +
  11099. " 1\n" +
  11100. " ELSE\n" +
  11101. " 0\n" +
  11102. " END) badcount\n" +
  11103. " , SUM(CASE\n" +
  11104. " WHEN sc.semichecktype = 1 AND sc.resemichecktype = 0 THEN\n" +
  11105. " 1\n" +
  11106. " ELSE\n" +
  11107. " 0\n" +
  11108. " END) renocount\n" +
  11109. " , SUM(CASE\n" +
  11110. " WHEN sc.semichecktype = 1 AND sc.resemichecktype = 1 THEN\n" +
  11111. " 1\n" +
  11112. " ELSE\n" +
  11113. " 0\n" +
  11114. " END) regoodcount\n" +
  11115. " , SUM(CASE\n" +
  11116. " WHEN sc.semichecktype = 1 AND sc.resemichecktype = 2 THEN\n" +
  11117. " 1\n" +
  11118. " ELSE\n" +
  11119. " 0\n" +
  11120. " END) rebadcount\n" +
  11121. " ,(SELECT COUNT(*)\n" +
  11122. " FROM tp_pm_semicheck sci\n" +
  11123. " WHERE sci.valueflag = '1'\n" +
  11124. " AND sci.backoutflag = '0'\n" +
  11125. " AND sci.semichecktype = 1\n" +
  11126. " AND sci.resemichecktype = 0\n" +
  11127. " AND sci.accountid = :accountid\n" +
  11128. " AND sci.reworkprocedureid = sc.reworkprocedureid\n" +
  11129. " AND sci.reworkuserid = sc.reworkuserid\n" +
  11130. " AND sci.goodsid = g.goodsid) AS renocountsum\n" +
  11131. " FROM (SELECT semicheckid\n" +
  11132. " ,barcode\n" +
  11133. " ,productionlineid\n" +
  11134. " ,procedureid\n" +
  11135. " ,proceduretime\n" +
  11136. " ,proceduremodel\n" +
  11137. " ,modeltype\n" +
  11138. " ,organizationid\n" +
  11139. " ,goodsid\n" +
  11140. " ,goodscode\n" +
  11141. " ,userid\n" +
  11142. " ,usercode\n" +
  11143. " ,productiondataid\n" +
  11144. " ,logoid\n" +
  11145. " ,ispublicbody\n" +
  11146. " ,specialrepairflag\n" +
  11147. " ,goodslevelid\n" +
  11148. " ,goodsleveltypeid\n" +
  11149. " ,groutingdailyid\n" +
  11150. " ,groutingdailydetailid\n" +
  11151. " ,groutinglineid\n" +
  11152. " ,groutinglinecode\n" +
  11153. " ,groutinglinename\n" +
  11154. " ,gmouldtypeid\n" +
  11155. " ,canmanytimes\n" +
  11156. " ,groutinglinedetailid\n" +
  11157. " ,groutingdate\n" +
  11158. " ,groutingmouldcode\n" +
  11159. " ,mouldcode\n" +
  11160. " ,groutinguserid\n" +
  11161. " ,groutingusercode\n" +
  11162. " ,groutingnum\n" +
  11163. " ,semichecktype\n" +
  11164. " ,semicheckuserid\n" +
  11165. " ,semicheckusercode\n" +
  11166. " ,semichecktime\n" +
  11167. " ,reworkprocedureid\n" +
  11168. " ,reworkprocedurecode\n" +
  11169. " ,reworkuserid\n" +
  11170. " ,reworkusercode\n" +
  11171. " ,resemichecktype\n" +
  11172. " ,resemicheckuserid\n" +
  11173. " ,resemicheckusercode\n" +
  11174. " ,resemichecktime\n" +
  11175. " ,backoutflag\n" +
  11176. " ,backouttime\n" +
  11177. " ,backoutuserid\n" +
  11178. " ,backoutusercode\n" +
  11179. " ,remarks\n" +
  11180. " ,createtime\n" +
  11181. " ,createuserid\n" +
  11182. " ,updateuserid\n" +
  11183. " FROM tp_pm_semicheck sc\n" +
  11184. " WHERE sc.accountid = :accountid\n" +
  11185. " AND sc.valueflag = '1'\n" +
  11186. " AND sc.semichecktype = 1\n" +
  11187. " AND sc.backoutflag = '0'\n" +
  11188. " UNION ALL\n" +
  11189. " SELECT DISTINCT sc.semicheckid\n" +
  11190. " ,sc.barcode\n" +
  11191. " ,sc.productionlineid\n" +
  11192. " ,sc.procedureid\n" +
  11193. " ,sc.proceduretime\n" +
  11194. " ,sc.proceduremodel\n" +
  11195. " ,sc.modeltype\n" +
  11196. " ,sc.organizationid\n" +
  11197. " ,sc.goodsid\n" +
  11198. " ,sc.goodscode\n" +
  11199. " ,sc.userid\n" +
  11200. " ,sc.usercode\n" +
  11201. " ,sc.productiondataid\n" +
  11202. " ,sc.logoid\n" +
  11203. " ,sc.ispublicbody\n" +
  11204. " ,sc.specialrepairflag\n" +
  11205. " ,sc.goodslevelid\n" +
  11206. " ,sc.goodsleveltypeid\n" +
  11207. " ,sc.groutingdailyid\n" +
  11208. " ,sc.groutingdailydetailid\n" +
  11209. " ,sc.groutinglineid\n" +
  11210. " ,sc.groutinglinecode\n" +
  11211. " ,sc.groutinglinename\n" +
  11212. " ,sc.gmouldtypeid\n" +
  11213. " ,sc.canmanytimes\n" +
  11214. " ,sc.groutinglinedetailid\n" +
  11215. " ,sc.groutingdate\n" +
  11216. " ,sc.groutingmouldcode\n" +
  11217. " ,sc.mouldcode\n" +
  11218. " ,sc.groutinguserid\n" +
  11219. " ,sc.groutingusercode\n" +
  11220. " ,sc.groutingnum\n" +
  11221. " ,sc.semichecktype\n" +
  11222. " ,sc.semicheckuserid\n" +
  11223. " ,sc.semicheckusercode\n" +
  11224. " ,sc.semichecktime\n" +
  11225. " --,sc.reworkprocedureid\n" +
  11226. " --,sc.reworkprocedurecode\n" +
  11227. " --,sc.reworkuserid\n" +
  11228. " --,sc.reworkusercode\n" +
  11229. " ,scd.defectprocedureid\n" +
  11230. " ,scdp.procedurename\n" +
  11231. " ,scd.defectuserid\n" +
  11232. " ,scd.defectusercode\n" +
  11233. " ,sc.resemichecktype\n" +
  11234. " ,sc.resemicheckuserid\n" +
  11235. " ,sc.resemicheckusercode\n" +
  11236. " ,sc.resemichecktime\n" +
  11237. " ,sc.backoutflag\n" +
  11238. " ,sc.backouttime\n" +
  11239. " ,sc.backoutuserid\n" +
  11240. " ,sc.backoutusercode\n" +
  11241. " ,sc.remarks\n" +
  11242. " ,sc.createtime\n" +
  11243. " ,sc.createuserid\n" +
  11244. " ,sc.updateuserid\n" +
  11245. " FROM tp_pm_semicheck sc\n" +
  11246. " LEFT JOIN TP_PM_SemiCheckDefect scd\n" +
  11247. " ON sc.semicheckid = scd.semicheckid\n" +
  11248. " AND scd.valueflag='1'\n" +
  11249. " LEFT JOIN tp_pc_procedure scdp\n" +
  11250. " ON scdp.procedureid = scd.defectprocedureid\n" +
  11251. " WHERE sc.accountid = :accountid\n" +
  11252. " AND sc.valueflag = '1'\n" +
  11253. " AND sc.semichecktype = 2\n" +
  11254. " AND sc.backoutflag = '0') sc\n" +
  11255. " LEFT JOIN tp_pc_procedure rp\n" +
  11256. " ON rp.procedureid = sc.reworkprocedureid\n" +
  11257. " INNER JOIN tp_mst_goods g\n" +
  11258. " ON g.goodsid = sc.goodsid\n" +
  11259. " INNER JOIN tp_mst_goodstype gt\n" +
  11260. " ON gt.goodstypeid = g.goodstypeid\n" +
  11261. " INNER JOIN tp_mst_goodstype gt2\n" +
  11262. " ON gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  11263. " AND gt2.accountid = gt.accountid\n" +
  11264. " INNER JOIN TP_PM_GroutingDailyDetail GroutingDailyDetail\n" +
  11265. " ON GroutingDailyDetail.GroutingDailyDetailID =\n" +
  11266. " sc.GroutingDailyDetailID\n" //+
  11267. //" WHERE EXISTS (SELECT 1\n" +
  11268. //" FROM TP_MST_UserPurview up\n" +
  11269. //" WHERE up.PurviewType = 9\n" +
  11270. //" AND up.UserID = :UserID\n" +
  11271. //" AND (up.PurviewID = -1 OR\n" +
  11272. //" up.PurviewID = sc.procedureid))\n"
  11273. ;
  11274. // 完成工序集
  11275. if (!string.IsNullOrEmpty(se.CProcedureIDS))
  11276. {
  11277. sqlString += " AND instr(','||:procedureids||',', ',' || sc.procedureid || ',') > 0";
  11278. parameters.Add(new OracleParameter(":procedureids", OracleDbType.Varchar2, se.CProcedureIDS, ParameterDirection.Input));
  11279. }
  11280. // 完成时间起始
  11281. if (se.CDateTimeStart.HasValue)
  11282. {
  11283. sqlString = sqlString + " AND sc.ProcedureTime >= :CDateTimeStart ";
  11284. parameters.Add(new OracleParameter(":CDateTimeStart", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11285. }
  11286. // 完成时间结束
  11287. if (se.CDateTimeEnd.HasValue)
  11288. {
  11289. sqlString = sqlString + " AND sc.ProcedureTime <= :CDateTimeEnd ";
  11290. parameters.Add(new OracleParameter(":CDateTimeEnd", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11291. }
  11292. // 完成工号
  11293. if (!string.IsNullOrEmpty(se.CUserCode))
  11294. {
  11295. sqlString = sqlString + " AND instr(sc.UserCode,:UserCode)>0";
  11296. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CUserCode, ParameterDirection.Input));
  11297. }
  11298. // 产品类别
  11299. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  11300. {
  11301. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 ";
  11302. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  11303. }
  11304. // 产品编码
  11305. if (!string.IsNullOrEmpty(se.GoodsCode))
  11306. {
  11307. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0";
  11308. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  11309. }
  11310. // 成型工号
  11311. if (!string.IsNullOrEmpty(se.GroutingUserCode))
  11312. {
  11313. sqlString = sqlString + " AND instr(sc.GroutingUserCode,:GroutingUserCode)>0";
  11314. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.NVarchar2, se.GroutingUserCode, ParameterDirection.Input));
  11315. }
  11316. // 注浆时间起始
  11317. if (se.GroutingDateTimeStart.HasValue)
  11318. {
  11319. sqlString = sqlString + " AND sc.GroutingDate >= :GroutingDateTimeStart ";
  11320. parameters.Add(new OracleParameter(":GroutingDateTimeStart", OracleDbType.Date, se.GroutingDateTimeStart.Value, ParameterDirection.Input));
  11321. }
  11322. // 注浆时间结束
  11323. if (se.GroutingDateTimeEnd.HasValue)
  11324. {
  11325. sqlString = sqlString + " AND sc.GroutingDate <= :GroutingDateTimeEnd ";
  11326. parameters.Add(new OracleParameter(":GroutingDateTimeEnd", OracleDbType.Date, se.GroutingDateTimeEnd.Value, ParameterDirection.Input));
  11327. }
  11328. // 交坯时间起始
  11329. if (se.DeliveryDateTimeStart.HasValue)
  11330. {
  11331. sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime >= :DeliveryDateTimeStart ";
  11332. parameters.Add(new OracleParameter(":DeliveryDateTimeStart", OracleDbType.Date, se.DeliveryDateTimeStart.Value, ParameterDirection.Input));
  11333. }
  11334. // 交坯时间结束
  11335. if (se.DeliveryDateTimeEnd.HasValue)
  11336. {
  11337. sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime <= :DeliveryDateTimeEnd ";
  11338. parameters.Add(new OracleParameter(":DeliveryDateTimeEnd", OracleDbType.Date, se.DeliveryDateTimeEnd.Value, ParameterDirection.Input));
  11339. }
  11340. // 半检状态
  11341. if (!string.IsNullOrEmpty(se.SemiCheckType))
  11342. {
  11343. sqlString = sqlString + " AND instr(','||:SemiCheckType||',',','||sc.SemiCheckType||',')>0 ";
  11344. parameters.Add(new OracleParameter(":SemiCheckType", OracleDbType.NVarchar2, se.SemiCheckType, ParameterDirection.Input));
  11345. }
  11346. // 半检时间起始
  11347. if (se.SemiCheckDateTimeStart.HasValue)
  11348. {
  11349. sqlString = sqlString + " AND sc.SemiCheckTime >= :SemiCheckDateTimeStart ";
  11350. parameters.Add(new OracleParameter(":SemiCheckDateTimeStart", OracleDbType.Date, se.SemiCheckDateTimeStart.Value, ParameterDirection.Input));
  11351. }
  11352. // 半检时间结束
  11353. if (se.SemiCheckDateTimeEnd.HasValue)
  11354. {
  11355. sqlString = sqlString + " AND sc.SemiCheckTime <= :SemiCheckDateTimeEnd ";
  11356. parameters.Add(new OracleParameter(":SemiCheckDateTimeEnd", OracleDbType.Date, se.SemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  11357. }
  11358. // 半检工号
  11359. if (!string.IsNullOrEmpty(se.SemiCheckUserCode))
  11360. {
  11361. sqlString = sqlString + " AND instr(sc.SemiCheckUserCode,:SemiCheckUserCode)>0";
  11362. parameters.Add(new OracleParameter(":SemiCheckUserCode", OracleDbType.NVarchar2, se.SemiCheckUserCode, ParameterDirection.Input));
  11363. }
  11364. // 返工工序
  11365. if (!string.IsNullOrEmpty(se.RProcedureIDS))
  11366. {
  11367. sqlString = sqlString + " AND instr(','||:RProcedureIDS||',',','||sc.ReworkProcedureID||',')>0 ";
  11368. parameters.Add(new OracleParameter(":RProcedureIDS", OracleDbType.NVarchar2, se.RProcedureIDS, ParameterDirection.Input));
  11369. }
  11370. // 返工工号
  11371. if (!string.IsNullOrEmpty(se.ReworkUserCode))
  11372. {
  11373. sqlString = sqlString + " AND instr(sc.ReworkUserCode,:ReworkUserCode)>0";
  11374. parameters.Add(new OracleParameter(":ReworkUserCode", OracleDbType.NVarchar2, se.ReworkUserCode, ParameterDirection.Input));
  11375. }
  11376. // 复检状态
  11377. if (!string.IsNullOrEmpty(se.ReSemiCheckType))
  11378. {
  11379. sqlString = sqlString + " AND instr(','||:ReSemiCheckType||',',','||sc.ReSemiCheckType||',')>0 ";
  11380. parameters.Add(new OracleParameter(":ReSemiCheckType", OracleDbType.NVarchar2, se.ReSemiCheckType, ParameterDirection.Input));
  11381. }
  11382. // 复检时间起始
  11383. if (se.ReSemiCheckDateTimeStart.HasValue)
  11384. {
  11385. sqlString = sqlString + " AND sc.ReSemiCheckTime >= :ReSemiCheckDateTimeStart ";
  11386. parameters.Add(new OracleParameter(":ReSemiCheckDateTimeStart", OracleDbType.Date, se.ReSemiCheckDateTimeStart.Value, ParameterDirection.Input));
  11387. }
  11388. // 复检时间结束
  11389. if (se.ReSemiCheckDateTimeEnd.HasValue)
  11390. {
  11391. sqlString = sqlString + " AND sc.ReSemiCheckTime <= :ReSemiCheckDateTimeEnd ";
  11392. parameters.Add(new OracleParameter(":ReSemiCheckDateTimeEnd", OracleDbType.Date, se.ReSemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  11393. }
  11394. // 复检工号
  11395. if (!string.IsNullOrEmpty(se.ReSemiCheckUserCode))
  11396. {
  11397. sqlString = sqlString + " AND instr(sc.ReSemiCheckUserCode,:ReSemiCheckUserCode)>0";
  11398. parameters.Add(new OracleParameter(":ReSemiCheckUserCode", OracleDbType.NVarchar2, se.ReSemiCheckUserCode, ParameterDirection.Input));
  11399. }
  11400. // 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),())
  11401. // ORDER BY rp.displayno
  11402. // ,gt2.goodstypename
  11403. // ,sc.reworkusercode
  11404. // ,g.goodscode
  11405. // ,gt.goodstypename, gid) t
  11406. // ";
  11407. sqlString = sqlString +
  11408. " GROUP BY rp.displayno\n" +
  11409. " ,sc.reworkprocedureid\n" +
  11410. " ,rp.procedurename\n" +
  11411. " ,gt2.goodstypecode\n" +
  11412. " ,gt2.goodstypename\n" +
  11413. " ,sc.reworkuserid\n" +
  11414. " ,sc.reworkusercode\n" +
  11415. " ,g.goodsid\n" +
  11416. " ,g.goodscode\n" +
  11417. " ,gt.goodstypename) sct\n" +
  11418. " 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" +
  11419. " ORDER BY sct.displayno\n" +
  11420. " ,sct.goodstypename\n" +
  11421. " ,sct.reworkusercode\n" +
  11422. " ,sct.goodscode\n" +
  11423. " ,sct.goodstypename\n" +
  11424. " ,gid) t";
  11425. return sqlString;
  11426. }
  11427. /// <summary>
  11428. /// 取得RPT080107(半检登记明细)的信息查询数据
  11429. /// </summary>
  11430. /// <param name="user">登录用户信息</param>
  11431. /// <param name="se">查询条件</param>
  11432. /// <returns>查询结果</returns>
  11433. public static ServiceResultEntity GetRPT080107IData(SUserInfo user, SemiCheckEntity se)
  11434. {
  11435. IDBConnection conn = null;
  11436. try
  11437. {
  11438. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  11439. List<OracleParameter> parameters = new List<OracleParameter>();
  11440. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080107ISQL(user, se, ref parameters));
  11441. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  11442. ServiceResultEntity sre = new ServiceResultEntity();
  11443. if (data == null || data.Rows.Count == 0)
  11444. {
  11445. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  11446. return sre;
  11447. }
  11448. sre.Data = new DataSet();
  11449. sre.Data.Tables.Add(data);
  11450. return sre;
  11451. }
  11452. catch (Exception ex)
  11453. {
  11454. throw ex;
  11455. }
  11456. finally
  11457. {
  11458. if (conn != null &&
  11459. conn.ConnState == ConnectionState.Open)
  11460. {
  11461. conn.Close();
  11462. }
  11463. }
  11464. }
  11465. //xuwei add 2019-10-14
  11466. /// <summary>
  11467. /// 取得RPT080108(半检返修登记明细)的信息查询数据
  11468. /// </summary>
  11469. /// <param name="user">登录用户信息</param>
  11470. /// <param name="se">查询条件</param>
  11471. /// <returns>查询结果</returns>
  11472. public static ServiceResultEntity GetRPT080108IData(SUserInfo user, SemiCheckEntity se)
  11473. {
  11474. IDBConnection conn = null;
  11475. try
  11476. {
  11477. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  11478. List<OracleParameter> parameters = new List<OracleParameter>();
  11479. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT080108ISQL(user, se, ref parameters));
  11480. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  11481. ServiceResultEntity sre = new ServiceResultEntity();
  11482. if (data == null || data.Rows.Count == 0)
  11483. {
  11484. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  11485. return sre;
  11486. }
  11487. sre.Data = new DataSet();
  11488. sre.Data.Tables.Add(data);
  11489. return sre;
  11490. }
  11491. catch (Exception ex)
  11492. {
  11493. throw ex;
  11494. }
  11495. finally
  11496. {
  11497. if (conn != null &&
  11498. conn.ConnState == ConnectionState.Open)
  11499. {
  11500. conn.Close();
  11501. }
  11502. }
  11503. }
  11504. /// <summary>
  11505. /// 获取RPT080108画面(半检返修登记明细)的汇总信息查询sql
  11506. /// </summary>
  11507. /// <returns>sql</returns>
  11508. private static string GetRPT080108ISQL(SUserInfo user, SemiCheckEntity se, ref List<OracleParameter> parameters)
  11509. {
  11510. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  11511. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  11512. string sqlString = @"
  11513. SELECT
  11514. sr.SEMIREWORKID ,--AS SEMIREWORKID,
  11515. p.PROCEDURECODE ,--AS 完成工序编码,
  11516. p.PROCEDURENAME ,--AS 完成工序,
  11517. sr.PROCEDURETIME ,--AS 完成时间,
  11518. sr.USERCODE ,--完成工号,
  11519. gt2.GOODSTYPENAME AS GOODSTYPENAME2,--AS 产品二级类别,
  11520. gt.GOODSTYPENAME ,--AS 产品类别,
  11521. g.GOODSCODE ,--AS 产品编码,
  11522. g.GOODSNAME,--AS 产品名称,
  11523. sr.BARCODE ,--AS 产品条码,
  11524. sr.SEMIREWORKUSERCODE ,--AS 半检工号,
  11525. sr.SEMIREWORKTIME ,--AS 半检时间,
  11526. pr.PROCEDURECODE AS REWORKPCODE,--AS 返修工序编码,
  11527. pr.PROCEDURENAME AS REWORKPNAME,--AS 返修工序,
  11528. sr.BACKOUTFLAG ,--AS 撤销标识,
  11529. sr.BACKOUTUSERCODE ,--AS 撤销工号,
  11530. sr.BACKOUTTIME ,--AS 撤销时间,
  11531. sr.GROUTINGUSERCODE ,--AS 成型工号,
  11532. sr.GROUTINGLINECODE ,--AS 成型线编码,
  11533. sr.GROUTINGMOULDCODE ,--AS 模具编号,
  11534. sr.GROUTINGDATE ,--AS 注浆时间,
  11535. gd.DELIVERTIME ,--AS 交坯时间,
  11536. l.LOGONAME ,--AS 商标,
  11537. srd.DEFECTCODE ,--AS 缺陷编码,
  11538. srd.DEFECTNAME ,--AS 缺陷名称,
  11539. srd.DEFECTPOSITIONCODE ,--AS 位置编码,
  11540. srd.DEFECTPOSITIONNAME ,--AS 缺陷位置,
  11541. pd.PROCEDURECODE AS DEFECTPCODE,--AS 责任工序编码,
  11542. pd.PROCEDURENAME AS DEFECTPNAME,--AS 责任工序,
  11543. srd.DEFECTUSERCODE ,--AS 责任工号,
  11544. inpp.PROCEDURENAME CurrPROCEDURENAME --AS 当前工序
  11545. FROM
  11546. TP_PM_SEMIREWORK sr
  11547. LEFT JOIN TP_PM_SEMIREWORKDEFECT srd ON sr.SEMIREWORKID = srd.SEMIREWORKID
  11548. LEFT JOIN TP_PC_PROCEDURE p ON p.PROCEDUREID = sr.PROCEDUREID
  11549. LEFT JOIN TP_PC_PROCEDURE pr ON pr.PROCEDUREID = sr.REWORKPROCEDUREID
  11550. LEFT JOIN TP_PC_PROCEDURE pd ON pd.PROCEDUREID = srd.DEFECTPROCEDUREID
  11551. LEFT JOIN TP_MST_GOODS g ON sr.GOODSID = g.GOODSID
  11552. LEFT JOIN TP_MST_GOODSTYPE gt ON g.GOODSTYPEID = gt.GOODSTYPEID
  11553. LEFT JOIN TP_MST_GOODSTYPE gt2 ON gt2.ACCOUNTID = gt.ACCOUNTID
  11554. AND gt2.GOODSTYPECODE = substr( gt.GOODSTYPECODE, 1, 6 )
  11555. LEFT JOIN TP_PM_GROUTINGDAILYDETAIL gd ON gd.GROUTINGDAILYDETAILID = sr.GROUTINGDAILYDETAILID
  11556. LEFT JOIN TP_MST_LOGO l ON gd.LOGOID = l.LOGOID
  11557. LEFT JOIN TP_PM_INPRODUCTION inp ON inp.BARCODE = sr.BARCODE
  11558. LEFT JOIN TP_PC_PROCEDURE inpp ON inp.PROCEDUREID = inpp.PROCEDUREID
  11559. WHERE
  11560. sr.VALUEFLAG = '1'
  11561. AND srd.VALUEFLAG = '1'
  11562. AND sr.AccountID=:AccountID
  11563. ";
  11564. //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))
  11565. // 完成工序
  11566. if (!string.IsNullOrEmpty(se.CProcedureIDS))
  11567. {
  11568. sqlString = sqlString + " AND instr(','||:CProcedureIDS||',',','||p.PROCEDURECODE||',')>0 ";
  11569. parameters.Add(new OracleParameter(":CProcedureIDS", OracleDbType.NVarchar2, se.CProcedureIDS, ParameterDirection.Input));
  11570. }
  11571. // 完成时间起始
  11572. if (se.CDateTimeStart.HasValue)
  11573. {
  11574. sqlString = sqlString + " AND sr.ProcedureTime >= :CDateTimeStart ";
  11575. parameters.Add(new OracleParameter(":CDateTimeStart", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11576. }
  11577. // 完成时间结束
  11578. if (se.CDateTimeEnd.HasValue)
  11579. {
  11580. sqlString = sqlString + " AND sr.ProcedureTime <= :CDateTimeEnd ";
  11581. parameters.Add(new OracleParameter(":CDateTimeEnd", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11582. }
  11583. // 完成工号
  11584. if (!string.IsNullOrEmpty(se.CUserCode))
  11585. {
  11586. sqlString = sqlString + " AND instr(','||:UserCode||',' , ','||sr.UserCode||',')>0";
  11587. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CUserCode, ParameterDirection.Input));
  11588. }
  11589. // 产品类别
  11590. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  11591. {
  11592. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 ";
  11593. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  11594. }
  11595. // 产品编码
  11596. if (!string.IsNullOrEmpty(se.GoodsCode))
  11597. {
  11598. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0";
  11599. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  11600. }
  11601. // 成型工号
  11602. if (!string.IsNullOrEmpty(se.GroutingUserCode))
  11603. {
  11604. sqlString = sqlString + " AND instr(','||:GroutingUserCode||',' , ','||sr.GroutingUserCode||',')>0";
  11605. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.NVarchar2, se.GroutingUserCode, ParameterDirection.Input));
  11606. }
  11607. // 注浆时间起始
  11608. if (se.GroutingDateTimeStart.HasValue)
  11609. {
  11610. sqlString = sqlString + " AND sr.GroutingDate >= :GroutingDateTimeStart ";
  11611. parameters.Add(new OracleParameter(":GroutingDateTimeStart", OracleDbType.Date, se.GroutingDateTimeStart.Value, ParameterDirection.Input));
  11612. }
  11613. // 注浆时间结束
  11614. if (se.GroutingDateTimeEnd.HasValue)
  11615. {
  11616. sqlString = sqlString + " AND sr.GroutingDate <= :GroutingDateTimeEnd ";
  11617. parameters.Add(new OracleParameter(":GroutingDateTimeEnd", OracleDbType.Date, se.GroutingDateTimeEnd.Value, ParameterDirection.Input));
  11618. }
  11619. // 交坯时间起始
  11620. if (se.DeliveryDateTimeStart.HasValue)
  11621. {
  11622. sqlString = sqlString + " AND gd.DeliverTime >= :DeliveryDateTimeStart ";
  11623. parameters.Add(new OracleParameter(":DeliveryDateTimeStart", OracleDbType.Date, se.DeliveryDateTimeStart.Value, ParameterDirection.Input));
  11624. }
  11625. // 交坯时间结束
  11626. if (se.DeliveryDateTimeEnd.HasValue)
  11627. {
  11628. sqlString = sqlString + " AND gd.DeliverTime <= :DeliveryDateTimeEnd ";
  11629. parameters.Add(new OracleParameter(":DeliveryDateTimeEnd", OracleDbType.Date, se.DeliveryDateTimeEnd.Value, ParameterDirection.Input));
  11630. }
  11631. // 半检时间起始
  11632. if (se.SemiCheckDateTimeStart.HasValue)
  11633. {
  11634. sqlString = sqlString + " AND sr.SEMIREWORKTIME >= :SemiCheckDateTimeStart ";
  11635. parameters.Add(new OracleParameter(":SemiCheckDateTimeStart", OracleDbType.Date, se.SemiCheckDateTimeStart.Value, ParameterDirection.Input));
  11636. }
  11637. // 半检时间结束
  11638. if (se.SemiCheckDateTimeEnd.HasValue)
  11639. {
  11640. sqlString = sqlString + " AND sr.SEMIREWORKTIME <= :SemiCheckDateTimeEnd ";
  11641. parameters.Add(new OracleParameter(":SemiCheckDateTimeEnd", OracleDbType.Date, se.SemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  11642. }
  11643. // 半检工号
  11644. if (!string.IsNullOrEmpty(se.SemiCheckUserCode))
  11645. {
  11646. sqlString = sqlString + " AND instr(','||:SemiCheckUserCode||',' , ','||sr.SEMIREWORKUSERCODE||',')>0";
  11647. parameters.Add(new OracleParameter(":SemiCheckUserCode", OracleDbType.NVarchar2, se.SemiCheckUserCode, ParameterDirection.Input));
  11648. }
  11649. // 返修工序
  11650. if (!string.IsNullOrEmpty(se.RProcedureIDS))
  11651. {
  11652. sqlString = sqlString + " AND instr(','||:RProcedureIDS||',',','||pr.PROCEDUREID||',')>0 ";
  11653. parameters.Add(new OracleParameter(":RProcedureIDS", OracleDbType.NVarchar2, se.RProcedureIDS, ParameterDirection.Input));
  11654. }
  11655. // 返修工号
  11656. if (!string.IsNullOrEmpty(se.ReworkUserCode))
  11657. {
  11658. sqlString = sqlString + " AND instr(sr.ReworkUserCode,:ReworkUserCode)>0";
  11659. parameters.Add(new OracleParameter(":ReworkUserCode", OracleDbType.NVarchar2, se.ReworkUserCode, ParameterDirection.Input));
  11660. }
  11661. // 撤销标识
  11662. if (!string.IsNullOrEmpty(se.BackOutFlag))
  11663. {
  11664. sqlString = sqlString + " AND instr(','||:BackOutFlag||',',','||sr.BackOutFlag||',')>0 ";
  11665. parameters.Add(new OracleParameter(":BackOutFlag", OracleDbType.NVarchar2, se.BackOutFlag, ParameterDirection.Input));
  11666. }
  11667. // 撤销时间起始
  11668. if (se.BackOutTimeStart.HasValue)
  11669. {
  11670. sqlString = sqlString + " AND sr.BackOutTime >= :BackOutTimeStart ";
  11671. parameters.Add(new OracleParameter(":BackOutTimeStart", OracleDbType.Date, se.BackOutTimeStart.Value, ParameterDirection.Input));
  11672. }
  11673. // 撤销时间结束
  11674. if (se.BackOutTimeEnd.HasValue)
  11675. {
  11676. sqlString = sqlString + " AND sr.BackOutTime <= :BackOutTimeEnd ";
  11677. parameters.Add(new OracleParameter(":BackOutTimeEnd", OracleDbType.Date, se.BackOutTimeEnd.Value, ParameterDirection.Input));
  11678. }
  11679. // 撤销工号
  11680. if (!string.IsNullOrEmpty(se.BackOutUserCode))
  11681. {
  11682. sqlString = sqlString + " AND instr(','||:BackOutUserCode||',' , ','||sr.BackOutUserCode||',')>0";
  11683. parameters.Add(new OracleParameter(":BackOutUserCode", OracleDbType.NVarchar2, se.BackOutUserCode, ParameterDirection.Input));
  11684. }
  11685. // 产品条码
  11686. if (!string.IsNullOrEmpty(se.BarCode))
  11687. {
  11688. sqlString = sqlString + " AND instr(sr.BarCode,:BarCode)>0";
  11689. parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.BarCode, ParameterDirection.Input));
  11690. }
  11691. // 缺陷编码
  11692. if (!string.IsNullOrEmpty(se.DefectCode))
  11693. {
  11694. sqlString = sqlString + " AND instr(srd.DefectCode,:DefectCode)>0";
  11695. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  11696. }
  11697. // 缺陷位置集
  11698. if (!string.IsNullOrEmpty(se.DefectPositionIDS))
  11699. {
  11700. sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||srd.DefectPositionID||',')>0 ";
  11701. parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectPositionIDS, ParameterDirection.Input));
  11702. }
  11703. // 责任工序集
  11704. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  11705. {
  11706. sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||pd.PROCEDUREID||',')>0 ";
  11707. parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  11708. }
  11709. // 责任工号
  11710. if (!string.IsNullOrEmpty(se.DefectUser))
  11711. {
  11712. sqlString = sqlString + " AND instr(srd.DEFECTUSERCODE,:DefectUser)>0";
  11713. parameters.Add(new OracleParameter(":DefectUser", OracleDbType.NVarchar2, se.DefectUser, ParameterDirection.Input));
  11714. }
  11715. // 只显示最后一条半检记录
  11716. if (se.SemiCheckType == "1")
  11717. {
  11718. // 撤销的记录全显示,未撤销的记录只显示最后一条
  11719. sqlString += " and (sr.backoutflag = '1' or not exists (select sw.semireworkid\n" +
  11720. " from TP_PM_SEMIREWORK sw\n" +
  11721. " where sw.barcode = sr.barcode\n" +
  11722. " and sw.valueflag = '1'\n" +
  11723. " and (sw.backoutflag = '0')\n" +
  11724. " and sw.semireworkid > sr.semireworkid) )";
  11725. }
  11726. return sqlString;
  11727. }
  11728. //xuwei end
  11729. //xuwei add 2019-10-21
  11730. /// <summary>
  11731. /// 统计当前工号,当日,按产品编码分组统计半检返修数据数量
  11732. /// </summary>
  11733. /// <param name="user">用户</param>
  11734. /// <param name="dataStr">统计日期</param>
  11735. /// <returns></returns>
  11736. public static ServiceResultEntity GetSemiReworkDayCount(SUserInfo user, string dateStr)
  11737. {
  11738. IDBConnection conn = null;
  11739. try
  11740. {
  11741. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  11742. string sqlStr = $@"
  11743. SELECT
  11744. nvl(sr.SEMIREWORKUSERCODE,'--') SEMIREWORKUSERCODE,--AS 半检工号,
  11745. nvl( g.GOODSCODE, '合计' ) GOODSCODE,--AS 产品编码,
  11746. nvl(g.GOODSNAME,'--') GOODSNAME,--AS 产口名称,
  11747. to_char(count( sr.SEMIREWORKID )) GOODSCOUNT --AS 返修数量
  11748. FROM
  11749. TP_PM_SEMIREWORK sr
  11750. LEFT JOIN TP_PM_SEMIREWORKDEFECT srd ON sr.SEMIREWORKID = srd.SEMIREWORKID
  11751. LEFT JOIN TP_MST_GOODS g ON sr.GOODSID = g.GOODSID
  11752. WHERE
  11753. sr.VALUEFLAG = '1'
  11754. AND sr.ACCOUNTID = '{user.AccountID}'
  11755. AND sr.SEMIREWORKUSERCODE = '{user.UserCode}'
  11756. AND to_date(to_char(sr.CREATETIME,'yyyy-mm-dd'),'yyyy-mm-dd') = to_date('{dateStr}','yyyy-mm-dd')
  11757. GROUP BY
  11758. grouping sets ( ( sr.SEMIREWORKUSERCODE, g.GOODSCODE, g.GOODSNAME ), ( ) )
  11759. ";
  11760. DataTable data = conn.GetSqlResultToDt(sqlStr);
  11761. ServiceResultEntity sre = new ServiceResultEntity();
  11762. //if (data == null || data.Rows.Count == 0)
  11763. //{
  11764. // sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  11765. // return sre;
  11766. //}
  11767. sre.Data = new DataSet();
  11768. sre.Data.Tables.Add(data);
  11769. return sre;
  11770. }
  11771. catch (Exception ex)
  11772. {
  11773. throw ex;
  11774. }
  11775. finally
  11776. {
  11777. if (conn != null &&
  11778. conn.ConnState == ConnectionState.Open)
  11779. {
  11780. conn.Close();
  11781. }
  11782. }
  11783. }
  11784. //xuwei end
  11785. /// <summary>
  11786. /// 获取RPT030110画面(半检登记汇总表)的汇总信息查询sql
  11787. /// </summary>
  11788. /// <returns>sql</returns>
  11789. private static string GetRPT080107ISQL(SUserInfo user, SemiCheckEntity se, ref List<OracleParameter> parameters)
  11790. {
  11791. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  11792. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  11793. string sqlString = @"
  11794. select
  11795. SemiCheck.SemiCheckID,
  11796. CProcedure.ProcedureName as CProcedureName,
  11797. SemiCheck.ProcedureTime,
  11798. SemiCheck.UserCode,
  11799. GoodsType2.GoodsTypeName as LevelGoodsTypeName,
  11800. GoodsType.GoodsTypeName,
  11801. Goods.GoodsCode,
  11802. SemiCheck.BarCode,
  11803. -- 复检后不显示半检状态
  11804. SemiCheckType.SemiCheckTypeName,
  11805. --decode(SemiCheck.ReSemiCheckType, 0, SemiCheckType.SemiCheckTypeName, '已复检') SemiCheckTypeName,
  11806. SemiCheck.SemiCheckUserCode,
  11807. SemiCheck.SemiCheckTime,
  11808. ReSemiCheckType.ReSemiCheckTypeName,
  11809. SemiCheck.ReSemiCheckUserCode,
  11810. SemiCheck.ReSemiCheckTime,
  11811. decode(SemiCheck.BackOutFlag,'0','正常','撤销') as BackOutFlag,
  11812. SemiCheck.BackOutUserCode,
  11813. SemiCheck.BackOutTime,
  11814. SemiCheck.GroutingUserCode,
  11815. SemiCheck.GroutingLineCode,
  11816. SemiCheck.GroutingMouldCode,
  11817. SemiCheck.GroutingDate,
  11818. GroutingDailyDetail.DeliverTime,
  11819. logo.logoName,
  11820. RProcedure.ProcedureName as RProcedureName,
  11821. SemiCheck.ReworkUserCode,
  11822. SemiCheckDefect.DefectCode,
  11823. SemiCheckDefect.DefectName as DefectName1,
  11824. concat(SemiCheckDefect.DefectCode||'->',SemiCheckDefect.DefectName) as DefectName,
  11825. SemiCheckDefect.DefectPositionName,
  11826. SemiCheckDefect.DefectPositionCode,
  11827. concat(SemiCheckDefect.DefectPositionCode||'->',SemiCheckDefect.DefectPositionName) as DefectPositionName,
  11828. Procedure.ProcedureName,
  11829. inpp.ProcedureName CurrProcedureName,
  11830. DefectUser.username as DefectUser
  11831. from TP_PM_SemiCheck SemiCheck
  11832. left join TP_PC_Procedure CProcedure
  11833. on SemiCheck.ProcedureID=CProcedure.ProcedureID
  11834. left join TP_MST_Goods Goods
  11835. on SemiCheck.GoodsID=Goods.GoodsID
  11836. left join TP_MST_GoodsType GoodsType
  11837. on Goods.GoodsTypeID=GoodsType.GoodsTypeID
  11838. left join TP_MST_GoodsType GoodsType2
  11839. on GoodsType2.accountid=GoodsType.accountid
  11840. and GoodsType2.GoodsTypecode=substr(GoodsType.GoodsTypecode,1,6)
  11841. left join TP_SYS_SemiCheckType SemiCheckType
  11842. on SemiCheck.SemiCheckType=SemiCheckType.SemiCheckTypeID
  11843. left join TP_SYS_ReSemiCheckType ReSemiCheckType
  11844. on SemiCheck.ReSemiCheckType=ReSemiCheckType.ReSemiCheckTypeID
  11845. left join TP_PM_GroutingDailyDetail GroutingDailyDetail
  11846. on GroutingDailyDetail.GroutingDailyDetailID=SemiCheck.GroutingDailyDetailID
  11847. left join TP_MST_Logo logo
  11848. on GroutingDailyDetail.LogoID=logo.LogoID
  11849. left join TP_PC_Procedure RProcedure
  11850. on SemiCheck.ReworkProcedureID=RProcedure.ProcedureID
  11851. left join TP_PM_SemiCheckDefect SemiCheckDefect
  11852. on SemiCheck.SemiCheckID=SemiCheckDefect.SemiCheckID
  11853. and SemiCheckDefect.ValueFlag='1'
  11854. left join TP_PC_Procedure Procedure
  11855. on SemiCheckDefect.DefectProcedureID=Procedure.ProcedureID
  11856. left join TP_MST_User DefectUser
  11857. on DefectUser.userid=SemiCheckDefect.DefectUserID
  11858. left join tp_pm_inproduction inp on inp.barcode = SemiCheck.barcode
  11859. left join TP_PC_Procedure inpp on inp.ProcedureID = inpp.ProcedureID
  11860. where SemiCheck.AccountID=:AccountID
  11861. ";
  11862. //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))
  11863. // 完成工序
  11864. if (!string.IsNullOrEmpty(se.CProcedureIDS))
  11865. {
  11866. sqlString = sqlString + " AND instr(','||:CProcedureIDS||',',','||SemiCheck.ProcedureID||',')>0 ";
  11867. parameters.Add(new OracleParameter(":CProcedureIDS", OracleDbType.NVarchar2, se.CProcedureIDS, ParameterDirection.Input));
  11868. }
  11869. // 完成时间起始
  11870. if (se.CDateTimeStart.HasValue)
  11871. {
  11872. sqlString = sqlString + " AND SemiCheck.ProcedureTime >= :CDateTimeStart ";
  11873. parameters.Add(new OracleParameter(":CDateTimeStart", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11874. }
  11875. // 完成时间结束
  11876. if (se.CDateTimeEnd.HasValue)
  11877. {
  11878. sqlString = sqlString + " AND SemiCheck.ProcedureTime <= :CDateTimeEnd ";
  11879. parameters.Add(new OracleParameter(":CDateTimeEnd", OracleDbType.Date, se.CDateTimeStart.Value, ParameterDirection.Input));
  11880. }
  11881. // 完成工号
  11882. if (!string.IsNullOrEmpty(se.CUserCode))
  11883. {
  11884. sqlString = sqlString + " AND instr(SemiCheck.UserCode,:UserCode)>0";
  11885. parameters.Add(new OracleParameter(":UserCode", OracleDbType.NVarchar2, se.CUserCode, ParameterDirection.Input));
  11886. }
  11887. // 产品类别
  11888. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  11889. {
  11890. sqlString = sqlString + " AND instr(GoodsType.GoodsTypeCode,:GoodsTypeCode)=1 ";
  11891. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  11892. }
  11893. // 产品编码
  11894. if (!string.IsNullOrEmpty(se.GoodsCode))
  11895. {
  11896. sqlString = sqlString + " AND instr(Goods.GoodsCode,:GoodsCode)>0";
  11897. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  11898. }
  11899. // 成型工号
  11900. if (!string.IsNullOrEmpty(se.GroutingUserCode))
  11901. {
  11902. sqlString = sqlString + " AND instr(SemiCheck.GroutingUserCode,:GroutingUserCode)>0";
  11903. parameters.Add(new OracleParameter(":GroutingUserCode", OracleDbType.NVarchar2, se.GroutingUserCode, ParameterDirection.Input));
  11904. }
  11905. // 注浆时间起始
  11906. if (se.GroutingDateTimeStart.HasValue)
  11907. {
  11908. sqlString = sqlString + " AND SemiCheck.GroutingDate >= :GroutingDateTimeStart ";
  11909. parameters.Add(new OracleParameter(":GroutingDateTimeStart", OracleDbType.Date, se.GroutingDateTimeStart.Value, ParameterDirection.Input));
  11910. }
  11911. // 注浆时间结束
  11912. if (se.GroutingDateTimeEnd.HasValue)
  11913. {
  11914. sqlString = sqlString + " AND SemiCheck.GroutingDate <= :GroutingDateTimeEnd ";
  11915. parameters.Add(new OracleParameter(":GroutingDateTimeEnd", OracleDbType.Date, se.GroutingDateTimeEnd.Value, ParameterDirection.Input));
  11916. }
  11917. // 交坯时间起始
  11918. if (se.DeliveryDateTimeStart.HasValue)
  11919. {
  11920. sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime >= :DeliveryDateTimeStart ";
  11921. parameters.Add(new OracleParameter(":DeliveryDateTimeStart", OracleDbType.Date, se.DeliveryDateTimeStart.Value, ParameterDirection.Input));
  11922. }
  11923. // 交坯时间结束
  11924. if (se.DeliveryDateTimeEnd.HasValue)
  11925. {
  11926. sqlString = sqlString + " AND GroutingDailyDetail.DeliverTime <= :DeliveryDateTimeEnd ";
  11927. parameters.Add(new OracleParameter(":DeliveryDateTimeEnd", OracleDbType.Date, se.DeliveryDateTimeEnd.Value, ParameterDirection.Input));
  11928. }
  11929. // 半检状态
  11930. if (!string.IsNullOrEmpty(se.SemiCheckType))
  11931. {
  11932. sqlString = sqlString + " AND instr(','||:SemiCheckType||',',','||SemiCheck.SemiCheckType||',')>0 ";
  11933. parameters.Add(new OracleParameter(":SemiCheckType", OracleDbType.NVarchar2, se.SemiCheckType, ParameterDirection.Input));
  11934. }
  11935. // 半检时间起始
  11936. if (se.SemiCheckDateTimeStart.HasValue)
  11937. {
  11938. sqlString = sqlString + " AND SemiCheck.SemiCheckTime >= :SemiCheckDateTimeStart ";
  11939. parameters.Add(new OracleParameter(":SemiCheckDateTimeStart", OracleDbType.Date, se.SemiCheckDateTimeStart.Value, ParameterDirection.Input));
  11940. }
  11941. // 半检时间结束
  11942. if (se.SemiCheckDateTimeEnd.HasValue)
  11943. {
  11944. sqlString = sqlString + " AND SemiCheck.SemiCheckTime <= :SemiCheckDateTimeEnd ";
  11945. parameters.Add(new OracleParameter(":SemiCheckDateTimeEnd", OracleDbType.Date, se.SemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  11946. }
  11947. // 半检工号
  11948. if (!string.IsNullOrEmpty(se.SemiCheckUserCode))
  11949. {
  11950. sqlString = sqlString + " AND instr(SemiCheck.SemiCheckUserCode,:SemiCheckUserCode)>0";
  11951. parameters.Add(new OracleParameter(":SemiCheckUserCode", OracleDbType.NVarchar2, se.SemiCheckUserCode, ParameterDirection.Input));
  11952. }
  11953. // 返工工序
  11954. if (!string.IsNullOrEmpty(se.RProcedureIDS))
  11955. {
  11956. sqlString = sqlString + " AND instr(','||:RProcedureIDS||',',','||SemiCheck.ReworkProcedureID||',')>0 ";
  11957. parameters.Add(new OracleParameter(":RProcedureIDS", OracleDbType.NVarchar2, se.RProcedureIDS, ParameterDirection.Input));
  11958. }
  11959. // 返工工号
  11960. if (!string.IsNullOrEmpty(se.ReworkUserCode))
  11961. {
  11962. sqlString = sqlString + " AND instr(SemiCheck.ReworkUserCode,:ReworkUserCode)>0";
  11963. parameters.Add(new OracleParameter(":ReworkUserCode", OracleDbType.NVarchar2, se.ReworkUserCode, ParameterDirection.Input));
  11964. }
  11965. // 复检状态
  11966. if (!string.IsNullOrEmpty(se.ReSemiCheckType))
  11967. {
  11968. sqlString = sqlString + " AND instr(','||:ReSemiCheckType||',',','||SemiCheck.ReSemiCheckType||',')>0 ";
  11969. parameters.Add(new OracleParameter(":ReSemiCheckType", OracleDbType.NVarchar2, se.ReSemiCheckType, ParameterDirection.Input));
  11970. }
  11971. // 复检时间起始
  11972. if (se.ReSemiCheckDateTimeStart.HasValue)
  11973. {
  11974. sqlString = sqlString + " AND SemiCheck.ReSemiCheckTime >= :ReSemiCheckDateTimeStart ";
  11975. parameters.Add(new OracleParameter(":ReSemiCheckDateTimeStart", OracleDbType.Date, se.ReSemiCheckDateTimeStart.Value, ParameterDirection.Input));
  11976. }
  11977. // 复检时间结束
  11978. if (se.ReSemiCheckDateTimeEnd.HasValue)
  11979. {
  11980. sqlString = sqlString + " AND SemiCheck.ReSemiCheckTime <= :ReSemiCheckDateTimeEnd ";
  11981. parameters.Add(new OracleParameter(":ReSemiCheckDateTimeEnd", OracleDbType.Date, se.ReSemiCheckDateTimeEnd.Value, ParameterDirection.Input));
  11982. }
  11983. // 复检工号
  11984. if (!string.IsNullOrEmpty(se.ReSemiCheckUserCode))
  11985. {
  11986. sqlString = sqlString + " AND instr(SemiCheck.ReSemiCheckUserCode,:ReSemiCheckUserCode)>0";
  11987. parameters.Add(new OracleParameter(":ReSemiCheckUserCode", OracleDbType.NVarchar2, se.ReSemiCheckUserCode, ParameterDirection.Input));
  11988. }
  11989. // 撤销标识
  11990. if (!string.IsNullOrEmpty(se.BackOutFlag))
  11991. {
  11992. sqlString = sqlString + " AND instr(','||:BackOutFlag||',',','||SemiCheck.BackOutFlag||',')>0 ";
  11993. parameters.Add(new OracleParameter(":BackOutFlag", OracleDbType.NVarchar2, se.BackOutFlag, ParameterDirection.Input));
  11994. }
  11995. // 撤销时间起始
  11996. if (se.BackOutTimeStart.HasValue)
  11997. {
  11998. sqlString = sqlString + " AND SemiCheck.BackOutTime >= :BackOutTimeStart ";
  11999. parameters.Add(new OracleParameter(":BackOutTimeStart", OracleDbType.Date, se.BackOutTimeStart.Value, ParameterDirection.Input));
  12000. }
  12001. // 撤销时间结束
  12002. if (se.BackOutTimeEnd.HasValue)
  12003. {
  12004. sqlString = sqlString + " AND SemiCheck.BackOutTime <= :BackOutTimeEnd ";
  12005. parameters.Add(new OracleParameter(":BackOutTimeEnd", OracleDbType.Date, se.BackOutTimeEnd.Value, ParameterDirection.Input));
  12006. }
  12007. // 撤销工号
  12008. if (!string.IsNullOrEmpty(se.BackOutUserCode))
  12009. {
  12010. sqlString = sqlString + " AND instr(SemiCheck.BackOutUserCode,:BackOutUserCode)>0";
  12011. parameters.Add(new OracleParameter(":BackOutUserCode", OracleDbType.NVarchar2, se.BackOutUserCode, ParameterDirection.Input));
  12012. }
  12013. // 产品条码
  12014. if (!string.IsNullOrEmpty(se.BarCode))
  12015. {
  12016. sqlString = sqlString + " AND instr(SemiCheck.BarCode,:BarCode)>0";
  12017. parameters.Add(new OracleParameter(":BarCode", OracleDbType.NVarchar2, se.BarCode, ParameterDirection.Input));
  12018. }
  12019. // 缺陷编码
  12020. if (!string.IsNullOrEmpty(se.DefectCode))
  12021. {
  12022. sqlString = sqlString + " AND instr(SemiCheckDefect.DefectCode,:DefectCode)>0";
  12023. parameters.Add(new OracleParameter(":DefectCode", OracleDbType.NVarchar2, se.DefectCode, ParameterDirection.Input));
  12024. }
  12025. // 缺陷位置集
  12026. if (!string.IsNullOrEmpty(se.DefectPositionIDS))
  12027. {
  12028. sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||SemiCheckDefect.DefectPositionID||',')>0 ";
  12029. parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectPositionIDS, ParameterDirection.Input));
  12030. }
  12031. // 责任工序集
  12032. if (!string.IsNullOrEmpty(se.DefectProcedureIDS))
  12033. {
  12034. sqlString = sqlString + " AND instr(','||:DefectPositionIDS||',',','||SemiCheckDefect.DefectPositionID||',')>0 ";
  12035. parameters.Add(new OracleParameter(":DefectPositionIDS", OracleDbType.NVarchar2, se.DefectProcedureIDS, ParameterDirection.Input));
  12036. }
  12037. // 责任工号
  12038. if (!string.IsNullOrEmpty(se.DefectUser))
  12039. {
  12040. sqlString = sqlString + " AND instr(DefectUser.UserCode,:DefectUser)>0";
  12041. parameters.Add(new OracleParameter(":DefectUser", OracleDbType.NVarchar2, se.DefectUser, ParameterDirection.Input));
  12042. }
  12043. return sqlString;
  12044. }
  12045. /// <summary>
  12046. /// 取得F_RPT_030112画面(产成品交接汇总表)的汇总信息查询数据
  12047. /// </summary>
  12048. /// <param name="user">登录用户信息</param>
  12049. /// <param name="se">查询条件</param>
  12050. /// <returns>查询结果</returns>
  12051. public static ServiceResultEntity GetRPT0030112SData(SUserInfo user, SearchFinishedProductEntity se)
  12052. {
  12053. IDBConnection conn = null;
  12054. try
  12055. {
  12056. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12057. List<OracleParameter> parameters = new List<OracleParameter>();
  12058. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT030112SSQL(user, se, ref parameters));
  12059. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  12060. ServiceResultEntity sre = new ServiceResultEntity();
  12061. if (data == null || data.Rows.Count == 0)
  12062. {
  12063. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12064. return sre;
  12065. }
  12066. sre.Data = new DataSet();
  12067. sre.Data.Tables.Add(data);
  12068. return sre;
  12069. }
  12070. catch (Exception ex)
  12071. {
  12072. throw ex;
  12073. }
  12074. finally
  12075. {
  12076. if (conn != null &&
  12077. conn.ConnState == ConnectionState.Open)
  12078. {
  12079. conn.Close();
  12080. }
  12081. }
  12082. }
  12083. /// <summary>
  12084. /// 获取RPT030112画面(产成品交接汇总表)的汇总信息查询sql
  12085. /// </summary>
  12086. /// <returns>sql</returns>
  12087. private static string GetRPT030112SSQL(SUserInfo user, SearchFinishedProductEntity se, ref List<OracleParameter> parameters)
  12088. {
  12089. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12090. //parameters.Add(new OracleParameter(":UserID", OracleDbType.Int32, user.UserID, ParameterDirection.Input));
  12091. string sqlString = @"SELECT ts.gid
  12092. ,logoid
  12093. ,decode(ts.gid,
  12094. '23',
  12095. '总计【' || orderno || '】',
  12096. decode(ts.gid, '1', '--', '3', '--', orderno)) AS orderno
  12097. ,decode(ts.gid,
  12098. '3',
  12099. '合计【' || logoname || '】',
  12100. decode(ts.gid, '1', '--', logoname)) AS logoname
  12101. ,decode(ts.gid, '1', '小计【' || goodscode || '】', goodscode) AS goodscode
  12102. ,decode(ts.gid, '1', '--', goodsmodel) AS goodsmodel
  12103. ,GoodsSpecification
  12104. ,fhtime
  12105. ,COUNT
  12106. FROM (SELECT grouping_id(l.logoid,
  12107. o.orderno,
  12108. l.logoname,
  12109. g.goodscode,
  12110. to_char(f.fhtime, 'yyyy-mm-dd')) AS gid
  12111. ,decode(GROUPING(l.logoid), 1, '--', l.logoid) AS logoid
  12112. ,decode(GROUPING(o.orderno), 1, '--', o.orderno) AS orderno
  12113. ,decode(GROUPING(l.logoname), 1, '--', l.logoname) AS logoname
  12114. ,decode(GROUPING(g.goodscode), 1, '--', g.goodscode) AS goodscode
  12115. ,decode(GROUPING(g.goodscode), 1, '--', g.goodsmodel) AS goodsmodel
  12116. ,decode(GROUPING(g.GoodsSpecification), 1, '--', g.GoodsSpecification) AS GoodsSpecification
  12117. ,decode(GROUPING(to_char(f.fhtime, 'yyyy-mm-dd')),
  12118. 1,
  12119. '--',
  12120. to_char(f.fhtime, 'yyyy-mm-dd')) AS fhtime
  12121. ,COUNT(f.fhtime) AS COUNT
  12122. FROM tp_pm_finishedproduct F
  12123. LEFT JOIN TP_PM_Order O ON F.Fhorderid = O.Orderid
  12124. LEFT JOIN tp_mst_logo L ON F.LOGOID = L.LOGOID
  12125. LEFT JOIN tp_mst_goods G ON g.goodsid = f.goodsid
  12126. LEFT JOIN TP_MST_GoodsType gt ON g.GoodsTypeID = gt.GoodsTypeID
  12127. where f.fhtime is not null and f.AccountID=:AccountID ";
  12128. // 交接时间起始
  12129. if (se.FHTimeStart.HasValue)
  12130. {
  12131. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart ";
  12132. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, se.FHTimeStart.Value, ParameterDirection.Input));
  12133. }
  12134. // 交接时间结束
  12135. if (se.FHTimeEnd.HasValue)
  12136. {
  12137. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd ";
  12138. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, se.FHTimeEnd.Value, ParameterDirection.Input));
  12139. }
  12140. // 订单号
  12141. if (!string.IsNullOrEmpty(se.OrderNo))
  12142. {
  12143. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0";
  12144. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, se.OrderNo, ParameterDirection.Input));
  12145. }
  12146. // 产品类别编码
  12147. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  12148. {
  12149. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1";
  12150. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  12151. }
  12152. // 产品编码
  12153. if (!string.IsNullOrEmpty(se.GoodsCode))
  12154. {
  12155. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0";
  12156. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  12157. }
  12158. // 产品型号
  12159. if (!string.IsNullOrEmpty(se.GoodsModel))
  12160. {
  12161. sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0";
  12162. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, se.GoodsModel, ParameterDirection.Input));
  12163. }
  12164. // 产品商标ID集
  12165. if (!string.IsNullOrEmpty(se.LogoIDS))
  12166. {
  12167. sqlString += " AND instr(','||:LogoIDS||',', ',' || L.logoid || ',') > 0";
  12168. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, se.LogoIDS, ParameterDirection.Input));
  12169. }
  12170. // 交接工号
  12171. if (!string.IsNullOrEmpty(se.FHUserCode))
  12172. {
  12173. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0";
  12174. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, se.FHUserCode, ParameterDirection.Input));
  12175. }
  12176. sqlString = sqlString + @" GROUP BY rollup(o.orderno,l.logoid, l.logoname,g.goodscode,g.goodsmodel,g.GoodsSpecification,to_char(f.fhtime, 'yyyy-mm-dd'))
  12177. order by o.orderno,l.logoid, l.logoname,g.goodscode,to_char(f.fhtime, 'yyyy-mm-dd')
  12178. )ts
  12179. where ( logoid!='--' and orderno!='--' and logoname!='--' and goodscode!='--' and fhtime!='--')
  12180. or (goodscode!='--')
  12181. or(logoname!='')
  12182. or (orderno!='--') and ts.gid!='7'";
  12183. return sqlString;
  12184. }
  12185. /// <summary>
  12186. /// 取得F_RPT_030112画面(产成品交接汇总表)的汇总信息
  12187. /// </summary>
  12188. /// <param name="user">登录用户信息</param>
  12189. /// <param name="se">查询条件</param>
  12190. /// <returns>查询结果</returns>
  12191. public static ServiceResultEntity GetRPT0030112SumData(ClientRequestEntity cre, SUserInfo user)
  12192. {
  12193. IDBConnection conn = null;
  12194. try
  12195. {
  12196. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12197. List<OracleParameter> parameters = new List<OracleParameter>();
  12198. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12199. //string sqlString = "SELECT trunc(f.fhtime) fhtime, g.goodscode, COUNT(*) goodscount\n" +
  12200. string sqlString = "SELECT nvl2(o.orderno,\n" +
  12201. " nvl2(l.logoname,\n" +
  12202. " o.orderno,\n" +
  12203. " to_char('合计[') || o.orderno ||\n" +
  12204. " to_char(']')),\n" +
  12205. " '总计') orderno\n" +
  12206. " ,nvl2(l.logoname,\n" +
  12207. " nvl2(g.goodscode,\n" +
  12208. " l.logoname,\n" +
  12209. " to_char('小计[' || l.logoname || ']')),\n" +
  12210. " '--') logoname\n" +
  12211. " ,nvl(g.goodscode, '--') goodscode" +
  12212. " ,nvl(g.goodsmodel, '--') goodsmodel" +
  12213. " ,nvl(gdd.materialcode, '--') mcode" +
  12214. " ,f.logoid" +
  12215. " ,f.goodsid" +
  12216. " ,f.fhorderid" +
  12217. " ,COUNT(*) count" +
  12218. " FROM tp_pm_finishedproduct f\n" +
  12219. " inner JOIN tp_pm_groutingdailydetail gdd\n" +
  12220. " ON gdd.barcode = f.barcode\n" +
  12221. " LEFT JOIN tp_mst_logo l\n" +
  12222. " ON f.logoid = l.logoid\n" +
  12223. " LEFT JOIN TP_PM_Order O\n" +
  12224. " ON f.Fhorderid = O.Orderid\n" +
  12225. " LEFT JOIN tp_mst_goods G\n" +
  12226. " ON g.goodsid = f.goodsid\n" +
  12227. " LEFT JOIN TP_MST_GoodsType gt\n" +
  12228. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  12229. " WHERE f.fhtime IS NOT NULL\n" +
  12230. " AND f.AccountID = :AccountID\n";
  12231. // 交接时间起始
  12232. if (cre.Properties["FHTimeStart"] != null)
  12233. {
  12234. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
  12235. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, cre.Properties["FHTimeStart"], ParameterDirection.Input));
  12236. }
  12237. // 交接时间结束
  12238. if (cre.Properties["FHTimeEnd"] != null)
  12239. {
  12240. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd \n";
  12241. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, cre.Properties["FHTimeEnd"], ParameterDirection.Input));
  12242. }
  12243. // 订单号
  12244. if (!string.IsNullOrEmpty(cre.Properties["OrderNo"] as string))
  12245. {
  12246. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0 \n";
  12247. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, cre.Properties["OrderNo"], ParameterDirection.Input));
  12248. }
  12249. // 产品类别编码
  12250. if (!string.IsNullOrEmpty(cre.Properties["GoodsTypeCode"] as string))
  12251. {
  12252. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 \n";
  12253. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input));
  12254. }
  12255. // 产品编码
  12256. if (!string.IsNullOrEmpty(cre.Properties["GoodsCode"] as string))
  12257. {
  12258. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
  12259. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input));
  12260. }
  12261. // 产品型号
  12262. if (!string.IsNullOrEmpty(cre.Properties["GoodsModel"] as string))
  12263. {
  12264. sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0 \n";
  12265. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, cre.Properties["GoodsModel"], ParameterDirection.Input));
  12266. }
  12267. // 产品商标ID集
  12268. if (!string.IsNullOrEmpty(cre.Properties["LogoIDS"] as string))
  12269. {
  12270. sqlString += " AND instr(','||:LogoIDS||',', ',' || f.logoid || ',') > 0 \n";
  12271. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, cre.Properties["LogoIDS"], ParameterDirection.Input));
  12272. }
  12273. // 交接工号
  12274. if (!string.IsNullOrEmpty(cre.Properties["FHUserCode"] as string))
  12275. {
  12276. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0 \n";
  12277. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, cre.Properties["FHUserCode"], ParameterDirection.Input));
  12278. }
  12279. //sqlString += " group by trunc(f.fhtime), g.goodscode order by trunc(f.fhtime), g.goodscode";
  12280. 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),())";
  12281. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  12282. ServiceResultEntity sre = new ServiceResultEntity();
  12283. if (data == null || data.Rows.Count == 0)
  12284. {
  12285. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12286. return sre;
  12287. }
  12288. sre.Data = new DataSet();
  12289. sre.Data.Tables.Add(data);
  12290. return sre;
  12291. }
  12292. catch (Exception ex)
  12293. {
  12294. throw ex;
  12295. }
  12296. finally
  12297. {
  12298. if (conn != null &&
  12299. conn.ConnState == ConnectionState.Open)
  12300. {
  12301. conn.Close();
  12302. }
  12303. }
  12304. }
  12305. /// <summary>
  12306. /// 取得F_RPT_030112画面(产成品交接汇总表)的明细信息查询数据
  12307. /// </summary>
  12308. /// <param name="user">登录用户信息</param>
  12309. /// <param name="se">查询条件</param>
  12310. /// <returns>查询结果</returns>
  12311. public static ServiceResultEntity GetRPT0030112DetailSData(SUserInfo user, SearchFinishedProductEntity se)
  12312. {
  12313. IDBConnection conn = null;
  12314. try
  12315. {
  12316. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12317. List<OracleParameter> parameters = new List<OracleParameter>();
  12318. StringBuilder sql = new StringBuilder(ReportModuleLogic.GetRPT0030112DetailSData(user, se, ref parameters));
  12319. DataTable data = conn.GetSqlResultToDt(sql.ToString(), parameters.ToArray());
  12320. ServiceResultEntity sre = new ServiceResultEntity();
  12321. if (data == null || data.Rows.Count == 0)
  12322. {
  12323. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12324. return sre;
  12325. }
  12326. sre.Data = new DataSet();
  12327. sre.Data.Tables.Add(data);
  12328. return sre;
  12329. }
  12330. catch (Exception ex)
  12331. {
  12332. throw ex;
  12333. }
  12334. finally
  12335. {
  12336. if (conn != null &&
  12337. conn.ConnState == ConnectionState.Open)
  12338. {
  12339. conn.Close();
  12340. }
  12341. }
  12342. }
  12343. private static string GetRPT0030112DetailSData(SUserInfo user, SearchFinishedProductEntity se, ref List<OracleParameter> parameters)
  12344. {
  12345. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12346. string sqlString = "SELECT O.ORDERNO,\n" +
  12347. " F.FHTIME,\n" +
  12348. " F.FHUSERCODE,\n" +
  12349. " F.BARCODE,\n" +
  12350. " F.GOODSCODE,\n" +
  12351. " L.LOGONAME,\n" +
  12352. " F.GROUTINGUSERCODE,\n" +
  12353. " F.GROUTINGLINECODE,\n" +
  12354. " F.GROUTINGMOULDCODE,\n" +
  12355. " F.GROUTINGDATE,\n" +
  12356. " G.DELIVERTIME,\n" +
  12357. " GOODS.goodsmodel,\n" +
  12358. //" (GOODS.MATERIALCODE || L.TAGCODE || G.ONLYCODE) AS FINISHEDBARCODE,\n" +
  12359. //" 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" +
  12360. " G.outlabelcode AS FINISHEDBARCODE,\n" +
  12361. " G.MATERIALCODE AS mcode,\n" +
  12362. " F.CREATETIME AS PRODUCTFINISHEDTIME\n" +
  12363. " FROM TP_PM_FINISHEDPRODUCT F\n" +
  12364. " LEFT JOIN TP_PM_ORDER O\n" +
  12365. " ON F.FHORDERID = O.ORDERID\n" +
  12366. " LEFT JOIN TP_MST_LOGO L\n" +
  12367. " ON F.LOGOID = L.LOGOID\n" +
  12368. " LEFT JOIN TP_PM_GROUTINGDAILYDETAIL G\n" +
  12369. " ON F.GROUTINGDAILYDETAILID = G.GROUTINGDAILYDETAILID\n" +
  12370. " LEFT JOIN TP_MST_GOODS GOODS\n" +
  12371. " ON F.GOODSID = GOODS.GOODSID\n" +
  12372. " LEFT JOIN TP_MST_GOODSTYPE GOODSTYPE\n" +
  12373. " ON GOODS.GOODSTYPEID = GOODSTYPE.GOODSTYPEID\n" +
  12374. " WHERE F.ACCOUNTID = :ACCOUNTID\n" +
  12375. " AND F.FHTIME IS NOT NULL";
  12376. // 交接时间起始
  12377. if (se.FHTimeStart.HasValue)
  12378. {
  12379. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart ";
  12380. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, se.FHTimeStart.Value, ParameterDirection.Input));
  12381. }
  12382. // 交接时间结束
  12383. if (se.FHTimeEnd.HasValue)
  12384. {
  12385. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd ";
  12386. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, se.FHTimeEnd.Value, ParameterDirection.Input));
  12387. }
  12388. // 订单号
  12389. if (!string.IsNullOrEmpty(se.OrderNo))
  12390. {
  12391. //sqlString = sqlString + " AND O.OrderNo=:OrderNo";
  12392. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0";
  12393. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, se.OrderNo, ParameterDirection.Input));
  12394. }
  12395. // 产品类别编码
  12396. if (!string.IsNullOrEmpty(se.GoodsTypeCode))
  12397. {
  12398. sqlString = sqlString + " AND instr(GoodsType.GoodsTypeCode,:GoodsTypeCode)=1";
  12399. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, se.GoodsTypeCode, ParameterDirection.Input));
  12400. }
  12401. // 产品编码
  12402. if (!string.IsNullOrEmpty(se.GoodsCode))
  12403. {
  12404. sqlString = sqlString + " AND instr(Goods.GoodsCode,:GoodsCode)>0";
  12405. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, se.GoodsCode, ParameterDirection.Input));
  12406. }
  12407. // 产品型号
  12408. if (!string.IsNullOrEmpty(se.GoodsModel))
  12409. {
  12410. sqlString = sqlString + " AND instr(Goods.GoodsModel,:GoodsModel)>0";
  12411. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, se.GoodsModel, ParameterDirection.Input));
  12412. }
  12413. // 产品商标ID集
  12414. if (!string.IsNullOrEmpty(se.LogoIDS))
  12415. {
  12416. sqlString += " AND instr(','||:LogoIDS||',', ',' || L.logoid || ',') > 0";
  12417. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, se.LogoIDS, ParameterDirection.Input));
  12418. }
  12419. // 交接工号
  12420. if (!string.IsNullOrEmpty(se.FHUserCode))
  12421. {
  12422. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0";
  12423. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, se.FHUserCode, ParameterDirection.Input));
  12424. }
  12425. if (se.OrderID != null)
  12426. {
  12427. sqlString = sqlString + " AND F.fhorderid = :fhorderid";
  12428. parameters.Add(new OracleParameter(":fhorderid", OracleDbType.Int32, se.OrderID, ParameterDirection.Input));
  12429. }
  12430. if (se.GoodsID != null)
  12431. {
  12432. sqlString = sqlString + " AND F.GoodsID = :GoodsID";
  12433. parameters.Add(new OracleParameter(":GoodsID", OracleDbType.Int32, se.GoodsID, ParameterDirection.Input));
  12434. }
  12435. if (se.LogoID != null)
  12436. {
  12437. sqlString = sqlString + " AND F.LogoID = :LogoID";
  12438. parameters.Add(new OracleParameter(":LogoID", OracleDbType.Int32, se.LogoID, ParameterDirection.Input));
  12439. }
  12440. return sqlString;
  12441. }
  12442. /// <summary>
  12443. /// 取得F_RPT_030112画面(产成品交接汇总表)的交接数量
  12444. /// </summary>
  12445. /// <param name="user">登录用户信息</param>
  12446. /// <param name="se">查询条件</param>
  12447. /// <returns>查询结果</returns>
  12448. public static ServiceResultEntity GetRPT0030112NData(ClientRequestEntity cre, SUserInfo user)
  12449. {
  12450. IDBConnection conn = null;
  12451. try
  12452. {
  12453. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12454. List<OracleParameter> parameters = new List<OracleParameter>();
  12455. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12456. //string sqlString = "SELECT trunc(f.fhtime) fhtime, g.goodscode, COUNT(*) goodscount\n" +
  12457. string sqlString = "SELECT nvl2(trunc(f.fhtime),\n" +
  12458. " nvl2(l.logoname,\n" +
  12459. " to_char(trunc(f.fhtime), 'yyyy-mm-dd'),\n" +
  12460. " to_char('合计[') || to_char(trunc(f.fhtime), 'yyyy-mm-dd') ||\n" +
  12461. " to_char(']')),\n" +
  12462. " '总计') fhtime\n" +
  12463. " ,nvl2(l.logoname,\n" +
  12464. " nvl2(g.goodscode,\n" +
  12465. " l.logoname,\n" +
  12466. " to_char('小计[' || l.logoname || ']')),\n" +
  12467. " '--') logoname\n" +
  12468. " ,nvl(g.goodscode, '--') goodscode" +
  12469. " ,nvl(g.goodsmodel, '--') goodsmodel" +
  12470. " ,nvl(gdd.materialcode, '--') mcode" +
  12471. " ,COUNT(*) goodscount" +
  12472. " FROM tp_pm_finishedproduct f\n" +
  12473. " inner JOIN tp_pm_groutingdailydetail gdd\n" +
  12474. " ON gdd.barcode = f.barcode\n" +
  12475. " LEFT JOIN tp_mst_logo l\n" +
  12476. " ON f.logoid = l.logoid\n" +
  12477. " LEFT JOIN TP_PM_Order O\n" +
  12478. " ON f.Fhorderid = O.Orderid\n" +
  12479. " LEFT JOIN tp_mst_goods G\n" +
  12480. " ON g.goodsid = f.goodsid\n" +
  12481. " LEFT JOIN TP_MST_GoodsType gt\n" +
  12482. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  12483. " WHERE f.fhtime IS NOT NULL\n" +
  12484. " AND f.AccountID = :AccountID\n";
  12485. // 交接时间起始
  12486. if (cre.Properties["FHTimeStart"] != null)
  12487. {
  12488. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
  12489. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, cre.Properties["FHTimeStart"], ParameterDirection.Input));
  12490. }
  12491. // 交接时间结束
  12492. if (cre.Properties["FHTimeEnd"] != null)
  12493. {
  12494. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd \n";
  12495. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, cre.Properties["FHTimeEnd"], ParameterDirection.Input));
  12496. }
  12497. // 订单号
  12498. if (!string.IsNullOrEmpty(cre.Properties["OrderNo"] as string))
  12499. {
  12500. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0 \n";
  12501. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, cre.Properties["OrderNo"], ParameterDirection.Input));
  12502. }
  12503. // 产品类别编码
  12504. if (!string.IsNullOrEmpty(cre.Properties["GoodsTypeCode"] as string))
  12505. {
  12506. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 \n";
  12507. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input));
  12508. }
  12509. // 产品编码
  12510. if (!string.IsNullOrEmpty(cre.Properties["GoodsCode"] as string))
  12511. {
  12512. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
  12513. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input));
  12514. }
  12515. // 产品型号
  12516. if (!string.IsNullOrEmpty(cre.Properties["GoodsModel"] as string))
  12517. {
  12518. sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0 \n";
  12519. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, cre.Properties["GoodsModel"], ParameterDirection.Input));
  12520. }
  12521. // 产品商标ID集
  12522. if (!string.IsNullOrEmpty(cre.Properties["LogoIDS"] as string))
  12523. {
  12524. sqlString += " AND instr(','||:LogoIDS||',', ',' || f.logoid || ',') > 0 \n";
  12525. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, cre.Properties["LogoIDS"], ParameterDirection.Input));
  12526. }
  12527. // 交接工号
  12528. if (!string.IsNullOrEmpty(cre.Properties["FHUserCode"] as string))
  12529. {
  12530. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0 \n";
  12531. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, cre.Properties["FHUserCode"], ParameterDirection.Input));
  12532. }
  12533. //sqlString += " group by trunc(f.fhtime), g.goodscode order by trunc(f.fhtime), g.goodscode";
  12534. sqlString += " GROUP BY GROUPING SETS((trunc(f.fhtime), l.logoname, g.goodscode,g.goodsmodel,gdd.materialcode),(trunc(f.fhtime), l.logoname),(trunc(f.fhtime)),())";
  12535. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  12536. ServiceResultEntity sre = new ServiceResultEntity();
  12537. if (data == null || data.Rows.Count == 0)
  12538. {
  12539. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12540. return sre;
  12541. }
  12542. sre.Data = new DataSet();
  12543. sre.Data.Tables.Add(data);
  12544. return sre;
  12545. }
  12546. catch (Exception ex)
  12547. {
  12548. throw ex;
  12549. }
  12550. finally
  12551. {
  12552. if (conn != null &&
  12553. conn.ConnState == ConnectionState.Open)
  12554. {
  12555. conn.Close();
  12556. }
  12557. }
  12558. }
  12559. /// <summary>
  12560. /// 取得F_RPT_030112画面(产成品交接汇总表)的型号数量
  12561. /// </summary>
  12562. /// <param name="user">登录用户信息</param>
  12563. /// <param name="se">查询条件</param>
  12564. /// <returns>查询结果</returns>
  12565. public static ServiceResultEntity GetRPT0030112GNData(ClientRequestEntity cre, SUserInfo user)
  12566. {
  12567. IDBConnection conn = null;
  12568. try
  12569. {
  12570. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12571. List<OracleParameter> parameters = new List<OracleParameter>();
  12572. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12573. //string sqlString = "SELECT trunc(f.fhtime) fhtime, g.goodscode, COUNT(*) goodscount\n" +
  12574. string sqlString = "SELECT --nvl2(trunc(f.fhtime),\n" +
  12575. //" nvl2(l.logoname,\n" +
  12576. //" to_char(trunc(f.fhtime), 'yyyy-mm-dd'),\n" +
  12577. //" to_char('合计[') || to_char(trunc(f.fhtime), 'yyyy-mm-dd') ||\n" +
  12578. //" to_char(']')),\n" +
  12579. //" '总计') fhtime\n" +
  12580. //" ,nvl2(l.logoname,\n" +
  12581. //" nvl2(g.goodscode,\n" +
  12582. //" l.logoname,\n" +
  12583. //" to_char('小计[' || l.logoname || ']')),\n" +
  12584. //" '--') logoname\n" +
  12585. " nvl(g.goodscode, '合计') goodscode" +
  12586. " ,nvl(g.goodsmodel, '--') goodsmodel" +
  12587. " ,nvl(gdd.materialcode, '--') mcode" +
  12588. " ,COUNT(*) goodscount" +
  12589. " FROM tp_pm_finishedproduct f\n" +
  12590. " inner JOIN tp_pm_groutingdailydetail gdd\n" +
  12591. " ON gdd.barcode = f.barcode\n" +
  12592. " LEFT JOIN tp_mst_logo l\n" +
  12593. " ON f.logoid = l.logoid\n" +
  12594. " LEFT JOIN TP_PM_Order O\n" +
  12595. " ON f.Fhorderid = O.Orderid\n" +
  12596. " LEFT JOIN tp_mst_goods G\n" +
  12597. " ON g.goodsid = f.goodsid\n" +
  12598. " LEFT JOIN TP_MST_GoodsType gt\n" +
  12599. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  12600. " WHERE f.fhtime IS NOT NULL\n" +
  12601. " AND f.AccountID = :AccountID\n";
  12602. // 交接时间起始
  12603. if (cre.Properties["FHTimeStart"] != null)
  12604. {
  12605. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
  12606. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, cre.Properties["FHTimeStart"], ParameterDirection.Input));
  12607. }
  12608. // 交接时间结束
  12609. if (cre.Properties["FHTimeEnd"] != null)
  12610. {
  12611. sqlString = sqlString + " AND F.FHTime <= :FHTimeEnd \n";
  12612. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, cre.Properties["FHTimeEnd"], ParameterDirection.Input));
  12613. }
  12614. // 订单号
  12615. if (!string.IsNullOrEmpty(cre.Properties["OrderNo"] as string))
  12616. {
  12617. sqlString = sqlString + " AND instr(O.OrderNo,:OrderNo)>0 \n";
  12618. parameters.Add(new OracleParameter(":OrderNo", OracleDbType.NVarchar2, cre.Properties["OrderNo"], ParameterDirection.Input));
  12619. }
  12620. // 产品类别编码
  12621. if (!string.IsNullOrEmpty(cre.Properties["GoodsTypeCode"] as string))
  12622. {
  12623. sqlString = sqlString + " AND instr(gt.GoodsTypeCode,:GoodsTypeCode)=1 \n";
  12624. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input));
  12625. }
  12626. // 产品编码
  12627. if (!string.IsNullOrEmpty(cre.Properties["GoodsCode"] as string))
  12628. {
  12629. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
  12630. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input));
  12631. }
  12632. // 产品型号
  12633. if (!string.IsNullOrEmpty(cre.Properties["GoodsModel"] as string))
  12634. {
  12635. sqlString = sqlString + " AND instr(g.GoodsModel,:GoodsModel)>0 \n";
  12636. parameters.Add(new OracleParameter(":GoodsModel", OracleDbType.NVarchar2, cre.Properties["GoodsModel"], ParameterDirection.Input));
  12637. }
  12638. // 产品商标ID集
  12639. if (!string.IsNullOrEmpty(cre.Properties["LogoIDS"] as string))
  12640. {
  12641. sqlString += " AND instr(','||:LogoIDS||',', ',' || f.logoid || ',') > 0 \n";
  12642. parameters.Add(new OracleParameter(":LogoIDS", OracleDbType.Varchar2, cre.Properties["LogoIDS"], ParameterDirection.Input));
  12643. }
  12644. // 交接工号
  12645. if (!string.IsNullOrEmpty(cre.Properties["FHUserCode"] as string))
  12646. {
  12647. sqlString = sqlString + " AND instr(F.FHUserCode,:FHUserCode)>0 \n";
  12648. parameters.Add(new OracleParameter(":FHUserCode", OracleDbType.NVarchar2, cre.Properties["FHUserCode"], ParameterDirection.Input));
  12649. }
  12650. //sqlString += " group by trunc(f.fhtime), g.goodscode order by trunc(f.fhtime), g.goodscode";
  12651. sqlString += " GROUP BY GROUPING SETS((g.goodscode,g.goodsmodel,gdd.materialcode),())";
  12652. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  12653. ServiceResultEntity sre = new ServiceResultEntity();
  12654. if (data == null || data.Rows.Count == 0)
  12655. {
  12656. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12657. return sre;
  12658. }
  12659. sre.Data = new DataSet();
  12660. sre.Data.Tables.Add(data);
  12661. return sre;
  12662. }
  12663. catch (Exception ex)
  12664. {
  12665. throw ex;
  12666. }
  12667. finally
  12668. {
  12669. if (conn != null &&
  12670. conn.ConnState == ConnectionState.Open)
  12671. {
  12672. conn.Close();
  12673. }
  12674. }
  12675. }
  12676. /// <summary>
  12677. /// 取得PDA(产成品交接汇总表)的交接数量
  12678. /// </summary>
  12679. /// <param name="user">登录用户信息</param>
  12680. /// <param name="se">查询条件</param>
  12681. /// <returns>查询结果</returns>
  12682. public static ServiceResultEntity GetRPT0030112NPDAData(DateTime date, string goodscode, SUserInfo user)
  12683. {
  12684. IDBConnection conn = null;
  12685. try
  12686. {
  12687. DateTime dateStart = date;
  12688. DateTime dateEnd = dateStart.AddDays(1);
  12689. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12690. List<OracleParameter> parameters = new List<OracleParameter>();
  12691. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  12692. string sqlString = "SELECT o.orderno, g.goodscode, COUNT(*) goodscount\n" +
  12693. " FROM tp_pm_finishedproduct f\n" +
  12694. " LEFT JOIN TP_PM_Order O\n" +
  12695. " ON f.Fhorderid = O.Orderid\n" +
  12696. " LEFT JOIN tp_mst_goods G\n" +
  12697. " ON g.goodsid = f.goodsid\n" +
  12698. " LEFT JOIN TP_MST_GoodsType gt\n" +
  12699. " ON g.GoodsTypeID = gt.GoodsTypeID\n" +
  12700. " WHERE f.fhtime IS NOT NULL\n" +
  12701. " AND f.AccountID = :AccountID\n";
  12702. sqlString = sqlString + " AND F.FHTime >= :FHTimeStart \n";
  12703. parameters.Add(new OracleParameter(":FHTimeStart", OracleDbType.Date, dateStart, ParameterDirection.Input));
  12704. sqlString = sqlString + " AND F.FHTime < :FHTimeEnd \n";
  12705. parameters.Add(new OracleParameter(":FHTimeEnd", OracleDbType.Date, dateEnd, ParameterDirection.Input));
  12706. // 产品型号
  12707. if (!string.IsNullOrEmpty(goodscode))
  12708. {
  12709. sqlString = sqlString + " AND instr(g.GoodsCode,:GoodsCode)>0 \n";
  12710. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, goodscode, ParameterDirection.Input));
  12711. }
  12712. sqlString += " group by orderno, g.goodscode order by orderno, g.goodscode";
  12713. DataTable data = conn.GetSqlResultToDt(sqlString, parameters.ToArray());
  12714. ServiceResultEntity sre = new ServiceResultEntity();
  12715. if (data == null || data.Rows.Count == 0)
  12716. {
  12717. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12718. return sre;
  12719. }
  12720. sre.Data = new DataSet();
  12721. sre.Data.Tables.Add(data);
  12722. return sre;
  12723. }
  12724. catch (Exception ex)
  12725. {
  12726. throw ex;
  12727. }
  12728. finally
  12729. {
  12730. if (conn != null &&
  12731. conn.ConnState == ConnectionState.Open)
  12732. {
  12733. conn.Close();
  12734. }
  12735. }
  12736. }
  12737. /// <summary>
  12738. /// 获取在产品备份表
  12739. /// </summary>
  12740. /// <param name="cre"></param>
  12741. /// <param name="sUserInfo"></param>
  12742. /// <returns></returns>
  12743. public static ServiceResultEntity GetRPT010404Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  12744. {
  12745. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12746. try
  12747. {
  12748. ServiceResultEntity sre = new ServiceResultEntity();
  12749. string sqlString = "SELECT inpb.BackupMonth\n" +
  12750. " ,gdd.BarCode\n" +
  12751. //" ,inpb.GoodsID\n" +
  12752. " ,inpb.GoodsCode\n" +
  12753. " ,inpb.GoodsName\n" +
  12754. //" ,inpb.Userid\n" +
  12755. " ,worker.USERNAME AS UserName\n" +
  12756. " ,worker.USERCode AS UserCode\n" +
  12757. //" ,inpb.ProductionLineID\n" +
  12758. " ,inpb.ProductionLineCode\n" +
  12759. " ,inpb.ProductionLineName\n" +
  12760. //" ,inpb.ModelType\n" +
  12761. " ,decode(inpb.inscrapflag, '1', '待审核的报废品', '正常') AS inscrapflag\n" +
  12762. " ,inpb.IsPublicBody\n" +
  12763. " ,decode(inpb.IsReFire,'6','1','0') IsReFire\n" +
  12764. " ,inpb.IsReworkFlag\n" +
  12765. " ,decode(inpb.CanManyTimes, '1', '能', '不能') AS CanManyTimes\n" +
  12766. " ,decode(inpb.ProcedureModel, '1', '计件模型', '检验模型') AS ProcedureModel\n" +
  12767. //" ,inpb.GroutingDailyID\n" +
  12768. //" ,inpb.GroutingDailyDetailID\n" +
  12769. " ,inpb.GroutingDate\n" +
  12770. //" ,inpb.GroutingLineID\n" +
  12771. " ,inpb.GroutingLineCode\n" +
  12772. " ,inpb.GroutingLineName\n" +
  12773. //" ,inpb.ProcedureID CompleteProcedureID\n" +
  12774. " ,pro.ProcedureName AS CompleteProcedureName\n" +
  12775. //" ,inpb.GMouldTypeID\n" +
  12776. " ,gmt.GMOULDTYPENAME AS GMouldTypeName\n" +
  12777. //" ,inpb.GroutingLineDetailID\n" +
  12778. " ,inpb.GroutingMouldCode\n" +
  12779. " ,inpb.SPECIALREPAIRFLAG\n" +
  12780. " ,inpb.GROUTINGUSERCODE\n" +
  12781. " ,gdd.GROUTINGCOUNT\n" +
  12782. " ,gdd.delivertime\n" +
  12783. " ,inpb.proceduretime\n" +
  12784. " ,inpb.Remarks\n" +
  12785. //" ,inpb.GoodsLevelID\n" +
  12786. " ,mgl.GOODSLEVELNAME\n" +
  12787. //" ,inpb.GoodsLevelTypeID\n" +
  12788. " ,mglt.GOODSLEVELTYPENAME\n" +
  12789. " ,inpb.BackupTime\n" +
  12790. " ,REPLACE((logo.Logoname || '[' || logo.Logocode || ']'), '[]', '') AS LogoCodeName\n" +
  12791. //" ,(Goods.MaterialCode || logo.tagcode || gdd.onlycode) AS FinishedBarCode\n" +
  12792. " ,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" +
  12793. " FROM TP_PM_InProduction_BakByMonth inpb\n" +
  12794. " INNER JOIN TP_MST_User worker\n" +
  12795. " ON worker.UserID = inpb.Userid\n" +
  12796. " INNER JOIN TP_PC_Procedure pro\n" +
  12797. " ON pro.PROCEDUREID = inpb.ProcedureID\n" +
  12798. " INNER JOIN TP_MST_GMouldType gmt\n" +
  12799. " ON gmt.GMouldTypeID = inpb.GMouldTypeID\n" +
  12800. " INNER JOIN TP_SYS_ProcedureModelType pmt\n" +
  12801. " ON pmt.ProcedureModelTypeID = inpb.ModelType\n" +
  12802. //" INNER JOIN TP_PM_GroutingDaily gd\n" +
  12803. //" ON gd.GroutingDailyID = inpb.GroutingDailyID\n" +
  12804. " INNER JOIN TP_PM_GroutingDailyDetail gdd\n" +
  12805. " ON gdd.Groutingdailydetailid = inpb.GroutingDailyDetailID\n" +
  12806. //" INNER JOIN TP_PC_GroutingLineDetail gld\n" +
  12807. //" ON gld.Groutinglinedetailid = inpb.GroutingLineDetailID\n" +
  12808. " LEFT JOIN TP_MST_GoodsLevel mgl\n" +
  12809. " ON mgl.GoodsLevelID = inpb.GoodsLevelID\n" +
  12810. " LEFT JOIN TP_SYS_GoodsLevelType mglt\n" +
  12811. " ON mglt.GoodsLevelTypeID = inpb.GoodsLevelTypeID\n" +
  12812. " LEFT JOIN TP_MST_Logo logo\n" +
  12813. " ON inpb.logoid = logo.logoid\n" +
  12814. " LEFT JOIN TP_MST_Goods Goods\n" +
  12815. " ON inpb.GoodsID = Goods.GoodsID\n" +
  12816. " WHERE inpb.AccountID = :AccountID" +
  12817. " AND inpb.BackupMonth = :BackupMonth" +
  12818. " ORDER BY pro.displayno,inpb.proceduretime";
  12819. OracleParameter[] oracleParameter = new OracleParameter[]
  12820. {
  12821. new Oracle.ManagedDataAccess.Client.OracleParameter(":AccountID",sUserInfo.AccountID),
  12822. new Oracle.ManagedDataAccess.Client.OracleParameter(":BackupMonth",cre.Properties["BackupMonth"]),
  12823. };
  12824. oracleConn.Open();
  12825. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  12826. oracleConn.Close();
  12827. sre.Data = result;
  12828. return sre;
  12829. }
  12830. catch (Exception ex)
  12831. {
  12832. if (oracleConn.ConnState == ConnectionState.Open)
  12833. {
  12834. oracleConn.Close();
  12835. }
  12836. throw ex;
  12837. }
  12838. }
  12839. /// <summary>
  12840. /// 产成品单值明细表
  12841. /// </summary>
  12842. /// <param name="cre"></param>
  12843. /// <param name="sUserInfo"></param>
  12844. /// <returns></returns>
  12845. public static ServiceResultEntity GetRPT010405Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  12846. {
  12847. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12848. try
  12849. {
  12850. string sql =
  12851. "SELECT up.id, up.NAME\n" +
  12852. " FROM tp_mst_unitprice up\n" +
  12853. " WHERE up.accountid = :AccountID\n" +
  12854. " AND up.valueflag = '1'\n" +
  12855. " AND (:upname IS NULL OR instr(up.name, :upname) > 0)\n" +
  12856. " ORDER BY up.displayno";
  12857. OracleParameter[] opara = new OracleParameter[]
  12858. {
  12859. new Oracle.ManagedDataAccess.Client.OracleParameter(":AccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  12860. new Oracle.ManagedDataAccess.Client.OracleParameter(":upname", OracleDbType.NVarchar2,cre.Properties["UPName"], ParameterDirection.Input),
  12861. };
  12862. DataTable upTable = oracleConn.GetSqlResultToDt(sql, opara);
  12863. StringBuilder upNames = new StringBuilder();
  12864. StringBuilder upTotals = new StringBuilder();
  12865. StringBuilder upSUMs = new StringBuilder();
  12866. foreach (DataRow item in upTable.Rows)
  12867. {
  12868. upNames.AppendFormat(", u{0} AS \"{1}\"\n", item["ID"], item["Name"]);
  12869. upTotals.AppendFormat(",(u{0} * nvl(fpcount, 0)) AS \"总【{1}】\"\n", item["ID"], item["Name"]);
  12870. upSUMs.AppendFormat(",SUM(decode(up.upid, {0}, up.unitprice, 0)) u{0}\n", item["ID"]);
  12871. }
  12872. ServiceResultEntity sre = new ServiceResultEntity();
  12873. string sqlString = "SELECT gt2.goodstypename GoodsTypeName2\n" +
  12874. " ,g.goodscode\n" +
  12875. " ,g.materialcode\n" +
  12876. " ,lg.logoname\n" +
  12877. " ,nvl(fpcount, 0) fpcount\n" +
  12878. // " ,u1 AS \"单值1\"\n" +
  12879. //" ,u2 AS \"单值2\"\n" +
  12880. upNames +
  12881. //" ,(u1 * nvl(fpcount, 0)) AS \"总【1】\"\n" +
  12882. //" ,(u2 * nvl(fpcount, 0)) AS \"总【2】\"\n" +
  12883. upTotals +
  12884. " FROM (SELECT up.goodsid\n" +
  12885. " ,up.logoid\n" +
  12886. //" ,SUM(decode(up.upid, 1, up.unitprice, 0)) u1\n" +
  12887. //" ,SUM(decode(up.upid, 2, up.unitprice, 0)) u2\n" +
  12888. upSUMs +
  12889. " FROM TP_MST_UnitPriceGoods up\n" +
  12890. " WHERE up.accountid = :AccountID\n" +
  12891. " GROUP BY up.goodsid, up.logoid) upg\n" +
  12892. " LEFT JOIN (SELECT fp.goodsid, fp.logoid, COUNT(*) fpcount\n" +
  12893. " FROM tp_pm_finishedproduct fp\n" +
  12894. " WHERE fp.accountid = :AccountID\n" +
  12895. " AND fp.fhtime BETWEEN :DateBegin AND :DateEnd\n" +
  12896. " AND (:GoodsCode IS NULL OR\n" +
  12897. " instr(fp.goodscode, :GoodsCode) > 0)\n" +
  12898. " GROUP BY fp.goodsid, fp.logoid) fpp\n" +
  12899. " ON fpp.goodsid = upg.goodsid\n" +
  12900. " AND fpp.logoid = upg.logoid\n" +
  12901. " INNER JOIN tp_mst_logo lg\n" +
  12902. " ON lg.logoid = upg.logoid\n" +
  12903. " INNER JOIN tp_mst_goods g\n" +
  12904. " ON g.goodsid = upg.goodsid\n" +
  12905. " INNER JOIN tp_mst_goodstype gt\n" +
  12906. " ON gt.goodstypeid = g.goodstypeid\n" +
  12907. " INNER JOIN tp_mst_goodstype gt2\n" +
  12908. " ON gt2.accountid = :AccountID\n" +
  12909. " AND length(gt2.goodstypecode) = 6\n" +
  12910. " AND instr(gt.goodstypecode, gt2.goodstypecode) = 1\n" +
  12911. " WHERE (:GoodsTypeCode IS NULL OR\n" +
  12912. " instr(gt.goodstypecode, :GoodsTypeCode) = 1)\n" +
  12913. " AND (:GoodsCode IS NULL OR instr(g.goodscode, :GoodsCode) > 0)\n" +
  12914. " AND (:logoname IS NULL OR instr(lg.logoname, :logoname) > 0)\n" +
  12915. " ORDER BY g.goodscode, lg.displayno";
  12916. OracleParameter[] oracleParameter = new OracleParameter[]
  12917. {
  12918. new Oracle.ManagedDataAccess.Client.OracleParameter(":AccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  12919. new Oracle.ManagedDataAccess.Client.OracleParameter(":DateBegin", OracleDbType.Date,cre.Properties["DateBegin"], ParameterDirection.Input),
  12920. new Oracle.ManagedDataAccess.Client.OracleParameter(":DateEnd", OracleDbType.Date,cre.Properties["DateEnd"], ParameterDirection.Input),
  12921. new Oracle.ManagedDataAccess.Client.OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2,cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  12922. new Oracle.ManagedDataAccess.Client.OracleParameter(":GoodsCode", OracleDbType.NVarchar2,cre.Properties["GoodsCode"], ParameterDirection.Input),
  12923. new Oracle.ManagedDataAccess.Client.OracleParameter(":logoname", OracleDbType.NVarchar2,cre.Properties["LogoName"], ParameterDirection.Input),
  12924. };
  12925. oracleConn.Open();
  12926. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  12927. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  12928. {
  12929. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  12930. }
  12931. sre.Data = result;
  12932. oracleConn.Close();
  12933. return sre;
  12934. }
  12935. catch (Exception ex)
  12936. {
  12937. if (oracleConn.ConnState == ConnectionState.Open)
  12938. {
  12939. oracleConn.Close();
  12940. }
  12941. throw ex;
  12942. }
  12943. }
  12944. /// <summary>
  12945. /// 产成品单值明细表-单值名管理
  12946. /// </summary>
  12947. /// <param name="cre"></param>
  12948. /// <param name="sUserInfo"></param>
  12949. /// <returns></returns>
  12950. public static ServiceResultEntity GetRPT01040501Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  12951. {
  12952. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  12953. try
  12954. {
  12955. ServiceResultEntity sre = new ServiceResultEntity();
  12956. string sqlString = "SELECT t.id, t.name, t.displayno, t.valueflag\n" +
  12957. " FROM TP_MST_UnitPrice t\n" +
  12958. " WHERE t.accountid = :accountid\n" +
  12959. " ORDER BY t.id";
  12960. OracleParameter[] oracleParameter = new OracleParameter[]
  12961. {
  12962. new Oracle.ManagedDataAccess.Client.OracleParameter(":AccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  12963. };
  12964. oracleConn.Open();
  12965. sre.Data = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  12966. oracleConn.Close();
  12967. return sre;
  12968. }
  12969. catch (Exception ex)
  12970. {
  12971. if (oracleConn.ConnState == ConnectionState.Open)
  12972. {
  12973. oracleConn.Close();
  12974. }
  12975. throw ex;
  12976. }
  12977. }
  12978. /// <summary>
  12979. /// 产成品单值明细表-单值名管理
  12980. /// </summary>
  12981. /// <param name="cre"></param>
  12982. /// <param name="sUserInfo"></param>
  12983. /// <returns></returns>
  12984. public static ServiceResultEntity SetRPT01040501Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  12985. {
  12986. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  12987. try
  12988. {
  12989. ServiceResultEntity sre = new ServiceResultEntity();
  12990. // 检验参数的有效性
  12991. if (cre.Data == null && cre.Data.Tables.Count == 0 ||
  12992. cre.Data.Tables[0].Rows.Count < Constant.INT_IS_ZERO)
  12993. {
  12994. return sre;
  12995. }
  12996. oracleTrConn.Connect();
  12997. foreach (DataRow dataRow in cre.Data.Tables[0].Rows)
  12998. {
  12999. // 新建
  13000. if (dataRow.RowState == DataRowState.Added)
  13001. {
  13002. #region 新增
  13003. string sqlString = "INSERT INTO TP_MST_UNITPRICE\n" +
  13004. " (NAME, displayno, accountid, valueflag, createuserid, updateuserid)\n" +
  13005. "VALUES\n" +
  13006. " (:NAME, nvl(:DisplayNo,0), :AccountID, :ValueFlag, :UserID, :UserID)";
  13007. OracleParameter[] oracleParameter = new OracleParameter[]
  13008. {
  13009. new OracleParameter(":NAME", OracleDbType.NVarchar2, dataRow["Name"],ParameterDirection.Input),
  13010. new OracleParameter(":DisplayNo",OracleDbType.Int32, dataRow["DisplayNo"], ParameterDirection.Input),
  13011. new OracleParameter(":AccountID",OracleDbType.Int32,sUserInfo.AccountID, ParameterDirection.Input),
  13012. new OracleParameter(":ValueFlag",OracleDbType.NVarchar2, dataRow["ValueFlag"],ParameterDirection.Input),
  13013. new OracleParameter(":UserID",OracleDbType.Int32,sUserInfo.UserID, ParameterDirection.Input),
  13014. };
  13015. oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  13016. #endregion
  13017. }
  13018. else if (dataRow.RowState == DataRowState.Modified)
  13019. {
  13020. #region 更新
  13021. string sqlUpdateString = "UPDATE TP_MST_UNITPRICE SET "
  13022. + " Name = :Name,"
  13023. + " DisplayNo = :DisplayNo,"
  13024. + " ValueFlag = :ValueFlag,"
  13025. + " UpdateUserID = :UserID"
  13026. + " WHERE ID = :ID";
  13027. OracleParameter[] oracleParameter = new OracleParameter[]
  13028. {
  13029. new OracleParameter(":ID",OracleDbType.Int32,dataRow["ID"], ParameterDirection.Input),
  13030. new OracleParameter(":Name", OracleDbType.NVarchar2, dataRow["Name"],ParameterDirection.Input),
  13031. new OracleParameter(":DisplayNo",OracleDbType.Int32, dataRow["DisplayNo"], ParameterDirection.Input),
  13032. new OracleParameter(":ValueFlag",OracleDbType.NVarchar2, dataRow["ValueFlag"],ParameterDirection.Input),
  13033. new OracleParameter(":UserID",OracleDbType.Int32,sUserInfo.UserID, ParameterDirection.Input),
  13034. };
  13035. oracleTrConn.ExecuteNonQuery(sqlUpdateString, oracleParameter);
  13036. #endregion
  13037. }
  13038. else if (dataRow.RowState == DataRowState.Deleted)
  13039. {
  13040. #region 删除
  13041. string sqlDeleteString = "DELETE TP_MST_UNITPRICE WHERE ID = :ID";
  13042. OracleParameter[] oracleParameter = new OracleParameter[]
  13043. {
  13044. new OracleParameter(":ID",OracleDbType.Int32,dataRow["ID"], ParameterDirection.Input),
  13045. };
  13046. oracleTrConn.ExecuteNonQuery(sqlDeleteString, oracleParameter);
  13047. #endregion
  13048. }
  13049. }
  13050. oracleTrConn.Commit();
  13051. oracleTrConn.Disconnect();
  13052. return sre;
  13053. }
  13054. catch (Exception ex)
  13055. {
  13056. if (oracleTrConn.ConnState == ConnectionState.Open)
  13057. {
  13058. oracleTrConn.Rollback();
  13059. oracleTrConn.Disconnect();
  13060. }
  13061. throw ex;
  13062. }
  13063. finally
  13064. {
  13065. if (oracleTrConn.ConnState == ConnectionState.Open)
  13066. {
  13067. oracleTrConn.Disconnect();
  13068. }
  13069. }
  13070. }
  13071. /// <summary>
  13072. /// 获取模具跟踪表
  13073. /// </summary>
  13074. /// <param name="cre"></param>
  13075. /// <param name="sUserInfo"></param>
  13076. /// <returns></returns>
  13077. public static ServiceResultEntity GetRPT020105Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13078. {
  13079. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13080. try
  13081. {
  13082. ServiceResultEntity sre = new ServiceResultEntity();
  13083. OracleParameter[] oracleParameter = new OracleParameter[]
  13084. {
  13085. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13086. new OracleParameter("in_MouldBarcode",OracleDbType.Varchar2, cre.Properties["MouldBarcode"], ParameterDirection.Input),
  13087. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13088. new OracleParameter("out_Tracking",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13089. };
  13090. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_GetMouldTracking", oracleParameter);
  13091. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13092. {
  13093. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13094. }
  13095. sre.Data = result;
  13096. return sre;
  13097. }
  13098. catch (Exception ex)
  13099. {
  13100. if (oracleConn.ConnState == ConnectionState.Open)
  13101. {
  13102. oracleConn.Close();
  13103. }
  13104. throw ex;
  13105. }
  13106. }
  13107. /// <summary>
  13108. /// 获取模具收发存汇总表
  13109. /// </summary>
  13110. /// <param name="cre"></param>
  13111. /// <param name="sUserInfo"></param>
  13112. /// <returns></returns>
  13113. public static ServiceResultEntity GetRPT030113Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13114. {
  13115. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13116. try
  13117. {
  13118. ServiceResultEntity sre = new ServiceResultEntity();
  13119. OracleParameter[] oracleParameter = new OracleParameter[]
  13120. {
  13121. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13122. new OracleParameter("in_YYYYMM",OracleDbType.Varchar2, cre.Properties["YYYYMM"], ParameterDirection.Input),
  13123. new OracleParameter("in_DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13124. new OracleParameter("in_DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13125. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13126. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13127. new OracleParameter("in_GoodsIDs",OracleDbType.Varchar2, cre.Properties["GoodsIDs"], ParameterDirection.Input),
  13128. new OracleParameter("in_GoodsID",OracleDbType.Int32, cre.Properties["GoodsID"], ParameterDirection.Input),
  13129. new OracleParameter("in_Type",OracleDbType.Int32, cre.Properties["Type"], ParameterDirection.Input),
  13130. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13131. };
  13132. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_GetMould_SUM", oracleParameter);
  13133. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13134. {
  13135. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13136. }
  13137. sre.Data = result;
  13138. oracleConn.Commit();
  13139. return sre;
  13140. }
  13141. catch (Exception ex)
  13142. {
  13143. if (oracleConn.ConnState == ConnectionState.Open)
  13144. {
  13145. oracleConn.Disconnect();
  13146. }
  13147. throw ex;
  13148. }
  13149. }
  13150. /// <summary>
  13151. /// 获取废弃产品汇总表
  13152. /// </summary>
  13153. /// <param name="cre"></param>
  13154. /// <param name="sUserInfo"></param>
  13155. /// <returns></returns>
  13156. public static ServiceResultEntity GetRPT030114Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13157. {
  13158. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13159. try
  13160. {
  13161. ServiceResultEntity sre = new ServiceResultEntity();
  13162. OracleParameter[] oracleParameter = new OracleParameter[]
  13163. {
  13164. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13165. new OracleParameter("in_DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13166. new OracleParameter("in_DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13167. new OracleParameter("in_scrapTypes",OracleDbType.Varchar2, cre.Properties["ScrapTypes"], ParameterDirection.Input),
  13168. new OracleParameter("in_ProcedureIDs",OracleDbType.Varchar2, cre.Properties["ProcedureIDs"], ParameterDirection.Input),
  13169. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13170. //new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13171. new OracleParameter("in_GoodsIDs",OracleDbType.Varchar2, cre.Properties["GoodsIDs"], ParameterDirection.Input),
  13172. new OracleParameter("in_GoodsID",OracleDbType.Int32, cre.Properties["GoodsID"], ParameterDirection.Input),
  13173. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13174. };
  13175. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_scrap_sum", oracleParameter);
  13176. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13177. {
  13178. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13179. }
  13180. sre.Data = result;
  13181. oracleConn.Commit();
  13182. return sre;
  13183. }
  13184. catch (Exception ex)
  13185. {
  13186. if (oracleConn.ConnState == ConnectionState.Open)
  13187. {
  13188. oracleConn.Disconnect();
  13189. }
  13190. throw ex;
  13191. }
  13192. }
  13193. /// <summary>
  13194. /// 获取废品损失汇总表
  13195. /// </summary>
  13196. /// <param name="cre"></param>
  13197. /// <param name="sUserInfo"></param>
  13198. /// <returns></returns>
  13199. public static ServiceResultEntity GetRPT030115Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13200. {
  13201. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13202. try
  13203. {
  13204. ServiceResultEntity sre = new ServiceResultEntity();
  13205. OracleParameter[] oracleParameter = new OracleParameter[]
  13206. {
  13207. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13208. new OracleParameter("in_ptid",OracleDbType.Int32, cre.Properties["PTID"], ParameterDirection.Input),
  13209. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13210. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13211. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13212. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13213. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13214. };
  13215. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_TECDEP_SCRAP_SUM", oracleParameter);
  13216. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13217. {
  13218. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13219. }
  13220. sre.Data = result;
  13221. oracleConn.Commit();
  13222. return sre;
  13223. }
  13224. catch (Exception ex)
  13225. {
  13226. if (oracleConn.ConnState == ConnectionState.Open)
  13227. {
  13228. oracleConn.Disconnect();
  13229. }
  13230. throw ex;
  13231. }
  13232. }
  13233. /// <summary>
  13234. /// 获取废品损失汇总-明细表
  13235. /// </summary>
  13236. /// <param name="cre"></param>
  13237. /// <param name="sUserInfo"></param>
  13238. /// <returns></returns>
  13239. public static ServiceResultEntity GetRPT030115DData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13240. {
  13241. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13242. try
  13243. {
  13244. ServiceResultEntity sre = new ServiceResultEntity();
  13245. OracleParameter[] oracleParameter = new OracleParameter[]
  13246. {
  13247. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13248. new OracleParameter("in_ptid",OracleDbType.Int32, cre.Properties["PTID"], ParameterDirection.Input),
  13249. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13250. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13251. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13252. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13253. new OracleParameter("in_GoodsID",OracleDbType.Varchar2, cre.Properties["GoodsID"], ParameterDirection.Input),
  13254. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13255. };
  13256. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_TECDEP_SCRAP_SUMDETAIL", oracleParameter);
  13257. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13258. {
  13259. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13260. }
  13261. sre.Data = result;
  13262. oracleConn.Commit();
  13263. return sre;
  13264. }
  13265. catch (Exception ex)
  13266. {
  13267. if (oracleConn.ConnState == ConnectionState.Open)
  13268. {
  13269. oracleConn.Disconnect();
  13270. }
  13271. throw ex;
  13272. }
  13273. }
  13274. /// <summary>
  13275. /// 获取废品损失汇总表-半成品损失汇总表
  13276. /// </summary>
  13277. /// <param name="cre"></param>
  13278. /// <param name="sUserInfo"></param>
  13279. /// <returns></returns>
  13280. public static ServiceResultEntity GetRPT030115SData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13281. {
  13282. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13283. try
  13284. {
  13285. ServiceResultEntity sre = new ServiceResultEntity();
  13286. OracleParameter[] oracleParameter = new OracleParameter[]
  13287. {
  13288. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13289. new OracleParameter("in_ptid",OracleDbType.Int32, cre.Properties["PTID"], ParameterDirection.Input),
  13290. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13291. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13292. new OracleParameter("in_GoodsTypeCode",OracleDbType.Varchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13293. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13294. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  13295. };
  13296. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_TECDEP_SCRAP_SUM_semi", oracleParameter);
  13297. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13298. {
  13299. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13300. }
  13301. StringBuilder cols = new StringBuilder();
  13302. StringBuilder sumCols = new StringBuilder();
  13303. foreach (DataRow item in result.Tables[0].Rows)
  13304. {
  13305. cols.AppendFormat(", d{0} AS \"{1}\"\n", item["id"], item["name"]);
  13306. sumCols.AppendFormat(", SUM(decode(td1.id, {0}, g.d, 0)) d{0}\n", item["id"]);
  13307. }
  13308. string sqlString = "SELECT gid\n" +
  13309. " ,decode(gid, 3, '合计', 1, '小计[' || gt2name || ']', gt2name) gt2name\n" +
  13310. " ,decode(gid, 0, td2name, '--') td2name\n" +
  13311. " ,gg.gc\n" +
  13312. " ,case when gg.gc is not null and gg.gc > 0 then round(tt.d / gg.gc,4) else null end gcc\n" +
  13313. " ,d\n" +
  13314. " ,c\n" +
  13315. " ,d-c g\n" +
  13316. cols +
  13317. " FROM (SELECT grouping_id(t.tecdepid, td2.id) gid\n" +
  13318. " ,nvl(t.tecdepid, -1) gt2id\n" +
  13319. " ,t.tecdepname gt2name\n" +
  13320. " ,td2.name td2name\n" +
  13321. " ,td2.displayno td2displayno\n" +
  13322. " ,SUM(g.d) d\n" +
  13323. " ,SUM(g.c) c\n" +
  13324. sumCols +
  13325. " FROM TMP_RPT_TECDEP_G g\n" +
  13326. " INNER JOIN TMP_RPT_TECDEP_T t\n" +
  13327. " ON g.goodsid = t.goodsid\n" +
  13328. " INNER JOIN tmp_rpt_tecdep_s s1\n" +
  13329. " ON s1.procedureid = g.pid\n" +
  13330. " INNER JOIN tp_mst_tecdep td1\n" +
  13331. " ON td1.id = s1.intecdepid\n" +
  13332. " LEFT JOIN tmp_rpt_tecdep_s s2\n" +
  13333. " ON s2.procedureid = g.f\n" +
  13334. " LEFT JOIN tp_mst_tecdep td2\n" +
  13335. " ON td2.id = s2.intecdepid\n" +
  13336. " WHERE td1.technologyflag = '1' -- 半成品工艺\n" +
  13337. " AND (td2.id IS NULL OR td2.technologyflag = '1')\n" +
  13338. " GROUP BY GROUPING SETS((t.tecdepid, t.tecdepname, td2.id, td2.name, td2.displayno),(t.tecdepid, t.tecdepname),())\n" +
  13339. " ORDER BY t.tecdepname, td2.displayno) tt\n" +
  13340. " LEFT JOIN (SELECT --grouping_id(gt2.goodstypeid) gid,\n" +
  13341. " nvl(t.tecdepid, -1) gt2id, COUNT(*) gc\n" +
  13342. " FROM tp_pm_groutingdailydetail gdd\n" +
  13343. " INNER JOIN TMP_RPT_TECDEP_T t\n" +
  13344. " ON gdd.goodsid = t.goodsid\n" +
  13345. " WHERE gdd.accountid = :in_accountid\n" +
  13346. " AND gdd.valueflag = '1'\n" +
  13347. " AND gdd.groutingflag = '1'\n" +
  13348. " AND gdd.groutingdate BETWEEN :in_datetimebegin AND\n" +
  13349. " :in_datetimeend\n" +
  13350. " GROUP BY GROUPING SETS((t.tecdepid),())) gg\n" +
  13351. " ON gg.gt2id = tt.gt2id\n" +
  13352. " ORDER BY tt.gt2name, tt.gid, tt.td2displayno";
  13353. oracleParameter = new OracleParameter[]
  13354. {
  13355. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13356. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13357. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13358. };
  13359. result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13360. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13361. {
  13362. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13363. }
  13364. sre.Data = result;
  13365. oracleConn.Commit();
  13366. return sre;
  13367. }
  13368. catch (Exception ex)
  13369. {
  13370. if (oracleConn.ConnState == ConnectionState.Open)
  13371. {
  13372. oracleConn.Disconnect();
  13373. }
  13374. throw ex;
  13375. }
  13376. }
  13377. /// <summary>
  13378. /// 获取成型存坯汇总表-注浆产品存坯汇总表
  13379. /// </summary>
  13380. /// <param name="cre"></param>
  13381. /// <param name="sUserInfo"></param>
  13382. /// <returns></returns>
  13383. public static ServiceResultEntity GetRPT030116GoodsData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13384. {
  13385. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13386. try
  13387. {
  13388. ServiceResultEntity sre = new ServiceResultEntity();
  13389. /*
  13390. string sqlString =
  13391. "SELECT gdrd.goodsid\n" +
  13392. " ,gdrd.goodscode\n" +
  13393. //" ,gdrd.groutinglineid\n" +
  13394. //" ,gdrd.groutinglinecode\n" +
  13395. //" ,gdrd.userid\n" +
  13396. //" ,gdrd.usercode\n" +
  13397. " ,gdrd.gddc rdcount -- 存坯数\n" +
  13398. " ,rdd.gldcount -- 模具数\n" +
  13399. " , CASE\n" +
  13400. " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
  13401. " round(gdrd.gddc / rdd.gldcount, 2)\n" +
  13402. " ELSE\n" +
  13403. " NULL\n" +
  13404. " END rddays -- 存坯天数\n" +
  13405. " ,gdrd.reserveddays -- 应存天数\n" +
  13406. " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
  13407. " FROM (SELECT gdd.goodsid\n" +
  13408. " ,gdd.goodscode\n" +
  13409. //" ,gdd.groutinglineid\n" +
  13410. //" ,gdd.groutinglinecode\n" +
  13411. //" ,gdd.userid\n" +
  13412. //" ,gdd.usercode\n" +
  13413. " ,g.reserveddays\n" +
  13414. " ,COUNT(*) gddc\n" +
  13415. " FROM tp_pm_groutingdailydetail gdd\n" +
  13416. " INNER JOIN tp_mst_goods g\n" +
  13417. " ON g.goodsid = gdd.goodsid\n" +
  13418. " INNER JOIN tp_mst_goodstype gt\n" +
  13419. " ON g.goodstypeid = gt.goodstypeid\n" +
  13420. " WHERE gdd.accountid = :accountid\n" +
  13421. " AND gdd.valueflag = '1'\n" +
  13422. " AND gdd.groutingflag = '1'\n" +
  13423. " AND gdd.barcode IS NOT NULL\n" +
  13424. " AND gdd.scrapflag = '0'\n" +
  13425. " AND gdd.deliverflag = '0'\n" +
  13426. " AND (:LineCode IS NULL OR\n" +
  13427. " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13428. " AND (:UserCode IS NULL OR instr(gdd.UserCode, :UserCode) > 0)\n" +
  13429. " AND (:GoodsCode IS NULL OR instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13430. " AND (:GoodsTypeCode IS NULL OR\n" +
  13431. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13432. " AND (:DateBegin IS NULL OR\n" +
  13433. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
  13434. " GROUP BY gdd.goodsid\n" +
  13435. " ,gdd.goodscode\n" +
  13436. //" ,gdd.groutinglineid\n" +
  13437. //" ,gdd.groutinglinecode\n" +
  13438. //" ,gdd.userid\n" +
  13439. //" ,gdd.usercode\n" +
  13440. " ,g.reserveddays) gdrd\n" +
  13441. " LEFT JOIN (SELECT gld.goodsid\n" +
  13442. //" ,gld.groutinglineid\n" +
  13443. " ,COUNT(*) gldcount\n" +
  13444. " FROM tp_pc_groutinglinedetail gld\n" +
  13445. " INNER JOIN tp_pc_groutingline gl\n" +
  13446. " ON gl.groutinglineid = gld.groutinglineid\n" +
  13447. " WHERE gld.valueflag = '1'\n" +
  13448. " AND gld.gmouldstatus = 1\n" +
  13449. " AND gl.accountid = :accountid\n" +
  13450. " AND gl.valueflag = '1'\n" +
  13451. " AND gl.gmouldstatus = 1\n" +
  13452. " GROUP BY gld.goodsid\n" +
  13453. //" ,gld.groutinglineid\n" +
  13454. " ) rdd\n" +
  13455. " ON rdd.goodsid = gdrd.goodsid\n" +
  13456. //" AND rdd.groutinglineid = gdrd.groutinglineid\n" +
  13457. " ORDER BY gdrd.goodscode\n" +
  13458. //" ,gdrd.groutinglinecode, gdrd.usercode"
  13459. "";
  13460. */
  13461. string sqlString =
  13462. "SELECT grouping_id(t.goodstypecode2, t.goodsid) gid\n" +
  13463. " ,t.goodstypecode2\n" +
  13464. " ,decode(grouping_id(t.goodstypecode2, t.goodsid),\n" +
  13465. " 3,\n" +
  13466. " '总计',\n" +
  13467. " 1,\n" +
  13468. " '合计[' || t.goodstypename2 || ']',\n" +
  13469. " t.goodstypename2) goodstypename2\n" +
  13470. " ,t.goodstypename\n" +
  13471. " ,t.goodsid\n" +
  13472. " ,t.goodscode\n" +
  13473. //" ,t.groutinglineid\n" +
  13474. //" ,t.groutinglinecode\n" +
  13475. //" ,t.userid\n" +
  13476. //" ,t.usercode\n" +
  13477. " ,SUM(t.rdcount) rdcount\n" +
  13478. " ,t.gldcount -- 模具数\n" +
  13479. " ,t.rddays -- 存坯天数\n" +
  13480. " ,t.reserveddays -- 应存天数\n" +
  13481. " ,SUM(t.ProfitNum) ProfitNum\n" +
  13482. " FROM (SELECT gt2.goodstypecode goodstypecode2\n" +
  13483. " ,gt2.goodstypename goodstypename2\n" +
  13484. " ,gdrd.goodsid\n" +
  13485. " ,gdrd.goodscode\n" +
  13486. " ,gdrd.goodstypename\n" +
  13487. //" ,gdrd.groutinglineid\n" +
  13488. //" ,gdrd.groutinglinecode\n" +
  13489. //" ,gdrd.userid\n" +
  13490. //" ,gdrd.usercode\n" +
  13491. " ,gdrd.gddc rdcount -- 存坯数\n" +
  13492. " ,rdd.gldcount -- 模具数\n" +
  13493. " , CASE\n" +
  13494. " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
  13495. " round(gdrd.gddc / rdd.gldcount, 2)\n" +
  13496. " ELSE\n" +
  13497. " NULL\n" +
  13498. " END rddays -- 存坯天数\n" +
  13499. " ,gdrd.reserveddays -- 应存天数\n" +
  13500. // 盈亏坯数 = 存坯数-应存天数*模具数 存坯天数 = 存坯数/模具数
  13501. " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
  13502. " FROM (SELECT gdd.goodsid\n" +
  13503. " ,gdd.goodscode\n" +
  13504. //" ,gdd.groutinglineid\n" +
  13505. //" ,gdd.groutinglinecode\n" +
  13506. //" ,gdd.userid\n" +
  13507. //" ,gdd.usercode\n" +
  13508. " ,g.reserveddays\n" +
  13509. " ,substr(gt.goodstypecode, 1, 6) goodstypecode2\n" +
  13510. " ,gt.goodstypename\n" +
  13511. " ,COUNT(*) gddc\n" +
  13512. " FROM tp_pm_groutingdailydetail gdd\n" +
  13513. " INNER JOIN tp_mst_goods g\n" +
  13514. " ON g.goodsid = gdd.goodsid\n" +
  13515. " INNER JOIN tp_mst_goodstype gt\n" +
  13516. " ON g.goodstypeid = gt.goodstypeid\n" +
  13517. " WHERE gdd.accountid = :accountid\n" +
  13518. " AND gdd.valueflag = '1'\n" +
  13519. " AND gdd.groutingflag = '1'\n" +
  13520. " AND gdd.barcode IS NOT NULL\n" +
  13521. " AND gdd.scrapflag = '0'\n" +
  13522. " AND gdd.deliverflag = '0'\n" +
  13523. " AND (:LineCode IS NULL OR\n" +
  13524. " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13525. " AND (:UserCode IS NULL OR\n" +
  13526. " instr(gdd.UserCode, :UserCode) > 0)\n" +
  13527. " AND (:GoodsCode IS NULL OR\n" +
  13528. " instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13529. " AND (:GoodsTypeCode IS NULL OR\n" +
  13530. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13531. " AND (:DateBegin IS NULL OR\n" +
  13532. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
  13533. " GROUP BY gt.goodstypecode,gt.goodstypename\n" +
  13534. " ,gdd.goodsid\n" +
  13535. " ,gdd.goodscode\n" +
  13536. //" ,gdd.groutinglineid\n" +
  13537. //" ,gdd.groutinglinecode\n" +
  13538. //" ,gdd.userid\n" +
  13539. //" ,gdd.usercode\n" +
  13540. " ,g.reserveddays) gdrd\n" +
  13541. " LEFT JOIN (SELECT gld.goodsid\n" +
  13542. //" ,gld.groutinglineid\n" +
  13543. " ,COUNT(*) gldcount\n" +
  13544. " FROM tp_pc_groutinglinedetail gld\n" +
  13545. " INNER JOIN tp_pc_groutingline gl\n" +
  13546. " ON gl.groutinglineid = gld.groutinglineid\n" +
  13547. " WHERE gld.valueflag = '1'\n" +
  13548. " AND gld.gmouldstatus = 1\n" +
  13549. " AND gl.accountid = :accountid\n" +
  13550. " AND gl.valueflag = '1'\n" +
  13551. " AND gl.gmouldstatus = 1\n" +
  13552. " GROUP BY gld.goodsid\n" +
  13553. //" , gld.groutinglineid" +
  13554. " ) rdd\n" +
  13555. " ON rdd.goodsid = gdrd.goodsid\n" +
  13556. //" AND rdd.groutinglineid = gdrd.groutinglineid\n" +
  13557. " INNER JOIN tp_mst_goodstype gt2\n" +
  13558. " ON gt2.accountid = :accountid\n" +
  13559. " AND gt2.goodstypecode = gdrd.goodstypecode2\n" +
  13560. " ORDER BY gt2.goodstypecode\n" +
  13561. " ,gdrd.goodscode\n" +
  13562. //" ,gdrd.groutinglinecode\n" +
  13563. //" ,gdrd.usercode" +
  13564. " ) t\n" +
  13565. " GROUP BY GROUPING SETS((t.goodstypecode2, t.goodstypename2,t.goodstypename, t.goodsid, t.goodscode, t.gldcount, t.rddays, t.reserveddays),(t.goodstypecode2, t.goodstypename2),())";
  13566. OracleParameter[] oracleParameter = new OracleParameter[]
  13567. {
  13568. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13569. new OracleParameter(":DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13570. new OracleParameter(":DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13571. new OracleParameter(":GoodsTypeCode",OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13572. new OracleParameter(":GoodsCode",OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13573. new OracleParameter(":LineCode",OracleDbType.NVarchar2, cre.Properties["LineCode"], ParameterDirection.Input),
  13574. new OracleParameter(":UserCode",OracleDbType.NVarchar2, cre.Properties["UserCode"], ParameterDirection.Input),
  13575. };
  13576. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13577. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13578. {
  13579. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13580. }
  13581. sre.Data = result;
  13582. return sre;
  13583. }
  13584. catch (Exception ex)
  13585. {
  13586. if (oracleConn.ConnState == ConnectionState.Open)
  13587. {
  13588. oracleConn.Close();
  13589. }
  13590. throw ex;
  13591. }
  13592. }
  13593. /// <summary>
  13594. /// 获取成型存坯汇总表-成型工号存坯汇总表
  13595. /// </summary>
  13596. /// <param name="cre"></param>
  13597. /// <param name="sUserInfo"></param>
  13598. /// <returns></returns>
  13599. public static ServiceResultEntity GetRPT030116UserData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13600. {
  13601. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13602. try
  13603. {
  13604. ServiceResultEntity sre = new ServiceResultEntity();
  13605. /*
  13606. string sqlString =
  13607. "SELECT gdrd.goodsid\n" +
  13608. " ,gdrd.goodscode\n" +
  13609. " ,gdrd.groutinglineid\n" +
  13610. " ,gdrd.groutinglinecode\n" +
  13611. " ,gdrd.userid\n" +
  13612. " ,gdrd.usercode\n" +
  13613. " ,gdrd.gddc rdcount -- 存坯数\n" +
  13614. " ,rdd.gldcount -- 模具数\n" +
  13615. " , CASE\n" +
  13616. " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
  13617. " round(gdrd.gddc / rdd.gldcount, 2)\n" +
  13618. " ELSE\n" +
  13619. " NULL\n" +
  13620. " END rddays -- 存坯天数\n" +
  13621. " ,gdrd.reserveddays -- 应存天数\n" +
  13622. " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
  13623. " FROM (SELECT gdd.goodsid\n" +
  13624. " ,gdd.goodscode\n" +
  13625. " ,gdd.groutinglineid\n" +
  13626. " ,gdd.groutinglinecode\n" +
  13627. " ,gdd.userid\n" +
  13628. " ,gdd.usercode\n" +
  13629. " ,g.reserveddays\n" +
  13630. " ,COUNT(*) gddc\n" +
  13631. " FROM tp_pm_groutingdailydetail gdd\n" +
  13632. " INNER JOIN tp_mst_goods g\n" +
  13633. " ON g.goodsid = gdd.goodsid\n" +
  13634. " INNER JOIN tp_mst_goodstype gt\n" +
  13635. " ON g.goodstypeid = gt.goodstypeid\n" +
  13636. " WHERE gdd.accountid = :accountid\n" +
  13637. " AND gdd.valueflag = '1'\n" +
  13638. " AND gdd.groutingflag = '1'\n" +
  13639. " AND gdd.barcode IS NOT NULL\n" +
  13640. " AND gdd.scrapflag = '0'\n" +
  13641. " AND gdd.deliverflag = '0'\n" +
  13642. " AND (:LineCode IS NULL OR\n" +
  13643. " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13644. " AND (:UserCode IS NULL OR instr(gdd.UserCode, :UserCode) > 0)\n" +
  13645. " AND (:GoodsCode IS NULL OR instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13646. " AND (:GoodsTypeCode IS NULL OR\n" +
  13647. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13648. " AND (:DateBegin IS NULL OR\n" +
  13649. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
  13650. " GROUP BY gdd.goodsid\n" +
  13651. " ,gdd.goodscode\n" +
  13652. " ,gdd.groutinglineid\n" +
  13653. " ,gdd.groutinglinecode\n" +
  13654. " ,gdd.userid\n" +
  13655. " ,gdd.usercode\n" +
  13656. " ,g.reserveddays) gdrd\n" +
  13657. " LEFT JOIN (SELECT gld.goodsid\n" +
  13658. " ,gld.groutinglineid\n" +
  13659. " ,COUNT(*) gldcount\n" +
  13660. " FROM tp_pc_groutinglinedetail gld\n" +
  13661. " INNER JOIN tp_pc_groutingline gl\n" +
  13662. " ON gl.groutinglineid = gld.groutinglineid\n" +
  13663. " WHERE gld.valueflag = '1'\n" +
  13664. " AND gld.gmouldstatus = 1\n" +
  13665. " AND gl.accountid = :accountid\n" +
  13666. " AND gl.valueflag = '1'\n" +
  13667. " AND gl.gmouldstatus = 1\n" +
  13668. " GROUP BY gld.goodsid\n" +
  13669. " ,gld.groutinglineid\n" +
  13670. " ) rdd\n" +
  13671. " ON rdd.goodsid = gdrd.goodsid\n" +
  13672. " AND rdd.groutinglineid = gdrd.groutinglineid\n" +
  13673. " ORDER BY gdrd.goodscode\n" +
  13674. " ,gdrd.groutinglinecode, gdrd.usercode" +
  13675. "";
  13676. */
  13677. string sqlString =
  13678. "SELECT grouping_id(t.goodstypecode2, t.goodsid) gid\n" +
  13679. " ,t.goodstypecode2\n" +
  13680. " ,decode(grouping_id(t.goodstypecode2, t.goodsid),\n" +
  13681. " 3,\n" +
  13682. " '总计',\n" +
  13683. " 1,\n" +
  13684. " '合计[' || t.goodstypename2 || ']',\n" +
  13685. " t.goodstypename2) goodstypename2\n" +
  13686. " ,t.goodsid\n" +
  13687. " ,t.goodscode\n" +
  13688. " ,t.groutinglineid\n" +
  13689. " ,t.groutinglinecode\n" +
  13690. " ,t.userid\n" +
  13691. " ,t.usercode\n" +
  13692. " ,t.MONITORName\n" +
  13693. " ,SUM(t.rdcount) rdcount\n" +
  13694. " ,t.gldcount -- 模具数\n" +
  13695. " ,t.rddays -- 存坯天数\n" +
  13696. " ,t.reserveddays -- 应存天数\n" +
  13697. " ,SUM(t.ProfitNum) ProfitNum\n" +
  13698. " FROM (SELECT gt2.goodstypecode goodstypecode2\n" +
  13699. " ,gt2.goodstypename goodstypename2\n" +
  13700. " ,gdrd.goodsid\n" +
  13701. " ,gdrd.goodscode\n" +
  13702. " ,gdrd.groutinglineid\n" +
  13703. " ,gdrd.groutinglinecode\n" +
  13704. " ,gdrd.userid\n" +
  13705. " ,gdrd.usercode\n" +
  13706. " ,mu.username MONITORName\n" +
  13707. " ,gdrd.gddc rdcount -- 存坯数\n" +
  13708. " ,rdd.gldcount -- 模具数\n" +
  13709. " , CASE\n" +
  13710. " WHEN rdd.gldcount IS NOT NULL AND rdd.gldcount > 0 THEN\n" +
  13711. " round(gdrd.gddc / rdd.gldcount, 2)\n" +
  13712. " ELSE\n" +
  13713. " NULL\n" +
  13714. " END rddays -- 存坯天数\n" +
  13715. " ,gdrd.reserveddays -- 应存天数\n" +
  13716. " ,(gdrd.gddc - gdrd.reserveddays * rdd.gldcount) ProfitNum --盈亏坯数\n" +
  13717. " FROM (SELECT gdd.goodsid\n" +
  13718. " ,gdd.goodscode\n" +
  13719. " ,gdd.groutinglineid\n" +
  13720. " ,gdd.groutinglinecode\n" +
  13721. " ,gdd.userid\n" +
  13722. " ,gdd.usercode\n" +
  13723. " ,g.reserveddays\n" +
  13724. " ,substr(gt.goodstypecode, 1, 6) goodstypecode2\n" +
  13725. " ,COUNT(*) gddc\n" +
  13726. " FROM tp_pm_groutingdailydetail gdd\n" +
  13727. " INNER JOIN tp_mst_goods g\n" +
  13728. " ON g.goodsid = gdd.goodsid\n" +
  13729. " INNER JOIN tp_mst_goodstype gt\n" +
  13730. " ON g.goodstypeid = gt.goodstypeid\n" +
  13731. " WHERE gdd.accountid = :accountid\n" +
  13732. " AND gdd.valueflag = '1'\n" +
  13733. " AND gdd.groutingflag = '1'\n" +
  13734. " AND gdd.barcode IS NOT NULL\n" +
  13735. " AND gdd.scrapflag = '0'\n" +
  13736. " AND gdd.deliverflag = '0'\n" +
  13737. " AND (:LineCode IS NULL OR\n" +
  13738. " instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13739. " AND (:UserCode IS NULL OR\n" +
  13740. " instr(gdd.UserCode, :UserCode) > 0)\n" +
  13741. " AND (:GoodsCode IS NULL OR\n" +
  13742. " instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13743. " AND (:GoodsTypeCode IS NULL OR\n" +
  13744. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13745. " AND (:DateBegin IS NULL OR\n" +
  13746. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)\n" +
  13747. " GROUP BY gt.goodstypecode\n" +
  13748. " ,gdd.goodsid\n" +
  13749. " ,gdd.goodscode\n" +
  13750. " ,gdd.groutinglineid\n" +
  13751. " ,gdd.groutinglinecode\n" +
  13752. " ,gdd.userid\n" +
  13753. " ,gdd.usercode\n" +
  13754. " ,g.reserveddays) gdrd\n" +
  13755. " LEFT JOIN (SELECT gld.goodsid\n" +
  13756. " ,gld.groutinglineid\n" +
  13757. " ,gl.MONITORID\n" +
  13758. " ,COUNT(*) gldcount\n" +
  13759. " FROM tp_pc_groutinglinedetail gld\n" +
  13760. " INNER JOIN tp_pc_groutingline gl\n" +
  13761. " ON gl.groutinglineid = gld.groutinglineid\n" +
  13762. " WHERE gld.valueflag = '1'\n" +
  13763. " AND gld.gmouldstatus = 1\n" +
  13764. " AND gl.accountid = :accountid\n" +
  13765. " AND gl.valueflag = '1'\n" +
  13766. " AND gl.gmouldstatus = 1\n" +
  13767. " GROUP BY gld.goodsid, gld.groutinglineid,gl.MONITORID) rdd\n" +
  13768. " ON rdd.goodsid = gdrd.goodsid\n" +
  13769. " AND rdd.groutinglineid = gdrd.groutinglineid\n" +
  13770. // 成型班长
  13771. " LEFT JOIN tp_mst_user mu\n" +
  13772. " ON mu.userid = rdd.MONITORID\n" +
  13773. " INNER JOIN tp_mst_goodstype gt2\n" +
  13774. " ON gt2.accountid = :accountid\n" +
  13775. " AND gt2.goodstypecode = gdrd.goodstypecode2\n" +
  13776. " ORDER BY gt2.goodstypecode\n" +
  13777. " ,gdrd.goodscode\n" +
  13778. " ,gdrd.groutinglinecode\n" +
  13779. " ,gdrd.usercode) t\n" +
  13780. " 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),())";
  13781. OracleParameter[] oracleParameter = new OracleParameter[]
  13782. {
  13783. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13784. new OracleParameter(":DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13785. new OracleParameter(":DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13786. new OracleParameter(":GoodsTypeCode",OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13787. new OracleParameter(":GoodsCode",OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13788. new OracleParameter(":LineCode",OracleDbType.NVarchar2, cre.Properties["LineCode"], ParameterDirection.Input),
  13789. new OracleParameter(":UserCode",OracleDbType.NVarchar2, cre.Properties["UserCode"], ParameterDirection.Input),
  13790. };
  13791. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13792. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13793. {
  13794. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13795. }
  13796. sre.Data = result;
  13797. return sre;
  13798. }
  13799. catch (Exception ex)
  13800. {
  13801. if (oracleConn.ConnState == ConnectionState.Open)
  13802. {
  13803. oracleConn.Close();
  13804. }
  13805. throw ex;
  13806. }
  13807. }
  13808. /// <summary>
  13809. /// 获取成型存坯汇总表-成型存坯明细表
  13810. /// </summary>
  13811. /// <param name="cre"></param>
  13812. /// <param name="sUserInfo"></param>
  13813. /// <returns></returns>
  13814. public static ServiceResultEntity GetRPT030116DData(ClientRequestEntity cre, SUserInfo sUserInfo)
  13815. {
  13816. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13817. try
  13818. {
  13819. ServiceResultEntity sre = new ServiceResultEntity();
  13820. string sqlString = "SELECT gdd.barcode\n" +
  13821. //" ,gdd.groutinglineid\n" +
  13822. " ,gdd.groutinglinecode\n" +
  13823. " ,gdd.GroutingMouldCode\n" +
  13824. //" ,gdd.goodsid\n" +
  13825. " ,gdd.goodscode\n" +
  13826. //" ,gdd.userid\n" +
  13827. " ,gdd.usercode\n" +
  13828. " ,gdd.groutingdate\n" +
  13829. // 成型班长
  13830. " ,mu.username as MONITORName" +
  13831. " FROM tp_pm_groutingdailydetail gdd\n" +
  13832. " INNER JOIN tp_mst_goods g\n" +
  13833. " ON g.goodsid = gdd.goodsid\n" +
  13834. // 成型线
  13835. " LEFT JOIN tp_pc_groutingline gl" +
  13836. " ON gl.groutinglineid = GDD.GroutingLineID" +
  13837. // 成型班长
  13838. " LEFT JOIN tp_mst_user mu" +
  13839. " ON mu.userid = gl.MONITORID " +
  13840. " INNER JOIN tp_mst_goodstype gt\n" +
  13841. " ON g.goodstypeid = gt.goodstypeid\n" +
  13842. " WHERE gdd.accountid = :accountid\n" +
  13843. " AND gdd.valueflag = '1'\n" +
  13844. " AND gdd.groutingflag = '1'\n" +
  13845. " AND gdd.barcode IS NOT NULL\n" +
  13846. " AND gdd.scrapflag = '0'\n" +
  13847. " AND gdd.deliverflag = '0'\n" +
  13848. " AND (:LineID IS NULL OR gdd.groutinglineid = :LineID)\n" +
  13849. " AND (:UserID IS NULL OR gdd.UserID = :UserID)\n" +
  13850. " AND (:GoodsID IS NULL OR gdd.goodsid = :GoodsID)\n" +
  13851. " AND (:LineCode IS NULL OR instr(gdd.groutinglinecode, :LineCode) > 0)\n" +
  13852. " AND (:UserCode IS NULL OR instr(gdd.UserCode, :UserCode) > 0)\n" +
  13853. " AND (:GoodsCode IS NULL OR instr(gdd.GoodsCode, :GoodsCode) > 0)\n" +
  13854. " AND (:GoodsTypeCode IS NULL OR\n" +
  13855. " instr(gt.GoodstypeCode, :GoodsTypeCode) = 1)\n" +
  13856. " AND (:DateBegin IS NULL OR\n" +
  13857. " gdd.groutingdate BETWEEN :DateBegin AND :DateEnd)" +
  13858. " ORDER BY gdd.barcode\n" +
  13859. //" ,gdd.goodscode, gdrd.groutinglinecode, gdrd.usercode" +
  13860. "";
  13861. OracleParameter[] oracleParameter = new OracleParameter[]
  13862. {
  13863. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13864. new OracleParameter(":DateBegin",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13865. new OracleParameter(":DateEnd",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13866. new OracleParameter(":GoodsTypeCode",OracleDbType.NVarchar2, cre.Properties["GoodsTypeCode"], ParameterDirection.Input),
  13867. new OracleParameter(":GoodsCode",OracleDbType.NVarchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  13868. new OracleParameter(":LineCode",OracleDbType.NVarchar2, cre.Properties["LineCode"], ParameterDirection.Input),
  13869. new OracleParameter(":UserCode",OracleDbType.NVarchar2, cre.Properties["UserCode"], ParameterDirection.Input),
  13870. new OracleParameter(":GoodsID",OracleDbType.Int32, cre.Properties["GoodsID"], ParameterDirection.Input),
  13871. new OracleParameter(":LineID",OracleDbType.Int32, cre.Properties["LineID"], ParameterDirection.Input),
  13872. new OracleParameter(":UserID",OracleDbType.Int32, cre.Properties["UserID"], ParameterDirection.Input),
  13873. };
  13874. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13875. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13876. {
  13877. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13878. }
  13879. sre.Data = result;
  13880. return sre;
  13881. }
  13882. catch (Exception ex)
  13883. {
  13884. if (oracleConn.ConnState == ConnectionState.Open)
  13885. {
  13886. oracleConn.Close();
  13887. }
  13888. throw ex;
  13889. }
  13890. }
  13891. /// <summary>
  13892. /// 年度各工序月产量统计表
  13893. /// </summary>
  13894. /// <param name="cre"></param>
  13895. /// <param name="sUserInfo"></param>
  13896. /// <returns></returns>
  13897. public static ServiceResultEntity GetRPT030118Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  13898. {
  13899. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  13900. try
  13901. {
  13902. ServiceResultEntity sre = new ServiceResultEntity();
  13903. string sump = INIUtility.Read("ReportParameters", "RPT_030118", AppDomain.CurrentDomain.BaseDirectory + "Config.ini");
  13904. string sqlString = "select gt2.goodstypecode\n" +
  13905. " ,nvl2(gt2.goodstypename\n" +
  13906. " ,nvl2(t.procedureid\n" +
  13907. " ,gt2.goodstypename\n" +
  13908. " ,'小计[' || gt2.goodstypename || ']')\n" +
  13909. " ,'总计') goodstypename\n" +
  13910. " ,p.displayno\n" +
  13911. " ,decode(t.procedureid, null, '--', 0, '注浆', p.procedurename) procedurename\n" +
  13912. " ,sum(decode(t.mm, '12', t.pcount, 0)) m12\n" +
  13913. " ,sum(decode(t.mm, '01', t.pcount, 0)) m01\n" +
  13914. " ,sum(decode(t.mm, '02', t.pcount, 0)) m02\n" +
  13915. " ,sum(decode(t.mm, '03', t.pcount, 0)) m03\n" +
  13916. " ,sum(decode(t.mm, '04', t.pcount, 0)) m04\n" +
  13917. " ,sum(decode(t.mm, '05', t.pcount, 0)) m05\n" +
  13918. " ,sum(decode(t.mm, '06', t.pcount, 0)) m06\n" +
  13919. " ,sum(decode(t.mm, '07', t.pcount, 0)) m07\n" +
  13920. " ,sum(decode(t.mm, '08', t.pcount, 0)) m08\n" +
  13921. " ,sum(decode(t.mm, '09', t.pcount, 0)) m09\n" +
  13922. " ,sum(decode(t.mm, '10', t.pcount, 0)) m10\n" +
  13923. " ,sum(decode(t.mm, '11', t.pcount, 0)) m11\n" +
  13924. " ,sum(t.pcount) msum\n" +
  13925. " from (select --substr(gt.goodstypecode, 1, 6) gtcode2\n" +
  13926. " gt.goodstypecode\n" +
  13927. " ,0 procedureid\n" +
  13928. " ,to_char(pd.groutingdate, 'mm') mm\n" +
  13929. " ,count(*) pcount\n" +
  13930. " from tp_pm_groutingdailydetail pd\n" +
  13931. " inner join tp_mst_goods g\n" +
  13932. " on g.goodsid = pd.goodsid\n" +
  13933. " inner join tp_mst_goodstype gt\n" +
  13934. " on gt.goodstypeid = g.goodstypeid\n" +
  13935. " where pd.accountid = :accountid\n" +
  13936. " and pd.groutingflag = '1'\n" +
  13937. " and pd.groutingdate >= :begindate\n" +
  13938. " and pd.groutingdate < :enddate\n" +
  13939. " group by --substr(gt.goodstypecode, 1, 6)\n" +
  13940. " gt.goodstypecode\n" +
  13941. " ,to_char(pd.groutingdate, 'mm')\n" +
  13942. " union all\n" +
  13943. " select --substr(gt.goodstypecode, 1, 6) gtcode2\n" +
  13944. " gt.goodstypecode\n" +
  13945. " ,pd.procedureid\n" +
  13946. " ,to_char(pd.createtime, 'mm') mm\n" +
  13947. " ,count(*) pcount\n" +
  13948. " from tp_pm_productiondata pd\n" +
  13949. " inner join tp_mst_goods g\n" +
  13950. " on g.goodsid = pd.goodsid\n" +
  13951. " inner join tp_mst_goodstype gt\n" +
  13952. " on gt.goodstypeid = g.goodstypeid\n" +
  13953. " where pd.accountid = :accountid\n" +
  13954. " and pd.createtime >= :begindate\n" +
  13955. " and pd.createtime < :enddate\n" +
  13956. (string.IsNullOrWhiteSpace(sump) ? "" : " and pd.procedureid in (" + sump + ")\n") +
  13957. " group by --substr(gt.goodstypecode, 1, 6)\n" +
  13958. " gt.goodstypecode\n" +
  13959. " ,pd.procedureid\n" +
  13960. " ,to_char(pd.createtime, 'mm')" +
  13961. " union all\n" +
  13962. " select --substr(gt.goodstypecode, 1, 6) gtcode2\n" +
  13963. " gt.goodstypecode\n" +
  13964. " ,pd.procedureid\n" +
  13965. " ,to_char(pd.BACKOUTTIME, 'mm') mm\n" +
  13966. " ,count(*) pcount\n" +
  13967. " from tp_pm_productiondata pd\n" +
  13968. " inner join tp_mst_goods g\n" +
  13969. " on g.goodsid = pd.goodsid\n" +
  13970. " inner join tp_mst_goodstype gt\n" +
  13971. " on gt.goodstypeid = g.goodstypeid\n" +
  13972. " where pd.accountid = :accountid\n" +
  13973. " and pd.valueflag = '0'\n" +
  13974. " and pd.BACKOUTTIME >= :begindate\n" +
  13975. " and pd.BACKOUTTIME < :enddate\n" +
  13976. (string.IsNullOrWhiteSpace(sump) ? "" : " and pd.procedureid in (" + sump + ")\n") +
  13977. " group by --substr(gt.goodstypecode, 1, 6)\n" +
  13978. " gt.goodstypecode\n" +
  13979. " ,pd.procedureid\n" +
  13980. " ,to_char(pd.BACKOUTTIME, 'mm')) t\n" +
  13981. " inner join tp_mst_goodstype gt2\n" +
  13982. " on gt2.accountid = 1\n" +
  13983. " and gt2.goodstypecode = substr(t.goodstypecode, 1, 6) --t.gtcode2\n" +
  13984. " left join tp_pc_procedure p\n" +
  13985. " on p.procedureid = t.procedureid\n" +
  13986. " group by grouping sets((gt2.goodstypecode, gt2.goodstypename, p.displayno, p.procedurename, t.procedureid),(gt2.goodstypecode, gt2.goodstypename),())";
  13987. OracleParameter[] oracleParameter = new OracleParameter[]
  13988. {
  13989. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  13990. new OracleParameter(":begindate",OracleDbType.Date, cre.Properties["DateBegin"], ParameterDirection.Input),
  13991. new OracleParameter(":enddate",OracleDbType.Date, cre.Properties["DateEnd"], ParameterDirection.Input),
  13992. };
  13993. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  13994. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  13995. {
  13996. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  13997. }
  13998. sre.Data = result;
  13999. return sre;
  14000. }
  14001. catch (Exception ex)
  14002. {
  14003. throw ex;
  14004. }
  14005. finally
  14006. {
  14007. oracleConn?.Close();
  14008. }
  14009. }
  14010. /// <summary>
  14011. /// 半检返修缺陷汇总表
  14012. /// </summary>
  14013. /// <param name="cre"></param>
  14014. /// <param name="sUserInfo"></param>
  14015. /// <returns></returns>
  14016. public static ServiceResultEntity GetRPT030119Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14017. {
  14018. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14019. try
  14020. {
  14021. ServiceResultEntity sre = new ServiceResultEntity();
  14022. string sqlString = "select dp.defectpositionid\n" +
  14023. " ,dp.defectpositioncode\n" +
  14024. " ,dp.defectpositionname\n" +
  14025. " ,'D_' || dp.defectpositionid colname\n" +
  14026. " from tp_mst_scdefectposition dp\n" +
  14027. " where dp.valueflag = '1'\n" +
  14028. " and dp.accountid = " + sUserInfo.AccountID + "\n";
  14029. if (!string.IsNullOrWhiteSpace(cre.Properties["defectpositionIDS"] + ""))
  14030. {
  14031. sqlString += " and instr(','||'"+ cre.Properties["defectpositionIDS"] + "'||',', ','||dp.defectpositionid||',') > 0 \n";
  14032. }
  14033. sqlString += " order by dp.displayno";
  14034. DataTable scdTable = oracleConn.GetSqlResultToDt(sqlString);
  14035. if (scdTable == null || scdTable.Rows.Count == 0)
  14036. {
  14037. return sre;
  14038. }
  14039. List<string> pivotFor = new List<string>();
  14040. foreach (DataRow item in scdTable.Rows)
  14041. {
  14042. pivotFor.Add($"{item["defectpositionid"]} as {item["colname"]}");
  14043. }
  14044. List<OracleParameter> oracleParameters = new List<OracleParameter>();
  14045. oracleParameters.Add(new OracleParameter(":accountid", sUserInfo.AccountID));
  14046. sqlString = "select *\n" +
  14047. " from (select srd.defectid\n" +
  14048. " ,scd.defectcode\n" +
  14049. " ,scd.defectname\n" +
  14050. " ,nvl(srd.defectpositionid, 0) defectpositionid\n" +
  14051. " ,count(srd.semireworkdefectid) cc\n" +
  14052. " from TP_PM_SEMIREWORKDEFECT srd\n" +
  14053. " inner join TP_PM_SEMIREWORK sr\n" +
  14054. " on sr.SEMIREWORKID = srd.SEMIREWORKID\n" +
  14055. " left join tp_mst_semicheckdefect scd\n" +
  14056. " on scd.defectid = srd.defectid\n" +
  14057. " left join tp_mst_scdefectposition scdp\n" +
  14058. " on scdp.defectpositionid = srd.defectpositionid\n" +
  14059. " left join TP_MST_GOODS g on g.GOODSID = sr.GOODSID\n" + //xuwei add 2019-11-29
  14060. " left join TP_MST_GOODSTYPE gt on g.GOODSTYPEID = gt.GOODSTYPEID\n" + //xuwei add 2019-11-29
  14061. " where srd.valueflag = '1'\n" +
  14062. " and sr.BACKOUTFLAG = '0'\n" +
  14063. " and sr.valueflag = '1'\n" +
  14064. " and sr.accountid = :accountid\n";
  14065. // 半检日期
  14066. if (cre.Properties["SemireWorkTimeBegin"] != null)
  14067. {
  14068. sqlString += " and sr.SEMIREWORKTIME >= :SemireWorkTimeBegin\n";
  14069. oracleParameters.Add(new OracleParameter(":SemireWorkTimeBegin", cre.Properties["SemireWorkTimeBegin"]));
  14070. }
  14071. if (cre.Properties["SemireWorkTimeEnd"] != null)
  14072. {
  14073. sqlString += " and sr.SEMIREWORKTIME < :SemireWorkTimeEnd\n";
  14074. oracleParameters.Add(new OracleParameter(":SemireWorkTimeEnd", cre.Properties["SemireWorkTimeEnd"]));
  14075. }
  14076. // 产品编码 GOODSCODE
  14077. if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSCODE"]+""))
  14078. {
  14079. sqlString += " and instr(','||:GOODSCODE||',' , ','||sr.GOODSCODE||',') > 0 \n";
  14080. oracleParameters.Add(new OracleParameter(":GOODSCODE", cre.Properties["GOODSCODE"]));
  14081. }
  14082. // 成型工号 GROUTINGUSERCODE
  14083. if (!string.IsNullOrWhiteSpace(cre.Properties["GROUTINGUSERCODE"] + ""))
  14084. {
  14085. //xuwei modify 2019-11-13
  14086. //sqlString += " and instr(sr.GROUTINGUSERCODE,:GROUTINGUSERCODE) > 0 \n";
  14087. sqlString += " and instr(','||:GROUTINGUSERCODE||',' , ','||sr.GROUTINGUSERCODE||',') > 0 \n";
  14088. //xuwei end
  14089. oracleParameters.Add(new OracleParameter(":GROUTINGUSERCODE", cre.Properties["GROUTINGUSERCODE"]));
  14090. }
  14091. // 半检工号 SEMIREWORKUSERCODE
  14092. if (!string.IsNullOrWhiteSpace(cre.Properties["SEMIREWORKUSERCODE"] + ""))
  14093. {
  14094. //xuwei modify 2019-11-13
  14095. //sqlString += " and instr(sr.SEMIREWORKUSERCODE,:SEMIREWORKUSERCODE) > 0 \n";
  14096. sqlString += " and instr(','||:SEMIREWORKUSERCODE||',' , ','||sr.SEMIREWORKUSERCODE||',') > 0 \n";
  14097. //xuwei end
  14098. oracleParameters.Add(new OracleParameter(":SEMIREWORKUSERCODE", cre.Properties["SEMIREWORKUSERCODE"]));
  14099. }
  14100. // 缺陷位置 scdp.defectpositionname
  14101. if (!string.IsNullOrWhiteSpace(cre.Properties["defectpositionname"] + ""))
  14102. {
  14103. sqlString += " and instr(scdp.defectpositionname,:defectpositionname) > 0 \n";
  14104. oracleParameters.Add(new OracleParameter(":defectpositionname", cre.Properties["defectpositionname"]));
  14105. }
  14106. if (!string.IsNullOrWhiteSpace(cre.Properties["defectpositionIDS"] + ""))
  14107. {
  14108. sqlString += " and instr(','||:defectpositionIDS||',', ','||srd.defectpositionid||',') > 0 \n";
  14109. oracleParameters.Add(new OracleParameter(":defectpositionIDS", cre.Properties["defectpositionIDS"]));
  14110. }
  14111. // 缺陷名称 scd.defectname
  14112. if (!string.IsNullOrWhiteSpace(cre.Properties["defectname"] + ""))
  14113. {
  14114. sqlString += " and instr(scd.defectname,:defectname) > 0 \n";
  14115. oracleParameters.Add(new OracleParameter(":defectname", cre.Properties["defectname"]));
  14116. }
  14117. // 缺陷编码 scd.defectcode
  14118. if (!string.IsNullOrWhiteSpace(cre.Properties["defectcode"] + ""))
  14119. {
  14120. sqlString += " and scd.defectcode = :defectcode \n";
  14121. oracleParameters.Add(new OracleParameter(":defectcode", cre.Properties["defectcode"]));
  14122. }
  14123. //产品类别ID xuwei add 2019-11-29 g.GOODSTYPEID
  14124. if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSTYPEID"] + ""))
  14125. {
  14126. sqlString += " and instr(','||:GOODSTYPEID||',' , ','||g.GOODSTYPEID||',') > 0 \n";
  14127. oracleParameters.Add(new OracleParameter(":GOODSTYPEID", cre.Properties["GOODSTYPEID"]));
  14128. }
  14129. //产品类别Code xuwei add 2019-11-29 g.GOODSTYPECODE
  14130. if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSTYPECODE"] + ""))
  14131. {
  14132. sqlString += " and instr(gt.GOODSTYPECODE , :GOODSTYPECODE) = 1 \n";
  14133. oracleParameters.Add(new OracleParameter(":GOODSTYPECODE", cre.Properties["GOODSTYPECODE"]));
  14134. }
  14135. //返修工序 xuwei add 2019-11-29 sr.REWORKPROCEDUREID
  14136. if (!string.IsNullOrWhiteSpace(cre.Properties["REWORKPROCEDUREID"] + ""))
  14137. {
  14138. sqlString += " and instr(','||:REWORKPROCEDUREID||',' , ','||sr.REWORKPROCEDUREID||',') > 0 \n";
  14139. oracleParameters.Add(new OracleParameter(":REWORKPROCEDUREID", cre.Properties["REWORKPROCEDUREID"]));
  14140. }
  14141. sqlString +=
  14142. " group by grouping sets((srd.defectid, scd.defectcode, scd.defectname, srd.defectpositionid),(srd.defectid, scd.defectcode, scd.defectname),(srd.defectpositionid))) t\n" +
  14143. "pivot(sum(cc)\n" +
  14144. " for defectpositionid in("+string.Join(",", pivotFor) + ", 0 AS D_0))\n" +
  14145. " order by defectid";
  14146. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameters.ToArray());
  14147. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14148. {
  14149. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14150. return sre;
  14151. }
  14152. DataTable table = result.Tables[0];
  14153. DataRow dataRow = table.Rows[table.Rows.Count - 1];
  14154. dataRow["defectname"] = "合计";
  14155. foreach (DataRow item in scdTable.Rows)
  14156. {
  14157. string colname = item["colname"] + "";
  14158. if (table.Columns.Contains(colname))
  14159. {
  14160. if (dataRow[colname] == null || dataRow[colname] == DBNull.Value)
  14161. {
  14162. table.Columns.Remove(colname);
  14163. }
  14164. else
  14165. {
  14166. table.Columns[colname].Caption = item["defectpositionname"] + "";
  14167. }
  14168. }
  14169. }
  14170. table.Columns["D_0"].Caption = "合计";
  14171. sre.Data = result;
  14172. return sre;
  14173. }
  14174. catch (Exception ex)
  14175. {
  14176. throw ex;
  14177. }
  14178. finally
  14179. {
  14180. oracleConn?.Close();
  14181. }
  14182. }
  14183. /// <summary>
  14184. /// 模具注浆分析表
  14185. /// </summary>
  14186. /// <param name="cre"></param>
  14187. /// <param name="sUserInfo"></param>
  14188. /// <returns></returns>
  14189. public static ServiceResultEntity GetRPT040111Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14190. {
  14191. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  14192. try
  14193. {
  14194. ServiceResultEntity sre = new ServiceResultEntity();
  14195. OracleParameter[] oracleParameter = new OracleParameter[]
  14196. {
  14197. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14198. new OracleParameter("in_datetimebegin",OracleDbType.Date, cre.Properties["GroutingDateBegin"], ParameterDirection.Input),
  14199. new OracleParameter("in_datetimeend",OracleDbType.Date, cre.Properties["GroutingDateEnd"], ParameterDirection.Input),
  14200. new OracleParameter("in_GoodsCode",OracleDbType.Varchar2, cre.Properties["GoodsCode"], ParameterDirection.Input),
  14201. new OracleParameter("in_MouldBarcode",OracleDbType.Varchar2, cre.Properties["MouldBarcode"], ParameterDirection.Input),
  14202. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  14203. };
  14204. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_Mould_Groutingnum_AN", oracleParameter);
  14205. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14206. {
  14207. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14208. }
  14209. sre.Data = result;
  14210. oracleConn.Commit();
  14211. return sre;
  14212. }
  14213. catch (Exception ex)
  14214. {
  14215. if (oracleConn.ConnState == ConnectionState.Open)
  14216. {
  14217. oracleConn.Disconnect();
  14218. }
  14219. throw ex;
  14220. }
  14221. }
  14222. /// <summary>
  14223. /// 成检产品预算分析表
  14224. /// </summary>
  14225. /// <param name="cre"></param>
  14226. /// <param name="sUserInfo"></param>
  14227. /// <returns></returns>
  14228. public static ServiceResultEntity GetRPT040112Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14229. {
  14230. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  14231. try
  14232. {
  14233. ServiceResultEntity sre = new ServiceResultEntity();
  14234. OracleParameter[] oracleParameter = new OracleParameter[]
  14235. {
  14236. new OracleParameter("in_AccountID",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14237. new OracleParameter("in_InTimeBegin",OracleDbType.Date, cre.Properties["InTimeBegin"], ParameterDirection.Input),
  14238. new OracleParameter("in_InTimeEnd",OracleDbType.Date, cre.Properties["InTimeEnd"], ParameterDirection.Input),
  14239. new OracleParameter("in_OutTimeBegin",OracleDbType.Date, cre.Properties["OutTimeBegin"], ParameterDirection.Input),
  14240. new OracleParameter("in_OutTimeEnd",OracleDbType.Date, cre.Properties["OutTimeEnd"], ParameterDirection.Input),
  14241. new OracleParameter("in_KilnID",OracleDbType.Int32, cre.Properties["KilnID"], ParameterDirection.Input),
  14242. new OracleParameter("in_KilnCarNumBegin",OracleDbType.Int32, cre.Properties["KilnCarNumBegin"], ParameterDirection.Input),
  14243. new OracleParameter("in_KilnCarNumEnd",OracleDbType.Int32, cre.Properties["KilnCarNumEnd"], ParameterDirection.Input),
  14244. new OracleParameter("out_KilnInfo",OracleDbType.RefCursor, null, ParameterDirection.Output),
  14245. new OracleParameter("out_Data",OracleDbType.RefCursor, null, ParameterDirection.Output),
  14246. };
  14247. DataSet result = oracleConn.ExecStoredProcedure("PRO_RPT_ExpectFinishedProduct", oracleParameter);
  14248. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14249. {
  14250. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14251. }
  14252. sre.Data = result;
  14253. oracleConn.Commit();
  14254. return sre;
  14255. }
  14256. catch (Exception ex)
  14257. {
  14258. if (oracleConn.ConnState == ConnectionState.Open)
  14259. {
  14260. oracleConn.Disconnect();
  14261. }
  14262. throw ex;
  14263. }
  14264. }
  14265. /// <summary>
  14266. /// 成检产品预算分析表-设置
  14267. /// </summary>
  14268. /// <param name="cre"></param>
  14269. /// <param name="sUserInfo"></param>
  14270. /// <returns></returns>
  14271. public static ServiceResultEntity GetRPT04011201Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14272. {
  14273. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14274. try
  14275. {
  14276. ServiceResultEntity sre = new ServiceResultEntity();
  14277. string sqlString = "SELECT s.settingkey, s.procedureid, p.procedurecode, p.procedurename\n" +
  14278. " FROM tp_qco_prosetting s\n" +
  14279. " LEFT JOIN tp_pc_procedure p\n" +
  14280. " ON s.procedureid = p.procedureid\n" +
  14281. " WHERE s.accountid = :accountid";
  14282. OracleParameter[] oracleParameter = new OracleParameter[]
  14283. {
  14284. new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14285. };
  14286. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  14287. sqlString = "SELECT k.kilnid, k.kilncode, k.kilnname, k.turnoverinterval\n" +
  14288. " FROM tp_mst_kiln k\n" +
  14289. " WHERE k.accountid = :accountid\n" +
  14290. " AND k.valueflag = '1'";
  14291. DataTable dt = oracleConn.GetSqlResultToDt(sqlString, oracleParameter);
  14292. result.Tables.Add(dt);
  14293. sre.Data = result;
  14294. return sre;
  14295. }
  14296. catch (Exception ex)
  14297. {
  14298. if (oracleConn.ConnState == ConnectionState.Open)
  14299. {
  14300. oracleConn.Close();
  14301. }
  14302. throw ex;
  14303. }
  14304. }
  14305. /// <summary>
  14306. /// 成检产品预算分析表-设置
  14307. /// </summary>
  14308. /// <param name="cre"></param>
  14309. /// <param name="sUserInfo"></param>
  14310. /// <returns></returns>
  14311. public static ServiceResultEntity SetRPT04011201Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14312. {
  14313. IDBTransaction oracleConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  14314. try
  14315. {
  14316. ServiceResultEntity sre = new ServiceResultEntity();
  14317. OracleParameter[] oracleParameter = null;
  14318. string sql = "update tp_qco_prosetting s set s.procedureid=:procedureid, s.procedurecode=:procedurecode\n" +
  14319. "where s.accountid=:accountid and s.settingkey=:settingkey";
  14320. foreach (DataRow item in cre.Data.Tables[0].Rows)
  14321. {
  14322. oracleParameter = new OracleParameter[]
  14323. {
  14324. new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14325. new OracleParameter("procedureid",OracleDbType.Int32, item["procedureid"], ParameterDirection.Input),
  14326. new OracleParameter("procedurecode",OracleDbType.NVarchar2, item["procedurecode"], ParameterDirection.Input),
  14327. new OracleParameter("settingkey",OracleDbType.NVarchar2, item["settingkey"], ParameterDirection.Input),
  14328. };
  14329. oracleConn.ExecuteNonQuery(sql, oracleParameter);
  14330. }
  14331. sql = "update tp_mst_kiln k set k.turnoverinterval=:turnoverinterval\n" +
  14332. "where k.accountid=:accountid and k.kilnid=:kilnid";
  14333. foreach (DataRow item in cre.Data.Tables[1].Rows)
  14334. {
  14335. oracleParameter = new OracleParameter[]
  14336. {
  14337. new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14338. new OracleParameter("turnoverinterval",OracleDbType.Int32, item["turnoverinterval"], ParameterDirection.Input),
  14339. new OracleParameter("kilnid",OracleDbType.Int32, item["kilnid"], ParameterDirection.Input),
  14340. };
  14341. oracleConn.ExecuteNonQuery(sql, oracleParameter);
  14342. }
  14343. oracleConn.Commit();
  14344. return sre;
  14345. }
  14346. catch (Exception ex)
  14347. {
  14348. if (oracleConn.ConnState == ConnectionState.Open)
  14349. {
  14350. oracleConn.Disconnect();
  14351. }
  14352. throw ex;
  14353. }
  14354. }
  14355. /// <summary>
  14356. /// 各工序质量表-恒洁三水
  14357. /// </summary>
  14358. /// <param name="cre"></param>
  14359. /// <param name="sUserInfo"></param>
  14360. /// <returns></returns>
  14361. public static ServiceResultEntity GetRPT040113Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14362. {
  14363. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14364. try
  14365. {
  14366. int p1ID = 11; // 成检交接工序
  14367. int p2ID = 12; // 成检登记工序
  14368. string gtcode2 = cre.Properties["gtcode2"] + "";
  14369. if (gtcode2 != "001001" && gtcode2 != "001002")
  14370. {
  14371. gtcode2 = "[ALL]";
  14372. }
  14373. // DEFECTDEDUCTIONNUM 缺陷扣除数 1,2,5
  14374. // goodsleveltypeid 次品 7
  14375. string sqlString = "select t.*\n" +
  14376. " ,gt.goodstypename\n" +
  14377. " ,nvl(outk.outkcount, 0) outkcount\n" +
  14378. " ,nvl(outk.outkcount, 0) - t.defectcount cc\n" +
  14379. " ,decode(nvl(outk.outkcount, 0)\n" +
  14380. " ,0\n" +
  14381. " ,to_number(null)\n" +
  14382. " ,round((nvl(outk.outkcount, 0) - t.defectcount) /\n" +
  14383. " nvl(outk.outkcount, 0)\n" +
  14384. " ,4)) ccp\n" +
  14385. " from (select 10 pcode\n" +
  14386. " ,'成型' pname\n" +
  14387. " ,gt2.goodstypecode gtcode2\n" +
  14388. " ,count(*) defectcount\n" +
  14389. " from tp_pm_defect dd\n" +
  14390. " inner join tp_pm_productiondata pd\n" +
  14391. " on dd.productiondataid = pd.productiondataid\n" +
  14392. " inner join tp_mst_goods g\n" +
  14393. " on dd.goodsid = g.goodsid\n" +
  14394. " inner join tp_mst_goodstype gt\n" +
  14395. " on gt.goodstypeid = g.goodstypeid\n" +
  14396. " inner join tp_mst_goodstype gt2\n" +
  14397. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14398. " where dd.valueflag = '1'\n" +
  14399. " and dd.accountid = :accountid\n" +
  14400. " and pd.goodsleveltypeid = 7\n" + // 次品
  14401. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14402. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14403. " and dd.procedureid = :p2ID\n" +
  14404. " and dd.checktime >= :timebegin\n" +
  14405. " and dd.checktime < :timeend\n" +
  14406. ////" -- 交坯、干补\n" +
  14407. //" and dd.defectprocedureid in (1, 17, 18)\n" +
  14408. " 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" +
  14409. " 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" +
  14410. " )\n" +
  14411. " group by gt2.goodstypecode\n" +
  14412. " union all\n" +
  14413. " select 20 pcode\n" +
  14414. " ,'改洗' pname\n" +
  14415. " ,gt2.goodstypecode gtcode2\n" +
  14416. " ,count(*) defectcount\n" +
  14417. " from tp_pm_defect dd\n" +
  14418. " inner join tp_pm_productiondata pd\n" +
  14419. " on dd.productiondataid = pd.productiondataid\n" +
  14420. " inner join tp_mst_goods g\n" +
  14421. " on dd.goodsid = g.goodsid\n" +
  14422. " inner join tp_mst_goodstype gt\n" +
  14423. " on gt.goodstypeid = g.goodstypeid\n" +
  14424. " inner join tp_mst_goodstype gt2\n" +
  14425. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14426. " where dd.valueflag = '1'\n" +
  14427. " and dd.accountid = :accountid\n" +
  14428. " and pd.goodsleveltypeid = 7\n" + // 次品
  14429. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14430. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14431. " and dd.procedureid = :p2ID\n" +
  14432. " and dd.checktime >= :timebegin\n" +
  14433. " and dd.checktime < :timeend\n" +
  14434. ////" -- 改洗、吹风\n" +
  14435. //" and dd.defectprocedureid in (2, 62)\n" +
  14436. ////" -- 除不平\n" +
  14437. //" and dd.defectid not in (91, 240)\n" +
  14438. " and ((gt2.goodstypecode='001001' and dd.defectid in (91,94,144,113,145,114,183))\n" +
  14439. " or (gt2.goodstypecode='001002' and dd.defectid in (91,93,94,144,113,145,114))\n" +
  14440. " )\n" +
  14441. " group by gt2.goodstypecode\n" +
  14442. " union all\n" +
  14443. " select 30 pcode\n" +
  14444. " ,'二检' pname\n" +
  14445. " ,gt2.goodstypecode gtcode2\n" +
  14446. " ,count(*) defectcount\n" +
  14447. " from tp_pm_defect dd\n" +
  14448. " inner join tp_pm_productiondata pd\n" +
  14449. " on dd.productiondataid = pd.productiondataid\n" +
  14450. " inner join tp_mst_goods g\n" +
  14451. " on dd.goodsid = g.goodsid\n" +
  14452. " inner join tp_mst_goodstype gt\n" +
  14453. " on gt.goodstypeid = g.goodstypeid\n" +
  14454. " inner join tp_mst_goodstype gt2\n" +
  14455. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14456. " where dd.valueflag = '1'\n" +
  14457. " and dd.accountid = :accountid\n" +
  14458. " and pd.goodsleveltypeid = 7\n" + // 次品
  14459. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14460. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14461. " and dd.procedureid = :p2ID\n" +
  14462. " and dd.checktime >= :timebegin\n" +
  14463. " and dd.checktime < :timeend\n" +
  14464. ////" -- 二检\n" +
  14465. //" and dd.defectprocedureid in (61)\n" +
  14466. " and ((gt2.goodstypecode='001001' and dd.defectid in (89,91,92,93,94,106,115,163,159,133,166,164))\n" +
  14467. " or (gt2.goodstypecode='001002' and dd.defectid in (89,91,92,93,94,106,115,163,133,192,166,164))\n" +
  14468. " )\n" +
  14469. " group by gt2.goodstypecode\n" +
  14470. " union all\n" +
  14471. " select 40 pcode\n" +
  14472. " ,'施釉' pname\n" +
  14473. " ,gt2.goodstypecode gtcode2\n" +
  14474. " ,count(*) defectcount\n" +
  14475. " from tp_pm_defect dd\n" +
  14476. " inner join tp_pm_productiondata pd\n" +
  14477. " on dd.productiondataid = pd.productiondataid\n" +
  14478. " inner join tp_mst_goods g\n" +
  14479. " on dd.goodsid = g.goodsid\n" +
  14480. " inner join tp_mst_goodstype gt\n" +
  14481. " on gt.goodstypeid = g.goodstypeid\n" +
  14482. " inner join tp_mst_goodstype gt2\n" +
  14483. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14484. " where dd.valueflag = '1'\n" +
  14485. " and dd.accountid = :accountid\n" +
  14486. " and pd.goodsleveltypeid = 7\n" + // 次品
  14487. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14488. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14489. " and dd.procedureid = :p2ID\n" +
  14490. " and dd.checktime >= :timebegin\n" +
  14491. " and dd.checktime < :timeend\n" +
  14492. ////" -- 施釉\n" +
  14493. //" and dd.defectprocedureid in (3, 4)\n" +
  14494. ////" -- 除铁、铜脏\n" +
  14495. //" and dd.defectid not in (827, 829, 398, 399, 830, 400)\n" +
  14496. " 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" +
  14497. " 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" +
  14498. " )\n" +
  14499. " group by gt2.goodstypecode\n" +
  14500. " union all\n" +
  14501. " select 50 pcode\n" +
  14502. " ,'刮登' pname\n" +
  14503. " ,gt2.goodstypecode gtcode2\n" +
  14504. " ,count(*) defectcount\n" +
  14505. " from tp_pm_defect dd\n" +
  14506. " inner join tp_pm_productiondata pd\n" +
  14507. " on dd.productiondataid = pd.productiondataid\n" +
  14508. " inner join tp_mst_goods g\n" +
  14509. " on dd.goodsid = g.goodsid\n" +
  14510. " inner join tp_mst_goodstype gt\n" +
  14511. " on gt.goodstypeid = g.goodstypeid\n" +
  14512. " inner join tp_mst_goodstype gt2\n" +
  14513. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14514. " where dd.valueflag = '1'\n" +
  14515. " and dd.accountid = :accountid\n" +
  14516. " and pd.goodsleveltypeid = 7\n" + // 次品
  14517. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14518. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14519. " and dd.procedureid = :p2ID\n" +
  14520. " and dd.checktime >= :timebegin\n" +
  14521. " and dd.checktime < :timeend\n" +
  14522. ////" -- 登窑、入窑、卸窑\n" +
  14523. //" and dd.defectprocedureid in (5, 9, 10)\n" +
  14524. " 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" +
  14525. " 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" +
  14526. " )\n" +
  14527. " group by gt2.goodstypecode\n" +
  14528. " union all\n" +
  14529. " select 60 pcode\n" +
  14530. " ,'烧成' pname\n" +
  14531. " ,gt2.goodstypecode gtcode2\n" +
  14532. " ,count(*) defectcount\n" +
  14533. " from tp_pm_defect dd\n" +
  14534. " inner join tp_pm_productiondata pd\n" +
  14535. " on dd.productiondataid = pd.productiondataid\n" +
  14536. " inner join tp_mst_goods g\n" +
  14537. " on dd.goodsid = g.goodsid\n" +
  14538. " inner join tp_mst_goodstype gt\n" +
  14539. " on gt.goodstypeid = g.goodstypeid\n" +
  14540. " inner join tp_mst_goodstype gt2\n" +
  14541. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14542. " where dd.valueflag = '1'\n" +
  14543. " and dd.accountid = :accountid\n" +
  14544. " and pd.goodsleveltypeid = 7\n" + // 次品
  14545. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14546. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14547. " and dd.procedureid = :p2ID\n" +
  14548. " and dd.checktime >= :timebegin\n" +
  14549. " and dd.checktime < :timeend\n" +
  14550. ////" -- 惊风、毛针孔、烧裂、窑脏、釉泡\n" +
  14551. //" and dd.defectid in (385\n" +
  14552. //" ,203\n" +
  14553. //" ,836\n" +
  14554. //" ,234\n" +
  14555. //" ,384\n" +
  14556. //" ,202\n" +
  14557. //" ,835\n" +
  14558. //" ,390\n" +
  14559. //" ,818\n" +
  14560. //" ,389\n" +
  14561. //" ,204\n" +
  14562. //" ,814\n" +
  14563. //" ,837\n" +
  14564. //" ,387)\n" +
  14565. " and dd.defectid in (234,385,386,387,388,389,390)\n" +
  14566. //" 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" +
  14567. //" 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" +
  14568. //" )\n" +
  14569. " group by gt2.goodstypecode\n" +
  14570. " union all\n" +
  14571. " select 70 pcode\n" +
  14572. " ,'杂锈点' pname\n" +
  14573. " ,gt2.goodstypecode gtcode2\n" +
  14574. " ,count(*) defectcount\n" +
  14575. " from tp_pm_defect dd\n" +
  14576. " inner join tp_pm_productiondata pd\n" +
  14577. " on dd.productiondataid = pd.productiondataid\n" +
  14578. " inner join tp_mst_goods g\n" +
  14579. " on dd.goodsid = g.goodsid\n" +
  14580. " inner join tp_mst_goodstype gt\n" +
  14581. " on gt.goodstypeid = g.goodstypeid\n" +
  14582. " inner join tp_mst_goodstype gt2\n" +
  14583. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14584. " where dd.valueflag = '1'\n" +
  14585. " and dd.accountid = :accountid\n" +
  14586. " and pd.goodsleveltypeid = 7\n" + // 次品
  14587. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14588. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14589. " and dd.procedureid = :p2ID\n" +
  14590. " and dd.checktime >= :timebegin\n" +
  14591. " and dd.checktime < :timeend\n" +
  14592. ////" -- 铁脏、铜脏、窑脏、釉脏\n" +
  14593. //" and dd.defectid in\n" +
  14594. //" (730, 818, 827, 829, 830, 389, 398, 399, 400, 170)\n" +
  14595. " and dd.defectid in (170,389,398,399)\n" +
  14596. //" 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" +
  14597. //" 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" +
  14598. //" )\n" +
  14599. " group by gt2.goodstypecode\n" +
  14600. " union all\n" +
  14601. " select 80 pcode\n" +
  14602. " ,'其他' pname\n" +
  14603. " ,gt2.goodstypecode gtcode2\n" +
  14604. " ,count(*) defectcount\n" +
  14605. " from tp_pm_defect dd\n" +
  14606. " inner join tp_pm_productiondata pd\n" +
  14607. " on dd.productiondataid = pd.productiondataid\n" +
  14608. " inner join tp_mst_goods g\n" +
  14609. " on dd.goodsid = g.goodsid\n" +
  14610. " inner join tp_mst_goodstype gt\n" +
  14611. " on gt.goodstypeid = g.goodstypeid\n" +
  14612. " inner join tp_mst_goodstype gt2\n" +
  14613. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14614. " where dd.valueflag = '1'\n" +
  14615. " and dd.accountid = :accountid\n" +
  14616. " and pd.goodsleveltypeid = 7\n" + // 次品
  14617. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14618. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14619. " and dd.procedureid = :p2ID\n" +
  14620. " and dd.checktime >= :timebegin\n" +
  14621. " and dd.checktime < :timeend\n" +
  14622. ////" -- 成检撞伤、炸坯、炸裂\n" +
  14623. //" and dd.defectid in (393, 180, 394, 395)\n" +
  14624. " and ((gt2.goodstypecode='001001' and dd.defectid in (402,393,395,396,397))\n" +
  14625. " or (gt2.goodstypecode='001002' and dd.defectid in (402,394,393,395,396,397))\n" +
  14626. " )\n" +
  14627. " group by gt2.goodstypecode) t\n" +
  14628. " left join (select gt2.goodstypecode gtcode2\n" +
  14629. " ,count(*) outkcount\n" +
  14630. " from tp_pm_productiondata pd\n" +
  14631. " inner join tp_mst_goods g\n" +
  14632. " on pd.goodsid = g.goodsid\n" +
  14633. " inner join tp_mst_goodstype gt\n" +
  14634. " on gt.goodstypeid = g.goodstypeid\n" +
  14635. " inner join tp_mst_goodstype gt2\n" +
  14636. " on length(gt2.goodstypecode)=6 and gt2.accountid = gt.accountid and instr(gt.goodstypecode, gt2.goodstypecode)=1\n" +
  14637. " where pd.valueflag = '1'\n" +
  14638. " and pd.accountid = :accountid\n" +
  14639. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14640. " and pd.procedureid = :p1ID\n" +
  14641. " and pd.createtime >= :timebegin\n" +
  14642. " and pd.createtime < :timeend\n" +
  14643. " group by gt2.goodstypecode) outk\n" +
  14644. " on t.gtcode2 = outk.gtcode2\n" +
  14645. " inner join tp_mst_goodstype gt\n" +
  14646. " on gt.goodstypecode = t.gtcode2\n" +
  14647. " and gt.accountid = :accountid\n" +
  14648. " order by t.pcode, t.gtcode2";
  14649. OracleParameter[] oracleParameter = new OracleParameter[]
  14650. {
  14651. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14652. new OracleParameter(":p1ID",OracleDbType.Int32, p1ID, ParameterDirection.Input),
  14653. new OracleParameter(":p2ID",OracleDbType.Int32, p2ID, ParameterDirection.Input),
  14654. new OracleParameter(":timebegin",OracleDbType.Date, cre.Properties["timebegin"], ParameterDirection.Input),
  14655. new OracleParameter(":timeend",OracleDbType.Date, cre.Properties["timeend"], ParameterDirection.Input),
  14656. new OracleParameter(":gtcode2",OracleDbType.Varchar2, gtcode2, ParameterDirection.Input),
  14657. };
  14658. ServiceResultEntity sre = new ServiceResultEntity();
  14659. sre.Data = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  14660. if (sre.Data != null && sre.Data.Tables.Count > 0 && sre.Data.Tables[0].Rows.Count > 0)
  14661. {
  14662. sre.Data.Tables[0].TableName = "S";
  14663. cre.Properties["pcode"] = sre.Data.Tables[0].Rows[0]["pcode"];
  14664. cre.Properties["pname"] = sre.Data.Tables[0].Rows[0]["pname"];
  14665. cre.Properties["gtcode2"] = sre.Data.Tables[0].Rows[0]["gtcode2"];
  14666. ServiceResultEntity sre1 = GetRPT040113DData(cre, sUserInfo);
  14667. if (sre1 != null&& sre1.Data != null&& sre1.Data.Tables.Count > 0)
  14668. {
  14669. sre1.Data.Tables[0].TableName = "D";
  14670. sre.Data.Merge(sre1.Data.Tables[0]);
  14671. }
  14672. }
  14673. sqlString =
  14674. "select t.gtcode2\n" +
  14675. " ,nvl(t.gtname2, '合计') gtname2\n" +
  14676. " ,sum(t.outk) outk\n" +
  14677. " ,sum(t.cipin) cipin\n" +
  14678. " ,sum(t.outk) - sum(t.cipin) hege\n" +
  14679. " ,decode(sum(t.outk), 0, to_number(null), round(1 - (sum(t.cipin) / sum(t.outk)),4)) hegep\n" +
  14680. " from (select gt2.goodstypecode gtcode2\n" +
  14681. " ,gt2.goodstypename gtname2\n" +
  14682. " ,nvl(sum(decode(pd.procedureid, :p1ID, 1, 0)), 0) outk\n" +
  14683. " ,nvl(sum(case\n" +
  14684. " when pd.procedureid = :p2ID and\n" +
  14685. " pd.goodsleveltypeid in (6, 7) then\n" +
  14686. " 1\n" +
  14687. " else\n" +
  14688. " 0\n" +
  14689. " end)\n" +
  14690. " ,0) cipin\n" +
  14691. " from tp_pm_productiondata pd\n" +
  14692. " inner join tp_mst_goods g\n" +
  14693. " on pd.goodsid = g.goodsid\n" +
  14694. " inner join tp_mst_goodstype gt\n" +
  14695. " on g.goodstypeid = gt.goodstypeid\n" +
  14696. " inner join tp_mst_goodstype gt2\n" +
  14697. " on length(gt2.goodstypecode) = 6\n" +
  14698. " and gt2.accountid = gt.accountid\n" +
  14699. " and instr(gt.goodstypecode, gt2.goodstypecode) = 1\n" +
  14700. " where pd.valueflag = '1'\n" +
  14701. " and pd.accountid = :accountid\n" +
  14702. " and (:gtcode2 = '[ALL]' or gt2.goodstypecode = :gtcode2)\n" +
  14703. " and (pd.procedureid = :p1ID or pd.procedureid = :p2ID)\n" +
  14704. //" and pd.checktime > date '2018-01-01'\n" +
  14705. " and pd.checktime >= :timebegin\n" +
  14706. " and pd.checktime < :timeend\n" +
  14707. " group by gt2.goodstypecode, gt2.goodstypename) t\n" +
  14708. " group by grouping sets((t.gtcode2, t.gtname2),())";
  14709. oracleParameter = new OracleParameter[]
  14710. {
  14711. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14712. new OracleParameter(":p1ID",OracleDbType.Int32, p1ID, ParameterDirection.Input),
  14713. new OracleParameter(":p2ID",OracleDbType.Int32, p2ID, ParameterDirection.Input),
  14714. new OracleParameter(":timebegin",OracleDbType.Date, cre.Properties["timebegin"], ParameterDirection.Input),
  14715. new OracleParameter(":timeend",OracleDbType.Date, cre.Properties["timeend"], ParameterDirection.Input),
  14716. new OracleParameter(":gtcode2",OracleDbType.Varchar2, gtcode2, ParameterDirection.Input),
  14717. };
  14718. DataTable alldata = oracleConn.GetSqlResultToDt(sqlString, oracleParameter);
  14719. alldata.TableName = "A";
  14720. DataTable data = sre.Data.Tables[0];
  14721. foreach (DataRow item in alldata.Rows)
  14722. {
  14723. data.Rows.Add(99, "总计", item["gtcode2"], item["cipin"], item["gtname2"], item["outk"], item["hege"], item["hegep"]);
  14724. }
  14725. return sre;
  14726. }
  14727. catch (Exception ex)
  14728. {
  14729. if (oracleConn.ConnState == ConnectionState.Open)
  14730. {
  14731. oracleConn.Close();
  14732. }
  14733. throw ex;
  14734. }
  14735. }
  14736. /// <summary>
  14737. /// 各工序质量表-缺陷明细-恒洁三水
  14738. /// </summary>
  14739. /// <param name="cre"></param>
  14740. /// <param name="sUserInfo"></param>
  14741. /// <returns></returns>
  14742. public static ServiceResultEntity GetRPT040113DData(ClientRequestEntity cre, SUserInfo sUserInfo)
  14743. {
  14744. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14745. try
  14746. {
  14747. //int p1ID = 11; // 成检交接工序
  14748. int p2ID = 12; // 成检登记工序
  14749. int pcode = Convert.ToInt32(cre.Properties["pcode"]);
  14750. string sqlString =
  14751. "select :pcode pcode\n" +
  14752. " ,:pname pname\n" +
  14753. " ,gt2.goodstypecode gtcode2\n" +
  14754. " ,gt2.goodstypename gtname2\n" +
  14755. " ,dd.defectcode\n" +
  14756. " ,dd.defectname\n" +
  14757. " ,count(*) defectcount\n" +
  14758. " from tp_pm_defect dd\n" +
  14759. //"--inner join tp_mst_defect md on md.defectid=dd.defectid\n" +
  14760. " inner join tp_mst_goods g\n" +
  14761. " on dd.goodsid = g.goodsid\n" +
  14762. " inner join tp_pm_productiondata pd\n" +
  14763. " on dd.productiondataid = pd.productiondataid\n" +
  14764. " inner join tp_mst_goodstype gt\n" +
  14765. " on gt.goodstypeid = g.goodstypeid\n" +
  14766. " inner join tp_mst_goodstype gt2\n" +
  14767. " on gt2.goodstypecode = substr(gt.goodstypecode, 1, 6)\n" +
  14768. " and gt2.accountid = :accountid\n" +
  14769. " where dd.valueflag = '1'\n" +
  14770. " and dd.accountid = :accountid\n" +
  14771. " and pd.goodsleveltypeid = 7\n" + // 次品
  14772. " and dd.DEFECTDEDUCTIONNUM in (1,2,5)\n" + // 缺陷扣除数 1,2,5
  14773. " and dd.procedureid = :p2ID\n" +
  14774. " and gt2.goodstypecode = :gtcode2\n" +
  14775. " and dd.checktime >= :timebegin\n" +
  14776. " and dd.checktime < :timeend\n";
  14777. switch (pcode)
  14778. {
  14779. case 10:
  14780. ////" -- 交坯、干补\n" +
  14781. //sqlString += " and dd.defectprocedureid in (1, 17, 18)\n";
  14782. sqlString +=
  14783. " 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" +
  14784. " 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" +
  14785. " )\n";
  14786. break;
  14787. case 20:
  14788. sqlString +=
  14789. ////" -- 改洗、吹风\n" +
  14790. //" and dd.defectprocedureid in (2, 62)\n" +
  14791. ////" -- 除不平\n" +
  14792. //" and dd.defectid not in (91, 240)\n";
  14793. " and ((gt2.goodstypecode='001001' and dd.defectid in (91,94,144,113,145,114,183))\n" +
  14794. " or (gt2.goodstypecode='001002' and dd.defectid in (91,93,94,144,113,145,114))\n" +
  14795. " )\n";
  14796. break;
  14797. case 30:
  14798. sqlString +=
  14799. ////" -- 二检\n" +
  14800. //" and dd.defectprocedureid in (61)\n";
  14801. " and ((gt2.goodstypecode='001001' and dd.defectid in (89,91,92,93,94,106,115,163,159,133,166,164))\n" +
  14802. " or (gt2.goodstypecode='001002' and dd.defectid in (89,91,92,93,94,106,115,163,133,192,166,164))\n" +
  14803. " )\n";
  14804. break;
  14805. case 40:
  14806. sqlString +=
  14807. ////" -- 施釉\n" +
  14808. //" and dd.defectprocedureid in (3, 4)\n" +
  14809. ////" -- 除铁、铜脏\n" +
  14810. //" and dd.defectid not in (827, 829, 398, 399, 830, 400)\n";
  14811. " 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" +
  14812. " 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" +
  14813. " )\n";
  14814. break;
  14815. case 50:
  14816. sqlString +=
  14817. ////" -- 登窑、入窑、卸窑\n" +
  14818. //" and dd.defectprocedureid in (5, 9, 10)\n";
  14819. " 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" +
  14820. " 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" +
  14821. " )\n";
  14822. break;
  14823. case 60:
  14824. sqlString +=
  14825. ////" -- 惊风、毛针孔、烧裂、窑脏、釉泡\n" +
  14826. //" and dd.defectid in (385\n" +
  14827. //" ,203\n" +
  14828. //" ,836\n" +
  14829. //" ,234\n" +
  14830. //" ,384\n" +
  14831. //" ,202\n" +
  14832. //" ,835\n" +
  14833. //" ,390\n" +
  14834. //" ,818\n" +
  14835. //" ,389\n" +
  14836. //" ,204\n" +
  14837. //" ,814\n" +
  14838. //" ,837\n" +
  14839. //" ,387)\n";
  14840. " and dd.defectid in (234,385,386,387,388,389,390)\n";
  14841. break;
  14842. case 70:
  14843. sqlString +=
  14844. ////" -- 铁脏、铜脏、窑脏、釉脏\n" +
  14845. //" and dd.defectid in\n" +
  14846. //" (730, 818, 827, 829, 830, 389, 398, 399, 400, 170)\n";
  14847. " and dd.defectid in (170,389,398,399)\n";
  14848. break;
  14849. case 80:
  14850. sqlString +=
  14851. ////" -- 成检撞伤、炸坯、炸裂\n" +
  14852. //" and dd.defectid in (393, 180, 394, 395)\n";
  14853. " and ((gt2.goodstypecode='001001' and dd.defectid in (402,393,395,396,397))\n" +
  14854. " or (gt2.goodstypecode='001002' and dd.defectid in (402,394,393,395,396,397))\n" +
  14855. " )\n";
  14856. break;
  14857. default:
  14858. break;
  14859. }
  14860. sqlString +=
  14861. " group by gt2.goodstypecode\n" +
  14862. " ,gt2.goodstypename\n" +
  14863. " ,dd.defectcode\n" +
  14864. " ,dd.defectname\n" +
  14865. " order by dd.defectcode";
  14866. OracleParameter[] oracleParameter = new OracleParameter[]
  14867. {
  14868. new OracleParameter("accountid",OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  14869. //new OracleParameter("p1ID",OracleDbType.Int32, p1ID, ParameterDirection.Input),
  14870. new OracleParameter("p2ID",OracleDbType.Int32, p2ID, ParameterDirection.Input),
  14871. new OracleParameter("pcode",OracleDbType.Int32, pcode, ParameterDirection.Input),
  14872. new OracleParameter("pname",OracleDbType.NVarchar2, cre.Properties["pname"], ParameterDirection.Input),
  14873. new OracleParameter("gtcode2",OracleDbType.Varchar2, cre.Properties["gtcode2"], ParameterDirection.Input),
  14874. new OracleParameter("timebegin",OracleDbType.Date, cre.Properties["timebegin"], ParameterDirection.Input),
  14875. new OracleParameter("timeend",OracleDbType.Date, cre.Properties["timeend"], ParameterDirection.Input),
  14876. };
  14877. ServiceResultEntity sre = new ServiceResultEntity();
  14878. sre.Data = oracleConn.GetSqlResultToDs(sqlString, oracleParameter);
  14879. return sre;
  14880. }
  14881. catch (Exception ex)
  14882. {
  14883. if (oracleConn.ConnState == ConnectionState.Open)
  14884. {
  14885. oracleConn.Close();
  14886. }
  14887. throw ex;
  14888. }
  14889. }
  14890. /// <summary>
  14891. /// 综合合格率分析表-半成品报废率分析表
  14892. /// </summary>
  14893. /// <param name="cre"></param>
  14894. /// <param name="sUserInfo"></param>
  14895. /// <returns></returns>
  14896. public static ServiceResultEntity GetRPT040114_1Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14897. {
  14898. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14899. try
  14900. {
  14901. ServiceResultEntity sre = new ServiceResultEntity();
  14902. List<OracleParameter> oracleParameters = new List<OracleParameter>();
  14903. oracleParameters.Add(new OracleParameter(":accountid", sUserInfo.AccountID));
  14904. string sqlString = "select g.goodscode\n" +
  14905. " ,tt.d_num\n" +
  14906. " ,tt.b_num\n" +
  14907. " ,tt.f_num\n" +
  14908. " ,tt.s_num\n" +
  14909. " ,decode(tt.d_num\n" +
  14910. " ,0\n" +
  14911. " ,to_number(null)\n" +
  14912. " ,round((tt.b_num + tt.f_num + tt.s_num) / tt.d_num,4)) sp_r\n" +
  14913. " from (select t.goodsid\n" +
  14914. " ,nvl(sum(decode(t.numtype, 'A', t.id_num, 0)), 0) d_num -- 交坯\n" +
  14915. " ,nvl(sum(decode(t.numtype, '2', t.id_num, 0)), 0) b_num -- 半检不合格数\n" +
  14916. " ,nvl(sum(decode(t.numtype, '3', t.id_num, 0)), 0) f_num -- 复检不合格数\n" +
  14917. " ,nvl(sum(decode(t.numtype, '0', t.id_num, 0)), 0) s_num -- 损坯数\n" +
  14918. " from (select gdd.goodsid\n" +
  14919. " ,'A' numtype\n" +
  14920. " ,count(gdd.groutingdailydetailid) id_num\n" +
  14921. " from tp_pm_groutingdailydetail gdd\n" +
  14922. " where gdd.groutingflag = '1'\n" +
  14923. " and gdd.valueflag = '1'\n" +
  14924. " and gdd.accountid = :accountid\n" +
  14925. " and gdd.deliverflag = '1'\n" +
  14926. " and gdd.delivertime >= :datebegin\n" +
  14927. " and gdd.delivertime < :dateend\n" +
  14928. " group by gdd.goodsid\n" +
  14929. " union all\n" +
  14930. " -- 半检不合格数 复检不合格数 损坯数\n" +
  14931. " select sp.goodsid\n" +
  14932. " ,sp.SCRAPTYPE numtype\n" +
  14933. " ,count(sp.scrapproductid) id_num\n" +
  14934. " from tp_pm_scrapproduct sp\n" +
  14935. " where sp.valueflag = '1'\n" +
  14936. " and sp.accountid = :accountid\n" +
  14937. " and sp.auditstatus = 1\n" +
  14938. " and sp.KILNID is null\n" +
  14939. " and sp.SCRAPTYPE <> '1'\n" +
  14940. " and sp.AUDITDATE >= :datebegin\n" +
  14941. " and sp.AUDITDATE < :dateend\n" +
  14942. " group by sp.goodsid, sp.SCRAPTYPE) t\n" +
  14943. " group by t.goodsid) tt\n" +
  14944. " inner join tp_mst_goods g\n" +
  14945. " on tt.goodsid = g.goodsid\n" +
  14946. " order by g.goodscode";
  14947. oracleParameters.Add(new OracleParameter(":datebegin", cre.Properties["datebegin"]));
  14948. oracleParameters.Add(new OracleParameter(":dateend", cre.Properties["dateend"]));
  14949. //// 产品编码 GOODSCODE
  14950. //if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSCODE"] + ""))
  14951. //{
  14952. // sqlString += " and instr(sr.GOODSCODE,:GOODSCODE) > 0 \n";
  14953. // oracleParameters.Add(new OracleParameter(":GOODSCODE", cre.Properties["GOODSCODE"]));
  14954. //}
  14955. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameters.ToArray());
  14956. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  14957. {
  14958. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  14959. return sre;
  14960. }
  14961. sre.Data = result;
  14962. return sre;
  14963. }
  14964. catch (Exception ex)
  14965. {
  14966. throw ex;
  14967. }
  14968. finally
  14969. {
  14970. oracleConn?.Close();
  14971. }
  14972. }
  14973. /// <summary>
  14974. /// 综合合格率分析表-综合优等率分析表
  14975. /// </summary>
  14976. /// <param name="cre"></param>
  14977. /// <param name="sUserInfo"></param>
  14978. /// <returns></returns>
  14979. public static ServiceResultEntity GetRPT040114_2Data(ClientRequestEntity cre, SUserInfo sUserInfo)
  14980. {
  14981. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  14982. try
  14983. {
  14984. ServiceResultEntity sre = new ServiceResultEntity();
  14985. List<OracleParameter> oracleParameters = new List<OracleParameter>();
  14986. oracleParameters.Add(new OracleParameter(":accountid", sUserInfo.AccountID));
  14987. string sqlString = "\n" +
  14988. "select g.goodscode\n" +
  14989. " ,pp.b_out_num\n" +
  14990. " ,(pp.b_out_num - pp.b_bad_num) b_h_num\n" +
  14991. " ,(pp.c_out_num - pp.c_bad_num) c_h_num\n" +
  14992. " ,decode(pp.b_out_num\n" +
  14993. " ,0\n" +
  14994. " ,to_number(null)\n" +
  14995. " ,round((pp.b_out_num - pp.b_bad_num + pp.c_out_num - pp.c_bad_num) /\n" +
  14996. " pp.b_out_num,4)) zh_r\n" +
  14997. " from (select p.goodsid\n" +
  14998. " ,nvl(sum(decode(p.procedureid, 11, 1, 0)), 0) b_out_num -- 本烧出窑数\n" +
  14999. " ,nvl(sum(decode(p.procedureid, 12, 1, 0)), 0) b_bad_num -- 本烧不合格数\n" +
  15000. " ,nvl(sum(decode(p.procedureid, 58, 1, 0)), 0) c_out_num -- 重烧出窑数\n" +
  15001. " ,nvl(sum(decode(p.procedureid, 59, 1, 0)), 0) c_bad_num -- 重烧不合格数\n" +
  15002. " from tp_pm_productiondata p\n" +
  15003. " where p.valueflag = '1'\n" +
  15004. " and p.accountid = :accountid\n" +
  15005. " and (p.procedureid in (11, 58) or\n" +
  15006. " (p.procedureid in (12, 59) and p.goodsleveltypeid in (6, 7)))\n" +
  15007. " and p.createtime >= :datebegin\n" +
  15008. " and p.createtime < :dateend\n" +
  15009. " group by p.goodsid) pp\n" +
  15010. " inner join tp_mst_goods g\n" +
  15011. " on g.goodsid = pp.goodsid\n" +
  15012. " order by g.goodscode";
  15013. oracleParameters.Add(new OracleParameter(":datebegin", cre.Properties["datebegin"]));
  15014. oracleParameters.Add(new OracleParameter(":dateend", cre.Properties["dateend"]));
  15015. //// 产品编码 GOODSCODE
  15016. //if (!string.IsNullOrWhiteSpace(cre.Properties["GOODSCODE"] + ""))
  15017. //{
  15018. // sqlString += " and instr(sr.GOODSCODE,:GOODSCODE) > 0 \n";
  15019. // oracleParameters.Add(new OracleParameter(":GOODSCODE", cre.Properties["GOODSCODE"]));
  15020. //}
  15021. DataSet result = oracleConn.GetSqlResultToDs(sqlString, oracleParameters.ToArray());
  15022. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  15023. {
  15024. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  15025. return sre;
  15026. }
  15027. sre.Data = result;
  15028. return sre;
  15029. }
  15030. catch (Exception ex)
  15031. {
  15032. throw ex;
  15033. }
  15034. finally
  15035. {
  15036. oracleConn?.Close();
  15037. }
  15038. }
  15039. #region 产成品交接撤销汇总表
  15040. /// <summary>
  15041. /// 取得F_RPT_030117画面(产成品交接撤销汇总表)
  15042. /// </summary>
  15043. /// <param name="user">登录用户信息</param>
  15044. /// <param name="se">查询条件</param>
  15045. /// <returns>查询结果</returns>
  15046. public static ServiceResultEntity GetF_RPT_030117SearchTotalData(SearchFinishedProductEntity orderEntity, SUserInfo user)
  15047. {
  15048. IDBConnection conn = null;
  15049. try
  15050. {
  15051. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  15052. string sqlString = "SELECT TS.GID,\n" +
  15053. " DECODE(TS.GID, '3', '合计', DECODE(TS.GID, '1', '小计[' || CREATETIME || ']', CREATETIME)) AS CREATETIME,\n" +
  15054. " DECODE(TS.GID, '1', '--', GOODSMODEL) AS GOODSMODEL,\n" +
  15055. " GOODSCOUNT\n" +
  15056. " FROM (SELECT GROUPING_ID(TO_CHAR(F.CREATETIME, 'yyyy-mm-dd'), G.GOODSCODE) AS GID,\n" +
  15057. " DECODE(GROUPING(TO_CHAR(F.CREATETIME, 'yyyy-mm-dd')), 1, '--', TO_CHAR(F.CREATETIME, 'yyyy-mm-dd')) AS CREATETIME,\n" +
  15058. " DECODE(GROUPING(G.GOODSCODE), 1, '--', G.GOODSCODE) AS GOODSMODEL,\n" +
  15059. " COUNT(G.GOODSCODE) AS GOODSCOUNT\n" +
  15060. " FROM TP_PM_FHUNDO F\n" +
  15061. " LEFT JOIN TP_PM_GROUTINGDAILYDETAIL GDD\n" +
  15062. " ON F.GROUTINGDAILYDETAILID = GDD.GROUTINGDAILYDETAILID\n" +
  15063. " LEFT JOIN TP_MST_GOODS G\n" +
  15064. " ON G.GOODSID = GDD.GOODSID\n" +
  15065. " WHERE F.ACCOUNTID = :AccountID\n";
  15066. List<OracleParameter> parameters = new List<OracleParameter>();
  15067. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  15068. // 撤销时间
  15069. if (orderEntity.UndoTimeStart != null)
  15070. {
  15071. sqlString = sqlString + " AND F.CREATETIME BETWEEN :UndoTimeStart AND :UndoTimeEnd \n";
  15072. parameters.Add(new OracleParameter(":UndoTimeStart", OracleDbType.Date, orderEntity.UndoTimeStart, ParameterDirection.Input));
  15073. parameters.Add(new OracleParameter(":UndoTimeEnd", OracleDbType.Date, orderEntity.UndoTimeEnd, ParameterDirection.Input));
  15074. }
  15075. // 产品型号
  15076. if (!string.IsNullOrEmpty(orderEntity.GoodsModel))
  15077. {
  15078. sqlString = sqlString + " AND INSTR(g.GoodsCode,:GoodsCode)>0 \n";
  15079. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, orderEntity.GoodsModel, ParameterDirection.Input));
  15080. }
  15081. sqlString += " GROUP BY GROUPING SETS((TO_CHAR(F.CREATETIME, 'yyyy-mm-dd'), G.GOODSCODE),\n" +
  15082. " (TO_CHAR(F.CREATETIME, 'yyyy-mm-dd')),())\n" +
  15083. " ORDER BY TO_CHAR(F.CREATETIME, 'yyyy-mm-dd'), G.GOODSCODE) TS";
  15084. ServiceResultEntity sre = new ServiceResultEntity();
  15085. DataSet result = conn.GetSqlResultToDs(sqlString, parameters.ToArray());
  15086. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  15087. {
  15088. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  15089. }
  15090. sre.Data = result;
  15091. return sre;
  15092. }
  15093. catch (Exception ex)
  15094. {
  15095. throw ex;
  15096. }
  15097. finally
  15098. {
  15099. if (conn != null &&
  15100. conn.ConnState == ConnectionState.Open)
  15101. {
  15102. conn.Close();
  15103. }
  15104. }
  15105. }
  15106. /// <summary>
  15107. /// 取得F_RPT_030112画面(产成品交接汇总表)的明细信息查询数据
  15108. /// </summary>
  15109. /// <param name="user">登录用户信息</param>
  15110. /// <param name="se">查询条件</param>
  15111. /// <returns>查询结果</returns>
  15112. public static ServiceResultEntity GetF_RPT_030117SearchDetailSData(SearchFinishedProductEntity orderEntity, SUserInfo user)
  15113. {
  15114. IDBConnection conn = null;
  15115. try
  15116. {
  15117. conn = ClsDbFactory.CreateDBConnection(DataBaseType.ORACLE, DataManager.ConnectionString);
  15118. string sqlString = "SELECT O.ORDERNO,\n" +
  15119. " F.FHTIME,\n" +
  15120. " F.FHUSERCODE,\n" +
  15121. " GDD.BARCODE,\n" +
  15122. " GOODS.GOODSCODE,\n" +
  15123. " L.LOGONAME,\n" +
  15124. " GDD.USERCODE AS GROUTINGUSERCODE,\n" +
  15125. " GDD.GROUTINGLINECODE,\n" +
  15126. " GDD.GROUTINGMOULDCODE,\n" +
  15127. " GDD.GROUTINGDATE,\n" +
  15128. " TO_CHAR(GDD.DELIVERTIME, 'yyyy-mm-dd') AS DELIVERTIME,\n" +
  15129. //" (GOODS.MATERIALCODE || L.TAGCODE || GDD.ONLYCODE) AS FINISHEDBARCODE,\n" +
  15130. " 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" +
  15131. " TO_CHAR(F.CREATETIME, 'yyyy-mm-dd HH24:mi:ss') AS UNDOTIME,\n" +
  15132. " UNDOUSER.USERCODE AS UNDOUSERCODE\n" +
  15133. " FROM TP_PM_FHUNDO F\n" +
  15134. " LEFT JOIN TP_PM_GROUTINGDAILYDETAIL GDD\n" +
  15135. " ON F.GROUTINGDAILYDETAILID = GDD.GROUTINGDAILYDETAILID\n" +
  15136. " LEFT JOIN TP_PM_ORDER O\n" +
  15137. " ON F.FHORDERID = O.ORDERID\n" +
  15138. " LEFT JOIN TP_MST_LOGO L\n" +
  15139. " ON GDD.LOGOID = L.LOGOID\n" +
  15140. " LEFT JOIN TP_MST_GOODS GOODS\n" +
  15141. " ON GDD.GOODSID = GOODS.GOODSID\n" +
  15142. " LEFT JOIN TP_MST_USER UNDOUSER\n" +
  15143. " ON UNDOUSER.USERID = F.CREATEUSERID\n" +
  15144. " WHERE F.ACCOUNTID = :AccountID";
  15145. List<OracleParameter> parameters = new List<OracleParameter>();
  15146. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, user.AccountID, ParameterDirection.Input));
  15147. // 撤销时间
  15148. if (orderEntity.UndoTimeStart != null)
  15149. {
  15150. sqlString = sqlString + " AND F.CREATETIME BETWEEN :UndoTimeStart AND :UndoTimeEnd \n";
  15151. parameters.Add(new OracleParameter(":UndoTimeStart", OracleDbType.Date, orderEntity.UndoTimeStart, ParameterDirection.Input));
  15152. parameters.Add(new OracleParameter(":UndoTimeEnd", OracleDbType.Date, orderEntity.UndoTimeEnd, ParameterDirection.Input));
  15153. }
  15154. // 产品型号
  15155. if (!string.IsNullOrEmpty(orderEntity.GoodsModel))
  15156. {
  15157. sqlString = sqlString + " AND INSTR(GOODS.GoodsCode,:GoodsCode) > 0 \n";
  15158. parameters.Add(new OracleParameter(":GoodsCode", OracleDbType.NVarchar2, orderEntity.GoodsModel, ParameterDirection.Input));
  15159. }
  15160. ServiceResultEntity sre = new ServiceResultEntity();
  15161. DataSet result = conn.GetSqlResultToDs(sqlString, parameters.ToArray());
  15162. if (result == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
  15163. {
  15164. sre.Status = Constant.ServiceResultStatus.NoSearchResults;
  15165. }
  15166. sre.Data = result;
  15167. return sre;
  15168. }
  15169. catch (Exception ex)
  15170. {
  15171. throw ex;
  15172. }
  15173. finally
  15174. {
  15175. if (conn != null &&
  15176. conn.ConnState == ConnectionState.Open)
  15177. {
  15178. conn.Close();
  15179. }
  15180. }
  15181. }
  15182. #endregion
  15183. }
  15184. }