PMModuleLogicDAL.cs 1.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:PMModuleLogicDAL.cs
  5. * 2.功能描述:生产管理数据库访问类(插入、修改、删除)
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 陈冰 2014/09/17 1.00 新建
  9. * 徐伟 2019/09/26 1.00 修改
  10. *******************************************************************************/
  11. using System;
  12. using System.Collections;
  13. using System.Collections.Generic;
  14. using System.Data;
  15. using System.IO;
  16. using System.Net;
  17. using System.Text;
  18. using Dongke.IBOSS.PRD.Basics.BaseResources;
  19. using Dongke.IBOSS.PRD.Basics.DataAccess;
  20. using Dongke.IBOSS.PRD.Basics.Library;
  21. using Dongke.IBOSS.PRD.Service.DataModels;
  22. using Dongke.IBOSS.PRD.Service.SAPHegiiDataService;
  23. using Dongke.IBOSS.PRD.Service.SAPHegiiDataService.HGSAPDK_ZPPFM008;
  24. using Dongke.IBOSS.PRD.Service.SAPHegiiDataService.HGSAPDK_ZPPFM010;
  25. using Dongke.IBOSS.PRD.Service.WMSDataService;
  26. using Dongke.IBOSS.PRD.WCF.DataModels;
  27. using Newtonsoft.Json;
  28. using Newtonsoft.Json.Linq;
  29. using Oracle.ManagedDataAccess.Client;
  30. using static Dongke.IBOSS.PRD.Service.SAPHegiiDataService.SAPDataLogic;
  31. namespace Dongke.IBOSS.PRD.Service.PMModuleLogic
  32. {
  33. /// <summary>
  34. /// 生产管理数据库访问类(插入、修改、删除)
  35. /// </summary>
  36. public partial class PMModuleLogicDAL
  37. {
  38. #region 生产管理
  39. #region 计件
  40. /// <summary>
  41. /// 添加生产计件
  42. /// </summary>
  43. /// <param name="procedureID">工序ID</param>
  44. /// <param name="barcodeTable">条码信息</param>
  45. /// <param name="sUserInfo">用户基本信息</param>
  46. /// <returns>DataTable null:添加成功 不为空:错误消息</returns>
  47. /// <remarks>
  48. /// 陈冰 2014.09.18 新建
  49. /// </remarks>
  50. public static DataTable AddWorkPiece(int procedureID, DataTable barcodeTable, SUserInfo sUserInfo, out ProcedureEntity procedureInfo)
  51. {
  52. procedureInfo = null;
  53. if (barcodeTable == null || barcodeTable.Rows.Count == 0)
  54. {
  55. return null;
  56. }
  57. // 实例返回的Talbe
  58. DataTable dtBarCode = PMModuleLogic.CreateBarCodeResultTable();
  59. DataRow dr = dtBarCode.NewRow();
  60. string errMsg = "";
  61. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  62. oracleTrConn.IgnoreCase = false;
  63. try
  64. {
  65. DataSet dsReturnSinglePoint = null;
  66. oracleTrConn.Connect();
  67. int goodsID = Constant.INT_IS_ZERO;
  68. string goodsCode = null;
  69. string goodsName = null;
  70. string groutingUserCode = string.Empty;
  71. string logoCode = string.Empty;
  72. string logoName = string.Empty;
  73. string groutingdate = string.Empty;
  74. #region 查询工序信息
  75. ProcedureEntity procedure = GetProcedurByID(oracleTrConn, procedureID);
  76. procedureInfo = procedure;
  77. #endregion
  78. if (barcodeTable.Columns.Contains("IsPDA"))
  79. {
  80. if (procedure.ModelType != (int)Constant.ProcedureModelType.DeliverMud)
  81. {
  82. if (barcodeTable.Columns.Contains("IsPublicBody"))
  83. {
  84. barcodeTable.Columns.Remove("IsPublicBody");
  85. barcodeTable.Columns.Remove("IsPDA");
  86. }
  87. }
  88. }
  89. #region 防止多次重复提交,导致数据重复
  90. // 通过锁定表tp_pm_usedbarcode中的条码,防止多次重复提交,导致数据重复
  91. // TODO PDA还没有修改,暂时注释。PDA(集中采集画面)点击保存时如果不成功提示消息后,清除了当前画面中的数据。应该不清空数据,可以继续保存。
  92. //string barcodes = null;
  93. //foreach (DataRow item in barcodeTable.Rows)
  94. //{
  95. // if (barcodes != null)
  96. // {
  97. // barcodes += ",";
  98. // }
  99. // barcodes += item["Barcode"].ToString();
  100. //}
  101. //if (barcodes != null)
  102. //{
  103. // string sql = "select uc.barcode from tp_pm_usedbarcode uc where uc.barcode in (" + barcodes + ") for update nowait";
  104. // try
  105. // {
  106. // oracleTrConn.GetSqlResultToDt(sql);
  107. // }
  108. // catch (Exception ex)
  109. // {
  110. // // 判断异常类型
  111. // if (ex.Message.IndexOf("ORA-00054") > -1)
  112. // {
  113. // dr[Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = "条码正在被处理中,请稍后再操作。";
  114. // dr[Constant.BarCodeResultTableColumns.out_missFlag.ToString()] = "0";
  115. // dtBarCode.Rows.Add(dr);
  116. // return dtBarCode;
  117. // }
  118. // throw ex;
  119. // }
  120. //}
  121. #endregion
  122. //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的
  123. //xuwei fix 2019-09-26 按原条理判定首节点得到正确的返回结果
  124. // 2019-1016
  125. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  126. {
  127. int nodeBegin = IsNodeBegin<IDBTransaction>(oracleTrConn, barcodeTable.Rows[0]["Barcode"].ToString());
  128. if (nodeBegin == 1)
  129. {
  130. procedure.NodeType = (int)Constant.ProcedureNodeType.Begin;
  131. }
  132. else if (nodeBegin == 0)
  133. {
  134. procedure.NodeType = (int)Constant.ProcedureNodeType.Middle;
  135. }
  136. }
  137. //if (nodeBegin == -1) errMsg = "条码不正确,请检查!";
  138. #region 标准计件和坯库
  139. if (procedure.ModelType == (int)Constant.ProcedureModelType.Normal
  140. || procedure.ModelType == (int)Constant.ProcedureModelType.AdobeStock)
  141. {
  142. if (procedure.CollectType == 1)
  143. {
  144. #region 集中采集
  145. errMsg = AddNormalWorkPiece(oracleTrConn, procedure, barcodeTable, sUserInfo,
  146. out goodsID, out goodsCode, out goodsName, out groutingUserCode);
  147. #endregion
  148. }
  149. else
  150. {
  151. #region 单点采集
  152. int? GroutingDailyDetailID = null;
  153. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  154. {
  155. dsReturnSinglePoint = PMModuleLogic.CheckBarcodeDeliverMudSinglePoint(procedureID, barcodeTable.Rows[0]["barcode"].ToString(), sUserInfo, ref GroutingDailyDetailID);
  156. }
  157. else
  158. {
  159. dsReturnSinglePoint = PMModuleLogic.CheckBarcodeSinglePoint(procedureID, barcodeTable.Rows[0]["barcode"].ToString(), sUserInfo);
  160. }
  161. if (dsReturnSinglePoint != null)
  162. {
  163. if (dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString() == ""
  164. && dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()].ToString() == "0")
  165. {
  166. goodsID = Convert.ToInt32(dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()].ToString());
  167. goodsCode = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()].ToString();
  168. goodsName = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()].ToString();
  169. groutingUserCode = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()].ToString();
  170. barcodeTable.Rows[0]["barcode"] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_barcode.ToString()];
  171. errMsg = AddNormalWorkPieceSinglePoint(oracleTrConn, procedure, barcodeTable, sUserInfo,
  172. goodsID, goodsCode, goodsName, groutingUserCode, null);
  173. }
  174. }
  175. #endregion
  176. }
  177. }
  178. #endregion
  179. #region 交坯
  180. else if (procedure.ModelType == (int)Constant.ProcedureModelType.DeliverMud)
  181. {
  182. if (procedure.CollectType == 1)
  183. {
  184. #region 集中采集
  185. //xuwei fix begin 2019-09-17
  186. //加入最后一个参数 true,识别为交坏
  187. errMsg = AddNormalWorkPiece(oracleTrConn, procedure, barcodeTable, sUserInfo,
  188. out goodsID, out goodsCode, out goodsName, out groutingUserCode, true);
  189. //xuwei end
  190. #endregion
  191. }
  192. else
  193. {
  194. #region 单点采集
  195. int? GroutingDailyDetailID = null;
  196. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  197. {
  198. dsReturnSinglePoint = PMModuleLogic.CheckBarcodeDeliverMudSinglePoint(procedureID, barcodeTable.Rows[0]["barcode"].ToString(), sUserInfo, ref GroutingDailyDetailID);
  199. }
  200. else
  201. {
  202. dsReturnSinglePoint = PMModuleLogic.CheckBarcodeSinglePoint(procedureID, barcodeTable.Rows[0]["barcode"].ToString(), sUserInfo);
  203. }
  204. //dsReturnSinglePoint = PMModuleLogic.CheckBarcodeDeliverMudSinglePoint(procedureID, barcodeTable.Rows[0]["barcode"].ToString(), sUserInfo, ref GroutingDailyDetailID);
  205. if (dsReturnSinglePoint != null)
  206. {
  207. //if (barcodeTable.Rows[0]["UserCode"].ToString() != dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()].ToString())
  208. //{
  209. // dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = "成型工号与交坯工号不一致,不允许交坯";
  210. //}
  211. //else
  212. //{
  213. if (dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString() == ""
  214. && dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()].ToString() == "0")
  215. {
  216. if (procedure.DeliverType == 0) //手动模式
  217. {
  218. if (barcodeTable.Rows[0]["UserCode"].ToString() != dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()].ToString())
  219. {
  220. if (barcodeTable.Rows[0]["IsPublicBody"].ToString() != "1")
  221. {
  222. dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = "成型工号与交坯工号不一致,不允许交坯";
  223. }
  224. else
  225. {
  226. goodsID = Convert.ToInt32(dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()].ToString());
  227. goodsCode = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()].ToString();
  228. goodsName = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()].ToString();
  229. groutingUserCode = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()].ToString();
  230. //xuwei fix begin 2019-09-17
  231. //加入最后一个参数 true,识别为交坏
  232. errMsg = AddNormalWorkPieceSinglePoint(oracleTrConn, procedure, barcodeTable, sUserInfo,
  233. goodsID, goodsCode, goodsName, groutingUserCode, GroutingDailyDetailID, true);
  234. if (!string.IsNullOrEmpty(errMsg))
  235. {
  236. dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = errMsg;
  237. }
  238. // wangx 2016-10-10 是否设置过期未交坯
  239. else
  240. {
  241. // string sqlNew = "select settingvalue from TP_MST_SystemSetting where settingcode='" + Constant.SettingType.S_PM_002.ToString() + "' and accountid=" + sUserInfo.AccountID;
  242. string sqlNew = "select deliverlimitCycle from TP_MST_Goods where goodsid=" + goodsID;
  243. string sqlSettingValue = oracleTrConn.GetSqlResultToStr(sqlNew);
  244. if (sqlSettingValue != "0")
  245. {
  246. ServiceResultEntity resultEntity = PMModuleLogic.BarcodeAllowCancel(
  247. Convert.ToDateTime(dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()]),
  248. Convert.ToInt32(sqlSettingValue), Constant.SettingType.S_PM_002.ToString(), sUserInfo);
  249. if (Convert.ToInt32(resultEntity.Result) < 0)
  250. {
  251. dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = resultEntity.Message;
  252. errMsg = resultEntity.Message;
  253. }
  254. }
  255. // wangx end
  256. }
  257. }
  258. }
  259. else
  260. {
  261. goodsID = Convert.ToInt32(dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()].ToString());
  262. goodsCode = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()].ToString();
  263. goodsName = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()].ToString();
  264. groutingUserCode = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()].ToString();
  265. //xuwei fix begin 2019-09-17
  266. //加入最后一个参数 true,识别为交坏
  267. errMsg = AddNormalWorkPieceSinglePoint(oracleTrConn, procedure, barcodeTable, sUserInfo,
  268. goodsID, goodsCode, goodsName, groutingUserCode, GroutingDailyDetailID, true);
  269. if (!string.IsNullOrEmpty(errMsg))
  270. {
  271. dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = errMsg;
  272. }
  273. // wangx 2016-10-10 是否设置过期未交坯
  274. else
  275. {
  276. // string sqlNew = "select settingvalue from TP_MST_SystemSetting where settingcode='" + Constant.SettingType.S_PM_002.ToString() + "' and accountid=" + sUserInfo.AccountID;
  277. string sqlNew = "select deliverlimitCycle from TP_MST_Goods where goodsid=" + goodsID;
  278. string sqlSettingValue = oracleTrConn.GetSqlResultToStr(sqlNew);
  279. if (sqlSettingValue != "0")
  280. {
  281. ServiceResultEntity resultEntity = PMModuleLogic.BarcodeAllowCancel(
  282. Convert.ToDateTime(dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()]),
  283. Convert.ToInt32(sqlSettingValue), Constant.SettingType.S_PM_002.ToString(), sUserInfo);
  284. if (Convert.ToInt32(resultEntity.Result) < 0)
  285. {
  286. dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = resultEntity.Message;
  287. errMsg = resultEntity.Message;
  288. }
  289. }
  290. // wangx end
  291. }
  292. }
  293. }
  294. else //2016-07-05
  295. {
  296. // 自动模式 .查出型工号,单点采集前台并没有传值,更新barcodeTable表对应的字段
  297. string sql = @"select tp_mst_user.userid,tp_mst_user.usercode,tp_mst_user.username from TP_PM_GroutingDailyDetail
  298. left join tp_mst_user
  299. on TP_PM_GroutingDailyDetail.userid=tp_mst_user.userid
  300. where TP_PM_GroutingDailyDetail.barcode='" + barcodeTable.Rows[0]["barcode"].ToString() + "'";
  301. DataSet ds = oracleTrConn.GetSqlResultToDs(sql);
  302. if (ds != null && ds.Tables[0].Rows.Count > 0)
  303. {
  304. barcodeTable.Rows[0]["UserCode"] = ds.Tables[0].Rows[0]["UserCode"];
  305. barcodeTable.Rows[0]["UserID"] = ds.Tables[0].Rows[0]["UserID"];
  306. barcodeTable.Rows[0]["UserName"] = ds.Tables[0].Rows[0]["UserName"];
  307. }
  308. goodsID = Convert.ToInt32(dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()].ToString());
  309. goodsCode = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()].ToString();
  310. goodsName = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()].ToString();
  311. groutingUserCode = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()].ToString();
  312. //xuwei fix begin 2019-09-17
  313. //加入最后一个参数 true,识别为交坏
  314. errMsg = AddNormalWorkPieceSinglePoint(oracleTrConn, procedure, barcodeTable, sUserInfo,
  315. goodsID, goodsCode, goodsName, groutingUserCode, GroutingDailyDetailID, true);
  316. if (!string.IsNullOrEmpty(errMsg))
  317. {
  318. dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = errMsg;
  319. }
  320. // wangx 2016-10-10 是否设置过期未交坯
  321. else
  322. {
  323. // string sqlNew = "select settingvalue from TP_MST_SystemSetting where settingcode='" + Constant.SettingType.S_PM_002.ToString() + "' and accountid=" + sUserInfo.AccountID;
  324. string sqlNew = "select deliverlimitCycle from TP_MST_Goods where goodsid=" + goodsID;
  325. string sqlSettingValue = oracleTrConn.GetSqlResultToStr(sqlNew);
  326. if (sqlSettingValue != "0")
  327. {
  328. ServiceResultEntity resultEntity = PMModuleLogic.BarcodeAllowCancel(
  329. Convert.ToDateTime(dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()]),
  330. Convert.ToInt32(sqlSettingValue), Constant.SettingType.S_PM_002.ToString(), sUserInfo);
  331. if (Convert.ToInt32(resultEntity.Result) < 0)
  332. {
  333. dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = resultEntity.Message;
  334. errMsg = resultEntity.Message;
  335. }
  336. }
  337. // wangx end
  338. }
  339. //
  340. }
  341. //}
  342. }
  343. }
  344. #endregion
  345. }
  346. }
  347. #endregion
  348. #region 装窑车
  349. else if (procedure.ModelType == (int)Constant.ProcedureModelType.LoadCar)
  350. {
  351. errMsg = AddLoadKilnCar(oracleTrConn, procedure, barcodeTable, sUserInfo,
  352. out goodsID, out goodsCode, out goodsName);
  353. }
  354. #endregion
  355. #region 窑车补件
  356. else if (procedure.ModelType == (int)Constant.ProcedureModelType.CarAdd)
  357. {
  358. errMsg = AddKilnCarSupplement(oracleTrConn, procedure, barcodeTable, sUserInfo,
  359. out goodsID, out goodsCode, out goodsName);
  360. }
  361. #endregion
  362. #region 入窑
  363. else if (procedure.ModelType == (int)Constant.ProcedureModelType.IntoKiln)
  364. {
  365. // PDA传入的窑车号。没有传入条码信息 需要转换
  366. /* modify by chenxy 2016-04-05 begin
  367. * 入窑画面显示条码后,登窑画面再做撤销登车,入窑再保存时,撤销的产品也到了入窑工序。
  368. * 入窑时窑车上的产品需要重新获取。
  369. */
  370. //if (barcodeTable.Columns.Contains("IsPDAFlag"))
  371. // modify by chenxy 2016-04-05 end
  372. {
  373. barcodeTable = CarNoInfoConvertToTable(oracleTrConn, barcodeTable, sUserInfo);
  374. }
  375. errMsg = AddIntoKilnCar(oracleTrConn, procedure, barcodeTable, sUserInfo,
  376. out goodsID, out goodsCode, out goodsName);
  377. }
  378. #endregion
  379. #region 出窑
  380. else if (procedure.ModelType == (int)Constant.ProcedureModelType.OutKiln)
  381. {
  382. // PDA传入的窑车号。没有传入条码信息 需要转换
  383. /* modify by chenxy 2016-04-05 begin
  384. * 入窑画面显示条码后,登窑画面再做撤销登车,入窑再保存时,撤销的产品也到了入窑工序。
  385. * 入窑时窑车上的产品需要重新获取。
  386. */
  387. //if (barcodeTable.Columns.Contains("IsPDAFlag"))
  388. // modify by chenxy 2016-04-05 end
  389. {
  390. barcodeTable = CarNoInfoConvertToTable(oracleTrConn, barcodeTable, sUserInfo);
  391. }
  392. errMsg = AddOutKilnCar(oracleTrConn, procedure, barcodeTable, sUserInfo,
  393. out goodsID, out goodsCode, out goodsName);
  394. }
  395. #endregion
  396. #region 卸窑车
  397. else if (procedure.ModelType == (int)Constant.ProcedureModelType.UnloadCar)
  398. {
  399. // PDA传入的窑车号。没有传入条码信息 需要转换
  400. /* modify by chenxy 2016-04-05 begin
  401. * 入窑画面显示条码后,登窑画面再做撤销登车,入窑再保存时,撤销的产品也到了入窑工序。
  402. * 入窑时窑车上的产品需要重新获取。
  403. */
  404. //if (barcodeTable.Columns.Contains("IsPDAFlag"))
  405. // modify by chenxy 2016-04-05 end
  406. {
  407. barcodeTable = CarNoInfoConvertToTable(oracleTrConn, barcodeTable, sUserInfo);
  408. }
  409. errMsg = AddUnloadingKilnCar(oracleTrConn, procedure, barcodeTable, sUserInfo,
  410. out goodsID, out goodsCode, out goodsName);
  411. }
  412. #endregion
  413. #region 干补
  414. else if (procedure.ModelType == (int)Constant.ProcedureModelType.SpecialRepair)
  415. {
  416. errMsg = AddDryRepairWorkPiece(oracleTrConn, procedure, barcodeTable, sUserInfo,
  417. out goodsID, out goodsCode, out goodsName, out groutingUserCode, out logoCode, out logoName, out groutingdate);
  418. }
  419. #endregion
  420. #region 回收
  421. else if (procedure.ModelType == (int)Constant.ProcedureModelType.Recovery)
  422. {
  423. errMsg = AddRecydingFlagWorkPiece(oracleTrConn, procedure, barcodeTable, sUserInfo,
  424. out goodsID, out goodsCode, out goodsName, out groutingUserCode, out logoCode, out logoName, out groutingdate);
  425. }
  426. #endregion
  427. #region 构造返回的DataTable
  428. if ((procedure.ModelType == (int)Constant.ProcedureModelType.DeliverMud
  429. || procedure.ModelType == (int)Constant.ProcedureModelType.Normal) && procedure.CollectType == 2)
  430. {
  431. dr[Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()];
  432. dr[Constant.BarCodeResultTableColumns.out_goodsID.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()];
  433. dr[Constant.BarCodeResultTableColumns.out_goodsCode.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()];
  434. dr[Constant.BarCodeResultTableColumns.out_goodsName.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()];
  435. dr[Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()];
  436. dr[Constant.BarCodeResultTableColumns.out_missFlag.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()];
  437. //新添加的
  438. dr[Constant.BarCodeResultTableColumns.out_groutingNum.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingNum.ToString()];
  439. dr[Constant.BarCodeResultTableColumns.out_mouldCode.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_mouldCode.ToString()];
  440. dr[Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()];
  441. dr[Constant.BarCodeResultTableColumns.out_ispublicbodyTrach.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_ispublicbodyTrach.ToString()];
  442. dr[Constant.BarCodeResultTableColumns.out_groutingdate.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()];
  443. dr[Constant.BarCodeResultTableColumns.out_specialRepairFlag.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_specialRepairFlag.ToString()];
  444. dr[Constant.BarCodeResultTableColumns.out_isReFire.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_isReFire.ToString()];
  445. dr[Constant.BarCodeResultTableColumns.out_logoID.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoID.ToString()];
  446. dr[Constant.BarCodeResultTableColumns.out_logoCode.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoCode.ToString()];
  447. dr[Constant.BarCodeResultTableColumns.out_logoName.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoName.ToString()];
  448. dr[Constant.BarCodeResultTableColumns.out_barcode.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_barcode.ToString()];
  449. dr[Constant.BarCodeResultTableColumns.out_WaterLabelCode.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_WaterLabelCode.ToString()];
  450. dr[Constant.BarCodeResultTableColumns.out_CodeCheckFlag.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_CodeCheckFlag.ToString()];
  451. }
  452. else
  453. {
  454. dr[Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = (errMsg == null ? "" : errMsg);
  455. dr[Constant.BarCodeResultTableColumns.out_goodsID.ToString()] = goodsID;
  456. dr[Constant.BarCodeResultTableColumns.out_goodsCode.ToString()] = goodsCode;
  457. dr[Constant.BarCodeResultTableColumns.out_goodsName.ToString()] = goodsName;
  458. dr[Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()] = groutingUserCode;
  459. dr[Constant.BarCodeResultTableColumns.out_logoCode.ToString()] = logoCode;
  460. dr[Constant.BarCodeResultTableColumns.out_logoName.ToString()] = logoName;
  461. dr[Constant.BarCodeResultTableColumns.out_groutingdate.ToString()] = groutingdate;
  462. //dr[Constant.BarCodeResultTableColumns.out_groutingNum.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingNum.ToString()];
  463. //dr[Constant.BarCodeResultTableColumns.out_mouldCode.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_mouldCode.ToString()];
  464. //dr[Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()];
  465. //dr[Constant.BarCodeResultTableColumns.out_ispublicbodyTrach.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_ispublicbodyTrach.ToString()];
  466. //dr[Constant.BarCodeResultTableColumns.out_groutingdate.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()];
  467. //dr[Constant.BarCodeResultTableColumns.out_specialRepairFlag.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_specialRepairFlag.ToString()];
  468. //dr[Constant.BarCodeResultTableColumns.out_isReFire.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_isReFire.ToString()];
  469. //dr[Constant.BarCodeResultTableColumns.out_logoID.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoID.ToString()];
  470. //dr[Constant.BarCodeResultTableColumns.out_logoCode.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoCode.ToString()];
  471. //dr[Constant.BarCodeResultTableColumns.out_logoName.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoName.ToString()];
  472. }
  473. dtBarCode.Rows.Add(dr);
  474. #endregion
  475. // 没有错误 提交事务
  476. if (string.IsNullOrEmpty(errMsg))
  477. {
  478. oracleTrConn.Commit();
  479. }
  480. }
  481. catch (Exception ex)
  482. {
  483. oracleTrConn.Rollback();
  484. throw ex;
  485. }
  486. finally
  487. {
  488. // 释放资源
  489. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  490. {
  491. oracleTrConn.Disconnect();
  492. }
  493. }
  494. return dtBarCode;
  495. }
  496. #region 是否公坯
  497. /// <summary>
  498. /// 是否公坯
  499. /// </summary>
  500. /// <param name="barcode">产品条码</param>
  501. /// <returns>int</returns>
  502. public static int IsPubilcByBarCode(IDBTransaction oracleTrConn, string barcode)
  503. {
  504. int isPubilcBody = 0;
  505. try
  506. {
  507. string sqlString = @"
  508. select
  509. ispublicbody
  510. from tp_pm_inproduction where barcode=:barcode
  511. union
  512. select
  513. ispublicbody
  514. from TP_PM_InProductionTrash where barcode=:barcode
  515. ";
  516. OracleParameter[] paras = new OracleParameter[]{
  517. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  518. };
  519. DataSet ds = oracleTrConn.GetSqlResultToDs(sqlString, paras);
  520. if (ds != null && ds.Tables[0].Rows.Count > 0)
  521. {
  522. isPubilcBody = Convert.ToInt32(ds.Tables[0].Rows[0]["ispublicbody"]);
  523. }
  524. return isPubilcBody;
  525. }
  526. catch (Exception ex)
  527. {
  528. throw ex;
  529. }
  530. }
  531. #endregion
  532. /// <summary>
  533. /// 标准计件
  534. /// </summary>
  535. /// <param name="oracleTrConn">数据连接对象</param>
  536. /// <param name="procedure">工序对象</param>
  537. /// <param name="barcodeTable">条码信息</param>
  538. /// <param name="sUserInfo">用户基本信息</param>
  539. /// <param name="goodsID">返回的产品ID</param>
  540. /// <param name="goodsCode">返回的产品Code</param>
  541. /// <param name="goodsName">返回的产品名称</param>
  542. /// <param name="groutingUserID">返回的注浆者ID</param>
  543. /// <returns>string</returns>
  544. /// <remarks>
  545. /// 陈冰 2014.09.18 新建
  546. /// </remarks>
  547. private static string AddNormalWorkPiece(IDBTransaction oracleTrConn,
  548. ProcedureEntity procedure,
  549. DataTable barcodeTable,
  550. SUserInfo sUserInfo,
  551. out int goodsID,
  552. out string goodsCode,
  553. out string goodsName,
  554. out string groutingUserCode,
  555. bool isSendBody = false
  556. )
  557. {
  558. try
  559. {
  560. goodsID = Constant.INT_IS_ZERO;
  561. goodsCode = null;
  562. goodsName = null;
  563. groutingUserCode = string.Empty; //Constant.INT_IS_ZERO;
  564. // 获得账务日期
  565. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  566. string errMsg = string.Empty;
  567. // 本批采集的批次号
  568. string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  569. string finishedloadbatchno = DateTime.Now.ToString("yyMMddHHmmss-") + centralizedBatchNo;
  570. // 条码信息
  571. foreach (DataRow barcodeRow in barcodeTable.Rows)
  572. {
  573. // 条码
  574. string barcode = barcodeRow["Barcode"].ToString();
  575. if (string.IsNullOrEmpty(barcode))
  576. {
  577. throw new Exception("传入的条码号为空");
  578. }
  579. // 生产工号
  580. int workUserID = Convert.ToInt32(barcodeRow["UserID"]);
  581. // 生产工号
  582. string workUserCode = barcodeRow["UserCode"].ToString();
  583. int? GroutingDailyDetailID = null;//注浆明细ID
  584. if (procedure.CollectType == 1)
  585. {
  586. #region 集中采集 校验条码
  587. // ccc todo
  588. //if (procedure.ModelType == (int)Constant.ProcedureModelType.DeliverMud)//是交坯节点,并且不是公坯的
  589. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  590. {
  591. #region 校验条码有效性
  592. errMsg = CheckBarcodeDeliverMud(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo, ref GroutingDailyDetailID);
  593. if (!string.IsNullOrEmpty(errMsg))
  594. {
  595. return errMsg;
  596. }
  597. #endregion
  598. }
  599. else
  600. {
  601. #region 校验条码有效性
  602. errMsg = CheckBarcode(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo);
  603. if (!string.IsNullOrEmpty(errMsg))
  604. {
  605. return errMsg;
  606. }
  607. #endregion
  608. }
  609. #endregion
  610. }
  611. else
  612. {
  613. #region 单点采集 获取注浆日报明细
  614. string sqlGroutingInfo = "";
  615. sqlGroutingInfo = @"select tp_pm_groutingdailydetail.goodsid,
  616. tp_pm_groutingdailydetail.goodscode,
  617. tp_pm_groutingdailydetail.goodsname,
  618. tp_pm_groutingdailydetail.usercode as groutingUserCode,
  619. tp_pm_groutingdailydetail.GroutingDailyDetailID
  620. from tp_pm_groutingdailydetail where barcode = :barcode";
  621. // from tp_pm_groutingdailydetail where groutingdailydetailid in
  622. //(select groutingdailydetailid from TP_PM_USEDBARCODE where barcode=:barcode)";
  623. OracleParameter[] ReFireparas = new OracleParameter[] {
  624. new OracleParameter(":barcode",barcode),
  625. };
  626. DataSet dsGrouting = oracleTrConn.GetSqlResultToDs(sqlGroutingInfo, ReFireparas);
  627. if (dsGrouting != null && dsGrouting.Tables[0].Rows.Count > 0)
  628. {
  629. GroutingDailyDetailID = Convert.ToInt32(dsGrouting.Tables[0].Rows[0]["GroutingDailyDetailID"]);
  630. goodsID = Convert.ToInt32(dsGrouting.Tables[0].Rows[0]["goodsid"]);
  631. goodsCode = dsGrouting.Tables[0].Rows[0]["goodscode"].ToString();
  632. goodsName = dsGrouting.Tables[0].Rows[0]["goodsName"].ToString();
  633. groutingUserCode = dsGrouting.Tables[0].Rows[0]["groutingUserCode"].ToString();
  634. }
  635. #endregion
  636. }
  637. int? ClassesSettingID = null;//班次配置ID
  638. #region 添加生产者数据
  639. //生产数据ID
  640. string sql = "select SEQ_PM_ProductionData_ID.nextval from dual";
  641. int productionDataID = Convert.ToInt32(oracleTrConn.GetSqlResultToStr(sql));
  642. if (procedure.ModelType == (int)Constant.ProcedureModelType.DeliverMud)//是交坯节点,并且不是公坯的
  643. {
  644. string GroutingUserCode = barcodeRow["GroutingUserCode"].ToString();
  645. if (GroutingUserCode.ToLower() == workUserCode.ToLower())
  646. {
  647. //errMsg = AddProducerDeliverAdobe(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo);
  648. }
  649. else
  650. {
  651. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID);
  652. }
  653. }
  654. else
  655. {
  656. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID);
  657. }
  658. if (!string.IsNullOrEmpty(errMsg))
  659. {
  660. return errMsg;
  661. }
  662. #endregion
  663. //xuwei fix 2019-09-23 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的
  664. //xuwei fix 2019-09-26 使用通用方法判定
  665. //if (IsNodeBegin<IDBTransaction>(oracleTrConn, barcode) == 1)
  666. // procedure.NodeType = (int)Constant.ProcedureNodeType.Begin;
  667. #region 添加生产数据
  668. ProductionDataEntity productionData = new ProductionDataEntity();
  669. #region 属性赋值
  670. productionData.GroutingDailyDetailID = GroutingDailyDetailID;//只有交坯的时候用到
  671. productionData.ClassesSettingID = ClassesSettingID;
  672. productionData.ProductionDataID = productionDataID;
  673. productionData.Barcode = barcode;
  674. productionData.CentralizedBatchNo = centralizedBatchNo;
  675. productionData.ProductionLineID = procedure.ProductionLineID;
  676. productionData.ProductionLineCode = procedure.ProductionlineCode;
  677. productionData.ProductionLineName = procedure.ProductionlineName;
  678. productionData.CompleteProcedureID = procedure.ProcedureID;
  679. productionData.ProcedureCode = procedure.ProcedureCode;
  680. productionData.ProcedureName = procedure.ProcedureName;
  681. productionData.ProcedureModel = procedure.ProcedureModel;
  682. productionData.ModelType = procedure.ModelType;
  683. productionData.NodeType = procedure.NodeType;
  684. productionData.PieceType = procedure.PieceType;
  685. if (barcodeRow["LogoID"].ToString() != "")
  686. {
  687. productionData.LogoID = Convert.ToInt32(barcodeRow["LogoID"]);
  688. }
  689. if (procedure.IsSpecialRework == 0)
  690. {
  691. productionData.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  692. //不加条件valueflag,是因为,成检后重烧走过之后,在次重烧,以后也是重烧状态
  693. //string sqlReFire = "select * from tp_PM_ProductionData where ProductionDataid=(select max(ProductionDataid) from tp_PM_ProductionData where barcode='" + productionData.Barcode + "')";
  694. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)//是交坯节点,肯定不会是重烧
  695. {
  696. productionData.IsReFire = (int)Constant.ReFireFlag.No;
  697. productionData.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  698. }
  699. ////// else
  700. ////// {
  701. ////// string sqlReFire = @"select
  702. ////// isrefire
  703. ////// from tp_pm_inproduction where barcode=:barcode
  704. ////// ";
  705. ////// OracleParameter[] ReFireparas = new OracleParameter[] {
  706. ////// new OracleParameter(":barcode",barcode),
  707. ////// };
  708. ////// DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas);
  709. ////// if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0)
  710. ////// {
  711. ////// if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0)
  712. ////// {
  713. ////// productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]);
  714. ////// //if (productionData.IsReFire == 6) wangxin modify 20150422 因为已经大于0,定是重烧,即有缺陷
  715. ////// //{
  716. ////// productionData.DefectFlag = (int)Constant.GoodsLevelType.Defect;
  717. ////// //}
  718. ////// }
  719. ////// }
  720. ////// }
  721. }
  722. else
  723. {
  724. productionData.IsReFire = (int)Constant.GoodsLevelType.ReFire;
  725. productionData.DefectFlag = (int)Constant.GoodsLevelType.Defect;
  726. }
  727. productionData.ReworkProcedureID = null;
  728. #region 交坯判断
  729. // 交坯节点
  730. if (barcodeTable.Columns.Contains("IsPublicBody"))
  731. {
  732. productionData.IsPublicBody = Convert.ToInt32(barcodeRow["IsPublicBody"]);
  733. }
  734. // 非交坯节点
  735. else
  736. {
  737. // 正常坯
  738. productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, barcode);
  739. }
  740. #endregion
  741. productionData.OrganizationID = procedure.OrganizationID;
  742. productionData.GoodsID = goodsID;
  743. productionData.GoodsCode = goodsCode;
  744. productionData.GoodsName = goodsName;
  745. productionData.UserID = workUserID;
  746. productionData.UserCode = barcodeRow["UserCode"].ToString();
  747. productionData.UserName = barcodeRow["UserName"].ToString();
  748. #endregion
  749. string OutSpecialRepairflag = "0";//干补标识
  750. DataSet outDataSet = null;
  751. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  752. {
  753. //添加首节点数据 (在产生产数据)
  754. //xuwei fix 2019-09-17 添加最后一个可选参数isSendBody识别交坯
  755. errMsg = AddProductionDataDeliverMud(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag, out outDataSet, isSendBody);
  756. }
  757. else
  758. {
  759. //添加非首节点数据
  760. //xuwei fix 2019-09-17 添加最后一个可选参数isSendBody识别交坯
  761. errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag, isSendBody);
  762. }
  763. if (!string.IsNullOrEmpty(errMsg))
  764. {
  765. return errMsg;
  766. }
  767. #endregion
  768. #region 开始节点
  769. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  770. {
  771. #region 添加在产产品数据
  772. InProductionEntity addInProductionEntity = new InProductionEntity();
  773. addInProductionEntity.BarCode = barcode;
  774. //流程工序ID
  775. addInProductionEntity.FlowProcedureID = procedure.ProcedureID;
  776. // 当前工序
  777. addInProductionEntity.ProcedureID = procedure.ProcedureID;
  778. //addInProductionEntity.CompleteProcedureID = procedure.ProcedureID;
  779. // 工序模型
  780. addInProductionEntity.ProcedureModel = procedure.ProcedureModel;
  781. // 工序类别
  782. addInProductionEntity.ModelType = procedure.ModelType;
  783. addInProductionEntity.SpecialRepairflag = Convert.ToInt32(OutSpecialRepairflag);//干补标识
  784. addInProductionEntity.ProductionDataID = productionDataID;
  785. #region 交坯判断
  786. addInProductionEntity.IsPublicBody = productionData.IsPublicBody;// 生产数据已经判断是否为公坯
  787. #endregion
  788. // 生产工号
  789. addInProductionEntity.UserID = workUserID;
  790. // 执行添加
  791. //xuwei fix 2019-09-17 添加最后一个可选参数isSendBody识别交坯
  792. errMsg = AddInProduction(oracleTrConn, addInProductionEntity, sUserInfo, outDataSet, isSendBody);
  793. // 执行失败
  794. if (!string.IsNullOrEmpty(errMsg))
  795. {
  796. return errMsg;
  797. }
  798. #endregion
  799. }
  800. #endregion
  801. #region 中间节点
  802. else if (procedure.NodeType == (int)Constant.ProcedureNodeType.Middle)
  803. {
  804. #region 修改在产产品数据的当前工序,清空返工工序字段
  805. InProductionEntity addInProductionEntity = new InProductionEntity();
  806. addInProductionEntity.BarCode = barcode;
  807. //流程工序ID
  808. addInProductionEntity.FlowProcedureID = procedure.ProcedureID;
  809. // 当前工序
  810. addInProductionEntity.ProcedureID = procedure.ProcedureID;
  811. //当前生产数据ID
  812. addInProductionEntity.ProductionDataID = productionDataID;
  813. // 工序模型
  814. addInProductionEntity.ProcedureModel = procedure.ProcedureModel;
  815. // 工序类别
  816. addInProductionEntity.ModelType = procedure.ModelType;
  817. // 生产工号
  818. addInProductionEntity.UserID = workUserID;
  819. addInProductionEntity.LogoID = productionData.LogoID;
  820. // 缺陷标识
  821. // addInProductionEntity.DefectFlag = (int)Constant.DefectFlag.No;
  822. //addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefect;
  823. if (procedure.IsSpecialRework == 0)
  824. {
  825. addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  826. }
  827. else
  828. {
  829. addInProductionEntity.IsReFire = (int)Constant.GoodsLevelType.ReFire;
  830. addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  831. }
  832. #region 交坯判断
  833. addInProductionEntity.IsPublicBody = productionData.IsPublicBody;// 生产数据已经判断是否为公坯
  834. #endregion
  835. // 执行修改
  836. errMsg = UpdateInProduction(oracleTrConn, addInProductionEntity, sUserInfo);
  837. // 执行失败
  838. if (!string.IsNullOrEmpty(errMsg))
  839. {
  840. return errMsg;
  841. }
  842. #endregion
  843. }
  844. #endregion
  845. #region 结束节点
  846. else
  847. {
  848. #region 添加成品数据 删除在产产品数据
  849. FinishedProductEntity finishedProduct = new FinishedProductEntity();
  850. finishedProduct.BarCode = barcode;
  851. finishedProduct.LogoID = productionData.LogoID;
  852. errMsg = AddFinishedProduct(oracleTrConn, finishedProduct, sUserInfo, finishedloadbatchno);
  853. if (!string.IsNullOrEmpty(errMsg))
  854. {
  855. return errMsg;
  856. }
  857. InProductionEntity delInProductionEntity = new InProductionEntity();
  858. delInProductionEntity.BarCode = barcode;
  859. // 执行删除 在产数据
  860. errMsg = DeleteInProduction(oracleTrConn, delInProductionEntity, true, sUserInfo);
  861. // 执行失败
  862. if (!string.IsNullOrEmpty(errMsg))
  863. {
  864. return errMsg;
  865. }
  866. #endregion
  867. }
  868. #endregion
  869. }
  870. return errMsg;
  871. }
  872. catch (Exception ex)
  873. {
  874. throw ex;
  875. }
  876. }
  877. /// <summary>
  878. /// 添加生产者(交坯单独调用,特殊)
  879. /// </summary>
  880. /// <param name="oracleTrConn">连接对象</param>
  881. /// <param name="accountDate">账务日期</param>
  882. /// <param name="productionDataID">生产数据ID</param>
  883. /// <param name="workUserID">生产工号ID</param>
  884. /// <param name="workUserCode">生产工号Code</param>
  885. /// <param name="sUserInfo">用户基本信息</param>
  886. /// <returns>string</returns>
  887. private static string AddProducerDeliverAdobe(IDBTransaction oracleTrConn, DateTime accountDate, int productionDataID, int workUserID, string workUserCode, SUserInfo sUserInfo)
  888. {
  889. // 参数
  890. OracleParameter[] paras;
  891. #region 将班次配置表中的数据插入生产者表中
  892. string sql = "insert into tp_pm_producer"
  893. + " (productiondataid,"
  894. + " staffid,"
  895. + " userid,"
  896. + " usercode,"
  897. + " UJobsID,"
  898. + " staffstatus,"
  899. + " SJobsID"
  900. + " )"
  901. + " select distinct :productiondataid,"
  902. + " staffid,"
  903. + " userid,"
  904. + " usercode,"
  905. + " UJobsID,"
  906. + " staffstatus,"
  907. + " SJobsID"
  908. + " "
  909. + " from TP_PM_GroutingProducer"
  910. + " where UserID = :userID";
  911. paras = new OracleParameter[] {
  912. new OracleParameter(":productiondataid",OracleDbType.Int32,productionDataID,ParameterDirection.Input),
  913. new OracleParameter(":userID",OracleDbType.Int32,workUserID,ParameterDirection.Input),
  914. };
  915. int resultCount = oracleTrConn.ExecuteNonQuery(sql, paras);
  916. // 失败
  917. if (resultCount == Constant.INT_IS_ZERO)
  918. {
  919. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  920. }
  921. #endregion
  922. return null;
  923. }
  924. /// <summary>
  925. /// 装车后,更新所有以前操作的工序窑车信息
  926. /// </summary>
  927. /// <param name="oracleTrConn">连接对象</param>
  928. /// <param name="barcode">条码</param>
  929. /// <param name="kilnCarID">窑车号</param>
  930. /// <param name="goodsID">产品ID</param>
  931. /// <param name="KilnCarPosition">窑车位置</param>
  932. /// <param name="kilnCarBatchNo">装车批次</param>
  933. /// <param name="sUserInfo">用户基本信息</param>
  934. /// <returns>string</returns>
  935. private static string UpdateRefineBybarcode(IDBTransaction oracleTrConn, ProductionDataEntity productionData)
  936. {
  937. string sql = "update TP_PM_ProductionData set "
  938. + " IsReFire=:IsReFire"
  939. + " where barcode=:barcode";
  940. #region 参数
  941. OracleParameter[] paras = new OracleParameter[] {
  942. new OracleParameter(":IsReFire",(int)Constant.GoodsLevelType.ReFire),
  943. new OracleParameter(":barcode",productionData.Barcode),
  944. };
  945. #endregion
  946. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  947. // 保存失败
  948. if (result == Constant.INT_IS_ZERO)
  949. {
  950. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  951. }
  952. // 保存成功返回null
  953. return null;
  954. }
  955. /// <summary>
  956. /// 装窑车计件
  957. /// </summary>
  958. /// <param name="oracleTrConn">数据连接对象</param>
  959. /// <param name="procedure">工序对象</param>
  960. /// <param name="barcodeTable">条码信息</param>
  961. /// <param name="sUserInfo">用户基本信息</param>
  962. /// <param name="goodsID">返回的产品ID</param>
  963. /// <param name="goodsCode">返回的产品Code</param>
  964. /// <param name="goodsName">返回的产品名称</param>
  965. /// <returns>string</returns>
  966. /// <remarks>
  967. /// 陈冰 2014.09.18 新建
  968. /// </remarks>
  969. private static string AddLoadKilnCar(IDBTransaction oracleTrConn,
  970. ProcedureEntity procedure,
  971. DataTable barcodeTable,
  972. SUserInfo sUserInfo,
  973. out int goodsID,
  974. out string goodsCode,
  975. out string goodsName)
  976. {
  977. try
  978. {
  979. goodsID = Constant.INT_IS_ZERO;
  980. goodsCode = null;
  981. goodsName = null;
  982. string groutingUserCode = string.Empty;
  983. // 获得账务日期
  984. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  985. string errMsg = string.Empty;
  986. // 生产工号
  987. int workUserID = Constant.INT_IS_ZERO;
  988. // 生产工号Code
  989. string workUserCode = string.Empty;
  990. // 生产工号Name
  991. string workUserName = string.Empty;
  992. // 本批采集的批次号
  993. string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  994. // 窑车批次号
  995. string kilnCarBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  996. // 窑车状态
  997. string kilnCarStatus = string.Empty;
  998. //////////////////////////////////////////////////
  999. DataView dv = barcodeTable.DefaultView;
  1000. DataTable dtNewKiln = dv.ToTable(true, "kilnCarCode");
  1001. for (int i = 0; i < dtNewKiln.Rows.Count; i++)
  1002. {
  1003. DataRow[] dr = barcodeTable.Select("kilnCarCode='" + dtNewKiln.Rows[i]["kilnCarCode"].ToString() + "'");
  1004. // 窑炉ID
  1005. //int kilnID = Convert.ToInt32(barcodeTable.Rows[0]["kilnID"].ToString());
  1006. int kilnID = Convert.ToInt32(dr[0]["kilnID"].ToString());
  1007. // 窑车ID
  1008. //int kilnCarID = Convert.ToInt32(barcodeTable.Rows[0]["KilnCarID"].ToString());
  1009. int kilnCarID = Convert.ToInt32(dr[0]["KilnCarID"].ToString());
  1010. // 窑车Code
  1011. // string kilnCarCode = barcodeTable.Rows[0]["kilnCarCode"].ToString();
  1012. string kilnCarCode = dr[0]["kilnCarCode"].ToString();
  1013. #region 校验窑车是否可装车
  1014. errMsg = CheckKilnCarrStatus(oracleTrConn, procedure.ProcedureID, kilnCarCode, procedure.ModelType, sUserInfo, out kilnCarStatus);
  1015. if (!string.IsNullOrEmpty(errMsg))
  1016. {
  1017. return errMsg;
  1018. }
  1019. #endregion
  1020. #region 如果窑车状态为空,需要插入窑车状态表
  1021. if (string.IsNullOrEmpty(kilnCarStatus))
  1022. {
  1023. // 自动生成窑车烧成批次号
  1024. kilnCarBatchNo = GetFiredKilnCarBatchNo(oracleTrConn, kilnCarID);
  1025. // 插入窑车状态表
  1026. errMsg = AddkilnCarStatus(oracleTrConn, procedure, kilnCarID, kilnID, kilnCarBatchNo, sUserInfo);
  1027. if (!string.IsNullOrEmpty(errMsg))
  1028. {
  1029. return errMsg;
  1030. }
  1031. }
  1032. #endregion
  1033. #region 窑车表存在,查询本次窑车产品的批次号 并更改装窑车时间
  1034. // 查询本次窑车产品的批次号
  1035. else
  1036. {
  1037. kilnCarBatchNo = GetKilnCarBatchNoByKilnCarID(oracleTrConn, kilnCarID);
  1038. // 更改窑车状态表入窑时间
  1039. errMsg = UpdatekilnCarStatus(oracleTrConn, kilnCarID, Constant.ProcedureModelType.LoadCar, sUserInfo, procedure, kilnCarBatchNo);
  1040. if (!string.IsNullOrEmpty(errMsg))
  1041. {
  1042. return errMsg;
  1043. }
  1044. }
  1045. #endregion
  1046. // 条码信息
  1047. DataView dvFilter = barcodeTable.DefaultView;
  1048. dvFilter.RowFilter = "kilnCarCode='" + dtNewKiln.Rows[i]["kilnCarCode"].ToString() + "'";
  1049. DataTable dtNew = dvFilter.ToTable();
  1050. // 条码信息
  1051. //foreach (DataRow barcodeRow in barcodeTable.Rows)
  1052. //--------------------------------
  1053. string sqllast = "select max(createtime) as createtime from TP_PM_KilnCarGoods"
  1054. + " where KilnCarID=:KilnCarID and AccountID=:AccountID";
  1055. OracleParameter[] paras = new OracleParameter[] {
  1056. new OracleParameter(":KilnCarID",kilnCarID),
  1057. new OracleParameter(":AccountID",sUserInfo.AccountID),
  1058. };
  1059. DataSet dsReturn = oracleTrConn.GetSqlResultToDs(sqllast, paras);
  1060. object lastcreatetime = null;
  1061. if (dsReturn != null && dsReturn.Tables[0].Rows.Count > 0 && dsReturn.Tables[0].Rows[0]["CreateTime"].ToString() != "")
  1062. {
  1063. lastcreatetime = Convert.ToDateTime(dsReturn.Tables[0].Rows[0]["CreateTime"]);
  1064. }
  1065. //--------------------------------
  1066. int? maxClassesSettingID = null;
  1067. foreach (DataRow barcodeRow in dtNew.Rows)
  1068. {
  1069. // 条码
  1070. string barcode = barcodeRow["Barcode"].ToString();
  1071. // 生产工号
  1072. workUserID = Convert.ToInt32(barcodeRow["UserID"]);
  1073. workUserCode = barcodeRow["UserCode"].ToString();
  1074. workUserName = barcodeRow["UserName"].ToString();
  1075. #region 校验条码有效性
  1076. errMsg = CheckBarcode(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo);
  1077. if (!string.IsNullOrEmpty(errMsg))
  1078. {
  1079. return errMsg;
  1080. }
  1081. #endregion
  1082. // 查询新插入的生产数据ID
  1083. string sql = "select SEQ_PM_ProductionData_ID.nextval from dual";
  1084. string idStr = oracleTrConn.GetSqlResultToStr(sql);
  1085. int productionDataID = 0;
  1086. if (!string.IsNullOrEmpty(idStr))
  1087. {
  1088. productionDataID = int.Parse(idStr);
  1089. }
  1090. else
  1091. {
  1092. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  1093. }
  1094. int? ClassesSettingID = null;//班次配置ID
  1095. #region 添加生产者数据
  1096. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID);
  1097. if (!string.IsNullOrEmpty(errMsg))
  1098. {
  1099. return errMsg;
  1100. }
  1101. #endregion
  1102. maxClassesSettingID = ClassesSettingID;
  1103. #region 添加生产数据
  1104. ProductionDataEntity productionData = new ProductionDataEntity();
  1105. #region 属性赋值
  1106. productionData.ClassesSettingID = ClassesSettingID;
  1107. productionData.ProductionDataID = Convert.ToInt32(idStr);
  1108. productionData.Barcode = barcode;
  1109. productionData.CentralizedBatchNo = centralizedBatchNo;
  1110. productionData.ProductionLineID = procedure.ProductionLineID;
  1111. productionData.ProductionLineCode = procedure.ProductionlineCode;
  1112. productionData.ProductionLineName = procedure.ProductionlineName;
  1113. productionData.CompleteProcedureID = procedure.ProcedureID;
  1114. productionData.ProcedureCode = procedure.ProcedureCode;
  1115. productionData.ProcedureName = procedure.ProcedureName;
  1116. productionData.ProcedureModel = procedure.ProcedureModel;
  1117. productionData.ModelType = procedure.ModelType;
  1118. productionData.NodeType = procedure.NodeType;
  1119. productionData.ReworkProcedureID = null;
  1120. productionData.PieceType = procedure.PieceType;
  1121. //productionData.IsPublicBody = (int)Constant.PublicBodyFlag.No;
  1122. if (procedure.IsSpecialRework == 0)
  1123. {
  1124. productionData.IsReFire = (int)Constant.ReFireFlag.No;
  1125. productionData.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  1126. }
  1127. else
  1128. {
  1129. productionData.IsReFire = (int)Constant.GoodsLevelType.ReFire;
  1130. productionData.DefectFlag = (int)Constant.GoodsLevelType.Defect;
  1131. }
  1132. //productionData.GoodsGrade = (int)Constant.GoodsLevelType.NoDefects;
  1133. //if (lastcreatetime != null)
  1134. //{
  1135. // productionData.CreateTime = Convert.ToDateTime(lastcreatetime);
  1136. //}
  1137. //不加条件valueflag,是因为,成检后重烧走过之后,在次重烧,以后也是重烧状态
  1138. ////string sqlReFire = "select * from tp_PM_ProductionData where ProductionDataid=(select max(ProductionDataid) from tp_PM_ProductionData where barcode='" + productionData.Barcode + "')";
  1139. ////DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire);
  1140. ////if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0)
  1141. ////{
  1142. //// if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0)
  1143. //// {
  1144. //// productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]);
  1145. //// }
  1146. ////}
  1147. productionData.OrganizationID = procedure.OrganizationID;
  1148. productionData.GoodsID = goodsID;
  1149. productionData.GoodsCode = goodsCode;
  1150. productionData.GoodsName = goodsName;
  1151. productionData.UserID = workUserID;
  1152. productionData.UserCode = barcodeRow["UserCode"].ToString();
  1153. productionData.UserName = barcodeRow["UserName"].ToString();
  1154. productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, barcode);
  1155. #region 窑炉窑车属性
  1156. productionData.KilnID = Convert.ToInt32(barcodeRow["KilnID"].ToString());
  1157. productionData.KilnCode = barcodeRow["KilnCode"].ToString();
  1158. productionData.KilnName = barcodeRow["KilnName"].ToString();
  1159. productionData.KilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString());
  1160. productionData.KilnCarCode = barcodeRow["KilnCarCode"].ToString();
  1161. productionData.KilnCarName = barcodeRow["KilnCarName"].ToString();
  1162. productionData.KilnCarBatchNo = kilnCarBatchNo;
  1163. productionData.KilnCarPosition = Convert.ToInt32(barcodeRow["KilnCarPosition"].ToString());
  1164. #endregion
  1165. #endregion
  1166. string OutSpecialRepairflag = "0";//干补标识
  1167. //if (lastcreatetime == null)
  1168. //{
  1169. errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag);
  1170. //}
  1171. //else
  1172. //{
  1173. // errMsg = AddProductionDataCreateTime(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag);
  1174. //}
  1175. if (!string.IsNullOrEmpty(errMsg))
  1176. {
  1177. return errMsg;
  1178. }
  1179. #endregion
  1180. #region 修改在产产品数据的当前工序,清空返工工序字段
  1181. InProductionEntity addInProductionEntity = new InProductionEntity();
  1182. addInProductionEntity.BarCode = barcode;
  1183. //流程工序
  1184. addInProductionEntity.FlowProcedureID = procedure.ProcedureID;
  1185. // 当前工序
  1186. //addInProductionEntity.CompleteProcedureID = procedure.ProcedureID;
  1187. addInProductionEntity.ProcedureID = procedure.ProcedureID;
  1188. //生产数据ID
  1189. addInProductionEntity.ProductionDataID = productionDataID;
  1190. // 工序模型
  1191. addInProductionEntity.ProcedureModel = procedure.ProcedureModel;
  1192. // 工序类别
  1193. addInProductionEntity.ModelType = procedure.ModelType;
  1194. // 生产工号
  1195. addInProductionEntity.UserID = workUserID;
  1196. // 缺陷标识
  1197. //addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  1198. #region 更新在产表窑车窑炉字段
  1199. addInProductionEntity.KilnID = Convert.ToInt32(barcodeRow["KilnID"].ToString());
  1200. addInProductionEntity.KilnCode = barcodeRow["KilnCode"].ToString();
  1201. addInProductionEntity.KilnName = barcodeRow["KilnName"].ToString();
  1202. addInProductionEntity.KilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString());
  1203. addInProductionEntity.KilnCarCode = barcodeRow["KilnCarCode"].ToString();
  1204. addInProductionEntity.KilnCarName = barcodeRow["KilnCarName"].ToString();
  1205. addInProductionEntity.KilnCarBatchNo = kilnCarBatchNo;
  1206. addInProductionEntity.KilnCarPosition = Convert.ToInt32(barcodeRow["KilnCarPosition"].ToString());
  1207. #endregion
  1208. if (procedure.IsSpecialRework == 0)
  1209. {
  1210. addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  1211. }
  1212. else
  1213. {
  1214. addInProductionEntity.IsReFire = (int)Constant.GoodsLevelType.ReFire;
  1215. addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  1216. }
  1217. // 执行修改
  1218. errMsg = UpdateInProduction(oracleTrConn, addInProductionEntity, sUserInfo);
  1219. // 执行失败
  1220. if (!string.IsNullOrEmpty(errMsg))
  1221. {
  1222. return errMsg;
  1223. }
  1224. #endregion
  1225. //#region 添加生产者数据
  1226. //errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo);
  1227. //if (!string.IsNullOrEmpty(errMsg))
  1228. //{
  1229. // return errMsg;
  1230. //}
  1231. //#endregion
  1232. //errMsg = UpdateKilnCarCreatetimeInfoBybarcode(oracleTrConn, productionData, sUserInfo);
  1233. //if (!string.IsNullOrEmpty(errMsg))
  1234. //{
  1235. // return errMsg;
  1236. //}
  1237. #region 插入窑车产品表
  1238. errMsg = AddKilnCarGoods(oracleTrConn,
  1239. barcode,
  1240. kilnCarID,
  1241. goodsID,
  1242. productionData.KilnCarPosition.Value,
  1243. kilnCarBatchNo,
  1244. workUserID,
  1245. workUserCode,
  1246. workUserName,
  1247. sUserInfo);
  1248. if (!string.IsNullOrEmpty(errMsg))
  1249. {
  1250. return errMsg;
  1251. }
  1252. #endregion
  1253. //#region 装车后,更新所有以前操作的工序窑车信息
  1254. //errMsg = UpdateKilnCarInfoBybarcode(oracleTrConn, productionData);
  1255. //if (!string.IsNullOrEmpty(errMsg))
  1256. //{
  1257. // return errMsg;
  1258. //}
  1259. //#endregion
  1260. }
  1261. #region 窑车生产数据
  1262. #region 插入窑车生产数据表
  1263. if (lastcreatetime == null) //加此判断为的是,在登车时落产品,进行第二些登车时,不插重复数据
  1264. {
  1265. errMsg = AddKilnCarData(oracleTrConn,
  1266. accountDate,
  1267. kilnCarID,
  1268. kilnCarBatchNo,
  1269. workUserID,
  1270. workUserCode,
  1271. workUserName,
  1272. null,
  1273. sUserInfo, maxClassesSettingID);
  1274. #region 窑车生产者
  1275. if (!string.IsNullOrEmpty(errMsg))
  1276. {
  1277. return errMsg;
  1278. }
  1279. #endregion
  1280. }
  1281. #endregion
  1282. #endregion
  1283. }
  1284. return errMsg;
  1285. }
  1286. catch (Exception ex)
  1287. {
  1288. throw ex;
  1289. }
  1290. }
  1291. /// <summary>
  1292. /// 装车后,更新所有以前操作的工序窑车信息
  1293. /// </summary>
  1294. /// <param name="oracleTrConn">连接对象</param>
  1295. /// <param name="barcode">条码</param>
  1296. /// <param name="kilnCarID">窑车号</param>
  1297. /// <param name="goodsID">产品ID</param>
  1298. /// <param name="KilnCarPosition">窑车位置</param>
  1299. /// <param name="kilnCarBatchNo">装车批次</param>
  1300. /// <param name="sUserInfo">用户基本信息</param>
  1301. /// <returns>string</returns>
  1302. private static string UpdateKilnCarInfoBybarcode(IDBTransaction oracleTrConn, ProductionDataEntity productionData)
  1303. {
  1304. string sql = "update TP_PM_ProductionData set "
  1305. + " KilnID=:KilnID,"
  1306. + "KilnCode=:KilnCode,"
  1307. + "KilnName=:KilnName,"
  1308. + "KilnCarID=:KilnCarID,"
  1309. + "KilnCarCode=:KilnCarCode,"
  1310. + "KilnCarName=:KilnCarName,"
  1311. + "KilnCarBatchNo=:KilnCarBatchNo,"
  1312. + "KilnCarPosition=:KilnCarPosition,"
  1313. + "isrefire=:isrefire "
  1314. + " where barcode=:barcode";
  1315. #region 参数
  1316. OracleParameter[] paras = new OracleParameter[] {
  1317. new OracleParameter(":KilnID",productionData.KilnID),
  1318. new OracleParameter(":KilnCode",productionData.KilnCode),
  1319. new OracleParameter(":KilnName",productionData.KilnName),
  1320. new OracleParameter(":KilnCarID",productionData.KilnCarID),
  1321. new OracleParameter(":KilnCarCode",productionData.KilnCarCode),
  1322. new OracleParameter(":KilnCarName",productionData.KilnCarName),
  1323. new OracleParameter(":KilnCarBatchNo",productionData.KilnCarBatchNo),
  1324. new OracleParameter(":KilnCarPosition",productionData.KilnCarPosition),
  1325. new OracleParameter(":isrefire",productionData.IsReFire),
  1326. new OracleParameter(":barcode",productionData.Barcode),
  1327. };
  1328. #endregion
  1329. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  1330. // 保存失败
  1331. if (result == Constant.INT_IS_ZERO)
  1332. {
  1333. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  1334. }
  1335. // 保存成功返回null
  1336. return null;
  1337. }
  1338. /// <summary>
  1339. /// 入窑车计件
  1340. /// </summary>
  1341. /// <param name="oracleTrConn">数据连接对象</param>
  1342. /// <param name="procedure">工序对象</param>
  1343. /// <param name="barcodeTable">条码信息</param>
  1344. /// <param name="sUserInfo">基本</param>
  1345. /// <param name="goodsID">返回的产品ID</param>
  1346. /// <param name="goodsCode">返回的产品Code</param>
  1347. /// <param name="goodsName">返回的产品名称</param>
  1348. /// <returns>string</returns>
  1349. /// <remarks>
  1350. /// 张国印 2014.10.04 新建
  1351. /// </remarks>
  1352. private static string AddIntoKilnCar(IDBTransaction oracleTrConn, ProcedureEntity procedure, DataTable barcodeTable, SUserInfo sUserInfo,
  1353. out int goodsID, out string goodsCode, out string goodsName)
  1354. {
  1355. try
  1356. {
  1357. goodsID = Constant.INT_IS_ZERO;
  1358. goodsCode = string.Empty;
  1359. goodsName = string.Empty;
  1360. string groutingUserCode = string.Empty;
  1361. // 获得账务日期
  1362. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  1363. string errMsg = string.Empty;
  1364. // 生产工号
  1365. int workUserID = Constant.INT_IS_ZERO;
  1366. // 生产工号Code
  1367. string workUserCode = string.Empty;
  1368. // 生产工号Name
  1369. string workUserName = string.Empty;
  1370. // 本批采集的批次号
  1371. string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  1372. // 窑车批次号
  1373. string kilnCarBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  1374. // 窑车状态
  1375. string kilnCarStatus = string.Empty;
  1376. //////////////////////////////////////////////////
  1377. DataView dv = barcodeTable.DefaultView;
  1378. DataTable dtNewKiln = dv.ToTable(true, "kilnCarCode");
  1379. for (int i = 0; i < dtNewKiln.Rows.Count; i++)
  1380. {
  1381. ///////////////////////////////////////////////////
  1382. // 窑车Code
  1383. //string kilnCarCode = barcodeTable.Rows[0]["kilnCarCode"].ToString();
  1384. DataRow[] dr = barcodeTable.Select("kilnCarCode='" + dtNewKiln.Rows[i]["kilnCarCode"].ToString() + "'");
  1385. string kilnCarCode = dr[0]["kilnCarCode"].ToString();
  1386. #region 校验窑车是否可入窑炉
  1387. errMsg = CheckKilnCarrStatus(oracleTrConn, procedure.ProcedureID, kilnCarCode, procedure.ModelType, sUserInfo, out kilnCarStatus);
  1388. if (!string.IsNullOrEmpty(errMsg))
  1389. {
  1390. return errMsg;
  1391. }
  1392. #endregion
  1393. // 窑炉ID
  1394. //int kilnID = Convert.ToInt32(barcodeTable.Rows[0]["kilnID"].ToString());
  1395. int kilnID = Convert.ToInt32(dr[0]["kilnID"].ToString());
  1396. // 窑车ID
  1397. //int kilnCarID = Convert.ToInt32(barcodeTable.Rows[0]["KilnCarID"].ToString());
  1398. int kilnCarID = Convert.ToInt32(dr[0]["KilnCarID"].ToString());
  1399. //备注信息
  1400. string Remarks = dr[0]["Remarks"].ToString();
  1401. // 主要目的防止输入窑车号,当前工序与该操作的工序不匹配,例如重烧入窑,在入窑工序上操作了
  1402. errMsg = GetKilnCarProcedureIDByKilnCarID(oracleTrConn, kilnCarID, Convert.ToInt32(procedure.ProcedureID));
  1403. if (!string.IsNullOrEmpty(errMsg))
  1404. {
  1405. return errMsg;
  1406. }
  1407. // 查询本次窑车产品的批次号
  1408. kilnCarBatchNo = GetKilnCarBatchNoByKilnCarID(oracleTrConn, kilnCarID);
  1409. #region 窑车表存在,查询本次窑车产品的批次号 并更改入窑车时间
  1410. //更改窑车状态表入窑时间
  1411. errMsg = UpdatekilnCarStatus(oracleTrConn, kilnCarID, Constant.ProcedureModelType.IntoKiln, sUserInfo, procedure, kilnCarBatchNo);
  1412. if (!string.IsNullOrEmpty(errMsg))
  1413. {
  1414. return errMsg;
  1415. }
  1416. #endregion
  1417. DataView dvFilter = barcodeTable.DefaultView;
  1418. dvFilter.RowFilter = "kilnCarCode='" + dtNewKiln.Rows[i]["kilnCarCode"].ToString() + "'";
  1419. DataTable dtNew = dvFilter.ToTable();
  1420. int? maxClassesSettingID = null;
  1421. // 条码信息
  1422. //foreach (DataRow barcodeRow in barcodeTable.Rows)
  1423. foreach (DataRow barcodeRow in dtNew.Rows)
  1424. {
  1425. // 条码
  1426. string barcode = barcodeRow["Barcode"].ToString();
  1427. // 生产工号
  1428. workUserID = Convert.ToInt32(barcodeRow["UserID"]);
  1429. workUserCode = barcodeRow["UserCode"].ToString();
  1430. workUserName = barcodeRow["UserName"].ToString();
  1431. // 查询新插入的生产数据ID
  1432. string sql = "select SEQ_PM_ProductionData_ID.nextval from dual";
  1433. string idStr = oracleTrConn.GetSqlResultToStr(sql);
  1434. int productionDataID = 0;
  1435. if (!string.IsNullOrEmpty(idStr))
  1436. {
  1437. productionDataID = int.Parse(idStr);
  1438. }
  1439. else
  1440. {
  1441. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  1442. }
  1443. int? ClassesSettingID = null;//班次配置ID
  1444. #region 添加生产者数据
  1445. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID);
  1446. if (!string.IsNullOrEmpty(errMsg))
  1447. {
  1448. return errMsg;
  1449. }
  1450. #endregion
  1451. maxClassesSettingID = ClassesSettingID;
  1452. #region 添加生产数据
  1453. ProductionDataEntity productionData = new ProductionDataEntity();
  1454. #region 属性赋值
  1455. productionData.ClassesSettingID = ClassesSettingID;
  1456. productionData.ProductionDataID = Convert.ToInt32(idStr);
  1457. productionData.Barcode = barcode;
  1458. productionData.CentralizedBatchNo = centralizedBatchNo;
  1459. productionData.ProductionLineID = procedure.ProductionLineID;
  1460. productionData.ProductionLineCode = procedure.ProductionlineCode;
  1461. productionData.ProductionLineName = procedure.ProductionlineName;
  1462. productionData.CompleteProcedureID = procedure.ProcedureID;
  1463. productionData.ProcedureCode = procedure.ProcedureCode;
  1464. productionData.ProcedureName = procedure.ProcedureName;
  1465. productionData.ProcedureModel = procedure.ProcedureModel;
  1466. productionData.ModelType = procedure.ModelType;
  1467. productionData.NodeType = procedure.NodeType;
  1468. productionData.DefectFlag = (int)Constant.DefectFlag.No;
  1469. productionData.ReworkProcedureID = null;
  1470. productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, barcode);
  1471. productionData.IsReFire = (int)Constant.ReFireFlag.No;
  1472. productionData.PieceType = procedure.PieceType;
  1473. //productionData.GoodsGrade = (int)Constant.GoodsGrade.Good;
  1474. //不加条件valueflag,是因为,成检后重烧走过之后,在次重烧,以后也是重烧状态
  1475. // string sqlReFire = "select * from tp_PM_ProductionData where ProductionDataid=(select max(ProductionDataid) from tp_PM_ProductionData where barcode='" + productionData.Barcode + "')";
  1476. ////// string sqlReFire = @"select
  1477. ////// isrefire
  1478. ////// from tp_pm_inproduction where barcode=:barcode
  1479. ////// ";
  1480. ////// OracleParameter[] ReFireparas = new OracleParameter[] {
  1481. ////// new OracleParameter(":barcode",barcode),
  1482. ////// };
  1483. ////// DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas);
  1484. ////// if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0)
  1485. ////// {
  1486. ////// if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0)
  1487. ////// {
  1488. ////// productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]);
  1489. ////// }
  1490. ////// }
  1491. productionData.OrganizationID = procedure.OrganizationID;
  1492. productionData.GoodsID = Convert.ToInt32(barcodeRow["GoodsID"]);
  1493. productionData.GoodsCode = barcodeRow["GoodsCode"].ToString();
  1494. productionData.GoodsName = barcodeRow["GoodsName"].ToString();
  1495. productionData.UserID = workUserID;
  1496. productionData.UserCode = barcodeRow["UserCode"].ToString();
  1497. productionData.UserName = barcodeRow["UserName"].ToString();
  1498. #region 窑炉窑车属性
  1499. productionData.KilnID = Convert.ToInt32(barcodeRow["KilnID"].ToString());
  1500. productionData.KilnCode = barcodeRow["KilnCode"].ToString();
  1501. productionData.KilnName = barcodeRow["KilnName"].ToString();
  1502. productionData.KilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString());
  1503. productionData.KilnCarCode = barcodeRow["KilnCarCode"].ToString();
  1504. productionData.KilnCarName = barcodeRow["KilnCarName"].ToString();
  1505. productionData.KilnCarBatchNo = kilnCarBatchNo;
  1506. productionData.KilnCarPosition = Convert.ToInt32(barcodeRow["KilnCarPosition"].ToString());
  1507. productionData.Remarks = "";
  1508. #endregion
  1509. #endregion
  1510. string OutSpecialRepairflag = "0";//干补标识
  1511. errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag);
  1512. if (!string.IsNullOrEmpty(errMsg))
  1513. {
  1514. return errMsg;
  1515. }
  1516. #endregion
  1517. #region 修改在产产品数据的当前工序,清空返工工序字段
  1518. InProductionEntity addInProductionEntity = new InProductionEntity();
  1519. addInProductionEntity.BarCode = barcode;
  1520. //流程工序
  1521. addInProductionEntity.FlowProcedureID = procedure.ProcedureID;
  1522. // 当前工序
  1523. //addInProductionEntity.CompleteProcedureID = procedure.ProcedureID;
  1524. addInProductionEntity.ProcedureID = procedure.ProcedureID;
  1525. //生产数据ID
  1526. addInProductionEntity.ProductionDataID = productionDataID;
  1527. // 工序模型
  1528. addInProductionEntity.ProcedureModel = procedure.ProcedureModel;
  1529. // 工序类别
  1530. addInProductionEntity.ModelType = procedure.ModelType;
  1531. // 生产工号
  1532. addInProductionEntity.UserID = workUserID;
  1533. // 缺陷标识
  1534. addInProductionEntity.DefectFlag = (int)Constant.DefectFlag.No;
  1535. #region 更新在产表窑车窑炉字段
  1536. addInProductionEntity.KilnID = Convert.ToInt32(barcodeRow["KilnID"].ToString());
  1537. addInProductionEntity.KilnCode = barcodeRow["KilnCode"].ToString();
  1538. addInProductionEntity.KilnName = barcodeRow["KilnName"].ToString();
  1539. addInProductionEntity.KilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString());
  1540. addInProductionEntity.KilnCarCode = barcodeRow["KilnCarCode"].ToString();
  1541. addInProductionEntity.KilnCarName = barcodeRow["KilnCarName"].ToString();
  1542. addInProductionEntity.KilnCarBatchNo = kilnCarBatchNo;
  1543. addInProductionEntity.KilnCarPosition = Convert.ToInt32(barcodeRow["KilnCarPosition"].ToString());
  1544. #endregion
  1545. // 执行修改
  1546. errMsg = UpdateInProduction(oracleTrConn, addInProductionEntity, sUserInfo);
  1547. // 执行失败
  1548. if (!string.IsNullOrEmpty(errMsg))
  1549. {
  1550. return errMsg;
  1551. }
  1552. #endregion
  1553. //#region 添加生产者数据
  1554. //errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo);
  1555. //if (!string.IsNullOrEmpty(errMsg))
  1556. //{
  1557. // return errMsg;
  1558. //}
  1559. //#endregion
  1560. }
  1561. #region 插入窑车生产数据表
  1562. errMsg = AddKilnCarData(oracleTrConn,
  1563. accountDate,
  1564. kilnCarID,
  1565. kilnCarBatchNo,
  1566. workUserID,
  1567. workUserCode,
  1568. workUserName,
  1569. Remarks,
  1570. sUserInfo, maxClassesSettingID);
  1571. if (!string.IsNullOrEmpty(errMsg))
  1572. {
  1573. return errMsg;
  1574. }
  1575. #endregion
  1576. //#region 窑车生产者
  1577. //// 查询新插入的生产数据ID
  1578. //string sqlKilnCar = "select SEQ_PM_KilnCarData_ID.Currval from dual";
  1579. //string idKilnCar = oracleTrConn.GetSqlResultToStr(sqlKilnCar);
  1580. //errMsg = AddKilnCarProducer(oracleTrConn, accountDate, Convert.ToInt32(idKilnCar), workUserID, sUserInfo);
  1581. //if (!string.IsNullOrEmpty(errMsg))
  1582. //{
  1583. // return errMsg;
  1584. //}
  1585. //#endregion
  1586. }
  1587. return errMsg;
  1588. }
  1589. catch (Exception ex)
  1590. {
  1591. throw ex;
  1592. }
  1593. }
  1594. /// <summary>
  1595. /// 校验窑车的工序与当前工序是否可以到达(重烧后,未走重烧入窑)
  1596. /// </summary>
  1597. /// <param name="oracleTrConn">数据连接</param>
  1598. /// <param name="barcode">产品条码</param>
  1599. /// <returns>string</returns>
  1600. private static string GetKilnCarProcedureIDByKilnCarID(IDBTransaction oracleTrConn, int KilnCarID, int ProcedureID)
  1601. {
  1602. string sql = @"select ProcedureID from TP_PM_KilnCarStatus where KilnCarID=:KilnCarID";
  1603. OracleParameter[] paras = new OracleParameter[] {
  1604. new OracleParameter(":KilnCarID", KilnCarID) ,
  1605. };
  1606. int currentProcedureID = 0;
  1607. DataSet result = oracleTrConn.GetSqlResultToDs(sql, paras);
  1608. if (result != null && result.Tables[0].Rows.Count > 0)
  1609. {
  1610. currentProcedureID = Convert.ToInt32(result.Tables[0].Rows[0][0]);
  1611. }
  1612. sql = @"select pro.ProcedureID
  1613. from TP_PC_ProcedureFlow flow
  1614. inner join TP_PC_Procedure pro
  1615. on flow.arriveprocedureid = pro.procedureid
  1616. inner join TP_PC_ProductionLine line
  1617. on pro.ProductionLineID = line.ProductionLineID
  1618. where flow.ProcedureID = :currentProcedureID
  1619. and flow.FlowFlag = 2";
  1620. paras = new OracleParameter[] {
  1621. new OracleParameter(":currentProcedureID", currentProcedureID) ,
  1622. };
  1623. result = oracleTrConn.GetSqlResultToDs(sql, paras);
  1624. int returnProcedureID = 0;
  1625. if (result != null && result.Tables[0].Rows.Count > 0)
  1626. {
  1627. if (result.Tables[0].Select("ProcedureID=" + ProcedureID).Length > 0)
  1628. {
  1629. returnProcedureID = 1;
  1630. }
  1631. }
  1632. // 保存失败
  1633. if (returnProcedureID == 0)
  1634. {
  1635. return string.Format("当前工序不允许进行操作", "条码", "保存");
  1636. }
  1637. return null;
  1638. }
  1639. /// <summary>
  1640. /// 出窑车计件
  1641. /// </summary>
  1642. /// <param name="oracleTrConn">数据连接对象</param>
  1643. /// <param name="procedure">工序对象</param>
  1644. /// <param name="barcodeTable">条码信息</param>
  1645. /// <param name="sUserInfo">用户基本信息</param>
  1646. /// <param name="goodsID">返回的产品ID</param>
  1647. /// <param name="goodsCode">返回的产品Code</param>
  1648. /// <param name="goodsName">返回的产品名称</param>
  1649. /// <returns>string</returns>
  1650. /// <remarks>
  1651. /// 张国印 2014.10.04 新建
  1652. /// </remarks>
  1653. private static string AddOutKilnCar(IDBTransaction oracleTrConn, ProcedureEntity procedure, DataTable barcodeTable, SUserInfo sUserInfo,
  1654. out int goodsID, out string goodsCode, out string goodsName)
  1655. {
  1656. try
  1657. {
  1658. goodsID = Constant.INT_IS_ZERO;
  1659. goodsCode = string.Empty;
  1660. goodsName = string.Empty;
  1661. string groutingUserCode = string.Empty;
  1662. // 获得账务日期
  1663. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  1664. string errMsg = string.Empty;
  1665. // 生产工号
  1666. int workUserID = Constant.INT_IS_ZERO;
  1667. // 生产工号Code
  1668. string workUserCode = string.Empty;
  1669. // 生产工号Name
  1670. string workUserName = string.Empty;
  1671. // 本批采集的批次号
  1672. string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  1673. // 窑车批次号
  1674. string kilnCarBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  1675. // 窑车状态
  1676. string kilnCarStatus = string.Empty;
  1677. //////////////////////////////////////////////////
  1678. DataView dv = barcodeTable.DefaultView;
  1679. DataTable dtNewKiln = dv.ToTable(true, "kilnCarCode");
  1680. for (int i = 0; i < dtNewKiln.Rows.Count; i++)
  1681. {
  1682. // 窑车Code
  1683. //string kilnCarCode = barcodeTable.Rows[0]["kilnCarCode"].ToString();
  1684. DataRow[] dr = barcodeTable.Select("kilnCarCode='" + dtNewKiln.Rows[i]["kilnCarCode"].ToString() + "'");
  1685. string kilnCarCode = dr[0]["kilnCarCode"].ToString();
  1686. string Remarks = dr[0]["Remarks"].ToString();
  1687. #region 校验窑车是否可出窑炉
  1688. errMsg = CheckKilnCarrStatus(oracleTrConn, procedure.ProcedureID, kilnCarCode, procedure.ModelType, sUserInfo, out kilnCarStatus);
  1689. if (!string.IsNullOrEmpty(errMsg))
  1690. {
  1691. return errMsg;
  1692. }
  1693. #endregion
  1694. // 窑炉ID
  1695. //int kilnID = Convert.ToInt32(barcodeTable.Rows[0]["kilnID"].ToString());
  1696. int kilnID = Convert.ToInt32(dr[0]["kilnID"].ToString());
  1697. // 窑车ID
  1698. //int kilnCarID = Convert.ToInt32(barcodeTable.Rows[0]["KilnCarID"].ToString());
  1699. int kilnCarID = Convert.ToInt32(dr[0]["KilnCarID"].ToString());
  1700. // 主要目的防止输入窑车号,当前工序与该操作的工序不匹配,例如重烧入窑,在入窑工序上操作了
  1701. errMsg = GetKilnCarProcedureIDByKilnCarID(oracleTrConn, kilnCarID, Convert.ToInt32(procedure.ProcedureID));
  1702. if (!string.IsNullOrEmpty(errMsg))
  1703. {
  1704. return errMsg;
  1705. }
  1706. // 查询本次窑车产品的批次号
  1707. kilnCarBatchNo = GetKilnCarBatchNoByKilnCarID(oracleTrConn, kilnCarID);
  1708. #region 窑车表存在,查询本次窑车产品的批次号 并更改出窑车时间
  1709. //更改窑车状态表入窑时间
  1710. errMsg = UpdatekilnCarStatus(oracleTrConn, kilnCarID, Constant.ProcedureModelType.OutKiln, sUserInfo, procedure, kilnCarBatchNo);
  1711. if (!string.IsNullOrEmpty(errMsg))
  1712. {
  1713. return errMsg;
  1714. }
  1715. #endregion
  1716. //// 条码信息
  1717. DataView dvFilter = barcodeTable.DefaultView;
  1718. dvFilter.RowFilter = "kilnCarCode='" + dtNewKiln.Rows[i]["kilnCarCode"].ToString() + "'";
  1719. DataTable dtNew = dvFilter.ToTable();
  1720. int? maxClassesSettingID = null;
  1721. // 条码信息
  1722. //foreach (DataRow barcodeRow in barcodeTable.Rows)
  1723. foreach (DataRow barcodeRow in dtNew.Rows)
  1724. {
  1725. // 条码
  1726. string barcode = barcodeRow["Barcode"].ToString();
  1727. // 生产工号
  1728. workUserID = Convert.ToInt32(barcodeRow["UserID"]);
  1729. workUserCode = barcodeRow["UserCode"].ToString();
  1730. workUserName = barcodeRow["UserName"].ToString();
  1731. // 查询新插入的生产数据ID
  1732. string sql = "select SEQ_PM_ProductionData_ID.nextval from dual";
  1733. string idStr = oracleTrConn.GetSqlResultToStr(sql);
  1734. int productionDataID = 0;
  1735. if (!string.IsNullOrEmpty(idStr))
  1736. {
  1737. productionDataID = int.Parse(idStr);
  1738. }
  1739. else
  1740. {
  1741. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  1742. }
  1743. int? ClassesSettingID = null;//班次配置ID
  1744. #region 添加生产者数据
  1745. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID);
  1746. if (!string.IsNullOrEmpty(errMsg))
  1747. {
  1748. return errMsg;
  1749. }
  1750. #endregion
  1751. maxClassesSettingID = ClassesSettingID;
  1752. #region 添加生产数据
  1753. ProductionDataEntity productionData = new ProductionDataEntity();
  1754. #region 属性赋值
  1755. productionData.ClassesSettingID = ClassesSettingID;
  1756. productionData.ProductionDataID = Convert.ToInt32(idStr);
  1757. productionData.Barcode = barcode;
  1758. productionData.CentralizedBatchNo = centralizedBatchNo;
  1759. productionData.ProductionLineID = procedure.ProductionLineID;
  1760. productionData.ProductionLineCode = procedure.ProductionlineCode;
  1761. productionData.ProductionLineName = procedure.ProductionlineName;
  1762. productionData.CompleteProcedureID = procedure.ProcedureID;
  1763. productionData.ProcedureCode = procedure.ProcedureCode;
  1764. productionData.ProcedureName = procedure.ProcedureName;
  1765. productionData.ProcedureModel = procedure.ProcedureModel;
  1766. productionData.ModelType = procedure.ModelType;
  1767. productionData.NodeType = procedure.NodeType;
  1768. productionData.DefectFlag = (int)Constant.DefectFlag.No;
  1769. productionData.ReworkProcedureID = null;
  1770. productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, barcode);
  1771. productionData.IsReFire = (int)Constant.ReFireFlag.No;
  1772. productionData.PieceType = procedure.PieceType;
  1773. //productionData.GoodsGrade = (int)Constant.GoodsGrade.Good;
  1774. ////// string sqlReFire = @"select
  1775. ////// isrefire
  1776. ////// from tp_pm_inproduction where barcode=:barcode
  1777. ////// ";
  1778. ////// OracleParameter[] ReFireparas = new OracleParameter[] {
  1779. ////// new OracleParameter(":barcode",barcode),
  1780. ////// };
  1781. ////// DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas);
  1782. ////// if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0)
  1783. ////// {
  1784. ////// if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0)
  1785. ////// {
  1786. ////// productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]);
  1787. ////// }
  1788. ////// }
  1789. productionData.OrganizationID = procedure.OrganizationID;
  1790. productionData.GoodsID = Convert.ToInt32(barcodeRow["GoodsID"]);
  1791. productionData.GoodsCode = barcodeRow["GoodsCode"].ToString();
  1792. productionData.GoodsName = barcodeRow["GoodsName"].ToString();
  1793. productionData.UserID = workUserID;
  1794. productionData.UserCode = barcodeRow["UserCode"].ToString();
  1795. productionData.UserName = barcodeRow["UserName"].ToString();
  1796. #region 窑炉窑车属性
  1797. productionData.KilnID = Convert.ToInt32(barcodeRow["KilnID"].ToString());
  1798. productionData.KilnCode = barcodeRow["KilnCode"].ToString();
  1799. productionData.KilnName = barcodeRow["KilnName"].ToString();
  1800. productionData.KilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString());
  1801. productionData.KilnCarCode = barcodeRow["KilnCarCode"].ToString();
  1802. productionData.KilnCarName = barcodeRow["KilnCarName"].ToString();
  1803. productionData.KilnCarBatchNo = kilnCarBatchNo;
  1804. productionData.KilnCarPosition = Convert.ToInt32(barcodeRow["KilnCarPosition"].ToString());
  1805. productionData.Remarks = barcodeRow["Remarks"].ToString();
  1806. #endregion
  1807. #endregion
  1808. string OutSpecialRepairflag = "0";//干补标识
  1809. errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag);
  1810. if (!string.IsNullOrEmpty(errMsg))
  1811. {
  1812. return errMsg;
  1813. }
  1814. #endregion
  1815. #region 修改在产产品数据的当前工序,清空返工工序字段
  1816. InProductionEntity addInProductionEntity = new InProductionEntity();
  1817. addInProductionEntity.BarCode = barcode;
  1818. //流程工序
  1819. addInProductionEntity.FlowProcedureID = procedure.ProcedureID;
  1820. // 当前工序
  1821. //addInProductionEntity.CompleteProcedureID = procedure.ProcedureID;
  1822. addInProductionEntity.ProcedureID = procedure.ProcedureID;
  1823. // 生产数据ID
  1824. addInProductionEntity.ProductionDataID = productionDataID;
  1825. // 工序模型
  1826. addInProductionEntity.ProcedureModel = procedure.ProcedureModel;
  1827. // 工序类别
  1828. addInProductionEntity.ModelType = procedure.ModelType;
  1829. // 生产工号
  1830. addInProductionEntity.UserID = workUserID;
  1831. // 缺陷标识
  1832. addInProductionEntity.DefectFlag = (int)Constant.DefectFlag.No;
  1833. #region 更新在产表窑车窑炉字段
  1834. addInProductionEntity.KilnID = Convert.ToInt32(barcodeRow["KilnID"].ToString());
  1835. addInProductionEntity.KilnCode = barcodeRow["KilnCode"].ToString();
  1836. addInProductionEntity.KilnName = barcodeRow["KilnName"].ToString();
  1837. addInProductionEntity.KilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString());
  1838. addInProductionEntity.KilnCarCode = barcodeRow["KilnCarCode"].ToString();
  1839. addInProductionEntity.KilnCarName = barcodeRow["KilnCarName"].ToString();
  1840. addInProductionEntity.KilnCarBatchNo = kilnCarBatchNo;
  1841. addInProductionEntity.KilnCarPosition = Convert.ToInt32(barcodeRow["KilnCarPosition"].ToString());
  1842. #endregion
  1843. // 执行修改
  1844. errMsg = UpdateInProduction(oracleTrConn, addInProductionEntity, sUserInfo);
  1845. // 执行失败
  1846. if (!string.IsNullOrEmpty(errMsg))
  1847. {
  1848. return errMsg;
  1849. }
  1850. #endregion
  1851. //#region 添加生产者数据
  1852. //errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo);
  1853. //if (!string.IsNullOrEmpty(errMsg))
  1854. //{
  1855. // return errMsg;
  1856. //}
  1857. //#endregion
  1858. }
  1859. #region 插入窑车生产数据表
  1860. errMsg = AddKilnCarData(oracleTrConn,
  1861. accountDate,
  1862. kilnCarID,
  1863. kilnCarBatchNo,
  1864. workUserID,
  1865. workUserCode,
  1866. workUserName,
  1867. Remarks,
  1868. sUserInfo, maxClassesSettingID);
  1869. if (!string.IsNullOrEmpty(errMsg))
  1870. {
  1871. return errMsg;
  1872. }
  1873. #endregion
  1874. //#region 窑车生产者
  1875. //// 查询新插入的生产数据ID
  1876. //string sqlKilnCar = "select SEQ_PM_KilnCarData_ID.Currval from dual";
  1877. //string idKilnCar = oracleTrConn.GetSqlResultToStr(sqlKilnCar);
  1878. //errMsg = AddKilnCarProducer(oracleTrConn, accountDate, Convert.ToInt32(idKilnCar), workUserID, sUserInfo);
  1879. //if (!string.IsNullOrEmpty(errMsg))
  1880. //{
  1881. // return errMsg;
  1882. //}
  1883. //#endregion
  1884. }
  1885. return errMsg;
  1886. }
  1887. catch (Exception ex)
  1888. {
  1889. throw ex;
  1890. }
  1891. }
  1892. /// <summary>
  1893. /// 卸窑车计件
  1894. /// </summary>
  1895. /// <param name="oracleTrConn">数据连接对象</param>
  1896. /// <param name="procedure">工序对象</param>
  1897. /// <param name="barcodeTable">条码信息</param>
  1898. /// <param name="sUserInfo">用户基本信息</param>
  1899. /// <param name="goodsID">返回的产品ID</param>
  1900. /// <param name="goodsCode">返回的产品Code</param>
  1901. /// <param name="goodsName">返回的产品名称</param>
  1902. /// <returns>string</returns>
  1903. /// <remarks>
  1904. /// 张国印 2014.10.04 新建
  1905. /// </remarks>
  1906. private static string AddUnloadingKilnCar(IDBTransaction oracleTrConn, ProcedureEntity procedure, DataTable barcodeTable, SUserInfo sUserInfo,
  1907. out int goodsID, out string goodsCode, out string goodsName)
  1908. {
  1909. try
  1910. {
  1911. goodsID = Constant.INT_IS_ZERO;
  1912. goodsCode = string.Empty;
  1913. goodsName = string.Empty;
  1914. string groutingUserCode = string.Empty;
  1915. // 获得账务日期
  1916. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  1917. string errMsg = string.Empty;
  1918. // 生产工号
  1919. int workUserID = Constant.INT_IS_ZERO;
  1920. // 生产工号Code
  1921. string workUserCode = string.Empty;
  1922. // 生产工号Name
  1923. string workUserName = string.Empty;
  1924. // 本批采集的批次号
  1925. string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  1926. string finishedloadbatchno = DateTime.Now.ToString("yyMMddHHmmss-") + centralizedBatchNo;
  1927. // 窑车批次号
  1928. string kilnCarBatchNo = null;//System.Guid.NewGuid().ToString().ToUpper();
  1929. // 窑车状态
  1930. string kilnCarStatus = string.Empty;
  1931. DataView dv = barcodeTable.DefaultView;
  1932. DataTable dtNewKiln = dv.ToTable(true, "kilnCarCode");
  1933. for (int i = 0; i < dtNewKiln.Rows.Count; i++)
  1934. {
  1935. // 窑车Code
  1936. //string kilnCarCode = barcodeTable.Rows[0]["kilnCarCode"].ToString();
  1937. DataRow[] dr = barcodeTable.Select("kilnCarCode='" + dtNewKiln.Rows[i]["kilnCarCode"].ToString() + "'");
  1938. string kilnCarCode = dr[0]["kilnCarCode"].ToString();
  1939. string Remarks = dr[0]["Remarks"].ToString();
  1940. #region 校验窑车是否可出窑炉
  1941. errMsg = CheckKilnCarrStatus(oracleTrConn, procedure.ProcedureID, kilnCarCode, procedure.ModelType, sUserInfo, out kilnCarStatus);
  1942. if (!string.IsNullOrEmpty(errMsg))
  1943. {
  1944. return errMsg;
  1945. }
  1946. #endregion
  1947. // 窑炉ID
  1948. //int kilnID = Convert.ToInt32(barcodeTable.Rows[0]["kilnID"].ToString());
  1949. int kilnID = Convert.ToInt32(dr[0]["kilnID"].ToString());
  1950. // 窑车ID
  1951. //int kilnCarID = Convert.ToInt32(barcodeTable.Rows[0]["KilnCarID"].ToString());
  1952. int kilnCarID = Convert.ToInt32(dr[0]["KilnCarID"].ToString());
  1953. // 主要目的防止输入窑车号,当前工序与该操作的工序不匹配,例如重烧入窑,在入窑工序上操作了
  1954. errMsg = GetKilnCarProcedureIDByKilnCarID(oracleTrConn, kilnCarID, Convert.ToInt32(procedure.ProcedureID));
  1955. if (!string.IsNullOrEmpty(errMsg))
  1956. {
  1957. return errMsg;
  1958. }
  1959. // 查询本次窑车产品的批次号
  1960. kilnCarBatchNo = GetKilnCarBatchNoByKilnCarID(oracleTrConn, kilnCarID);
  1961. #region 窑车表存在,查询本次窑车产品的批次号 并更改出窑车时间
  1962. //更改窑车状态表入窑时间
  1963. errMsg = UpdatekilnCarStatus(oracleTrConn, kilnCarID, Constant.ProcedureModelType.UnloadCar, sUserInfo, procedure, kilnCarBatchNo);
  1964. if (!string.IsNullOrEmpty(errMsg))
  1965. {
  1966. return errMsg;
  1967. }
  1968. #endregion
  1969. // 条码信息
  1970. DataView dvFilter = barcodeTable.DefaultView;
  1971. dvFilter.RowFilter = "kilnCarCode='" + dtNewKiln.Rows[i]["kilnCarCode"].ToString() + "'";
  1972. DataTable dtNew = dvFilter.ToTable();
  1973. int? maxClassesSettingID = null;
  1974. // 条码信息
  1975. //foreach (DataRow barcodeRow in barcodeTable.Rows)
  1976. foreach (DataRow barcodeRow in dtNew.Rows)
  1977. {
  1978. // 条码
  1979. string barcode = barcodeRow["Barcode"].ToString();
  1980. // 生产工号
  1981. workUserID = Convert.ToInt32(barcodeRow["UserID"]);
  1982. workUserCode = barcodeRow["UserCode"].ToString();
  1983. workUserName = barcodeRow["UserName"].ToString();
  1984. // 查询新插入的生产数据ID
  1985. string sql = "select SEQ_PM_ProductionData_ID.nextval from dual";
  1986. string idStr = oracleTrConn.GetSqlResultToStr(sql);
  1987. int productionDataID = 0;
  1988. if (!string.IsNullOrEmpty(idStr))
  1989. {
  1990. productionDataID = int.Parse(idStr);
  1991. }
  1992. else
  1993. {
  1994. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  1995. }
  1996. int? ClassesSettingID = null;//班次配置ID
  1997. #region 添加生产者数据
  1998. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID);
  1999. if (!string.IsNullOrEmpty(errMsg))
  2000. {
  2001. return errMsg;
  2002. }
  2003. #endregion
  2004. maxClassesSettingID = ClassesSettingID;
  2005. #region 添加生产数据
  2006. ProductionDataEntity productionData = new ProductionDataEntity();
  2007. #region 属性赋值
  2008. productionData.ClassesSettingID = ClassesSettingID;
  2009. productionData.ProductionDataID = Convert.ToInt32(idStr);
  2010. productionData.Barcode = barcode;
  2011. productionData.CentralizedBatchNo = centralizedBatchNo;
  2012. productionData.ProductionLineID = procedure.ProductionLineID;
  2013. productionData.ProductionLineCode = procedure.ProductionlineCode;
  2014. productionData.ProductionLineName = procedure.ProductionlineName;
  2015. productionData.CompleteProcedureID = procedure.ProcedureID;
  2016. productionData.ProcedureCode = procedure.ProcedureCode;
  2017. productionData.ProcedureName = procedure.ProcedureName;
  2018. productionData.ProcedureModel = procedure.ProcedureModel;
  2019. productionData.ModelType = procedure.ModelType;
  2020. productionData.NodeType = procedure.NodeType;
  2021. productionData.DefectFlag = (int)Constant.DefectFlag.No;
  2022. productionData.ReworkProcedureID = null;
  2023. productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, barcode);
  2024. productionData.IsReFire = (int)Constant.ReFireFlag.No;
  2025. productionData.GoodsGrade = (int)Constant.GoodsGrade.Good;
  2026. productionData.PieceType = procedure.PieceType;
  2027. ////// string sqlReFire = @"select
  2028. ////// isrefire
  2029. ////// from tp_pm_inproduction where barcode=:barcode
  2030. ////// ";
  2031. ////// OracleParameter[] ReFireparas = new OracleParameter[] {
  2032. ////// new OracleParameter(":barcode",barcode),
  2033. ////// };
  2034. ////// DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas);
  2035. ////// if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0)
  2036. ////// {
  2037. ////// if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0)
  2038. ////// {
  2039. ////// productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]);
  2040. ////// }
  2041. ////// }
  2042. productionData.OrganizationID = procedure.OrganizationID;
  2043. productionData.GoodsID = Convert.ToInt32(barcodeRow["GoodsID"]);
  2044. productionData.GoodsCode = barcodeRow["GoodsCode"].ToString();
  2045. productionData.GoodsName = barcodeRow["GoodsName"].ToString();
  2046. productionData.UserID = workUserID;
  2047. productionData.UserCode = barcodeRow["UserCode"].ToString();
  2048. productionData.UserName = barcodeRow["UserName"].ToString();
  2049. #region 窑炉窑车属性
  2050. productionData.KilnID = Convert.ToInt32(barcodeRow["KilnID"].ToString());
  2051. productionData.KilnCode = barcodeRow["KilnCode"].ToString();
  2052. productionData.KilnName = barcodeRow["KilnName"].ToString();
  2053. productionData.KilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString());
  2054. productionData.KilnCarCode = barcodeRow["KilnCarCode"].ToString();
  2055. productionData.KilnCarName = barcodeRow["KilnCarName"].ToString();
  2056. productionData.KilnCarBatchNo = kilnCarBatchNo;
  2057. productionData.KilnCarPosition = Convert.ToInt32(barcodeRow["KilnCarPosition"].ToString());
  2058. productionData.Remarks = barcodeRow["Remarks"].ToString();
  2059. #endregion
  2060. #endregion
  2061. string OutSpecialRepairflag = "0";//干补标识
  2062. errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag);
  2063. if (!string.IsNullOrEmpty(errMsg))
  2064. {
  2065. return errMsg;
  2066. }
  2067. #endregion
  2068. if (procedure.NodeType == Constant.ProcedureNodeType.Middle.GetHashCode())
  2069. {
  2070. #region 中间工序 修改在产产品数据的当前工序,清空返工工序字段
  2071. InProductionEntity addInProductionEntity = new InProductionEntity();
  2072. addInProductionEntity.BarCode = barcode;
  2073. //流程工序ID
  2074. addInProductionEntity.FlowProcedureID = procedure.ProcedureID;
  2075. // 当前工序
  2076. addInProductionEntity.ProcedureID = procedure.ProcedureID;
  2077. // 生产数据ID
  2078. addInProductionEntity.ProductionDataID = productionDataID;
  2079. // 工序模型
  2080. addInProductionEntity.ProcedureModel = procedure.ProcedureModel;
  2081. // 工序类别
  2082. addInProductionEntity.ModelType = procedure.ModelType;
  2083. // 生产工号
  2084. addInProductionEntity.UserID = workUserID;
  2085. // 缺陷标识
  2086. addInProductionEntity.DefectFlag = (int)Constant.DefectFlag.No;
  2087. #region 更新在产表窑车窑炉字段
  2088. addInProductionEntity.KilnID = Convert.ToInt32(barcodeRow["KilnID"].ToString());
  2089. addInProductionEntity.KilnCode = barcodeRow["KilnCode"].ToString();
  2090. addInProductionEntity.KilnName = barcodeRow["KilnName"].ToString();
  2091. addInProductionEntity.KilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString());
  2092. addInProductionEntity.KilnCarCode = barcodeRow["KilnCarCode"].ToString();
  2093. addInProductionEntity.KilnCarName = barcodeRow["KilnCarName"].ToString();
  2094. addInProductionEntity.KilnCarBatchNo = kilnCarBatchNo;
  2095. addInProductionEntity.KilnCarPosition = Convert.ToInt32(barcodeRow["KilnCarPosition"].ToString());
  2096. #endregion
  2097. // 执行修改
  2098. errMsg = UpdateInProduction(oracleTrConn, addInProductionEntity, sUserInfo);
  2099. // 执行失败
  2100. if (!string.IsNullOrEmpty(errMsg))
  2101. {
  2102. return errMsg;
  2103. }
  2104. #endregion
  2105. }
  2106. else if (procedure.NodeType == Constant.ProcedureNodeType.End.GetHashCode())
  2107. {
  2108. #region 结束工序 添加成品数据 删除在产产品数据
  2109. FinishedProductEntity finishedProduct = new FinishedProductEntity();
  2110. finishedProduct.BarCode = barcode;
  2111. errMsg = AddFinishedProduct(oracleTrConn, finishedProduct, sUserInfo, finishedloadbatchno);
  2112. if (!string.IsNullOrEmpty(errMsg))
  2113. {
  2114. return errMsg;
  2115. }
  2116. InProductionEntity delInProductionEntity = new InProductionEntity();
  2117. delInProductionEntity.BarCode = barcode;
  2118. // 执行删除 在产数据
  2119. errMsg = DeleteInProduction(oracleTrConn, delInProductionEntity, true, sUserInfo);
  2120. // 执行失败
  2121. if (!string.IsNullOrEmpty(errMsg))
  2122. {
  2123. return errMsg;
  2124. }
  2125. #endregion
  2126. }
  2127. //#region 添加生产者数据
  2128. //errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo);
  2129. //if (!string.IsNullOrEmpty(errMsg))
  2130. //{
  2131. // return errMsg;
  2132. //}
  2133. //#endregion
  2134. }
  2135. #region 插入窑车生产数据表
  2136. errMsg = AddKilnCarData(oracleTrConn,
  2137. accountDate,
  2138. kilnCarID,
  2139. kilnCarBatchNo,
  2140. workUserID,
  2141. workUserCode,
  2142. workUserName,
  2143. Remarks,
  2144. sUserInfo, maxClassesSettingID);
  2145. if (!string.IsNullOrEmpty(errMsg))
  2146. {
  2147. return errMsg;
  2148. }
  2149. #endregion
  2150. //#region 窑车生产者
  2151. //// 查询新插入的生产数据ID
  2152. //string sqlKilnCar = "select SEQ_PM_KilnCarData_ID.Currval from dual";
  2153. //string idKilnCar = oracleTrConn.GetSqlResultToStr(sqlKilnCar);
  2154. //errMsg = AddKilnCarProducer(oracleTrConn, accountDate, Convert.ToInt32(idKilnCar), workUserID, sUserInfo);
  2155. //if (!string.IsNullOrEmpty(errMsg))
  2156. //{
  2157. // return errMsg;
  2158. //}
  2159. //#endregion
  2160. #region 删除TP_PM_KilnCarGoods数据 按照窑车ID
  2161. errMsg = DeleteKilnCarGoodsByKilnCarID(oracleTrConn, kilnCarID);
  2162. if (!string.IsNullOrEmpty(errMsg))
  2163. {
  2164. return errMsg;
  2165. }
  2166. #endregion
  2167. }
  2168. return errMsg;
  2169. }
  2170. catch (Exception ex)
  2171. {
  2172. throw ex;
  2173. }
  2174. }
  2175. /// <summary>
  2176. /// 窑车补件计件
  2177. /// </summary>
  2178. /// <param name="oracleTrConn">数据连接对象</param>
  2179. /// <param name="procedure">工序对象</param>
  2180. /// <param name="barcodeTable">条码信息</param>
  2181. /// <param name="sUserInfo">用户基本信息</param>
  2182. /// <param name="goodsID">返回的产品ID</param>
  2183. /// <param name="goodsCode">返回的产品Code</param>
  2184. /// <param name="goodsName">返回的产品名称</param>
  2185. /// <returns>string</returns>
  2186. /// <remarks>
  2187. /// 张国印 2014.10.05 新建
  2188. /// </remarks>
  2189. private static string AddKilnCarSupplement(IDBTransaction oracleTrConn, ProcedureEntity procedure, DataTable barcodeTable, SUserInfo sUserInfo,
  2190. out int goodsID, out string goodsCode, out string goodsName)
  2191. {
  2192. try
  2193. {
  2194. goodsID = Constant.INT_IS_ZERO;
  2195. goodsCode = null;
  2196. goodsName = null;
  2197. string groutingUserCode = string.Empty;
  2198. // 获得账务日期
  2199. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  2200. string errMsg = "";
  2201. // 生产工号
  2202. int workUserID = Constant.INT_IS_ZERO;
  2203. // 生产工号Code
  2204. string workUserCode = string.Empty;
  2205. // 生产工号Name
  2206. string workUserName = string.Empty;
  2207. // 本批采集的批次号
  2208. string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  2209. // 窑车Code
  2210. string kilnCarCode = barcodeTable.Rows[0]["kilnCarCode"].ToString();
  2211. // 窑车批次号
  2212. string kilnCarBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  2213. // 窑车状态
  2214. string kilnCarStatus = string.Empty;
  2215. #region 校验窑车是否可装车
  2216. errMsg = CheckKilnCarrStatus(oracleTrConn, procedure.ProcedureID, kilnCarCode, procedure.ModelType, sUserInfo, out kilnCarStatus);
  2217. if (!string.IsNullOrEmpty(errMsg))
  2218. {
  2219. return errMsg;
  2220. }
  2221. #endregion
  2222. // 窑炉ID
  2223. //int kilnID = Convert.ToInt32(barcodeTable.Rows[0]["kilnID"].ToString());
  2224. //// 窑车ID
  2225. //int kilnCarID = Convert.ToInt32(barcodeTable.Rows[0]["KilnCarID"].ToString());
  2226. int kilnID = 0;
  2227. // 窑车ID
  2228. int kilnCarID = 0;
  2229. // 条码信息
  2230. foreach (DataRow barcodeRow in barcodeTable.Rows)
  2231. {
  2232. kilnID = Convert.ToInt32(barcodeRow["kilnID"]);
  2233. kilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString());
  2234. //窑车表存在,查询本次窑车产品的批次号 并更改装窑车时间
  2235. kilnCarBatchNo = GetKilnCarBatchNoByKilnCarID(oracleTrConn, kilnCarID);
  2236. // 条码
  2237. string barcode = barcodeRow["Barcode"].ToString();
  2238. // 生产工号
  2239. workUserID = Convert.ToInt32(barcodeRow["UserID"]);
  2240. workUserCode = barcodeRow["UserCode"].ToString();
  2241. workUserName = barcodeRow["UserName"].ToString();
  2242. //#region 校验条码有效性
  2243. //errMsg = CheckBarcode(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo);
  2244. //if (!string.IsNullOrEmpty(errMsg))
  2245. //{
  2246. // return errMsg;
  2247. //}
  2248. //#endregion
  2249. if (procedure.CollectType == 1)
  2250. {
  2251. #region 校验条码有效性
  2252. errMsg = CheckBarcode(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo);
  2253. if (!string.IsNullOrEmpty(errMsg))
  2254. {
  2255. return errMsg;
  2256. }
  2257. #endregion
  2258. }
  2259. else
  2260. {
  2261. string sqlGroutingInfo = @"select tp_pm_groutingdailydetail.goodsid,
  2262. tp_pm_groutingdailydetail.goodscode,
  2263. tp_pm_groutingdailydetail.goodsname,
  2264. tp_pm_groutingdailydetail.usercode as groutingUserCode
  2265. from tp_pm_groutingdailydetail where barcode=:barcode
  2266. ";
  2267. OracleParameter[] ReFireparas = new OracleParameter[] {
  2268. new OracleParameter(":barcode",barcode),
  2269. };
  2270. DataSet dsGrouting = oracleTrConn.GetSqlResultToDs(sqlGroutingInfo, ReFireparas);
  2271. if (dsGrouting != null && dsGrouting.Tables[0].Rows.Count > 0)
  2272. {
  2273. goodsID = Convert.ToInt32(dsGrouting.Tables[0].Rows[0]["goodsid"]);
  2274. goodsCode = dsGrouting.Tables[0].Rows[0]["goodscode"].ToString();
  2275. goodsName = dsGrouting.Tables[0].Rows[0]["goodsName"].ToString();
  2276. groutingUserCode = dsGrouting.Tables[0].Rows[0]["groutingUserCode"].ToString();
  2277. }
  2278. }
  2279. // 查询新插入的生产数据ID
  2280. string sql = "select SEQ_PM_ProductionData_ID.nextval from dual";
  2281. string idStr = oracleTrConn.GetSqlResultToStr(sql);
  2282. int productionDataID = 0;
  2283. if (!string.IsNullOrEmpty(idStr))
  2284. {
  2285. productionDataID = int.Parse(idStr);
  2286. }
  2287. else
  2288. {
  2289. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  2290. }
  2291. int? ClassesSettingID = null;//班次配置ID
  2292. #region 添加生产者数据
  2293. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID);
  2294. if (!string.IsNullOrEmpty(errMsg))
  2295. {
  2296. return errMsg;
  2297. }
  2298. #endregion
  2299. #region 添加生产数据
  2300. ProductionDataEntity productionData = new ProductionDataEntity();
  2301. #region 属性赋值
  2302. productionData.ClassesSettingID = ClassesSettingID;
  2303. productionData.ProductionDataID = Convert.ToInt32(idStr);
  2304. productionData.Barcode = barcode;
  2305. productionData.CentralizedBatchNo = centralizedBatchNo;
  2306. productionData.ProductionLineID = procedure.ProductionLineID;
  2307. productionData.ProductionLineCode = procedure.ProductionlineCode;
  2308. productionData.ProductionLineName = procedure.ProductionlineName;
  2309. productionData.CompleteProcedureID = procedure.ProcedureID;
  2310. productionData.ProcedureCode = procedure.ProcedureCode;
  2311. productionData.ProcedureName = procedure.ProcedureName;
  2312. productionData.ProcedureModel = procedure.ProcedureModel;
  2313. productionData.ModelType = procedure.ModelType;
  2314. productionData.NodeType = procedure.NodeType;
  2315. productionData.DefectFlag = (int)Constant.DefectFlag.No;
  2316. productionData.ReworkProcedureID = null;
  2317. productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, barcode);
  2318. productionData.IsReFire = (int)Constant.ReFireFlag.No;
  2319. productionData.GoodsGrade = (int)Constant.GoodsGrade.Good;
  2320. productionData.OrganizationID = procedure.OrganizationID;
  2321. productionData.GoodsID = goodsID;
  2322. productionData.GoodsCode = goodsCode;
  2323. productionData.GoodsName = goodsName;
  2324. productionData.UserID = workUserID;
  2325. productionData.UserCode = barcodeRow["UserCode"].ToString();
  2326. productionData.UserName = barcodeRow["UserName"].ToString();
  2327. productionData.PieceType = procedure.PieceType;
  2328. #region 窑炉窑车属性
  2329. productionData.KilnID = Convert.ToInt32(barcodeRow["KilnID"].ToString());
  2330. productionData.KilnCode = barcodeRow["KilnCode"].ToString();
  2331. productionData.KilnName = barcodeRow["KilnName"].ToString();
  2332. productionData.KilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString());
  2333. productionData.KilnCarCode = barcodeRow["KilnCarCode"].ToString();
  2334. productionData.KilnCarName = barcodeRow["KilnCarName"].ToString();
  2335. productionData.KilnCarBatchNo = kilnCarBatchNo;
  2336. productionData.KilnCarPosition = Convert.ToInt32(barcodeRow["KilnCarPosition"].ToString());
  2337. #endregion
  2338. #endregion
  2339. string OutSpecialRepairflag = "0";//干补标识
  2340. errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag);
  2341. if (!string.IsNullOrEmpty(errMsg))
  2342. {
  2343. return errMsg;
  2344. }
  2345. #endregion
  2346. #region 修改在产产品数据的当前工序,清空返工工序字段
  2347. InProductionEntity addInProductionEntity = new InProductionEntity();
  2348. addInProductionEntity.BarCode = barcode;
  2349. //流程工序
  2350. addInProductionEntity.FlowProcedureID = procedure.ProcedureID;
  2351. // 当前工序
  2352. //addInProductionEntity.CompleteProcedureID = procedure.ProcedureID;
  2353. addInProductionEntity.ProcedureID = procedure.ProcedureID;
  2354. //生产数据ID
  2355. addInProductionEntity.ProductionDataID = productionDataID;
  2356. // 工序模型
  2357. addInProductionEntity.ProcedureModel = procedure.ProcedureModel;
  2358. // 工序类别
  2359. addInProductionEntity.ModelType = procedure.ModelType;
  2360. // 生产工号
  2361. addInProductionEntity.UserID = workUserID;
  2362. // 缺陷标识
  2363. addInProductionEntity.DefectFlag = (int)Constant.DefectFlag.No;
  2364. #region 更新在产表窑车窑炉字段
  2365. addInProductionEntity.KilnID = Convert.ToInt32(barcodeRow["KilnID"].ToString());
  2366. addInProductionEntity.KilnCode = barcodeRow["KilnCode"].ToString();
  2367. addInProductionEntity.KilnName = barcodeRow["KilnName"].ToString();
  2368. addInProductionEntity.KilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString());
  2369. addInProductionEntity.KilnCarCode = barcodeRow["KilnCarCode"].ToString();
  2370. addInProductionEntity.KilnCarName = barcodeRow["KilnCarName"].ToString();
  2371. addInProductionEntity.KilnCarBatchNo = kilnCarBatchNo;
  2372. addInProductionEntity.KilnCarPosition = Convert.ToInt32(barcodeRow["KilnCarPosition"].ToString());
  2373. #endregion
  2374. // 执行修改
  2375. errMsg = UpdateInProduction(oracleTrConn, addInProductionEntity, sUserInfo);
  2376. // 执行失败
  2377. if (!string.IsNullOrEmpty(errMsg))
  2378. {
  2379. return errMsg;
  2380. }
  2381. #endregion
  2382. //#region 添加生产者数据
  2383. //errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo);
  2384. //if (!string.IsNullOrEmpty(errMsg))
  2385. //{
  2386. // return errMsg;
  2387. //}
  2388. //#endregion
  2389. #region 插入窑车产品表
  2390. errMsg = AddKilnCarGoods(oracleTrConn,
  2391. barcode,
  2392. kilnCarID,
  2393. goodsID,
  2394. productionData.KilnCarPosition.Value,
  2395. kilnCarBatchNo,
  2396. workUserID,
  2397. workUserCode,
  2398. workUserName,
  2399. sUserInfo);
  2400. if (!string.IsNullOrEmpty(errMsg))
  2401. {
  2402. return errMsg;
  2403. }
  2404. #endregion
  2405. }
  2406. return errMsg;
  2407. }
  2408. catch (Exception ex)
  2409. {
  2410. throw ex;
  2411. }
  2412. }
  2413. /// <summary>
  2414. /// 插入窑车生产数据表(装车)
  2415. /// </summary>
  2416. /// <param name="oracleTrConn">连接对象</param>
  2417. /// <param name="accountDate">账务日期</param>
  2418. /// <param name="kilnCarID">窑车ID</param>
  2419. /// <param name="kilnCarBatchNo">窑车批次号</param>
  2420. /// <param name="workUserID">生产工号ID</param>
  2421. /// <param name="workUserCode">生产工号Code</param>
  2422. /// <param name="workUserName">生产工号Name</param>
  2423. /// <param name="sUserInfo">用户基本信息</param>
  2424. /// <returns>string</returns>
  2425. private static string AddKilnCarDataCreateTime(IDBTransaction oracleTrConn,
  2426. DateTime accountDate,
  2427. int kilnCarID,
  2428. string kilnCarBatchNo,
  2429. int workUserID,
  2430. string workUserCode,
  2431. string workUserName,
  2432. string remarks,
  2433. DateTime? createtime,
  2434. SUserInfo sUserInfo)
  2435. {
  2436. #region SQL
  2437. string sql = "insert into tp_pm_kilncardata"
  2438. + " (kilncarbatchno,"
  2439. + " kilncarid,"
  2440. + " kilnid,"
  2441. + " productionlineid,"
  2442. + " procedureid,"
  2443. + " procedurecode,"
  2444. + " procedurename,"
  2445. + " proceduremodel,"
  2446. + " modeltype,"
  2447. + " piecetype,"
  2448. + " kilncarstatus,"
  2449. + " UserID,"
  2450. + " UserCode,"
  2451. + " UserName,"
  2452. + " loadingtime,"
  2453. + " intokilntime,"
  2454. + " outkilntime,"
  2455. + " unloadingtime,"
  2456. + " accountdate,"
  2457. + " accountid,"
  2458. + " createuserid,"
  2459. + " updateuserid,"
  2460. + " createtime,"
  2461. + " remarks)"
  2462. + " select "
  2463. + " :pkilncarbatchno,"
  2464. + " kilncarid,"
  2465. + " kilnid,"
  2466. + " productionlineid,"
  2467. + " procedureid,"
  2468. + " procedurecode,"
  2469. + " procedurename,"
  2470. + " proceduremodel,"
  2471. + " modeltype,"
  2472. + " piecetype,"
  2473. + " kilncarstatus,"
  2474. + " :puserID,"
  2475. + " :puserCode,"
  2476. + " :puserName,"
  2477. + " loadingtime,"
  2478. + " intokilntime,"
  2479. + " outkilntime,"
  2480. + " unloadingtime,"
  2481. + " :paccountdate,"
  2482. + " :paccountid,"
  2483. + " :pcreateuserid,"
  2484. + " :pupdateuserid,"
  2485. + " :createtime,"
  2486. + " :remarks"
  2487. + " from tp_pm_kilncarstatus"
  2488. + " where kilncarid = :pkilncarid";
  2489. #endregion
  2490. #region 参数
  2491. OracleParameter[] paras = new OracleParameter[] {
  2492. new OracleParameter(":pkilncarbatchno",OracleDbType.Varchar2,kilnCarBatchNo,ParameterDirection.Input),
  2493. new OracleParameter(":puserID",OracleDbType.Int32,workUserID,ParameterDirection.Input),
  2494. new OracleParameter(":puserCode",OracleDbType.Varchar2,workUserCode,ParameterDirection.Input),
  2495. new OracleParameter(":puserName",OracleDbType.Varchar2,workUserName,ParameterDirection.Input),
  2496. new OracleParameter(":paccountdate",OracleDbType.Date,accountDate,ParameterDirection.Input),
  2497. new OracleParameter(":paccountid",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  2498. new OracleParameter(":pcreateuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  2499. new OracleParameter(":pupdateuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  2500. new OracleParameter(":pkilncarid",OracleDbType.Int32,kilnCarID,ParameterDirection.Input),
  2501. new OracleParameter(":remarks",OracleDbType.Varchar2,remarks,ParameterDirection.Input),
  2502. new OracleParameter(":createtime",OracleDbType.Date,Convert.ToDateTime(createtime),ParameterDirection.Input),
  2503. };
  2504. #endregion
  2505. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  2506. // 保存失败
  2507. if (result != Constant.INT_IS_ONE)
  2508. {
  2509. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  2510. }
  2511. // 保存成功返回null
  2512. return null;
  2513. }
  2514. /// <summary>
  2515. /// 插入窑车生产数据表
  2516. /// </summary>
  2517. /// <param name="oracleTrConn">连接对象</param>
  2518. /// <param name="accountDate">账务日期</param>
  2519. /// <param name="kilnCarID">窑车ID</param>
  2520. /// <param name="kilnCarBatchNo">窑车批次号</param>
  2521. /// <param name="workUserID">生产工号ID</param>
  2522. /// <param name="workUserCode">生产工号Code</param>
  2523. /// <param name="workUserName">生产工号Name</param>
  2524. /// <param name="sUserInfo">用户基本信息</param>
  2525. /// <returns>string</returns>
  2526. private static string AddKilnCarData(IDBTransaction oracleTrConn,
  2527. DateTime accountDate,
  2528. int kilnCarID,
  2529. string kilnCarBatchNo,
  2530. int workUserID,
  2531. string workUserCode,
  2532. string workUserName,
  2533. string remarks,
  2534. SUserInfo sUserInfo, int? ClassesSettingID)
  2535. {
  2536. #region SQL
  2537. string sql = "insert into tp_pm_kilncardata"
  2538. + " (kilncarbatchno,"
  2539. + " kilncarid,"
  2540. + " kilnid,"
  2541. + " productionlineid,"
  2542. + " procedureid,"
  2543. + " procedurecode,"
  2544. + " procedurename,"
  2545. + " proceduremodel,"
  2546. + " modeltype,"
  2547. + " piecetype,"
  2548. + " kilncarstatus,"
  2549. + " UserID,"
  2550. + " UserCode,"
  2551. + " UserName,"
  2552. + " loadingtime,"
  2553. + " intokilntime,"
  2554. + " outkilntime,"
  2555. + " unloadingtime,"
  2556. + " accountdate,"
  2557. + " accountid,"
  2558. + " createuserid,"
  2559. + " updateuserid,"
  2560. + " classesSettingID,"
  2561. + " remarks)"
  2562. + " select "
  2563. + " :pkilncarbatchno,"
  2564. + " kilncarid,"
  2565. + " kilnid,"
  2566. + " productionlineid,"
  2567. + " procedureid,"
  2568. + " procedurecode,"
  2569. + " procedurename,"
  2570. + " proceduremodel,"
  2571. + " modeltype,"
  2572. + " piecetype,"
  2573. + " kilncarstatus,"
  2574. + " :puserID,"
  2575. + " :puserCode,"
  2576. + " :puserName,"
  2577. + " loadingtime,"
  2578. + " intokilntime,"
  2579. + " outkilntime,"
  2580. + " unloadingtime,"
  2581. + " :paccountdate,"
  2582. + " :paccountid,"
  2583. + " :pcreateuserid,"
  2584. + " :pupdateuserid,"
  2585. + " :classesSettingID,"
  2586. + " :remarks"
  2587. + " from tp_pm_kilncarstatus"
  2588. + " where kilncarid = :pkilncarid";
  2589. #endregion
  2590. #region 参数
  2591. OracleParameter[] paras = new OracleParameter[] {
  2592. new OracleParameter(":classesSettingID",OracleDbType.Int32,ClassesSettingID,ParameterDirection.Input),
  2593. new OracleParameter(":pkilncarbatchno",OracleDbType.Varchar2,kilnCarBatchNo,ParameterDirection.Input),
  2594. new OracleParameter(":puserID",OracleDbType.Int32,workUserID,ParameterDirection.Input),
  2595. new OracleParameter(":puserCode",OracleDbType.Varchar2,workUserCode,ParameterDirection.Input),
  2596. new OracleParameter(":puserName",OracleDbType.Varchar2,workUserName,ParameterDirection.Input),
  2597. new OracleParameter(":paccountdate",OracleDbType.Date,accountDate,ParameterDirection.Input),
  2598. new OracleParameter(":paccountid",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  2599. new OracleParameter(":pcreateuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  2600. new OracleParameter(":pupdateuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  2601. new OracleParameter(":pkilncarid",OracleDbType.Int32,kilnCarID,ParameterDirection.Input),
  2602. new OracleParameter(":remarks",OracleDbType.Varchar2,remarks,ParameterDirection.Input),
  2603. };
  2604. #endregion
  2605. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  2606. // 保存失败
  2607. if (result != Constant.INT_IS_ONE)
  2608. {
  2609. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  2610. }
  2611. // 保存成功返回null
  2612. return null;
  2613. }
  2614. /// <summary>
  2615. /// 插入窑车产品表
  2616. /// </summary>
  2617. /// <param name="oracleTrConn">连接对象</param>
  2618. /// <param name="barcode">条码</param>
  2619. /// <param name="kilnCarID">窑车号</param>
  2620. /// <param name="goodsID">产品ID</param>
  2621. /// <param name="KilnCarPosition">窑车位置</param>
  2622. /// <param name="kilnCarBatchNo">装车批次</param>
  2623. /// <param name="sUserInfo">用户基本信息</param>
  2624. /// <returns>string</returns>
  2625. private static string AddKilnCarGoods(IDBTransaction oracleTrConn, string barcode, int kilnCarID, int goodsID, int KilnCarPosition, string kilnCarBatchNo, int workUserID,
  2626. string workUserCode,
  2627. string workUserName, SUserInfo sUserInfo)
  2628. {
  2629. string sqlExist = "select 1 from tp_pm_kilncargoods where barcode=:barcode and accountid=:accountid";
  2630. OracleParameter[] parasExist = new OracleParameter[] {
  2631. new OracleParameter(":barcode",barcode),
  2632. new OracleParameter(":accountid",sUserInfo.AccountID),
  2633. };
  2634. oracleTrConn.ExecuteNonQuery(sqlExist, parasExist);
  2635. DataSet dsExist = oracleTrConn.GetSqlResultToDs(sqlExist, parasExist);
  2636. if (dsExist != null && dsExist.Tables[0].Rows.Count == 0)
  2637. {
  2638. string sql = "insert into tp_pm_kilncargoods"
  2639. + " (barcode,"
  2640. + " kilncarid,"
  2641. + " goodsid,"
  2642. + " kilncarposition,"
  2643. + " kilncarbatchno,"
  2644. + " accountid,"
  2645. + " userid,"
  2646. + " usercode,"
  2647. + " username,"
  2648. + " createuserid,"
  2649. + " updateuserid)"
  2650. + " values"
  2651. + " (:barcode,"
  2652. + " :kilncarid,"
  2653. + " :goodsid,"
  2654. + " :kilncarposition,"
  2655. + " :kilncarbatchno,"
  2656. + " :accountid,"
  2657. + " :userid,"
  2658. + " :usercode,"
  2659. + " :username,"
  2660. + " :createuserid,"
  2661. + " :updateuserid)";
  2662. #region 参数
  2663. OracleParameter[] paras = new OracleParameter[] {
  2664. new OracleParameter(":barcode",barcode),
  2665. new OracleParameter(":kilncarid",kilnCarID),
  2666. new OracleParameter(":goodsid",goodsID),
  2667. new OracleParameter(":kilncarposition",KilnCarPosition),
  2668. new OracleParameter(":kilncarbatchno",kilnCarBatchNo),
  2669. new OracleParameter(":accountid",sUserInfo.AccountID),
  2670. new OracleParameter(":createuserid",sUserInfo.UserID),
  2671. new OracleParameter(":updateuserid",sUserInfo.UserID),
  2672. new OracleParameter(":userid",workUserID),
  2673. new OracleParameter(":usercode",workUserCode),
  2674. new OracleParameter(":username",workUserName),
  2675. };
  2676. #endregion
  2677. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  2678. // 保存失败
  2679. if (result != Constant.INT_IS_ONE)
  2680. {
  2681. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  2682. }
  2683. }
  2684. // 保存成功返回null
  2685. return null;
  2686. }
  2687. /// <summary>
  2688. /// 查询本次批次号
  2689. /// </summary>
  2690. /// <param name="oracleTrConn">连接对象</param>
  2691. /// <param name="kilnCarID">窑车ID</param>
  2692. /// <returns>string</returns>
  2693. private static string GetKilnCarBatchNoByKilnCarID(IDBTransaction oracleTrConn, int kilnCarID)
  2694. {
  2695. string sql = "SELECT Max(KilnCarBatchNo) FROM TP_PM_KilnCarGoods where KilnCarID = :kilnCarID";
  2696. #region 参数
  2697. OracleParameter[] paras = new OracleParameter[] {
  2698. new OracleParameter(":kilnCarID",kilnCarID),
  2699. };
  2700. #endregion
  2701. string batchNo = oracleTrConn.GetSqlResultToStr(sql, paras);
  2702. if (!string.IsNullOrEmpty(batchNo))
  2703. {
  2704. return batchNo;
  2705. }
  2706. else
  2707. {
  2708. // 自动生成窑车烧成批次号
  2709. //return System.Guid.NewGuid().ToString().ToUpper();
  2710. return GetFiredKilnCarBatchNo(oracleTrConn, kilnCarID);
  2711. }
  2712. }
  2713. /// <summary>
  2714. /// 自动生成窑车烧成批次号
  2715. /// </summary>
  2716. /// <param name="oracleTrConn"></param>
  2717. /// <param name="kilnCarID"></param>
  2718. /// <returns></returns>
  2719. public static string GetFiredKilnCarBatchNo(IDBTransaction oracleTrConn, int kilnCarID)
  2720. {
  2721. DateTime now = DateTime.Now.Date;
  2722. string sqlString = "select k.kilnid, k.kilncode, k.fireddate, k.firedbatchno, kc.kilncarcode\n" +
  2723. " from TP_MST_Kiln k\n" +
  2724. " inner join tp_mst_kilncar kc\n" +
  2725. " on k.kilnid = kc.kilnid\n" +
  2726. " where kc.kilncarid = :kilncarid\n" +
  2727. //" and k.fireddate = :fireddate"
  2728. " for update";
  2729. OracleParameter[] paras = new OracleParameter[] {
  2730. new OracleParameter(":kilncarid",kilnCarID),
  2731. //new OracleParameter(":fireddate",now),
  2732. };
  2733. DataTable dt = oracleTrConn.GetSqlResultToDt(sqlString, paras);
  2734. if (dt == null || dt.Rows.Count == 0)
  2735. {
  2736. // 窑车、窑炉不存在
  2737. return null;
  2738. }
  2739. int kilnid = Convert.ToInt32(dt.Rows[0]["kilnid"]);
  2740. string kilncode = dt.Rows[0]["kilncode"] + "";
  2741. string kilncarcode = dt.Rows[0]["kilncarcode"] + "";
  2742. int firedbatchno = 0;
  2743. if (dt.Rows[0]["fireddate"] == null || dt.Rows[0]["fireddate"] == DBNull.Value)
  2744. {
  2745. firedbatchno = -1;
  2746. }
  2747. else
  2748. {
  2749. DateTime fireddate = Convert.ToDateTime(dt.Rows[0]["fireddate"]);
  2750. if (now > fireddate)
  2751. {
  2752. firedbatchno = -1;
  2753. }
  2754. }
  2755. if (firedbatchno < 0)
  2756. {
  2757. // 当日第一车
  2758. sqlString = "update TP_MST_Kiln k\n" +
  2759. " set k.fireddate = :fireddate, k.firedbatchno = 1\n" +
  2760. " where k.kilnid = :kilnid";
  2761. paras = new OracleParameter[] {
  2762. new OracleParameter(":kilnid",kilnid),
  2763. new OracleParameter(":fireddate",now),
  2764. };
  2765. oracleTrConn.ExecuteNonQuery(sqlString, paras);
  2766. return $"{kilncode}#{kilncarcode}#{now.ToString("yyyyMMdd")}#001";
  2767. }
  2768. firedbatchno = Convert.ToInt32(dt.Rows[0]["firedbatchno"]) + 1;
  2769. sqlString = "update TP_MST_Kiln k\n" +
  2770. " set k.firedbatchno = k.firedbatchno + 1\n" +
  2771. " where k.kilnid = :kilnid";
  2772. paras = new OracleParameter[] {
  2773. new OracleParameter(":kilnid",kilnid),
  2774. };
  2775. oracleTrConn.ExecuteNonQuery(sqlString, paras);
  2776. return $"{kilncode}#{kilncarcode}#{now.ToString("yyyyMMdd")}#{firedbatchno.ToString("000")}";
  2777. }
  2778. /// <summary>
  2779. /// 插入窑车状态表
  2780. /// </summary>
  2781. /// <param name="oracleTrConn">连接对象</param>
  2782. /// <param name="procedure">工序ID</param>
  2783. /// <param name="kilnCarID">窑车ID</param>
  2784. /// <param name="kilnID">窑炉ID</param>
  2785. /// <param name="sUserInfo">用户基本信息</param>
  2786. /// <returns>string</returns>
  2787. private static string AddkilnCarStatus(IDBTransaction oracleTrConn, ProcedureEntity procedure, int kilnCarID, int kilnID, string kilnCarBatchNo, SUserInfo sUserInfo)
  2788. {
  2789. #region SQL
  2790. string sql = " insert into tp_pm_kilncarstatus "
  2791. + " (kilncarid, "
  2792. + " kilnid, "
  2793. + " productionlineid, "
  2794. + " procedureid, "
  2795. + " procedurecode, "
  2796. + " procedurename, "
  2797. + " proceduremodel, "
  2798. + " modeltype, "
  2799. + " piecetype, "
  2800. + " kilncarstatus, "
  2801. + " loadingtime, "
  2802. + " accountid, "
  2803. + " createuserid, "
  2804. + " updateuserid,kilnCarBatchNo) "
  2805. + " values "
  2806. + " (:kilncarid, "
  2807. + " :kilnid, "
  2808. + " :productionlineid, "
  2809. + " :procedureid, "
  2810. + " :procedurecode, "
  2811. + " :procedurename, "
  2812. + " :proceduremodel, "
  2813. + " :modeltype, "
  2814. + " :piecetype, "
  2815. + " '0', "
  2816. + " sysdate, "
  2817. + " :accountid, "
  2818. + " :createuserid, "
  2819. + " :updateuserid,:kilnCarBatchNo)";
  2820. #endregion
  2821. #region 参数
  2822. OracleParameter[] paras = new OracleParameter[] {
  2823. new OracleParameter(":kilncarid",kilnCarID),
  2824. new OracleParameter(":kilnid",kilnID),
  2825. new OracleParameter(":productionlineid",procedure.ProductionLineID),
  2826. new OracleParameter(":procedureid",procedure.ProcedureID),
  2827. new OracleParameter(":procedurecode",procedure.ProcedureCode),
  2828. new OracleParameter(":procedurename",procedure.ProcedureName),
  2829. new OracleParameter(":proceduremodel",procedure.ProcedureModel),
  2830. new OracleParameter(":modeltype",procedure.ModelType),
  2831. new OracleParameter(":piecetype",procedure.PieceType),
  2832. new OracleParameter(":accountID",sUserInfo.AccountID),
  2833. new OracleParameter(":createuserid",sUserInfo.UserID),
  2834. new OracleParameter(":updateuserid",sUserInfo.UserID),
  2835. new OracleParameter(":kilnCarBatchNo",kilnCarBatchNo),
  2836. };
  2837. #endregion
  2838. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  2839. // 保存失败
  2840. if (result != Constant.INT_IS_ONE)
  2841. {
  2842. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  2843. }
  2844. // 保存成功返回null
  2845. return null;
  2846. }
  2847. /// <summary>
  2848. /// 更新窑车状态表中的对应的时间
  2849. /// </summary>
  2850. /// <param name="oracleTrConn">数据连接</param>
  2851. /// <param name="kilnCarID">窑车ID</param>
  2852. /// <param name="pModelType">操作类型</param>
  2853. /// <param name="sUserInfo">用户基本信息</param>
  2854. /// <returns>
  2855. /// 张国印 2014.10.04 新建
  2856. /// </returns>
  2857. private static string UpdatekilnCarStatus(IDBTransaction oracleTrConn, int kilnCarID, Constant.ProcedureModelType pModelType, SUserInfo sUserInfo, ProcedureEntity procedure, string kilnCarBatchNo)
  2858. {
  2859. if (pModelType == Constant.ProcedureModelType.LoadCar)
  2860. {
  2861. //procedure.ProcedureID,
  2862. //procedure.ProcedureCode,
  2863. //procedure.ProcedureName,
  2864. //procedure.ModelType
  2865. #region 装窑车操作时,更新tp_pm_kilncarstatus的装车时间
  2866. #region SQL语句和参数
  2867. string sql = " Update tp_pm_kilncarstatus Set"
  2868. + " KilnCarStatus = :pKilnCarStatus, "
  2869. + " LoadingTime = sysdate, "
  2870. + " IntoKilnTime = null, "
  2871. + " OutKilnTime = null, "
  2872. + " UnloadingTime = null, "
  2873. + " UpdateUserID = :pUpdateUserID, "
  2874. + " ProcedureID = :ProcedureID, "
  2875. + " ProcedureCode = :ProcedureCode, "
  2876. + " ProcedureName = :ProcedureName, "
  2877. + " ModelType = :ModelType, "
  2878. + " kilnCarBatchNo = :kilnCarBatchNo "
  2879. + " Where KilnCarID = :pKilnCarID And AccountID = :pAccountID";
  2880. OracleParameter[] paras = new OracleParameter[]
  2881. {
  2882. new OracleParameter(":pKilnCarStatus", OracleDbType.Int32, 0, ParameterDirection.Input),
  2883. new OracleParameter(":pUpdateUserID", OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input),
  2884. new OracleParameter(":pKilnCarID", OracleDbType.Int32, kilnCarID, ParameterDirection.Input),
  2885. new OracleParameter(":pAccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  2886. new OracleParameter(":ProcedureID", OracleDbType.Int32, procedure.ProcedureID, ParameterDirection.Input),
  2887. new OracleParameter(":ProcedureCode", OracleDbType.Varchar2, procedure.ProcedureCode, ParameterDirection.Input),
  2888. new OracleParameter(":ProcedureName", OracleDbType.Varchar2, procedure.ProcedureName, ParameterDirection.Input),
  2889. new OracleParameter(":ModelType", OracleDbType.Int32, procedure.ModelType, ParameterDirection.Input),
  2890. new OracleParameter(":kilnCarBatchNo", OracleDbType.Varchar2, kilnCarBatchNo, ParameterDirection.Input),
  2891. };
  2892. #endregion
  2893. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  2894. // 保存失败
  2895. if (result != Constant.INT_IS_ONE)
  2896. {
  2897. return string.Format(Messages.MSG_CMN_W001, "窑车状态", "保存");
  2898. }
  2899. #endregion
  2900. }
  2901. else if (pModelType == Constant.ProcedureModelType.IntoKiln)
  2902. {
  2903. #region 入窑操作时,更新tp_pm_kilncarstatus的入窑时间
  2904. #region SQL语句和参数
  2905. string sql = " Update tp_pm_kilncarstatus Set"
  2906. + " KilnCarStatus = :pKilnCarStatus, "
  2907. + " IntoKilnTime = sysdate, "
  2908. + " UpdateUserID = :pUpdateUserID, "
  2909. + " ProcedureID = :ProcedureID, "
  2910. + " ProcedureCode = :ProcedureCode, "
  2911. + " ProcedureName = :ProcedureName, "
  2912. + " ModelType = :ModelType "
  2913. + " Where KilnCarID = :pKilnCarID And AccountID = :pAccountID";
  2914. OracleParameter[] paras = new OracleParameter[]
  2915. {
  2916. new OracleParameter(":pKilnCarStatus", OracleDbType.Int32, 1, ParameterDirection.Input),
  2917. new OracleParameter(":pUpdateUserID", OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input),
  2918. new OracleParameter(":pKilnCarID", OracleDbType.Int32, kilnCarID, ParameterDirection.Input),
  2919. new OracleParameter(":pAccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  2920. new OracleParameter(":ProcedureID", OracleDbType.Int32, procedure.ProcedureID, ParameterDirection.Input),
  2921. new OracleParameter(":ProcedureCode", OracleDbType.Varchar2, procedure.ProcedureCode, ParameterDirection.Input),
  2922. new OracleParameter(":ProcedureName", OracleDbType.Varchar2, procedure.ProcedureName, ParameterDirection.Input),
  2923. new OracleParameter(":ModelType", OracleDbType.Int32, procedure.ModelType, ParameterDirection.Input),
  2924. };
  2925. #endregion
  2926. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  2927. // 保存失败
  2928. if (result != Constant.INT_IS_ONE)
  2929. {
  2930. return string.Format(Messages.MSG_CMN_W001, "窑车状态", "保存");
  2931. }
  2932. #endregion
  2933. }
  2934. else if (pModelType == Constant.ProcedureModelType.OutKiln)
  2935. {
  2936. #region 出窑操作时,更新tp_pm_kilncarstatus的出窑时间
  2937. #region SQL语句和参数
  2938. string sql = " Update tp_pm_kilncarstatus Set"
  2939. + " OutKilnTime = sysdate, "
  2940. + " UpdateUserID = :pUpdateUserID, "
  2941. + " ProcedureID = :ProcedureID, "
  2942. + " ProcedureCode = :ProcedureCode, "
  2943. + " ProcedureName = :ProcedureName, "
  2944. + " ModelType = :ModelType "
  2945. + " Where KilnCarID = :pKilnCarID And AccountID = :pAccountID";
  2946. OracleParameter[] paras = new OracleParameter[]
  2947. {
  2948. new OracleParameter(":pUpdateUserID", OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input),
  2949. new OracleParameter(":pKilnCarID", OracleDbType.Int32, kilnCarID, ParameterDirection.Input),
  2950. new OracleParameter(":pAccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  2951. new OracleParameter(":ProcedureID", OracleDbType.Int32, procedure.ProcedureID, ParameterDirection.Input),
  2952. new OracleParameter(":ProcedureCode", OracleDbType.Varchar2, procedure.ProcedureCode, ParameterDirection.Input),
  2953. new OracleParameter(":ProcedureName", OracleDbType.Varchar2, procedure.ProcedureName, ParameterDirection.Input),
  2954. new OracleParameter(":ModelType", OracleDbType.Int32, procedure.ModelType, ParameterDirection.Input),
  2955. };
  2956. #endregion
  2957. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  2958. // 保存失败
  2959. if (result != Constant.INT_IS_ONE)
  2960. {
  2961. return string.Format(Messages.MSG_CMN_W001, "窑车状态", "保存");
  2962. }
  2963. #endregion
  2964. }
  2965. else if (pModelType == Constant.ProcedureModelType.UnloadCar)
  2966. {
  2967. #region 卸窑车操作时,更新tp_pm_kilncarstatus的卸窑车时间
  2968. #region SQL语句和参数
  2969. string sql = " Update tp_pm_kilncarstatus Set"
  2970. + " KilnCarStatus = :pKilnCarStatus, "
  2971. //+ " LoadingTime = null, "
  2972. //+ " IntoKilnTime = null, "
  2973. //+ " OutKilnTime = null, "
  2974. + " UnloadingTime = sysdate, "
  2975. + " UpdateUserID = :pUpdateUserID, "
  2976. + " ProcedureID = :ProcedureID, "
  2977. + " ProcedureCode = :ProcedureCode, "
  2978. + " ProcedureName = :ProcedureName, "
  2979. + " ModelType = :ModelType "
  2980. + " Where KilnCarID = :pKilnCarID And AccountID = :pAccountID";
  2981. OracleParameter[] paras = new OracleParameter[]
  2982. {
  2983. new OracleParameter(":pKilnCarStatus", OracleDbType.Int32, 0, ParameterDirection.Input),
  2984. new OracleParameter(":pUpdateUserID", OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input),
  2985. new OracleParameter(":pKilnCarID", OracleDbType.Int32, kilnCarID, ParameterDirection.Input),
  2986. new OracleParameter(":pAccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  2987. new OracleParameter(":ProcedureID", OracleDbType.Int32, procedure.ProcedureID, ParameterDirection.Input),
  2988. new OracleParameter(":ProcedureCode", OracleDbType.Varchar2, procedure.ProcedureCode, ParameterDirection.Input),
  2989. new OracleParameter(":ProcedureName", OracleDbType.Varchar2, procedure.ProcedureName, ParameterDirection.Input),
  2990. new OracleParameter(":ModelType", OracleDbType.Int32, procedure.ModelType, ParameterDirection.Input),
  2991. };
  2992. #endregion
  2993. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  2994. // 保存失败
  2995. if (result != Constant.INT_IS_ONE)
  2996. {
  2997. return string.Format(Messages.MSG_CMN_W001, "窑车状态", "保存");
  2998. }
  2999. #endregion
  3000. }
  3001. // 保存成功返回null
  3002. return string.Empty;
  3003. }
  3004. /// <summary>
  3005. /// 校验窑车是否可用
  3006. /// </summary>
  3007. /// <param name="oracleTrConn">连接对象</param>
  3008. /// <param name="pProcedureId">工序ID</param>
  3009. /// <param name="kilnCarCode">窑车号</param>
  3010. /// <param name="pModelType">操作类型</param>
  3011. /// <param name="sUserInfo">用户基本信息</param>
  3012. /// <param name="kilnCarStatus">窑车状态</param>
  3013. /// <returns>string</returns>
  3014. private static string CheckKilnCarrStatus(IDBTransaction oracleTrConn, int pProcedureId, string kilnCarCode, int pModelType, SUserInfo sUserInfo, out string kilnCarStatus)
  3015. {
  3016. kilnCarStatus = string.Empty;
  3017. OracleParameter[] paras = new OracleParameter[]{
  3018. new OracleParameter("in_accountID",OracleDbType.Int32, sUserInfo.AccountID,ParameterDirection.Input),
  3019. new OracleParameter("in_kilnCarCode",OracleDbType.NVarchar2, kilnCarCode,ParameterDirection.Input),
  3020. new OracleParameter("in_modelType",OracleDbType.Int32, pModelType,ParameterDirection.Input),
  3021. new OracleParameter("out_errMsg",OracleDbType.NVarchar2,2000,null,ParameterDirection.Output),
  3022. new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  3023. new OracleParameter("in_procedureid",OracleDbType.Int32, pProcedureId,ParameterDirection.Input),
  3024. // 验证能否卸窑
  3025. new OracleParameter("in_UserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input),
  3026. };
  3027. DataSet returnDataSet = oracleTrConn.ExecStoredProcedure("PRO_PM_CheckKilnCar", paras);
  3028. string errMsg = paras[3].Value.ToString() == "null" ? string.Empty : paras[3].Value.ToString();
  3029. if (string.IsNullOrEmpty(errMsg))
  3030. {
  3031. if (pModelType == (int)Constant.ProcedureModelType.LoadCar)
  3032. {
  3033. kilnCarStatus = returnDataSet.Tables[0].Rows[0]["KilnCarStatus"].ToString();
  3034. }
  3035. }
  3036. return errMsg;
  3037. }
  3038. /// <summary>
  3039. /// 添加生产者
  3040. /// </summary>
  3041. /// <param name="oracleTrConn">连接对象</param>
  3042. /// <param name="accountDate">账务日期</param>
  3043. /// <param name="productionDataID">生产数据ID</param>
  3044. /// <param name="workUserID">生产工号ID</param>
  3045. /// <param name="workUserCode">生产工号Code</param>
  3046. /// <param name="sUserInfo">用户基本信息</param>
  3047. /// <returns>string</returns>
  3048. private static string AddProducer(IDBTransaction oracleTrConn, DateTime accountDate, int productionDataID, int workUserID, string workUserCode, SUserInfo sUserInfo, ref int? ClassesSettingID)
  3049. {
  3050. // 参数
  3051. OracleParameter[] paras;
  3052. #region 查询班次配置表是否有数据
  3053. string sql = "select max(ClassesSettingID)"
  3054. + " from tp_pc_classessetting"
  3055. + " where Valueflag =1 and AccountID = :accountID"
  3056. + " and UserID = :userID"
  3057. + " and AccountDate = :accountDate";
  3058. paras = new OracleParameter[] {
  3059. new OracleParameter(":accountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  3060. new OracleParameter(":userID",OracleDbType.Int32,workUserID,ParameterDirection.Input),
  3061. new OracleParameter(":accountDate",OracleDbType.Date,accountDate,ParameterDirection.Input),
  3062. };
  3063. string countStr = oracleTrConn.GetSqlResultToStr(sql, paras);
  3064. int classesSettingID = 0;
  3065. #endregion
  3066. #region 没有班次配置数据,将工号所属员工插入班次配置表中
  3067. if (string.IsNullOrEmpty(countStr) || Constant.INT_IS_ZERO == int.Parse(countStr))
  3068. {
  3069. // 查询新插入的班次配置表ID
  3070. sql = "select SEQ_PC_ClassesSetting_ID.nextval from dual";
  3071. string idStr = oracleTrConn.GetSqlResultToStr(sql);
  3072. // 新插入的班次配置表ID
  3073. if (!string.IsNullOrEmpty(idStr))
  3074. {
  3075. classesSettingID = int.Parse(idStr);
  3076. }
  3077. else
  3078. {
  3079. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  3080. }
  3081. ClassesSettingID = Convert.ToInt32(classesSettingID);
  3082. #region 班次配置总表
  3083. sql = "insert into tp_pc_classessetting"
  3084. + " (ClassesSettingID,accountdate, "
  3085. + " userid, "
  3086. + " usercode, "
  3087. + " accountid, "
  3088. + " createuserid, "
  3089. + " updateuserid,ORGANIZATIONID)"
  3090. + " select "
  3091. + " :classesSettingID, "
  3092. + " :accountdate, "
  3093. + " USERID, "
  3094. + " UserCode, "
  3095. + " accountid,"
  3096. + " :createuserid,"
  3097. + " :updateuserid,ORGANIZATIONID"
  3098. + " from TP_MST_User"
  3099. + " where UserID = :userID";
  3100. paras = new OracleParameter[] {
  3101. new OracleParameter(":classesSettingID",OracleDbType.Int32,classesSettingID,ParameterDirection.Input),
  3102. new OracleParameter(":accountDate",OracleDbType.Date,accountDate,ParameterDirection.Input),
  3103. new OracleParameter(":createuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  3104. new OracleParameter(":updateuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  3105. new OracleParameter(":userID",OracleDbType.Int32,workUserID,ParameterDirection.Input),
  3106. };
  3107. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  3108. // 失败
  3109. if (result != Constant.INT_IS_ONE)
  3110. {
  3111. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  3112. }
  3113. #endregion
  3114. #region 班次配置明细SQL
  3115. sql = " insert into tp_pc_classesdetail"
  3116. + " (classessettingid,"
  3117. + " accountdate,"
  3118. + " userid,"
  3119. + " usercode,"
  3120. + " UJobsID,"
  3121. + " staffid,"
  3122. + " SJobsID,"
  3123. + " staffstatus,"
  3124. + " accountid,"
  3125. + " createuserid,"
  3126. + " updateuserid,Uorganizationid,Sorganizationid)"
  3127. + " select "
  3128. + " :classessettingid,"
  3129. + " :accountdate,"
  3130. + " userStaff.Userid,"
  3131. + " :usercode,"
  3132. + " userStaff.Ujobsid,"
  3133. + " userStaff.Staffid,"
  3134. + " staff.Jobs,"
  3135. + " staff.staffstatus,"
  3136. + " :accountID,"
  3137. + " :createuserid,"
  3138. + " :updateuserid,user2.organizationid,staff.organizationid"
  3139. + " from TP_MST_UserStaff userStaff"
  3140. + " inner join tp_hr_staff staff on staff.staffid = userStaff.Staffid"
  3141. + " inner join tp_mst_user user2 on userStaff.userid = user2.userid"
  3142. + " where (staff.StaffStatus = 1 or staff.StaffStatus = 2)"
  3143. + " and staff.ValueFlag = 1"
  3144. + " and staff.AccountID = :accountID"
  3145. + " and userStaff.UserID = :userID";
  3146. paras = new OracleParameter[] {
  3147. new OracleParameter(":classessettingid",OracleDbType.Int32,classesSettingID,ParameterDirection.Input),
  3148. new OracleParameter(":accountdate",OracleDbType.Date,accountDate,ParameterDirection.Input),
  3149. new OracleParameter(":usercode",OracleDbType.Varchar2,workUserCode,ParameterDirection.Input),
  3150. new OracleParameter(":accountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  3151. new OracleParameter(":createuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  3152. new OracleParameter(":updateuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  3153. new OracleParameter(":accountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  3154. new OracleParameter(":userID",OracleDbType.Int32,workUserID,ParameterDirection.Input),
  3155. };
  3156. result = oracleTrConn.ExecuteNonQuery(sql, paras);
  3157. // 失败
  3158. if (result == Constant.INT_IS_ZERO)
  3159. {
  3160. return string.Format(Messages.MSG_CMN_W007, "生产工号[" + workUserCode + "]没有配置生产员工");
  3161. }
  3162. #endregion
  3163. }
  3164. else
  3165. {
  3166. ClassesSettingID = int.Parse(countStr);
  3167. }
  3168. #endregion
  3169. //#region 将班次配置表中的数据插入生产者表中
  3170. //sql = "insert into tp_pm_producer"
  3171. // + " (productiondataid,"
  3172. // + " staffid,"
  3173. // + " userid,"
  3174. // + " usercode,"
  3175. // + " UJobsID,"
  3176. // + " staffstatus,"
  3177. // + " SJobsID,"
  3178. // + " classessettingid"
  3179. // + " )"
  3180. // + " select :productiondataid,"
  3181. // + " staffid,"
  3182. // + " userid,"
  3183. // + " usercode,"
  3184. // + " UJobsID,"
  3185. // + " staffstatus,"
  3186. // + " SJobsID,"
  3187. // + " :classessettingid"
  3188. // + " from tp_pc_classesdetail"
  3189. // + " where ValueFlag = 1"
  3190. // + " and classessettingid = (select max(ClassesSettingID)"
  3191. // + " from TP_PC_ClassesSetting"
  3192. // + " where ValueFlag = 1 and AccountDate=:accountDate"
  3193. // + " and UserID = :userID)";
  3194. //paras = new OracleParameter[] {
  3195. // new OracleParameter(":productiondataid",OracleDbType.Int32,productionDataID,ParameterDirection.Input),
  3196. // new OracleParameter(":classessettingid",OracleDbType.Int32,classesSettingID.ToString()=="0"?null:classesSettingID.ToString(),ParameterDirection.Input),
  3197. // new OracleParameter(":accountDate",OracleDbType.Date,accountDate,ParameterDirection.Input),
  3198. // new OracleParameter(":userID",OracleDbType.Int32,workUserID,ParameterDirection.Input),
  3199. // };
  3200. //int resultCount = oracleTrConn.ExecuteNonQuery(sql, paras);
  3201. //// 失败
  3202. //if (resultCount == Constant.INT_IS_ZERO)
  3203. //{
  3204. // return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  3205. //}
  3206. //#endregion
  3207. return null;
  3208. }
  3209. /// <summary>
  3210. /// 窑车生产者
  3211. /// </summary>
  3212. /// <param name="oracleTrConn">连接对象</param>
  3213. /// <param name="accountDate">账务日期</param>
  3214. /// <param name="kilnCarDataID">窑车生产数据ID</param>
  3215. /// <param name="workUserID">生产工号ID</param>
  3216. /// <param name="sUserInfo">用户基本信息</param>
  3217. /// <returns>string</returns>
  3218. private static string AddKilnCarProducer(IDBTransaction oracleTrConn, DateTime accountDate, int kilnCarDataID, int workUserID, SUserInfo sUserInfo)
  3219. {
  3220. // 参数
  3221. OracleParameter[] paras;
  3222. #region 将班次配置表中的数据插入生产者表中
  3223. string sql = "insert into TP_PM_KilnCarProducer"
  3224. + " (KilnCarDataID,"
  3225. + " staffid,"
  3226. + " userid,"
  3227. + " usercode,"
  3228. + " Ujobsid,"
  3229. + " staffstatus,"
  3230. + " Sjobsid,"
  3231. + " classessettingid"
  3232. + " )"
  3233. + " select :kilnCarDataID,"
  3234. + " staffid,"
  3235. + " userid,"
  3236. + " usercode,"
  3237. + " Ujobsid,"
  3238. + " staffstatus,"
  3239. + " Sjobsid,"
  3240. + " classessettingid"
  3241. + " from tp_pc_classesdetail"
  3242. + " where ValueFlag = 1"
  3243. + " and classessettingid = (select max(ClassesSettingID)"
  3244. + " from TP_PC_ClassesSetting"
  3245. + " where ValueFlag = 1 and AccountDate=:accountDate"
  3246. + " and UserID = :userID)";
  3247. paras = new OracleParameter[] {
  3248. new OracleParameter(":kilnCarDataID",OracleDbType.Int32,kilnCarDataID,ParameterDirection.Input),
  3249. new OracleParameter(":accountDate",OracleDbType.Date,accountDate,ParameterDirection.Input),
  3250. new OracleParameter(":userID",OracleDbType.Int32,workUserID,ParameterDirection.Input),
  3251. };
  3252. int resultCount = oracleTrConn.ExecuteNonQuery(sql, paras);
  3253. // 失败
  3254. if (resultCount == Constant.INT_IS_ZERO)
  3255. {
  3256. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  3257. }
  3258. #endregion
  3259. return null;
  3260. }
  3261. /// <summary>
  3262. /// 添加生产数据
  3263. /// </summary>
  3264. /// <param name="oracleTrConn">连接对象</param>
  3265. /// <param name="accountDate">账务日期</param>
  3266. /// <param name="productionData">生产数据</param>
  3267. /// <param name="sUserInfo">用户基本信息</param>
  3268. /// <returns>string</returns>
  3269. /// <remarks>
  3270. /// 陈冰 2014.09.18 新建
  3271. /// </remarks>
  3272. private static string AddProductionDataCreateTime(IDBTransaction oracleTrConn, DateTime accountDate, ProductionDataEntity productionData, SUserInfo sUserInfo, out string OutSpecialRepairflag)
  3273. {
  3274. #region 查出产品注浆日期,注浆工号ID,注浆工号编码,注浆次数,注浆模具编号,模具编号
  3275. // string selectSql = @"select TP_PM_GroutingProduct.GroutingDate,
  3276. // TP_PM_GroutingProduct.GroutingUserID,
  3277. // TP_PM_GroutingProduct.GroutingUserCode,
  3278. // TP_PM_GroutingProduct.GroutingNum,
  3279. // TP_PM_GroutingProduct.GroutingMouldCode,
  3280. // TP_PM_GroutingProduct.MouldCode,
  3281. // TP_PM_GroutingDaily.GroutingDailyID,
  3282. // TP_PM_GroutingDailyDetail.GroutingDailyDetailID,
  3283. // TP_PM_GroutingDaily.GroutingLineID,
  3284. // TP_PM_GroutingDaily.GroutingLineCode,
  3285. // TP_PM_GroutingDaily.GroutingLineName,
  3286. // TP_PM_GroutingDaily.GMouldTypeID,
  3287. // TP_PM_GroutingDaily.CanManyTimes,
  3288. // TP_PM_GroutingDailyDetail.GroutingLineDetailID
  3289. // from TP_PM_GroutingProduct
  3290. // left join TP_PM_GroutingDaily
  3291. // on TP_PM_GroutingProduct.GroutingDailyID=TP_PM_GroutingDaily.GroutingDailyID
  3292. // left join TP_PM_GroutingDailyDetail
  3293. // on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_GroutingDailyDetail.GroutingDailyID
  3294. // where TP_PM_GroutingProduct.barcode=:barcode";
  3295. //这地方连了两张表,为了成检的时候,次品在次新增
  3296. string returnVal = "";
  3297. string selectSql = @"select
  3298. GroutingDate,
  3299. GroutingUserID,
  3300. GroutingUserCode,
  3301. GroutingNum,
  3302. GroutingMouldCode,
  3303. MouldCode,
  3304. GroutingDailyID,
  3305. GroutingDailyDetailID,
  3306. GroutingLineID,
  3307. GroutingLineCode,
  3308. GroutingLineName,
  3309. GMouldTypeID,
  3310. CanManyTimes,
  3311. GroutingLineDetailID,
  3312. SpecialRepairflag
  3313. from tp_pm_inproduction where barcode=:barcode
  3314. union
  3315. select
  3316. GroutingDate,
  3317. GroutingUserID,
  3318. GroutingUserCode,
  3319. GroutingNum,
  3320. GroutingMouldCode,
  3321. MouldCode,
  3322. GroutingDailyID,
  3323. GroutingDailyDetailID,
  3324. GroutingLineID,
  3325. GroutingLineCode,
  3326. GroutingLineName,
  3327. GMouldTypeID,
  3328. CanManyTimes,
  3329. GroutingLineDetailID,
  3330. SpecialRepairflag
  3331. from TP_PM_InProductionTrash where barcode=:barcode
  3332. ";
  3333. OracleParameter[] selectparas = new OracleParameter[] {
  3334. new OracleParameter(":barcode",productionData.Barcode),
  3335. };
  3336. DataSet dsGroutingProduct = oracleTrConn.GetSqlResultToDs(selectSql, selectparas);
  3337. DateTime GroutingDate = new DateTime();
  3338. int GroutingUserID = 0, SpecialRepairflag = 0;
  3339. string GroutingUserCode = "";
  3340. int GroutingNum = 0;
  3341. string GroutingMouldCode = "";
  3342. string MouldCode = "";
  3343. //注浆日报ID
  3344. int GroutingDailyID = 0;
  3345. //注浆日报明细ID
  3346. int GroutingDailyDetailID = 0;
  3347. //成型生产线ID
  3348. int GroutingLineID = 0;
  3349. //成型生产线编码
  3350. string GroutingLineCode = "";
  3351. // 成型生产线名称
  3352. string GroutingLineName = "";
  3353. //成型线类型ID
  3354. int GMouldTypeID = 0;
  3355. // 能否多次注浆
  3356. int CanManyTimes = 0;
  3357. // 成型生产线明细ID
  3358. int GroutingLineDetailID = 0;
  3359. if (dsGroutingProduct != null && dsGroutingProduct.Tables[0].Rows.Count > 0)
  3360. {
  3361. GroutingDate = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
  3362. GroutingUserID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingUserID"]);
  3363. GroutingUserCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"].ToString();
  3364. GroutingNum = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"]);
  3365. GroutingMouldCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingMouldCode"].ToString();
  3366. MouldCode = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"].ToString();
  3367. GroutingDailyID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyID"]);
  3368. GroutingDailyDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyDetailID"]);
  3369. GroutingLineID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineID"]);
  3370. GroutingLineCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineCode"].ToString();
  3371. GroutingLineName = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineName"].ToString();
  3372. GMouldTypeID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GMouldTypeID"]);
  3373. CanManyTimes = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["CanManyTimes"]);
  3374. GroutingLineDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineDetailID"]);
  3375. SpecialRepairflag = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["SpecialRepairflag"]);
  3376. returnVal = SpecialRepairflag.ToString();
  3377. }
  3378. #endregion
  3379. #region 更新窑炉窑车属性
  3380. if (productionData.ModelType != 1 && productionData.ModelType != 2 && productionData.ModelType != 3 && productionData.ModelType != 4)
  3381. {
  3382. DataSet ds = GetKilnCarInfo(oracleTrConn, productionData.Barcode, sUserInfo);
  3383. if (ds != null)
  3384. {
  3385. if (ds.Tables[0].Rows[0]["KilnID"].ToString() != "") //表示以前有过窑炉相关信息
  3386. {
  3387. productionData.KilnID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnID"]);
  3388. productionData.KilnCode = ds.Tables[0].Rows[0]["KilnCode"].ToString();
  3389. productionData.KilnName = ds.Tables[0].Rows[0]["KilnName"].ToString();
  3390. productionData.KilnCarID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarID"]);
  3391. productionData.KilnCarCode = ds.Tables[0].Rows[0]["KilnCarCode"].ToString();
  3392. productionData.KilnCarName = ds.Tables[0].Rows[0]["KilnCarName"].ToString();
  3393. productionData.KilnCarBatchNo = ds.Tables[0].Rows[0]["KilnCarBatchNo"].ToString();
  3394. productionData.KilnCarPosition = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarPosition"]);
  3395. }
  3396. }
  3397. }
  3398. #endregion
  3399. //string sql = "select createtime from TP_PM_KilnCarGoods"
  3400. // + " where KilnCarID=:KilnCarID and AccountID=:AccountID";
  3401. //OracleParameter[] paras = new OracleParameter[] {
  3402. // new OracleParameter(":KilnCarID",productionData.KilnCarID),
  3403. // new OracleParameter(":AccountID",sUserInfo.AccountID),
  3404. //};
  3405. //DataSet dsReturn = oracleTrConn.GetSqlResultToDs(sql, paras);
  3406. //if (dsReturn != null && dsReturn.Tables[0].Rows.Count > 0)
  3407. //{
  3408. // sql = "update TP_PM_ProductionData set "
  3409. // + " CreateTime=:CreateTime"
  3410. // + " where barcode=:barcode and ProcedureID=:ProcedureID and KilnCarID=:KilnCarID and AccountID=:AccountID";
  3411. // paras = new OracleParameter[] {
  3412. // new OracleParameter(":CreateTime",Convert.ToDateTime(dsReturn.Tables[0].Rows[0]["CreateTime"])),
  3413. // new OracleParameter(":barcode",productionData.Barcode),
  3414. // new OracleParameter(":ProcedureID",productionData.CompleteProcedureID),
  3415. // new OracleParameter(":KilnCarID",productionData.KilnCarID),
  3416. // new OracleParameter(":AccountID",sUserInfo.AccountID),
  3417. // };
  3418. // int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  3419. //}
  3420. #region SQL
  3421. string sql = "insert into tp_pm_productiondata"
  3422. + " ("
  3423. + " barcode,"
  3424. + " centralizedbatchno,"
  3425. + " productionlineid,"
  3426. + " productionlinecode,"
  3427. + " productionlinename,"
  3428. + " procedureid,"
  3429. + " procedurecode,"
  3430. + " procedurename,"
  3431. + " proceduremodel,"
  3432. + " modeltype,"
  3433. + " piecetype,"
  3434. + " isreworked,"
  3435. + " nodetype,"
  3436. + " ispublicbody,"
  3437. + " isrefire,"
  3438. + " organizationid,"
  3439. + " goodsid,"
  3440. + " goodscode,"
  3441. + " goodsname,"
  3442. + " userid,"
  3443. + " usercode,"
  3444. + " username,"
  3445. + " kilnid,"
  3446. + " kilncode,"
  3447. + " kilnname,"
  3448. + " kilncarid,"
  3449. + " kilncarcode,"
  3450. + " kilncarname,"
  3451. + " kilncarbatchno,"
  3452. + " kilncarposition,"
  3453. + " reworkprocedureid,"
  3454. + " reworkprocedurecode,"
  3455. + " reworkprocedurename,"
  3456. + " remarks,"
  3457. + " accountdate,"
  3458. + " accountid,"
  3459. + " GoodsLevelID,"
  3460. + " GoodsLevelTypeID,"
  3461. + " createuserid,"
  3462. + " updateuserid,"
  3463. + " GroutingDate,"
  3464. + " GroutingUserID,"
  3465. + " GroutingUserCode,"
  3466. + " GroutingNum,"
  3467. + " GroutingMouldCode,"
  3468. + " MouldCode,"
  3469. + "GroutingDailyID,"
  3470. + "GroutingDailyDetailID,"
  3471. + "GroutingLineID,"
  3472. + " GroutingLineCode,"
  3473. + "GroutingLineName,"
  3474. + "GMouldTypeID,"
  3475. + "CanManyTimes,"
  3476. + "GroutingLineDetailID,"
  3477. + "CreateTime,SpecialRepairflag"
  3478. + ")"
  3479. + " values"
  3480. + " ("
  3481. + " :barcode,"
  3482. + " :centralizedbatchno,"
  3483. + " :productionlineid,"
  3484. + " :productionlinecode,"
  3485. + " :productionlinename,"
  3486. + " :procedureid,"
  3487. + " :procedurecode,"
  3488. + " :procedurename,"
  3489. + " :proceduremodel,"
  3490. + " :modeltype,"
  3491. + " :piecetype,"
  3492. + " :isreworked,"
  3493. + " :nodetype,"
  3494. + " :ispublicbody,"
  3495. + " :isrefire,"
  3496. + " :organizationid,"
  3497. + " :goodsid,"
  3498. + " :goodscode,"
  3499. + " :goodsname,"
  3500. + " :userid,"
  3501. + " :usercode,"
  3502. + " :username,"
  3503. + " :kilnid,"
  3504. + " :kilncode,"
  3505. + " :kilnname,"
  3506. + " :kilncarid,"
  3507. + " :kilncarcode,"
  3508. + " :kilncarname,"
  3509. + " :kilncarbatchno,"
  3510. + " :kilncarposition,"
  3511. + " :reworkprocedureid,"
  3512. + " :reworkprocedurecode,"
  3513. + " :reworkprocedurename,"
  3514. + " :remarks,"
  3515. + " :accountdata,"
  3516. + " :accountid,"
  3517. + " :GoodsLevelID,"
  3518. + " :GoodsLevelTypeID,"
  3519. + " :createuserid,"
  3520. + " :updateuserid,"
  3521. + " :groutingdate,"
  3522. + " :groutinguserid,"
  3523. + " :groutingusercode,"
  3524. + " :groutingnum,"
  3525. + " :groutingmouldcode,"
  3526. + " :mouldcode,"
  3527. + ":groutingdailyid,"
  3528. + ":groutingdailydetailid,"
  3529. + ":groutinglineid,"
  3530. + " :groutinglinecode,"
  3531. + ":groutinglinename,"
  3532. + ":gmouldtypeid,"
  3533. + ":canmanytimes,"
  3534. + ":groutinglinedetailid,"
  3535. + ":CreateTime,:SpecialRepairflag"
  3536. + ")";
  3537. #endregion
  3538. #region OracleParameter
  3539. OracleParameter[] paras = new OracleParameter[] {
  3540. new OracleParameter(":barcode",productionData.Barcode),
  3541. new OracleParameter(":centralizedbatchno",productionData.CentralizedBatchNo),
  3542. new OracleParameter(":productionlineid",productionData.ProductionLineID),
  3543. new OracleParameter(":productionlinecode",productionData.ProductionLineCode),
  3544. new OracleParameter(":productionlinename",productionData.ProductionLineName),
  3545. new OracleParameter(":procedureid",productionData.CompleteProcedureID),
  3546. new OracleParameter(":procedurecode",productionData.ProcedureCode),
  3547. new OracleParameter(":procedurename",productionData.ProcedureName),
  3548. new OracleParameter(":proceduremodel",productionData.ProcedureModel),
  3549. new OracleParameter(":modeltype",productionData.ModelType),
  3550. new OracleParameter(":piecetype",productionData.PieceType),
  3551. new OracleParameter(":isreworked",productionData.IsReworked),
  3552. new OracleParameter(":nodetype",productionData.NodeType),
  3553. new OracleParameter(":ispublicbody",productionData.IsPublicBody),
  3554. new OracleParameter(":isrefire",productionData.IsReFire),
  3555. new OracleParameter(":organizationid",productionData.OrganizationID),
  3556. new OracleParameter(":goodsid",productionData.GoodsID),
  3557. new OracleParameter(":goodscode",productionData.GoodsCode),
  3558. new OracleParameter(":goodsname",productionData.GoodsName),
  3559. new OracleParameter(":userid",productionData.UserID),
  3560. new OracleParameter(":usercode",productionData.UserCode),
  3561. new OracleParameter(":username",productionData.UserName),
  3562. new OracleParameter(":kilnid",productionData.KilnID),
  3563. new OracleParameter(":kilncode",productionData.KilnCode),
  3564. new OracleParameter(":kilnname",productionData.KilnName),
  3565. new OracleParameter(":kilncarid",productionData.KilnCarID),
  3566. new OracleParameter(":kilncarcode",productionData.KilnCarCode),
  3567. new OracleParameter(":kilncarname",productionData.KilnCarName),
  3568. new OracleParameter(":kilncarbatchno",productionData.KilnCarBatchNo),
  3569. new OracleParameter(":kilncarposition",productionData.KilnCarPosition),
  3570. new OracleParameter(":reworkprocedureid",productionData.ReworkProcedureID),
  3571. new OracleParameter(":reworkprocedurecode",productionData.ReworkProcedureCode),
  3572. new OracleParameter(":reworkprocedurename",productionData.ReworkProcedureName),
  3573. new OracleParameter(":remarks",productionData.Remarks),
  3574. new OracleParameter(":accountdata",accountDate),
  3575. new OracleParameter(":accountid",sUserInfo.AccountID),
  3576. new OracleParameter(":GoodsLevelID",productionData.GoodsLevelID),
  3577. new OracleParameter(":GoodsLevelTypeID",productionData.GoodsLevelTypeID),
  3578. new OracleParameter(":createuserid",sUserInfo.UserID),
  3579. new OracleParameter(":updateuserid",sUserInfo.UserID),
  3580. new OracleParameter(":groutingdate",GroutingDate),
  3581. new OracleParameter(":groutinguserid",GroutingUserID),
  3582. new OracleParameter(":groutingusercode",GroutingUserCode),
  3583. new OracleParameter(":groutingnum",GroutingNum),
  3584. new OracleParameter(":groutingmouldcode",GroutingMouldCode),
  3585. new OracleParameter(":mouldcode",MouldCode),
  3586. new OracleParameter(":groutingdailyid",GroutingDailyID),
  3587. new OracleParameter(":groutingdailydetailid",GroutingDailyDetailID),
  3588. new OracleParameter(":groutinglineid",GroutingLineID),
  3589. new OracleParameter(":groutinglinecode",GroutingLineCode),
  3590. new OracleParameter(":groutinglinename",GroutingLineName),
  3591. new OracleParameter(":gmouldtypeid",GMouldTypeID),
  3592. new OracleParameter(":canmanytimes",CanManyTimes),
  3593. new OracleParameter(":groutinglinedetailid",GroutingLineDetailID),
  3594. new OracleParameter(":CreateTime",productionData.CreateTime),
  3595. new OracleParameter(":specialRepairflag",SpecialRepairflag),
  3596. };
  3597. #endregion
  3598. foreach (OracleParameter para in paras)
  3599. {
  3600. if (string.IsNullOrEmpty(para.Value + ""))
  3601. {
  3602. para.Value = DBNull.Value;
  3603. }
  3604. }
  3605. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  3606. OutSpecialRepairflag = returnVal;
  3607. // 失败
  3608. if (result != Constant.INT_IS_ONE)
  3609. {
  3610. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  3611. }
  3612. // 成功返回null
  3613. return null;
  3614. }
  3615. /// <summary>
  3616. /// 添加生产数据
  3617. /// </summary>
  3618. /// <param name="oracleTrConn">连接对象</param>
  3619. /// <param name="accountDate">账务日期</param>
  3620. /// <param name="productionData">生产数据</param>
  3621. /// <param name="sUserInfo">用户基本信息</param>
  3622. /// <param name="isSendBody">是否交坯</param>
  3623. /// <returns>string</returns>
  3624. /// <remarks>
  3625. /// 陈冰 2014.09.18 新建
  3626. /// xuwei 2019-09-17 修改
  3627. /// </remarks>
  3628. private static string AddProductionDataDeliverMud(IDBTransaction oracleTrConn, DateTime accountDate, ProductionDataEntity productionData, SUserInfo sUserInfo, out string OutSpecialRepairflag
  3629. , out DataSet outGroutingProduct, bool isSendBody = false)
  3630. {
  3631. #region 查出产品注浆日期,注浆工号ID,注浆工号编码,注浆次数,注浆模具编号,模具编号
  3632. string selectSql = "";
  3633. string returnVal = "";
  3634. //xuwei fix 2019-09-23 修正非交坯时 productionData.GroutingDailyDetailID 为空无法得到结果
  3635. //改用 条码查询
  3636. //selectSql = @"select GroutingDate,
  3637. // ClassesSettingID,
  3638. // UserID as GroutingUserID,
  3639. // UserCode as GroutingUserCode,
  3640. // GroutingCount as GroutingNum,
  3641. // GroutingMouldCode,
  3642. // MouldCode,
  3643. // GroutingDailyID,
  3644. // GroutingDailyDetailID,
  3645. // GroutingLineID,
  3646. // GroutingLineCode,
  3647. // GroutingLineName,
  3648. // GroutingLineDetailID,
  3649. // SpecialRepairflag,
  3650. // goodsid,
  3651. // goodscode,
  3652. // goodsname,
  3653. // GMouldTypeID,
  3654. // CanManyTimes,
  3655. // LogoID
  3656. // from tp_pm_GroutingDailyDetail
  3657. // where tp_pm_GroutingDailyDetail.GroutingDailyDetailID=:GroutingDailyDetailID";
  3658. //OracleParameter[] selectparas1 = new OracleParameter[] {
  3659. // new OracleParameter(":GroutingDailyDetailID",productionData.GroutingDailyDetailID),
  3660. //};
  3661. selectSql = @"select GroutingDate,
  3662. ClassesSettingID,
  3663. UserID as GroutingUserID,
  3664. UserCode as GroutingUserCode,
  3665. GroutingCount as GroutingNum,
  3666. GroutingMouldCode,
  3667. MouldCode,
  3668. GroutingDailyID,
  3669. GroutingDailyDetailID,
  3670. GroutingLineID,
  3671. GroutingLineCode,
  3672. GroutingLineName,
  3673. GroutingLineDetailID,
  3674. SpecialRepairflag,
  3675. goodsid,
  3676. goodscode,
  3677. goodsname,
  3678. GMouldTypeID,
  3679. CanManyTimes,
  3680. LogoID
  3681. from tp_pm_GroutingDailyDetail
  3682. where tp_pm_GroutingDailyDetail.Barcode=:Barcode";
  3683. OracleParameter[] selectparas1 = new OracleParameter[] {
  3684. new OracleParameter(":Barcode",productionData.Barcode),
  3685. };
  3686. //xuwei fix end
  3687. DataSet dsGroutingProduct = oracleTrConn.GetSqlResultToDs(selectSql, selectparas1);
  3688. DateTime GroutingDate = new DateTime();
  3689. int GroutingUserID = 0, GroutingNum = 0, GroutingDailyID = 0, GroutingDailyDetailID = 0, GroutingLineID = 0, GMouldTypeID = 0, CanManyTimes = 0, GroutingLineDetailID = 0, SpecialRepairflag = 0;
  3690. string GroutingUserCode = "", GroutingMouldCode = "", MouldCode = "", GroutingLineCode = "", GroutingLineName = "";
  3691. int? ClassesSettingID = null;
  3692. int? LogoID = null;
  3693. if (dsGroutingProduct != null && dsGroutingProduct.Tables[0].Rows.Count > 0)
  3694. {
  3695. GroutingDate = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
  3696. GroutingUserID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingUserID"]);
  3697. GroutingUserCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"].ToString();
  3698. GroutingNum = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"]);
  3699. GroutingMouldCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingMouldCode"].ToString();
  3700. MouldCode = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"].ToString();
  3701. GroutingDailyID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyID"]);
  3702. GroutingDailyDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyDetailID"]);
  3703. GroutingLineID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineID"]);
  3704. GroutingLineCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineCode"].ToString();
  3705. GroutingLineName = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineName"].ToString();
  3706. GMouldTypeID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GMouldTypeID"]);
  3707. CanManyTimes = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["CanManyTimes"]);
  3708. GroutingLineDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineDetailID"]);
  3709. SpecialRepairflag = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["SpecialRepairflag"]);
  3710. returnVal = SpecialRepairflag.ToString();
  3711. if (productionData.IsPublicBody.ToString() != "1")
  3712. ClassesSettingID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["ClassesSettingID"]);
  3713. else
  3714. ClassesSettingID = productionData.ClassesSettingID == null ? Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["ClassesSettingID"]) : productionData.ClassesSettingID;
  3715. if (dsGroutingProduct.Tables[0].Rows[0]["LogoID"] != DBNull.Value)
  3716. {
  3717. LogoID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["LogoID"]);
  3718. }
  3719. //xuwei fix begin
  3720. //2019-09-17
  3721. //更新注浆日报(交坯处理)
  3722. if (isSendBody)
  3723. {
  3724. selectSql = "update TP_PM_GroutingDailyDetail set ispublicbody=:ispublicbody, DELIVERFLAG=1,DELIVERTIME=sysdate,deliveruserid=:deliveruserid,deliverusercode=:deliverusercode where GroutingDailyDetailID=" + GroutingDailyDetailID;
  3725. OracleParameter[] paras2 = new OracleParameter[] {
  3726. new OracleParameter(":deliveruserid",productionData.UserID),
  3727. new OracleParameter(":deliverusercode",productionData.UserCode),
  3728. new OracleParameter(":ispublicbody",productionData.IsPublicBody),
  3729. };
  3730. oracleTrConn.ExecuteNonQuery(selectSql, paras2);
  3731. }
  3732. //更新 注浆日报 在产标识(BEGINNINGFLAG)
  3733. selectSql = "update TP_PM_GroutingDailyDetail set BEGINNINGFLAG = '1' where Barcode='" + productionData.Barcode + "'";
  3734. oracleTrConn.ExecuteNonQuery(selectSql);
  3735. //xuwei end
  3736. }
  3737. outGroutingProduct = dsGroutingProduct;
  3738. #endregion
  3739. #region 更新窑炉窑车属性
  3740. //if (productionData.ModelType != 1 && productionData.ModelType != 2 && productionData.ModelType != 3 && productionData.ModelType != 4)
  3741. //{
  3742. // DataSet ds = GetKilnCarInfo(oracleTrConn, productionData.Barcode, sUserInfo);
  3743. // if (ds != null)
  3744. // {
  3745. // if (ds.Tables[0].Rows[0]["KilnID"].ToString() != "") //表示以前有过窑炉相关信息
  3746. // {
  3747. // productionData.KilnID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnID"]);
  3748. // productionData.KilnCode = ds.Tables[0].Rows[0]["KilnCode"].ToString();
  3749. // productionData.KilnName = ds.Tables[0].Rows[0]["KilnName"].ToString();
  3750. // productionData.KilnCarID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarID"]);
  3751. // productionData.KilnCarCode = ds.Tables[0].Rows[0]["KilnCarCode"].ToString();
  3752. // productionData.KilnCarName = ds.Tables[0].Rows[0]["KilnCarName"].ToString();
  3753. // productionData.KilnCarBatchNo = ds.Tables[0].Rows[0]["KilnCarBatchNo"].ToString();
  3754. // productionData.KilnCarPosition = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarPosition"]);
  3755. // }
  3756. // }
  3757. //}
  3758. #endregion
  3759. #region SQL
  3760. string sql = "insert into tp_pm_productiondataIn"
  3761. + " (productiondataid,"
  3762. + " barcode,"
  3763. + " centralizedbatchno,"
  3764. + " productionlineid,"
  3765. + " productionlinecode,"
  3766. + " productionlinename,"
  3767. + " procedureid,"
  3768. + " procedurecode,"
  3769. + " procedurename,"
  3770. + " proceduremodel,"
  3771. + " modeltype,"
  3772. + " piecetype,"
  3773. + " isreworked,"
  3774. + " nodetype,"
  3775. + " ispublicbody,"
  3776. + " isrefire,"
  3777. + " organizationid,"
  3778. + " goodsid,"
  3779. + " goodscode,"
  3780. + " goodsname,"
  3781. + " userid,"
  3782. + " usercode,"
  3783. + " username,"
  3784. + " kilnid,"
  3785. + " kilncode,"
  3786. + " kilnname,"
  3787. + " kilncarid,"
  3788. + " kilncarcode,"
  3789. + " kilncarname,"
  3790. + " kilncarbatchno,"
  3791. + " kilncarposition,"
  3792. + " reworkprocedureid,"
  3793. + " reworkprocedurecode,"
  3794. + " reworkprocedurename,"
  3795. + " remarks,"
  3796. + " accountdate,"
  3797. + " accountid,"
  3798. + " GoodsLevelID,"
  3799. + " GoodsLevelTypeID,"
  3800. + " createuserid,"
  3801. + " updateuserid,"
  3802. + " GroutingDate,"
  3803. + " GroutingUserID,"
  3804. + " GroutingUserCode,"
  3805. + " GroutingNum,"
  3806. + " GroutingMouldCode,"
  3807. + " MouldCode,"
  3808. + "GroutingDailyID,"
  3809. + "GroutingDailyDetailID,"
  3810. + "GroutingLineID,"
  3811. + " GroutingLineCode,"
  3812. + "GroutingLineName,"
  3813. + "GMouldTypeID,"
  3814. + "CanManyTimes,"
  3815. + "GroutingLineDetailID,"
  3816. + "SpecialRepairflag,"
  3817. + "ClassesSettingID,"
  3818. + "LogoID"
  3819. + ")"
  3820. + " values"
  3821. + " (:productiondataid,"
  3822. + " :barcode,"
  3823. + " :centralizedbatchno,"
  3824. + " :productionlineid,"
  3825. + " :productionlinecode,"
  3826. + " :productionlinename,"
  3827. + " :procedureid,"
  3828. + " :procedurecode,"
  3829. + " :procedurename,"
  3830. + " :proceduremodel,"
  3831. + " :modeltype,"
  3832. + " :piecetype,"
  3833. + " :isreworked,"
  3834. + " :nodetype,"
  3835. + " :ispublicbody,"
  3836. + " :isrefire,"
  3837. + " :organizationid,"
  3838. + " :goodsid,"
  3839. + " :goodscode,"
  3840. + " :goodsname,"
  3841. + " :userid,"
  3842. + " :usercode,"
  3843. + " :username,"
  3844. + " :kilnid,"
  3845. + " :kilncode,"
  3846. + " :kilnname,"
  3847. + " :kilncarid,"
  3848. + " :kilncarcode,"
  3849. + " :kilncarname,"
  3850. + " :kilncarbatchno,"
  3851. + " :kilncarposition,"
  3852. + " :reworkprocedureid,"
  3853. + " :reworkprocedurecode,"
  3854. + " :reworkprocedurename,"
  3855. + " :remarks,"
  3856. + " :accountdata,"
  3857. + " :accountid,"
  3858. + " :GoodsLevelID,"
  3859. + " :GoodsLevelTypeID,"
  3860. + " :createuserid,"
  3861. + " :updateuserid,"
  3862. + " :groutingdate,"
  3863. + " :groutinguserid,"
  3864. + " :groutingusercode,"
  3865. + " :groutingnum,"
  3866. + " :groutingmouldcode,"
  3867. + " :mouldcode,"
  3868. + ":groutingdailyid,"
  3869. + ":groutingdailydetailid,"
  3870. + ":groutinglineid,"
  3871. + " :groutinglinecode,"
  3872. + ":groutinglinename,"
  3873. + ":gmouldtypeid,"
  3874. + ":canmanytimes,"
  3875. + ":groutinglinedetailid,"
  3876. + ":specialRepairflag,"
  3877. + ":classesSettingID,"
  3878. + ":LogoID"
  3879. + ")";
  3880. #endregion
  3881. #region OracleParameter
  3882. OracleParameter[] paras = new OracleParameter[] {
  3883. new OracleParameter(":classesSettingID",ClassesSettingID),
  3884. new OracleParameter(":productiondataid",productionData.ProductionDataID),
  3885. new OracleParameter(":barcode",productionData.Barcode),
  3886. new OracleParameter(":centralizedbatchno",productionData.CentralizedBatchNo),
  3887. new OracleParameter(":productionlineid",productionData.ProductionLineID),
  3888. new OracleParameter(":productionlinecode",productionData.ProductionLineCode),
  3889. new OracleParameter(":productionlinename",productionData.ProductionLineName),
  3890. new OracleParameter(":procedureid",productionData.CompleteProcedureID),
  3891. new OracleParameter(":procedurecode",productionData.ProcedureCode),
  3892. new OracleParameter(":procedurename",productionData.ProcedureName),
  3893. new OracleParameter(":proceduremodel",productionData.ProcedureModel),
  3894. new OracleParameter(":modeltype",productionData.ModelType),
  3895. new OracleParameter(":piecetype",productionData.PieceType),
  3896. new OracleParameter(":isreworked",productionData.IsReworked),
  3897. new OracleParameter(":nodetype",productionData.NodeType),
  3898. new OracleParameter(":ispublicbody",productionData.IsPublicBody),
  3899. new OracleParameter(":isrefire",productionData.IsReFire),
  3900. new OracleParameter(":organizationid",productionData.OrganizationID),
  3901. new OracleParameter(":goodsid",productionData.GoodsID),
  3902. new OracleParameter(":goodscode",productionData.GoodsCode),
  3903. new OracleParameter(":goodsname",productionData.GoodsName),
  3904. new OracleParameter(":userid",productionData.UserID),
  3905. new OracleParameter(":usercode",productionData.UserCode),
  3906. new OracleParameter(":username",productionData.UserName),
  3907. new OracleParameter(":kilnid",productionData.KilnID),
  3908. new OracleParameter(":kilncode",productionData.KilnCode),
  3909. new OracleParameter(":kilnname",productionData.KilnName),
  3910. new OracleParameter(":kilncarid",productionData.KilnCarID),
  3911. new OracleParameter(":kilncarcode",productionData.KilnCarCode),
  3912. new OracleParameter(":kilncarname",productionData.KilnCarName),
  3913. new OracleParameter(":kilncarbatchno",productionData.KilnCarBatchNo),
  3914. new OracleParameter(":kilncarposition",productionData.KilnCarPosition),
  3915. new OracleParameter(":reworkprocedureid",productionData.ReworkProcedureID),
  3916. new OracleParameter(":reworkprocedurecode",productionData.ReworkProcedureCode),
  3917. new OracleParameter(":reworkprocedurename",productionData.ReworkProcedureName),
  3918. new OracleParameter(":remarks",productionData.Remarks),
  3919. new OracleParameter(":accountdata",accountDate),
  3920. new OracleParameter(":accountid",sUserInfo.AccountID),
  3921. new OracleParameter(":GoodsLevelID",productionData.GoodsLevelID),
  3922. new OracleParameter(":GoodsLevelTypeID",productionData.GoodsLevelTypeID),
  3923. new OracleParameter(":createuserid",sUserInfo.UserID),
  3924. new OracleParameter(":updateuserid",sUserInfo.UserID),
  3925. new OracleParameter(":groutingdate",GroutingDate),
  3926. new OracleParameter(":groutinguserid",GroutingUserID),
  3927. new OracleParameter(":groutingusercode",GroutingUserCode),
  3928. new OracleParameter(":groutingnum",GroutingNum),
  3929. new OracleParameter(":groutingmouldcode",GroutingMouldCode),
  3930. new OracleParameter(":mouldcode",MouldCode),
  3931. new OracleParameter(":groutingdailyid",GroutingDailyID),
  3932. new OracleParameter(":groutingdailydetailid",GroutingDailyDetailID),
  3933. new OracleParameter(":groutinglineid",GroutingLineID),
  3934. new OracleParameter(":groutinglinecode",GroutingLineCode),
  3935. new OracleParameter(":groutinglinename",GroutingLineName),
  3936. new OracleParameter(":gmouldtypeid",GMouldTypeID),
  3937. new OracleParameter(":canmanytimes",CanManyTimes),
  3938. new OracleParameter(":groutinglinedetailid",GroutingLineDetailID),
  3939. new OracleParameter(":specialRepairflag",SpecialRepairflag),
  3940. new OracleParameter(":LogoID",LogoID),
  3941. };
  3942. #endregion
  3943. foreach (OracleParameter para in paras)
  3944. {
  3945. if (string.IsNullOrEmpty(para.Value + ""))
  3946. {
  3947. para.Value = DBNull.Value;
  3948. }
  3949. }
  3950. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  3951. OutSpecialRepairflag = returnVal;
  3952. // 失败
  3953. if (result != Constant.INT_IS_ONE)
  3954. {
  3955. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  3956. }
  3957. // 成功返回null
  3958. return null;
  3959. }
  3960. /// <summary>
  3961. /// 添加生产数据
  3962. /// </summary>
  3963. /// <param name="oracleTrConn">连接对象</param>
  3964. /// <param name="accountDate">账务日期</param>
  3965. /// <param name="productionData">生产数据</param>
  3966. /// <param name="sUserInfo">用户基本信息</param>
  3967. /// <param name="isSendBody">是否交坯</param>
  3968. /// <returns>string</returns>
  3969. /// <remarks>
  3970. /// 陈冰 2014.09.18 新建
  3971. /// </remarks>
  3972. private static string AddProductionData(IDBTransaction oracleTrConn, DateTime accountDate, ProductionDataEntity productionData, SUserInfo sUserInfo, out string OutSpecialRepairflag, bool isSendBody = false)
  3973. {
  3974. #region 查出产品注浆日期,注浆工号ID,注浆工号编码,注浆次数,注浆模具编号,模具编号
  3975. string selectSql = "";
  3976. string returnVal = "";
  3977. if (productionData.NodeType == (int)Constant.ProcedureNodeType.Begin)//开始节点时从注浆登记取值
  3978. {
  3979. // wangxin 20150409 删除掉TP_PM_GroutingProduct表后,进行的修改
  3980. // selectSql = @"select TP_PM_GroutingDaily.GroutingDate,
  3981. // TP_PM_GroutingDailyDetail.UserID as GroutingUserID,
  3982. // TP_PM_GroutingDailyDetail.UserCode as GroutingUserCode,
  3983. // TP_PM_GroutingDailyDetail.GroutingCount as GroutingNum,
  3984. // TP_PM_GroutingDailyDetail.GroutingMouldCode,
  3985. // TP_PM_GroutingDailyDetail.MouldCode,
  3986. // TP_PM_GroutingDailyDetail.GroutingDailyID,
  3987. // TP_PM_GroutingDailyDetail.GroutingDailyDetailID,
  3988. // TP_PM_GroutingDailyDetail.GroutingLineID,
  3989. // TP_PM_GroutingDailyDetail.GroutingLineCode,
  3990. // TP_PM_GroutingDailyDetail.GroutingLineName,
  3991. // TP_PM_GroutingDaily.GMouldTypeID,
  3992. // TP_PM_GroutingDaily.CanManyTimes,
  3993. // TP_PM_GroutingDailyDetail.GroutingLineDetailID,
  3994. // TP_PM_GroutingDailyDetail.SpecialRepairflag
  3995. // from TP_PM_GroutingDaily
  3996. // inner join TP_PM_GroutingDailyDetail
  3997. // on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_GroutingDailyDetail.GroutingDailyID
  3998. // where TP_PM_GroutingDailyDetail.barcode=:barcode";
  3999. selectSql = @"select TP_PM_GroutingDailyDetail.GroutingDate,
  4000. TP_PM_GroutingDailyDetail.UserID as GroutingUserID,
  4001. TP_PM_GroutingDailyDetail.UserCode as GroutingUserCode,
  4002. TP_PM_GroutingDailyDetail.GroutingCount as GroutingNum,
  4003. TP_PM_GroutingDailyDetail.GroutingMouldCode,
  4004. TP_PM_GroutingDailyDetail.MouldCode,
  4005. TP_PM_GroutingDailyDetail.GroutingDailyID,
  4006. TP_PM_GroutingDailyDetail.GroutingDailyDetailID,
  4007. TP_PM_GroutingDailyDetail.GroutingLineID,
  4008. TP_PM_GroutingDailyDetail.GroutingLineCode,
  4009. TP_PM_GroutingDailyDetail.GroutingLineName,
  4010. TP_PM_GroutingDailyDetail.GroutingLineDetailID,
  4011. TP_PM_GroutingDailyDetail.SpecialRepairflag,
  4012. (select GMouldTypeID
  4013. from TP_PM_GroutingDaily
  4014. where TP_PM_GroutingDaily.GroutingDailyID =
  4015. TP_PM_GroutingDailyDetail.GroutingDailyID) as GMouldTypeID,
  4016. (select CanManyTimes
  4017. from TP_PM_GroutingDaily
  4018. where TP_PM_GroutingDaily.GroutingDailyID =
  4019. TP_PM_GroutingDailyDetail.GroutingDailyID) as CanManyTimes,
  4020. 0 as IsReFire
  4021. from TP_PM_GroutingDailyDetail
  4022. where TP_PM_GroutingDailyDetail.barcode=:barcode";
  4023. }
  4024. else
  4025. {
  4026. //这地方连了两张表,为了成检的时候,次品在次新增
  4027. // selectSql = @"select
  4028. // GroutingDate,
  4029. // GroutingUserID,
  4030. // GroutingUserCode,
  4031. // GroutingNum,
  4032. // GroutingMouldCode,
  4033. // MouldCode,
  4034. // GroutingDailyID,
  4035. // GroutingDailyDetailID,
  4036. // GroutingLineID,
  4037. // GroutingLineCode,
  4038. // GroutingLineName,
  4039. // GMouldTypeID,
  4040. // CanManyTimes,
  4041. // GroutingLineDetailID,
  4042. // SpecialRepairflag,
  4043. // IsReFire
  4044. //
  4045. // from tp_pm_inproduction where barcode=:barcode
  4046. // union
  4047. // select
  4048. // GroutingDate,
  4049. // GroutingUserID,
  4050. // GroutingUserCode,
  4051. // GroutingNum,
  4052. // GroutingMouldCode,
  4053. // MouldCode,
  4054. // GroutingDailyID,
  4055. // GroutingDailyDetailID,
  4056. // GroutingLineID,
  4057. // GroutingLineCode,
  4058. // GroutingLineName,
  4059. // GMouldTypeID,
  4060. // CanManyTimes,
  4061. // GroutingLineDetailID,
  4062. // SpecialRepairflag,
  4063. // IsReFire
  4064. // from TP_PM_InProductionTrash where barcode=:barcode
  4065. // ";
  4066. selectSql = @"select
  4067. ip.GroutingDate,
  4068. ip.GroutingUserID,
  4069. ip.GroutingUserCode,
  4070. ip.GroutingNum,
  4071. ip.GroutingMouldCode,
  4072. ip.MouldCode,
  4073. ip.GroutingDailyID,
  4074. ip.GroutingDailyDetailID,
  4075. ip.GroutingLineID,
  4076. ip.GroutingLineCode,
  4077. ip.GroutingLineName,
  4078. ip.GMouldTypeID,
  4079. ip.CanManyTimes,
  4080. ip.GroutingLineDetailID,
  4081. ip.SpecialRepairflag,
  4082. ip.IsReFire,
  4083. ip.logoid,
  4084. gdd.ClassesSettingID
  4085. from tp_pm_inproduction ip inner join TP_PM_GroutingDailyDetail gdd on ip.GroutingDailyDetailID=gdd.GroutingDailyDetailID
  4086. where ip.barcode=:barcode
  4087. ";
  4088. }
  4089. OracleParameter[] selectparas = new OracleParameter[] {
  4090. new OracleParameter(":barcode",productionData.Barcode),
  4091. };
  4092. DataSet dsGroutingProduct = oracleTrConn.GetSqlResultToDs(selectSql, selectparas);
  4093. DateTime GroutingDate = new DateTime();
  4094. int GroutingUserID = 0, GroutingNum = 0, GroutingDailyID = 0, GroutingDailyDetailID = 0, GroutingLineID = 0, GMouldTypeID = 0, CanManyTimes = 0, GroutingLineDetailID = 0, SpecialRepairflag = 0;
  4095. string GroutingUserCode = "", GroutingMouldCode = "", MouldCode = "", GroutingLineCode = "", GroutingLineName = "";
  4096. int IsReFire = 0;
  4097. int? logoID = null;
  4098. if (dsGroutingProduct != null && dsGroutingProduct.Tables[0].Rows.Count > 0)
  4099. {
  4100. GroutingDate = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
  4101. GroutingUserID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingUserID"]);
  4102. GroutingUserCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"].ToString();
  4103. GroutingNum = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"]);
  4104. GroutingMouldCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingMouldCode"].ToString();
  4105. MouldCode = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"].ToString();
  4106. GroutingDailyID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyID"]);
  4107. GroutingDailyDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyDetailID"]);
  4108. GroutingLineID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineID"]);
  4109. GroutingLineCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineCode"].ToString();
  4110. GroutingLineName = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineName"].ToString();
  4111. GMouldTypeID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GMouldTypeID"]);
  4112. CanManyTimes = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["CanManyTimes"]);
  4113. GroutingLineDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineDetailID"]);
  4114. SpecialRepairflag = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["SpecialRepairflag"]);
  4115. IsReFire = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["IsReFire"]);
  4116. if (IsReFire > 0) //大于零代表重烧过
  4117. {
  4118. productionData.IsReFire = IsReFire;
  4119. productionData.DefectFlag = (int)Constant.GoodsLevelType.Defect;
  4120. }
  4121. if (dsGroutingProduct.Tables[0].Rows[0]["logoID"].ToString() != "")
  4122. {
  4123. logoID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["logoID"]);
  4124. }
  4125. //if (productionData.LogoID != null) //当前工序有商标
  4126. //{
  4127. // if (logoID != productionData.LogoID && productionData.LogoID != 0)
  4128. // {
  4129. // logoID = productionData.LogoID;
  4130. // //根据明细ID.update
  4131. // selectSql = "update TP_PM_GroutingDailyDetail set logoid=:logoid where GroutingDailyDetailID=" + GroutingDailyDetailID;
  4132. // OracleParameter[] paras2 = new OracleParameter[] {
  4133. // new OracleParameter(":logoid",productionData.LogoID)
  4134. // };
  4135. // oracleTrConn.ExecuteNonQuery(selectSql, paras2);
  4136. // }
  4137. //}
  4138. //xuwei add begin
  4139. //2019-09-17
  4140. //更新注浆日报(交坯处理)
  4141. if (isSendBody)
  4142. {
  4143. if (productionData.IsPublicBody.ToString() != "1" || productionData.ClassesSettingID == null)
  4144. productionData.ClassesSettingID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["ClassesSettingID"]);
  4145. selectSql = "update TP_PM_GroutingDailyDetail set ispublicbody=:ispublicbody, DELIVERFLAG=1,DELIVERTIME=sysdate,deliveruserid=:deliveruserid,deliverusercode=:deliverusercode where GroutingDailyDetailID=" + GroutingDailyDetailID;
  4146. OracleParameter[] paras2 = new OracleParameter[] {
  4147. new OracleParameter(":deliveruserid",productionData.UserID),
  4148. new OracleParameter(":deliverusercode",productionData.UserCode),
  4149. new OracleParameter(":ispublicbody",productionData.IsPublicBody),
  4150. };
  4151. oracleTrConn.ExecuteNonQuery(selectSql, paras2);
  4152. }
  4153. returnVal = SpecialRepairflag.ToString();
  4154. }
  4155. #endregion
  4156. #region 更新窑炉窑车属性
  4157. if (productionData.ModelType != 1 && productionData.ModelType != 2 && productionData.ModelType != 3 && productionData.ModelType != 4)
  4158. {
  4159. DataSet ds = GetKilnCarInfo(oracleTrConn, productionData.Barcode, sUserInfo);
  4160. if (ds != null)
  4161. {
  4162. if (ds.Tables[0].Rows[0]["KilnID"].ToString() != "") //表示以前有过窑炉相关信息
  4163. {
  4164. productionData.KilnID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnID"]);
  4165. productionData.KilnCode = ds.Tables[0].Rows[0]["KilnCode"].ToString();
  4166. productionData.KilnName = ds.Tables[0].Rows[0]["KilnName"].ToString();
  4167. productionData.KilnCarID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarID"]);
  4168. productionData.KilnCarCode = ds.Tables[0].Rows[0]["KilnCarCode"].ToString();
  4169. productionData.KilnCarName = ds.Tables[0].Rows[0]["KilnCarName"].ToString();
  4170. productionData.KilnCarBatchNo = ds.Tables[0].Rows[0]["KilnCarBatchNo"].ToString();
  4171. productionData.KilnCarPosition = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarPosition"]);
  4172. }
  4173. }
  4174. }
  4175. #endregion
  4176. #region SQL
  4177. string sql = "insert into tp_pm_productiondataIn"
  4178. + " (productiondataid,"
  4179. + " barcode,"
  4180. + " centralizedbatchno,"
  4181. + " productionlineid,"
  4182. + " productionlinecode,"
  4183. + " productionlinename,"
  4184. + " procedureid,"
  4185. + " procedurecode,"
  4186. + " procedurename,"
  4187. + " proceduremodel,"
  4188. + " modeltype,"
  4189. + " piecetype,"
  4190. + " isreworked,"
  4191. + " nodetype,"
  4192. + " ispublicbody,"
  4193. + " isrefire,"
  4194. + " organizationid,"
  4195. + " goodsid,"
  4196. + " goodscode,"
  4197. + " goodsname,"
  4198. + " userid,"
  4199. + " usercode,"
  4200. + " username,"
  4201. + " kilnid,"
  4202. + " kilncode,"
  4203. + " kilnname,"
  4204. + " kilncarid,"
  4205. + " kilncarcode,"
  4206. + " kilncarname,"
  4207. + " kilncarbatchno,"
  4208. + " kilncarposition,"
  4209. + " reworkprocedureid,"
  4210. + " reworkprocedurecode,"
  4211. + " reworkprocedurename,"
  4212. + " remarks,"
  4213. + " accountdate,"
  4214. + " accountid,"
  4215. + " GoodsLevelID,"
  4216. + " GoodsLevelTypeID,"
  4217. + " createuserid,"
  4218. + " updateuserid,"
  4219. + " GroutingDate,"
  4220. + " GroutingUserID,"
  4221. + " GroutingUserCode,"
  4222. + " GroutingNum,"
  4223. + " GroutingMouldCode,"
  4224. + " MouldCode,"
  4225. + "GroutingDailyID,"
  4226. + "GroutingDailyDetailID,"
  4227. + "GroutingLineID,"
  4228. + " GroutingLineCode,"
  4229. + "GroutingLineName,"
  4230. + "GMouldTypeID,"
  4231. + "CanManyTimes,"
  4232. + "GroutingLineDetailID,"
  4233. + "SpecialRepairflag,"
  4234. + "ClassesSettingID,"
  4235. + "LogoID"
  4236. + ")"
  4237. + " values"
  4238. + " (:productiondataid,"
  4239. + " :barcode,"
  4240. + " :centralizedbatchno,"
  4241. + " :productionlineid,"
  4242. + " :productionlinecode,"
  4243. + " :productionlinename,"
  4244. + " :procedureid,"
  4245. + " :procedurecode,"
  4246. + " :procedurename,"
  4247. + " :proceduremodel,"
  4248. + " :modeltype,"
  4249. + " :piecetype,"
  4250. + " :isreworked,"
  4251. + " :nodetype,"
  4252. + " :ispublicbody,"
  4253. + " :isrefire,"
  4254. + " :organizationid,"
  4255. + " :goodsid,"
  4256. + " :goodscode,"
  4257. + " :goodsname,"
  4258. + " :userid,"
  4259. + " :usercode,"
  4260. + " :username,"
  4261. + " :kilnid,"
  4262. + " :kilncode,"
  4263. + " :kilnname,"
  4264. + " :kilncarid,"
  4265. + " :kilncarcode,"
  4266. + " :kilncarname,"
  4267. + " :kilncarbatchno,"
  4268. + " :kilncarposition,"
  4269. + " :reworkprocedureid,"
  4270. + " :reworkprocedurecode,"
  4271. + " :reworkprocedurename,"
  4272. + " :remarks,"
  4273. + " :accountdata,"
  4274. + " :accountid,"
  4275. + " :GoodsLevelID,"
  4276. + " :GoodsLevelTypeID,"
  4277. + " :createuserid,"
  4278. + " :updateuserid,"
  4279. + " :groutingdate,"
  4280. + " :groutinguserid,"
  4281. + " :groutingusercode,"
  4282. + " :groutingnum,"
  4283. + " :groutingmouldcode,"
  4284. + " :mouldcode,"
  4285. + ":groutingdailyid,"
  4286. + ":groutingdailydetailid,"
  4287. + ":groutinglineid,"
  4288. + " :groutinglinecode,"
  4289. + ":groutinglinename,"
  4290. + ":gmouldtypeid,"
  4291. + ":canmanytimes,"
  4292. + ":groutinglinedetailid,"
  4293. + ":specialRepairflag,"
  4294. + ":classesSettingID,"
  4295. + ":logoID"
  4296. + ")";
  4297. #endregion
  4298. #region OracleParameter
  4299. OracleParameter[] paras = new OracleParameter[] {
  4300. new OracleParameter(":classesSettingID",productionData.ClassesSettingID),
  4301. new OracleParameter(":productiondataid",productionData.ProductionDataID),
  4302. new OracleParameter(":barcode",productionData.Barcode),
  4303. new OracleParameter(":centralizedbatchno",productionData.CentralizedBatchNo),
  4304. new OracleParameter(":productionlineid",productionData.ProductionLineID),
  4305. new OracleParameter(":productionlinecode",productionData.ProductionLineCode),
  4306. new OracleParameter(":productionlinename",productionData.ProductionLineName),
  4307. new OracleParameter(":procedureid",productionData.CompleteProcedureID),
  4308. new OracleParameter(":procedurecode",productionData.ProcedureCode),
  4309. new OracleParameter(":procedurename",productionData.ProcedureName),
  4310. new OracleParameter(":proceduremodel",productionData.ProcedureModel),
  4311. new OracleParameter(":modeltype",productionData.ModelType),
  4312. new OracleParameter(":piecetype",productionData.PieceType),
  4313. new OracleParameter(":isreworked",productionData.IsReworked),
  4314. new OracleParameter(":nodetype",productionData.NodeType),
  4315. new OracleParameter(":ispublicbody",productionData.IsPublicBody),
  4316. new OracleParameter(":isrefire",productionData.IsReFire),
  4317. new OracleParameter(":organizationid",productionData.OrganizationID),
  4318. new OracleParameter(":goodsid",productionData.GoodsID),
  4319. new OracleParameter(":goodscode",productionData.GoodsCode),
  4320. new OracleParameter(":goodsname",productionData.GoodsName),
  4321. new OracleParameter(":userid",productionData.UserID),
  4322. new OracleParameter(":usercode",productionData.UserCode),
  4323. new OracleParameter(":username",productionData.UserName),
  4324. new OracleParameter(":kilnid",productionData.KilnID),
  4325. new OracleParameter(":kilncode",productionData.KilnCode),
  4326. new OracleParameter(":kilnname",productionData.KilnName),
  4327. new OracleParameter(":kilncarid",productionData.KilnCarID),
  4328. new OracleParameter(":kilncarcode",productionData.KilnCarCode),
  4329. new OracleParameter(":kilncarname",productionData.KilnCarName),
  4330. new OracleParameter(":kilncarbatchno",productionData.KilnCarBatchNo),
  4331. new OracleParameter(":kilncarposition",productionData.KilnCarPosition),
  4332. new OracleParameter(":reworkprocedureid",productionData.ReworkProcedureID),
  4333. new OracleParameter(":reworkprocedurecode",productionData.ReworkProcedureCode),
  4334. new OracleParameter(":reworkprocedurename",productionData.ReworkProcedureName),
  4335. new OracleParameter(":remarks",productionData.Remarks),
  4336. new OracleParameter(":accountdata",accountDate),
  4337. new OracleParameter(":accountid",sUserInfo.AccountID),
  4338. new OracleParameter(":GoodsLevelID",productionData.GoodsLevelID),
  4339. new OracleParameter(":GoodsLevelTypeID",productionData.GoodsLevelTypeID),
  4340. new OracleParameter(":createuserid",sUserInfo.UserID),
  4341. new OracleParameter(":updateuserid",sUserInfo.UserID),
  4342. new OracleParameter(":groutingdate",GroutingDate),
  4343. new OracleParameter(":groutinguserid",GroutingUserID),
  4344. new OracleParameter(":groutingusercode",GroutingUserCode),
  4345. new OracleParameter(":groutingnum",GroutingNum),
  4346. new OracleParameter(":groutingmouldcode",GroutingMouldCode),
  4347. new OracleParameter(":mouldcode",MouldCode),
  4348. new OracleParameter(":groutingdailyid",GroutingDailyID),
  4349. new OracleParameter(":groutingdailydetailid",GroutingDailyDetailID),
  4350. new OracleParameter(":groutinglineid",GroutingLineID),
  4351. new OracleParameter(":groutinglinecode",GroutingLineCode),
  4352. new OracleParameter(":groutinglinename",GroutingLineName),
  4353. new OracleParameter(":gmouldtypeid",GMouldTypeID),
  4354. new OracleParameter(":canmanytimes",CanManyTimes),
  4355. new OracleParameter(":groutinglinedetailid",GroutingLineDetailID),
  4356. new OracleParameter(":specialRepairflag",SpecialRepairflag),
  4357. new OracleParameter(":logoID",logoID),
  4358. };
  4359. #endregion
  4360. foreach (OracleParameter para in paras)
  4361. {
  4362. if (string.IsNullOrEmpty(para.Value + ""))
  4363. {
  4364. para.Value = DBNull.Value;
  4365. }
  4366. }
  4367. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  4368. OutSpecialRepairflag = returnVal;
  4369. // 失败
  4370. if (result != Constant.INT_IS_ONE)
  4371. {
  4372. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  4373. }
  4374. // 成功返回null
  4375. return null;
  4376. }
  4377. /// <summary>
  4378. /// 添加生产数据(单独为成检所做,因为成检可以从次品到其它,需要读一标识,别的不需要连接回收站表)
  4379. /// </summary>
  4380. /// <param name="oracleTrConn">连接对象</param>
  4381. /// <param name="accountDate">账务日期</param>
  4382. /// <param name="productionData">生产数据</param>
  4383. /// <param name="sUserInfo">用户基本信息</param>
  4384. /// <returns>string</returns>
  4385. /// <remarks>
  4386. /// 陈冰 2014.09.18 新建
  4387. /// </remarks>
  4388. private static string AddFinishCheckProductionData(IDBTransaction oracleTrConn, DateTime accountDate, ProductionDataEntity productionData, SUserInfo sUserInfo, out string OutSpecialRepairflag)
  4389. {
  4390. #region 查出产品注浆日期,注浆工号ID,注浆工号编码,注浆次数,注浆模具编号,模具编号
  4391. string selectSql = "";
  4392. string returnVal = "";
  4393. if (productionData.NodeType == (int)Constant.ProcedureNodeType.Begin)//开始节点时从注浆登记取值
  4394. {
  4395. // wangxin 20150409 删除掉TP_PM_GroutingProduct表后,进行的修改
  4396. // selectSql = @"select TP_PM_GroutingDaily.GroutingDate,
  4397. // TP_PM_GroutingDailyDetail.UserID as GroutingUserID,
  4398. // TP_PM_GroutingDailyDetail.UserCode as GroutingUserCode,
  4399. // TP_PM_GroutingDailyDetail.GroutingCount as GroutingNum,
  4400. // TP_PM_GroutingDailyDetail.GroutingMouldCode,
  4401. // TP_PM_GroutingDailyDetail.MouldCode,
  4402. // TP_PM_GroutingDailyDetail.GroutingDailyID,
  4403. // TP_PM_GroutingDailyDetail.GroutingDailyDetailID,
  4404. // TP_PM_GroutingDailyDetail.GroutingLineID,
  4405. // TP_PM_GroutingDailyDetail.GroutingLineCode,
  4406. // TP_PM_GroutingDailyDetail.GroutingLineName,
  4407. // TP_PM_GroutingDaily.GMouldTypeID,
  4408. // TP_PM_GroutingDaily.CanManyTimes,
  4409. // TP_PM_GroutingDailyDetail.GroutingLineDetailID,
  4410. // TP_PM_GroutingDailyDetail.SpecialRepairflag
  4411. // from TP_PM_GroutingDaily
  4412. // inner join TP_PM_GroutingDailyDetail
  4413. // on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_GroutingDailyDetail.GroutingDailyID
  4414. // where TP_PM_GroutingDailyDetail.barcode=:barcode";
  4415. selectSql = @"select TP_PM_GroutingDailyDetail.GroutingDate,
  4416. TP_PM_GroutingDailyDetail.UserID as GroutingUserID,
  4417. TP_PM_GroutingDailyDetail.UserCode as GroutingUserCode,
  4418. TP_PM_GroutingDailyDetail.GroutingCount as GroutingNum,
  4419. TP_PM_GroutingDailyDetail.GroutingMouldCode,
  4420. TP_PM_GroutingDailyDetail.MouldCode,
  4421. TP_PM_GroutingDailyDetail.GroutingDailyID,
  4422. TP_PM_GroutingDailyDetail.GroutingDailyDetailID,
  4423. TP_PM_GroutingDailyDetail.GroutingLineID,
  4424. TP_PM_GroutingDailyDetail.GroutingLineCode,
  4425. TP_PM_GroutingDailyDetail.GroutingLineName,
  4426. TP_PM_GroutingDailyDetail.GroutingLineDetailID,
  4427. TP_PM_GroutingDailyDetail.SpecialRepairflag,
  4428. (select GMouldTypeID
  4429. from TP_PM_GroutingDaily
  4430. where TP_PM_GroutingDaily.GroutingDailyID =
  4431. TP_PM_GroutingDailyDetail.GroutingDailyID) as GMouldTypeID,
  4432. (select CanManyTimes
  4433. from TP_PM_GroutingDaily
  4434. where TP_PM_GroutingDaily.GroutingDailyID =
  4435. TP_PM_GroutingDailyDetail.GroutingDailyID) as CanManyTimes,
  4436. 0 as IsReFire
  4437. from TP_PM_GroutingDailyDetail
  4438. where TP_PM_GroutingDailyDetail.barcode=:barcode";
  4439. }
  4440. else
  4441. {
  4442. //这地方连了两张表,为了成检的时候,次品在次新增
  4443. selectSql = @"select
  4444. GroutingDate,
  4445. GroutingUserID,
  4446. GroutingUserCode,
  4447. GroutingNum,
  4448. GroutingMouldCode,
  4449. MouldCode,
  4450. GroutingDailyID,
  4451. GroutingDailyDetailID,
  4452. GroutingLineID,
  4453. GroutingLineCode,
  4454. GroutingLineName,
  4455. GMouldTypeID,
  4456. CanManyTimes,
  4457. GroutingLineDetailID,
  4458. SpecialRepairflag,
  4459. IsReFire,
  4460. Logoid
  4461. from tp_pm_inproduction where barcode=:barcode
  4462. union
  4463. select
  4464. GroutingDate,
  4465. GroutingUserID,
  4466. GroutingUserCode,
  4467. GroutingNum,
  4468. GroutingMouldCode,
  4469. MouldCode,
  4470. GroutingDailyID,
  4471. GroutingDailyDetailID,
  4472. GroutingLineID,
  4473. GroutingLineCode,
  4474. GroutingLineName,
  4475. GMouldTypeID,
  4476. CanManyTimes,
  4477. GroutingLineDetailID,
  4478. SpecialRepairflag,
  4479. IsReFire,
  4480. logoid
  4481. from TP_PM_InProductionTrash where barcode=:barcode
  4482. ";
  4483. }
  4484. OracleParameter[] selectparas = new OracleParameter[] {
  4485. new OracleParameter(":barcode",productionData.Barcode),
  4486. };
  4487. DataSet dsGroutingProduct = oracleTrConn.GetSqlResultToDs(selectSql, selectparas);
  4488. DateTime GroutingDate = new DateTime();
  4489. int GroutingUserID = 0, GroutingNum = 0, GroutingDailyID = 0, GroutingDailyDetailID = 0, GroutingLineID = 0, GMouldTypeID = 0, CanManyTimes = 0, GroutingLineDetailID = 0, SpecialRepairflag = 0;
  4490. string GroutingUserCode = "", GroutingMouldCode = "", MouldCode = "", GroutingLineCode = "", GroutingLineName = "";
  4491. int IsReFire = 0;
  4492. int? logoid = null;
  4493. if (dsGroutingProduct != null && dsGroutingProduct.Tables[0].Rows.Count > 0)
  4494. {
  4495. GroutingDate = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
  4496. GroutingUserID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingUserID"]);
  4497. GroutingUserCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"].ToString();
  4498. GroutingNum = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"]);
  4499. GroutingMouldCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingMouldCode"].ToString();
  4500. MouldCode = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"].ToString();
  4501. GroutingDailyID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyID"]);
  4502. GroutingDailyDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyDetailID"]);
  4503. GroutingLineID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineID"]);
  4504. GroutingLineCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineCode"].ToString();
  4505. GroutingLineName = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineName"].ToString();
  4506. GMouldTypeID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GMouldTypeID"]);
  4507. CanManyTimes = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["CanManyTimes"]);
  4508. GroutingLineDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineDetailID"]);
  4509. SpecialRepairflag = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["SpecialRepairflag"]);
  4510. IsReFire = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["IsReFire"]);
  4511. if (dsGroutingProduct.Tables[0].Rows[0]["logoid"].ToString() != "")
  4512. {
  4513. logoid = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["logoid"]);
  4514. }
  4515. if (IsReFire > 0) //大于零代表重烧过
  4516. {
  4517. productionData.IsReFire = IsReFire;
  4518. productionData.DefectFlag = (int)Constant.GoodsLevelType.Defect;
  4519. }
  4520. returnVal = SpecialRepairflag.ToString();
  4521. }
  4522. #endregion
  4523. #region 更新窑炉窑车属性
  4524. if (productionData.ModelType != 1 && productionData.ModelType != 2 && productionData.ModelType != 3 && productionData.ModelType != 4)
  4525. {
  4526. DataSet ds = GetFinishCheckKilnCarInfo(oracleTrConn, productionData.Barcode, sUserInfo);
  4527. if (ds != null)
  4528. {
  4529. if (ds.Tables[0].Rows[0]["KilnID"].ToString() != "") //表示以前有过窑炉相关信息
  4530. {
  4531. productionData.KilnID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnID"]);
  4532. productionData.KilnCode = ds.Tables[0].Rows[0]["KilnCode"].ToString();
  4533. productionData.KilnName = ds.Tables[0].Rows[0]["KilnName"].ToString();
  4534. productionData.KilnCarID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarID"]);
  4535. productionData.KilnCarCode = ds.Tables[0].Rows[0]["KilnCarCode"].ToString();
  4536. productionData.KilnCarName = ds.Tables[0].Rows[0]["KilnCarName"].ToString();
  4537. productionData.KilnCarBatchNo = ds.Tables[0].Rows[0]["KilnCarBatchNo"].ToString();
  4538. productionData.KilnCarPosition = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarPosition"]);
  4539. }
  4540. }
  4541. }
  4542. #endregion
  4543. if (Convert.ToInt32(productionData.GoodsLevelTypeID) == 6) //判断重烧必须有返工工序
  4544. {
  4545. if (productionData.ReworkProcedureID == null || Convert.ToInt32(productionData.ReworkProcedureID) == 0)
  4546. {
  4547. OutSpecialRepairflag = "";
  4548. return string.Format("产品分级【重烧】必须填写返工工序", "条码", "保存");
  4549. }
  4550. }
  4551. DateTime? checkTime = null;
  4552. if (productionData.IsPDA != null)
  4553. {
  4554. if (productionData.PDACheckTime != null)
  4555. {
  4556. // PDA端
  4557. if (productionData.PDACheckTime.ToString() != string.Empty)
  4558. {
  4559. checkTime = Convert.ToDateTime(productionData.PDACheckTime);
  4560. }
  4561. }
  4562. }
  4563. else
  4564. {
  4565. if (productionData.CheckTime != null)
  4566. {
  4567. // PDA端
  4568. if (productionData.CheckTime.ToString() != string.Empty)
  4569. {
  4570. checkTime = Convert.ToDateTime(productionData.CheckTime);
  4571. }
  4572. }
  4573. }
  4574. #region SQL
  4575. string sql = "insert into tp_pm_productiondataIn"
  4576. + " (productiondataid,"
  4577. + " barcode,"
  4578. + " centralizedbatchno,"
  4579. + " productionlineid,"
  4580. + " productionlinecode,"
  4581. + " productionlinename,"
  4582. + " procedureid,"
  4583. + " procedurecode,"
  4584. + " procedurename,"
  4585. + " proceduremodel,"
  4586. + " modeltype,"
  4587. + " piecetype,"
  4588. + " isreworked,"
  4589. + " nodetype,"
  4590. + " ispublicbody,"
  4591. + " isrefire,"
  4592. + " organizationid,"
  4593. + " goodsid,"
  4594. + " goodscode,"
  4595. + " goodsname,"
  4596. + " userid,"
  4597. + " usercode,"
  4598. + " username,"
  4599. + " kilnid,"
  4600. + " kilncode,"
  4601. + " kilnname,"
  4602. + " kilncarid,"
  4603. + " kilncarcode,"
  4604. + " kilncarname,"
  4605. + " kilncarbatchno,"
  4606. + " kilncarposition,"
  4607. + " reworkprocedureid,"
  4608. + " reworkprocedurecode,"
  4609. + " reworkprocedurename,"
  4610. + " remarks,"
  4611. + " accountdate,"
  4612. + " accountid,"
  4613. + " GoodsLevelID,"
  4614. + " GoodsLevelTypeID,"
  4615. + " createuserid,"
  4616. + " updateuserid,"
  4617. + " GroutingDate,"
  4618. + " GroutingUserID,"
  4619. + " GroutingUserCode,"
  4620. + " GroutingNum,"
  4621. + " GroutingMouldCode,"
  4622. + " MouldCode,"
  4623. + "GroutingDailyID,"
  4624. + "GroutingDailyDetailID,"
  4625. + "GroutingLineID,"
  4626. + " GroutingLineCode,"
  4627. + "GroutingLineName,"
  4628. + "GMouldTypeID,"
  4629. + "CanManyTimes,"
  4630. + "GroutingLineDetailID,"
  4631. + "SpecialRepairflag,"
  4632. + "ClassesSettingID,"
  4633. + "LogoID,"
  4634. + "CheckTime"
  4635. + ")"
  4636. + " values"
  4637. + " (:productiondataid,"
  4638. + " :barcode,"
  4639. + " :centralizedbatchno,"
  4640. + " :productionlineid,"
  4641. + " :productionlinecode,"
  4642. + " :productionlinename,"
  4643. + " :procedureid,"
  4644. + " :procedurecode,"
  4645. + " :procedurename,"
  4646. + " :proceduremodel,"
  4647. + " :modeltype,"
  4648. + " :piecetype,"
  4649. + " :isreworked,"
  4650. + " :nodetype,"
  4651. + " :ispublicbody,"
  4652. + " :isrefire,"
  4653. + " :organizationid,"
  4654. + " :goodsid,"
  4655. + " :goodscode,"
  4656. + " :goodsname,"
  4657. + " :userid,"
  4658. + " :usercode,"
  4659. + " :username,"
  4660. + " :kilnid,"
  4661. + " :kilncode,"
  4662. + " :kilnname,"
  4663. + " :kilncarid,"
  4664. + " :kilncarcode,"
  4665. + " :kilncarname,"
  4666. + " :kilncarbatchno,"
  4667. + " :kilncarposition,"
  4668. + " :reworkprocedureid,"
  4669. + " :reworkprocedurecode,"
  4670. + " :reworkprocedurename,"
  4671. + " :remarks,"
  4672. + " :accountdata,"
  4673. + " :accountid,"
  4674. + " :GoodsLevelID,"
  4675. + " :GoodsLevelTypeID,"
  4676. + " :createuserid,"
  4677. + " :updateuserid,"
  4678. + " :groutingdate,"
  4679. + " :groutinguserid,"
  4680. + " :groutingusercode,"
  4681. + " :groutingnum,"
  4682. + " :groutingmouldcode,"
  4683. + " :mouldcode,"
  4684. + ":groutingdailyid,"
  4685. + ":groutingdailydetailid,"
  4686. + ":groutinglineid,"
  4687. + " :groutinglinecode,"
  4688. + ":groutinglinename,"
  4689. + ":gmouldtypeid,"
  4690. + ":canmanytimes,"
  4691. + ":groutinglinedetailid,"
  4692. + ":specialRepairflag,"
  4693. + ":classesSettingID,"
  4694. + ":logoid,";
  4695. if (checkTime == null)
  4696. {
  4697. sql = sql + "sysdate";
  4698. }
  4699. else
  4700. {
  4701. sql = sql + ":checkTime";
  4702. }
  4703. sql = sql + ")";
  4704. #endregion
  4705. #region OracleParameter
  4706. OracleParameter[] paras = null;
  4707. if (checkTime != null)
  4708. {
  4709. paras = new OracleParameter[] {
  4710. new OracleParameter(":classesSettingID",productionData.ClassesSettingID),
  4711. new OracleParameter(":productiondataid",productionData.ProductionDataID),
  4712. new OracleParameter(":barcode",productionData.Barcode),
  4713. new OracleParameter(":centralizedbatchno",productionData.CentralizedBatchNo),
  4714. new OracleParameter(":productionlineid",productionData.ProductionLineID),
  4715. new OracleParameter(":productionlinecode",productionData.ProductionLineCode),
  4716. new OracleParameter(":productionlinename",productionData.ProductionLineName),
  4717. new OracleParameter(":procedureid",productionData.CompleteProcedureID),
  4718. new OracleParameter(":procedurecode",productionData.ProcedureCode),
  4719. new OracleParameter(":procedurename",productionData.ProcedureName),
  4720. new OracleParameter(":proceduremodel",productionData.ProcedureModel),
  4721. new OracleParameter(":modeltype",productionData.ModelType),
  4722. new OracleParameter(":piecetype",productionData.PieceType),
  4723. new OracleParameter(":isreworked",productionData.IsReworked),
  4724. new OracleParameter(":nodetype",productionData.NodeType),
  4725. new OracleParameter(":ispublicbody",productionData.IsPublicBody),
  4726. new OracleParameter(":isrefire",productionData.IsReFire),
  4727. new OracleParameter(":organizationid",productionData.OrganizationID),
  4728. new OracleParameter(":goodsid",productionData.GoodsID),
  4729. new OracleParameter(":goodscode",productionData.GoodsCode),
  4730. new OracleParameter(":goodsname",productionData.GoodsName),
  4731. new OracleParameter(":userid",productionData.UserID),
  4732. new OracleParameter(":usercode",productionData.UserCode),
  4733. new OracleParameter(":username",productionData.UserName),
  4734. new OracleParameter(":kilnid",productionData.KilnID),
  4735. new OracleParameter(":kilncode",productionData.KilnCode),
  4736. new OracleParameter(":kilnname",productionData.KilnName),
  4737. new OracleParameter(":kilncarid",productionData.KilnCarID),
  4738. new OracleParameter(":kilncarcode",productionData.KilnCarCode),
  4739. new OracleParameter(":kilncarname",productionData.KilnCarName),
  4740. new OracleParameter(":kilncarbatchno",productionData.KilnCarBatchNo),
  4741. new OracleParameter(":kilncarposition",productionData.KilnCarPosition),
  4742. new OracleParameter(":reworkprocedureid",productionData.ReworkProcedureID),
  4743. new OracleParameter(":reworkprocedurecode",productionData.ReworkProcedureCode),
  4744. new OracleParameter(":reworkprocedurename",productionData.ReworkProcedureName),
  4745. new OracleParameter(":remarks",productionData.Remarks),
  4746. new OracleParameter(":accountdata",accountDate),
  4747. new OracleParameter(":accountid",sUserInfo.AccountID),
  4748. new OracleParameter(":GoodsLevelID",productionData.GoodsLevelID),
  4749. new OracleParameter(":GoodsLevelTypeID",productionData.GoodsLevelTypeID),
  4750. new OracleParameter(":createuserid",sUserInfo.UserID),
  4751. new OracleParameter(":updateuserid",sUserInfo.UserID),
  4752. new OracleParameter(":groutingdate",GroutingDate),
  4753. new OracleParameter(":groutinguserid",GroutingUserID),
  4754. new OracleParameter(":groutingusercode",GroutingUserCode),
  4755. new OracleParameter(":groutingnum",GroutingNum),
  4756. new OracleParameter(":groutingmouldcode",GroutingMouldCode),
  4757. new OracleParameter(":mouldcode",MouldCode),
  4758. new OracleParameter(":groutingdailyid",GroutingDailyID),
  4759. new OracleParameter(":groutingdailydetailid",GroutingDailyDetailID),
  4760. new OracleParameter(":groutinglineid",GroutingLineID),
  4761. new OracleParameter(":groutinglinecode",GroutingLineCode),
  4762. new OracleParameter(":groutinglinename",GroutingLineName),
  4763. new OracleParameter(":gmouldtypeid",GMouldTypeID),
  4764. new OracleParameter(":canmanytimes",CanManyTimes),
  4765. new OracleParameter(":groutinglinedetailid",GroutingLineDetailID),
  4766. new OracleParameter(":specialRepairflag",SpecialRepairflag),
  4767. new OracleParameter(":logoid",logoid),
  4768. new OracleParameter(":checkTime",checkTime),
  4769. };
  4770. }
  4771. else
  4772. {
  4773. paras = new OracleParameter[] {
  4774. new OracleParameter(":classesSettingID",productionData.ClassesSettingID),
  4775. new OracleParameter(":productiondataid",productionData.ProductionDataID),
  4776. new OracleParameter(":barcode",productionData.Barcode),
  4777. new OracleParameter(":centralizedbatchno",productionData.CentralizedBatchNo),
  4778. new OracleParameter(":productionlineid",productionData.ProductionLineID),
  4779. new OracleParameter(":productionlinecode",productionData.ProductionLineCode),
  4780. new OracleParameter(":productionlinename",productionData.ProductionLineName),
  4781. new OracleParameter(":procedureid",productionData.CompleteProcedureID),
  4782. new OracleParameter(":procedurecode",productionData.ProcedureCode),
  4783. new OracleParameter(":procedurename",productionData.ProcedureName),
  4784. new OracleParameter(":proceduremodel",productionData.ProcedureModel),
  4785. new OracleParameter(":modeltype",productionData.ModelType),
  4786. new OracleParameter(":piecetype",productionData.PieceType),
  4787. new OracleParameter(":isreworked",productionData.IsReworked),
  4788. new OracleParameter(":nodetype",productionData.NodeType),
  4789. new OracleParameter(":ispublicbody",productionData.IsPublicBody),
  4790. new OracleParameter(":isrefire",productionData.IsReFire),
  4791. new OracleParameter(":organizationid",productionData.OrganizationID),
  4792. new OracleParameter(":goodsid",productionData.GoodsID),
  4793. new OracleParameter(":goodscode",productionData.GoodsCode),
  4794. new OracleParameter(":goodsname",productionData.GoodsName),
  4795. new OracleParameter(":userid",productionData.UserID),
  4796. new OracleParameter(":usercode",productionData.UserCode),
  4797. new OracleParameter(":username",productionData.UserName),
  4798. new OracleParameter(":kilnid",productionData.KilnID),
  4799. new OracleParameter(":kilncode",productionData.KilnCode),
  4800. new OracleParameter(":kilnname",productionData.KilnName),
  4801. new OracleParameter(":kilncarid",productionData.KilnCarID),
  4802. new OracleParameter(":kilncarcode",productionData.KilnCarCode),
  4803. new OracleParameter(":kilncarname",productionData.KilnCarName),
  4804. new OracleParameter(":kilncarbatchno",productionData.KilnCarBatchNo),
  4805. new OracleParameter(":kilncarposition",productionData.KilnCarPosition),
  4806. new OracleParameter(":reworkprocedureid",productionData.ReworkProcedureID),
  4807. new OracleParameter(":reworkprocedurecode",productionData.ReworkProcedureCode),
  4808. new OracleParameter(":reworkprocedurename",productionData.ReworkProcedureName),
  4809. new OracleParameter(":remarks",productionData.Remarks),
  4810. new OracleParameter(":accountdata",accountDate),
  4811. new OracleParameter(":accountid",sUserInfo.AccountID),
  4812. new OracleParameter(":GoodsLevelID",productionData.GoodsLevelID),
  4813. new OracleParameter(":GoodsLevelTypeID",productionData.GoodsLevelTypeID),
  4814. new OracleParameter(":createuserid",sUserInfo.UserID),
  4815. new OracleParameter(":updateuserid",sUserInfo.UserID),
  4816. new OracleParameter(":groutingdate",GroutingDate),
  4817. new OracleParameter(":groutinguserid",GroutingUserID),
  4818. new OracleParameter(":groutingusercode",GroutingUserCode),
  4819. new OracleParameter(":groutingnum",GroutingNum),
  4820. new OracleParameter(":groutingmouldcode",GroutingMouldCode),
  4821. new OracleParameter(":mouldcode",MouldCode),
  4822. new OracleParameter(":groutingdailyid",GroutingDailyID),
  4823. new OracleParameter(":groutingdailydetailid",GroutingDailyDetailID),
  4824. new OracleParameter(":groutinglineid",GroutingLineID),
  4825. new OracleParameter(":groutinglinecode",GroutingLineCode),
  4826. new OracleParameter(":groutinglinename",GroutingLineName),
  4827. new OracleParameter(":gmouldtypeid",GMouldTypeID),
  4828. new OracleParameter(":canmanytimes",CanManyTimes),
  4829. new OracleParameter(":groutinglinedetailid",GroutingLineDetailID),
  4830. new OracleParameter(":specialRepairflag",SpecialRepairflag),
  4831. new OracleParameter(":logoid",logoid),
  4832. };
  4833. }
  4834. #endregion
  4835. foreach (OracleParameter para in paras)
  4836. {
  4837. if (string.IsNullOrEmpty(para.Value + ""))
  4838. {
  4839. para.Value = DBNull.Value;
  4840. }
  4841. }
  4842. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  4843. OutSpecialRepairflag = returnVal;
  4844. // 失败
  4845. if (result != Constant.INT_IS_ONE)
  4846. {
  4847. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  4848. }
  4849. // 成功返回null
  4850. return null;
  4851. }
  4852. /// <summary>
  4853. /// 删除在产数据
  4854. /// </summary>
  4855. /// <param name="oracleTrConn">连接对象</param>
  4856. /// <param name="delInProductionEntity">在产数据对象</param>
  4857. /// <returns>string</returns>
  4858. /// <remarks>
  4859. /// 陈冰 2014.09.18 新建
  4860. /// </remarks>
  4861. private static string DeleteInProduction(IDBTransaction oracleTrConn, InProductionEntity delInProductionEntity, bool FinishedProduct, SUserInfo sUserInfo)
  4862. {
  4863. OracleParameter[] paras = new OracleParameter[] {
  4864. new OracleParameter(":barcode",delInProductionEntity.BarCode),
  4865. };
  4866. int result = 0;
  4867. //删除在产表之前,插入到产品回收表中
  4868. if (!FinishedProduct)//如果不是产成品的时候,就是报废,产成品的时候不添加这个表里,只删除在产数据
  4869. {
  4870. OracleParameter[] parasPDA = new OracleParameter[] {
  4871. new OracleParameter(":CreateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  4872. new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  4873. new OracleParameter(":barcode",delInProductionEntity.BarCode),
  4874. new OracleParameter(":FlowProcedureID",delInProductionEntity.CompleteProcedureID),
  4875. };
  4876. string sqlInsert = @"insert into TP_PM_InProductionTrash
  4877. (
  4878. BarCode,
  4879. ProductionLineID,
  4880. ProductionLineCode,
  4881. ProductionLineName,
  4882. ProcedureModel,
  4883. ModelType,
  4884. DefectFlag,
  4885. ReworkProcedureID,
  4886. IsPublicBody,
  4887. IsReFire,
  4888. GoodsLevelID,
  4889. GoodsLevelTypeID,
  4890. GoodsID,
  4891. GoodsCode,
  4892. GoodsName,
  4893. UserID,
  4894. GroutingDailyID,
  4895. GroutingDailyDetailID,
  4896. GroutingDate,
  4897. GroutingLineID,
  4898. GroutingLineCode,
  4899. GroutingLineName,
  4900. GMouldTypeID,
  4901. CanManyTimes,
  4902. GroutingLineDetailID,
  4903. GroutingMouldCode,
  4904. MouldCode,
  4905. GroutingUserID,
  4906. GroutingUserCode,
  4907. GroutingNum,
  4908. Remarks,
  4909. KilnID,
  4910. KilnCode,
  4911. KilnName,
  4912. KilnCarID,
  4913. KilnCarCode,
  4914. KilnCarName,
  4915. KilnCarBatchNo,
  4916. KilnCarPosition,
  4917. AccountID,
  4918. ValueFlag,
  4919. CreateTime,
  4920. CreateUserID,
  4921. UpdateUserID,
  4922. SpecialRepairflag,
  4923. FlowProcedureID,
  4924. FlowProcedureTime,
  4925. ProcedureID,
  4926. ProcedureTime,
  4927. ProductionDataID,
  4928. logoid, ISREWORKFLAG, SEMICHECKID
  4929. )
  4930. select
  4931. BarCode,
  4932. ProductionLineID,
  4933. ProductionLineCode,
  4934. ProductionLineName,
  4935. ProcedureModel,
  4936. ModelType,
  4937. DefectFlag,
  4938. ReworkProcedureID,
  4939. IsPublicBody,
  4940. IsReFire,
  4941. GoodsLevelID,
  4942. GoodsLevelTypeID,
  4943. GoodsID,
  4944. GoodsCode,
  4945. GoodsName,
  4946. UserID,
  4947. GroutingDailyID,
  4948. GroutingDailyDetailID,
  4949. GroutingDate,
  4950. GroutingLineID,
  4951. GroutingLineCode,
  4952. GroutingLineName,
  4953. GMouldTypeID,
  4954. CanManyTimes,
  4955. GroutingLineDetailID,
  4956. GroutingMouldCode,
  4957. MouldCode,
  4958. GroutingUserID,
  4959. GroutingUserCode,
  4960. GroutingNum,
  4961. Remarks,
  4962. KilnID,
  4963. KilnCode,
  4964. KilnName,
  4965. KilnCarID,
  4966. KilnCarCode,
  4967. KilnCarName,
  4968. KilnCarBatchNo,
  4969. KilnCarPosition,
  4970. AccountID,
  4971. ValueFlag,
  4972. CreateTime,
  4973. :CreateUserID,
  4974. :UpdateUserID,
  4975. SpecialRepairflag,
  4976. :FlowProcedureID,
  4977. FlowProcedureTime,
  4978. :FlowProcedureID,
  4979. ProcedureTime,
  4980. ProductionDataID,
  4981. logoid, ISREWORKFLAG, SEMICHECKID
  4982. from TP_PM_InProduction
  4983. where barcode=:barcode
  4984. ";
  4985. result = oracleTrConn.ExecuteNonQuery(sqlInsert, parasPDA);
  4986. }
  4987. string sql = "delete tp_pm_inproduction where barcode = :barcode";
  4988. result += oracleTrConn.ExecuteNonQuery(sql, paras);
  4989. // 删除失败
  4990. //if (result != Constant.INT_IS_TWO)//删除在产的同时,应该往产品加收表里插入,这样就是影响行数为2,以前是1
  4991. if (result == Constant.INT_IS_ZERO)
  4992. {
  4993. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  4994. }
  4995. // 成功返回null
  4996. return null;
  4997. }
  4998. /// <summary>
  4999. /// 删除在产数据
  5000. /// </summary>
  5001. /// <param name="oracleTrConn">连接对象</param>
  5002. /// <param name="delInProductionEntity">在产数据对象</param>
  5003. /// <returns>string</returns>
  5004. /// <remarks>
  5005. /// 陈冰 2014.09.18 新建
  5006. /// </remarks>
  5007. private static string DeletePDAInProduction(IDBTransaction oracleTrConn, InProductionEntity delInProductionEntity, bool FinishedProduct, SUserInfo sUserInfo)
  5008. {
  5009. OracleParameter[] paras = new OracleParameter[] {
  5010. new OracleParameter(":barcode",delInProductionEntity.BarCode),
  5011. };
  5012. int result = 0;
  5013. //删除在产表之前,插入到产品回收表中
  5014. if (!FinishedProduct)//如果不是产成品的时候,就是报废,产成品的时候不添加这个表里,只删除在产数据
  5015. {
  5016. OracleParameter[] parasPDA = new OracleParameter[] {
  5017. new OracleParameter(":barcode",delInProductionEntity.BarCode),
  5018. new OracleParameter(":FlowProcedureID",delInProductionEntity.CompleteProcedureID),
  5019. new OracleParameter(":CreateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  5020. new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  5021. new OracleParameter(":ProductionDataID",OracleDbType.Int32,delInProductionEntity.ProductionDataID,ParameterDirection.Input),
  5022. new OracleParameter(":GoodsLevelID",OracleDbType.Int32,delInProductionEntity.GoodsLevelID,ParameterDirection.Input),
  5023. new OracleParameter(":GoodsLevelTypeID",OracleDbType.Int32,delInProductionEntity.GoodsLevelTypeID,ParameterDirection.Input),
  5024. };
  5025. //删除在产表前,在产表生产数据ID更新下,如不更新这样就不准了,例如,次品到次品 第一次不会影响,因为第一次TP_PM_InProductionTrash表里没有
  5026. // 如果第二次走次品到次品,才有效,下面的sqlInsert则没有效,因为在产表里没有数据插入不到回收表
  5027. string sqlupdate = "update TP_PM_InProductionTrash set ProductionDataID=:ProductionDataID where barcode=:barcode";
  5028. OracleParameter[] parasupdate = new OracleParameter[] {
  5029. new OracleParameter(":barcode",delInProductionEntity.BarCode),
  5030. new OracleParameter(":ProductionDataID",delInProductionEntity.ProductionDataID),
  5031. };
  5032. oracleTrConn.ExecuteNonQuery(sqlupdate, parasupdate);
  5033. string sqlInsert = @"insert into TP_PM_InProductionTrash
  5034. (
  5035. BarCode,
  5036. ProductionLineID,
  5037. ProductionLineCode,
  5038. ProductionLineName,
  5039. ProcedureModel,
  5040. ModelType,
  5041. DefectFlag,
  5042. ReworkProcedureID,
  5043. IsPublicBody,
  5044. IsReFire,
  5045. GoodsLevelID,
  5046. GoodsLevelTypeID,
  5047. GoodsID,
  5048. GoodsCode,
  5049. GoodsName,
  5050. UserID,
  5051. GroutingDailyID,
  5052. GroutingDailyDetailID,
  5053. GroutingDate,
  5054. GroutingLineID,
  5055. GroutingLineCode,
  5056. GroutingLineName,
  5057. GMouldTypeID,
  5058. CanManyTimes,
  5059. GroutingLineDetailID,
  5060. GroutingMouldCode,
  5061. MouldCode,
  5062. GroutingUserID,
  5063. GroutingUserCode,
  5064. GroutingNum,
  5065. Remarks,
  5066. KilnID,
  5067. KilnCode,
  5068. KilnName,
  5069. KilnCarID,
  5070. KilnCarCode,
  5071. KilnCarName,
  5072. KilnCarBatchNo,
  5073. KilnCarPosition,
  5074. AccountID,
  5075. ValueFlag,
  5076. CreateUserID,
  5077. UpdateUserID,
  5078. SpecialRepairflag,
  5079. FlowProcedureID,
  5080. FlowProcedureTime,
  5081. ProcedureID,
  5082. ProcedureTime,
  5083. ProductionDataID,
  5084. logoid, ISREWORKFLAG, SEMICHECKID
  5085. )
  5086. select
  5087. BarCode,
  5088. ProductionLineID,
  5089. ProductionLineCode,
  5090. ProductionLineName,
  5091. ProcedureModel,
  5092. ModelType,
  5093. DefectFlag,
  5094. ReworkProcedureID,
  5095. IsPublicBody,
  5096. IsReFire,
  5097. :GoodsLevelID,
  5098. :GoodsLevelTypeID,
  5099. GoodsID,
  5100. GoodsCode,
  5101. GoodsName,
  5102. UserID,
  5103. GroutingDailyID,
  5104. GroutingDailyDetailID,
  5105. GroutingDate,
  5106. GroutingLineID,
  5107. GroutingLineCode,
  5108. GroutingLineName,
  5109. GMouldTypeID,
  5110. CanManyTimes,
  5111. GroutingLineDetailID,
  5112. GroutingMouldCode,
  5113. MouldCode,
  5114. GroutingUserID,
  5115. GroutingUserCode,
  5116. GroutingNum,
  5117. Remarks,
  5118. KilnID,
  5119. KilnCode,
  5120. KilnName,
  5121. KilnCarID,
  5122. KilnCarCode,
  5123. KilnCarName,
  5124. KilnCarBatchNo,
  5125. KilnCarPosition,
  5126. AccountID,
  5127. ValueFlag,
  5128. :CreateUserID,
  5129. :UpdateUserID,
  5130. SpecialRepairflag,
  5131. :FlowProcedureID,
  5132. FlowProcedureTime,
  5133. :FlowProcedureID,
  5134. ProcedureTime,
  5135. :ProductionDataID,
  5136. logoid, ISREWORKFLAG, SEMICHECKID
  5137. from TP_PM_InProduction
  5138. where barcode=:barcode
  5139. ";
  5140. result = oracleTrConn.ExecuteNonQuery(sqlInsert, parasPDA);
  5141. }
  5142. string sql = "delete tp_pm_inproduction where barcode = :barcode";
  5143. result += oracleTrConn.ExecuteNonQuery(sql, paras);
  5144. // 删除失败
  5145. //if (result != Constant.INT_IS_TWO)//删除在产的同时,应该往产品加收表里插入,这样就是影响行数为2,以前是1
  5146. if (result == Constant.INT_IS_ZERO)
  5147. {
  5148. //return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  5149. }
  5150. // 成功返回null
  5151. return null;
  5152. }
  5153. /// <summary>
  5154. /// 根据窑车ID 删除窑车产品
  5155. /// </summary>
  5156. /// <param name="oracleTrConn">数据连接</param>
  5157. /// <param name="pKilnCarID">窑车ID</param>
  5158. /// <returns>
  5159. /// 张国印 2014.10.04 新建
  5160. /// </returns>
  5161. private static string DeleteKilnCarGoodsByKilnCarID(IDBTransaction oracleTrConn, int pKilnCarID)
  5162. {
  5163. string sql = "delete TP_PM_KilnCarGoods where KilnCarID = :pKilnCarID";
  5164. OracleParameter[] paras = new OracleParameter[] {
  5165. new OracleParameter(":pKilnCarID", OracleDbType.Int32, pKilnCarID, ParameterDirection.Input),
  5166. };
  5167. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  5168. // 删除失败
  5169. if (result <= Constant.INT_IS_ZERO)
  5170. {
  5171. return string.Format(Messages.MSG_CMN_W001, "窑车产品", "保存");
  5172. }
  5173. // 成功返回null
  5174. return null;
  5175. }
  5176. /// <summary>
  5177. /// 添加产成品
  5178. /// </summary>
  5179. /// <param name="oracleTrConn">连接对象</param>
  5180. /// <param name="finishedProduct">产成品对象</param>
  5181. /// <param name="sUserInfo">用户基本信息</param>
  5182. /// <returns>string</returns>
  5183. /// <remarks>
  5184. /// 陈冰 2014.09.18 新建
  5185. /// </remarks>
  5186. private static string AddFinishedProduct(IDBTransaction oracleTrConn,
  5187. FinishedProductEntity finishedProduct, SUserInfo sUserInfo
  5188. , string finishedloadbatchno)
  5189. {
  5190. List<OracleParameter> paras = new List<OracleParameter>();
  5191. string sql = "";
  5192. #region
  5193. // add 2015/11/16
  5194. // if (finishedProduct.LogoID != null && Convert.ToInt32(finishedProduct.LogoID) > 0)
  5195. // {
  5196. // #region SQL
  5197. // //废弃
  5198. // sql = " insert into tp_pm_finishedproduct"
  5199. // + " (barcode, "
  5200. // + " productionlineid, "
  5201. // + " productionlinecode, "
  5202. // + " productionlinename, "
  5203. // + " ispublicbody, "
  5204. // + " isrefire, "
  5205. // + " GoodsLevelID, "
  5206. // + " GoodsLevelTypeID, "
  5207. // + " goodsid, "
  5208. // + " goodscode, "
  5209. // + " goodsname, "
  5210. // + " groutingdailyid, "
  5211. // + " groutingdailydetailid, "
  5212. // + " groutingdate, "
  5213. // + " groutinglineid, "
  5214. // + " groutinglinecode, "
  5215. // + " groutinglinename, "
  5216. // + " gmouldtypeid, "
  5217. // + " groutinglinedetailid, "
  5218. // + " groutingmouldcode, "
  5219. // + " mouldcode, "
  5220. // + " accountdate, "
  5221. // + " accountid, "
  5222. // + " createuserid, "
  5223. // + " updateuserid,"
  5224. // + " groutinguserid, "
  5225. // + " groutingusercode, "
  5226. // + " groutingnum, "
  5227. // + " kilnid, "
  5228. // + " kilncode, "
  5229. // + " kilnname, "
  5230. // + " kilncarid, "
  5231. // + " kilncarcode, "
  5232. // + " kilncarname, "
  5233. // + " kilncarbatchno, "
  5234. // + " kilncarposition, "
  5235. // + " specialRepairflag, "
  5236. // + " logoid "
  5237. // + ") "
  5238. // + " select barcode, "
  5239. // + " productionlineid, "
  5240. // + " productionlinecode, "
  5241. // + " productionlinename, "
  5242. // + " ispublicbody, "
  5243. // + " isrefire, ";
  5244. // #region 产品等级
  5245. // //if (finishedProduct.GoodsGrade == null)
  5246. // //{
  5247. // // sql = sql + " goodsgrade,";
  5248. // //}
  5249. // //// 最后一个工序如果是检验工序,可更改产品等级
  5250. // //else
  5251. // //{
  5252. // // sql = sql + " :goodsgrade, ";
  5253. // // paras.Add(new OracleParameter(":goodsgrade", finishedProduct.GoodsGrade));
  5254. // //}
  5255. // //如果包装时,产成品未走过成检,则直接视为正品
  5256. // int? GoodsLevelTypeID = null;
  5257. // int? GoodsLevelID = null;
  5258. // if (finishedProduct.GoodsLevelID == null)
  5259. // {
  5260. // string sqlQuery = @"select GoodsLevelID,GoodsLevelTypeID from TP_MST_GoodsLevel where GoodsLevelTypeID=
  5261. // (
  5262. // select distinct GoodsLevelTypeID from tp_pm_inproduction where Barcode='" + finishedProduct.BarCode + "'" +
  5263. // ") and AccountID=" + sUserInfo.AccountID;
  5264. // DataSet ds = oracleTrConn.GetSqlResultToDs(sqlQuery);
  5265. // if (ds != null && ds.Tables[0].Rows.Count > 0)
  5266. // {
  5267. // if (ds.Tables[0].Rows[0]["GoodsLevelID"].ToString() != "")
  5268. // {
  5269. // if (Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]) == 5)//副品
  5270. // {
  5271. // GoodsLevelTypeID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]);
  5272. // GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]);
  5273. // }
  5274. // else
  5275. // {
  5276. // string sqlQuery2 = @"select GoodsLevelID,GoodsLevelTypeID from TP_MST_GoodsLevel where GoodsLevelTypeID=4 and AccountID=" + sUserInfo.AccountID;
  5277. // ds = oracleTrConn.GetSqlResultToDs(sqlQuery2);
  5278. // if (ds.Tables[0].Rows[0]["GoodsLevelID"].ToString() != "")
  5279. // {
  5280. // GoodsLevelTypeID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]);
  5281. // GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]);
  5282. // }
  5283. // }
  5284. // }
  5285. // }
  5286. // else
  5287. // {
  5288. // string sqlQuery2 = @"select GoodsLevelID,GoodsLevelTypeID from TP_MST_GoodsLevel where GoodsLevelTypeID=4 and AccountID=" + sUserInfo.AccountID;
  5289. // ds = oracleTrConn.GetSqlResultToDs(sqlQuery2);
  5290. // if (ds.Tables[0].Rows[0]["GoodsLevelID"].ToString() != "")
  5291. // {
  5292. // GoodsLevelTypeID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]);
  5293. // GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]);
  5294. // }
  5295. // }
  5296. // }
  5297. // if (finishedProduct.GoodsLevelID == null)
  5298. // {
  5299. // //sql = sql + " GoodsLevelID,";
  5300. // // 包装后,这个值并没有,这里的值除了在检验的时候会给赋值,其它工序应该没有设置,所以查询了一次
  5301. // ////// sql = sql + @"
  5302. // ////// (select GoodsLevelID from TP_MST_GoodsLevel where GoodsLevelTypeID=
  5303. // ////// (
  5304. // ////// select distinct GoodsLevelTypeID from tp_pm_inproduction where Barcode=:barcode
  5305. // ////// ) and AccountID=:AccountID),";
  5306. // sql = sql + GoodsLevelID.ToString() + " ,";
  5307. // }
  5308. // // 最后一个工序如果是检验工序,可更改产品等级
  5309. // else
  5310. // {
  5311. // sql = sql + " :GoodsLevelID, ";
  5312. // paras.Add(new OracleParameter(":GoodsLevelID", finishedProduct.GoodsLevelID));
  5313. // }
  5314. // if (finishedProduct.GoodsLevelTypeID == null)
  5315. // {
  5316. // //sql = sql + " GoodsLevelTypeID,";
  5317. // sql = sql + GoodsLevelTypeID.ToString() + " ,";
  5318. // }
  5319. // // 最后一个工序如果是检验工序,可更改产品等级
  5320. // else
  5321. // {
  5322. // sql = sql + " :GoodsLevelTypeID, ";
  5323. // paras.Add(new OracleParameter(":GoodsLevelTypeID", finishedProduct.GoodsLevelTypeID));
  5324. // }
  5325. // #endregion
  5326. // sql = sql + " goodsid, "
  5327. // + " goodscode, "
  5328. // + " goodsname, "
  5329. // + " groutingdailyid, "
  5330. // + " groutingdailydetailid, "
  5331. // + " groutingdate, "
  5332. // + " groutinglineid, "
  5333. // + " groutinglinecode, "
  5334. // + " groutinglinename, "
  5335. // + " gmouldtypeid, "
  5336. // + " groutinglinedetailid, "
  5337. // + " groutingmouldcode, "
  5338. // + " mouldcode, "
  5339. // + " fun_cmn_getaccountdate(accountid), "
  5340. // + " accountid, "
  5341. // + " :createuserid, "
  5342. // + " :updateuserid, "
  5343. // + " groutinguserid, "
  5344. // + " groutingusercode, "
  5345. // + " groutingnum, "
  5346. // + " kilnid, "
  5347. // + " kilncode, "
  5348. // + " kilnname, "
  5349. // + " kilncarid, "
  5350. // + " kilncarcode, "
  5351. // + " kilncarname, "
  5352. // + " kilncarbatchno, "
  5353. // + " kilncarposition, "
  5354. // + " specialRepairflag, "
  5355. // + " :logoid "
  5356. // + " from tp_pm_inproduction "
  5357. // + " where Barcode=:barcode";
  5358. // #endregion
  5359. // paras.Add(new OracleParameter(":createuserid", sUserInfo.UserID));
  5360. // paras.Add(new OracleParameter(":updateuserid", sUserInfo.UserID));
  5361. // paras.Add(new OracleParameter(":barcode", finishedProduct.BarCode));
  5362. // paras.Add(new OracleParameter(":logoid", finishedProduct.LogoID));
  5363. // // end 2015/11/16
  5364. // }
  5365. // else
  5366. // {
  5367. #endregion
  5368. #region SQL
  5369. //废弃
  5370. sql = " insert into tp_pm_finishedproduct"
  5371. + " (barcode, "
  5372. + " productionlineid, "
  5373. + " productionlinecode, "
  5374. + " productionlinename, "
  5375. + " ispublicbody, "
  5376. + " isrefire, "
  5377. + " GoodsLevelID, "
  5378. + " GoodsLevelTypeID, "
  5379. + " goodsid, "
  5380. + " goodscode, "
  5381. + " goodsname, "
  5382. + " groutingdailyid, "
  5383. + " groutingdailydetailid, "
  5384. + " groutingdate, "
  5385. + " groutinglineid, "
  5386. + " groutinglinecode, "
  5387. + " groutinglinename, "
  5388. + " gmouldtypeid, "
  5389. + " groutinglinedetailid, "
  5390. + " groutingmouldcode, "
  5391. + " mouldcode, "
  5392. + " accountdate, "
  5393. + " accountid, "
  5394. + " createuserid, "
  5395. + " updateuserid,"
  5396. + " groutinguserid, "
  5397. + " groutingusercode, "
  5398. + " groutingnum, "
  5399. + " kilnid, "
  5400. + " kilncode, "
  5401. + " kilnname, "
  5402. + " kilncarid, "
  5403. + " kilncarcode, "
  5404. + " kilncarname, "
  5405. + " kilncarbatchno, "
  5406. + " kilncarposition, "
  5407. + " specialRepairflag, "
  5408. + " logoid,OnlyCode ,finishedloadbatchno"
  5409. + ") "
  5410. + " select barcode, "
  5411. + " productionlineid, "
  5412. + " productionlinecode, "
  5413. + " productionlinename, "
  5414. + " ispublicbody, "
  5415. + " isrefire, ";
  5416. #region 产品等级
  5417. //if (finishedProduct.GoodsGrade == null)
  5418. //{
  5419. // sql = sql + " goodsgrade,";
  5420. //}
  5421. //// 最后一个工序如果是检验工序,可更改产品等级
  5422. //else
  5423. //{
  5424. // sql = sql + " :goodsgrade, ";
  5425. // paras.Add(new OracleParameter(":goodsgrade", finishedProduct.GoodsGrade));
  5426. //}
  5427. //如果包装时,产成品未走过成检,则直接视为正品
  5428. int? GoodsLevelTypeID = null;
  5429. int? GoodsLevelID = null;
  5430. if (finishedProduct.GoodsLevelID == null)
  5431. {
  5432. string sqlQuery = @"select GoodsLevelID,GoodsLevelTypeID from TP_MST_GoodsLevel where GoodsLevelTypeID=
  5433. (
  5434. select distinct GoodsLevelTypeID from tp_pm_inproduction where Barcode='" + finishedProduct.BarCode + "'" +
  5435. ") and AccountID=" + sUserInfo.AccountID;
  5436. DataSet ds = oracleTrConn.GetSqlResultToDs(sqlQuery);
  5437. if (ds != null && ds.Tables[0].Rows.Count > 0)
  5438. {
  5439. if (ds.Tables[0].Rows[0]["GoodsLevelID"].ToString() != "")
  5440. {
  5441. if (Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]) == 5)//副品
  5442. {
  5443. GoodsLevelTypeID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]);
  5444. GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]);
  5445. }
  5446. else if (Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]) == 4)//正品
  5447. {
  5448. string sqlQuery2 = @"select GoodsLevelID,GoodsLevelTypeID from TP_MST_GoodsLevel where GoodsLevelTypeID=4 and AccountID=" + sUserInfo.AccountID;
  5449. ds = oracleTrConn.GetSqlResultToDs(sqlQuery2);
  5450. if (ds.Tables[0].Rows[0]["GoodsLevelID"].ToString() != "")
  5451. {
  5452. GoodsLevelTypeID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]);
  5453. GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]);
  5454. }
  5455. }
  5456. else
  5457. {
  5458. GoodsLevelTypeID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]);
  5459. GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]);
  5460. }
  5461. }
  5462. }
  5463. else
  5464. {
  5465. string sqlQuery2 = @"select GoodsLevelID,GoodsLevelTypeID from TP_MST_GoodsLevel where GoodsLevelTypeID=4 and AccountID=" + sUserInfo.AccountID;
  5466. ds = oracleTrConn.GetSqlResultToDs(sqlQuery2);
  5467. if (ds.Tables[0].Rows[0]["GoodsLevelID"].ToString() != "")
  5468. {
  5469. GoodsLevelTypeID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]);
  5470. GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]);
  5471. }
  5472. }
  5473. }
  5474. if (finishedProduct.GoodsLevelID == null)
  5475. {
  5476. //sql = sql + " GoodsLevelID,";
  5477. // 包装后,这个值并没有,这里的值除了在检验的时候会给赋值,其它工序应该没有设置,所以查询了一次
  5478. ////// sql = sql + @"
  5479. ////// (select GoodsLevelID from TP_MST_GoodsLevel where GoodsLevelTypeID=
  5480. ////// (
  5481. ////// select distinct GoodsLevelTypeID from tp_pm_inproduction where Barcode=:barcode
  5482. ////// ) and AccountID=:AccountID),";
  5483. sql = sql + GoodsLevelID.ToString() + " ,";
  5484. }
  5485. // 最后一个工序如果是检验工序,可更改产品等级
  5486. else
  5487. {
  5488. sql = sql + " :GoodsLevelID, ";
  5489. paras.Add(new OracleParameter(":GoodsLevelID", finishedProduct.GoodsLevelID));
  5490. }
  5491. if (finishedProduct.GoodsLevelTypeID == null)
  5492. {
  5493. //sql = sql + " GoodsLevelTypeID,";
  5494. sql = sql + GoodsLevelTypeID.ToString() + " ,";
  5495. }
  5496. // 最后一个工序如果是检验工序,可更改产品等级
  5497. else
  5498. {
  5499. sql = sql + " :GoodsLevelTypeID, ";
  5500. paras.Add(new OracleParameter(":GoodsLevelTypeID", finishedProduct.GoodsLevelTypeID));
  5501. }
  5502. #endregion
  5503. sql = sql + " goodsid, "
  5504. + " goodscode, "
  5505. + " goodsname, "
  5506. + " groutingdailyid, "
  5507. + " groutingdailydetailid, "
  5508. + " groutingdate, "
  5509. + " groutinglineid, "
  5510. + " groutinglinecode, "
  5511. + " groutinglinename, "
  5512. + " gmouldtypeid, "
  5513. + " groutinglinedetailid, "
  5514. + " groutingmouldcode, "
  5515. + " mouldcode, "
  5516. + " fun_cmn_getaccountdate(accountid), "
  5517. + " accountid, "
  5518. + " :createuserid, "
  5519. + " :updateuserid, "
  5520. + " groutinguserid, "
  5521. + " groutingusercode, "
  5522. + " groutingnum, "
  5523. + " kilnid, "
  5524. + " kilncode, "
  5525. + " kilnname, "
  5526. + " kilncarid, "
  5527. + " kilncarcode, "
  5528. + " kilncarname, "
  5529. + " kilncarbatchno, "
  5530. + " kilncarposition, "
  5531. + " specialRepairflag, "
  5532. + " logoid, "
  5533. + " (select OnlyCode from tp_pm_groutingdailydetail where barcode=:barcode), :finishedloadbatchno"
  5534. + " from tp_pm_inproduction "
  5535. + " where Barcode=:barcode";
  5536. #endregion
  5537. paras.Add(new OracleParameter(":createuserid", sUserInfo.UserID));
  5538. paras.Add(new OracleParameter(":updateuserid", sUserInfo.UserID));
  5539. paras.Add(new OracleParameter(":barcode", finishedProduct.BarCode));
  5540. paras.Add(new OracleParameter(":finishedloadbatchno", finishedloadbatchno));
  5541. //}
  5542. //paras.Add(new OracleParameter(":AccountID", sUserInfo.AccountID));
  5543. int result = oracleTrConn.ExecuteNonQuery(sql, paras.ToArray());
  5544. // 保存失败
  5545. if (result != Constant.INT_IS_ONE)
  5546. {
  5547. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  5548. }
  5549. // 保存成功返回null
  5550. return null;
  5551. }
  5552. /// <summary>
  5553. /// 添加在产产品数据
  5554. /// </summary>
  5555. /// <param name="oracleTrConn">连接对象</param>
  5556. /// <param name="inProduction">在产产品实体类</param>
  5557. /// <param name="sUserInfo">用户基本信息</param>
  5558. /// <param name="isSendBody">是否交坯</param>
  5559. /// <returns>string</returns>
  5560. /// <remarks>
  5561. /// 陈冰 2014.09.18 新建
  5562. /// </remarks>
  5563. private static string AddInProduction(IDBTransaction oracleTrConn, InProductionEntity inProduction, SUserInfo sUserInfo, DataSet _dsDataset, bool isSendBody = false)
  5564. {
  5565. #region SQL
  5566. string sqlExist = "select 1 from tp_pm_inproduction where barcode = :barcode ";
  5567. OracleParameter[] parasExist = new OracleParameter[] {
  5568. new OracleParameter(":barcode",inProduction.BarCode.Trim()),
  5569. };
  5570. DataSet dsresult = oracleTrConn.GetSqlResultToDs(sqlExist, parasExist);
  5571. if (dsresult != null && dsresult.Tables[0].Rows.Count == 0)
  5572. {
  5573. // 获取生产线ID,生产线名称,生产编码
  5574. string sql = @"select TP_PC_ProductionLine.ProductionLineID,TP_PC_ProductionLine.ProductionLineCode,TP_PC_ProductionLine.ProductionLineName
  5575. from TP_PC_Procedure inner join TP_PC_ProductionLine
  5576. on TP_PC_Procedure.ProductionLineID=TP_PC_ProductionLine.ProductionLineID
  5577. where TP_PC_Procedure.ProcedureID=:ProcedureID
  5578. ";
  5579. OracleParameter[] paras = new OracleParameter[] {
  5580. new OracleParameter(":ProcedureID",inProduction.FlowProcedureID),
  5581. };
  5582. dsresult = oracleTrConn.GetSqlResultToDs(sql, paras);
  5583. #region 获取生产线信息
  5584. int ProductionLineID = 0;//生产线ID
  5585. string ProductionLineCode = "", ProductionLineName = "";//生产线名称,编码
  5586. if (dsresult != null && dsresult.Tables[0].Rows.Count > 0)
  5587. {
  5588. ProductionLineID = Convert.ToInt32(dsresult.Tables[0].Rows[0]["ProductionLineID"]);
  5589. ProductionLineCode = dsresult.Tables[0].Rows[0]["ProductionLineCode"].ToString();
  5590. ProductionLineName = dsresult.Tables[0].Rows[0]["ProductionLineName"].ToString();
  5591. }
  5592. #endregion
  5593. #region 获取注浆信息
  5594. // sql = @"select
  5595. // TP_PM_GroutingDailyDetail.UserID as GroutingUserID,
  5596. // TP_PM_GroutingDailyDetail.UserCode as GroutingUserCode,
  5597. // TP_PM_GroutingDailyDetail.GroutingCount as GroutingNum,
  5598. // TP_PM_GroutingDailyDetail.GroutingMouldCode,
  5599. // TP_PM_GroutingDailyDetail.MouldCode,
  5600. // TP_PM_GroutingDailyDetail.GroutingDailyID,
  5601. // TP_PM_GroutingDailyDetail.GroutingDailyDetailID,
  5602. // TP_PM_GroutingDailyDetail.GroutingLineID,
  5603. // TP_PM_GroutingDailyDetail.GroutingLineCode,
  5604. // TP_PM_GroutingDailyDetail.GroutingLineName,
  5605. // TP_PM_GroutingDaily.GMouldTypeID,
  5606. // TP_PM_GroutingDaily.CanManyTimes,
  5607. // TP_PM_GroutingDailyDetail.GroutingLineDetailID,
  5608. // TP_PM_GroutingDailyDetail.SpecialRepairflag,
  5609. // TP_PM_GroutingDailyDetail.GoodsID,
  5610. // TP_PM_GroutingDailyDetail.GoodsCode,
  5611. // TP_PM_GroutingDailyDetail.GoodsName,
  5612. // TP_PM_GroutingDailyDetail.GroutingDate
  5613. // from TP_PM_GroutingDaily
  5614. // inner join TP_PM_GroutingDailyDetail
  5615. // on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_GroutingDailyDetail.GroutingDailyID
  5616. // where TP_PM_GroutingDailyDetail.barcode=:barcode";
  5617. // sql = @"select
  5618. // UserID as GroutingUserID,
  5619. // UserCode as GroutingUserCode,
  5620. // GroutingCount as GroutingNum,
  5621. // GroutingMouldCode,
  5622. // MouldCode,
  5623. // GroutingDailyID,
  5624. // GroutingDailyDetailID,
  5625. // GroutingLineID,
  5626. // GroutingLineCode,
  5627. // GroutingLineName,
  5628. // GroutingLineDetailID,
  5629. // SpecialRepairflag,
  5630. // GoodsID,
  5631. // GoodsCode,
  5632. // GoodsName,
  5633. // GroutingDate,
  5634. // (select GMouldTypeID
  5635. // from TP_PM_GroutingDaily
  5636. // where TP_PM_GroutingDaily.GroutingDailyID =
  5637. // TP_PM_GroutingDailyDetail.GroutingDailyID) as GMouldTypeID,
  5638. // (select CanManyTimes
  5639. // from TP_PM_GroutingDaily
  5640. // where TP_PM_GroutingDaily.GroutingDailyID =
  5641. // TP_PM_GroutingDailyDetail.GroutingDailyID) as CanManyTimes
  5642. // from TP_PM_GroutingDailyDetail
  5643. // where TP_PM_GroutingDailyDetail.barcode=:barcode";
  5644. // sql = @"select
  5645. // GroutingUserID,
  5646. // GroutingUserCode,
  5647. // GroutingNum,
  5648. // GroutingMouldCode,
  5649. // MouldCode,
  5650. // GroutingDailyID,
  5651. // GroutingDailyDetailID,
  5652. // GroutingLineID,
  5653. // GroutingLineCode,
  5654. // GroutingLineName,
  5655. // GroutingLineDetailID,
  5656. // SpecialRepairflag,
  5657. // GoodsID,
  5658. // GoodsCode,
  5659. // GoodsName,
  5660. // GroutingDate,
  5661. // GMouldTypeID
  5662. // CanManyTimes
  5663. // from tp_pm_productiondata
  5664. // where tp_pm_productiondata.barcode=:barcode";
  5665. // paras = new OracleParameter[] {
  5666. // new OracleParameter(":barcode",inProduction.BarCode),
  5667. // };
  5668. dsresult = _dsDataset;
  5669. //dsresult = oracleTrConn.GetSqlResultToDs(sql, paras);
  5670. // 产品ID, 注浆登记ID, 注浆明细ID, 成型线ID 成型线类型ID 能否多次注浆 成型生产线明细ID
  5671. int goodsid = 0, groutingDailyID = 0, groutingdailydetailid = 0, groutinglineid = 0, gMouldTypeID = 0, canManyTimes = 0, groutingLineDetailID = 0;
  5672. // 产品编码, 产品名称 成型线编码 成型线名称 注浆模具编号 模具编号
  5673. string goodsCode = "", goodsName = "", groutingLineCode = "", groutingLineName = "", groutingmouldcode = "", mouldCode = "";
  5674. DateTime? groutingdate = null; // 注浆日期
  5675. int groutingUserID = 0, groutingNum = 0; //注浆工号ID,注浆次数
  5676. string groutingUserCode = "";//注浆工号
  5677. int? LogoID = null;
  5678. if (dsresult != null && dsresult.Tables[0].Rows.Count > 0)
  5679. {
  5680. goodsid = Convert.ToInt32(dsresult.Tables[0].Rows[0]["GoodsID"]);
  5681. groutingDailyID = Convert.ToInt32(dsresult.Tables[0].Rows[0]["GroutingDailyID"]);
  5682. groutingdailydetailid = Convert.ToInt32(dsresult.Tables[0].Rows[0]["GroutingDailyDetailID"]);
  5683. groutinglineid = Convert.ToInt32(dsresult.Tables[0].Rows[0]["GroutingLineID"]);
  5684. groutingLineDetailID = Convert.ToInt32(dsresult.Tables[0].Rows[0]["GroutingLineDetailID"]);
  5685. groutingdate = Convert.ToDateTime(dsresult.Tables[0].Rows[0]["GroutingDate"]);
  5686. goodsCode = dsresult.Tables[0].Rows[0]["GoodsCode"].ToString();
  5687. goodsName = dsresult.Tables[0].Rows[0]["GoodsName"].ToString();
  5688. groutingLineCode = dsresult.Tables[0].Rows[0]["GroutingLineCode"].ToString();
  5689. groutingLineName = dsresult.Tables[0].Rows[0]["GroutingLineName"].ToString();
  5690. groutingmouldcode = dsresult.Tables[0].Rows[0]["GroutingMouldCode"].ToString();
  5691. mouldCode = dsresult.Tables[0].Rows[0]["MouldCode"].ToString();
  5692. groutingUserCode = dsresult.Tables[0].Rows[0]["GroutingUserCode"].ToString();
  5693. groutingUserID = Convert.ToInt32(dsresult.Tables[0].Rows[0]["GroutingUserID"]);
  5694. gMouldTypeID = Convert.ToInt32(dsresult.Tables[0].Rows[0]["GMouldTypeID"]);
  5695. canManyTimes = Convert.ToInt32(dsresult.Tables[0].Rows[0]["CanManyTimes"]);
  5696. groutingNum = Convert.ToInt32(dsresult.Tables[0].Rows[0]["GroutingNum"]);
  5697. if (dsresult.Tables[0].Rows[0]["logoid"].ToString() != "")
  5698. {
  5699. LogoID = Convert.ToInt32(dsresult.Tables[0].Rows[0]["logoid"]);
  5700. }
  5701. }
  5702. #endregion
  5703. sql = " insert into tp_pm_inproduction"
  5704. + " ( barcode,"
  5705. + " productionlineid,"
  5706. + " productionlinecode,"
  5707. + " productionlinename,"
  5708. + " proceduremodel,"
  5709. + " modeltype,"
  5710. + " ispublicbody,"
  5711. + " goodsid,"
  5712. + " goodscode,"
  5713. + " goodsname,"
  5714. + " userid,"
  5715. + " groutingdailyid,"
  5716. + " groutingdailydetailid,"
  5717. + " groutingdate,"
  5718. + " groutinglineid,"
  5719. + " groutinglinecode,"
  5720. + " groutinglinename,"
  5721. + " gmouldtypeid,"
  5722. + " canmanytimes,"
  5723. + " groutinglinedetailid,"
  5724. + " groutingmouldcode,"
  5725. + " mouldcode,"
  5726. + " accountid,"
  5727. + " createuserid,"
  5728. + " updateuserid,GoodsLevelTypeID,"
  5729. + " GroutingUserID,"
  5730. + " GroutingUserCode,"
  5731. + " GroutingNum,"
  5732. + " SpecialRepairflag,"
  5733. + " FlowProcedureID,"
  5734. + " FlowProcedureTime,"
  5735. + " ProcedureID,"
  5736. + " ProcedureTime,"
  5737. + " ProductionDataID,logoid"
  5738. + " ) values ("
  5739. + " :barcode,"
  5740. + " :productionlineid,"
  5741. + " :productionlinecode,"
  5742. + " :productionlinename,"
  5743. + " :procedureModel,"
  5744. + " :modelType,"
  5745. + " :isPublicBody,"
  5746. + " :goodsid,"
  5747. + " :goodscode,"
  5748. + " :goodsname,"
  5749. + " :userID,"
  5750. + " :groutingdailyid,"
  5751. + " :groutingdailydetailid,"
  5752. + " :groutingdate,"
  5753. + " :groutinglineid,"
  5754. + " :groutinglinecode,"
  5755. + " :groutinglinename,"
  5756. + " :gmouldtypeid,"
  5757. + " :canmanytimes,"
  5758. + " :groutinglinedetailid,"
  5759. + " :groutingmouldcode,"
  5760. + " :mouldcode,"
  5761. + " :accountID,"
  5762. + " :createUserID,"
  5763. + " :updateUserID,"
  5764. + " null,"
  5765. + " :groutinguserid,"
  5766. + " :groutingusercode,"
  5767. + " :groutingnum,"
  5768. + " :specialRepairflag,"
  5769. + " :flowProcedureID,"
  5770. + " sysdate,"
  5771. + " :procedureID,"
  5772. + " sysdate,"
  5773. + " :productionDataID,:logoid"
  5774. + " ) ";
  5775. #endregion
  5776. paras = new OracleParameter[] {
  5777. new OracleParameter(":procedureModel",inProduction.ProcedureModel),
  5778. new OracleParameter(":modelType",inProduction.ModelType),
  5779. new OracleParameter(":isPublicBody",inProduction.IsPublicBody),
  5780. new OracleParameter(":userID",inProduction.UserID),
  5781. new OracleParameter(":accountID",sUserInfo.AccountID),
  5782. new OracleParameter(":createUserID",sUserInfo.UserID),
  5783. new OracleParameter(":updateUserID",sUserInfo.UserID),
  5784. new OracleParameter(":barcode",inProduction.BarCode),
  5785. new OracleParameter(":specialRepairflag",inProduction.SpecialRepairflag),
  5786. new OracleParameter(":productionlineid",ProductionLineID),//---开始赋值
  5787. new OracleParameter(":productionlinecode",ProductionLineCode),
  5788. new OracleParameter(":productionlinename",ProductionLineName),
  5789. new OracleParameter(":goodsid",goodsid),
  5790. new OracleParameter(":goodscode",goodsCode),
  5791. new OracleParameter(":goodsname",goodsName),
  5792. new OracleParameter(":groutingdailyid",groutingDailyID),
  5793. new OracleParameter(":groutingdailydetailid",groutingdailydetailid),
  5794. new OracleParameter(":groutingdate",groutingdate),
  5795. new OracleParameter(":groutinglineid",groutinglineid),
  5796. new OracleParameter(":groutinglinecode",groutingLineCode),
  5797. new OracleParameter(":groutinglinename",groutingLineName),
  5798. new OracleParameter(":gmouldtypeid",gMouldTypeID),
  5799. new OracleParameter(":canmanytimes",canManyTimes),
  5800. new OracleParameter(":groutinglinedetailid",groutingLineDetailID),
  5801. new OracleParameter(":groutingmouldcode",groutingmouldcode),
  5802. new OracleParameter(":mouldcode",mouldCode),
  5803. new OracleParameter(":groutinguserid",groutingUserID),
  5804. new OracleParameter(":groutingusercode",groutingUserCode),
  5805. new OracleParameter(":groutingnum",groutingNum),
  5806. new OracleParameter(":flowProcedureID",inProduction.FlowProcedureID),
  5807. new OracleParameter(":procedureID",inProduction.FlowProcedureID),
  5808. new OracleParameter(":productionDataID",inProduction.ProductionDataID),
  5809. new OracleParameter(":logoid",LogoID),
  5810. };
  5811. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  5812. // 保存失败
  5813. if (result != Constant.INT_IS_ONE)
  5814. {
  5815. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  5816. }
  5817. //xuwei fix begin
  5818. //2019-09-17
  5819. //更新用过条码
  5820. //交坯=4,在产=3
  5821. string barcodeStatus = isSendBody ? "4" : "3";
  5822. string updateUsedBarCode = "update TP_PM_USEDBARCODE set barcodestatus=" + barcodeStatus + " where barcode='" + inProduction.BarCode + "'";
  5823. oracleTrConn.ExecuteNonQuery(updateUsedBarCode);
  5824. //xuwei end
  5825. }
  5826. // 保存成功返回null
  5827. return null;
  5828. }
  5829. /// <summary>
  5830. /// 根据最大生产数据ID,获取窑车窑炉等信息
  5831. /// </summary>
  5832. /// <param name="oracleTrConn"></param>
  5833. /// <param name="barcode"></param>
  5834. /// <param name="sUserInfo"></param>
  5835. /// <returns></returns>
  5836. private static DataSet GetFinishCheckKilnCarInfo(IDBTransaction oracleTrConn, string barcode, SUserInfo sUserInfo)
  5837. {
  5838. string sql = @"select
  5839. KilnID,
  5840. KilnCode,
  5841. KilnName,
  5842. KilnCarID,
  5843. KilnCarCode,
  5844. KilnCarName,
  5845. to_char(KilnCarBatchNo) as KilnCarBatchNo,
  5846. KilnCarPosition
  5847. from tp_pm_inproduction where barcode=:barcode
  5848. union
  5849. select
  5850. KilnID,
  5851. KilnCode,
  5852. KilnName,
  5853. KilnCarID,
  5854. KilnCarCode,
  5855. KilnCarName,
  5856. to_char(KilnCarBatchNo) as KilnCarBatchNo,
  5857. KilnCarPosition
  5858. from TP_PM_InProductionTrash where barcode=:barcode
  5859. ";
  5860. try
  5861. {
  5862. IDataParameter[] paras = new OracleParameter[]
  5863. {
  5864. new OracleParameter(":barcode", OracleDbType.Varchar2, barcode, ParameterDirection.Input),
  5865. };
  5866. DataSet returnDs = oracleTrConn.GetSqlResultToDs(sql, paras);
  5867. if (returnDs != null
  5868. && returnDs.Tables.Count > Constant.INT_IS_ZERO
  5869. && returnDs.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  5870. {
  5871. return returnDs;
  5872. }
  5873. else
  5874. {
  5875. return null;
  5876. }
  5877. }
  5878. catch (Exception ex)
  5879. {
  5880. throw ex;
  5881. }
  5882. }
  5883. /// <summary>
  5884. /// 根据最大生产数据ID,获取窑车窑炉等信息
  5885. /// </summary>
  5886. /// <param name="oracleTrConn"></param>
  5887. /// <param name="barcode"></param>
  5888. /// <param name="sUserInfo"></param>
  5889. /// <returns></returns>
  5890. private static DataSet GetKilnCarInfo(IDBTransaction oracleTrConn, string barcode, SUserInfo sUserInfo)
  5891. {
  5892. // string sql = @"select * from tp_pm_productiondata where Productiondataid=
  5893. // (
  5894. // select nvl(max(Productiondataid),0) Productiondataid from tp_pm_productiondata where barcode=:barcode
  5895. // )";
  5896. // string sql = @"select
  5897. // KilnID,
  5898. // KilnCode,
  5899. // KilnName,
  5900. // KilnCarID,
  5901. // KilnCarCode,
  5902. // KilnCarName,
  5903. // to_char(KilnCarBatchNo) as KilnCarBatchNo,
  5904. // KilnCarPosition
  5905. // from tp_pm_inproduction where barcode=:barcode
  5906. // union
  5907. // select
  5908. // KilnID,
  5909. // KilnCode,
  5910. // KilnName,
  5911. // KilnCarID,
  5912. // KilnCarCode,
  5913. // KilnCarName,
  5914. // to_char(KilnCarBatchNo) as KilnCarBatchNo,
  5915. // KilnCarPosition
  5916. // from TP_PM_InProductionTrash where barcode=:barcode
  5917. //";
  5918. string sql = @"select
  5919. KilnID,
  5920. KilnCode,
  5921. KilnName,
  5922. KilnCarID,
  5923. KilnCarCode,
  5924. KilnCarName,
  5925. to_char(KilnCarBatchNo) as KilnCarBatchNo,
  5926. KilnCarPosition
  5927. from tp_pm_inproduction where barcode=:barcode
  5928. ";
  5929. try
  5930. {
  5931. IDataParameter[] paras = new OracleParameter[]
  5932. {
  5933. new OracleParameter(":barcode", OracleDbType.Varchar2, barcode, ParameterDirection.Input),
  5934. };
  5935. DataSet returnDs = oracleTrConn.GetSqlResultToDs(sql, paras);
  5936. if (returnDs != null
  5937. && returnDs.Tables.Count > Constant.INT_IS_ZERO
  5938. && returnDs.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  5939. {
  5940. return returnDs;
  5941. }
  5942. else
  5943. {
  5944. return null;
  5945. }
  5946. }
  5947. catch (Exception ex)
  5948. {
  5949. throw ex;
  5950. }
  5951. }
  5952. /// <summary>
  5953. /// 修改在产数据
  5954. /// </summary>
  5955. /// <param name="oracleTrConn">连接对象</param>
  5956. /// <param name="inProduction">在产数据实体类</param>
  5957. /// <param name="sUserInfo">用户基本信息</param>
  5958. /// <returns>string</returns>
  5959. /// <remarks>
  5960. /// 陈冰 2014.09.18 新建
  5961. /// </remarks>
  5962. private static string UpdateInProduction(IDBTransaction oracleTrConn, InProductionEntity inProduction, SUserInfo sUserInfo)
  5963. {
  5964. List<OracleParameter> paras = new List<OracleParameter>();
  5965. //paras.Add(new OracleParameter(":completeProcedureID", inProduction.CompleteProcedureID));
  5966. paras.Add(new OracleParameter(":procedureModel", inProduction.ProcedureModel));
  5967. paras.Add(new OracleParameter(":modelType", inProduction.ModelType));
  5968. paras.Add(new OracleParameter(":defectFlag", inProduction.DefectFlag));
  5969. paras.Add(new OracleParameter(":reworkProcedureID", inProduction.ReworkProcedureID));
  5970. paras.Add(new OracleParameter(":flowprocedureid", inProduction.FlowProcedureID));
  5971. paras.Add(new OracleParameter(":procedureID", inProduction.ProcedureID));
  5972. paras.Add(new OracleParameter(":productionDataID", inProduction.ProductionDataID));
  5973. #region SQL
  5974. string sql = " update TP_PM_InProduction "
  5975. //+ " set CompleteProcedureID = :completeProcedureID,"
  5976. + "set ProcedureModel = :procedureModel,"
  5977. + " ModelType = :modelType,"
  5978. + " DefectFlag = :defectFlag,"
  5979. + " flowprocedureid = :flowprocedureid,"
  5980. + " flowproceduretime = sysdate,"
  5981. + " procedureID = :procedureID,"
  5982. + " procedureTime = sysdate,"
  5983. + " productionDataID = :productionDataID,"
  5984. // + " GoodsLevelTypeID = :GoodsLevelTypeID,"
  5985. // 扫码后,返修标识清除
  5986. + " isreworkflag = '0',"
  5987. + " ReworkProcedureID = :reworkProcedureID,";
  5988. #region 只有交坯工序是才传值更改公坯字段
  5989. if (inProduction.IsPublicBody != null)
  5990. {
  5991. sql = sql + " IsPublicBody = :isPublicBody,";
  5992. paras.Add(new OracleParameter(":isPublicBody", inProduction.IsPublicBody));
  5993. }
  5994. #endregion
  5995. #region 只有走特定返工工序时才更改重烧字段
  5996. if (inProduction.IsReFire != null)
  5997. {
  5998. sql = sql + " IsReFire = :isReFire,";
  5999. paras.Add(new OracleParameter(":isReFire", inProduction.IsReFire));
  6000. }
  6001. #endregion
  6002. #region 只有成检时才更新产品分级字段
  6003. //if (inProduction.GoodsGrade != null)
  6004. //{
  6005. // sql = sql + " GoodsGrade = :goodsGrade,";
  6006. // paras.Add(new OracleParameter(":goodsGrade", inProduction.GoodsGrade));
  6007. //}
  6008. if (inProduction.GoodsLevelID != null)
  6009. {
  6010. sql = sql + " GoodsLevelID = :GoodsLevelID,";
  6011. paras.Add(new OracleParameter(":GoodsLevelID", inProduction.GoodsLevelID));
  6012. }
  6013. if (inProduction.GoodsLevelTypeID != null)
  6014. {
  6015. sql = sql + " GoodsLevelTypeID = :GoodsLevelTypeID,";
  6016. paras.Add(new OracleParameter(":GoodsLevelTypeID", inProduction.GoodsLevelTypeID));
  6017. }
  6018. #region 更新窑炉窑车属性
  6019. if (inProduction.ModelType == 1 || inProduction.ModelType == 2 || inProduction.ModelType == 3 || inProduction.ModelType == 4 || inProduction.ModelType == 6)
  6020. {
  6021. sql = sql + " KilnID = :KilnID,";
  6022. paras.Add(new OracleParameter(":KilnID", inProduction.KilnID));
  6023. sql = sql + " KilnCode = :KilnCode,";
  6024. paras.Add(new OracleParameter(":KilnCode", inProduction.KilnCode));
  6025. sql = sql + " KilnName = :KilnName,";
  6026. paras.Add(new OracleParameter(":KilnName", inProduction.KilnName));
  6027. sql = sql + " KilnCarID = :KilnCarID,";
  6028. paras.Add(new OracleParameter(":KilnCarID", inProduction.KilnCarID));
  6029. sql = sql + " KilnCarCode = :KilnCarCode,";
  6030. paras.Add(new OracleParameter(":KilnCarCode", inProduction.KilnCarCode));
  6031. sql = sql + " KilnCarName = :KilnCarName,";
  6032. paras.Add(new OracleParameter(":KilnCarName", inProduction.KilnCarName));
  6033. sql = sql + " KilnCarBatchNo = :KilnCarBatchNo,";
  6034. paras.Add(new OracleParameter(":KilnCarBatchNo", inProduction.KilnCarBatchNo));
  6035. sql = sql + " KilnCarPosition = :KilnCarPosition,";
  6036. paras.Add(new OracleParameter(":KilnCarPosition", inProduction.KilnCarPosition));
  6037. }
  6038. else
  6039. {
  6040. //
  6041. ////////DataSet ds = GetKilnCarInfo(oracleTrConn, inProduction.BarCode, sUserInfo);
  6042. ////////if (ds != null)
  6043. ////////{
  6044. //////// if (ds.Tables[0].Rows[0]["KilnID"].ToString() != "") //表示以前有过窑炉相关信息
  6045. //////// {
  6046. //////// sql = sql + " KilnID = :KilnID,";
  6047. //////// paras.Add(new OracleParameter(":KilnID", Convert.ToInt32(ds.Tables[0].Rows[0]["KilnID"])));
  6048. //////// sql = sql + " KilnCode = :KilnCode,";
  6049. //////// paras.Add(new OracleParameter(":KilnCode", ds.Tables[0].Rows[0]["KilnCode"].ToString()));
  6050. //////// sql = sql + " KilnName = :KilnName,";
  6051. //////// paras.Add(new OracleParameter(":KilnName", ds.Tables[0].Rows[0]["KilnName"].ToString()));
  6052. //////// sql = sql + " KilnCarID = :KilnCarID,";
  6053. //////// paras.Add(new OracleParameter(":KilnCarID", Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarID"])));
  6054. //////// sql = sql + " KilnCarCode = :KilnCarCode,";
  6055. //////// paras.Add(new OracleParameter(":KilnCarCode", ds.Tables[0].Rows[0]["KilnCarCode"].ToString()));
  6056. //////// sql = sql + " KilnCarName = :KilnCarName,";
  6057. //////// paras.Add(new OracleParameter(":KilnCarName", ds.Tables[0].Rows[0]["KilnCarName"].ToString()));
  6058. //////// sql = sql + " KilnCarBatchNo = :KilnCarBatchNo,";
  6059. //////// paras.Add(new OracleParameter(":KilnCarBatchNo", ds.Tables[0].Rows[0]["KilnCarBatchNo"].ToString()));
  6060. //////// sql = sql + " KilnCarPosition = :KilnCarPosition,";
  6061. //////// paras.Add(new OracleParameter(":KilnCarPosition", Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarPosition"])));
  6062. //////// }
  6063. ////////}
  6064. }
  6065. #endregion
  6066. #endregion
  6067. #region 更新在产商标
  6068. if (inProduction.LogoID != null)
  6069. {
  6070. sql = sql + " LogoID = :LogoID,";
  6071. paras.Add(new OracleParameter(":LogoID", inProduction.LogoID));
  6072. }
  6073. #endregion
  6074. sql = sql + " UserID = :userID,"
  6075. + " UpdateUserID = :updateUserID"
  6076. + " where Barcode = :barCode";
  6077. #endregion
  6078. paras.Add(new OracleParameter(":userID", inProduction.UserID));
  6079. paras.Add(new OracleParameter(":updateUserID", sUserInfo.UserID));
  6080. paras.Add(new OracleParameter(":barCode", inProduction.BarCode));
  6081. foreach (var para in paras)
  6082. {
  6083. if (para.Value + "" == "")
  6084. {
  6085. para.Value = DBNull.Value;
  6086. }
  6087. }
  6088. int result = oracleTrConn.ExecuteNonQuery(sql, paras.ToArray());
  6089. // 保存失败
  6090. if (result != Constant.INT_IS_ONE)
  6091. {
  6092. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  6093. }
  6094. // 保存成功返回null
  6095. return null;
  6096. }
  6097. /// <summary>
  6098. /// 校验条码有效
  6099. /// </summary>
  6100. /// <param name="oracleTrConn">连接对象</param>
  6101. /// <param name="procedureID">工序ID</param>
  6102. /// <param name="barcode">条码</param>
  6103. /// <param name="goodsID">返回的产品ID</param>
  6104. /// <param name="goodsCode">返回的产品Code</param>
  6105. /// <param name="goodsName">返回的产品名称</param>
  6106. /// <param name="groutingUserID">返回的注浆者ID</param>
  6107. /// <returns>string</returns>
  6108. /// <remarks>
  6109. /// 陈冰 2014.09.18 新建
  6110. /// </remarks>
  6111. private static string CheckBarcode(IDBTransaction oracleTrConn,
  6112. int procedureID,
  6113. string barcode,
  6114. out int goodsID,
  6115. out string goodsCode,
  6116. out string goodsName,
  6117. out string groutingUserCode,
  6118. SUserInfo sUserInfo
  6119. )
  6120. {
  6121. try
  6122. {
  6123. OracleParameter[] paras = new OracleParameter[]{
  6124. new OracleParameter("in_procedureid",OracleDbType.Int32,procedureID,ParameterDirection.Input),
  6125. new OracleParameter("in_barcode",OracleDbType.Varchar2,barcode,ParameterDirection.Input),
  6126. new OracleParameter("out_errMsg",OracleDbType.Varchar2,2000,"",ParameterDirection.Output),
  6127. new OracleParameter("out_goodsID",OracleDbType.Int32,ParameterDirection.Output),
  6128. new OracleParameter("out_goodsCode",OracleDbType.Varchar2,50,"",ParameterDirection.Output),
  6129. new OracleParameter("out_goodsName",OracleDbType.Varchar2,50,"",ParameterDirection.Output),
  6130. new OracleParameter("out_groutingUserCode",OracleDbType.NVarchar2,50,null,ParameterDirection.Output),
  6131. new OracleParameter("out_errMsg_Status",OracleDbType.Varchar2,50,"",ParameterDirection.Output),
  6132. };
  6133. oracleTrConn.ExecStoredProcedure("PRO_PM_CheckBarcode", paras);
  6134. if (!"null".Equals(paras[3].Value + ""))
  6135. {
  6136. goodsID = Convert.ToInt32(paras[3].Value + "");
  6137. }
  6138. else
  6139. {
  6140. goodsID = 0;
  6141. }
  6142. goodsCode = paras[4].Value + "";
  6143. goodsName = paras[5].Value + "";
  6144. if (!"null".Equals(paras[6].Value + ""))
  6145. {
  6146. groutingUserCode = paras[6].Value + "";
  6147. }
  6148. else
  6149. {
  6150. groutingUserCode = null;
  6151. }
  6152. if ("null".Equals(paras[2].Value + ""))
  6153. {
  6154. return null;
  6155. }
  6156. return paras[2].Value.ToString().Replace("\\n\\r", "\n\r");
  6157. }
  6158. catch (Exception ex)
  6159. {
  6160. throw ex;
  6161. }
  6162. }
  6163. /// <summary>
  6164. /// 查询工序信息
  6165. /// </summary>
  6166. /// <param name="oracleTrConn">连接对象</param>
  6167. /// <param name="procedureID">工序ID</param>
  6168. /// <returns>工序实体</returns>
  6169. private static ProcedureEntity GetProcedurByID(IDBTransaction oracleTrConn, int procedureID)
  6170. {
  6171. ProcedureEntity procedureEntity = new ProcedureEntity();
  6172. string procsql = "pro_pm_searchProcedurbyID";
  6173. try
  6174. {
  6175. IDataParameter[] paras = new OracleParameter[]
  6176. {
  6177. new OracleParameter("in_procedureID", OracleDbType.Int32, procedureID, ParameterDirection.Input),
  6178. new OracleParameter("out_result", OracleDbType.RefCursor, ParameterDirection.Output)
  6179. };
  6180. DataSet returnDs = oracleTrConn.ExecStoredProcedure(procsql, paras);
  6181. if (returnDs != null
  6182. && returnDs.Tables.Count > Constant.INT_IS_ZERO
  6183. && returnDs.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  6184. {
  6185. DataRow row = returnDs.Tables[0].Rows[0];
  6186. // 转实体
  6187. procedureEntity = DataConvert.DataRowConvertToObject<ProcedureEntity>(row);
  6188. return procedureEntity;
  6189. }
  6190. else
  6191. {
  6192. return null;
  6193. }
  6194. }
  6195. catch (Exception ex)
  6196. {
  6197. throw ex;
  6198. }
  6199. }
  6200. #endregion
  6201. #region 检验
  6202. /// <summary>
  6203. /// 保存条码信息
  6204. /// </summary>
  6205. /// <param name="procedureID">工序ID</param>
  6206. /// <param name="productionDataEntitys">生产数据集</param>
  6207. /// <param name="sUserInfo">用户基本信息</param>
  6208. /// <returns>string</returns>
  6209. public static string AddCheckBarcode(int procedureID, ProductionDataEntity[] productionDataEntitys, SUserInfo sUserInfo)
  6210. {
  6211. string errMsg = "";
  6212. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  6213. try
  6214. {
  6215. oracleTrConn.Connect();
  6216. #region 查询工序信息
  6217. ProcedureEntity procedure = GetProcedurByID(oracleTrConn, procedureID);
  6218. #endregion
  6219. #region 标准检验(半成品)
  6220. if (procedure.ModelType == (int)Constant.ProcedureModelType.Normal)
  6221. {
  6222. errMsg = AddNormalCheck(oracleTrConn, procedure, productionDataEntitys, sUserInfo);
  6223. }
  6224. #endregion
  6225. #region 成品检验
  6226. else if (procedure.ModelType == (int)Constant.ProcedureModelType.QualityStatistics)
  6227. {
  6228. errMsg = AddFinishCheckPDA(oracleTrConn, procedure, productionDataEntitys, sUserInfo);
  6229. }
  6230. #endregion
  6231. #region 半检 与成检相同处理 xuwei add 2019-12-12
  6232. else if (procedure.ModelType == (int)Constant.ProcedureModelType.SemiQualityStatistics)
  6233. {
  6234. errMsg = AddFinishCheckPDA(oracleTrConn, procedure, productionDataEntitys, sUserInfo);
  6235. }
  6236. #endregion
  6237. #region 入窑前检验
  6238. else if (procedure.ModelType == (int)Constant.ProcedureModelType.IntoKilnCheck)
  6239. {
  6240. errMsg = AddIntoKilnCheck(oracleTrConn, procedure, productionDataEntitys, sUserInfo);
  6241. }
  6242. #endregion
  6243. // 没有错误 提交事务
  6244. if (string.IsNullOrEmpty(errMsg))
  6245. {
  6246. oracleTrConn.Commit();
  6247. }
  6248. }
  6249. catch (Exception ex)
  6250. {
  6251. oracleTrConn.Rollback();
  6252. throw ex;
  6253. }
  6254. finally
  6255. {
  6256. // 释放资源
  6257. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  6258. {
  6259. oracleTrConn.Disconnect();
  6260. }
  6261. }
  6262. return errMsg;
  6263. }
  6264. /// <summary>
  6265. /// 入窑前检验
  6266. /// </summary>
  6267. /// <param name="oracleTrConn">连接对象</param>
  6268. /// <param name="procedure">工序</param>
  6269. /// <param name="productionDataEntitys">生产数据集</param>
  6270. /// <param name="sUserInfo">用户基本信息</param>
  6271. /// <returns>string</returns>
  6272. private static string AddIntoKilnCheck(IDBTransaction oracleTrConn, ProcedureEntity procedure, ProductionDataEntity[] productionDataEntitys, SUserInfo sUserInfo)
  6273. {
  6274. string errMsg = "";
  6275. // 获得账务日期
  6276. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  6277. // 本批采集的批次号
  6278. string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  6279. #region 查询产品分级
  6280. string sqlGoodsLevel = "select GoodsLevelID,GoodsLevelTypeID from TP_MST_GoodsLevel where AccountID=:accountID and ValueFlag=1";
  6281. DataTable goodsLevelTable = oracleTrConn.GetSqlResultToDt(sqlGoodsLevel, new OracleParameter[] { new OracleParameter(":accountID", sUserInfo.AccountID) });
  6282. #endregion
  6283. foreach (ProductionDataEntity productionData in productionDataEntitys)
  6284. {
  6285. if (string.IsNullOrEmpty(productionData.Barcode))
  6286. {
  6287. throw new Exception("传入的条码号为空");
  6288. }
  6289. if (productionData.ProductionDataID != 0)
  6290. {
  6291. errMsg = DeleteSubstandardToSubstandardByID(oracleTrConn, productionData.ProductionDataID, productionData.Barcode, sUserInfo);
  6292. if (!string.IsNullOrEmpty(errMsg))
  6293. {
  6294. return errMsg;
  6295. }
  6296. // 删除报废条码
  6297. string updateScrapSql = @"update tp_pm_scrapproduct set ValueFlag=0
  6298. where tp_pm_scrapproduct.barcode=:barcode";
  6299. OracleParameter[] ScrapProductparas = new OracleParameter[]{
  6300. new OracleParameter(":barcode",OracleDbType.Varchar2, productionData.Barcode,ParameterDirection.Input),
  6301. };
  6302. oracleTrConn.ExecuteNonQuery(updateScrapSql, ScrapProductparas);
  6303. string sqlInsInProdString = @"insert into TP_PM_InProduction(BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME,
  6304. PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID,
  6305. ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME,
  6306. USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE,
  6307. GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID,
  6308. CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE,
  6309. REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME,
  6310. CREATEUSERID, UPDATETIME, UPDATEUSERID,
  6311. ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG,
  6312. GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM,
  6313. KILNID, KILNCODE, KILNNAME, KILNCARID,
  6314. KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID
  6315. ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,logoid,IsReworkFlag,SemiCheckID)
  6316. select BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME,
  6317. PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID,
  6318. ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME,
  6319. USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE,
  6320. GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID,
  6321. CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE,
  6322. REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME,
  6323. CREATEUSERID, UPDATETIME, :UpdateUserID,
  6324. ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG,
  6325. GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM,
  6326. KILNID, KILNCODE, KILNNAME, KILNCARID,
  6327. KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID ,
  6328. FlowProcedureTime,ProcedureID,sysdate,ProductionDataID,logoid,IsReworkFlag,SemiCheckID
  6329. from TP_PM_InProductionTrash where barcode=:barcode ";
  6330. OracleParameter[] InProductparas = new OracleParameter[]{
  6331. new OracleParameter(":UpdateUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input),
  6332. new OracleParameter(":barcode",OracleDbType.Varchar2, productionData.Barcode,ParameterDirection.Input),
  6333. };
  6334. oracleTrConn.ExecuteNonQuery(sqlInsInProdString, InProductparas);
  6335. //删除回收站中的条码
  6336. string sqlDelInProductTrashString = "delete from TP_PM_InProductionTrash where barcode=:barcode ";
  6337. OracleParameter[] TrashProductparas = new OracleParameter[]{
  6338. new OracleParameter(":barcode",OracleDbType.Varchar2, productionData.Barcode,ParameterDirection.Input)
  6339. };
  6340. oracleTrConn.ExecuteNonQuery(sqlDelInProductTrashString, TrashProductparas);
  6341. }
  6342. int goodsID = Constant.INT_IS_ZERO;
  6343. string goodsCode = string.Empty;
  6344. string goodsName = string.Empty;
  6345. // 注浆者工号
  6346. string groutingUserCode = string.Empty;
  6347. #region 校验条码有效性
  6348. errMsg = CheckBarcode(oracleTrConn, procedure.ProcedureID, productionData.Barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo);
  6349. if (!string.IsNullOrEmpty(errMsg))
  6350. {
  6351. if (productionData.ProductionDataID == 0)
  6352. return errMsg;
  6353. }
  6354. #endregion
  6355. #region 获得产品分级ID
  6356. DataRow[] dr = goodsLevelTable.Select("GoodsLevelTypeID=" + productionData.GoodsLevelTypeID);
  6357. // 获得产品分级ID
  6358. productionData.GoodsLevelID = Convert.ToInt32(dr[0]["GoodsLevelID"]);
  6359. #endregion
  6360. // 查询新插入的生产数据ID
  6361. string sql = "select SEQ_PM_ProductionData_ID.nextval from dual";
  6362. string idStr = oracleTrConn.GetSqlResultToStr(sql);
  6363. int productionDataID = 0;
  6364. if (!string.IsNullOrEmpty(idStr))
  6365. {
  6366. productionDataID = int.Parse(idStr);
  6367. }
  6368. else
  6369. {
  6370. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  6371. }
  6372. int? ClassesSettingID = null;//班次配置ID
  6373. #region 添加生产者数据
  6374. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, productionData.UserID, productionData.UserName, sUserInfo, ref ClassesSettingID);
  6375. if (!string.IsNullOrEmpty(errMsg))
  6376. {
  6377. return errMsg;
  6378. }
  6379. #endregion
  6380. #region 添加生产数据
  6381. #region 属性赋值
  6382. productionData.ClassesSettingID = ClassesSettingID;
  6383. productionData.ProductionDataID = Convert.ToInt32(idStr);
  6384. productionData.CentralizedBatchNo = centralizedBatchNo;
  6385. productionData.ProductionLineID = procedure.ProductionLineID;
  6386. productionData.ProductionLineCode = procedure.ProductionlineCode;
  6387. productionData.ProductionLineName = procedure.ProductionlineName;
  6388. productionData.ProcedureID = procedure.ProcedureID;
  6389. productionData.ProcedureCode = procedure.ProcedureCode;
  6390. productionData.ProcedureName = procedure.ProcedureName;
  6391. productionData.ProcedureModel = procedure.ProcedureModel;
  6392. productionData.ModelType = procedure.ModelType;
  6393. productionData.NodeType = procedure.NodeType;
  6394. productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, productionData.Barcode);
  6395. productionData.IsReFire = (int)Constant.ReFireFlag.No;
  6396. productionData.GoodsGrade = (int)Constant.GoodsGrade.Good;
  6397. productionData.OrganizationID = procedure.OrganizationID;
  6398. productionData.GoodsID = goodsID;
  6399. productionData.GoodsCode = goodsCode;
  6400. productionData.GoodsName = goodsName;
  6401. productionData.GoodsLevelID = productionData.GoodsLevelID;
  6402. productionData.GoodsLevelTypeID = productionData.GoodsLevelTypeID;
  6403. //如果报废给此产品最状态赋值 wangxin 2015/4/1 因为删除掉了生产数据表中的产品最终状态
  6404. ////if (productionData.ProductionDefects != null)
  6405. ////{
  6406. //// foreach (ProductionDefectEntity productionDefect in productionData.ProductionDefects)
  6407. //// {
  6408. //// if ((string.IsNullOrEmpty(productionDefect.ScrapResponFlag) ? "0" : productionDefect.ScrapResponFlag) == "1")
  6409. //// {
  6410. //// productionData.GoodsEnding = productionData.GoodsLevelTypeID.ToString();
  6411. //// break;
  6412. //// }
  6413. //// }
  6414. ////}
  6415. ////if (productionData.GoodsLevelTypeID == (int)Constant.GoodsLevelType.Waste)
  6416. ////{
  6417. //// productionData.GoodsEnding = Constant.GoodsLevelType.Waste.GetHashCode().ToString();
  6418. ////}
  6419. ////// string sqlReFire = @"select
  6420. ////// isrefire
  6421. ////// from tp_pm_inproduction where barcode=:barcode
  6422. ////// ";
  6423. ////// OracleParameter[] ReFireparas = new OracleParameter[] {
  6424. ////// new OracleParameter(":barcode",productionData.Barcode),
  6425. ////// };
  6426. ////// DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas);
  6427. ////// //DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire);
  6428. ////// if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0)
  6429. ////// {
  6430. ////// if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0)
  6431. ////// {
  6432. ////// productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]);
  6433. ////// }
  6434. ////// }
  6435. #endregion
  6436. string OutSpecialRepairflag = "0";//干补标识
  6437. //errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag);
  6438. errMsg = AddProductionDataWaster(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag);
  6439. if (!string.IsNullOrEmpty(errMsg))
  6440. {
  6441. return errMsg;
  6442. }
  6443. #endregion
  6444. //#region 添加生产者数据
  6445. //errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, productionData.UserID, productionData.UserName, sUserInfo);
  6446. //if (!string.IsNullOrEmpty(errMsg))
  6447. //{
  6448. // return errMsg;
  6449. //}
  6450. //#endregion
  6451. #region 条码有缺陷
  6452. // 废品标识
  6453. bool scrapFlag = false;
  6454. // 存在缺陷 插入缺陷表
  6455. if (productionData.ProductionDefects != null)
  6456. {
  6457. foreach (ProductionDefectEntity productionDefect in productionData.ProductionDefects)
  6458. {
  6459. #region 保存缺陷
  6460. productionDefect.ProductionDataID = productionDataID;
  6461. productionDefect.BarCode = productionData.Barcode;
  6462. productionDefect.ProductionLineID = procedure.ProductionLineID;
  6463. productionDefect.ProductionLineCode = procedure.ProductionlineCode;
  6464. productionDefect.ProductionLineName = procedure.ProductionlineName;
  6465. productionDefect.ProcedureID = procedure.ProcedureID;
  6466. productionDefect.ProcedureCode = procedure.ProcedureCode;
  6467. productionDefect.ProcedureName = procedure.ProcedureName;
  6468. productionDefect.UserID = productionData.UserID;
  6469. productionDefect.UserCode = productionData.UserCode;
  6470. productionDefect.UserName = productionData.UserName;
  6471. productionDefect.GoodsID = productionData.GoodsID;
  6472. productionDefect.GoodsCode = productionData.GoodsCode;
  6473. productionDefect.GoodsName = productionData.GoodsName;
  6474. productionData.Remarks = productionData.Remarks;
  6475. productionDefect.ScrapResponFlag
  6476. = string.IsNullOrEmpty(productionDefect.ScrapResponFlag) ? "0" : productionDefect.ScrapResponFlag;
  6477. // 保存缺陷
  6478. errMsg = AddDefect(oracleTrConn, productionDefect, sUserInfo);
  6479. if (!string.IsNullOrEmpty(errMsg))
  6480. {
  6481. return errMsg;
  6482. }
  6483. #endregion
  6484. #region 缺陷列表中只有一个报废工序 添加废弃产品 删除在产产品数据
  6485. if (!scrapFlag && productionDefect.ScrapResponFlag == "1")
  6486. {
  6487. scrapFlag = true;
  6488. #region 添加废弃产品 删除在产产品数据
  6489. #region 添加废弃产品
  6490. ScrapProductEntity scrapProduct = new ScrapProductEntity();
  6491. #region 属性赋值
  6492. scrapProduct.BarCode = productionData.Barcode;
  6493. scrapProduct.ScrapType = Constant.ScrapType.Waste.GetHashCode();
  6494. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  6495. {
  6496. scrapProduct.ResponType = Constant.ScrapResponType.NoPerson.GetHashCode();
  6497. }
  6498. else
  6499. {
  6500. scrapProduct.ResponType = Constant.ScrapResponType.Procedure.GetHashCode();
  6501. }
  6502. scrapProduct.ScrapDate = accountDate;
  6503. scrapProduct.Rreason = Constant.SCRAPTYPE_WASTE;
  6504. scrapProduct.Remarks = productionDefect.Remarks;
  6505. scrapProduct.AuditStatus = Constant.AuditStatus.Agree.GetHashCode();
  6506. scrapProduct.Auditor = sUserInfo.UserID;
  6507. scrapProduct.AuditlDate = accountDate;
  6508. scrapProduct.AccountDate = accountDate;
  6509. scrapProduct.GoodsLevelID = productionData.GoodsLevelID;
  6510. scrapProduct.GoodsLevelTypeID = productionData.GoodsLevelTypeID;
  6511. scrapProduct.IsPublicBody = productionData.IsPublicBody;
  6512. string sqlScrapProduct = "select SEQ_PM_ScrapProduct_ID.nextval from dual";
  6513. string idStrScrapProduct = oracleTrConn.GetSqlResultToStr(sqlScrapProduct);
  6514. scrapProduct.ScrapProductID = Convert.ToInt32(idStrScrapProduct);
  6515. scrapProduct.ScrapType = 1;
  6516. #endregion
  6517. // 保存报废
  6518. errMsg = AddScrapProduct(oracleTrConn, scrapProduct, sUserInfo);
  6519. // 保存失败
  6520. if (!string.IsNullOrEmpty(errMsg))
  6521. {
  6522. return errMsg;
  6523. }
  6524. #endregion
  6525. #region 添加责任工序
  6526. //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的
  6527. //xuwei fix 2019-09-26 使用通用方法判定
  6528. if (IsNodeBegin<IDBTransaction>(oracleTrConn, productionData.Barcode) == 1)
  6529. procedure.NodeType = (int)Constant.ProcedureNodeType.Begin;
  6530. if (procedure.NodeType != Constant.ProcedureNodeType.Begin.GetHashCode())
  6531. {
  6532. //string sqlScrapProduct = "select SEQ_PM_ScrapProduct_ID.Currval from dual";
  6533. //string idStrScrapProduct = oracleTrConn.GetSqlResultToStr(sqlScrapProduct);
  6534. ResponProcedureEntity responProce = new ResponProcedureEntity();
  6535. #region 属性赋值
  6536. responProce.BarCode = productionData.Barcode;
  6537. responProce.ProductionDataID = productionDataID;
  6538. responProce.ProductionLineID = productionDefect.ProductionLineID;
  6539. responProce.ProductionLineCode = productionDefect.ProductionLineCode;
  6540. responProce.ProductionLineName = productionDefect.ProductionLineName;
  6541. responProce.ProcedureID = productionDefect.DefectProcedureID;
  6542. responProce.ProcedureCode = productionDefect.DefectProcedureCode;
  6543. responProce.ProcedureName = productionDefect.DefectProcedureName;
  6544. responProce.UserID = productionDefect.DefectUserID;
  6545. responProce.UserCode = productionDefect.DefectUserCode;
  6546. responProce.UserName = productionDefect.DefectUserName;
  6547. responProce.Remarks = productionDefect.Remarks;
  6548. responProce.ScrapProductID = Convert.ToInt32(idStrScrapProduct);
  6549. #endregion
  6550. // 保存责任工序
  6551. errMsg = AddResponProcedure(oracleTrConn, responProce, productionDefect, sUserInfo);
  6552. // 保存失败
  6553. if (!string.IsNullOrEmpty(errMsg))
  6554. {
  6555. return errMsg;
  6556. }
  6557. }
  6558. #endregion
  6559. #region 删除在产产品数据
  6560. InProductionEntity delInProductionEntity = new InProductionEntity();
  6561. delInProductionEntity.BarCode = productionData.Barcode;
  6562. delInProductionEntity.CompleteProcedureID = productionData.ProcedureID;
  6563. // 执行删除 在产数据
  6564. errMsg = DeleteInProduction(oracleTrConn, delInProductionEntity, false, sUserInfo);
  6565. // 执行失败
  6566. // if (!string.IsNullOrEmpty(errMsg)) 注释日期2015-12-28
  6567. // {
  6568. // return errMsg;
  6569. // }
  6570. #endregion
  6571. #endregion
  6572. }
  6573. #endregion
  6574. }
  6575. }
  6576. #endregion
  6577. // 条码有缺陷或者报废
  6578. //wangxin 20150414
  6579. //if (scrapFlag || productionData.GoodsLevelTypeID == Constant.GoodsLevelType.Defect.GetHashCode())
  6580. //{
  6581. #region 有缺陷 删除条码对应窑车产品
  6582. if (productionData.DefectFlag == Constant.GoodsLevelType.Defect.GetHashCode())
  6583. {
  6584. errMsg = DeleteKilnCarGoods(oracleTrConn, productionData.Barcode);
  6585. if (!string.IsNullOrEmpty(errMsg))
  6586. {
  6587. return errMsg;
  6588. }
  6589. }
  6590. #endregion
  6591. //}
  6592. //wangxin 20150414 end
  6593. // 条码没有报废
  6594. if (!scrapFlag)
  6595. {
  6596. #region 修改在产产品数据的当前工序
  6597. InProductionEntity inProductionEntity = new InProductionEntity();
  6598. inProductionEntity.BarCode = productionData.Barcode;
  6599. //流程工序
  6600. inProductionEntity.FlowProcedureID = procedure.ProcedureID;
  6601. // 当前工序
  6602. //inProductionEntity.CompleteProcedureID = procedure.ProcedureID;
  6603. inProductionEntity.ProcedureID = procedure.ProcedureID;
  6604. // 生产数据ID
  6605. inProductionEntity.ProductionDataID = productionDataID;
  6606. // 工序模型
  6607. inProductionEntity.ProcedureModel = procedure.ProcedureModel;
  6608. // 工序类别
  6609. inProductionEntity.ModelType = procedure.ModelType;
  6610. // 生产工号
  6611. inProductionEntity.UserID = productionData.UserID;
  6612. // 缺陷标识
  6613. inProductionEntity.DefectFlag = productionData.DefectFlag;
  6614. // 返工工序ID
  6615. inProductionEntity.ReworkProcedureID = productionData.ReworkProcedureID;
  6616. inProductionEntity.GoodsLevelID = productionData.GoodsLevelID;
  6617. inProductionEntity.GoodsLevelTypeID = productionData.GoodsLevelTypeID;
  6618. inProductionEntity.IsPublicBody = productionData.IsPublicBody;
  6619. // 执行修改
  6620. errMsg = UpdateInProduction(oracleTrConn, inProductionEntity, sUserInfo);
  6621. // 执行失败
  6622. if (!string.IsNullOrEmpty(errMsg))
  6623. {
  6624. return errMsg;
  6625. }
  6626. #endregion
  6627. }
  6628. }
  6629. return errMsg;
  6630. }
  6631. /// <summary>
  6632. /// 删除窑车产品
  6633. /// </summary>
  6634. /// <param name="oracleTrConn">数据连接</param>
  6635. /// <param name="barcode">产品条码</param>
  6636. /// <returns>string</returns>
  6637. private static string DeleteKilnCarGoods(IDBTransaction oracleTrConn, string barcode)
  6638. {
  6639. string sql = "delete TP_PM_KilnCarGoods where BarCode = :barcode";
  6640. OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":barcode", barcode) };
  6641. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  6642. // 保存失败
  6643. if (result != Constant.INT_IS_ONE)
  6644. {
  6645. //return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  6646. }
  6647. return null;
  6648. }
  6649. /// <summary>
  6650. /// 添加成品编辑
  6651. /// </summary>
  6652. /// <param name="oracleTrConn">数据连接</param>
  6653. /// <param name="procedure">工序对象</param>
  6654. /// <param name="productionDataEntitys">生产数据集</param>
  6655. /// <param name="sUserInfo">用户基本信息</param>
  6656. /// <returns>string</returns>
  6657. //private static string AddFinishCheck(IDBTransaction oracleTrConn, ProcedureEntity procedure, ProductionDataEntity[] productionDataEntitys, SUserInfo sUserInfo)
  6658. //{
  6659. // string errMsg = "";
  6660. // // 获得账务日期
  6661. // DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  6662. // // 本批采集的批次号
  6663. // string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  6664. // foreach (ProductionDataEntity productionData in productionDataEntitys)
  6665. // {
  6666. // if (string.IsNullOrEmpty(productionData.Barcode))
  6667. // {
  6668. // throw new Exception("传入的条码号为空");
  6669. // }
  6670. // int goodsID = Constant.INT_IS_ZERO;
  6671. // string goodsCode = string.Empty;
  6672. // string goodsName = string.Empty;
  6673. // // 注浆者工号
  6674. // string groutingUserCode = string.Empty;
  6675. // // 次品标识
  6676. // bool substandardFlag = false;
  6677. // #region 校验条码有效性
  6678. // errMsg = CheckBarcode(oracleTrConn, procedure.ProcedureID, productionData.Barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo);
  6679. // if (!string.IsNullOrEmpty(errMsg))
  6680. // {
  6681. // if (productionData.ProductionDataID == 0)
  6682. // return errMsg;
  6683. // }
  6684. // #endregion
  6685. // #region 添加生产数据
  6686. // #region 属性赋值
  6687. // productionData.CentralizedBatchNo = centralizedBatchNo;
  6688. // productionData.ProductionLineID = procedure.ProductionLineID;
  6689. // productionData.ProductionLineCode = procedure.ProductionlineCode;
  6690. // productionData.ProductionLineName = procedure.ProductionlineName;
  6691. // productionData.CompleteProcedureID = procedure.ProcedureID;
  6692. // productionData.ProcedureCode = procedure.ProcedureCode;
  6693. // productionData.ProcedureName = procedure.ProcedureName;
  6694. // productionData.ProcedureModel = procedure.ProcedureModel;
  6695. // productionData.ModelType = procedure.ModelType;
  6696. // productionData.IsPublicBody = (int)Constant.PublicBodyFlag.No;
  6697. // // 重烧
  6698. // if (productionData.GoodsLevelTypeID == (int)Constant.GoodsLevelType.ReFire)
  6699. // {
  6700. // //productionData.GoodsLevelID = null;
  6701. // productionData.IsReFire = (int)Constant.ReFireFlag.No;
  6702. // }
  6703. // // 次品
  6704. // else if (productionData.GoodsLevelTypeID == (int)Constant.GoodsLevelType.Reject)
  6705. // {
  6706. // //productionData.GoodsLevelID = null;
  6707. // substandardFlag = true;
  6708. // }
  6709. // // 查询新插入的生产数据ID
  6710. // if (productionData.GoodsLevelTypeID != (int)Constant.GoodsLevelType.ReFire)
  6711. // {
  6712. // //不加条件valueflag,是因为,成检后重烧走过之后,在次重烧,以后也是重烧状态
  6713. // //string sqlReFire = "select * from tp_PM_ProductionData where ProductionData=(select max(ProductionDataid) from ProductionData where barcode=" + productionData.Barcode + " and ProcedureID=" + productionData.ProcedureID + ")";
  6714. // string sqlReFire = "select * from tp_PM_ProductionData where ProductionDataid=(select max(ProductionDataid) from tp_PM_ProductionData where barcode='" + productionData.Barcode + "')";
  6715. // DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire);
  6716. // if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0)
  6717. // {
  6718. // productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]);
  6719. // }
  6720. // }
  6721. // productionData.OrganizationID = procedure.OrganizationID;
  6722. // productionData.GoodsID = goodsID;
  6723. // productionData.GoodsCode = goodsCode;
  6724. // productionData.GoodsName = goodsName;
  6725. // productionData.GoodsLevelID = productionData.GoodsLevelID;
  6726. // productionData.GoodsLevelTypeID = productionData.GoodsLevelTypeID;
  6727. // //if (productionData.GoodsLevelTypeID == (int)Constant.GoodsLevelType.Reject)
  6728. // //{
  6729. // // productionData.GoodsEnding = Constant.GoodsLevelType.Reject.GetHashCode().ToString();
  6730. // //}
  6731. // #endregion
  6732. // string OutSpecialRepairflag = "0";//干补标识
  6733. // errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag);
  6734. // if (!string.IsNullOrEmpty(errMsg))
  6735. // {
  6736. // return errMsg;
  6737. // }
  6738. // // 查询新插入的生产数据ID
  6739. // string sql = "select SEQ_PM_ProductionData_ID.Currval from dual";
  6740. // string idStr = oracleTrConn.GetSqlResultToStr(sql);
  6741. // // 新插入的班次配置表ID
  6742. // int productionDataID = 0;
  6743. // if (!string.IsNullOrEmpty(idStr))
  6744. // {
  6745. // productionDataID = int.Parse(idStr);
  6746. // }
  6747. // else
  6748. // {
  6749. // return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  6750. // }
  6751. // #endregion
  6752. // #region 添加生产者数据
  6753. // int? ClassesSettingID = null;//班次配置ID
  6754. // errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, productionData.UserID, productionData.UserName, sUserInfo, ref ClassesSettingID);
  6755. // if (!string.IsNullOrEmpty(errMsg))
  6756. // {
  6757. // return errMsg;
  6758. // }
  6759. // #endregion
  6760. // #region 条码有缺陷
  6761. // #region 是次品 添加废弃产品
  6762. // if (substandardFlag)
  6763. // {
  6764. // #region 添加废弃产品
  6765. // ScrapProductEntity scrapProduct = new ScrapProductEntity();
  6766. // #region 属性赋值
  6767. // scrapProduct.BarCode = productionData.Barcode;
  6768. // scrapProduct.ScrapType = Constant.ScrapType.Substandard.GetHashCode();
  6769. // scrapProduct.ResponType = Constant.ScrapResponType.Procedure.GetHashCode();
  6770. // scrapProduct.ScrapDate = accountDate;
  6771. // scrapProduct.Rreason = Constant.SCRAPTYPE_SUBSTANDARD;
  6772. // scrapProduct.AuditStatus = Constant.AuditStatus.Agree.GetHashCode();
  6773. // scrapProduct.Auditor = sUserInfo.UserID;
  6774. // scrapProduct.AuditlDate = accountDate;
  6775. // scrapProduct.AccountDate = accountDate;
  6776. // scrapProduct.GoodsLevelID = productionData.GoodsLevelID;
  6777. // scrapProduct.GoodsLevelTypeID = productionData.GoodsLevelTypeID;
  6778. // #endregion
  6779. // // 保存报废
  6780. // errMsg = AddScrapProduct(oracleTrConn, scrapProduct, sUserInfo);
  6781. // // 保存失败
  6782. // if (!string.IsNullOrEmpty(errMsg))
  6783. // {
  6784. // return errMsg;
  6785. // }
  6786. // #endregion
  6787. // }
  6788. // #endregion
  6789. // // 存在缺陷 插入缺陷表
  6790. // if (productionData.ProductionDefects != null)
  6791. // {
  6792. // foreach (ProductionDefectEntity productionDefect in productionData.ProductionDefects)
  6793. // {
  6794. // #region 保存缺陷
  6795. // productionDefect.ProductionDataID = productionDataID;
  6796. // productionDefect.BarCode = productionData.Barcode;
  6797. // productionDefect.ProductionLineID = procedure.ProductionLineID;
  6798. // productionDefect.ProductionLineCode = procedure.ProductionlineCode;
  6799. // productionDefect.ProductionLineName = procedure.ProductionlineName;
  6800. // productionDefect.ProcedureID = procedure.ProcedureID;
  6801. // productionDefect.ProcedureCode = procedure.ProcedureCode;
  6802. // productionDefect.ProcedureName = procedure.ProcedureName;
  6803. // productionDefect.UserID = productionData.UserID;
  6804. // productionDefect.UserCode = productionData.UserCode;
  6805. // productionDefect.UserName = productionData.UserName;
  6806. // productionDefect.GoodsID = productionData.GoodsID;
  6807. // productionDefect.GoodsCode = productionData.GoodsCode;
  6808. // productionDefect.GoodsName = productionData.GoodsName;
  6809. // productionData.Remarks = productionData.Remarks;
  6810. // productionDefect.ScrapResponFlag
  6811. // = string.IsNullOrEmpty(productionDefect.ScrapResponFlag) ? "0" : productionDefect.ScrapResponFlag;
  6812. // // 保存缺陷
  6813. // errMsg = AddDefect(oracleTrConn, productionDefect, sUserInfo);
  6814. // if (!string.IsNullOrEmpty(errMsg))
  6815. // {
  6816. // return errMsg;
  6817. // }
  6818. // #endregion
  6819. // #region 是次品 添加废弃责任工序
  6820. // if (substandardFlag)
  6821. // {
  6822. // #region 添加责任工序
  6823. // ResponProcedureEntity responProce = new ResponProcedureEntity();
  6824. // // 查询新插入的废弃ID
  6825. // string ResponProceduresql = "select SEQ_PM_ScrapProduct_ID.Currval from dual";
  6826. // string ResponProcedureidStr = oracleTrConn.GetSqlResultToStr(ResponProceduresql);
  6827. // #region 属性赋值
  6828. // responProce.BarCode = productionData.Barcode;
  6829. // responProce.ProductionDataID = productionDataID;
  6830. // responProce.ProductionLineID = productionDefect.ProductionLineID;
  6831. // responProce.ProductionLineCode = productionDefect.ProductionLineCode;
  6832. // responProce.ProductionLineName = productionDefect.ProductionLineName;
  6833. // responProce.ProcedureID = productionDefect.DefectProcedureID;
  6834. // responProce.ProcedureCode = productionDefect.DefectProcedureCode;
  6835. // responProce.ProcedureName = productionDefect.DefectProcedureName;
  6836. // responProce.UserID = productionDefect.DefectUserID;
  6837. // responProce.UserCode = productionDefect.DefectUserCode;
  6838. // responProce.UserName = productionDefect.DefectUserName;
  6839. // responProce.Remarks = productionDefect.Remarks;
  6840. // responProce.ScrapProductID = Convert.ToInt32(ResponProcedureidStr);
  6841. // #endregion
  6842. // // 保存责任工序
  6843. // errMsg = AddResponProcedure(oracleTrConn, responProce, productionDefect, sUserInfo);
  6844. // // 保存失败
  6845. // if (!string.IsNullOrEmpty(errMsg))
  6846. // {
  6847. // return errMsg;
  6848. // }
  6849. // #endregion
  6850. // }
  6851. // #endregion
  6852. // }
  6853. // }
  6854. // #endregion
  6855. // #region 条码是次品 删除在产产品数据
  6856. // if (substandardFlag)
  6857. // {
  6858. // #region 删除在产产品数据
  6859. // InProductionEntity delInProductionEntity = new InProductionEntity();
  6860. // delInProductionEntity.BarCode = productionData.Barcode;
  6861. // // 执行删除 在产数据
  6862. // errMsg = DeleteInProduction(oracleTrConn, delInProductionEntity, false, sUserInfo);
  6863. // // 执行失败
  6864. // if (!string.IsNullOrEmpty(errMsg))
  6865. // {
  6866. // return errMsg;
  6867. // }
  6868. // #endregion
  6869. // }
  6870. // #endregion
  6871. // #region 条码不是次品
  6872. // if (!substandardFlag)
  6873. // {
  6874. // #region 中间工序/重烧 修改在产产品数据
  6875. // if (procedure.NodeType == (int)Constant.ProcedureNodeType.Middle
  6876. // || productionData.IsReFire == Constant.GoodsGrade.ReFire.GetHashCode())
  6877. // {
  6878. // #region 修改在产产品数据的当前工序
  6879. // InProductionEntity inProductionEntity = new InProductionEntity();
  6880. // inProductionEntity.BarCode = productionData.Barcode;
  6881. // // 当前工序
  6882. // inProductionEntity.CompleteProcedureID = procedure.ProcedureID;
  6883. // // 工序模型
  6884. // inProductionEntity.ProcedureModel = procedure.ProcedureModel;
  6885. // // 工序类别
  6886. // inProductionEntity.ModelType = procedure.ModelType;
  6887. // // 生产工号
  6888. // inProductionEntity.UserID = productionData.UserID;
  6889. // // 重烧
  6890. // inProductionEntity.IsReFire = productionData.IsReFire;
  6891. // // 缺陷
  6892. // inProductionEntity.DefectFlag = productionData.DefectFlag;
  6893. // // 产品分级
  6894. // inProductionEntity.GoodsGrade = productionData.GoodsGrade;
  6895. // // 返工工序ID
  6896. // inProductionEntity.ReworkProcedureID = productionData.ReworkProcedureID;
  6897. // inProductionEntity.GoodsLevelID = productionData.GoodsLevelID;
  6898. // inProductionEntity.GoodsLevelTypeID = productionData.GoodsLevelTypeID;
  6899. // // 执行修改
  6900. // errMsg = UpdateInProduction(oracleTrConn, inProductionEntity, sUserInfo);
  6901. // // 执行失败
  6902. // if (!string.IsNullOrEmpty(errMsg))
  6903. // {
  6904. // return errMsg;
  6905. // }
  6906. // #endregion
  6907. // }
  6908. // #endregion
  6909. // #region 结束工序 添加成品数据 删除在产产品数据
  6910. // else if (procedure.NodeType == (int)Constant.ProcedureNodeType.End)
  6911. // {
  6912. // #region 添加成品数据 删除在产产品数据
  6913. // FinishedProductEntity finishedProduct = new FinishedProductEntity();
  6914. // finishedProduct.BarCode = productionData.Barcode;
  6915. // errMsg = AddFinishedProduct(oracleTrConn, finishedProduct, sUserInfo);
  6916. // if (!string.IsNullOrEmpty(errMsg))
  6917. // {
  6918. // return errMsg;
  6919. // }
  6920. // InProductionEntity delInProductionEntity = new InProductionEntity();
  6921. // delInProductionEntity.BarCode = productionData.Barcode;
  6922. // // 执行删除 在产数据
  6923. // errMsg = DeleteInProduction(oracleTrConn, delInProductionEntity, true, sUserInfo);
  6924. // // 执行失败
  6925. // if (!string.IsNullOrEmpty(errMsg))
  6926. // {
  6927. // return errMsg;
  6928. // }
  6929. // #endregion
  6930. // }
  6931. // #endregion
  6932. // }
  6933. // #endregion
  6934. // }
  6935. // return errMsg;
  6936. //}
  6937. /// <summary>
  6938. /// 保存标准检验
  6939. /// </summary>
  6940. /// <param name="oracleTrConn">连接对象</param>
  6941. /// <param name="procedure">工序信息</param>
  6942. /// <param name="productionDataEntitys">生产数据集合</param>
  6943. /// <param name="sUserInfo">用户基本信息</param>
  6944. /// <returns>string</returns>
  6945. private static string AddNormalCheck(IDBTransaction oracleTrConn, ProcedureEntity procedure, ProductionDataEntity[] productionDataEntitys, SUserInfo sUserInfo)
  6946. {
  6947. string errMsg = "";
  6948. // 获得账务日期
  6949. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  6950. // 本批采集的批次号
  6951. string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  6952. string finishedloadbatchno = DateTime.Now.ToString("yyMMddHHmmss-") + centralizedBatchNo;
  6953. #region 查询产品分级
  6954. string sqlGoodsLevel = "select GoodsLevelID,GoodsLevelTypeID from TP_MST_GoodsLevel where AccountID=:accountID and ValueFlag=1";
  6955. DataTable goodsLevelTable = oracleTrConn.GetSqlResultToDt(sqlGoodsLevel, new OracleParameter[] { new OracleParameter(":accountID", sUserInfo.AccountID) });
  6956. #endregion
  6957. foreach (ProductionDataEntity productionData in productionDataEntitys)
  6958. {
  6959. if (string.IsNullOrEmpty(productionData.Barcode))
  6960. {
  6961. throw new Exception("传入的条码号为空");
  6962. }
  6963. if (productionData.ProductionDataID != 0)
  6964. {
  6965. errMsg = DeleteSubstandardToSubstandardByID(oracleTrConn, productionData.ProductionDataID, productionData.Barcode, sUserInfo);
  6966. if (!string.IsNullOrEmpty(errMsg))
  6967. {
  6968. return errMsg;
  6969. }
  6970. // 删除报废条码
  6971. string updateScrapSql = @"update tp_pm_scrapproduct set ValueFlag=0
  6972. where tp_pm_scrapproduct.barcode=:barcode";
  6973. OracleParameter[] ScrapProductparas = new OracleParameter[]{
  6974. new OracleParameter(":barcode",OracleDbType.Varchar2, productionData.Barcode,ParameterDirection.Input),
  6975. };
  6976. oracleTrConn.ExecuteNonQuery(updateScrapSql, ScrapProductparas);
  6977. string sqlInsInProdString = @"insert into TP_PM_InProduction(BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME,
  6978. PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID,
  6979. ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME,
  6980. USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE,
  6981. GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID,
  6982. CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE,
  6983. REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME,
  6984. CREATEUSERID, UPDATETIME, UPDATEUSERID,
  6985. ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG,
  6986. GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM,
  6987. KILNID, KILNCODE, KILNNAME, KILNCARID,
  6988. KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID
  6989. ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,logoid,IsReworkFlag,SemiCheckID)
  6990. select BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME,
  6991. PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID,
  6992. ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME,
  6993. USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE,
  6994. GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID,
  6995. CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE,
  6996. REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME,
  6997. CREATEUSERID, UPDATETIME, :UpdateUserID,
  6998. ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG,
  6999. GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM,
  7000. KILNID, KILNCODE, KILNNAME, KILNCARID,
  7001. KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID ,
  7002. FlowProcedureTime,ProcedureID,sysdate,ProductionDataID,logoid,IsReworkFlag,SemiCheckID
  7003. from TP_PM_InProductionTrash where barcode=:barcode ";
  7004. OracleParameter[] InProductparas = new OracleParameter[]{
  7005. new OracleParameter(":UpdateUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input),
  7006. new OracleParameter(":barcode",OracleDbType.Varchar2, productionData.Barcode,ParameterDirection.Input),
  7007. };
  7008. oracleTrConn.ExecuteNonQuery(sqlInsInProdString, InProductparas);
  7009. //删除回收站中的条码
  7010. string sqlDelInProductTrashString = "delete from TP_PM_InProductionTrash where barcode=:barcode ";
  7011. OracleParameter[] TrashProductparas = new OracleParameter[]{
  7012. new OracleParameter(":barcode",OracleDbType.Varchar2, productionData.Barcode,ParameterDirection.Input)
  7013. };
  7014. oracleTrConn.ExecuteNonQuery(sqlDelInProductTrashString, TrashProductparas);
  7015. }
  7016. int goodsID = Constant.INT_IS_ZERO;
  7017. string goodsCode = string.Empty;
  7018. string goodsName = string.Empty;
  7019. // 注浆者工号
  7020. string groutingUserCode = string.Empty;
  7021. #region 校验条码有效性
  7022. errMsg = CheckBarcode(oracleTrConn, procedure.ProcedureID, productionData.Barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo);
  7023. if (!string.IsNullOrEmpty(errMsg))
  7024. {
  7025. if (productionData.ProductionDataID == 0)
  7026. return errMsg;
  7027. }
  7028. #endregion
  7029. // 查询新插入的生产数据ID
  7030. string sql = "select SEQ_PM_ProductionData_ID.nextval from dual";
  7031. string idStr = oracleTrConn.GetSqlResultToStr(sql);
  7032. int? ClassesSettingID = null;//班次配置ID
  7033. // 新插入的班次配置表ID
  7034. int productionDataID = 0;
  7035. if (!string.IsNullOrEmpty(idStr))
  7036. {
  7037. productionDataID = int.Parse(idStr);
  7038. }
  7039. else
  7040. {
  7041. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  7042. }
  7043. #region 添加生产者数据
  7044. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, productionData.UserID, productionData.UserName, sUserInfo, ref ClassesSettingID);
  7045. if (!string.IsNullOrEmpty(errMsg))
  7046. {
  7047. return errMsg;
  7048. }
  7049. #endregion
  7050. #region 添加生产数据
  7051. #region 属性赋值
  7052. productionData.ClassesSettingID = ClassesSettingID;
  7053. productionData.ProductionDataID = Convert.ToInt32(idStr);
  7054. productionData.CentralizedBatchNo = centralizedBatchNo;
  7055. productionData.ProductionLineID = procedure.ProductionLineID;
  7056. productionData.ProductionLineCode = procedure.ProductionlineCode;
  7057. productionData.ProductionLineName = procedure.ProductionlineName;
  7058. productionData.CompleteProcedureID = procedure.ProcedureID;
  7059. productionData.ProcedureID = procedure.ProcedureID;
  7060. productionData.ProcedureCode = procedure.ProcedureCode;
  7061. productionData.ProcedureName = procedure.ProcedureName;
  7062. productionData.ProcedureModel = procedure.ProcedureModel;
  7063. productionData.ModelType = procedure.ModelType;
  7064. productionData.NodeType = procedure.NodeType;
  7065. productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, productionData.Barcode);
  7066. productionData.IsReFire = (int)Constant.ReFireFlag.No;
  7067. productionData.GoodsGrade = (int)Constant.GoodsGrade.Good;
  7068. productionData.OrganizationID = procedure.OrganizationID;
  7069. productionData.GoodsID = goodsID;
  7070. productionData.GoodsCode = goodsCode;
  7071. productionData.GoodsName = goodsName;
  7072. productionData.GoodsLevelID = productionData.GoodsLevelID;
  7073. productionData.GoodsLevelTypeID = productionData.GoodsLevelTypeID;
  7074. ////////如果报废给此产品最状态赋值
  7075. //////if (productionData.ProductionDefects != null)
  7076. //////{
  7077. ////// foreach (ProductionDefectEntity productionDefect in productionData.ProductionDefects)
  7078. ////// {
  7079. ////// if ((string.IsNullOrEmpty(productionDefect.ScrapResponFlag) ? "0" : productionDefect.ScrapResponFlag) == "1")
  7080. ////// {
  7081. ////// productionData.GoodsEnding = productionData.GoodsLevelTypeID.ToString();
  7082. ////// break;
  7083. ////// }
  7084. ////// }
  7085. //////}
  7086. //////if (productionData.GoodsLevelTypeID == (int)Constant.GoodsLevelType.Waste)
  7087. //////{
  7088. ////// productionData.GoodsEnding = Constant.GoodsLevelType.Waste.GetHashCode().ToString();
  7089. //////}
  7090. ////// string sqlReFire = @"select
  7091. ////// isrefire
  7092. ////// from tp_pm_inproduction where barcode=:barcode
  7093. ////// ";
  7094. ////// OracleParameter[] ReFireparas = new OracleParameter[] {
  7095. ////// new OracleParameter(":barcode",productionData.Barcode),
  7096. ////// };
  7097. ////// DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas);
  7098. ////// if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0)
  7099. ////// {
  7100. ////// if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0)
  7101. ////// {
  7102. ////// productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]);
  7103. ////// }
  7104. ////// }
  7105. #endregion
  7106. string OutSpecialRepairflag = "0";//干补标识
  7107. DataSet outDataSet = null;
  7108. //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的
  7109. //xuwei fix 2019-09-26 使用通用方法判定
  7110. // 2019-1016
  7111. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  7112. {
  7113. int isNodeBegin = IsNodeBegin<IDBTransaction>(oracleTrConn, productionData.Barcode);
  7114. if (isNodeBegin == 0)
  7115. {
  7116. procedure.NodeType = (int)Constant.ProcedureNodeType.Middle;
  7117. }
  7118. }
  7119. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  7120. {
  7121. errMsg = AddProductionDataDeliverMud(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag, out outDataSet);
  7122. }
  7123. else
  7124. {
  7125. errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag);
  7126. }
  7127. if (!string.IsNullOrEmpty(errMsg))
  7128. {
  7129. return errMsg;
  7130. }
  7131. if (productionData.ProductionDefects == null || productionData.ProductionDefects.Count == 0)
  7132. {
  7133. productionData.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  7134. }
  7135. #endregion
  7136. #region 获得产品分级ID
  7137. DataRow[] dr = goodsLevelTable.Select("GoodsLevelTypeID=" + productionData.GoodsLevelTypeID);
  7138. // 获得产品分级ID
  7139. productionData.GoodsLevelID = Convert.ToInt32(dr[0]["GoodsLevelID"]);
  7140. #endregion
  7141. #region 开始节点
  7142. //xuwei remove 2019-09-26 此处应该是重复判定 移除
  7143. //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的
  7144. //xuwei fix 2019-09-26 使用通用方法判定
  7145. //int isNodeBegin = IsNodeBegin<IDBTransaction>(oracleTrConn, productionData.Barcode);
  7146. // 2019-1016
  7147. //if (isNodeBegin == 1) procedure.NodeType = (int)Constant.ProcedureNodeType.Begin;
  7148. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  7149. {
  7150. #region 添加在产产品数据
  7151. InProductionEntity addInProductionEntity = new InProductionEntity();
  7152. addInProductionEntity.ProductionDataID = productionData.ProductionDataID;
  7153. addInProductionEntity.BarCode = productionData.Barcode;
  7154. //流程工序
  7155. addInProductionEntity.FlowProcedureID = procedure.ProcedureID;
  7156. // 当前工序
  7157. //addInProductionEntity.CompleteProcedureID = procedure.ProcedureID;
  7158. addInProductionEntity.ProcedureID = procedure.ProcedureID;
  7159. //生产数据ID
  7160. addInProductionEntity.ProductionDataID = productionDataID;
  7161. // 工序模型
  7162. addInProductionEntity.ProcedureModel = procedure.ProcedureModel;
  7163. // 工序类别
  7164. addInProductionEntity.ModelType = procedure.ModelType;
  7165. // 正常坯
  7166. addInProductionEntity.IsPublicBody = (int)Constant.PublicBodyFlag.No;
  7167. #endregion
  7168. // 生产工号
  7169. addInProductionEntity.UserID = productionData.UserID;
  7170. // 执行添加
  7171. errMsg = AddInProduction(oracleTrConn, addInProductionEntity, sUserInfo, outDataSet);
  7172. // 执行失败
  7173. if (!string.IsNullOrEmpty(errMsg))
  7174. {
  7175. return errMsg;
  7176. }
  7177. }
  7178. #endregion
  7179. #region 条码有缺陷
  7180. // 废品标识
  7181. bool scrapFlag = false;
  7182. // 存在缺陷 插入缺陷表
  7183. if (productionData.ProductionDefects != null)
  7184. {
  7185. foreach (ProductionDefectEntity productionDefect in productionData.ProductionDefects)
  7186. {
  7187. #region 保存缺陷
  7188. productionDefect.ProductionDataID = productionDataID;
  7189. productionDefect.BarCode = productionData.Barcode;
  7190. productionDefect.ProductionLineID = procedure.ProductionLineID;
  7191. productionDefect.ProductionLineCode = procedure.ProductionlineCode;
  7192. productionDefect.ProductionLineName = procedure.ProductionlineName;
  7193. productionDefect.ProcedureID = procedure.ProcedureID;
  7194. productionDefect.ProcedureCode = procedure.ProcedureCode;
  7195. productionDefect.ProcedureName = procedure.ProcedureName;
  7196. productionDefect.UserID = productionData.UserID;
  7197. productionDefect.UserCode = productionData.UserCode;
  7198. productionDefect.UserName = productionData.UserName;
  7199. productionDefect.GoodsID = productionData.GoodsID;
  7200. productionDefect.GoodsCode = productionData.GoodsCode;
  7201. productionDefect.GoodsName = productionData.GoodsName;
  7202. productionDefect.Remarks = productionData.Remarks;
  7203. productionDefect.ScrapResponFlag
  7204. = string.IsNullOrEmpty(productionDefect.ScrapResponFlag) ? "0" : productionDefect.ScrapResponFlag;
  7205. // 保存缺陷
  7206. errMsg = AddDefect(oracleTrConn, productionDefect, sUserInfo);
  7207. if (!string.IsNullOrEmpty(errMsg))
  7208. {
  7209. return errMsg;
  7210. }
  7211. #endregion
  7212. #region 缺陷列表中只有一个报废工序 添加废弃产品 删除在产产品数据
  7213. if (!scrapFlag && productionDefect.ScrapResponFlag == "1")
  7214. {
  7215. scrapFlag = true;
  7216. #region 添加废弃产品 删除在产产品数据
  7217. #region 添加废弃产品
  7218. ScrapProductEntity scrapProduct = new ScrapProductEntity();
  7219. #region 属性赋值
  7220. scrapProduct.BarCode = productionData.Barcode;
  7221. scrapProduct.ScrapType = Constant.ScrapType.Waste.GetHashCode();
  7222. //xuwei remove 2019-09-26 此处是重复判定移除
  7223. //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的
  7224. //xuwei fix 2019-09-26 使用通用方法判定
  7225. //int isNodeBegin = IsNodeBegin<IDBTransaction>(oracleTrConn, productionData.Barcode);
  7226. // 2019-1016
  7227. //if (isNodeBegin == 1) procedure.NodeType = (int)Constant.ProcedureNodeType.Begin;
  7228. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  7229. {
  7230. scrapProduct.ResponType = Constant.ScrapResponType.NoPerson.GetHashCode();
  7231. }
  7232. else
  7233. {
  7234. scrapProduct.ResponType = Constant.ScrapResponType.Procedure.GetHashCode();
  7235. }
  7236. scrapProduct.ScrapDate = accountDate;
  7237. scrapProduct.Rreason = Constant.SCRAPTYPE_WASTE;
  7238. scrapProduct.Remarks = productionDefect.Remarks;
  7239. scrapProduct.AuditStatus = Constant.AuditStatus.Agree.GetHashCode();
  7240. scrapProduct.Auditor = sUserInfo.UserID;
  7241. scrapProduct.AuditlDate = accountDate;
  7242. scrapProduct.AccountDate = accountDate;
  7243. scrapProduct.GoodsLevelID = productionData.GoodsLevelID;
  7244. scrapProduct.GoodsLevelTypeID = productionData.GoodsLevelTypeID;
  7245. string sqlScrapProduct = "select SEQ_PM_ScrapProduct_ID.nextval from dual";
  7246. string idStrScrapProduct = oracleTrConn.GetSqlResultToStr(sqlScrapProduct);
  7247. scrapProduct.ScrapProductID = Convert.ToInt32(idStrScrapProduct);
  7248. scrapProduct.ScrapType = 1;
  7249. scrapProduct.IsQualityStatistics = 1;
  7250. scrapProduct.ProductionDataID = productionData.ProductionDataID;
  7251. #endregion
  7252. // 保存报废
  7253. errMsg = AddScrapProduct(oracleTrConn, scrapProduct, sUserInfo);
  7254. // 保存失败
  7255. if (!string.IsNullOrEmpty(errMsg))
  7256. {
  7257. return errMsg;
  7258. }
  7259. #endregion
  7260. #region 添加责任工序
  7261. //xuwei remove 2019-09-26 此处是重复判定移除
  7262. //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的
  7263. //xuwei fix 2019-09-26 使用通用方法判定
  7264. //int isNodeBegin = IsNodeBegin<IDBTransaction>(oracleTrConn, productionData.Barcode);
  7265. // 2019-1016
  7266. //if (isNodeBegin == 1) procedure.NodeType = (int)Constant.ProcedureNodeType.Begin;
  7267. // 不是开始工序时。需要添加责任工序
  7268. if (procedure.NodeType != Constant.ProcedureNodeType.Begin.GetHashCode())
  7269. {
  7270. //string sqlScrapProduct = "select SEQ_PM_ScrapProduct_ID.Currval from dual";
  7271. //string idStrScrapProduct = oracleTrConn.GetSqlResultToStr(sqlScrapProduct);
  7272. ResponProcedureEntity responProce = new ResponProcedureEntity();
  7273. #region 属性赋值
  7274. responProce.BarCode = productionData.Barcode;
  7275. responProce.ProductionDataID = productionDataID;
  7276. responProce.ProductionLineID = productionDefect.ProductionLineID;
  7277. responProce.ProductionLineCode = productionDefect.ProductionLineCode;
  7278. responProce.ProductionLineName = productionDefect.ProductionLineName;
  7279. responProce.ProcedureID = productionDefect.DefectProcedureID;
  7280. responProce.ProcedureCode = productionDefect.DefectProcedureCode;
  7281. responProce.ProcedureName = productionDefect.DefectProcedureName;
  7282. responProce.UserID = productionDefect.DefectUserID;
  7283. responProce.UserCode = productionDefect.DefectUserCode;
  7284. responProce.UserName = productionDefect.DefectUserName;
  7285. responProce.Remarks = productionDefect.Remarks;
  7286. responProce.ScrapProductID = Convert.ToInt32(idStrScrapProduct);
  7287. #endregion
  7288. // 保存责任工序
  7289. errMsg = AddResponProcedure(oracleTrConn, responProce, productionDefect, sUserInfo);
  7290. // 保存失败
  7291. if (!string.IsNullOrEmpty(errMsg))
  7292. {
  7293. return errMsg;
  7294. }
  7295. }
  7296. #endregion
  7297. #region 删除在产产品数据
  7298. InProductionEntity delInProductionEntity = new InProductionEntity();
  7299. delInProductionEntity.BarCode = productionData.Barcode;
  7300. delInProductionEntity.CompleteProcedureID = productionData.ProcedureID;
  7301. // 执行删除 在产数据
  7302. errMsg = DeleteInProduction(oracleTrConn, delInProductionEntity, false, sUserInfo);
  7303. // 执行失败
  7304. if (!string.IsNullOrEmpty(errMsg))
  7305. {
  7306. return errMsg;
  7307. }
  7308. #endregion
  7309. #endregion
  7310. }
  7311. #endregion
  7312. }
  7313. }
  7314. #endregion
  7315. #region 条码没有报废
  7316. if (!scrapFlag)
  7317. {
  7318. #region 检验出缺陷 并且不是废品 修改在产产品数据
  7319. //xuwei remove 2019-09-26 此处是重复判定移除
  7320. //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的
  7321. //xuwei fix 2019-09-26 使用通用方法判定
  7322. //int isNodeBegin = IsNodeBegin<IDBTransaction>(oracleTrConn, productionData.Barcode);
  7323. // 2019-1016
  7324. //if (isNodeBegin == 1) procedure.NodeType = (int)Constant.ProcedureNodeType.Begin;
  7325. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Middle
  7326. || procedure.NodeType == (int)Constant.ProcedureNodeType.Begin
  7327. || productionData.GoodsLevelTypeID == Constant.GoodsLevelType.Defect.GetHashCode())
  7328. {
  7329. #region 修改在产产品数据的当前工序
  7330. InProductionEntity inProductionEntity = new InProductionEntity();
  7331. inProductionEntity.ProductionDataID = Convert.ToInt32(idStr);
  7332. inProductionEntity.BarCode = productionData.Barcode;
  7333. // 当前工序
  7334. inProductionEntity.ProcedureID = procedure.ProcedureID;
  7335. inProductionEntity.FlowProcedureID = procedure.ProcedureID;
  7336. // 工序模型
  7337. inProductionEntity.ProcedureModel = procedure.ProcedureModel;
  7338. // 工序类别
  7339. inProductionEntity.ModelType = procedure.ModelType;
  7340. // 生产工号
  7341. inProductionEntity.UserID = productionData.UserID;
  7342. // 缺陷标识
  7343. inProductionEntity.DefectFlag = productionData.DefectFlag;
  7344. // 返工工序ID
  7345. inProductionEntity.ReworkProcedureID = productionData.ReworkProcedureID;
  7346. inProductionEntity.GoodsLevelTypeID = productionData.GoodsLevelTypeID;
  7347. inProductionEntity.GoodsLevelID = productionData.GoodsLevelID;
  7348. // 执行修改
  7349. errMsg = UpdateInProduction(oracleTrConn, inProductionEntity, sUserInfo);
  7350. // 执行失败
  7351. if (!string.IsNullOrEmpty(errMsg))
  7352. {
  7353. return errMsg;
  7354. }
  7355. #endregion
  7356. }
  7357. #endregion
  7358. #region 结束工序、没有缺陷 添加成品数据 删除在产产品数据
  7359. //else if (procedure.NodeType == (int)Constant.ProcedureNodeType.End
  7360. // && productionData.DefectFlag == Constant.DefectFlag.No.GetHashCode())
  7361. else if (procedure.NodeType == (int)Constant.ProcedureNodeType.End
  7362. && productionData.GoodsLevelTypeID == Constant.GoodsLevelType.NoDefects.GetHashCode())
  7363. {
  7364. #region 添加成品数据 删除在产产品数据
  7365. FinishedProductEntity finishedProduct = new FinishedProductEntity();
  7366. finishedProduct.BarCode = productionData.Barcode;
  7367. errMsg = AddFinishedProduct(oracleTrConn, finishedProduct, sUserInfo, finishedloadbatchno);
  7368. if (!string.IsNullOrEmpty(errMsg))
  7369. {
  7370. return errMsg;
  7371. }
  7372. InProductionEntity delInProductionEntity = new InProductionEntity();
  7373. delInProductionEntity.BarCode = productionData.Barcode;
  7374. // 执行删除 在产数据
  7375. errMsg = DeleteInProduction(oracleTrConn, delInProductionEntity, true, sUserInfo);
  7376. // 执行失败
  7377. if (!string.IsNullOrEmpty(errMsg))
  7378. {
  7379. return errMsg;
  7380. }
  7381. #endregion
  7382. }
  7383. #endregion
  7384. }
  7385. #endregion
  7386. }
  7387. return errMsg;
  7388. }
  7389. ///// <summary>
  7390. ///// 报废更新产品数据最终状态
  7391. ///// </summary>
  7392. ///// <param name="oracleTrConn">连接对象</param>
  7393. ///// <param name="barcode">产品条码</param>
  7394. ///// <param name="sUserInfo">用记基本信息</param>
  7395. ///// <returns>string</returns>
  7396. ///// <remarks>
  7397. ///// 王鑫 2015.01.07 新建
  7398. ///// </remarks>
  7399. //private static string UpdateProductionDataGoodsEnding(IDBTransaction oracleTrConn, int productionDataID, int? goodsEnding, SUserInfo sUserInfo)
  7400. //{
  7401. // string sql = "update TP_PM_ProductionData set GoodsEnding=:goodsEnding where ProductionDataID = :productionDataID and AccountID=:accountid";
  7402. // OracleParameter[] paras = new OracleParameter[] {
  7403. // new OracleParameter(":goodsEnding",goodsEnding),
  7404. // new OracleParameter(":productionDataID",productionDataID),
  7405. // new OracleParameter(":accountid",sUserInfo.AccountID),
  7406. // };
  7407. // int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  7408. // // 更新失败
  7409. // if (result <= Constant.INT_IS_ZERO)
  7410. // {
  7411. // return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  7412. // }
  7413. // // 成功返回null
  7414. // return null;
  7415. //}
  7416. /// <summary>
  7417. /// 添加责任工序
  7418. /// </summary>
  7419. /// <param name="oracleTrConn">连接对象</param>
  7420. /// <param name="responProce">责任工序</param>
  7421. /// <param name="productionDefect">缺陷数据</param>
  7422. /// <param name="sUserInfo">用户基本信息</param>
  7423. /// <returns>string</returns>
  7424. private static string AddResponProcedure(IDBTransaction oracleTrConn, ResponProcedureEntity responProce, ProductionDefectEntity productionDefect, SUserInfo sUserInfo)
  7425. {
  7426. OracleParameter[] oracleParameters = null;
  7427. string sql = null;
  7428. int result = 0;
  7429. // 查询新插入ID
  7430. if (productionDefect.DefectProcedureID != null)
  7431. {
  7432. sql = "select SEQ_PM_ResponProcedure_ID.nextval from dual";
  7433. string idStr = oracleTrConn.GetSqlResultToStr(sql);
  7434. if (!string.IsNullOrEmpty(idStr))
  7435. {
  7436. responProce.ResponProcedureID = int.Parse(idStr);
  7437. }
  7438. else
  7439. {
  7440. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  7441. }
  7442. #region SQL
  7443. sql = "insert into tp_pm_responprocedure"
  7444. + " (ResponProcedureID,"
  7445. + " scrapproductid,"
  7446. + " barcode,"
  7447. + " productiondataid,"
  7448. + " productionlineid,"
  7449. + " productionlinecode,"
  7450. + " productionlinename,"
  7451. + " procedureid,"
  7452. + " procedurecode,"
  7453. + " procedurename,"
  7454. + " userid,"
  7455. + " usercode,"
  7456. + " username,"
  7457. + " remarks,"
  7458. + " accountid,"
  7459. + " createuserid,"
  7460. + " updateuserid)"
  7461. + " values"
  7462. + " ("
  7463. + " :ResponProcedureID,"
  7464. + " :scrapproductid,"
  7465. + " :barcode,"
  7466. + " :productiondataid,"
  7467. + " :productionlineid,"
  7468. + " :productionlinecode,"
  7469. + " :productionlinename,"
  7470. + " :procedureid,"
  7471. + " :procedurecode,"
  7472. + " :procedurename,"
  7473. + " :userid,"
  7474. + " :usercode,"
  7475. + " :username,"
  7476. + " :remarks,"
  7477. + " :accountid,"
  7478. + " :createuserid,"
  7479. + " :updateuserid)";
  7480. #endregion
  7481. #region 参数
  7482. oracleParameters = new OracleParameter[] {
  7483. new OracleParameter(":ResponProcedureID",responProce.ResponProcedureID),
  7484. new OracleParameter(":scrapproductid",responProce.ScrapProductID),
  7485. new OracleParameter(":barcode",responProce.BarCode),
  7486. new OracleParameter(":productiondataid",responProce.ProductionDataID),
  7487. new OracleParameter(":productionlineid",responProce.ProductionLineID),
  7488. new OracleParameter(":productionlinecode",responProce.ProductionLineCode),
  7489. new OracleParameter(":productionlinename",responProce.ProductionLineName),
  7490. new OracleParameter(":procedureid",responProce.ProcedureID),
  7491. new OracleParameter(":procedurecode",responProce.ProcedureCode),
  7492. new OracleParameter(":procedurename",responProce.ProcedureName),
  7493. new OracleParameter(":userid",responProce.UserID),
  7494. new OracleParameter(":usercode",responProce.UserCode),
  7495. new OracleParameter(":username",responProce.UserName),
  7496. new OracleParameter(":remarks",responProce.Remarks),
  7497. new OracleParameter(":accountid",sUserInfo.AccountID),
  7498. new OracleParameter(":createuserid",sUserInfo.UserID),
  7499. new OracleParameter(":updateuserid",sUserInfo.UserID),
  7500. };
  7501. #endregion
  7502. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  7503. // 保存失败
  7504. if (result != Constant.INT_IS_ONE)
  7505. {
  7506. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  7507. }
  7508. //// 查询新插入ID
  7509. //sql = "select SEQ_PM_ResponProcedure_ID.Currval from dual";
  7510. //string idStr = oracleTrConn.GetSqlResultToStr(sql);
  7511. //if (!string.IsNullOrEmpty(idStr))
  7512. //{
  7513. // responProce.ResponProcedureID = int.Parse(idStr);
  7514. //}
  7515. //else
  7516. //{
  7517. // return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  7518. //}
  7519. }
  7520. #region 插入责任人
  7521. foreach (DefectResponsibleEntity defectResponsible in productionDefect.DefectResponsibles)
  7522. {
  7523. #region SQL
  7524. sql = "insert into tp_pm_scrapresponsible"
  7525. + " (barcode,"
  7526. + " scrapproductid,"
  7527. + " staffid,"
  7528. + " userid,"
  7529. + " usercode,"
  7530. + " ujobsid,"
  7531. + " sjobsid,"
  7532. + " staffstatus,"
  7533. + " accountid,"
  7534. + " createuserid,"
  7535. + " updateuserid,"
  7536. + " responprocedureid,"
  7537. + " respontype)"
  7538. + " values"
  7539. + " (:barcode,"
  7540. + " :scrapproductid,"
  7541. + " :staffid,"
  7542. + " :userid,"
  7543. + " :usercode,"
  7544. + " :ujobsid,"
  7545. + " :sjobsid,"
  7546. + " :staffstatus,"
  7547. + " :accountid,"
  7548. + " :createuserid,"
  7549. + " :updateuserid,"
  7550. + " :responprocedureid,"
  7551. + " :respontype)";
  7552. #endregion
  7553. #region 参数
  7554. oracleParameters = new OracleParameter[] {
  7555. new OracleParameter(":scrapproductid",responProce.ScrapProductID),
  7556. new OracleParameter(":barcode",responProce.BarCode),
  7557. new OracleParameter(":staffid",defectResponsible.StaffID),
  7558. new OracleParameter(":userid",defectResponsible.UserID),
  7559. new OracleParameter(":usercode",defectResponsible.UserCode),
  7560. new OracleParameter(":ujobsid",defectResponsible.UJobsID),
  7561. new OracleParameter(":sjobsid",defectResponsible.SJobsID),
  7562. new OracleParameter(":staffstatus",defectResponsible.StaffStatus),
  7563. new OracleParameter(":accountid",sUserInfo.AccountID),
  7564. new OracleParameter(":createuserid",sUserInfo.UserID),
  7565. new OracleParameter(":updateuserid",sUserInfo.UserID),
  7566. new OracleParameter(":responprocedureid",responProce.ResponProcedureID),
  7567. new OracleParameter(":respontype",Constant.ScrapResponType.Procedure.GetHashCode()),
  7568. };
  7569. #endregion
  7570. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  7571. // 保存失败
  7572. if (result != Constant.INT_IS_ONE)
  7573. {
  7574. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  7575. }
  7576. }
  7577. #endregion
  7578. return null;
  7579. }
  7580. /// <summary>
  7581. /// 保存废弃产品
  7582. /// </summary>
  7583. /// <param name="oracleTrConn">连接对象</param>
  7584. /// <param name="scrapProduct">报废产品</param>
  7585. /// <param name="sUserInfo">用户基本信息</param>
  7586. /// <returns>string</returns>
  7587. private static string AddScrapProductRejectToReject(IDBTransaction oracleTrConn, ScrapProductEntity scrapProduct, SUserInfo sUserInfo)
  7588. {
  7589. #region sql
  7590. string sql = "insert into tp_pm_scrapproduct"
  7591. + " (scrapproductid,barcode,"
  7592. + " productionlineid,"
  7593. + " productionlinecode,"
  7594. + " productionlinename,"
  7595. + " goodsid,"
  7596. + " goodscode,"
  7597. + " goodsname,"
  7598. + " groutingdailyid,"
  7599. + " groutingdailydetailid,"
  7600. + " groutingdate,"
  7601. + " groutinglineid,"
  7602. + " groutinglinecode,"
  7603. + " groutinglinename,"
  7604. + " gmouldtypeid,"
  7605. + " groutinglinedetailid,"
  7606. + " groutingmouldcode,"
  7607. + " mouldcode,"
  7608. + " scrapdate,"
  7609. + " rreason,"
  7610. + " remarks,"
  7611. + " auditstatus,"
  7612. + " auditor,"
  7613. + " auditdate,"
  7614. + " accountdate,"
  7615. + " accountid,"
  7616. + " createuserid,"
  7617. + " updateuserid,"
  7618. + " respontype,GoodsLevelID,GoodsLevelTypeID,"
  7619. + " auditopinion,"
  7620. + " GroutingUserID,"
  7621. + " GroutingUserCode,"
  7622. + " GroutingNum,"
  7623. + " IsPublicBody,"
  7624. + " IsReFire,"
  7625. + " kilnid,"
  7626. + " kilncode,"
  7627. + " kilnname,"
  7628. + " kilncarid,"
  7629. + " kilncarcode,"
  7630. + " kilncarname,"
  7631. + " kilncarbatchno,"
  7632. + " kilncarposition,"
  7633. + " specialRepairflag,"
  7634. + " logoid,ProductionDataID, "
  7635. + " ProcedureID, "
  7636. + " ProcedureCode, "
  7637. + " ProcedureName, "
  7638. + " ScrapType "
  7639. + ")"
  7640. + " select :scrapproductid,trash.barcode,"
  7641. + " trash.productionlineid,"
  7642. + " trash.productionlinecode,"
  7643. + " trash.productionlinename,"
  7644. + " trash.goodsid,"
  7645. + " trash.goodscode,"
  7646. + " trash.goodsname,"
  7647. + " trash.groutingdailyid,"
  7648. + " trash.groutingdailydetailid,"
  7649. + " trash.groutingdate,"
  7650. + " trash.groutinglineid,"
  7651. + " trash.groutinglinecode,"
  7652. + " trash.groutinglinename,"
  7653. + " trash.gmouldtypeid,"
  7654. + " trash.groutinglinedetailid,"
  7655. + " trash.groutingmouldcode,"
  7656. + " trash.mouldcode,"
  7657. + " :scrapdate,"
  7658. + " :rreason,"
  7659. + " :remarks,"
  7660. + " :auditstatus,"
  7661. + " :auditor,"
  7662. // + " :auditdate,"
  7663. + " sysdate,"
  7664. + " :accountdate,"
  7665. + " trash.accountid,"
  7666. + " :createuserid,"
  7667. + " :updateuserid,"
  7668. + " :respontype,:GoodsLevelID,:GoodsLevelTypeID,"
  7669. + " :auditopinion,"
  7670. + " trash.GroutingUserID,"
  7671. + " trash.GroutingUserCode,"
  7672. + " trash.GroutingNum,"
  7673. + " trash.IsPublicBody,"
  7674. + " trash.IsReFire,"
  7675. + " trash.kilnid,"
  7676. + " trash.kilncode,"
  7677. + " trash.kilnname,"
  7678. + " trash.kilncarid,"
  7679. + " trash.kilncarcode,"
  7680. + " trash.kilncarname,"
  7681. + " trash.kilncarbatchno,"
  7682. + " trash.kilncarposition,"
  7683. + " trash.specialRepairflag,"
  7684. + " trash.logoid,:ProductionDataID,"
  7685. + " TP_PC_Procedure.ProcedureID, "
  7686. + " TP_PC_Procedure.ProcedureCode, "
  7687. + " TP_PC_Procedure.ProcedureName, "
  7688. + " :ScrapType "
  7689. + " from tp_pm_inproductiontrash trash"
  7690. + " left join TP_PC_Procedure on trash.FlowProcedureID=TP_PC_Procedure.ProcedureID"
  7691. + " where trash.barcode = :barcode";
  7692. #endregion
  7693. #region 参数
  7694. OracleParameter[] oracleParameters = null;
  7695. oracleParameters = new OracleParameter[] {
  7696. new OracleParameter(":scrapproductid",OracleDbType.Int32,scrapProduct.ScrapProductID,ParameterDirection.Input),
  7697. new OracleParameter(":scrapdate",OracleDbType.Date,scrapProduct.ScrapDate,ParameterDirection.Input),
  7698. new OracleParameter(":rreason",OracleDbType.Varchar2,scrapProduct.Rreason,ParameterDirection.Input),
  7699. new OracleParameter(":remarks",OracleDbType.Varchar2,scrapProduct.Remarks,ParameterDirection.Input),
  7700. new OracleParameter(":auditstatus",OracleDbType.Int32,scrapProduct.AuditStatus,ParameterDirection.Input),
  7701. new OracleParameter(":auditor",OracleDbType.Int32,scrapProduct.Auditor,ParameterDirection.Input),
  7702. //new OracleParameter(":auditdate",OracleDbType.Date,scrapProduct.AuditlDate,ParameterDirection.Input),
  7703. new OracleParameter(":accountdate",OracleDbType.Date,scrapProduct.AccountDate,ParameterDirection.Input),
  7704. new OracleParameter(":createuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  7705. new OracleParameter(":updateuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  7706. new OracleParameter(":respontype",OracleDbType.Varchar2,scrapProduct.ResponType,ParameterDirection.Input),
  7707. new OracleParameter(":auditopinion",OracleDbType.Varchar2,scrapProduct.AuditOpinion,ParameterDirection.Input),
  7708. new OracleParameter(":barcode",OracleDbType.Varchar2,scrapProduct.BarCode,ParameterDirection.Input),
  7709. new OracleParameter(":GoodsLevelID",OracleDbType.Int32,scrapProduct.GoodsLevelID,ParameterDirection.Input),
  7710. new OracleParameter(":GoodsLevelTypeID",OracleDbType.Int32,scrapProduct.GoodsLevelTypeID,ParameterDirection.Input),
  7711. new OracleParameter(":ScrapType",OracleDbType.Int32,scrapProduct.ScrapType,ParameterDirection.Input),
  7712. new OracleParameter(":ProductionDataID",OracleDbType.Int32,scrapProduct.ProductionDataID,ParameterDirection.Input),
  7713. };
  7714. #endregion
  7715. int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  7716. // result += oracleTrConn.ExecuteNonQuery(sql2, oracleParameters);
  7717. //// 保存失败
  7718. //if (result != Constant.INT_IS_ONE)
  7719. //{
  7720. // return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  7721. //}
  7722. return null;
  7723. }
  7724. /// <summary>
  7725. /// 保存废弃产品
  7726. /// </summary>
  7727. /// <param name="oracleTrConn">连接对象</param>
  7728. /// <param name="scrapProduct">报废产品</param>
  7729. /// <param name="sUserInfo">用户基本信息</param>
  7730. /// <returns>string</returns>
  7731. private static string AddScrapProduct(IDBTransaction oracleTrConn, ScrapProductEntity scrapProduct, SUserInfo sUserInfo)
  7732. {
  7733. #region sql
  7734. string sql = "insert into tp_pm_scrapproduct"
  7735. + " (scrapproductid,barcode,"
  7736. + " productionlineid,"
  7737. + " productionlinecode,"
  7738. + " productionlinename,"
  7739. + " goodsid,"
  7740. + " goodscode,"
  7741. + " goodsname,"
  7742. + " groutingdailyid,"
  7743. + " groutingdailydetailid,"
  7744. + " groutingdate,"
  7745. + " groutinglineid,"
  7746. + " groutinglinecode,"
  7747. + " groutinglinename,"
  7748. + " gmouldtypeid,"
  7749. + " groutinglinedetailid,"
  7750. + " groutingmouldcode,"
  7751. + " mouldcode,"
  7752. + " scrapdate,"
  7753. + " rreason,"
  7754. + " remarks,"
  7755. + " auditstatus,"
  7756. + " auditor,"
  7757. + " auditdate,"
  7758. + " accountdate,"
  7759. + " accountid,"
  7760. + " createuserid,"
  7761. + " updateuserid,"
  7762. + " respontype,GoodsLevelID,GoodsLevelTypeID,"
  7763. + " auditopinion,"
  7764. + " GroutingUserID,"
  7765. + " GroutingUserCode,"
  7766. + " GroutingNum,"
  7767. + " IsPublicBody,"
  7768. + " IsReFire,"
  7769. + " kilnid,"
  7770. + " kilncode,"
  7771. + " kilnname,"
  7772. + " kilncarid,"
  7773. + " kilncarcode,"
  7774. + " kilncarname,"
  7775. + " kilncarbatchno,"
  7776. + " kilncarposition,"
  7777. + " specialRepairflag,"
  7778. + " logoid,"
  7779. + " ProductionDataID, "
  7780. + " ProcedureID, "
  7781. + " ProcedureCode, "
  7782. + " ProcedureName, "
  7783. + " ScrapType "
  7784. + ")"
  7785. + " select :scrapproductid,barcode,"
  7786. + " InProduction.productionlineid,"
  7787. + " InProduction.productionlinecode,"
  7788. + " InProduction.productionlinename,"
  7789. + " InProduction.goodsid,"
  7790. + " InProduction.goodscode,"
  7791. + " InProduction.goodsname,"
  7792. + " InProduction.groutingdailyid,"
  7793. + " InProduction.groutingdailydetailid,"
  7794. + " InProduction.groutingdate,"
  7795. + " InProduction.groutinglineid,"
  7796. + " InProduction.groutinglinecode,"
  7797. + " InProduction.groutinglinename,"
  7798. + " InProduction.gmouldtypeid,"
  7799. + " InProduction.groutinglinedetailid,"
  7800. + " InProduction.groutingmouldcode,"
  7801. + " InProduction.mouldcode,"
  7802. + " :scrapdate,"
  7803. + " :rreason,"
  7804. + " :remarks,"
  7805. + " :auditstatus,"
  7806. + " :auditor,"
  7807. // + " :auditdate,"
  7808. + " sysdate,"
  7809. + " :accountdate,"
  7810. + " InProduction.accountid,"
  7811. + " :createuserid,"
  7812. + " :updateuserid,"
  7813. + " :respontype,:GoodsLevelID,:GoodsLevelTypeID,"
  7814. + " :auditopinion,"
  7815. + " InProduction.GroutingUserID,"
  7816. + " InProduction.GroutingUserCode,"
  7817. + " InProduction.GroutingNum,"
  7818. + " InProduction.IsPublicBody,"
  7819. + " InProduction.IsReFire,"
  7820. + " InProduction.kilnid,"
  7821. + " InProduction.kilncode,"
  7822. + " InProduction.kilnname,"
  7823. + " InProduction.kilncarid,"
  7824. + " InProduction.kilncarcode,"
  7825. + " InProduction.kilncarname,"
  7826. + " InProduction.kilncarbatchno,"
  7827. + " InProduction.kilncarposition,"
  7828. + " InProduction.specialRepairflag,"
  7829. + " InProduction.logoid,";
  7830. if (scrapProduct.IsQualityStatistics == null)
  7831. {
  7832. sql += " InProduction.ProductionDataID,";
  7833. }
  7834. else
  7835. {
  7836. sql += " :ProductionDataID,";
  7837. }
  7838. sql += " TP_PC_Procedure.ProcedureID, "
  7839. + " TP_PC_Procedure.ProcedureCode, "
  7840. + " TP_PC_Procedure.ProcedureName, "
  7841. + " :ScrapType"
  7842. + " from TP_PM_InProduction InProduction"
  7843. + " left join TP_PC_Procedure on InProduction.FlowProcedureID=TP_PC_Procedure.ProcedureID"
  7844. + " where InProduction.barcode = :barcode";
  7845. #endregion
  7846. #region 参数
  7847. OracleParameter[] oracleParameters = null;
  7848. if (scrapProduct.IsQualityStatistics == null)
  7849. {
  7850. oracleParameters = new OracleParameter[] {
  7851. new OracleParameter(":scrapproductid",OracleDbType.Int32,scrapProduct.ScrapProductID,ParameterDirection.Input),
  7852. new OracleParameter(":scrapdate",OracleDbType.Date,scrapProduct.ScrapDate,ParameterDirection.Input),
  7853. new OracleParameter(":rreason",OracleDbType.Varchar2,scrapProduct.Rreason,ParameterDirection.Input),
  7854. new OracleParameter(":remarks",OracleDbType.Varchar2,scrapProduct.Remarks,ParameterDirection.Input),
  7855. new OracleParameter(":auditstatus",OracleDbType.Int32,scrapProduct.AuditStatus,ParameterDirection.Input),
  7856. new OracleParameter(":auditor",OracleDbType.Int32,scrapProduct.Auditor,ParameterDirection.Input),
  7857. //new OracleParameter(":auditdate",OracleDbType.Date,scrapProduct.AuditlDate,ParameterDirection.Input),
  7858. new OracleParameter(":accountdate",OracleDbType.Date,scrapProduct.AccountDate,ParameterDirection.Input),
  7859. new OracleParameter(":createuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  7860. new OracleParameter(":updateuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  7861. new OracleParameter(":respontype",OracleDbType.Varchar2,scrapProduct.ResponType,ParameterDirection.Input),
  7862. new OracleParameter(":auditopinion",OracleDbType.Varchar2,scrapProduct.AuditOpinion,ParameterDirection.Input),
  7863. new OracleParameter(":barcode",OracleDbType.Varchar2,scrapProduct.BarCode,ParameterDirection.Input),
  7864. new OracleParameter(":GoodsLevelID",OracleDbType.Int32,scrapProduct.GoodsLevelID,ParameterDirection.Input),
  7865. new OracleParameter(":GoodsLevelTypeID",OracleDbType.Int32,scrapProduct.GoodsLevelTypeID,ParameterDirection.Input),
  7866. new OracleParameter(":ScrapType",OracleDbType.Int32,scrapProduct.ScrapType,ParameterDirection.Input),
  7867. };
  7868. }
  7869. else
  7870. {
  7871. oracleParameters = new OracleParameter[] {
  7872. new OracleParameter(":scrapproductid",OracleDbType.Int32,scrapProduct.ScrapProductID,ParameterDirection.Input),
  7873. new OracleParameter(":scrapdate",OracleDbType.Date,scrapProduct.ScrapDate,ParameterDirection.Input),
  7874. new OracleParameter(":rreason",OracleDbType.Varchar2,scrapProduct.Rreason,ParameterDirection.Input),
  7875. new OracleParameter(":remarks",OracleDbType.Varchar2,scrapProduct.Remarks,ParameterDirection.Input),
  7876. new OracleParameter(":auditstatus",OracleDbType.Int32,scrapProduct.AuditStatus,ParameterDirection.Input),
  7877. new OracleParameter(":auditor",OracleDbType.Int32,scrapProduct.Auditor,ParameterDirection.Input),
  7878. //new OracleParameter(":auditdate",OracleDbType.Date,scrapProduct.AuditlDate,ParameterDirection.Input),
  7879. new OracleParameter(":accountdate",OracleDbType.Date,scrapProduct.AccountDate,ParameterDirection.Input),
  7880. new OracleParameter(":createuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  7881. new OracleParameter(":updateuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  7882. new OracleParameter(":respontype",OracleDbType.Varchar2,scrapProduct.ResponType,ParameterDirection.Input),
  7883. new OracleParameter(":auditopinion",OracleDbType.Varchar2,scrapProduct.AuditOpinion,ParameterDirection.Input),
  7884. new OracleParameter(":barcode",OracleDbType.Varchar2,scrapProduct.BarCode,ParameterDirection.Input),
  7885. new OracleParameter(":GoodsLevelID",OracleDbType.Int32,scrapProduct.GoodsLevelID,ParameterDirection.Input),
  7886. new OracleParameter(":GoodsLevelTypeID",OracleDbType.Int32,scrapProduct.GoodsLevelTypeID,ParameterDirection.Input),
  7887. new OracleParameter(":ScrapType",OracleDbType.Int32,scrapProduct.ScrapType,ParameterDirection.Input),
  7888. new OracleParameter(":ProductionDataID",OracleDbType.Int32,scrapProduct.ProductionDataID,ParameterDirection.Input),
  7889. };
  7890. }
  7891. #endregion
  7892. int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  7893. if (result == 0)
  7894. {
  7895. sql = "insert into tp_pm_scrapproduct"
  7896. + " (scrapproductid,barcode,"
  7897. + " productionlineid,"
  7898. + " productionlinecode,"
  7899. + " productionlinename,"
  7900. + " goodsid,"
  7901. + " goodscode,"
  7902. + " goodsname,"
  7903. + " groutingdailyid,"
  7904. + " groutingdailydetailid,"
  7905. + " groutingdate,"
  7906. + " groutinglineid,"
  7907. + " groutinglinecode,"
  7908. + " groutinglinename,"
  7909. + " gmouldtypeid,"
  7910. + " groutinglinedetailid,"
  7911. + " groutingmouldcode,"
  7912. + " mouldcode,"
  7913. + " scrapdate,"
  7914. + " rreason,"
  7915. + " remarks,"
  7916. + " auditstatus,"
  7917. + " auditor,"
  7918. + " auditdate,"
  7919. + " accountdate,"
  7920. + " accountid,"
  7921. + " createuserid,"
  7922. + " updateuserid,"
  7923. + " respontype,GoodsLevelID,GoodsLevelTypeID,"
  7924. + " auditopinion,"
  7925. + " GroutingUserID,"
  7926. + " GroutingUserCode,"
  7927. + " GroutingNum,"
  7928. + " IsPublicBody,"
  7929. + " IsReFire,"
  7930. + " kilnid,"
  7931. + " kilncode,"
  7932. + " kilnname,"
  7933. + " kilncarid,"
  7934. + " kilncarcode,"
  7935. + " kilncarname,"
  7936. + " kilncarbatchno,"
  7937. + " kilncarposition,"
  7938. + " specialRepairflag,"
  7939. + " logoid,"
  7940. + " ProductionDataID,"
  7941. + " ProcedureID, "
  7942. + " ProcedureCode, "
  7943. + " ProcedureName, "
  7944. + " ScrapType "
  7945. + ")"
  7946. + " select :scrapproductid,trash.barcode,"
  7947. + " trash.productionlineid,"
  7948. + " trash.productionlinecode,"
  7949. + " trash.productionlinename,"
  7950. + " trash.goodsid,"
  7951. + " trash.goodscode,"
  7952. + " trash.goodsname,"
  7953. + " trash.groutingdailyid,"
  7954. + " trash.groutingdailydetailid,"
  7955. + " trash.groutingdate,"
  7956. + " trash.groutinglineid,"
  7957. + " trash.groutinglinecode,"
  7958. + " trash.groutinglinename,"
  7959. + " trash.gmouldtypeid,"
  7960. + " trash.groutinglinedetailid,"
  7961. + " trash.groutingmouldcode,"
  7962. + " trash.mouldcode,"
  7963. + " :scrapdate,"
  7964. + " :rreason,"
  7965. + " :remarks,"
  7966. + " :auditstatus,"
  7967. + " :auditor,"
  7968. //+ " :auditdate,"
  7969. + " sysdate,"
  7970. + " :accountdate,"
  7971. + " trash.accountid,"
  7972. + " :createuserid,"
  7973. + " :updateuserid,"
  7974. + " :respontype,:GoodsLevelID,:GoodsLevelTypeID,"
  7975. + " :auditopinion,"
  7976. + " trash.GroutingUserID,"
  7977. + " trash.GroutingUserCode,"
  7978. + " trash.GroutingNum,"
  7979. + " trash.IsPublicBody,"
  7980. + " trash.IsReFire,"
  7981. + " trash.kilnid,"
  7982. + " trash.kilncode,"
  7983. + " trash.kilnname,"
  7984. + " trash.kilncarid,"
  7985. + " trash.kilncarcode,"
  7986. + " trash.kilncarname,"
  7987. + " trash.kilncarbatchno,"
  7988. + " trash.kilncarposition,"
  7989. + " trash.specialRepairflag,"
  7990. + " trash.logoid,";
  7991. if (scrapProduct.IsQualityStatistics == null)
  7992. {
  7993. sql += " trash.ProductionDataID,";
  7994. }
  7995. else
  7996. {
  7997. sql += " :ProductionDataID,";
  7998. }
  7999. sql += //" trash.ProductionDataID," +
  8000. " TP_PC_Procedure.ProcedureID, "
  8001. + " TP_PC_Procedure.ProcedureCode, "
  8002. + " TP_PC_Procedure.ProcedureName, "
  8003. + " :ScrapType "
  8004. + " from TP_PM_InProductionTrash trash"
  8005. + " left join TP_PC_Procedure on trash.FlowProcedureID=TP_PC_Procedure.ProcedureID"
  8006. + " where trash.barcode = :barcode";
  8007. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  8008. }
  8009. // result += oracleTrConn.ExecuteNonQuery(sql2, oracleParameters);
  8010. //// 保存失败
  8011. //if (result != Constant.INT_IS_ONE)
  8012. //{
  8013. // return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  8014. //}
  8015. return null;
  8016. }
  8017. /// <summary>
  8018. /// 保存缺陷
  8019. /// </summary>
  8020. /// <param name="oracleTrConn">连接对象</param>
  8021. /// <param name="productionDefect">缺陷数据</param>
  8022. /// <param name="sUserInfo">用户基本信息</param>
  8023. /// <returns>string</returns>
  8024. private static string AddDefect(IDBTransaction oracleTrConn, ProductionDefectEntity productionDefect, SUserInfo sUserInfo)
  8025. {
  8026. // 查询新插入的生产数据ID
  8027. string sql = "select SEQ_PM_Defect_DefectID.nextval from dual";
  8028. string idStr = oracleTrConn.GetSqlResultToStr(sql);
  8029. int productionDefectID = 0;
  8030. if (!string.IsNullOrEmpty(idStr))
  8031. {
  8032. productionDefectID = int.Parse(idStr);
  8033. }
  8034. else
  8035. {
  8036. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  8037. }
  8038. #region SQL
  8039. sql = "insert into tp_pm_defect"
  8040. + " ( ProductionDefectID,"
  8041. + " productiondataid,"
  8042. + " barcode,"
  8043. + " productionlineid,"
  8044. + " productionlinecode,"
  8045. + " productionlinename,"
  8046. + " procedureid,"
  8047. + " procedurecode,"
  8048. + " procedurename,"
  8049. + " userid,"
  8050. + " usercode,"
  8051. + " username,"
  8052. + " goodsid,"
  8053. + " goodscode,"
  8054. + " goodsname,"
  8055. + " defectid,"
  8056. + " defectcode,"
  8057. + " defectname,"
  8058. + " defectpositionid,"
  8059. + " defectpositioncode,"
  8060. + " defectpositionname,"
  8061. + " scrapResponFlag,"
  8062. + " defectproductiondataid,"
  8063. + " defectprocedureid,"
  8064. + " defectprocedurecode,"
  8065. + " defectprocedurename,"
  8066. + " defectuserid,"
  8067. + " defectusercode,"
  8068. + " defectusername,"
  8069. + " defectjobs,"
  8070. + " remarks,"
  8071. + " accountid,"
  8072. + " createuserid,"
  8073. + " defectfine,"
  8074. + " misseduserid,"
  8075. + " missedusercode,"
  8076. + " missedusername,"
  8077. + " updateuserid,SpecialDefect,DefectDeductionNum,CheckTime)"
  8078. + " values"
  8079. + " ("
  8080. + " :ProductionDefectID,"
  8081. + " :productiondataid,"
  8082. + " :barcode,"
  8083. + " :productionlineid,"
  8084. + " :productionlinecode,"
  8085. + " :productionlinename,"
  8086. + " :procedureid,"
  8087. + " :procedurecode,"
  8088. + " :procedurename,"
  8089. + " :userid,"
  8090. + " :usercode,"
  8091. + " :username,"
  8092. + " :goodsid,"
  8093. + " :goodscode,"
  8094. + " :goodsname,"
  8095. + " :defectid,"
  8096. + " :defectcode,"
  8097. + " :defectname,"
  8098. + " :defectpositionid,"
  8099. + " :defectpositioncode,"
  8100. + " :defectpositionname,"
  8101. + " :scrapResponFlag,"
  8102. + " :defectproductiondataid,"
  8103. + " :defectprocedureid,"
  8104. + " :defectprocedurecode,"
  8105. + " :defectprocedurename,"
  8106. + " :defectuserid,"
  8107. + " :defectusercode,"
  8108. + " :defectusername,"
  8109. + " :defectjobs,"
  8110. + " :remarks,"
  8111. + " :accountid,"
  8112. + " :createuserid,"
  8113. + " :defectfine,"
  8114. + " :misseduserid,"
  8115. + " :missedusercode,"
  8116. + " :missedusername,"
  8117. + " :updateuserid,:SpecialDefect,:DefectDeductionNum,:CheckTime)";
  8118. #endregion
  8119. #region 参数
  8120. OracleParameter[] oracleParameters = null;
  8121. if (productionDefect.IsPDA == null)
  8122. {
  8123. oracleParameters = new OracleParameter[] {
  8124. new OracleParameter(":ProductionDefectID",productionDefectID),
  8125. new OracleParameter(":productiondataid",productionDefect.ProductionDataID),
  8126. new OracleParameter(":barcode",productionDefect.BarCode),
  8127. new OracleParameter(":productionlineid",productionDefect.ProductionLineID),
  8128. new OracleParameter(":productionlinecode",productionDefect.ProductionLineCode),
  8129. new OracleParameter(":productionlinename",productionDefect.ProductionLineName),
  8130. new OracleParameter(":procedureid",productionDefect.ProcedureID),
  8131. new OracleParameter(":procedurecode",productionDefect.ProcedureCode),
  8132. new OracleParameter(":procedurename",productionDefect.ProcedureName),
  8133. new OracleParameter(":userid",productionDefect.UserID),
  8134. new OracleParameter(":usercode",productionDefect.UserCode),
  8135. new OracleParameter(":username",productionDefect.UserName),
  8136. new OracleParameter(":goodsid",productionDefect.GoodsID),
  8137. new OracleParameter(":goodscode",productionDefect.GoodsCode),
  8138. new OracleParameter(":goodsname",productionDefect.GoodsName),
  8139. new OracleParameter(":defectid",productionDefect.DefectID),
  8140. new OracleParameter(":defectcode",productionDefect.DefectCode),
  8141. new OracleParameter(":defectname",productionDefect.DefectName),
  8142. new OracleParameter(":defectpositionid",productionDefect.DefectPositionID),
  8143. new OracleParameter(":defectpositioncode",productionDefect.DefectPositionCode),
  8144. new OracleParameter(":defectpositionname",productionDefect.DefectPositionName),
  8145. new OracleParameter(":scrapResponFlag",productionDefect.ScrapResponFlag),
  8146. new OracleParameter(":defectproductiondataid",productionDefect.DefectProductionDataID),
  8147. new OracleParameter(":defectprocedureid",productionDefect.DefectProcedureID),
  8148. new OracleParameter(":defectprocedurecode",productionDefect.DefectProcedureCode),
  8149. new OracleParameter(":defectprocedurename",productionDefect.DefectProcedureName),
  8150. new OracleParameter(":defectuserid",productionDefect.DefectUserID),
  8151. new OracleParameter(":defectusercode",productionDefect.DefectUserCode),
  8152. new OracleParameter(":defectusername",productionDefect.DefectUserName),
  8153. new OracleParameter(":defectjobs",productionDefect.DefectJobs),
  8154. new OracleParameter(":remarks",productionDefect.Remarks),
  8155. new OracleParameter(":accountid",sUserInfo.AccountID),
  8156. new OracleParameter(":createuserid",sUserInfo.UserID),
  8157. new OracleParameter(":defectfine",productionDefect.DefectFine),
  8158. new OracleParameter(":misseduserid",productionDefect.MissedUserID),
  8159. new OracleParameter(":missedusercode",productionDefect.MissedUserCode),
  8160. new OracleParameter(":missedusername",productionDefect.MissedUserName),
  8161. new OracleParameter(":updateuserid",sUserInfo.UserID),
  8162. new OracleParameter(":SpecialDefect",productionDefect.SpecialDefect==null?"0":productionDefect.SpecialDefect),
  8163. new OracleParameter(":DefectDeductionNum",productionDefect.DefectDeductionNum==null?0:productionDefect.DefectDeductionNum),
  8164. new OracleParameter(":CheckTime",productionDefect.CheckTime.ToString()==string.Empty?null:productionDefect.CheckTime),
  8165. };
  8166. }
  8167. else
  8168. {
  8169. DateTime? pdaCheckTime = null;
  8170. if (productionDefect.PDACheckTime != null)
  8171. {
  8172. if (productionDefect.PDACheckTime.ToString() != string.Empty)
  8173. {
  8174. pdaCheckTime = Convert.ToDateTime(productionDefect.PDACheckTime);
  8175. }
  8176. }
  8177. oracleParameters = new OracleParameter[] {
  8178. new OracleParameter(":ProductionDefectID",productionDefectID),
  8179. new OracleParameter(":productiondataid",productionDefect.ProductionDataID),
  8180. new OracleParameter(":barcode",productionDefect.BarCode),
  8181. new OracleParameter(":productionlineid",productionDefect.ProductionLineID),
  8182. new OracleParameter(":productionlinecode",productionDefect.ProductionLineCode),
  8183. new OracleParameter(":productionlinename",productionDefect.ProductionLineName),
  8184. new OracleParameter(":procedureid",productionDefect.ProcedureID),
  8185. new OracleParameter(":procedurecode",productionDefect.ProcedureCode),
  8186. new OracleParameter(":procedurename",productionDefect.ProcedureName),
  8187. new OracleParameter(":userid",productionDefect.UserID),
  8188. new OracleParameter(":usercode",productionDefect.UserCode),
  8189. new OracleParameter(":username",productionDefect.UserName),
  8190. new OracleParameter(":goodsid",productionDefect.GoodsID),
  8191. new OracleParameter(":goodscode",productionDefect.GoodsCode),
  8192. new OracleParameter(":goodsname",productionDefect.GoodsName),
  8193. new OracleParameter(":defectid",productionDefect.DefectID),
  8194. new OracleParameter(":defectcode",productionDefect.DefectCode),
  8195. new OracleParameter(":defectname",productionDefect.DefectName),
  8196. new OracleParameter(":defectpositionid",productionDefect.DefectPositionID),
  8197. new OracleParameter(":defectpositioncode",productionDefect.DefectPositionCode),
  8198. new OracleParameter(":defectpositionname",productionDefect.DefectPositionName),
  8199. new OracleParameter(":scrapResponFlag",productionDefect.ScrapResponFlag),
  8200. new OracleParameter(":defectproductiondataid",productionDefect.DefectProductionDataID),
  8201. new OracleParameter(":defectprocedureid",productionDefect.DefectProcedureID),
  8202. new OracleParameter(":defectprocedurecode",productionDefect.DefectProcedureCode),
  8203. new OracleParameter(":defectprocedurename",productionDefect.DefectProcedureName),
  8204. new OracleParameter(":defectuserid",productionDefect.DefectUserID),
  8205. new OracleParameter(":defectusercode",productionDefect.DefectUserCode),
  8206. new OracleParameter(":defectusername",productionDefect.DefectUserName),
  8207. new OracleParameter(":defectjobs",productionDefect.DefectJobs),
  8208. new OracleParameter(":remarks",productionDefect.Remarks),
  8209. new OracleParameter(":accountid",sUserInfo.AccountID),
  8210. new OracleParameter(":createuserid",sUserInfo.UserID),
  8211. new OracleParameter(":defectfine",productionDefect.DefectFine),
  8212. new OracleParameter(":misseduserid",productionDefect.MissedUserID),
  8213. new OracleParameter(":missedusercode",productionDefect.MissedUserCode),
  8214. new OracleParameter(":missedusername",productionDefect.MissedUserName),
  8215. new OracleParameter(":updateuserid",sUserInfo.UserID),
  8216. new OracleParameter(":SpecialDefect",productionDefect.SpecialDefect==null?"0":productionDefect.SpecialDefect),
  8217. new OracleParameter(":DefectDeductionNum",productionDefect.DefectDeductionNum==null?0:productionDefect.DefectDeductionNum),
  8218. new OracleParameter(":CheckTime",pdaCheckTime),
  8219. };
  8220. }
  8221. #endregion
  8222. int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  8223. // 保存失败
  8224. if (result != Constant.INT_IS_ONE)
  8225. {
  8226. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  8227. }
  8228. //// 查询新插入的生产数据ID
  8229. //sql = "select SEQ_PM_Defect_DefectID.Currval from dual";
  8230. //string idStr = oracleTrConn.GetSqlResultToStr(sql);
  8231. //int productionDefectID = 0;
  8232. //if (!string.IsNullOrEmpty(idStr))
  8233. //{
  8234. // productionDefectID = int.Parse(idStr);
  8235. //}
  8236. //else
  8237. //{
  8238. // return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  8239. //}
  8240. #region 插入生产缺陷责任者
  8241. if (productionDefect.DefectResponsibles != null)
  8242. {
  8243. foreach (DefectResponsibleEntity DefectResponsible in productionDefect.DefectResponsibles)
  8244. {
  8245. #region SQL
  8246. sql = "insert into tp_pm_defectresponsible"
  8247. + " (productiondefectid,"
  8248. + " staffid,"
  8249. + " userid,"
  8250. + " usercode,"
  8251. + " Ujobsid,"
  8252. + " SJobsID,"
  8253. + " staffstatus,"
  8254. + " accountid,"
  8255. + " createuserid,"
  8256. + " updateuserid)"
  8257. + " values"
  8258. + " (:productiondefectid,"
  8259. + " :staffid,"
  8260. + " :userid,"
  8261. + " :usercode,"
  8262. + " :ujobsid,"
  8263. + " :sjobsid,"
  8264. + " :staffstatus,"
  8265. + " :accountid,"
  8266. + " :createuserid,"
  8267. + " :updateuserid)";
  8268. #endregion
  8269. #region 参数
  8270. oracleParameters = new OracleParameter[] {
  8271. new OracleParameter(":productiondefectid",productionDefectID),
  8272. new OracleParameter(":staffid",DefectResponsible.StaffID),
  8273. new OracleParameter(":userid",DefectResponsible.UserID),
  8274. new OracleParameter(":usercode",DefectResponsible.UserCode),
  8275. new OracleParameter(":ujobsid",DefectResponsible.UJobsID),
  8276. new OracleParameter(":sjobsid",DefectResponsible.SJobsID),
  8277. new OracleParameter(":staffstatus",DefectResponsible.StaffStatus),
  8278. new OracleParameter(":accountid",sUserInfo.AccountID),
  8279. new OracleParameter(":createuserid",sUserInfo.UserID),
  8280. new OracleParameter(":updateuserid",sUserInfo.UserID),
  8281. };
  8282. #endregion
  8283. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  8284. // 保存失败
  8285. if (result != Constant.INT_IS_ONE)
  8286. {
  8287. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  8288. }
  8289. }
  8290. }
  8291. #endregion
  8292. #region 插入生产漏检缺陷责任者
  8293. if (productionDefect.DefectMissedResponsibles != null)
  8294. {
  8295. foreach (DefectMissedResponsibleEntity DefectMissedResponsible in productionDefect.DefectMissedResponsibles)
  8296. {
  8297. #region SQL
  8298. sql = "insert into TP_PM_DefectMissedResponsible"
  8299. + " (productiondefectid,"
  8300. + " staffid,"
  8301. + " userid,"
  8302. + " usercode,"
  8303. + " Ujobsid,"
  8304. + " SJobsID,"
  8305. + " staffstatus,"
  8306. + " accountid,"
  8307. + " createuserid,"
  8308. + " updateuserid)"
  8309. + " values"
  8310. + " (:productiondefectid,"
  8311. + " :staffid,"
  8312. + " :userid,"
  8313. + " :usercode,"
  8314. + " :ujobsid,"
  8315. + " :sjobsid,"
  8316. + " :staffstatus,"
  8317. + " :accountid,"
  8318. + " :createuserid,"
  8319. + " :updateuserid)";
  8320. #endregion
  8321. #region 参数
  8322. oracleParameters = new OracleParameter[] {
  8323. new OracleParameter(":productiondefectid",productionDefectID),
  8324. new OracleParameter(":staffid",DefectMissedResponsible.StaffID),
  8325. new OracleParameter(":userid",DefectMissedResponsible.UserID),
  8326. new OracleParameter(":usercode",DefectMissedResponsible.UserCode),
  8327. new OracleParameter(":ujobsid",DefectMissedResponsible.UJobsID),
  8328. new OracleParameter(":sjobsid",DefectMissedResponsible.SJobsID),
  8329. new OracleParameter(":staffstatus",DefectMissedResponsible.StaffStatus),
  8330. new OracleParameter(":accountid",sUserInfo.AccountID),
  8331. new OracleParameter(":createuserid",sUserInfo.UserID),
  8332. new OracleParameter(":updateuserid",sUserInfo.UserID),
  8333. };
  8334. #endregion
  8335. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  8336. // 保存失败
  8337. if (result != Constant.INT_IS_ONE)
  8338. {
  8339. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  8340. }
  8341. }
  8342. }
  8343. #endregion
  8344. #region 添加图片
  8345. if (productionDefect.DefectImages != null)
  8346. {
  8347. DateTime upTime = DateTime.Now;
  8348. foreach (DefectImageEntity defectImage in productionDefect.DefectImages)
  8349. {
  8350. // 图片路径为空。上传图片返回路径
  8351. if (string.IsNullOrEmpty(defectImage.ImagePath))
  8352. {
  8353. defectImage.ImagePath = CommonModuleLogic.CommonModuleLogic
  8354. .UpLoadImg(Constant.SYSTEM_MODULE_PM, upTime, defectImage.Image);
  8355. defectImage.ThumbnailPath = CommonModuleLogic.CommonModuleLogic
  8356. .ConvertThumbnail(Constant.SYSTEM_MODULE_PM, upTime, defectImage.Image);
  8357. }
  8358. else
  8359. {
  8360. // 安卓端上传的图片
  8361. defectImage.ImagePath = CommonModuleLogic.CommonModuleLogic
  8362. .MoveImg(Constant.SYSTEM_MODULE_PM, upTime, defectImage.ImagePath);
  8363. defectImage.ThumbnailPath = CommonModuleLogic.CommonModuleLogic
  8364. .ConvertThumbnail(Constant.SYSTEM_MODULE_PM, upTime, defectImage.ImagePath);
  8365. }
  8366. #region 保存图片
  8367. sql = "insert into tp_pm_defectimage"
  8368. + " ("
  8369. + " productiondefectid,"
  8370. + " barcode,"
  8371. + " thumbnailpath,"
  8372. + " imagepath,"
  8373. + " accountid,"
  8374. + " createuserid,"
  8375. + " updateuserid)"
  8376. + " values"
  8377. + " ("
  8378. + " :productiondefectid,"
  8379. + " :barcode,"
  8380. + " :thumbnailpath,"
  8381. + " :imagepath,"
  8382. + " :accountid,"
  8383. + " :createuserid,"
  8384. + " :updateuserid)";
  8385. oracleParameters = new OracleParameter[] {
  8386. new OracleParameter(":productiondefectid",productionDefectID),
  8387. new OracleParameter(":barcode",productionDefect.BarCode),
  8388. new OracleParameter(":thumbnailpath",defectImage.ThumbnailPath),
  8389. new OracleParameter(":imagepath",defectImage.ImagePath),
  8390. new OracleParameter(":accountid",sUserInfo.AccountID),
  8391. new OracleParameter(":createuserid",sUserInfo.UserID),
  8392. new OracleParameter(":updateuserid",sUserInfo.UserID),
  8393. };
  8394. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  8395. // 保存失败
  8396. if (result != Constant.INT_IS_ONE)
  8397. {
  8398. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  8399. }
  8400. #endregion
  8401. }
  8402. }
  8403. #endregion
  8404. // 保存成功返回null
  8405. return null;
  8406. }
  8407. #endregion
  8408. #region 进度考核奖惩
  8409. /// <summary>
  8410. /// 根据传入的实体保存 进度考核奖惩记录
  8411. /// </summary>
  8412. /// <param name="pAdminRAPEntity">进度考核奖惩实体</param>
  8413. /// <param name="sUserInfo">用户基本信息</param>
  8414. /// <param name="pStatus">新增还是编辑枚举</param>
  8415. /// <returns>PMResultEntity操作结果状态信息</returns>
  8416. public static PMResultEntity SaveStaffProgressRAPInfo(PMProgressRAPEntity pProgressRAPEntity, SUserInfo sUserInfo, WCFConstant.FormMode pStatus)
  8417. {
  8418. PMResultEntity resultEnity = new PMResultEntity();
  8419. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  8420. try
  8421. {
  8422. if (pProgressRAPEntity == null)
  8423. {
  8424. resultEnity.OperateStatus = 0;
  8425. return resultEnity;
  8426. }
  8427. oracleTrConn.Connect();
  8428. if (pStatus == WCFConstant.FormMode.Add)
  8429. {
  8430. string strSeq = oracleTrConn.GetSqlResultToStr("Select SEQ_PM_ProgressRAP_RAPID.nextval from dual");
  8431. #region 新建时插入数据
  8432. string strSql1 = "Insert Into TP_PM_ProgressRAP (RAPID,"
  8433. + "STAFFID"
  8434. + ",RAPTYPE"
  8435. + ",REASON"
  8436. + ",RAPDATE"
  8437. + ",RAPAMOUNT"
  8438. + ",REMARKS"
  8439. + ",AUDITSTATUS"
  8440. + ",ACCOUNTID"
  8441. + ",CREATEUSERID"
  8442. + ",UPDATEUSERID)"
  8443. + " Values ("
  8444. + ":RAPID"
  8445. + ",:pSTAFFID"
  8446. + ",:pRAPTYPE"
  8447. + ",:pREASON"
  8448. + ",:pRAPDATE"
  8449. + ",:pRAPAMOUNT"
  8450. + ",:pREMARKS"
  8451. + ",:pAUDITSTATUS"
  8452. + ",:pACCOUNTID"
  8453. + ",:pCREATEUSERID"
  8454. + ",:pUPDATEUSERID"
  8455. + ")";
  8456. OracleParameter[] parmetersSql1 = new OracleParameter[]
  8457. {
  8458. new OracleParameter(":RAPID", OracleDbType.Int32, Convert.ToInt32(strSeq) , ParameterDirection.Input),
  8459. new OracleParameter(":pSTAFFID", OracleDbType.Int32, pProgressRAPEntity.StaffID , ParameterDirection.Input),
  8460. new OracleParameter(":pRAPTYPE", OracleDbType.Double, pProgressRAPEntity.RAPType , ParameterDirection.Input),
  8461. new OracleParameter(":pREASON", OracleDbType.Varchar2, pProgressRAPEntity.Reason , ParameterDirection.Input),
  8462. new OracleParameter(":pRAPDATE", OracleDbType.Date, pProgressRAPEntity.RAPDate , ParameterDirection.Input),
  8463. new OracleParameter(":pRAPAMOUNT", OracleDbType.Double, pProgressRAPEntity.RAPAmount , ParameterDirection.Input),
  8464. new OracleParameter(":pREMARKS", OracleDbType.Varchar2, pProgressRAPEntity.Remarks , ParameterDirection.Input),
  8465. new OracleParameter(":pAUDITSTATUS", OracleDbType.Int32, 0 , ParameterDirection.Input),
  8466. new OracleParameter(":pACCOUNTID", OracleDbType.Int32, sUserInfo.AccountID , ParameterDirection.Input),
  8467. new OracleParameter(":pCREATEUSERID", OracleDbType.Int32, sUserInfo.UserID , ParameterDirection.Input),
  8468. new OracleParameter(":pUPDATEUSERID", OracleDbType.Int32, sUserInfo.UserID , ParameterDirection.Input),
  8469. };
  8470. #endregion
  8471. resultEnity.OperateStatus = oracleTrConn.ExecuteNonQuery(strSql1, parmetersSql1);
  8472. //string strSeq = oracleTrConn.GetSqlResultToStr("Select SEQ_PM_ProgressRAP_RAPID.Currval from dual");
  8473. resultEnity.OperateKey = Convert.ToInt32(strSeq);
  8474. }
  8475. else
  8476. {
  8477. #region 判断数据是否可以编辑
  8478. string strSlq2 = "Select max(AuditStatus) From TP_PM_ProgressRAP Where RAPID = :pRAPID And OPTimeStamp = :pOPTimeStamp";
  8479. OracleParameter[] parmetersSql2 = new OracleParameter[]
  8480. {
  8481. new OracleParameter(":pRAPID", OracleDbType.Int32, pProgressRAPEntity.RAPID , ParameterDirection.Input),
  8482. new OracleParameter(":pOPTimeStamp", OracleDbType.TimeStamp, pProgressRAPEntity.OPTimeStamp , ParameterDirection.Input),
  8483. };
  8484. string strAuditStatus = oracleTrConn.GetSqlResultToStr(strSlq2, parmetersSql2);
  8485. if (string.IsNullOrEmpty(strAuditStatus))
  8486. {
  8487. oracleTrConn.Rollback();
  8488. oracleTrConn.Disconnect();
  8489. resultEnity.OperateStatus = -2;
  8490. return resultEnity;
  8491. }
  8492. if (!"0".Equals(strAuditStatus))
  8493. {
  8494. //不是待审批状态
  8495. oracleTrConn.Rollback();
  8496. oracleTrConn.Disconnect();
  8497. resultEnity.OperateStatus = -1;
  8498. return resultEnity;
  8499. }
  8500. #endregion
  8501. #region 编辑时更新数据
  8502. string strSql3 = "Update TP_PM_ProgressRAP Set "
  8503. + "RAPTYPE = :pRAPTYPE"
  8504. + ",REASON = :pREASON"
  8505. + ",RAPDATE = :pRAPDATE"
  8506. + ",RAPAMOUNT = :pRAPAMOUNT"
  8507. + ",REMARKS = :pREMARKS"
  8508. + ",UPDATEUSERID = :pUPDATEUSERID"
  8509. + " Where RAPID = :pRAPID And STAFFID = :pSTAFFID And AccountID = :pAccountID";
  8510. OracleParameter[] parmetersSql3 = new OracleParameter[]
  8511. {
  8512. new OracleParameter(":pRAPTYPE", OracleDbType.Double, pProgressRAPEntity.RAPType , ParameterDirection.Input),
  8513. new OracleParameter(":pREASON", OracleDbType.Varchar2, pProgressRAPEntity.Reason , ParameterDirection.Input),
  8514. new OracleParameter(":pRAPDATE", OracleDbType.Date, pProgressRAPEntity.RAPDate , ParameterDirection.Input),
  8515. new OracleParameter(":pRAPAMOUNT", OracleDbType.Double, pProgressRAPEntity.RAPAmount , ParameterDirection.Input),
  8516. new OracleParameter(":pREMARKS", OracleDbType.Varchar2, pProgressRAPEntity.Remarks , ParameterDirection.Input),
  8517. new OracleParameter(":pUPDATEUSERID", OracleDbType.Int32, sUserInfo.UserID , ParameterDirection.Input),
  8518. new OracleParameter(":pRAPID", OracleDbType.Int32, pProgressRAPEntity.RAPID , ParameterDirection.Input),
  8519. new OracleParameter(":pSTAFFID", OracleDbType.Int32, pProgressRAPEntity.StaffID , ParameterDirection.Input),
  8520. new OracleParameter(":pAccountID", OracleDbType.Int32, sUserInfo.AccountID , ParameterDirection.Input),
  8521. };
  8522. #endregion
  8523. resultEnity.OperateStatus = oracleTrConn.ExecuteNonQuery(strSql3, parmetersSql3);
  8524. resultEnity.OperateKey = pProgressRAPEntity.RAPID;
  8525. }
  8526. oracleTrConn.Commit();
  8527. oracleTrConn.Disconnect();
  8528. return resultEnity;
  8529. }
  8530. catch (Exception ex)
  8531. {
  8532. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  8533. {
  8534. oracleTrConn.Rollback();
  8535. oracleTrConn.Disconnect();
  8536. }
  8537. throw ex;
  8538. }
  8539. finally
  8540. {
  8541. if (oracleTrConn.ConnState == ConnectionState.Open)
  8542. {
  8543. oracleTrConn.Disconnect();
  8544. }
  8545. }
  8546. }
  8547. /// <summary>
  8548. /// 进度考核奖惩审批
  8549. /// </summary>
  8550. /// <param name="pAdminRAPEntity">进度考核奖惩实体</param>
  8551. /// <param name="pState">审批状态 True 通过 False 不通过</param>
  8552. /// <param name="sUserInfo">用户基本信息</param>
  8553. /// <returns>PMResultEntity操作结果状态信息</returns>
  8554. public static PMResultEntity SaveStaffProgressRAPApprovalInfo(PMProgressRAPEntity pProgressRAPEntity, bool pState, SUserInfo sUserInfo)
  8555. {
  8556. PMResultEntity resultEnity = new PMResultEntity();
  8557. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  8558. try
  8559. {
  8560. if (pProgressRAPEntity == null)
  8561. {
  8562. resultEnity.OperateStatus = 0;
  8563. return resultEnity;
  8564. }
  8565. oracleTrConn.Connect();
  8566. #region 判断数据是否可以编辑
  8567. string strSlq1 = "Select max(AuditStatus) From TP_PM_ProgressRAP Where RAPID = :pRAPID And OPTimeStamp = :pOPTimeStamp";
  8568. OracleParameter[] parmetersSql1 = new OracleParameter[]
  8569. {
  8570. new OracleParameter(":pRAPID", OracleDbType.Int32, pProgressRAPEntity.RAPID , ParameterDirection.Input),
  8571. new OracleParameter(":pOPTimeStamp", OracleDbType.TimeStamp, pProgressRAPEntity.OPTimeStamp , ParameterDirection.Input),
  8572. };
  8573. string strAuditStatus = oracleTrConn.GetSqlResultToStr(strSlq1, parmetersSql1);
  8574. if (string.IsNullOrEmpty(strAuditStatus))
  8575. {
  8576. oracleTrConn.Rollback();
  8577. oracleTrConn.Disconnect();
  8578. resultEnity.OperateStatus = -2;
  8579. return resultEnity;
  8580. }
  8581. if (!"0".Equals(strAuditStatus))
  8582. {
  8583. //不是待审批状态
  8584. oracleTrConn.Rollback();
  8585. oracleTrConn.Disconnect();
  8586. resultEnity.OperateStatus = -1;
  8587. return resultEnity;
  8588. }
  8589. #endregion
  8590. #region 更新审批数据
  8591. int intAuditStatus = 2; //2:审核未通过
  8592. if (pState)
  8593. {
  8594. intAuditStatus = 1; //1:审核通过;
  8595. }
  8596. string strSql2 = "Update TP_PM_ProgressRAP Set "
  8597. + "AUDITSTATUS = :pAUDITSTATUS"
  8598. + ",AUDITOR = :pAUDITOR"
  8599. + ",AuditlDate = sysdate"
  8600. + ",ACCOUNTDATE = FUN_CMN_GetAccountDate(:pAccountID1)"
  8601. + ",UPDATEUSERID = :pUPDATEUSERID"
  8602. + " Where RAPID = :pRAPID And AccountID = :pAccountID";
  8603. OracleParameter[] parmetersSql2 = new OracleParameter[]
  8604. {
  8605. new OracleParameter(":pAUDITSTATUS", OracleDbType.Int32,intAuditStatus, ParameterDirection.Input),
  8606. new OracleParameter(":pAUDITOR", OracleDbType.Int32, sUserInfo.UserID , ParameterDirection.Input),
  8607. new OracleParameter(":pAccountID1", OracleDbType.Int32, sUserInfo.AccountID , ParameterDirection.Input),
  8608. new OracleParameter(":pUPDATEUSERID", OracleDbType.Int32, sUserInfo.UserID , ParameterDirection.Input),
  8609. new OracleParameter(":pRAPID", OracleDbType.Int32, pProgressRAPEntity.RAPID , ParameterDirection.Input),
  8610. new OracleParameter(":pAccountID", OracleDbType.Int32, sUserInfo.AccountID , ParameterDirection.Input),
  8611. };
  8612. #endregion
  8613. resultEnity.OperateStatus = oracleTrConn.ExecuteNonQuery(strSql2, parmetersSql2);
  8614. resultEnity.OperateKey = pProgressRAPEntity.RAPID;
  8615. oracleTrConn.Commit();
  8616. oracleTrConn.Disconnect();
  8617. return resultEnity;
  8618. }
  8619. catch (Exception ex)
  8620. {
  8621. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  8622. {
  8623. oracleTrConn.Rollback();
  8624. oracleTrConn.Disconnect();
  8625. }
  8626. throw ex;
  8627. }
  8628. finally
  8629. {
  8630. if (oracleTrConn.ConnState == ConnectionState.Open)
  8631. {
  8632. oracleTrConn.Disconnect();
  8633. }
  8634. }
  8635. }
  8636. /// <summary>
  8637. /// 设置进度考核奖惩停用
  8638. /// </summary>
  8639. /// <param name="pRAPID">进度考核奖惩编号</param>
  8640. /// <param name="sUserInfo">用户基本信息</param>
  8641. /// <returns>PMResultEntity操作结果状态信息</returns>
  8642. public static PMResultEntity SetStaffProgressRAPValueFlag(int pRAPID, SUserInfo sUserInfo)
  8643. {
  8644. PMResultEntity resultEnity = new PMResultEntity();
  8645. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  8646. try
  8647. {
  8648. oracleTrConn.Connect();
  8649. string sql = "Select max(SettlementFlag) From TP_PM_ProgressRAP Where RAPID =" + pRAPID + " And AuditStatus = 0 And ValueFlag = 1";
  8650. string strSettlementFlag = oracleTrConn.GetSqlResultToStr(sql);
  8651. if (!string.IsNullOrEmpty(strSettlementFlag))
  8652. {
  8653. if ("1".Equals(strSettlementFlag)) //工资结算标识 1:已经结算 0:未结算
  8654. {
  8655. oracleTrConn.Rollback();
  8656. oracleTrConn.Disconnect();
  8657. resultEnity.OperateStatus = -3;
  8658. return resultEnity;
  8659. }
  8660. string sqlString = "Update TP_PM_ProgressRAP Set ValueFlag = 0,UpdateUserID = :pUpdateUserID"
  8661. + " Where RAPID = :pRAPID And AccountID = :pAccountID";
  8662. OracleParameter[] parmetersSql = new OracleParameter[]
  8663. {
  8664. new OracleParameter(":pUpdateUserID", OracleDbType.Int32,sUserInfo.UserID, ParameterDirection.Input),
  8665. new OracleParameter(":pRAPID", OracleDbType.Int32, pRAPID , ParameterDirection.Input),
  8666. new OracleParameter(":pAccountID", OracleDbType.Int32, sUserInfo.AccountID , ParameterDirection.Input),
  8667. };
  8668. resultEnity.OperateStatus = oracleTrConn.ExecuteNonQuery(sqlString, parmetersSql);
  8669. oracleTrConn.Commit();
  8670. oracleTrConn.Disconnect();
  8671. return resultEnity;
  8672. }
  8673. else
  8674. {
  8675. oracleTrConn.Rollback();
  8676. oracleTrConn.Disconnect();
  8677. resultEnity.OperateStatus = -2;
  8678. return resultEnity;
  8679. }
  8680. }
  8681. catch (Exception ex)
  8682. {
  8683. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  8684. {
  8685. oracleTrConn.Rollback();
  8686. oracleTrConn.Disconnect();
  8687. }
  8688. throw ex;
  8689. }
  8690. finally
  8691. {
  8692. if (oracleTrConn.ConnState == ConnectionState.Open)
  8693. {
  8694. oracleTrConn.Disconnect();
  8695. }
  8696. }
  8697. }
  8698. #endregion
  8699. #endregion
  8700. #region 私有方法
  8701. /// <summary>
  8702. /// 将窑车号下的条码转换成Table
  8703. /// </summary>
  8704. /// <param name="oracleTrConn">数据连接</param>
  8705. /// <param name="productionTable">手机传入的Table</param>
  8706. /// <param name="sUserInfo">用户基本信息</param>
  8707. /// <returns>DataTable</returns>
  8708. private static DataTable CarNoInfoConvertToTable(IDBTransaction oracleTrConn, DataTable productionTable, SUserInfo sUserInfo)
  8709. {
  8710. if (productionTable != null
  8711. && productionTable.Rows.Count > Constant.INT_IS_ZERO)
  8712. {
  8713. DataRow row = productionTable.Rows[Constant.INT_IS_ZERO];
  8714. string sql = "select carGoods.Barcode,"
  8715. + " carGoods.KilnCarID,"
  8716. + " car.KilncarCode,"
  8717. + " car.KilncarName,"
  8718. + " kiln.kilnid,"
  8719. + " kiln.kilnCode,"
  8720. + " kiln.kilnName,"
  8721. + " carGoods.Kilncarposition,"
  8722. + " carGoods.KilnCarBatchNo,"
  8723. + " carGoods.GoodsID,"
  8724. + " goods.GoodsCode,"
  8725. + " goods.GoodsName,"
  8726. + " :userID as UserID,"
  8727. + " :userCode as UserCode,"
  8728. + " :userName as UserName,"
  8729. + " :Remarks as Remarks"
  8730. + " from TP_PM_KilnCarGoods carGoods"
  8731. + " inner join TP_MST_KilnCar car on car.KilnCarID = carGoods.KilnCarID"
  8732. + " inner join TP_MST_Kiln kiln on kiln.KilnID = car.KilnID"
  8733. + " inner join TP_MST_Goods goods on goods.goodsid = carGoods.GoodsID"
  8734. + " where car.kilncarcode = :kilncarcode and carGoods.AccountID = :accountID";
  8735. OracleParameter[] oracleParameters = new OracleParameter[] {
  8736. new OracleParameter(":userID",row["UserID"].ToString()),
  8737. new OracleParameter(":userCode",row["UserCode"].ToString()),
  8738. new OracleParameter(":userName",row["UserName"].ToString()),
  8739. new OracleParameter(":kilncarcode",row["KilnCarCode"].ToString()),
  8740. new OracleParameter(":accountID",sUserInfo.AccountID),
  8741. new OracleParameter(":Remarks",row["Remarks"].ToString()),
  8742. };
  8743. DataSet ds = oracleTrConn.GetSqlResultToDs(sql, oracleParameters);
  8744. if (ds != null
  8745. && ds.Tables.Count > Constant.INT_IS_ZERO
  8746. && ds.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  8747. {
  8748. return ds.Tables[0];
  8749. }
  8750. return productionTable;
  8751. }
  8752. return productionTable;
  8753. }
  8754. #endregion
  8755. #region PDA端保存条码
  8756. /// <summary>
  8757. /// 添加成品编辑
  8758. /// </summary>
  8759. /// <param name="oracleTrConn">数据连接</param>
  8760. /// <param name="procedure">工序对象</param>
  8761. /// <param name="productionDataEntitys">生产数据集</param>
  8762. /// <param name="sUserInfo">用户基本信息</param>
  8763. /// <returns>string</returns>
  8764. private static string AddFinishCheckPDA(IDBTransaction oracleTrConn, ProcedureEntity procedure, ProductionDataEntity[] productionDataEntitys, SUserInfo sUserInfo)
  8765. {
  8766. string errMsg = "";
  8767. // 获得账务日期
  8768. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  8769. // 本批采集的批次号
  8770. string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  8771. string finishedloadbatchno = DateTime.Now.ToString("yyMMddHHmmss-") + centralizedBatchNo;
  8772. foreach (ProductionDataEntity productionData in productionDataEntitys)
  8773. {
  8774. bool RejectToReject = false;
  8775. if (string.IsNullOrEmpty(productionData.Barcode))
  8776. {
  8777. throw new Exception("传入的条码号为空");
  8778. }
  8779. int goodsID = Constant.INT_IS_ZERO;
  8780. string goodsCode = string.Empty;
  8781. string goodsName = string.Empty;
  8782. // 注浆者工号
  8783. string groutingUserCode = string.Empty;
  8784. // 次品标识
  8785. bool substandardFlag = false;
  8786. #region 校验条码有效性
  8787. errMsg = CheckBarcode(oracleTrConn, procedure.ProcedureID, productionData.Barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo);
  8788. if (!string.IsNullOrEmpty(errMsg))
  8789. {
  8790. // 编辑重烧时,会提示不可到达;编辑次品时,会提示已经报废
  8791. //if (productionData.ProductionDataID == 0)
  8792. //if (!errMsg.Contains("次品"))
  8793. return errMsg;
  8794. }
  8795. #endregion
  8796. int isInProduction = 1;
  8797. #region 修改条码
  8798. if (productionData.ProductionDataID > 0) //表示编辑条码
  8799. {
  8800. #region 验证改判有效期
  8801. // 前台已有相关验证,但还是产生了超期改判,后台保存前增加验证。
  8802. string sqlString = "select pdin.createtime from tp_pm_productiondatain pdin where pdin.productiondataid = " + productionData.ProductionDataID;
  8803. DateTime createtime = Convert.ToDateTime(oracleTrConn.GetSqlResultToObj(sqlString)).Date;
  8804. // 参数验证用服务端当前设置
  8805. sqlString = "SELECT sst.settingvalue\n" +
  8806. " FROM tp_mst_systemsetting sst\n" +
  8807. " WHERE sst.accountid = " + sUserInfo.AccountID + "\n" +
  8808. " AND sst.settingcode = 'S_PM_009'";
  8809. string strValue = oracleTrConn.GetSqlResultToStr(sqlString);
  8810. int days = 0;
  8811. int pDays = 0;
  8812. if (int.TryParse(strValue, out pDays))
  8813. {
  8814. days = pDays;
  8815. }
  8816. if (days != 0 && createtime <= DateTime.Now.Date.AddDays(-days))
  8817. {
  8818. return string.Format(Messages.MSG_S_PM_009, createtime.ToString("yyyy-MM-dd"), days.ToString(), createtime.AddDays(days - 1).ToString("yyyy-MM-dd"));
  8819. }
  8820. #endregion
  8821. //
  8822. string sqlOPTimeStamp = "";
  8823. OracleParameter[] parmetersSql = null;
  8824. #region 验证在产时间戳
  8825. if (productionData.OPTimeStampPDA == null) // 表示PC端,因为只有安卓端才给此数据字段给值
  8826. {
  8827. sqlOPTimeStamp = @"select
  8828. 1
  8829. from TP_PM_InProduction
  8830. where
  8831. TP_PM_InProduction.BarCode=:BarCode and TP_PM_InProduction.OPTimeStamp = :OPTimeStamp
  8832. union
  8833. select
  8834. 0
  8835. from Tp_Pm_Inproductiontrash
  8836. where
  8837. Tp_Pm_Inproductiontrash.BarCode=:BarCode and Tp_Pm_Inproductiontrash.OPTimeStamp = :OPTimeStamp ";
  8838. parmetersSql = new OracleParameter[]
  8839. {
  8840. new OracleParameter(":OPTimeStamp", OracleDbType.TimeStamp, productionData.OPTimeStamp, ParameterDirection.Input),
  8841. new OracleParameter(":BarCode", OracleDbType.NVarchar2, productionData.Barcode, ParameterDirection.Input),
  8842. };
  8843. }
  8844. else
  8845. {
  8846. sqlOPTimeStamp = @"select
  8847. 1
  8848. from TP_PM_InProduction
  8849. where
  8850. TP_PM_InProduction.BarCode=:BarCode and TP_PM_InProduction.OPTimeStamp =TO_TIMESTAMP(to_char(:OPTimeStamp),'DD-MM-YYHH12.MI.SS.FFAM')
  8851. union
  8852. select
  8853. 0
  8854. from Tp_Pm_Inproductiontrash
  8855. where
  8856. Tp_Pm_Inproductiontrash.BarCode=:BarCode and Tp_Pm_Inproductiontrash.OPTimeStamp =TO_TIMESTAMP(to_char(:OPTimeStamp),'DD-MM-YYHH12.MI.SS.FFAM')";
  8857. parmetersSql = new OracleParameter[]
  8858. {
  8859. new OracleParameter(":OPTimeStamp", OracleDbType.NVarchar2, productionData.OPTimeStampPDA, ParameterDirection.Input),
  8860. new OracleParameter(":BarCode", OracleDbType.NVarchar2, productionData.Barcode, ParameterDirection.Input),
  8861. };
  8862. }
  8863. DataSet returnDataset = oracleTrConn.GetSqlResultToDs(sqlOPTimeStamp, parmetersSql);
  8864. if (returnDataset != null
  8865. && returnDataset.Tables[0].Rows.Count == 0)
  8866. {
  8867. return "数据已经被修改,请重新进行编辑";
  8868. }
  8869. isInProduction = Convert.ToInt32(returnDataset.Tables[0].Rows[0][0]);
  8870. #endregion
  8871. //如果原来是 次品 / 废品 xuwei modify 2019-12-13 加入 废品识别
  8872. if (productionData.OrgGoodsLevelTypeID == Constant.GoodsLevelType.Reject.GetHashCode()
  8873. ||
  8874. productionData.OrgGoodsLevelTypeID == Constant.GoodsLevelType.Waste.GetHashCode()
  8875. )
  8876. {
  8877. //改为 次品 废品 xuwei modify 2019-12-13 加入废品识别
  8878. if (productionData.GoodsLevelTypeID == Constant.GoodsLevelType.Reject.GetHashCode()
  8879. ||
  8880. productionData.GoodsLevelTypeID == Constant.GoodsLevelType.Waste.GetHashCode()
  8881. )
  8882. {
  8883. // 删除生产数据及相关表与报损表
  8884. errMsg = DeleteSubstandardToSubstandardByID(oracleTrConn, productionData.ProductionDataID, productionData.Barcode, sUserInfo);
  8885. if (!string.IsNullOrEmpty(errMsg))
  8886. {
  8887. return errMsg;
  8888. }
  8889. RejectToReject = true;
  8890. } //改为不是 次品 废品 xuwei modify 2019-12-13 加入废品识别
  8891. else if (productionData.GoodsLevelTypeID != Constant.GoodsLevelType.Reject.GetHashCode()
  8892. ||
  8893. productionData.GoodsLevelTypeID != Constant.GoodsLevelType.Waste.GetHashCode()
  8894. )
  8895. {
  8896. // 删除生产数据及相关表与报损表
  8897. errMsg = DeleteSubstandardToOtherByID(oracleTrConn, productionData.ProductionDataID, productionData.Barcode, sUserInfo);
  8898. if (!string.IsNullOrEmpty(errMsg))
  8899. {
  8900. return errMsg;
  8901. }
  8902. }
  8903. }
  8904. else
  8905. {
  8906. // 原来产品分级不是次品
  8907. errMsg = DeleteNormalToOtherByID(oracleTrConn, productionData.ProductionDataID, productionData.Barcode, sUserInfo);
  8908. if (!string.IsNullOrEmpty(errMsg))
  8909. {
  8910. return errMsg;
  8911. }
  8912. }
  8913. }
  8914. else // wangx 2016-12-13 防止同时两个人新建数据,加判断条件
  8915. {
  8916. string sqlCurrrentProcedure = @"select Flowprocedureid from tp_pm_inproduction where BarCode=:BarCode";
  8917. OracleParameter[] parmetersSql = null;
  8918. parmetersSql = new OracleParameter[]
  8919. {
  8920. new OracleParameter(":BarCode", OracleDbType.NVarchar2, productionData.Barcode, ParameterDirection.Input),
  8921. };
  8922. DataSet returnDataset = oracleTrConn.GetSqlResultToDs(sqlCurrrentProcedure, parmetersSql);
  8923. // 判定次品时,在产表中已经没有条码数据 modify by chenxy 2017-07-03 begin
  8924. //if (returnDataset != null
  8925. // && returnDataset.Tables[0].Rows.Count > 0)
  8926. //{
  8927. // if (Convert.ToInt32(returnDataset.Tables[0].Rows[0]["Flowprocedureid"]) == procedure.ProcedureID)
  8928. // {
  8929. // return "【此条码生产数据已被修改,请重开画面后再扫描】";
  8930. // }
  8931. //}
  8932. if (returnDataset == null ||
  8933. returnDataset.Tables.Count == 0 ||
  8934. returnDataset.Tables[0].Rows.Count == 0 ||
  8935. Convert.ToInt32(returnDataset.Tables[0].Rows[0]["Flowprocedureid"]) == procedure.ProcedureID
  8936. )
  8937. {
  8938. return "【此条码生产数据已被修改,请重新扫描此条码】";
  8939. }
  8940. // 判定次品时,在产表中已经没有条码数据 modify by chenxy 2017-07-03 end
  8941. }
  8942. #endregion
  8943. // 查询新插入的生产数据ID
  8944. string sql = "select SEQ_PM_ProductionData_ID.nextval from dual";
  8945. string idStr = oracleTrConn.GetSqlResultToStr(sql);
  8946. int productionDataID = 0;
  8947. if (!string.IsNullOrEmpty(idStr))
  8948. {
  8949. productionDataID = int.Parse(idStr);
  8950. }
  8951. else
  8952. {
  8953. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  8954. }
  8955. int? ClassesSettingID = null;//班次配置ID
  8956. #region 添加生产者数据
  8957. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, productionData.UserID, productionData.UserName, sUserInfo, ref ClassesSettingID);
  8958. if (!string.IsNullOrEmpty(errMsg))
  8959. {
  8960. return errMsg;
  8961. }
  8962. #endregion
  8963. #region 添加生产数据
  8964. #region 属性赋值
  8965. productionData.ClassesSettingID = ClassesSettingID;
  8966. productionData.ProductionDataID = Convert.ToInt32(idStr);
  8967. productionData.CentralizedBatchNo = centralizedBatchNo;
  8968. productionData.ProductionLineID = procedure.ProductionLineID;
  8969. productionData.ProductionLineCode = procedure.ProductionlineCode;
  8970. productionData.ProductionLineName = procedure.ProductionlineName;
  8971. productionData.CompleteProcedureID = procedure.ProcedureID;
  8972. productionData.ProcedureCode = procedure.ProcedureCode;
  8973. productionData.ProcedureName = procedure.ProcedureName;
  8974. productionData.ProcedureModel = procedure.ProcedureModel;
  8975. productionData.ModelType = procedure.ModelType;
  8976. productionData.NodeType = procedure.NodeType;
  8977. productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, productionData.Barcode);
  8978. // 重烧
  8979. if (productionData.GoodsLevelTypeID == (int)Constant.GoodsLevelType.ReFire)
  8980. {
  8981. //productionData.GoodsLevelID = null;
  8982. //productionData.IsReFire = (int)Constant.GoodsLevelType.ReFire;
  8983. productionData.IsReFire = (int)Constant.ReFireFlag.No;//产品分级的时候,并不标记,走过重烧第一个结点之后,更新此字段
  8984. }
  8985. // 次品 废品 xuwei 2019-12-13 加入 废品识别
  8986. else if (productionData.GoodsLevelTypeID == (int)Constant.GoodsLevelType.Reject
  8987. ||
  8988. productionData.GoodsLevelTypeID == (int)Constant.GoodsLevelType.Waste
  8989. )
  8990. {
  8991. //productionData.GoodsLevelID = null;
  8992. substandardFlag = true;
  8993. }
  8994. // 查询新插入的生产数据ID
  8995. //if (productionData.GoodsLevelTypeID != (int)Constant.GoodsLevelType.ReFire)
  8996. // {
  8997. //不加条件valueflag,是因为,成检后重烧走过之后,在次重烧,以后也是重烧状态
  8998. //string sqlReFire = "select * from tp_PM_ProductionData where ProductionData=(select max(ProductionDataid) from ProductionData where barcode=" + productionData.Barcode + " and ProcedureID=" + productionData.ProcedureID + ")";
  8999. //if (productionData.GoodsLevelTypeID != (int)Constant.GoodsLevelType.ReFire)
  9000. // {
  9001. ////// string sqlReFire = @"select
  9002. ////// isrefire
  9003. ////// from tp_pm_inproduction where barcode=:barcode
  9004. ////// union
  9005. ////// select
  9006. ////// isrefire
  9007. ////// from TP_PM_InProductionTrash where barcode=:barcode
  9008. ////// ";
  9009. ////// OracleParameter[] ReFireparas = new OracleParameter[] {
  9010. ////// new OracleParameter(":barcode", productionData.Barcode),
  9011. ////// };
  9012. ////// DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas);
  9013. ////// if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0)
  9014. ////// {
  9015. ////// productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]);
  9016. ////// }
  9017. // }
  9018. productionData.OrganizationID = procedure.OrganizationID;
  9019. productionData.GoodsID = goodsID;
  9020. productionData.GoodsCode = goodsCode;
  9021. productionData.GoodsName = goodsName;
  9022. productionData.GoodsLevelID = productionData.GoodsLevelID;
  9023. productionData.GoodsLevelTypeID = productionData.GoodsLevelTypeID;
  9024. //if (productionData.GoodsLevelTypeID == (int)Constant.GoodsLevelType.Reject)
  9025. //{
  9026. // productionData.GoodsEnding = Constant.GoodsLevelType.Reject.GetHashCode().ToString();
  9027. //}
  9028. //else
  9029. //{
  9030. // productionData.GoodsEnding = null;
  9031. //}
  9032. #endregion
  9033. string OutSpecialRepairflag = "0";//干补标识
  9034. //errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag);
  9035. errMsg = AddFinishCheckProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag);
  9036. if (!string.IsNullOrEmpty(errMsg))
  9037. {
  9038. return errMsg;
  9039. }
  9040. #endregion
  9041. //#region 添加生产者数据
  9042. //errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, productionData.UserID, productionData.UserName, sUserInfo);
  9043. //if (!string.IsNullOrEmpty(errMsg))
  9044. //{
  9045. // return errMsg;
  9046. //}
  9047. //#endregion
  9048. #region 条码有缺陷
  9049. #region 是次品 添加废弃产品
  9050. string ResponProcedureidStr = "";
  9051. if (substandardFlag)
  9052. {
  9053. #region 修改在产产品数据的当前工序,防止直接报损在产工序没有改过来,记录的是上一个工序
  9054. string updateInInProductionForScrap = @"Update tp_pm_inproduction
  9055. set FlowProcedureID=:flowProcedureID,ProcedureID=:flowProcedureID where barcode=:barcode";
  9056. List<OracleParameter> paras = new List<OracleParameter>();
  9057. paras.Add(new OracleParameter(":barcode", productionData.Barcode));
  9058. paras.Add(new OracleParameter(":flowProcedureID", procedure.ProcedureID));
  9059. oracleTrConn.ExecuteNonQuery(updateInInProductionForScrap, paras.ToArray());
  9060. #endregion
  9061. #region 添加废弃产品
  9062. ScrapProductEntity scrapProduct = new ScrapProductEntity();
  9063. #region 属性赋值
  9064. scrapProduct.BarCode = productionData.Barcode;
  9065. scrapProduct.ScrapType = Constant.ScrapType.Substandard.GetHashCode();
  9066. scrapProduct.ResponType = Constant.ScrapResponType.Procedure.GetHashCode();
  9067. scrapProduct.ScrapDate = accountDate;
  9068. scrapProduct.Rreason = Constant.SCRAPTYPE_SUBSTANDARD;
  9069. scrapProduct.AuditStatus = Constant.AuditStatus.Agree.GetHashCode();
  9070. scrapProduct.Auditor = sUserInfo.UserID;
  9071. scrapProduct.AuditlDate = accountDate;
  9072. scrapProduct.AccountDate = accountDate;
  9073. scrapProduct.GoodsLevelID = productionData.GoodsLevelID;
  9074. scrapProduct.GoodsLevelTypeID = productionData.GoodsLevelTypeID;
  9075. scrapProduct.IsPublicBody = productionData.IsPublicBody;
  9076. // 查询新插入的废弃ID
  9077. string ResponProceduresql = "select SEQ_PM_ScrapProduct_ID.nextval from dual";
  9078. ResponProcedureidStr = oracleTrConn.GetSqlResultToStr(ResponProceduresql);
  9079. scrapProduct.ScrapProductID = Convert.ToInt32(ResponProcedureidStr);
  9080. scrapProduct.ScrapType = 1;
  9081. scrapProduct.IsQualityStatistics = 1;//新加的,因为这个报损方法是共通的,用于区别是哪里传进去的
  9082. scrapProduct.ProductionDataID = productionData.ProductionDataID;
  9083. #endregion
  9084. if (!RejectToReject) //不是次品到次品 wangxin 20150417
  9085. {
  9086. // 保存报废
  9087. errMsg = AddScrapProduct(oracleTrConn, scrapProduct, sUserInfo);
  9088. }
  9089. else
  9090. {
  9091. if (isInProduction == 1)
  9092. {
  9093. errMsg = AddScrapProduct(oracleTrConn, scrapProduct, sUserInfo);
  9094. }
  9095. else
  9096. {
  9097. // 保存报废
  9098. errMsg = AddScrapProductRejectToReject(oracleTrConn, scrapProduct, sUserInfo);
  9099. }
  9100. }
  9101. //不是次品到次品 wangxin 20150417
  9102. // 保存失败
  9103. if (!string.IsNullOrEmpty(errMsg))
  9104. {
  9105. return errMsg;
  9106. }
  9107. #endregion
  9108. }
  9109. #endregion
  9110. // 存在缺陷 插入缺陷表
  9111. if (productionData.ProductionDefects != null)
  9112. {
  9113. foreach (ProductionDefectEntity productionDefect in productionData.ProductionDefects)
  9114. {
  9115. #region 保存缺陷
  9116. productionDefect.ProductionDataID = productionDataID;
  9117. productionDefect.BarCode = productionData.Barcode;
  9118. productionDefect.ProductionLineID = procedure.ProductionLineID;
  9119. productionDefect.ProductionLineCode = procedure.ProductionlineCode;
  9120. productionDefect.ProductionLineName = procedure.ProductionlineName;
  9121. productionDefect.ProcedureID = procedure.ProcedureID;
  9122. productionDefect.ProcedureCode = procedure.ProcedureCode;
  9123. productionDefect.ProcedureName = procedure.ProcedureName;
  9124. productionDefect.UserID = productionData.UserID;
  9125. productionDefect.UserCode = productionData.UserCode;
  9126. productionDefect.UserName = productionData.UserName;
  9127. productionDefect.GoodsID = productionData.GoodsID;
  9128. productionDefect.GoodsCode = productionData.GoodsCode;
  9129. productionDefect.GoodsName = productionData.GoodsName;
  9130. productionData.Remarks = productionData.Remarks;
  9131. productionDefect.ScrapResponFlag
  9132. = string.IsNullOrEmpty(productionDefect.ScrapResponFlag) ? "0" : productionDefect.ScrapResponFlag;
  9133. // 保存缺陷
  9134. errMsg = AddDefect(oracleTrConn, productionDefect, sUserInfo);
  9135. if (!string.IsNullOrEmpty(errMsg))
  9136. {
  9137. return errMsg;
  9138. }
  9139. #endregion
  9140. #region 是次品 添加废弃责任工序
  9141. if (substandardFlag)
  9142. {
  9143. //if (productionDefect.DefectProcedureID != null)
  9144. {
  9145. #region 添加责任工序
  9146. ResponProcedureEntity responProce = new ResponProcedureEntity();
  9147. //// 查询新插入的废弃ID
  9148. //string ResponProceduresql = "select SEQ_PM_ScrapProduct_ID.Currval from dual";
  9149. //string ResponProcedureidStr = oracleTrConn.GetSqlResultToStr(ResponProceduresql);
  9150. #region 属性赋值
  9151. responProce.BarCode = productionData.Barcode;
  9152. responProce.ProductionDataID = productionDataID;
  9153. responProce.ProductionLineID = productionDefect.ProductionLineID;
  9154. responProce.ProductionLineCode = productionDefect.ProductionLineCode;
  9155. responProce.ProductionLineName = productionDefect.ProductionLineName;
  9156. responProce.ProcedureID = productionDefect.DefectProcedureID;
  9157. responProce.ProcedureCode = productionDefect.DefectProcedureCode;
  9158. responProce.ProcedureName = productionDefect.DefectProcedureName;
  9159. responProce.UserID = productionDefect.DefectUserID;
  9160. responProce.UserCode = productionDefect.DefectUserCode;
  9161. responProce.UserName = productionDefect.DefectUserName;
  9162. responProce.Remarks = productionDefect.Remarks;
  9163. responProce.ScrapProductID = Convert.ToInt32(ResponProcedureidStr);
  9164. #endregion
  9165. // 保存责任工序
  9166. errMsg = AddResponProcedure(oracleTrConn, responProce, productionDefect, sUserInfo);
  9167. // 保存失败
  9168. if (!string.IsNullOrEmpty(errMsg))
  9169. {
  9170. return errMsg;
  9171. }
  9172. #endregion
  9173. }
  9174. }
  9175. #endregion
  9176. }
  9177. }
  9178. #endregion
  9179. #region 条码是次品 删除在产产品数据
  9180. if (substandardFlag)
  9181. {
  9182. #region 删除在产产品数据
  9183. InProductionEntity delInProductionEntity = new InProductionEntity();
  9184. delInProductionEntity.BarCode = productionData.Barcode;
  9185. delInProductionEntity.CompleteProcedureID = procedure.ProcedureID;
  9186. delInProductionEntity.ProductionDataID = productionDataID;
  9187. delInProductionEntity.GoodsLevelID = productionData.GoodsLevelID;
  9188. delInProductionEntity.GoodsLevelTypeID = productionData.GoodsLevelTypeID;
  9189. // 执行删除 在产数据
  9190. errMsg = DeletePDAInProduction(oracleTrConn, delInProductionEntity, false, sUserInfo);
  9191. // 执行失败
  9192. if (!string.IsNullOrEmpty(errMsg))
  9193. {
  9194. return errMsg;
  9195. }
  9196. #endregion
  9197. }
  9198. #endregion
  9199. #region 条码不是次品
  9200. if (!substandardFlag)
  9201. {
  9202. #region 中间工序/重烧 修改在产产品数据
  9203. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Middle
  9204. || productionData.IsReFire == Constant.GoodsGrade.ReFire.GetHashCode())
  9205. {
  9206. #region 修改在产产品数据的当前工序
  9207. InProductionEntity inProductionEntity = new InProductionEntity();
  9208. inProductionEntity.BarCode = productionData.Barcode;
  9209. //流程工序
  9210. inProductionEntity.FlowProcedureID = procedure.ProcedureID;
  9211. // 当前工序
  9212. //inProductionEntity.CompleteProcedureID = procedure.ProcedureID;
  9213. inProductionEntity.ProcedureID = procedure.ProcedureID;
  9214. //生产数据ID
  9215. inProductionEntity.ProductionDataID = productionDataID;
  9216. // 工序模型
  9217. inProductionEntity.ProcedureModel = procedure.ProcedureModel;
  9218. // 工序类别
  9219. inProductionEntity.ModelType = procedure.ModelType;
  9220. // 生产工号
  9221. inProductionEntity.UserID = productionData.UserID;
  9222. // 重烧
  9223. inProductionEntity.IsReFire = productionData.IsReFire;
  9224. // 缺陷
  9225. inProductionEntity.DefectFlag = productionData.DefectFlag;
  9226. // 产品分级
  9227. inProductionEntity.GoodsGrade = productionData.GoodsGrade;
  9228. // 返工工序ID
  9229. inProductionEntity.ReworkProcedureID = productionData.ReworkProcedureID;
  9230. inProductionEntity.GoodsLevelID = productionData.GoodsLevelID;
  9231. inProductionEntity.GoodsLevelTypeID = productionData.GoodsLevelTypeID;
  9232. inProductionEntity.IsPublicBody = productionData.IsPublicBody;
  9233. // 执行修改
  9234. errMsg = UpdateInProduction(oracleTrConn, inProductionEntity, sUserInfo);
  9235. // 执行失败
  9236. if (!string.IsNullOrEmpty(errMsg))
  9237. {
  9238. return errMsg;
  9239. }
  9240. #endregion
  9241. }
  9242. #endregion
  9243. #region 结束工序 添加成品数据 删除在产产品数据
  9244. else if (procedure.NodeType == (int)Constant.ProcedureNodeType.End)
  9245. {
  9246. #region 添加成品数据 删除在产产品数据
  9247. FinishedProductEntity finishedProduct = new FinishedProductEntity();
  9248. finishedProduct.BarCode = productionData.Barcode;
  9249. errMsg = AddFinishedProduct(oracleTrConn, finishedProduct, sUserInfo, finishedloadbatchno);
  9250. if (!string.IsNullOrEmpty(errMsg))
  9251. {
  9252. return errMsg;
  9253. }
  9254. InProductionEntity delInProductionEntity = new InProductionEntity();
  9255. delInProductionEntity.BarCode = productionData.Barcode;
  9256. // 执行删除 在产数据
  9257. errMsg = DeleteInProduction(oracleTrConn, delInProductionEntity, true, sUserInfo);
  9258. // 执行失败
  9259. if (!string.IsNullOrEmpty(errMsg))
  9260. {
  9261. return errMsg;
  9262. }
  9263. #endregion
  9264. }
  9265. #endregion
  9266. }
  9267. #endregion
  9268. #region 写入检验标识 CheckFlag 用于计件 xuwei 2020-04-21
  9269. oracleTrConn.ExecuteNonQuery(@"
  9270. UPDATE
  9271. TP_PM_PRODUCTIONDATA SET CHECKFLAG = :CHECKFLAG
  9272. WHERE
  9273. PRODUCTIONDATAID = :PRODUCTIONDATAID
  9274. ",
  9275. new OracleParameter[] {
  9276. new OracleParameter(":CHECKFLAG",productionData.CheckFlag),
  9277. new OracleParameter(":PRODUCTIONDATAID",productionDataID)
  9278. }
  9279. );
  9280. #endregion
  9281. }
  9282. return errMsg;
  9283. }
  9284. /// <summary>
  9285. /// 编辑后删除生产数据
  9286. /// </summary>
  9287. /// <param name="productionDataID">生产数据ID</param>
  9288. /// <returns>int</returns>
  9289. public static string DeleteSubstandardToSubstandardByID(IDBTransaction oracleTrConn, int productionDataID, string barcode, SUserInfo sUserInfo)
  9290. {
  9291. int deleteRow = 0;
  9292. try
  9293. {
  9294. string sqlString5 = @"update TP_PM_DefectMissedResponsible set ValueFlag=0, UpdateUserID=:UpdateUserID
  9295. where TP_PM_DefectMissedResponsible.Productiondefectid in
  9296. (
  9297. select ProductionDefectID from TP_PM_Defect where TP_PM_Defect.Productiondataid=:ProductionDataID
  9298. )";
  9299. string sqlString4 = @"update TP_PM_ProductionDataIn set ValueFlag=0, UpdateUserID=:UpdateUserID
  9300. where
  9301. TP_PM_ProductionDataIn.Productiondataid=:ProductionDataID
  9302. ";
  9303. string sqlString3 = @"update TP_PM_Defect set ValueFlag=0, UpdateUserID=:UpdateUserID
  9304. where TP_PM_Defect.Productiondataid =:ProductionDataID";
  9305. string sqlString2 = @"update TP_PM_DefectResponsible set ValueFlag=0, UpdateUserID=:UpdateUserID
  9306. where TP_PM_DefectResponsible.Productiondefectid in
  9307. (
  9308. select ProductionDefectID from TP_PM_Defect where TP_PM_Defect.Productiondataid=:ProductionDataID
  9309. )";
  9310. string sqlString = @"update TP_PM_DefectImage set ValueFlag=0, UpdateUserID=:UpdateUserID
  9311. where TP_PM_DefectImage.Productiondefectid in
  9312. (
  9313. select ProductionDefectID from TP_PM_Defect where TP_PM_Defect.Productiondataid=:ProductionDataID
  9314. )";
  9315. // string sqlScrapProduct = @"update TP_PM_ScrapProduct set ValueFlag=0 where barcode=:barcode";
  9316. string sqlScrapProduct = @"update TP_PM_ScrapProduct set ValueFlag=0, UpdateUserID=:UpdateUserID where ScrapProductID=(
  9317. select max(ScrapProductID) from TP_PM_ScrapProduct where barcode=:barcode)";
  9318. OracleParameter[] paras = new OracleParameter[]{
  9319. new OracleParameter(":ProductionDataID",OracleDbType.Int32, productionDataID,ParameterDirection.Input),
  9320. new OracleParameter(":UpdateUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input),
  9321. };
  9322. OracleParameter[] ScrapProductparas = new OracleParameter[]{
  9323. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  9324. new OracleParameter(":UpdateUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input),
  9325. };
  9326. deleteRow += oracleTrConn.ExecuteNonQuery(sqlString, paras);
  9327. deleteRow += oracleTrConn.ExecuteNonQuery(sqlString2, paras);
  9328. deleteRow += oracleTrConn.ExecuteNonQuery(sqlString3, paras);
  9329. deleteRow += oracleTrConn.ExecuteNonQuery(sqlString4, paras);
  9330. deleteRow += oracleTrConn.ExecuteNonQuery(sqlString5, paras);
  9331. deleteRow += oracleTrConn.ExecuteNonQuery(sqlScrapProduct, ScrapProductparas);
  9332. // 有错误
  9333. if (deleteRow == 0)
  9334. {
  9335. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  9336. }
  9337. return null;
  9338. }
  9339. catch (Exception ex)
  9340. {
  9341. throw ex;
  9342. }
  9343. }
  9344. /// <summary>
  9345. /// 编辑后删除生产数据
  9346. /// </summary>
  9347. /// <param name="productionDataID">生产数据ID</param>
  9348. /// <returns>int</returns>
  9349. public static string DeleteSubstandardToOtherByID(IDBTransaction oracleTrConn, int productionDataID, string barcode, SUserInfo sUserInfo)
  9350. {
  9351. int deleteRow = 0;
  9352. try
  9353. {
  9354. string sqlString5 = @"update TP_PM_DefectMissedResponsible set ValueFlag=0, UpdateUserID=:UpdateUserID
  9355. where TP_PM_DefectMissedResponsible.Productiondefectid in
  9356. (
  9357. select ProductionDefectID from TP_PM_Defect where TP_PM_Defect.Productiondataid=:ProductionDataID
  9358. )";
  9359. string sqlString4 = @"update TP_PM_ProductionDataIn set ValueFlag=0, UpdateUserID=:UpdateUserID
  9360. where
  9361. TP_PM_ProductionDataIn.Productiondataid=:ProductionDataID
  9362. ";
  9363. string sqlString3 = @"update TP_PM_Defect set ValueFlag=0, UpdateUserID=:UpdateUserID
  9364. where TP_PM_Defect.Productiondataid =:ProductionDataID";
  9365. string sqlString2 = @"update TP_PM_DefectResponsible set ValueFlag=0, UpdateUserID=:UpdateUserID
  9366. where TP_PM_DefectResponsible.Productiondefectid in
  9367. (
  9368. select ProductionDefectID from TP_PM_Defect where TP_PM_Defect.Productiondataid=:ProductionDataID
  9369. )";
  9370. string sqlString = @"update TP_PM_DefectImage set ValueFlag=0, UpdateUserID=:UpdateUserID
  9371. where TP_PM_DefectImage.Productiondefectid in
  9372. (
  9373. select ProductionDefectID from TP_PM_Defect where TP_PM_Defect.Productiondataid=:ProductionDataID
  9374. )";
  9375. //string sqlScrapProduct = @"update TP_PM_ScrapProduct set ValueFlag=0 where barcode=:barcode";
  9376. string sqlScrapProduct = @"update TP_PM_ScrapProduct set ValueFlag=0, UpdateUserID=:UpdateUserID where ScrapProductID=(
  9377. select max(ScrapProductID) from TP_PM_ScrapProduct where barcode=:barcode)";
  9378. string sqlExist = "select 1 from tp_pm_inproduction where barcode = :barcode ";
  9379. string sqlInsert = @"insert into TP_PM_InProduction
  9380. (
  9381. BarCode,
  9382. ProductionLineID,
  9383. ProductionLineCode,
  9384. ProductionLineName,
  9385. ProcedureModel,
  9386. ModelType,
  9387. DefectFlag,
  9388. ReworkProcedureID,
  9389. IsPublicBody,
  9390. IsReFire,
  9391. GoodsLevelID,
  9392. GoodsLevelTypeID,
  9393. GoodsID,
  9394. GoodsCode,
  9395. GoodsName,
  9396. UserID,
  9397. GroutingDailyID,
  9398. GroutingDailyDetailID,
  9399. GroutingDate,
  9400. GroutingLineID,
  9401. GroutingLineCode,
  9402. GroutingLineName,
  9403. GMouldTypeID,
  9404. CanManyTimes,
  9405. GroutingLineDetailID,
  9406. GroutingMouldCode,
  9407. MouldCode,
  9408. GroutingUserID,
  9409. GroutingUserCode,
  9410. GroutingNum,
  9411. Remarks,
  9412. KilnID,
  9413. KilnCode,
  9414. KilnName,
  9415. KilnCarID,
  9416. KilnCarCode,
  9417. KilnCarName,
  9418. KilnCarBatchNo,
  9419. KilnCarPosition,
  9420. AccountID,
  9421. ValueFlag,
  9422. CreateTime,
  9423. CreateUserID,
  9424. UpdateTime,
  9425. UpdateUserID,
  9426. OPTimeStamp,
  9427. SpecialRepairflag,
  9428. FlowProcedureID,
  9429. FlowProcedureTime,
  9430. ProcedureID,
  9431. ProcedureTime,
  9432. ProductionDataID,
  9433. logoid, ISREWORKFLAG, SEMICHECKID
  9434. )
  9435. select
  9436. BarCode,
  9437. ProductionLineID,
  9438. ProductionLineCode,
  9439. ProductionLineName,
  9440. ProcedureModel,
  9441. ModelType,
  9442. DefectFlag,
  9443. ReworkProcedureID,
  9444. IsPublicBody,
  9445. IsReFire,
  9446. GoodsLevelID,
  9447. GoodsLevelTypeID,
  9448. GoodsID,
  9449. GoodsCode,
  9450. GoodsName,
  9451. UserID,
  9452. GroutingDailyID,
  9453. GroutingDailyDetailID,
  9454. GroutingDate,
  9455. GroutingLineID,
  9456. GroutingLineCode,
  9457. GroutingLineName,
  9458. GMouldTypeID,
  9459. CanManyTimes,
  9460. GroutingLineDetailID,
  9461. GroutingMouldCode,
  9462. MouldCode,
  9463. GroutingUserID,
  9464. GroutingUserCode,
  9465. GroutingNum,
  9466. Remarks,
  9467. KilnID,
  9468. KilnCode,
  9469. KilnName,
  9470. KilnCarID,
  9471. KilnCarCode,
  9472. KilnCarName,
  9473. KilnCarBatchNo,
  9474. KilnCarPosition,
  9475. AccountID,
  9476. ValueFlag,
  9477. CreateTime,
  9478. CreateUserID,
  9479. UpdateTime,
  9480. UpdateUserID,
  9481. OPTimeStamp,
  9482. SpecialRepairflag,
  9483. FlowProcedureID,
  9484. FlowProcedureTime,
  9485. ProcedureID,
  9486. ProcedureTime,
  9487. ProductionDataID,
  9488. logoid, ISREWORKFLAG, SEMICHECKID
  9489. from TP_PM_InProductionTrash
  9490. where barcode=:barcode
  9491. ";
  9492. string sqlDelete = @"delete from TP_PM_InProductionTrash where barcode=:barcode";
  9493. OracleParameter[] paras = new OracleParameter[]{
  9494. new OracleParameter(":ProductionDataID",OracleDbType.Int32, productionDataID,ParameterDirection.Input),
  9495. new OracleParameter(":UpdateUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input),
  9496. };
  9497. OracleParameter[] ScrapProductparas = new OracleParameter[]{
  9498. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  9499. new OracleParameter(":UpdateUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input),
  9500. };
  9501. OracleParameter[] Existparas = new OracleParameter[]{
  9502. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  9503. };
  9504. deleteRow += oracleTrConn.ExecuteNonQuery(sqlString, paras);
  9505. deleteRow += oracleTrConn.ExecuteNonQuery(sqlString2, paras);
  9506. deleteRow += oracleTrConn.ExecuteNonQuery(sqlString3, paras);
  9507. deleteRow += oracleTrConn.ExecuteNonQuery(sqlString4, paras);
  9508. deleteRow += oracleTrConn.ExecuteNonQuery(sqlString5, paras);
  9509. deleteRow += oracleTrConn.ExecuteNonQuery(sqlScrapProduct, ScrapProductparas);
  9510. DataSet dsresult = oracleTrConn.GetSqlResultToDs(sqlExist, Existparas);
  9511. if (dsresult != null && dsresult.Tables[0].Rows.Count == 0)
  9512. {
  9513. deleteRow += oracleTrConn.ExecuteNonQuery(sqlInsert, Existparas);
  9514. }
  9515. deleteRow += oracleTrConn.ExecuteNonQuery(sqlDelete, Existparas);
  9516. // 有错误
  9517. if (deleteRow == 0)
  9518. {
  9519. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  9520. }
  9521. return null;
  9522. }
  9523. catch (Exception ex)
  9524. {
  9525. throw ex;
  9526. }
  9527. }
  9528. /// <summary>
  9529. /// 编辑后删除生产数据
  9530. /// </summary>
  9531. /// <param name="productionDataID">生产数据ID</param>
  9532. /// <returns>int</returns>
  9533. public static string DeleteNormalToOtherByID(IDBTransaction oracleTrConn, int productionDataID, string barcode, SUserInfo sUserInfo)
  9534. {
  9535. int deleteRow = 0;
  9536. try
  9537. {
  9538. string sqlString5 = @"update TP_PM_DefectMissedResponsible set ValueFlag=0, UpdateUserID=:UpdateUserID
  9539. where TP_PM_DefectMissedResponsible.Productiondefectid in
  9540. (
  9541. select ProductionDefectID from TP_PM_Defect where TP_PM_Defect.Productiondataid=:ProductionDataID
  9542. )";
  9543. string sqlString4 = @"update TP_PM_ProductionDataIn set ValueFlag=0, UpdateUserID=:UpdateUserID
  9544. where
  9545. TP_PM_ProductionDataIn.Productiondataid=:ProductionDataID
  9546. ";
  9547. string sqlString3 = @"update TP_PM_Defect set ValueFlag=0, UpdateUserID=:UpdateUserID
  9548. where TP_PM_Defect.Productiondataid =:ProductionDataID";
  9549. string sqlString2 = @"update TP_PM_DefectResponsible set ValueFlag=0, UpdateUserID=:UpdateUserID
  9550. where TP_PM_DefectResponsible.Productiondefectid in
  9551. (
  9552. select ProductionDefectID from TP_PM_Defect where TP_PM_Defect.Productiondataid=:ProductionDataID
  9553. )";
  9554. string sqlString = @"update TP_PM_DefectImage set ValueFlag=0, UpdateUserID=:UpdateUserID
  9555. where TP_PM_DefectImage.Productiondefectid in
  9556. (
  9557. select ProductionDefectID from TP_PM_Defect where TP_PM_Defect.Productiondataid=:ProductionDataID
  9558. )";
  9559. OracleParameter[] paras = new OracleParameter[]{
  9560. new OracleParameter(":ProductionDataID",OracleDbType.Int32, productionDataID,ParameterDirection.Input),
  9561. new OracleParameter(":UpdateUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input),
  9562. };
  9563. deleteRow += oracleTrConn.ExecuteNonQuery(sqlString, paras);
  9564. deleteRow += oracleTrConn.ExecuteNonQuery(sqlString2, paras);
  9565. deleteRow += oracleTrConn.ExecuteNonQuery(sqlString3, paras);
  9566. deleteRow += oracleTrConn.ExecuteNonQuery(sqlString4, paras);
  9567. deleteRow += oracleTrConn.ExecuteNonQuery(sqlString5, paras);
  9568. // 有错误
  9569. if (deleteRow == 0)
  9570. {
  9571. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  9572. }
  9573. return null;
  9574. }
  9575. catch (Exception ex)
  9576. {
  9577. throw ex;
  9578. }
  9579. }
  9580. /// <summary>
  9581. /// 保存条码信息
  9582. /// </summary>
  9583. /// <param name="procedureID">工序ID</param>
  9584. /// <param name="productionDataEntitys">生产数据集</param>
  9585. /// <param name="sUserInfo">用户基本信息</param>
  9586. /// <returns>string</returns>
  9587. public static string AddCheckBarcodePDA(int procedureID, ProductionDataEntity[] productionDataEntitys, SUserInfo sUserInfo)
  9588. {
  9589. string errMsg = "";
  9590. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  9591. try
  9592. {
  9593. oracleTrConn.Connect();
  9594. #region 查询工序信息
  9595. ProcedureEntity procedure = GetProcedurByID(oracleTrConn, procedureID);
  9596. #endregion
  9597. #region 标准检验(半成品)
  9598. if (procedure.ModelType == (int)Constant.ProcedureModelType.Normal)
  9599. {
  9600. errMsg = AddNormalCheck(oracleTrConn, procedure, productionDataEntitys, sUserInfo);
  9601. }
  9602. #endregion
  9603. #region 成品检验
  9604. else if (procedure.ModelType == (int)Constant.ProcedureModelType.QualityStatistics)
  9605. {
  9606. errMsg = AddFinishCheckPDA(oracleTrConn, procedure, productionDataEntitys, sUserInfo);
  9607. }
  9608. #endregion
  9609. #region 半检 xuwei add 2019-12-13
  9610. else if (procedure.ModelType == (int)Constant.ProcedureModelType.SemiQualityStatistics)
  9611. {
  9612. errMsg = AddFinishCheckPDA(oracleTrConn, procedure, productionDataEntitys, sUserInfo);
  9613. }
  9614. #endregion
  9615. #region 入窑前检验
  9616. else if (procedure.ModelType == (int)Constant.ProcedureModelType.IntoKilnCheck)
  9617. {
  9618. errMsg = AddIntoKilnCheck(oracleTrConn, procedure, productionDataEntitys, sUserInfo);
  9619. }
  9620. #endregion
  9621. // 没有错误 提交事务
  9622. if (string.IsNullOrEmpty(errMsg))
  9623. {
  9624. oracleTrConn.Commit();
  9625. }
  9626. }
  9627. catch (Exception ex)
  9628. {
  9629. oracleTrConn.Rollback();
  9630. throw ex;
  9631. }
  9632. finally
  9633. {
  9634. // 释放资源
  9635. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  9636. {
  9637. oracleTrConn.Disconnect();
  9638. }
  9639. }
  9640. return errMsg;
  9641. }
  9642. #endregion
  9643. /// <summary>
  9644. /// 校验干补条码有效
  9645. /// </summary>
  9646. /// <param name="oracleTrConn">连接对象</param>
  9647. /// <param name="procedureID">工序ID</param>
  9648. /// <param name="barcode">条码</param>
  9649. /// <param name="goodsID">返回的产品ID</param>
  9650. /// <param name="goodsCode">返回的产品Code</param>
  9651. /// <param name="goodsName">返回的产品名称</param>
  9652. /// <param name="groutingUserID">返回的注浆者ID</param>
  9653. /// <returns>string</returns>
  9654. /// <remarks>
  9655. /// 袁新成 2015.3.27 新建
  9656. /// </remarks>
  9657. private static string CheckDryRepairBarcode(IDBTransaction oracleTrConn,
  9658. int procedureID,
  9659. string barcode,
  9660. out int goodsID,
  9661. out string goodsCode,
  9662. out string goodsName,
  9663. out string groutingUserCode,
  9664. SUserInfo sUserInfo
  9665. )
  9666. {
  9667. try
  9668. {
  9669. OracleParameter[] paras = new OracleParameter[]{
  9670. new OracleParameter("in_procedureid",OracleDbType.Int32,procedureID,ParameterDirection.Input),
  9671. new OracleParameter("in_barcode",OracleDbType.Varchar2,barcode,ParameterDirection.Input),
  9672. new OracleParameter("out_errMsg",OracleDbType.Varchar2,2000,"",ParameterDirection.Output),
  9673. new OracleParameter("out_goodsID",OracleDbType.Int32,ParameterDirection.Output),
  9674. new OracleParameter("out_goodsCode",OracleDbType.Varchar2,50,"",ParameterDirection.Output),
  9675. new OracleParameter("out_goodsName",OracleDbType.Varchar2,50,"",ParameterDirection.Output),
  9676. new OracleParameter("out_groutingUserCode",OracleDbType.NVarchar2,50,null,ParameterDirection.Output),
  9677. };
  9678. oracleTrConn.ExecStoredProcedure("pro_pm_checkdryrepairbarcode", paras);
  9679. if (!"null".Equals(paras[3].Value + ""))
  9680. {
  9681. goodsID = Convert.ToInt32(paras[3].Value + "");
  9682. }
  9683. else
  9684. {
  9685. goodsID = 0;
  9686. }
  9687. goodsCode = paras[4].Value + "";
  9688. goodsName = paras[5].Value + "";
  9689. if (!"null".Equals(paras[6].Value + ""))
  9690. {
  9691. groutingUserCode = paras[6].Value + "";
  9692. }
  9693. else
  9694. {
  9695. groutingUserCode = null;
  9696. }
  9697. if ("null".Equals(paras[2].Value + ""))
  9698. {
  9699. return null;
  9700. }
  9701. return paras[2].Value.ToString().Replace("\\n\\r", "\n\r");
  9702. }
  9703. catch (Exception ex)
  9704. {
  9705. throw ex;
  9706. }
  9707. }
  9708. /// <summary>
  9709. /// 干补标准计件
  9710. /// </summary>
  9711. /// <param name="oracleTrConn">数据连接对象</param>
  9712. /// <param name="procedure">工序对象</param>
  9713. /// <param name="barcodeTable">条码信息</param>
  9714. /// <param name="sUserInfo">用户基本信息</param>
  9715. /// <param name="goodsID">返回的产品ID</param>
  9716. /// <param name="goodsCode">返回的产品Code</param>
  9717. /// <param name="goodsName">返回的产品名称</param>
  9718. /// <param name="groutingUserID">返回的注浆者ID</param>
  9719. /// <returns>string</returns>
  9720. /// <remarks>
  9721. /// 袁新成 2015.3.26 新建
  9722. /// </remarks>
  9723. private static string AddDryRepairWorkPiece(IDBTransaction oracleTrConn,
  9724. ProcedureEntity procedure,
  9725. DataTable barcodeTable,
  9726. SUserInfo sUserInfo,
  9727. out int goodsID,
  9728. out string goodsCode,
  9729. out string goodsName,
  9730. out string groutingUserCode, out string logoCode, out string logoName, out string groutingdate)
  9731. {
  9732. try
  9733. {
  9734. int deleteRow = 0;
  9735. goodsID = Constant.INT_IS_ZERO;
  9736. goodsCode = null;
  9737. goodsName = null;
  9738. groutingUserCode = string.Empty; //Constant.INT_IS_ZERO;
  9739. // 获得账务日期
  9740. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  9741. string errMsg = string.Empty;
  9742. // 本批采集的批次号
  9743. string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  9744. // 条码信息
  9745. string logoName_Temp = "";
  9746. string logoCode_Temp = "";
  9747. string groutingdate_Temp = "";
  9748. foreach (DataRow barcodeRow in barcodeTable.Rows)
  9749. {
  9750. // 条码
  9751. string barcode = barcodeRow["Barcode"].ToString();
  9752. if (string.IsNullOrEmpty(barcode))
  9753. {
  9754. throw new Exception("传入的条码号为空");
  9755. }
  9756. // 生产工号
  9757. int workUserID = Convert.ToInt32(barcodeRow["UserID"]);
  9758. // 生产工号
  9759. string workUserCode = barcodeRow["UserCode"].ToString();
  9760. //#region 校验条码有效性
  9761. //errMsg = CheckDryRepairBarcode(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo);
  9762. //if (!string.IsNullOrEmpty(errMsg))
  9763. //{
  9764. // return errMsg;
  9765. //}
  9766. //#endregion
  9767. if (procedure.CollectType == 1)
  9768. {
  9769. #region 校验条码有效性
  9770. errMsg = CheckDryRepairBarcode(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo);
  9771. if (!string.IsNullOrEmpty(errMsg))
  9772. {
  9773. logoName = "";
  9774. logoCode = "";
  9775. groutingdate = "";
  9776. return errMsg;
  9777. }
  9778. #endregion
  9779. }
  9780. else
  9781. {
  9782. string sqlGroutingInfo = @"select tp_pm_groutingdailydetail.goodsid,
  9783. tp_pm_groutingdailydetail.goodscode,
  9784. tp_pm_groutingdailydetail.goodsname,
  9785. tp_pm_groutingdailydetail.usercode as groutingUserCode,
  9786. tp_pm_groutingdailydetail.groutingdate,
  9787. tp_mst_logo.logoid,
  9788. tp_mst_logo.logocode,
  9789. tp_mst_logo.logoname
  9790. from tp_pm_groutingdailydetail
  9791. left join tp_mst_logo
  9792. on tp_pm_groutingdailydetail.logoid=tp_mst_logo.logoid
  9793. where tp_pm_groutingdailydetail.barcode=:barcode
  9794. ";
  9795. OracleParameter[] paras = new OracleParameter[] {
  9796. new OracleParameter(":barcode",barcode),
  9797. };
  9798. DataSet dsGrouting = oracleTrConn.GetSqlResultToDs(sqlGroutingInfo, paras);
  9799. if (dsGrouting != null && dsGrouting.Tables[0].Rows.Count > 0)
  9800. {
  9801. goodsID = Convert.ToInt32(dsGrouting.Tables[0].Rows[0]["goodsid"]);
  9802. goodsCode = dsGrouting.Tables[0].Rows[0]["goodscode"].ToString();
  9803. goodsName = dsGrouting.Tables[0].Rows[0]["goodsName"].ToString();
  9804. groutingUserCode = dsGrouting.Tables[0].Rows[0]["groutingUserCode"].ToString();
  9805. logoName = dsGrouting.Tables[0].Rows[0]["logoName"].ToString();
  9806. logoCode = dsGrouting.Tables[0].Rows[0]["logoCode"].ToString();
  9807. groutingdate = dsGrouting.Tables[0].Rows[0]["groutingdate"].ToString();
  9808. logoName_Temp = logoName;
  9809. logoCode_Temp = logoCode;
  9810. groutingdate_Temp = groutingdate;
  9811. }
  9812. }
  9813. #region 数据处理
  9814. #region 处理废弃数据并转回收数据为在产数据
  9815. string querysql = @"select GOODSLEVELID from TP_MST_GOODSLEVEL where GOODSLEVELTYPEID=9 and ACCOUNTID=:accountid and VALUEFLAG=1";
  9816. OracleParameter[] queryparas = new OracleParameter[]{
  9817. new OracleParameter(":accountid",OracleDbType.Varchar2, sUserInfo.AccountID,ParameterDirection.Input)
  9818. };
  9819. DataSet returnDs = oracleTrConn.GetSqlResultToDs(querysql, queryparas);
  9820. if (returnDs == null || returnDs.Tables[0].Rows.Count == 0)
  9821. {
  9822. errMsg = "未设定干补等级";
  9823. logoName = "";
  9824. logoCode = "";
  9825. groutingdate = "";
  9826. return errMsg;
  9827. }
  9828. string goodsLevelID = returnDs.Tables[0].Rows[0][0].ToString();
  9829. //第一步,废弃数据的产品分级类别由 8损坯13不合格14不合格(返) 改为 9干补,产品分级=此账套相应的设置
  9830. /*string sqlUpdateLevelTypeString = @"update TP_PM_ScrapProduct set GOODSLEVELID=:GOODSLEVELID, GoodsLevelTypeID=9,SpecialRepairFlag=1,
  9831. SpecialRepairUserID=:SpecialRepairUserID,SpecialRepairUserCode=:SpecialRepairUserCode,SpecialRepairTime=sysdate,
  9832. UpdateUserID=:UpdateUserID
  9833. where BarCode=:barcode
  9834. and CreateTime=(select max(CreateTime) from TP_PM_ScrapProduct where BarCode=:barcode1 and ValueFlag=1)
  9835. and ValueFlag=1 and GoodsLevelTypeID=(select max(GoodsLevelTypeID) from TP_PM_ScrapProduct where BarCode=:barcode1 and ValueFlag=1) ";
  9836. */
  9837. // and ValueFlag=1 and GoodsLevelTypeID=8 ";
  9838. string sqlUpdateLevelTypeString = @"update TP_PM_ScrapProduct set GOODSLEVELID=:GOODSLEVELID, GoodsLevelTypeID=9,
  9839. SpecialRepairUserID=:SpecialRepairUserID,SpecialRepairUserCode=:SpecialRepairUserCode,SpecialRepairTime=sysdate,
  9840. UpdateUserID=:UpdateUserID
  9841. where BarCode=:barcode
  9842. and CreateTime=(select max(CreateTime) from TP_PM_ScrapProduct where BarCode=:barcode1 and ValueFlag=1)
  9843. and ValueFlag=1 and GoodsLevelTypeID in (8, 13, 14) ";
  9844. OracleParameter[] ScrapProductparas = new OracleParameter[]{
  9845. new OracleParameter(":GOODSLEVELID",OracleDbType.Int32,int.Parse(goodsLevelID),ParameterDirection.Input),
  9846. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  9847. new OracleParameter(":barcode1",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  9848. new OracleParameter(":SpecialRepairUserID",OracleDbType.Int32,workUserID,ParameterDirection.Input),
  9849. new OracleParameter(":SpecialRepairUserCode",OracleDbType.Varchar2,workUserCode,ParameterDirection.Input),
  9850. new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  9851. };
  9852. //modify wangx 20150623
  9853. OracleParameter[] sqlUpdateparas = new OracleParameter[]{
  9854. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  9855. };
  9856. //string sqlUpdate = "update TP_PM_InCheckedDetail set SpecialRepairFlag=1 where barcode=:barcode";
  9857. //oracleTrConn.ExecuteNonQuery(sqlUpdate, sqlUpdateparas);
  9858. string sqlUpdate = "update TP_PM_ProductionDataIn set SpecialRepairFlag=1 where barcode=:barcode";
  9859. oracleTrConn.ExecuteNonQuery(sqlUpdate, sqlUpdateparas);
  9860. //modify wangx 20150623 end
  9861. #region
  9862. //第五步,插入干补工序的生产数据(同其他计件工序),设置干补标识,产品分级类别=9干补,产品分级=此账套相应的设置
  9863. // 查询新插入的生产数据ID
  9864. string sql = "select SEQ_PM_ProductionData_ID.nextval from dual";
  9865. string idStr = oracleTrConn.GetSqlResultToStr(sql);
  9866. int productionDataID = 0;
  9867. if (!string.IsNullOrEmpty(idStr))
  9868. {
  9869. productionDataID = int.Parse(idStr);
  9870. }
  9871. else
  9872. {
  9873. logoName = "";
  9874. logoCode = "";
  9875. groutingdate = "";
  9876. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  9877. }
  9878. int? ClassesSettingID = null;//班次配置ID
  9879. #region 第五步 添加生产者数据
  9880. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID);
  9881. if (!string.IsNullOrEmpty(errMsg))
  9882. {
  9883. logoName = "";
  9884. logoCode = "";
  9885. groutingdate = "";
  9886. return errMsg;
  9887. }
  9888. #endregion
  9889. ProductionDataEntity productionData = new ProductionDataEntity();
  9890. #region 属性赋值
  9891. productionData.ClassesSettingID = ClassesSettingID;
  9892. productionData.ProductionDataID = Convert.ToInt32(idStr);
  9893. productionData.Barcode = barcode;
  9894. productionData.CentralizedBatchNo = centralizedBatchNo;
  9895. productionData.ProductionLineID = procedure.ProductionLineID;
  9896. productionData.ProductionLineCode = procedure.ProductionlineCode;
  9897. productionData.ProductionLineName = procedure.ProductionlineName;
  9898. productionData.CompleteProcedureID = procedure.ProcedureID;
  9899. productionData.ProcedureCode = procedure.ProcedureCode;
  9900. productionData.ProcedureName = procedure.ProcedureName;
  9901. productionData.ProcedureModel = procedure.ProcedureModel;
  9902. productionData.ModelType = procedure.ModelType;
  9903. productionData.NodeType = procedure.NodeType;
  9904. productionData.DefectFlag = (int)Constant.DefectFlag.No;
  9905. productionData.ReworkProcedureID = null;
  9906. productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, barcode);
  9907. productionData.IsReFire = (int)Constant.ReFireFlag.No;
  9908. //设置干补标识,产品分级类别=9干补
  9909. productionData.GoodsLevelTypeID = 9;
  9910. productionData.GoodsLevelID = int.Parse(goodsLevelID);
  9911. productionData.GoodsGrade = (int)Constant.GoodsGrade.Good;
  9912. productionData.OrganizationID = procedure.OrganizationID;
  9913. productionData.GoodsID = goodsID;
  9914. productionData.GoodsCode = goodsCode;
  9915. productionData.GoodsName = goodsName;
  9916. productionData.UserID = workUserID;
  9917. productionData.UserCode = barcodeRow["UserCode"].ToString();
  9918. productionData.UserName = barcodeRow["UserName"].ToString();
  9919. productionData.PieceType = procedure.PieceType;
  9920. if (barcodeRow["LogoID"].ToString() != "")
  9921. {
  9922. productionData.LogoID = Convert.ToInt32(barcodeRow["LogoID"]);
  9923. }
  9924. string sqlReFire = @"select
  9925. isrefire,
  9926. logoid
  9927. from tp_pm_inproduction where barcode=:barcode
  9928. union
  9929. select
  9930. isrefire,
  9931. logoid
  9932. from TP_PM_InProductionTrash where barcode=:barcode
  9933. union
  9934. select
  9935. isrefire,
  9936. logoid
  9937. from TP_PM_FinishedProduct where barcode=:barcode ";
  9938. OracleParameter[] ReFireparas = new OracleParameter[] {
  9939. new OracleParameter(":barcode",barcode),
  9940. };
  9941. DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas);
  9942. if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0)
  9943. {
  9944. if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0)
  9945. {
  9946. productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]);
  9947. }
  9948. if (dsReFire.Tables[0].Rows[0]["logoid"].ToString() != "")
  9949. {
  9950. productionData.LogoID = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["LogoID"]);
  9951. }
  9952. }
  9953. #endregion 属性赋值
  9954. string OutSpecialRepairflag = "0";//干补标识
  9955. productionData.SpecialRepairflag = 1;
  9956. errMsg = AddDryRepairProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag);
  9957. if (!string.IsNullOrEmpty(errMsg))
  9958. {
  9959. logoName = "";
  9960. logoCode = "";
  9961. groutingdate = "";
  9962. return errMsg;
  9963. }
  9964. #endregion
  9965. //第二步,回收站中数据回到在产中,设置干补标识。
  9966. string sqlInsInProdString = @"insert into TP_PM_InProduction(BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME,
  9967. PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID,
  9968. ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME,
  9969. USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE,
  9970. GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID,
  9971. CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE,
  9972. REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME,
  9973. CREATEUSERID, UPDATETIME, UPDATEUSERID,
  9974. ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG,
  9975. GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM,
  9976. KILNID, KILNCODE, KILNNAME, KILNCARID,
  9977. KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID
  9978. ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,logoid, ISREWORKFLAG, SEMICHECKID)
  9979. select BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME,
  9980. :PROCEDUREMODEL, :MODELTYPE, REWORKPROCEDUREID,
  9981. ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME,
  9982. USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE,
  9983. GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID,
  9984. CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE,
  9985. REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME,
  9986. CREATEUSERID, UPDATETIME, :UpdateUserID,
  9987. ISREFIRE, null, null, DEFECTFLAG,
  9988. GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM,
  9989. KILNID, KILNCODE, KILNNAME, KILNCARID,
  9990. KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,1,FlowProcedureID ,
  9991. FlowProcedureTime,:ProcedureID,sysdate,:ProductionDataID,logoid, ISREWORKFLAG, SEMICHECKID
  9992. from TP_PM_InProductionTrash where barcode=:barcode ";
  9993. OracleParameter[] InProductparas = new OracleParameter[]{
  9994. new OracleParameter(":UpdateUserID",OracleDbType.Int32, workUserID,ParameterDirection.Input),
  9995. // new OracleParameter(":GOODSLEVELID",OracleDbType.Int32,int.Parse(goodsLevelID),ParameterDirection.Input),
  9996. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  9997. new OracleParameter(":ProcedureID",OracleDbType.Int32,procedure.ProcedureID,ParameterDirection.Input),
  9998. new OracleParameter(":PROCEDUREMODEL",OracleDbType.Varchar2,procedure.ProcedureModel,ParameterDirection.Input),
  9999. new OracleParameter(":MODELTYPE",OracleDbType.Int32,procedure.ModelType,ParameterDirection.Input),
  10000. new OracleParameter(":ProductionDataID",OracleDbType.Int32,productionDataID,ParameterDirection.Input)
  10001. };
  10002. //第三步,删除回收站中的条码
  10003. string sqlDelInProductTrashString = "delete from TP_PM_InProductionTrash where barcode=:barcode ";
  10004. OracleParameter[] TrashProductparas = new OracleParameter[]{
  10005. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input)
  10006. };
  10007. //第四步,更新注浆表干补标识
  10008. // string sqlUpGroutingDeilString = @"update TP_PM_GroutingDailyDetail set SpecialRepairFlag=1
  10009. // where GroutingDailyDetailID=(select GroutingDailyDetailID from TP_PM_GROUTINGPRODUCT
  10010. // where barcode=:barcode)";
  10011. string sqlUpGroutingDeilString = @"update TP_PM_GroutingDailyDetail set SpecialRepairFlag=1
  10012. where barcode=:barcode";
  10013. OracleParameter[] GroutingProductparas = new OracleParameter[]{
  10014. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input)
  10015. };
  10016. // string sqlUpCompleteString = @"update TP_PM_FINISHEDPRODUCT set SpecialRepairFlag=1
  10017. // where barcode=:barcode ";
  10018. // OracleParameter[] CompleteProductparas = new OracleParameter[]{
  10019. // new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input)
  10020. // };
  10021. deleteRow += oracleTrConn.ExecuteNonQuery(sqlUpdateLevelTypeString, ScrapProductparas);
  10022. deleteRow += oracleTrConn.ExecuteNonQuery(sqlInsInProdString, InProductparas);
  10023. deleteRow += oracleTrConn.ExecuteNonQuery(sqlDelInProductTrashString, TrashProductparas);
  10024. deleteRow += oracleTrConn.ExecuteNonQuery(sqlUpGroutingDeilString, GroutingProductparas);
  10025. //deleteRow += oracleTrConn.ExecuteNonQuery(sqlUpCompleteString, CompleteProductparas); //由于成品后,不能报损,所以这个执行去掉
  10026. // 失败
  10027. if (deleteRow == Constant.INT_IS_ZERO)
  10028. {
  10029. logoName = "";
  10030. logoCode = "";
  10031. groutingdate = "";
  10032. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  10033. }
  10034. #endregion
  10035. //#region 第五步 添加生产者数据
  10036. //errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo);
  10037. //if (!string.IsNullOrEmpty(errMsg))
  10038. //{
  10039. // return errMsg;
  10040. //}
  10041. //#endregion
  10042. //第五步,回添加生产数据 modify wangx 2015/07/20 新添加的代码
  10043. sql = "select 1 from tp_pm_productiondatain where barcode=:barcode and valueflag=1";
  10044. OracleParameter[] Paras = new OracleParameter[] {
  10045. new OracleParameter(":barcode",OracleDbType.Varchar2,
  10046. barcode,ParameterDirection.Input)
  10047. };
  10048. DataSet ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  10049. if (ds.Tables[0].Rows.Count == 0)
  10050. {
  10051. // 2 生产数据恢复到在产生产数据
  10052. sql = @"insert into tp_pm_productiondatain
  10053. (
  10054. ProductionDataID,
  10055. BarCode,
  10056. CentralizedBatchNo,
  10057. ProductionLineID,
  10058. ProductionLineCode,
  10059. ProductionLineName,
  10060. ProcedureID,
  10061. ProcedureCode,
  10062. ProcedureName,
  10063. ProcedureModel,
  10064. ModelType,
  10065. PieceType,
  10066. IsReworked,
  10067. NodeType,
  10068. IsPublicBody,
  10069. IsReFire,
  10070. GoodsLevelID,
  10071. GoodsLevelTypeID,
  10072. SpecialRepairFlag,
  10073. OrganizationID,
  10074. GoodsID,
  10075. GoodsCode,
  10076. GoodsName,
  10077. UserID,
  10078. UserCode,
  10079. UserName,
  10080. ClassesSettingID,
  10081. KilnID,
  10082. KilnCode,
  10083. KilnName,
  10084. KilnCarID,
  10085. KilnCarCode,
  10086. KilnCarName,
  10087. KilnCarBatchNo,
  10088. KilnCarPosition,
  10089. ReworkProcedureID,
  10090. ReworkProcedureCode,
  10091. ReworkProcedureName,
  10092. GroutingDailyID,
  10093. GroutingDailyDetailID,
  10094. GroutingLineID,
  10095. GroutingLineCode,
  10096. GroutingLineName,
  10097. GMouldTypeID,
  10098. CanManyTimes,
  10099. GroutingLineDetailID,
  10100. GroutingDate,
  10101. GroutingMouldCode,
  10102. MouldCode,
  10103. GroutingUserID,
  10104. GroutingUserCode,
  10105. GroutingNum,
  10106. Remarks,
  10107. AccountDate,
  10108. SettlementFlag,
  10109. AccountID,
  10110. ValueFlag,
  10111. CreateTime,
  10112. CreateUserID,
  10113. UpdateTime,
  10114. UpdateUserID,
  10115. OPTimeStamp,
  10116. TriggerFlag,
  10117. logoid,
  10118. BackOutTime,BackOutUserID,BackOutUserCode
  10119. )
  10120. select
  10121. ProductionDataID,
  10122. BarCode,
  10123. CentralizedBatchNo,
  10124. ProductionLineID,
  10125. ProductionLineCode,
  10126. ProductionLineName,
  10127. ProcedureID,
  10128. ProcedureCode,
  10129. ProcedureName,
  10130. ProcedureModel,
  10131. ModelType,
  10132. PieceType,
  10133. IsReworked,
  10134. NodeType,
  10135. IsPublicBody,
  10136. IsReFire,
  10137. GoodsLevelID,
  10138. GoodsLevelTypeID,
  10139. SpecialRepairFlag,
  10140. OrganizationID,
  10141. GoodsID,
  10142. GoodsCode,
  10143. GoodsName,
  10144. UserID,
  10145. UserCode,
  10146. UserName,
  10147. ClassesSettingID,
  10148. KilnID,
  10149. KilnCode,
  10150. KilnName,
  10151. KilnCarID,
  10152. KilnCarCode,
  10153. KilnCarName,
  10154. KilnCarBatchNo,
  10155. KilnCarPosition,
  10156. ReworkProcedureID,
  10157. ReworkProcedureCode,
  10158. ReworkProcedureName,
  10159. GroutingDailyID,
  10160. GroutingDailyDetailID,
  10161. GroutingLineID,
  10162. GroutingLineCode,
  10163. GroutingLineName,
  10164. GMouldTypeID,
  10165. CanManyTimes,
  10166. GroutingLineDetailID,
  10167. GroutingDate,
  10168. GroutingMouldCode,
  10169. MouldCode,
  10170. GroutingUserID,
  10171. GroutingUserCode,
  10172. GroutingNum,
  10173. Remarks,
  10174. AccountDate,
  10175. SettlementFlag,
  10176. AccountID,
  10177. ValueFlag,
  10178. CreateTime,
  10179. CreateUserID,
  10180. UpdateTime,
  10181. UpdateUserID,
  10182. OPTimeStamp,
  10183. 1,
  10184. logoid,
  10185. BackOutTime,BackOutUserID,BackOutUserCode
  10186. from TP_PM_ProductionData where valueflag=1 and barcode=:barcode
  10187. ";
  10188. oracleTrConn.ExecuteNonQuery(sql, Paras);
  10189. }
  10190. //第五步,回添加生产数据 modify wangx 2015/07/20 新添加的代码 end
  10191. #endregion 数据处理
  10192. }
  10193. logoName = logoName_Temp;
  10194. logoCode = logoCode_Temp;
  10195. groutingdate = groutingdate_Temp;
  10196. return errMsg;
  10197. }
  10198. catch (Exception ex)
  10199. {
  10200. throw ex;
  10201. }
  10202. }
  10203. /// <summary>
  10204. /// 添加干补生产数据
  10205. /// </summary>
  10206. /// <param name="oracleTrConn">连接对象</param>
  10207. /// <param name="accountDate">账务日期</param>
  10208. /// <param name="productionData">生产数据</param>
  10209. /// <param name="sUserInfo">用户基本信息</param>
  10210. /// <returns>string</returns>
  10211. /// <remarks>
  10212. /// 袁新成 2015.04.1 新建
  10213. /// </remarks>
  10214. private static string AddDryRepairProductionData(IDBTransaction oracleTrConn, DateTime accountDate, ProductionDataEntity productionData, SUserInfo sUserInfo, out string OutSpecialRepairflag)
  10215. {
  10216. #region 查出产品注浆日期,注浆工号ID,注浆工号编码,注浆次数,注浆模具编号,模具编号
  10217. string selectSql = "";
  10218. string returnVal = "";
  10219. //这地方连了两张表,为了成检的时候,次品在次新增
  10220. selectSql = @"select
  10221. GroutingDate,
  10222. GroutingUserID,
  10223. GroutingUserCode,
  10224. GroutingNum,
  10225. GroutingMouldCode,
  10226. MouldCode,
  10227. GroutingDailyID,
  10228. GroutingDailyDetailID,
  10229. GroutingLineID,
  10230. GroutingLineCode,
  10231. GroutingLineName,
  10232. GMouldTypeID,
  10233. CanManyTimes,
  10234. GroutingLineDetailID,
  10235. SpecialRepairflag
  10236. from tp_pm_inproduction where barcode=:barcode
  10237. union
  10238. select
  10239. GroutingDate,
  10240. GroutingUserID,
  10241. GroutingUserCode,
  10242. GroutingNum,
  10243. GroutingMouldCode,
  10244. MouldCode,
  10245. GroutingDailyID,
  10246. GroutingDailyDetailID,
  10247. GroutingLineID,
  10248. GroutingLineCode,
  10249. GroutingLineName,
  10250. GMouldTypeID,
  10251. CanManyTimes,
  10252. GroutingLineDetailID,
  10253. SpecialRepairflag
  10254. from TP_PM_InProductionTrash where barcode=:barcode
  10255. ";
  10256. OracleParameter[] selectparas = new OracleParameter[] {
  10257. new OracleParameter(":barcode",productionData.Barcode),
  10258. };
  10259. DataSet dsGroutingProduct = oracleTrConn.GetSqlResultToDs(selectSql, selectparas);
  10260. if (dsGroutingProduct == null || dsGroutingProduct.Tables[0].Rows.Count == 0)
  10261. {
  10262. selectSql = @"select TP_PM_GroutingDaily.GroutingDate,
  10263. TP_PM_GroutingDailyDetail.UserID as GroutingUserID,
  10264. TP_PM_GroutingDailyDetail.UserCode as GroutingUserCode,
  10265. TP_PM_GroutingDailyDetail.GroutingCount as GroutingNum,
  10266. TP_PM_GroutingDailyDetail.GroutingMouldCode,
  10267. TP_PM_GroutingDailyDetail.MouldCode,
  10268. TP_PM_GroutingDailyDetail.GroutingDailyID,
  10269. TP_PM_GroutingDailyDetail.GroutingDailyDetailID,
  10270. TP_PM_GroutingDailyDetail.GroutingLineID,
  10271. TP_PM_GroutingDailyDetail.GroutingLineCode,
  10272. TP_PM_GroutingDailyDetail.GroutingLineName,
  10273. TP_PM_GroutingDaily.GMouldTypeID,
  10274. TP_PM_GroutingDaily.CanManyTimes,
  10275. TP_PM_GroutingDailyDetail.GroutingLineDetailID,
  10276. TP_PM_GroutingDailyDetail.SpecialRepairflag
  10277. from TP_PM_GroutingDaily
  10278. left join TP_PM_GroutingDailyDetail
  10279. on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_GroutingDailyDetail.GroutingDailyID
  10280. where TP_PM_GroutingDailyDetail.barcode=:barcode
  10281. ";
  10282. dsGroutingProduct = oracleTrConn.GetSqlResultToDs(selectSql, selectparas);
  10283. }
  10284. DateTime GroutingDate = new DateTime();
  10285. int GroutingUserID = 0, GroutingNum = 0, GroutingDailyID = 0, GroutingDailyDetailID = 0, GroutingLineID = 0, GMouldTypeID = 0, CanManyTimes = 0, GroutingLineDetailID = 0, SpecialRepairflag = 0;
  10286. string GroutingUserCode = "", GroutingMouldCode = "", MouldCode = "", GroutingLineCode = "", GroutingLineName = "";
  10287. if (dsGroutingProduct != null && dsGroutingProduct.Tables[0].Rows.Count > 0)
  10288. {
  10289. GroutingDate = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
  10290. GroutingUserID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingUserID"]);
  10291. GroutingUserCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"].ToString();
  10292. GroutingNum = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"]);
  10293. GroutingMouldCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingMouldCode"].ToString();
  10294. MouldCode = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"].ToString();
  10295. GroutingDailyID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyID"]);
  10296. GroutingDailyDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyDetailID"]);
  10297. GroutingLineID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineID"]);
  10298. GroutingLineCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineCode"].ToString();
  10299. GroutingLineName = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineName"].ToString();
  10300. GMouldTypeID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GMouldTypeID"]);
  10301. CanManyTimes = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["CanManyTimes"]);
  10302. GroutingLineDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineDetailID"]);
  10303. SpecialRepairflag = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["SpecialRepairflag"]);
  10304. returnVal = SpecialRepairflag.ToString();
  10305. }
  10306. #endregion
  10307. #region 更新窑炉窑车属性
  10308. if (productionData.ModelType != 1 && productionData.ModelType != 2 && productionData.ModelType != 3 && productionData.ModelType != 4)
  10309. {
  10310. DataSet ds = GetDryRepairKilnCarInfo(oracleTrConn, productionData.Barcode, sUserInfo);
  10311. if (ds != null)
  10312. {
  10313. if (ds.Tables[0].Rows[0]["KilnID"].ToString() != "") //表示以前有过窑炉相关信息
  10314. {
  10315. productionData.KilnID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnID"]);
  10316. productionData.KilnCode = ds.Tables[0].Rows[0]["KilnCode"].ToString();
  10317. productionData.KilnName = ds.Tables[0].Rows[0]["KilnName"].ToString();
  10318. productionData.KilnCarID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarID"]);
  10319. productionData.KilnCarCode = ds.Tables[0].Rows[0]["KilnCarCode"].ToString();
  10320. productionData.KilnCarName = ds.Tables[0].Rows[0]["KilnCarName"].ToString();
  10321. productionData.KilnCarBatchNo = ds.Tables[0].Rows[0]["KilnCarBatchNo"].ToString();
  10322. productionData.KilnCarPosition = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarPosition"]);
  10323. }
  10324. }
  10325. }
  10326. #endregion
  10327. #region SQL
  10328. string sql = "insert into tp_pm_productiondataIn"
  10329. + " (productiondataid,"
  10330. + " barcode,"
  10331. + " centralizedbatchno,"
  10332. + " productionlineid,"
  10333. + " productionlinecode,"
  10334. + " productionlinename,"
  10335. + " procedureid,"
  10336. + " procedurecode,"
  10337. + " procedurename,"
  10338. + " proceduremodel,"
  10339. + " modeltype,"
  10340. + " piecetype,"
  10341. + " isreworked,"
  10342. + " nodetype,"
  10343. + " ispublicbody,"
  10344. + " isrefire,"
  10345. + " organizationid,"
  10346. + " goodsid,"
  10347. + " goodscode,"
  10348. + " goodsname,"
  10349. + " userid,"
  10350. + " usercode,"
  10351. + " username,"
  10352. + " kilnid,"
  10353. + " kilncode,"
  10354. + " kilnname,"
  10355. + " kilncarid,"
  10356. + " kilncarcode,"
  10357. + " kilncarname,"
  10358. + " kilncarbatchno,"
  10359. + " kilncarposition,"
  10360. + " reworkprocedureid,"
  10361. + " reworkprocedurecode,"
  10362. + " reworkprocedurename,"
  10363. + " remarks,"
  10364. + " accountdate,"
  10365. + " accountid,"
  10366. + " GoodsLevelID,"
  10367. + " GoodsLevelTypeID,"
  10368. + " createuserid,"
  10369. + " updateuserid,"
  10370. + " GroutingDate,"
  10371. + " GroutingUserID,"
  10372. + " GroutingUserCode,"
  10373. + " GroutingNum,"
  10374. + " GroutingMouldCode,"
  10375. + " MouldCode,"
  10376. + "GroutingDailyID,"
  10377. + "GroutingDailyDetailID,"
  10378. + "GroutingLineID,"
  10379. + " GroutingLineCode,"
  10380. + "GroutingLineName,"
  10381. + "GMouldTypeID,"
  10382. + "CanManyTimes,"
  10383. + "GroutingLineDetailID,"
  10384. + "SpecialRepairflag,"
  10385. + "ClassesSettingID,"
  10386. + "LogoID"
  10387. + ")"
  10388. + " values"
  10389. + " (:productiondataid,"
  10390. + " :barcode,"
  10391. + " :centralizedbatchno,"
  10392. + " :productionlineid,"
  10393. + " :productionlinecode,"
  10394. + " :productionlinename,"
  10395. + " :procedureid,"
  10396. + " :procedurecode,"
  10397. + " :procedurename,"
  10398. + " :proceduremodel,"
  10399. + " :modeltype,"
  10400. + " :piecetype,"
  10401. + " :isreworked,"
  10402. + " :nodetype,"
  10403. + " :ispublicbody,"
  10404. + " :isrefire,"
  10405. + " :organizationid,"
  10406. + " :goodsid,"
  10407. + " :goodscode,"
  10408. + " :goodsname,"
  10409. + " :userid,"
  10410. + " :usercode,"
  10411. + " :username,"
  10412. + " :kilnid,"
  10413. + " :kilncode,"
  10414. + " :kilnname,"
  10415. + " :kilncarid,"
  10416. + " :kilncarcode,"
  10417. + " :kilncarname,"
  10418. + " :kilncarbatchno,"
  10419. + " :kilncarposition,"
  10420. + " :reworkprocedureid,"
  10421. + " :reworkprocedurecode,"
  10422. + " :reworkprocedurename,"
  10423. + " :remarks,"
  10424. + " :accountdata,"
  10425. + " :accountid,"
  10426. + " :GoodsLevelID,"
  10427. + " :GoodsLevelTypeID,"
  10428. + " :createuserid,"
  10429. + " :updateuserid,"
  10430. + " :groutingdate,"
  10431. + " :groutinguserid,"
  10432. + " :groutingusercode,"
  10433. + " :groutingnum,"
  10434. + " :groutingmouldcode,"
  10435. + " :mouldcode,"
  10436. + ":groutingdailyid,"
  10437. + ":groutingdailydetailid,"
  10438. + ":groutinglineid,"
  10439. + " :groutinglinecode,"
  10440. + ":groutinglinename,"
  10441. + ":gmouldtypeid,"
  10442. + ":canmanytimes,"
  10443. + ":groutinglinedetailid,"
  10444. + ":specialRepairflag,"
  10445. + ":classesSettingID,"
  10446. + ":logoID"
  10447. + ")";
  10448. #endregion
  10449. #region OracleParameter
  10450. OracleParameter[] paras = new OracleParameter[] {
  10451. new OracleParameter(":productiondataid",productionData.ProductionDataID),
  10452. new OracleParameter(":barcode",productionData.Barcode),
  10453. new OracleParameter(":centralizedbatchno",productionData.CentralizedBatchNo),
  10454. new OracleParameter(":productionlineid",productionData.ProductionLineID),
  10455. new OracleParameter(":productionlinecode",productionData.ProductionLineCode),
  10456. new OracleParameter(":productionlinename",productionData.ProductionLineName),
  10457. new OracleParameter(":procedureid",productionData.CompleteProcedureID),
  10458. new OracleParameter(":procedurecode",productionData.ProcedureCode),
  10459. new OracleParameter(":procedurename",productionData.ProcedureName),
  10460. new OracleParameter(":proceduremodel",productionData.ProcedureModel),
  10461. new OracleParameter(":modeltype",productionData.ModelType),
  10462. new OracleParameter(":piecetype",productionData.PieceType),
  10463. new OracleParameter(":isreworked",productionData.IsReworked),
  10464. new OracleParameter(":nodetype",productionData.NodeType),
  10465. new OracleParameter(":ispublicbody",productionData.IsPublicBody),
  10466. new OracleParameter(":isrefire",productionData.IsReFire),
  10467. new OracleParameter(":organizationid",productionData.OrganizationID),
  10468. new OracleParameter(":goodsid",productionData.GoodsID),
  10469. new OracleParameter(":goodscode",productionData.GoodsCode),
  10470. new OracleParameter(":goodsname",productionData.GoodsName),
  10471. new OracleParameter(":userid",productionData.UserID),
  10472. new OracleParameter(":usercode",productionData.UserCode),
  10473. new OracleParameter(":username",productionData.UserName),
  10474. new OracleParameter(":kilnid",productionData.KilnID),
  10475. new OracleParameter(":kilncode",productionData.KilnCode),
  10476. new OracleParameter(":kilnname",productionData.KilnName),
  10477. new OracleParameter(":kilncarid",productionData.KilnCarID),
  10478. new OracleParameter(":kilncarcode",productionData.KilnCarCode),
  10479. new OracleParameter(":kilncarname",productionData.KilnCarName),
  10480. new OracleParameter(":kilncarbatchno",productionData.KilnCarBatchNo),
  10481. new OracleParameter(":kilncarposition",productionData.KilnCarPosition),
  10482. new OracleParameter(":reworkprocedureid",productionData.ReworkProcedureID),
  10483. new OracleParameter(":reworkprocedurecode",productionData.ReworkProcedureCode),
  10484. new OracleParameter(":reworkprocedurename",productionData.ReworkProcedureName),
  10485. new OracleParameter(":remarks",productionData.Remarks),
  10486. new OracleParameter(":accountdata",accountDate),
  10487. new OracleParameter(":accountid",sUserInfo.AccountID),
  10488. new OracleParameter(":GoodsLevelID",productionData.GoodsLevelID),
  10489. new OracleParameter(":GoodsLevelTypeID",productionData.GoodsLevelTypeID),
  10490. new OracleParameter(":createuserid",sUserInfo.UserID),
  10491. new OracleParameter(":updateuserid",sUserInfo.UserID),
  10492. new OracleParameter(":groutingdate",GroutingDate),
  10493. new OracleParameter(":groutinguserid",GroutingUserID),
  10494. new OracleParameter(":groutingusercode",GroutingUserCode),
  10495. new OracleParameter(":groutingnum",GroutingNum),
  10496. new OracleParameter(":groutingmouldcode",GroutingMouldCode),
  10497. new OracleParameter(":mouldcode",MouldCode),
  10498. new OracleParameter(":groutingdailyid",GroutingDailyID),
  10499. new OracleParameter(":groutingdailydetailid",GroutingDailyDetailID),
  10500. new OracleParameter(":groutinglineid",GroutingLineID),
  10501. new OracleParameter(":groutinglinecode",GroutingLineCode),
  10502. new OracleParameter(":groutinglinename",GroutingLineName),
  10503. new OracleParameter(":gmouldtypeid",GMouldTypeID),
  10504. new OracleParameter(":canmanytimes",CanManyTimes),
  10505. new OracleParameter(":groutinglinedetailid",GroutingLineDetailID),
  10506. new OracleParameter(":specialRepairflag",productionData.SpecialRepairflag),
  10507. new OracleParameter(":classesSettingID",productionData.ClassesSettingID),
  10508. new OracleParameter(":logoID",productionData.LogoID),
  10509. };
  10510. #endregion
  10511. foreach (OracleParameter para in paras)
  10512. {
  10513. if (string.IsNullOrEmpty(para.Value + ""))
  10514. {
  10515. para.Value = DBNull.Value;
  10516. }
  10517. }
  10518. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  10519. OutSpecialRepairflag = returnVal;
  10520. // 失败
  10521. if (result != Constant.INT_IS_ONE)
  10522. {
  10523. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  10524. }
  10525. // 成功返回null
  10526. return null;
  10527. }
  10528. /// <summary>
  10529. /// 根据最大生产数据ID,获取窑车窑炉等信息
  10530. /// </summary>
  10531. /// <param name="oracleTrConn"></param>
  10532. /// <param name="barcode"></param>
  10533. /// <param name="sUserInfo"></param>
  10534. /// <returns></returns>
  10535. private static DataSet GetDryRepairKilnCarInfo(IDBTransaction oracleTrConn, string barcode, SUserInfo sUserInfo)
  10536. {
  10537. // string sql = @"select * from tp_pm_productiondata where Productiondataid=
  10538. // (
  10539. // select nvl(max(Productiondataid),0) Productiondataid from tp_pm_productiondata where barcode=:barcode
  10540. // )";
  10541. string sql = @"select
  10542. KilnID,
  10543. KilnCode,
  10544. KilnName,
  10545. KilnCarID,
  10546. KilnCarCode,
  10547. KilnCarName,
  10548. to_char(KilnCarBatchNo) as KilnCarBatchNo,
  10549. KilnCarPosition
  10550. from tp_pm_inproduction where barcode=:barcode
  10551. union
  10552. select
  10553. KilnID,
  10554. KilnCode,
  10555. KilnName,
  10556. KilnCarID,
  10557. KilnCarCode,
  10558. KilnCarName,
  10559. to_char(KilnCarBatchNo) as KilnCarBatchNo,
  10560. KilnCarPosition
  10561. from TP_PM_InProductionTrash where barcode=:barcode
  10562. ";
  10563. try
  10564. {
  10565. IDataParameter[] paras = new OracleParameter[]
  10566. {
  10567. new OracleParameter(":barcode", OracleDbType.Varchar2, barcode, ParameterDirection.Input),
  10568. };
  10569. DataSet returnDs = oracleTrConn.GetSqlResultToDs(sql, paras);
  10570. if (returnDs != null
  10571. && returnDs.Tables.Count > Constant.INT_IS_ZERO
  10572. && returnDs.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  10573. {
  10574. return returnDs;
  10575. }
  10576. else
  10577. {
  10578. sql = @"select
  10579. KilnID,
  10580. KilnCode,
  10581. KilnName,
  10582. KilnCarID,
  10583. KilnCarCode,
  10584. KilnCarName,
  10585. to_char(KilnCarBatchNo) as KilnCarBatchNo,
  10586. KilnCarPosition
  10587. from TP_PM_FINISHEDPRODUCT where barcode=:barcode";
  10588. returnDs = oracleTrConn.GetSqlResultToDs(sql, paras);
  10589. if (returnDs != null
  10590. && returnDs.Tables.Count > Constant.INT_IS_ZERO
  10591. && returnDs.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  10592. {
  10593. return returnDs;
  10594. }
  10595. else
  10596. {
  10597. return null;
  10598. }
  10599. }
  10600. }
  10601. catch (Exception ex)
  10602. {
  10603. throw ex;
  10604. }
  10605. }
  10606. /// <summary>
  10607. /// 更新漏扫的成型工号
  10608. /// </summary>
  10609. /// <param name="groutingUserCode">成型工号</param>
  10610. /// <param name="missingID">漏扫ID</param>
  10611. /// <param name="sUserInfo">用户基本信息</param>
  10612. /// <returns>int</returns>
  10613. public static int UpdateGroutingUserCodeByMissingID(string groutingUserCode, int missingID, SUserInfo sUserInfo)
  10614. {
  10615. int UpdateRow = 0;
  10616. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  10617. try
  10618. {
  10619. oracleTrConn.Connect();
  10620. //string sql = "select userid from tp_mst_user where usercode=:usercode and valueflag=1 and isworker=1 and accountid=:accountid";
  10621. //OracleParameter[] paras = new OracleParameter[]{
  10622. // new OracleParameter(":usercode",OracleDbType.Varchar2, groutingUserCode,ParameterDirection.Input),
  10623. // new OracleParameter(":accountid", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  10624. //};
  10625. //DataSet returnDataset = oracleTrConn.GetSqlResultToDs(sql, paras);
  10626. //if (returnDataset != null && returnDataset.Tables[0].Rows.Count == 0)
  10627. //{
  10628. // oracleTrConn.Commit();
  10629. // UpdateRow = -1;
  10630. // return UpdateRow;//成型工号无效
  10631. //}
  10632. // 20150605 wangxin begin
  10633. string[] subGroutingUserCode = groutingUserCode.Trim(',').Split(',');
  10634. bool isError = false;
  10635. int FirstUserID = 0;
  10636. string sql = "";
  10637. OracleParameter[] paras = null;
  10638. DataSet returnDataset = null;
  10639. for (int i = 0; i < subGroutingUserCode.Length; i++)
  10640. {
  10641. sql = "select userid from tp_mst_user where usercode=:usercode and valueflag=1 and isworker=1 and accountid=:accountid";
  10642. paras = new OracleParameter[]{
  10643. new OracleParameter(":usercode",OracleDbType.Varchar2, subGroutingUserCode[i],ParameterDirection.Input),
  10644. new OracleParameter(":accountid", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  10645. };
  10646. returnDataset = oracleTrConn.GetSqlResultToDs(sql, paras);
  10647. if (returnDataset != null && returnDataset.Tables[0].Rows.Count == 0)
  10648. {
  10649. isError = true;
  10650. break;
  10651. }
  10652. if (i == 0)
  10653. {
  10654. FirstUserID = Convert.ToInt32(returnDataset.Tables[0].Rows[0]["userid"]);
  10655. }
  10656. }
  10657. if (isError)
  10658. {
  10659. oracleTrConn.Commit();
  10660. UpdateRow = -1;
  10661. return UpdateRow;//成型工号无效
  10662. }
  10663. // 20150605 wangxin end
  10664. sql = "update TP_PM_BarCodeMissing set Missuserid=:Missuserid, Missusercode=:Missusercode where missid=:missid";
  10665. paras = new OracleParameter[]{
  10666. //new OracleParameter(":Missuserid",OracleDbType.Int32,Convert.ToInt32(returnDataset.Tables[0].Rows[0]["userid"]),ParameterDirection.Input),
  10667. new OracleParameter(":Missuserid",OracleDbType.Int32,FirstUserID,ParameterDirection.Input),
  10668. new OracleParameter(":Missusercode", OracleDbType.Varchar2, groutingUserCode.Trim(','), ParameterDirection.Input),
  10669. new OracleParameter(":missid", OracleDbType.Int32, missingID, ParameterDirection.Input),
  10670. };
  10671. UpdateRow = oracleTrConn.ExecuteNonQuery(sql, paras);
  10672. if (UpdateRow > 0)
  10673. {
  10674. oracleTrConn.Commit();
  10675. }
  10676. else
  10677. {
  10678. oracleTrConn.Rollback();
  10679. }
  10680. }
  10681. catch (Exception ex)
  10682. {
  10683. oracleTrConn.Rollback();
  10684. throw ex;
  10685. }
  10686. finally
  10687. {
  10688. // 释放资源
  10689. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  10690. {
  10691. oracleTrConn.Disconnect();
  10692. }
  10693. }
  10694. return UpdateRow;
  10695. }
  10696. /// <summary>
  10697. /// 在入窑工序检验窑车号是否存在
  10698. /// </summary>
  10699. /// <param name="kilncarcode">窑车编码</param>
  10700. /// <param name="procedureid">工序ID</param>
  10701. /// <param name="sUserInfo">用户基本信息</param>
  10702. /// <returns></returns>
  10703. public static int CheckKilnCarByIntoCar(string kilncarcode, int procedureid, SUserInfo sUserInfo)
  10704. {
  10705. int UpdateRow = 0;
  10706. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  10707. try
  10708. {
  10709. oracleTrConn.Connect();
  10710. // 判断窑车编码是否有效
  10711. string sql = "select kilncarid from tp_mst_kilncar where kilncarcode=:kilncarcode and valueflag=1 and accountid=:accountid";
  10712. OracleParameter[] paras = new OracleParameter[]{
  10713. new OracleParameter(":kilncarcode",OracleDbType.Varchar2, kilncarcode,ParameterDirection.Input),
  10714. new OracleParameter(":accountid", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  10715. };
  10716. DataSet dsExists = oracleTrConn.GetSqlResultToDs(sql, paras);
  10717. int kilncarid = 0;
  10718. if (dsExists != null && dsExists.Tables[0].Rows.Count == 0)
  10719. {
  10720. oracleTrConn.Commit();
  10721. UpdateRow = -99;
  10722. return UpdateRow;//窑车编码无效
  10723. }
  10724. kilncarid = Convert.ToInt32(dsExists.Tables[0].Rows[0]["kilncarid"]);//窑车ID
  10725. //判断此窑车号有无产品
  10726. sql = "select barcode,KilnCarBatchNo from TP_PM_KilnCarGoods where KilnCarID=:KilnCarID and accountid=:accountid and valueflag=1";
  10727. paras = new OracleParameter[]{
  10728. new OracleParameter(":KilnCarID",OracleDbType.Int32, kilncarid,ParameterDirection.Input),
  10729. new OracleParameter(":accountid", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  10730. };
  10731. DataSet dsGoods = oracleTrConn.GetSqlResultToDs(sql, paras);
  10732. if (dsGoods != null && dsGoods.Tables[0].Rows.Count == 0)
  10733. {
  10734. oracleTrConn.Commit();
  10735. UpdateRow = -98;
  10736. return UpdateRow;//窑车己无产品
  10737. }
  10738. // 判断窑车编码是否在入窑工序
  10739. sql = "select 1 from TP_PM_InProduction where KilnCarID=:KilnCarID and accountid=:accountid and valueflag=1 and FlowProcedureID=:FlowProcedureID";
  10740. paras = new OracleParameter[]{
  10741. new OracleParameter(":KilnCarID",OracleDbType.Int32, kilncarid,ParameterDirection.Input),
  10742. new OracleParameter(":accountid", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  10743. new OracleParameter(":FlowProcedureID", OracleDbType.Int32, procedureid, ParameterDirection.Input),
  10744. };
  10745. dsExists = oracleTrConn.GetSqlResultToDs(sql, paras);
  10746. if (dsExists != null && dsExists.Tables[0].Rows.Count == 0)
  10747. {
  10748. oracleTrConn.Commit();
  10749. UpdateRow = -97;
  10750. return UpdateRow;//窑车号没有入窑,不可以撤销
  10751. }
  10752. int KilnCarDataID = 0;//窑车生产数据ID
  10753. string KilnCarBatchNo = "";
  10754. // 遍历窑车产品
  10755. bool isError = false;//默认没有错误
  10756. for (int i = 0; i < dsGoods.Tables[0].Rows.Count; i++)
  10757. {
  10758. #region 先查询生产数据最后3条
  10759. string sqlString = @"select ProductionDataID,
  10760. ProcedureID,
  10761. ProcedureModel,
  10762. ModelType,
  10763. ReworkProcedureID,
  10764. UserID
  10765. from (select ProductionDataID,
  10766. ProcedureID,
  10767. ProcedureModel,
  10768. ModelType,
  10769. ReworkProcedureID,
  10770. UserID
  10771. from Tp_Pm_ProductiondataIn
  10772. where barcode = :barcode
  10773. and valueflag = 1 and ModelType<>1 and ModelType<>2
  10774. order by ProductionDataID desc)
  10775. where rownum <=1";//where rownum <=3";
  10776. paras = new OracleParameter[]{
  10777. new OracleParameter(":barcode",OracleDbType.Varchar2, dsGoods.Tables[0].Rows[i]["barcode"].ToString(),ParameterDirection.Input),
  10778. };
  10779. DataSet productionData = oracleTrConn.GetSqlResultToDs(sqlString, paras);
  10780. if (productionData == null
  10781. || productionData.Tables.Count == Constant.INT_IS_ZERO
  10782. || productionData.Tables[0].Rows.Count != Constant.INT_IS_ONE)
  10783. {
  10784. //errMsg = Messages.MSG_PM_W016;
  10785. isError = true;
  10786. break;
  10787. }
  10788. #endregion
  10789. #region 回滚在产数据
  10790. sqlString = @"update TP_PM_InProduction
  10791. set FlowProcedureID = :flowProcedureID,
  10792. ProcedureModel = :procedureModel,
  10793. ProcedureID = :flowProcedureID,
  10794. ModelType = :modelType,
  10795. ReworkProcedureID = :reworkProcedureID,
  10796. UserID = :userID,
  10797. updateuserid = :updateuserid
  10798. where barcode = :barcode";
  10799. paras = new OracleParameter[]{
  10800. new OracleParameter(":flowProcedureID",OracleDbType.Int32,
  10801. productionData.Tables[0].Rows[0]["ProcedureID"],ParameterDirection.Input),//2-->1
  10802. new OracleParameter(":procedureModel",OracleDbType.Int32,
  10803. productionData.Tables[0].Rows[0]["procedureModel"],ParameterDirection.Input),
  10804. new OracleParameter(":modelType",OracleDbType.Int32,
  10805. productionData.Tables[0].Rows[0]["modelType"],ParameterDirection.Input),
  10806. new OracleParameter(":reworkProcedureID",OracleDbType.Int32,
  10807. productionData.Tables[0].Rows[0]["reworkProcedureID"],ParameterDirection.Input),
  10808. new OracleParameter(":userID",OracleDbType.Int32,
  10809. productionData.Tables[0].Rows[0]["userID"],ParameterDirection.Input),
  10810. new OracleParameter(":updateuserid",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input),
  10811. new OracleParameter(":barcode",OracleDbType.Varchar2, dsGoods.Tables[0].Rows[i]["barcode"].ToString(),ParameterDirection.Input),
  10812. };
  10813. UpdateRow = oracleTrConn.ExecuteNonQuery(sqlString, paras);
  10814. if (UpdateRow == Constant.INT_IS_ZERO)
  10815. {
  10816. // 保存失败
  10817. isError = true;
  10818. break;
  10819. }
  10820. #endregion
  10821. #region 删除生产者和最后一条生产数据
  10822. //sqlString = "delete TP_PM_Producer where ProductionDataID=:productionDataID";
  10823. paras = new OracleParameter[]{
  10824. new OracleParameter(":productionDataID",OracleDbType.Int32,
  10825. productionData.Tables[0].Rows[0]["productionDataID"],ParameterDirection.Input),
  10826. //new OracleParameter(":productionDataID2",OracleDbType.Int32,
  10827. // productionData.Tables[0].Rows[0]["productionDataID"],ParameterDirection.Input),
  10828. new OracleParameter(":barcode",OracleDbType.Varchar2,
  10829. dsGoods.Tables[0].Rows[i]["barcode"].ToString(),ParameterDirection.Input),
  10830. };
  10831. //modify 2015/05/13 wangx GoodsLevelTypeID=12 撤销入窑
  10832. sqlString = "select GoodsLevelID,GoodsLevelName,GoodsLevelTypeID from TP_MST_GoodsLevel where GoodsLevelTypeID=12 and AccountID=" + sUserInfo.AccountID + " and ValueFlag=1";
  10833. DataSet dsGoodsLevel = oracleTrConn.GetSqlResultToDs(sqlString, null);
  10834. int? GoodsLevelID = null;
  10835. if (dsGoodsLevel != null && dsGoodsLevel.Tables[0].Rows.Count > 0)
  10836. {
  10837. GoodsLevelID = Convert.ToInt32(dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelID"]);
  10838. }
  10839. //modify end
  10840. sqlString = "update TP_PM_ProductionDataIn set valueflag=0 ,updateuserid=" + sUserInfo.UserID;
  10841. if (GoodsLevelID != null)
  10842. {
  10843. sqlString += ",GoodsLevelID=" + GoodsLevelID;
  10844. sqlString += ",GoodsLevelTypeID=12";
  10845. }
  10846. //sqlString += " where ProductionDataID=:productionDataID or ProductionDataID=:productionDataID2";
  10847. sqlString += " where barcode=:barcode and ProductionDataID>:productionDataID "; //or ProductionDataID=:productionDataID2
  10848. UpdateRow = oracleTrConn.ExecuteNonQuery(sqlString, paras);
  10849. if (UpdateRow == Constant.INT_IS_ZERO)
  10850. {
  10851. // 保存失败
  10852. isError = true;
  10853. break;
  10854. }
  10855. #endregion
  10856. #region 删除窑车产品
  10857. sqlString = "delete TP_PM_KilnCarGoods where BarCode=:barCode";
  10858. paras = new OracleParameter[]{
  10859. new OracleParameter(":barCode",OracleDbType.Varchar2,
  10860. dsGoods.Tables[0].Rows[i]["barcode"],ParameterDirection.Input),
  10861. };
  10862. UpdateRow = oracleTrConn.ExecuteNonQuery(sqlString, paras);
  10863. if (UpdateRow == Constant.INT_IS_ZERO)
  10864. {
  10865. // 保存失败
  10866. isError = true;
  10867. break;
  10868. }
  10869. #endregion
  10870. #region 读取窑车生产数据,进行撤销
  10871. sql = @"select KilnCarDataID, ProductionLineID,ProcedureID,
  10872. ProcedureCode,ProcedureName,ProcedureModel,ModelType,PieceType
  10873. from TP_PM_KilnCarData where KilnCarID=:KilnCarID and accountid=:accountid and valueflag=1 and KilnCarBatchNo=:KilnCarBatchNo order by KilnCarDataID ";
  10874. paras = new OracleParameter[]{
  10875. new OracleParameter(":KilnCarID",OracleDbType.Int32,
  10876. kilncarid,ParameterDirection.Input),
  10877. new OracleParameter(":accountid",OracleDbType.Int32,
  10878. sUserInfo.AccountID,ParameterDirection.Input),
  10879. new OracleParameter(":KilnCarBatchNo",OracleDbType.Varchar2,
  10880. dsGoods.Tables[0].Rows[i]["KilnCarBatchNo"].ToString(),ParameterDirection.Input),
  10881. };
  10882. KilnCarBatchNo = dsGoods.Tables[0].Rows[i]["KilnCarBatchNo"].ToString();
  10883. dsExists = oracleTrConn.GetSqlResultToDs(sql, paras);
  10884. if (dsExists != null && dsExists.Tables[0].Rows.Count > 0)
  10885. {
  10886. //最后窑车生产数据ID赋值 撤二步骤
  10887. KilnCarDataID = Convert.ToInt32(dsExists.Tables[0].Rows[0]["KilnCarDataID"]);
  10888. sqlString = @"update TP_PM_KilnCarStatus set
  10889. ProductionLineID=:ProductionLineID
  10890. ,ProcedureID=:ProcedureID
  10891. ,ProcedureCode=:ProcedureCode
  10892. ,ProcedureName=:ProcedureName
  10893. ,ProcedureModel=:ProcedureModel
  10894. ,ModelType=:ModelType
  10895. ,PieceType=:PieceType
  10896. ,KilnCarStatus=0,LoadingTime=null,IntoKilnTime=null,OutKilnTime=null,UnloadingTime=null
  10897. where KilnCarID=:KilnCarID";
  10898. paras = new OracleParameter[]{
  10899. new OracleParameter(":ProductionLineID",OracleDbType.Int32,
  10900. dsExists.Tables[0].Rows[0]["ProductionLineID"],ParameterDirection.Input),
  10901. new OracleParameter(":ProcedureID",OracleDbType.Int32,
  10902. dsExists.Tables[0].Rows[0]["ProcedureID"],ParameterDirection.Input),
  10903. new OracleParameter(":ProcedureCode",OracleDbType.Varchar2,
  10904. dsExists.Tables[0].Rows[0]["ProcedureCode"].ToString(),ParameterDirection.Input),
  10905. new OracleParameter(":ProcedureModel",OracleDbType.Varchar2,
  10906. dsExists.Tables[0].Rows[0]["ProcedureModel"].ToString(),ParameterDirection.Input),
  10907. new OracleParameter(":ModelType",OracleDbType.Int32,
  10908. Convert.ToInt32(dsExists.Tables[0].Rows[0]["ModelType"]),ParameterDirection.Input),
  10909. new OracleParameter(":PieceType",OracleDbType.Varchar2,
  10910. dsExists.Tables[0].Rows[0]["PieceType"].ToString(),ParameterDirection.Input),
  10911. new OracleParameter(":KilnCarID",OracleDbType.Int32,
  10912. kilncarid,ParameterDirection.Input),
  10913. new OracleParameter(":ProcedureName",OracleDbType.Varchar2,
  10914. dsExists.Tables[0].Rows[0]["ProcedureName"].ToString(),ParameterDirection.Input),
  10915. };
  10916. UpdateRow = oracleTrConn.ExecuteNonQuery(sqlString, paras);
  10917. if (UpdateRow == Constant.INT_IS_ZERO)
  10918. {
  10919. // 保存失败
  10920. isError = true;
  10921. break;
  10922. }
  10923. }
  10924. #endregion
  10925. }
  10926. //modify wangx 20150606 begin
  10927. string updateSql = "update TP_PM_KilnCarData set valueflag=0,UpdateUserID=" + sUserInfo.UserID + " where KilnCarDataID>=" + KilnCarDataID + " and KilnCarBatchNo=" + KilnCarBatchNo;
  10928. int row = oracleTrConn.ExecuteNonQuery(updateSql);
  10929. //modify wangx 20150606 end
  10930. if (isError) //有错误消息
  10931. {
  10932. UpdateRow = -1;//失败
  10933. oracleTrConn.Rollback();
  10934. }
  10935. else
  10936. {
  10937. UpdateRow = 1;//成功
  10938. oracleTrConn.Commit();
  10939. }
  10940. }
  10941. catch (Exception ex)
  10942. {
  10943. oracleTrConn.Rollback();
  10944. throw ex;
  10945. }
  10946. finally
  10947. {
  10948. // 释放资源
  10949. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  10950. {
  10951. oracleTrConn.Disconnect();
  10952. }
  10953. }
  10954. return UpdateRow;
  10955. }
  10956. /// <summary>
  10957. /// 在入窑工序检验窑车号是否存在
  10958. /// </summary>
  10959. /// <param name="kilncarcode">窑车编码</param>
  10960. /// <param name="procedureid">工序ID</param>
  10961. /// <param name="sUserInfo">用户基本信息</param>
  10962. /// <returns></returns>
  10963. public static int CheckKilnCarByIntoCar2(string kilncarcode, int procedureid, SUserInfo sUserInfo)
  10964. {
  10965. int UpdateRow = 0;
  10966. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  10967. try
  10968. {
  10969. oracleTrConn.Connect();
  10970. // 判断窑车编码是否有效
  10971. string sql = "select kilncarid from tp_mst_kilncar where kilncarcode=:kilncarcode and valueflag=1 and accountid=:accountid";
  10972. OracleParameter[] paras = new OracleParameter[]{
  10973. new OracleParameter(":kilncarcode",OracleDbType.Varchar2, kilncarcode,ParameterDirection.Input),
  10974. new OracleParameter(":accountid", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  10975. };
  10976. DataSet dsExists = oracleTrConn.GetSqlResultToDs(sql, paras);
  10977. int kilncarid = 0;
  10978. if (dsExists != null && dsExists.Tables[0].Rows.Count == 0)
  10979. {
  10980. oracleTrConn.Commit();
  10981. UpdateRow = -99;
  10982. return UpdateRow;//窑车编码无效
  10983. }
  10984. kilncarid = Convert.ToInt32(dsExists.Tables[0].Rows[0]["kilncarid"]);//窑车ID
  10985. //判断此窑车号有无产品
  10986. sql = "select barcode,KilnCarBatchNo from TP_PM_KilnCarGoods where KilnCarID=:KilnCarID and accountid=:accountid and valueflag=1";
  10987. paras = new OracleParameter[]{
  10988. new OracleParameter(":KilnCarID",OracleDbType.Int32, kilncarid,ParameterDirection.Input),
  10989. new OracleParameter(":accountid", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  10990. };
  10991. DataSet dsGoods = oracleTrConn.GetSqlResultToDs(sql, paras);
  10992. if (dsGoods != null && dsGoods.Tables[0].Rows.Count == 0)
  10993. {
  10994. oracleTrConn.Commit();
  10995. UpdateRow = -98;
  10996. return UpdateRow;//窑车己无产品
  10997. }
  10998. // 判断窑车编码是否在入窑工序
  10999. sql = "select 1 from TP_PM_InProduction where KilnCarID=:KilnCarID and accountid=:accountid and valueflag=1 and FlowProcedureID=:FlowProcedureID";
  11000. paras = new OracleParameter[]{
  11001. new OracleParameter(":KilnCarID",OracleDbType.Int32, kilncarid,ParameterDirection.Input),
  11002. new OracleParameter(":accountid", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  11003. new OracleParameter(":FlowProcedureID", OracleDbType.Int32, procedureid, ParameterDirection.Input),
  11004. };
  11005. dsExists = oracleTrConn.GetSqlResultToDs(sql, paras);
  11006. if (dsExists != null && dsExists.Tables[0].Rows.Count == 0)
  11007. {
  11008. oracleTrConn.Commit();
  11009. UpdateRow = -97;
  11010. return UpdateRow;//窑车号没有入窑,不可以撤销
  11011. }
  11012. int KilnCarDataID = 0;//窑车生产数据ID
  11013. // 遍历窑车产品
  11014. bool isError = false;//默认没有错误
  11015. for (int i = 0; i < dsGoods.Tables[0].Rows.Count; i++)
  11016. {
  11017. #region 先查询生产数据最后3条
  11018. string sqlString = @"select ProductionDataID,
  11019. ProcedureID,
  11020. ProcedureModel,
  11021. ModelType,
  11022. ReworkProcedureID,
  11023. UserID,
  11024. logoid
  11025. from (select ProductionDataID,
  11026. ProcedureID,
  11027. ProcedureModel,
  11028. ModelType,
  11029. ReworkProcedureID,
  11030. UserID,
  11031. logoid
  11032. from Tp_Pm_ProductiondataIn
  11033. where barcode = :barcode
  11034. and valueflag = 1 and ModelType<>2
  11035. order by ProductionDataID desc)
  11036. where rownum <=1";
  11037. paras = new OracleParameter[]{
  11038. new OracleParameter(":barcode",OracleDbType.Varchar2, dsGoods.Tables[0].Rows[i]["barcode"].ToString(),ParameterDirection.Input),
  11039. };
  11040. DataSet productionData = oracleTrConn.GetSqlResultToDs(sqlString, paras);
  11041. if (productionData == null
  11042. || productionData.Tables.Count == Constant.INT_IS_ZERO
  11043. || productionData.Tables[0].Rows.Count != Constant.INT_IS_ONE)
  11044. {
  11045. //errMsg = Messages.MSG_PM_W016;
  11046. isError = true;
  11047. break;
  11048. }
  11049. #endregion
  11050. #region 回滚在产数据
  11051. sqlString = @"update TP_PM_InProduction
  11052. set FlowProcedureID = :flowProcedureID,
  11053. ProcedureModel = :procedureModel,
  11054. ProcedureID = :flowProcedureID,
  11055. ModelType = :modelType,
  11056. ReworkProcedureID = :reworkProcedureID,
  11057. UserID = :userID,
  11058. updateuserid = :updateuserid,
  11059. logoid = :logoid
  11060. where barcode = :barcode";
  11061. paras = new OracleParameter[]{
  11062. new OracleParameter(":flowProcedureID",OracleDbType.Int32,
  11063. productionData.Tables[0].Rows[0]["ProcedureID"],ParameterDirection.Input),//2-->1
  11064. new OracleParameter(":procedureModel",OracleDbType.Int32,
  11065. productionData.Tables[0].Rows[0]["procedureModel"],ParameterDirection.Input),
  11066. new OracleParameter(":modelType",OracleDbType.Int32,
  11067. productionData.Tables[0].Rows[0]["modelType"],ParameterDirection.Input),
  11068. new OracleParameter(":reworkProcedureID",OracleDbType.Int32,
  11069. productionData.Tables[0].Rows[0]["reworkProcedureID"],ParameterDirection.Input),
  11070. new OracleParameter(":userID",OracleDbType.Int32,
  11071. productionData.Tables[0].Rows[0]["userID"],ParameterDirection.Input),
  11072. new OracleParameter(":updateuserid",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input),
  11073. new OracleParameter(":barcode",OracleDbType.Varchar2, dsGoods.Tables[0].Rows[i]["barcode"].ToString(),ParameterDirection.Input),
  11074. new OracleParameter(":logoid",OracleDbType.Int32, productionData.Tables[0].Rows[0]["logoid"].ToString()==""?null:productionData.Tables[0].Rows[0]["logoid"],ParameterDirection.Input),
  11075. };
  11076. UpdateRow = oracleTrConn.ExecuteNonQuery(sqlString, paras);
  11077. if (UpdateRow == Constant.INT_IS_ZERO)
  11078. {
  11079. // 保存失败
  11080. isError = true;
  11081. break;
  11082. }
  11083. #endregion
  11084. #region 删除生产者和最后一条生产数据
  11085. //sqlString = "delete TP_PM_Producer where ProductionDataID=:productionDataID";
  11086. paras = new OracleParameter[]{
  11087. new OracleParameter(":productionDataID",OracleDbType.Int32,
  11088. productionData.Tables[0].Rows[0]["productionDataID"],ParameterDirection.Input),
  11089. new OracleParameter(":barcode",OracleDbType.Varchar2,
  11090. dsGoods.Tables[0].Rows[i]["barcode"].ToString(),ParameterDirection.Input),
  11091. };
  11092. //modify 2015/05/13 wangx GoodsLevelTypeID=12 撤销入窑
  11093. sqlString = "select GoodsLevelID,GoodsLevelName,GoodsLevelTypeID from TP_MST_GoodsLevel where GoodsLevelTypeID=12 and AccountID=" + sUserInfo.AccountID + " and ValueFlag=1";
  11094. DataSet dsGoodsLevel = oracleTrConn.GetSqlResultToDs(sqlString, null);
  11095. int? GoodsLevelID = null;
  11096. if (dsGoodsLevel != null && dsGoodsLevel.Tables[0].Rows.Count > 0)
  11097. {
  11098. GoodsLevelID = Convert.ToInt32(dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelID"]);
  11099. }
  11100. //modify end
  11101. sqlString = "update TP_PM_ProductionDataIn set valueflag=0,updateuserid= " + sUserInfo.UserID;
  11102. if (GoodsLevelID != null)
  11103. {
  11104. sqlString += ",GoodsLevelID=" + GoodsLevelID;
  11105. sqlString += ",GoodsLevelTypeID=12";
  11106. }
  11107. //sqlString += " where ProductionDataID=:productionDataID or ProductionDataID=:productionDataID2";
  11108. sqlString += " where barcode=:barcode and ProductionDataID>:productionDataID "; //or ProductionDataID=:productionDataID2
  11109. UpdateRow = oracleTrConn.ExecuteNonQuery(sqlString, paras);
  11110. if (UpdateRow == Constant.INT_IS_ZERO)
  11111. {
  11112. // 保存失败
  11113. isError = true;
  11114. break;
  11115. }
  11116. #endregion
  11117. //#region 删除窑车产品
  11118. //sqlString = "delete TP_PM_KilnCarGoods where BarCode=:barCode";
  11119. //paras = new OracleParameter[]{
  11120. // new OracleParameter(":barCode",OracleDbType.Varchar2,
  11121. // dsGoods.Tables[0].Rows[i]["barcode"],ParameterDirection.Input),
  11122. //};
  11123. //UpdateRow = oracleTrConn.ExecuteNonQuery(sqlString, paras);
  11124. //if (UpdateRow == Constant.INT_IS_ZERO)
  11125. //{
  11126. // // 保存失败
  11127. // isError = true;
  11128. // break;
  11129. //}
  11130. //#endregion
  11131. #region 读取窑车生产数据,进行撤销
  11132. sql = @"select KilnCarDataID, ProductionLineID,ProcedureID,
  11133. ProcedureCode,ProcedureName,ProcedureModel,ModelType,PieceType
  11134. from TP_PM_KilnCarData where KilnCarID=:KilnCarID and accountid=:accountid and valueflag=1 and KilnCarBatchNo=:KilnCarBatchNo order by KilnCarDataID ";
  11135. paras = new OracleParameter[]{
  11136. new OracleParameter(":KilnCarID",OracleDbType.Int32,
  11137. kilncarid,ParameterDirection.Input),
  11138. new OracleParameter(":accountid",OracleDbType.Int32,
  11139. sUserInfo.AccountID,ParameterDirection.Input),
  11140. new OracleParameter(":KilnCarBatchNo",OracleDbType.Varchar2,
  11141. dsGoods.Tables[0].Rows[i]["KilnCarBatchNo"].ToString(),ParameterDirection.Input),
  11142. };
  11143. dsExists = oracleTrConn.GetSqlResultToDs(sql, paras);
  11144. if (dsExists != null && dsExists.Tables[0].Rows.Count > 0)
  11145. {
  11146. //最后窑车生产数据ID赋值
  11147. KilnCarDataID = Convert.ToInt32(dsExists.Tables[0].Rows[dsExists.Tables[0].Rows.Count - 1]["KilnCarDataID"]);
  11148. sqlString = @"update TP_PM_KilnCarStatus set
  11149. ProductionLineID=:ProductionLineID
  11150. ,ProcedureID=:ProcedureID
  11151. ,ProcedureCode=:ProcedureCode
  11152. ,ProcedureName=:ProcedureName
  11153. ,ProcedureModel=:ProcedureModel
  11154. ,ModelType=:ModelType
  11155. ,PieceType=:PieceType
  11156. ,KilnCarStatus=0,IntoKilnTime=null,OutKilnTime=null,UnloadingTime=null
  11157. where KilnCarID=:KilnCarID";
  11158. paras = new OracleParameter[]{
  11159. new OracleParameter(":ProductionLineID",OracleDbType.Int32,
  11160. dsExists.Tables[0].Rows[0]["ProductionLineID"],ParameterDirection.Input),
  11161. new OracleParameter(":ProcedureID",OracleDbType.Int32,
  11162. dsExists.Tables[0].Rows[0]["ProcedureID"],ParameterDirection.Input),
  11163. new OracleParameter(":ProcedureCode",OracleDbType.Varchar2,
  11164. dsExists.Tables[0].Rows[0]["ProcedureCode"].ToString(),ParameterDirection.Input),
  11165. new OracleParameter(":ProcedureModel",OracleDbType.Varchar2,
  11166. dsExists.Tables[0].Rows[0]["ProcedureModel"].ToString(),ParameterDirection.Input),
  11167. new OracleParameter(":ModelType",OracleDbType.Int32,
  11168. Convert.ToInt32(dsExists.Tables[0].Rows[0]["ModelType"]),ParameterDirection.Input),
  11169. new OracleParameter(":PieceType",OracleDbType.Varchar2,
  11170. dsExists.Tables[0].Rows[0]["PieceType"].ToString(),ParameterDirection.Input),
  11171. new OracleParameter(":KilnCarID",OracleDbType.Int32,
  11172. kilncarid,ParameterDirection.Input),
  11173. new OracleParameter(":ProcedureName",OracleDbType.Varchar2,
  11174. dsExists.Tables[0].Rows[0]["ProcedureName"].ToString(),ParameterDirection.Input),
  11175. };
  11176. UpdateRow = oracleTrConn.ExecuteNonQuery(sqlString, paras);
  11177. if (UpdateRow == Constant.INT_IS_ZERO)
  11178. {
  11179. // 保存失败
  11180. isError = true;
  11181. break;
  11182. }
  11183. }
  11184. #endregion
  11185. }
  11186. //modify wangx 20150606 begin
  11187. string updateSql = "update TP_PM_KilnCarData set valueflag=0,UpdateUserID=" + sUserInfo.UserID + " where KilnCarDataID=" + KilnCarDataID;
  11188. int row = oracleTrConn.ExecuteNonQuery(updateSql);
  11189. //modify wangx 20150606 end
  11190. if (isError) //有错误消息
  11191. {
  11192. UpdateRow = -1;//失败
  11193. oracleTrConn.Rollback();
  11194. }
  11195. else
  11196. {
  11197. UpdateRow = 1;//成功
  11198. oracleTrConn.Commit();
  11199. }
  11200. }
  11201. catch (Exception ex)
  11202. {
  11203. oracleTrConn.Rollback();
  11204. throw ex;
  11205. }
  11206. finally
  11207. {
  11208. // 释放资源
  11209. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  11210. {
  11211. oracleTrConn.Disconnect();
  11212. }
  11213. }
  11214. return UpdateRow;
  11215. }
  11216. /// <summary>
  11217. /// 保存盘点单
  11218. /// </summary>
  11219. /// <param name="inProductionEntity"></param>
  11220. /// <param name="remarks"></param>
  11221. /// <param name="sUserInfo"></param>
  11222. /// <returns></returns>
  11223. public static int SaveInChecked(InProductionEntity[] inProductionEntity, string remarks, SUserInfo sUserInfo)
  11224. {
  11225. int returnRows = 0;
  11226. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  11227. try
  11228. {
  11229. if (inProductionEntity[0].ReworkProcedureID == 0)
  11230. {
  11231. //盘点单号
  11232. string InCheckedNo = string.Format("IPC{0}", DateTime.Now.ToString("yyyyMMddHHmmss"));
  11233. //获得账务日期
  11234. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  11235. //备注
  11236. string Remarks = remarks;
  11237. oracleTrConn.Connect();
  11238. //盘点单ID
  11239. string sql = "select SEQ_PM_InChecked_ID.nextval from dual";
  11240. int InCheckedID = Convert.ToInt32(oracleTrConn.GetSqlResultToStr(sql));
  11241. #region 插入盘点单主表信息
  11242. sql = @"insert into TP_PM_InChecked
  11243. (
  11244. InCheckedID,
  11245. InCheckedNo,
  11246. AccountDate,
  11247. Remarks,
  11248. AccountID,
  11249. CreateUserID,
  11250. UpdateUserID,
  11251. INCHECKNAME
  11252. ) values
  11253. ( :InCheckedID,
  11254. :InCheckedNo,
  11255. :AccountDate,
  11256. :Remarks,
  11257. :AccountID,
  11258. :CreateUserID,
  11259. :UpdateUserID,
  11260. :INCHECKNAME
  11261. )";
  11262. OracleParameter[] Paras = new OracleParameter[] {
  11263. new OracleParameter(":InCheckedID",OracleDbType.Int32,
  11264. InCheckedID,ParameterDirection.Input),
  11265. new OracleParameter(":InCheckedNo",OracleDbType.NVarchar2,
  11266. InCheckedNo,ParameterDirection.Input),
  11267. new OracleParameter(":AccountDate",OracleDbType.Date,
  11268. accountDate,ParameterDirection.Input),
  11269. new OracleParameter(":Remarks",OracleDbType.NVarchar2,
  11270. Remarks,ParameterDirection.Input),
  11271. new OracleParameter(":AccountID",OracleDbType.Int32,
  11272. sUserInfo.AccountID,ParameterDirection.Input),
  11273. new OracleParameter(":CreateUserID",OracleDbType.Int32,
  11274. sUserInfo.UserID,ParameterDirection.Input),
  11275. new OracleParameter(":UpdateUserID",OracleDbType.Int32,
  11276. sUserInfo.UserID,ParameterDirection.Input),
  11277. new OracleParameter(":INCHECKNAME",OracleDbType.NVarchar2,
  11278. inProductionEntity[0].CompleteProcedureName,ParameterDirection.Input),
  11279. };
  11280. returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  11281. #endregion
  11282. //string barcodes = "";
  11283. List<OracleParameter> parameters = null;
  11284. //int row = 0;
  11285. //foreach (InProductionEntity entity in inProductionEntity)
  11286. //{
  11287. // barcodes += entity.BarCode + ",";
  11288. // row++;
  11289. // if (row > 15) //为了15查数据库一次
  11290. // {
  11291. // barcodes = barcodes.TrimEnd(',') + '|';
  11292. // row = 0;//重置
  11293. // }
  11294. //}
  11295. //barcodes = barcodes.TrimEnd(',');
  11296. //string[] subsplit = barcodes.Split('|');
  11297. // foreach (InProductionEntity entity in inProductionEntity)foreach (InProductionEntity entity in inProductionEntity)
  11298. //foreach (string entity in subsplit)
  11299. //{
  11300. //barcodes += entity.BarCode + ",";
  11301. //barcodes = barcodes.TrimEnd(','); //在产产品是唯一的,直接根据条码查询,并插入到盘点明细
  11302. sql = @"
  11303. insert into TP_PM_InCheckedDetail
  11304. (
  11305. InCheckedID,
  11306. BarCode,
  11307. InCheckedNo,
  11308. ProductionLineID,
  11309. ProductionLineCode,
  11310. ProductionLineName,
  11311. ProcedureID,
  11312. ProcedureTime,
  11313. ProcedureModel,
  11314. ModelType,
  11315. DefectFlag,
  11316. ReworkProcedureID,
  11317. IsPublicBody,
  11318. IsReFire,
  11319. SpecialRepairFlag,
  11320. GoodsLevelID,
  11321. GoodsLevelTypeID,
  11322. GoodsID,
  11323. GoodsCode,
  11324. GoodsName,
  11325. UserID,
  11326. GroutingDailyID,
  11327. GroutingDailyDetailID,
  11328. GroutingDate,
  11329. GroutingLineID,
  11330. GroutingLineCode,
  11331. GroutingLineName,
  11332. GMouldTypeID,
  11333. CanManyTimes,
  11334. GroutingLineDetailID,
  11335. GroutingMouldCode,
  11336. MouldCode,
  11337. GroutingUserID,
  11338. GroutingUserCode,
  11339. GroutingNum,
  11340. Remarks,
  11341. KilnID,
  11342. KilnCode,
  11343. KilnName,
  11344. KilnCarID,
  11345. KilnCarCode,
  11346. KilnCarName,
  11347. KilnCarBatchNo,
  11348. KilnCarPosition,
  11349. AccountID,
  11350. CreateUserID,
  11351. UpdateUserID,
  11352. valueflag,
  11353. logoid,
  11354. ISREWORKFLAG,INSCRAPFLAG
  11355. )
  11356. select
  11357. :InCheckedID,
  11358. inp.BarCode,
  11359. :InCheckedNo,
  11360. inp.ProductionLineID,
  11361. inp.ProductionLineCode,
  11362. inp.ProductionLineName,
  11363. inp.ProcedureID,
  11364. inp.ProcedureTime,
  11365. inp.ProcedureModel,
  11366. inp.ModelType,
  11367. inp.DefectFlag,
  11368. inp.ReworkProcedureID,
  11369. inp.IsPublicBody,
  11370. inp.IsReFire,
  11371. inp.SpecialRepairFlag,
  11372. inp.GoodsLevelID,
  11373. inp.GoodsLevelTypeID,
  11374. inp.GoodsID,
  11375. inp.GoodsCode,
  11376. inp.GoodsName,
  11377. inp.UserID,
  11378. inp.GroutingDailyID,
  11379. inp.GroutingDailyDetailID,
  11380. inp.GroutingDate,
  11381. inp.GroutingLineID,
  11382. inp.GroutingLineCode,
  11383. inp.GroutingLineName,
  11384. inp.GMouldTypeID,
  11385. inp.CanManyTimes,
  11386. inp.GroutingLineDetailID,
  11387. inp.GroutingMouldCode,
  11388. inp.MouldCode,
  11389. inp.GroutingUserID,
  11390. inp.GroutingUserCode,
  11391. inp.GroutingNum,
  11392. inp.Remarks,
  11393. inp.KilnID,
  11394. inp.KilnCode,
  11395. inp.KilnName,
  11396. inp.KilnCarID,
  11397. inp.KilnCarCode,
  11398. inp.KilnCarName,
  11399. inp.KilnCarBatchNo,
  11400. inp.KilnCarPosition,
  11401. :AccountID,
  11402. :CreateUserID,
  11403. :UpdateUserID,
  11404. 1,
  11405. inp.logoid,
  11406. inp.ISREWORKFLAG,inp.INSCRAPFLAG
  11407. from TP_PM_InProduction inp
  11408. LEFT JOIN tp_mst_goods g
  11409. ON g.goodsid = inp.goodsid
  11410. LEFT JOIN tp_mst_goodsType gt
  11411. ON gt.goodstypeid = g.goodstypeid
  11412. where 1=1
  11413. ";
  11414. //sql += "AND instr(','||:ProcedureIDS||',',','||TP_PM_InProduction.ProcedureID||',')>0 ";
  11415. parameters = new List<OracleParameter>();
  11416. // 工序IDS
  11417. if (!string.IsNullOrEmpty(inProductionEntity[0].ProcedureIDS))
  11418. {
  11419. sql += "AND instr(','||:ProcedureIDS||',',','||inp.FlowProcedureID||',')>0 ";
  11420. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, inProductionEntity[0].ProcedureIDS, ParameterDirection.Input));
  11421. }
  11422. // 完成日期
  11423. if (inProductionEntity[0].StartCompleteDate != null)
  11424. {
  11425. sql = sql + " AND inp.ProcedureTime >= :Createdate AND inp.ProcedureTime <= :EndDate ";
  11426. parameters.Add(new OracleParameter(":Createdate", OracleDbType.Date, inProductionEntity[0].StartCompleteDate, ParameterDirection.Input));
  11427. parameters.Add(new OracleParameter(":EndDate", OracleDbType.Date, inProductionEntity[0].EndCompleteDate, ParameterDirection.Input));
  11428. }
  11429. // 编码IDS
  11430. if (!string.IsNullOrEmpty(inProductionEntity[0].GoodsCodeList))
  11431. {
  11432. sql += "AND instr(','||:GoodsIDS||',',','||inp.GoodsID||',')>0 ";
  11433. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, inProductionEntity[0].GoodsCodeList, ParameterDirection.Input));
  11434. }
  11435. // 产品类型
  11436. if (!string.IsNullOrEmpty(inProductionEntity[0].GoodsTypeCode))
  11437. {
  11438. sql += "AND instr(gt.goodstypecode, :GoodsTypeCode)=1 ";
  11439. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, inProductionEntity[0].GoodsTypeCode, ParameterDirection.Input));
  11440. }
  11441. parameters.Add(new OracleParameter(":InCheckedID", OracleDbType.Int32, InCheckedID, ParameterDirection.Input));
  11442. parameters.Add(new OracleParameter(":InCheckedNo", OracleDbType.Varchar2, InCheckedNo, ParameterDirection.Input));
  11443. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input));
  11444. parameters.Add(new OracleParameter(":CreateUserID", OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input));
  11445. parameters.Add(new OracleParameter(":UpdateUserID", OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input));
  11446. returnRows += oracleTrConn.ExecuteNonQuery(sql, parameters.ToArray());
  11447. #region 插入盘点工号列表
  11448. foreach (DataRow r in inProductionEntity[0].UserTable.Rows)
  11449. {
  11450. if (r["userid"] != DBNull.Value)
  11451. {
  11452. sql = @" Insert into tp_pm_incheckeduser
  11453. (
  11454. incheckedid,
  11455. userCode,
  11456. userid
  11457. )
  11458. values
  11459. (
  11460. :inchecked,
  11461. :userCode,
  11462. :userid
  11463. )
  11464. ";
  11465. Paras = new OracleParameter[] {
  11466. new OracleParameter(":inchecked",OracleDbType.Int32,
  11467. InCheckedID,ParameterDirection.Input),
  11468. new OracleParameter(":userCode",OracleDbType.NVarchar2,
  11469. r["userCode"],ParameterDirection.Input),
  11470. new OracleParameter(":userid",OracleDbType.Int32,
  11471. r["userid"],ParameterDirection.Input),
  11472. };
  11473. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  11474. }
  11475. }
  11476. #endregion
  11477. }
  11478. else
  11479. {
  11480. string sql = @"Update TP_PM_InChecked set Incheckname=:Incheckname,Remarks=:Remarks,updateuserid=:updateuserid where InCheckedID=:InCheckedID";
  11481. OracleParameter[] Paras = new OracleParameter[] {
  11482. new OracleParameter(":InCheckedID",OracleDbType.Int32,
  11483. inProductionEntity[0].ReworkProcedureID,ParameterDirection.Input),
  11484. new OracleParameter(":Incheckname",OracleDbType.NVarchar2,
  11485. inProductionEntity[0].CompleteProcedureName,ParameterDirection.Input),
  11486. new OracleParameter(":Remarks",OracleDbType.NVarchar2,
  11487. remarks,ParameterDirection.Input),
  11488. new OracleParameter(":updateuserid",OracleDbType.Int32,
  11489. sUserInfo.UserID,ParameterDirection.Input),
  11490. };
  11491. returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  11492. sql = @"delete from tp_pm_incheckeduser where InCheckedID=:InCheckedID";
  11493. Paras = new OracleParameter[] {
  11494. new OracleParameter(":InCheckedID",OracleDbType.Int32,
  11495. inProductionEntity[0].ReworkProcedureID,ParameterDirection.Input),
  11496. };
  11497. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  11498. #region 插入盘点工号列表
  11499. foreach (DataRow r in inProductionEntity[0].UserTable.Rows)
  11500. {
  11501. if (string.IsNullOrEmpty(r["userCode"].ToString()) ||
  11502. string.IsNullOrEmpty(r["userid"].ToString()))
  11503. {
  11504. continue;
  11505. }
  11506. sql = @" Insert into tp_pm_incheckeduser
  11507. (
  11508. incheckedid,
  11509. userCode,
  11510. userid
  11511. )
  11512. values
  11513. (
  11514. :inchecked,
  11515. :userCode,
  11516. :userid
  11517. )
  11518. ";
  11519. Paras = new OracleParameter[] {
  11520. new OracleParameter(":inchecked",OracleDbType.Int32,
  11521. inProductionEntity[0].ReworkProcedureID,ParameterDirection.Input),
  11522. new OracleParameter(":userCode",OracleDbType.NVarchar2,
  11523. r["userCode"],ParameterDirection.Input),
  11524. new OracleParameter(":userid",OracleDbType.Int32,
  11525. r["userid"],ParameterDirection.Input),
  11526. };
  11527. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  11528. }
  11529. #endregion
  11530. }
  11531. if (returnRows == 0)
  11532. {
  11533. oracleTrConn.Rollback();
  11534. oracleTrConn.Disconnect();
  11535. }
  11536. else
  11537. {
  11538. oracleTrConn.Commit();
  11539. oracleTrConn.Disconnect();
  11540. }
  11541. }
  11542. catch (Exception ex)
  11543. {
  11544. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  11545. {
  11546. oracleTrConn.Rollback();
  11547. oracleTrConn.Disconnect();
  11548. }
  11549. throw ex;
  11550. }
  11551. finally
  11552. {
  11553. if (oracleTrConn.ConnState == ConnectionState.Open)
  11554. {
  11555. oracleTrConn.Disconnect();
  11556. }
  11557. }
  11558. return returnRows;
  11559. }
  11560. /// <summary>
  11561. /// 更新盘点单
  11562. /// </summary>
  11563. /// <param name="InCheckedID">盘点单号</param>
  11564. /// <param name="BarCode">产品条码</param>
  11565. /// <param name="sUserInfo">用户基本信息</param>
  11566. /// <returns></returns>
  11567. public static int UpdateInChecked(int InCheckedID, string BarCode, SUserInfo sUserInfo)
  11568. {
  11569. int returnRows = 0;
  11570. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  11571. try
  11572. {
  11573. // 转换条码
  11574. string sqlString = @"select FUN_CMN_GetBarCode(:barcode,null,:accountid) From DUAL";
  11575. OracleParameter[] paras1 = new OracleParameter[]{
  11576. new OracleParameter(":barcode",OracleDbType.Varchar2, BarCode,ParameterDirection.Input),
  11577. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID,ParameterDirection.Input),
  11578. };
  11579. BarCode = oracleTrConn.GetSqlResultToStr(sqlString, paras1);
  11580. string sql = @"select 1 from TP_PM_InProduction where barcode=:barcode";
  11581. OracleParameter[] Paras = new OracleParameter[] {
  11582. new OracleParameter(":barcode",OracleDbType.NVarchar2,
  11583. BarCode,ParameterDirection.Input)
  11584. };
  11585. DataSet ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  11586. if (ds != null && ds.Tables[0].Rows.Count == 0)
  11587. {
  11588. returnRows = -2;//该产品不在生产线
  11589. return returnRows;
  11590. }
  11591. sql = @"select InCheckedFlag,CHECKEDUSERID as Userid from TP_PM_InCheckedDetail where InCheckedID=:InCheckedID and BarCode=:BarCode and Valueflag=1";
  11592. Paras = new OracleParameter[] {
  11593. new OracleParameter(":InCheckedID",OracleDbType.Int32,
  11594. InCheckedID,ParameterDirection.Input),
  11595. new OracleParameter(":BarCode",OracleDbType.NVarchar2,
  11596. BarCode,ParameterDirection.Input)
  11597. };
  11598. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  11599. if (ds != null && ds.Tables[0].Rows.Count == 0)
  11600. {
  11601. sql = @"select InCheckedNo from TP_PM_InChecked where InCheckedID=:InCheckedID";
  11602. Paras = new OracleParameter[] {
  11603. new OracleParameter(":InCheckedID",OracleDbType.Int32,
  11604. InCheckedID,ParameterDirection.Input),
  11605. };
  11606. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  11607. string InCheckedNo = ds.Tables[0].Rows[0]["InCheckedNo"].ToString();//肯定会有盘点单号,所以就没有加判断
  11608. //在产不在生产线上,属于盘赢
  11609. sql = @"
  11610. insert into TP_PM_InCheckedDetail
  11611. (
  11612. InCheckedID,
  11613. BarCode,
  11614. InCheckedNo,
  11615. ProductionLineID,
  11616. ProductionLineCode,
  11617. ProductionLineName,
  11618. ProcedureID,
  11619. ProcedureTime,
  11620. ProcedureModel,
  11621. ModelType,
  11622. DefectFlag,
  11623. ReworkProcedureID,
  11624. IsPublicBody,
  11625. IsReFire,
  11626. SpecialRepairFlag,
  11627. GoodsLevelID,
  11628. GoodsLevelTypeID,
  11629. GoodsID,
  11630. GoodsCode,
  11631. GoodsName,
  11632. UserID,
  11633. GroutingDailyID,
  11634. GroutingDailyDetailID,
  11635. GroutingDate,
  11636. GroutingLineID,
  11637. GroutingLineCode,
  11638. GroutingLineName,
  11639. GMouldTypeID,
  11640. CanManyTimes,
  11641. GroutingLineDetailID,
  11642. GroutingMouldCode,
  11643. MouldCode,
  11644. GroutingUserID,
  11645. GroutingUserCode,
  11646. GroutingNum,
  11647. Remarks,
  11648. KilnID,
  11649. KilnCode,
  11650. KilnName,
  11651. KilnCarID,
  11652. KilnCarCode,
  11653. KilnCarName,
  11654. KilnCarBatchNo,
  11655. KilnCarPosition,
  11656. AccountID,
  11657. CreateUserID,
  11658. UpdateUserID,
  11659. InCheckedFlag,
  11660. CheckedDate,
  11661. CheckedUserID,
  11662. logoid
  11663. )
  11664. select
  11665. :InCheckedID,
  11666. BarCode,
  11667. :InCheckedNo,
  11668. ProductionLineID,
  11669. ProductionLineCode,
  11670. ProductionLineName,
  11671. ProcedureID,
  11672. ProcedureTime,
  11673. ProcedureModel,
  11674. ModelType,
  11675. DefectFlag,
  11676. ReworkProcedureID,
  11677. IsPublicBody,
  11678. IsReFire,
  11679. SpecialRepairFlag,
  11680. GoodsLevelID,
  11681. GoodsLevelTypeID,
  11682. GoodsID,
  11683. GoodsCode,
  11684. GoodsName,
  11685. UserID,
  11686. GroutingDailyID,
  11687. GroutingDailyDetailID,
  11688. GroutingDate,
  11689. GroutingLineID,
  11690. GroutingLineCode,
  11691. GroutingLineName,
  11692. GMouldTypeID,
  11693. CanManyTimes,
  11694. GroutingLineDetailID,
  11695. GroutingMouldCode,
  11696. MouldCode,
  11697. GroutingUserID,
  11698. GroutingUserCode,
  11699. GroutingNum,
  11700. Remarks,
  11701. KilnID,
  11702. KilnCode,
  11703. KilnName,
  11704. KilnCarID,
  11705. KilnCarCode,
  11706. KilnCarName,
  11707. KilnCarBatchNo,
  11708. KilnCarPosition,
  11709. :AccountID,
  11710. :CreateUserID,
  11711. :UpdateUserID,
  11712. :InCheckedFlag,
  11713. sysdate,
  11714. :CheckedUserID,
  11715. logoid
  11716. from TP_PM_InProduction where 1=1
  11717. ";
  11718. ;
  11719. List<OracleParameter> parameters = new List<OracleParameter>();
  11720. sql += "AND instr(','||:barcode||',',','||TP_PM_InProduction.barcode||',')>0 ";
  11721. parameters.Add(new OracleParameter(":InCheckedID", OracleDbType.Int32, InCheckedID, ParameterDirection.Input));
  11722. parameters.Add(new OracleParameter(":InCheckedNo", OracleDbType.Varchar2, InCheckedNo, ParameterDirection.Input));
  11723. parameters.Add(new OracleParameter(":barcode", OracleDbType.NVarchar2, BarCode, ParameterDirection.Input));
  11724. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input));
  11725. parameters.Add(new OracleParameter(":CreateUserID", OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input));
  11726. parameters.Add(new OracleParameter(":UpdateUserID", OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input));
  11727. parameters.Add(new OracleParameter(":InCheckedFlag", OracleDbType.Int32, Constant.InCheckedFlag.InCheckedWin.GetHashCode(), ParameterDirection.Input));
  11728. parameters.Add(new OracleParameter(":CheckedUserID", OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input));
  11729. returnRows += oracleTrConn.ExecuteNonQuery(sql, parameters.ToArray());
  11730. returnRows = 10;
  11731. }
  11732. else
  11733. {
  11734. int InCheckedFlag = Convert.ToInt32(ds.Tables[0].Rows[0]["InCheckedFlag"]);
  11735. if (InCheckedFlag == 1)
  11736. {
  11737. if (Convert.ToInt32(ds.Tables[0].Rows[0]["Userid"]) != sUserInfo.UserID)
  11738. {
  11739. returnRows = -22;//己被其他工号盘点
  11740. }
  11741. else
  11742. {
  11743. returnRows = -24;//己被自己工号盘点
  11744. }
  11745. return returnRows;
  11746. }
  11747. else if (InCheckedFlag == 2)
  11748. {
  11749. if (Convert.ToInt32(ds.Tables[0].Rows[0]["Userid"]) != sUserInfo.UserID)
  11750. {
  11751. returnRows = -23;//己被其他工号盘盈
  11752. }
  11753. else
  11754. {
  11755. returnRows = -25;//己被自己工号盘盈
  11756. }
  11757. return returnRows;
  11758. }
  11759. sql = "update TP_PM_InCheckedDetail set InCheckedFlag=:InCheckedFlag,CheckedDate=sysdate,CheckedUserID=:CheckedUserID,UpdateUserID=:UpdateUserID where InCheckedID=:InCheckedID and BarCode=:BarCode and InCheckedFlag=:whereInCheckedFlag";
  11760. Paras = new OracleParameter[] {
  11761. new OracleParameter(":CheckedUserID",OracleDbType.Int32,
  11762. sUserInfo.UserID,ParameterDirection.Input),
  11763. new OracleParameter(":InCheckedFlag",OracleDbType.Int32,
  11764. Constant.InCheckedFlag.InCheckeded,ParameterDirection.Input),
  11765. new OracleParameter(":InCheckedID",OracleDbType.Int32,
  11766. InCheckedID,ParameterDirection.Input),
  11767. new OracleParameter(":BarCode",OracleDbType.NVarchar2,
  11768. BarCode,ParameterDirection.Input),
  11769. new OracleParameter(":whereInCheckedFlag",OracleDbType.Int32,
  11770. Constant.InCheckedFlag.InCheckedNo,ParameterDirection.Input),
  11771. new OracleParameter(":UpdateUserID",OracleDbType.Int32,
  11772. sUserInfo.UserID,ParameterDirection.Input),
  11773. };
  11774. returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  11775. returnRows = 1;//防止多次盘点此条码,下面在回滚回来,代码是有作用
  11776. }
  11777. if (returnRows == 0)
  11778. {
  11779. oracleTrConn.Rollback();
  11780. oracleTrConn.Disconnect();
  11781. }
  11782. else
  11783. {
  11784. oracleTrConn.Commit();
  11785. oracleTrConn.Disconnect();
  11786. }
  11787. }
  11788. catch (Exception ex)
  11789. {
  11790. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  11791. {
  11792. oracleTrConn.Rollback();
  11793. oracleTrConn.Disconnect();
  11794. }
  11795. throw ex;
  11796. }
  11797. finally
  11798. {
  11799. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  11800. {
  11801. oracleTrConn.Disconnect();
  11802. }
  11803. }
  11804. return returnRows;
  11805. }
  11806. /// <summary>
  11807. /// 停用盘点单
  11808. /// </summary>
  11809. /// <param name="InCheckedID">盘点单号</param>
  11810. /// <returns></returns>
  11811. public static int DisableInChecked(int InCheckedID, SUserInfo sUserInfo)
  11812. {
  11813. int returnRows = 0;
  11814. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  11815. try
  11816. {
  11817. string sql = "update TP_PM_InChecked set valueflag='0', updateuserid=:updateuserid where InCheckedID=:InCheckedID and valueflag='1'";
  11818. OracleParameter[] Paras = new OracleParameter[] {
  11819. new OracleParameter(":InCheckedID",OracleDbType.Int32,
  11820. InCheckedID,ParameterDirection.Input),
  11821. new OracleParameter(":updateuserid",OracleDbType.Int32,
  11822. sUserInfo.UserID,ParameterDirection.Input)
  11823. };
  11824. returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  11825. if (returnRows == 0)
  11826. {
  11827. oracleTrConn.Rollback();
  11828. oracleTrConn.Disconnect();
  11829. }
  11830. else
  11831. {
  11832. oracleTrConn.Commit();
  11833. oracleTrConn.Disconnect();
  11834. }
  11835. }
  11836. catch (Exception ex)
  11837. {
  11838. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  11839. {
  11840. oracleTrConn.Rollback();
  11841. oracleTrConn.Disconnect();
  11842. }
  11843. throw ex;
  11844. }
  11845. finally
  11846. {
  11847. if (oracleTrConn.ConnState == ConnectionState.Open)
  11848. {
  11849. oracleTrConn.Disconnect();
  11850. }
  11851. }
  11852. return returnRows;
  11853. }
  11854. /// <summary>
  11855. /// 撤销包装
  11856. /// </summary>
  11857. /// <param name="barcode">产品条码</param>
  11858. /// <returns></returns>
  11859. public static ServiceResultEntity AddChancelFinishedproduct(string barcode, SUserInfo sUserInfo)
  11860. {
  11861. ServiceResultEntity entity = new ServiceResultEntity();
  11862. int returnRows = 0;
  11863. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  11864. try
  11865. {
  11866. //xuwei add 2019-10-15 修正 撤销包装时 副品变正品
  11867. int goodsLevelID;
  11868. int goodsLevelTypeID;
  11869. //xuwei end
  11870. // 转换注浆条码
  11871. barcode = CommonModuleLogic.CommonModuleLogic.GetBarcode(oracleTrConn, barcode, sUserInfo);
  11872. DateTime? createTime = null;
  11873. // 1 条码是否在产成品表中
  11874. string sql = "select createTime,FHUserCode,GoodsCode,GoodsLevelID,GoodsLevelTypeID from tp_pm_finishedproduct where barcode=:barcode and valueflag=1";
  11875. OracleParameter[] Paras = new OracleParameter[] {
  11876. new OracleParameter(":barcode",OracleDbType.Varchar2,
  11877. barcode,ParameterDirection.Input)
  11878. };
  11879. DataSet ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  11880. if (ds.Tables[0].Rows.Count == 0)
  11881. {
  11882. //不存在产成品
  11883. returnRows = -1;
  11884. oracleTrConn.Rollback();
  11885. oracleTrConn.Disconnect();
  11886. entity.Result = returnRows;
  11887. return entity;
  11888. }
  11889. else
  11890. {
  11891. //wangx 2017-02-10 已经交接不允许撤销
  11892. if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["FHUserCode"].ToString()))
  11893. {
  11894. entity.Result = -200; //已交接,不能再次进行交接
  11895. entity.Message = "此产品【" + ds.Tables[0].Rows[0]["GoodsCode"].ToString() + "】已交接,不能进行该操作";
  11896. oracleTrConn.Rollback();
  11897. oracleTrConn.Disconnect();
  11898. return entity;
  11899. }
  11900. //wangx 2017-02-10 end
  11901. createTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["createTime"]); // 成品时间
  11902. //xuwei add 2019-10-15 修正 撤销包装时 副品变正品
  11903. goodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]);
  11904. goodsLevelTypeID = Convert.ToInt32(ds.Tables[0].Rows[0]["goodsLevelTypeID"]);
  11905. //xuwei end
  11906. }
  11907. #region 是否启用成品撤销限制天数
  11908. if (createTime != null)
  11909. {
  11910. sql = "select settingvalue from TP_MST_SystemSetting where settingcode=:settingcode and accountid=:accountid";
  11911. Paras = new OracleParameter[] {
  11912. new OracleParameter(":settingcode",OracleDbType.Varchar2,
  11913. Constant.SettingType.S_PM_005.ToString(),ParameterDirection.Input),
  11914. new OracleParameter(":accountid",OracleDbType.Int32,
  11915. sUserInfo.AccountID,ParameterDirection.Input)
  11916. };
  11917. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  11918. if (ds != null && ds.Tables[0].Rows.Count > 0)
  11919. {
  11920. if (Convert.ToInt32(ds.Tables[0].Rows[0]["settingvalue"]) > 0)
  11921. {
  11922. // 开启了限制
  11923. ServiceResultEntity resultEntity = PMModuleLogic.BarcodeAllowCancel(Convert.ToDateTime(createTime),
  11924. Convert.ToInt32(ds.Tables[0].Rows[0]["settingvalue"]), Constant.SettingType.S_PM_005.ToString(), sUserInfo);
  11925. if (Convert.ToInt32(resultEntity.Result) < 0)
  11926. {
  11927. //超过成品撤销限制天数
  11928. returnRows = -200;
  11929. oracleTrConn.Rollback();
  11930. oracleTrConn.Disconnect();
  11931. entity.Result = returnRows;
  11932. entity.Message = resultEntity.Message;
  11933. return entity;
  11934. }
  11935. }
  11936. }
  11937. }
  11938. #endregion
  11939. sql = "select 1 from tp_pm_productiondatain where barcode=:barcode and valueflag=1";
  11940. Paras = new OracleParameter[] {
  11941. new OracleParameter(":barcode",OracleDbType.Varchar2,
  11942. barcode,ParameterDirection.Input)
  11943. };
  11944. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  11945. if (ds.Tables[0].Rows.Count == 0)
  11946. {
  11947. // 2 生产数据恢复到在产生产数据 xuwei 不用处理
  11948. sql = @"insert into tp_pm_productiondatain
  11949. (
  11950. ProductionDataID,
  11951. BarCode,
  11952. CentralizedBatchNo,
  11953. ProductionLineID,
  11954. ProductionLineCode,
  11955. ProductionLineName,
  11956. ProcedureID,
  11957. ProcedureCode,
  11958. ProcedureName,
  11959. ProcedureModel,
  11960. ModelType,
  11961. PieceType,
  11962. IsReworked,
  11963. NodeType,
  11964. IsPublicBody,
  11965. IsReFire,
  11966. GoodsLevelID,
  11967. GoodsLevelTypeID,
  11968. SpecialRepairFlag,
  11969. OrganizationID,
  11970. GoodsID,
  11971. GoodsCode,
  11972. GoodsName,
  11973. UserID,
  11974. UserCode,
  11975. UserName,
  11976. ClassesSettingID,
  11977. KilnID,
  11978. KilnCode,
  11979. KilnName,
  11980. KilnCarID,
  11981. KilnCarCode,
  11982. KilnCarName,
  11983. KilnCarBatchNo,
  11984. KilnCarPosition,
  11985. ReworkProcedureID,
  11986. ReworkProcedureCode,
  11987. ReworkProcedureName,
  11988. GroutingDailyID,
  11989. GroutingDailyDetailID,
  11990. GroutingLineID,
  11991. GroutingLineCode,
  11992. GroutingLineName,
  11993. GMouldTypeID,
  11994. CanManyTimes,
  11995. GroutingLineDetailID,
  11996. GroutingDate,
  11997. GroutingMouldCode,
  11998. MouldCode,
  11999. GroutingUserID,
  12000. GroutingUserCode,
  12001. GroutingNum,
  12002. Remarks,
  12003. AccountDate,
  12004. SettlementFlag,
  12005. AccountID,
  12006. ValueFlag,
  12007. CreateTime,
  12008. CreateUserID,
  12009. UpdateTime,
  12010. UpdateUserID,
  12011. OPTimeStamp,
  12012. TriggerFlag,
  12013. LogoID,
  12014. BackOutTime,BackOutUserID,BackOutUserCode,CheckTime
  12015. )
  12016. select
  12017. ProductionDataID,
  12018. BarCode,
  12019. CentralizedBatchNo,
  12020. ProductionLineID,
  12021. ProductionLineCode,
  12022. ProductionLineName,
  12023. ProcedureID,
  12024. ProcedureCode,
  12025. ProcedureName,
  12026. ProcedureModel,
  12027. ModelType,
  12028. PieceType,
  12029. IsReworked,
  12030. NodeType,
  12031. IsPublicBody,
  12032. IsReFire,
  12033. GoodsLevelID,
  12034. GoodsLevelTypeID,
  12035. SpecialRepairFlag,
  12036. OrganizationID,
  12037. GoodsID,
  12038. GoodsCode,
  12039. GoodsName,
  12040. UserID,
  12041. UserCode,
  12042. UserName,
  12043. ClassesSettingID,
  12044. KilnID,
  12045. KilnCode,
  12046. KilnName,
  12047. KilnCarID,
  12048. KilnCarCode,
  12049. KilnCarName,
  12050. KilnCarBatchNo,
  12051. KilnCarPosition,
  12052. ReworkProcedureID,
  12053. ReworkProcedureCode,
  12054. ReworkProcedureName,
  12055. GroutingDailyID,
  12056. GroutingDailyDetailID,
  12057. GroutingLineID,
  12058. GroutingLineCode,
  12059. GroutingLineName,
  12060. GMouldTypeID,
  12061. CanManyTimes,
  12062. GroutingLineDetailID,
  12063. GroutingDate,
  12064. GroutingMouldCode,
  12065. MouldCode,
  12066. GroutingUserID,
  12067. GroutingUserCode,
  12068. GroutingNum,
  12069. Remarks,
  12070. AccountDate,
  12071. SettlementFlag,
  12072. AccountID,
  12073. ValueFlag,
  12074. CreateTime,
  12075. CreateUserID,
  12076. UpdateTime,
  12077. UpdateUserID,
  12078. OPTimeStamp,
  12079. 1,
  12080. LogoID,
  12081. BackOutTime,BackOutUserID,BackOutUserCode,CheckTime
  12082. from TP_PM_ProductionData where valueflag=1 and barcode=:barcode
  12083. ";
  12084. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  12085. }
  12086. // 3 停用在产生产数据包装数据
  12087. sql = "update TP_PM_ProductionDataIn set valueflag=0,updateuserID=" + sUserInfo.UserID
  12088. + " where ProductionDataID=(select max(ProductionDataID) from TP_PM_ProductionDataIn where barcode=:barcode and valueflag=1)";
  12089. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  12090. // 4 插入在产数据
  12091. //xuwei fix 2019-10-15 修正 撤销包装时 副品变正品
  12092. sql = $@"insert into TP_PM_InProduction
  12093. (
  12094. BarCode,
  12095. ProductionLineID,
  12096. ProductionLineCode,
  12097. ProductionLineName,
  12098. FlowProcedureID,
  12099. FlowProcedureTime,
  12100. ProcedureID,
  12101. ProcedureTime,
  12102. ProductionDataID,
  12103. ProcedureModel,
  12104. ModelType,
  12105. DefectFlag,
  12106. ReworkProcedureID,
  12107. IsPublicBody,
  12108. IsReFire,
  12109. SpecialRepairFlag,
  12110. GoodsLevelID,
  12111. GoodsLevelTypeID,
  12112. GoodsID,
  12113. GoodsCode,
  12114. GoodsName,
  12115. UserID,
  12116. GroutingDailyID,
  12117. GroutingDailyDetailID,
  12118. GroutingDate,
  12119. GroutingLineID,
  12120. GroutingLineCode,
  12121. GroutingLineName,
  12122. GMouldTypeID,
  12123. CanManyTimes,
  12124. GroutingLineDetailID,
  12125. GroutingMouldCode,
  12126. MouldCode,
  12127. GroutingUserID,
  12128. GroutingUserCode,
  12129. GroutingNum,
  12130. Remarks,
  12131. KilnID,
  12132. KilnCode,
  12133. KilnName,
  12134. KilnCarID,
  12135. KilnCarCode,
  12136. KilnCarName,
  12137. KilnCarBatchNo,
  12138. KilnCarPosition,
  12139. AccountID,
  12140. ValueFlag,
  12141. CreateTime,
  12142. CreateUserID,
  12143. UpdateTime,
  12144. UpdateUserID,
  12145. OPTimeStamp,
  12146. LogoID
  12147. )
  12148. select
  12149. BarCode,
  12150. ProductionLineID,
  12151. ProductionLineCode,
  12152. ProductionLineName,
  12153. ProcedureID,
  12154. CreateTime,
  12155. ProcedureID,
  12156. CreateTime,
  12157. ProductionDataID,
  12158. ProcedureModel,
  12159. ModelType,
  12160. 0,
  12161. ReworkProcedureID,
  12162. IsPublicBody,
  12163. IsReFire,
  12164. SpecialRepairFlag,
  12165. {goodsLevelID} AS GoodsLevelID,
  12166. {goodsLevelTypeID} AS GoodsLevelTypeID,
  12167. GoodsID,
  12168. GoodsCode,
  12169. GoodsName,
  12170. UserID,
  12171. GroutingDailyID,
  12172. GroutingDailyDetailID,
  12173. GroutingDate,
  12174. GroutingLineID,
  12175. GroutingLineCode,
  12176. GroutingLineName,
  12177. GMouldTypeID,
  12178. CanManyTimes,
  12179. GroutingLineDetailID,
  12180. GroutingMouldCode,
  12181. MouldCode,
  12182. GroutingUserID,
  12183. GroutingUserCode,
  12184. GroutingNum,
  12185. Remarks,
  12186. KilnID,
  12187. KilnCode,
  12188. KilnName,
  12189. KilnCarID,
  12190. KilnCarCode,
  12191. KilnCarName,
  12192. KilnCarBatchNo,
  12193. KilnCarPosition,
  12194. AccountID,
  12195. ValueFlag,
  12196. CreateTime,
  12197. CreateUserID,
  12198. UpdateTime,
  12199. UpdateUserID,
  12200. OPTimeStamp,
  12201. LogoID
  12202. from TP_PM_ProductionData where TP_PM_ProductionData.ProductionDataID=(select max(ProductionDataID) from TP_PM_ProductionData where barcode=:barcode and valueflag=1)";
  12203. //xuwei end
  12204. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  12205. // 5 删除产成品表
  12206. sql = "delete from tp_pm_finishedproduct where barcode=:barcode and valueflag=1";
  12207. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  12208. if (returnRows <= 0)
  12209. {
  12210. oracleTrConn.Rollback();
  12211. oracleTrConn.Disconnect();
  12212. }
  12213. else
  12214. {
  12215. oracleTrConn.Commit();
  12216. oracleTrConn.Disconnect();
  12217. }
  12218. }
  12219. catch (Exception ex)
  12220. {
  12221. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  12222. {
  12223. oracleTrConn.Rollback();
  12224. oracleTrConn.Disconnect();
  12225. }
  12226. throw ex;
  12227. }
  12228. finally
  12229. {
  12230. if (oracleTrConn.ConnState == ConnectionState.Open)
  12231. {
  12232. oracleTrConn.Disconnect();
  12233. }
  12234. }
  12235. entity.Result = returnRows;
  12236. return entity;
  12237. }
  12238. /// <summary>
  12239. /// 公坯设定
  12240. /// </summary>
  12241. /// <param name="barcode">产品条码</param>
  12242. /// <returns></returns>
  12243. public static int AddPublicBodyProduct(string barcode, SUserInfo sUserInfo)
  12244. {
  12245. int returnRows = 0;
  12246. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  12247. try
  12248. {
  12249. // 1 条码是否在在产表中
  12250. string sql = "select ispublicbody from tp_pm_inproduction where barcode=:barcode and valueflag=1";
  12251. OracleParameter[] Paras = new OracleParameter[] {
  12252. new OracleParameter(":barcode",OracleDbType.Varchar2,
  12253. barcode,ParameterDirection.Input)
  12254. };
  12255. DataSet ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  12256. if (ds.Tables[0].Rows.Count == 0)
  12257. {
  12258. //不存在生产线上,
  12259. returnRows = -1;
  12260. oracleTrConn.Rollback();
  12261. oracleTrConn.Disconnect();
  12262. return returnRows;
  12263. }
  12264. else
  12265. {
  12266. if (ds.Tables[0].Rows[0]["ispublicbody"].ToString() == "1")
  12267. {
  12268. returnRows = -2;
  12269. oracleTrConn.Rollback();
  12270. oracleTrConn.Disconnect();
  12271. return returnRows;
  12272. }
  12273. }
  12274. // 2 TP_PM_GroutingDailyDetail 在产盘点明细
  12275. sql = "update TP_PM_GroutingDailyDetail set ispublicbody=1 where barcode=:barcode";
  12276. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  12277. // 3 TP_PM_InCheckedDetail
  12278. sql = "update TP_PM_InCheckedDetail set ispublicbody=1 where barcode=:barcode";
  12279. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  12280. // 4 TP_PM_InProduction
  12281. sql = "update TP_PM_InProduction set ispublicbody=1 where barcode=:barcode";
  12282. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  12283. // 5 TP_PM_InProductionTrash
  12284. sql = "update TP_PM_InProductionTrash set ispublicbody=1 where barcode=:barcode";
  12285. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  12286. // 6 TP_PM_ProductionDataIn
  12287. sql = "update TP_PM_ProductionDataIn set ispublicbody=1 where barcode=:barcode";
  12288. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  12289. // 7 TP_PM_ScrapProduct
  12290. sql = "update TP_PM_ScrapProduct set ispublicbody=1 where barcode=:barcode";
  12291. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  12292. if (returnRows <= 0)
  12293. {
  12294. oracleTrConn.Rollback();
  12295. oracleTrConn.Disconnect();
  12296. }
  12297. else
  12298. {
  12299. oracleTrConn.Commit();
  12300. oracleTrConn.Disconnect();
  12301. }
  12302. }
  12303. catch (Exception ex)
  12304. {
  12305. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  12306. {
  12307. oracleTrConn.Rollback();
  12308. oracleTrConn.Disconnect();
  12309. }
  12310. throw ex;
  12311. }
  12312. finally
  12313. {
  12314. if (oracleTrConn.ConnState == ConnectionState.Open)
  12315. {
  12316. oracleTrConn.Disconnect();
  12317. }
  12318. }
  12319. return returnRows;
  12320. }
  12321. /// <summary>
  12322. /// 交坯保存校验(首节点)
  12323. /// </summary>
  12324. /// <param name="oracleTrConn">连接对象</param>
  12325. /// <param name="procedureID">工序ID</param>
  12326. /// <param name="barcode">条码</param>
  12327. /// <param name="goodsID">返回的产品ID</param>
  12328. /// <param name="goodsCode">返回的产品Code</param>
  12329. /// <param name="goodsName">返回的产品名称</param>
  12330. /// <param name="groutingUserID">返回的注浆者ID</param>
  12331. /// <returns>string</returns>
  12332. /// <remarks>
  12333. /// 陈冰 2014.09.18 新建
  12334. /// </remarks>
  12335. private static string CheckBarcodeDeliverMud(IDBTransaction oracleTrConn,
  12336. int procedureID,
  12337. string barcode,
  12338. out int goodsID,
  12339. out string goodsCode,
  12340. out string goodsName,
  12341. out string groutingUserCode,
  12342. SUserInfo sUserInfo, ref int? GroutingDailyDetailID
  12343. )
  12344. {
  12345. try
  12346. {
  12347. string sql = "select barcodestatus,barcode,GroutingDailyDetailid from TP_PM_USEDBARCODE where barcode=:barcode";
  12348. OracleParameter[] paras = new OracleParameter[]{
  12349. new OracleParameter("barcode",OracleDbType.NVarchar2,barcode,ParameterDirection.Input),
  12350. };
  12351. DataSet ds = oracleTrConn.GetSqlResultToDs(sql, paras);
  12352. string ErrorMessage = "";
  12353. if (ds != null && ds.Tables[0].Rows.Count == 0)
  12354. {
  12355. ErrorMessage = "无效条码";
  12356. }
  12357. else
  12358. {
  12359. //不等于空的时候
  12360. if (ds.Tables[0].Rows[0]["barcodestatus"].ToString() == "-1")
  12361. {
  12362. sql = "select max(newbarcode) from TP_PM_BarCodeRecord where BarCode='" + ds.Tables[0].Rows[0]["barcode"].ToString() + "'";
  12363. string newbarcode = oracleTrConn.GetSqlResultToStr(sql);
  12364. ErrorMessage = "条码已被替换,新条码为" + newbarcode;
  12365. }
  12366. else if (ds.Tables[0].Rows[0]["barcodestatus"].ToString() == "2")
  12367. {
  12368. ErrorMessage = "产品开模时已损坏";
  12369. }
  12370. // 已经交坯
  12371. else if (ds.Tables[0].Rows[0]["barcodestatus"].ToString() == "3" ||
  12372. ds.Tables[0].Rows[0]["barcodestatus"].ToString() == "4")
  12373. {
  12374. //ErrorMessage = "产品已交坯";
  12375. ErrorMessage = "产品已在产";
  12376. }
  12377. }
  12378. string sqlString = @"select
  12379. GroutingDailyDetailid,
  12380. GoodsID,
  12381. GoodsCode,
  12382. GoodsName,
  12383. UserCode as GroutingUserCode,
  12384. groutingcount as GroutingNum,
  12385. GroutingMouldCode as MouldCode,
  12386. ispublicbody,
  12387. Groutingdate,
  12388. SpecialRepairFlag
  12389. from
  12390. tp_pm_GroutingDailyDetail
  12391. where tp_pm_GroutingDailyDetail.groutingdailydetailid=:groutingdailydetailid";
  12392. paras = new OracleParameter[]{
  12393. new OracleParameter(":groutingdailydetailid",ds.Tables[0].Rows[0]["GroutingDailyDetailid"].ToString()),
  12394. };
  12395. ds = oracleTrConn.GetSqlResultToDs(sqlString, paras);
  12396. goodsID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsID"]);
  12397. goodsCode = ds.Tables[0].Rows[0]["GoodsCode"].ToString();
  12398. goodsName = ds.Tables[0].Rows[0]["GoodsName"].ToString();
  12399. groutingUserCode = ds.Tables[0].Rows[0]["GroutingUserCode"].ToString();
  12400. GroutingDailyDetailID = Convert.ToInt32(ds.Tables[0].Rows[0]["GroutingDailyDetailID"]);
  12401. string sqlExistGoods = "select count(GoodsID) from TP_PC_ProcedureGoods where GoodsID=:GoodsID and ProcedureID=:ProcedureID";
  12402. paras = new OracleParameter[]{
  12403. new OracleParameter(":GoodsID",ds.Tables[0].Rows[0]["GoodsID"].ToString()),
  12404. new OracleParameter(":ProcedureID",procedureID),
  12405. };
  12406. DataSet dsGoods = oracleTrConn.GetSqlResultToDs(sqlExistGoods, paras);
  12407. if (dsGoods.Tables[0].Rows[0][0].ToString() != "1")
  12408. {
  12409. ErrorMessage = @"条码[" + barcode +
  12410. "]不可以经过该工序\n\r原因:条码对应的产品编码[" +
  12411. ds.Tables[0].Rows[0]["GoodsCode"].ToString() + "]没有在该工序中配置";
  12412. }
  12413. return ErrorMessage;
  12414. }
  12415. catch (Exception ex)
  12416. {
  12417. throw ex;
  12418. }
  12419. }
  12420. /// <summary>
  12421. /// 标准计件(单点采集)
  12422. /// </summary>
  12423. /// <param name="oracleTrConn">数据连接对象</param>
  12424. /// <param name="procedure">工序对象</param>
  12425. /// <param name="barcodeTable">条码信息</param>
  12426. /// <param name="sUserInfo">用户基本信息</param>
  12427. /// <param name="goodsID">返回的产品ID</param>
  12428. /// <param name="goodsCode">返回的产品Code</param>
  12429. /// <param name="goodsName">返回的产品名称</param>
  12430. /// <param name="groutingUserID">返回的注浆者ID</param>
  12431. /// <returns>string</returns>
  12432. /// <remarks>
  12433. /// 陈冰 2014.09.18 新建
  12434. /// </remarks>
  12435. private static string AddNormalWorkPiece2(IDBTransaction oracleTrConn,
  12436. ProcedureEntity procedure,
  12437. DataTable barcodeTable,
  12438. SUserInfo sUserInfo,
  12439. out int goodsID,
  12440. out string goodsCode,
  12441. out string goodsName,
  12442. out string groutingUserCode)
  12443. {
  12444. try
  12445. {
  12446. goodsID = Constant.INT_IS_ZERO;
  12447. goodsCode = null;
  12448. goodsName = null;
  12449. groutingUserCode = string.Empty; //Constant.INT_IS_ZERO;
  12450. // 获得账务日期
  12451. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  12452. string errMsg = string.Empty;
  12453. // 本批采集的批次号
  12454. string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  12455. string finishedloadbatchno = DateTime.Now.ToString("yyMMddHHmmss-") + centralizedBatchNo;
  12456. // 条码信息
  12457. foreach (DataRow barcodeRow in barcodeTable.Rows)
  12458. {
  12459. // 条码
  12460. string barcode = barcodeRow["Barcode"].ToString();
  12461. if (string.IsNullOrEmpty(barcode))
  12462. {
  12463. throw new Exception("传入的条码号为空");
  12464. }
  12465. // 生产工号
  12466. int workUserID = Convert.ToInt32(barcodeRow["UserID"]);
  12467. // 生产工号
  12468. string workUserCode = barcodeRow["UserCode"].ToString();
  12469. //生产数据ID
  12470. string sql = "select SEQ_PM_ProductionData_ID.nextval from dual";
  12471. int productionDataID = Convert.ToInt32(oracleTrConn.GetSqlResultToStr(sql));
  12472. int? GroutingDailyDetailID = null;//注浆明细ID
  12473. if (procedure.CollectType == 1)
  12474. {
  12475. // ccc todo
  12476. //if (procedure.ModelType == (int)Constant.ProcedureModelType.DeliverMud)//是交坯节点,并且不是公坯的
  12477. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  12478. {
  12479. #region 校验条码有效性
  12480. errMsg = CheckBarcodeDeliverMud(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo, ref GroutingDailyDetailID);
  12481. if (!string.IsNullOrEmpty(errMsg))
  12482. {
  12483. return errMsg;
  12484. }
  12485. #endregion
  12486. }
  12487. else
  12488. {
  12489. #region 校验条码有效性
  12490. errMsg = CheckBarcode(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo);
  12491. if (!string.IsNullOrEmpty(errMsg))
  12492. {
  12493. return errMsg;
  12494. }
  12495. #endregion
  12496. }
  12497. }
  12498. else
  12499. {
  12500. // string sqlGroutingInfo = @"select tp_pm_groutingdailydetail.goodsid,
  12501. // tp_pm_groutingdailydetail.goodscode,
  12502. // tp_pm_groutingdailydetail.goodsname,
  12503. // tp_pm_groutingdailydetail.usercode as groutingUserCode
  12504. // from tp_pm_groutingdailydetail where barcode=:barcode
  12505. // ";
  12506. string sqlGroutingInfo = "";
  12507. // sqlGroutingInfo = @"select tp_pm_groutingdailydetail.goodsid,
  12508. // tp_pm_groutingdailydetail.goodscode,
  12509. // tp_pm_groutingdailydetail.goodsname,
  12510. // tp_pm_groutingdailydetail.usercode as groutingUserCode
  12511. // from tp_pm_groutingdailydetail where barcode=:barcode
  12512. // ";
  12513. //if (procedure.NodeType == (int)Constant.ProcedureNodeType.End)
  12514. //{
  12515. sqlGroutingInfo = @"select tp_pm_groutingdailydetail.goodsid,
  12516. tp_pm_groutingdailydetail.goodscode,
  12517. tp_pm_groutingdailydetail.goodsname,
  12518. tp_pm_groutingdailydetail.usercode as groutingUserCode
  12519. from tp_pm_groutingdailydetail where groutingdailydetailid in
  12520. (select groutingdailydetailid from TP_PM_USEDBARCODE where barcode=:barcode)
  12521. ";
  12522. //}
  12523. OracleParameter[] ReFireparas = new OracleParameter[] {
  12524. new OracleParameter(":barcode",barcode),
  12525. };
  12526. DataSet dsGrouting = oracleTrConn.GetSqlResultToDs(sqlGroutingInfo, ReFireparas);
  12527. if (dsGrouting != null && dsGrouting.Tables[0].Rows.Count > 0)
  12528. {
  12529. goodsID = Convert.ToInt32(dsGrouting.Tables[0].Rows[0]["goodsid"]);
  12530. goodsCode = dsGrouting.Tables[0].Rows[0]["goodscode"].ToString();
  12531. goodsName = dsGrouting.Tables[0].Rows[0]["goodsName"].ToString();
  12532. groutingUserCode = dsGrouting.Tables[0].Rows[0]["groutingUserCode"].ToString();
  12533. }
  12534. }
  12535. int? ClassesSettingID = null;//班次配置ID
  12536. #region 添加生产者数据
  12537. if (procedure.ModelType == (int)Constant.ProcedureModelType.DeliverMud)//是交坯节点,并且不是公坯的
  12538. {
  12539. string GroutingUserCode = barcodeRow["GroutingUserCode"].ToString();
  12540. if (GroutingUserCode.ToLower() == workUserCode.ToLower())
  12541. {
  12542. //errMsg = AddProducerDeliverAdobe(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo);
  12543. }
  12544. else
  12545. {
  12546. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID);
  12547. }
  12548. }
  12549. else
  12550. {
  12551. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID);
  12552. }
  12553. if (!string.IsNullOrEmpty(errMsg))
  12554. {
  12555. return errMsg;
  12556. }
  12557. #endregion
  12558. #region 添加生产数据
  12559. ProductionDataEntity productionData = new ProductionDataEntity();
  12560. #region 属性赋值
  12561. productionData.GroutingDailyDetailID = GroutingDailyDetailID;//只有交坯的时候用到
  12562. productionData.ClassesSettingID = ClassesSettingID;
  12563. productionData.ProductionDataID = productionDataID;
  12564. productionData.Barcode = barcode;
  12565. productionData.CentralizedBatchNo = centralizedBatchNo;
  12566. productionData.ProductionLineID = procedure.ProductionLineID;
  12567. productionData.ProductionLineCode = procedure.ProductionlineCode;
  12568. productionData.ProductionLineName = procedure.ProductionlineName;
  12569. productionData.CompleteProcedureID = procedure.ProcedureID;
  12570. productionData.ProcedureCode = procedure.ProcedureCode;
  12571. productionData.ProcedureName = procedure.ProcedureName;
  12572. productionData.ProcedureModel = procedure.ProcedureModel;
  12573. productionData.ModelType = procedure.ModelType;
  12574. productionData.NodeType = procedure.NodeType;
  12575. productionData.PieceType = procedure.PieceType;
  12576. if (procedure.IsSpecialRework == 0)
  12577. {
  12578. productionData.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  12579. //不加条件valueflag,是因为,成检后重烧走过之后,在次重烧,以后也是重烧状态
  12580. //string sqlReFire = "select * from tp_PM_ProductionData where ProductionDataid=(select max(ProductionDataid) from tp_PM_ProductionData where barcode='" + productionData.Barcode + "')";
  12581. //xuwei 2019-09-18 交坯节点判定 0引用 不做处理
  12582. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)//是交坯节点,肯定不会是重烧
  12583. {
  12584. productionData.IsReFire = (int)Constant.ReFireFlag.No;
  12585. productionData.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  12586. }
  12587. ////// else
  12588. ////// {
  12589. ////// string sqlReFire = @"select
  12590. ////// isrefire
  12591. ////// from tp_pm_inproduction where barcode=:barcode
  12592. ////// ";
  12593. ////// OracleParameter[] ReFireparas = new OracleParameter[] {
  12594. ////// new OracleParameter(":barcode",barcode),
  12595. ////// };
  12596. ////// DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas);
  12597. ////// if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0)
  12598. ////// {
  12599. ////// if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0)
  12600. ////// {
  12601. ////// productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]);
  12602. ////// //if (productionData.IsReFire == 6) wangxin modify 20150422 因为已经大于0,定是重烧,即有缺陷
  12603. ////// //{
  12604. ////// productionData.DefectFlag = (int)Constant.GoodsLevelType.Defect;
  12605. ////// //}
  12606. ////// }
  12607. ////// }
  12608. ////// }
  12609. }
  12610. else
  12611. {
  12612. productionData.IsReFire = (int)Constant.GoodsLevelType.ReFire;
  12613. productionData.DefectFlag = (int)Constant.GoodsLevelType.Defect;
  12614. }
  12615. productionData.ReworkProcedureID = null;
  12616. #region 交坯判断
  12617. // 交坯节点
  12618. if (barcodeTable.Columns.Contains("IsPublicBody"))
  12619. {
  12620. productionData.IsPublicBody = Convert.ToInt32(barcodeRow["IsPublicBody"]);
  12621. }
  12622. // 非交坯节点
  12623. else
  12624. {
  12625. // 正常坯
  12626. productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, barcode);
  12627. }
  12628. #endregion
  12629. productionData.OrganizationID = procedure.OrganizationID;
  12630. productionData.GoodsID = goodsID;
  12631. productionData.GoodsCode = goodsCode;
  12632. productionData.GoodsName = goodsName;
  12633. productionData.UserID = workUserID;
  12634. productionData.UserCode = barcodeRow["UserCode"].ToString();
  12635. productionData.UserName = barcodeRow["UserName"].ToString();
  12636. #endregion
  12637. string OutSpecialRepairflag = "0";//干补标识
  12638. DataSet outDataSet = null;
  12639. //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的
  12640. //xuwei fix 2019-09-26 使用通用方法判定
  12641. // 2019-1016
  12642. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  12643. {
  12644. int isNodeBegin = IsNodeBegin<IDBTransaction>(oracleTrConn, productionData.Barcode);
  12645. if (isNodeBegin == 0)
  12646. {
  12647. procedure.NodeType = (int)Constant.ProcedureNodeType.Middle;
  12648. }
  12649. }
  12650. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  12651. {
  12652. errMsg = AddProductionDataDeliverMud(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag, out outDataSet);
  12653. }
  12654. else
  12655. {
  12656. errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag);
  12657. }
  12658. if (!string.IsNullOrEmpty(errMsg))
  12659. {
  12660. return errMsg;
  12661. }
  12662. #endregion
  12663. #region 开始节点
  12664. //xuwei remove 2019-09-26 此处为重复判定移除
  12665. //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的
  12666. //xuwei fix 2019-09-26 使用通用方法判定
  12667. //int isNodeBegin = IsNodeBegin<IDBTransaction>(oracleTrConn, productionData.Barcode);
  12668. // 2019-1016
  12669. //if (isNodeBegin == 1) procedure.NodeType = (int)Constant.ProcedureNodeType.Begin;
  12670. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  12671. {
  12672. #region 添加在产产品数据
  12673. InProductionEntity addInProductionEntity = new InProductionEntity();
  12674. addInProductionEntity.BarCode = barcode;
  12675. //流程工序ID
  12676. addInProductionEntity.FlowProcedureID = procedure.ProcedureID;
  12677. // 当前工序
  12678. addInProductionEntity.ProcedureID = procedure.ProcedureID;
  12679. //addInProductionEntity.CompleteProcedureID = procedure.ProcedureID;
  12680. // 工序模型
  12681. addInProductionEntity.ProcedureModel = procedure.ProcedureModel;
  12682. // 工序类别
  12683. addInProductionEntity.ModelType = procedure.ModelType;
  12684. addInProductionEntity.SpecialRepairflag = Convert.ToInt32(OutSpecialRepairflag);//干补标识
  12685. addInProductionEntity.ProductionDataID = productionDataID;
  12686. #region 交坯判断
  12687. addInProductionEntity.IsPublicBody = productionData.IsPublicBody;// 生产数据已经判断是否为公坯
  12688. #endregion
  12689. // 生产工号
  12690. addInProductionEntity.UserID = workUserID;
  12691. // 执行添加
  12692. errMsg = AddInProduction(oracleTrConn, addInProductionEntity, sUserInfo, outDataSet);
  12693. // 执行失败
  12694. if (!string.IsNullOrEmpty(errMsg))
  12695. {
  12696. return errMsg;
  12697. }
  12698. #endregion
  12699. }
  12700. #endregion
  12701. #region 中间节点
  12702. else if (procedure.NodeType == (int)Constant.ProcedureNodeType.Middle)
  12703. {
  12704. #region 修改在产产品数据的当前工序,清空返工工序字段
  12705. InProductionEntity addInProductionEntity = new InProductionEntity();
  12706. addInProductionEntity.BarCode = barcode;
  12707. //流程工序ID
  12708. addInProductionEntity.FlowProcedureID = procedure.ProcedureID;
  12709. // 当前工序
  12710. addInProductionEntity.ProcedureID = procedure.ProcedureID;
  12711. //当前生产数据ID
  12712. addInProductionEntity.ProductionDataID = productionDataID;
  12713. // 工序模型
  12714. addInProductionEntity.ProcedureModel = procedure.ProcedureModel;
  12715. // 工序类别
  12716. addInProductionEntity.ModelType = procedure.ModelType;
  12717. // 生产工号
  12718. addInProductionEntity.UserID = workUserID;
  12719. // 缺陷标识
  12720. // addInProductionEntity.DefectFlag = (int)Constant.DefectFlag.No;
  12721. //addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefect;
  12722. if (procedure.IsSpecialRework == 0)
  12723. {
  12724. addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  12725. }
  12726. else
  12727. {
  12728. addInProductionEntity.IsReFire = (int)Constant.GoodsLevelType.ReFire;
  12729. addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  12730. }
  12731. #region 交坯判断
  12732. addInProductionEntity.IsPublicBody = productionData.IsPublicBody;// 生产数据已经判断是否为公坯
  12733. #endregion
  12734. // 执行修改
  12735. errMsg = UpdateInProduction(oracleTrConn, addInProductionEntity, sUserInfo);
  12736. // 执行失败
  12737. if (!string.IsNullOrEmpty(errMsg))
  12738. {
  12739. return errMsg;
  12740. }
  12741. #endregion
  12742. }
  12743. #endregion
  12744. #region 结束节点
  12745. else
  12746. {
  12747. #region 添加成品数据 删除在产产品数据
  12748. FinishedProductEntity finishedProduct = new FinishedProductEntity();
  12749. finishedProduct.BarCode = barcode;
  12750. errMsg = AddFinishedProduct(oracleTrConn, finishedProduct, sUserInfo, finishedloadbatchno);
  12751. if (!string.IsNullOrEmpty(errMsg))
  12752. {
  12753. return errMsg;
  12754. }
  12755. InProductionEntity delInProductionEntity = new InProductionEntity();
  12756. delInProductionEntity.BarCode = barcode;
  12757. // 执行删除 在产数据
  12758. errMsg = DeleteInProduction(oracleTrConn, delInProductionEntity, true, sUserInfo);
  12759. // 执行失败
  12760. if (!string.IsNullOrEmpty(errMsg))
  12761. {
  12762. return errMsg;
  12763. }
  12764. #endregion
  12765. }
  12766. #endregion
  12767. }
  12768. return errMsg;
  12769. }
  12770. catch (Exception ex)
  12771. {
  12772. throw ex;
  12773. }
  12774. }
  12775. /// <summary>
  12776. /// 标准计件
  12777. /// </summary>
  12778. /// <param name="oracleTrConn">数据连接对象</param>
  12779. /// <param name="procedure">工序对象</param>
  12780. /// <param name="barcodeTable">条码信息</param>
  12781. /// <param name="sUserInfo">用户基本信息</param>
  12782. /// <param name="goodsID">返回的产品ID</param>
  12783. /// <param name="goodsCode">返回的产品Code</param>
  12784. /// <param name="goodsName">返回的产品名称</param>
  12785. /// <param name="groutingUserID">返回的注浆者ID</param>
  12786. /// <returns>string</returns>
  12787. /// <remarks>
  12788. /// 陈冰 2014.09.18 新建
  12789. /// </remarks>
  12790. private static string AddNormalWorkPieceSinglePoint(IDBTransaction oracleTrConn,
  12791. ProcedureEntity procedure,
  12792. DataTable barcodeTable,
  12793. SUserInfo sUserInfo,
  12794. int goodsID,
  12795. string goodsCode,
  12796. string goodsName,
  12797. string groutingUserCode,
  12798. int? arvGroutingDailyDetailID,
  12799. bool isSendBody = false)
  12800. {
  12801. try
  12802. {
  12803. //goodsID = Constant.INT_IS_ZERO;
  12804. //goodsCode = null;
  12805. //goodsName = null;
  12806. //groutingUserCode = string.Empty; //Constant.INT_IS_ZERO;
  12807. // 获得账务日期
  12808. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  12809. string errMsg = string.Empty;
  12810. // 本批采集的批次号
  12811. string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  12812. string finishedloadbatchno = DateTime.Now.ToString("yyMMddHHmmss-") + centralizedBatchNo;
  12813. // 条码信息
  12814. foreach (DataRow barcodeRow in barcodeTable.Rows)
  12815. {
  12816. // 条码
  12817. string barcode = barcodeRow["Barcode"].ToString();
  12818. if (string.IsNullOrEmpty(barcode))
  12819. {
  12820. throw new Exception("传入的条码号为空");
  12821. }
  12822. // 生产工号
  12823. int workUserID = Convert.ToInt32(barcodeRow["UserID"]);
  12824. // 生产工号
  12825. string workUserCode = barcodeRow["UserCode"].ToString();
  12826. //生产数据ID
  12827. string sql = "select SEQ_PM_ProductionData_ID.nextval from dual";
  12828. int productionDataID = Convert.ToInt32(oracleTrConn.GetSqlResultToStr(sql));
  12829. int? GroutingDailyDetailID = arvGroutingDailyDetailID;//注浆明细ID
  12830. if (procedure.CollectType == 1)
  12831. {
  12832. // ccc todo
  12833. //if (procedure.ModelType == (int)Constant.ProcedureModelType.DeliverMud)//是交坯节点,并且不是公坯的
  12834. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  12835. {
  12836. #region 校验条码有效性
  12837. errMsg = CheckBarcodeDeliverMud(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo, ref GroutingDailyDetailID);
  12838. if (!string.IsNullOrEmpty(errMsg))
  12839. {
  12840. return errMsg;
  12841. }
  12842. #endregion
  12843. }
  12844. else
  12845. {
  12846. #region 校验条码有效性
  12847. errMsg = CheckBarcode(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo);
  12848. if (!string.IsNullOrEmpty(errMsg))
  12849. {
  12850. return errMsg;
  12851. }
  12852. #endregion
  12853. }
  12854. }
  12855. else
  12856. {
  12857. // string sqlGroutingInfo = "";
  12858. // sqlGroutingInfo = @"select tp_pm_groutingdailydetail.goodsid,
  12859. // tp_pm_groutingdailydetail.goodscode,
  12860. // tp_pm_groutingdailydetail.goodsname,
  12861. // tp_pm_groutingdailydetail.usercode as groutingUserCode,
  12862. // tp_pm_groutingdailydetail.GroutingDailyDetailID
  12863. // from tp_pm_groutingdailydetail where groutingdailydetailid in
  12864. // (select groutingdailydetailid from TP_PM_USEDBARCODE where barcode=:barcode)
  12865. // ";
  12866. // OracleParameter[] ReFireparas = new OracleParameter[] {
  12867. // new OracleParameter(":barcode",barcode),
  12868. // };
  12869. // DataSet dsGrouting = oracleTrConn.GetSqlResultToDs(sqlGroutingInfo, ReFireparas);
  12870. // if (dsGrouting != null && dsGrouting.Tables[0].Rows.Count > 0)
  12871. // {
  12872. // GroutingDailyDetailID = Convert.ToInt32(dsGrouting.Tables[0].Rows[0]["GroutingDailyDetailID"]);
  12873. // goodsID = Convert.ToInt32(dsGrouting.Tables[0].Rows[0]["goodsid"]);
  12874. // goodsCode = dsGrouting.Tables[0].Rows[0]["goodscode"].ToString();
  12875. // goodsName = dsGrouting.Tables[0].Rows[0]["goodsName"].ToString();
  12876. // groutingUserCode = dsGrouting.Tables[0].Rows[0]["groutingUserCode"].ToString();
  12877. // }
  12878. }
  12879. int? ClassesSettingID = null;//班次配置ID
  12880. #region 添加生产者数据
  12881. if (procedure.ModelType == (int)Constant.ProcedureModelType.DeliverMud)//是交坯节点,并且不是公坯的
  12882. {
  12883. string GroutingUserCode = barcodeRow["GroutingUserCode"].ToString();
  12884. if (GroutingUserCode.ToLower() == workUserCode.ToLower())
  12885. {
  12886. //errMsg = AddProducerDeliverAdobe(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo);
  12887. }
  12888. else
  12889. {
  12890. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID);
  12891. }
  12892. }
  12893. else
  12894. {
  12895. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID);
  12896. }
  12897. if (!string.IsNullOrEmpty(errMsg))
  12898. {
  12899. return errMsg;
  12900. }
  12901. #endregion
  12902. #region 添加生产数据
  12903. ProductionDataEntity productionData = new ProductionDataEntity();
  12904. if (barcodeTable.Columns.Contains("Remarks"))
  12905. {
  12906. productionData.Remarks = barcodeRow["Remarks"] + "";
  12907. }
  12908. #region 属性赋值
  12909. productionData.GroutingDailyDetailID = GroutingDailyDetailID;//只有交坯的时候用到
  12910. productionData.ClassesSettingID = ClassesSettingID;
  12911. productionData.ProductionDataID = productionDataID;
  12912. productionData.Barcode = barcode;
  12913. productionData.CentralizedBatchNo = centralizedBatchNo;
  12914. productionData.ProductionLineID = procedure.ProductionLineID;
  12915. productionData.ProductionLineCode = procedure.ProductionlineCode;
  12916. productionData.ProductionLineName = procedure.ProductionlineName;
  12917. productionData.CompleteProcedureID = procedure.ProcedureID;
  12918. productionData.ProcedureCode = procedure.ProcedureCode;
  12919. productionData.ProcedureName = procedure.ProcedureName;
  12920. productionData.ProcedureModel = procedure.ProcedureModel;
  12921. productionData.ModelType = procedure.ModelType;
  12922. productionData.NodeType = procedure.NodeType;
  12923. productionData.PieceType = procedure.PieceType;
  12924. if (barcodeRow["LogoID"].ToString() != "")
  12925. {
  12926. productionData.LogoID = Convert.ToInt32(barcodeRow["LogoID"]);
  12927. }
  12928. if (procedure.IsSpecialRework == 0)
  12929. {
  12930. productionData.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  12931. //不加条件valueflag,是因为,成检后重烧走过之后,在次重烧,以后也是重烧状态
  12932. //string sqlReFire = "select * from tp_PM_ProductionData where ProductionDataid=(select max(ProductionDataid) from tp_PM_ProductionData where barcode='" + productionData.Barcode + "')";
  12933. //xuwei fix 2019-09-18 交坯节点判定修改
  12934. //if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)//是交坯节点,肯定不会是重烧
  12935. if (isSendBody)//是交坯节点,肯定不会是重烧
  12936. {
  12937. productionData.IsReFire = (int)Constant.ReFireFlag.No;
  12938. productionData.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  12939. }
  12940. ////// else
  12941. ////// {
  12942. ////// string sqlReFire = @"select
  12943. ////// isrefire
  12944. ////// from tp_pm_inproduction where barcode=:barcode
  12945. ////// ";
  12946. ////// OracleParameter[] ReFireparas = new OracleParameter[] {
  12947. ////// new OracleParameter(":barcode",barcode),
  12948. ////// };
  12949. ////// DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas);
  12950. ////// if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0)
  12951. ////// {
  12952. ////// if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0)
  12953. ////// {
  12954. ////// productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]);
  12955. ////// //if (productionData.IsReFire == 6) wangxin modify 20150422 因为已经大于0,定是重烧,即有缺陷
  12956. ////// //{
  12957. ////// productionData.DefectFlag = (int)Constant.GoodsLevelType.Defect;
  12958. ////// //}
  12959. ////// }
  12960. ////// }
  12961. ////// }
  12962. }
  12963. else
  12964. {
  12965. productionData.IsReFire = (int)Constant.GoodsLevelType.ReFire;
  12966. productionData.DefectFlag = (int)Constant.GoodsLevelType.Defect;
  12967. }
  12968. productionData.ReworkProcedureID = null;
  12969. #region 交坯判断
  12970. // 交坯节点
  12971. if (barcodeTable.Columns.Contains("IsPublicBody"))
  12972. {
  12973. productionData.IsPublicBody = Convert.ToInt32(barcodeRow["IsPublicBody"]);
  12974. }
  12975. // 非交坯节点
  12976. else
  12977. {
  12978. // 正常坯
  12979. productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, barcode);
  12980. }
  12981. #endregion
  12982. productionData.OrganizationID = procedure.OrganizationID;
  12983. productionData.GoodsID = goodsID;
  12984. productionData.GoodsCode = goodsCode;
  12985. productionData.GoodsName = goodsName;
  12986. productionData.UserID = workUserID;
  12987. productionData.UserCode = barcodeRow["UserCode"].ToString();
  12988. productionData.UserName = barcodeRow["UserName"].ToString();
  12989. #endregion
  12990. string OutSpecialRepairflag = "0";//干补标识
  12991. DataSet outDataSet = null;
  12992. //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的
  12993. //xuwei fix 2019-09-26 使用通用方法判定
  12994. // 2019-1016
  12995. //int isNodeBegin = IsNodeBegin<IDBTransaction>(oracleTrConn, productionData.Barcode);
  12996. //if (isNodeBegin == 1) procedure.NodeType = (int)Constant.ProcedureNodeType.Begin;
  12997. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  12998. {
  12999. int isNodeBegin = IsNodeBegin<IDBTransaction>(oracleTrConn, productionData.Barcode);
  13000. if (isNodeBegin == 0)
  13001. {
  13002. procedure.NodeType = (int)Constant.ProcedureNodeType.Middle;
  13003. }
  13004. }
  13005. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  13006. {
  13007. //xuwei fix 2019-09-17 加入最后一个参数 isSendBody识别交坯
  13008. errMsg = AddProductionDataDeliverMud(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag, out outDataSet, isSendBody);
  13009. }
  13010. else
  13011. {
  13012. //xuwei fix 2019-09-17 加入最后一个参数 isSendBody识别交坯
  13013. errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag, isSendBody);
  13014. }
  13015. if (!string.IsNullOrEmpty(errMsg))
  13016. {
  13017. return errMsg;
  13018. }
  13019. #endregion
  13020. #region 开始节点
  13021. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  13022. {
  13023. #region 添加在产产品数据
  13024. InProductionEntity addInProductionEntity = new InProductionEntity();
  13025. addInProductionEntity.BarCode = barcode;
  13026. //流程工序ID
  13027. addInProductionEntity.FlowProcedureID = procedure.ProcedureID;
  13028. // 当前工序
  13029. addInProductionEntity.ProcedureID = procedure.ProcedureID;
  13030. //addInProductionEntity.CompleteProcedureID = procedure.ProcedureID;
  13031. // 工序模型
  13032. addInProductionEntity.ProcedureModel = procedure.ProcedureModel;
  13033. // 工序类别
  13034. addInProductionEntity.ModelType = procedure.ModelType;
  13035. addInProductionEntity.SpecialRepairflag = Convert.ToInt32(OutSpecialRepairflag);//干补标识
  13036. addInProductionEntity.ProductionDataID = productionDataID;
  13037. #region 交坯判断
  13038. addInProductionEntity.IsPublicBody = productionData.IsPublicBody;// 生产数据已经判断是否为公坯
  13039. #endregion
  13040. // 生产工号
  13041. addInProductionEntity.UserID = workUserID;
  13042. // 执行添加
  13043. //xuwei fix 2019-09-17 加入最后一个参数 isSendBody识别交坯
  13044. errMsg = AddInProduction(oracleTrConn, addInProductionEntity, sUserInfo, outDataSet, isSendBody);
  13045. // 执行失败
  13046. if (!string.IsNullOrEmpty(errMsg))
  13047. {
  13048. return errMsg;
  13049. }
  13050. #endregion
  13051. }
  13052. #endregion
  13053. #region 中间节点
  13054. else if (procedure.NodeType == (int)Constant.ProcedureNodeType.Middle)
  13055. {
  13056. #region 修改在产产品数据的当前工序,清空返工工序字段
  13057. InProductionEntity addInProductionEntity = new InProductionEntity();
  13058. addInProductionEntity.BarCode = barcode;
  13059. //流程工序ID
  13060. addInProductionEntity.FlowProcedureID = procedure.ProcedureID;
  13061. // 当前工序
  13062. addInProductionEntity.ProcedureID = procedure.ProcedureID;
  13063. //当前生产数据ID
  13064. addInProductionEntity.ProductionDataID = productionDataID;
  13065. // 工序模型
  13066. addInProductionEntity.ProcedureModel = procedure.ProcedureModel;
  13067. // 工序类别
  13068. addInProductionEntity.ModelType = procedure.ModelType;
  13069. // 生产工号
  13070. addInProductionEntity.UserID = workUserID;
  13071. // 缺陷标识
  13072. // addInProductionEntity.DefectFlag = (int)Constant.DefectFlag.No;
  13073. //addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefect;
  13074. if (procedure.IsSpecialRework == 0)
  13075. {
  13076. addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  13077. }
  13078. else
  13079. {
  13080. addInProductionEntity.IsReFire = (int)Constant.GoodsLevelType.ReFire;
  13081. addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  13082. }
  13083. addInProductionEntity.LogoID = productionData.LogoID == 0 ? null : productionData.LogoID;
  13084. #region 交坯判断
  13085. addInProductionEntity.IsPublicBody = productionData.IsPublicBody;// 生产数据已经判断是否为公坯
  13086. #endregion
  13087. // 执行修改
  13088. errMsg = UpdateInProduction(oracleTrConn, addInProductionEntity, sUserInfo);
  13089. // 执行失败
  13090. if (!string.IsNullOrEmpty(errMsg))
  13091. {
  13092. return errMsg;
  13093. }
  13094. #endregion
  13095. }
  13096. #endregion
  13097. #region 结束节点
  13098. else
  13099. {
  13100. #region 添加成品数据 删除在产产品数据
  13101. FinishedProductEntity finishedProduct = new FinishedProductEntity();
  13102. finishedProduct.BarCode = barcode;
  13103. finishedProduct.LogoID = productionData.LogoID;
  13104. errMsg = AddFinishedProduct(oracleTrConn, finishedProduct, sUserInfo, finishedloadbatchno);
  13105. if (!string.IsNullOrEmpty(errMsg))
  13106. {
  13107. return errMsg;
  13108. }
  13109. InProductionEntity delInProductionEntity = new InProductionEntity();
  13110. delInProductionEntity.BarCode = barcode;
  13111. // 执行删除 在产数据
  13112. errMsg = DeleteInProduction(oracleTrConn, delInProductionEntity, true, sUserInfo);
  13113. // 执行失败
  13114. if (!string.IsNullOrEmpty(errMsg))
  13115. {
  13116. return errMsg;
  13117. }
  13118. #endregion
  13119. }
  13120. #endregion
  13121. }
  13122. return errMsg;
  13123. }
  13124. catch (Exception ex)
  13125. {
  13126. throw ex;
  13127. }
  13128. }
  13129. /// <summary>
  13130. /// 清除在产残留数据(清除选择)
  13131. /// </summary>
  13132. /// <param name="barcodes">产品条码集</param>
  13133. /// <returns></returns>
  13134. public static int SaveClearInproduction(string barcodes, SUserInfo sUserInfo)
  13135. {
  13136. int returnRows = 0;
  13137. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13138. try
  13139. {
  13140. string sql = "";
  13141. string[] subbarcode = barcodes.Split(',');
  13142. OracleParameter[] Paras = null;
  13143. for (int i = 0; i < subbarcode.Length; i++)
  13144. {
  13145. // 0.登窑、入窑、出窑工序的产品不能清除
  13146. sql = "select p.modeltype from tp_pm_inproduction p where p.barcode = :barcode";
  13147. Paras = new OracleParameter[] {
  13148. new OracleParameter(":barcode",OracleDbType.NVarchar2,
  13149. subbarcode[i],ParameterDirection.Input)
  13150. };
  13151. string modeltype = oracleTrConn.GetSqlResultToStr(sql, Paras);
  13152. if (!string.IsNullOrWhiteSpace(modeltype))
  13153. {
  13154. Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType pmt =
  13155. (Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType)Convert.ToInt32(modeltype);
  13156. if (pmt == Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType.LoadCar ||
  13157. pmt == Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType.IntoKiln ||
  13158. pmt == Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType.OutKiln)
  13159. {
  13160. continue;
  13161. }
  13162. }
  13163. // 返工标识或者是报损标识不允许清除 2016-07-12
  13164. sql = "select IsReworkFlag,InScrapFlag from tp_pm_inproduction p where p.barcode = :barcode";
  13165. Paras = new OracleParameter[] {
  13166. new OracleParameter(":barcode",OracleDbType.NVarchar2,
  13167. subbarcode[i],ParameterDirection.Input)
  13168. };
  13169. DataSet ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  13170. if (ds != null && ds.Tables[0].Rows.Count > 0)
  13171. {
  13172. // chenxy 2019-10-02 半检返修 IsReworkFlag=2
  13173. //if (ds.Tables[0].Rows[0]["IsReworkFlag"].ToString() == "1")
  13174. if (ds.Tables[0].Rows[0]["IsReworkFlag"].ToString() != "0")
  13175. {
  13176. returnRows = -1;
  13177. break;
  13178. }
  13179. if (ds.Tables[0].Rows[0]["InScrapFlag"].ToString() == "1")
  13180. {
  13181. returnRows = -2;
  13182. break;
  13183. }
  13184. }
  13185. // 返工标识或者是报损标识不允许清除 end
  13186. //把在产数据插入到在产临时表中。(数据来源标识0:在产表)
  13187. sql = @"insert into tp_pm_inproduction_tmp
  13188. (
  13189. BARCODE,
  13190. PRODUCTIONLINEID,
  13191. PRODUCTIONLINECODE,
  13192. PRODUCTIONLINENAME,
  13193. PROCEDUREMODEL,
  13194. MODELTYPE,
  13195. REWORKPROCEDUREID,
  13196. ISPUBLICBODY,
  13197. GOODSID,
  13198. GOODSCODE,
  13199. GOODSNAME,
  13200. USERID,
  13201. GROUTINGDAILYID,
  13202. GROUTINGDAILYDETAILID,
  13203. GROUTINGDATE,
  13204. GROUTINGLINEID,
  13205. GROUTINGLINECODE,
  13206. GROUTINGLINENAME,
  13207. GMOULDTYPEID,
  13208. CANMANYTIMES,
  13209. GROUTINGLINEDETAILID,
  13210. GROUTINGMOULDCODE,
  13211. MOULDCODE,
  13212. REMARKS,
  13213. ACCOUNTID,
  13214. VALUEFLAG,
  13215. CREATETIME,
  13216. CREATEUSERID,
  13217. UPDATETIME,
  13218. UPDATEUSERID,
  13219. OPTIMESTAMP,
  13220. ISREFIRE,
  13221. GOODSLEVELID,
  13222. GOODSLEVELTYPEID,
  13223. DEFECTFLAG,
  13224. GROUTINGUSERID,
  13225. GROUTINGUSERCODE,
  13226. GROUTINGNUM,
  13227. KILNID,
  13228. KILNCODE,
  13229. KILNNAME,
  13230. KILNCARID,
  13231. KILNCARCODE,
  13232. KILNCARNAME,
  13233. KILNCARBATCHNO,
  13234. KILNCARPOSITION,
  13235. SPECIALREPAIRFLAG,
  13236. FLOWPROCEDUREID,
  13237. FLOWPROCEDURETIME,
  13238. PROCEDUREID,
  13239. PROCEDURETIME,
  13240. PRODUCTIONDATAID,
  13241. trashflag,
  13242. Deletedtime,
  13243. logoid,
  13244. IsReworkFlag,
  13245. SemiCheckID,
  13246. DELETEDUSERID,
  13247. DELETEDUSERCODE
  13248. )
  13249. select
  13250. BARCODE,
  13251. PRODUCTIONLINEID,
  13252. PRODUCTIONLINECODE,
  13253. PRODUCTIONLINENAME,
  13254. PROCEDUREMODEL,
  13255. MODELTYPE,
  13256. REWORKPROCEDUREID,
  13257. ISPUBLICBODY,
  13258. GOODSID,
  13259. GOODSCODE,
  13260. GOODSNAME,
  13261. USERID,
  13262. GROUTINGDAILYID,
  13263. GROUTINGDAILYDETAILID,
  13264. GROUTINGDATE,
  13265. GROUTINGLINEID,
  13266. GROUTINGLINECODE,
  13267. GROUTINGLINENAME,
  13268. GMOULDTYPEID,
  13269. CANMANYTIMES,
  13270. GROUTINGLINEDETAILID,
  13271. GROUTINGMOULDCODE,
  13272. MOULDCODE,
  13273. REMARKS,
  13274. ACCOUNTID,
  13275. VALUEFLAG,
  13276. CREATETIME,
  13277. CREATEUSERID,
  13278. UPDATETIME,
  13279. UPDATEUSERID,
  13280. OPTIMESTAMP,
  13281. ISREFIRE,
  13282. GOODSLEVELID,
  13283. GOODSLEVELTYPEID,
  13284. DEFECTFLAG,
  13285. GROUTINGUSERID,
  13286. GROUTINGUSERCODE,
  13287. GROUTINGNUM,
  13288. KILNID,
  13289. KILNCODE,
  13290. KILNNAME,
  13291. KILNCARID,
  13292. KILNCARCODE,
  13293. KILNCARNAME,
  13294. KILNCARBATCHNO,
  13295. KILNCARPOSITION,
  13296. SPECIALREPAIRFLAG,
  13297. FLOWPROCEDUREID,
  13298. FLOWPROCEDURETIME,
  13299. PROCEDUREID,
  13300. PROCEDURETIME,
  13301. PRODUCTIONDATAID,
  13302. INSCRAPFLAG,
  13303. sysdate,
  13304. logoid,
  13305. IsReworkFlag,
  13306. SemiCheckID,
  13307. " + sUserInfo.UserID + ",'" + sUserInfo.UserCode +
  13308. "' from tp_pm_inproduction p where p.barcode = :barcode";
  13309. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  13310. //删除在产数据
  13311. sql = "delete from tp_pm_inproduction p where p.barcode =:barcode";
  13312. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  13313. //删除在产生产数据
  13314. sql = "delete from tp_pm_productiondatain p where p.barcode =:barcode";
  13315. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  13316. }
  13317. if (returnRows <= 0)
  13318. {
  13319. oracleTrConn.Rollback();
  13320. oracleTrConn.Disconnect();
  13321. }
  13322. else
  13323. {
  13324. oracleTrConn.Commit();
  13325. oracleTrConn.Disconnect();
  13326. }
  13327. }
  13328. catch (Exception ex)
  13329. {
  13330. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  13331. {
  13332. oracleTrConn.Rollback();
  13333. oracleTrConn.Disconnect();
  13334. }
  13335. throw ex;
  13336. }
  13337. finally
  13338. {
  13339. if (oracleTrConn.ConnState == ConnectionState.Open)
  13340. {
  13341. oracleTrConn.Disconnect();
  13342. }
  13343. }
  13344. return returnRows;
  13345. }
  13346. #region 清除在产残留数据(批量)
  13347. /// <summary>
  13348. /// 清除在产残留数据(批量清除)
  13349. /// </summary>
  13350. /// <param name="barcodes">产品条码集</param>
  13351. /// <returns></returns>
  13352. public static int SaveClearAllInproduction(SUserInfo user, RPT010401_SE se)
  13353. {
  13354. int returnRows = 0;
  13355. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13356. try
  13357. {
  13358. List<OracleParameter> parameters = new List<OracleParameter>();
  13359. StringBuilder sql = new StringBuilder(GetClearInproductionData(user.AccountID));
  13360. if (se != null)
  13361. {
  13362. //生产线IDS
  13363. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  13364. {
  13365. sql.Append(" AND instr(','||:ProductionLineIDS||',',','||TP_PM_InProduction.ProductionLineID||',')>0 ");
  13366. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  13367. }
  13368. //完成工序IDS
  13369. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  13370. {
  13371. sql.Append(" AND instr(','||:ProcedureIDS||',',','||TP_PM_InProduction.ProcedureID||',')>0 ");
  13372. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  13373. }
  13374. // 生产时间--开始
  13375. if (se.UpdateTimeStart.HasValue)
  13376. {
  13377. sql.Append(" AND TP_PM_InProduction.Proceduretime >= :UpdateTimeStart ");
  13378. parameters.Add(new OracleParameter(":UpdateTimeStart", OracleDbType.Date, se.UpdateTimeStart.Value, ParameterDirection.Input));
  13379. }
  13380. // 生产时间--结束
  13381. if (se.UpdateTimeEnd.HasValue)
  13382. {
  13383. sql.Append(" AND TP_PM_InProduction.Proceduretime <= :UpdateTimeEnd ");
  13384. parameters.Add(new OracleParameter(":UpdateTimeEnd", OracleDbType.Date, se.UpdateTimeEnd.Value, ParameterDirection.Input));
  13385. }
  13386. // 是否清除报损待审产品
  13387. if (se.inscrapflag == 0)
  13388. {
  13389. sql.Append(" AND TP_PM_InProduction.inscrapflag=0 ");
  13390. }
  13391. else
  13392. {
  13393. sql.Append(" AND TP_PM_InProduction.inscrapflag in (0,1) ");
  13394. }
  13395. // 是否清除返工产品
  13396. if (se.IsReworkFlag == 0)
  13397. {
  13398. sql.Append(" AND TP_PM_InProduction.IsReworkFlag=0 ");
  13399. }
  13400. else
  13401. {
  13402. // chenxy 2019-10-02 半检返修 IsReworkFlag=2
  13403. //sql.Append(" AND TP_PM_InProduction.IsReworkFlag in (0,1) ");
  13404. }
  13405. }
  13406. //把在产数据插入到在产临时表中。(数据来源标识0:在产表)
  13407. string updatsql1 = @"insert into tp_pm_inproduction_tmp
  13408. (
  13409. BARCODE,
  13410. PRODUCTIONLINEID,
  13411. PRODUCTIONLINECODE,
  13412. PRODUCTIONLINENAME,
  13413. PROCEDUREMODEL,
  13414. MODELTYPE,
  13415. REWORKPROCEDUREID,
  13416. ISPUBLICBODY,
  13417. GOODSID,
  13418. GOODSCODE,
  13419. GOODSNAME,
  13420. USERID,
  13421. GROUTINGDAILYID,
  13422. GROUTINGDAILYDETAILID,
  13423. GROUTINGDATE,
  13424. GROUTINGLINEID,
  13425. GROUTINGLINECODE,
  13426. GROUTINGLINENAME,
  13427. GMOULDTYPEID,
  13428. CANMANYTIMES,
  13429. GROUTINGLINEDETAILID,
  13430. GROUTINGMOULDCODE,
  13431. MOULDCODE,
  13432. REMARKS,
  13433. ACCOUNTID,
  13434. VALUEFLAG,
  13435. CREATETIME,
  13436. CREATEUSERID,
  13437. UPDATETIME,
  13438. UPDATEUSERID,
  13439. OPTIMESTAMP,
  13440. ISREFIRE,
  13441. GOODSLEVELID,
  13442. GOODSLEVELTYPEID,
  13443. DEFECTFLAG,
  13444. GROUTINGUSERID,
  13445. GROUTINGUSERCODE,
  13446. GROUTINGNUM,
  13447. KILNID,
  13448. KILNCODE,
  13449. KILNNAME,
  13450. KILNCARID,
  13451. KILNCARCODE,
  13452. KILNCARNAME,
  13453. KILNCARBATCHNO,
  13454. KILNCARPOSITION,
  13455. SPECIALREPAIRFLAG,
  13456. FLOWPROCEDUREID,
  13457. FLOWPROCEDURETIME,
  13458. PROCEDUREID,
  13459. PROCEDURETIME,
  13460. PRODUCTIONDATAID,
  13461. trashflag,
  13462. Deletedtime,
  13463. logoid,
  13464. IsReworkFlag,
  13465. SemiCheckID,
  13466. DELETEDUSERID,
  13467. DELETEDUSERCODE
  13468. )
  13469. select
  13470. BARCODE,
  13471. PRODUCTIONLINEID,
  13472. PRODUCTIONLINECODE,
  13473. PRODUCTIONLINENAME,
  13474. PROCEDUREMODEL,
  13475. MODELTYPE,
  13476. REWORKPROCEDUREID,
  13477. ISPUBLICBODY,
  13478. GOODSID,
  13479. GOODSCODE,
  13480. GOODSNAME,
  13481. USERID,
  13482. GROUTINGDAILYID,
  13483. GROUTINGDAILYDETAILID,
  13484. GROUTINGDATE,
  13485. GROUTINGLINEID,
  13486. GROUTINGLINECODE,
  13487. GROUTINGLINENAME,
  13488. GMOULDTYPEID,
  13489. CANMANYTIMES,
  13490. GROUTINGLINEDETAILID,
  13491. GROUTINGMOULDCODE,
  13492. MOULDCODE,
  13493. REMARKS,
  13494. ACCOUNTID,
  13495. VALUEFLAG,
  13496. CREATETIME,
  13497. CREATEUSERID,
  13498. UPDATETIME,
  13499. UPDATEUSERID,
  13500. OPTIMESTAMP,
  13501. ISREFIRE,
  13502. GOODSLEVELID,
  13503. GOODSLEVELTYPEID,
  13504. DEFECTFLAG,
  13505. GROUTINGUSERID,
  13506. GROUTINGUSERCODE,
  13507. GROUTINGNUM,
  13508. KILNID,
  13509. KILNCODE,
  13510. KILNNAME,
  13511. KILNCARID,
  13512. KILNCARCODE,
  13513. KILNCARNAME,
  13514. KILNCARBATCHNO,
  13515. KILNCARPOSITION,
  13516. SPECIALREPAIRFLAG,
  13517. FLOWPROCEDUREID,
  13518. FLOWPROCEDURETIME,
  13519. PROCEDUREID,
  13520. PROCEDURETIME,
  13521. PRODUCTIONDATAID,
  13522. INSCRAPFLAG,
  13523. sysdate,
  13524. logoid,
  13525. IsReworkFlag,
  13526. SemiCheckID,"
  13527. + user.UserID + ",'" + user.UserCode +
  13528. "' from tp_pm_inproduction p where p.barcode in (" + sql.ToString() + ")";
  13529. returnRows += oracleTrConn.ExecuteNonQuery(updatsql1, parameters.ToArray());
  13530. //删除在产数据
  13531. updatsql1 = "delete from tp_pm_inproduction p where p.barcode in (" + sql.ToString() + ")";
  13532. returnRows += oracleTrConn.ExecuteNonQuery(updatsql1, parameters.ToArray());
  13533. //删除在产生产数据
  13534. updatsql1 = "delete from tp_pm_productiondatain p where p.barcode in (" + sql.ToString() + ")";
  13535. returnRows += oracleTrConn.ExecuteNonQuery(updatsql1, parameters.ToArray());
  13536. if (returnRows == 0)
  13537. {
  13538. oracleTrConn.Rollback();
  13539. oracleTrConn.Disconnect();
  13540. }
  13541. else
  13542. {
  13543. oracleTrConn.Commit();
  13544. oracleTrConn.Disconnect();
  13545. }
  13546. }
  13547. catch (Exception ex)
  13548. {
  13549. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  13550. {
  13551. oracleTrConn.Rollback();
  13552. oracleTrConn.Disconnect();
  13553. }
  13554. throw ex;
  13555. }
  13556. return returnRows;
  13557. }
  13558. /// <summary>
  13559. /// 获取批量数据
  13560. /// </summary>
  13561. /// <returns></returns>
  13562. private static string GetClearInproductionData(int accountid)
  13563. {
  13564. string selSql =
  13565. "SELECT " +
  13566. " TP_PM_InProduction.BarCode " +
  13567. " FROM TP_PM_InProduction " +
  13568. " Where TP_PM_InProduction.ValueFlag = '1' " +
  13569. " and TP_PM_InProduction.modeltype not in (1,2,3)" +
  13570. " and TP_PM_InProduction.AccountID= " + accountid;
  13571. return selSql;
  13572. }
  13573. #endregion
  13574. #region
  13575. /// <summary>
  13576. /// 清除在产加收站残留数据(清除选择)
  13577. /// </summary>
  13578. /// <param name="barcodes">产品条码集</param>
  13579. /// <returns></returns>
  13580. public static int SaveClearInproductionTrash(string barcodes, SUserInfo user)
  13581. {
  13582. int returnRows = 0;
  13583. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13584. try
  13585. {
  13586. string sql = "";
  13587. string[] subbarcode = barcodes.Split(',');
  13588. OracleParameter[] Paras = null;
  13589. for (int i = 0; i < subbarcode.Length; i++)
  13590. {
  13591. Paras = new OracleParameter[] {
  13592. new OracleParameter(":barcode",OracleDbType.NVarchar2,
  13593. subbarcode[i],ParameterDirection.Input)
  13594. };
  13595. //把在产数据插入到在产临时表中。(数据来源标识0:在产表)
  13596. sql = @"insert into tp_pm_inproduction_tmp
  13597. (
  13598. BARCODE,
  13599. PRODUCTIONLINEID,
  13600. PRODUCTIONLINECODE,
  13601. PRODUCTIONLINENAME,
  13602. PROCEDUREMODEL,
  13603. MODELTYPE,
  13604. REWORKPROCEDUREID,
  13605. ISPUBLICBODY,
  13606. GOODSID,
  13607. GOODSCODE,
  13608. GOODSNAME,
  13609. USERID,
  13610. GROUTINGDAILYID,
  13611. GROUTINGDAILYDETAILID,
  13612. GROUTINGDATE,
  13613. GROUTINGLINEID,
  13614. GROUTINGLINECODE,
  13615. GROUTINGLINENAME,
  13616. GMOULDTYPEID,
  13617. CANMANYTIMES,
  13618. GROUTINGLINEDETAILID,
  13619. GROUTINGMOULDCODE,
  13620. MOULDCODE,
  13621. REMARKS,
  13622. ACCOUNTID,
  13623. VALUEFLAG,
  13624. CREATETIME,
  13625. CREATEUSERID,
  13626. UPDATETIME,
  13627. UPDATEUSERID,
  13628. OPTIMESTAMP,
  13629. ISREFIRE,
  13630. GOODSLEVELID,
  13631. GOODSLEVELTYPEID,
  13632. DEFECTFLAG,
  13633. GROUTINGUSERID,
  13634. GROUTINGUSERCODE,
  13635. GROUTINGNUM,
  13636. KILNID,
  13637. KILNCODE,
  13638. KILNNAME,
  13639. KILNCARID,
  13640. KILNCARCODE,
  13641. KILNCARNAME,
  13642. KILNCARBATCHNO,
  13643. KILNCARPOSITION,
  13644. SPECIALREPAIRFLAG,
  13645. FLOWPROCEDUREID,
  13646. FLOWPROCEDURETIME,
  13647. PROCEDUREID,
  13648. PROCEDURETIME,
  13649. PRODUCTIONDATAID,
  13650. trashflag,
  13651. Deletedtime,
  13652. logoid,
  13653. IsReworkFlag,
  13654. SemiCheckID,
  13655. DELETEDUSERID,
  13656. DELETEDUSERCODE
  13657. )
  13658. select
  13659. BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME,
  13660. PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID,
  13661. ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME,
  13662. USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE,
  13663. GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID,
  13664. CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE,
  13665. REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME,
  13666. CREATEUSERID, UPDATETIME, UPDATEUSERID,optimestamp,
  13667. ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG,
  13668. GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM,
  13669. KILNID, KILNCODE, KILNNAME, KILNCARID,
  13670. KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID
  13671. ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,1,sysdate,logoid,IsReworkFlag,SemiCheckID,"
  13672. + user.UserID + ",'" + user.UserCode +
  13673. "' from TP_PM_InProductionTrash p where p.barcode = :barcode";
  13674. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  13675. //删除在产回收站数据
  13676. sql = "delete from TP_PM_InProductionTrash p where p.barcode =:barcode";
  13677. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  13678. //删除在产生产数据
  13679. sql = "delete from tp_pm_productiondatain p where p.barcode =:barcode";
  13680. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  13681. }
  13682. if (returnRows == 0)
  13683. {
  13684. oracleTrConn.Rollback();
  13685. oracleTrConn.Disconnect();
  13686. }
  13687. else
  13688. {
  13689. oracleTrConn.Commit();
  13690. oracleTrConn.Disconnect();
  13691. }
  13692. }
  13693. catch (Exception ex)
  13694. {
  13695. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  13696. {
  13697. oracleTrConn.Rollback();
  13698. oracleTrConn.Disconnect();
  13699. }
  13700. throw ex;
  13701. }
  13702. finally
  13703. {
  13704. if (oracleTrConn.ConnState == ConnectionState.Open)
  13705. {
  13706. oracleTrConn.Disconnect();
  13707. }
  13708. }
  13709. return returnRows;
  13710. }
  13711. #endregion
  13712. #region 清除在产回收站残留数据(批量)
  13713. /// <summary>
  13714. /// 清除在产残留数据(批量清除)
  13715. /// </summary>
  13716. /// <param name="barcodes">产品条码集</param>
  13717. /// <returns></returns>
  13718. public static int SaveClearAllInproductionTrash(SUserInfo user, FPM2110_SE se)
  13719. {
  13720. int returnRows = 0;
  13721. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13722. try
  13723. {
  13724. List<OracleParameter> parameters = new List<OracleParameter>();
  13725. StringBuilder sql = new StringBuilder(GetClearInproductionTrashData(user.AccountID));
  13726. if (se != null)
  13727. {
  13728. //生产线IDS
  13729. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  13730. {
  13731. sql.Append(" AND instr(','||:ProductionLineIDS||',',','||TP_PM_InProductionTrash.ProductionLineID||',')>0 ");
  13732. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  13733. }
  13734. //完成工序IDS
  13735. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  13736. {
  13737. sql.Append(" AND instr(','||:ProcedureIDS||',',','||TP_PM_InProductionTrash.ProcedureID||',')>0 ");
  13738. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  13739. }
  13740. // 生产时间--开始
  13741. if (se.UpdateTimeStart.HasValue)
  13742. {
  13743. sql.Append(" AND TP_PM_InProductionTrash.Proceduretime >= :UpdateTimeStart ");
  13744. parameters.Add(new OracleParameter(":UpdateTimeStart", OracleDbType.Date, se.UpdateTimeStart.Value, ParameterDirection.Input));
  13745. }
  13746. // 生产时间--结束
  13747. if (se.UpdateTimeEnd.HasValue)
  13748. {
  13749. sql.Append(" AND TP_PM_InProductionTrash.Proceduretime <= :UpdateTimeEnd ");
  13750. parameters.Add(new OracleParameter(":UpdateTimeEnd", OracleDbType.Date, se.UpdateTimeEnd.Value, ParameterDirection.Input));
  13751. }
  13752. //报废日期开始
  13753. if (se.ScrapDataStart.HasValue)
  13754. {
  13755. sql.Append(" AND TP_PM_SCRAPPRODUCT.SCRAPDATE >= trunc(:ScrapDateStart) ");
  13756. parameters.Add(new OracleParameter(":ScrapDateStart", OracleDbType.Date, se.ScrapDataStart.Value, ParameterDirection.Input));
  13757. }
  13758. //报废日期结束
  13759. if (se.ScrapDataEnd.HasValue)
  13760. {
  13761. sql.Append(" AND TP_PM_SCRAPPRODUCT.SCRAPDATE <= trunc(:ScrapDateEnd)");
  13762. parameters.Add(new OracleParameter(":ScrapDateEnd", OracleDbType.Date, se.ScrapDataEnd.Value, ParameterDirection.Input));
  13763. }
  13764. // 产品分级
  13765. sql.Append(" AND TP_PM_SCRAPPRODUCT.GOODSLEVELTYPEID = :GooddLevelTypeID ");
  13766. parameters.Add(new OracleParameter(":GooddLevelTypeID", OracleDbType.Int32, se.GooddLevelTypeID, ParameterDirection.Input));
  13767. }
  13768. //把在产数据插入到在产临时表中。(数据来源标识0:在产表)
  13769. string updatsql1 = @"insert into tp_pm_inproduction_tmp
  13770. (
  13771. BARCODE,
  13772. PRODUCTIONLINEID,
  13773. PRODUCTIONLINECODE,
  13774. PRODUCTIONLINENAME,
  13775. PROCEDUREMODEL,
  13776. MODELTYPE,
  13777. REWORKPROCEDUREID,
  13778. ISPUBLICBODY,
  13779. GOODSID,
  13780. GOODSCODE,
  13781. GOODSNAME,
  13782. USERID,
  13783. GROUTINGDAILYID,
  13784. GROUTINGDAILYDETAILID,
  13785. GROUTINGDATE,
  13786. GROUTINGLINEID,
  13787. GROUTINGLINECODE,
  13788. GROUTINGLINENAME,
  13789. GMOULDTYPEID,
  13790. CANMANYTIMES,
  13791. GROUTINGLINEDETAILID,
  13792. GROUTINGMOULDCODE,
  13793. MOULDCODE,
  13794. REMARKS,
  13795. ACCOUNTID,
  13796. VALUEFLAG,
  13797. CREATETIME,
  13798. CREATEUSERID,
  13799. UPDATETIME,
  13800. UPDATEUSERID,
  13801. OPTIMESTAMP,
  13802. ISREFIRE,
  13803. GOODSLEVELID,
  13804. GOODSLEVELTYPEID,
  13805. DEFECTFLAG,
  13806. GROUTINGUSERID,
  13807. GROUTINGUSERCODE,
  13808. GROUTINGNUM,
  13809. KILNID,
  13810. KILNCODE,
  13811. KILNNAME,
  13812. KILNCARID,
  13813. KILNCARCODE,
  13814. KILNCARNAME,
  13815. KILNCARBATCHNO,
  13816. KILNCARPOSITION,
  13817. SPECIALREPAIRFLAG,
  13818. FLOWPROCEDUREID,
  13819. FLOWPROCEDURETIME,
  13820. PROCEDUREID,
  13821. PROCEDURETIME,
  13822. PRODUCTIONDATAID,
  13823. trashflag,
  13824. Deletedtime,
  13825. logoid,
  13826. IsReworkFlag,
  13827. SemiCheckID,
  13828. DELETEDUSERID,
  13829. DELETEDUSERCODE
  13830. )
  13831. select
  13832. BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME,
  13833. PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID,
  13834. ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME,
  13835. USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE,
  13836. GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID,
  13837. CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE,
  13838. REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME,
  13839. CREATEUSERID, UPDATETIME, UPDATEUSERID,optimestamp,
  13840. ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG,
  13841. GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM,
  13842. KILNID, KILNCODE, KILNNAME, KILNCARID,
  13843. KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID
  13844. ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,1,sysdate,logoid,IsReworkFlag,SemiCheckID,"
  13845. + user.UserID + ",'" + user.UserCode +
  13846. "' from TP_PM_InProductionTrash p where p.barcode in (" + sql.ToString() + ")";
  13847. returnRows += oracleTrConn.ExecuteNonQuery(updatsql1, parameters.ToArray());
  13848. //删除在产数据
  13849. updatsql1 = "delete from TP_PM_InProductionTrash p where p.barcode in (" + sql.ToString() + ")";
  13850. returnRows += oracleTrConn.ExecuteNonQuery(updatsql1, parameters.ToArray());
  13851. //删除在产生产数据
  13852. updatsql1 = "delete from tp_pm_productiondatain p where p.barcode in (" + sql.ToString() + ")";
  13853. returnRows += oracleTrConn.ExecuteNonQuery(updatsql1, parameters.ToArray());
  13854. if (returnRows == 0)
  13855. {
  13856. oracleTrConn.Rollback();
  13857. oracleTrConn.Disconnect();
  13858. }
  13859. else
  13860. {
  13861. oracleTrConn.Commit();
  13862. oracleTrConn.Disconnect();
  13863. }
  13864. }
  13865. catch (Exception ex)
  13866. {
  13867. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  13868. {
  13869. oracleTrConn.Rollback();
  13870. oracleTrConn.Disconnect();
  13871. }
  13872. throw ex;
  13873. }
  13874. finally
  13875. {
  13876. if (oracleTrConn.ConnState == ConnectionState.Open)
  13877. {
  13878. oracleTrConn.Disconnect();
  13879. }
  13880. }
  13881. return returnRows;
  13882. }
  13883. /// <summary>
  13884. /// 获取批量数据
  13885. /// </summary>
  13886. /// <returns></returns>
  13887. private static string GetClearInproductionTrashData(int accountid)
  13888. {
  13889. string selSql =
  13890. "SELECT " +
  13891. " TP_PM_InProductionTrash.BarCode " +
  13892. " FROM TP_PM_InProductionTrash " +
  13893. " left join tp_pm_scrapproduct " +
  13894. " on tp_pm_scrapproduct.barcode=TP_PM_InProductionTrash.barcode " +
  13895. " Where 1=1 and TP_PM_InProductionTrash.ValueFlag = 1 " +
  13896. " and TP_PM_InProductionTrash.AccountID= " + accountid;
  13897. return selSql;
  13898. }
  13899. #endregion
  13900. /// <summary>
  13901. /// 清除在产临时表残留数据(清除选择)
  13902. /// </summary>
  13903. /// <param name="barcodes">产品条码集</param>
  13904. /// <returns></returns>
  13905. public static int SaveClearInproductionTmp(string barcodes)
  13906. {
  13907. int returnRows = 0;
  13908. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13909. try
  13910. {
  13911. string sql = "";
  13912. string[] subbarcode = barcodes.Split(',');
  13913. OracleParameter[] Paras = null;
  13914. for (int i = 0; i < subbarcode.Length; i++)
  13915. {
  13916. Paras = new OracleParameter[] {
  13917. new OracleParameter(":barcode",OracleDbType.NVarchar2,
  13918. subbarcode[i],ParameterDirection.Input)
  13919. };
  13920. //删除在产临时表数据
  13921. sql = "delete from TP_PM_InProduction_Tmp p where p.barcode =:barcode";
  13922. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  13923. }
  13924. if (returnRows == 0)
  13925. {
  13926. oracleTrConn.Rollback();
  13927. oracleTrConn.Disconnect();
  13928. }
  13929. else
  13930. {
  13931. oracleTrConn.Commit();
  13932. oracleTrConn.Disconnect();
  13933. }
  13934. }
  13935. catch (Exception ex)
  13936. {
  13937. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  13938. {
  13939. oracleTrConn.Rollback();
  13940. oracleTrConn.Disconnect();
  13941. }
  13942. throw ex;
  13943. }
  13944. finally
  13945. {
  13946. if (oracleTrConn.ConnState == ConnectionState.Open)
  13947. {
  13948. oracleTrConn.Disconnect();
  13949. }
  13950. }
  13951. return returnRows;
  13952. }
  13953. #region 清除在产回收站残留数据(批量)
  13954. /// <summary>
  13955. /// 清除在产残留数据(批量清除)
  13956. /// </summary>
  13957. /// <param name="barcodes">产品条码集</param>
  13958. /// <returns></returns>
  13959. public static int SaveClearAllInproductionTmp(SUserInfo user, FPM2112_SE se)
  13960. {
  13961. int returnRows = 0;
  13962. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13963. try
  13964. {
  13965. List<OracleParameter> parameters = new List<OracleParameter>();
  13966. StringBuilder sql = new StringBuilder(GetClearInproductionTmpData(user.AccountID));
  13967. if (se != null)
  13968. {
  13969. //生产线IDS
  13970. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  13971. {
  13972. sql.Append(" AND instr(','||:ProductionLineIDS||',',','||TP_PM_InProduction_Tmp.ProductionLineID||',')>0 ");
  13973. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  13974. }
  13975. //完成工序IDS
  13976. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  13977. {
  13978. sql.Append(" AND instr(','||:ProcedureIDS||',',','||TP_PM_InProduction_Tmp.ProcedureID||',')>0 ");
  13979. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  13980. }
  13981. // 生产时间--开始
  13982. if (se.UpdateTimeStart.HasValue)
  13983. {
  13984. sql.Append(" AND TP_PM_InProduction_Tmp.Proceduretime >= :UpdateTimeStart ");
  13985. parameters.Add(new OracleParameter(":UpdateTimeStart", OracleDbType.Date, se.UpdateTimeStart.Value, ParameterDirection.Input));
  13986. }
  13987. // 生产时间--结束
  13988. if (se.UpdateTimeEnd.HasValue)
  13989. {
  13990. sql.Append(" AND TP_PM_InProduction_Tmp.Proceduretime <= :UpdateTimeEnd ");
  13991. parameters.Add(new OracleParameter(":UpdateTimeEnd", OracleDbType.Date, se.UpdateTimeEnd.Value, ParameterDirection.Input));
  13992. }
  13993. //报废日期开始
  13994. if (se.ScrapDataStart.HasValue)
  13995. {
  13996. sql.Append(" AND TP_PM_SCRAPPRODUCT.SCRAPDATE >= trunc(:ScrapDateStart) ");
  13997. parameters.Add(new OracleParameter(":ScrapDateStart", OracleDbType.Date, se.ScrapDataStart.Value, ParameterDirection.Input));
  13998. }
  13999. //报废日期结束
  14000. if (se.ScrapDataEnd.HasValue)
  14001. {
  14002. sql.Append(" AND TP_PM_SCRAPPRODUCT.SCRAPDATE <= trunc(:ScrapDateEnd)");
  14003. parameters.Add(new OracleParameter(":ScrapDateEnd", OracleDbType.Date, se.ScrapDataEnd.Value, ParameterDirection.Input));
  14004. }
  14005. if (se.GooddLevelTypeID != null)
  14006. {
  14007. // 产品分级
  14008. sql.Append(" AND TP_PM_SCRAPPRODUCT.GOODSLEVELTYPEID = :GooddLevelTypeID ");
  14009. parameters.Add(new OracleParameter(":GooddLevelTypeID", OracleDbType.Int32, se.GooddLevelTypeID, ParameterDirection.Input));
  14010. }
  14011. //在产or 回收站
  14012. sql.Append(" AND TP_PM_InProduction_Tmp.TrashFlag = :TrashFlag ");
  14013. parameters.Add(new OracleParameter(":TrashFlag", OracleDbType.Int32, se.TrashFlag, ParameterDirection.Input));
  14014. }
  14015. //删除在产临时表数据
  14016. string updatsql1 = "delete from TP_PM_InProduction_Tmp p where p.barcode in (" + sql.ToString() + ")";
  14017. returnRows += oracleTrConn.ExecuteNonQuery(updatsql1, parameters.ToArray());
  14018. if (returnRows == 0)
  14019. {
  14020. oracleTrConn.Rollback();
  14021. oracleTrConn.Disconnect();
  14022. }
  14023. else
  14024. {
  14025. oracleTrConn.Commit();
  14026. oracleTrConn.Disconnect();
  14027. }
  14028. }
  14029. catch (Exception ex)
  14030. {
  14031. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  14032. {
  14033. oracleTrConn.Rollback();
  14034. oracleTrConn.Disconnect();
  14035. }
  14036. throw ex;
  14037. }
  14038. finally
  14039. {
  14040. if (oracleTrConn.ConnState == ConnectionState.Open)
  14041. {
  14042. oracleTrConn.Disconnect();
  14043. }
  14044. }
  14045. return returnRows;
  14046. }
  14047. /// <summary>
  14048. /// 获取批量数据
  14049. /// </summary>
  14050. /// <returns></returns>
  14051. private static string GetClearInproductionTmpData(int accountid)
  14052. {
  14053. string selSql =
  14054. "SELECT " +
  14055. " TP_PM_InProduction_Tmp.BarCode " +
  14056. " FROM TP_PM_InProduction_Tmp " +
  14057. " left join tp_pm_scrapproduct " +
  14058. " on tp_pm_scrapproduct.barcode=TP_PM_InProduction_Tmp.barcode " +
  14059. " Where 1=1 and TP_PM_InProduction_Tmp.ValueFlag = 1 " +
  14060. " and TP_PM_InProduction_Tmp.AccountID= " + accountid;
  14061. return selSql;
  14062. }
  14063. #endregion
  14064. #region 恢复数据
  14065. /// <summary>
  14066. /// 恢复数据
  14067. /// </summary>
  14068. /// <param name="barcodes">产品条码集</param>
  14069. /// <returns></returns>
  14070. public static int ResetBarCode(string barcode)
  14071. {
  14072. int returnRows = 0;
  14073. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  14074. try
  14075. {
  14076. string sql = "select trashflag from Tp_Pm_Inproduction_Tmp where barcode=:barcode";
  14077. OracleParameter[] Paras = Paras = new OracleParameter[] {
  14078. new OracleParameter(":barcode",OracleDbType.NVarchar2,
  14079. barcode,ParameterDirection.Input)
  14080. };
  14081. DataSet ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  14082. if (ds != null && ds.Tables[0].Rows.Count == 0)
  14083. {
  14084. oracleTrConn.Rollback();
  14085. oracleTrConn.Disconnect();
  14086. return -1; //此条码没有清除,不能恢复
  14087. }
  14088. if (ds.Tables[0].Rows[0]["trashflag"].ToString() == "0") //在产删除
  14089. {
  14090. sql = @"insert into tp_pm_inproduction select
  14091. BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME,
  14092. PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID,
  14093. ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME,
  14094. USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE,
  14095. GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID,
  14096. CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE,
  14097. REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME,
  14098. CREATEUSERID, UPDATETIME, UPDATEUSERID,optimestamp,
  14099. ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG,
  14100. GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM,
  14101. KILNID, KILNCODE, KILNNAME, KILNCARID,
  14102. KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID
  14103. ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,0,logoid,IsReworkFlag,SemiCheckID
  14104. from TP_PM_InProduction_Tmp p where p.barcode = :barcode";
  14105. }
  14106. else
  14107. {
  14108. sql = @"insert into tp_pm_inproductiontrash select
  14109. BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME,
  14110. PROCEDUREMODEL, MODELTYPE,
  14111. defectflag,
  14112. REWORKPROCEDUREID,
  14113. ISPUBLICBODY,
  14114. ISRefire,
  14115. GOODSLEVELID, GOODSLEVELTYPEID,
  14116. GOODSID, GOODSCODE, GOODSNAME,
  14117. USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE,
  14118. GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID,
  14119. CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE,
  14120. GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM,
  14121. REMARKS,
  14122. KILNID, KILNCODE, KILNNAME, KILNCARID,
  14123. KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,
  14124. ACCOUNTID, VALUEFLAG, CREATETIME,
  14125. CREATEUSERID, UPDATETIME, UPDATEUSERID,optimestamp,
  14126. SpecialRepairFlag,FlowProcedureID
  14127. ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,logoid,IsReworkFlag,SemiCheckID
  14128. from TP_PM_InProduction_Tmp p where p.barcode = :barcode";
  14129. }
  14130. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  14131. //将生产数据表中的数据插入到在产生产数据表中
  14132. sql = @"insert into tp_pm_productiondatain
  14133. select
  14134. pd.PRODUCTIONDATAID,
  14135. pd.BARCODE,
  14136. pd.CENTRALIZEDBATCHNO,
  14137. pd.PRODUCTIONLINEID,
  14138. pd.PRODUCTIONLINECODE,
  14139. pd.PRODUCTIONLINENAME,
  14140. pd.PROCEDUREID,
  14141. pd.PROCEDURECODE,
  14142. pd.PROCEDURENAME,
  14143. pd.PROCEDUREMODEL,
  14144. pd.MODELTYPE,
  14145. pd.PIECETYPE,
  14146. pd.ISREWORKED,
  14147. pd.NODETYPE,
  14148. pd.ISPUBLICBODY,
  14149. pd.ISREFIRE,
  14150. pd.ORGANIZATIONID,
  14151. pd.GOODSID,
  14152. pd.GOODSCODE,
  14153. pd.GOODSNAME,
  14154. pd.USERID,
  14155. pd.USERCODE,
  14156. pd.USERNAME,
  14157. pd.KILNID,
  14158. pd.KILNCODE,
  14159. pd.KILNNAME,
  14160. pd.KILNCARID,
  14161. pd.KILNCARCODE,
  14162. pd.KILNCARNAME,
  14163. pd.KILNCARBATCHNO,
  14164. pd.KILNCARPOSITION,
  14165. pd.REWORKPROCEDUREID,
  14166. pd.REWORKPROCEDURECODE,
  14167. pd.REWORKPROCEDURENAME,
  14168. pd.REMARKS,pd.ACCOUNTDATE,pd.SETTLEMENTFLAG,pd.ACCOUNTID,pd.VALUEFLAG,
  14169. pd.CREATETIME,pd.CREATEUSERID,pd.UPDATETIME,pd.UPDATEUSERID,pd.OPTIMESTAMP,
  14170. pd.GOODSLEVELID,pd.GOODSLEVELTYPEID,pd.GROUTINGDATE,pd.GROUTINGMOULDCODE,pd.MOULDCODE,
  14171. pd.GROUTINGUSERID,pd.GROUTINGUSERCODE,pd.GROUTINGNUM,pd.GROUTINGDAILYID,pd.GROUTINGDAILYDETAILID,
  14172. pd.GROUTINGLINEID,pd.GROUTINGLINECODE,pd.GROUTINGLINENAME,pd.GMOULDTYPEID,pd.CANMANYTIMES,
  14173. pd.GROUTINGLINEDETAILID,pd.SPECIALREPAIRFLAG,pd.CLASSESSETTINGID,
  14174. '1',pd.LOGOID,
  14175. pd.BackOutTime,pd.BackOutUserID,pd.BackOutUserCode,pd.checktime
  14176. from tp_pm_productiondata pd
  14177. where pd.barcode = :barcode
  14178. and pd.productiondataid not in
  14179. (select pp.productiondataid
  14180. from tp_pm_productiondatain pp
  14181. where pp.barcode = :barcode)";
  14182. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  14183. //删除在产临时表数据
  14184. sql = "delete from TP_PM_InProduction_Tmp p where p.barcode =:barcode";
  14185. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  14186. if (returnRows == 0)
  14187. {
  14188. oracleTrConn.Rollback();
  14189. oracleTrConn.Disconnect();
  14190. }
  14191. else
  14192. {
  14193. oracleTrConn.Commit();
  14194. oracleTrConn.Disconnect();
  14195. }
  14196. }
  14197. catch (Exception ex)
  14198. {
  14199. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  14200. {
  14201. oracleTrConn.Rollback();
  14202. oracleTrConn.Disconnect();
  14203. }
  14204. throw ex;
  14205. }
  14206. finally
  14207. {
  14208. if (oracleTrConn.ConnState == ConnectionState.Open)
  14209. {
  14210. oracleTrConn.Disconnect();
  14211. }
  14212. }
  14213. return returnRows;
  14214. }
  14215. /// <summary>
  14216. /// 批量恢复数据
  14217. /// </summary>
  14218. /// <param name="barcodes">产品条码集</param>
  14219. /// <returns></returns>
  14220. public static int ResetSelectedBarCode(string barcodes)
  14221. {
  14222. int returnRows = 0;
  14223. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  14224. try
  14225. {
  14226. string sql = "";
  14227. string[] subbarcode = barcodes.Split(',');
  14228. OracleParameter[] Paras = null;
  14229. DataSet ds = null;
  14230. for (int i = 0; i < subbarcode.Length; i++)
  14231. {
  14232. sql = "select trashflag from Tp_Pm_Inproduction_Tmp where barcode=:barcode";
  14233. Paras = Paras = new OracleParameter[] {
  14234. new OracleParameter(":barcode",OracleDbType.NVarchar2,
  14235. subbarcode[i],ParameterDirection.Input)
  14236. };
  14237. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  14238. if (ds != null && ds.Tables[0].Rows.Count == 0)
  14239. {
  14240. oracleTrConn.Rollback();
  14241. oracleTrConn.Disconnect();
  14242. return -1; //此条码没有清除,不能恢复
  14243. }
  14244. if (ds.Tables[0].Rows[0]["trashflag"].ToString() == "0") //在产删除
  14245. {
  14246. sql = @"insert into tp_pm_inproduction select
  14247. BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME,
  14248. PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID,
  14249. ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME,
  14250. USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE,
  14251. GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID,
  14252. CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE,
  14253. REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME,
  14254. CREATEUSERID, UPDATETIME, UPDATEUSERID,optimestamp,
  14255. ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG,
  14256. GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM,
  14257. KILNID, KILNCODE, KILNNAME, KILNCARID,
  14258. KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID
  14259. ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,0,logoid,IsReworkFlag,SemiCheckID
  14260. from TP_PM_InProduction_Tmp p where p.barcode = :barcode";
  14261. }
  14262. else
  14263. {
  14264. sql = @"insert into tp_pm_inproductiontrash select
  14265. BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME,
  14266. PROCEDUREMODEL, MODELTYPE,
  14267. defectflag,
  14268. REWORKPROCEDUREID,
  14269. ISPUBLICBODY,
  14270. ISRefire,
  14271. GOODSLEVELID, GOODSLEVELTYPEID,
  14272. GOODSID, GOODSCODE, GOODSNAME,
  14273. USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE,
  14274. GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID,
  14275. CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE,
  14276. GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM,
  14277. REMARKS,
  14278. KILNID, KILNCODE, KILNNAME, KILNCARID,
  14279. KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,
  14280. ACCOUNTID, VALUEFLAG, CREATETIME,
  14281. CREATEUSERID, UPDATETIME, UPDATEUSERID,optimestamp,
  14282. SpecialRepairFlag,FlowProcedureID
  14283. ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,logoid,IsReworkFlag,SemiCheckID
  14284. from TP_PM_InProduction_Tmp p where p.barcode = :barcode";
  14285. }
  14286. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  14287. //将生产数据表中的数据插入到在产生产数据表中
  14288. sql = @"insert into tp_pm_productiondatain
  14289. select pd.PRODUCTIONDATAID,
  14290. pd.BARCODE,
  14291. pd.CENTRALIZEDBATCHNO,
  14292. pd.PRODUCTIONLINEID,
  14293. pd.PRODUCTIONLINECODE,
  14294. pd.PRODUCTIONLINENAME,
  14295. pd.PROCEDUREID,
  14296. pd.PROCEDURECODE,
  14297. pd.PROCEDURENAME,
  14298. pd.PROCEDUREMODEL,
  14299. pd.MODELTYPE,
  14300. pd.PIECETYPE,
  14301. pd.ISREWORKED,
  14302. pd.NODETYPE,
  14303. pd.ISPUBLICBODY,
  14304. pd.ISREFIRE,
  14305. pd.ORGANIZATIONID,
  14306. pd.GOODSID,
  14307. pd.GOODSCODE,
  14308. pd.GOODSNAME,
  14309. pd.USERID,
  14310. pd.USERCODE,
  14311. pd.USERNAME,
  14312. pd.KILNID,
  14313. pd.KILNCODE,
  14314. pd.KILNNAME,
  14315. pd.KILNCARID,
  14316. pd.KILNCARCODE,
  14317. pd.KILNCARNAME,
  14318. pd.KILNCARBATCHNO,
  14319. pd.KILNCARPOSITION,
  14320. pd.REWORKPROCEDUREID,
  14321. pd.REWORKPROCEDURECODE,
  14322. pd.REWORKPROCEDURENAME,
  14323. pd.REMARKS,pd.ACCOUNTDATE,pd.SETTLEMENTFLAG,pd.ACCOUNTID,pd.VALUEFLAG,
  14324. pd.CREATETIME,pd.CREATEUSERID,pd.UPDATETIME,pd.UPDATEUSERID,pd.OPTIMESTAMP,
  14325. pd.GOODSLEVELID,pd.GOODSLEVELTYPEID,pd.GROUTINGDATE,pd.GROUTINGMOULDCODE,pd.MOULDCODE,
  14326. pd.GROUTINGUSERID,pd.GROUTINGUSERCODE,pd.GROUTINGNUM,pd.GROUTINGDAILYID,pd.GROUTINGDAILYDETAILID,
  14327. pd.GROUTINGLINEID,pd.GROUTINGLINECODE,pd.GROUTINGLINENAME,pd.GMOULDTYPEID,pd.CANMANYTIMES,
  14328. pd.GROUTINGLINEDETAILID,pd.SPECIALREPAIRFLAG,pd.CLASSESSETTINGID,
  14329. '1',pd.LOGOID,
  14330. pd.BackOutTime,pd.BackOutUserID,pd.BackOutUserCode,pd.checktime
  14331. from tp_pm_productiondata pd
  14332. where pd.barcode = :barcode
  14333. and pd.productiondataid not in
  14334. (select pp.productiondataid
  14335. from tp_pm_productiondatain pp
  14336. where pp.barcode = :barcode)";
  14337. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  14338. //删除在产临时表数据
  14339. sql = "delete from TP_PM_InProduction_Tmp p where p.barcode =:barcode";
  14340. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  14341. }
  14342. if (returnRows == 0)
  14343. {
  14344. oracleTrConn.Rollback();
  14345. oracleTrConn.Disconnect();
  14346. }
  14347. else
  14348. {
  14349. oracleTrConn.Commit();
  14350. oracleTrConn.Disconnect();
  14351. }
  14352. }
  14353. catch (Exception ex)
  14354. {
  14355. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  14356. {
  14357. oracleTrConn.Rollback();
  14358. oracleTrConn.Disconnect();
  14359. }
  14360. throw ex;
  14361. }
  14362. finally
  14363. {
  14364. if (oracleTrConn.ConnState == ConnectionState.Open)
  14365. {
  14366. oracleTrConn.Disconnect();
  14367. }
  14368. }
  14369. return returnRows;
  14370. }
  14371. #endregion
  14372. /// <summary>
  14373. /// 撤销特殊工序撤销
  14374. /// </summary>
  14375. /// <param name="barcode">产品条码</param>
  14376. /// <returns></returns>
  14377. public static ServiceResultEntity AddChancelBarCode(string barcode, SUserInfo sUserInfo)
  14378. {
  14379. ServiceResultEntity entity = new ServiceResultEntity();
  14380. int returnRows = 0;
  14381. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  14382. try
  14383. {
  14384. // 转换注浆条码
  14385. barcode = CommonModuleLogic.CommonModuleLogic.GetBarcode(oracleTrConn, barcode, sUserInfo);
  14386. DateTime? flowProcedureTime = null;
  14387. // 1 条码是否有效
  14388. string sql = "select 1 from TP_PM_GroutingDailyDetail where barcode=:barcode and valueflag=1";
  14389. OracleParameter[] Paras = new OracleParameter[] {
  14390. new OracleParameter(":barcode",OracleDbType.Varchar2,
  14391. barcode,ParameterDirection.Input)
  14392. };
  14393. DataSet ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  14394. if (ds.Tables[0].Rows.Count == 0)
  14395. {
  14396. //无效条码
  14397. returnRows = -1;
  14398. oracleTrConn.Rollback();
  14399. oracleTrConn.Disconnect();
  14400. entity.Result = returnRows;
  14401. return entity;
  14402. }
  14403. // 2.看看是否在产,如果在产看看是否已经损坯标识
  14404. int? ProcedureID = null;
  14405. // 撤销时,需要判定当前工序,而不是流程工序,干补时,当前工序是干补,流程工序是报损时的工序。
  14406. //sql = "select InScrapFlag,flowProcedureID,IsReworkFlag,flowProcedureTime from TP_PM_InProduction where barcode=:barcode and valueflag=1";
  14407. sql = "select InScrapFlag,ProcedureID,IsReworkFlag,ProcedureTime from TP_PM_InProduction where barcode=:barcode and valueflag=1";
  14408. Paras = new OracleParameter[] {
  14409. new OracleParameter(":barcode",OracleDbType.Varchar2,
  14410. barcode,ParameterDirection.Input)
  14411. };
  14412. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  14413. if (ds.Tables[0].Rows.Count == 0) //不存在在产信息
  14414. {
  14415. // 不在产,看看是否有成品
  14416. sql = @"select 1 from TP_PM_FinishedProduct where barcode=:barcode";
  14417. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  14418. if (ds.Tables[0].Rows.Count > 0)
  14419. {
  14420. //生产完成
  14421. returnRows = -2;
  14422. oracleTrConn.Rollback();
  14423. oracleTrConn.Disconnect();
  14424. entity.Result = returnRows;
  14425. return entity;
  14426. }
  14427. else
  14428. {
  14429. //条码不在生产线上
  14430. returnRows = -7;
  14431. oracleTrConn.Rollback();
  14432. oracleTrConn.Disconnect();
  14433. entity.Result = returnRows;
  14434. return entity;
  14435. }
  14436. }
  14437. else
  14438. {
  14439. if (ds.Tables[0].Rows[0]["InScrapFlag"].ToString() == "1")
  14440. {
  14441. //申请报废
  14442. returnRows = -3;
  14443. oracleTrConn.Rollback();
  14444. oracleTrConn.Disconnect();
  14445. entity.Result = returnRows;
  14446. return entity;
  14447. }
  14448. // chenxy 2019-10-02 半检返修 IsReworkFlag=2
  14449. //if (ds.Tables[0].Rows[0]["IsReworkFlag"].ToString() == "1")
  14450. if (ds.Tables[0].Rows[0]["IsReworkFlag"].ToString() != "0")
  14451. {
  14452. //申请报废
  14453. returnRows = -9;
  14454. oracleTrConn.Rollback();
  14455. oracleTrConn.Disconnect();
  14456. entity.Result = returnRows;
  14457. return entity;
  14458. }
  14459. //ProcedureID = Convert.ToInt32(ds.Tables[0].Rows[0]["flowProcedureID"]); //条码完成工序
  14460. //flowProcedureTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["flowProcedureTime"]); // 流程工序时间
  14461. ProcedureID = Convert.ToInt32(ds.Tables[0].Rows[0]["ProcedureID"]); //条码完成工序
  14462. flowProcedureTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["ProcedureTime"]); // 完成工序时间
  14463. }
  14464. // 此工序所在条码是否是特殊工序,即可以撤销工序
  14465. sql = "select UnDoFlag from tp_pc_procedure where procedureid=:procdureid and valueflag=1";
  14466. Paras = new OracleParameter[] {
  14467. new OracleParameter(":procdureid",OracleDbType.Int32,
  14468. ProcedureID,ParameterDirection.Input)
  14469. };
  14470. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  14471. if (ds != null && ds.Tables[0].Rows.Count > 0)
  14472. {
  14473. if (ds.Tables[0].Rows[0]["UnDoFlag"].ToString() != "1")
  14474. {
  14475. //此条码所在工序不允许进行撤销
  14476. returnRows = -4;
  14477. oracleTrConn.Rollback();
  14478. oracleTrConn.Disconnect();
  14479. entity.Result = returnRows;
  14480. return entity;
  14481. }
  14482. }
  14483. // 计件撤销 应该不用验证是否回收了 by chenxiaoye 2020-02-28
  14484. //// 如果不合格,查询报损表里是否回收
  14485. //sql = "select recyclingflag from TP_PM_ScrapProduct "
  14486. // + " where BarCode=:BarCode and CreateTime=(select max(CreateTime) "
  14487. // + " from TP_PM_ScrapProduct "
  14488. // + " where BarCode=:BarCode and ValueFlag=1)"
  14489. // + " and ValueFlag=1";
  14490. //Paras = new OracleParameter[]{
  14491. // new OracleParameter(":BarCode",OracleDbType.NVarchar2,barcode,ParameterDirection.Input),
  14492. // };
  14493. //DataSet dsResult2 = oracleTrConn.GetSqlResultToDs(sql, Paras);
  14494. //if (dsResult2 != null && dsResult2.Tables[0].Rows.Count > 0)
  14495. //{
  14496. // if (Convert.ToInt32(dsResult2.Tables[0].Rows[0]["recyclingflag"]) > 0)
  14497. // {
  14498. // returnRows = -200;
  14499. // oracleTrConn.Rollback();
  14500. // oracleTrConn.Disconnect();
  14501. // entity.Result = returnRows;
  14502. // entity.Message = "此产品已经回收,不能撤销";
  14503. // return entity;
  14504. // }
  14505. //}
  14506. // 计件撤销 应该不用验证是否回收了 by chenxiaoye 2020-02-28
  14507. // 判断是否有撤销范围权限
  14508. sql = @"select 1 from TP_MST_UserPurview where UserID=:UserID and (PurviewID=:PurviewID or PurviewID=-1) and PurviewType=13";
  14509. Paras = new OracleParameter[] {
  14510. new OracleParameter(":PurviewID",OracleDbType.Int32,
  14511. ProcedureID,ParameterDirection.Input),
  14512. new OracleParameter(":UserID",OracleDbType.Int32,
  14513. sUserInfo.UserID,ParameterDirection.Input)
  14514. };
  14515. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  14516. if (ds != null && ds.Tables[0].Rows.Count == 0)
  14517. {
  14518. //此用户无此工序撤销权限
  14519. returnRows = -8;
  14520. oracleTrConn.Rollback();
  14521. oracleTrConn.Disconnect();
  14522. entity.Result = returnRows;
  14523. return entity;
  14524. }
  14525. //
  14526. #region 是否启用撤销限制天数
  14527. if (flowProcedureTime != null)
  14528. {
  14529. sql = "select settingvalue from TP_MST_SystemSetting where settingcode=:settingcode and accountid=:accountid";
  14530. Paras = new OracleParameter[] {
  14531. new OracleParameter(":settingcode",OracleDbType.Varchar2,
  14532. Constant.SettingType.S_PM_004.ToString(),ParameterDirection.Input),
  14533. new OracleParameter(":accountid",OracleDbType.Int32,
  14534. sUserInfo.AccountID,ParameterDirection.Input)
  14535. };
  14536. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  14537. if (ds != null && ds.Tables[0].Rows.Count > 0)
  14538. {
  14539. if (Convert.ToInt32(ds.Tables[0].Rows[0]["settingvalue"]) > 0)
  14540. {
  14541. // 开启了限制
  14542. ServiceResultEntity resultEntity = PMModuleLogic.BarcodeAllowCancel(Convert.ToDateTime(flowProcedureTime),
  14543. Convert.ToInt32(ds.Tables[0].Rows[0]["settingvalue"]), Constant.SettingType.S_PM_004.ToString(), sUserInfo);
  14544. if (Convert.ToInt32(resultEntity.Result) < 0)
  14545. {
  14546. //计件撤销限制天数
  14547. returnRows = -200;
  14548. oracleTrConn.Rollback();
  14549. oracleTrConn.Disconnect();
  14550. entity.Result = returnRows;
  14551. entity.Message = resultEntity.Message;
  14552. return entity;
  14553. }
  14554. }
  14555. }
  14556. }
  14557. #endregion
  14558. // 进行撤销
  14559. string sqlString = @"select ProductionDataID,
  14560. ProcedureID,
  14561. ProcedureModel,
  14562. ModelType,
  14563. ReworkProcedureID,
  14564. UserID,
  14565. logoid,
  14566. (select max(ProcedureID) from Tp_Pm_ProductiondataIn inpp where inpp.barcode = :barcode and inpp.ProductionDataID > t.ProductionDataID and ModelType=8 and valueflag='1') p8id --干补
  14567. from (select ProductionDataID,
  14568. ProcedureID,
  14569. ProcedureModel,
  14570. ModelType,
  14571. ReworkProcedureID,
  14572. UserID,
  14573. logoid
  14574. from Tp_Pm_ProductiondataIn
  14575. where barcode = :barcode
  14576. and valueflag = 1 and ModelType<>8
  14577. order by ProductionDataID desc) t
  14578. where rownum <= 2";
  14579. Paras = new OracleParameter[]{
  14580. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  14581. };
  14582. DataSet productionData = oracleTrConn.GetSqlResultToDs(sqlString, Paras);
  14583. if (productionData == null
  14584. || productionData.Tables.Count == Constant.INT_IS_ZERO
  14585. //|| productionData.Tables[0].Rows.Count != Constant.INT_IS_TWO
  14586. )
  14587. {
  14588. // 条码至少要有2次数据采集
  14589. //条码没有此工序前数据
  14590. returnRows = -5;
  14591. oracleTrConn.Rollback();
  14592. oracleTrConn.Disconnect();
  14593. entity.Result = returnRows;
  14594. return entity;
  14595. }
  14596. //xuwei fix 2019-09-25 tables只有一行记录 rows[1]无记录 改成rows[0]?
  14597. object pid = productionData.Tables[0].Rows[productionData.Tables[0].Rows.Count - 1]["p8id"];
  14598. if (pid == null || pid == DBNull.Value)
  14599. {
  14600. pid = productionData.Tables[0].Rows[productionData.Tables[0].Rows.Count - 1]["ProcedureID"];
  14601. }
  14602. #region 回滚在产数据
  14603. //xuwei fix 2019-09-23 加条件限制 如果是首节点 删除在产产品数据 否则 更新在产产品数据
  14604. if (productionData.Tables[0].Rows.Count == 1)
  14605. {
  14606. sqlString = "delete from TP_PM_InProduction where barcode=:barcode"; //wangxin 20150406
  14607. //sqlString += " where ProductionDataID=:productionDataID";
  14608. //新添加的 begin
  14609. Paras = new OracleParameter[]{
  14610. new OracleParameter(":barcode",OracleDbType.Varchar2,
  14611. barcode,ParameterDirection.Input),
  14612. };
  14613. int rows = oracleTrConn.ExecuteNonQuery(sqlString, Paras);
  14614. returnRows += rows;
  14615. if (rows == Constant.INT_IS_ZERO)
  14616. {
  14617. // 保存失败
  14618. //没有任何影响行
  14619. returnRows = -6;
  14620. oracleTrConn.Rollback();
  14621. oracleTrConn.Disconnect();
  14622. entity.Result = returnRows;
  14623. return entity;
  14624. }
  14625. //xuwei add 2019-09-23 更新回生产状态 BEGINNINGFLAG = '0'
  14626. oracleTrConn.ExecuteNonQuery($"update TP_PM_GroutingDailyDetail set BEGINNINGFLAG = '0' where BARCODE = '{barcode}'");
  14627. //xuwei fix 2019-09-25 加条件判断 如果是首节点 回退到注浆1
  14628. sql = $"update TP_PM_USEDBARCODE set barcodestatus=1 where BarCode='{barcode}'";
  14629. rows = oracleTrConn.ExecuteNonQuery(sql);
  14630. returnRows += rows;
  14631. }
  14632. else
  14633. {
  14634. //xuwei 下述代码为原代码 并未判定首节点
  14635. sqlString = @"update TP_PM_InProduction
  14636. set FlowProcedureID = :flowProcedureID,
  14637. ProcedureModel = :procedureModel,
  14638. ProcedureID = :ProcedureID,
  14639. ModelType = :modelType,
  14640. ReworkProcedureID = :reworkProcedureID,
  14641. UserID = :userID,
  14642. updateuserid = :updateuserid,
  14643. ProductionDataID = :ProductionDataID
  14644. --logoid = :logoid
  14645. where barcode = :barcode";
  14646. Paras = new OracleParameter[]{
  14647. new OracleParameter(":flowProcedureID",OracleDbType.Int32,
  14648. productionData.Tables[0].Rows[1]["ProcedureID"],ParameterDirection.Input),//1--->0
  14649. new OracleParameter(":ProcedureID",OracleDbType.Int32,
  14650. pid,ParameterDirection.Input),
  14651. new OracleParameter(":procedureModel",OracleDbType.Int32,
  14652. productionData.Tables[0].Rows[1]["procedureModel"],ParameterDirection.Input),
  14653. new OracleParameter(":modelType",OracleDbType.Int32,
  14654. productionData.Tables[0].Rows[1]["modelType"],ParameterDirection.Input),
  14655. new OracleParameter(":reworkProcedureID",OracleDbType.Int32,
  14656. productionData.Tables[0].Rows[1]["reworkProcedureID"],ParameterDirection.Input),
  14657. new OracleParameter(":userID",OracleDbType.Int32,
  14658. productionData.Tables[0].Rows[1]["userID"],ParameterDirection.Input),
  14659. new OracleParameter(":updateuserid",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input),
  14660. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  14661. new OracleParameter(":ProductionDataID",OracleDbType.Int32,
  14662. productionData.Tables[0].Rows[1]["ProductionDataID"],ParameterDirection.Input)
  14663. //new OracleParameter(":logoid",OracleDbType.Int32,
  14664. // productionData.Tables[0].Rows[1]["logoid"].ToString()==""?null:productionData.Tables[0].Rows[1]["logoid"],ParameterDirection.Input),
  14665. };
  14666. int rows = oracleTrConn.ExecuteNonQuery(sqlString, Paras);
  14667. returnRows += rows;
  14668. if (rows == Constant.INT_IS_ZERO)
  14669. {
  14670. // 保存失败
  14671. //没有任何影响行
  14672. returnRows = -6;
  14673. oracleTrConn.Rollback();
  14674. oracleTrConn.Disconnect();
  14675. entity.Result = returnRows;
  14676. return entity;
  14677. }
  14678. }
  14679. //modify end
  14680. sqlString = "update Tp_Pm_ProductiondataIn set valueflag=0 ,updateuserid=" + sUserInfo.UserID; //wangxin 20150406
  14681. //sqlString += " where ProductionDataID=:productionDataID";
  14682. //新添加的 begin
  14683. Paras = new OracleParameter[]{
  14684. new OracleParameter(":productionDataID",OracleDbType.Int32,
  14685. Convert.ToInt32(productionData.Tables[0].Rows[0]["productionDataID"]),ParameterDirection.Input),
  14686. new OracleParameter(":barcode",OracleDbType.Varchar2,
  14687. barcode,ParameterDirection.Input),
  14688. };
  14689. //新添加的 end
  14690. sqlString += " where ProductionDataID=:productionDataID and barcode=:barcode";
  14691. int rutenRows = oracleTrConn.ExecuteNonQuery(sqlString, Paras);
  14692. returnRows += rutenRows;
  14693. if (rutenRows == Constant.INT_IS_ZERO)
  14694. {
  14695. // 保存失败
  14696. //没有任何影响行
  14697. returnRows = -6;
  14698. oracleTrConn.Rollback();
  14699. oracleTrConn.Disconnect();
  14700. entity.Result = returnRows;
  14701. return entity;
  14702. }
  14703. #endregion
  14704. if (returnRows <= 0)
  14705. {
  14706. oracleTrConn.Rollback();
  14707. oracleTrConn.Disconnect();
  14708. }
  14709. else
  14710. {
  14711. oracleTrConn.Commit();
  14712. oracleTrConn.Disconnect();
  14713. }
  14714. }
  14715. catch (Exception ex)
  14716. {
  14717. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  14718. {
  14719. oracleTrConn.Rollback();
  14720. oracleTrConn.Disconnect();
  14721. }
  14722. throw ex;
  14723. }
  14724. finally
  14725. {
  14726. if (oracleTrConn.ConnState == ConnectionState.Open)
  14727. {
  14728. oracleTrConn.Disconnect();
  14729. }
  14730. }
  14731. entity.Result = returnRows;
  14732. return entity;
  14733. }
  14734. /// <summary>
  14735. /// 交坯特殊工序撤销
  14736. /// </summary>
  14737. /// <param name="barcode">产品条码</param>
  14738. /// <returns></returns>
  14739. public static ServiceResultEntity AddChancelDeliverMudBarCode(string barcode, SUserInfo sUserInfo)
  14740. {
  14741. ServiceResultEntity entity = new ServiceResultEntity();
  14742. int returnRows = 0;
  14743. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  14744. try
  14745. {
  14746. DateTime? deliverTime = null;
  14747. // 1 条码是否有效
  14748. string sql = "select DeliverTime from TP_PM_GroutingDailyDetail where barcode=:barcode and valueflag=1";
  14749. OracleParameter[] Paras = new OracleParameter[] {
  14750. new OracleParameter(":barcode",OracleDbType.Varchar2,
  14751. barcode,ParameterDirection.Input)
  14752. };
  14753. DataSet ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  14754. if (ds.Tables[0].Rows.Count == 0)
  14755. {
  14756. //无效条码
  14757. returnRows = -1;
  14758. oracleTrConn.Rollback();
  14759. oracleTrConn.Disconnect();
  14760. entity.Result = returnRows;
  14761. return entity;
  14762. }
  14763. else
  14764. {
  14765. if (ds.Tables[0].Rows[0]["DeliverTime"].ToString() != "")
  14766. {
  14767. deliverTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["DeliverTime"]);
  14768. }
  14769. }
  14770. // 2.看看是否在产,如果在产看看是否已经损坯标识
  14771. int? ProcedureID = null;
  14772. //xuwei fix 2019-09-27 选出交坏判定字段
  14773. //sql = "select InScrapFlag,flowProcedureID,IsReworkFlag,Specialrepairflag from TP_PM_InProduction where barcode=:barcode and valueflag=1";
  14774. sql = "select MODELTYPE,InScrapFlag,flowProcedureID,IsReworkFlag,Specialrepairflag from TP_PM_InProduction where barcode=:barcode and valueflag=1";
  14775. Paras = new OracleParameter[] {
  14776. new OracleParameter(":barcode",OracleDbType.Varchar2,
  14777. barcode,ParameterDirection.Input)
  14778. };
  14779. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  14780. if (ds.Tables[0].Rows.Count == 0) //不存在在产信息
  14781. {
  14782. // 不在产,看看是否有成品
  14783. sql = @"select 1 from TP_PM_FinishedProduct where barcode=:barcode";
  14784. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  14785. if (ds.Tables[0].Rows.Count > 0)
  14786. {
  14787. //生产完成
  14788. returnRows = -2;
  14789. oracleTrConn.Rollback();
  14790. oracleTrConn.Disconnect();
  14791. entity.Result = returnRows;
  14792. return entity;
  14793. }
  14794. else
  14795. {
  14796. //条码不在生产线上
  14797. returnRows = -7;
  14798. oracleTrConn.Rollback();
  14799. oracleTrConn.Disconnect();
  14800. entity.Result = returnRows;
  14801. return entity;
  14802. }
  14803. }
  14804. else
  14805. {
  14806. //xuwei add 2019-09-27 如果是非交坯工序不能在此节点撤销 5是交坯模型
  14807. if (ds.Tables[0].Rows[0]["MODELTYPE"].ToString() != "5")
  14808. {
  14809. //非交坯工序,不能交坯撤销
  14810. returnRows = -200;
  14811. oracleTrConn.Rollback();
  14812. oracleTrConn.Disconnect();
  14813. entity.Result = returnRows;
  14814. entity.Message = "非交坯工序,不能交坯撤销";
  14815. return entity;
  14816. }
  14817. //xuwei end
  14818. if (ds.Tables[0].Rows[0]["Specialrepairflag"].ToString() == "1")
  14819. {
  14820. //干补后不允许撤销
  14821. returnRows = -200;
  14822. oracleTrConn.Rollback();
  14823. oracleTrConn.Disconnect();
  14824. entity.Result = returnRows;
  14825. entity.Message = "干补后不允许撤销";
  14826. return entity;
  14827. }
  14828. if (ds.Tables[0].Rows[0]["InScrapFlag"].ToString() == "1")
  14829. {
  14830. //申请报废
  14831. returnRows = -3;
  14832. oracleTrConn.Rollback();
  14833. oracleTrConn.Disconnect();
  14834. entity.Result = returnRows;
  14835. return entity;
  14836. }
  14837. // chenxy 2019-10-02 半检返修 IsReworkFlag=2
  14838. //if (ds.Tables[0].Rows[0]["IsReworkFlag"].ToString() == "1")
  14839. if (ds.Tables[0].Rows[0]["IsReworkFlag"].ToString() != "0")
  14840. {
  14841. //申请报废
  14842. returnRows = -8;
  14843. oracleTrConn.Rollback();
  14844. oracleTrConn.Disconnect();
  14845. entity.Result = returnRows;
  14846. return entity;
  14847. }
  14848. ProcedureID = Convert.ToInt32(ds.Tables[0].Rows[0]["flowProcedureID"]); //条码完成工序
  14849. }
  14850. //// 此工序所在条码是否是特殊工序,即可以撤销工序
  14851. //sql = "select UnDoFlag from tp_pc_procedure where procedureid=:procdureid and valueflag=1";
  14852. //Paras = new OracleParameter[] {
  14853. // new OracleParameter(":procdureid",OracleDbType.Int32,
  14854. // ProcedureID,ParameterDirection.Input)
  14855. //};
  14856. //ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  14857. //if (ds != null && ds.Tables[0].Rows.Count > 0)
  14858. //{
  14859. // if (ds.Tables[0].Rows[0]["UnDoFlag"].ToString() != "1")
  14860. // {
  14861. // //此条码所在工序不允许进行撤销
  14862. // returnRows = -4;
  14863. // oracleTrConn.Rollback();
  14864. // oracleTrConn.Disconnect();
  14865. // return returnRows;
  14866. // }
  14867. //}
  14868. #region 是否启用交坯撤销限制天数
  14869. if (deliverTime != null)
  14870. {
  14871. sql = "select settingvalue from TP_MST_SystemSetting where settingcode=:settingcode and accountid=:accountid";
  14872. Paras = new OracleParameter[] {
  14873. new OracleParameter(":settingcode",OracleDbType.Varchar2,
  14874. Constant.SettingType.S_PM_003.ToString(),ParameterDirection.Input),
  14875. new OracleParameter(":accountid",OracleDbType.Int32,
  14876. sUserInfo.AccountID,ParameterDirection.Input)
  14877. };
  14878. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  14879. if (ds != null && ds.Tables[0].Rows.Count > 0)
  14880. {
  14881. if (Convert.ToInt32(ds.Tables[0].Rows[0]["settingvalue"]) > 0)
  14882. {
  14883. // 开启了限制
  14884. ServiceResultEntity resultEntity = PMModuleLogic.BarcodeAllowCancel(Convert.ToDateTime(deliverTime),
  14885. Convert.ToInt32(ds.Tables[0].Rows[0]["settingvalue"]), Constant.SettingType.S_PM_003.ToString(), sUserInfo);
  14886. if (Convert.ToInt32(resultEntity.Result) < 0)
  14887. {
  14888. //超过交坯撤销限制天数
  14889. returnRows = -200;
  14890. oracleTrConn.Rollback();
  14891. oracleTrConn.Disconnect();
  14892. entity.Result = returnRows;
  14893. entity.Message = resultEntity.Message;
  14894. return entity;
  14895. }
  14896. }
  14897. }
  14898. }
  14899. #endregion
  14900. // 进行撤销
  14901. string sqlString = @"select ProductionDataID,
  14902. ProcedureID,
  14903. ProcedureModel,
  14904. ModelType,
  14905. ReworkProcedureID,
  14906. UserID,
  14907. (select max(ProcedureID) from Tp_Pm_ProductiondataIn inpp where inpp.barcode = :barcode and inpp.ProductionDataID > t.ProductionDataID and ModelType=8 and valueflag='1') p8id --干补
  14908. from (select ProductionDataID,
  14909. ProcedureID,
  14910. ProcedureModel,
  14911. ModelType,
  14912. ReworkProcedureID,
  14913. UserID
  14914. from Tp_Pm_ProductiondataIn
  14915. where barcode = :barcode
  14916. and valueflag = 1 and ModelType<>8
  14917. order by ProductionDataID desc) t
  14918. where rownum <= 2";
  14919. Paras = new OracleParameter[]{
  14920. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  14921. };
  14922. DataSet productionData = oracleTrConn.GetSqlResultToDs(sqlString, Paras);
  14923. if (productionData == null
  14924. || productionData.Tables.Count == Constant.INT_IS_ZERO
  14925. )
  14926. {
  14927. // 条码至少要有1次数据采集
  14928. //条码没有此工序前数据
  14929. returnRows = -5; //条码至少要有1次数据采集
  14930. oracleTrConn.Rollback();
  14931. oracleTrConn.Disconnect();
  14932. entity.Result = returnRows;
  14933. return entity;
  14934. }
  14935. //if (productionData.Tables[0].Rows.Count != Constant.INT_IS_ONE)
  14936. //{
  14937. // // 条码至少要有1次数据采集
  14938. // //条码没有此工序前数据
  14939. // returnRows = -55; //条码已经经过多个工序,不允许撤销
  14940. // oracleTrConn.Rollback();
  14941. // oracleTrConn.Disconnect();
  14942. // entity.Result = returnRows;
  14943. // return entity;
  14944. //}
  14945. //xuwei fix 2019-09-25 tables只有一行记录 rows[1]无记录 改成rows[0]?
  14946. object pid = productionData.Tables[0].Rows[productionData.Tables[0].Rows.Count - 1]["p8id"];
  14947. if (pid == null || pid == DBNull.Value)
  14948. {
  14949. pid = productionData.Tables[0].Rows[productionData.Tables[0].Rows.Count - 1]["ProcedureID"];
  14950. }
  14951. #region 回滚在产数据
  14952. // sqlString = @"update TP_PM_InProduction
  14953. // set FlowProcedureID = :flowProcedureID,
  14954. // ProcedureModel = :procedureModel,
  14955. // ProcedureID = :flowProcedureID,
  14956. // ModelType = :modelType,
  14957. // ReworkProcedureID = :reworkProcedureID,
  14958. // UserID = :userID,
  14959. // updateuserid = :updateuserid
  14960. // where barcode = :barcode";
  14961. // Paras = new OracleParameter[]{
  14962. // new OracleParameter(":flowProcedureID",OracleDbType.Int32,
  14963. // productionData.Tables[0].Rows[1]["ProcedureID"],ParameterDirection.Input),//1--->0
  14964. // new OracleParameter(":procedureModel",OracleDbType.Int32,
  14965. // productionData.Tables[0].Rows[1]["procedureModel"],ParameterDirection.Input),
  14966. // new OracleParameter(":modelType",OracleDbType.Int32,
  14967. // productionData.Tables[0].Rows[1]["modelType"],ParameterDirection.Input),
  14968. // new OracleParameter(":reworkProcedureID",OracleDbType.Int32,
  14969. // productionData.Tables[0].Rows[1]["reworkProcedureID"],ParameterDirection.Input),
  14970. // new OracleParameter(":userID",OracleDbType.Int32,
  14971. // productionData.Tables[0].Rows[1]["userID"],ParameterDirection.Input),
  14972. // new OracleParameter(":updateuserid",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input),
  14973. // new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  14974. // };
  14975. // int rutenRows = oracleTrConn.ExecuteNonQuery(sqlString, Paras);
  14976. // returnRows += rutenRows;
  14977. // if (rutenRows == Constant.INT_IS_ZERO)
  14978. // {
  14979. // // 保存失败
  14980. // //没有任何影响行
  14981. // returnRows = -6;
  14982. // oracleTrConn.Rollback();
  14983. // oracleTrConn.Disconnect();
  14984. // return returnRows;
  14985. // }
  14986. int rutenRows = 0;
  14987. //modify end
  14988. sqlString = "update Tp_Pm_ProductiondataIn set valueflag=0 ,updateuserid=" + sUserInfo.UserID; //wangxin 20150406
  14989. //sqlString += " where ProductionDataID=:productionDataID";
  14990. //新添加的 begin
  14991. Paras = new OracleParameter[]{
  14992. new OracleParameter(":productionDataID",OracleDbType.Int32,
  14993. Convert.ToInt32(productionData.Tables[0].Rows[0]["productionDataID"]),ParameterDirection.Input),
  14994. new OracleParameter(":barcode",OracleDbType.Varchar2,
  14995. barcode,ParameterDirection.Input),
  14996. };
  14997. //新添加的 end
  14998. sqlString += " where ProductionDataID=:productionDataID and barcode=:barcode";
  14999. rutenRows = oracleTrConn.ExecuteNonQuery(sqlString, Paras);
  15000. returnRows += rutenRows;
  15001. if (rutenRows == Constant.INT_IS_ZERO)
  15002. {
  15003. // 保存失败
  15004. //没有任何影响行
  15005. returnRows = -6;
  15006. oracleTrConn.Rollback();
  15007. oracleTrConn.Disconnect();
  15008. entity.Result = returnRows;
  15009. return entity;
  15010. }
  15011. //modify end
  15012. //xuwei fix 2019-09-23 加条件限制 如果是首节点 删除在产产品数据
  15013. if (productionData.Tables[0].Rows.Count == 1)
  15014. {
  15015. sqlString = "delete from TP_PM_InProduction where barcode=:barcode"; //wangxin 20150406
  15016. //sqlString += " where ProductionDataID=:productionDataID";
  15017. //新添加的 begin
  15018. Paras = new OracleParameter[]{
  15019. new OracleParameter(":barcode",OracleDbType.Varchar2,
  15020. barcode,ParameterDirection.Input),
  15021. };
  15022. rutenRows = oracleTrConn.ExecuteNonQuery(sqlString, Paras);
  15023. returnRows += rutenRows;
  15024. if (rutenRows == Constant.INT_IS_ZERO)
  15025. {
  15026. // 保存失败
  15027. //没有任何影响行
  15028. returnRows = -6;
  15029. oracleTrConn.Rollback();
  15030. oracleTrConn.Disconnect();
  15031. entity.Result = returnRows;
  15032. return entity;
  15033. }
  15034. //xuwei add 2019-09-23 更新回生产状态 BEGINNINGFLAG = '0'
  15035. oracleTrConn.ExecuteNonQuery($"update TP_PM_GroutingDailyDetail set BEGINNINGFLAG = '0' where BARCODE = '{barcode}'");
  15036. }
  15037. else
  15038. {
  15039. //xuwei 下述代码为原代码 并未判定首节点
  15040. sqlString = @"update TP_PM_InProduction
  15041. set FlowProcedureID = :flowProcedureID,
  15042. ProcedureModel = :procedureModel,
  15043. ProcedureID = :ProcedureID,
  15044. ModelType = :modelType,
  15045. ReworkProcedureID = :reworkProcedureID,
  15046. UserID = :userID,
  15047. updateuserid = :updateuserid,
  15048. ProductionDataID = :ProductionDataID
  15049. --logoid = :logoid
  15050. where barcode = :barcode";
  15051. Paras = new OracleParameter[]{
  15052. new OracleParameter(":flowProcedureID",OracleDbType.Int32,
  15053. productionData.Tables[0].Rows[1]["ProcedureID"],ParameterDirection.Input),//1--->0
  15054. new OracleParameter(":ProcedureID",OracleDbType.Int32,
  15055. pid,ParameterDirection.Input),
  15056. new OracleParameter(":procedureModel",OracleDbType.Int32,
  15057. productionData.Tables[0].Rows[1]["procedureModel"],ParameterDirection.Input),
  15058. new OracleParameter(":modelType",OracleDbType.Int32,
  15059. productionData.Tables[0].Rows[1]["modelType"],ParameterDirection.Input),
  15060. new OracleParameter(":reworkProcedureID",OracleDbType.Int32,
  15061. productionData.Tables[0].Rows[1]["reworkProcedureID"],ParameterDirection.Input),
  15062. new OracleParameter(":userID",OracleDbType.Int32,
  15063. productionData.Tables[0].Rows[1]["userID"],ParameterDirection.Input),
  15064. new OracleParameter(":updateuserid",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input),
  15065. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  15066. new OracleParameter(":ProductionDataID",OracleDbType.Int32,
  15067. productionData.Tables[0].Rows[1]["ProductionDataID"],ParameterDirection.Input)
  15068. //new OracleParameter(":logoid",OracleDbType.Int32,
  15069. // productionData.Tables[0].Rows[1]["logoid"].ToString()==""?null:productionData.Tables[0].Rows[1]["logoid"],ParameterDirection.Input),
  15070. };
  15071. int rows = oracleTrConn.ExecuteNonQuery(sqlString, Paras);
  15072. returnRows += rows;
  15073. if (rows == Constant.INT_IS_ZERO)
  15074. {
  15075. // 保存失败
  15076. //没有任何影响行
  15077. returnRows = -6;
  15078. oracleTrConn.Rollback();
  15079. oracleTrConn.Disconnect();
  15080. entity.Result = returnRows;
  15081. return entity;
  15082. }
  15083. }
  15084. #endregion
  15085. // 更新注浆明交坯标识把已经交坯改回,正常交坯
  15086. sqlString = "update TP_PM_GroutingDailyDetail set SpecialRepairFlag=0,ScrapFlag=0,IsPublicBody=0,DeliverFlag=0,DeliverTime=null,DeliverUserID=null,DeliverUserCode=null where barcode=:barcode"; //wangxin 20150406
  15087. Paras = new OracleParameter[]{
  15088. new OracleParameter(":barcode",OracleDbType.Varchar2,
  15089. barcode,ParameterDirection.Input),
  15090. };
  15091. rutenRows = oracleTrConn.ExecuteNonQuery(sqlString, Paras);
  15092. returnRows += rutenRows;
  15093. // TODO 回退到注浆 1 还是 在产 3
  15094. //xuwei fix 2019-09-23 加条件判断 如果是首节点 回退到注浆1 否则回退到在产 3
  15095. if (productionData.Tables[0].Rows.Count == 1)
  15096. {
  15097. sql = "update TP_PM_USEDBARCODE set barcodestatus=1 where BarCode=:barcode";
  15098. }
  15099. else
  15100. {
  15101. sql = "update TP_PM_USEDBARCODE set barcodestatus=3 where BarCode=:barcode";
  15102. }
  15103. Paras = new OracleParameter[]{
  15104. new OracleParameter(":barcode",OracleDbType.Varchar2,
  15105. barcode,ParameterDirection.Input),
  15106. };
  15107. rutenRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  15108. returnRows += rutenRows;
  15109. if (returnRows <= 0)
  15110. {
  15111. oracleTrConn.Rollback();
  15112. oracleTrConn.Disconnect();
  15113. }
  15114. else
  15115. {
  15116. oracleTrConn.Commit();
  15117. oracleTrConn.Disconnect();
  15118. }
  15119. }
  15120. catch (Exception ex)
  15121. {
  15122. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  15123. {
  15124. oracleTrConn.Rollback();
  15125. oracleTrConn.Disconnect();
  15126. }
  15127. throw ex;
  15128. }
  15129. finally
  15130. {
  15131. if (oracleTrConn.ConnState == ConnectionState.Open)
  15132. {
  15133. oracleTrConn.Disconnect();
  15134. }
  15135. }
  15136. entity.Result = returnRows;
  15137. return entity;
  15138. }
  15139. #region
  15140. /// <summary>
  15141. /// 清除未盘点残留数据(清除选择)
  15142. /// </summary>
  15143. /// <param name="inCheckedID">盘点单ID</param>
  15144. /// <param name="barcodes">条码集</param>
  15145. /// <returns></returns>
  15146. public static int SaveClearInChecked(int inCheckedID, string barcodes, SUserInfo sUserInfo)
  15147. {
  15148. int returnRows = 0;
  15149. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  15150. try
  15151. {
  15152. string sql = "";
  15153. string[] subbarcodes = barcodes.Split(',');
  15154. OracleParameter[] Paras = null;
  15155. for (int i = 0; i < subbarcodes.Length; i++)
  15156. {
  15157. // 0.登窑、入窑、出窑工序的产品不能清除
  15158. sql = "select p.modeltype from tp_pm_inproduction p where p.barcode = :barcode";
  15159. Paras = new OracleParameter[] {
  15160. new OracleParameter(":barcode",OracleDbType.NVarchar2,
  15161. subbarcodes[i],ParameterDirection.Input),
  15162. };
  15163. string modeltype = oracleTrConn.GetSqlResultToStr(sql, Paras);
  15164. if (!string.IsNullOrWhiteSpace(modeltype))
  15165. {
  15166. Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType pmt =
  15167. (Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType)Convert.ToInt32(modeltype);
  15168. if (pmt == Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType.LoadCar ||
  15169. pmt == Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType.IntoKiln ||
  15170. pmt == Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType.OutKiln ||
  15171. pmt == Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType.CarAdd)
  15172. {
  15173. continue;
  15174. }
  15175. }
  15176. // 返工标识或者是报损标识不允许清除 2016-07-12
  15177. sql = "select IsReworkFlag,InScrapFlag from tp_pm_inproduction p where p.barcode = :barcode";
  15178. Paras = new OracleParameter[] {
  15179. new OracleParameter(":barcode",OracleDbType.NVarchar2,
  15180. subbarcodes[i],ParameterDirection.Input)
  15181. };
  15182. DataSet ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  15183. if (ds != null && ds.Tables[0].Rows.Count > 0)
  15184. {
  15185. // chenxy 2019-10-02 半检返修 IsReworkFlag=2
  15186. //if (ds.Tables[0].Rows[0]["IsReworkFlag"].ToString() == "1")
  15187. if (ds.Tables[0].Rows[0]["IsReworkFlag"].ToString() != "0")
  15188. {
  15189. returnRows = -1;
  15190. break;
  15191. }
  15192. if (ds.Tables[0].Rows[0]["InScrapFlag"].ToString() == "1")
  15193. {
  15194. returnRows = -2;
  15195. break;
  15196. }
  15197. }
  15198. // 1.清除未盘点数据
  15199. sql = @"update TP_PM_INCHECKEDDETAIL p set p.INCHECKEDFLAG = '3' /*, p.valueflag='0'*/ where p.INCHECKEDID=:InCheckedID and p.barcode =:barcode and p.InCheckedFlag='0'";
  15200. Paras = new OracleParameter[] {
  15201. new OracleParameter(":barcode",OracleDbType.NVarchar2,
  15202. subbarcodes[i],ParameterDirection.Input),
  15203. new OracleParameter(":InCheckedID",OracleDbType.Int32,
  15204. inCheckedID,ParameterDirection.Input)
  15205. };
  15206. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  15207. // 2. 把在产数据插入到在产临时表中。(数据来源标识0:在产表)
  15208. // sql = @"insert into tp_pm_inproduction_tmp
  15209. // select * from tp_pm_inproduction p where p.barcode = :barcode";
  15210. sql = "INSERT INTO tp_pm_inproduction_tmp\n" +
  15211. " (barcode\n" +
  15212. " ,productionlineid\n" +
  15213. " ,productionlinecode\n" +
  15214. " ,productionlinename\n" +
  15215. " ,proceduremodel\n" +
  15216. " ,modeltype\n" +
  15217. " ,reworkprocedureid\n" +
  15218. " ,ispublicbody\n" +
  15219. " ,goodsid\n" +
  15220. " ,goodscode\n" +
  15221. " ,goodsname\n" +
  15222. " ,userid\n" +
  15223. " ,groutingdailyid\n" +
  15224. " ,groutingdailydetailid\n" +
  15225. " ,groutingdate\n" +
  15226. " ,groutinglineid\n" +
  15227. " ,groutinglinecode\n" +
  15228. " ,groutinglinename\n" +
  15229. " ,gmouldtypeid\n" +
  15230. " ,canmanytimes\n" +
  15231. " ,groutinglinedetailid\n" +
  15232. " ,groutingmouldcode\n" +
  15233. " ,mouldcode\n" +
  15234. " ,remarks\n" +
  15235. " ,accountid\n" +
  15236. " ,valueflag\n" +
  15237. " ,createtime\n" +
  15238. " ,createuserid\n" +
  15239. " ,updatetime\n" +
  15240. " ,updateuserid\n" +
  15241. " ,optimestamp\n" +
  15242. " ,isrefire\n" +
  15243. " ,goodslevelid\n" +
  15244. " ,goodsleveltypeid\n" +
  15245. " ,defectflag\n" +
  15246. " ,groutinguserid\n" +
  15247. " ,groutingusercode\n" +
  15248. " ,groutingnum\n" +
  15249. " ,kilnid\n" +
  15250. " ,kilncode\n" +
  15251. " ,kilnname\n" +
  15252. " ,kilncarid\n" +
  15253. " ,kilncarcode\n" +
  15254. " ,kilncarname\n" +
  15255. " ,kilncarbatchno\n" +
  15256. " ,kilncarposition\n" +
  15257. " ,specialrepairflag\n" +
  15258. " ,flowprocedureid\n" +
  15259. " ,flowproceduretime\n" +
  15260. " ,procedureid\n" +
  15261. " ,proceduretime\n" +
  15262. " ,productiondataid\n" +
  15263. " ,deleteduserid\n" +
  15264. " ,deletedusercode\n" +
  15265. " --,trashflag\n" +
  15266. " --,deletedtime\n" +
  15267. " ,logoid)\n" +
  15268. " SELECT barcode\n" +
  15269. " ,productionlineid\n" +
  15270. " ,productionlinecode\n" +
  15271. " ,productionlinename\n" +
  15272. " ,proceduremodel\n" +
  15273. " ,modeltype\n" +
  15274. " ,reworkprocedureid\n" +
  15275. " ,ispublicbody\n" +
  15276. " ,goodsid\n" +
  15277. " ,goodscode\n" +
  15278. " ,goodsname\n" +
  15279. " ,userid\n" +
  15280. " ,groutingdailyid\n" +
  15281. " ,groutingdailydetailid\n" +
  15282. " ,groutingdate\n" +
  15283. " ,groutinglineid\n" +
  15284. " ,groutinglinecode\n" +
  15285. " ,groutinglinename\n" +
  15286. " ,gmouldtypeid\n" +
  15287. " ,canmanytimes\n" +
  15288. " ,groutinglinedetailid\n" +
  15289. " ,groutingmouldcode\n" +
  15290. " ,mouldcode\n" +
  15291. " ,remarks\n" +
  15292. " ,accountid\n" +
  15293. " ,valueflag\n" +
  15294. " ,createtime\n" +
  15295. " ,createuserid\n" +
  15296. " ,updatetime\n" +
  15297. " ,updateuserid\n" +
  15298. " ,optimestamp\n" +
  15299. " ,isrefire\n" +
  15300. " ,goodslevelid\n" +
  15301. " ,goodsleveltypeid\n" +
  15302. " ,defectflag\n" +
  15303. " ,groutinguserid\n" +
  15304. " ,groutingusercode\n" +
  15305. " ,groutingnum\n" +
  15306. " ,kilnid\n" +
  15307. " ,kilncode\n" +
  15308. " ,kilnname\n" +
  15309. " ,kilncarid\n" +
  15310. " ,kilncarcode\n" +
  15311. " ,kilncarname\n" +
  15312. " ,kilncarbatchno\n" +
  15313. " ,kilncarposition\n" +
  15314. " ,specialrepairflag\n" +
  15315. " ,flowprocedureid\n" +
  15316. " ,flowproceduretime\n" +
  15317. " ,procedureid\n" +
  15318. " ,proceduretime\n" +
  15319. " ,productiondataid\n" +
  15320. " ,:deleteduserid\n" +
  15321. " ,:deletedusercode\n" +
  15322. " --,inscrapflag\n" +
  15323. " ,logoid\n" +
  15324. " FROM tp_pm_inproduction p\n" +
  15325. " WHERE p.barcode = :barcode\n" +
  15326. " AND p.modeltype not in (1,2,3,6)\n" +
  15327. // chenxy 2019-10-02 半检返修 IsReworkFlag=2
  15328. //" AND p.IsReworkFlag <> '1' AND p.InScrapFlag <> '1' \n" +
  15329. " AND p.IsReworkFlag = '0' AND p.InScrapFlag = '0' \n" +
  15330. "";
  15331. Paras = new OracleParameter[] {
  15332. new OracleParameter(":barcode",OracleDbType.NVarchar2,
  15333. subbarcodes[i],ParameterDirection.Input),
  15334. new OracleParameter(":deleteduserid",OracleDbType.Int32,
  15335. sUserInfo.UserID,ParameterDirection.Input),
  15336. new OracleParameter(":deletedusercode",OracleDbType.NVarchar2,
  15337. sUserInfo.UserCode,ParameterDirection.Input),
  15338. };
  15339. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  15340. // 3 删除在产数据
  15341. // chenxy 2019-10-02 半检返修 IsReworkFlag=2
  15342. //sql = @" delete from tp_pm_inproduction p where p.barcode =:barcode AND p.modeltype not in (1,2,3,6) AND p.IsReworkFlag <> '1' AND p.InScrapFlag <> '1'";
  15343. sql = @" delete from tp_pm_inproduction p where p.barcode =:barcode AND p.modeltype not in (1,2,3,6) AND p.IsReworkFlag = '0' AND p.InScrapFlag = '0'";
  15344. Paras = new OracleParameter[] {
  15345. new OracleParameter(":barcode",OracleDbType.NVarchar2,
  15346. subbarcodes[i],ParameterDirection.Input),
  15347. };
  15348. returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  15349. if (returnRows > 0)
  15350. {
  15351. // 4. 删除在产生产数据
  15352. sql = @" delete from tp_pm_productiondatain p where p.barcode = :barcode";
  15353. Paras = new OracleParameter[] {
  15354. new OracleParameter(":barcode",OracleDbType.NVarchar2,
  15355. subbarcodes[i],ParameterDirection.Input),
  15356. };
  15357. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  15358. }
  15359. }
  15360. if (returnRows <= 0)
  15361. {
  15362. oracleTrConn.Rollback();
  15363. oracleTrConn.Disconnect();
  15364. }
  15365. else
  15366. {
  15367. oracleTrConn.Commit();
  15368. oracleTrConn.Disconnect();
  15369. }
  15370. }
  15371. catch (Exception ex)
  15372. {
  15373. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  15374. {
  15375. oracleTrConn.Rollback();
  15376. oracleTrConn.Disconnect();
  15377. }
  15378. throw ex;
  15379. }
  15380. finally
  15381. {
  15382. if (oracleTrConn.ConnState == ConnectionState.Open)
  15383. {
  15384. oracleTrConn.Disconnect();
  15385. }
  15386. }
  15387. return returnRows;
  15388. }
  15389. /// <summary>
  15390. /// 清除未盘点残留数据(根据条件进行选择)
  15391. /// </summary>
  15392. /// <param name="inCheckedID">盘点单ID</param>
  15393. /// <param name="procedureIDs">完成工序集</param>
  15394. /// <param name="goodsCodes">产品编码集</param>
  15395. /// <returns></returns>
  15396. public static int SaveClearInCheckedAll(int inCheckedID, string procedureIDs, string goodsCodes, DateTime? startDateTime, DateTime? endDateTime, SUserInfo sUserInfo)
  15397. {
  15398. int returnRows = 0;
  15399. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  15400. try
  15401. {
  15402. OracleParameter[] Paras = null;
  15403. string Insql = "";
  15404. // 1 查出根据条件进行未盘点数据
  15405. // 0.登窑、入窑、出窑工序的产品不能清除
  15406. Insql = @"select p.barcode from TP_PM_INCHECKEDDETAIL p "
  15407. + " inner join tp_pm_inproduction pin on pin.barcode = p.barcode and p.PROCEDUREID = pin.PROCEDUREID"
  15408. + " where p.INCHECKEDID=:InCheckedID and p.InCheckedFlag in ('0','9') and (pin.modeltype is null or pin.modeltype not in (1,2,3,6)) and pin.IsReworkFlag='0' and pin.InScrapFlag='0'";
  15409. if (!string.IsNullOrEmpty(procedureIDs))
  15410. {
  15411. Insql += " and p.PROCEDUREID in (" + procedureIDs + ")";
  15412. }
  15413. if (!string.IsNullOrEmpty(goodsCodes))
  15414. {
  15415. Insql += " and p.GoodsID in (" + goodsCodes + ")";
  15416. }
  15417. if (startDateTime != null)
  15418. {
  15419. Insql += Insql + " AND pin.ProcedureTime >= :Createdate AND pin.ProcedureTime <= :EndDate ";
  15420. Paras = new OracleParameter[] {
  15421. new OracleParameter(":InCheckedID",OracleDbType.Int32,inCheckedID,ParameterDirection.Input),
  15422. new OracleParameter(":Createdate", OracleDbType.Date, startDateTime, ParameterDirection.Input),
  15423. new OracleParameter(":EndDate", OracleDbType.Date, endDateTime, ParameterDirection.Input),
  15424. };
  15425. }
  15426. else
  15427. {
  15428. Paras = new OracleParameter[] {
  15429. new OracleParameter(":InCheckedID",OracleDbType.Int32,inCheckedID,ParameterDirection.Input),
  15430. };
  15431. }
  15432. string sql = "";
  15433. // 1.清除未盘点数据
  15434. sql = @"update TP_PM_INCHECKEDDETAIL p set p.INCHECKEDFLAG = '9' /*, p.valueflag='0'*/ where p.INCHECKEDID=:InCheckedID and p.barcode in (" + Insql + ") and p.InCheckedFlag='0'";
  15435. //Paras = new OracleParameter[] {
  15436. // new OracleParameter(":InCheckedID",OracleDbType.Int32,
  15437. // inCheckedID,ParameterDirection.Input)
  15438. // };
  15439. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  15440. // 2. 把在产数据插入到在产临时表中。(数据来源标识0:在产表)
  15441. sql = @"insert into tp_pm_inproduction_tmp
  15442. (
  15443. BARCODE,
  15444. PRODUCTIONLINEID,
  15445. PRODUCTIONLINECODE,
  15446. PRODUCTIONLINENAME,
  15447. PROCEDUREMODEL,
  15448. MODELTYPE,
  15449. REWORKPROCEDUREID,
  15450. ISPUBLICBODY,
  15451. GOODSID,
  15452. GOODSCODE,
  15453. GOODSNAME,
  15454. USERID,
  15455. GROUTINGDAILYID,
  15456. GROUTINGDAILYDETAILID,
  15457. GROUTINGDATE,
  15458. GROUTINGLINEID,
  15459. GROUTINGLINECODE,
  15460. GROUTINGLINENAME,
  15461. GMOULDTYPEID,
  15462. CANMANYTIMES,
  15463. GROUTINGLINEDETAILID,
  15464. GROUTINGMOULDCODE,
  15465. MOULDCODE,
  15466. REMARKS,
  15467. ACCOUNTID,
  15468. VALUEFLAG,
  15469. CREATETIME,
  15470. CREATEUSERID,
  15471. UPDATETIME,
  15472. UPDATEUSERID,
  15473. OPTIMESTAMP,
  15474. ISREFIRE,
  15475. GOODSLEVELID,
  15476. GOODSLEVELTYPEID,
  15477. DEFECTFLAG,
  15478. GROUTINGUSERID,
  15479. GROUTINGUSERCODE,
  15480. GROUTINGNUM,
  15481. KILNID,
  15482. KILNCODE,
  15483. KILNNAME,
  15484. KILNCARID,
  15485. KILNCARCODE,
  15486. KILNCARNAME,
  15487. KILNCARBATCHNO,
  15488. KILNCARPOSITION,
  15489. SPECIALREPAIRFLAG,
  15490. FLOWPROCEDUREID,
  15491. FLOWPROCEDURETIME,
  15492. PROCEDUREID,
  15493. PROCEDURETIME,
  15494. PRODUCTIONDATAID,
  15495. trashflag,
  15496. Deletedtime,
  15497. logoid,
  15498. IsReworkFlag,
  15499. SemiCheckID,
  15500. DELETEDUSERID,
  15501. DELETEDUSERCODE
  15502. )
  15503. select
  15504. BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME,
  15505. PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID,
  15506. ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME,
  15507. USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE,
  15508. GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID,
  15509. CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE,
  15510. REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME,
  15511. CREATEUSERID, UPDATETIME, UPDATEUSERID,optimestamp,
  15512. ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG,
  15513. GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM,
  15514. KILNID, KILNCODE, KILNNAME, KILNCARID,
  15515. KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID
  15516. ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,0,sysdate,logoid,ISREWORKFLAG,SEMICHECKID,"
  15517. + sUserInfo.UserID + ",'" + sUserInfo.UserCode +
  15518. "' from tp_pm_inproduction pp where pp.barcode in (" + Insql + ")";
  15519. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  15520. // 4. 删除在产生产数据
  15521. sql = @" delete from tp_pm_productiondatain pp where pp.barcode in(" + Insql + ")";
  15522. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  15523. // 3 删除在产数据
  15524. sql = @" delete from tp_pm_inproduction pp where pp.barcode in(" + Insql + ")";
  15525. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  15526. sql = @" update TP_PM_INCHECKEDDETAIL p set p.INCHECKEDFLAG = '3' where p.INCHECKEDFLAG='9' and p.InCheckedID=" + inCheckedID;
  15527. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  15528. if (returnRows == 0)
  15529. {
  15530. oracleTrConn.Rollback();
  15531. oracleTrConn.Disconnect();
  15532. }
  15533. else
  15534. {
  15535. oracleTrConn.Commit();
  15536. oracleTrConn.Disconnect();
  15537. }
  15538. }
  15539. catch (Exception ex)
  15540. {
  15541. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  15542. {
  15543. oracleTrConn.Rollback();
  15544. oracleTrConn.Disconnect();
  15545. }
  15546. throw ex;
  15547. }
  15548. finally
  15549. {
  15550. if (oracleTrConn.ConnState == ConnectionState.Open)
  15551. {
  15552. oracleTrConn.Disconnect();
  15553. }
  15554. }
  15555. return returnRows;
  15556. }
  15557. /// <summary>
  15558. /// 设置条码商标
  15559. /// </summary>
  15560. /// <returns></returns>
  15561. public static int SaveBarCodeLogo(string barcode, int logoid, SUserInfo sUserInfo)
  15562. {
  15563. int returnRows = 0;
  15564. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  15565. try
  15566. {
  15567. // 转换条码
  15568. string sqlString = @"select FUN_CMN_GetBarCode(:barcode,null,:accountid) From DUAL";
  15569. OracleParameter[] paras1 = new OracleParameter[]{
  15570. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  15571. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID,ParameterDirection.Input),
  15572. };
  15573. barcode = oracleTrConn.GetSqlResultToStr(sqlString, paras1);
  15574. OracleParameter[] Paras = null;
  15575. object oldLogoID = null;
  15576. object pid = null;
  15577. string sql = "";
  15578. //sql = @"select logoid from tp_pm_groutingdailydetail where barcode=:barcode";
  15579. //oldLogoID = oracleTrConn.GetSqlResultToObj(sql, new OracleParameter[]{
  15580. // new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input)
  15581. // });
  15582. sql = @"select g.logoid, f.fhuserid from tp_pm_groutingdailydetail g
  15583. left join tp_pm_finishedproduct f on g.barcode = f.barcode
  15584. where g.barcode=:barcode";
  15585. DataTable dt = oracleTrConn.GetSqlResultToDt(sql, new OracleParameter[]{
  15586. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input)
  15587. });
  15588. if (dt != null && dt.Rows.Count > 0)
  15589. {
  15590. oldLogoID = dt.Rows[0]["logoid"];
  15591. object fhuserid = dt.Rows[0]["fhuserid"];
  15592. if (oldLogoID == null || oldLogoID == DBNull.Value)
  15593. {
  15594. // 条码不存在
  15595. return -2;
  15596. }
  15597. if (fhuserid != null && fhuserid != DBNull.Value)
  15598. {
  15599. // "已交接的产品不能变更商标";
  15600. return -3;
  15601. }
  15602. }
  15603. // 1.更新注浆明细
  15604. sql = @"update tp_pm_groutingdailydetail set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode";
  15605. Paras = new OracleParameter[] {
  15606. new OracleParameter(":logoid",OracleDbType.Int32,
  15607. logoid,ParameterDirection.Input),
  15608. new OracleParameter(":updateuserid",OracleDbType.Int32,
  15609. sUserInfo.UserID,ParameterDirection.Input),
  15610. new OracleParameter(":barcode",OracleDbType.Varchar2,
  15611. barcode,ParameterDirection.Input)
  15612. };
  15613. returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  15614. // 2.在产产品
  15615. sql = @"update tp_pm_inproduction set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode";
  15616. //Paras = new OracleParameter[] {
  15617. // new OracleParameter(":logoid",OracleDbType.Int32,
  15618. // logoid,ParameterDirection.Input),
  15619. // new OracleParameter(":updateuserid",OracleDbType.Int32,
  15620. // sUserInfo.UserID,ParameterDirection.Input),
  15621. // new OracleParameter(":barcode",OracleDbType.Varchar2,
  15622. // barcode,ParameterDirection.Input)
  15623. // };
  15624. returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  15625. if (returnRows > 0)
  15626. {
  15627. sql = @"select ProcedureID from tp_pm_inproduction where barcode=:barcode";
  15628. pid = oracleTrConn.GetSqlResultToObj(sql, new OracleParameter[]{
  15629. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input)
  15630. });
  15631. }
  15632. // 3.在产回收站
  15633. sql = @"update tp_pm_inproductiontrash set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode";
  15634. //Paras = new OracleParameter[] {
  15635. // new OracleParameter(":logoid",OracleDbType.Int32,
  15636. // logoid,ParameterDirection.Input),
  15637. // new OracleParameter(":updateuserid",OracleDbType.Int32,
  15638. // sUserInfo.UserID,ParameterDirection.Input),
  15639. // new OracleParameter(":barcode",OracleDbType.Varchar2,
  15640. // barcode,ParameterDirection.Input)
  15641. // };
  15642. returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  15643. // 4.在产临时表
  15644. sql = @"update tp_pm_inproduction_tmp set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode";
  15645. //Paras = new OracleParameter[] {
  15646. // new OracleParameter(":logoid",OracleDbType.Int32,
  15647. // logoid,ParameterDirection.Input),
  15648. // new OracleParameter(":updateuserid",OracleDbType.Int32,
  15649. // sUserInfo.UserID,ParameterDirection.Input),
  15650. // new OracleParameter(":barcode",OracleDbType.Varchar2,
  15651. // barcode,ParameterDirection.Input)
  15652. // };
  15653. returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  15654. // 5.成品表
  15655. sql = @"update tp_pm_finishedproduct set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode";
  15656. //Paras = new OracleParameter[] {
  15657. // new OracleParameter(":logoid",OracleDbType.Int32,
  15658. // logoid,ParameterDirection.Input),
  15659. // new OracleParameter(":updateuserid",OracleDbType.Int32,
  15660. // sUserInfo.UserID,ParameterDirection.Input),
  15661. // new OracleParameter(":barcode",OracleDbType.Varchar2,
  15662. // barcode,ParameterDirection.Input)
  15663. // };
  15664. returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  15665. // 6 在产盘点明细
  15666. sql = @"update TP_PM_InCheckedDetail set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode";
  15667. //Paras = new OracleParameter[] {
  15668. // new OracleParameter(":logoid",OracleDbType.Int32,
  15669. // logoid,ParameterDirection.Input),
  15670. // new OracleParameter(":updateuserid",OracleDbType.Int32,
  15671. // sUserInfo.UserID,ParameterDirection.Input),
  15672. // new OracleParameter(":barcode",OracleDbType.Varchar2,
  15673. // barcode,ParameterDirection.Input)
  15674. // };
  15675. // ? returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  15676. // 7 半成品检验登记
  15677. sql = @"update TP_PM_SemiCheck set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode";
  15678. //Paras = new OracleParameter[] {
  15679. // new OracleParameter(":logoid",OracleDbType.Int32,
  15680. // logoid,ParameterDirection.Input),
  15681. // new OracleParameter(":updateuserid",OracleDbType.Int32,
  15682. // sUserInfo.UserID,ParameterDirection.Input),
  15683. // new OracleParameter(":barcode",OracleDbType.Varchar2,
  15684. // barcode,ParameterDirection.Input)
  15685. // };
  15686. // ? returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  15687. // 8 废弃产品
  15688. sql = @"update TP_PM_ScrapProduct set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode";
  15689. //Paras = new OracleParameter[] {
  15690. // new OracleParameter(":logoid",OracleDbType.Int32,
  15691. // logoid,ParameterDirection.Input),
  15692. // new OracleParameter(":updateuserid",OracleDbType.Int32,
  15693. // sUserInfo.UserID,ParameterDirection.Input),
  15694. // new OracleParameter(":barcode",OracleDbType.Varchar2,
  15695. // barcode,ParameterDirection.Input)
  15696. // };
  15697. // ? returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  15698. // 9 在产生产数据
  15699. sql = @"update TP_PM_ProductionDataIn set Triggerflag=1, logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode";
  15700. //Paras = new OracleParameter[] {
  15701. // new OracleParameter(":logoid",OracleDbType.Int32,
  15702. // logoid,ParameterDirection.Input),
  15703. // new OracleParameter(":updateuserid",OracleDbType.Int32,
  15704. // sUserInfo.UserID,ParameterDirection.Input),
  15705. // new OracleParameter(":barcode",OracleDbType.Varchar2,
  15706. // barcode,ParameterDirection.Input)
  15707. // };
  15708. // ? returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  15709. // 10 生产数据
  15710. sql = @"update TP_PM_ProductionData set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode";
  15711. //Paras = new OracleParameter[] {
  15712. // new OracleParameter(":logoid",OracleDbType.Int32,
  15713. // logoid,ParameterDirection.Input),
  15714. // new OracleParameter(":updateuserid",OracleDbType.Int32,
  15715. // sUserInfo.UserID,ParameterDirection.Input),
  15716. // new OracleParameter(":barcode",OracleDbType.Varchar2,
  15717. // barcode,ParameterDirection.Input)
  15718. // };
  15719. // ? returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  15720. // 变更履历
  15721. sql =
  15722. "INSERT INTO TP_PM_LOGOCHANGEDRECORD\n" +
  15723. " (BARCODE\n" +
  15724. " ,OLDLOGOID\n" +
  15725. " ,NEWLOGOID\n" +
  15726. " ,PROCEDUREID\n" +
  15727. " ,REMARKS\n" +
  15728. " ,ACCOUNTID\n" +
  15729. " ,CREATETIME\n" +
  15730. " ,CREATEUSERID)\n" +
  15731. "VALUES\n" +
  15732. " (:BARCODE\n" +
  15733. " ,:OLDLOGOID\n" +
  15734. " ,:NEWLOGOID\n" +
  15735. " ,:PROCEDUREID\n" +
  15736. " ,NULL\n" +
  15737. " ,:ACCOUNTID\n" +
  15738. " ,SYSDATE\n" +
  15739. " ,:CREATEUSERID)";
  15740. Paras = new OracleParameter[] {
  15741. new OracleParameter(":OLDLOGOID",OracleDbType.Int32,
  15742. oldLogoID,ParameterDirection.Input),
  15743. new OracleParameter(":NEWLOGOID",OracleDbType.Int32,
  15744. logoid,ParameterDirection.Input),
  15745. new OracleParameter(":PROCEDUREID",OracleDbType.Int32,
  15746. pid,ParameterDirection.Input),
  15747. new OracleParameter(":ACCOUNTID",OracleDbType.Int32,
  15748. sUserInfo.AccountID,ParameterDirection.Input),
  15749. new OracleParameter(":CREATEUSERID",OracleDbType.Int32,
  15750. sUserInfo.UserID,ParameterDirection.Input),
  15751. new OracleParameter(":BARCODE",OracleDbType.Varchar2,
  15752. barcode,ParameterDirection.Input)
  15753. };
  15754. returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  15755. //if (returnRows == 0)
  15756. //{
  15757. // oracleTrConn.Rollback();
  15758. // oracleTrConn.Disconnect();
  15759. //}
  15760. //else
  15761. {
  15762. oracleTrConn.Commit();
  15763. oracleTrConn.Disconnect();
  15764. }
  15765. }
  15766. catch (Exception ex)
  15767. {
  15768. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  15769. {
  15770. oracleTrConn.Rollback();
  15771. oracleTrConn.Disconnect();
  15772. }
  15773. throw ex;
  15774. }
  15775. return returnRows;
  15776. }
  15777. /// <summary>
  15778. /// 设置条码商标 釉料
  15779. /// </summary>
  15780. /// <returns></returns>
  15781. public static int SaveBarCodeLogoAndGlazetype(string barcode, int logoid, int glazetypeid,
  15782. SUserInfo sUserInfo)
  15783. {
  15784. int returnRows = 0;
  15785. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  15786. try
  15787. {
  15788. // 转换条码
  15789. //string sqlString = @"select FUN_CMN_GetBarCode(:barcode,null,:accountid) From DUAL";
  15790. //OracleParameter[] paras1 = new OracleParameter[]{
  15791. // new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  15792. // new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID,ParameterDirection.Input),
  15793. // };
  15794. //barcode = oracleTrConn.GetSqlResultToStr(sqlString, paras1);
  15795. OracleParameter[] Paras = null;
  15796. string sql = "select g.groutingdailydetailid, g.logoid, g.glazetypeid, t.PROCEDUREID from tp_pm_groutingdailydetail g \n" +
  15797. " left join tp_pm_inproduction t on t.barcode = g.barcode\n" +
  15798. "where g.barcode = :barcode";
  15799. Paras = new OracleParameter[] {
  15800. new OracleParameter(":barcode",OracleDbType.NVarchar2,
  15801. barcode,ParameterDirection.Input), };
  15802. DataTable dt = oracleTrConn.GetSqlResultToDt(sql, Paras);
  15803. if (dt == null || dt.Rows.Count == 0)
  15804. {
  15805. return -2;
  15806. }
  15807. // 釉料变更履历
  15808. sql = "insert into TP_PM_GlazetypeRecord\n" +
  15809. //"values\n" + xuwei update 2020-01-02
  15810. " (GROUTINGDAILYDETAILID\n" +
  15811. " ,OldGlazetypeid\n" +
  15812. " ,NewGlazetypeid\n" +
  15813. " ,ProcedureID\n" +
  15814. " ,Remarks\n" +
  15815. " ,AccountID\n" +
  15816. " ,CreateUserID)\n" +
  15817. "values\n" +
  15818. " (:GROUTINGDAILYDETAILID\n" +
  15819. " ,:OldGlazetypeid\n" +
  15820. " ,:NewGlazetypeid\n" +
  15821. " ,:ProcedureID\n" +
  15822. " ,:Remarks\n" +
  15823. " ,:AccountID\n" +
  15824. " ,:CreateUserID)";
  15825. Paras = new OracleParameter[] {
  15826. new OracleParameter(":GROUTINGDAILYDETAILID",OracleDbType.Int32,
  15827. dt.Rows[0]["GROUTINGDAILYDETAILID"],ParameterDirection.Input),
  15828. new OracleParameter(":OldGlazetypeid",OracleDbType.Int32,
  15829. dt.Rows[0]["glazetypeid"],ParameterDirection.Input),
  15830. new OracleParameter(":NewGlazetypeid",OracleDbType.Int32,
  15831. glazetypeid,ParameterDirection.Input),
  15832. new OracleParameter(":ProcedureID",OracleDbType.Int32,
  15833. dt.Rows[0]["PROCEDUREID"],ParameterDirection.Input),
  15834. new OracleParameter(":Remarks",OracleDbType.NVarchar2,
  15835. null,ParameterDirection.Input),
  15836. new OracleParameter(":AccountID",OracleDbType.Int32,
  15837. sUserInfo.AccountID,ParameterDirection.Input),
  15838. new OracleParameter(":CreateUserID",OracleDbType.Int32,
  15839. sUserInfo.UserID,ParameterDirection.Input),
  15840. };
  15841. returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  15842. // 变更履历
  15843. sql =
  15844. "INSERT INTO TP_PM_LOGOCHANGEDRECORD\n" +
  15845. " (BARCODE\n" +
  15846. " ,OLDLOGOID\n" +
  15847. " ,NEWLOGOID\n" +
  15848. //" ,PROCEDUREID\n" +
  15849. " ,REMARKS\n" +
  15850. " ,ACCOUNTID\n" +
  15851. " ,CREATETIME\n" +
  15852. " ,CREATEUSERID)\n" +
  15853. "VALUES\n" +
  15854. " (:BARCODE\n" +
  15855. " ,:OLDLOGOID\n" +
  15856. " ,:NEWLOGOID\n" +
  15857. //" ,:PROCEDUREID\n" +
  15858. " ,NULL\n" +
  15859. " ,:ACCOUNTID\n" +
  15860. " ,SYSDATE\n" +
  15861. " ,:CREATEUSERID)";
  15862. Paras = new OracleParameter[] {
  15863. new OracleParameter(":OLDLOGOID",OracleDbType.Int32,
  15864. dt.Rows[0]["LOGOID"],ParameterDirection.Input),
  15865. new OracleParameter(":NEWLOGOID",OracleDbType.Int32,
  15866. logoid,ParameterDirection.Input),
  15867. //new OracleParameter(":PROCEDUREID",OracleDbType.Int32,
  15868. // pid,ParameterDirection.Input),
  15869. new OracleParameter(":ACCOUNTID",OracleDbType.Int32,
  15870. sUserInfo.AccountID,ParameterDirection.Input),
  15871. new OracleParameter(":CREATEUSERID",OracleDbType.Int32,
  15872. sUserInfo.UserID,ParameterDirection.Input),
  15873. new OracleParameter(":BARCODE",OracleDbType.Varchar2,
  15874. barcode,ParameterDirection.Input)
  15875. };
  15876. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  15877. // 1.更新注浆明细
  15878. sql = "update tp_pm_groutingdailydetail set logoid=:logoid, glazetypeid =:glazetypeid, updateuserid=:updateuserid where barcode=:barcode";
  15879. Paras = new OracleParameter[] {
  15880. new OracleParameter(":logoid",OracleDbType.Int32,
  15881. logoid,ParameterDirection.Input),
  15882. new OracleParameter(":glazetypeid",OracleDbType.Int32,
  15883. glazetypeid,ParameterDirection.Input),
  15884. new OracleParameter(":updateuserid",OracleDbType.Int32,
  15885. sUserInfo.UserID,ParameterDirection.Input),
  15886. new OracleParameter(":barcode",OracleDbType.Varchar2,
  15887. barcode,ParameterDirection.Input)
  15888. };
  15889. returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  15890. // 1.更新在产
  15891. sql = @"update TP_PM_INPRODUCTION set logoid=:logoid,
  15892. --glazetypeid =:glazetypeid,
  15893. updateuserid=:updateuserid where barcode=:barcode";
  15894. Paras = new OracleParameter[] {
  15895. new OracleParameter(":logoid",OracleDbType.Int32,
  15896. logoid,ParameterDirection.Input),
  15897. //new OracleParameter(":glazetypeid",OracleDbType.Int32,
  15898. // glazetypeid,ParameterDirection.Input),
  15899. new OracleParameter(":updateuserid",OracleDbType.Int32,
  15900. sUserInfo.UserID,ParameterDirection.Input),
  15901. new OracleParameter(":barcode",OracleDbType.Varchar2,
  15902. barcode,ParameterDirection.Input)
  15903. };
  15904. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  15905. oracleTrConn.Commit();
  15906. }
  15907. catch (Exception ex)
  15908. {
  15909. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  15910. {
  15911. oracleTrConn.Rollback();
  15912. }
  15913. throw ex;
  15914. }
  15915. finally { oracleTrConn.Disconnect(); }
  15916. return returnRows;
  15917. }
  15918. /// <summary>
  15919. /// 设置条码商标 釉料
  15920. /// </summary>
  15921. /// <returns></returns>
  15922. public static int SaveBarCodesLogoAndGlazetype(string barcodesstr, int logoid, int glazetypeid,
  15923. int procedureID, SUserInfo sUserInfo)
  15924. {
  15925. int returnRows = 0;
  15926. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  15927. try
  15928. {
  15929. OracleParameter[] Paras = null;
  15930. string sql = "select g.groutingdailydetailid, g.logoid, g.glazetypeid, t.PROCEDUREID from tp_pm_groutingdailydetail g \n" +
  15931. " left join tp_pm_inproduction t on t.barcode = g.barcode\n" +
  15932. "where g.barcode = :barcode";
  15933. string sql0 = "select g.groutingdailydetailid, g.logoid, g.glazetypeid from tp_pm_groutingdailydetail g \n" +
  15934. "where g.barcode = :barcode";
  15935. // 釉料变更履历
  15936. string sql1 = "insert into TP_PM_GlazetypeRecord\n" +
  15937. //"values\n" + xuwei update 2020-01-02
  15938. " (GROUTINGDAILYDETAILID\n" +
  15939. " ,OldGlazetypeid\n" +
  15940. " ,NewGlazetypeid\n" +
  15941. " ,ProcedureID\n" +
  15942. " ,Remarks\n" +
  15943. " ,AccountID\n" +
  15944. " ,CreateUserID)\n" +
  15945. "values\n" +
  15946. " (:GROUTINGDAILYDETAILID\n" +
  15947. " ,:OldGlazetypeid\n" +
  15948. " ,:NewGlazetypeid\n" +
  15949. " ,:ProcedureID\n" +
  15950. " ,:Remarks\n" +
  15951. " ,:AccountID\n" +
  15952. " ,:CreateUserID)";
  15953. // 变更履历
  15954. string sqllogo =
  15955. "INSERT INTO TP_PM_LOGOCHANGEDRECORD\n" +
  15956. " (BARCODE\n" +
  15957. " ,OLDLOGOID\n" +
  15958. " ,NEWLOGOID\n" +
  15959. //" ,PROCEDUREID\n" +
  15960. " ,REMARKS\n" +
  15961. " ,ACCOUNTID\n" +
  15962. " ,CREATETIME\n" +
  15963. " ,CREATEUSERID)\n" +
  15964. "VALUES\n" +
  15965. " (:BARCODE\n" +
  15966. " ,:OLDLOGOID\n" +
  15967. " ,:NEWLOGOID\n" +
  15968. //" ,:PROCEDUREID\n" +
  15969. " ,NULL\n" +
  15970. " ,:ACCOUNTID\n" +
  15971. " ,SYSDATE\n" +
  15972. " ,:CREATEUSERID)";
  15973. string sql2 = "update tp_pm_groutingdailydetail set logoid=:logoid, glazetypeid =:glazetypeid, updateuserid=:updateuserid where barcode=:barcode";
  15974. // 1.更新在产
  15975. string sqlin = @"update TP_PM_INPRODUCTION set logoid=:logoid,
  15976. --glazetypeid =:glazetypeid,
  15977. updateuserid=:updateuserid where barcode=:barcode";
  15978. //xuwei add 2020-01-02
  15979. string[] barcodes = barcodesstr.Split(',');
  15980. foreach (string barcode in barcodes)
  15981. {
  15982. Paras = new OracleParameter[] {
  15983. new OracleParameter(":barcode",OracleDbType.NVarchar2,
  15984. barcode,ParameterDirection.Input), };
  15985. DataTable dt = null;
  15986. if (procedureID > 0)
  15987. {
  15988. dt = oracleTrConn.GetSqlResultToDt(sql0, Paras);
  15989. }
  15990. else
  15991. {
  15992. dt = oracleTrConn.GetSqlResultToDt(sql, Paras);
  15993. }
  15994. if (dt == null || dt.Rows.Count == 0)
  15995. {
  15996. //continue;
  15997. return -2;
  15998. }
  15999. Paras = new OracleParameter[] {
  16000. new OracleParameter(":GROUTINGDAILYDETAILID",OracleDbType.Int32,
  16001. dt.Rows[0]["GROUTINGDAILYDETAILID"],ParameterDirection.Input),
  16002. new OracleParameter(":OldGlazetypeid",OracleDbType.Int32,
  16003. dt.Rows[0]["glazetypeid"],ParameterDirection.Input),
  16004. new OracleParameter(":NewGlazetypeid",OracleDbType.Int32,
  16005. glazetypeid,ParameterDirection.Input),
  16006. new OracleParameter(":ProcedureID",OracleDbType.Int32,
  16007. (procedureID > 0 ? procedureID : dt.Rows[0]["PROCEDUREID"]),ParameterDirection.Input),
  16008. new OracleParameter(":Remarks",OracleDbType.NVarchar2,
  16009. null,ParameterDirection.Input),
  16010. new OracleParameter(":AccountID",OracleDbType.Int32,
  16011. sUserInfo.AccountID,ParameterDirection.Input),
  16012. new OracleParameter(":CreateUserID",OracleDbType.Int32,
  16013. sUserInfo.UserID,ParameterDirection.Input),
  16014. };
  16015. oracleTrConn.ExecuteNonQuery(sql1, Paras);
  16016. // 商标履历
  16017. Paras = new OracleParameter[] {
  16018. new OracleParameter(":OLDLOGOID",OracleDbType.Int32,
  16019. dt.Rows[0]["LOGOID"],ParameterDirection.Input),
  16020. new OracleParameter(":NEWLOGOID",OracleDbType.Int32,
  16021. logoid,ParameterDirection.Input),
  16022. //new OracleParameter(":PROCEDUREID",OracleDbType.Int32,
  16023. // pid,ParameterDirection.Input),
  16024. new OracleParameter(":ACCOUNTID",OracleDbType.Int32,
  16025. sUserInfo.AccountID,ParameterDirection.Input),
  16026. new OracleParameter(":CREATEUSERID",OracleDbType.Int32,
  16027. sUserInfo.UserID,ParameterDirection.Input),
  16028. new OracleParameter(":BARCODE",OracleDbType.Varchar2,
  16029. barcode,ParameterDirection.Input)
  16030. };
  16031. returnRows += oracleTrConn.ExecuteNonQuery(sqllogo, Paras);
  16032. // 1.更新注浆明细
  16033. Paras = new OracleParameter[] {
  16034. new OracleParameter(":logoid",OracleDbType.Int32,
  16035. logoid,ParameterDirection.Input),
  16036. new OracleParameter(":glazetypeid",OracleDbType.Int32,
  16037. glazetypeid,ParameterDirection.Input),
  16038. new OracleParameter(":updateuserid",OracleDbType.Int32,
  16039. sUserInfo.UserID,ParameterDirection.Input),
  16040. new OracleParameter(":barcode",OracleDbType.Varchar2,
  16041. barcode,ParameterDirection.Input)
  16042. };
  16043. returnRows += oracleTrConn.ExecuteNonQuery(sql2, Paras);
  16044. // 1.更新在产
  16045. Paras = new OracleParameter[] {
  16046. new OracleParameter(":logoid",OracleDbType.Int32,
  16047. logoid,ParameterDirection.Input),
  16048. //new OracleParameter(":glazetypeid",OracleDbType.Int32,
  16049. // glazetypeid,ParameterDirection.Input),
  16050. new OracleParameter(":updateuserid",OracleDbType.Int32,
  16051. sUserInfo.UserID,ParameterDirection.Input),
  16052. new OracleParameter(":barcode",OracleDbType.Varchar2,
  16053. barcode,ParameterDirection.Input)
  16054. };
  16055. returnRows = oracleTrConn.ExecuteNonQuery(sqlin, Paras);
  16056. }
  16057. oracleTrConn.Commit();
  16058. }
  16059. catch (Exception ex)
  16060. {
  16061. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  16062. {
  16063. oracleTrConn.Rollback();
  16064. }
  16065. throw ex;
  16066. }
  16067. finally { oracleTrConn.Disconnect(); }
  16068. return returnRows;
  16069. }
  16070. /// <summary>
  16071. /// 设置产成品商标
  16072. /// </summary>
  16073. /// <param name="barcodes"></param>
  16074. /// <param name="logoid"></param>
  16075. /// <param name="sUserInfo"></param>
  16076. /// <returns></returns>
  16077. public static int SetFinishedLogo(string[] barcodes, int logoid, SUserInfo sUserInfo)
  16078. {
  16079. int returnRows = 0;
  16080. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  16081. try
  16082. {
  16083. OracleParameter[] Paras = null;
  16084. object oldLogoID = null;
  16085. object gdid = null;
  16086. //object pid = null;
  16087. string sql = "";
  16088. DataTable dataTable = null;
  16089. foreach (string barcode in barcodes)
  16090. {
  16091. sql = @"select groutingdailydetailid, logoid from tp_pm_groutingdailydetail where barcode=:barcode";
  16092. dataTable = oracleTrConn.GetSqlResultToDt(sql, new OracleParameter[]{
  16093. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input)
  16094. });
  16095. if (dataTable == null || dataTable.Rows.Count == 0)
  16096. {
  16097. continue;
  16098. }
  16099. gdid = dataTable.Rows[0]["groutingdailydetailid"];
  16100. oldLogoID = dataTable.Rows[0]["logoid"];
  16101. // 1.更新注浆明细
  16102. sql = @"update tp_pm_groutingdailydetail set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode";
  16103. Paras = new OracleParameter[] {
  16104. new OracleParameter(":logoid",OracleDbType.Int32,
  16105. logoid,ParameterDirection.Input),
  16106. new OracleParameter(":updateuserid",OracleDbType.Int32,
  16107. sUserInfo.UserID,ParameterDirection.Input),
  16108. new OracleParameter(":barcode",OracleDbType.Varchar2,
  16109. barcode,ParameterDirection.Input)
  16110. };
  16111. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  16112. // 5.成品表
  16113. sql = @"update tp_pm_finishedproduct set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode";
  16114. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  16115. // 变更履历
  16116. sql =
  16117. "INSERT INTO TP_PM_LOGOCHANGEDRECORD\n" +
  16118. " (BARCODE\n" +
  16119. " ,OLDLOGOID\n" +
  16120. " ,NEWLOGOID\n" +
  16121. //" ,PROCEDUREID\n" +
  16122. " ,REMARKS\n" +
  16123. " ,ACCOUNTID\n" +
  16124. " ,CREATETIME\n" +
  16125. " ,CREATEUSERID)\n" +
  16126. "VALUES\n" +
  16127. " (:BARCODE\n" +
  16128. " ,:OLDLOGOID\n" +
  16129. " ,:NEWLOGOID\n" +
  16130. //" ,:PROCEDUREID\n" +
  16131. " ,NULL\n" +
  16132. " ,:ACCOUNTID\n" +
  16133. " ,SYSDATE\n" +
  16134. " ,:CREATEUSERID)";
  16135. Paras = new OracleParameter[] {
  16136. new OracleParameter(":OLDLOGOID",OracleDbType.Int32,
  16137. oldLogoID,ParameterDirection.Input),
  16138. new OracleParameter(":NEWLOGOID",OracleDbType.Int32,
  16139. logoid,ParameterDirection.Input),
  16140. //new OracleParameter(":PROCEDUREID",OracleDbType.Int32,
  16141. // pid,ParameterDirection.Input),
  16142. new OracleParameter(":ACCOUNTID",OracleDbType.Int32,
  16143. sUserInfo.AccountID,ParameterDirection.Input),
  16144. new OracleParameter(":CREATEUSERID",OracleDbType.Int32,
  16145. sUserInfo.UserID,ParameterDirection.Input),
  16146. new OracleParameter(":BARCODE",OracleDbType.Varchar2,
  16147. barcode,ParameterDirection.Input)
  16148. };
  16149. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  16150. }
  16151. //if (returnRows == 0)
  16152. //{
  16153. // oracleTrConn.Rollback();
  16154. // oracleTrConn.Disconnect();
  16155. //}
  16156. //else
  16157. {
  16158. oracleTrConn.Commit();
  16159. oracleTrConn.Disconnect();
  16160. }
  16161. }
  16162. catch (Exception ex)
  16163. {
  16164. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  16165. {
  16166. oracleTrConn.Rollback();
  16167. oracleTrConn.Disconnect();
  16168. }
  16169. throw ex;
  16170. }
  16171. return returnRows;
  16172. }
  16173. /// <summary>
  16174. /// 设置产成品订单
  16175. /// </summary>
  16176. /// <param name="barcodes"></param>
  16177. /// <param name="orderid"></param>
  16178. /// <param name="sUserInfo"></param>
  16179. /// <returns></returns>
  16180. public static int SetHandoveredOrder(string[] barcodes, int orderID, SUserInfo sUserInfo)
  16181. {
  16182. int returnRows = 0;
  16183. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  16184. try
  16185. {
  16186. string sql = @"update tp_pm_finishedproduct set FHOrderID=:FHOrderID,updateuserid=:updateuserid where barcode=:barcode and FHOrderID is not null";
  16187. OracleParameter[] Paras = new OracleParameter[] {
  16188. new OracleParameter(":barcode",OracleDbType.Varchar2,
  16189. "",ParameterDirection.Input),
  16190. new OracleParameter(":FHOrderID",OracleDbType.Int32,
  16191. orderID,ParameterDirection.Input),
  16192. new OracleParameter(":updateuserid",OracleDbType.Int32,
  16193. sUserInfo.UserID,ParameterDirection.Input)
  16194. };
  16195. foreach (string barcode in barcodes)
  16196. {
  16197. Paras[0].Value = barcode;
  16198. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  16199. }
  16200. oracleTrConn.Commit();
  16201. oracleTrConn.Disconnect();
  16202. }
  16203. catch (Exception ex)
  16204. {
  16205. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  16206. {
  16207. oracleTrConn.Rollback();
  16208. oracleTrConn.Disconnect();
  16209. }
  16210. throw ex;
  16211. }
  16212. return returnRows;
  16213. }
  16214. #endregion
  16215. /// <summary>
  16216. /// 添加生产数据
  16217. /// </summary>
  16218. /// <param name="oracleTrConn">连接对象</param>
  16219. /// <param name="accountDate">账务日期</param>
  16220. /// <param name="productionData">生产数据</param>
  16221. /// <param name="sUserInfo">用户基本信息</param>
  16222. /// <returns>string</returns>
  16223. /// <remarks>
  16224. /// 陈冰 2014.09.18 新建
  16225. /// </remarks>
  16226. private static string AddProductionDataWaster(IDBTransaction oracleTrConn, DateTime accountDate, ProductionDataEntity productionData, SUserInfo sUserInfo, out string OutSpecialRepairflag)
  16227. {
  16228. #region 查出产品注浆日期,注浆工号ID,注浆工号编码,注浆次数,注浆模具编号,模具编号
  16229. string selectSql = "";
  16230. string returnVal = "";
  16231. //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的
  16232. //xuwei fix 2019-09-26 使用通用方法判定
  16233. // 2019-1016
  16234. //int isNodeBegin = IsNodeBegin<IDBTransaction>(oracleTrConn, productionData.Barcode);
  16235. //if (isNodeBegin == 1) productionData.NodeType = (int)Constant.ProcedureNodeType.Begin;
  16236. if (productionData.NodeType == (int)Constant.ProcedureNodeType.Begin)
  16237. {
  16238. int isNodeBegin = IsNodeBegin<IDBTransaction>(oracleTrConn, productionData.Barcode);
  16239. if (isNodeBegin == 0)
  16240. {
  16241. productionData.NodeType = (int)Constant.ProcedureNodeType.Middle;
  16242. }
  16243. }
  16244. if (productionData.NodeType == (int)Constant.ProcedureNodeType.Begin)//开始节点时从注浆登记取值
  16245. {
  16246. selectSql = @"select TP_PM_GroutingDailyDetail.GroutingDate,
  16247. TP_PM_GroutingDailyDetail.UserID as GroutingUserID,
  16248. TP_PM_GroutingDailyDetail.UserCode as GroutingUserCode,
  16249. TP_PM_GroutingDailyDetail.GroutingCount as GroutingNum,
  16250. TP_PM_GroutingDailyDetail.GroutingMouldCode,
  16251. TP_PM_GroutingDailyDetail.MouldCode,
  16252. TP_PM_GroutingDailyDetail.GroutingDailyID,
  16253. TP_PM_GroutingDailyDetail.GroutingDailyDetailID,
  16254. TP_PM_GroutingDailyDetail.GroutingLineID,
  16255. TP_PM_GroutingDailyDetail.GroutingLineCode,
  16256. TP_PM_GroutingDailyDetail.GroutingLineName,
  16257. TP_PM_GroutingDailyDetail.GroutingLineDetailID,
  16258. TP_PM_GroutingDailyDetail.SpecialRepairflag,
  16259. (select GMouldTypeID
  16260. from TP_PM_GroutingDaily
  16261. where TP_PM_GroutingDaily.GroutingDailyID =
  16262. TP_PM_GroutingDailyDetail.GroutingDailyID) as GMouldTypeID,
  16263. (select CanManyTimes
  16264. from TP_PM_GroutingDaily
  16265. where TP_PM_GroutingDaily.GroutingDailyID =
  16266. TP_PM_GroutingDailyDetail.GroutingDailyID) as CanManyTimes,
  16267. 0 as IsReFire
  16268. from TP_PM_GroutingDailyDetail
  16269. where TP_PM_GroutingDailyDetail.barcode=:barcode";
  16270. }
  16271. else
  16272. {
  16273. selectSql = @"select
  16274. GroutingDate,
  16275. userid as GroutingUserID,
  16276. usercode as GroutingUserCode,
  16277. Groutingcount as GroutingNum,
  16278. GroutingMouldCode,
  16279. MouldCode,
  16280. GroutingDailyID,
  16281. GroutingDailyDetailID,
  16282. GroutingLineID,
  16283. GroutingLineCode,
  16284. GroutingLineName,
  16285. GMouldTypeID,
  16286. CanManyTimes,
  16287. GroutingLineDetailID,
  16288. SpecialRepairflag,
  16289. 0 as IsReFire,
  16290. logoid
  16291. from TP_PM_GroutingDailyDetail where barcode=:barcode
  16292. ";
  16293. }
  16294. OracleParameter[] selectparas = new OracleParameter[] {
  16295. new OracleParameter(":barcode",productionData.Barcode),
  16296. };
  16297. DataSet dsGroutingProduct = oracleTrConn.GetSqlResultToDs(selectSql, selectparas);
  16298. DateTime GroutingDate = new DateTime();
  16299. int GroutingUserID = 0, GroutingNum = 0, GroutingDailyID = 0, GroutingDailyDetailID = 0, GroutingLineID = 0, GMouldTypeID = 0, CanManyTimes = 0, GroutingLineDetailID = 0, SpecialRepairflag = 0;
  16300. string GroutingUserCode = "", GroutingMouldCode = "", MouldCode = "", GroutingLineCode = "", GroutingLineName = "";
  16301. int IsReFire = 0;
  16302. int? logoID = null;
  16303. if (dsGroutingProduct != null && dsGroutingProduct.Tables[0].Rows.Count > 0)
  16304. {
  16305. GroutingDate = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
  16306. GroutingUserID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingUserID"]);
  16307. GroutingUserCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"].ToString();
  16308. GroutingNum = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"]);
  16309. GroutingMouldCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingMouldCode"].ToString();
  16310. MouldCode = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"].ToString();
  16311. GroutingDailyID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyID"]);
  16312. GroutingDailyDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyDetailID"]);
  16313. GroutingLineID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineID"]);
  16314. GroutingLineCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineCode"].ToString();
  16315. GroutingLineName = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineName"].ToString();
  16316. GMouldTypeID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GMouldTypeID"]);
  16317. CanManyTimes = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["CanManyTimes"]);
  16318. GroutingLineDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineDetailID"]);
  16319. SpecialRepairflag = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["SpecialRepairflag"]);
  16320. IsReFire = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["IsReFire"]);
  16321. if (IsReFire > 0) //大于零代表重烧过
  16322. {
  16323. productionData.IsReFire = IsReFire;
  16324. productionData.DefectFlag = (int)Constant.GoodsLevelType.Defect;
  16325. }
  16326. if (dsGroutingProduct.Tables[0].Rows[0]["logoID"].ToString() != "")
  16327. {
  16328. logoID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["logoID"]);
  16329. }
  16330. //if (productionData.LogoID != null) //当前工序有商标
  16331. //{
  16332. // if (logoID != productionData.LogoID && productionData.LogoID != 0)
  16333. // {
  16334. // logoID = productionData.LogoID;
  16335. // //根据明细ID.update
  16336. // selectSql = "update TP_PM_GroutingDailyDetail set logoid=:logoid where GroutingDailyDetailID=" + GroutingDailyDetailID;
  16337. // OracleParameter[] paras2 = new OracleParameter[] {
  16338. // new OracleParameter(":logoid",productionData.LogoID)
  16339. // };
  16340. // oracleTrConn.ExecuteNonQuery(selectSql, paras2);
  16341. // }
  16342. //}
  16343. returnVal = SpecialRepairflag.ToString();
  16344. }
  16345. #endregion
  16346. #region 更新窑炉窑车属性
  16347. if (productionData.ModelType != 1 && productionData.ModelType != 2 && productionData.ModelType != 3 && productionData.ModelType != 4)
  16348. {
  16349. DataSet ds = GetKilnCarInfo(oracleTrConn, productionData.Barcode, sUserInfo);
  16350. if (ds != null)
  16351. {
  16352. if (ds.Tables[0].Rows[0]["KilnID"].ToString() != "") //表示以前有过窑炉相关信息
  16353. {
  16354. productionData.KilnID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnID"]);
  16355. productionData.KilnCode = ds.Tables[0].Rows[0]["KilnCode"].ToString();
  16356. productionData.KilnName = ds.Tables[0].Rows[0]["KilnName"].ToString();
  16357. productionData.KilnCarID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarID"]);
  16358. productionData.KilnCarCode = ds.Tables[0].Rows[0]["KilnCarCode"].ToString();
  16359. productionData.KilnCarName = ds.Tables[0].Rows[0]["KilnCarName"].ToString();
  16360. productionData.KilnCarBatchNo = ds.Tables[0].Rows[0]["KilnCarBatchNo"].ToString();
  16361. productionData.KilnCarPosition = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarPosition"]);
  16362. }
  16363. }
  16364. }
  16365. #endregion
  16366. #region SQL
  16367. string sql = "insert into tp_pm_productiondataIn"
  16368. + " (productiondataid,"
  16369. + " barcode,"
  16370. + " centralizedbatchno,"
  16371. + " productionlineid,"
  16372. + " productionlinecode,"
  16373. + " productionlinename,"
  16374. + " procedureid,"
  16375. + " procedurecode,"
  16376. + " procedurename,"
  16377. + " proceduremodel,"
  16378. + " modeltype,"
  16379. + " piecetype,"
  16380. + " isreworked,"
  16381. + " nodetype,"
  16382. + " ispublicbody,"
  16383. + " isrefire,"
  16384. + " organizationid,"
  16385. + " goodsid,"
  16386. + " goodscode,"
  16387. + " goodsname,"
  16388. + " userid,"
  16389. + " usercode,"
  16390. + " username,"
  16391. + " kilnid,"
  16392. + " kilncode,"
  16393. + " kilnname,"
  16394. + " kilncarid,"
  16395. + " kilncarcode,"
  16396. + " kilncarname,"
  16397. + " kilncarbatchno,"
  16398. + " kilncarposition,"
  16399. + " reworkprocedureid,"
  16400. + " reworkprocedurecode,"
  16401. + " reworkprocedurename,"
  16402. + " remarks,"
  16403. + " accountdate,"
  16404. + " accountid,"
  16405. + " GoodsLevelID,"
  16406. + " GoodsLevelTypeID,"
  16407. + " createuserid,"
  16408. + " updateuserid,"
  16409. + " GroutingDate,"
  16410. + " GroutingUserID,"
  16411. + " GroutingUserCode,"
  16412. + " GroutingNum,"
  16413. + " GroutingMouldCode,"
  16414. + " MouldCode,"
  16415. + "GroutingDailyID,"
  16416. + "GroutingDailyDetailID,"
  16417. + "GroutingLineID,"
  16418. + " GroutingLineCode,"
  16419. + "GroutingLineName,"
  16420. + "GMouldTypeID,"
  16421. + "CanManyTimes,"
  16422. + "GroutingLineDetailID,"
  16423. + "SpecialRepairflag,"
  16424. + "ClassesSettingID,"
  16425. + "LogoID"
  16426. + ")"
  16427. + " values"
  16428. + " (:productiondataid,"
  16429. + " :barcode,"
  16430. + " :centralizedbatchno,"
  16431. + " :productionlineid,"
  16432. + " :productionlinecode,"
  16433. + " :productionlinename,"
  16434. + " :procedureid,"
  16435. + " :procedurecode,"
  16436. + " :procedurename,"
  16437. + " :proceduremodel,"
  16438. + " :modeltype,"
  16439. + " :piecetype,"
  16440. + " :isreworked,"
  16441. + " :nodetype,"
  16442. + " :ispublicbody,"
  16443. + " :isrefire,"
  16444. + " :organizationid,"
  16445. + " :goodsid,"
  16446. + " :goodscode,"
  16447. + " :goodsname,"
  16448. + " :userid,"
  16449. + " :usercode,"
  16450. + " :username,"
  16451. + " :kilnid,"
  16452. + " :kilncode,"
  16453. + " :kilnname,"
  16454. + " :kilncarid,"
  16455. + " :kilncarcode,"
  16456. + " :kilncarname,"
  16457. + " :kilncarbatchno,"
  16458. + " :kilncarposition,"
  16459. + " :reworkprocedureid,"
  16460. + " :reworkprocedurecode,"
  16461. + " :reworkprocedurename,"
  16462. + " :remarks,"
  16463. + " :accountdata,"
  16464. + " :accountid,"
  16465. + " :GoodsLevelID,"
  16466. + " :GoodsLevelTypeID,"
  16467. + " :createuserid,"
  16468. + " :updateuserid,"
  16469. + " :groutingdate,"
  16470. + " :groutinguserid,"
  16471. + " :groutingusercode,"
  16472. + " :groutingnum,"
  16473. + " :groutingmouldcode,"
  16474. + " :mouldcode,"
  16475. + ":groutingdailyid,"
  16476. + ":groutingdailydetailid,"
  16477. + ":groutinglineid,"
  16478. + " :groutinglinecode,"
  16479. + ":groutinglinename,"
  16480. + ":gmouldtypeid,"
  16481. + ":canmanytimes,"
  16482. + ":groutinglinedetailid,"
  16483. + ":specialRepairflag,"
  16484. + ":classesSettingID,"
  16485. + ":logoID"
  16486. + ")";
  16487. #endregion
  16488. #region OracleParameter
  16489. OracleParameter[] paras = new OracleParameter[] {
  16490. new OracleParameter(":classesSettingID",productionData.ClassesSettingID),
  16491. new OracleParameter(":productiondataid",productionData.ProductionDataID),
  16492. new OracleParameter(":barcode",productionData.Barcode),
  16493. new OracleParameter(":centralizedbatchno",productionData.CentralizedBatchNo),
  16494. new OracleParameter(":productionlineid",productionData.ProductionLineID),
  16495. new OracleParameter(":productionlinecode",productionData.ProductionLineCode),
  16496. new OracleParameter(":productionlinename",productionData.ProductionLineName),
  16497. new OracleParameter(":procedureid",productionData.ProcedureID),
  16498. new OracleParameter(":procedurecode",productionData.ProcedureCode),
  16499. new OracleParameter(":procedurename",productionData.ProcedureName),
  16500. new OracleParameter(":proceduremodel",productionData.ProcedureModel),
  16501. new OracleParameter(":modeltype",productionData.ModelType),
  16502. new OracleParameter(":piecetype",productionData.PieceType),
  16503. new OracleParameter(":isreworked",productionData.IsReworked),
  16504. new OracleParameter(":nodetype",productionData.NodeType),
  16505. new OracleParameter(":ispublicbody",productionData.IsPublicBody),
  16506. new OracleParameter(":isrefire",productionData.IsReFire),
  16507. new OracleParameter(":organizationid",productionData.OrganizationID),
  16508. new OracleParameter(":goodsid",productionData.GoodsID),
  16509. new OracleParameter(":goodscode",productionData.GoodsCode),
  16510. new OracleParameter(":goodsname",productionData.GoodsName),
  16511. new OracleParameter(":userid",productionData.UserID),
  16512. new OracleParameter(":usercode",productionData.UserCode),
  16513. new OracleParameter(":username",productionData.UserName),
  16514. new OracleParameter(":kilnid",productionData.KilnID),
  16515. new OracleParameter(":kilncode",productionData.KilnCode),
  16516. new OracleParameter(":kilnname",productionData.KilnName),
  16517. new OracleParameter(":kilncarid",productionData.KilnCarID),
  16518. new OracleParameter(":kilncarcode",productionData.KilnCarCode),
  16519. new OracleParameter(":kilncarname",productionData.KilnCarName),
  16520. new OracleParameter(":kilncarbatchno",productionData.KilnCarBatchNo),
  16521. new OracleParameter(":kilncarposition",productionData.KilnCarPosition),
  16522. new OracleParameter(":reworkprocedureid",productionData.ReworkProcedureID),
  16523. new OracleParameter(":reworkprocedurecode",productionData.ReworkProcedureCode),
  16524. new OracleParameter(":reworkprocedurename",productionData.ReworkProcedureName),
  16525. new OracleParameter(":remarks",productionData.Remarks),
  16526. new OracleParameter(":accountdata",accountDate),
  16527. new OracleParameter(":accountid",sUserInfo.AccountID),
  16528. new OracleParameter(":GoodsLevelID",productionData.GoodsLevelID),
  16529. new OracleParameter(":GoodsLevelTypeID",productionData.GoodsLevelTypeID),
  16530. new OracleParameter(":createuserid",sUserInfo.UserID),
  16531. new OracleParameter(":updateuserid",sUserInfo.UserID),
  16532. new OracleParameter(":groutingdate",GroutingDate),
  16533. new OracleParameter(":groutinguserid",GroutingUserID),
  16534. new OracleParameter(":groutingusercode",GroutingUserCode),
  16535. new OracleParameter(":groutingnum",GroutingNum),
  16536. new OracleParameter(":groutingmouldcode",GroutingMouldCode),
  16537. new OracleParameter(":mouldcode",MouldCode),
  16538. new OracleParameter(":groutingdailyid",GroutingDailyID),
  16539. new OracleParameter(":groutingdailydetailid",GroutingDailyDetailID),
  16540. new OracleParameter(":groutinglineid",GroutingLineID),
  16541. new OracleParameter(":groutinglinecode",GroutingLineCode),
  16542. new OracleParameter(":groutinglinename",GroutingLineName),
  16543. new OracleParameter(":gmouldtypeid",GMouldTypeID),
  16544. new OracleParameter(":canmanytimes",CanManyTimes),
  16545. new OracleParameter(":groutinglinedetailid",GroutingLineDetailID),
  16546. new OracleParameter(":specialRepairflag",SpecialRepairflag),
  16547. new OracleParameter(":logoID",logoID),
  16548. };
  16549. #endregion
  16550. foreach (OracleParameter para in paras)
  16551. {
  16552. if (string.IsNullOrEmpty(para.Value + ""))
  16553. {
  16554. para.Value = DBNull.Value;
  16555. }
  16556. }
  16557. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  16558. OutSpecialRepairflag = returnVal;
  16559. // 失败
  16560. if (result != Constant.INT_IS_ONE)
  16561. {
  16562. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  16563. }
  16564. // 成功返回null
  16565. return null;
  16566. }
  16567. #region 保存半检登记
  16568. /// <summary>
  16569. /// 保存半检登记
  16570. /// </summary>
  16571. /// <param name="entity">半检实体类</param>
  16572. /// <param name="sUserInfo">用户基本信息</param>
  16573. /// <returns>ServiceResultEntity</returns>
  16574. /// <remarks>
  16575. /// 王鑫 2016.06.27 新建
  16576. /// </remarks>
  16577. public static ServiceResultEntity AddSemiCheck(SemiCheckEntity[] entityobj, SUserInfo sUserInfo)
  16578. {
  16579. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  16580. oracleTrConn.IgnoreCase = false;
  16581. ServiceResultEntity resultEntity = new ServiceResultEntity();
  16582. try
  16583. {
  16584. oracleTrConn.Connect();
  16585. SemiCheckEntity entity = entityobj[0];
  16586. string errMsg = "";
  16587. if (entity.SemiCheckCategory == 1) // 半检登记
  16588. {
  16589. errMsg = AddNormalSemiCheck(oracleTrConn, entity, sUserInfo);
  16590. }
  16591. else if (entity.SemiCheckCategory == 2)// 复检登记
  16592. {
  16593. errMsg = AddReSemiCheck(oracleTrConn, entity, sUserInfo);
  16594. }
  16595. else if (entity.SemiCheckCategory == 3)// 撤销复检
  16596. {
  16597. errMsg = AddCancelSemiCheck(oracleTrConn, entity, sUserInfo);
  16598. }
  16599. // 没有错误 提交事务
  16600. if (string.IsNullOrEmpty(errMsg))
  16601. {
  16602. oracleTrConn.Commit();
  16603. }
  16604. else
  16605. {
  16606. resultEntity.Message = errMsg;
  16607. }
  16608. }
  16609. catch (Exception ex)
  16610. {
  16611. oracleTrConn.Rollback();
  16612. throw ex;
  16613. }
  16614. finally
  16615. {
  16616. // 释放资源
  16617. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  16618. {
  16619. oracleTrConn.Disconnect();
  16620. }
  16621. }
  16622. return resultEntity;
  16623. }
  16624. #endregion
  16625. /// <summary>
  16626. /// 半检数据
  16627. /// </summary>
  16628. /// <param name="oracleTrConn">数据连接对象</param>
  16629. /// <param name="entity">半检实体类</param>
  16630. /// <param name="sUserInfo">用户基本信息</param>
  16631. /// <returns>string</returns>
  16632. /// <remarks>
  16633. /// 王鑫 2016.06.27 新建
  16634. /// </remarks>
  16635. private static string AddNormalSemiCheck(IDBTransaction oracleTrConn,
  16636. SemiCheckEntity entity,
  16637. SUserInfo sUserInfo)
  16638. {
  16639. try
  16640. {
  16641. // 获得账务日期
  16642. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  16643. string errMsg = string.Empty;
  16644. // 本批采集的批次号
  16645. string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  16646. // 条码
  16647. string barcode = entity.BarCode;
  16648. if (string.IsNullOrEmpty(barcode))
  16649. {
  16650. throw new Exception("传入的条码号为空");
  16651. }
  16652. // 半检工号ID
  16653. int workUserID = Convert.ToInt32(entity.SemiCheckUserID);
  16654. // 半检工号编码
  16655. string workUserCode = entity.SemiCheckUserCode;
  16656. // 查询新插入的半检数据ID
  16657. string sql = "select SEQ_PM_SemiCheck_ID.nextval from dual";
  16658. string idStr = "";
  16659. if (entity.SemiCheckEditType == 1) //新增
  16660. {
  16661. idStr = oracleTrConn.GetSqlResultToStr(sql);
  16662. }
  16663. else if (entity.SemiCheckEditType == 2) //编辑返工
  16664. {
  16665. if (entity.SemiCheckType != "0") //正常
  16666. {
  16667. idStr = oracleTrConn.GetSqlResultToStr(sql);
  16668. }
  16669. }
  16670. else if (entity.SemiCheckEditType == 3) //编辑不合格
  16671. {
  16672. if (entity.SemiCheckType != "0") //正常
  16673. {
  16674. idStr = oracleTrConn.GetSqlResultToStr(sql);
  16675. }
  16676. }
  16677. // 保存时再验证,前台已有缺陷不能为空的验证,但还是产生了无责任和缺陷记录的数据,后台保存时增加验证。
  16678. if (!string.IsNullOrEmpty(idStr) && (entity.SemiCheckDefects == null || entity.SemiCheckDefects.Count == 0))
  16679. {
  16680. errMsg = "缺陷责任记录不能为空";
  16681. return errMsg;
  16682. }
  16683. if (entity.SemiCheckEditType == 1) //新增
  16684. {
  16685. #region 校验条码有效性
  16686. errMsg = CheckBarcodeByNew(oracleTrConn, barcode, sUserInfo);
  16687. if (!string.IsNullOrEmpty(errMsg))
  16688. {
  16689. return errMsg;
  16690. }
  16691. #endregion
  16692. #region 添加半检数据
  16693. entity.SemiCheckID = Convert.ToInt32(idStr);
  16694. if (entity.SemiCheckType == "2")
  16695. {
  16696. errMsg = AddSemiCheckDataNoPass(oracleTrConn, entity, sUserInfo);
  16697. // 注浆明细 产品等级
  16698. sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=13,updateuserid=:updateuserid
  16699. where barcode=:barcode";
  16700. OracleParameter[] oracleParameters = new OracleParameter[] {
  16701. new OracleParameter(":accountid", sUserInfo.AccountID),
  16702. new OracleParameter(":barcode",entity.BarCode),
  16703. new OracleParameter(":updateuserid",sUserInfo.UserID),
  16704. };
  16705. oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  16706. }
  16707. else
  16708. {
  16709. errMsg = AddSemiCheckData(oracleTrConn, entity, sUserInfo);
  16710. if (entity.SemiCheckType == "1")
  16711. {
  16712. // 注浆明细 产品等级
  16713. sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=2,updateuserid=:updateuserid
  16714. where barcode=:barcode";
  16715. OracleParameter[] oracleParameters = new OracleParameter[] {
  16716. new OracleParameter(":accountid", sUserInfo.AccountID),
  16717. new OracleParameter(":barcode",entity.BarCode),
  16718. new OracleParameter(":updateuserid",sUserInfo.UserID),
  16719. };
  16720. oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  16721. }
  16722. else
  16723. {
  16724. // 注浆明细 产品等级
  16725. sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=1,updateuserid=:updateuserid
  16726. where barcode=:barcode";
  16727. OracleParameter[] oracleParameters = new OracleParameter[] {
  16728. new OracleParameter(":accountid", sUserInfo.AccountID),
  16729. new OracleParameter(":barcode",entity.BarCode),
  16730. new OracleParameter(":updateuserid",sUserInfo.UserID),
  16731. };
  16732. oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  16733. }
  16734. }
  16735. if (!string.IsNullOrEmpty(errMsg))
  16736. {
  16737. return errMsg;
  16738. }
  16739. #endregion
  16740. #region 条码有缺陷
  16741. #region 是次品 添加废弃产品
  16742. string ResponProcedureidStr = "";
  16743. if (entity.SemiCheckType == "2") //新建时不合格,直接报损
  16744. {
  16745. #region 添加废弃产品
  16746. ScrapProductEntity scrapProduct = new ScrapProductEntity();
  16747. #region 属性赋值
  16748. scrapProduct.BarCode = entity.BarCode;
  16749. scrapProduct.ScrapType = Constant.ScrapType.Substandard.GetHashCode();
  16750. // 不能责任人吗? TODO 单独责任时,没有插入废品数据。
  16751. //scrapProduct.ResponType = Constant.ScrapResponType.Procedure.GetHashCode();
  16752. scrapProduct.ResponType = (int)Constant.ScrapResponType.Person;
  16753. scrapProduct.ScrapDate = accountDate;// sysdate
  16754. scrapProduct.Rreason = Constant.SCRAPTYPE_NOPASS;
  16755. scrapProduct.AuditStatus = Constant.AuditStatus.Agree.GetHashCode();
  16756. scrapProduct.Auditor = sUserInfo.UserID;
  16757. scrapProduct.AuditlDate = accountDate;// sysdate
  16758. scrapProduct.AccountDate = accountDate;
  16759. sql = "select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=13 and accountid=" + sUserInfo.AccountID;
  16760. DataSet ds = oracleTrConn.GetSqlResultToDs(sql);
  16761. if (ds != null && ds.Tables[0].Rows.Count > 0)
  16762. {
  16763. scrapProduct.GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]);
  16764. }
  16765. scrapProduct.GoodsLevelTypeID = 13;
  16766. //scrapProduct.IsPublicBody = IsPubilcByBarCode(oracleTrConn, entity.BarCode);
  16767. // 查询新插入的废弃ID
  16768. string ResponProceduresql = "select SEQ_PM_ScrapProduct_ID.nextval from dual";
  16769. ResponProcedureidStr = oracleTrConn.GetSqlResultToStr(ResponProceduresql);
  16770. scrapProduct.ScrapProductID = Convert.ToInt32(ResponProcedureidStr);
  16771. scrapProduct.ScrapType = 2;
  16772. #endregion
  16773. // 保存报废
  16774. errMsg = AddScrapProduct(oracleTrConn, scrapProduct, sUserInfo);
  16775. // 保存失败
  16776. if (!string.IsNullOrEmpty(errMsg))
  16777. {
  16778. return errMsg;
  16779. }
  16780. #endregion
  16781. }
  16782. #endregion
  16783. // 存在缺陷 插入缺陷表
  16784. if (entity.SemiCheckDefects != null)
  16785. {
  16786. int row = 0;
  16787. foreach (SemiCheckDefectEntity semiCheckDefect in entity.SemiCheckDefects)
  16788. {
  16789. if (row == 0)
  16790. {
  16791. #region 保存缺陷
  16792. semiCheckDefect.SemiCheckID = Convert.ToInt32(idStr);
  16793. semiCheckDefect.ScrapResponFlag
  16794. = string.IsNullOrEmpty(semiCheckDefect.ScrapResponFlag) ? "0" : semiCheckDefect.ScrapResponFlag;
  16795. // 保存缺陷
  16796. errMsg = AddSemiCheckDefect(oracleTrConn, semiCheckDefect, sUserInfo);
  16797. if (!string.IsNullOrEmpty(errMsg))
  16798. {
  16799. return errMsg;
  16800. }
  16801. #endregion
  16802. #region 是不合格 添加废弃责任工序
  16803. if (entity.SemiCheckType == "2")
  16804. {
  16805. //if (semiCheckDefect.DefectProcedureID != null)
  16806. {
  16807. #region 添加责任工序
  16808. ResponProcedureEntity responProce = new ResponProcedureEntity();
  16809. // 新建-不合格 获取生产线及生产数据ID
  16810. sql = "select ProductionLineID,ProductionLineCode,ProductionLineName,ProductionDataID from TP_PM_InProduction where barcode=:barcode";
  16811. OracleParameter[] oracleParameters = new OracleParameter[] {
  16812. new OracleParameter(":barcode",entity.BarCode),
  16813. };
  16814. DataSet ds = oracleTrConn.GetSqlResultToDs(sql, oracleParameters);
  16815. if (ds != null && ds.Tables[0].Rows.Count > 0)
  16816. {
  16817. responProce.ProductionDataID = Convert.ToInt32(ds.Tables[0].Rows[0]["ProductionDataID"]);
  16818. responProce.ProductionLineID = Convert.ToInt32(ds.Tables[0].Rows[0]["ProductionLineID"]);
  16819. responProce.ProductionLineCode = ds.Tables[0].Rows[0]["ProductionLineCode"].ToString();
  16820. responProce.ProductionLineName = ds.Tables[0].Rows[0]["ProductionLineName"].ToString();
  16821. }
  16822. //新建-不合格 获取生产线及生产数据ID end
  16823. #region 属性赋值
  16824. responProce.BarCode = entity.BarCode;
  16825. responProce.ProcedureID = semiCheckDefect.DefectProcedureID;
  16826. responProce.ProcedureCode = semiCheckDefect.DefectProcedureCode;
  16827. responProce.ProcedureName = semiCheckDefect.DefectProcedureName;
  16828. responProce.UserID = semiCheckDefect.DefectUserID;
  16829. responProce.UserCode = semiCheckDefect.DefectUserCode;
  16830. responProce.UserName = semiCheckDefect.DefectUserName;
  16831. responProce.Remarks = semiCheckDefect.Remarks;
  16832. responProce.ScrapProductID = Convert.ToInt32(ResponProcedureidStr);
  16833. #endregion
  16834. // 保存责任工序
  16835. errMsg = AddSemiCheckResponProcedure(oracleTrConn, responProce, semiCheckDefect, sUserInfo);
  16836. // 保存失败
  16837. if (!string.IsNullOrEmpty(errMsg))
  16838. {
  16839. return errMsg;
  16840. }
  16841. #endregion
  16842. }
  16843. }
  16844. #endregion
  16845. }
  16846. row++;
  16847. }
  16848. }
  16849. #endregion
  16850. #region 条码是不合格 删除在产产品数据
  16851. if (entity.SemiCheckType == "2") //新建时不合格
  16852. {
  16853. // 1.在产表产品设置产品等级【13不合格】,半检登记ID=记录的半检登记ID。
  16854. sql = @"update TP_PM_InProduction set GoodsLevelID=
  16855. (
  16856. select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=13 and accountid=:accountid
  16857. )
  16858. ,GoodsLevelTypeID=13,SemiCheckID=:SemiCheckID,updateuserid=:updateuserid
  16859. where barcode=:barcode";
  16860. OracleParameter[] oracleParameters = new OracleParameter[] {
  16861. //new OracleParameter(":GoodsLevelID",entity.GoodsLevelID),
  16862. //new OracleParameter(":GoodsLevelTypeID",entity.GoodsLevelTypeID),
  16863. new OracleParameter(":accountid",sUserInfo.AccountID),
  16864. new OracleParameter(":SemiCheckID",Convert.ToInt32(idStr)),
  16865. new OracleParameter(":barcode",entity.BarCode),
  16866. // new OracleParameter(":createuserid",sUserInfo.UserID),
  16867. new OracleParameter(":updateuserid",sUserInfo.UserID),
  16868. };
  16869. int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  16870. // 2.将在产数据保存到在产回收站表中(产品等级【13不合格】,半检登记ID=记录的半检登记ID)。
  16871. string sqlInsert = @"insert into TP_PM_InProductionTrash
  16872. (
  16873. BarCode,
  16874. ProductionLineID,
  16875. ProductionLineCode,
  16876. ProductionLineName,
  16877. ProcedureModel,
  16878. ModelType,
  16879. DefectFlag,
  16880. ReworkProcedureID,
  16881. IsPublicBody,
  16882. IsReFire,
  16883. GoodsLevelID,
  16884. GoodsLevelTypeID,
  16885. GoodsID,
  16886. GoodsCode,
  16887. GoodsName,
  16888. UserID,
  16889. GroutingDailyID,
  16890. GroutingDailyDetailID,
  16891. GroutingDate,
  16892. GroutingLineID,
  16893. GroutingLineCode,
  16894. GroutingLineName,
  16895. GMouldTypeID,
  16896. CanManyTimes,
  16897. GroutingLineDetailID,
  16898. GroutingMouldCode,
  16899. MouldCode,
  16900. GroutingUserID,
  16901. GroutingUserCode,
  16902. GroutingNum,
  16903. Remarks,
  16904. KilnID,
  16905. KilnCode,
  16906. KilnName,
  16907. KilnCarID,
  16908. KilnCarCode,
  16909. KilnCarName,
  16910. KilnCarBatchNo,
  16911. KilnCarPosition,
  16912. AccountID,
  16913. ValueFlag,
  16914. CreateUserID,
  16915. UpdateUserID,
  16916. SpecialRepairflag,
  16917. FlowProcedureID,
  16918. FlowProcedureTime,
  16919. ProcedureID,
  16920. ProcedureTime,
  16921. ProductionDataID,
  16922. logoid,
  16923. ISREWORKFLAG, SEMICHECKID
  16924. )
  16925. select
  16926. BarCode,
  16927. ProductionLineID,
  16928. ProductionLineCode,
  16929. ProductionLineName,
  16930. ProcedureModel,
  16931. ModelType,
  16932. DefectFlag,
  16933. ReworkProcedureID,
  16934. IsPublicBody,
  16935. IsReFire,
  16936. -- GoodsLevelID,
  16937. --GoodsLevelTypeID,
  16938. (
  16939. select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=13 and accountid=:accountid
  16940. )
  16941. ,13,
  16942. GoodsID,
  16943. GoodsCode,
  16944. GoodsName,
  16945. UserID,
  16946. GroutingDailyID,
  16947. GroutingDailyDetailID,
  16948. GroutingDate,
  16949. GroutingLineID,
  16950. GroutingLineCode,
  16951. GroutingLineName,
  16952. GMouldTypeID,
  16953. CanManyTimes,
  16954. GroutingLineDetailID,
  16955. GroutingMouldCode,
  16956. MouldCode,
  16957. GroutingUserID,
  16958. GroutingUserCode,
  16959. GroutingNum,
  16960. Remarks,
  16961. KilnID,
  16962. KilnCode,
  16963. KilnName,
  16964. KilnCarID,
  16965. KilnCarCode,
  16966. KilnCarName,
  16967. KilnCarBatchNo,
  16968. KilnCarPosition,
  16969. AccountID,
  16970. ValueFlag,
  16971. :CreateUserID,
  16972. :UpdateUserID,
  16973. SpecialRepairflag,
  16974. FlowProcedureID,
  16975. FlowProcedureTime,
  16976. FlowProcedureID,
  16977. ProcedureTime,
  16978. ProductionDataID,
  16979. logoid,
  16980. ISREWORKFLAG, SEMICHECKID
  16981. from TP_PM_InProduction
  16982. where barcode=:barcode
  16983. ";
  16984. oracleParameters = new OracleParameter[] {
  16985. new OracleParameter(":barcode",entity.BarCode),
  16986. new OracleParameter(":CreateUserID",sUserInfo.UserID),
  16987. new OracleParameter(":UpdateUserID",sUserInfo.UserID),
  16988. new OracleParameter(":accountid",sUserInfo.AccountID),
  16989. };
  16990. result += oracleTrConn.ExecuteNonQuery(sqlInsert, oracleParameters);
  16991. // 删除在产数据
  16992. sql = "delete tp_pm_inproduction where barcode = :barcode";
  16993. oracleParameters = new OracleParameter[] {
  16994. new OracleParameter(":barcode",entity.BarCode),
  16995. };
  16996. result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  16997. }
  16998. else if (entity.SemiCheckType == "1") //返工
  16999. {
  17000. sql = @"update TP_PM_InProduction set GoodsLevelTypeID=2,IsReworkFlag=1,SemiCheckID=:SemiCheckID,updateuserid=:updateuserid
  17001. where barcode=:barcode";
  17002. OracleParameter[] oracleParameters = new OracleParameter[] {
  17003. new OracleParameter(":SemiCheckID",Convert.ToInt32(idStr)),
  17004. new OracleParameter(":barcode",entity.BarCode),
  17005. new OracleParameter(":updateuserid",sUserInfo.UserID),
  17006. };
  17007. int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17008. }
  17009. #endregion
  17010. }
  17011. else if (entity.SemiCheckEditType == 2) //编辑返工
  17012. {
  17013. #region 校验条码有效性
  17014. errMsg = CheckBarcodeByEditRework(oracleTrConn, barcode, sUserInfo);
  17015. if (!string.IsNullOrEmpty(errMsg))
  17016. {
  17017. return errMsg;
  17018. }
  17019. #endregion
  17020. #region 删除当前半检数据
  17021. errMsg = SetSemiCheckDataValueFlag(oracleTrConn, entity, sUserInfo);
  17022. if (!string.IsNullOrEmpty(errMsg))
  17023. {
  17024. return errMsg;
  17025. }
  17026. #endregion
  17027. if (entity.SemiCheckType != "0") //正常
  17028. {
  17029. #region 添加半检数据
  17030. entity.SemiCheckID = Convert.ToInt32(idStr);
  17031. errMsg = AddSemiCheckData(oracleTrConn, entity, sUserInfo);
  17032. if (!string.IsNullOrEmpty(errMsg))
  17033. {
  17034. return errMsg;
  17035. }
  17036. #endregion
  17037. }
  17038. #region 条码有缺陷
  17039. #region 是次品 添加废弃产品
  17040. string ResponProcedureidStr = "";
  17041. if (entity.SemiCheckType == "2") //新建时不合格,直接报损
  17042. {
  17043. #region 添加废弃产品
  17044. ScrapProductEntity scrapProduct = new ScrapProductEntity();
  17045. #region 属性赋值
  17046. scrapProduct.BarCode = entity.BarCode;
  17047. scrapProduct.ScrapType = Constant.ScrapType.Substandard.GetHashCode();
  17048. scrapProduct.ResponType = Constant.ScrapResponType.Procedure.GetHashCode();
  17049. scrapProduct.ScrapDate = accountDate;
  17050. scrapProduct.Rreason = Constant.SCRAPTYPE_NOPASS;
  17051. scrapProduct.AuditStatus = Constant.AuditStatus.Agree.GetHashCode();
  17052. scrapProduct.Auditor = sUserInfo.UserID;
  17053. scrapProduct.AuditlDate = accountDate;
  17054. scrapProduct.AccountDate = accountDate;
  17055. //scrapProduct.GoodsLevelID = entity.GoodsLevelID;
  17056. //scrapProduct.GoodsLevelTypeID = entity.GoodsLevelTypeID;
  17057. sql = "select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=13 and accountid=" + sUserInfo.AccountID;
  17058. DataSet ds = oracleTrConn.GetSqlResultToDs(sql);
  17059. if (ds != null && ds.Tables[0].Rows.Count > 0)
  17060. {
  17061. scrapProduct.GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]);
  17062. }
  17063. scrapProduct.GoodsLevelTypeID = 13;
  17064. scrapProduct.IsPublicBody = IsPubilcByBarCode(oracleTrConn, entity.BarCode);
  17065. // 查询新插入的废弃ID
  17066. string ResponProceduresql = "select SEQ_PM_ScrapProduct_ID.nextval from dual";
  17067. ResponProcedureidStr = oracleTrConn.GetSqlResultToStr(ResponProceduresql);
  17068. scrapProduct.ScrapProductID = Convert.ToInt32(ResponProcedureidStr);
  17069. scrapProduct.ScrapType = 2;
  17070. #endregion
  17071. // 保存报废
  17072. errMsg = AddScrapProduct(oracleTrConn, scrapProduct, sUserInfo);
  17073. // 保存失败
  17074. if (!string.IsNullOrEmpty(errMsg))
  17075. {
  17076. return errMsg;
  17077. }
  17078. #endregion
  17079. }
  17080. #endregion
  17081. // 存在缺陷 插入缺陷表
  17082. if (entity.SemiCheckDefects != null)
  17083. {
  17084. foreach (SemiCheckDefectEntity semiCheckDefect in entity.SemiCheckDefects)
  17085. {
  17086. #region 保存缺陷
  17087. semiCheckDefect.SemiCheckID = Convert.ToInt32(idStr);
  17088. semiCheckDefect.ScrapResponFlag
  17089. = string.IsNullOrEmpty(semiCheckDefect.ScrapResponFlag) ? "0" : semiCheckDefect.ScrapResponFlag;
  17090. // 保存缺陷
  17091. errMsg = AddSemiCheckDefect(oracleTrConn, semiCheckDefect, sUserInfo);
  17092. if (!string.IsNullOrEmpty(errMsg))
  17093. {
  17094. return errMsg;
  17095. }
  17096. #endregion
  17097. #region 是不合格 添加废弃责任工序
  17098. if (entity.SemiCheckType == "2")
  17099. {
  17100. //if (semiCheckDefect.DefectProcedureID != null)
  17101. {
  17102. #region 添加责任工序
  17103. ResponProcedureEntity responProce = new ResponProcedureEntity();
  17104. // 获取生产线及生产数据ID
  17105. sql = "select ProductionLineID,ProductionLineCode,ProductionLineName,ProductionDataID from TP_PM_InProduction where barcode=:barcode";
  17106. OracleParameter[] oracleParameters = new OracleParameter[] {
  17107. new OracleParameter(":barcode",entity.BarCode),
  17108. };
  17109. DataSet ds = oracleTrConn.GetSqlResultToDs(sql, oracleParameters);
  17110. if (ds != null && ds.Tables[0].Rows.Count > 0)
  17111. {
  17112. responProce.ProductionDataID = Convert.ToInt32(ds.Tables[0].Rows[0]["ProductionDataID"]);
  17113. responProce.ProductionLineID = Convert.ToInt32(ds.Tables[0].Rows[0]["ProductionLineID"]);
  17114. responProce.ProductionLineCode = ds.Tables[0].Rows[0]["ProductionLineCode"].ToString();
  17115. responProce.ProductionLineName = ds.Tables[0].Rows[0]["ProductionLineName"].ToString();
  17116. }
  17117. //获取生产线及生产数据ID end
  17118. #region 属性赋值
  17119. responProce.BarCode = entity.BarCode;
  17120. responProce.ProcedureID = semiCheckDefect.DefectProcedureID;
  17121. responProce.ProcedureCode = semiCheckDefect.DefectProcedureCode;
  17122. responProce.ProcedureName = semiCheckDefect.DefectProcedureName;
  17123. responProce.UserID = semiCheckDefect.DefectUserID;
  17124. responProce.UserCode = semiCheckDefect.DefectUserCode;
  17125. responProce.UserName = semiCheckDefect.DefectUserName;
  17126. responProce.Remarks = semiCheckDefect.Remarks;
  17127. responProce.ScrapProductID = Convert.ToInt32(ResponProcedureidStr);
  17128. #endregion
  17129. // 保存责任工序
  17130. errMsg = AddSemiCheckResponProcedure(oracleTrConn, responProce, semiCheckDefect, sUserInfo);
  17131. // 保存失败
  17132. if (!string.IsNullOrEmpty(errMsg))
  17133. {
  17134. return errMsg;
  17135. }
  17136. #endregion
  17137. }
  17138. }
  17139. #endregion
  17140. }
  17141. }
  17142. #endregion
  17143. #region 条码是不合格 删除在产产品数据
  17144. if (entity.SemiCheckType == "2") //编辑时不合格
  17145. {
  17146. // 1.在产表产品设置产品等级【13不合格】,半检登记ID=记录的半检登记ID。
  17147. sql = @"update TP_PM_InProduction set GoodsLevelID= (
  17148. select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=13 and accountid=:accountid
  17149. ),GoodsLevelTypeID=13,SemiCheckID=:SemiCheckID,IsReworkFlag=0,
  17150. updateuserid=:updateuserid
  17151. where barcode=:barcode";
  17152. OracleParameter[] oracleParameters = new OracleParameter[] {
  17153. //new OracleParameter(":GoodsLevelID",entity.GoodsLevelID),
  17154. //new OracleParameter(":GoodsLevelTypeID",entity.GoodsLevelTypeID),
  17155. new OracleParameter(":SemiCheckID",Convert.ToInt32(idStr)),
  17156. new OracleParameter(":barcode",entity.BarCode),
  17157. //new OracleParameter(":createuserid",sUserInfo.UserID),
  17158. new OracleParameter(":updateuserid",sUserInfo.UserID),
  17159. new OracleParameter(":accountid",sUserInfo.AccountID),
  17160. };
  17161. int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17162. // 注浆明细 产品等级
  17163. sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=13,updateuserid=:updateuserid
  17164. where barcode=:barcode";
  17165. oracleParameters = new OracleParameter[] {
  17166. new OracleParameter(":accountid", sUserInfo.AccountID),
  17167. new OracleParameter(":barcode",entity.BarCode),
  17168. new OracleParameter(":updateuserid",sUserInfo.UserID),
  17169. };
  17170. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17171. // 2.将在产数据保存到在产回收站表中(产品等级【13不合格】,半检登记ID=记录的半检登记ID)。
  17172. string sqlInsert = @"insert into TP_PM_InProductionTrash
  17173. (
  17174. BarCode,
  17175. ProductionLineID,
  17176. ProductionLineCode,
  17177. ProductionLineName,
  17178. ProcedureModel,
  17179. ModelType,
  17180. DefectFlag,
  17181. ReworkProcedureID,
  17182. IsPublicBody,
  17183. IsReFire,
  17184. GoodsLevelID,
  17185. GoodsLevelTypeID,
  17186. GoodsID,
  17187. GoodsCode,
  17188. GoodsName,
  17189. UserID,
  17190. GroutingDailyID,
  17191. GroutingDailyDetailID,
  17192. GroutingDate,
  17193. GroutingLineID,
  17194. GroutingLineCode,
  17195. GroutingLineName,
  17196. GMouldTypeID,
  17197. CanManyTimes,
  17198. GroutingLineDetailID,
  17199. GroutingMouldCode,
  17200. MouldCode,
  17201. GroutingUserID,
  17202. GroutingUserCode,
  17203. GroutingNum,
  17204. Remarks,
  17205. KilnID,
  17206. KilnCode,
  17207. KilnName,
  17208. KilnCarID,
  17209. KilnCarCode,
  17210. KilnCarName,
  17211. KilnCarBatchNo,
  17212. KilnCarPosition,
  17213. AccountID,
  17214. ValueFlag,
  17215. CreateUserID,
  17216. UpdateUserID,
  17217. SpecialRepairflag,
  17218. FlowProcedureID,
  17219. FlowProcedureTime,
  17220. ProcedureID,
  17221. ProcedureTime,
  17222. ProductionDataID,
  17223. logoid, SEMICHECKID
  17224. )
  17225. select
  17226. BarCode,
  17227. ProductionLineID,
  17228. ProductionLineCode,
  17229. ProductionLineName,
  17230. ProcedureModel,
  17231. ModelType,
  17232. DefectFlag,
  17233. ReworkProcedureID,
  17234. IsPublicBody,
  17235. IsReFire,
  17236. -- GoodsLevelID,
  17237. --GoodsLevelTypeID,
  17238. (
  17239. select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=13 and accountid=:accountid
  17240. )
  17241. ,13,
  17242. GoodsID,
  17243. GoodsCode,
  17244. GoodsName,
  17245. UserID,
  17246. GroutingDailyID,
  17247. GroutingDailyDetailID,
  17248. GroutingDate,
  17249. GroutingLineID,
  17250. GroutingLineCode,
  17251. GroutingLineName,
  17252. GMouldTypeID,
  17253. CanManyTimes,
  17254. GroutingLineDetailID,
  17255. GroutingMouldCode,
  17256. MouldCode,
  17257. GroutingUserID,
  17258. GroutingUserCode,
  17259. GroutingNum,
  17260. Remarks,
  17261. KilnID,
  17262. KilnCode,
  17263. KilnName,
  17264. KilnCarID,
  17265. KilnCarCode,
  17266. KilnCarName,
  17267. KilnCarBatchNo,
  17268. KilnCarPosition,
  17269. AccountID,
  17270. ValueFlag,
  17271. :CreateUserID,
  17272. :UpdateUserID,
  17273. SpecialRepairflag,
  17274. FlowProcedureID,
  17275. FlowProcedureTime,
  17276. FlowProcedureID,
  17277. ProcedureTime,
  17278. ProductionDataID,
  17279. logoid,
  17280. :SemiCheckID
  17281. from TP_PM_InProduction
  17282. where barcode=:barcode
  17283. ";
  17284. oracleParameters = new OracleParameter[] {
  17285. new OracleParameter(":barcode",entity.BarCode),
  17286. new OracleParameter(":CreateUserID",sUserInfo.UserID),
  17287. new OracleParameter(":UpdateUserID",sUserInfo.UserID),
  17288. new OracleParameter(":SemiCheckID",entity.SemiCheckID),
  17289. new OracleParameter(":accountid",sUserInfo.AccountID),
  17290. };
  17291. result += oracleTrConn.ExecuteNonQuery(sqlInsert, oracleParameters);
  17292. // 删除在产数据
  17293. sql = "delete tp_pm_inproduction where barcode = :barcode";
  17294. oracleParameters = new OracleParameter[] {
  17295. new OracleParameter(":barcode",entity.BarCode),
  17296. };
  17297. result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17298. }
  17299. else if (entity.SemiCheckType == "1") //返工
  17300. {
  17301. sql = @"update TP_PM_InProduction set GoodsLevelTypeID=2,IsReworkFlag=1,SemiCheckID=:SemiCheckID,updateuserid=:updateuserid
  17302. where barcode=:barcode";
  17303. OracleParameter[] oracleParameters = new OracleParameter[] {
  17304. new OracleParameter(":SemiCheckID",Convert.ToInt32(idStr)),
  17305. new OracleParameter(":barcode",entity.BarCode),
  17306. new OracleParameter(":updateuserid",sUserInfo.UserID),
  17307. };
  17308. int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17309. // 注浆明细 产品等级
  17310. sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=2,updateuserid=:updateuserid
  17311. where barcode=:barcode";
  17312. oracleParameters = new OracleParameter[] {
  17313. new OracleParameter(":accountid", sUserInfo.AccountID),
  17314. new OracleParameter(":barcode",entity.BarCode),
  17315. new OracleParameter(":updateuserid",sUserInfo.UserID),
  17316. };
  17317. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17318. }
  17319. else if (entity.SemiCheckType == "0") //正常
  17320. {
  17321. sql = @"update TP_PM_InProduction set GoodsLevelTypeID=1,IsReworkFlag=0,SemiCheckID=null,updateuserid=:updateuserid
  17322. where barcode=:barcode";
  17323. OracleParameter[] oracleParameters = new OracleParameter[] {
  17324. new OracleParameter(":barcode",entity.BarCode),
  17325. new OracleParameter(":updateuserid",sUserInfo.UserID),
  17326. };
  17327. int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17328. // 注浆明细 产品等级
  17329. sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=1,updateuserid=:updateuserid
  17330. where barcode=:barcode";
  17331. oracleParameters = new OracleParameter[] {
  17332. new OracleParameter(":accountid", sUserInfo.AccountID),
  17333. new OracleParameter(":barcode",entity.BarCode),
  17334. new OracleParameter(":updateuserid",sUserInfo.UserID),
  17335. };
  17336. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17337. }
  17338. #endregion
  17339. }
  17340. else if (entity.SemiCheckEditType == 3) //编辑不合格
  17341. {
  17342. #region 校验条码有效性
  17343. errMsg = CheckBarcodeByEditNoPass(oracleTrConn, barcode, sUserInfo);
  17344. if (!string.IsNullOrEmpty(errMsg))
  17345. {
  17346. return errMsg;
  17347. }
  17348. #endregion
  17349. #region 删除当前半检数据
  17350. errMsg = SetSemiCheckDataValueFlag(oracleTrConn, entity, sUserInfo);
  17351. if (!string.IsNullOrEmpty(errMsg))
  17352. {
  17353. return errMsg;
  17354. }
  17355. #endregion
  17356. if (entity.SemiCheckType != "0") //正常
  17357. {
  17358. #region 添加半检数据
  17359. entity.SemiCheckID = Convert.ToInt32(idStr);
  17360. errMsg = AddSemiCheckDataTrash(oracleTrConn, entity, sUserInfo);
  17361. if (!string.IsNullOrEmpty(errMsg))
  17362. {
  17363. return errMsg;
  17364. }
  17365. #endregion
  17366. }
  17367. #region 条码是不合格 删除在产产品数据
  17368. OracleParameter[] spParameters = null;
  17369. int spResult = 0;
  17370. if (entity.SemiCheckType == "2") //编辑时不合格
  17371. {
  17372. #region 1.废弃产品表中对应的总单数据和明细数据valueflag='0'。
  17373. string sqlString = "select max(sp.scrapproductid) scrapproductid\n" +
  17374. " from TP_PM_ScrapProduct sp\n" +
  17375. " where sp.barcode = :barcode\n" +
  17376. " and sp.auditstatus = 1\n" +
  17377. " and sp.valueflag = '1'\n" +
  17378. " and sp.scraptype = '2'";
  17379. spParameters = new OracleParameter[] {
  17380. new OracleParameter(":barcode",entity.BarCode),
  17381. };
  17382. string scrapproductid = oracleTrConn.GetSqlResultToStr(sqlString, spParameters);
  17383. sqlString = @"update TP_PM_ScrapProduct set valueflag='0', updateuserid=:updateuserid, backouttime=sysdate where scrapproductid=:scrapproductid";
  17384. spParameters = new OracleParameter[] {
  17385. new OracleParameter(":updateuserid",sUserInfo.UserID),
  17386. new OracleParameter(":scrapproductid",scrapproductid),
  17387. };
  17388. spResult = oracleTrConn.ExecuteNonQuery(sqlString, spParameters);
  17389. sqlString = @"update TP_PM_ResponProcedure set valueflag='0', updateuserid=:updateuserid where scrapproductid=:scrapproductid";
  17390. //oracleParameters = new OracleParameter[] {
  17391. // new OracleParameter(":barcode",entity.BarCode),
  17392. //};
  17393. spResult += oracleTrConn.ExecuteNonQuery(sqlString, spParameters);
  17394. //sql = @"update TP_PM_ScrapProduct set valueflag='0' where barcode=:barcode";
  17395. //OracleParameter[] oracleParameters = new OracleParameter[] {
  17396. // new OracleParameter(":barcode",entity.BarCode),
  17397. //};
  17398. //int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17399. //sql = @"update TP_PM_ResponProcedure set valueflag='0' where barcode=:barcode";
  17400. //oracleParameters = new OracleParameter[] {
  17401. // new OracleParameter(":barcode",entity.BarCode),
  17402. //};
  17403. //result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17404. ////sql = @"update TP_PM_ScrapResponsible set valueflag='0' where barcode=:barcode";
  17405. ////oracleParameters = new OracleParameter[] {
  17406. //// new OracleParameter(":barcode",entity.BarCode),
  17407. ////};
  17408. ////result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17409. #endregion
  17410. #region 2.修改在产回收站表中的数据(产品等级【13不合格】,半检登记ID=新记录的半检登记ID)。
  17411. sql = @"update TP_PM_InProductionTrash set GoodsLevelID= (
  17412. select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=13 and accountid=:accountid
  17413. ),GoodsLevelTypeID=13,SemiCheckID=:SemiCheckID where barcode=:barcode";
  17414. OracleParameter[] oracleParameters = new OracleParameter[] {
  17415. new OracleParameter(":barcode",entity.BarCode),
  17416. new OracleParameter(":accountid",sUserInfo.AccountID),
  17417. //new OracleParameter(":GoodsLevelTypeID",entity.GoodsLevelTypeID),
  17418. new OracleParameter(":SemiCheckID",entity.SemiCheckID),
  17419. };
  17420. int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17421. // 注浆明细 产品等级
  17422. sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=13,updateuserid=:updateuserid
  17423. where barcode=:barcode";
  17424. oracleParameters = new OracleParameter[] {
  17425. new OracleParameter(":accountid", sUserInfo.AccountID),
  17426. new OracleParameter(":barcode",entity.BarCode),
  17427. new OracleParameter(":updateuserid",sUserInfo.UserID),
  17428. };
  17429. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17430. #endregion
  17431. #region 条码有缺陷
  17432. #region 是次品 添加废弃产品
  17433. string ResponProcedureidStr = "";
  17434. if (entity.SemiCheckType == "2") //新建时不合格,直接报损
  17435. {
  17436. #region 添加废弃产品
  17437. ScrapProductEntity scrapProduct = new ScrapProductEntity();
  17438. #region 属性赋值
  17439. scrapProduct.BarCode = entity.BarCode;
  17440. scrapProduct.ScrapType = Constant.ScrapType.Substandard.GetHashCode();
  17441. scrapProduct.ResponType = Constant.ScrapResponType.Procedure.GetHashCode();
  17442. scrapProduct.ScrapDate = accountDate;
  17443. scrapProduct.Rreason = Constant.SCRAPTYPE_NOPASS;
  17444. scrapProduct.AuditStatus = Constant.AuditStatus.Agree.GetHashCode();
  17445. scrapProduct.Auditor = sUserInfo.UserID;
  17446. scrapProduct.AuditlDate = accountDate;
  17447. scrapProduct.AccountDate = accountDate;
  17448. sql = "select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=13 and accountid=" + sUserInfo.AccountID;
  17449. DataSet ds = oracleTrConn.GetSqlResultToDs(sql);
  17450. if (ds != null && ds.Tables[0].Rows.Count > 0)
  17451. {
  17452. scrapProduct.GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]);
  17453. }
  17454. scrapProduct.GoodsLevelTypeID = 13;
  17455. //scrapProduct.GoodsLevelID = entity.GoodsLevelID;
  17456. //scrapProduct.GoodsLevelTypeID = entity.GoodsLevelTypeID;
  17457. scrapProduct.IsPublicBody = IsPubilcByBarCode(oracleTrConn, entity.BarCode);
  17458. // 查询新插入的废弃ID
  17459. string ResponProceduresql = "select SEQ_PM_ScrapProduct_ID.nextval from dual";
  17460. ResponProcedureidStr = oracleTrConn.GetSqlResultToStr(ResponProceduresql);
  17461. scrapProduct.ScrapProductID = Convert.ToInt32(ResponProcedureidStr);
  17462. scrapProduct.ScrapType = 2;
  17463. #endregion
  17464. // 保存报废
  17465. errMsg = AddScrapProduct(oracleTrConn, scrapProduct, sUserInfo);
  17466. // 保存失败
  17467. if (!string.IsNullOrEmpty(errMsg))
  17468. {
  17469. return errMsg;
  17470. }
  17471. #endregion
  17472. }
  17473. #endregion
  17474. // 存在缺陷 插入缺陷表
  17475. if (entity.SemiCheckDefects != null)
  17476. {
  17477. foreach (SemiCheckDefectEntity semiCheckDefect in entity.SemiCheckDefects)
  17478. {
  17479. #region 保存缺陷
  17480. semiCheckDefect.SemiCheckID = Convert.ToInt32(idStr);
  17481. semiCheckDefect.ScrapResponFlag
  17482. = string.IsNullOrEmpty(semiCheckDefect.ScrapResponFlag) ? "0" : semiCheckDefect.ScrapResponFlag;
  17483. // 保存缺陷
  17484. errMsg = AddSemiCheckDefect(oracleTrConn, semiCheckDefect, sUserInfo);
  17485. if (!string.IsNullOrEmpty(errMsg))
  17486. {
  17487. return errMsg;
  17488. }
  17489. #endregion
  17490. #region 是不合格 添加废弃责任工序
  17491. if (entity.SemiCheckType == "2")
  17492. {
  17493. //if (semiCheckDefect.DefectProcedureID != null)
  17494. {
  17495. #region 添加责任工序
  17496. ResponProcedureEntity responProce = new ResponProcedureEntity();
  17497. // 取生产线及生产数据ID
  17498. sql = "select ProductionLineID,ProductionLineCode,ProductionLineName,ProductionDataID from TP_PM_InProductionTrash where barcode=:barcode";
  17499. oracleParameters = new OracleParameter[] {
  17500. new OracleParameter(":barcode",entity.BarCode),
  17501. };
  17502. DataSet ds = oracleTrConn.GetSqlResultToDs(sql, oracleParameters);
  17503. if (ds != null && ds.Tables[0].Rows.Count > 0)
  17504. {
  17505. responProce.ProductionDataID = Convert.ToInt32(ds.Tables[0].Rows[0]["ProductionDataID"]);
  17506. responProce.ProductionLineID = Convert.ToInt32(ds.Tables[0].Rows[0]["ProductionLineID"]);
  17507. responProce.ProductionLineCode = ds.Tables[0].Rows[0]["ProductionLineCode"].ToString();
  17508. responProce.ProductionLineName = ds.Tables[0].Rows[0]["ProductionLineName"].ToString();
  17509. }
  17510. //获取生产线及生产数据ID end
  17511. #region 属性赋值
  17512. responProce.BarCode = entity.BarCode;
  17513. //responProce.ProductionDataID = semiCheckDefect.ProductionDataID;
  17514. //responProce.ProductionLineID = semiCheckDefect.ProductionLineID;
  17515. //responProce.ProductionLineCode = semiCheckDefect.ProductionLineCode;
  17516. //responProce.ProductionLineName = semiCheckDefect.ProductionLineName;
  17517. responProce.ProcedureID = semiCheckDefect.DefectProcedureID;
  17518. responProce.ProcedureCode = semiCheckDefect.DefectProcedureCode;
  17519. responProce.ProcedureName = semiCheckDefect.DefectProcedureName;
  17520. responProce.UserID = semiCheckDefect.DefectUserID;
  17521. responProce.UserCode = semiCheckDefect.DefectUserCode;
  17522. responProce.UserName = semiCheckDefect.DefectUserName;
  17523. responProce.Remarks = semiCheckDefect.Remarks;
  17524. responProce.ScrapProductID = Convert.ToInt32(ResponProcedureidStr);
  17525. #endregion
  17526. // 保存责任工序
  17527. errMsg = AddSemiCheckResponProcedure(oracleTrConn, responProce, semiCheckDefect, sUserInfo);
  17528. // 保存失败
  17529. if (!string.IsNullOrEmpty(errMsg))
  17530. {
  17531. return errMsg;
  17532. }
  17533. #endregion
  17534. }
  17535. }
  17536. #endregion
  17537. }
  17538. }
  17539. #endregion
  17540. }
  17541. else if (entity.SemiCheckType == "1") //返工
  17542. {
  17543. #region 1.从在产回收站中把数据恢复到在产表中。
  17544. string sqlInsert = @"insert into TP_PM_InProduction
  17545. (
  17546. BarCode,
  17547. ProductionLineID,
  17548. ProductionLineCode,
  17549. ProductionLineName,
  17550. ProcedureModel,
  17551. ModelType,
  17552. DefectFlag,
  17553. ReworkProcedureID,
  17554. IsPublicBody,
  17555. IsReFire,
  17556. GoodsLevelID,
  17557. GoodsLevelTypeID,
  17558. GoodsID,
  17559. GoodsCode,
  17560. GoodsName,
  17561. UserID,
  17562. GroutingDailyID,
  17563. GroutingDailyDetailID,
  17564. GroutingDate,
  17565. GroutingLineID,
  17566. GroutingLineCode,
  17567. GroutingLineName,
  17568. GMouldTypeID,
  17569. CanManyTimes,
  17570. GroutingLineDetailID,
  17571. GroutingMouldCode,
  17572. MouldCode,
  17573. GroutingUserID,
  17574. GroutingUserCode,
  17575. GroutingNum,
  17576. Remarks,
  17577. KilnID,
  17578. KilnCode,
  17579. KilnName,
  17580. KilnCarID,
  17581. KilnCarCode,
  17582. KilnCarName,
  17583. KilnCarBatchNo,
  17584. KilnCarPosition,
  17585. AccountID,
  17586. ValueFlag,
  17587. CreateUserID,
  17588. UpdateUserID,
  17589. SpecialRepairflag,
  17590. FlowProcedureID,
  17591. FlowProcedureTime,
  17592. ProcedureID,
  17593. ProcedureTime,
  17594. ProductionDataID,
  17595. logoid,
  17596. IsReworkFlag,
  17597. SemiCheckID
  17598. )
  17599. select
  17600. BarCode,
  17601. ProductionLineID,
  17602. ProductionLineCode,
  17603. ProductionLineName,
  17604. ProcedureModel,
  17605. ModelType,
  17606. DefectFlag,
  17607. ReworkProcedureID,
  17608. IsPublicBody,
  17609. IsReFire,
  17610. null,
  17611. 2,
  17612. GoodsID,
  17613. GoodsCode,
  17614. GoodsName,
  17615. UserID,
  17616. GroutingDailyID,
  17617. GroutingDailyDetailID,
  17618. GroutingDate,
  17619. GroutingLineID,
  17620. GroutingLineCode,
  17621. GroutingLineName,
  17622. GMouldTypeID,
  17623. CanManyTimes,
  17624. GroutingLineDetailID,
  17625. GroutingMouldCode,
  17626. MouldCode,
  17627. GroutingUserID,
  17628. GroutingUserCode,
  17629. GroutingNum,
  17630. Remarks,
  17631. KilnID,
  17632. KilnCode,
  17633. KilnName,
  17634. KilnCarID,
  17635. KilnCarCode,
  17636. KilnCarName,
  17637. KilnCarBatchNo,
  17638. KilnCarPosition,
  17639. AccountID,
  17640. ValueFlag,
  17641. :CreateUserID,
  17642. :UpdateUserID,
  17643. SpecialRepairflag,
  17644. FlowProcedureID,
  17645. FlowProcedureTime,
  17646. FlowProcedureID,
  17647. ProcedureTime,
  17648. ProductionDataID,
  17649. logoid,
  17650. 1,
  17651. :SemiCheckID
  17652. from TP_PM_InProductionTrash
  17653. where barcode=:barcode
  17654. ";
  17655. OracleParameter[] oracleParameters = new OracleParameter[] {
  17656. new OracleParameter(":barcode",entity.BarCode),
  17657. new OracleParameter(":SemiCheckID",entity.SemiCheckID),
  17658. new OracleParameter(":CreateUserID",sUserInfo.UserID),
  17659. new OracleParameter(":UpdateUserID",sUserInfo.UserID),
  17660. };
  17661. int result = oracleTrConn.ExecuteNonQuery(sqlInsert, oracleParameters);
  17662. // 注浆明细 产品等级
  17663. sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=2,updateuserid=:updateuserid
  17664. where barcode=:barcode";
  17665. oracleParameters = new OracleParameter[] {
  17666. new OracleParameter(":accountid", sUserInfo.AccountID),
  17667. new OracleParameter(":barcode",entity.BarCode),
  17668. new OracleParameter(":updateuserid",sUserInfo.UserID),
  17669. };
  17670. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17671. #endregion
  17672. #region 2.废弃产品表中对应的总单数据和明细数据valueflag='0'。
  17673. string sqlString = "select max(sp.scrapproductid) scrapproductid\n" +
  17674. " from TP_PM_ScrapProduct sp\n" +
  17675. " where sp.barcode = :barcode\n" +
  17676. " and sp.auditstatus = 1\n" +
  17677. " and sp.valueflag = '1'\n" +
  17678. " and sp.scraptype = '2'";
  17679. spParameters = new OracleParameter[] {
  17680. new OracleParameter(":barcode",entity.BarCode),
  17681. };
  17682. string scrapproductid = oracleTrConn.GetSqlResultToStr(sqlString, spParameters);
  17683. sqlString = @"update TP_PM_ScrapProduct set valueflag='0', updateuserid=:updateuserid, backouttime=sysdate where scrapproductid=:scrapproductid";
  17684. spParameters = new OracleParameter[] {
  17685. new OracleParameter(":updateuserid",sUserInfo.UserID),
  17686. new OracleParameter(":scrapproductid",scrapproductid),
  17687. };
  17688. spResult = oracleTrConn.ExecuteNonQuery(sqlString, spParameters);
  17689. sqlString = @"update TP_PM_ResponProcedure set valueflag='0', updateuserid=:updateuserid where scrapproductid=:scrapproductid";
  17690. //oracleParameters = new OracleParameter[] {
  17691. // new OracleParameter(":barcode",entity.BarCode),
  17692. //};
  17693. spResult += oracleTrConn.ExecuteNonQuery(sqlString, spParameters);
  17694. //sql = @"update TP_PM_ScrapProduct set valueflag='0' where barcode=:barcode";
  17695. //oracleParameters = new OracleParameter[] {
  17696. // new OracleParameter(":barcode",entity.BarCode),
  17697. //};
  17698. //result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17699. //sql = @"update TP_PM_ResponProcedure set valueflag='0' where barcode=:barcode";
  17700. //oracleParameters = new OracleParameter[] {
  17701. // new OracleParameter(":barcode",entity.BarCode),
  17702. //};
  17703. //result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17704. ////sql = @"update TP_PM_ScrapResponsible set valueflag='0' where barcode=:barcode";
  17705. ////oracleParameters = new OracleParameter[] {
  17706. //// new OracleParameter(":barcode",entity.BarCode),
  17707. ////};
  17708. ////result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17709. #endregion
  17710. #region 3.删除在产产品数据
  17711. sql = "delete from TP_PM_InProductionTrash where barcode=:barcode";
  17712. oracleParameters = new OracleParameter[] {
  17713. new OracleParameter(":barcode",entity.BarCode),
  17714. };
  17715. result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17716. #endregion
  17717. #region 4.更新半检数据产品分级
  17718. sql = "update TP_PM_SemiCheck set GoodsLevelID=null,GoodsLevelTypeID=null where SemiCheckID=:SemiCheckID";
  17719. oracleParameters = new OracleParameter[] {
  17720. new OracleParameter(":SemiCheckID",idStr),
  17721. };
  17722. result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17723. #endregion
  17724. #region 存在缺陷 插入缺陷表
  17725. if (entity.SemiCheckDefects != null)
  17726. {
  17727. foreach (SemiCheckDefectEntity semiCheckDefect in entity.SemiCheckDefects)
  17728. {
  17729. #region 保存缺陷
  17730. semiCheckDefect.SemiCheckID = Convert.ToInt32(idStr);
  17731. semiCheckDefect.ScrapResponFlag
  17732. = string.IsNullOrEmpty(semiCheckDefect.ScrapResponFlag) ? "0" : semiCheckDefect.ScrapResponFlag;
  17733. // 保存缺陷
  17734. errMsg = AddSemiCheckDefect(oracleTrConn, semiCheckDefect, sUserInfo);
  17735. if (!string.IsNullOrEmpty(errMsg))
  17736. {
  17737. return errMsg;
  17738. }
  17739. #endregion
  17740. }
  17741. }
  17742. #endregion
  17743. }
  17744. else if (entity.SemiCheckType == "0") //正常
  17745. {
  17746. #region 1.从在产回收站中把数据恢复到在产表中。
  17747. string sqlInsert = @"insert into TP_PM_InProduction
  17748. (
  17749. BarCode,
  17750. ProductionLineID,
  17751. ProductionLineCode,
  17752. ProductionLineName,
  17753. ProcedureModel,
  17754. ModelType,
  17755. DefectFlag,
  17756. ReworkProcedureID,
  17757. IsPublicBody,
  17758. IsReFire,
  17759. GoodsLevelID,
  17760. GoodsLevelTypeID,
  17761. GoodsID,
  17762. GoodsCode,
  17763. GoodsName,
  17764. UserID,
  17765. GroutingDailyID,
  17766. GroutingDailyDetailID,
  17767. GroutingDate,
  17768. GroutingLineID,
  17769. GroutingLineCode,
  17770. GroutingLineName,
  17771. GMouldTypeID,
  17772. CanManyTimes,
  17773. GroutingLineDetailID,
  17774. GroutingMouldCode,
  17775. MouldCode,
  17776. GroutingUserID,
  17777. GroutingUserCode,
  17778. GroutingNum,
  17779. Remarks,
  17780. KilnID,
  17781. KilnCode,
  17782. KilnName,
  17783. KilnCarID,
  17784. KilnCarCode,
  17785. KilnCarName,
  17786. KilnCarBatchNo,
  17787. KilnCarPosition,
  17788. AccountID,
  17789. ValueFlag,
  17790. CreateUserID,
  17791. UpdateUserID,
  17792. SpecialRepairflag,
  17793. FlowProcedureID,
  17794. FlowProcedureTime,
  17795. ProcedureID,
  17796. ProcedureTime,
  17797. ProductionDataID,
  17798. logoid,
  17799. IsReworkFlag,
  17800. SemiCheckID
  17801. )
  17802. select
  17803. BarCode,
  17804. ProductionLineID,
  17805. ProductionLineCode,
  17806. ProductionLineName,
  17807. ProcedureModel,
  17808. ModelType,
  17809. DefectFlag,
  17810. ReworkProcedureID,
  17811. IsPublicBody,
  17812. IsReFire,
  17813. null,
  17814. 1,
  17815. GoodsID,
  17816. GoodsCode,
  17817. GoodsName,
  17818. UserID,
  17819. GroutingDailyID,
  17820. GroutingDailyDetailID,
  17821. GroutingDate,
  17822. GroutingLineID,
  17823. GroutingLineCode,
  17824. GroutingLineName,
  17825. GMouldTypeID,
  17826. CanManyTimes,
  17827. GroutingLineDetailID,
  17828. GroutingMouldCode,
  17829. MouldCode,
  17830. GroutingUserID,
  17831. GroutingUserCode,
  17832. GroutingNum,
  17833. Remarks,
  17834. KilnID,
  17835. KilnCode,
  17836. KilnName,
  17837. KilnCarID,
  17838. KilnCarCode,
  17839. KilnCarName,
  17840. KilnCarBatchNo,
  17841. KilnCarPosition,
  17842. AccountID,
  17843. ValueFlag,
  17844. :CreateUserID,
  17845. :UpdateUserID,
  17846. SpecialRepairflag,
  17847. FlowProcedureID,
  17848. FlowProcedureTime,
  17849. FlowProcedureID,
  17850. ProcedureTime,
  17851. ProductionDataID,
  17852. logoid,
  17853. 0,
  17854. null
  17855. from TP_PM_InProductionTrash
  17856. where barcode=:barcode
  17857. ";
  17858. OracleParameter[] oracleParameters = new OracleParameter[] {
  17859. new OracleParameter(":barcode",entity.BarCode),
  17860. new OracleParameter(":CreateUserID",sUserInfo.UserID),
  17861. new OracleParameter(":UpdateUserID",sUserInfo.UserID),
  17862. };
  17863. int result = oracleTrConn.ExecuteNonQuery(sqlInsert, oracleParameters);
  17864. // 注浆明细 产品等级
  17865. sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=1,updateuserid=:updateuserid
  17866. where barcode=:barcode";
  17867. oracleParameters = new OracleParameter[] {
  17868. new OracleParameter(":accountid", sUserInfo.AccountID),
  17869. new OracleParameter(":barcode",entity.BarCode),
  17870. new OracleParameter(":updateuserid",sUserInfo.UserID),
  17871. };
  17872. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17873. #endregion
  17874. #region 2.废弃产品表中对应的总单数据和明细数据valueflag='0'。
  17875. string sqlString = "select max(sp.scrapproductid) scrapproductid\n" +
  17876. " from TP_PM_ScrapProduct sp\n" +
  17877. " where sp.barcode = :barcode\n" +
  17878. " and sp.auditstatus = 1\n" +
  17879. " and sp.valueflag = '1'\n" +
  17880. " and sp.scraptype = '2'";
  17881. spParameters = new OracleParameter[] {
  17882. new OracleParameter(":barcode",entity.BarCode),
  17883. };
  17884. string scrapproductid = oracleTrConn.GetSqlResultToStr(sqlString, spParameters);
  17885. sqlString = @"update TP_PM_ScrapProduct set valueflag='0', updateuserid=:updateuserid, backouttime=sysdate where scrapproductid=:scrapproductid";
  17886. spParameters = new OracleParameter[] {
  17887. new OracleParameter(":updateuserid",sUserInfo.UserID),
  17888. new OracleParameter(":scrapproductid",scrapproductid),
  17889. };
  17890. spResult = oracleTrConn.ExecuteNonQuery(sqlString, spParameters);
  17891. sqlString = @"update TP_PM_ResponProcedure set valueflag='0', updateuserid=:updateuserid where scrapproductid=:scrapproductid";
  17892. //oracleParameters = new OracleParameter[] {
  17893. // new OracleParameter(":barcode",entity.BarCode),
  17894. //};
  17895. spResult += oracleTrConn.ExecuteNonQuery(sqlString, spParameters);
  17896. //sql = @"update TP_PM_ScrapProduct set valueflag='0' where barcode=:barcode";
  17897. //oracleParameters = new OracleParameter[] {
  17898. // new OracleParameter(":barcode",entity.BarCode),
  17899. //};
  17900. //result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17901. //sql = @"update TP_PM_ResponProcedure set valueflag='0' where barcode=:barcode";
  17902. //oracleParameters = new OracleParameter[] {
  17903. // new OracleParameter(":barcode",entity.BarCode),
  17904. //};
  17905. //result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17906. ////sql = @"update TP_PM_ScrapResponsible set valueflag='0' where barcode=:barcode";
  17907. ////oracleParameters = new OracleParameter[] {
  17908. //// new OracleParameter(":barcode",entity.BarCode),
  17909. ////};
  17910. ////result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17911. #endregion
  17912. #region 3.删除在产回收站产品数据
  17913. sql = "delete from TP_PM_InProductionTrash where barcode=:barcode";
  17914. oracleParameters = new OracleParameter[] {
  17915. new OracleParameter(":barcode",entity.BarCode),
  17916. };
  17917. result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17918. #endregion
  17919. }
  17920. #endregion
  17921. }
  17922. return errMsg;
  17923. }
  17924. catch (Exception ex)
  17925. {
  17926. throw ex;
  17927. }
  17928. }
  17929. /// <summary>
  17930. /// 校验条码有效(新建)
  17931. /// </summary>
  17932. /// <param name="oracleTrConn">连接对象</param>
  17933. /// <param name="barcode">条码</param>
  17934. /// <param name="sUserInfo">登录用户信息</param>
  17935. /// <returns>string</returns>
  17936. /// <remarks>
  17937. /// 王鑫 2016.06.27 新建
  17938. /// </remarks>
  17939. private static string CheckBarcodeByNew(IDBTransaction oracleTrConn,
  17940. string barcode,
  17941. SUserInfo sUserInfo
  17942. )
  17943. {
  17944. try
  17945. {
  17946. OracleParameter[] paras = new OracleParameter[]{
  17947. new OracleParameter(":barcode",OracleDbType.Varchar2,barcode,ParameterDirection.Input),
  17948. };
  17949. // 重复登记的问题 for update
  17950. string sql = @"
  17951. select InScrapFlag,
  17952. KilnCarID,
  17953. KilnCarName,
  17954. IsReworkFlag,
  17955. SemiCheckID from TP_PM_InProduction where barcode=:barcode for update
  17956. ";
  17957. DataSet dsResult = oracleTrConn.GetSqlResultToDs(sql, paras);
  17958. if (dsResult != null && dsResult.Tables[0].Rows.Count > 0)
  17959. {
  17960. if (dsResult.Tables[0].Rows[0]["InScrapFlag"].ToString() == "1")
  17961. {
  17962. return "条码[" + barcode + "]已经报损待审批";
  17963. }
  17964. if (!string.IsNullOrEmpty(dsResult.Tables[0].Rows[0]["KilnCarID"].ToString()))
  17965. {
  17966. return "条码[" + barcode + "]已经在窑车[" + dsResult.Tables[0].Rows[0]["KilnCarName"].ToString() + "]";
  17967. ;
  17968. }
  17969. // chenxy 2019-10-02 半检返修 IsReworkFlag=2
  17970. if (dsResult.Tables[0].Rows[0]["IsReworkFlag"].ToString() == "1")
  17971. {
  17972. return "条码[" + barcode + "]已经半检返工中";
  17973. }
  17974. if (dsResult.Tables[0].Rows[0]["IsReworkFlag"].ToString() == "2")
  17975. {
  17976. return "条码[" + barcode + "]已经半检返修中";
  17977. }
  17978. }
  17979. else
  17980. {
  17981. return "条码[" + barcode + "]不在在产流程";
  17982. }
  17983. return null;
  17984. }
  17985. catch (Exception ex)
  17986. {
  17987. throw ex;
  17988. }
  17989. }
  17990. /// <summary>
  17991. /// 校验条码有效(编辑返工)
  17992. /// </summary>
  17993. /// <param name="oracleTrConn">连接对象</param>
  17994. /// <param name="barcode">条码</param>
  17995. /// <param name="sUserInfo">登录用户信息</param>
  17996. /// <returns>string</returns>
  17997. /// <remarks>
  17998. /// 王鑫 2016.06.27 新建
  17999. /// </remarks>
  18000. private static string CheckBarcodeByEditRework(IDBTransaction oracleTrConn,
  18001. string barcode,
  18002. SUserInfo sUserInfo
  18003. )
  18004. {
  18005. try
  18006. {
  18007. OracleParameter[] paras = new OracleParameter[]{
  18008. new OracleParameter(":barcode",OracleDbType.Varchar2,barcode,ParameterDirection.Input),
  18009. };
  18010. // 重复登记的问题 for update
  18011. string sql = @"
  18012. select InScrapFlag,
  18013. KilnCarID,
  18014. KilnCarName,
  18015. IsReworkFlag,
  18016. SemiCheckID from TP_PM_InProduction where barcode=:barcode for update
  18017. ";
  18018. DataSet dsResult = oracleTrConn.GetSqlResultToDs(sql, paras);
  18019. if (dsResult != null && dsResult.Tables[0].Rows.Count > 0)
  18020. {
  18021. if (dsResult.Tables[0].Rows[0]["InScrapFlag"].ToString() == "1")
  18022. {
  18023. return "条码[" + barcode + "]已经报损待审批";
  18024. }
  18025. if (!string.IsNullOrEmpty(dsResult.Tables[0].Rows[0]["KilnCarID"].ToString()))
  18026. {
  18027. return "条码[" + barcode + "]已经在窑车[" + dsResult.Tables[0].Rows[0]["KilnCarName"].ToString() + "]";
  18028. ;
  18029. }
  18030. // chenxy 2019-10-02 半检返修 IsReworkFlag=2
  18031. if (dsResult.Tables[0].Rows[0]["IsReworkFlag"].ToString() != "1")
  18032. {
  18033. return "条码[" + barcode + "]不在返工中";
  18034. }
  18035. }
  18036. else
  18037. {
  18038. return "条码[" + barcode + "]不在在产流程";
  18039. }
  18040. return null;
  18041. }
  18042. catch (Exception ex)
  18043. {
  18044. throw ex;
  18045. }
  18046. }
  18047. /// <summary>
  18048. /// 校验条码有效(编辑不合格)
  18049. /// </summary>
  18050. /// <param name="oracleTrConn">连接对象</param>
  18051. /// <param name="barcode">条码</param>
  18052. /// <param name="sUserInfo">登录用户信息</param>
  18053. /// <returns>string</returns>
  18054. /// <remarks>
  18055. /// 王鑫 2016.06.27 新建
  18056. /// </remarks>
  18057. private static string CheckBarcodeByEditNoPass(IDBTransaction oracleTrConn,
  18058. string barcode,
  18059. SUserInfo sUserInfo
  18060. )
  18061. {
  18062. try
  18063. {
  18064. OracleParameter[] paras = new OracleParameter[]{
  18065. new OracleParameter(":barcode",OracleDbType.Varchar2,barcode,ParameterDirection.Input),
  18066. };
  18067. // 重复登记的问题 for update
  18068. string sql = @" select 1 from TP_PM_InProductionTrash where barcode=:barcode and GoodsLevelTypeID=13 for update";
  18069. DataSet dsResult = oracleTrConn.GetSqlResultToDs(sql, paras);
  18070. if (dsResult != null && dsResult.Tables[0].Rows.Count == 0)
  18071. {
  18072. return "条码[" + barcode + "]不在在产回收站中";
  18073. }
  18074. return null;
  18075. }
  18076. catch (Exception ex)
  18077. {
  18078. throw ex;
  18079. }
  18080. }
  18081. /// <summary>
  18082. /// 添加半成品检验数据
  18083. /// </summary>
  18084. /// <param name="oracleTrConn">连接对象</param>
  18085. /// <param name="accountDate">账务日期</param>
  18086. /// <param name="productionData">生产数据</param>
  18087. /// <param name="sUserInfo">用户基本信息</param>
  18088. /// <returns>string</returns>
  18089. /// <remarks>
  18090. /// 陈冰 2014.09.18 新建
  18091. /// </remarks>
  18092. private static string AddSemiCheckData(IDBTransaction oracleTrConn, SemiCheckEntity entity, SUserInfo sUserInfo)
  18093. {
  18094. #region SQL
  18095. string sql = "insert into tp_pm_semicheck"
  18096. + " (semicheckid,"
  18097. + " barcode,"
  18098. + " productionlineid,"
  18099. + " procedureid,"
  18100. + " proceduretime,"
  18101. + " proceduremodel,"
  18102. + " modeltype,"
  18103. + " organizationid,"
  18104. + " goodsid,"
  18105. + " goodscode,"
  18106. + " userid,"
  18107. + " usercode,"
  18108. + " productiondataid,"
  18109. + " logoid,"
  18110. + " ispublicbody,"
  18111. + " specialrepairflag,"
  18112. + " goodslevelid,"
  18113. + " goodsleveltypeid,"
  18114. + " groutingdailyid,"
  18115. + " groutingdailydetailid,"
  18116. + " groutinglineid,"
  18117. + " groutinglinecode,"
  18118. + " groutinglinename,"
  18119. + " gmouldtypeid,"
  18120. + " canmanytimes,"
  18121. + " groutinglinedetailid,"
  18122. + " groutingdate,"
  18123. + " groutingmouldcode,"
  18124. + " mouldcode,"
  18125. + " groutinguserid,"
  18126. + " groutingusercode,"
  18127. + " groutingnum,"
  18128. + " semichecktype,"
  18129. + " semicheckuserID,"
  18130. + " semicheckusercode,"
  18131. + " semichecktime,"
  18132. + " remarks,"
  18133. + " accountid,"
  18134. + " createuserid,"
  18135. + " updateuserid,"
  18136. + " reworkprocedureid,"
  18137. + " reworkprocedurecode,"
  18138. + " reworkuserid,"
  18139. + " reworkusercode"
  18140. + ")"
  18141. + " select"
  18142. + " :semicheckid,"
  18143. + " TP_PM_InProduction.barcode,"
  18144. + " TP_PM_InProduction.productionlineid,"
  18145. + " TP_PM_InProduction.procedureid,"
  18146. + " TP_PM_InProduction.proceduretime,"
  18147. + " TP_PM_InProduction.proceduremodel,"
  18148. + " TP_PM_InProduction.modeltype,"
  18149. + " tp_pc_procedure.organizationid,"
  18150. + " TP_PM_InProduction.goodsid,"
  18151. + " TP_PM_InProduction.goodscode,"
  18152. + " TP_PM_InProduction.userid,"
  18153. + " tp_mst_user.usercode,"
  18154. + " TP_PM_InProduction.productiondataid,"
  18155. + " TP_PM_InProduction.logoid,"
  18156. + " TP_PM_InProduction.ispublicbody,"
  18157. + " TP_PM_InProduction.specialrepairflag,"
  18158. + " TP_PM_InProduction.goodslevelid,"
  18159. + " TP_PM_InProduction.goodsleveltypeid,"
  18160. + " TP_PM_InProduction.groutingdailyid,"
  18161. + " TP_PM_InProduction.groutingdailydetailid,"
  18162. + " TP_PM_InProduction.groutinglineid,"
  18163. + " TP_PM_InProduction.groutinglinecode,"
  18164. + " TP_PM_InProduction.groutinglinename,"
  18165. + " TP_PM_InProduction.gmouldtypeid,"
  18166. + " TP_PM_InProduction.canmanytimes,"
  18167. + " TP_PM_InProduction.groutinglinedetailid,"
  18168. + " TP_PM_InProduction.groutingdate,"
  18169. + " TP_PM_InProduction.groutingmouldcode,"
  18170. + " TP_PM_InProduction.mouldcode,"
  18171. + " TP_PM_InProduction.groutinguserid,"
  18172. + " TP_PM_InProduction.groutingusercode,"
  18173. + " TP_PM_InProduction.groutingnum,"
  18174. + " :semichecktype,"
  18175. + " :semicheckuserID,"
  18176. + " :semicheckusercode,"
  18177. + " sysdate,"
  18178. + " :remarks,"
  18179. + " :accountid,"
  18180. + " :createuserid,"
  18181. + " :updateuserid,"
  18182. + " :reworkprocedureid,"
  18183. + " :reworkprocedurecode,"
  18184. + " :reworkuserid,"
  18185. + " :reworkusercode"
  18186. + " from TP_PM_InProduction left join tp_mst_user on TP_PM_InProduction.UserID=tp_mst_user.userid "
  18187. + " left join tp_pc_procedure on TP_PM_InProduction.ProcedureID=tp_pc_procedure.ProcedureID "
  18188. + " where TP_PM_InProduction.barcode=:barcode";
  18189. #endregion
  18190. #region OracleParameter
  18191. OracleParameter[] paras = new OracleParameter[] {
  18192. new OracleParameter(":semicheckid",entity.SemiCheckID),
  18193. new OracleParameter(":semichecktype",entity.SemiCheckType),
  18194. new OracleParameter(":semicheckuserID",entity.SemiCheckUserID),
  18195. new OracleParameter(":semicheckusercode",entity.SemiCheckUserCode),
  18196. new OracleParameter(":remarks",entity.Remarks),
  18197. new OracleParameter(":accountid",sUserInfo.AccountID),
  18198. new OracleParameter(":createuserid",sUserInfo.UserID),
  18199. new OracleParameter(":updateuserid",sUserInfo.UserID),
  18200. new OracleParameter(":barcode",entity.BarCode),
  18201. new OracleParameter(":reworkprocedureid",entity.ReworkProcedureID),
  18202. new OracleParameter(":reworkprocedurecode",entity.ReworkProcedureCode),
  18203. new OracleParameter(":reworkuserid",entity.ReworkUserID),
  18204. new OracleParameter(":reworkusercode",entity.ReworkUserCode),
  18205. };
  18206. #endregion
  18207. foreach (OracleParameter para in paras)
  18208. {
  18209. if (string.IsNullOrEmpty(para.Value + ""))
  18210. {
  18211. para.Value = DBNull.Value;
  18212. }
  18213. }
  18214. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  18215. // 失败
  18216. if (result != Constant.INT_IS_ONE)
  18217. {
  18218. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  18219. }
  18220. // 成功返回null
  18221. return null;
  18222. }
  18223. /// <summary>
  18224. /// 添加半成品检验数据(不合格)
  18225. /// </summary>
  18226. /// <param name="oracleTrConn">连接对象</param>
  18227. /// <param name="accountDate">账务日期</param>
  18228. /// <param name="productionData">生产数据</param>
  18229. /// <param name="sUserInfo">用户基本信息</param>
  18230. /// <returns>string</returns>
  18231. /// <remarks>
  18232. /// 陈冰 2014.09.18 新建
  18233. /// </remarks>
  18234. private static string AddSemiCheckDataNoPass(IDBTransaction oracleTrConn, SemiCheckEntity entity, SUserInfo sUserInfo)
  18235. {
  18236. #region SQL
  18237. string sql = "insert into tp_pm_semicheck"
  18238. + " (semicheckid,"
  18239. + " barcode,"
  18240. + " productionlineid,"
  18241. + " procedureid,"
  18242. + " proceduretime,"
  18243. + " proceduremodel,"
  18244. + " modeltype,"
  18245. + " organizationid,"
  18246. + " goodsid,"
  18247. + " goodscode,"
  18248. + " userid,"
  18249. + " usercode,"
  18250. + " productiondataid,"
  18251. + " logoid,"
  18252. + " ispublicbody,"
  18253. + " specialrepairflag,"
  18254. + " goodslevelid,"
  18255. + " goodsleveltypeid,"
  18256. + " groutingdailyid,"
  18257. + " groutingdailydetailid,"
  18258. + " groutinglineid,"
  18259. + " groutinglinecode,"
  18260. + " groutinglinename,"
  18261. + " gmouldtypeid,"
  18262. + " canmanytimes,"
  18263. + " groutinglinedetailid,"
  18264. + " groutingdate,"
  18265. + " groutingmouldcode,"
  18266. + " mouldcode,"
  18267. + " groutinguserid,"
  18268. + " groutingusercode,"
  18269. + " groutingnum,"
  18270. + " semichecktype,"
  18271. + " semicheckuserID,"
  18272. + " semicheckusercode,"
  18273. + " semichecktime,"
  18274. + " remarks,"
  18275. + " accountid,"
  18276. + " createuserid,"
  18277. + " updateuserid,"
  18278. + " reworkprocedureid,"
  18279. + " reworkprocedurecode,"
  18280. + " reworkuserid,"
  18281. + " reworkusercode"
  18282. + ")"
  18283. + " select"
  18284. + " :semicheckid,"
  18285. + " TP_PM_InProduction.barcode,"
  18286. + " TP_PM_InProduction.productionlineid,"
  18287. + " TP_PM_InProduction.procedureid,"
  18288. + " TP_PM_InProduction.proceduretime,"
  18289. + " TP_PM_InProduction.proceduremodel,"
  18290. + " TP_PM_InProduction.modeltype,"
  18291. + " tp_pc_procedure.organizationid,"
  18292. + " TP_PM_InProduction.goodsid,"
  18293. + " TP_PM_InProduction.goodscode,"
  18294. + " TP_PM_InProduction.userid,"
  18295. + " tp_mst_user.usercode,"
  18296. + " TP_PM_InProduction.productiondataid,"
  18297. + " TP_PM_InProduction.logoid,"
  18298. + " TP_PM_InProduction.ispublicbody,"
  18299. + " TP_PM_InProduction.specialrepairflag,"
  18300. + " (select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=13 and accountid=:accountid),"
  18301. + " 13,"
  18302. + " TP_PM_InProduction.groutingdailyid,"
  18303. + " TP_PM_InProduction.groutingdailydetailid,"
  18304. + " TP_PM_InProduction.groutinglineid,"
  18305. + " TP_PM_InProduction.groutinglinecode,"
  18306. + " TP_PM_InProduction.groutinglinename,"
  18307. + " TP_PM_InProduction.gmouldtypeid,"
  18308. + " TP_PM_InProduction.canmanytimes,"
  18309. + " TP_PM_InProduction.groutinglinedetailid,"
  18310. + " TP_PM_InProduction.groutingdate,"
  18311. + " TP_PM_InProduction.groutingmouldcode,"
  18312. + " TP_PM_InProduction.mouldcode,"
  18313. + " TP_PM_InProduction.groutinguserid,"
  18314. + " TP_PM_InProduction.groutingusercode,"
  18315. + " TP_PM_InProduction.groutingnum,"
  18316. + " :semichecktype,"
  18317. + " :semicheckuserID,"
  18318. + " :semicheckusercode,"
  18319. + " sysdate,"
  18320. + " :remarks,"
  18321. + " :accountid,"
  18322. + " :createuserid,"
  18323. + " :updateuserid,"
  18324. + " :reworkprocedureid,"
  18325. + " :reworkprocedurecode,"
  18326. + " :reworkuserid,"
  18327. + " :reworkusercode"
  18328. + " from TP_PM_InProduction left join tp_mst_user on TP_PM_InProduction.UserID=tp_mst_user.userid "
  18329. + " left join tp_pc_procedure on TP_PM_InProduction.ProcedureID=tp_pc_procedure.ProcedureID "
  18330. + " where TP_PM_InProduction.barcode=:barcode";
  18331. #endregion
  18332. #region OracleParameter
  18333. OracleParameter[] paras = new OracleParameter[] {
  18334. new OracleParameter(":semicheckid",entity.SemiCheckID),
  18335. new OracleParameter(":semichecktype",entity.SemiCheckType),
  18336. new OracleParameter(":semicheckuserID",entity.SemiCheckUserID),
  18337. new OracleParameter(":semicheckusercode",entity.SemiCheckUserCode),
  18338. new OracleParameter(":remarks",entity.Remarks),
  18339. new OracleParameter(":accountid",sUserInfo.AccountID),
  18340. new OracleParameter(":createuserid",sUserInfo.UserID),
  18341. new OracleParameter(":updateuserid",sUserInfo.UserID),
  18342. new OracleParameter(":accountid",sUserInfo.AccountID),
  18343. new OracleParameter(":barcode",entity.BarCode),
  18344. new OracleParameter(":reworkprocedureid",entity.ReworkProcedureID),
  18345. new OracleParameter(":reworkprocedurecode",entity.ReworkProcedureCode),
  18346. new OracleParameter(":reworkuserid",entity.ReworkUserID),
  18347. new OracleParameter(":reworkusercode",entity.ReworkUserCode),
  18348. };
  18349. #endregion
  18350. foreach (OracleParameter para in paras)
  18351. {
  18352. if (string.IsNullOrEmpty(para.Value + ""))
  18353. {
  18354. para.Value = DBNull.Value;
  18355. }
  18356. }
  18357. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  18358. // 失败
  18359. if (result != Constant.INT_IS_ONE)
  18360. {
  18361. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  18362. }
  18363. // 成功返回null
  18364. return null;
  18365. }
  18366. /// <summary>
  18367. /// 添加半成品检验数据
  18368. /// </summary>
  18369. /// <param name="oracleTrConn">连接对象</param>
  18370. /// <param name="accountDate">账务日期</param>
  18371. /// <param name="productionData">生产数据</param>
  18372. /// <param name="sUserInfo">用户基本信息</param>
  18373. /// <returns>string</returns>
  18374. /// <remarks>
  18375. /// 陈冰 2014.09.18 新建
  18376. /// </remarks>
  18377. private static string AddSemiCheckDataTrash(IDBTransaction oracleTrConn, SemiCheckEntity entity, SUserInfo sUserInfo)
  18378. {
  18379. #region SQL
  18380. string sql = "insert into tp_pm_semicheck"
  18381. + " (semicheckid,"
  18382. + " barcode,"
  18383. + " productionlineid,"
  18384. + " procedureid,"
  18385. + " proceduretime,"
  18386. + " proceduremodel,"
  18387. + " modeltype,"
  18388. + " organizationid,"
  18389. + " goodsid,"
  18390. + " goodscode,"
  18391. + " userid,"
  18392. + " usercode,"
  18393. + " productiondataid,"
  18394. + " logoid,"
  18395. + " ispublicbody,"
  18396. + " specialrepairflag,"
  18397. + " goodslevelid,"
  18398. + " goodsleveltypeid,"
  18399. + " groutingdailyid,"
  18400. + " groutingdailydetailid,"
  18401. + " groutinglineid,"
  18402. + " groutinglinecode,"
  18403. + " groutinglinename,"
  18404. + " gmouldtypeid,"
  18405. + " canmanytimes,"
  18406. + " groutinglinedetailid,"
  18407. + " groutingdate,"
  18408. + " groutingmouldcode,"
  18409. + " mouldcode,"
  18410. + " groutinguserid,"
  18411. + " groutingusercode,"
  18412. + " groutingnum,"
  18413. + " semichecktype,"
  18414. + " semicheckuserID,"
  18415. + " semicheckusercode,"
  18416. + " semichecktime,"
  18417. + " remarks,"
  18418. + " accountid,"
  18419. + " createuserid,"
  18420. + " updateuserid,"
  18421. + " reworkprocedureid,"
  18422. + " reworkprocedurecode,"
  18423. + " reworkuserid,"
  18424. + " reworkusercode"
  18425. + ")"
  18426. + " select"
  18427. + " :semicheckid,"
  18428. + " trash.barcode,"
  18429. + " trash.productionlineid,"
  18430. + " trash.procedureid,"
  18431. + " trash.proceduretime,"
  18432. + " trash.proceduremodel,"
  18433. + " trash.modeltype,"
  18434. + " tp_pc_procedure.organizationid,"
  18435. + " trash.goodsid,"
  18436. + " trash.goodscode,"
  18437. + " trash.userid,"
  18438. + " tp_mst_user.usercode,"
  18439. + " trash.productiondataid,"
  18440. + " trash.logoid,"
  18441. + " trash.ispublicbody,"
  18442. + " trash.specialrepairflag,"
  18443. + " trash.goodslevelid,"
  18444. + " trash.goodsleveltypeid,"
  18445. + " trash.groutingdailyid,"
  18446. + " trash.groutingdailydetailid,"
  18447. + " trash.groutinglineid,"
  18448. + " trash.groutinglinecode,"
  18449. + " trash.groutinglinename,"
  18450. + " trash.gmouldtypeid,"
  18451. + " trash.canmanytimes,"
  18452. + " trash.groutinglinedetailid,"
  18453. + " trash.groutingdate,"
  18454. + " trash.groutingmouldcode,"
  18455. + " trash.mouldcode,"
  18456. + " trash.groutinguserid,"
  18457. + " trash.groutingusercode,"
  18458. + " trash.groutingnum,"
  18459. + " :semichecktype,"
  18460. + " :semicheckuserID,"
  18461. + " :semicheckusercode,"
  18462. + " sysdate,"
  18463. + " :remarks,"
  18464. + " :accountid,"
  18465. + " :createuserid,"
  18466. + " :updateuserid,"
  18467. + " :reworkprocedureid,"
  18468. + " :reworkprocedurecode,"
  18469. + " :reworkuserid,"
  18470. + " :reworkusercode"
  18471. + " from TP_PM_InProductionTrash trash left join tp_mst_user on trash.UserID=tp_mst_user.userid "
  18472. + " left join tp_pc_procedure on trash.ProcedureID=tp_pc_procedure.ProcedureID "
  18473. + " where trash.barcode=:barcode";
  18474. #endregion
  18475. #region OracleParameter
  18476. OracleParameter[] paras = new OracleParameter[] {
  18477. new OracleParameter(":semicheckid",entity.SemiCheckID),
  18478. new OracleParameter(":semichecktype",entity.SemiCheckType),
  18479. new OracleParameter(":semicheckuserID",entity.SemiCheckUserID),
  18480. new OracleParameter(":semicheckusercode",entity.SemiCheckUserCode),
  18481. new OracleParameter(":remarks",entity.Remarks),
  18482. new OracleParameter(":accountid",sUserInfo.AccountID),
  18483. new OracleParameter(":createuserid",sUserInfo.UserID),
  18484. new OracleParameter(":updateuserid",sUserInfo.UserID),
  18485. new OracleParameter(":barcode",entity.BarCode),
  18486. new OracleParameter(":reworkprocedureid",entity.ReworkProcedureID),
  18487. new OracleParameter(":reworkprocedurecode",entity.ReworkProcedureCode),
  18488. new OracleParameter(":reworkuserid",entity.ReworkUserID),
  18489. new OracleParameter(":reworkusercode",entity.ReworkUserCode),
  18490. };
  18491. #endregion
  18492. foreach (OracleParameter para in paras)
  18493. {
  18494. if (string.IsNullOrEmpty(para.Value + ""))
  18495. {
  18496. para.Value = DBNull.Value;
  18497. }
  18498. }
  18499. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  18500. // 失败
  18501. if (result != Constant.INT_IS_ONE)
  18502. {
  18503. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  18504. }
  18505. // 成功返回null
  18506. return null;
  18507. }
  18508. /// <summary>
  18509. /// 添加半成品检验数据
  18510. /// </summary>
  18511. /// <param name="oracleTrConn">连接对象</param>
  18512. /// <param name="accountDate">账务日期</param>
  18513. /// <param name="productionData">生产数据</param>
  18514. /// <param name="sUserInfo">用户基本信息</param>
  18515. /// <returns>string</returns>
  18516. /// <remarks>
  18517. /// 陈冰 2014.09.18 新建
  18518. /// </remarks>
  18519. private static string SetSemiCheckDataValueFlag(IDBTransaction oracleTrConn, SemiCheckEntity entity, SUserInfo sUserInfo)
  18520. {
  18521. #region SQL
  18522. string sql = @"update TP_PM_SemiCheck
  18523. set BackOutUserID=:BackOutUserID,
  18524. BackOutUserCode=:BackOutUserCode,
  18525. BackOutFlag=1,
  18526. BackOutTime=sysdate,
  18527. ValueFlag='0',
  18528. updateuserid=:updateuserid
  18529. where semicheckid=:semicheckid";
  18530. #region OracleParameter
  18531. OracleParameter[] paras = new OracleParameter[] {
  18532. new OracleParameter(":semicheckid",entity.SemiCheckID),
  18533. new OracleParameter(":updateuserid",sUserInfo.UserID),
  18534. new OracleParameter(":BackOutUserID",sUserInfo.UserID),
  18535. new OracleParameter(":BackOutUserCode",sUserInfo.UserCode),
  18536. };
  18537. #endregion
  18538. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  18539. string sql2 = @"update TP_PM_SemiCheckDefect
  18540. set
  18541. ValueFlag='0',
  18542. updateuserid=:updateuserid
  18543. where semicheckid=:semicheckid";
  18544. string sql3 = @"update TP_PM_SCDefectResponsible
  18545. set
  18546. ValueFlag='0',
  18547. updateuserid=:updateuserid
  18548. where semicheckid=:semicheckid";
  18549. #endregion
  18550. #region OracleParameter
  18551. paras = new OracleParameter[] {
  18552. new OracleParameter(":semicheckid",entity.SemiCheckID),
  18553. new OracleParameter(":updateuserid",sUserInfo.UserID),
  18554. };
  18555. #endregion
  18556. foreach (OracleParameter para in paras)
  18557. {
  18558. if (string.IsNullOrEmpty(para.Value + ""))
  18559. {
  18560. para.Value = DBNull.Value;
  18561. }
  18562. }
  18563. result += oracleTrConn.ExecuteNonQuery(sql2, paras);
  18564. result += oracleTrConn.ExecuteNonQuery(sql3, paras);
  18565. // 失败
  18566. if (result == Constant.INT_IS_ZERO)
  18567. {
  18568. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  18569. }
  18570. // 成功返回null
  18571. return null;
  18572. }
  18573. /// <summary>
  18574. /// 保存半检缺陷
  18575. /// </summary>
  18576. /// <param name="oracleTrConn">连接对象</param>
  18577. /// <param name="productionDefect">缺陷数据</param>
  18578. /// <param name="sUserInfo">用户基本信息</param>
  18579. /// <returns>string</returns>
  18580. private static string AddSemiCheckDefect(IDBTransaction oracleTrConn, SemiCheckDefectEntity semiCheckDefect, SUserInfo sUserInfo)
  18581. {
  18582. // 查询新插入的半检缺陷ID
  18583. string sql = "select SEQ_PM_SemiCheckDefect_ID.nextval from dual";
  18584. string idStr = oracleTrConn.GetSqlResultToStr(sql);
  18585. int semiCheckDefectID = 0;
  18586. if (!string.IsNullOrEmpty(idStr))
  18587. {
  18588. semiCheckDefectID = int.Parse(idStr);
  18589. }
  18590. else
  18591. {
  18592. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  18593. }
  18594. #region SQL
  18595. sql = "insert into TP_PM_SemiCheckDefect"
  18596. + " (semicheckdefectid,"
  18597. + " semicheckid,"
  18598. + " defectid,"
  18599. + " defectcode,"
  18600. + " defectname,"
  18601. + " defectpositionid,"
  18602. + " defectpositioncode,"
  18603. + " defectpositionname,"
  18604. + " scrapResponFlag,"
  18605. + " defectproductiondataid,"
  18606. + " defectprocedureid,"
  18607. + " defectuserid,"
  18608. + " defectusercode,"
  18609. + " remarks,"
  18610. + " accountid,"
  18611. + " createuserid,"
  18612. + " updateuserid)"
  18613. + " values"
  18614. + " ("
  18615. + " :semicheckdefectid,"
  18616. + " :semicheckid,"
  18617. + " :defectid,"
  18618. + " :defectcode,"
  18619. + " :defectname,"
  18620. + " :defectpositionid,"
  18621. + " :defectpositioncode,"
  18622. + " :defectpositionname,"
  18623. + " :scrapResponFlag,"
  18624. + " :defectproductiondataid,"
  18625. + " :defectprocedureid,"
  18626. + " :defectuserid,"
  18627. + " :defectusercode,"
  18628. + " :remarks,"
  18629. + " :accountid,"
  18630. + " :createuserid,"
  18631. + " :updateuserid)";
  18632. #endregion
  18633. #region 参数
  18634. OracleParameter[] oracleParameters = new OracleParameter[] {
  18635. new OracleParameter(":semicheckdefectid",semiCheckDefectID),
  18636. new OracleParameter(":semicheckid",semiCheckDefect.SemiCheckID),
  18637. new OracleParameter(":defectid",semiCheckDefect.DefectID),
  18638. new OracleParameter(":defectcode",semiCheckDefect.DefectCode),
  18639. new OracleParameter(":defectname",semiCheckDefect.DefectName),
  18640. new OracleParameter(":defectpositionid",semiCheckDefect.DefectPositionID),
  18641. new OracleParameter(":defectpositioncode",semiCheckDefect.DefectPositionCode),
  18642. new OracleParameter(":defectpositionname",semiCheckDefect.DefectPositionName),
  18643. new OracleParameter(":scrapResponFlag",semiCheckDefect.ScrapResponFlag),
  18644. new OracleParameter(":defectproductiondataid",semiCheckDefect.DefectProductionDataID),
  18645. new OracleParameter(":defectprocedureid",semiCheckDefect.DefectProcedureID),
  18646. new OracleParameter(":defectuserid",semiCheckDefect.DefectUserID),
  18647. new OracleParameter(":defectusercode",semiCheckDefect.DefectUserCode),
  18648. new OracleParameter(":remarks",semiCheckDefect.Remarks),
  18649. new OracleParameter(":accountid",sUserInfo.AccountID),
  18650. new OracleParameter(":createuserid",sUserInfo.UserID),
  18651. new OracleParameter(":updateuserid",sUserInfo.UserID),
  18652. };
  18653. #endregion
  18654. int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  18655. // 保存失败
  18656. if (result != Constant.INT_IS_ONE)
  18657. {
  18658. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  18659. }
  18660. #region 插入生产缺陷责任者
  18661. if (semiCheckDefect.DefectResponsibles != null)
  18662. {
  18663. foreach (SemiCheckResponsibleEntity DefectResponsible in semiCheckDefect.DefectResponsibles)
  18664. {
  18665. #region SQL
  18666. sql = "insert into TP_PM_SCDefectResponsible"
  18667. + " (semicheckdefectid,"
  18668. + " staffid,"
  18669. + " semicheckid,"
  18670. + " userid,"
  18671. + " usercode,"
  18672. + " Ujobsid,"
  18673. + " SJobsID,"
  18674. + " staffstatus,"
  18675. + " accountid,"
  18676. + " createuserid,"
  18677. + " updateuserid)"
  18678. + " values"
  18679. + " (:semicheckdefectid,"
  18680. + " :staffid,"
  18681. + " :semicheckid,"
  18682. + " :userid,"
  18683. + " :usercode,"
  18684. + " :ujobsid,"
  18685. + " :sjobsid,"
  18686. + " :staffstatus,"
  18687. + " :accountid,"
  18688. + " :createuserid,"
  18689. + " :updateuserid)";
  18690. #endregion
  18691. #region 参数
  18692. oracleParameters = new OracleParameter[] {
  18693. new OracleParameter(":semicheckdefectid",semiCheckDefectID),
  18694. new OracleParameter(":staffid",DefectResponsible.StaffID),
  18695. new OracleParameter(":semicheckid",semiCheckDefect.SemiCheckID),
  18696. new OracleParameter(":userid",DefectResponsible.UserID),
  18697. new OracleParameter(":usercode",DefectResponsible.UserCode),
  18698. new OracleParameter(":ujobsid",DefectResponsible.UJobsID),
  18699. new OracleParameter(":sjobsid",DefectResponsible.SJobsID),
  18700. new OracleParameter(":staffstatus",DefectResponsible.StaffStatus),
  18701. new OracleParameter(":accountid",sUserInfo.AccountID),
  18702. new OracleParameter(":createuserid",sUserInfo.UserID),
  18703. new OracleParameter(":updateuserid",sUserInfo.UserID),
  18704. };
  18705. #endregion
  18706. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  18707. // 保存失败
  18708. if (result != Constant.INT_IS_ONE)
  18709. {
  18710. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  18711. }
  18712. }
  18713. }
  18714. #endregion
  18715. return null;
  18716. }
  18717. /// <summary>
  18718. /// 添加责任工序
  18719. /// </summary>
  18720. /// <param name="oracleTrConn">连接对象</param>
  18721. /// <param name="responProce">责任工序</param>
  18722. /// <param name="productionDefect">缺陷数据</param>
  18723. /// <param name="sUserInfo">用户基本信息</param>
  18724. /// <returns>string</returns>
  18725. private static string AddSemiCheckResponProcedure(IDBTransaction oracleTrConn, ResponProcedureEntity responProce, SemiCheckDefectEntity productionDefect, SUserInfo sUserInfo)
  18726. {
  18727. OracleParameter[] oracleParameters = null;
  18728. string sql = null;
  18729. int result = 0;
  18730. // 查询新插入ID
  18731. if (responProce.ProcedureID != null)
  18732. {
  18733. sql = "select SEQ_PM_ResponProcedure_ID.nextval from dual";
  18734. string idStr = oracleTrConn.GetSqlResultToStr(sql);
  18735. if (!string.IsNullOrEmpty(idStr))
  18736. {
  18737. responProce.ResponProcedureID = int.Parse(idStr);
  18738. }
  18739. else
  18740. {
  18741. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  18742. }
  18743. #region SQL
  18744. sql = "insert into tp_pm_responprocedure"
  18745. + " (ResponProcedureID,"
  18746. + " scrapproductid,"
  18747. + " barcode,"
  18748. + " productiondataid,"
  18749. + " productionlineid,"
  18750. + " productionlinecode,"
  18751. + " productionlinename,"
  18752. + " procedureid,"
  18753. + " procedurecode,"
  18754. + " procedurename,"
  18755. + " userid,"
  18756. + " usercode,"
  18757. + " username,"
  18758. + " remarks,"
  18759. + " accountid,"
  18760. + " createuserid,"
  18761. + " updateuserid)"
  18762. + " values"
  18763. + " ("
  18764. + " :ResponProcedureID,"
  18765. + " :scrapproductid,"
  18766. + " :barcode,"
  18767. + " :productiondataid,"
  18768. + " :productionlineid,"
  18769. + " :productionlinecode,"
  18770. + " :productionlinename,"
  18771. + " :procedureid,"
  18772. + " :procedurecode,"
  18773. + " :procedurename,"
  18774. + " :userid,"
  18775. + " :usercode,"
  18776. + " :username,"
  18777. + " :remarks,"
  18778. + " :accountid,"
  18779. + " :createuserid,"
  18780. + " :updateuserid)";
  18781. #endregion
  18782. #region 参数
  18783. oracleParameters = new OracleParameter[] {
  18784. new OracleParameter(":ResponProcedureID",responProce.ResponProcedureID),
  18785. new OracleParameter(":scrapproductid",responProce.ScrapProductID),
  18786. new OracleParameter(":barcode",responProce.BarCode),
  18787. new OracleParameter(":productiondataid",responProce.ProductionDataID),
  18788. new OracleParameter(":productionlineid",responProce.ProductionLineID),
  18789. new OracleParameter(":productionlinecode",responProce.ProductionLineCode),
  18790. new OracleParameter(":productionlinename",responProce.ProductionLineName),
  18791. new OracleParameter(":procedureid",responProce.ProcedureID),
  18792. new OracleParameter(":procedurecode",responProce.ProcedureCode),
  18793. new OracleParameter(":procedurename",responProce.ProcedureName),
  18794. new OracleParameter(":userid",responProce.UserID),
  18795. new OracleParameter(":usercode",responProce.UserCode),
  18796. new OracleParameter(":username",responProce.UserName),
  18797. new OracleParameter(":remarks",responProce.Remarks),
  18798. new OracleParameter(":accountid",sUserInfo.AccountID),
  18799. new OracleParameter(":createuserid",sUserInfo.UserID),
  18800. new OracleParameter(":updateuserid",sUserInfo.UserID),
  18801. };
  18802. #endregion
  18803. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  18804. // 保存失败
  18805. if (result != Constant.INT_IS_ONE)
  18806. {
  18807. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  18808. }
  18809. //// 查询新插入ID
  18810. //sql = "select SEQ_PM_ResponProcedure_ID.Currval from dual";
  18811. //string idStr = oracleTrConn.GetSqlResultToStr(sql);
  18812. //if (!string.IsNullOrEmpty(idStr))
  18813. //{
  18814. // responProce.ResponProcedureID = int.Parse(idStr);
  18815. //}
  18816. //else
  18817. //{
  18818. // return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  18819. //}
  18820. }
  18821. #region 插入责任人
  18822. foreach (SemiCheckResponsibleEntity defectResponsible in productionDefect.DefectResponsibles)
  18823. {
  18824. #region SQL
  18825. sql = "insert into tp_pm_scrapresponsible"
  18826. + " (barcode,"
  18827. + " scrapproductid,"
  18828. + " staffid,"
  18829. + " userid,"
  18830. + " usercode,"
  18831. + " ujobsid,"
  18832. + " sjobsid,"
  18833. + " staffstatus,"
  18834. + " accountid,"
  18835. + " createuserid,"
  18836. + " updateuserid,"
  18837. + " responprocedureid,"
  18838. + " respontype)"
  18839. + " values"
  18840. + " (:barcode,"
  18841. + " :scrapproductid,"
  18842. + " :staffid,"
  18843. + " :userid,"
  18844. + " :usercode,"
  18845. + " :ujobsid,"
  18846. + " :sjobsid,"
  18847. + " :staffstatus,"
  18848. + " :accountid,"
  18849. + " :createuserid,"
  18850. + " :updateuserid,"
  18851. + " :responprocedureid,"
  18852. + " :respontype)";
  18853. #endregion
  18854. #region 参数
  18855. oracleParameters = new OracleParameter[] {
  18856. new OracleParameter(":scrapproductid",responProce.ScrapProductID),
  18857. new OracleParameter(":barcode",responProce.BarCode),
  18858. new OracleParameter(":staffid",defectResponsible.StaffID),
  18859. new OracleParameter(":userid",defectResponsible.UserID),
  18860. new OracleParameter(":usercode",defectResponsible.UserCode),
  18861. new OracleParameter(":ujobsid",defectResponsible.UJobsID),
  18862. new OracleParameter(":sjobsid",defectResponsible.SJobsID),
  18863. new OracleParameter(":staffstatus",defectResponsible.StaffStatus),
  18864. new OracleParameter(":accountid",sUserInfo.AccountID),
  18865. new OracleParameter(":createuserid",sUserInfo.UserID),
  18866. new OracleParameter(":updateuserid",sUserInfo.UserID),
  18867. new OracleParameter(":responprocedureid",responProce.ResponProcedureID),
  18868. new OracleParameter(":respontype", (responProce.ResponProcedureID == null? (int)Constant.ScrapResponType.Person:(int)Constant.ScrapResponType.Procedure)),
  18869. };
  18870. #endregion
  18871. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  18872. // 保存失败
  18873. if (result != Constant.INT_IS_ONE)
  18874. {
  18875. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  18876. }
  18877. }
  18878. #endregion
  18879. return null;
  18880. }
  18881. #region 复检
  18882. /// <summary>
  18883. /// 复检数据
  18884. /// </summary>
  18885. /// <param name="oracleTrConn">数据连接对象</param>
  18886. /// <param name="entity">半检实体类</param>
  18887. /// <param name="sUserInfo">用户基本信息</param>
  18888. /// <returns>string</returns>
  18889. /// <remarks>
  18890. /// 王鑫 2016.06.28 新建
  18891. /// </remarks>
  18892. private static string AddReSemiCheck(IDBTransaction oracleTrConn,
  18893. SemiCheckEntity entity,
  18894. SUserInfo sUserInfo)
  18895. {
  18896. try
  18897. {
  18898. // 获得账务日期
  18899. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  18900. string errMsg = string.Empty;
  18901. #region 校验条码有效性
  18902. errMsg = CheckBarcodeByEditRework(oracleTrConn, entity.BarCode, sUserInfo);
  18903. if (!string.IsNullOrEmpty(errMsg))
  18904. {
  18905. return errMsg;
  18906. }
  18907. #endregion
  18908. //------------------------------
  18909. #region 条码是不合格 删除在产产品数据
  18910. if (entity.ReSemiCheckType == "2") //编辑时不合格
  18911. {
  18912. #region 修改半检登记的复检状态=2不合格(返)、复检工号=当前工号、复检时间=sysdate。
  18913. string sqlUpdate = @"update TP_PM_SemiCheck set ReSemiCheckType='2' ,ReSemiCheckUserID=:ReSemiCheckUserID,
  18914. ReSemiCheckUserCode=:ReSemiCheckUserCode,ReSemiCheckTime=sysdate,updateuserid=:updateuserid where SemiCheckID=:SemiCheckID";
  18915. OracleParameter[] oracleParameters = new OracleParameter[] {
  18916. new OracleParameter(":ReSemiCheckUserID",sUserInfo.UserID),
  18917. new OracleParameter(":ReSemiCheckUserCode",sUserInfo.UserCode),
  18918. new OracleParameter(":SemiCheckID",entity.SemiCheckID),
  18919. new OracleParameter(":updateuserid",sUserInfo.UserID),
  18920. };
  18921. int result = oracleTrConn.ExecuteNonQuery(sqlUpdate, oracleParameters);
  18922. // 保存失败
  18923. if (result != Constant.INT_IS_ONE)
  18924. {
  18925. errMsg = string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  18926. }
  18927. #endregion
  18928. #region 条码有缺陷
  18929. #region 是次品 添加废弃产品
  18930. string ResponProcedureidStr = "";
  18931. if (entity.ReSemiCheckType == "2") //新建时不合格,直接报损
  18932. {
  18933. #region 添加废弃产品
  18934. ScrapProductEntity scrapProduct = new ScrapProductEntity();
  18935. #region 属性赋值
  18936. scrapProduct.BarCode = entity.BarCode;
  18937. scrapProduct.ScrapType = Constant.ScrapType.Substandard.GetHashCode();
  18938. scrapProduct.ResponType = Constant.ScrapResponType.Procedure.GetHashCode();
  18939. scrapProduct.ScrapDate = accountDate;
  18940. scrapProduct.Rreason = Constant.SCRAPTYPE_NOPASSREWORK;
  18941. scrapProduct.AuditStatus = Constant.AuditStatus.Agree.GetHashCode();
  18942. scrapProduct.Auditor = sUserInfo.UserID;
  18943. scrapProduct.AuditlDate = accountDate;
  18944. scrapProduct.AccountDate = accountDate;
  18945. sqlUpdate = "select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=14 and accountid=" + sUserInfo.AccountID;
  18946. DataSet ds = oracleTrConn.GetSqlResultToDs(sqlUpdate);
  18947. if (ds != null && ds.Tables[0].Rows.Count > 0)
  18948. {
  18949. scrapProduct.GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]);
  18950. }
  18951. scrapProduct.GoodsLevelTypeID = 14;
  18952. //scrapProduct.GoodsLevelID = entity.GoodsLevelID;
  18953. //scrapProduct.GoodsLevelTypeID = entity.GoodsLevelTypeID;
  18954. scrapProduct.IsPublicBody = IsPubilcByBarCode(oracleTrConn, entity.BarCode);
  18955. // 查询新插入的废弃ID
  18956. string ResponProceduresql = "select SEQ_PM_ScrapProduct_ID.nextval from dual";
  18957. ResponProcedureidStr = oracleTrConn.GetSqlResultToStr(ResponProceduresql);
  18958. scrapProduct.ScrapProductID = Convert.ToInt32(ResponProcedureidStr);
  18959. scrapProduct.ScrapType = 3;
  18960. #endregion
  18961. // 保存报废
  18962. errMsg = AddScrapProduct(oracleTrConn, scrapProduct, sUserInfo);
  18963. // 保存失败
  18964. if (!string.IsNullOrEmpty(errMsg))
  18965. {
  18966. return errMsg;
  18967. }
  18968. #endregion
  18969. }
  18970. #endregion
  18971. // 存在缺陷 插入缺陷表
  18972. if (entity.SemiCheckDefects != null)
  18973. {
  18974. foreach (SemiCheckDefectEntity semiCheckDefect in entity.SemiCheckDefects)
  18975. {
  18976. #region 保存缺陷
  18977. //semiCheckDefect.SemiCheckID = Convert.ToInt32(semiCheckDefect.SemiCheckID);
  18978. //semiCheckDefect.ScrapResponFlag
  18979. // = string.IsNullOrEmpty(semiCheckDefect.ScrapResponFlag) ? "0" : semiCheckDefect.ScrapResponFlag;
  18980. //// 保存缺陷
  18981. //errMsg = AddSemiCheckDefect(oracleTrConn, semiCheckDefect, sUserInfo);
  18982. //if (!string.IsNullOrEmpty(errMsg))
  18983. //{
  18984. // return errMsg;
  18985. //}
  18986. #endregion
  18987. #region 是不合格 添加废弃责任工序
  18988. if (entity.ReSemiCheckType == "2")
  18989. {
  18990. //if (semiCheckDefect.DefectProcedureID != null)
  18991. {
  18992. #region 添加责任工序
  18993. ResponProcedureEntity responProce = new ResponProcedureEntity();
  18994. #region 属性赋值
  18995. responProce.BarCode = entity.BarCode;
  18996. // 新建-不合格 获取生产线及生产数据ID
  18997. sqlUpdate = "select ProductionLineID,ProductionLineCode,ProductionLineName,ProductionDataID from TP_PM_InProduction where barcode=:barcode";
  18998. oracleParameters = new OracleParameter[] {
  18999. new OracleParameter(":barcode",entity.BarCode),
  19000. };
  19001. DataSet ds = oracleTrConn.GetSqlResultToDs(sqlUpdate, oracleParameters);
  19002. if (ds != null && ds.Tables[0].Rows.Count > 0)
  19003. {
  19004. responProce.ProductionDataID = Convert.ToInt32(ds.Tables[0].Rows[0]["ProductionDataID"]);
  19005. responProce.ProductionLineID = Convert.ToInt32(ds.Tables[0].Rows[0]["ProductionLineID"]);
  19006. responProce.ProductionLineCode = ds.Tables[0].Rows[0]["ProductionLineCode"].ToString();
  19007. responProce.ProductionLineName = ds.Tables[0].Rows[0]["ProductionLineName"].ToString();
  19008. }
  19009. //responProce.ProductionDataID = semiCheckDefect.ProductionDataID;
  19010. //responProce.ProductionLineID = semiCheckDefect.ProductionLineID;
  19011. //responProce.ProductionLineCode = semiCheckDefect.ProductionLineCode;
  19012. //responProce.ProductionLineName = semiCheckDefect.ProductionLineName;
  19013. responProce.ProcedureID = semiCheckDefect.DefectProcedureID;
  19014. responProce.ProcedureCode = semiCheckDefect.DefectProcedureCode;
  19015. responProce.ProcedureName = semiCheckDefect.DefectProcedureName;
  19016. responProce.UserID = semiCheckDefect.DefectUserID;
  19017. responProce.UserCode = semiCheckDefect.DefectUserCode;
  19018. responProce.UserName = semiCheckDefect.DefectUserName;
  19019. responProce.Remarks = semiCheckDefect.Remarks;
  19020. responProce.ScrapProductID = Convert.ToInt32(ResponProcedureidStr);
  19021. #endregion
  19022. // 保存责任工序
  19023. errMsg = AddSemiCheckResponProcedure(oracleTrConn, responProce, semiCheckDefect, sUserInfo);
  19024. // 保存失败
  19025. if (!string.IsNullOrEmpty(errMsg))
  19026. {
  19027. return errMsg;
  19028. }
  19029. #endregion
  19030. }
  19031. }
  19032. #endregion
  19033. }
  19034. }
  19035. #endregion
  19036. // 1.在产表产品设置产品等级【14不合格返】。
  19037. string sql = @"update TP_PM_InProduction set GoodsLevelID=
  19038. (
  19039. select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=14 and accountid=:accountid
  19040. ),GoodsLevelTypeID=14,updateuserid=:updateuserid
  19041. where barcode=:barcode";
  19042. oracleParameters = new OracleParameter[] {
  19043. new OracleParameter(":accountid", sUserInfo.AccountID),
  19044. // new OracleParameter(":updateuserid",scrapProduct.GoodsLevelTypeID),
  19045. new OracleParameter(":barcode",entity.BarCode),
  19046. new OracleParameter(":updateuserid",sUserInfo.UserID),
  19047. };
  19048. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  19049. // 注浆明细 产品等级
  19050. sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=14,updateuserid=:updateuserid
  19051. where barcode=:barcode";
  19052. oracleParameters = new OracleParameter[] {
  19053. new OracleParameter(":accountid", sUserInfo.AccountID),
  19054. new OracleParameter(":barcode",entity.BarCode),
  19055. new OracleParameter(":updateuserid",sUserInfo.UserID),
  19056. };
  19057. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  19058. // 2.将在产数据保存到在产回收站表中(产品等级【14不合格返】)。
  19059. string sqlInsert = @"insert into TP_PM_InProductionTrash
  19060. (
  19061. BarCode,
  19062. ProductionLineID,
  19063. ProductionLineCode,
  19064. ProductionLineName,
  19065. ProcedureModel,
  19066. ModelType,
  19067. DefectFlag,
  19068. ReworkProcedureID,
  19069. IsPublicBody,
  19070. IsReFire,
  19071. GoodsLevelID,
  19072. GoodsLevelTypeID,
  19073. GoodsID,
  19074. GoodsCode,
  19075. GoodsName,
  19076. UserID,
  19077. GroutingDailyID,
  19078. GroutingDailyDetailID,
  19079. GroutingDate,
  19080. GroutingLineID,
  19081. GroutingLineCode,
  19082. GroutingLineName,
  19083. GMouldTypeID,
  19084. CanManyTimes,
  19085. GroutingLineDetailID,
  19086. GroutingMouldCode,
  19087. MouldCode,
  19088. GroutingUserID,
  19089. GroutingUserCode,
  19090. GroutingNum,
  19091. Remarks,
  19092. KilnID,
  19093. KilnCode,
  19094. KilnName,
  19095. KilnCarID,
  19096. KilnCarCode,
  19097. KilnCarName,
  19098. KilnCarBatchNo,
  19099. KilnCarPosition,
  19100. AccountID,
  19101. ValueFlag,
  19102. CreateUserID,
  19103. UpdateUserID,
  19104. SpecialRepairflag,
  19105. FlowProcedureID,
  19106. FlowProcedureTime,
  19107. ProcedureID,
  19108. ProcedureTime,
  19109. ProductionDataID,
  19110. logoid,ISREWORKFLAG,
  19111. SemiCheckID
  19112. )
  19113. select
  19114. BarCode,
  19115. ProductionLineID,
  19116. ProductionLineCode,
  19117. ProductionLineName,
  19118. ProcedureModel,
  19119. ModelType,
  19120. DefectFlag,
  19121. ReworkProcedureID,
  19122. IsPublicBody,
  19123. IsReFire,
  19124. --GoodsLevelID,
  19125. --GoodsLevelTypeID,
  19126. (
  19127. select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=14 and accountid=:accountid
  19128. ),14,
  19129. GoodsID,
  19130. GoodsCode,
  19131. GoodsName,
  19132. UserID,
  19133. GroutingDailyID,
  19134. GroutingDailyDetailID,
  19135. GroutingDate,
  19136. GroutingLineID,
  19137. GroutingLineCode,
  19138. GroutingLineName,
  19139. GMouldTypeID,
  19140. CanManyTimes,
  19141. GroutingLineDetailID,
  19142. GroutingMouldCode,
  19143. MouldCode,
  19144. GroutingUserID,
  19145. GroutingUserCode,
  19146. GroutingNum,
  19147. Remarks,
  19148. KilnID,
  19149. KilnCode,
  19150. KilnName,
  19151. KilnCarID,
  19152. KilnCarCode,
  19153. KilnCarName,
  19154. KilnCarBatchNo,
  19155. KilnCarPosition,
  19156. AccountID,
  19157. ValueFlag,
  19158. :CreateUserID,
  19159. :UpdateUserID,
  19160. SpecialRepairflag,
  19161. FlowProcedureID,
  19162. FlowProcedureTime,
  19163. FlowProcedureID,
  19164. ProcedureTime,
  19165. ProductionDataID,
  19166. logoid,ISREWORKFLAG,
  19167. SemiCheckID
  19168. from TP_PM_InProduction
  19169. where barcode=:barcode
  19170. ";
  19171. oracleParameters = new OracleParameter[] {
  19172. new OracleParameter(":barcode",entity.BarCode),
  19173. new OracleParameter(":CreateUserID",sUserInfo.UserID),
  19174. new OracleParameter(":UpdateUserID",sUserInfo.UserID),
  19175. new OracleParameter(":accountid", sUserInfo.AccountID),
  19176. };
  19177. result += oracleTrConn.ExecuteNonQuery(sqlInsert, oracleParameters);
  19178. // 删除在产数据
  19179. sql = "delete tp_pm_inproduction where barcode = :barcode";
  19180. oracleParameters = new OracleParameter[] {
  19181. new OracleParameter(":barcode",entity.BarCode),
  19182. };
  19183. result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  19184. }
  19185. else if (entity.ReSemiCheckType == "1") //正常
  19186. {
  19187. #region 修改半检登记的复检状态=1合格(返)、复检工号=当前工号、复检时间=sysdate。
  19188. string sqlUpdate = @"update TP_PM_SemiCheck set ReSemiCheckType='1' ,ReSemiCheckUserID=:ReSemiCheckUserID,
  19189. ReSemiCheckUserCode=:ReSemiCheckUserCode,ReSemiCheckTime=sysdate,updateuserid=:updateuserid where SemiCheckID=:SemiCheckID";
  19190. OracleParameter[] oracleParameters = new OracleParameter[] {
  19191. new OracleParameter(":ReSemiCheckUserID",sUserInfo.UserID),
  19192. new OracleParameter(":ReSemiCheckUserCode",sUserInfo.UserCode),
  19193. new OracleParameter(":SemiCheckID",entity.SemiCheckID),
  19194. new OracleParameter(":updateuserid",sUserInfo.UserID),
  19195. };
  19196. int result = oracleTrConn.ExecuteNonQuery(sqlUpdate, oracleParameters);
  19197. // 保存失败
  19198. if (result != Constant.INT_IS_ONE)
  19199. {
  19200. errMsg = string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  19201. }
  19202. #endregion
  19203. #region 3.修改在产产品数据,在产表产品设置非返工状态(IsReworkFlag = '0'),半检登记ID=null(半检登记ID不变)。
  19204. string sql = "update tp_pm_inproduction set GoodsLevelTypeID=1, IsReworkFlag='0',UpdateUserID=:UpdateUserID where barcode = :barcode";
  19205. oracleParameters = new OracleParameter[] {
  19206. new OracleParameter(":barcode",entity.BarCode),
  19207. new OracleParameter(":UpdateUserID",sUserInfo.UserID),
  19208. };
  19209. result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  19210. // 注浆明细 产品等级
  19211. sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=1,updateuserid=:updateuserid
  19212. where barcode=:barcode";
  19213. oracleParameters = new OracleParameter[] {
  19214. new OracleParameter(":accountid", sUserInfo.AccountID),
  19215. new OracleParameter(":barcode",entity.BarCode),
  19216. new OracleParameter(":updateuserid",sUserInfo.UserID),
  19217. };
  19218. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  19219. #endregion
  19220. }
  19221. #endregion
  19222. //------------------------------
  19223. return errMsg;
  19224. }
  19225. catch (Exception ex)
  19226. {
  19227. throw ex;
  19228. }
  19229. }
  19230. #endregion
  19231. #region 撤销复检
  19232. /// <summary>
  19233. /// 撤销复检数据
  19234. /// </summary>
  19235. /// <param name="oracleTrConn">数据连接对象</param>
  19236. /// <param name="entity">半检实体类</param>
  19237. /// <param name="sUserInfo">用户基本信息</param>
  19238. /// <returns>string</returns>
  19239. /// <remarks>
  19240. /// 王鑫 2016.06.28 新建
  19241. /// </remarks>
  19242. private static string AddCancelSemiCheck(IDBTransaction oracleTrConn,
  19243. SemiCheckEntity entity,
  19244. SUserInfo sUserInfo)
  19245. {
  19246. try
  19247. {
  19248. // 获得账务日期
  19249. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  19250. string errMsg = string.Empty;
  19251. string sql = null;
  19252. #region 校验条码有效性
  19253. if (entity.ReSemiCheckType == "1") //撤销合格
  19254. {
  19255. errMsg = CheckBarcodeByCancelReSemiCheckPass(oracleTrConn, entity.BarCode, sUserInfo);
  19256. }
  19257. else if (entity.ReSemiCheckType == "2") //撤销不合格
  19258. {
  19259. errMsg = CheckBarcodeByCancelReSemiCheckNoPass(oracleTrConn, entity.BarCode, sUserInfo);
  19260. }
  19261. if (!string.IsNullOrEmpty(errMsg))
  19262. {
  19263. return errMsg;
  19264. }
  19265. #endregion
  19266. if (entity.ReSemiCheckType == "1") //撤销合格
  19267. {
  19268. #region 在产表产品设置返工状态(IsReworkFlag = '1')。
  19269. sql = "update tp_pm_inproduction set GoodsLevelTypeID=2, IsReworkFlag='1',UpdateUserID=:UpdateUserID where barcode = :barcode";
  19270. OracleParameter[] oracleParameters = new OracleParameter[] {
  19271. new OracleParameter(":barcode",entity.BarCode),
  19272. new OracleParameter(":UpdateUserID",sUserInfo.UserID),
  19273. };
  19274. int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  19275. // 注浆明细 产品等级
  19276. sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=2,updateuserid=:updateuserid
  19277. where barcode=:barcode";
  19278. oracleParameters = new OracleParameter[] {
  19279. new OracleParameter(":accountid", sUserInfo.AccountID),
  19280. new OracleParameter(":barcode",entity.BarCode),
  19281. new OracleParameter(":updateuserid",sUserInfo.UserID),
  19282. };
  19283. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  19284. #endregion
  19285. #region .半检登记的复检状态=0未复检,复检工号=null,复检时间=null。
  19286. // 复检撤销不需要记录撤销标识 - chenxy
  19287. string sqlUpdate = @"update TP_PM_SemiCheck set ReSemiCheckType='0' ,ReSemiCheckUserID=null,
  19288. ReSemiCheckUserCode=null,ReSemiCheckTime=null,updateuserid=:updateuserid
  19289. --,BackOutFlag=1,BackOutTime=sysdate,BackOutUserID=:BackOutUserID,BackOutUserCode=:BackOutUserCode
  19290. where SemiCheckID=:SemiCheckID";
  19291. oracleParameters = new OracleParameter[] {
  19292. new OracleParameter(":SemiCheckID",entity.SemiCheckID),
  19293. new OracleParameter(":updateuserid",sUserInfo.UserID),
  19294. //new OracleParameter(":BackOutUserID",sUserInfo.UserID),
  19295. //new OracleParameter(":BackOutUserCode",sUserInfo.UserCode),
  19296. };
  19297. result = oracleTrConn.ExecuteNonQuery(sqlUpdate, oracleParameters);
  19298. // 保存失败
  19299. if (result != Constant.INT_IS_ONE)
  19300. {
  19301. errMsg = string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  19302. }
  19303. #endregion
  19304. }
  19305. else if (entity.ReSemiCheckType == "2") //撤销不合格
  19306. {
  19307. #region 从在产回收站中把数据恢复到在产表中。
  19308. string sqlInsert = @"insert into TP_PM_InProduction
  19309. (
  19310. BarCode,
  19311. ProductionLineID,
  19312. ProductionLineCode,
  19313. ProductionLineName,
  19314. ProcedureModel,
  19315. ModelType,
  19316. DefectFlag,
  19317. ReworkProcedureID,
  19318. IsPublicBody,
  19319. IsReFire,
  19320. GoodsLevelID,
  19321. GoodsLevelTypeID,
  19322. GoodsID,
  19323. GoodsCode,
  19324. GoodsName,
  19325. UserID,
  19326. GroutingDailyID,
  19327. GroutingDailyDetailID,
  19328. GroutingDate,
  19329. GroutingLineID,
  19330. GroutingLineCode,
  19331. GroutingLineName,
  19332. GMouldTypeID,
  19333. CanManyTimes,
  19334. GroutingLineDetailID,
  19335. GroutingMouldCode,
  19336. MouldCode,
  19337. GroutingUserID,
  19338. GroutingUserCode,
  19339. GroutingNum,
  19340. Remarks,
  19341. KilnID,
  19342. KilnCode,
  19343. KilnName,
  19344. KilnCarID,
  19345. KilnCarCode,
  19346. KilnCarName,
  19347. KilnCarBatchNo,
  19348. KilnCarPosition,
  19349. AccountID,
  19350. ValueFlag,
  19351. CreateUserID,
  19352. UpdateUserID,
  19353. SpecialRepairflag,
  19354. FlowProcedureID,
  19355. FlowProcedureTime,
  19356. ProcedureID,
  19357. ProcedureTime,
  19358. ProductionDataID,
  19359. logoid,ISREWORKFLAG,
  19360. SemiCheckID
  19361. )
  19362. select
  19363. BarCode,
  19364. ProductionLineID,
  19365. ProductionLineCode,
  19366. ProductionLineName,
  19367. ProcedureModel,
  19368. ModelType,
  19369. DefectFlag,
  19370. ReworkProcedureID,
  19371. IsPublicBody,
  19372. IsReFire,
  19373. GoodsLevelID,
  19374. GoodsLevelTypeID,
  19375. GoodsID,
  19376. GoodsCode,
  19377. GoodsName,
  19378. UserID,
  19379. GroutingDailyID,
  19380. GroutingDailyDetailID,
  19381. GroutingDate,
  19382. GroutingLineID,
  19383. GroutingLineCode,
  19384. GroutingLineName,
  19385. GMouldTypeID,
  19386. CanManyTimes,
  19387. GroutingLineDetailID,
  19388. GroutingMouldCode,
  19389. MouldCode,
  19390. GroutingUserID,
  19391. GroutingUserCode,
  19392. GroutingNum,
  19393. Remarks,
  19394. KilnID,
  19395. KilnCode,
  19396. KilnName,
  19397. KilnCarID,
  19398. KilnCarCode,
  19399. KilnCarName,
  19400. KilnCarBatchNo,
  19401. KilnCarPosition,
  19402. AccountID,
  19403. ValueFlag,
  19404. :CreateUserID,
  19405. :UpdateUserID,
  19406. SpecialRepairflag,
  19407. FlowProcedureID,
  19408. FlowProcedureTime,
  19409. FlowProcedureID,
  19410. ProcedureTime,
  19411. ProductionDataID,
  19412. logoid,ISREWORKFLAG,
  19413. SemiCheckID
  19414. from TP_PM_InProductionTrash
  19415. where barcode=:barcode
  19416. ";
  19417. OracleParameter[] oracleParameters = new OracleParameter[] {
  19418. new OracleParameter(":barcode",entity.BarCode),
  19419. new OracleParameter(":CreateUserID",sUserInfo.UserID),
  19420. new OracleParameter(":UpdateUserID",sUserInfo.UserID),
  19421. };
  19422. int result = oracleTrConn.ExecuteNonQuery(sqlInsert, oracleParameters);
  19423. #endregion
  19424. #region 1.废弃产品表中对应的总单数据和明细数据valueflag='0'。
  19425. OracleParameter[] spParameters = null;
  19426. int spResult = 0;
  19427. string sqlString = "select max(sp.scrapproductid) scrapproductid\n" +
  19428. " from TP_PM_ScrapProduct sp\n" +
  19429. " where sp.barcode = :barcode\n" +
  19430. " and sp.auditstatus = 1\n" +
  19431. " and sp.valueflag = '1'\n" +
  19432. " and sp.scraptype = '3'";
  19433. spParameters = new OracleParameter[] {
  19434. new OracleParameter(":barcode",entity.BarCode),
  19435. };
  19436. string scrapproductid = oracleTrConn.GetSqlResultToStr(sqlString, spParameters);
  19437. sqlString = @"update TP_PM_ScrapProduct set valueflag='0', updateuserid=:updateuserid, backouttime=sysdate where scrapproductid=:scrapproductid";
  19438. spParameters = new OracleParameter[] {
  19439. new OracleParameter(":updateuserid",sUserInfo.UserID),
  19440. new OracleParameter(":scrapproductid",scrapproductid),
  19441. };
  19442. spResult = oracleTrConn.ExecuteNonQuery(sqlString, spParameters);
  19443. sqlString = @"update TP_PM_ResponProcedure set valueflag='0', updateuserid=:updateuserid where scrapproductid=:scrapproductid";
  19444. //oracleParameters = new OracleParameter[] {
  19445. // new OracleParameter(":barcode",entity.BarCode),
  19446. //};
  19447. spResult += oracleTrConn.ExecuteNonQuery(sqlString, spParameters);
  19448. //string sql = @"update TP_PM_ScrapProduct set valueflag='0' where barcode=:barcode";
  19449. //oracleParameters = new OracleParameter[] {
  19450. // new OracleParameter(":barcode",entity.BarCode),
  19451. // };
  19452. //result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  19453. //sql = @"update TP_PM_ResponProcedure set valueflag='0' where barcode=:barcode";
  19454. //oracleParameters = new OracleParameter[] {
  19455. // new OracleParameter(":barcode",entity.BarCode),
  19456. // };
  19457. //result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  19458. ////sql = @"update TP_PM_ScrapResponsible set valueflag='0' where barcode=:barcode";
  19459. ////oracleParameters = new OracleParameter[] {
  19460. //// new OracleParameter(":barcode",entity.BarCode),
  19461. //// };
  19462. ////result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  19463. #endregion
  19464. #region 删除在产回收站数据
  19465. sql = "delete TP_PM_InProductionTrash where barcode = :barcode";
  19466. oracleParameters = new OracleParameter[] {
  19467. new OracleParameter(":barcode",entity.BarCode),
  19468. };
  19469. result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  19470. #endregion
  19471. #region .在产表产品设置返工状态(IsReworkFlag = '1')。
  19472. sql = "update tp_pm_inproduction set GoodsLevelTypeID=2,IsReworkFlag='1',UpdateUserID=:UpdateUserID where barcode = :barcode";
  19473. oracleParameters = new OracleParameter[] {
  19474. new OracleParameter(":barcode",entity.BarCode),
  19475. new OracleParameter(":UpdateUserID",sUserInfo.UserID),
  19476. };
  19477. result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  19478. // 注浆明细 产品等级
  19479. sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=2,updateuserid=:updateuserid
  19480. where barcode=:barcode";
  19481. oracleParameters = new OracleParameter[] {
  19482. new OracleParameter(":accountid", sUserInfo.AccountID),
  19483. new OracleParameter(":barcode",entity.BarCode),
  19484. new OracleParameter(":updateuserid",sUserInfo.UserID),
  19485. };
  19486. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  19487. #endregion
  19488. #region 6.半检登记的复检状态=0未复检,复检工号=null,复检时间=null。
  19489. // 复检撤销不需要记录撤销标识 - chenxy
  19490. string sqlUpdate = @"update TP_PM_SemiCheck set ReSemiCheckType='0' ,ReSemiCheckUserID=null,
  19491. ReSemiCheckUserCode=null,ReSemiCheckTime=null,updateuserid=:updateuserid
  19492. --,BackOutFlag=1,BackOutTime=sysdate,BackOutUserID=:BackOutUserID,BackOutUserCode=:BackOutUserCode
  19493. where SemiCheckID=:SemiCheckID";
  19494. oracleParameters = new OracleParameter[] {
  19495. //new OracleParameter(":ReSemiCheckUserID",entity.ReSemiCheckUserID),
  19496. //new OracleParameter(":ReSemiCheckUserCode",entity.ReSemiCheckUserCode),
  19497. new OracleParameter(":SemiCheckID",entity.SemiCheckID),
  19498. new OracleParameter(":updateuserid",sUserInfo.UserID),
  19499. //new OracleParameter(":BackOutUserID",sUserInfo.UserID),
  19500. //new OracleParameter(":BackOutUserCode",sUserInfo.UserCode),
  19501. };
  19502. result = oracleTrConn.ExecuteNonQuery(sqlUpdate, oracleParameters);
  19503. // 保存失败
  19504. if (result != Constant.INT_IS_ONE)
  19505. {
  19506. errMsg = string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  19507. }
  19508. #endregion
  19509. }
  19510. return errMsg;
  19511. }
  19512. catch (Exception ex)
  19513. {
  19514. throw ex;
  19515. }
  19516. }
  19517. #endregion
  19518. /// <summary>
  19519. /// 校验条码有效(撤销复检-不合格)
  19520. /// </summary>
  19521. /// <param name="oracleTrConn">连接对象</param>
  19522. /// <param name="barcode">条码</param>
  19523. /// <param name="sUserInfo">登录用户信息</param>
  19524. /// <returns>string</returns>
  19525. /// <remarks>
  19526. /// 王鑫 2016.06.28 新建
  19527. /// </remarks>
  19528. private static string CheckBarcodeByCancelReSemiCheckNoPass(IDBTransaction oracleTrConn,
  19529. string barcode,
  19530. SUserInfo sUserInfo
  19531. )
  19532. {
  19533. try
  19534. {
  19535. OracleParameter[] paras = new OracleParameter[]{
  19536. new OracleParameter(":barcode",OracleDbType.Varchar2,barcode,ParameterDirection.Input),
  19537. };
  19538. string sql = @"
  19539. select 1 from TP_PM_InProductionTrash where barcode=:barcode and GoodsLevelTypeID=14 and SemiCheckID is not null
  19540. ";
  19541. DataSet dsResult = oracleTrConn.GetSqlResultToDs(sql, paras);
  19542. if (dsResult != null && dsResult.Tables[0].Rows.Count == 0)
  19543. {
  19544. return "条码[" + barcode + "]不在在产回收站中";
  19545. }
  19546. return null;
  19547. }
  19548. catch (Exception ex)
  19549. {
  19550. throw ex;
  19551. }
  19552. }
  19553. /// <summary>
  19554. /// 校验条码有效(撤销复检-合格)
  19555. /// </summary>
  19556. /// <param name="oracleTrConn">连接对象</param>
  19557. /// <param name="barcode">条码</param>
  19558. /// <param name="sUserInfo">登录用户信息</param>
  19559. /// <returns>string</returns>
  19560. /// <remarks>
  19561. /// 王鑫 2016.06.28 新建
  19562. /// </remarks>
  19563. private static string CheckBarcodeByCancelReSemiCheckPass(IDBTransaction oracleTrConn,
  19564. string barcode,
  19565. SUserInfo sUserInfo
  19566. )
  19567. {
  19568. try
  19569. {
  19570. OracleParameter[] paras = new OracleParameter[]{
  19571. new OracleParameter(":barcode",OracleDbType.Varchar2,barcode,ParameterDirection.Input),
  19572. };
  19573. string sql = @"
  19574. select InScrapFlag,
  19575. KilnCarID,
  19576. KilnCarName,
  19577. IsReworkFlag,
  19578. SemiCheckID from TP_PM_InProduction where barcode=:barcode
  19579. ";
  19580. DataSet dsResult = oracleTrConn.GetSqlResultToDs(sql, paras);
  19581. if (dsResult != null && dsResult.Tables[0].Rows.Count > 0)
  19582. {
  19583. if (dsResult.Tables[0].Rows[0]["InScrapFlag"].ToString() == "1")
  19584. {
  19585. return "条码[" + barcode + "]已经报损待审批";
  19586. }
  19587. if (!string.IsNullOrEmpty(dsResult.Tables[0].Rows[0]["KilnCarID"].ToString()))
  19588. {
  19589. return "条码[" + barcode + "]已经在窑车[" + dsResult.Tables[0].Rows[0]["KilnCarName"].ToString() + "]";
  19590. }
  19591. // chenxy 2019-10-02 半检返修 IsReworkFlag=2
  19592. if (dsResult.Tables[0].Rows[0]["IsReworkFlag"].ToString() == "1")
  19593. {
  19594. return "条码[" + barcode + "]是半检返工状态";
  19595. }
  19596. if (dsResult.Tables[0].Rows[0]["IsReworkFlag"].ToString() == "2")
  19597. {
  19598. return "条码[" + barcode + "]是半检返修状态";
  19599. }
  19600. if (string.IsNullOrEmpty(dsResult.Tables[0].Rows[0]["SemiCheckID"].ToString()))
  19601. {
  19602. return "条码[" + barcode + "]已经做过其他操作,不能撤销";
  19603. }
  19604. }
  19605. else
  19606. {
  19607. return "条码[" + barcode + "]不在在产流程";
  19608. }
  19609. return null;
  19610. }
  19611. catch (Exception ex)
  19612. {
  19613. throw ex;
  19614. }
  19615. }
  19616. #region 生产订单 wangx 2017-2-7
  19617. /// <summary>
  19618. /// 保存订单
  19619. /// </summary>
  19620. /// <param name="order"></param>
  19621. /// <param name="sUserInfo"></param>
  19622. /// <returns></returns>
  19623. public static ServiceResultEntity SaveOrder(OrderEntity order, SUserInfo sUserInfo)
  19624. {
  19625. ServiceResultEntity entity = new ServiceResultEntity();
  19626. int returnRows = 0;
  19627. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  19628. try
  19629. {
  19630. string sql = string.Empty;
  19631. OracleParameter[] Paras = null;
  19632. DataSet ds = null;
  19633. #region 查询订单号是否有重复
  19634. sql = "select OrderID from TP_PM_Order where OrderNo=:OrderNo and AccountID=:AccountID";
  19635. Paras = new OracleParameter[] {
  19636. new OracleParameter(":OrderNo",OracleDbType.Varchar2,
  19637. order.OrderNo,ParameterDirection.Input),
  19638. new OracleParameter(":AccountID",OracleDbType.Int32,
  19639. sUserInfo.AccountID,ParameterDirection.Input)
  19640. };
  19641. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  19642. if (ds != null && ds.Tables[0].Rows.Count > 0)
  19643. {
  19644. if (order.OrderID == 0 || (order.OrderID != Convert.ToInt32(ds.Tables[0].Rows[0]["OrderID"])))
  19645. {
  19646. //重复订单号
  19647. returnRows = -1;
  19648. oracleTrConn.Rollback();
  19649. oracleTrConn.Disconnect();
  19650. entity.Result = returnRows;
  19651. entity.Message = "系统存在相同的生产订单号!";
  19652. return entity;
  19653. }
  19654. }
  19655. #endregion
  19656. #region 添加、编辑生产订单
  19657. if (order.OrderID == 0)
  19658. {
  19659. string sqlText = "SELECT SEQ_PM_Order_OrderID.NEXTVAL FROM dual";
  19660. int newOrderID = int.Parse(oracleTrConn.GetSqlResultToStr(sqlText));
  19661. sql = @"Insert into TP_PM_Order
  19662. (
  19663. OrderID,
  19664. OrderNo,
  19665. OrderDate,
  19666. Remarks,
  19667. AccountID,
  19668. ValueFlag,
  19669. DisplayNo,
  19670. CreateTime,
  19671. CreateUserID,
  19672. UpdateTime,
  19673. UpdateUserID
  19674. )
  19675. Values
  19676. (
  19677. :OrderID,
  19678. :OrderNo,
  19679. :OrderDate,
  19680. :Remarks,
  19681. :AccountID,
  19682. :ValueFlag,
  19683. :DisplayNo,
  19684. sysdate,
  19685. :CreateUserID,
  19686. sysdate,
  19687. :UpdateUserID
  19688. )";
  19689. Paras = new OracleParameter[] {
  19690. new OracleParameter(":OrderID",OracleDbType.Int32,newOrderID,ParameterDirection.Input),
  19691. new OracleParameter(":OrderNo",OracleDbType.Varchar2,order.OrderNo,ParameterDirection.Input),
  19692. new OracleParameter(":OrderDate",OracleDbType.Date,order.OrderDate,ParameterDirection.Input),
  19693. new OracleParameter(":Remarks",OracleDbType.Varchar2,order.Remarks,ParameterDirection.Input),
  19694. new OracleParameter(":ValueFlag",OracleDbType.Int32,order.ValueFlag,ParameterDirection.Input),
  19695. new OracleParameter(":DisplayNo",OracleDbType.Int32,order.DisplayNo,ParameterDirection.Input),
  19696. new OracleParameter(":CreateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  19697. new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  19698. new OracleParameter(":AccountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  19699. };
  19700. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  19701. order.OrderID = newOrderID;
  19702. }
  19703. else
  19704. {
  19705. sql = @"Update TP_PM_Order
  19706. set
  19707. OrderNo=:OrderNo,
  19708. OrderDate=:OrderDate,
  19709. Remarks=:Remarks,
  19710. ValueFlag=:ValueFlag,
  19711. DisplayNo=:DisplayNo,
  19712. UpdateUserID=:UpdateUserID
  19713. where OrderID=:OrderID
  19714. ";
  19715. Paras = new OracleParameter[] {
  19716. new OracleParameter(":OrderID",OracleDbType.Int32,order.OrderID,ParameterDirection.Input),
  19717. new OracleParameter(":OrderNo",OracleDbType.Varchar2,order.OrderNo,ParameterDirection.Input),
  19718. new OracleParameter(":OrderDate",OracleDbType.Date,order.OrderDate,ParameterDirection.Input),
  19719. new OracleParameter(":Remarks",OracleDbType.Varchar2,order.Remarks,ParameterDirection.Input),
  19720. new OracleParameter(":ValueFlag",OracleDbType.Int32,order.ValueFlag,ParameterDirection.Input),
  19721. new OracleParameter(":DisplayNo",OracleDbType.Int32,order.DisplayNo,ParameterDirection.Input),
  19722. new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  19723. };
  19724. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  19725. }
  19726. #endregion
  19727. #region 保存订单明细
  19728. if (order.OrderDetail != null)
  19729. {
  19730. // 删除明细
  19731. sql = "DELETE FROM tp_pm_orderdetail od WHERE od.orderid = :orderid";
  19732. Paras = new OracleParameter[] { new OracleParameter(":orderid", order.OrderID) };
  19733. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  19734. // 新建明细
  19735. sql = "INSERT INTO tp_pm_orderdetail\n" +
  19736. " (orderid\n" +
  19737. " ,materialcode\n" +
  19738. " ,accountid\n" +
  19739. " ,createuserid)\n" +
  19740. "VALUES\n" +
  19741. " (:orderid\n" +
  19742. " ,:materialcode\n" +
  19743. " ,:accountid\n" +
  19744. " ,:createuserid)";
  19745. foreach (DataRow row in order.OrderDetail.Rows)
  19746. {
  19747. Paras = new OracleParameter[]
  19748. {
  19749. new OracleParameter(":orderid", order.OrderID),
  19750. new OracleParameter(":materialcode", (row["materialcode"]+"").ToUpper().Trim()),
  19751. new OracleParameter(":createuserid",sUserInfo.UserID),
  19752. new OracleParameter(":accountid",sUserInfo.AccountID)
  19753. };
  19754. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  19755. }
  19756. }
  19757. #endregion
  19758. if (returnRows <= 0)
  19759. {
  19760. oracleTrConn.Rollback();
  19761. oracleTrConn.Disconnect();
  19762. }
  19763. else
  19764. {
  19765. oracleTrConn.Commit();
  19766. oracleTrConn.Disconnect();
  19767. }
  19768. }
  19769. catch (Exception ex)
  19770. {
  19771. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  19772. {
  19773. oracleTrConn.Rollback();
  19774. oracleTrConn.Disconnect();
  19775. }
  19776. throw ex;
  19777. }
  19778. finally
  19779. {
  19780. if (oracleTrConn.ConnState == ConnectionState.Open)
  19781. {
  19782. oracleTrConn.Disconnect();
  19783. }
  19784. }
  19785. entity.Result = returnRows;
  19786. return entity;
  19787. }
  19788. /// <summary>
  19789. /// 启用、停用订单标识
  19790. /// </summary>
  19791. /// <param name="order"></param>
  19792. /// <param name="sUserInfo"></param>
  19793. /// <returns></returns>
  19794. public static ServiceResultEntity ChangeOrderFlag(OrderEntity order, SUserInfo sUserInfo)
  19795. {
  19796. ServiceResultEntity entity = new ServiceResultEntity();
  19797. int returnRows = 0;
  19798. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  19799. try
  19800. {
  19801. string sql = string.Empty;
  19802. OracleParameter[] Paras = null;
  19803. #region 添加、编辑生产订单
  19804. sql = @"Update TP_PM_Order
  19805. set
  19806. ValueFlag=:ValueFlag,
  19807. UpdateUserID=:UpdateUserID
  19808. where OrderID=:OrderID
  19809. ";
  19810. Paras = new OracleParameter[] {
  19811. new OracleParameter(":ValueFlag",OracleDbType.Int32,order.ValueFlag,ParameterDirection.Input),
  19812. new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  19813. new OracleParameter(":OrderID",OracleDbType.Int32,order.OrderID,ParameterDirection.Input),
  19814. };
  19815. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  19816. #endregion
  19817. if (returnRows <= 0)
  19818. {
  19819. oracleTrConn.Rollback();
  19820. oracleTrConn.Disconnect();
  19821. }
  19822. else
  19823. {
  19824. oracleTrConn.Commit();
  19825. oracleTrConn.Disconnect();
  19826. }
  19827. }
  19828. catch (Exception ex)
  19829. {
  19830. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  19831. {
  19832. oracleTrConn.Rollback();
  19833. oracleTrConn.Disconnect();
  19834. }
  19835. throw ex;
  19836. }
  19837. entity.Result = returnRows;
  19838. return entity;
  19839. }
  19840. #endregion
  19841. #region 保存交接
  19842. /// <summary>
  19843. /// 保存交接校验
  19844. /// </summary>
  19845. /// <param name="orderid"></param>
  19846. /// <param name="dtData"></param>
  19847. /// <param name="sUserInfo"></param>
  19848. /// <returns></returns>
  19849. public static ServiceResultEntity SaveFinishedHandover(int orderid, DataTable dtData, SUserInfo sUserInfo)
  19850. {
  19851. ServiceResultEntity sre = new ServiceResultEntity();
  19852. string logid_bg = "0";
  19853. OracleParameter[] Paras = null;
  19854. // 条码串
  19855. string fifter = " AND (bar.barcode = '";
  19856. foreach (DataRow row in dtData.Rows)
  19857. {
  19858. fifter += row["barcode"] + "' OR bar.barcode = '";
  19859. }
  19860. fifter = fifter.Substring(0, fifter.Length - 18) + ")";
  19861. IDBTransaction oracleTrConn2 = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  19862. try
  19863. {
  19864. #region 判断订单是否有明细
  19865. DataTable dtMaterialcode = null;
  19866. string sql =
  19867. "SELECT COUNT(1) AS detailcount\n" +
  19868. " FROM tp_pm_orderdetail od\n" +
  19869. " WHERE od.orderid = :orderid and od.valueflag = '1'";
  19870. Paras = new OracleParameter[]
  19871. {
  19872. new OracleParameter(":orderid", orderid)
  19873. };
  19874. bool isExistsDetail = true;
  19875. object detailcount = oracleTrConn2.GetSqlResultToObj(sql, Paras);
  19876. if (detailcount == null || detailcount == DBNull.Value || Convert.ToInt32(detailcount) == 0)
  19877. {
  19878. isExistsDetail = false;
  19879. }
  19880. #endregion
  19881. for (int i = 0; i < dtData.Rows.Count; i++)
  19882. {
  19883. if (isExistsDetail)
  19884. {
  19885. #region 校验产品是否在订单里
  19886. sql = "SELECT gdd.materialcode\n" +
  19887. " ,(select od.materialcode from tp_pm_orderdetail od where od.orderid = :orderid AND od.valueflag = '1' and gdd.materialcode = od.materialcode) " +
  19888. " AS ordermaterialcode\n" +
  19889. " FROM tp_pm_groutingdailydetail gdd\n" +
  19890. " WHERE gdd.barcode = :barcode";
  19891. Paras = new OracleParameter[]
  19892. {
  19893. new OracleParameter(":orderid", orderid),
  19894. new OracleParameter(":barcode", dtData.Rows[i]["barcode"].ToString())
  19895. };
  19896. dtMaterialcode = oracleTrConn2.GetSqlResultToDt(sql, Paras);
  19897. if (dtMaterialcode == null || dtMaterialcode.Rows.Count == 0)
  19898. {
  19899. sre.Result = -2;
  19900. sre.Message = $"当前产品条码{dtData.Rows[i]["barcode"]}不存在";
  19901. return sre;
  19902. }
  19903. if (string.IsNullOrWhiteSpace(dtMaterialcode.Rows[0]["materialcode"] + ""))
  19904. {
  19905. sre.Result = -2;
  19906. sre.Message = $"当前产品条码{dtData.Rows[i]["barcode"]}没有物料编码,不能上传数据";
  19907. return sre;
  19908. }
  19909. if (string.IsNullOrWhiteSpace(dtMaterialcode.Rows[0]["ordermaterialcode"] + ""))
  19910. {
  19911. sre.Result = -2;
  19912. sre.Message = "此订单不包含【" + dtMaterialcode.Rows[0]["materialcode"] + "】物料,不能上传数据";
  19913. return sre;
  19914. }
  19915. #endregion
  19916. }
  19917. #region 产品是否在产成表中
  19918. sql = "select FHUserCode,GoodsCode,GoodsID from TP_PM_FinishedProduct where Barcode=:Barcode";
  19919. Paras = new OracleParameter[]{
  19920. new OracleParameter(":Barcode",OracleDbType.Varchar2, dtData.Rows[i]["barcode"].ToString(),ParameterDirection.Input),
  19921. };
  19922. DataSet ds = oracleTrConn2.GetSqlResultToDs(sql, Paras);
  19923. if (ds != null && ds.Tables[0].Rows.Count > 0)
  19924. {
  19925. #region 是否交接过
  19926. string fhUserCode = ds.Tables[0].Rows[0]["FHUserCode"].ToString();
  19927. if (!string.IsNullOrEmpty(fhUserCode))
  19928. {
  19929. sre.Result = -2; //已交接,不能再次进行交接
  19930. sre.Message = "此产品【" + dtData.Rows[i]["barcode"].ToString() + "】已交接,不能再次进行交接";
  19931. return sre;
  19932. }
  19933. #endregion
  19934. }
  19935. else
  19936. {
  19937. #region 不是产成品
  19938. sre.Result = -1; //不是产成品
  19939. sre.Message = "此产品【" + dtData.Rows[i]["barcode"].ToString() + "】不是产成品";
  19940. return sre;
  19941. #endregion
  19942. }
  19943. #endregion
  19944. }
  19945. sql = @"
  19946. SELECT COUNT(DISTINCT FINISHEDLOADBATCHNO) CC
  19947. FROM TP_PM_FINISHEDPRODUCT BAR
  19948. WHERE 1 = 1 " + fifter;
  19949. string cc = oracleTrConn2.GetSqlResultToStr(sql);
  19950. if (!"1".Equals(cc))
  19951. {
  19952. sre.Result = -2;
  19953. sre.Message = "不允许多板一起交接";
  19954. return sre;
  19955. }
  19956. sql = @"
  19957. SELECT DISTINCT BGLOGID
  19958. FROM TP_PM_FINISHEDPRODUCT BAR
  19959. WHERE 1 = 1 " + fifter;
  19960. string currentBGlogid = oracleTrConn2.GetSqlResultToStr(sql);
  19961. if (string.IsNullOrEmpty(currentBGlogid))
  19962. {
  19963. logid_bg = oracleTrConn2.GetSqlResultToStr("select SEQ_TSAP_DATALOG_BG.Nextval from dual");
  19964. sql = @"
  19965. UPDATE TP_PM_FINISHEDPRODUCT BAR
  19966. SET BAR.BGLOGIDCX = NULL
  19967. ,BAR.BGLOGID = " + logid_bg + @"
  19968. WHERE 1 = 1 " + fifter;
  19969. int r2 = oracleTrConn2.ExecuteNonQuery(sql);
  19970. }
  19971. else
  19972. {
  19973. logid_bg = currentBGlogid;
  19974. }
  19975. oracleTrConn2.Commit();
  19976. oracleTrConn2.Disconnect();
  19977. }
  19978. catch (Exception ex)
  19979. {
  19980. throw ex;
  19981. }
  19982. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  19983. try
  19984. {
  19985. #region 产成品交接
  19986. if (dtData == null || dtData.Rows.Count == 0)
  19987. {
  19988. sre.Result = -2;
  19989. sre.Message = "条码信息不能为空";
  19990. return sre;
  19991. }
  19992. string sql = string.Empty;
  19993. DataSet ds = null;
  19994. oracleTrConn.Connect();
  19995. // 包装装板,产成品交接不限制
  19996. //string GoodsModel = string.Empty;
  19997. //int? logoID = null;
  19998. //string logoName = string.Empty;
  19999. //int PlateLimitNum = 0;
  20000. //string _isEnable_S_PM_011 = "0";
  20001. //// 2.产成品交接是否限制同型号
  20002. //string _isEnable_S_PM_012 = "0";
  20003. //// 3.产成品交接是否限制每板装板数量(必须先启用限制同型号);
  20004. //string _isEnable_S_PM_013 = "0";
  20005. //// 读取系统设置
  20006. //sql = "select settingcode,settingvalue from tp_mst_systemsetting where settingcode in ('S_PM_011','S_PM_012','S_PM_013') and accountid=" + sUserInfo.AccountID;
  20007. //ds = oracleTrConn.GetSqlResultToDs(sql);
  20008. //foreach (DataRow dr in ds.Tables[0].Rows)
  20009. //{
  20010. // if (dr["settingcode"] == "S_PM_011")
  20011. // _isEnable_S_PM_011 = dr["settingcode"].ToString();
  20012. // else if (dr["settingcode"] == "S_PM_012")
  20013. // _isEnable_S_PM_012 = dr["settingcode"].ToString();
  20014. // else if (dr["settingcode"] == "S_PM_013")
  20015. // _isEnable_S_PM_013 = dr["settingcode"].ToString();
  20016. //}
  20017. // 本批交接的批次号
  20018. #region 判断订单是否有明细
  20019. string fhBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  20020. DataTable dtMaterialcode = null;
  20021. sql = "SELECT COUNT(1) AS detailcount\n" +
  20022. " FROM tp_pm_orderdetail od\n" +
  20023. " WHERE od.orderid = :orderid and od.valueflag = '1'";
  20024. Paras = new OracleParameter[]
  20025. {
  20026. new OracleParameter(":orderid", orderid)
  20027. };
  20028. bool isExistsDetail = true;
  20029. object detailcount = oracleTrConn.GetSqlResultToObj(sql, Paras);
  20030. if (detailcount == null || detailcount == DBNull.Value || Convert.ToInt32(detailcount) == 0)
  20031. {
  20032. isExistsDetail = false;
  20033. }
  20034. #endregion
  20035. for (int i = 0; i < dtData.Rows.Count; i++)
  20036. {
  20037. if (isExistsDetail)
  20038. {
  20039. #region 校验产品是否在订单里
  20040. //sql = "SELECT gdd.materialcode\n" +
  20041. //" ,od.materialcode AS ordermaterialcode\n" +
  20042. //" FROM tp_pm_groutingdailydetail gdd\n" +
  20043. //" LEFT JOIN tp_pm_orderdetail od\n" +
  20044. //" ON gdd.materialcode = od.materialcode\n" +
  20045. //" AND od.orderid = :orderid\n" +
  20046. //" AND od.valueflag = '1'\n" +
  20047. //" WHERE gdd.barcode = :barcode";
  20048. sql = "SELECT gdd.materialcode\n" +
  20049. " ,(select od.materialcode from tp_pm_orderdetail od where od.orderid = :orderid AND od.valueflag = '1' and gdd.materialcode = od.materialcode) " +
  20050. " AS ordermaterialcode\n" +
  20051. " FROM tp_pm_groutingdailydetail gdd\n" +
  20052. " WHERE gdd.barcode = :barcode";
  20053. Paras = new OracleParameter[]
  20054. {
  20055. new OracleParameter(":orderid", orderid),
  20056. new OracleParameter(":barcode", dtData.Rows[i]["barcode"].ToString())
  20057. };
  20058. dtMaterialcode = oracleTrConn.GetSqlResultToDt(sql, Paras);
  20059. if (dtMaterialcode == null || dtMaterialcode.Rows.Count == 0)
  20060. {
  20061. sre.Result = -2;
  20062. sre.Message = $"当前产品条码{dtData.Rows[i]["barcode"]}不存在";
  20063. return sre;
  20064. }
  20065. if (string.IsNullOrWhiteSpace(dtMaterialcode.Rows[0]["materialcode"] + ""))
  20066. {
  20067. sre.Result = -2;
  20068. sre.Message = $"当前产品条码{dtData.Rows[i]["barcode"]}没有物料编码,不能上传数据";
  20069. return sre;
  20070. }
  20071. if (string.IsNullOrWhiteSpace(dtMaterialcode.Rows[0]["ordermaterialcode"] + ""))
  20072. {
  20073. sre.Result = -2;
  20074. sre.Message = "此订单不包含【" + dtMaterialcode.Rows[0]["materialcode"] + "】物料,不能上传数据";
  20075. return sre;
  20076. }
  20077. #endregion
  20078. }
  20079. #region 产品是否在产成表中
  20080. sql = "select FHUserCode,GoodsCode,GoodsID from TP_PM_FinishedProduct where Barcode=:Barcode";
  20081. Paras = new OracleParameter[]{
  20082. new OracleParameter(":Barcode",OracleDbType.Varchar2, dtData.Rows[i]["barcode"].ToString(),ParameterDirection.Input),
  20083. };
  20084. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  20085. if (ds != null && ds.Tables[0].Rows.Count > 0)
  20086. {
  20087. #region 是否交接过
  20088. string fhUserCode = ds.Tables[0].Rows[0]["FHUserCode"].ToString();
  20089. if (!string.IsNullOrEmpty(fhUserCode))
  20090. {
  20091. sre.Result = -2; //已交接,不能再次进行交接
  20092. sre.Message = "此产品【" + dtData.Rows[i]["barcode"].ToString() + "】已交接,不能再次进行交接";
  20093. return sre;
  20094. }
  20095. #endregion
  20096. }
  20097. else
  20098. {
  20099. #region 不是产成品
  20100. sre.Result = -1; //不是产成品
  20101. sre.Message = "此产品【" + dtData.Rows[i]["barcode"].ToString() + "】不是产成品";
  20102. return sre;
  20103. #endregion
  20104. }
  20105. #endregion
  20106. /* 包装装板,产成品交接不限制
  20107. if (i == 0)
  20108. {
  20109. #region 记录产品型号,最大限制数量,商标
  20110. GoodsModel = dtData.Rows[i]["GoodsModel"].ToString();
  20111. logoID = Convert.ToInt32(dtData.Rows[i]["logoID"]);
  20112. logoName = dtData.Rows[i]["logoName"].ToString();
  20113. sql = "select PlateLimitNum from TP_MST_Goods where GoodsID=:GoodsID";
  20114. Paras = new OracleParameter[]{
  20115. new OracleParameter(":GoodsID",OracleDbType.Int32, ds.Tables[0].Rows[0]["GoodsID"],ParameterDirection.Input),
  20116. };
  20117. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  20118. if (ds != null && ds.Tables[0].Rows.Count > 0)
  20119. {
  20120. if (_isEnable_S_PM_013 == "1" && _isEnable_S_PM_012 == "1")
  20121. {
  20122. PlateLimitNum = Convert.ToInt32(ds.Tables[0].Rows[0]["PlateLimitNum"]);
  20123. }
  20124. }
  20125. #endregion
  20126. }
  20127. else
  20128. {
  20129. #region 启用限制同商标
  20130. if (_isEnable_S_PM_011 == "1")
  20131. {
  20132. if (Convert.ToInt32(dtData.Rows[0]["logoid"]) != logoID)
  20133. {
  20134. sre.Result = -3;
  20135. sre.Message = "此产品【" + dtData.Rows[i]["barcode"] + "】的商标【"
  20136. + dtData.Rows[0]["logoname"] + "】与此批次商标【" + logoName + "】不同,不能进行该操作。 ";
  20137. isError = true;
  20138. break;
  20139. }
  20140. }
  20141. #endregion
  20142. #region 启用限制同型号
  20143. if (_isEnable_S_PM_012 == "1")
  20144. {
  20145. if (dtData.Rows[0]["GoodsModel"].ToString() != GoodsModel)
  20146. {
  20147. sre.Result = -4;
  20148. sre.Message = "此产品【" + dtData.Rows[i]["barcode"] + "】的型号【"
  20149. + dtData.Rows[0]["GoodsModel"] + "】与此批次型号【" + GoodsModel + "】不同,不能进行该操作。 ";
  20150. isError = true;
  20151. break;
  20152. }
  20153. }
  20154. #endregion
  20155. #region 产品列表是否大于限制条数
  20156. if (PlateLimitNum > 0)
  20157. {
  20158. if (dtData.Rows.Count > PlateLimitNum)
  20159. {
  20160. sre.Result = -5;
  20161. sre.Message = "产品列表数量大于每板装板数量【" + PlateLimitNum + "】";
  20162. isError = true;
  20163. break;
  20164. }
  20165. }
  20166. #endregion
  20167. }
  20168. */
  20169. #region 更新产成品相关信息
  20170. sql = @"update TP_PM_FinishedProduct
  20171. set FHUserID=:FHUserID,
  20172. FHUserCode=:FHUserCode,
  20173. FHBatchNo=:FHBatchNo,
  20174. FHTime=sysdate,
  20175. FHOrderID=:FHOrderID,
  20176. UpdateUserID=:UpdateUserID
  20177. where Barcode=:Barcode";
  20178. Paras = new OracleParameter[]{
  20179. new OracleParameter(":Barcode",OracleDbType.Varchar2, dtData.Rows[i]["barcode"].ToString(),ParameterDirection.Input),
  20180. new OracleParameter(":FHUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input),
  20181. new OracleParameter(":UpdateUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input),
  20182. new OracleParameter(":FHUserCode",OracleDbType.Varchar2, sUserInfo.UserCode,ParameterDirection.Input),
  20183. new OracleParameter(":FHBatchNo",OracleDbType.Varchar2, fhBatchNo,ParameterDirection.Input),
  20184. new OracleParameter(":FHOrderID",OracleDbType.Int32, orderid,ParameterDirection.Input),
  20185. };
  20186. oracleTrConn.ExecuteNonQuery(sql, Paras);
  20187. #endregion
  20188. }
  20189. #endregion
  20190. #region 同步SAP
  20191. #region 同步日志
  20192. object isExists;
  20193. string sqlString = string.Empty;
  20194. OracleParameter[] oracleParameter = null;
  20195. int r = 0;
  20196. //// 条码串
  20197. //string fifter = " AND (bar.barcode = '";
  20198. //foreach (DataRow row in dtData.Rows)
  20199. //{
  20200. // fifter += row["barcode"] + "' OR bar.barcode = '";
  20201. //}
  20202. //fifter = fifter.Substring(0, fifter.Length - 18) + ")";
  20203. //sqlString = "SELECT 1\n" +
  20204. //" FROM tp_pm_groutingdailydetail bar\n" +
  20205. //" WHERE bar.issync = '1'\n" + fifter;
  20206. //object isExists = oracleTrConn.GetSqlResultToObj(sqlString, oracleParameter);
  20207. //if (isExists != null)
  20208. //{
  20209. // sre.Result = -2;
  20210. // sre.Message = "当前产品已经同步过,不能重复同步。";
  20211. // return sre;
  20212. //}
  20213. DateTime date = DateTime.Now;
  20214. string yyyymmdd = date.ToString("yyyyMMdd");
  20215. sqlString = "select workcode from tp_mst_account where rownum = 1";
  20216. string workcode = oracleTrConn.GetSqlResultToStr(sqlString);
  20217. //DateTime datebegin = date.Date;
  20218. //DateTime dateend = date.Date.AddDays(1);
  20219. //sqlString =
  20220. //"SELECT :yyyymmdd AS yyyymmdd\n" +
  20221. //" ,SYSDATE AS createtime\n" +
  20222. //" ,tt.goodscode\n" +
  20223. //" ,tt.sapcode\n" +
  20224. //" ,tt.usercode\n" +
  20225. //" ,tt.ordercode\n" +
  20226. //" ,tt.orderitem\n" +
  20227. //" ,tt.zscs\n" +
  20228. //" ,to_char(tt.outputnum) AS outputnum\n" +
  20229. //" ,to_char(tt.recoverynum) AS recoverynum\n" +
  20230. //" FROM (SELECT t.goodscode\n" +
  20231. //" ,t.sapcode\n" +
  20232. //" ,t.usercode\n" +
  20233. //" ,t.ordercode\n" +
  20234. //" ,t.orderitem\n" +
  20235. //" ,t.zscs\n" +
  20236. //" ,SUM(decode(t.recyclingflag, '1', 0, decode(t.datatype, 51, 1, -1))) outputnum\n" +
  20237. //" ,SUM(decode(t.recyclingflag, '0', 0, decode(t.datatype, 51, 1, -1))) recoverynum\n" +
  20238. //" FROM (SELECT gh.goodscode\n" +
  20239. //" ,gh.sapcode\n" +
  20240. //" ,u.usercode\n" +
  20241. //" ,o.orderno\n" +
  20242. //" ,bar.recyclingflag\n" +
  20243. //" ,gh.datatype\n" +
  20244. //" ,'' zscs\n" +
  20245. ////" ,case when g.goods_line_type = 1 or gl.highpressureflag = '1' then 'G' else 'L' end zscs\n" +
  20246. //" ,CASE\n" +
  20247. //" WHEN o.orderid IS NULL\n" +
  20248. //" OR o.orderno LIKE 'HEGII%' THEN\n" +
  20249. //" ' '\n" +
  20250. //" WHEN instr(o.orderno, '/') = 0 THEN\n" +
  20251. //" to_char(o.orderno)\n" +
  20252. //" ELSE\n" +
  20253. //" to_char(substr(o.orderno, 1, instr(o.orderno, '/') - 1))\n" +
  20254. //" END ordercode -- 销售凭证\n" +
  20255. //" ,CASE\n" +
  20256. //" WHEN o.orderid IS NULL\n" +
  20257. //" OR o.orderno LIKE 'HEGII%'\n" +
  20258. //" OR instr(o.orderno, '/') = 0 THEN\n" +
  20259. //" '0'\n" +
  20260. //" WHEN instr(o.orderno, '#') = 0 THEN\n" +
  20261. //" to_char(substr(o.orderno, instr(o.orderno, '/') + 1))\n" +
  20262. //" ELSE\n" +
  20263. //" to_char(substr(o.orderno\n" +
  20264. //" ,instr(o.orderno, '/') + 1\n" +
  20265. //" ,instr(o.orderno, '#') - instr(o.orderno, '/') - 1))\n" +
  20266. //" END orderitem -- 销售凭证项目\n" +
  20267. //" FROM (SELECT gch.goodscode\n" +
  20268. //" ,gch.sapcode\n" +
  20269. //" ,decode(gch.datatype, 53, 51, gch.datatype) datatype\n" +
  20270. //" ,gch.userid\n" +
  20271. //" ,gch.groutingdailydetailid\n" +
  20272. //" ,gch.otherid\n" +
  20273. //" FROM tp_pm_goodschangehistory gch\n" +
  20274. //" WHERE gch.datatype IN (51, 52, 53)\n" +
  20275. //" UNION ALL\n" +
  20276. //" SELECT gch.goodscode\n" +
  20277. //" ,gch.sapcode\n" +
  20278. //" ,52 datatype\n" +
  20279. //" ,gch.userid\n" +
  20280. //" ,gch.groutingdailydetailid\n" +
  20281. //" ,gch.goodsidafter\n" +
  20282. //" FROM tp_pm_goodschangehistory gch\n" +
  20283. //" WHERE gch.datatype = 53) gh\n" +
  20284. //" INNER JOIN tp_mst_user u\n" +
  20285. //" ON u.userid = gh.userid\n" +
  20286. //" INNER JOIN tp_pm_groutingdailydetail bar\n" +
  20287. //" ON bar.groutingdailydetailid = gh.groutingdailydetailid\n" + fifter +
  20288. ////" AND bar.barcode IN (" + fifter + ")\n" +
  20289. //" INNER JOIN tp_pc_groutingline gl\n" +
  20290. //" ON gl.groutinglineid = bar.groutinglineid\n" +
  20291. //" INNER JOIN tp_mst_goods g\n" +
  20292. //" ON g.goodsid = bar.goodsid\n" +
  20293. //" LEFT JOIN tp_pm_order o\n" +
  20294. //" ON o.orderid = gh.otherid) t\n" +
  20295. //" GROUP BY t.goodscode\n" +
  20296. //" ,t.sapcode\n" +
  20297. //" ,t.usercode\n" +
  20298. //" ,t.ordercode\n" +
  20299. //" ,t.orderitem,t.zscs) tt\n" +
  20300. //" WHERE tt.outputnum <> 0\n" +
  20301. //" OR tt.recoverynum <> 0\n" +
  20302. //" ORDER BY tt.goodscode\n" +
  20303. //" ,tt.sapcode\n" +
  20304. //" ,tt.usercode\n" +
  20305. //" ,tt.ordercode\n" +
  20306. //" ,tt.orderitem,tt.zscs";
  20307. sqlString =
  20308. "SELECT :yyyymmdd AS yyyymmdd\n" +
  20309. " ,SYSDATE AS createtime\n" +
  20310. " ,tt.goodscode\n" +
  20311. " ,tt.sapcode\n" +
  20312. " ,tt.usercode\n" +
  20313. " ,tt.ordercode\n" +
  20314. " ,tt.orderitem\n" +
  20315. " ,tt.zscs\n" +
  20316. " ,to_char(tt.outputnum) AS outputnum\n" +
  20317. " ,to_char(tt.recoverynum) AS recoverynum\n" +
  20318. " FROM (SELECT t.goodscode\n" +
  20319. " ,t.sapcode\n" +
  20320. " ,t.usercode\n" +
  20321. " ,t.ordercode\n" +
  20322. " ,t.orderitem\n" +
  20323. " ,t.zscs\n" +
  20324. //" ,SUM(decode(t.recyclingflag, '1', 0, decode(t.datatype, 51, 1, -1))) outputnum\n" +
  20325. //" ,SUM(decode(t.recyclingflag, '0', 0, decode(t.datatype, 51, 1, -1))) recoverynum\n" +
  20326. " ,SUM(decode(t.recyclingflag, '1', 0, 1)) outputnum\n" +
  20327. " ,SUM(decode(t.recyclingflag, '0', 0, 1)) recoverynum\n" +
  20328. " FROM (SELECT bar.goodscode\n" +
  20329. //" ,gh.sapcode\n" +
  20330. //" ,u.usercode\n" +
  20331. " ,bar.materialcode sapcode\n" +
  20332. " ,gh.fhusercode usercode\n" +
  20333. " ,o.orderno\n" +
  20334. " ,bar.recyclingflag\n" +
  20335. //" ,gh.datatype\n" +
  20336. " ,'' zscs\n" +
  20337. //" ,case when g.goods_line_type = 1 or gl.highpressureflag = '1' then 'G' else 'L' end zscs\n" +
  20338. " ,CASE\n" +
  20339. " WHEN o.orderid IS NULL\n" +
  20340. " OR o.orderno LIKE 'HEGII%' THEN\n" +
  20341. " ' '\n" +
  20342. " WHEN instr(o.orderno, '/') = 0 THEN\n" +
  20343. " to_char(o.orderno)\n" +
  20344. " ELSE\n" +
  20345. " to_char(substr(o.orderno, 1, instr(o.orderno, '/') - 1))\n" +
  20346. " END ordercode -- 销售凭证\n" +
  20347. " ,CASE\n" +
  20348. " WHEN o.orderid IS NULL\n" +
  20349. " OR o.orderno LIKE 'HEGII%'\n" +
  20350. " OR instr(o.orderno, '/') = 0 THEN\n" +
  20351. " '0'\n" +
  20352. " WHEN instr(o.orderno, '#') = 0 THEN\n" +
  20353. " to_char(substr(o.orderno, instr(o.orderno, '/') + 1))\n" +
  20354. " ELSE\n" +
  20355. " to_char(substr(o.orderno\n" +
  20356. " ,instr(o.orderno, '/') + 1\n" +
  20357. " ,instr(o.orderno, '#') - instr(o.orderno, '/') - 1))\n" +
  20358. " END orderitem -- 销售凭证项目\n" +
  20359. " FROM tp_pm_groutingdailydetail bar\n" +
  20360. //" INNER JOIN tp_mst_user u\n" +
  20361. //" ON u.userid = gh.userid\n" +
  20362. " INNER JOIN tp_pm_finishedproduct gh\n" +
  20363. " ON bar.groutingdailydetailid = gh.groutingdailydetailid\n" +
  20364. //" AND bar.barcode IN (" + fifter + ")\n" +
  20365. //" INNER JOIN tp_pc_groutingline gl\n" +
  20366. //" ON gl.groutinglineid = bar.groutinglineid\n" +
  20367. //" INNER JOIN tp_mst_goods g\n" +
  20368. //" ON g.goodsid = bar.goodsid\n" +
  20369. " LEFT JOIN tp_pm_order o\n" +
  20370. " ON o.orderid = gh.fhorderid where 1=1 " + fifter + ") t\n" +
  20371. " GROUP BY t.goodscode\n" +
  20372. " ,t.sapcode\n" +
  20373. " ,t.usercode\n" +
  20374. " ,t.ordercode\n" +
  20375. " ,t.orderitem,t.zscs) tt\n" +
  20376. " WHERE tt.outputnum <> 0\n" +
  20377. " OR tt.recoverynum <> 0\n" +
  20378. " ORDER BY tt.goodscode\n" +
  20379. " ,tt.sapcode\n" +
  20380. " ,tt.usercode\n" +
  20381. " ,tt.ordercode\n" +
  20382. " ,tt.orderitem,tt.zscs";
  20383. oracleParameter = new OracleParameter[]
  20384. {
  20385. new OracleParameter(":yyyymmdd", yyyymmdd)
  20386. };
  20387. DataTable workData = oracleTrConn.GetSqlResultToDt(sqlString, oracleParameter);
  20388. // 同步日志ID
  20389. string logid = oracleTrConn.GetSqlResultToStr("select SEQ_SAP_HEGII_DataLog_ID.Nextval from dual");
  20390. //string msg = "data:" + datebegin.ToString("yyyyMMdd-HHmm") + "~" +
  20391. // dateend.ToString("yyyyMMdd-HHmm");
  20392. string msg = $"整板条码[{logid}]:" + dtData.Rows[0]["barcode"];
  20393. sqlString = "insert into tsap_hegii_datalog\n" +
  20394. " (LogID\n" +
  20395. " ,LogType\n" +
  20396. " ,BeginTime\n" +
  20397. " ,YYYYMMDD\n" +
  20398. " ,WorkCode\n" +
  20399. " ,DataCode\n" +
  20400. " ,DataStuts\n" +
  20401. " ,DataMSG\n" +
  20402. " ,CreateUserID\n" +
  20403. " ,DataLogID)\n" +
  20404. "values\n" +
  20405. " (:LogID\n" +
  20406. " ,'2'\n" +
  20407. " ,sysdate\n" +
  20408. " ,:YYYYMMDD\n" +
  20409. " ,:WorkCode\n" +
  20410. " ,'60'\n" +
  20411. " ,'S'\n" +
  20412. " ,:DataMSG\n" +
  20413. " ,:CreateUserID\n" +
  20414. " ,:LogID)";
  20415. oracleParameter = new OracleParameter[]
  20416. {
  20417. new OracleParameter(":LogID",OracleDbType.Int32, logid, ParameterDirection.Input),
  20418. new OracleParameter(":CreateUserID",OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input),
  20419. new OracleParameter(":YYYYMMDD",OracleDbType.Varchar2, yyyymmdd, ParameterDirection.Input),
  20420. new OracleParameter(":WorkCode",OracleDbType.Varchar2, workcode, ParameterDirection.Input),
  20421. new OracleParameter(":DataMSG",OracleDbType.Varchar2, msg, ParameterDirection.Input),
  20422. };
  20423. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  20424. #endregion
  20425. #region 同步条码明细
  20426. sqlString =
  20427. "INSERT INTO tsap_hegii_finishedproduct\n" +
  20428. " (yyyymmdd\n" +
  20429. " ,workcode\n" +
  20430. " ,barcode\n" +
  20431. " ,outcode\n" +
  20432. " ,goodscode\n" +
  20433. " ,sapcode\n" +
  20434. " ,sapflbatchno\n" +
  20435. " ,sapfhundoflag\n" +
  20436. " ,ordercode\n" +
  20437. " ,orderitem, LOGID)\n" +
  20438. " SELECT :yyyymmdd\n" +
  20439. " ,:workcode\n" +
  20440. " ,bar.barcode\n" +
  20441. " ,nvl(gdd.outlabelcode, (g.materialcode || :workcode || gdd.onlycode))\n" +
  20442. " ,gdd.goodscode\n" +
  20443. " ,nvl(gdd.materialcode, nvl(g.materialcode, g.goodscode))\n" +
  20444. " ,nvl(bar.finishedloadbatchno, bar.fhbatchno)\n" +
  20445. //" ,decode(gdd.sapfhundoflag, '1', 'X', ' ')\n" +
  20446. " ,' '\n" +
  20447. " ,CASE\n" +
  20448. //" WHEN :workcode IN ('5010', '5011')\n" +
  20449. //" WHEN :workcode <> '5020'\n" +
  20450. //" OR o.orderid IS NULL\n" +
  20451. " WHEN o.orderid IS NULL\n" +
  20452. " OR o.orderno LIKE 'HEGII%' THEN\n" +
  20453. " NULL\n" +
  20454. " WHEN instr(o.orderno, '/') = 0 THEN\n" +
  20455. " to_char(o.orderno)\n" +
  20456. " ELSE\n" +
  20457. " to_char(substr(o.orderno, 1, instr(o.orderno, '/') - 1))\n" +
  20458. " END ordercode -- 销售凭证\n" +
  20459. " ,CASE\n" +
  20460. //" WHEN :workcode IN ('5010', '5011')\n" +
  20461. //" WHEN :workcode <> '5020'\n" +
  20462. //" OR o.orderid IS NULL\n" +
  20463. " WHEN o.orderid IS NULL\n" +
  20464. " OR o.orderno LIKE 'HEGII%'\n" +
  20465. " OR instr(o.orderno, '/') = 0 THEN\n" +
  20466. " '0'\n" +
  20467. " WHEN instr(o.orderno, '#') = 0 THEN\n" +
  20468. " to_char(substr(o.orderno, instr(o.orderno, '/') + 1))\n" +
  20469. " ELSE\n" +
  20470. " to_char(substr(o.orderno\n" +
  20471. " ,instr(o.orderno, '/') + 1\n" +
  20472. " ,instr(o.orderno, '#') - instr(o.orderno, '/') - 1))\n" +
  20473. " END orderitem -- 销售凭证项目\n" +
  20474. " ,:LOGID\n" +
  20475. " FROM tp_pm_finishedproduct bar\n" +
  20476. " INNER JOIN tp_pm_groutingdailydetail gdd\n" +
  20477. " ON gdd.barcode = bar.barcode\n" +
  20478. " INNER JOIN tp_mst_goods g\n" +
  20479. " ON g.goodsid = gdd.goodsid\n" +
  20480. " LEFT JOIN tp_pm_order o\n" +
  20481. " ON o.orderid = bar.fhorderid\n" +
  20482. " WHERE 1 = 1 " + fifter;
  20483. //" WHERE :FHBatchNo = fhBatchNo";
  20484. oracleParameter = new OracleParameter[]
  20485. {
  20486. //new OracleParameter(":FHBatchNo",OracleDbType.Varchar2, fhBatchNo,ParameterDirection.Input),
  20487. new OracleParameter(":yyyymmdd", yyyymmdd),
  20488. new OracleParameter(":workcode", workcode),
  20489. new OracleParameter(":LOGID", logid)
  20490. };
  20491. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  20492. sqlString =
  20493. "select bar.yyyymmdd\n" +
  20494. " ,bar.workcode\n" +
  20495. " ,bar.barcode\n" +
  20496. " ,bar.outcode\n" +
  20497. " ,bar.goodscode\n" +
  20498. " ,bar.sapcode\n" +
  20499. " ,bar.sapflbatchno\n" +
  20500. " ,bar.sapfhundoflag\n" +
  20501. " ,bar.ordercode\n" +
  20502. " ,bar.orderitem\n" +
  20503. //" from tsap_hegii_finishedproduct bar where ztype is null " + fifter +
  20504. " from tsap_hegii_finishedproduct bar where LOGID=:LOGID " +
  20505. " order by bar.sapflbatchno, bar.barcode";
  20506. oracleParameter = new OracleParameter[]
  20507. {
  20508. new OracleParameter(":LOGID", logid)
  20509. };
  20510. DataTable fpData = oracleTrConn.GetSqlResultToDt(sqlString, oracleParameter);
  20511. // 单次传输最大条数
  20512. int maxCount = 100000;
  20513. List<Zppfm010> sapParameterList = new List<Zppfm010>();
  20514. if (fpData != null && fpData.Rows.Count > 0)
  20515. {
  20516. int index = 0;
  20517. //Zppfm010 sapParameter = new Zppfm010();
  20518. //sapParameter.Zsum = maxCount;
  20519. //sapParameter.TableIn = new Zspp110[sapParameter.Zsum];
  20520. List<ZSPP110> tableInList = new List<ZSPP110>();
  20521. foreach (DataRow item in fpData.Rows)
  20522. {
  20523. if (index >= maxCount)
  20524. {
  20525. Zppfm010 sapItem = new Zppfm010();
  20526. sapItem.ZSUM = tableInList.Count;
  20527. sapItem.TABLE_IN = tableInList.ToArray();
  20528. sapParameterList.Add(sapItem);
  20529. index = 0;
  20530. tableInList.Clear();
  20531. }
  20532. ZSPP110 info110 = new ZSPP110();
  20533. // 时间戳
  20534. info110.ZSCNU = yyyymmdd;
  20535. // 工厂
  20536. info110.WERKS = workcode;
  20537. // 生产条码
  20538. info110.ZSCTM = item["barcode"].ToString();
  20539. // 包装条码
  20540. info110.ZBZTM = item["outcode"].ToString();
  20541. // 产品编码
  20542. info110.ZCPBM = item["goodscode"].ToString();
  20543. // 物料编号
  20544. info110.MATNR = item["sapcode"].ToString();
  20545. // 包装整板标识
  20546. info110.ZBZBS = item["sapflbatchno"].ToString();
  20547. // 重新绑定标识
  20548. info110.ZCXBD = item["sapfhundoflag"].ToString();
  20549. // 销售凭证
  20550. info110.KDAUF = item["ordercode"].ToString();
  20551. // 销售凭证项目
  20552. info110.KDPOS = item["orderitem"].ToString();
  20553. info110.UZEIT = date.ToString("HH:mm:ss");
  20554. info110.ZCODEN = "";
  20555. info110.ZCODEYZM = "";
  20556. //if (info110.WERKS == "5011" && info110.ZCPBM == "K047L")
  20557. //{
  20558. // continue;
  20559. //}
  20560. tableInList.Add(info110);
  20561. index++;
  20562. }
  20563. Zppfm010 sapParameter010 = new Zppfm010();
  20564. sapParameter010.ZSUM = tableInList.Count;
  20565. sapParameter010.TABLE_IN = tableInList.ToArray();
  20566. sapParameterList.Add(sapParameter010);
  20567. index = 0;
  20568. tableInList.Clear();
  20569. }
  20570. else
  20571. {
  20572. Zppfm010 sapParameter010 = new Zppfm010();
  20573. sapParameter010.ZSUM = 0;
  20574. sapParameter010.TABLE_IN = new ZSPP110[sapParameter010.ZSUM];
  20575. sapParameterList.Add(sapParameter010);
  20576. }
  20577. //2022年9月23日13:06:25 添加时间限制,10月1号零点整不再传输原接口产量数据
  20578. // 当前时间
  20579. DateTime dateTimeNow = DateTime.Now;
  20580. DateTime setTime = new DateTime(2022, 10, 1, 0, 0, 0);
  20581. if (dateTimeNow < setTime)
  20582. {
  20583. foreach (Zppfm010 sapParameter010 in sapParameterList)
  20584. {
  20585. ZPPFM010Response result010 = SAPDataLogic.HGSAPDK_ZPPFM010(sapParameter010, yyyymmdd);
  20586. //sre.Message = result010.ZMSG;
  20587. sre.Message = $"{result010.ZMSG}({sapParameter010.ZSUM})";
  20588. sre.Result = result010.ZTYPE;
  20589. if (result010.TABLE_OUT != null && result010.TABLE_OUT.Length > 0)
  20590. {
  20591. sqlString = "update tsap_hegii_finishedproduct t set t.ZTime =sysdate, ZTYPE = nvl(:ZTYPE,'S'), ZMSG = :ZMSG where barcode=:barcode and sapflbatchno=:sapflbatchno and logid=:logid";
  20592. foreach (ZSPP110 item in result010.TABLE_OUT)
  20593. {
  20594. oracleParameter = new OracleParameter[]
  20595. {
  20596. new OracleParameter(":ZTYPE",OracleDbType.Varchar2, item.ZTYPE, ParameterDirection.Input),
  20597. new OracleParameter(":ZMSG",OracleDbType.Varchar2, item.ZMSG, ParameterDirection.Input),
  20598. new OracleParameter(":barcode",OracleDbType.Varchar2, item.ZSCTM, ParameterDirection.Input),
  20599. new OracleParameter(":sapflbatchno",OracleDbType.Varchar2, item.ZBZBS, ParameterDirection.Input),
  20600. new OracleParameter(":logid", logid)
  20601. };
  20602. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  20603. }
  20604. }
  20605. if (result010.ZTYPE != "S")
  20606. {
  20607. sre.Result = -2;
  20608. sre.Message = "同步条码失败," + result010.ZMSG;
  20609. return sre;
  20610. }
  20611. }
  20612. }
  20613. #endregion
  20614. #region 同步产量
  20615. // 潮州 暂时不同步产量 2020-10-25 chenxy
  20616. Zppfm008 sapParameter = new Zppfm008();
  20617. if (workData != null && workData.Rows.Count > 0)
  20618. {
  20619. sapParameter.ZSUM = workData.Rows.Count;
  20620. sapParameter.TABLE_IN = new ZSPP100[sapParameter.ZSUM];
  20621. sqlString = "insert into TSAP_HEGII_WorkData\n" +
  20622. " (YYYYMMDD\n" +
  20623. " ,WorkCode\n" +
  20624. " ,DataCode\n" +
  20625. " ,GoodsCode\n" +
  20626. " ,SAPCode\n" +
  20627. " ,UserCode\n" +
  20628. " ,OutputNum\n" +
  20629. " ,RECOVERYNUM\n" +
  20630. " ,ORDERCODE\n" +
  20631. " ,ORDERITEM\n" +
  20632. " ,zscs\n" +
  20633. " ,LogID,createtime)\n" +
  20634. "values\n" +
  20635. " ('" + yyyymmdd + "'\n" +
  20636. " ,'" + workcode + "'\n" +
  20637. " ,'60'\n" +
  20638. " ,:GoodsCode\n" +
  20639. " ,:SAPCode\n" +
  20640. " ,:UserCode\n" +
  20641. " ,:OutputNum\n" +
  20642. " ,:RECOVERYNUM\n" +
  20643. " ,:ORDERCODE\n" +
  20644. " ,:ORDERITEM\n" +
  20645. " ,:zscs\n" +
  20646. " ," + logid + ",:createtime)";
  20647. int index = 0;
  20648. DateTime now = DateTime.Now;
  20649. foreach (DataRow item in workData.Rows)
  20650. {
  20651. ZSPP100 info100 = new ZSPP100();
  20652. // 工厂
  20653. info100.WERKS = workcode;
  20654. // 型号
  20655. info100.GROES = item["GoodsCode"].ToString();
  20656. // 物料编号
  20657. info100.MATNR = item["SAPCode"].ToString();
  20658. // 生产工号
  20659. info100.ZGHNU = item["UserCode"].ToString();
  20660. // 数据节点
  20661. info100.ZJDNU = "60";
  20662. // 时间戳
  20663. info100.ZSCNU = yyyymmdd;
  20664. // 销售凭证
  20665. info100.VBELN = item["ORDERCODE"].ToString().Trim();
  20666. // 销售凭证项目
  20667. info100.POSNR = item["ORDERITEM"].ToString();
  20668. // 产量
  20669. info100.ZCLNG = item["OutputNum"].ToString();
  20670. // 损坯
  20671. info100.ZSPNG = "0";
  20672. // 清除
  20673. info100.ZQCNG = "0";
  20674. // 回收
  20675. info100.ZHSNG = item["RECOVERYNUM"].ToString();
  20676. // 干补
  20677. info100.ZGBNG = "0";
  20678. // 注浆类型 G高压 L普通
  20679. info100.ZSCS = item["ZSCS"].ToString();
  20680. info100.ZKSSJ = now.ToString("HHmmss");
  20681. info100.ZJSRQ = Convert.ToDecimal(now.ToString("yyyyMMddHHmmss"));
  20682. oracleParameter = new OracleParameter[]
  20683. {
  20684. new OracleParameter(":GoodsCode",OracleDbType.Varchar2, item["GoodsCode"], ParameterDirection.Input),
  20685. new OracleParameter(":SAPCode",OracleDbType.Varchar2, item["SAPCode"], ParameterDirection.Input),
  20686. new OracleParameter(":UserCode",OracleDbType.Varchar2, item["UserCode"], ParameterDirection.Input),
  20687. new OracleParameter(":OutputNum",OracleDbType.Varchar2, item["OutputNum"], ParameterDirection.Input),
  20688. new OracleParameter(":RECOVERYNUM",OracleDbType.Varchar2, item["RECOVERYNUM"], ParameterDirection.Input),
  20689. new OracleParameter(":ORDERCODE",OracleDbType.Varchar2, item["ORDERCODE"], ParameterDirection.Input),
  20690. new OracleParameter(":ORDERITEM",OracleDbType.Varchar2, item["ORDERITEM"], ParameterDirection.Input),
  20691. new OracleParameter(":ZSCS",OracleDbType.Varchar2, item["ZSCS"], ParameterDirection.Input),
  20692. new OracleParameter(":createtime",OracleDbType.Date, item["createtime"], ParameterDirection.Input),
  20693. };
  20694. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  20695. sapParameter.TABLE_IN[index++] = info100;
  20696. }
  20697. }
  20698. else
  20699. {
  20700. sapParameter.ZSUM = 0;
  20701. sapParameter.TABLE_IN = new ZSPP100[sapParameter.ZSUM];
  20702. }
  20703. //2022年9月23日13:06:25 添加时间限制,10月1号零点整不再传输原接口产量数据
  20704. if (dateTimeNow < setTime)
  20705. {
  20706. ZPPFM008Response result = SAPDataLogic.HGSAPDK_ZPPFM008(sapParameter, yyyymmdd, "60");
  20707. //if (result.Ztype == "E")
  20708. //{
  20709. // sqlString = "update tsap_hegii_datalog t set t.EndTime = sysdate, DataStuts = 'E', DataMSG = DataMSG||:msg where logid = :logid";
  20710. // oracleParameter = new OracleParameter[]
  20711. // {
  20712. // new OracleParameter(":msg",OracleDbType.Varchar2, result.Zmsg, ParameterDirection.Input),
  20713. // new OracleParameter(":logid",OracleDbType.Int32, logid, ParameterDirection.Input),
  20714. // };
  20715. // r = oracleConn.ExecuteNonQuery(sqlString, oracleParameter);
  20716. //}
  20717. //else
  20718. if (result.TABLE_OUT != null && result.TABLE_OUT.Length > 0)
  20719. {
  20720. sqlString = "update TSAP_HEGII_WorkData t set t.ZTime =sysdate, ZTYPE = :ZTYPE, ZMSG = :ZMSG where logid = " + logid +
  20721. " \n and YYYYMMDD='" + yyyymmdd + "' and WorkCode='" + workcode +
  20722. "' and DataCode='60' and GoodsCode=:GoodsCode and SAPCode=:SAPCode and UserCode=:UserCode \n" +
  20723. "and OrderCode=:OrderCode and OrderItem=:OrderItem";
  20724. foreach (ZSPP100 item in result.TABLE_OUT)
  20725. {
  20726. string posnr = item.POSNR.TrimStart('0');
  20727. oracleParameter = new OracleParameter[]
  20728. {
  20729. new OracleParameter(":ZTYPE",OracleDbType.Varchar2, item.ZTYPE, ParameterDirection.Input),
  20730. new OracleParameter(":ZMSG",OracleDbType.Varchar2, item.ZMSG, ParameterDirection.Input),
  20731. new OracleParameter(":GoodsCode",OracleDbType.Varchar2, item.GROES, ParameterDirection.Input),
  20732. new OracleParameter(":SAPCode",OracleDbType.Varchar2, item.MATNR, ParameterDirection.Input),
  20733. new OracleParameter(":UserCode",OracleDbType.Varchar2, item.ZGHNU, ParameterDirection.Input),
  20734. new OracleParameter(":OrderCode",OracleDbType.Varchar2, (string.IsNullOrEmpty(item.VBELN) ? " " : item.VBELN), ParameterDirection.Input),
  20735. new OracleParameter(":OrderItem",OracleDbType.Varchar2, (string.IsNullOrEmpty(posnr) ? "0" : posnr), ParameterDirection.Input),
  20736. };
  20737. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  20738. }
  20739. //:msg||chr(13)||DataMSG
  20740. result.ZMSG = $"{result.ZMSG}({sapParameter.ZSUM})";
  20741. sqlString = "update tsap_hegii_datalog t set t.EndTime = sysdate, DataStuts = :DataStuts, DataMSG =nvl2(:msg,:msg||' '||chr(13)||DataMSG,DataMSG) where logid = :logid";
  20742. oracleParameter = new OracleParameter[]
  20743. {
  20744. new OracleParameter(":DataStuts",OracleDbType.Varchar2, result.ZTYPE, ParameterDirection.Input),
  20745. new OracleParameter(":msg",OracleDbType.Varchar2, result.ZMSG, ParameterDirection.Input),
  20746. new OracleParameter(":logid",OracleDbType.Int32, logid, ParameterDirection.Input),
  20747. };
  20748. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  20749. }
  20750. if (result.ZTYPE != "S")
  20751. {
  20752. sre.Result = -2;
  20753. sre.Message = "同步产量失败," + result.ZMSG;
  20754. return sre;
  20755. }
  20756. sqlString =
  20757. "UPDATE tp_pm_groutingdailydetail bar\n" +
  20758. " SET bar.issync = '1'\n" +
  20759. " WHERE 1 = 1" + fifter;
  20760. r = oracleTrConn.ExecuteNonQuery(sqlString);
  20761. }
  20762. else
  20763. {
  20764. //调用新报工接口
  20765. #region
  20766. INIUtility sap_hegii = INIUtility.Instance(INIUtility.IniFile.SAP_HEGII);
  20767. workcode = sap_hegii.ReadIniData("SAP_NEW_INFO", "Factory");
  20768. //workcode = "5310"; //原5010
  20769. //workcode = "5320"; //原5011
  20770. sqlString = @"
  20771. SELECT TO_CHAR(SYSDATE, 'YYYYMMDD') AS YYYYMMDD,
  20772. SYSDATE AS CREATETIME,
  20773. TT.GOODSCODE GROES,
  20774. TT.SAPCODE MATNR,
  20775. TT.USERCODE ZGHNU,
  20776. TT.ORDERCODE VBELN,
  20777. TT.ORDERITEM POSNR,
  20778. 'C' AS ZSCMS,
  20779. 'T' AS ZSCS,
  20780. TO_CHAR(TT.OUTPUTNUM) AS ZCLNG,
  20781. TO_CHAR(TT.RECOVERYNUM) AS ZHSNG,
  20782. :WORKCODE AS WERKS,
  20783. '60' ZJDNU,
  20784. TO_CHAR(SYSDATE, 'YYYYMMDD') ZSCNU,
  20785. TO_CHAR(SYSDATE, 'HH24MISS') ZKSSJ,
  20786. TO_CHAR(SYSDATE, 'YYYYMMDDHH24MISS') ZJSRQ,
  20787. '0' ZSPNG,
  20788. '0' ZQCNG,
  20789. '0' ZGBNG,
  20790. TO_CHAR(TT.WORKSHOP) ZSCCJ,
  20791. '60' DATACODE,
  20792. TT.CHARG
  20793. FROM (SELECT T.GOODSCODE,
  20794. T.SAPCODE,
  20795. T.USERCODE,
  20796. T.ORDERCODE,
  20797. T.ORDERITEM,
  20798. T.WORKSHOP,
  20799. T.CHARG,
  20800. SUM(DECODE(T.RECYCLINGFLAG, '1', 0, 1)) OUTPUTNUM,
  20801. SUM(DECODE(T.RECYCLINGFLAG, '0', 0, 1)) RECOVERYNUM
  20802. FROM (SELECT BAR.GOODSCODE,
  20803. BAR.MATERIALCODE SAPCODE,
  20804. GH.FHUSERCODE USERCODE,
  20805. O.ORDERNO,
  20806. BAR.RECYCLINGFLAG,
  20807. CASE
  20808. WHEN O.ORDERID IS NULL
  20809. OR O.ORDERNO LIKE 'HEGII%' THEN
  20810. ' '
  20811. WHEN INSTR(O.ORDERNO, '/') = 0 THEN
  20812. TO_CHAR(O.ORDERNO)
  20813. ELSE
  20814. TO_CHAR(SUBSTR(O.ORDERNO, 1, INSTR(O.ORDERNO, '/') - 1))
  20815. END ORDERCODE -- 销售凭证
  20816. ,
  20817. CASE
  20818. WHEN O.ORDERID IS NULL
  20819. OR O.ORDERNO LIKE 'HEGII%'
  20820. OR INSTR(O.ORDERNO, '/') = 0 THEN
  20821. '0'
  20822. WHEN INSTR(O.ORDERNO, '#') = 0 THEN
  20823. TO_CHAR(SUBSTR(O.ORDERNO, INSTR(O.ORDERNO, '/') + 1))
  20824. ELSE
  20825. TO_CHAR(SUBSTR(O.ORDERNO
  20826. ,INSTR(O.ORDERNO, '/') + 1
  20827. ,INSTR(O.ORDERNO, '#') - INSTR(O.ORDERNO, '/') - 1))
  20828. END ORDERITEM,
  20829. 1 AS WORKSHOP,
  20830. TO_CHAR(GH.FHTIME, 'yyyymm') AS CHARG
  20831. FROM TP_PM_GROUTINGDAILYDETAIL BAR
  20832. INNER JOIN TP_PM_FINISHEDPRODUCT GH
  20833. ON BAR.GROUTINGDAILYDETAILID = GH.GROUTINGDAILYDETAILID
  20834. INNER JOIN TP_MST_GOODS G
  20835. ON G.GOODSID = BAR.GOODSID
  20836. INNER JOIN TP_MST_GOODSTYPE GT
  20837. ON GT.GOODSTYPEID = G.GOODSTYPEID
  20838. LEFT JOIN TP_PM_ORDER O
  20839. ON O.ORDERID = GH.FHORDERID
  20840. WHERE 1 = 1 " + fifter + @") T
  20841. GROUP BY T.GOODSCODE,
  20842. T.SAPCODE,
  20843. T.USERCODE,
  20844. T.ORDERCODE,
  20845. T.ORDERITEM,
  20846. T.WORKSHOP,
  20847. T.CHARG) TT
  20848. WHERE TT.OUTPUTNUM <> 0
  20849. OR TT.RECOVERYNUM <> 0
  20850. ORDER BY TT.GOODSCODE,
  20851. TT.SAPCODE,
  20852. TT.USERCODE,
  20853. TT.ORDERCODE,
  20854. TT.ORDERITEM,
  20855. TT.WORKSHOP,
  20856. TT.CHARG ";
  20857. oracleParameter = new OracleParameter[]
  20858. {
  20859. new OracleParameter(":WORKCODE", workcode)
  20860. };
  20861. DataTable workData5000 = oracleTrConn.GetSqlResultToDt(sqlString, oracleParameter);
  20862. //string logid_bg = oracleTrConn.GetSqlResultToStr("select SEQ_TSAP_DATALOG_BG.Nextval from dual");
  20863. sqlString = "insert into TSAP_HEGII_DATALOG_BG\n" +
  20864. " (LogID\n" +
  20865. " ,LogType\n" +
  20866. " ,BeginTime\n" +
  20867. " ,YYYYMMDD\n" +
  20868. " ,WorkCode\n" +
  20869. " ,DataCode\n" +
  20870. " ,DataStuts\n" +
  20871. " ,DataMSG\n" +
  20872. " ,DATALOGID\n" +
  20873. " ,EXECUTEDATEBEGIN\n" +
  20874. " ,EXECUTEDATEEND,SAPGUID)\n" +
  20875. "values\n" +
  20876. " (:LogID\n" +
  20877. " ,'2'\n" +
  20878. " ,sysdate\n" +
  20879. " ,:YYYYMMDD\n" +
  20880. " ,:workcode\n" +
  20881. " ,'60'\n" +
  20882. " ,'F'\n" +
  20883. " ,:DataMSG\n" +
  20884. " ,:LogID\n" +
  20885. " ,sysdate\n" +
  20886. " ,sysdate,sys_guid())";
  20887. oracleParameter = new OracleParameter[]
  20888. {
  20889. new OracleParameter(":LogID",OracleDbType.Int32, logid_bg, ParameterDirection.Input),
  20890. new OracleParameter(":YYYYMMDD",OracleDbType.Varchar2, yyyymmdd, ParameterDirection.Input),
  20891. new OracleParameter(":workcode",OracleDbType.Varchar2, workcode, ParameterDirection.Input),
  20892. new OracleParameter(":DataMSG",OracleDbType.Varchar2, "", ParameterDirection.Input),
  20893. };
  20894. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  20895. sqlString = "insert into TSAP_HEGII_WORKDATA_BG\n" +
  20896. " (YYYYMMDD\n" +
  20897. " ,WorkCode\n" +
  20898. " ,DataCode\n" +
  20899. " ,GoodsCode\n" +
  20900. " ,SAPCode\n" +
  20901. " ,UserCode\n" +
  20902. " ,WORKSHOP\n" +
  20903. " ,OutputNum\n" +
  20904. " ,RECOVERYNUM\n" +
  20905. " ,ORDERCODE\n" +
  20906. " ,ORDERITEM\n" +
  20907. " ,testmouldflag\n" +
  20908. " ,zscs\n" +
  20909. " ,LogID,createtime,workdataid,charg)\n" +
  20910. "values\n" +
  20911. " ('" + yyyymmdd + "'\n" +
  20912. " ,:workcode\n" +
  20913. " ,'60'\n" +
  20914. " ,:GoodsCode\n" +
  20915. " ,:SAPCode\n" +
  20916. " ,:UserCode\n" +
  20917. " ,:ZSCCJ\n" +
  20918. " ,:OutputNum\n" +
  20919. " ,:RECOVERYNUM\n" +
  20920. " ,:ORDERCODE\n" +
  20921. " ,:ORDERITEM\n" +
  20922. " ,:testmouldflag\n" +
  20923. " ,:zscs\n" +
  20924. " ," + logid_bg + ",:createtime,:workdataid,:charg)";
  20925. DateTime now = DateTime.Now;
  20926. foreach (DataRow item in workData5000.Rows)
  20927. {
  20928. string workdataid = oracleTrConn.GetSqlResultToStr("select SEQ_HEGII_WORKDATA_BG.Nextval from dual");
  20929. oracleParameter = new OracleParameter[]
  20930. {
  20931. new OracleParameter(":workcode", workcode),
  20932. new OracleParameter(":GoodsCode", item["GROES"].ToString()),
  20933. new OracleParameter(":SAPCode", item["MATNR"].ToString()),
  20934. new OracleParameter(":UserCode", item["ZGHNU"].ToString()),
  20935. new OracleParameter(":ZSCCJ", item["ZSCCJ"].ToString()),
  20936. new OracleParameter(":OutputNum", item["ZCLNG"].ToString()),
  20937. new OracleParameter(":RECOVERYNUM", item["ZHSNG"].ToString()),
  20938. new OracleParameter(":ORDERCODE", item["VBELN"].ToString()),
  20939. new OracleParameter(":ORDERITEM", item["POSNR"].ToString()),
  20940. new OracleParameter(":testmouldflag", item["ZSCMS"].ToString()),
  20941. new OracleParameter(":zscs", item["ZSCS"].ToString()),
  20942. new OracleParameter(":createtime", OracleDbType.Date,item["createtime"], ParameterDirection.Input),
  20943. new OracleParameter(":workdataid", workdataid),
  20944. new OracleParameter(":charg", item["CHARG"].ToString()),
  20945. };
  20946. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  20947. }
  20948. sqlString = "SELECT TO_CHAR(wd.yyyymmdd) yyyymmdd\n" +
  20949. " ,wd.workcode WERKS\n" +
  20950. " ,TO_CHAR(wd.goodscode) GROES\n" +
  20951. " ,TO_CHAR(wd.sapcode) MATNR\n" +
  20952. " ,TO_CHAR(wd.usercode) ZGHNU\n" +
  20953. " ,TO_CHAR(wd.datacode) ZJDNU\n" +
  20954. " ,to_char(sysdate, 'YYYYMMDD' ) ZSCNU\n" +
  20955. " ,to_char(sysdate, 'HH24MISS' ) ZKSSJ\n" +
  20956. " ,to_char(sysdate, 'YYYYMMDDHH24MISS' ) ZJSRQ\n" +
  20957. " ,TO_CHAR(wd.ordercode) VBELN\n" +
  20958. " ,TO_CHAR(wd.orderitem) POSNR\n" +
  20959. " ,TO_CHAR(wd.outputnum) ZCLNG\n" +
  20960. " ,TO_CHAR(wd.scrapnum) ZSPNG\n" +
  20961. " ,TO_CHAR(wd.cleanupnum) ZQCNG\n" +
  20962. " ,TO_CHAR(wd.recoverynum) ZHSNG\n" +
  20963. " ,TO_CHAR(wd.repairnum) ZGBNG\n" +
  20964. " ,TO_CHAR(wd.testmouldflag) ZSCMS\n" +
  20965. " -- ,TO_CHAR(wd.zscs) zscs\n" +
  20966. " ,'T' AS zscs\n" +
  20967. " ,TO_CHAR(wd.WORKSHOP) ZSCCJ\n" +
  20968. " ,WD.CHARG\n" +
  20969. " ,TO_CHAR(60) datacode\n" +
  20970. " ,wd.workcode || LPAD(DL.LOGID, 10,'0') AS ZID\n" +
  20971. " FROM tsap_hegii_workdata_bg wd\n" +
  20972. " INNER JOIN TSAP_HEGII_DATALOG_BG DL\n" +
  20973. " ON wd.LOGID = DL.LOGID \n" +
  20974. " WHERE wd.logid = :logid";
  20975. OracleParameter[] par = null;
  20976. par = new OracleParameter[]
  20977. {
  20978. new OracleParameter(":logid", OracleDbType.Int32, logid_bg, ParameterDirection.Input),
  20979. };
  20980. DataTable dtt = oracleTrConn.GetSqlResultToDt(sqlString, par);
  20981. int num = dtt.Rows.Count;
  20982. string sq = "select SAP_INI_BG from TP_SYS_SAPCONFIG";
  20983. string SAP_ING_NEW = oracleTrConn.GetSqlResultToStr(sq);
  20984. if (SAP_ING_NEW == "1")
  20985. //if (true)
  20986. {
  20987. // 调用SAP接口
  20988. string postString = "{\"ZSUM\":" + num.ToString() + ",\"TABLE_IN\":{\"item\":" + JsonHelper.ToJson(ModelConvertHelper<BGToSAP>.ConvertToModel(dtt)) + "}}";
  20989. INIUtility ini = INIUtility.Instance(INIUtility.IniFile.SAP_HEGII);
  20990. string url030 = ini.ReadIniData("SAP_NEW_INFO", "Url030");
  20991. //string url030 = "http://hgs4podev.hegii.com:50200/RESTAdapter/DKMES/ZPPFM030";
  20992. string result = SAPDataLogic.PostData(url030, postString, "POST");
  20993. if (JObject.Parse(result)["TABLE_OUT"] != null && JObject.Parse(result)["TABLE_OUT"].ToString().Length > 0)
  20994. {
  20995. sqlString = "update TSAP_HEGII_WorkData_bg t set t.ZTime =sysdate, ZTYPE = :ZTYPE, ZMSG = :ZMSG where logid = " + logid_bg +
  20996. " \n and YYYYMMDD='" + yyyymmdd + "' and WorkCode='" + workcode +
  20997. "' and DataCode='60' and GoodsCode=:GoodsCode and SAPCode=:SAPCode and UserCode=:UserCode \n" +
  20998. "and OrderCode=:OrderCode and OrderItem=:OrderItem";
  20999. Dictionary<string, object> obj = JsonConvert.DeserializeObject<Dictionary<string, object>>(result);
  21000. object TABLE_OUT;
  21001. obj.TryGetValue("TABLE_OUT", out TABLE_OUT);
  21002. obj = JsonConvert.DeserializeObject<Dictionary<string, object>>(TABLE_OUT + "");
  21003. object item1;
  21004. obj.TryGetValue("item", out item1);
  21005. JArray arr = JArray.FromObject(item1);
  21006. foreach (JObject item60 in arr)
  21007. {
  21008. string posnr = item60["POSNR"].ToString().TrimStart('0');
  21009. oracleParameter = new OracleParameter[]
  21010. {
  21011. new OracleParameter(":ZTYPE",OracleDbType.Varchar2, item60["ZTYPE"].ToString(), ParameterDirection.Input),
  21012. new OracleParameter(":ZMSG",OracleDbType.Varchar2, item60["ZMSG"].ToString(), ParameterDirection.Input),
  21013. new OracleParameter(":GoodsCode",OracleDbType.Varchar2, item60["GROES"].ToString(), ParameterDirection.Input),
  21014. new OracleParameter(":SAPCode",OracleDbType.Varchar2, item60["MATNR"].ToString(), ParameterDirection.Input),
  21015. new OracleParameter(":UserCode",OracleDbType.Varchar2, item60["ZGHNU"].ToString(), ParameterDirection.Input),
  21016. new OracleParameter(":OrderCode",OracleDbType.Varchar2, (string.IsNullOrEmpty(item60["VBELN"].ToString()) ? " " : item60["VBELN"].ToString()), ParameterDirection.Input),
  21017. new OracleParameter(":Orderitem",OracleDbType.Varchar2, ((string.IsNullOrEmpty(posnr)) ? "0" : posnr), ParameterDirection.Input),
  21018. };
  21019. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  21020. }
  21021. //:msg||chr(13)||DataMSG
  21022. JObject.Parse(result)["ZMSG"] = $"{JObject.Parse(result)["ZMSG"]}(" + num + ")";
  21023. sqlString = "update tsap_hegii_datalog_bg t set t.EndTime = sysdate, DataStuts = :DataStuts, DataMSG =nvl2(:msg,:msg||' '||chr(13)||DataMSG,DataMSG) where logid = :logid";
  21024. oracleParameter = new OracleParameter[]
  21025. {
  21026. new OracleParameter(":DataStuts",OracleDbType.Varchar2, JObject.Parse(result)["ZTYPE"].ToString(), ParameterDirection.Input),
  21027. new OracleParameter(":msg",OracleDbType.Varchar2, JObject.Parse(result)["ZMSG"].ToString(), ParameterDirection.Input),
  21028. new OracleParameter(":logid",OracleDbType.Int32, logid_bg, ParameterDirection.Input),
  21029. };
  21030. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  21031. }
  21032. if (JObject.Parse(result)["ZTYPE"].ToString() != "S")
  21033. {
  21034. sre.Result = -2;
  21035. sre.Message = "同步产量失败," + JObject.Parse(result)["ZMSG"].ToString();
  21036. return sre;
  21037. }
  21038. //sqlString =
  21039. //"UPDATE tp_pm_groutingdailydetail bar\n" +
  21040. //" SET bar.issync = '1'\n" +
  21041. //" WHERE 1 = 1" + fifter;
  21042. //r = oracleTrConn.ExecuteNonQuery(sqlString);
  21043. }
  21044. #endregion
  21045. sqlString = "update TSAP_HEGII_WorkData t set t.ZTime =sysdate, ZTYPE = 'S' where logid = " + logid +
  21046. " \n and YYYYMMDD='" + yyyymmdd + "' and WorkCode='" + workcode +
  21047. "' and DataCode='60' and GoodsCode=:GoodsCode and SAPCode=:SAPCode \n" +
  21048. "and OrderCode=:OrderCode and OrderItem=:OrderItem";
  21049. foreach (DataRow row in fpData.Rows)
  21050. {
  21051. string posnr = (row["ORDERITEM"] + "").TrimStart('0');
  21052. oracleParameter = new OracleParameter[]
  21053. {
  21054. new OracleParameter(":GoodsCode",OracleDbType.Varchar2, row["GoodsCode"], ParameterDirection.Input),
  21055. new OracleParameter(":SAPCode",OracleDbType.Varchar2, row["SAPCode"], ParameterDirection.Input),
  21056. //new OracleParameter(":UserCode",OracleDbType.Varchar2, row["UserCode"], ParameterDirection.Input),
  21057. new OracleParameter(":OrderCode",OracleDbType.Varchar2, (string.IsNullOrEmpty(row["OrderCode"] + "") ? " " :row["OrderCode"]), ParameterDirection.Input),
  21058. new OracleParameter(":OrderItem",OracleDbType.Varchar2, (string.IsNullOrEmpty(posnr) ? "0" : posnr), ParameterDirection.Input),
  21059. };
  21060. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  21061. }
  21062. }
  21063. #endregion
  21064. #endregion
  21065. #region 同步WMS系统
  21066. if (fpData.Rows.Count > 0)
  21067. {
  21068. INIUtility ini = INIUtility.Instance(INIUtility.IniFile.Config);
  21069. string factory = ini.ReadIniData("WMS_INFO", "Factory");
  21070. DateTime now = DateTime.Now;
  21071. string message = WMSDataLogic.PushWMS(fpData, now);
  21072. // 同步日志
  21073. sqlString = @"
  21074. INSERT INTO TP_WMS_LOG
  21075. (LOGTYPE,
  21076. SPS,
  21077. SKU,
  21078. SERIALNO,
  21079. ADDDAY,
  21080. ADDTIME,
  21081. CODEI,
  21082. UDF1,
  21083. UDF2,
  21084. LPN,
  21085. RETURNDESC,
  21086. ACCOUNTID,
  21087. CREATETIME,
  21088. UPDATETIME,
  21089. CREATEUSERID,
  21090. UPDATEUSERID)
  21091. VALUES
  21092. (:LOGTYPE,
  21093. :SPS,
  21094. :SKU,
  21095. :SERIALNO,
  21096. :ADDDAY,
  21097. :ADDTIME,
  21098. :CODEI,
  21099. :UDF1,
  21100. :UDF2,
  21101. :LPN,
  21102. :RETURNDESC,
  21103. :ACCOUNTID,
  21104. :CREATETIME,
  21105. :CREATETIME,
  21106. :USERID,
  21107. :USERID) ";
  21108. string orderitem;
  21109. foreach (DataRow row in fpData.Rows)
  21110. {
  21111. orderitem = row["orderitem"] + "";
  21112. if (string.IsNullOrEmpty(orderitem) || "0".Equals(orderitem))
  21113. {
  21114. orderitem = "000000";
  21115. }
  21116. oracleParameter = new OracleParameter[]
  21117. {
  21118. new OracleParameter(":LOGTYPE",OracleDbType.Int32, 1, ParameterDirection.Input),
  21119. new OracleParameter(":SPS",OracleDbType.Varchar2, factory, ParameterDirection.Input),
  21120. new OracleParameter(":SKU",OracleDbType.Varchar2, row["sapcode"], ParameterDirection.Input),
  21121. new OracleParameter(":SERIALNO",OracleDbType.Varchar2, row["outcode"], ParameterDirection.Input),
  21122. new OracleParameter(":ADDDAY",OracleDbType.Varchar2, now.ToString("yyyyMMdd"), ParameterDirection.Input),
  21123. new OracleParameter(":ADDTIME",OracleDbType.Varchar2, now.ToString("HHmmss"), ParameterDirection.Input),
  21124. new OracleParameter(":CODEI",OracleDbType.Varchar2, row["barcode"], ParameterDirection.Input),
  21125. new OracleParameter(":UDF1",OracleDbType.Varchar2, row["ordercode"], ParameterDirection.Input),
  21126. new OracleParameter(":UDF2",OracleDbType.Varchar2, orderitem, ParameterDirection.Input),
  21127. new OracleParameter(":LPN",OracleDbType.Varchar2, row["sapflbatchno"], ParameterDirection.Input),
  21128. new OracleParameter(":RETURNDESC",OracleDbType.Varchar2, message, ParameterDirection.Input),
  21129. new OracleParameter(":ACCOUNTID",OracleDbType.Varchar2, sUserInfo.AccountID, ParameterDirection.Input),
  21130. new OracleParameter(":CREATETIME",OracleDbType.Date, now, ParameterDirection.Input),
  21131. new OracleParameter(":USERID",OracleDbType.Varchar2, sUserInfo.UserID, ParameterDirection.Input),
  21132. };
  21133. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  21134. }
  21135. }
  21136. #endregion
  21137. #region 释放包材库库存
  21138. //INIUtility ini = INIUtility.Instance(INIUtility.IniFile.SAP_HEGII);
  21139. //string packingURL = ini.ReadIniData("SAP_HEGII", "PackingURL");
  21140. //foreach (DataRow row in workData.Rows)
  21141. //{
  21142. // string url = packingURL + row["sapcode"] + "&num=" + row["outputnum"];
  21143. // WebRequest req = WebRequest.Create(url);
  21144. // req.Method = "GET";
  21145. // Stream stream = req.GetResponse().GetResponseStream();
  21146. // StreamReader reader = new StreamReader(stream);
  21147. // JObject json = JObject.Parse(reader.ReadToEnd());
  21148. // if (json["success"].ToString() == "false")
  21149. // {
  21150. // sre.Result = -2;
  21151. // sre.Message = json["message"].ToString();
  21152. // return sre;
  21153. // }
  21154. //}
  21155. #endregion
  21156. sre.Result = 1;
  21157. oracleTrConn.Commit();
  21158. oracleTrConn.Disconnect();
  21159. return sre;
  21160. }
  21161. catch (Exception ex)
  21162. {
  21163. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  21164. {
  21165. oracleTrConn.Rollback();
  21166. oracleTrConn.Disconnect();
  21167. }
  21168. throw ex;
  21169. }
  21170. finally
  21171. {
  21172. if (oracleTrConn.ConnState == ConnectionState.Open)
  21173. {
  21174. oracleTrConn.Disconnect();
  21175. }
  21176. }
  21177. }
  21178. /// <summary>
  21179. /// 撤销整板交接
  21180. /// </summary>
  21181. /// <param name="orderid"></param>
  21182. /// <param name="dtData"></param>
  21183. /// <param name="sUserInfo"></param>
  21184. /// <returns></returns>
  21185. public static ServiceResultEntity BackFinishedHandover(DataTable dtData, SUserInfo sUserInfo)
  21186. {
  21187. ServiceResultEntity sre = new ServiceResultEntity();
  21188. if (dtData == null || dtData.Rows.Count == 0)
  21189. {
  21190. sre.Result = -2;
  21191. sre.Message = "条码信息不能为空";
  21192. return sre;
  21193. }
  21194. string logid_bg = "0";
  21195. OracleParameter[] Paras = null;
  21196. // 条码串
  21197. string fifter = " AND (bar.barcode = '";
  21198. foreach (DataRow row in dtData.Rows)
  21199. {
  21200. fifter += row["barcode"] + "' OR bar.barcode = '";
  21201. }
  21202. fifter = fifter.Substring(0, fifter.Length - 18) + ")";
  21203. IDBTransaction oracleTrConn2 = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  21204. try
  21205. {
  21206. #region 相关校验
  21207. string sql = "";
  21208. // 本批交接的批次号
  21209. for (int i = 0; i < dtData.Rows.Count; i++)
  21210. {
  21211. // 1.判断产品是否在产成品表中
  21212. sql = @"select
  21213. FHUserID,
  21214. FHUserCode,
  21215. GoodsID,
  21216. GoodsCode,
  21217. GoodsName
  21218. from TP_PM_FinishedProduct
  21219. where BarCode=:BarCode";
  21220. Paras = new OracleParameter[]
  21221. {
  21222. new OracleParameter(":BarCode",OracleDbType.NVarchar2,dtData.Rows[i]["barcode"],ParameterDirection.Input),
  21223. };
  21224. DataSet dsResult = oracleTrConn2.GetSqlResultToDs(sql, Paras);
  21225. if (dsResult != null && dsResult.Tables[0].Rows.Count > 0)
  21226. {
  21227. // 在产成品表中
  21228. #region 是否交接过
  21229. string fhUserCode = dsResult.Tables[0].Rows[0]["FHUserCode"].ToString();
  21230. if (string.IsNullOrEmpty(fhUserCode))
  21231. {
  21232. sre.Result = -1; //未交接,不能撤销
  21233. sre.Message = "此产品【" + dtData.Rows[i]["barcode"] + "】未交接,不能进行该操作";
  21234. return sre;
  21235. }
  21236. #endregion
  21237. }
  21238. else
  21239. {
  21240. sre.Result = -2; //不能产成品,不能撤销
  21241. sql = "select GoodsCode from TP_PM_GroutingDailyDetail where BarCode=:BarCode";
  21242. dsResult = oracleTrConn2.GetSqlResultToDs(sql, Paras);
  21243. if (dsResult != null && dsResult.Tables[0].Rows.Count > 0)
  21244. {
  21245. sre.Message = "此产品【" + dtData.Rows[i]["barcode"] + "】不是产成品,不能进行该操作";
  21246. }
  21247. else
  21248. {
  21249. sre.Message = "此条码【" + dtData.Rows[i]["barcode"] + "】无效,不能进行该操作";
  21250. }
  21251. return sre;
  21252. }
  21253. }
  21254. #endregion
  21255. sql = @"
  21256. SELECT DISTINCT BGLOGIDCX
  21257. FROM TP_PM_FINISHEDPRODUCT BAR
  21258. WHERE 1 = 1 " + fifter;
  21259. string currentBGlogid = oracleTrConn2.GetSqlResultToStr(sql);
  21260. if (string.IsNullOrEmpty(currentBGlogid))
  21261. {
  21262. logid_bg = oracleTrConn2.GetSqlResultToStr("select SEQ_TSAP_DATALOG_BG.Nextval from dual");
  21263. sql = @"
  21264. UPDATE TP_PM_FINISHEDPRODUCT BAR
  21265. SET BAR.BGLOGID = NULL
  21266. ,BAR.BGLOGIDCX = " + logid_bg + @"
  21267. WHERE 1 = 1 " + fifter;
  21268. int r2 = oracleTrConn2.ExecuteNonQuery(sql);
  21269. }
  21270. else
  21271. {
  21272. logid_bg = currentBGlogid;
  21273. }
  21274. oracleTrConn2.Commit();
  21275. oracleTrConn2.Disconnect();
  21276. }
  21277. catch (Exception ex)
  21278. {
  21279. throw ex;
  21280. }
  21281. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  21282. try
  21283. {
  21284. if (dtData == null || dtData.Rows.Count == 0)
  21285. {
  21286. sre.Result = -2;
  21287. sre.Message = "条码信息不能为空";
  21288. return sre;
  21289. }
  21290. string sql = string.Empty;
  21291. oracleTrConn.Connect();
  21292. #region 相关校验
  21293. // 本批交接的批次号
  21294. for (int i = 0; i < dtData.Rows.Count; i++)
  21295. {
  21296. // 1.判断产品是否在产成品表中
  21297. sql = @"select
  21298. FHUserID,
  21299. FHUserCode,
  21300. GoodsID,
  21301. GoodsCode,
  21302. GoodsName
  21303. from TP_PM_FinishedProduct
  21304. where BarCode=:BarCode";
  21305. Paras = new OracleParameter[]
  21306. {
  21307. new OracleParameter(":BarCode",OracleDbType.NVarchar2,dtData.Rows[i]["barcode"],ParameterDirection.Input),
  21308. };
  21309. DataSet dsResult = oracleTrConn.GetSqlResultToDs(sql, Paras);
  21310. if (dsResult != null && dsResult.Tables[0].Rows.Count > 0)
  21311. {
  21312. // 在产成品表中
  21313. #region 是否交接过
  21314. string fhUserCode = dsResult.Tables[0].Rows[0]["FHUserCode"].ToString();
  21315. if (string.IsNullOrEmpty(fhUserCode))
  21316. {
  21317. sre.Result = -1; //未交接,不能撤销
  21318. sre.Message = "此产品【" + dtData.Rows[i]["barcode"] + "】未交接,不能进行该操作";
  21319. return sre;
  21320. }
  21321. #endregion
  21322. }
  21323. else
  21324. {
  21325. sre.Result = -2; //不能产成品,不能撤销
  21326. sql = "select GoodsCode from TP_PM_GroutingDailyDetail where BarCode=:BarCode";
  21327. dsResult = oracleTrConn.GetSqlResultToDs(sql, Paras);
  21328. if (dsResult != null && dsResult.Tables[0].Rows.Count > 0)
  21329. {
  21330. sre.Message = "此产品【" + dtData.Rows[i]["barcode"] + "】不是产成品,不能进行该操作";
  21331. }
  21332. else
  21333. {
  21334. sre.Message = "此条码【" + dtData.Rows[i]["barcode"] + "】无效,不能进行该操作";
  21335. }
  21336. return sre;
  21337. }
  21338. }
  21339. #endregion
  21340. #region 同步SAP
  21341. #region 取相关数据
  21342. object isExists;
  21343. string sqlString = string.Empty;
  21344. OracleParameter[] oracleParameter = null;
  21345. int r = 0;
  21346. //// 条码串
  21347. //string fifter = " AND (bar.barcode = '";
  21348. //foreach (DataRow row in dtData.Rows)
  21349. //{
  21350. // fifter += row["barcode"] + "' OR bar.barcode = '";
  21351. //}
  21352. //fifter = fifter.Substring(0, fifter.Length - 18) + ")";
  21353. //sqlString = "SELECT 1\n" +
  21354. //" FROM tp_pm_groutingdailydetail bar\n" +
  21355. //" WHERE bar.issync IS NULL" + fifter;
  21356. //object isExists = oracleTrConn.GetSqlResultToObj(sqlString, oracleParameter);
  21357. //if (isExists != null)
  21358. //{
  21359. // sre.Result = -2;
  21360. // sre.Message = "当前产品已经撤销,不能重复同步。";
  21361. // return sre;
  21362. //}
  21363. DateTime date = DateTime.Now;
  21364. string yyyymmdd = date.ToString("yyyyMMdd");
  21365. sqlString = "select workcode from tp_mst_account where rownum = 1";
  21366. string workcode = oracleTrConn.GetSqlResultToStr(sqlString);
  21367. //DateTime datebegin = date.Date;
  21368. //DateTime dateend = date.Date.AddDays(1);
  21369. //sqlString =
  21370. //"SELECT :yyyymmdd AS yyyymmdd\n" +
  21371. //" ,SYSDATE AS createtime\n" +
  21372. //" ,tt.goodscode\n" +
  21373. //" ,tt.sapcode\n" +
  21374. //" ,tt.usercode\n" +
  21375. //" ,tt.ordercode\n" +
  21376. //" ,tt.orderitem\n" +
  21377. //" ,tt.zscs\n" +
  21378. //" ,to_char(tt.outputnum) AS outputnum\n" +
  21379. //" ,to_char(tt.recoverynum) AS recoverynum\n" +
  21380. //" FROM (SELECT t.goodscode\n" +
  21381. //" ,t.sapcode\n" +
  21382. //" ,t.usercode\n" +
  21383. //" ,t.ordercode\n" +
  21384. //" ,t.orderitem\n" +
  21385. //" ,t.zscs\n" +
  21386. //" ,0 - SUM(decode(t.recyclingflag, '1', 0, decode(t.datatype, 51, 1, -1))) outputnum\n" +
  21387. //" ,0 - SUM(decode(t.recyclingflag, '0', 0, decode(t.datatype, 51, 1, -1))) recoverynum\n" +
  21388. //" FROM (SELECT gh.goodscode\n" +
  21389. //" ,gh.sapcode\n" +
  21390. //" ,u.usercode\n" +
  21391. //" ,o.orderno\n" +
  21392. //" ,bar.recyclingflag\n" +
  21393. //" ,gh.datatype\n" +
  21394. //" ,'' zscs\n" +
  21395. ////" ,case when g.goods_line_type = 1 or gl.highpressureflag = '1' then 'G' else 'L' end zscs\n" +
  21396. //" ,CASE\n" +
  21397. //" WHEN o.orderid IS NULL\n" +
  21398. //" OR o.orderno LIKE 'HEGII%' THEN\n" +
  21399. //" ' '\n" +
  21400. //" WHEN instr(o.orderno, '/') = 0 THEN\n" +
  21401. //" to_char(o.orderno)\n" +
  21402. //" ELSE\n" +
  21403. //" to_char(substr(o.orderno, 1, instr(o.orderno, '/') - 1))\n" +
  21404. //" END ordercode -- 销售凭证\n" +
  21405. //" ,CASE\n" +
  21406. //" WHEN o.orderid IS NULL\n" +
  21407. //" OR o.orderno LIKE 'HEGII%'\n" +
  21408. //" OR instr(o.orderno, '/') = 0 THEN\n" +
  21409. //" '0'\n" +
  21410. //" WHEN instr(o.orderno, '#') = 0 THEN\n" +
  21411. //" to_char(substr(o.orderno, instr(o.orderno, '/') + 1))\n" +
  21412. //" ELSE\n" +
  21413. //" to_char(substr(o.orderno\n" +
  21414. //" ,instr(o.orderno, '/') + 1\n" +
  21415. //" ,instr(o.orderno, '#') - instr(o.orderno, '/') - 1))\n" +
  21416. //" END orderitem -- 销售凭证项目\n" +
  21417. //" FROM (SELECT gch.goodscode\n" +
  21418. //" ,gch.sapcode\n" +
  21419. //" ,decode(gch.datatype, 53, 51, gch.datatype) datatype\n" +
  21420. //" ,gch.userid\n" +
  21421. //" ,gch.groutingdailydetailid\n" +
  21422. //" ,gch.otherid\n" +
  21423. //" FROM tp_pm_goodschangehistory gch\n" +
  21424. //" WHERE gch.datatype IN (51, 52, 53)\n" +
  21425. //" UNION ALL\n" +
  21426. //" SELECT gch.goodscode\n" +
  21427. //" ,gch.sapcode\n" +
  21428. //" ,52 datatype\n" +
  21429. //" ,gch.userid\n" +
  21430. //" ,gch.groutingdailydetailid\n" +
  21431. //" ,gch.goodsidafter\n" +
  21432. //" FROM tp_pm_goodschangehistory gch\n" +
  21433. //" WHERE gch.datatype = 53) gh\n" +
  21434. //" INNER JOIN tp_mst_user u\n" +
  21435. //" ON u.userid = gh.userid\n" +
  21436. //" INNER JOIN tp_pm_groutingdailydetail bar\n" +
  21437. //" ON bar.groutingdailydetailid = gh.groutingdailydetailid\n" + fifter +
  21438. //" INNER JOIN tp_pc_groutingline gl\n" +
  21439. //" ON gl.groutinglineid = bar.groutinglineid\n" +
  21440. //" INNER JOIN tp_mst_goods g\n" +
  21441. //" ON g.goodsid = bar.goodsid\n" +
  21442. //" LEFT JOIN tp_pm_order o\n" +
  21443. //" ON o.orderid = gh.otherid) t\n" +
  21444. //" GROUP BY t.goodscode\n" +
  21445. //" ,t.sapcode\n" +
  21446. //" ,t.usercode\n" +
  21447. //" ,t.ordercode\n" +
  21448. //" ,t.orderitem,t.zscs) tt\n" +
  21449. //" WHERE tt.outputnum <> 0\n" +
  21450. //" OR tt.recoverynum <> 0\n" +
  21451. //" ORDER BY tt.goodscode\n" +
  21452. //" ,tt.sapcode\n" +
  21453. //" ,tt.usercode\n" +
  21454. //" ,tt.ordercode\n" +
  21455. //" ,tt.orderitem,tt.zscs";
  21456. sqlString =
  21457. "SELECT :yyyymmdd AS yyyymmdd\n" +
  21458. " ,SYSDATE AS createtime\n" +
  21459. " ,tt.goodscode\n" +
  21460. " ,tt.sapcode\n" +
  21461. " ,tt.usercode\n" +
  21462. " ,tt.ordercode\n" +
  21463. " ,tt.orderitem\n" +
  21464. " ,tt.zscs\n" +
  21465. " ,to_char(tt.outputnum) AS outputnum\n" +
  21466. " ,to_char(tt.recoverynum) AS recoverynum\n" +
  21467. " FROM (SELECT t.goodscode\n" +
  21468. " ,t.sapcode\n" +
  21469. " ,t.usercode\n" +
  21470. " ,t.ordercode\n" +
  21471. " ,t.orderitem\n" +
  21472. " ,t.zscs\n" +
  21473. //" ,0-SUM(decode(t.recyclingflag, '1', 0, decode(t.datatype, 51, 1, -1))) outputnum\n" +
  21474. //" ,0-SUM(decode(t.recyclingflag, '0', 0, decode(t.datatype, 51, 1, -1))) recoverynum\n" +
  21475. " ,0-SUM(decode(t.recyclingflag, '1', 0, 1)) outputnum\n" +
  21476. " ,0-SUM(decode(t.recyclingflag, '0', 0, 1)) recoverynum\n" +
  21477. " FROM (SELECT bar.goodscode\n" +
  21478. //" ,gh.sapcode\n" +
  21479. //" ,u.usercode\n" +
  21480. " ,bar.materialcode sapcode\n" +
  21481. " ,gh.fhusercode usercode\n" +
  21482. " ,o.orderno\n" +
  21483. " ,bar.recyclingflag\n" +
  21484. //" ,gh.datatype\n" +
  21485. " ,'' zscs\n" +
  21486. //" ,case when g.goods_line_type = 1 or gl.highpressureflag = '1' then 'G' else 'L' end zscs\n" +
  21487. " ,CASE\n" +
  21488. " WHEN o.orderid IS NULL\n" +
  21489. " OR o.orderno LIKE 'HEGII%' THEN\n" +
  21490. " ' '\n" +
  21491. " WHEN instr(o.orderno, '/') = 0 THEN\n" +
  21492. " to_char(o.orderno)\n" +
  21493. " ELSE\n" +
  21494. " to_char(substr(o.orderno, 1, instr(o.orderno, '/') - 1))\n" +
  21495. " END ordercode -- 销售凭证\n" +
  21496. " ,CASE\n" +
  21497. " WHEN o.orderid IS NULL\n" +
  21498. " OR o.orderno LIKE 'HEGII%'\n" +
  21499. " OR instr(o.orderno, '/') = 0 THEN\n" +
  21500. " '0'\n" +
  21501. " WHEN instr(o.orderno, '#') = 0 THEN\n" +
  21502. " to_char(substr(o.orderno, instr(o.orderno, '/') + 1))\n" +
  21503. " ELSE\n" +
  21504. " to_char(substr(o.orderno\n" +
  21505. " ,instr(o.orderno, '/') + 1\n" +
  21506. " ,instr(o.orderno, '#') - instr(o.orderno, '/') - 1))\n" +
  21507. " END orderitem -- 销售凭证项目\n" +
  21508. " FROM tp_pm_groutingdailydetail bar\n" +
  21509. //" INNER JOIN tp_mst_user u\n" +
  21510. //" ON u.userid = gh.userid\n" +
  21511. " INNER JOIN tp_pm_finishedproduct gh\n" +
  21512. " ON bar.groutingdailydetailid = gh.groutingdailydetailid\n" +
  21513. //" AND bar.barcode IN (" + fifter + ")\n" +
  21514. //" INNER JOIN tp_pc_groutingline gl\n" +
  21515. //" ON gl.groutinglineid = bar.groutinglineid\n" +
  21516. //" INNER JOIN tp_mst_goods g\n" +
  21517. //" ON g.goodsid = bar.goodsid\n" +
  21518. " LEFT JOIN tp_pm_order o\n" +
  21519. " ON o.orderid = gh.fhorderid where 1=1 " + fifter + ") t\n" +
  21520. " GROUP BY t.goodscode\n" +
  21521. " ,t.sapcode\n" +
  21522. " ,t.usercode\n" +
  21523. " ,t.ordercode\n" +
  21524. " ,t.orderitem,t.zscs) tt\n" +
  21525. " WHERE tt.outputnum <> 0\n" +
  21526. " OR tt.recoverynum <> 0\n" +
  21527. " ORDER BY tt.goodscode\n" +
  21528. " ,tt.sapcode\n" +
  21529. " ,tt.usercode\n" +
  21530. " ,tt.ordercode\n" +
  21531. " ,tt.orderitem,tt.zscs";
  21532. oracleParameter = new OracleParameter[]
  21533. {
  21534. new OracleParameter(":yyyymmdd", yyyymmdd)
  21535. };
  21536. DataTable workData = oracleTrConn.GetSqlResultToDt(sqlString, oracleParameter);
  21537. string logid = oracleTrConn.GetSqlResultToStr("select SEQ_SAP_HEGII_DataLog_ID.Nextval from dual");
  21538. string msg = $"整板撤销[{logid}]:" + dtData.Rows[0]["barcode"];
  21539. sqlString = "insert into tsap_hegii_datalog\n" +
  21540. " (LogID\n" +
  21541. " ,LogType\n" +
  21542. " ,BeginTime\n" +
  21543. " ,YYYYMMDD\n" +
  21544. " ,WorkCode\n" +
  21545. " ,DataCode\n" +
  21546. " ,DataStuts\n" +
  21547. " ,DataMSG\n" +
  21548. " ,CreateUserID\n" +
  21549. " ,DataLogID)\n" +
  21550. "values\n" +
  21551. " (:LogID\n" +
  21552. " ,'2'\n" +
  21553. " ,sysdate\n" +
  21554. " ,:YYYYMMDD\n" +
  21555. " ,:WorkCode\n" +
  21556. " ,'60'\n" +
  21557. " ,'S'\n" +
  21558. " ,:DataMSG\n" +
  21559. " ,:CreateUserID\n" +
  21560. " ,:LogID)";
  21561. oracleParameter = new OracleParameter[]
  21562. {
  21563. new OracleParameter(":LogID",OracleDbType.Int32, logid, ParameterDirection.Input),
  21564. new OracleParameter(":CreateUserID",OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input),
  21565. new OracleParameter(":YYYYMMDD",OracleDbType.Varchar2, yyyymmdd, ParameterDirection.Input),
  21566. new OracleParameter(":WorkCode",OracleDbType.Varchar2, workcode, ParameterDirection.Input),
  21567. new OracleParameter(":DataMSG",OracleDbType.Varchar2, msg, ParameterDirection.Input),
  21568. };
  21569. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  21570. #endregion
  21571. #region 同步条码明细(注销)
  21572. sqlString =
  21573. "select bar.yyyymmdd\n" +
  21574. " ,bar.workcode\n" +
  21575. " ,bar.barcode\n" +
  21576. " ,bar.outcode\n" +
  21577. " ,bar.goodscode\n" +
  21578. " ,bar.sapcode\n" +
  21579. " ,bar.sapflbatchno\n" +
  21580. " ,bar.sapfhundoflag\n" +
  21581. " ,bar.ordercode\n" +
  21582. " ,bar.orderitem\n" +
  21583. // 保留条码同步履历 2020-10-14 by chenxy ztype = 'S'
  21584. //" from tsap_hegii_finishedproduct bar where 1 = 1" + fifter +
  21585. " from tsap_hegii_finishedproduct bar where ztype = 'S' " + fifter +
  21586. " order by bar.sapflbatchno, bar.barcode";
  21587. DataTable fpData = oracleTrConn.GetSqlResultToDt(sqlString, oracleParameter);
  21588. // 单次传输最大条数
  21589. int maxCount = 100000;
  21590. List<Zppfm010> sapParameterList = new List<Zppfm010>();
  21591. if (fpData != null && fpData.Rows.Count > 0)
  21592. {
  21593. int index = 0;
  21594. //Zppfm010 sapParameter = new Zppfm010();
  21595. //sapParameter.Zsum = maxCount;
  21596. //sapParameter.TableIn = new Zspp110[sapParameter.Zsum];
  21597. List<ZSPP110> tableInList = new List<ZSPP110>();
  21598. foreach (DataRow item in fpData.Rows)
  21599. {
  21600. if (index >= maxCount)
  21601. {
  21602. Zppfm010 sapItem = new Zppfm010();
  21603. sapItem.ZSUM = tableInList.Count;
  21604. sapItem.TABLE_IN = tableInList.ToArray();
  21605. sapParameterList.Add(sapItem);
  21606. index = 0;
  21607. tableInList.Clear();
  21608. }
  21609. ZSPP110 info110 = new ZSPP110();
  21610. // 时间戳
  21611. info110.ZSCNU = yyyymmdd;
  21612. // 工厂
  21613. info110.WERKS = workcode;
  21614. // 生产条码
  21615. info110.ZSCTM = item["barcode"].ToString();
  21616. // 包装条码
  21617. info110.ZBZTM = item["outcode"].ToString();
  21618. // 产品编码
  21619. info110.ZCPBM = item["goodscode"].ToString();
  21620. // 物料编号
  21621. info110.MATNR = item["sapcode"].ToString();
  21622. // 包装整板标识
  21623. info110.ZBZBS = item["sapflbatchno"].ToString();
  21624. // 重新绑定标识
  21625. info110.ZCXBD = "X";
  21626. // 销售凭证
  21627. info110.KDAUF = item["ordercode"].ToString();
  21628. // 销售凭证项目
  21629. info110.KDPOS = item["orderitem"].ToString();
  21630. info110.UZEIT = date.ToString("HH:mm:ss");
  21631. info110.ZCODEN = "";
  21632. info110.ZCODEYZM = "";
  21633. //if (info110.WERKS == "5011" && info110.ZCPBM == "K047L")
  21634. //{
  21635. // continue;
  21636. //}
  21637. tableInList.Add(info110);
  21638. index++;
  21639. }
  21640. Zppfm010 sapParameter010 = new Zppfm010();
  21641. sapParameter010.ZSUM = tableInList.Count;
  21642. sapParameter010.TABLE_IN = tableInList.ToArray();
  21643. sapParameterList.Add(sapParameter010);
  21644. index = 0;
  21645. tableInList.Clear();
  21646. }
  21647. else
  21648. {
  21649. Zppfm010 sapParameter010 = new Zppfm010();
  21650. sapParameter010.ZSUM = 0;
  21651. sapParameter010.TABLE_IN = new ZSPP110[sapParameter010.ZSUM];
  21652. sapParameterList.Add(sapParameter010);
  21653. }
  21654. //2022年9月23日13:06:25 添加时间限制,10月1号零点整不再传输原接口产量数据
  21655. // 当前时间
  21656. DateTime dateTimeNow = DateTime.Now;
  21657. DateTime setTime = new DateTime(2022, 10, 1, 0, 0, 0);
  21658. if (dateTimeNow < setTime)
  21659. {
  21660. foreach (Zppfm010 sapParameter010 in sapParameterList)
  21661. {
  21662. ZPPFM010Response result010 = SAPDataLogic.HGSAPDK_ZPPFM010(sapParameter010, yyyymmdd);
  21663. //sre.Message = result010.ZMSG;
  21664. sre.Message = $"{result010.ZMSG}({sapParameter010.ZSUM})";
  21665. sre.Result = result010.ZTYPE;
  21666. if (result010.TABLE_OUT != null && result010.TABLE_OUT.Length > 0)
  21667. {
  21668. // 保留条码同步履历 2020-10-14 by chenxy ztype = 'S'
  21669. //sqlString = "update tsap_hegii_finishedproduct t set t.ZTime =sysdate, ZTYPE = nvl(:ZTYPE,'S'), ZMSG = :ZMSG where barcode=:barcode and sapflbatchno=:sapflbatchno";
  21670. sqlString = "update tsap_hegii_finishedproduct t set t.ZTime =sysdate, ZTYPE = 'D', ZMSG = :ZMSG where barcode=:barcode and ztype = 'S' and sapflbatchno=:sapflbatchno";
  21671. foreach (ZSPP110 item in result010.TABLE_OUT)
  21672. {
  21673. oracleParameter = new OracleParameter[]
  21674. {
  21675. new OracleParameter(":ZTYPE",OracleDbType.Varchar2, item.ZTYPE, ParameterDirection.Input),
  21676. new OracleParameter(":ZMSG",OracleDbType.Varchar2, item.ZMSG, ParameterDirection.Input),
  21677. new OracleParameter(":barcode",OracleDbType.Varchar2, item.ZSCTM, ParameterDirection.Input),
  21678. new OracleParameter(":sapflbatchno",OracleDbType.Varchar2, item.ZBZBS, ParameterDirection.Input),
  21679. };
  21680. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  21681. }
  21682. }
  21683. if (result010.ZTYPE != "S")
  21684. {
  21685. sre.Result = -2;
  21686. sre.Message = "同步条码失败," + result010.ZMSG;
  21687. return sre;
  21688. }
  21689. }
  21690. }
  21691. else
  21692. {
  21693. sqlString = "update tsap_hegii_finishedproduct t set t.ZTime =sysdate, ZTYPE = 'D' where barcode=:barcode and ztype = 'S' and sapflbatchno=:sapflbatchno";
  21694. foreach (DataRow row in fpData.Rows)
  21695. {
  21696. oracleParameter = new OracleParameter[]
  21697. {
  21698. new OracleParameter(":barcode",OracleDbType.Varchar2, row["barcode"], ParameterDirection.Input),
  21699. new OracleParameter(":sapflbatchno",OracleDbType.Varchar2, row["sapflbatchno"], ParameterDirection.Input),
  21700. };
  21701. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  21702. }
  21703. }
  21704. // 删除已同步条码
  21705. // 保留条码同步履历 2020-10-14 by chenxy ztype = 'S'
  21706. //sql = "Delete from tsap_hegii_finishedproduct bar where 1 = 1" + fifter;
  21707. //r = oracleTrConn.ExecuteNonQuery(sql);
  21708. #endregion
  21709. #region 同步产量
  21710. // 潮州 暂时不同步产量 2020-10-25 chenxy
  21711. Zppfm008 sapParameter = new Zppfm008();
  21712. if (workData != null && workData.Rows.Count > 0)
  21713. {
  21714. sapParameter.ZSUM = workData.Rows.Count;
  21715. sapParameter.TABLE_IN = new ZSPP100[sapParameter.ZSUM];
  21716. sqlString = "insert into TSAP_HEGII_WorkData\n" +
  21717. " (YYYYMMDD\n" +
  21718. " ,WorkCode\n" +
  21719. " ,DataCode\n" +
  21720. " ,GoodsCode\n" +
  21721. " ,SAPCode\n" +
  21722. " ,UserCode\n" +
  21723. " ,OutputNum\n" +
  21724. " ,RECOVERYNUM\n" +
  21725. " ,ORDERCODE\n" +
  21726. " ,ORDERITEM\n" +
  21727. " ,zscs\n" +
  21728. " ,LogID,createtime)\n" +
  21729. "values\n" +
  21730. " ('" + yyyymmdd + "'\n" +
  21731. " ,'" + workcode + "'\n" +
  21732. " ,'60'\n" +
  21733. " ,:GoodsCode\n" +
  21734. " ,:SAPCode\n" +
  21735. " ,:UserCode\n" +
  21736. " ,:OutputNum\n" +
  21737. " ,:RECOVERYNUM\n" +
  21738. " ,:ORDERCODE\n" +
  21739. " ,:ORDERITEM\n" +
  21740. " ,:zscs\n" +
  21741. " ," + logid + ",:createtime)";
  21742. int index = 0;
  21743. DateTime now = DateTime.Now;
  21744. foreach (DataRow item in workData.Rows)
  21745. {
  21746. ZSPP100 info100 = new ZSPP100();
  21747. // 工厂
  21748. info100.WERKS = workcode;
  21749. // 型号
  21750. info100.GROES = item["GoodsCode"].ToString();
  21751. // 物料编号
  21752. info100.MATNR = item["SAPCode"].ToString();
  21753. // 生产工号
  21754. info100.ZGHNU = item["UserCode"].ToString();
  21755. // 数据节点
  21756. info100.ZJDNU = "60";
  21757. // 时间戳
  21758. info100.ZSCNU = yyyymmdd;
  21759. // 销售凭证
  21760. info100.VBELN = item["ORDERCODE"].ToString().Trim();
  21761. // 销售凭证项目
  21762. info100.POSNR = item["ORDERITEM"].ToString();
  21763. // 产量
  21764. info100.ZCLNG = item["OutputNum"].ToString();
  21765. // 损坯
  21766. info100.ZSPNG = "0";
  21767. // 清除
  21768. info100.ZQCNG = "0";
  21769. // 回收
  21770. info100.ZHSNG = item["RECOVERYNUM"].ToString();
  21771. // 干补
  21772. info100.ZGBNG = "0";
  21773. // 注浆类型 G高压 L普通
  21774. info100.ZSCS = item["ZSCS"].ToString();
  21775. info100.ZKSSJ = now.ToString("HHmmss");
  21776. info100.ZJSRQ = Convert.ToDecimal(now.ToString("yyyyMMddHHmmss"));
  21777. oracleParameter = new OracleParameter[]
  21778. {
  21779. new OracleParameter(":GoodsCode",OracleDbType.Varchar2, item["GoodsCode"], ParameterDirection.Input),
  21780. new OracleParameter(":SAPCode",OracleDbType.Varchar2, item["SAPCode"], ParameterDirection.Input),
  21781. new OracleParameter(":UserCode",OracleDbType.Varchar2, item["UserCode"], ParameterDirection.Input),
  21782. new OracleParameter(":OutputNum",OracleDbType.Varchar2, item["OutputNum"], ParameterDirection.Input),
  21783. new OracleParameter(":RECOVERYNUM",OracleDbType.Varchar2, item["RECOVERYNUM"], ParameterDirection.Input),
  21784. new OracleParameter(":ORDERCODE",OracleDbType.Varchar2, item["ORDERCODE"], ParameterDirection.Input),
  21785. new OracleParameter(":ORDERITEM",OracleDbType.Varchar2, item["ORDERITEM"], ParameterDirection.Input),
  21786. new OracleParameter(":ZSCS",OracleDbType.Varchar2, item["ZSCS"], ParameterDirection.Input),
  21787. new OracleParameter(":createtime",OracleDbType.Date, item["createtime"], ParameterDirection.Input),
  21788. };
  21789. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  21790. sapParameter.TABLE_IN[index++] = info100;
  21791. }
  21792. }
  21793. else
  21794. {
  21795. sapParameter.ZSUM = 0;
  21796. sapParameter.TABLE_IN = new ZSPP100[sapParameter.ZSUM];
  21797. }
  21798. //2022年9月23日13:06:25 添加时间限制,10月1号零点整不再传输原接口产量数据
  21799. // 当前时间
  21800. if (dateTimeNow < setTime)
  21801. {
  21802. ZPPFM008Response result = SAPDataLogic.HGSAPDK_ZPPFM008(sapParameter, yyyymmdd, "60");
  21803. //if (result.Ztype == "E")
  21804. //{
  21805. // sqlString = "update tsap_hegii_datalog t set t.EndTime = sysdate, DataStuts = 'E', DataMSG = DataMSG||:msg where logid = :logid";
  21806. // oracleParameter = new OracleParameter[]
  21807. // {
  21808. // new OracleParameter(":msg",OracleDbType.Varchar2, result.Zmsg, ParameterDirection.Input),
  21809. // new OracleParameter(":logid",OracleDbType.Int32, logid, ParameterDirection.Input),
  21810. // };
  21811. // r = oracleConn.ExecuteNonQuery(sqlString, oracleParameter);
  21812. //}
  21813. //else
  21814. if (result.TABLE_OUT != null && result.TABLE_OUT.Length > 0)
  21815. {
  21816. sqlString = "update TSAP_HEGII_WorkData t set t.ZTime =sysdate, ZTYPE = :ZTYPE, ZMSG = :ZMSG where logid = " + logid +
  21817. " \n and YYYYMMDD='" + yyyymmdd + "' and WorkCode='" + workcode +
  21818. "' and DataCode='60' and GoodsCode=:GoodsCode and SAPCode=:SAPCode and UserCode=:UserCode \n" +
  21819. "and OrderCode=:OrderCode and OrderItem=:OrderItem";
  21820. foreach (ZSPP100 item in result.TABLE_OUT)
  21821. {
  21822. string posnr = item.POSNR.TrimStart('0');
  21823. oracleParameter = new OracleParameter[]
  21824. {
  21825. new OracleParameter(":ZTYPE",OracleDbType.Varchar2, item.ZTYPE, ParameterDirection.Input),
  21826. new OracleParameter(":ZMSG",OracleDbType.Varchar2, item.ZMSG, ParameterDirection.Input),
  21827. new OracleParameter(":GoodsCode",OracleDbType.Varchar2, item.GROES, ParameterDirection.Input),
  21828. new OracleParameter(":SAPCode",OracleDbType.Varchar2, item.MATNR, ParameterDirection.Input),
  21829. new OracleParameter(":UserCode",OracleDbType.Varchar2, item.ZGHNU, ParameterDirection.Input),
  21830. new OracleParameter(":OrderCode",OracleDbType.Varchar2, (string.IsNullOrEmpty(item.VBELN) ? " " : item.VBELN), ParameterDirection.Input),
  21831. new OracleParameter(":OrderItem",OracleDbType.Varchar2, (string.IsNullOrEmpty(posnr) ? "0" : posnr), ParameterDirection.Input),
  21832. };
  21833. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  21834. }
  21835. //:msg||chr(13)||DataMSG
  21836. result.ZMSG = $"{result.ZMSG}({sapParameter.ZSUM})";
  21837. sqlString = "update tsap_hegii_datalog t set t.EndTime = sysdate, DataStuts = :DataStuts, DataMSG =nvl2(:msg,:msg||' '||chr(13)||DataMSG,DataMSG) where logid = :logid";
  21838. oracleParameter = new OracleParameter[]
  21839. {
  21840. new OracleParameter(":DataStuts",OracleDbType.Varchar2, result.ZTYPE, ParameterDirection.Input),
  21841. new OracleParameter(":msg",OracleDbType.Varchar2, result.ZMSG, ParameterDirection.Input),
  21842. new OracleParameter(":logid",OracleDbType.Int32, logid, ParameterDirection.Input),
  21843. };
  21844. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  21845. }
  21846. if (result.ZTYPE != "S")
  21847. {
  21848. sre.Result = -2;
  21849. sre.Message = "同步产量失败," + result.ZMSG;
  21850. return sre;
  21851. }
  21852. sqlString =
  21853. "UPDATE tp_pm_groutingdailydetail bar\n" +
  21854. " SET bar.issync = NULL\n" +
  21855. " WHERE 1 = 1" + fifter;
  21856. r = oracleTrConn.ExecuteNonQuery(sqlString);
  21857. }
  21858. else
  21859. {
  21860. INIUtility sap_hegii = INIUtility.Instance(INIUtility.IniFile.SAP_HEGII);
  21861. workcode = sap_hegii.ReadIniData("SAP_NEW_INFO", "Factory");
  21862. //workcode = "5310"; //原5010
  21863. //workcode = "5320"; //原5011
  21864. sqlString = @"
  21865. SELECT TO_CHAR(SYSDATE, 'YYYYMMDD') AS YYYYMMDD,
  21866. SYSDATE AS CREATETIME,
  21867. TT.GOODSCODE GROES,
  21868. TT.SAPCODE MATNR,
  21869. TT.USERCODE ZGHNU,
  21870. TT.ORDERCODE VBELN,
  21871. TT.ORDERITEM POSNR,
  21872. 'C' AS ZSCMS,
  21873. 'T' AS ZSCS,
  21874. TO_CHAR(TT.OUTPUTNUM) AS ZCLNG,
  21875. TO_CHAR(TT.RECOVERYNUM) AS ZHSNG,
  21876. :WORKCODE WERKS,
  21877. '60' ZJDNU,
  21878. TO_CHAR(SYSDATE, 'YYYYMMDD') ZSCNU,
  21879. TO_CHAR(SYSDATE, 'HH24MISS') ZKSSJ,
  21880. TO_CHAR(SYSDATE, 'YYYYMMDDHH24MISS') ZJSRQ,
  21881. '0' ZSPNG,
  21882. '0' ZQCNG,
  21883. '0' ZGBNG,
  21884. TO_CHAR(TT.WORKSHOP) ZSCCJ,
  21885. '0' DATACODE,
  21886. TT.CHARG
  21887. FROM (SELECT T.GOODSCODE,
  21888. T.SAPCODE,
  21889. T.USERCODE,
  21890. T.ORDERCODE,
  21891. T.ORDERITEM,
  21892. T.WORKSHOP,
  21893. T.CHARG,
  21894. 0 - SUM(DECODE(T.RECYCLINGFLAG, '1', 0, 1)) OUTPUTNUM,
  21895. 0 - SUM(DECODE(T.RECYCLINGFLAG, '0', 0, 1)) RECOVERYNUM
  21896. FROM (SELECT BAR.GOODSCODE,
  21897. BAR.MATERIALCODE SAPCODE,
  21898. GH.FHUSERCODE USERCODE,
  21899. O.ORDERNO,
  21900. BAR.RECYCLINGFLAG,
  21901. CASE
  21902. WHEN O.ORDERID IS NULL
  21903. OR O.ORDERNO LIKE 'HEGII%' THEN
  21904. ' '
  21905. WHEN INSTR(O.ORDERNO, '/') = 0 THEN
  21906. TO_CHAR(O.ORDERNO)
  21907. ELSE
  21908. TO_CHAR(SUBSTR(O.ORDERNO, 1, INSTR(O.ORDERNO, '/') - 1))
  21909. END ORDERCODE -- 销售凭证
  21910. ,
  21911. CASE
  21912. WHEN O.ORDERID IS NULL
  21913. OR O.ORDERNO LIKE 'HEGII%'
  21914. OR INSTR(O.ORDERNO, '/') = 0 THEN
  21915. '0'
  21916. WHEN INSTR(O.ORDERNO, '#') = 0 THEN
  21917. TO_CHAR(SUBSTR(O.ORDERNO, INSTR(O.ORDERNO, '/') + 1))
  21918. ELSE
  21919. TO_CHAR(SUBSTR(O.ORDERNO
  21920. ,INSTR(O.ORDERNO, '/') + 1
  21921. ,INSTR(O.ORDERNO, '#') - INSTR(O.ORDERNO, '/') - 1))
  21922. END ORDERITEM,
  21923. 1 AS WORKSHOP,
  21924. TO_CHAR(GH.FHTIME, 'yyyymm') AS CHARG
  21925. FROM TP_PM_GROUTINGDAILYDETAIL BAR
  21926. INNER JOIN TP_PM_FINISHEDPRODUCT GH
  21927. ON BAR.GROUTINGDAILYDETAILID = GH.GROUTINGDAILYDETAILID
  21928. INNER JOIN TP_MST_GOODS G
  21929. ON G.GOODSID = BAR.GOODSID
  21930. INNER JOIN TP_MST_GOODSTYPE GT
  21931. ON GT.GOODSTYPEID = G.GOODSTYPEID
  21932. LEFT JOIN TP_PM_ORDER O
  21933. ON O.ORDERID = GH.FHORDERID
  21934. WHERE 1 = 1 " + fifter + @") T
  21935. GROUP BY T.GOODSCODE,
  21936. T.SAPCODE,
  21937. T.USERCODE,
  21938. T.ORDERCODE,
  21939. T.ORDERITEM,
  21940. T.WORKSHOP,
  21941. T.CHARG) TT
  21942. WHERE TT.OUTPUTNUM <> 0
  21943. OR TT.RECOVERYNUM <> 0
  21944. ORDER BY TT.GOODSCODE,
  21945. TT.SAPCODE,
  21946. TT.USERCODE,
  21947. TT.ORDERCODE,
  21948. TT.ORDERITEM,
  21949. TT.WORKSHOP,
  21950. TT.CHARG ";
  21951. oracleParameter = new OracleParameter[]
  21952. {
  21953. new OracleParameter(":WORKCODE", workcode)
  21954. };
  21955. DataTable workData5000 = oracleTrConn.GetSqlResultToDt(sqlString, oracleParameter);
  21956. //string logid_bg = oracleTrConn.GetSqlResultToStr("select SEQ_TSAP_DATALOG_BG.Nextval from dual");
  21957. sqlString = "insert into tsap_hegii_datalog_bg\n" +
  21958. " (LogID\n" +
  21959. " ,LogType\n" +
  21960. " ,BeginTime\n" +
  21961. " ,YYYYMMDD\n" +
  21962. " ,WorkCode\n" +
  21963. " ,DataCode\n" +
  21964. " ,DataStuts\n" +
  21965. " ,DataMSG\n" +
  21966. " ,DATALOGID\n" +
  21967. " ,EXECUTEDATEBEGIN\n" +
  21968. " ,EXECUTEDATEEND,SAPGUID)\n" +
  21969. "values\n" +
  21970. " (:LogID\n" +
  21971. " ,'2'\n" +
  21972. " ,sysdate\n" +
  21973. " ,:YYYYMMDD\n" +
  21974. " ,:workcode\n" +
  21975. " ,'60'\n" +
  21976. " ,'F'\n" +
  21977. " ,:DataMSG\n" +
  21978. " ,:LogID\n" +
  21979. " ,sysdate\n" +
  21980. " ,sysdate,sys_guid())";
  21981. oracleParameter = new OracleParameter[]
  21982. {
  21983. new OracleParameter(":LogID",OracleDbType.Int32, logid_bg, ParameterDirection.Input),
  21984. new OracleParameter(":YYYYMMDD",OracleDbType.Varchar2, yyyymmdd, ParameterDirection.Input),
  21985. new OracleParameter(":workcode",OracleDbType.Varchar2, workcode, ParameterDirection.Input),
  21986. new OracleParameter(":DataMSG",OracleDbType.Varchar2, "", ParameterDirection.Input),
  21987. };
  21988. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  21989. sqlString = "insert into TSAP_HEGII_WORKDATA_BG\n" +
  21990. " (YYYYMMDD\n" +
  21991. " ,WorkCode\n" +
  21992. " ,DataCode\n" +
  21993. " ,GoodsCode\n" +
  21994. " ,SAPCode\n" +
  21995. " ,UserCode\n" +
  21996. " ,WORKSHOP\n" +
  21997. " ,OutputNum\n" +
  21998. " ,RECOVERYNUM\n" +
  21999. " ,ORDERCODE\n" +
  22000. " ,ORDERITEM\n" +
  22001. " ,testmouldflag\n" +
  22002. " ,zscs\n" +
  22003. " ,LogID,createtime,workdataid,charg)\n" +
  22004. "values\n" +
  22005. " ('" + yyyymmdd + "'\n" +
  22006. " ,:workcode\n" +
  22007. " ,'60'\n" +
  22008. " ,:GoodsCode\n" +
  22009. " ,:SAPCode\n" +
  22010. " ,:UserCode\n" +
  22011. " ,:ZSCCJ\n" +
  22012. " ,:OutputNum\n" +
  22013. " ,:RECOVERYNUM\n" +
  22014. " ,:ORDERCODE\n" +
  22015. " ,:ORDERITEM\n" +
  22016. " ,:testmouldflag\n" +
  22017. " ,:zscs\n" +
  22018. " ," + logid_bg + ",:createtime,:workdataid,:charg)";
  22019. DateTime now = DateTime.Now;
  22020. foreach (DataRow item in workData5000.Rows)
  22021. {
  22022. string workdataid = oracleTrConn.GetSqlResultToStr("select SEQ_HEGII_WORKDATA_BG.Nextval from dual");
  22023. oracleParameter = new OracleParameter[]
  22024. {
  22025. new OracleParameter(":workcode", workcode),
  22026. new OracleParameter(":GoodsCode", item["GROES"].ToString()),
  22027. new OracleParameter(":SAPCode", item["MATNR"].ToString()),
  22028. new OracleParameter(":UserCode", item["ZGHNU"].ToString()),
  22029. new OracleParameter(":ZSCCJ", item["ZSCCJ"].ToString()),
  22030. new OracleParameter(":OutputNum", item["ZCLNG"].ToString()),
  22031. new OracleParameter(":RECOVERYNUM", item["ZHSNG"].ToString()),
  22032. new OracleParameter(":ORDERCODE", item["VBELN"].ToString()),
  22033. new OracleParameter(":ORDERITEM", item["POSNR"].ToString()),
  22034. new OracleParameter(":testmouldflag", item["ZSCMS"].ToString()),
  22035. new OracleParameter(":zscs", item["ZSCS"].ToString()),
  22036. new OracleParameter(":createtime", OracleDbType.Date,item["createtime"], ParameterDirection.Input),
  22037. new OracleParameter(":workdataid", workdataid),
  22038. new OracleParameter(":charg", item["CHARG"].ToString()),
  22039. };
  22040. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  22041. }
  22042. sqlString = "SELECT TO_CHAR(wd.yyyymmdd) yyyymmdd\n" +
  22043. " ,wd.WORKCODE WERKS\n" +
  22044. " ,TO_CHAR(wd.goodscode) GROES\n" +
  22045. " ,TO_CHAR(wd.sapcode) MATNR\n" +
  22046. " ,TO_CHAR(wd.usercode) ZGHNU\n" +
  22047. " ,TO_CHAR(wd.datacode) ZJDNU\n" +
  22048. " ,to_char(sysdate, 'YYYYMMDD' ) ZSCNU\n" +
  22049. " ,to_char(sysdate, 'HH24MISS' ) ZKSSJ\n" +
  22050. " ,to_char(sysdate, 'YYYYMMDDHH24MISS' ) ZJSRQ\n" +
  22051. " ,TO_CHAR(wd.ordercode) VBELN\n" +
  22052. " ,TO_CHAR(wd.orderitem) POSNR\n" +
  22053. " ,TO_CHAR(wd.outputnum) ZCLNG\n" +
  22054. " ,TO_CHAR(wd.scrapnum) ZSPNG\n" +
  22055. " ,TO_CHAR(wd.cleanupnum) ZQCNG\n" +
  22056. " ,TO_CHAR(wd.recoverynum) ZHSNG\n" +
  22057. " ,TO_CHAR(wd.repairnum) ZGBNG\n" +
  22058. " ,TO_CHAR(wd.testmouldflag) ZSCMS\n" +
  22059. " -- ,TO_CHAR(wd.zscs) zscs\n" +
  22060. " ,'T' AS zscs\n" +
  22061. " ,TO_CHAR(wd.WORKSHOP) ZSCCJ\n" +
  22062. " ,WD.CHARG\n" +
  22063. " ,TO_CHAR(60) datacode\n" +
  22064. " ,wd.WORKCODE || LPAD(DL.LOGID, 10,'0') AS ZID\n" +
  22065. " FROM tsap_hegii_workdata_bg wd\n" +
  22066. " INNER JOIN TSAP_HEGII_DATALOG_BG DL\n" +
  22067. " ON wd.LOGID = DL.LOGID \n" +
  22068. " WHERE wd.logid = :logid";
  22069. OracleParameter[] par = null;
  22070. par = new OracleParameter[]
  22071. {
  22072. new OracleParameter(":logid", OracleDbType.Int32, logid_bg, ParameterDirection.Input),
  22073. };
  22074. DataTable dtt = oracleTrConn.GetSqlResultToDt(sqlString, par);
  22075. int num = dtt.Rows.Count;
  22076. string sq = "select SAP_INI_BG from TP_SYS_SAPCONFIG";
  22077. string SAP_ING_NEW = oracleTrConn.GetSqlResultToStr(sq);
  22078. if (SAP_ING_NEW == "1")
  22079. //if (true)
  22080. {
  22081. // 调用SAP接口
  22082. string postString = "{\"ZSUM\":" + num.ToString() + ",\"TABLE_IN\":{\"item\":" + JsonHelper.ToJson(ModelConvertHelper<BGToSAP>.ConvertToModel(dtt)) + "}}";
  22083. INIUtility ini = INIUtility.Instance(INIUtility.IniFile.SAP_HEGII);
  22084. string url030 = ini.ReadIniData("SAP_NEW_INFO", "Url030");
  22085. //string url030 = "http://hgs4podev.hegii.com:50200/RESTAdapter/DKMES/ZPPFM030";
  22086. string result = SAPDataLogic.PostData(url030, postString, "POST");
  22087. if (JObject.Parse(result)["TABLE_OUT"] != null && JObject.Parse(result)["TABLE_OUT"].ToString().Length > 0)
  22088. {
  22089. sqlString = "update TSAP_HEGII_WorkData_bg t set t.ZTime =sysdate, ZTYPE = :ZTYPE, ZMSG = :ZMSG where logid = " + logid_bg +
  22090. " \n and YYYYMMDD='" + yyyymmdd + "' and WorkCode='" + workcode +
  22091. "' and DataCode='60' and GoodsCode=:GoodsCode and SAPCode=:SAPCode and UserCode=:UserCode \n" +
  22092. "and OrderCode=:OrderCode and OrderItem=:OrderItem";
  22093. Dictionary<string, object> obj = JsonConvert.DeserializeObject<Dictionary<string, object>>(result);
  22094. object TABLE_OUT;
  22095. obj.TryGetValue("TABLE_OUT", out TABLE_OUT);
  22096. obj = JsonConvert.DeserializeObject<Dictionary<string, object>>(TABLE_OUT + "");
  22097. object item1;
  22098. obj.TryGetValue("item", out item1);
  22099. JArray arr = JArray.FromObject(item1);
  22100. foreach (JObject item60 in arr)
  22101. {
  22102. string posnr = item60["POSNR"].ToString().TrimStart('0');
  22103. oracleParameter = new OracleParameter[]
  22104. {
  22105. new OracleParameter(":ZTYPE",OracleDbType.Varchar2, item60["ZTYPE"].ToString(), ParameterDirection.Input),
  22106. new OracleParameter(":ZMSG",OracleDbType.Varchar2, item60["ZMSG"].ToString(), ParameterDirection.Input),
  22107. new OracleParameter(":GoodsCode",OracleDbType.Varchar2, item60["GROES"].ToString(), ParameterDirection.Input),
  22108. new OracleParameter(":SAPCode",OracleDbType.Varchar2, item60["MATNR"].ToString(), ParameterDirection.Input),
  22109. new OracleParameter(":UserCode",OracleDbType.Varchar2, item60["ZGHNU"].ToString(), ParameterDirection.Input),
  22110. new OracleParameter(":OrderCode",OracleDbType.Varchar2, (string.IsNullOrEmpty(item60["VBELN"].ToString()) ? " " : item60["VBELN"].ToString()), ParameterDirection.Input),
  22111. new OracleParameter(":Orderitem",OracleDbType.Varchar2, ((string.IsNullOrEmpty(posnr)) ? "0" : posnr), ParameterDirection.Input),
  22112. };
  22113. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  22114. }
  22115. //:msg||chr(13)||DataMSG
  22116. JObject.Parse(result)["ZMSG"] = $"{JObject.Parse(result)["ZMSG"]}({num})";
  22117. sqlString = "update tsap_hegii_datalog_bg t set t.EndTime = sysdate, DataStuts = :DataStuts, DataMSG =nvl2(:msg,:msg||' '||chr(13)||DataMSG,DataMSG) where logid = :logid";
  22118. oracleParameter = new OracleParameter[]
  22119. {
  22120. new OracleParameter(":DataStuts",OracleDbType.Varchar2, JObject.Parse(result)["ZTYPE"].ToString(), ParameterDirection.Input),
  22121. new OracleParameter(":msg",OracleDbType.Varchar2, JObject.Parse(result)["ZMSG"].ToString(), ParameterDirection.Input),
  22122. new OracleParameter(":logid",OracleDbType.Int32, logid_bg, ParameterDirection.Input),
  22123. };
  22124. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  22125. }
  22126. if (JObject.Parse(result)["ZTYPE"].ToString() != "S")
  22127. {
  22128. sre.Result = -2;
  22129. sre.Message = "同步产量失败," + JObject.Parse(result)["ZMSG"].ToString();
  22130. return sre;
  22131. }
  22132. //sqlString =
  22133. //"UPDATE tp_pm_groutingdailydetail bar\n" +
  22134. //" SET bar.issync = '1'\n" +
  22135. //" WHERE 1 = 1" + fifter;
  22136. //r = oracleTrConn.ExecuteNonQuery(sqlString);
  22137. }
  22138. }
  22139. #endregion
  22140. #endregion
  22141. #region 产成品交接撤销
  22142. // 本批交接的批次号
  22143. for (int i = 0; i < dtData.Rows.Count; i++)
  22144. {
  22145. #region 查询产品相关信息
  22146. // 撤销记录
  22147. sql = "INSERT INTO TP_PM_FHUndo\n" +
  22148. " (GroutingDailyDetailID\n" +
  22149. " ,GoodsLevelTypeID\n" +
  22150. " ,FHUserID\n" +
  22151. " ,FHUserCode\n" +
  22152. " ,FHBatchNo\n" +
  22153. " ,FHTime\n" +
  22154. " ,FHOrderID\n" +
  22155. " ,OnlyCode\n" +
  22156. " ,FINISHEDLOADBATCHNO\n" +
  22157. " ,AccountID\n" +
  22158. " ,CreateUserID)\n" +
  22159. " SELECT t.groutingdailydetailid\n" +
  22160. " ,t.GoodsLevelTypeID\n" +
  22161. " ,t.fhuserid\n" +
  22162. " ,t.fhusercode\n" +
  22163. " ,t.fhbatchno\n" +
  22164. " ,t.fhtime\n" +
  22165. " ,t.FHOrderID\n" +
  22166. " ,t.onlycode\n" +
  22167. " ,t.FINISHEDLOADBATCHNO\n" +
  22168. " ,t.AccountID\n" +
  22169. " ,:UpdateUserID\n" +
  22170. " FROM TP_PM_FinishedProduct t\n" +
  22171. " WHERE t.barcode = :BarCode";
  22172. Paras = new OracleParameter[]
  22173. {
  22174. new OracleParameter(":BarCode",OracleDbType.NVarchar2,dtData.Rows[i]["barcode"],ParameterDirection.Input),
  22175. new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  22176. };
  22177. int resultRow = oracleTrConn.ExecuteNonQuery(sql, Paras);
  22178. // SAP同步后再成品交接撤销的,记录撤销标识
  22179. string sapsql = null;
  22180. //string sapsql = "select count(*) from tsap_hegii_FinishedProduct t where t.barcode = :BarCode and ztype='S' and rownum=1 ";
  22181. OracleParameter[] sapparas = new OracleParameter[]
  22182. {
  22183. new OracleParameter(":BarCode",OracleDbType.NVarchar2,dtData.Rows[i]["barcode"],ParameterDirection.Input),
  22184. };
  22185. //int sapcount = Convert.ToInt32(oracleTrConn.GetSqlResultToObj(sapsql, sapparas));
  22186. //if (sapcount > 0)
  22187. {
  22188. sapsql = "update tp_pm_groutingdailydetail set SAPFHUndoFlag = '1' where barcode=:BarCode";
  22189. oracleTrConn.ExecuteNonQuery(sapsql, sapparas);
  22190. }
  22191. // 保留条码同步履历 2020-10-14 by chenxy ztype = 'S'
  22192. //sapsql = "update tsap_hegii_FinishedProduct set ztype = 'D' where barcode=:BarCode and (ztype is null or ztype not in ('S','D'))";
  22193. //sapsql = "update tsap_hegii_FinishedProduct set ztype = 'D' where barcode=:BarCode and (ztype is null or ztype = 'S')";
  22194. oracleTrConn.ExecuteNonQuery(sapsql, sapparas);
  22195. sql = @"Update TP_PM_FinishedProduct
  22196. set FHUserID=null,
  22197. FHUserCode=null,
  22198. FHBatchNo=null,
  22199. FHTime=null,
  22200. FHOrderID=null,
  22201. --FINISHEDLOADBATCHNO=null,
  22202. UpdateUserID=:UpdateUserID
  22203. where BarCode=:BarCode";
  22204. resultRow = oracleTrConn.ExecuteNonQuery(sql, Paras);
  22205. #endregion
  22206. }
  22207. #endregion
  22208. #region 同步WMS系统
  22209. if (fpData.Rows.Count > 0)
  22210. {
  22211. INIUtility ini = INIUtility.Instance(INIUtility.IniFile.Config);
  22212. string factory = ini.ReadIniData("WMS_INFO", "Factory");
  22213. DateTime now = DateTime.Now;
  22214. string message = WMSDataLogic.BackPushWMS(fpData, now);
  22215. // 同步日志
  22216. sqlString = @"
  22217. INSERT INTO TP_WMS_LOG
  22218. (LOGTYPE,
  22219. SPS,
  22220. SKU,
  22221. SERIALNO,
  22222. ADDDAY,
  22223. ADDTIME,
  22224. CODEI,
  22225. UDF1,
  22226. UDF2,
  22227. LPN,
  22228. RETURNDESC,
  22229. ACCOUNTID,
  22230. CREATETIME,
  22231. UPDATETIME,
  22232. CREATEUSERID,
  22233. UPDATEUSERID)
  22234. VALUES
  22235. (:LOGTYPE,
  22236. :SPS,
  22237. :SKU,
  22238. :SERIALNO,
  22239. :ADDDAY,
  22240. :ADDTIME,
  22241. :CODEI,
  22242. :UDF1,
  22243. :UDF2,
  22244. :LPN,
  22245. :RETURNDESC,
  22246. :ACCOUNTID,
  22247. :CREATETIME,
  22248. :CREATETIME,
  22249. :USERID,
  22250. :USERID) ";
  22251. string orderitem;
  22252. foreach (DataRow row in fpData.Rows)
  22253. {
  22254. orderitem = row["orderitem"] + "";
  22255. if (string.IsNullOrEmpty(orderitem) || "0".Equals(orderitem))
  22256. {
  22257. orderitem = "000000";
  22258. }
  22259. oracleParameter = new OracleParameter[]
  22260. {
  22261. new OracleParameter(":LOGTYPE",OracleDbType.Int32, 2, ParameterDirection.Input),
  22262. new OracleParameter(":SPS",OracleDbType.Varchar2, factory, ParameterDirection.Input),
  22263. new OracleParameter(":SKU",OracleDbType.Varchar2, row["sapcode"], ParameterDirection.Input),
  22264. new OracleParameter(":SERIALNO",OracleDbType.Varchar2, row["outcode"], ParameterDirection.Input),
  22265. new OracleParameter(":ADDDAY",OracleDbType.Varchar2, now.ToString("yyyyMMdd"), ParameterDirection.Input),
  22266. new OracleParameter(":ADDTIME",OracleDbType.Varchar2, now.ToString("HHmmss"), ParameterDirection.Input),
  22267. new OracleParameter(":CODEI",OracleDbType.Varchar2, row["barcode"], ParameterDirection.Input),
  22268. new OracleParameter(":UDF1",OracleDbType.Varchar2, row["ordercode"], ParameterDirection.Input),
  22269. new OracleParameter(":UDF2",OracleDbType.Varchar2, orderitem, ParameterDirection.Input),
  22270. new OracleParameter(":LPN",OracleDbType.Varchar2, row["sapflbatchno"], ParameterDirection.Input),
  22271. new OracleParameter(":RETURNDESC",OracleDbType.Varchar2, message, ParameterDirection.Input),
  22272. new OracleParameter(":ACCOUNTID",OracleDbType.Varchar2, sUserInfo.AccountID, ParameterDirection.Input),
  22273. new OracleParameter(":CREATETIME",OracleDbType.Date, now, ParameterDirection.Input),
  22274. new OracleParameter(":USERID",OracleDbType.Varchar2, sUserInfo.UserID, ParameterDirection.Input),
  22275. };
  22276. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  22277. }
  22278. }
  22279. #endregion
  22280. #region 回收包材库库存
  22281. //INIUtility ini = INIUtility.Instance(INIUtility.IniFile.SAP_HEGII);
  22282. //string packingURL = ini.ReadIniData("SAP_HEGII", "PackingURL");
  22283. //foreach (DataRow row in workData.Rows)
  22284. //{
  22285. // string url = packingURL + row["sapcode"] + "&num=" + row["outputnum"];
  22286. // WebRequest req = WebRequest.Create(url);
  22287. // req.Method = "GET";
  22288. // Stream stream = req.GetResponse().GetResponseStream();
  22289. // StreamReader reader = new StreamReader(stream);
  22290. // JObject json = JObject.Parse(reader.ReadToEnd());
  22291. // if (json["success"].ToString() == "false")
  22292. // {
  22293. // sre.Result = -2;
  22294. // sre.Message = json["message"].ToString();
  22295. // return sre;
  22296. // }
  22297. //}
  22298. #endregion
  22299. sre.Result = 1;
  22300. oracleTrConn.Commit();
  22301. oracleTrConn.Disconnect();
  22302. return sre;
  22303. }
  22304. catch (Exception ex)
  22305. {
  22306. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  22307. {
  22308. oracleTrConn.Rollback();
  22309. oracleTrConn.Disconnect();
  22310. }
  22311. throw ex;
  22312. }
  22313. finally
  22314. {
  22315. if (oracleTrConn.ConnState == ConnectionState.Open)
  22316. {
  22317. oracleTrConn.Disconnect();
  22318. }
  22319. }
  22320. }
  22321. #endregion
  22322. /// <summary>
  22323. /// 撤销产成品交接
  22324. /// </summary>
  22325. /// <param name="barcode"></param>
  22326. /// <param name="sUserInfo"></param>
  22327. /// <returns></returns>
  22328. public static ServiceResultEntity SaveCancelFinishedHandoverByBarcode(string barcode, SUserInfo sUserInfo)
  22329. {
  22330. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  22331. try
  22332. {
  22333. ServiceResultEntity resultEntity = new ServiceResultEntity();
  22334. // 1.判断产品是否在产成品表中
  22335. string sql = @"select
  22336. FHUserID,
  22337. FHUserCode,
  22338. GoodsID,
  22339. GoodsCode,
  22340. GoodsName
  22341. from TP_PM_FinishedProduct
  22342. where BarCode=:BarCode";
  22343. OracleParameter[] paras = new OracleParameter[]{
  22344. new OracleParameter(":BarCode",OracleDbType.NVarchar2,barcode,ParameterDirection.Input),
  22345. };
  22346. DataSet dsResult = oracleTrConn.GetSqlResultToDs(sql, paras);
  22347. if (dsResult != null && dsResult.Tables[0].Rows.Count > 0)
  22348. {
  22349. // 在产成品表中
  22350. #region 是否交接过
  22351. string fhUserCode = dsResult.Tables[0].Rows[0]["FHUserCode"].ToString();
  22352. if (string.IsNullOrEmpty(fhUserCode))
  22353. {
  22354. resultEntity.Result = -1; //未交接,不能撤销
  22355. resultEntity.Message = "此产品【" + barcode + "】未交接,不能进行该操作";
  22356. return resultEntity;
  22357. }
  22358. #endregion
  22359. }
  22360. else
  22361. {
  22362. resultEntity.Result = -2; //不能产成品,不能撤销
  22363. sql = "select GoodsCode from TP_PM_GroutingDailyDetail where BarCode=:BarCode";
  22364. dsResult = oracleTrConn.GetSqlResultToDs(sql, paras);
  22365. if (dsResult != null && dsResult.Tables[0].Rows.Count > 0)
  22366. {
  22367. resultEntity.Message = "此产品【" + barcode + "】不是产成品,不能进行该操作";
  22368. }
  22369. else
  22370. {
  22371. resultEntity.Message = "此条码【" + barcode + "】无效,不能进行该操作";
  22372. }
  22373. return resultEntity;
  22374. }
  22375. #region 查询产品相关信息
  22376. // 撤销记录
  22377. string sqlString = "INSERT INTO TP_PM_FHUndo\n" +
  22378. " (GroutingDailyDetailID\n" +
  22379. " ,GoodsLevelTypeID\n" +
  22380. " ,FHUserID\n" +
  22381. " ,FHUserCode\n" +
  22382. " ,FHBatchNo\n" +
  22383. " ,FHTime\n" +
  22384. " ,FHOrderID\n" +
  22385. " ,OnlyCode\n" +
  22386. " ,FINISHEDLOADBATCHNO\n" +
  22387. " ,AccountID\n" +
  22388. " ,CreateUserID)\n" +
  22389. " SELECT t.groutingdailydetailid\n" +
  22390. " ,t.GoodsLevelTypeID\n" +
  22391. " ,t.fhuserid\n" +
  22392. " ,t.fhusercode\n" +
  22393. " ,t.fhbatchno\n" +
  22394. " ,t.fhtime\n" +
  22395. " ,t.FHOrderID\n" +
  22396. " ,t.onlycode\n" +
  22397. " ,t.FINISHEDLOADBATCHNO\n" +
  22398. " ,t.AccountID\n" +
  22399. " ,:UpdateUserID\n" +
  22400. " FROM TP_PM_FinishedProduct t\n" +
  22401. " WHERE t.barcode = :BarCode";
  22402. paras = new OracleParameter[]{
  22403. new OracleParameter(":BarCode",OracleDbType.NVarchar2,barcode,ParameterDirection.Input),
  22404. new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  22405. };
  22406. int resultRow = oracleTrConn.ExecuteNonQuery(sqlString, paras);
  22407. // SAP同步后再成品交接撤销的,记录撤销标识
  22408. string sapsql = "select count(*) from tsap_hegii_FinishedProduct t where t.barcode = :BarCode and ztype='S' and rownum=1 ";
  22409. OracleParameter[] sapparas = new OracleParameter[]{
  22410. new OracleParameter(":BarCode",OracleDbType.NVarchar2,barcode,ParameterDirection.Input),
  22411. };
  22412. int sapcount = Convert.ToInt32(oracleTrConn.GetSqlResultToObj(sapsql, sapparas));
  22413. if (sapcount > 0)
  22414. {
  22415. sapsql = "update tp_pm_groutingdailydetail set SAPFHUndoFlag = '1' where barcode=:BarCode";
  22416. oracleTrConn.ExecuteNonQuery(sapsql, sapparas);
  22417. }
  22418. sapsql = "update tsap_hegii_FinishedProduct set ztype = 'D' where barcode=:BarCode and (ztype is null or ztype not in ('S','D'))";
  22419. oracleTrConn.ExecuteNonQuery(sapsql, sapparas);
  22420. sql = @"Update TP_PM_FinishedProduct
  22421. set FHUserID=null,
  22422. FHUserCode=null,
  22423. FHBatchNo=null,
  22424. FHTime=null,
  22425. FHOrderID=null,FINISHEDLOADBATCHNO=null,
  22426. UpdateUserID=:UpdateUserID
  22427. where BarCode=:BarCode";
  22428. resultRow = oracleTrConn.ExecuteNonQuery(sql, paras);
  22429. if (resultRow == 0)
  22430. {
  22431. oracleTrConn.Rollback();
  22432. oracleTrConn.Disconnect();
  22433. }
  22434. else
  22435. {
  22436. resultEntity.Result = 1;
  22437. oracleTrConn.Commit();
  22438. oracleTrConn.Disconnect();
  22439. }
  22440. #endregion
  22441. return resultEntity;
  22442. }
  22443. catch (Exception ex)
  22444. {
  22445. throw ex;
  22446. }
  22447. }
  22448. /// <summary>
  22449. /// 更改产成品交接订单号
  22450. /// </summary>
  22451. /// <param name="barcode"></param>
  22452. /// <param name="orderid"></param>
  22453. /// <param name="sUserInfo"></param>
  22454. /// <returns></returns>
  22455. public static ServiceResultEntity SaveChangeFinishedHandoverByBarcode(string barcode, int orderid, SUserInfo sUserInfo)
  22456. {
  22457. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  22458. try
  22459. {
  22460. ServiceResultEntity resultEntity = new ServiceResultEntity();
  22461. // 1.判断产品是否在产成品表中
  22462. string sql = @"select
  22463. FHUserID,
  22464. FHUserCode,
  22465. GoodsID,
  22466. GoodsCode,
  22467. GoodsName
  22468. from TP_PM_FinishedProduct
  22469. where BarCode=:BarCode";
  22470. OracleParameter[] paras = new OracleParameter[]{
  22471. new OracleParameter(":BarCode",OracleDbType.NVarchar2,barcode,ParameterDirection.Input),
  22472. };
  22473. DataSet dsResult = oracleTrConn.GetSqlResultToDs(sql, paras);
  22474. if (dsResult != null && dsResult.Tables[0].Rows.Count > 0)
  22475. {
  22476. // 在产成品表中
  22477. #region 是否交接过
  22478. string fhUserCode = dsResult.Tables[0].Rows[0]["FHUserCode"].ToString();
  22479. if (string.IsNullOrEmpty(fhUserCode))
  22480. {
  22481. resultEntity.Result = -1; //未交接,不能撤销
  22482. resultEntity.Message = "此产品【" + barcode + "】未交接,不能进行该操作";
  22483. return resultEntity;
  22484. }
  22485. #endregion
  22486. }
  22487. else
  22488. {
  22489. resultEntity.Result = -2; //不能产成品,不能撤销
  22490. sql = "select GoodsCode from TP_PM_GroutingDailyDetail where BarCode=:BarCode";
  22491. dsResult = oracleTrConn.GetSqlResultToDs(sql, paras);
  22492. if (dsResult != null && dsResult.Tables[0].Rows.Count > 0)
  22493. {
  22494. resultEntity.Message = "此产品【" + barcode + "】不是产成品,不能进行该操作";
  22495. }
  22496. else
  22497. {
  22498. resultEntity.Message = "此条码【" + barcode + "】无效,不能进行该操作";
  22499. }
  22500. return resultEntity;
  22501. }
  22502. #region 查询产品相关信息
  22503. sql = @"Update TP_PM_FinishedProduct
  22504. set
  22505. FHOrderID=:FHOrderID,
  22506. UpdateUserID=:UpdateUserID
  22507. where BarCode=:BarCode";
  22508. paras = new OracleParameter[]{
  22509. new OracleParameter(":BarCode",OracleDbType.NVarchar2,barcode,ParameterDirection.Input),
  22510. new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  22511. new OracleParameter(":FHOrderID",OracleDbType.Int32,orderid,ParameterDirection.Input),
  22512. };
  22513. int resultRow = oracleTrConn.ExecuteNonQuery(sql, paras);
  22514. if (resultRow == 0)
  22515. {
  22516. oracleTrConn.Rollback();
  22517. oracleTrConn.Disconnect();
  22518. }
  22519. else
  22520. {
  22521. resultEntity.Result = 1;
  22522. oracleTrConn.Commit();
  22523. oracleTrConn.Disconnect();
  22524. }
  22525. #endregion
  22526. return resultEntity;
  22527. }
  22528. catch (Exception ex)
  22529. {
  22530. throw ex;
  22531. }
  22532. }
  22533. /// <summary>
  22534. /// 回收标准计件
  22535. /// </summary>
  22536. /// <param name="oracleTrConn">数据连接对象</param>
  22537. /// <param name="procedure">工序对象</param>
  22538. /// <param name="barcodeTable">条码信息</param>
  22539. /// <param name="sUserInfo">用户基本信息</param>
  22540. /// <param name="goodsID">返回的产品ID</param>
  22541. /// <param name="goodsCode">返回的产品Code</param>
  22542. /// <param name="goodsName">返回的产品名称</param>
  22543. /// <param name="groutingUserID">返回的注浆者ID</param>
  22544. /// <returns>string</returns>
  22545. /// <remarks>
  22546. /// 王鑫 2017.7.20 新建
  22547. /// </remarks>
  22548. private static string AddRecydingFlagWorkPiece(IDBTransaction oracleTrConn,
  22549. ProcedureEntity procedure,
  22550. DataTable barcodeTable,
  22551. SUserInfo sUserInfo,
  22552. out int goodsID,
  22553. out string goodsCode,
  22554. out string goodsName,
  22555. out string groutingUserCode, out string logoCode, out string logoName, out string groutingdate)
  22556. {
  22557. try
  22558. {
  22559. int deleteRow = 0;
  22560. goodsID = Constant.INT_IS_ZERO;
  22561. goodsCode = null;
  22562. goodsName = null;
  22563. groutingUserCode = string.Empty; //Constant.INT_IS_ZERO;
  22564. // 获得账务日期
  22565. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  22566. string errMsg = string.Empty;
  22567. // 本批采集的批次号
  22568. string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  22569. // 条码信息
  22570. string logoName_Temp = "";
  22571. string logoCode_Temp = "";
  22572. string groutingdate_Temp = "";
  22573. foreach (DataRow barcodeRow in barcodeTable.Rows)
  22574. {
  22575. // 条码
  22576. string barcode = barcodeRow["Barcode"].ToString();
  22577. if (string.IsNullOrEmpty(barcode))
  22578. {
  22579. throw new Exception("传入的条码号为空");
  22580. }
  22581. // 生产工号
  22582. int workUserID = Convert.ToInt32(barcodeRow["UserID"]);
  22583. // 生产工号
  22584. string workUserCode = barcodeRow["UserCode"].ToString();
  22585. //#region 校验条码有效性
  22586. //errMsg = CheckDryRepairBarcode(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo);
  22587. //if (!string.IsNullOrEmpty(errMsg))
  22588. //{
  22589. // return errMsg;
  22590. //}
  22591. //#endregion
  22592. if (procedure.CollectType == 1)
  22593. {
  22594. #region 校验条码有效性
  22595. errMsg = CheckRecyclingFlagBarcode(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo);
  22596. if (!string.IsNullOrEmpty(errMsg))
  22597. {
  22598. logoName = "";
  22599. logoCode = "";
  22600. groutingdate = "";
  22601. return errMsg;
  22602. }
  22603. #endregion
  22604. }
  22605. else
  22606. {
  22607. string sqlGroutingInfo = @"select tp_pm_groutingdailydetail.goodsid,
  22608. tp_pm_groutingdailydetail.goodscode,
  22609. tp_pm_groutingdailydetail.goodsname,
  22610. tp_pm_groutingdailydetail.usercode as groutingUserCode,
  22611. tp_pm_groutingdailydetail.groutingdate,
  22612. tp_mst_logo.logoid,
  22613. tp_mst_logo.logocode,
  22614. tp_mst_logo.logoname
  22615. from tp_pm_groutingdailydetail
  22616. left join tp_mst_logo
  22617. on tp_pm_groutingdailydetail.logoid=tp_mst_logo.logoid
  22618. where tp_pm_groutingdailydetail.barcode=:barcode
  22619. ";
  22620. OracleParameter[] paras = new OracleParameter[] {
  22621. new OracleParameter(":barcode",barcode),
  22622. };
  22623. DataSet dsGrouting = oracleTrConn.GetSqlResultToDs(sqlGroutingInfo, paras);
  22624. if (dsGrouting != null && dsGrouting.Tables[0].Rows.Count > 0)
  22625. {
  22626. goodsID = Convert.ToInt32(dsGrouting.Tables[0].Rows[0]["goodsid"]);
  22627. goodsCode = dsGrouting.Tables[0].Rows[0]["goodscode"].ToString();
  22628. goodsName = dsGrouting.Tables[0].Rows[0]["goodsName"].ToString();
  22629. groutingUserCode = dsGrouting.Tables[0].Rows[0]["groutingUserCode"].ToString();
  22630. logoName = dsGrouting.Tables[0].Rows[0]["logoName"].ToString();
  22631. logoCode = dsGrouting.Tables[0].Rows[0]["logoCode"].ToString();
  22632. groutingdate = dsGrouting.Tables[0].Rows[0]["groutingdate"].ToString();
  22633. logoName_Temp = logoName;
  22634. logoCode_Temp = logoCode;
  22635. groutingdate_Temp = groutingdate;
  22636. }
  22637. }
  22638. #region 数据处理
  22639. #region 处理废弃数据并转回收数据为在产数据
  22640. //////string querysql = @"select GOODSLEVELID from TP_MST_GOODSLEVEL where GOODSLEVELTYPEID=9 and ACCOUNTID=:accountid and VALUEFLAG=1";
  22641. //////OracleParameter[] queryparas = new OracleParameter[]{
  22642. ////// new OracleParameter(":accountid",OracleDbType.Varchar2, sUserInfo.AccountID,ParameterDirection.Input)
  22643. //////};
  22644. //////DataSet returnDs = oracleTrConn.GetSqlResultToDs(querysql, queryparas);
  22645. //////if (returnDs == null || returnDs.Tables[0].Rows.Count == 0)
  22646. //////{
  22647. ////// errMsg = "未设定干补等级";
  22648. ////// logoName = "";
  22649. ////// logoCode = "";
  22650. ////// groutingdate = "";
  22651. ////// return errMsg;
  22652. //////}
  22653. //////string goodsLevelID = returnDs.Tables[0].Rows[0][0].ToString();
  22654. //第一步,废弃数据的产品分级类别由 8损坯13不合格14不合格(返) 改为 9干补,产品分级=此账套相应的设置
  22655. /*string sqlUpdateLevelTypeString = @"update TP_PM_ScrapProduct set GOODSLEVELID=:GOODSLEVELID, GoodsLevelTypeID=9,SpecialRepairFlag=1,
  22656. SpecialRepairUserID=:SpecialRepairUserID,SpecialRepairUserCode=:SpecialRepairUserCode,SpecialRepairTime=sysdate,
  22657. UpdateUserID=:UpdateUserID
  22658. where BarCode=:barcode
  22659. and CreateTime=(select max(CreateTime) from TP_PM_ScrapProduct where BarCode=:barcode1 and ValueFlag=1)
  22660. and ValueFlag=1 and GoodsLevelTypeID=(select max(GoodsLevelTypeID) from TP_PM_ScrapProduct where BarCode=:barcode1 and ValueFlag=1) ";
  22661. */
  22662. // and ValueFlag=1 and GoodsLevelTypeID=8 ";
  22663. ////// string sqlUpdateLevelTypeString = @"update TP_PM_ScrapProduct set GOODSLEVELID=:GOODSLEVELID, GoodsLevelTypeID=9,
  22664. ////// SpecialRepairUserID=:SpecialRepairUserID,SpecialRepairUserCode=:SpecialRepairUserCode,SpecialRepairTime=sysdate,
  22665. ////// UpdateUserID=:UpdateUserID
  22666. ////// where BarCode=:barcode
  22667. ////// and CreateTime=(select max(CreateTime) from TP_PM_ScrapProduct where BarCode=:barcode1 and ValueFlag=1)
  22668. ////// and ValueFlag=1 and GoodsLevelTypeID in (8, 13, 14) ";
  22669. string sqlUpdateLevelTypeString = @"update TP_PM_ScrapProduct set RecyclingFlag=1,
  22670. UpdateUserID=:UpdateUserID,RecyclingUserID=:RecyclingUserID,RecyclingUserCode=:RecyclingUserCode,
  22671. RecyclingTime=sysdate
  22672. where BarCode=:barcode
  22673. and CreateTime=(select max(CreateTime) from TP_PM_ScrapProduct where BarCode=:barcode and ValueFlag=1)
  22674. and ValueFlag=1 ";
  22675. OracleParameter[] ScrapProductparas = new OracleParameter[]{
  22676. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  22677. new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  22678. new OracleParameter(":RecyclingUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  22679. new OracleParameter(":RecyclingUserCode",OracleDbType.Varchar2, sUserInfo.UserCode,ParameterDirection.Input),
  22680. };
  22681. oracleTrConn.ExecuteNonQuery(sqlUpdateLevelTypeString, ScrapProductparas);
  22682. string sqlUpdateGROUTString = @"update TP_PM_GROUTINGDAILYDETAIL set RecyclingFlag=1,
  22683. UpdateUserID=:UpdateUserID
  22684. where BarCode=:barcode ";
  22685. OracleParameter[] GROUTparas = new OracleParameter[]{
  22686. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  22687. new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  22688. };
  22689. oracleTrConn.ExecuteNonQuery(sqlUpdateGROUTString, GROUTparas);
  22690. //modify wangx 20150623
  22691. //////OracleParameter[] sqlUpdateparas = new OracleParameter[]{
  22692. ////// new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  22693. //////};
  22694. //string sqlUpdate = "update TP_PM_InCheckedDetail set SpecialRepairFlag=1 where barcode=:barcode";
  22695. //oracleTrConn.ExecuteNonQuery(sqlUpdate, sqlUpdateparas);
  22696. //////string sqlUpdate = "update TP_PM_ProductionDataIn set SpecialRepairFlag=1 where barcode=:barcode";
  22697. //////oracleTrConn.ExecuteNonQuery(sqlUpdate, sqlUpdateparas);
  22698. //modify wangx 20150623 end
  22699. #region
  22700. //第五步,插入回收工序的生产数据(同其他计件工序),设置干补标识,产品分级类别=9干补,产品分级=此账套相应的设置
  22701. // 查询新插入的生产数据ID
  22702. string sql = "select SEQ_PM_ProductionData_ID.nextval from dual";
  22703. string idStr = oracleTrConn.GetSqlResultToStr(sql);
  22704. int productionDataID = 0;
  22705. if (!string.IsNullOrEmpty(idStr))
  22706. {
  22707. productionDataID = int.Parse(idStr);
  22708. }
  22709. else
  22710. {
  22711. logoName = "";
  22712. logoCode = "";
  22713. groutingdate = "";
  22714. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  22715. }
  22716. int? ClassesSettingID = null;//班次配置ID
  22717. #region 第五步 添加生产者数据
  22718. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID);
  22719. if (!string.IsNullOrEmpty(errMsg))
  22720. {
  22721. logoName = "";
  22722. logoCode = "";
  22723. groutingdate = "";
  22724. return errMsg;
  22725. }
  22726. #endregion
  22727. ProductionDataEntity productionData = new ProductionDataEntity();
  22728. #region 属性赋值
  22729. productionData.ClassesSettingID = ClassesSettingID;
  22730. productionData.ProductionDataID = Convert.ToInt32(idStr);
  22731. productionData.Barcode = barcode;
  22732. productionData.CentralizedBatchNo = centralizedBatchNo;
  22733. productionData.ProductionLineID = procedure.ProductionLineID;
  22734. productionData.ProductionLineCode = procedure.ProductionlineCode;
  22735. productionData.ProductionLineName = procedure.ProductionlineName;
  22736. productionData.CompleteProcedureID = procedure.ProcedureID;
  22737. productionData.ProcedureCode = procedure.ProcedureCode;
  22738. productionData.ProcedureName = procedure.ProcedureName;
  22739. productionData.ProcedureModel = procedure.ProcedureModel;
  22740. productionData.ModelType = procedure.ModelType;
  22741. productionData.NodeType = procedure.NodeType;
  22742. productionData.DefectFlag = (int)Constant.DefectFlag.No;
  22743. productionData.ReworkProcedureID = null;
  22744. productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, barcode);
  22745. productionData.IsReFire = (int)Constant.ReFireFlag.No;
  22746. //设置干补标识,产品分级类别=9干补
  22747. ////productionData.GoodsLevelTypeID = 9;
  22748. //productionData.GoodsLevelID = int.Parse(goodsLevelID);
  22749. //productionData.GoodsGrade = (int)Constant.GoodsGrade.Good;
  22750. productionData.OrganizationID = procedure.OrganizationID;
  22751. productionData.GoodsID = goodsID;
  22752. productionData.GoodsCode = goodsCode;
  22753. productionData.GoodsName = goodsName;
  22754. productionData.UserID = workUserID;
  22755. productionData.UserCode = barcodeRow["UserCode"].ToString();
  22756. productionData.UserName = barcodeRow["UserName"].ToString();
  22757. productionData.PieceType = procedure.PieceType;
  22758. if (barcodeRow["LogoID"].ToString() != "")
  22759. {
  22760. productionData.LogoID = Convert.ToInt32(barcodeRow["LogoID"]);
  22761. }
  22762. string sqlReFire = @"select
  22763. isrefire,
  22764. logoid,GoodsLevelID,GoodsLevelTypeID
  22765. from tp_pm_inproduction where barcode=:barcode
  22766. union
  22767. select
  22768. isrefire,
  22769. logoid,GoodsLevelID,GoodsLevelTypeID
  22770. from TP_PM_InProductionTrash where barcode=:barcode
  22771. union
  22772. select
  22773. isrefire,
  22774. logoid,GoodsLevelID,GoodsLevelTypeID
  22775. from TP_PM_FinishedProduct where barcode=:barcode ";
  22776. OracleParameter[] ReFireparas = new OracleParameter[] {
  22777. new OracleParameter(":barcode",barcode),
  22778. };
  22779. DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas);
  22780. if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0)
  22781. {
  22782. if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0)
  22783. {
  22784. productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]);
  22785. }
  22786. if (dsReFire.Tables[0].Rows[0]["logoid"].ToString() != "")
  22787. {
  22788. productionData.LogoID = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["LogoID"]);
  22789. }
  22790. if (dsReFire.Tables[0].Rows[0]["GoodsLevelTypeID"].ToString() != string.Empty)
  22791. {
  22792. productionData.GoodsLevelTypeID = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["GoodsLevelTypeID"]);
  22793. productionData.GoodsLevelID = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["GoodsLevelID"]);
  22794. }
  22795. }
  22796. #endregion 属性赋值
  22797. productionData.SpecialRepairflag = 0;
  22798. string OutSpecialRepairflag = "0";// 没有什么特殊的,同干补保存生产数据共用同一个方法
  22799. errMsg = AddDryRepairProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag);
  22800. if (!string.IsNullOrEmpty(errMsg))
  22801. {
  22802. logoName = "";
  22803. logoCode = "";
  22804. groutingdate = "";
  22805. return errMsg;
  22806. }
  22807. #endregion
  22808. //第二步,回收站中数据回到在产中,设置干补标识。
  22809. string sqlInsInProdString = @"insert into TP_PM_InProduction(BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME,
  22810. PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID,
  22811. ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME,
  22812. USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE,
  22813. GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID,
  22814. CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE,
  22815. REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME,
  22816. CREATEUSERID, UPDATETIME, UPDATEUSERID,
  22817. ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG,
  22818. GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM,
  22819. KILNID, KILNCODE, KILNNAME, KILNCARID,
  22820. KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID
  22821. ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,logoid, ISREWORKFLAG, SEMICHECKID)
  22822. select BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME,
  22823. :PROCEDUREMODEL, :MODELTYPE, null,
  22824. ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME,
  22825. USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE,
  22826. GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID,
  22827. CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE,
  22828. REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME,
  22829. CREATEUSERID, UPDATETIME, :UpdateUserID,
  22830. ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, 1,
  22831. GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM,
  22832. KILNID, KILNCODE, KILNNAME, KILNCARID,
  22833. KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,:ProcedureID ,--FlowProcedureID
  22834. FlowProcedureTime,:ProcedureID,sysdate,:ProductionDataID,logoid, ISREWORKFLAG, SEMICHECKID
  22835. from TP_PM_InProductionTrash where barcode=:barcode ";
  22836. OracleParameter[] InProductparas = new OracleParameter[]{
  22837. new OracleParameter(":UpdateUserID",OracleDbType.Int32, workUserID,ParameterDirection.Input),
  22838. ////new OracleParameter(":GOODSLEVELID",OracleDbType.Int32,int.Parse(goodsLevelID),ParameterDirection.Input),
  22839. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  22840. new OracleParameter(":ProcedureID",OracleDbType.Int32,procedure.ProcedureID,ParameterDirection.Input),
  22841. new OracleParameter(":PROCEDUREMODEL",OracleDbType.Varchar2,procedure.ProcedureModel,ParameterDirection.Input),
  22842. new OracleParameter(":MODELTYPE",OracleDbType.Int32,procedure.ModelType,ParameterDirection.Input),
  22843. new OracleParameter(":ProductionDataID",OracleDbType.Int32,productionDataID,ParameterDirection.Input)
  22844. };
  22845. //第三步,删除回收站中的条码
  22846. string sqlDelInProductTrashString = "delete from TP_PM_InProductionTrash where barcode=:barcode ";
  22847. OracleParameter[] TrashProductparas = new OracleParameter[]{
  22848. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input)
  22849. };
  22850. //第四步,更新注浆表干补标识
  22851. // string sqlUpGroutingDeilString = @"update TP_PM_GroutingDailyDetail set SpecialRepairFlag=1
  22852. // where GroutingDailyDetailID=(select GroutingDailyDetailID from TP_PM_GROUTINGPRODUCT
  22853. // where barcode=:barcode)";
  22854. ////// string sqlUpGroutingDeilString = @"update TP_PM_GroutingDailyDetail set SpecialRepairFlag=1
  22855. ////// where barcode=:barcode";
  22856. ////// OracleParameter[] GroutingProductparas = new OracleParameter[]{
  22857. ////// new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input)
  22858. ////// };
  22859. // string sqlUpCompleteString = @"update TP_PM_FINISHEDPRODUCT set SpecialRepairFlag=1
  22860. // where barcode=:barcode ";
  22861. // OracleParameter[] CompleteProductparas = new OracleParameter[]{
  22862. // new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input)
  22863. // };
  22864. deleteRow += oracleTrConn.ExecuteNonQuery(sqlUpdateLevelTypeString, ScrapProductparas);
  22865. deleteRow += oracleTrConn.ExecuteNonQuery(sqlInsInProdString, InProductparas);
  22866. deleteRow += oracleTrConn.ExecuteNonQuery(sqlDelInProductTrashString, TrashProductparas);
  22867. //deleteRow += oracleTrConn.ExecuteNonQuery(sqlUpGroutingDeilString, GroutingProductparas);
  22868. //deleteRow += oracleTrConn.ExecuteNonQuery(sqlUpCompleteString, CompleteProductparas); //由于成品后,不能报损,所以这个执行去掉
  22869. // 失败
  22870. if (deleteRow == Constant.INT_IS_ZERO)
  22871. {
  22872. logoName = "";
  22873. logoCode = "";
  22874. groutingdate = "";
  22875. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  22876. }
  22877. #endregion
  22878. //#region 第五步 添加生产者数据
  22879. //errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo);
  22880. //if (!string.IsNullOrEmpty(errMsg))
  22881. //{
  22882. // return errMsg;
  22883. //}
  22884. //#endregion
  22885. //第五步,回添加生产数据 modify wangx 2015/07/20 新添加的代码
  22886. sql = "select 1 from tp_pm_productiondatain where barcode=:barcode and valueflag=1";
  22887. OracleParameter[] Paras = new OracleParameter[] {
  22888. new OracleParameter(":barcode",OracleDbType.Varchar2,
  22889. barcode,ParameterDirection.Input)
  22890. };
  22891. DataSet ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  22892. if (ds.Tables[0].Rows.Count == 0)
  22893. {
  22894. // 2 生产数据恢复到在产生产数据
  22895. sql = @"insert into tp_pm_productiondatain
  22896. (
  22897. ProductionDataID,
  22898. BarCode,
  22899. CentralizedBatchNo,
  22900. ProductionLineID,
  22901. ProductionLineCode,
  22902. ProductionLineName,
  22903. ProcedureID,
  22904. ProcedureCode,
  22905. ProcedureName,
  22906. ProcedureModel,
  22907. ModelType,
  22908. PieceType,
  22909. IsReworked,
  22910. NodeType,
  22911. IsPublicBody,
  22912. IsReFire,
  22913. GoodsLevelID,
  22914. GoodsLevelTypeID,
  22915. SpecialRepairFlag,
  22916. OrganizationID,
  22917. GoodsID,
  22918. GoodsCode,
  22919. GoodsName,
  22920. UserID,
  22921. UserCode,
  22922. UserName,
  22923. ClassesSettingID,
  22924. KilnID,
  22925. KilnCode,
  22926. KilnName,
  22927. KilnCarID,
  22928. KilnCarCode,
  22929. KilnCarName,
  22930. KilnCarBatchNo,
  22931. KilnCarPosition,
  22932. ReworkProcedureID,
  22933. ReworkProcedureCode,
  22934. ReworkProcedureName,
  22935. GroutingDailyID,
  22936. GroutingDailyDetailID,
  22937. GroutingLineID,
  22938. GroutingLineCode,
  22939. GroutingLineName,
  22940. GMouldTypeID,
  22941. CanManyTimes,
  22942. GroutingLineDetailID,
  22943. GroutingDate,
  22944. GroutingMouldCode,
  22945. MouldCode,
  22946. GroutingUserID,
  22947. GroutingUserCode,
  22948. GroutingNum,
  22949. Remarks,
  22950. AccountDate,
  22951. SettlementFlag,
  22952. AccountID,
  22953. ValueFlag,
  22954. CreateTime,
  22955. CreateUserID,
  22956. UpdateTime,
  22957. UpdateUserID,
  22958. OPTimeStamp,
  22959. TriggerFlag,
  22960. logoid,
  22961. BackOutTime,BackOutUserID,BackOutUserCode
  22962. )
  22963. select
  22964. ProductionDataID,
  22965. BarCode,
  22966. CentralizedBatchNo,
  22967. ProductionLineID,
  22968. ProductionLineCode,
  22969. ProductionLineName,
  22970. ProcedureID,
  22971. ProcedureCode,
  22972. ProcedureName,
  22973. ProcedureModel,
  22974. ModelType,
  22975. PieceType,
  22976. IsReworked,
  22977. NodeType,
  22978. IsPublicBody,
  22979. IsReFire,
  22980. GoodsLevelID,
  22981. GoodsLevelTypeID,
  22982. SpecialRepairFlag,
  22983. OrganizationID,
  22984. GoodsID,
  22985. GoodsCode,
  22986. GoodsName,
  22987. UserID,
  22988. UserCode,
  22989. UserName,
  22990. ClassesSettingID,
  22991. KilnID,
  22992. KilnCode,
  22993. KilnName,
  22994. KilnCarID,
  22995. KilnCarCode,
  22996. KilnCarName,
  22997. KilnCarBatchNo,
  22998. KilnCarPosition,
  22999. ReworkProcedureID,
  23000. ReworkProcedureCode,
  23001. ReworkProcedureName,
  23002. GroutingDailyID,
  23003. GroutingDailyDetailID,
  23004. GroutingLineID,
  23005. GroutingLineCode,
  23006. GroutingLineName,
  23007. GMouldTypeID,
  23008. CanManyTimes,
  23009. GroutingLineDetailID,
  23010. GroutingDate,
  23011. GroutingMouldCode,
  23012. MouldCode,
  23013. GroutingUserID,
  23014. GroutingUserCode,
  23015. GroutingNum,
  23016. Remarks,
  23017. AccountDate,
  23018. SettlementFlag,
  23019. AccountID,
  23020. ValueFlag,
  23021. CreateTime,
  23022. CreateUserID,
  23023. UpdateTime,
  23024. UpdateUserID,
  23025. OPTimeStamp,
  23026. 1,
  23027. logoid,
  23028. BackOutTime,BackOutUserID,BackOutUserCode
  23029. from TP_PM_ProductionData where valueflag=1 and barcode=:barcode
  23030. ";
  23031. oracleTrConn.ExecuteNonQuery(sql, Paras);
  23032. }
  23033. //第五步,回添加生产数据 modify wangx 2015/07/20 新添加的代码 end
  23034. #endregion 数据处理
  23035. }
  23036. logoName = logoName_Temp;
  23037. logoCode = logoCode_Temp;
  23038. groutingdate = groutingdate_Temp;
  23039. return errMsg;
  23040. }
  23041. catch (Exception ex)
  23042. {
  23043. throw ex;
  23044. }
  23045. }
  23046. /// <summary>
  23047. /// 校验回收条码有效
  23048. /// </summary>
  23049. /// <param name="oracleTrConn">连接对象</param>
  23050. /// <param name="procedureID">工序ID</param>
  23051. /// <param name="barcode">条码</param>
  23052. /// <param name="goodsID">返回的产品ID</param>
  23053. /// <param name="goodsCode">返回的产品Code</param>
  23054. /// <param name="goodsName">返回的产品名称</param>
  23055. /// <param name="groutingUserID">返回的注浆者ID</param>
  23056. /// <returns>string</returns>
  23057. /// <remarks>
  23058. /// 王鑫 2017.7.20 新建
  23059. /// </remarks>
  23060. private static string CheckRecyclingFlagBarcode(IDBTransaction oracleTrConn,
  23061. int procedureID,
  23062. string barcode,
  23063. out int goodsID,
  23064. out string goodsCode,
  23065. out string goodsName,
  23066. out string groutingUserCode,
  23067. SUserInfo sUserInfo
  23068. )
  23069. {
  23070. try
  23071. {
  23072. //OracleParameter[] paras = new OracleParameter[]{
  23073. // new OracleParameter("in_procedureid",OracleDbType.Int32,procedureID,ParameterDirection.Input),
  23074. // new OracleParameter("in_barcode",OracleDbType.Varchar2,barcode,ParameterDirection.Input),
  23075. // new OracleParameter("out_errMsg",OracleDbType.Varchar2,2000,"",ParameterDirection.Output),
  23076. // new OracleParameter("out_goodsID",OracleDbType.Int32,ParameterDirection.Output),
  23077. // new OracleParameter("out_goodsCode",OracleDbType.Varchar2,50,"",ParameterDirection.Output),
  23078. // new OracleParameter("out_goodsName",OracleDbType.Varchar2,50,"",ParameterDirection.Output),
  23079. // new OracleParameter("out_groutingUserCode",OracleDbType.NVarchar2,50,null,ParameterDirection.Output),
  23080. //};
  23081. //oracleTrConn.ExecStoredProcedure("pro_pm_checkdryrepairbarcode", paras);
  23082. //if (!"null".Equals(paras[3].Value + ""))
  23083. //{
  23084. // goodsID = Convert.ToInt32(paras[3].Value + "");
  23085. //}
  23086. //else
  23087. //{
  23088. // goodsID = 0;
  23089. //}
  23090. //goodsCode = paras[4].Value + "";
  23091. //goodsName = paras[5].Value + "";
  23092. //if (!"null".Equals(paras[6].Value + ""))
  23093. //{
  23094. // groutingUserCode = paras[6].Value + "";
  23095. //}
  23096. //else
  23097. //{
  23098. // groutingUserCode = null;
  23099. //}
  23100. //if ("null".Equals(paras[2].Value + ""))
  23101. //{
  23102. // return null;
  23103. //}
  23104. //return paras[2].Value.ToString().Replace("\\n\\r", "\n\r");
  23105. string errorMessage = string.Empty;
  23106. goodsID = 0;
  23107. goodsCode = string.Empty;
  23108. goodsName = string.Empty;
  23109. groutingUserCode = string.Empty;
  23110. string sqlString = @"select settingcode,settingvalue,settingdefaultvalues from tp_mst_systemsetting
  23111. where Accountid=:Accountid and settingcode in ('S_PM_017','S_PM_018','S_PM_019','S_PM_020')";
  23112. OracleParameter[] paras = new OracleParameter[]{
  23113. new OracleParameter("Accountid",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  23114. };
  23115. DataSet ds = oracleTrConn.GetSqlResultToDs(sqlString, paras);
  23116. #region 读出系统配置 17(损坯可否回收) 18(半检不合格可否回收) 19(复检不合格可否回收) 20(次品可否回收)
  23117. int S_PM_017_Value = 0, S_PM_018_Value = 0, S_PM_019_Value = 0, S_PM_020_Value = 0;
  23118. if (ds != null && ds.Tables[0].Rows.Count > 0)
  23119. {
  23120. foreach (DataRow r in ds.Tables[0].Rows)
  23121. {
  23122. if (r["settingcode"].ToString() == "S_PM_017")
  23123. {
  23124. S_PM_017_Value = Convert.ToInt32(r["settingvalue"]);
  23125. }
  23126. else if (r["settingcode"].ToString() == "S_PM_018")
  23127. {
  23128. S_PM_018_Value = Convert.ToInt32(r["settingvalue"]);
  23129. }
  23130. else if (r["settingcode"].ToString() == "S_PM_019")
  23131. {
  23132. S_PM_019_Value = Convert.ToInt32(r["settingvalue"]);
  23133. }
  23134. else if (r["settingcode"].ToString() == "S_PM_020")
  23135. {
  23136. S_PM_020_Value = Convert.ToInt32(r["settingvalue"]);
  23137. }
  23138. }
  23139. }
  23140. #endregion
  23141. #region 第1步 查当前工序在系统是否存在
  23142. sqlString = @"select NodeType,ModelType from tp_pc_procedure where procedureid=:procedureid and ValueFlag=1";
  23143. paras = new OracleParameter[]{
  23144. new OracleParameter(":procedureid",procedureID),
  23145. };
  23146. ds = oracleTrConn.GetSqlResultToDs(sqlString, paras);
  23147. if (ds == null || ds.Tables[0].Rows.Count == 0)
  23148. {
  23149. errorMessage = "当前工序在系统中不存在";
  23150. return errorMessage;
  23151. }
  23152. #endregion
  23153. #region 第2步 查产品是否有效
  23154. sqlString = @"select distinct GoodsID, GoodsCode,GoodsName,UserCode,DeliverFlag
  23155. from TP_PM_GroutingDailyDetail where BarCode=:barCode and ValueFlag=1 ";
  23156. paras = new OracleParameter[]{
  23157. new OracleParameter(":barCode",barcode),
  23158. };
  23159. ds = oracleTrConn.GetSqlResultToDs(sqlString, paras);
  23160. if (ds == null || ds.Tables[0].Rows.Count == 0)
  23161. {
  23162. // 是否被替换
  23163. string sql = @"select count(barcode),max(newbarcode) from TP_PM_BarCodeRecord where BarCode=:barcode";
  23164. OracleParameter[] paras2 = new OracleParameter[]{
  23165. new OracleParameter(":barCode",barcode) };
  23166. DataSet ds2 = oracleTrConn.GetSqlResultToDs(sql, paras2);
  23167. if (ds2 != null && Convert.ToInt32(ds2.Tables[0].Rows[0][0]) == 0)
  23168. {
  23169. // 无效条件
  23170. errorMessage = "无效条码[" + barcode + "]";
  23171. }
  23172. else
  23173. {
  23174. errorMessage = "条码[" + barcode + "]已经被[" + ds2.Tables[0].Rows[0][1] + "]替换";
  23175. }
  23176. }
  23177. else
  23178. {
  23179. if (Convert.ToInt32(ds.Tables[0].Rows[0]["DeliverFlag"]) != 1)
  23180. {
  23181. errorMessage = "条码[" + barcode + "]未交坯,不能回收";
  23182. }
  23183. else
  23184. {
  23185. goodsID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsID"]);
  23186. goodsName = ds.Tables[0].Rows[0]["goodsName"].ToString();
  23187. goodsCode = ds.Tables[0].Rows[0]["GoodsCode"].ToString();
  23188. groutingUserCode = ds.Tables[0].Rows[0]["UserCode"].ToString();
  23189. }
  23190. }
  23191. if (!string.IsNullOrEmpty(errorMessage))
  23192. {
  23193. return errorMessage;
  23194. }
  23195. #endregion
  23196. #region 第3步 查产品是否在当前工序配置
  23197. sqlString = @"select count(GoodsID) from TP_PC_ProcedureGoods where GoodsID=:GoodsID and ProcedureID=:ProcedureID";
  23198. paras = new OracleParameter[]{
  23199. new OracleParameter(":GoodsID",goodsID),
  23200. new OracleParameter(":ProcedureID",procedureID),
  23201. };
  23202. ds = oracleTrConn.GetSqlResultToDs(sqlString, paras);
  23203. if (Convert.ToInt32(ds.Tables[0].Rows[0][0]) != 1)
  23204. {
  23205. errorMessage =
  23206. @"条码[" + barcode + "]不可以经过该工序\n\r原因:条码对应的产品编码[" + goodsCode + "]没有在该工序中配置";
  23207. }
  23208. if (!string.IsNullOrEmpty(errorMessage))
  23209. {
  23210. return errorMessage;
  23211. }
  23212. #endregion
  23213. #region 第4步,校验在产产品不能回收
  23214. string sqlString2 = "select InScrapFlag,ISREWORKFLAG from tp_pm_inproduction where barcode=:barcode";
  23215. OracleParameter[] parasNew = new OracleParameter[]{
  23216. new OracleParameter(":barcode",barcode) };
  23217. DataSet dsNew = oracleTrConn.GetSqlResultToDs(sqlString2, parasNew);
  23218. if (dsNew != null && dsNew.Tables[0].Rows.Count > 0)
  23219. {
  23220. if (Convert.ToInt32(dsNew.Tables[0].Rows[0]["InScrapFlag"]) == 1)
  23221. {
  23222. errorMessage = "报损待审产品不能回收";
  23223. }
  23224. // chenxy 2019-10-02 半检返修 IsReworkFlag=2
  23225. else if (Convert.ToInt32(dsNew.Tables[0].Rows[0]["ISREWORKFLAG"]) == 1)
  23226. {
  23227. errorMessage = "半检返工中不能回收";
  23228. }
  23229. else if (Convert.ToInt32(dsNew.Tables[0].Rows[0]["ISREWORKFLAG"]) == 2)
  23230. {
  23231. errorMessage = "半检返工中不能回收";
  23232. }
  23233. else
  23234. {
  23235. errorMessage = "在产产品不能回收";
  23236. }
  23237. }
  23238. if (!string.IsNullOrEmpty(errorMessage))
  23239. {
  23240. return errorMessage;
  23241. }
  23242. #endregion
  23243. #region 第4步,校验报损表数据是否可以回收
  23244. sqlString = @"select GoodsLevelID,GoodsLevelTypeID,ScrapType,SpecialRepairFlag,RecyclingFlag,AuditStatus,SpecialRepairUserID from TP_PM_ScrapProduct where barcode=:barcode
  23245. and ValueFlag=1 and CreateTime=
  23246. (select max(CreateTime) from TP_PM_ScrapProduct where barcode=:barcode
  23247. and ValueFlag=1 )";
  23248. paras = new OracleParameter[]{
  23249. new OracleParameter(":barcode",barcode),
  23250. };
  23251. ds = oracleTrConn.GetSqlResultToDs(sqlString, paras);
  23252. if (ds == null || ds.Tables[0].Rows.Count == 0)
  23253. {
  23254. errorMessage = "不存在回收数据,不能回收";
  23255. }
  23256. else
  23257. {
  23258. if (Convert.ToInt32(ds.Tables[0].Rows[0]["AuditStatus"]) == 1 &&
  23259. Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]) != 9 &&
  23260. Convert.ToInt32(ds.Tables[0].Rows[0]["RecyclingFlag"]) == 0)
  23261. {
  23262. // 可回收
  23263. string sqlString3 = "select 1 from tp_pm_inproductiontrash where barcode=:barcode";
  23264. OracleParameter[] parasNewt = new OracleParameter[]{
  23265. new OracleParameter(":barcode",barcode) };
  23266. DataSet dsNewt = oracleTrConn.GetSqlResultToDs(sqlString3, parasNewt);
  23267. if (dsNewt == null || dsNewt.Tables[0].Rows.Count == 0)
  23268. {
  23269. errorMessage = "报损数据被清除,不能回收";
  23270. }
  23271. }
  23272. else
  23273. {
  23274. errorMessage = "不存在回收数据,不能回收";
  23275. }
  23276. if (!string.IsNullOrEmpty(errorMessage))
  23277. {
  23278. if (Convert.ToInt32(ds.Tables[0].Rows[0]["ScrapType"]) == 0)
  23279. {
  23280. // 损坯
  23281. if (S_PM_017_Value == 0)
  23282. {
  23283. errorMessage = "系统参数产品回收-报损未启用";
  23284. }
  23285. }
  23286. else if (Convert.ToInt32(ds.Tables[0].Rows[0]["ScrapType"]) == 1)
  23287. {
  23288. // 成检
  23289. if (S_PM_020_Value == 0)
  23290. {
  23291. errorMessage = "系统参数产品回收-次品未启用";
  23292. }
  23293. }
  23294. else if (Convert.ToInt32(ds.Tables[0].Rows[0]["ScrapType"]) == 2)
  23295. {
  23296. // 半检
  23297. if (S_PM_018_Value == 0)
  23298. {
  23299. errorMessage = "系统参数产品回收-半检不合格未启用";
  23300. }
  23301. }
  23302. else if (Convert.ToInt32(ds.Tables[0].Rows[0]["ScrapType"]) == 3)
  23303. {
  23304. // 复检
  23305. if (S_PM_019_Value == 0)
  23306. {
  23307. errorMessage = "系统参数产品回收-复检不合格未启用";
  23308. }
  23309. }
  23310. }
  23311. }
  23312. #endregion
  23313. return errorMessage;
  23314. }
  23315. catch (Exception ex)
  23316. {
  23317. throw ex;
  23318. }
  23319. }
  23320. /// <summary>
  23321. /// 按条码判定是否为首节点
  23322. /// 从TP_PM_GroutingDailyDetail表中的BEGINNINGFLAG字段判定是否为首节点
  23323. /// "0":非首节点,"1":首节点
  23324. /// </summary>
  23325. /// <param name="oracleTrConn">数据连接</param>
  23326. /// <param name="barCode">条码</param>
  23327. /// <returns>是否首节点</returns>
  23328. /// xuwei add 2019-09-23
  23329. //public static bool IsNodeBegin(IDBTransaction oracleTrConn, string barCode)
  23330. //{
  23331. // bool result = false;
  23332. // try
  23333. // {
  23334. // if (barCode != "")
  23335. // {
  23336. // string flag = oracleTrConn.GetSqlResultToStr($@"select BEGINNINGFLAG as flag
  23337. // from TP_PM_GroutingDailyDetail
  23338. // where BARCODE = {barCode}");
  23339. // if (flag == "") throw new Exception("条码无效!请检查!");
  23340. // result = flag == "0" ? true : false;
  23341. // }
  23342. // }
  23343. // catch (Exception ex)
  23344. // {
  23345. // throw ex;
  23346. // }
  23347. // return result;
  23348. //}
  23349. //public static bool IsNodeBegin(IDBConnection oracleTrConn, string barCode)
  23350. //{
  23351. // bool result = false;
  23352. // try
  23353. // {
  23354. // if (barCode != "")
  23355. // {
  23356. // string flag = oracleTrConn.GetSqlResultToStr($@"select BEGINNINGFLAG as flag
  23357. // from TP_PM_GroutingDailyDetail
  23358. // where BARCODE = {barCode}");
  23359. // if (flag == "") throw new Exception("条码无效!请检查!");
  23360. // result = flag == "0" ? true : false;
  23361. // }
  23362. // }
  23363. // catch (Exception ex)
  23364. // {
  23365. // throw ex;
  23366. // }
  23367. // return result;
  23368. //}
  23369. /// <summary>
  23370. /// 按条码判定是否为首节点(调整为复用方法)
  23371. /// 从TP_PM_GroutingDailyDetail表中的BEGINNINGFLAG字段判定是否为首节点
  23372. /// "0":非首节点,"1":首节点,"-1":条码无效
  23373. /// </summary>
  23374. /// <param name="oracleTrConn">数据连接</param>
  23375. /// <param name="barCode">条码</param>
  23376. /// <returns>是否首节点</returns>
  23377. /// xuwei add 2019-09-26
  23378. public static int IsNodeBegin<T>(T oracleTrConn, string barCode)
  23379. {
  23380. Type t = typeof(T);
  23381. int result = -1;
  23382. try
  23383. {
  23384. if (barCode != "")
  23385. {
  23386. OracleParameter[] parasNew = new OracleParameter[]{
  23387. new OracleParameter(":barcode",barCode) };
  23388. string flag = t.GetMethod("GetSqlResultToStr")
  23389. .Invoke(oracleTrConn, new object[] { $@"select BEGINNINGFLAG as flag
  23390. from TP_PM_GroutingDailyDetail
  23391. where BARCODE = :barcode", parasNew }).ToString();
  23392. //if (flag == "") throw new Exception("无效条码,请检查!");
  23393. //xuwei fix 2019-09-26 找不到和非首节点均返回0
  23394. // 返修指定首节点时,判断错误
  23395. if (string.IsNullOrWhiteSpace(flag))
  23396. {
  23397. return -1;
  23398. }
  23399. result = (flag == "0" ? 1 : 0);
  23400. }
  23401. }
  23402. catch (Exception ex)
  23403. {
  23404. throw ex;
  23405. }
  23406. return result;
  23407. }
  23408. }
  23409. }