PMModuleLogicDAL.cs 1.3 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829
  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. //xuwei add 2022-05-23 自动识别 成检交接 9 重烧成检交接 15 (挪到AddNormalWorkPiece中 G:628)
  66. //if(procedureID == 9 || procedureID == 15)
  67. //{
  68. // string result = oracleTrConn.GetSqlResultToObj(@"
  69. // SELECT T.ISREFIRE
  70. // FROM TP_PM_INPRODUCTION T
  71. // WHERE T.BARCODE = :BARCODE
  72. // ",
  73. // new OracleParameter[] {
  74. // new OracleParameter(":BARCODE",barcodeTable.Rows[0]["Barcode"].ToString()),
  75. // }
  76. // ).ToString();
  77. // if (result == "6") procedureID = 15; else procedureID = 9;
  78. //}
  79. //xuwei end
  80. DataSet dsReturnSinglePoint = null;
  81. oracleTrConn.Connect();
  82. int goodsID = Constant.INT_IS_ZERO;
  83. string goodsCode = null;
  84. string goodsName = null;
  85. string groutingUserCode = string.Empty;
  86. string logoCode = string.Empty;
  87. string logoName = string.Empty;
  88. string groutingdate = string.Empty;
  89. #region 查询工序信息
  90. ProcedureEntity procedure = GetProcedurByID(oracleTrConn, procedureID);
  91. procedureInfo = procedure;
  92. #endregion
  93. if (barcodeTable.Columns.Contains("IsPDA"))
  94. {
  95. if (procedure.ModelType != (int)Constant.ProcedureModelType.DeliverMud)
  96. {
  97. if (barcodeTable.Columns.Contains("IsPublicBody"))
  98. {
  99. barcodeTable.Columns.Remove("IsPublicBody");
  100. barcodeTable.Columns.Remove("IsPDA");
  101. }
  102. }
  103. }
  104. #region 防止多次重复提交,导致数据重复
  105. // 通过锁定表tp_pm_usedbarcode中的条码,防止多次重复提交,导致数据重复
  106. // TODO PDA还没有修改,暂时注释。PDA(集中采集画面)点击保存时如果不成功提示消息后,清除了当前画面中的数据。应该不清空数据,可以继续保存。
  107. //string barcodes = null;
  108. //foreach (DataRow item in barcodeTable.Rows)
  109. //{
  110. // if (barcodes != null)
  111. // {
  112. // barcodes += ",";
  113. // }
  114. // barcodes += item["Barcode"].ToString();
  115. //}
  116. //if (barcodes != null)
  117. //{
  118. // string sql = "select uc.barcode from tp_pm_usedbarcode uc where uc.barcode in (" + barcodes + ") for update nowait";
  119. // try
  120. // {
  121. // oracleTrConn.GetSqlResultToDt(sql);
  122. // }
  123. // catch (Exception ex)
  124. // {
  125. // // 判断异常类型
  126. // if (ex.Message.IndexOf("ORA-00054") > -1)
  127. // {
  128. // dr[Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = "条码正在被处理中,请稍后再操作。";
  129. // dr[Constant.BarCodeResultTableColumns.out_missFlag.ToString()] = "0";
  130. // dtBarCode.Rows.Add(dr);
  131. // return dtBarCode;
  132. // }
  133. // throw ex;
  134. // }
  135. //}
  136. #endregion
  137. //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的
  138. //xuwei fix 2019-09-26 按原条理判定首节点得到正确的返回结果
  139. // 2019-1016
  140. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  141. {
  142. int nodeBegin = IsNodeBegin<IDBTransaction>(oracleTrConn, barcodeTable.Rows[0]["Barcode"].ToString());
  143. if (nodeBegin == 1)
  144. {
  145. procedure.NodeType = (int)Constant.ProcedureNodeType.Begin;
  146. }
  147. else if (nodeBegin == 0)
  148. {
  149. procedure.NodeType = (int)Constant.ProcedureNodeType.Middle;
  150. }
  151. }
  152. //if (nodeBegin == -1) errMsg = "条码不正确,请检查!";
  153. #region 标准计件和坯库
  154. if (procedure.ModelType == (int)Constant.ProcedureModelType.Normal
  155. || procedure.ModelType == (int)Constant.ProcedureModelType.AdobeStock)
  156. {
  157. if (procedure.CollectType == 1)
  158. {
  159. #region 集中采集
  160. errMsg = AddNormalWorkPiece(oracleTrConn, procedure, barcodeTable, sUserInfo,
  161. out goodsID, out goodsCode, out goodsName, out groutingUserCode);
  162. #endregion
  163. }
  164. else
  165. {
  166. #region 单点采集
  167. int? GroutingDailyDetailID = null;
  168. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  169. {
  170. dsReturnSinglePoint = PMModuleLogic.CheckBarcodeDeliverMudSinglePoint(procedureID, barcodeTable.Rows[0]["barcode"].ToString(), sUserInfo, ref GroutingDailyDetailID);
  171. }
  172. else
  173. {
  174. dsReturnSinglePoint = PMModuleLogic.CheckBarcodeSinglePoint(procedureID, barcodeTable.Rows[0]["barcode"].ToString(), sUserInfo);
  175. }
  176. if (dsReturnSinglePoint != null)
  177. {
  178. if (dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString() == ""
  179. && dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()].ToString() == "0")
  180. {
  181. goodsID = Convert.ToInt32(dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()].ToString());
  182. goodsCode = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()].ToString();
  183. goodsName = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()].ToString();
  184. groutingUserCode = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()].ToString();
  185. barcodeTable.Rows[0]["barcode"] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_barcode.ToString()];
  186. errMsg = AddNormalWorkPieceSinglePoint(oracleTrConn, procedure, barcodeTable, sUserInfo,
  187. goodsID, goodsCode, goodsName, groutingUserCode, null);
  188. }
  189. }
  190. #endregion
  191. }
  192. }
  193. #endregion
  194. #region 交坯
  195. else if (procedure.ModelType == (int)Constant.ProcedureModelType.DeliverMud)
  196. {
  197. if (procedure.CollectType == 1)
  198. {
  199. #region 集中采集
  200. //xuwei fix begin 2019-09-17
  201. //加入最后一个参数 true,识别为交坏
  202. errMsg = AddNormalWorkPiece(oracleTrConn, procedure, barcodeTable, sUserInfo,
  203. out goodsID, out goodsCode, out goodsName, out groutingUserCode, true);
  204. //xuwei end
  205. #endregion
  206. }
  207. else
  208. {
  209. #region 单点采集
  210. int? GroutingDailyDetailID = null;
  211. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  212. {
  213. dsReturnSinglePoint = PMModuleLogic.CheckBarcodeDeliverMudSinglePoint(procedureID, barcodeTable.Rows[0]["barcode"].ToString(), sUserInfo, ref GroutingDailyDetailID);
  214. }
  215. else
  216. {
  217. dsReturnSinglePoint = PMModuleLogic.CheckBarcodeSinglePoint(procedureID, barcodeTable.Rows[0]["barcode"].ToString(), sUserInfo);
  218. }
  219. //dsReturnSinglePoint = PMModuleLogic.CheckBarcodeDeliverMudSinglePoint(procedureID, barcodeTable.Rows[0]["barcode"].ToString(), sUserInfo, ref GroutingDailyDetailID);
  220. if (dsReturnSinglePoint != null)
  221. {
  222. //if (barcodeTable.Rows[0]["UserCode"].ToString() != dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()].ToString())
  223. //{
  224. // dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = "成型工号与交坯工号不一致,不允许交坯";
  225. //}
  226. //else
  227. //{
  228. if (dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString() == ""
  229. && dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()].ToString() == "0")
  230. {
  231. if (procedure.DeliverType == 0) //手动模式
  232. {
  233. if (barcodeTable.Rows[0]["UserCode"].ToString() != dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()].ToString())
  234. {
  235. if (barcodeTable.Rows[0]["IsPublicBody"].ToString() != "1")
  236. {
  237. dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = "成型工号与交坯工号不一致,不允许交坯";
  238. }
  239. else
  240. {
  241. goodsID = Convert.ToInt32(dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()].ToString());
  242. goodsCode = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()].ToString();
  243. goodsName = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()].ToString();
  244. groutingUserCode = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()].ToString();
  245. //xuwei fix begin 2019-09-17
  246. //加入最后一个参数 true,识别为交坏
  247. errMsg = AddNormalWorkPieceSinglePoint(oracleTrConn, procedure, barcodeTable, sUserInfo,
  248. goodsID, goodsCode, goodsName, groutingUserCode, GroutingDailyDetailID, true);
  249. if (!string.IsNullOrEmpty(errMsg))
  250. {
  251. dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = errMsg;
  252. }
  253. // wangx 2016-10-10 是否设置过期未交坯
  254. else
  255. {
  256. // string sqlNew = "select settingvalue from TP_MST_SystemSetting where settingcode='" + Constant.SettingType.S_PM_002.ToString() + "' and accountid=" + sUserInfo.AccountID;
  257. string sqlNew = "select deliverlimitCycle from TP_MST_Goods where goodsid=" + goodsID;
  258. string sqlSettingValue = oracleTrConn.GetSqlResultToStr(sqlNew);
  259. if (sqlSettingValue != "0")
  260. {
  261. ServiceResultEntity resultEntity = PMModuleLogic.BarcodeAllowCancel(
  262. Convert.ToDateTime(dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()]),
  263. Convert.ToInt32(sqlSettingValue), Constant.SettingType.S_PM_002.ToString(), sUserInfo);
  264. if (Convert.ToInt32(resultEntity.Result) < 0)
  265. {
  266. dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = resultEntity.Message;
  267. errMsg = resultEntity.Message;
  268. }
  269. }
  270. // wangx end
  271. }
  272. }
  273. }
  274. else
  275. {
  276. goodsID = Convert.ToInt32(dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()].ToString());
  277. goodsCode = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()].ToString();
  278. goodsName = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()].ToString();
  279. groutingUserCode = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()].ToString();
  280. //xuwei fix begin 2019-09-17
  281. //加入最后一个参数 true,识别为交坏
  282. errMsg = AddNormalWorkPieceSinglePoint(oracleTrConn, procedure, barcodeTable, sUserInfo,
  283. goodsID, goodsCode, goodsName, groutingUserCode, GroutingDailyDetailID, true);
  284. if (!string.IsNullOrEmpty(errMsg))
  285. {
  286. dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = errMsg;
  287. }
  288. // wangx 2016-10-10 是否设置过期未交坯
  289. else
  290. {
  291. // string sqlNew = "select settingvalue from TP_MST_SystemSetting where settingcode='" + Constant.SettingType.S_PM_002.ToString() + "' and accountid=" + sUserInfo.AccountID;
  292. string sqlNew = "select deliverlimitCycle from TP_MST_Goods where goodsid=" + goodsID;
  293. string sqlSettingValue = oracleTrConn.GetSqlResultToStr(sqlNew);
  294. if (sqlSettingValue != "0")
  295. {
  296. ServiceResultEntity resultEntity = PMModuleLogic.BarcodeAllowCancel(
  297. Convert.ToDateTime(dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()]),
  298. Convert.ToInt32(sqlSettingValue), Constant.SettingType.S_PM_002.ToString(), sUserInfo);
  299. if (Convert.ToInt32(resultEntity.Result) < 0)
  300. {
  301. dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = resultEntity.Message;
  302. errMsg = resultEntity.Message;
  303. }
  304. }
  305. // wangx end
  306. }
  307. }
  308. }
  309. else //2016-07-05
  310. {
  311. // 自动模式 .查出型工号,单点采集前台并没有传值,更新barcodeTable表对应的字段
  312. //xuwei fix 2022-05-19 修正交坯节点使用注浆工号
  313. for (int i = 0; i < barcodeTable.Rows.Count; i++)
  314. {
  315. string sql = @"select tp_mst_user.userid,tp_mst_user.usercode,tp_mst_user.username from TP_PM_GroutingDailyDetail
  316. left join tp_mst_user
  317. on TP_PM_GroutingDailyDetail.userid=tp_mst_user.userid
  318. where TP_PM_GroutingDailyDetail.barcode='" + barcodeTable.Rows[i]["barcode"].ToString() + "'";
  319. DataSet ds = oracleTrConn.GetSqlResultToDs(sql);
  320. if (ds != null && ds.Tables[0].Rows.Count > 0)
  321. {
  322. barcodeTable.Rows[i]["UserCode"] = ds.Tables[0].Rows[0]["UserCode"];
  323. barcodeTable.Rows[i]["UserID"] = ds.Tables[0].Rows[0]["UserID"];
  324. barcodeTable.Rows[i]["UserName"] = ds.Tables[0].Rows[0]["UserName"];
  325. }
  326. }
  327. //xuwei fix end
  328. goodsID = Convert.ToInt32(dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()].ToString());
  329. goodsCode = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()].ToString();
  330. goodsName = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()].ToString();
  331. groutingUserCode = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()].ToString();
  332. //xuwei fix begin 2019-09-17
  333. //加入最后一个参数 true,识别为交坏
  334. errMsg = AddNormalWorkPieceSinglePoint(oracleTrConn, procedure, barcodeTable, sUserInfo,
  335. goodsID, goodsCode, goodsName, groutingUserCode, GroutingDailyDetailID, true);
  336. if (!string.IsNullOrEmpty(errMsg))
  337. {
  338. dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = errMsg;
  339. }
  340. // wangx 2016-10-10 是否设置过期未交坯
  341. else
  342. {
  343. // string sqlNew = "select settingvalue from TP_MST_SystemSetting where settingcode='" + Constant.SettingType.S_PM_002.ToString() + "' and accountid=" + sUserInfo.AccountID;
  344. string sqlNew = "select deliverlimitCycle from TP_MST_Goods where goodsid=" + goodsID;
  345. string sqlSettingValue = oracleTrConn.GetSqlResultToStr(sqlNew);
  346. if (sqlSettingValue != "0")
  347. {
  348. ServiceResultEntity resultEntity = PMModuleLogic.BarcodeAllowCancel(
  349. Convert.ToDateTime(dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()]),
  350. Convert.ToInt32(sqlSettingValue), Constant.SettingType.S_PM_002.ToString(), sUserInfo);
  351. if (Convert.ToInt32(resultEntity.Result) < 0)
  352. {
  353. dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = resultEntity.Message;
  354. errMsg = resultEntity.Message;
  355. }
  356. }
  357. // wangx end
  358. }
  359. //
  360. }
  361. //}
  362. }
  363. }
  364. #endregion
  365. }
  366. }
  367. #endregion
  368. #region 装窑车
  369. else if (procedure.ModelType == (int)Constant.ProcedureModelType.LoadCar)
  370. {
  371. errMsg = AddLoadKilnCar(oracleTrConn, procedure, barcodeTable, sUserInfo,
  372. out goodsID, out goodsCode, out goodsName);
  373. }
  374. #endregion
  375. #region 窑车补件
  376. else if (procedure.ModelType == (int)Constant.ProcedureModelType.CarAdd)
  377. {
  378. errMsg = AddKilnCarSupplement(oracleTrConn, procedure, barcodeTable, sUserInfo,
  379. out goodsID, out goodsCode, out goodsName);
  380. }
  381. #endregion
  382. #region 入窑
  383. else if (procedure.ModelType == (int)Constant.ProcedureModelType.IntoKiln)
  384. {
  385. // PDA传入的窑车号。没有传入条码信息 需要转换
  386. /* modify by chenxy 2016-04-05 begin
  387. * 入窑画面显示条码后,登窑画面再做撤销登车,入窑再保存时,撤销的产品也到了入窑工序。
  388. * 入窑时窑车上的产品需要重新获取。
  389. */
  390. //if (barcodeTable.Columns.Contains("IsPDAFlag"))
  391. // modify by chenxy 2016-04-05 end
  392. {
  393. barcodeTable = CarNoInfoConvertToTable(oracleTrConn, barcodeTable, sUserInfo);
  394. }
  395. errMsg = AddIntoKilnCar(oracleTrConn, procedure, barcodeTable, sUserInfo,
  396. out goodsID, out goodsCode, out goodsName);
  397. }
  398. #endregion
  399. #region 出窑
  400. else if (procedure.ModelType == (int)Constant.ProcedureModelType.OutKiln)
  401. {
  402. // PDA传入的窑车号。没有传入条码信息 需要转换
  403. /* modify by chenxy 2016-04-05 begin
  404. * 入窑画面显示条码后,登窑画面再做撤销登车,入窑再保存时,撤销的产品也到了入窑工序。
  405. * 入窑时窑车上的产品需要重新获取。
  406. */
  407. //if (barcodeTable.Columns.Contains("IsPDAFlag"))
  408. // modify by chenxy 2016-04-05 end
  409. {
  410. barcodeTable = CarNoInfoConvertToTable(oracleTrConn, barcodeTable, sUserInfo);
  411. }
  412. errMsg = AddOutKilnCar(oracleTrConn, procedure, barcodeTable, sUserInfo,
  413. out goodsID, out goodsCode, out goodsName);
  414. }
  415. #endregion
  416. #region 卸窑车
  417. else if (procedure.ModelType == (int)Constant.ProcedureModelType.UnloadCar)
  418. {
  419. // PDA传入的窑车号。没有传入条码信息 需要转换
  420. /* modify by chenxy 2016-04-05 begin
  421. * 入窑画面显示条码后,登窑画面再做撤销登车,入窑再保存时,撤销的产品也到了入窑工序。
  422. * 入窑时窑车上的产品需要重新获取。
  423. */
  424. //if (barcodeTable.Columns.Contains("IsPDAFlag"))
  425. // modify by chenxy 2016-04-05 end
  426. {
  427. barcodeTable = CarNoInfoConvertToTable(oracleTrConn, barcodeTable, sUserInfo);
  428. }
  429. errMsg = AddUnloadingKilnCar(oracleTrConn, procedure, barcodeTable, sUserInfo,
  430. out goodsID, out goodsCode, out goodsName);
  431. }
  432. #endregion
  433. #region 干补
  434. else if (procedure.ModelType == (int)Constant.ProcedureModelType.SpecialRepair)
  435. {
  436. errMsg = AddDryRepairWorkPiece(oracleTrConn, procedure, barcodeTable, sUserInfo,
  437. out goodsID, out goodsCode, out goodsName, out groutingUserCode, out logoCode, out logoName, out groutingdate);
  438. }
  439. #endregion
  440. #region 回收
  441. else if (procedure.ModelType == (int)Constant.ProcedureModelType.Recovery)
  442. {
  443. errMsg = AddRecydingFlagWorkPiece(oracleTrConn, procedure, barcodeTable, sUserInfo,
  444. out goodsID, out goodsCode, out goodsName, out groutingUserCode, out logoCode, out logoName, out groutingdate);
  445. }
  446. #endregion
  447. #region 构造返回的DataTable
  448. if ((procedure.ModelType == (int)Constant.ProcedureModelType.DeliverMud
  449. || procedure.ModelType == (int)Constant.ProcedureModelType.Normal) && procedure.CollectType == 2)
  450. {
  451. dr[Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()];
  452. dr[Constant.BarCodeResultTableColumns.out_goodsID.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()];
  453. dr[Constant.BarCodeResultTableColumns.out_goodsCode.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()];
  454. dr[Constant.BarCodeResultTableColumns.out_goodsName.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()];
  455. dr[Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()];
  456. dr[Constant.BarCodeResultTableColumns.out_missFlag.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()];
  457. //新添加的
  458. dr[Constant.BarCodeResultTableColumns.out_groutingNum.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingNum.ToString()];
  459. dr[Constant.BarCodeResultTableColumns.out_mouldCode.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_mouldCode.ToString()];
  460. dr[Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()];
  461. dr[Constant.BarCodeResultTableColumns.out_ispublicbodyTrach.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_ispublicbodyTrach.ToString()];
  462. dr[Constant.BarCodeResultTableColumns.out_groutingdate.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()];
  463. dr[Constant.BarCodeResultTableColumns.out_specialRepairFlag.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_specialRepairFlag.ToString()];
  464. dr[Constant.BarCodeResultTableColumns.out_isReFire.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_isReFire.ToString()];
  465. dr[Constant.BarCodeResultTableColumns.out_logoID.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoID.ToString()];
  466. dr[Constant.BarCodeResultTableColumns.out_logoCode.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoCode.ToString()];
  467. dr[Constant.BarCodeResultTableColumns.out_logoName.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoName.ToString()];
  468. dr[Constant.BarCodeResultTableColumns.out_barcode.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_barcode.ToString()];
  469. dr[Constant.BarCodeResultTableColumns.out_WaterLabelCode.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_WaterLabelCode.ToString()];
  470. dr[Constant.BarCodeResultTableColumns.out_CodeCheckFlag.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_CodeCheckFlag.ToString()];
  471. }
  472. else
  473. {
  474. dr[Constant.BarCodeResultTableColumns.out_errMsg.ToString()] = (errMsg == null ? "" : errMsg);
  475. dr[Constant.BarCodeResultTableColumns.out_goodsID.ToString()] = goodsID;
  476. dr[Constant.BarCodeResultTableColumns.out_goodsCode.ToString()] = goodsCode;
  477. dr[Constant.BarCodeResultTableColumns.out_goodsName.ToString()] = goodsName;
  478. dr[Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()] = groutingUserCode;
  479. dr[Constant.BarCodeResultTableColumns.out_logoCode.ToString()] = logoCode;
  480. dr[Constant.BarCodeResultTableColumns.out_logoName.ToString()] = logoName;
  481. dr[Constant.BarCodeResultTableColumns.out_groutingdate.ToString()] = groutingdate;
  482. //dr[Constant.BarCodeResultTableColumns.out_groutingNum.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingNum.ToString()];
  483. //dr[Constant.BarCodeResultTableColumns.out_mouldCode.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_mouldCode.ToString()];
  484. //dr[Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()];
  485. //dr[Constant.BarCodeResultTableColumns.out_ispublicbodyTrach.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_ispublicbodyTrach.ToString()];
  486. //dr[Constant.BarCodeResultTableColumns.out_groutingdate.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()];
  487. //dr[Constant.BarCodeResultTableColumns.out_specialRepairFlag.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_specialRepairFlag.ToString()];
  488. //dr[Constant.BarCodeResultTableColumns.out_isReFire.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_isReFire.ToString()];
  489. //dr[Constant.BarCodeResultTableColumns.out_logoID.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoID.ToString()];
  490. //dr[Constant.BarCodeResultTableColumns.out_logoCode.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoCode.ToString()];
  491. //dr[Constant.BarCodeResultTableColumns.out_logoName.ToString()] = dsReturnSinglePoint.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoName.ToString()];
  492. }
  493. dtBarCode.Rows.Add(dr);
  494. #endregion
  495. // 没有错误 提交事务
  496. if (string.IsNullOrEmpty(errMsg))
  497. {
  498. oracleTrConn.Commit();
  499. }
  500. }
  501. catch (Exception ex)
  502. {
  503. oracleTrConn.Rollback();
  504. throw ex;
  505. }
  506. finally
  507. {
  508. // 释放资源
  509. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  510. {
  511. oracleTrConn.Disconnect();
  512. }
  513. }
  514. return dtBarCode;
  515. }
  516. #region 是否公坯
  517. /// <summary>
  518. /// 是否公坯
  519. /// </summary>
  520. /// <param name="barcode">产品条码</param>
  521. /// <returns>int</returns>
  522. public static int IsPubilcByBarCode(IDBTransaction oracleTrConn, string barcode)
  523. {
  524. int isPubilcBody = 0;
  525. try
  526. {
  527. string sqlString = @"
  528. select
  529. ispublicbody
  530. from tp_pm_inproduction where barcode=:barcode
  531. union
  532. select
  533. ispublicbody
  534. from TP_PM_InProductionTrash where barcode=:barcode
  535. ";
  536. OracleParameter[] paras = new OracleParameter[]{
  537. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  538. };
  539. DataSet ds = oracleTrConn.GetSqlResultToDs(sqlString, paras);
  540. if (ds != null && ds.Tables[0].Rows.Count > 0)
  541. {
  542. isPubilcBody = Convert.ToInt32(ds.Tables[0].Rows[0]["ispublicbody"]);
  543. }
  544. return isPubilcBody;
  545. }
  546. catch (Exception ex)
  547. {
  548. throw ex;
  549. }
  550. }
  551. #endregion
  552. /// <summary>
  553. /// 标准计件
  554. /// </summary>
  555. /// <param name="oracleTrConn">数据连接对象</param>
  556. /// <param name="procedure">工序对象</param>
  557. /// <param name="barcodeTable">条码信息</param>
  558. /// <param name="sUserInfo">用户基本信息</param>
  559. /// <param name="goodsID">返回的产品ID</param>
  560. /// <param name="goodsCode">返回的产品Code</param>
  561. /// <param name="goodsName">返回的产品名称</param>
  562. /// <param name="groutingUserID">返回的注浆者ID</param>
  563. /// <returns>string</returns>
  564. /// <remarks>
  565. /// 陈冰 2014.09.18 新建
  566. /// </remarks>
  567. private static string AddNormalWorkPiece(IDBTransaction oracleTrConn,
  568. ProcedureEntity procedure,
  569. DataTable barcodeTable,
  570. SUserInfo sUserInfo,
  571. out int goodsID,
  572. out string goodsCode,
  573. out string goodsName,
  574. out string groutingUserCode,
  575. bool isSendBody = false
  576. )
  577. {
  578. try
  579. {
  580. goodsID = Constant.INT_IS_ZERO;
  581. goodsCode = null;
  582. goodsName = null;
  583. groutingUserCode = string.Empty; //Constant.INT_IS_ZERO;
  584. // 获得账务日期
  585. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  586. string errMsg = string.Empty;
  587. // 本批采集的批次号
  588. string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  589. string finishedloadbatchno = DateTime.Now.ToString("yyMMddHHmmss-") + centralizedBatchNo;
  590. // 条码信息
  591. foreach (DataRow barcodeRow in barcodeTable.Rows)
  592. {
  593. // 条码
  594. string barcode = barcodeRow["Barcode"].ToString();
  595. if (string.IsNullOrEmpty(barcode))
  596. {
  597. throw new Exception("传入的条码号为空");
  598. }
  599. //fubin add 2022-05-27 自动识别 成检交接 9 重烧成检交接 15
  600. //本烧和重烧可能一起走成检交接节点,需要挨个识别
  601. int tempProcedureID = procedure.ProcedureID;
  602. if (tempProcedureID == 9 || tempProcedureID == 15)
  603. {
  604. string result = oracleTrConn.GetSqlResultToObj(@"
  605. SELECT T.ISREFIRE
  606. FROM TP_PM_INPRODUCTION T
  607. WHERE T.BARCODE = :BARCODE ",
  608. new OracleParameter[] {
  609. new OracleParameter(":BARCODE", barcode),
  610. }).ToString();
  611. if (result == "6") tempProcedureID = 15; else tempProcedureID = 9;
  612. }
  613. // 如果目标工序变了,替换掉目标工序
  614. if (tempProcedureID != procedure.ProcedureID)
  615. {
  616. procedure = GetProcedurByID(oracleTrConn, tempProcedureID);
  617. }
  618. //fubin end
  619. // 生产工号
  620. int workUserID = Convert.ToInt32(barcodeRow["UserID"]);
  621. // 生产工号
  622. string workUserCode = barcodeRow["UserCode"].ToString();
  623. int? GroutingDailyDetailID = null;//注浆明细ID
  624. if (procedure.CollectType == 1)
  625. {
  626. #region 集中采集 校验条码
  627. // ccc todo
  628. //if (procedure.ModelType == (int)Constant.ProcedureModelType.DeliverMud)//是交坯节点,并且不是公坯的
  629. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  630. {
  631. #region 校验条码有效性
  632. errMsg = CheckBarcodeDeliverMud(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo, ref GroutingDailyDetailID);
  633. if (!string.IsNullOrEmpty(errMsg))
  634. {
  635. return errMsg;
  636. }
  637. #endregion
  638. }
  639. else
  640. {
  641. #region 校验条码有效性
  642. errMsg = CheckBarcode(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo);
  643. if (!string.IsNullOrEmpty(errMsg))
  644. {
  645. return errMsg;
  646. }
  647. #endregion
  648. }
  649. #endregion
  650. }
  651. else
  652. {
  653. #region 单点采集 获取注浆日报明细
  654. string sqlGroutingInfo = "";
  655. sqlGroutingInfo = @"select tp_pm_groutingdailydetail.goodsid,
  656. tp_pm_groutingdailydetail.goodscode,
  657. tp_pm_groutingdailydetail.goodsname,
  658. tp_pm_groutingdailydetail.usercode as groutingUserCode,
  659. tp_pm_groutingdailydetail.GroutingDailyDetailID
  660. from tp_pm_groutingdailydetail where barcode = :barcode";
  661. // from tp_pm_groutingdailydetail where groutingdailydetailid in
  662. //(select groutingdailydetailid from TP_PM_USEDBARCODE where barcode=:barcode)";
  663. OracleParameter[] ReFireparas = new OracleParameter[] {
  664. new OracleParameter(":barcode",barcode),
  665. };
  666. DataSet dsGrouting = oracleTrConn.GetSqlResultToDs(sqlGroutingInfo, ReFireparas);
  667. if (dsGrouting != null && dsGrouting.Tables[0].Rows.Count > 0)
  668. {
  669. GroutingDailyDetailID = Convert.ToInt32(dsGrouting.Tables[0].Rows[0]["GroutingDailyDetailID"]);
  670. goodsID = Convert.ToInt32(dsGrouting.Tables[0].Rows[0]["goodsid"]);
  671. goodsCode = dsGrouting.Tables[0].Rows[0]["goodscode"].ToString();
  672. goodsName = dsGrouting.Tables[0].Rows[0]["goodsName"].ToString();
  673. groutingUserCode = dsGrouting.Tables[0].Rows[0]["groutingUserCode"].ToString();
  674. }
  675. #endregion
  676. }
  677. int? ClassesSettingID = null;//班次配置ID
  678. #region 添加生产者数据
  679. //生产数据ID
  680. string sql = "select SEQ_PM_ProductionData_ID.nextval from dual";
  681. int productionDataID = Convert.ToInt32(oracleTrConn.GetSqlResultToStr(sql));
  682. if (procedure.ModelType == (int)Constant.ProcedureModelType.DeliverMud)//是交坯节点,并且不是公坯的
  683. {
  684. string GroutingUserCode = barcodeRow["GroutingUserCode"].ToString();
  685. if (GroutingUserCode.ToLower() == workUserCode.ToLower())
  686. {
  687. //errMsg = AddProducerDeliverAdobe(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo);
  688. }
  689. else
  690. {
  691. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID);
  692. }
  693. }
  694. else
  695. {
  696. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID);
  697. }
  698. if (!string.IsNullOrEmpty(errMsg))
  699. {
  700. return errMsg;
  701. }
  702. #endregion
  703. //xuwei fix 2019-09-23 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的
  704. //xuwei fix 2019-09-26 使用通用方法判定
  705. //if (IsNodeBegin<IDBTransaction>(oracleTrConn, barcode) == 1)
  706. // procedure.NodeType = (int)Constant.ProcedureNodeType.Begin;
  707. #region 添加生产数据
  708. ProductionDataEntity productionData = new ProductionDataEntity();
  709. #region 属性赋值
  710. productionData.GroutingDailyDetailID = GroutingDailyDetailID;//只有交坯的时候用到
  711. productionData.ClassesSettingID = ClassesSettingID;
  712. productionData.ProductionDataID = productionDataID;
  713. productionData.Barcode = barcode;
  714. productionData.CentralizedBatchNo = centralizedBatchNo;
  715. productionData.ProductionLineID = procedure.ProductionLineID;
  716. productionData.ProductionLineCode = procedure.ProductionlineCode;
  717. productionData.ProductionLineName = procedure.ProductionlineName;
  718. productionData.CompleteProcedureID = procedure.ProcedureID;
  719. productionData.ProcedureCode = procedure.ProcedureCode;
  720. productionData.ProcedureName = procedure.ProcedureName;
  721. productionData.ProcedureModel = procedure.ProcedureModel;
  722. productionData.ModelType = procedure.ModelType;
  723. productionData.NodeType = procedure.NodeType;
  724. productionData.PieceType = procedure.PieceType;
  725. if (barcodeRow["LogoID"].ToString() != "")
  726. {
  727. productionData.LogoID = Convert.ToInt32(barcodeRow["LogoID"]);
  728. }
  729. if (procedure.IsSpecialRework == 0)
  730. {
  731. productionData.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  732. //不加条件valueflag,是因为,成检后重烧走过之后,在次重烧,以后也是重烧状态
  733. //string sqlReFire = "select * from tp_PM_ProductionData where ProductionDataid=(select max(ProductionDataid) from tp_PM_ProductionData where barcode='" + productionData.Barcode + "')";
  734. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)//是交坯节点,肯定不会是重烧
  735. {
  736. productionData.IsReFire = (int)Constant.ReFireFlag.No;
  737. productionData.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  738. }
  739. ////// else
  740. ////// {
  741. ////// string sqlReFire = @"select
  742. ////// isrefire
  743. ////// from tp_pm_inproduction where barcode=:barcode
  744. ////// ";
  745. ////// OracleParameter[] ReFireparas = new OracleParameter[] {
  746. ////// new OracleParameter(":barcode",barcode),
  747. ////// };
  748. ////// DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas);
  749. ////// if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0)
  750. ////// {
  751. ////// if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0)
  752. ////// {
  753. ////// productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]);
  754. ////// //if (productionData.IsReFire == 6) wangxin modify 20150422 因为已经大于0,定是重烧,即有缺陷
  755. ////// //{
  756. ////// productionData.DefectFlag = (int)Constant.GoodsLevelType.Defect;
  757. ////// //}
  758. ////// }
  759. ////// }
  760. ////// }
  761. }
  762. else
  763. {
  764. productionData.IsReFire = (int)Constant.GoodsLevelType.ReFire;
  765. productionData.DefectFlag = (int)Constant.GoodsLevelType.Defect;
  766. }
  767. productionData.ReworkProcedureID = null;
  768. #region 交坯判断
  769. // 交坯节点
  770. if (barcodeTable.Columns.Contains("IsPublicBody"))
  771. {
  772. productionData.IsPublicBody = Convert.ToInt32(barcodeRow["IsPublicBody"]);
  773. }
  774. // 非交坯节点
  775. else
  776. {
  777. // 正常坯
  778. productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, barcode);
  779. }
  780. #endregion
  781. productionData.OrganizationID = procedure.OrganizationID;
  782. productionData.GoodsID = goodsID;
  783. productionData.GoodsCode = goodsCode;
  784. productionData.GoodsName = goodsName;
  785. productionData.UserID = workUserID;
  786. productionData.UserCode = barcodeRow["UserCode"].ToString();
  787. productionData.UserName = barcodeRow["UserName"].ToString();
  788. #endregion
  789. string OutSpecialRepairflag = "0";//干补标识
  790. DataSet outDataSet = null;
  791. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  792. {
  793. //添加首节点数据 (在产生产数据)
  794. //xuwei fix 2019-09-17 添加最后一个可选参数isSendBody识别交坯
  795. errMsg = AddProductionDataDeliverMud(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag, out outDataSet, isSendBody);
  796. }
  797. else
  798. {
  799. //添加非首节点数据
  800. //xuwei fix 2019-09-17 添加最后一个可选参数isSendBody识别交坯
  801. errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag, isSendBody);
  802. }
  803. if (!string.IsNullOrEmpty(errMsg))
  804. {
  805. return errMsg;
  806. }
  807. #endregion
  808. #region 开始节点
  809. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  810. {
  811. #region 添加在产产品数据
  812. InProductionEntity addInProductionEntity = new InProductionEntity();
  813. addInProductionEntity.BarCode = barcode;
  814. //流程工序ID
  815. addInProductionEntity.FlowProcedureID = procedure.ProcedureID;
  816. // 当前工序
  817. addInProductionEntity.ProcedureID = procedure.ProcedureID;
  818. //addInProductionEntity.CompleteProcedureID = procedure.ProcedureID;
  819. // 工序模型
  820. addInProductionEntity.ProcedureModel = procedure.ProcedureModel;
  821. // 工序类别
  822. addInProductionEntity.ModelType = procedure.ModelType;
  823. addInProductionEntity.SpecialRepairflag = Convert.ToInt32(OutSpecialRepairflag);//干补标识
  824. addInProductionEntity.ProductionDataID = productionDataID;
  825. #region 交坯判断
  826. addInProductionEntity.IsPublicBody = productionData.IsPublicBody;// 生产数据已经判断是否为公坯
  827. #endregion
  828. // 生产工号
  829. addInProductionEntity.UserID = workUserID;
  830. // 执行添加
  831. //xuwei fix 2019-09-17 添加最后一个可选参数isSendBody识别交坯
  832. errMsg = AddInProduction(oracleTrConn, addInProductionEntity, sUserInfo, outDataSet, isSendBody);
  833. // 执行失败
  834. if (!string.IsNullOrEmpty(errMsg))
  835. {
  836. return errMsg;
  837. }
  838. #endregion
  839. }
  840. #endregion
  841. #region 中间节点
  842. else if (procedure.NodeType == (int)Constant.ProcedureNodeType.Middle)
  843. {
  844. #region 修改在产产品数据的当前工序,清空返工工序字段
  845. InProductionEntity addInProductionEntity = new InProductionEntity();
  846. addInProductionEntity.BarCode = barcode;
  847. //流程工序ID
  848. addInProductionEntity.FlowProcedureID = procedure.ProcedureID;
  849. // 当前工序
  850. addInProductionEntity.ProcedureID = procedure.ProcedureID;
  851. //当前生产数据ID
  852. addInProductionEntity.ProductionDataID = productionDataID;
  853. // 工序模型
  854. addInProductionEntity.ProcedureModel = procedure.ProcedureModel;
  855. // 工序类别
  856. addInProductionEntity.ModelType = procedure.ModelType;
  857. // 生产工号
  858. addInProductionEntity.UserID = workUserID;
  859. addInProductionEntity.LogoID = productionData.LogoID;
  860. // 缺陷标识
  861. // addInProductionEntity.DefectFlag = (int)Constant.DefectFlag.No;
  862. //addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefect;
  863. if (procedure.IsSpecialRework == 0)
  864. {
  865. addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  866. }
  867. else
  868. {
  869. addInProductionEntity.IsReFire = (int)Constant.GoodsLevelType.ReFire;
  870. addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  871. }
  872. #region 交坯判断
  873. addInProductionEntity.IsPublicBody = productionData.IsPublicBody;// 生产数据已经判断是否为公坯
  874. #endregion
  875. // 执行修改
  876. errMsg = UpdateInProduction(oracleTrConn, addInProductionEntity, sUserInfo);
  877. // 执行失败
  878. if (!string.IsNullOrEmpty(errMsg))
  879. {
  880. return errMsg;
  881. }
  882. #endregion
  883. }
  884. #endregion
  885. #region 结束节点
  886. else
  887. {
  888. #region 添加成品数据 删除在产产品数据
  889. FinishedProductEntity finishedProduct = new FinishedProductEntity();
  890. finishedProduct.BarCode = barcode;
  891. finishedProduct.LogoID = productionData.LogoID;
  892. errMsg = AddFinishedProduct(oracleTrConn, finishedProduct, sUserInfo, finishedloadbatchno);
  893. if (!string.IsNullOrEmpty(errMsg))
  894. {
  895. return errMsg;
  896. }
  897. InProductionEntity delInProductionEntity = new InProductionEntity();
  898. delInProductionEntity.BarCode = barcode;
  899. // 执行删除 在产数据
  900. errMsg = DeleteInProduction(oracleTrConn, delInProductionEntity, true, sUserInfo);
  901. // 执行失败
  902. if (!string.IsNullOrEmpty(errMsg))
  903. {
  904. return errMsg;
  905. }
  906. #endregion
  907. }
  908. #endregion
  909. }
  910. return errMsg;
  911. }
  912. catch (Exception ex)
  913. {
  914. throw ex;
  915. }
  916. }
  917. /// <summary>
  918. /// 添加生产者(交坯单独调用,特殊)
  919. /// </summary>
  920. /// <param name="oracleTrConn">连接对象</param>
  921. /// <param name="accountDate">账务日期</param>
  922. /// <param name="productionDataID">生产数据ID</param>
  923. /// <param name="workUserID">生产工号ID</param>
  924. /// <param name="workUserCode">生产工号Code</param>
  925. /// <param name="sUserInfo">用户基本信息</param>
  926. /// <returns>string</returns>
  927. private static string AddProducerDeliverAdobe(IDBTransaction oracleTrConn, DateTime accountDate, int productionDataID, int workUserID, string workUserCode, SUserInfo sUserInfo)
  928. {
  929. // 参数
  930. OracleParameter[] paras;
  931. #region 将班次配置表中的数据插入生产者表中
  932. string sql = "insert into tp_pm_producer"
  933. + " (productiondataid,"
  934. + " staffid,"
  935. + " userid,"
  936. + " usercode,"
  937. + " UJobsID,"
  938. + " staffstatus,"
  939. + " SJobsID"
  940. + " )"
  941. + " select distinct :productiondataid,"
  942. + " staffid,"
  943. + " userid,"
  944. + " usercode,"
  945. + " UJobsID,"
  946. + " staffstatus,"
  947. + " SJobsID"
  948. + " "
  949. + " from TP_PM_GroutingProducer"
  950. + " where UserID = :userID";
  951. paras = new OracleParameter[] {
  952. new OracleParameter(":productiondataid",OracleDbType.Int32,productionDataID,ParameterDirection.Input),
  953. new OracleParameter(":userID",OracleDbType.Int32,workUserID,ParameterDirection.Input),
  954. };
  955. int resultCount = oracleTrConn.ExecuteNonQuery(sql, paras);
  956. // 失败
  957. if (resultCount == Constant.INT_IS_ZERO)
  958. {
  959. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  960. }
  961. #endregion
  962. return null;
  963. }
  964. /// <summary>
  965. /// 装车后,更新所有以前操作的工序窑车信息
  966. /// </summary>
  967. /// <param name="oracleTrConn">连接对象</param>
  968. /// <param name="barcode">条码</param>
  969. /// <param name="kilnCarID">窑车号</param>
  970. /// <param name="goodsID">产品ID</param>
  971. /// <param name="KilnCarPosition">窑车位置</param>
  972. /// <param name="kilnCarBatchNo">装车批次</param>
  973. /// <param name="sUserInfo">用户基本信息</param>
  974. /// <returns>string</returns>
  975. private static string UpdateRefineBybarcode(IDBTransaction oracleTrConn, ProductionDataEntity productionData)
  976. {
  977. string sql = "update TP_PM_ProductionData set "
  978. + " IsReFire=:IsReFire"
  979. + " where barcode=:barcode";
  980. #region 参数
  981. OracleParameter[] paras = new OracleParameter[] {
  982. new OracleParameter(":IsReFire",(int)Constant.GoodsLevelType.ReFire),
  983. new OracleParameter(":barcode",productionData.Barcode),
  984. };
  985. #endregion
  986. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  987. // 保存失败
  988. if (result == Constant.INT_IS_ZERO)
  989. {
  990. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  991. }
  992. // 保存成功返回null
  993. return null;
  994. }
  995. /// <summary>
  996. /// 装窑车计件
  997. /// </summary>
  998. /// <param name="oracleTrConn">数据连接对象</param>
  999. /// <param name="procedure">工序对象</param>
  1000. /// <param name="barcodeTable">条码信息</param>
  1001. /// <param name="sUserInfo">用户基本信息</param>
  1002. /// <param name="goodsID">返回的产品ID</param>
  1003. /// <param name="goodsCode">返回的产品Code</param>
  1004. /// <param name="goodsName">返回的产品名称</param>
  1005. /// <returns>string</returns>
  1006. /// <remarks>
  1007. /// 陈冰 2014.09.18 新建
  1008. /// </remarks>
  1009. private static string AddLoadKilnCar(IDBTransaction oracleTrConn,
  1010. ProcedureEntity procedure,
  1011. DataTable barcodeTable,
  1012. SUserInfo sUserInfo,
  1013. out int goodsID,
  1014. out string goodsCode,
  1015. out string goodsName)
  1016. {
  1017. try
  1018. {
  1019. goodsID = Constant.INT_IS_ZERO;
  1020. goodsCode = null;
  1021. goodsName = null;
  1022. string groutingUserCode = string.Empty;
  1023. // 获得账务日期
  1024. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  1025. string errMsg = string.Empty;
  1026. // 生产工号
  1027. int workUserID = Constant.INT_IS_ZERO;
  1028. // 生产工号Code
  1029. string workUserCode = string.Empty;
  1030. // 生产工号Name
  1031. string workUserName = string.Empty;
  1032. // 本批采集的批次号
  1033. string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  1034. // 窑车批次号
  1035. string kilnCarBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  1036. // 窑车状态
  1037. string kilnCarStatus = string.Empty;
  1038. //////////////////////////////////////////////////
  1039. DataView dv = barcodeTable.DefaultView;
  1040. DataTable dtNewKiln = dv.ToTable(true, "kilnCarCode");
  1041. for (int i = 0; i < dtNewKiln.Rows.Count; i++)
  1042. {
  1043. DataRow[] dr = barcodeTable.Select("kilnCarCode='" + dtNewKiln.Rows[i]["kilnCarCode"].ToString() + "'");
  1044. // 窑炉ID
  1045. //int kilnID = Convert.ToInt32(barcodeTable.Rows[0]["kilnID"].ToString());
  1046. int kilnID = Convert.ToInt32(dr[0]["kilnID"].ToString());
  1047. // 窑车ID
  1048. //int kilnCarID = Convert.ToInt32(barcodeTable.Rows[0]["KilnCarID"].ToString());
  1049. int kilnCarID = Convert.ToInt32(dr[0]["KilnCarID"].ToString());
  1050. // 窑车Code
  1051. // string kilnCarCode = barcodeTable.Rows[0]["kilnCarCode"].ToString();
  1052. string kilnCarCode = dr[0]["kilnCarCode"].ToString();
  1053. #region 校验窑车是否可装车
  1054. errMsg = CheckKilnCarrStatus(oracleTrConn, procedure.ProcedureID, kilnCarCode, procedure.ModelType, sUserInfo, out kilnCarStatus);
  1055. if (!string.IsNullOrEmpty(errMsg))
  1056. {
  1057. return errMsg;
  1058. }
  1059. #endregion
  1060. #region 如果窑车状态为空,需要插入窑车状态表
  1061. if (string.IsNullOrEmpty(kilnCarStatus))
  1062. {
  1063. // 自动生成窑车烧成批次号
  1064. kilnCarBatchNo = GetFiredKilnCarBatchNo(oracleTrConn, kilnCarID);
  1065. // 插入窑车状态表
  1066. errMsg = AddkilnCarStatus(oracleTrConn, procedure, kilnCarID, kilnID, kilnCarBatchNo, sUserInfo);
  1067. if (!string.IsNullOrEmpty(errMsg))
  1068. {
  1069. return errMsg;
  1070. }
  1071. }
  1072. #endregion
  1073. #region 窑车表存在,查询本次窑车产品的批次号 并更改装窑车时间
  1074. // 查询本次窑车产品的批次号
  1075. else
  1076. {
  1077. kilnCarBatchNo = GetKilnCarBatchNoByKilnCarID(oracleTrConn, kilnCarID);
  1078. // 更改窑车状态表入窑时间
  1079. errMsg = UpdatekilnCarStatus(oracleTrConn, kilnCarID, Constant.ProcedureModelType.LoadCar, sUserInfo, procedure, kilnCarBatchNo);
  1080. if (!string.IsNullOrEmpty(errMsg))
  1081. {
  1082. return errMsg;
  1083. }
  1084. }
  1085. #endregion
  1086. // 条码信息
  1087. DataView dvFilter = barcodeTable.DefaultView;
  1088. dvFilter.RowFilter = "kilnCarCode='" + dtNewKiln.Rows[i]["kilnCarCode"].ToString() + "'";
  1089. DataTable dtNew = dvFilter.ToTable();
  1090. // 条码信息
  1091. //foreach (DataRow barcodeRow in barcodeTable.Rows)
  1092. //--------------------------------
  1093. string sqllast = "select max(createtime) as createtime from TP_PM_KilnCarGoods"
  1094. + " where KilnCarID=:KilnCarID and AccountID=:AccountID";
  1095. OracleParameter[] paras = new OracleParameter[] {
  1096. new OracleParameter(":KilnCarID",kilnCarID),
  1097. new OracleParameter(":AccountID",sUserInfo.AccountID),
  1098. };
  1099. DataSet dsReturn = oracleTrConn.GetSqlResultToDs(sqllast, paras);
  1100. object lastcreatetime = null;
  1101. if (dsReturn != null && dsReturn.Tables[0].Rows.Count > 0 && dsReturn.Tables[0].Rows[0]["CreateTime"].ToString() != "")
  1102. {
  1103. lastcreatetime = Convert.ToDateTime(dsReturn.Tables[0].Rows[0]["CreateTime"]);
  1104. }
  1105. //--------------------------------
  1106. int? maxClassesSettingID = null;
  1107. int j = 0;
  1108. // 查询窑车位置
  1109. string sqlKilnCarPosition = "SELECT DICTIONARYID FROM TP_MST_DataDictionary WHERE DictionaryType = 'TPC003' ORDER BY DICTIONARYID";
  1110. DataTable dtKilnCarPosition = oracleTrConn.GetSqlResultToDt(sqlKilnCarPosition);
  1111. foreach (DataRow barcodeRow in dtNew.Rows)
  1112. {
  1113. // 条码
  1114. string barcode = barcodeRow["Barcode"].ToString();
  1115. // 生产工号
  1116. workUserID = Convert.ToInt32(barcodeRow["UserID"]);
  1117. workUserCode = barcodeRow["UserCode"].ToString();
  1118. workUserName = barcodeRow["UserName"].ToString();
  1119. #region 校验条码有效性
  1120. errMsg = CheckBarcode(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo);
  1121. if (!string.IsNullOrEmpty(errMsg))
  1122. {
  1123. return errMsg;
  1124. }
  1125. #endregion
  1126. // 查询新插入的生产数据ID
  1127. string sql = "select SEQ_PM_ProductionData_ID.nextval from dual";
  1128. string idStr = oracleTrConn.GetSqlResultToStr(sql);
  1129. int productionDataID = 0;
  1130. if (!string.IsNullOrEmpty(idStr))
  1131. {
  1132. productionDataID = int.Parse(idStr);
  1133. }
  1134. else
  1135. {
  1136. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  1137. }
  1138. int? ClassesSettingID = null;//班次配置ID
  1139. #region 添加生产者数据
  1140. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID);
  1141. if (!string.IsNullOrEmpty(errMsg))
  1142. {
  1143. return errMsg;
  1144. }
  1145. #endregion
  1146. maxClassesSettingID = ClassesSettingID;
  1147. #region 添加生产数据
  1148. ProductionDataEntity productionData = new ProductionDataEntity();
  1149. #region 属性赋值
  1150. productionData.ClassesSettingID = ClassesSettingID;
  1151. productionData.ProductionDataID = Convert.ToInt32(idStr);
  1152. productionData.Barcode = barcode;
  1153. productionData.CentralizedBatchNo = centralizedBatchNo;
  1154. productionData.ProductionLineID = procedure.ProductionLineID;
  1155. productionData.ProductionLineCode = procedure.ProductionlineCode;
  1156. productionData.ProductionLineName = procedure.ProductionlineName;
  1157. productionData.CompleteProcedureID = procedure.ProcedureID;
  1158. productionData.ProcedureCode = procedure.ProcedureCode;
  1159. productionData.ProcedureName = procedure.ProcedureName;
  1160. productionData.ProcedureModel = procedure.ProcedureModel;
  1161. productionData.ModelType = procedure.ModelType;
  1162. productionData.NodeType = procedure.NodeType;
  1163. productionData.ReworkProcedureID = null;
  1164. productionData.PieceType = procedure.PieceType;
  1165. //productionData.IsPublicBody = (int)Constant.PublicBodyFlag.No;
  1166. if (procedure.IsSpecialRework == 0)
  1167. {
  1168. productionData.IsReFire = (int)Constant.ReFireFlag.No;
  1169. productionData.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  1170. }
  1171. else
  1172. {
  1173. productionData.IsReFire = (int)Constant.GoodsLevelType.ReFire;
  1174. productionData.DefectFlag = (int)Constant.GoodsLevelType.Defect;
  1175. }
  1176. //productionData.GoodsGrade = (int)Constant.GoodsLevelType.NoDefects;
  1177. //if (lastcreatetime != null)
  1178. //{
  1179. // productionData.CreateTime = Convert.ToDateTime(lastcreatetime);
  1180. //}
  1181. //不加条件valueflag,是因为,成检后重烧走过之后,在次重烧,以后也是重烧状态
  1182. ////string sqlReFire = "select * from tp_PM_ProductionData where ProductionDataid=(select max(ProductionDataid) from tp_PM_ProductionData where barcode='" + productionData.Barcode + "')";
  1183. ////DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire);
  1184. ////if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0)
  1185. ////{
  1186. //// if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0)
  1187. //// {
  1188. //// productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]);
  1189. //// }
  1190. ////}
  1191. productionData.OrganizationID = procedure.OrganizationID;
  1192. productionData.GoodsID = goodsID;
  1193. productionData.GoodsCode = goodsCode;
  1194. productionData.GoodsName = goodsName;
  1195. productionData.UserID = workUserID;
  1196. productionData.UserCode = barcodeRow["UserCode"].ToString();
  1197. productionData.UserName = barcodeRow["UserName"].ToString();
  1198. productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, barcode);
  1199. #region 窑炉窑车属性
  1200. productionData.KilnID = Convert.ToInt32(barcodeRow["KilnID"].ToString());
  1201. productionData.KilnCode = barcodeRow["KilnCode"].ToString();
  1202. productionData.KilnName = barcodeRow["KilnName"].ToString();
  1203. productionData.KilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString());
  1204. productionData.KilnCarCode = barcodeRow["KilnCarCode"].ToString();
  1205. productionData.KilnCarName = barcodeRow["KilnCarName"].ToString();
  1206. productionData.KilnCarBatchNo = kilnCarBatchNo;
  1207. productionData.KilnCarPosition = Convert.ToInt32(dtKilnCarPosition.Rows[j]["DICTIONARYID"]);
  1208. #endregion
  1209. j++;
  1210. #endregion
  1211. string OutSpecialRepairflag = "0";//干补标识
  1212. //if (lastcreatetime == null)
  1213. //{
  1214. errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag);
  1215. //}
  1216. //else
  1217. //{
  1218. // errMsg = AddProductionDataCreateTime(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag);
  1219. //}
  1220. if (!string.IsNullOrEmpty(errMsg))
  1221. {
  1222. return errMsg;
  1223. }
  1224. #endregion
  1225. #region 修改在产产品数据的当前工序,清空返工工序字段
  1226. InProductionEntity addInProductionEntity = new InProductionEntity();
  1227. addInProductionEntity.BarCode = barcode;
  1228. //流程工序
  1229. addInProductionEntity.FlowProcedureID = procedure.ProcedureID;
  1230. // 当前工序
  1231. //addInProductionEntity.CompleteProcedureID = procedure.ProcedureID;
  1232. addInProductionEntity.ProcedureID = procedure.ProcedureID;
  1233. //生产数据ID
  1234. addInProductionEntity.ProductionDataID = productionDataID;
  1235. // 工序模型
  1236. addInProductionEntity.ProcedureModel = procedure.ProcedureModel;
  1237. // 工序类别
  1238. addInProductionEntity.ModelType = procedure.ModelType;
  1239. // 生产工号
  1240. addInProductionEntity.UserID = workUserID;
  1241. // 缺陷标识
  1242. //addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  1243. #region 更新在产表窑车窑炉字段
  1244. addInProductionEntity.KilnID = Convert.ToInt32(barcodeRow["KilnID"].ToString());
  1245. addInProductionEntity.KilnCode = barcodeRow["KilnCode"].ToString();
  1246. addInProductionEntity.KilnName = barcodeRow["KilnName"].ToString();
  1247. addInProductionEntity.KilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString());
  1248. addInProductionEntity.KilnCarCode = barcodeRow["KilnCarCode"].ToString();
  1249. addInProductionEntity.KilnCarName = barcodeRow["KilnCarName"].ToString();
  1250. addInProductionEntity.KilnCarBatchNo = kilnCarBatchNo;
  1251. addInProductionEntity.KilnCarPosition = Convert.ToInt32(barcodeRow["KilnCarPosition"].ToString());
  1252. #endregion
  1253. if (procedure.IsSpecialRework == 0)
  1254. {
  1255. addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  1256. }
  1257. else
  1258. {
  1259. addInProductionEntity.IsReFire = (int)Constant.GoodsLevelType.ReFire;
  1260. addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  1261. }
  1262. // 执行修改
  1263. errMsg = UpdateInProduction(oracleTrConn, addInProductionEntity, sUserInfo);
  1264. // 执行失败
  1265. if (!string.IsNullOrEmpty(errMsg))
  1266. {
  1267. return errMsg;
  1268. }
  1269. #endregion
  1270. //#region 添加生产者数据
  1271. //errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo);
  1272. //if (!string.IsNullOrEmpty(errMsg))
  1273. //{
  1274. // return errMsg;
  1275. //}
  1276. //#endregion
  1277. //errMsg = UpdateKilnCarCreatetimeInfoBybarcode(oracleTrConn, productionData, sUserInfo);
  1278. //if (!string.IsNullOrEmpty(errMsg))
  1279. //{
  1280. // return errMsg;
  1281. //}
  1282. #region 插入窑车产品表
  1283. errMsg = AddKilnCarGoods(oracleTrConn,
  1284. barcode,
  1285. kilnCarID,
  1286. goodsID,
  1287. productionData.KilnCarPosition.Value,
  1288. kilnCarBatchNo,
  1289. workUserID,
  1290. workUserCode,
  1291. workUserName,
  1292. sUserInfo);
  1293. if (!string.IsNullOrEmpty(errMsg))
  1294. {
  1295. return errMsg;
  1296. }
  1297. #endregion
  1298. //#region 装车后,更新所有以前操作的工序窑车信息
  1299. //errMsg = UpdateKilnCarInfoBybarcode(oracleTrConn, productionData);
  1300. //if (!string.IsNullOrEmpty(errMsg))
  1301. //{
  1302. // return errMsg;
  1303. //}
  1304. //#endregion
  1305. }
  1306. #region 窑车生产数据
  1307. #region 插入窑车生产数据表
  1308. if (lastcreatetime == null) //加此判断为的是,在登车时落产品,进行第二些登车时,不插重复数据
  1309. {
  1310. errMsg = AddKilnCarData(oracleTrConn,
  1311. accountDate,
  1312. kilnCarID,
  1313. kilnCarBatchNo,
  1314. workUserID,
  1315. workUserCode,
  1316. workUserName,
  1317. null,
  1318. sUserInfo, maxClassesSettingID);
  1319. #region 窑车生产者
  1320. if (!string.IsNullOrEmpty(errMsg))
  1321. {
  1322. return errMsg;
  1323. }
  1324. #endregion
  1325. }
  1326. #endregion
  1327. #endregion
  1328. }
  1329. return errMsg;
  1330. }
  1331. catch (Exception ex)
  1332. {
  1333. throw ex;
  1334. }
  1335. }
  1336. /// <summary>
  1337. /// 装车后,更新所有以前操作的工序窑车信息
  1338. /// </summary>
  1339. /// <param name="oracleTrConn">连接对象</param>
  1340. /// <param name="barcode">条码</param>
  1341. /// <param name="kilnCarID">窑车号</param>
  1342. /// <param name="goodsID">产品ID</param>
  1343. /// <param name="KilnCarPosition">窑车位置</param>
  1344. /// <param name="kilnCarBatchNo">装车批次</param>
  1345. /// <param name="sUserInfo">用户基本信息</param>
  1346. /// <returns>string</returns>
  1347. private static string UpdateKilnCarInfoBybarcode(IDBTransaction oracleTrConn, ProductionDataEntity productionData)
  1348. {
  1349. string sql = "update TP_PM_ProductionData set "
  1350. + " KilnID=:KilnID,"
  1351. + "KilnCode=:KilnCode,"
  1352. + "KilnName=:KilnName,"
  1353. + "KilnCarID=:KilnCarID,"
  1354. + "KilnCarCode=:KilnCarCode,"
  1355. + "KilnCarName=:KilnCarName,"
  1356. + "KilnCarBatchNo=:KilnCarBatchNo,"
  1357. + "KilnCarPosition=:KilnCarPosition,"
  1358. + "isrefire=:isrefire "
  1359. + " where barcode=:barcode";
  1360. #region 参数
  1361. OracleParameter[] paras = new OracleParameter[] {
  1362. new OracleParameter(":KilnID",productionData.KilnID),
  1363. new OracleParameter(":KilnCode",productionData.KilnCode),
  1364. new OracleParameter(":KilnName",productionData.KilnName),
  1365. new OracleParameter(":KilnCarID",productionData.KilnCarID),
  1366. new OracleParameter(":KilnCarCode",productionData.KilnCarCode),
  1367. new OracleParameter(":KilnCarName",productionData.KilnCarName),
  1368. new OracleParameter(":KilnCarBatchNo",productionData.KilnCarBatchNo),
  1369. new OracleParameter(":KilnCarPosition",productionData.KilnCarPosition),
  1370. new OracleParameter(":isrefire",productionData.IsReFire),
  1371. new OracleParameter(":barcode",productionData.Barcode),
  1372. };
  1373. #endregion
  1374. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  1375. // 保存失败
  1376. if (result == Constant.INT_IS_ZERO)
  1377. {
  1378. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  1379. }
  1380. // 保存成功返回null
  1381. return null;
  1382. }
  1383. /// <summary>
  1384. /// 入窑车计件
  1385. /// </summary>
  1386. /// <param name="oracleTrConn">数据连接对象</param>
  1387. /// <param name="procedure">工序对象</param>
  1388. /// <param name="barcodeTable">条码信息</param>
  1389. /// <param name="sUserInfo">基本</param>
  1390. /// <param name="goodsID">返回的产品ID</param>
  1391. /// <param name="goodsCode">返回的产品Code</param>
  1392. /// <param name="goodsName">返回的产品名称</param>
  1393. /// <returns>string</returns>
  1394. /// <remarks>
  1395. /// 张国印 2014.10.04 新建
  1396. /// </remarks>
  1397. private static string AddIntoKilnCar(IDBTransaction oracleTrConn, ProcedureEntity procedure, DataTable barcodeTable, SUserInfo sUserInfo,
  1398. out int goodsID, out string goodsCode, out string goodsName)
  1399. {
  1400. try
  1401. {
  1402. goodsID = Constant.INT_IS_ZERO;
  1403. goodsCode = string.Empty;
  1404. goodsName = string.Empty;
  1405. string groutingUserCode = string.Empty;
  1406. // 获得账务日期
  1407. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  1408. string errMsg = string.Empty;
  1409. // 生产工号
  1410. int workUserID = Constant.INT_IS_ZERO;
  1411. // 生产工号Code
  1412. string workUserCode = string.Empty;
  1413. // 生产工号Name
  1414. string workUserName = string.Empty;
  1415. // 本批采集的批次号
  1416. string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  1417. // 窑车批次号
  1418. string kilnCarBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  1419. // 窑车状态
  1420. string kilnCarStatus = string.Empty;
  1421. //////////////////////////////////////////////////
  1422. DataView dv = barcodeTable.DefaultView;
  1423. DataTable dtNewKiln = dv.ToTable(true, "kilnCarCode");
  1424. for (int i = 0; i < dtNewKiln.Rows.Count; i++)
  1425. {
  1426. ///////////////////////////////////////////////////
  1427. // 窑车Code
  1428. //string kilnCarCode = barcodeTable.Rows[0]["kilnCarCode"].ToString();
  1429. DataRow[] dr = barcodeTable.Select("kilnCarCode='" + dtNewKiln.Rows[i]["kilnCarCode"].ToString() + "'");
  1430. string kilnCarCode = dr[0]["kilnCarCode"].ToString();
  1431. #region 校验窑车是否可入窑炉
  1432. errMsg = CheckKilnCarrStatus(oracleTrConn, procedure.ProcedureID, kilnCarCode, procedure.ModelType, sUserInfo, out kilnCarStatus);
  1433. if (!string.IsNullOrEmpty(errMsg))
  1434. {
  1435. return errMsg;
  1436. }
  1437. #endregion
  1438. // 窑炉ID
  1439. //int kilnID = Convert.ToInt32(barcodeTable.Rows[0]["kilnID"].ToString());
  1440. int kilnID = Convert.ToInt32(dr[0]["kilnID"].ToString());
  1441. // 窑车ID
  1442. //int kilnCarID = Convert.ToInt32(barcodeTable.Rows[0]["KilnCarID"].ToString());
  1443. int kilnCarID = Convert.ToInt32(dr[0]["KilnCarID"].ToString());
  1444. //备注信息
  1445. string Remarks = dr[0]["Remarks"].ToString();
  1446. // 主要目的防止输入窑车号,当前工序与该操作的工序不匹配,例如重烧入窑,在入窑工序上操作了
  1447. errMsg = GetKilnCarProcedureIDByKilnCarID(oracleTrConn, kilnCarID, Convert.ToInt32(procedure.ProcedureID));
  1448. if (!string.IsNullOrEmpty(errMsg))
  1449. {
  1450. return errMsg;
  1451. }
  1452. // 查询本次窑车产品的批次号
  1453. kilnCarBatchNo = GetKilnCarBatchNoByKilnCarID(oracleTrConn, kilnCarID);
  1454. #region 窑车表存在,查询本次窑车产品的批次号 并更改入窑车时间
  1455. //更改窑车状态表入窑时间
  1456. errMsg = UpdatekilnCarStatus(oracleTrConn, kilnCarID, Constant.ProcedureModelType.IntoKiln, sUserInfo, procedure, kilnCarBatchNo);
  1457. if (!string.IsNullOrEmpty(errMsg))
  1458. {
  1459. return errMsg;
  1460. }
  1461. #endregion
  1462. DataView dvFilter = barcodeTable.DefaultView;
  1463. dvFilter.RowFilter = "kilnCarCode='" + dtNewKiln.Rows[i]["kilnCarCode"].ToString() + "'";
  1464. DataTable dtNew = dvFilter.ToTable();
  1465. int? maxClassesSettingID = null;
  1466. // 条码信息
  1467. //foreach (DataRow barcodeRow in barcodeTable.Rows)
  1468. foreach (DataRow barcodeRow in dtNew.Rows)
  1469. {
  1470. // 条码
  1471. string barcode = barcodeRow["Barcode"].ToString();
  1472. // 生产工号
  1473. workUserID = Convert.ToInt32(barcodeRow["UserID"]);
  1474. workUserCode = barcodeRow["UserCode"].ToString();
  1475. workUserName = barcodeRow["UserName"].ToString();
  1476. // 查询新插入的生产数据ID
  1477. string sql = "select SEQ_PM_ProductionData_ID.nextval from dual";
  1478. string idStr = oracleTrConn.GetSqlResultToStr(sql);
  1479. int productionDataID = 0;
  1480. if (!string.IsNullOrEmpty(idStr))
  1481. {
  1482. productionDataID = int.Parse(idStr);
  1483. }
  1484. else
  1485. {
  1486. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  1487. }
  1488. int? ClassesSettingID = null;//班次配置ID
  1489. #region 添加生产者数据
  1490. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID);
  1491. if (!string.IsNullOrEmpty(errMsg))
  1492. {
  1493. return errMsg;
  1494. }
  1495. #endregion
  1496. maxClassesSettingID = ClassesSettingID;
  1497. #region 添加生产数据
  1498. ProductionDataEntity productionData = new ProductionDataEntity();
  1499. #region 属性赋值
  1500. productionData.ClassesSettingID = ClassesSettingID;
  1501. productionData.ProductionDataID = Convert.ToInt32(idStr);
  1502. productionData.Barcode = barcode;
  1503. productionData.CentralizedBatchNo = centralizedBatchNo;
  1504. productionData.ProductionLineID = procedure.ProductionLineID;
  1505. productionData.ProductionLineCode = procedure.ProductionlineCode;
  1506. productionData.ProductionLineName = procedure.ProductionlineName;
  1507. productionData.CompleteProcedureID = procedure.ProcedureID;
  1508. productionData.ProcedureCode = procedure.ProcedureCode;
  1509. productionData.ProcedureName = procedure.ProcedureName;
  1510. productionData.ProcedureModel = procedure.ProcedureModel;
  1511. productionData.ModelType = procedure.ModelType;
  1512. productionData.NodeType = procedure.NodeType;
  1513. productionData.DefectFlag = (int)Constant.DefectFlag.No;
  1514. productionData.ReworkProcedureID = null;
  1515. productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, barcode);
  1516. productionData.IsReFire = (int)Constant.ReFireFlag.No;
  1517. productionData.PieceType = procedure.PieceType;
  1518. //productionData.GoodsGrade = (int)Constant.GoodsGrade.Good;
  1519. //不加条件valueflag,是因为,成检后重烧走过之后,在次重烧,以后也是重烧状态
  1520. // string sqlReFire = "select * from tp_PM_ProductionData where ProductionDataid=(select max(ProductionDataid) from tp_PM_ProductionData where barcode='" + productionData.Barcode + "')";
  1521. ////// string sqlReFire = @"select
  1522. ////// isrefire
  1523. ////// from tp_pm_inproduction where barcode=:barcode
  1524. ////// ";
  1525. ////// OracleParameter[] ReFireparas = new OracleParameter[] {
  1526. ////// new OracleParameter(":barcode",barcode),
  1527. ////// };
  1528. ////// DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas);
  1529. ////// if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0)
  1530. ////// {
  1531. ////// if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0)
  1532. ////// {
  1533. ////// productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]);
  1534. ////// }
  1535. ////// }
  1536. productionData.OrganizationID = procedure.OrganizationID;
  1537. productionData.GoodsID = Convert.ToInt32(barcodeRow["GoodsID"]);
  1538. productionData.GoodsCode = barcodeRow["GoodsCode"].ToString();
  1539. productionData.GoodsName = barcodeRow["GoodsName"].ToString();
  1540. productionData.UserID = workUserID;
  1541. productionData.UserCode = barcodeRow["UserCode"].ToString();
  1542. productionData.UserName = barcodeRow["UserName"].ToString();
  1543. #region 窑炉窑车属性
  1544. productionData.KilnID = Convert.ToInt32(barcodeRow["KilnID"].ToString());
  1545. productionData.KilnCode = barcodeRow["KilnCode"].ToString();
  1546. productionData.KilnName = barcodeRow["KilnName"].ToString();
  1547. productionData.KilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString());
  1548. productionData.KilnCarCode = barcodeRow["KilnCarCode"].ToString();
  1549. productionData.KilnCarName = barcodeRow["KilnCarName"].ToString();
  1550. productionData.KilnCarBatchNo = kilnCarBatchNo;
  1551. productionData.KilnCarPosition = Convert.ToInt32(barcodeRow["KilnCarPosition"].ToString());
  1552. productionData.Remarks = "";
  1553. #endregion
  1554. #endregion
  1555. string OutSpecialRepairflag = "0";//干补标识
  1556. errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag);
  1557. if (!string.IsNullOrEmpty(errMsg))
  1558. {
  1559. return errMsg;
  1560. }
  1561. #endregion
  1562. #region 修改在产产品数据的当前工序,清空返工工序字段
  1563. InProductionEntity addInProductionEntity = new InProductionEntity();
  1564. addInProductionEntity.BarCode = barcode;
  1565. //流程工序
  1566. addInProductionEntity.FlowProcedureID = procedure.ProcedureID;
  1567. // 当前工序
  1568. //addInProductionEntity.CompleteProcedureID = procedure.ProcedureID;
  1569. addInProductionEntity.ProcedureID = procedure.ProcedureID;
  1570. //生产数据ID
  1571. addInProductionEntity.ProductionDataID = productionDataID;
  1572. // 工序模型
  1573. addInProductionEntity.ProcedureModel = procedure.ProcedureModel;
  1574. // 工序类别
  1575. addInProductionEntity.ModelType = procedure.ModelType;
  1576. // 生产工号
  1577. addInProductionEntity.UserID = workUserID;
  1578. // 缺陷标识
  1579. addInProductionEntity.DefectFlag = (int)Constant.DefectFlag.No;
  1580. #region 更新在产表窑车窑炉字段
  1581. addInProductionEntity.KilnID = Convert.ToInt32(barcodeRow["KilnID"].ToString());
  1582. addInProductionEntity.KilnCode = barcodeRow["KilnCode"].ToString();
  1583. addInProductionEntity.KilnName = barcodeRow["KilnName"].ToString();
  1584. addInProductionEntity.KilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString());
  1585. addInProductionEntity.KilnCarCode = barcodeRow["KilnCarCode"].ToString();
  1586. addInProductionEntity.KilnCarName = barcodeRow["KilnCarName"].ToString();
  1587. addInProductionEntity.KilnCarBatchNo = kilnCarBatchNo;
  1588. addInProductionEntity.KilnCarPosition = Convert.ToInt32(barcodeRow["KilnCarPosition"].ToString());
  1589. #endregion
  1590. // 执行修改
  1591. errMsg = UpdateInProduction(oracleTrConn, addInProductionEntity, sUserInfo);
  1592. // 执行失败
  1593. if (!string.IsNullOrEmpty(errMsg))
  1594. {
  1595. return errMsg;
  1596. }
  1597. #endregion
  1598. //#region 添加生产者数据
  1599. //errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo);
  1600. //if (!string.IsNullOrEmpty(errMsg))
  1601. //{
  1602. // return errMsg;
  1603. //}
  1604. //#endregion
  1605. }
  1606. #region 插入窑车生产数据表
  1607. errMsg = AddKilnCarData(oracleTrConn,
  1608. accountDate,
  1609. kilnCarID,
  1610. kilnCarBatchNo,
  1611. workUserID,
  1612. workUserCode,
  1613. workUserName,
  1614. Remarks,
  1615. sUserInfo, maxClassesSettingID);
  1616. if (!string.IsNullOrEmpty(errMsg))
  1617. {
  1618. return errMsg;
  1619. }
  1620. #endregion
  1621. //#region 窑车生产者
  1622. //// 查询新插入的生产数据ID
  1623. //string sqlKilnCar = "select SEQ_PM_KilnCarData_ID.Currval from dual";
  1624. //string idKilnCar = oracleTrConn.GetSqlResultToStr(sqlKilnCar);
  1625. //errMsg = AddKilnCarProducer(oracleTrConn, accountDate, Convert.ToInt32(idKilnCar), workUserID, sUserInfo);
  1626. //if (!string.IsNullOrEmpty(errMsg))
  1627. //{
  1628. // return errMsg;
  1629. //}
  1630. //#endregion
  1631. }
  1632. return errMsg;
  1633. }
  1634. catch (Exception ex)
  1635. {
  1636. throw ex;
  1637. }
  1638. }
  1639. /// <summary>
  1640. /// 校验窑车的工序与当前工序是否可以到达(重烧后,未走重烧入窑)
  1641. /// </summary>
  1642. /// <param name="oracleTrConn">数据连接</param>
  1643. /// <param name="barcode">产品条码</param>
  1644. /// <returns>string</returns>
  1645. private static string GetKilnCarProcedureIDByKilnCarID(IDBTransaction oracleTrConn, int KilnCarID, int ProcedureID)
  1646. {
  1647. string sql = @"select ProcedureID from TP_PM_KilnCarStatus where KilnCarID=:KilnCarID";
  1648. OracleParameter[] paras = new OracleParameter[] {
  1649. new OracleParameter(":KilnCarID", KilnCarID) ,
  1650. };
  1651. int currentProcedureID = 0;
  1652. DataSet result = oracleTrConn.GetSqlResultToDs(sql, paras);
  1653. if (result != null && result.Tables[0].Rows.Count > 0)
  1654. {
  1655. currentProcedureID = Convert.ToInt32(result.Tables[0].Rows[0][0]);
  1656. }
  1657. sql = @"select pro.ProcedureID
  1658. from TP_PC_ProcedureFlow flow
  1659. inner join TP_PC_Procedure pro
  1660. on flow.arriveprocedureid = pro.procedureid
  1661. inner join TP_PC_ProductionLine line
  1662. on pro.ProductionLineID = line.ProductionLineID
  1663. where flow.ProcedureID = :currentProcedureID
  1664. and flow.FlowFlag = 2";
  1665. paras = new OracleParameter[] {
  1666. new OracleParameter(":currentProcedureID", currentProcedureID) ,
  1667. };
  1668. result = oracleTrConn.GetSqlResultToDs(sql, paras);
  1669. int returnProcedureID = 0;
  1670. if (result != null && result.Tables[0].Rows.Count > 0)
  1671. {
  1672. if (result.Tables[0].Select("ProcedureID=" + ProcedureID).Length > 0)
  1673. {
  1674. returnProcedureID = 1;
  1675. }
  1676. }
  1677. // 保存失败
  1678. if (returnProcedureID == 0)
  1679. {
  1680. return string.Format("当前工序不允许进行操作", "条码", "保存");
  1681. }
  1682. return null;
  1683. }
  1684. /// <summary>
  1685. /// 出窑车计件
  1686. /// </summary>
  1687. /// <param name="oracleTrConn">数据连接对象</param>
  1688. /// <param name="procedure">工序对象</param>
  1689. /// <param name="barcodeTable">条码信息</param>
  1690. /// <param name="sUserInfo">用户基本信息</param>
  1691. /// <param name="goodsID">返回的产品ID</param>
  1692. /// <param name="goodsCode">返回的产品Code</param>
  1693. /// <param name="goodsName">返回的产品名称</param>
  1694. /// <returns>string</returns>
  1695. /// <remarks>
  1696. /// 张国印 2014.10.04 新建
  1697. /// </remarks>
  1698. private static string AddOutKilnCar(IDBTransaction oracleTrConn, ProcedureEntity procedure, DataTable barcodeTable, SUserInfo sUserInfo,
  1699. out int goodsID, out string goodsCode, out string goodsName)
  1700. {
  1701. try
  1702. {
  1703. goodsID = Constant.INT_IS_ZERO;
  1704. goodsCode = string.Empty;
  1705. goodsName = string.Empty;
  1706. string groutingUserCode = string.Empty;
  1707. // 获得账务日期
  1708. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  1709. string errMsg = string.Empty;
  1710. // 生产工号
  1711. int workUserID = Constant.INT_IS_ZERO;
  1712. // 生产工号Code
  1713. string workUserCode = string.Empty;
  1714. // 生产工号Name
  1715. string workUserName = string.Empty;
  1716. // 本批采集的批次号
  1717. string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  1718. // 窑车批次号
  1719. string kilnCarBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  1720. // 窑车状态
  1721. string kilnCarStatus = string.Empty;
  1722. //////////////////////////////////////////////////
  1723. DataView dv = barcodeTable.DefaultView;
  1724. DataTable dtNewKiln = dv.ToTable(true, "kilnCarCode");
  1725. for (int i = 0; i < dtNewKiln.Rows.Count; i++)
  1726. {
  1727. // 窑车Code
  1728. //string kilnCarCode = barcodeTable.Rows[0]["kilnCarCode"].ToString();
  1729. DataRow[] dr = barcodeTable.Select("kilnCarCode='" + dtNewKiln.Rows[i]["kilnCarCode"].ToString() + "'");
  1730. string kilnCarCode = dr[0]["kilnCarCode"].ToString();
  1731. string Remarks = dr[0]["Remarks"].ToString();
  1732. #region 校验窑车是否可出窑炉
  1733. errMsg = CheckKilnCarrStatus(oracleTrConn, procedure.ProcedureID, kilnCarCode, procedure.ModelType, sUserInfo, out kilnCarStatus);
  1734. if (!string.IsNullOrEmpty(errMsg))
  1735. {
  1736. return errMsg;
  1737. }
  1738. #endregion
  1739. // 窑炉ID
  1740. //int kilnID = Convert.ToInt32(barcodeTable.Rows[0]["kilnID"].ToString());
  1741. int kilnID = Convert.ToInt32(dr[0]["kilnID"].ToString());
  1742. // 窑车ID
  1743. //int kilnCarID = Convert.ToInt32(barcodeTable.Rows[0]["KilnCarID"].ToString());
  1744. int kilnCarID = Convert.ToInt32(dr[0]["KilnCarID"].ToString());
  1745. // 主要目的防止输入窑车号,当前工序与该操作的工序不匹配,例如重烧入窑,在入窑工序上操作了
  1746. errMsg = GetKilnCarProcedureIDByKilnCarID(oracleTrConn, kilnCarID, Convert.ToInt32(procedure.ProcedureID));
  1747. if (!string.IsNullOrEmpty(errMsg))
  1748. {
  1749. return errMsg;
  1750. }
  1751. // 查询本次窑车产品的批次号
  1752. kilnCarBatchNo = GetKilnCarBatchNoByKilnCarID(oracleTrConn, kilnCarID);
  1753. #region 窑车表存在,查询本次窑车产品的批次号 并更改出窑车时间
  1754. //更改窑车状态表入窑时间
  1755. errMsg = UpdatekilnCarStatus(oracleTrConn, kilnCarID, Constant.ProcedureModelType.OutKiln, sUserInfo, procedure, kilnCarBatchNo);
  1756. if (!string.IsNullOrEmpty(errMsg))
  1757. {
  1758. return errMsg;
  1759. }
  1760. #endregion
  1761. //// 条码信息
  1762. DataView dvFilter = barcodeTable.DefaultView;
  1763. dvFilter.RowFilter = "kilnCarCode='" + dtNewKiln.Rows[i]["kilnCarCode"].ToString() + "'";
  1764. DataTable dtNew = dvFilter.ToTable();
  1765. int? maxClassesSettingID = null;
  1766. // 条码信息
  1767. //foreach (DataRow barcodeRow in barcodeTable.Rows)
  1768. foreach (DataRow barcodeRow in dtNew.Rows)
  1769. {
  1770. // 条码
  1771. string barcode = barcodeRow["Barcode"].ToString();
  1772. // 生产工号
  1773. workUserID = Convert.ToInt32(barcodeRow["UserID"]);
  1774. workUserCode = barcodeRow["UserCode"].ToString();
  1775. workUserName = barcodeRow["UserName"].ToString();
  1776. // 查询新插入的生产数据ID
  1777. string sql = "select SEQ_PM_ProductionData_ID.nextval from dual";
  1778. string idStr = oracleTrConn.GetSqlResultToStr(sql);
  1779. int productionDataID = 0;
  1780. if (!string.IsNullOrEmpty(idStr))
  1781. {
  1782. productionDataID = int.Parse(idStr);
  1783. }
  1784. else
  1785. {
  1786. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  1787. }
  1788. int? ClassesSettingID = null;//班次配置ID
  1789. #region 添加生产者数据
  1790. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID);
  1791. if (!string.IsNullOrEmpty(errMsg))
  1792. {
  1793. return errMsg;
  1794. }
  1795. #endregion
  1796. maxClassesSettingID = ClassesSettingID;
  1797. #region 添加生产数据
  1798. ProductionDataEntity productionData = new ProductionDataEntity();
  1799. #region 属性赋值
  1800. productionData.ClassesSettingID = ClassesSettingID;
  1801. productionData.ProductionDataID = Convert.ToInt32(idStr);
  1802. productionData.Barcode = barcode;
  1803. productionData.CentralizedBatchNo = centralizedBatchNo;
  1804. productionData.ProductionLineID = procedure.ProductionLineID;
  1805. productionData.ProductionLineCode = procedure.ProductionlineCode;
  1806. productionData.ProductionLineName = procedure.ProductionlineName;
  1807. productionData.CompleteProcedureID = procedure.ProcedureID;
  1808. productionData.ProcedureCode = procedure.ProcedureCode;
  1809. productionData.ProcedureName = procedure.ProcedureName;
  1810. productionData.ProcedureModel = procedure.ProcedureModel;
  1811. productionData.ModelType = procedure.ModelType;
  1812. productionData.NodeType = procedure.NodeType;
  1813. productionData.DefectFlag = (int)Constant.DefectFlag.No;
  1814. productionData.ReworkProcedureID = null;
  1815. productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, barcode);
  1816. productionData.IsReFire = (int)Constant.ReFireFlag.No;
  1817. productionData.PieceType = procedure.PieceType;
  1818. //productionData.GoodsGrade = (int)Constant.GoodsGrade.Good;
  1819. ////// string sqlReFire = @"select
  1820. ////// isrefire
  1821. ////// from tp_pm_inproduction where barcode=:barcode
  1822. ////// ";
  1823. ////// OracleParameter[] ReFireparas = new OracleParameter[] {
  1824. ////// new OracleParameter(":barcode",barcode),
  1825. ////// };
  1826. ////// DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas);
  1827. ////// if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0)
  1828. ////// {
  1829. ////// if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0)
  1830. ////// {
  1831. ////// productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]);
  1832. ////// }
  1833. ////// }
  1834. productionData.OrganizationID = procedure.OrganizationID;
  1835. productionData.GoodsID = Convert.ToInt32(barcodeRow["GoodsID"]);
  1836. productionData.GoodsCode = barcodeRow["GoodsCode"].ToString();
  1837. productionData.GoodsName = barcodeRow["GoodsName"].ToString();
  1838. productionData.UserID = workUserID;
  1839. productionData.UserCode = barcodeRow["UserCode"].ToString();
  1840. productionData.UserName = barcodeRow["UserName"].ToString();
  1841. #region 窑炉窑车属性
  1842. productionData.KilnID = Convert.ToInt32(barcodeRow["KilnID"].ToString());
  1843. productionData.KilnCode = barcodeRow["KilnCode"].ToString();
  1844. productionData.KilnName = barcodeRow["KilnName"].ToString();
  1845. productionData.KilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString());
  1846. productionData.KilnCarCode = barcodeRow["KilnCarCode"].ToString();
  1847. productionData.KilnCarName = barcodeRow["KilnCarName"].ToString();
  1848. productionData.KilnCarBatchNo = kilnCarBatchNo;
  1849. productionData.KilnCarPosition = Convert.ToInt32(barcodeRow["KilnCarPosition"].ToString());
  1850. productionData.Remarks = barcodeRow["Remarks"].ToString();
  1851. #endregion
  1852. #endregion
  1853. string OutSpecialRepairflag = "0";//干补标识
  1854. errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag);
  1855. if (!string.IsNullOrEmpty(errMsg))
  1856. {
  1857. return errMsg;
  1858. }
  1859. #endregion
  1860. #region 修改在产产品数据的当前工序,清空返工工序字段
  1861. InProductionEntity addInProductionEntity = new InProductionEntity();
  1862. addInProductionEntity.BarCode = barcode;
  1863. //流程工序
  1864. addInProductionEntity.FlowProcedureID = procedure.ProcedureID;
  1865. // 当前工序
  1866. //addInProductionEntity.CompleteProcedureID = procedure.ProcedureID;
  1867. addInProductionEntity.ProcedureID = procedure.ProcedureID;
  1868. // 生产数据ID
  1869. addInProductionEntity.ProductionDataID = productionDataID;
  1870. // 工序模型
  1871. addInProductionEntity.ProcedureModel = procedure.ProcedureModel;
  1872. // 工序类别
  1873. addInProductionEntity.ModelType = procedure.ModelType;
  1874. // 生产工号
  1875. addInProductionEntity.UserID = workUserID;
  1876. // 缺陷标识
  1877. addInProductionEntity.DefectFlag = (int)Constant.DefectFlag.No;
  1878. #region 更新在产表窑车窑炉字段
  1879. addInProductionEntity.KilnID = Convert.ToInt32(barcodeRow["KilnID"].ToString());
  1880. addInProductionEntity.KilnCode = barcodeRow["KilnCode"].ToString();
  1881. addInProductionEntity.KilnName = barcodeRow["KilnName"].ToString();
  1882. addInProductionEntity.KilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString());
  1883. addInProductionEntity.KilnCarCode = barcodeRow["KilnCarCode"].ToString();
  1884. addInProductionEntity.KilnCarName = barcodeRow["KilnCarName"].ToString();
  1885. addInProductionEntity.KilnCarBatchNo = kilnCarBatchNo;
  1886. addInProductionEntity.KilnCarPosition = Convert.ToInt32(barcodeRow["KilnCarPosition"].ToString());
  1887. #endregion
  1888. // 执行修改
  1889. errMsg = UpdateInProduction(oracleTrConn, addInProductionEntity, sUserInfo);
  1890. // 执行失败
  1891. if (!string.IsNullOrEmpty(errMsg))
  1892. {
  1893. return errMsg;
  1894. }
  1895. #endregion
  1896. //#region 添加生产者数据
  1897. //errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo);
  1898. //if (!string.IsNullOrEmpty(errMsg))
  1899. //{
  1900. // return errMsg;
  1901. //}
  1902. //#endregion
  1903. }
  1904. #region 插入窑车生产数据表
  1905. errMsg = AddKilnCarData(oracleTrConn,
  1906. accountDate,
  1907. kilnCarID,
  1908. kilnCarBatchNo,
  1909. workUserID,
  1910. workUserCode,
  1911. workUserName,
  1912. Remarks,
  1913. sUserInfo, maxClassesSettingID);
  1914. if (!string.IsNullOrEmpty(errMsg))
  1915. {
  1916. return errMsg;
  1917. }
  1918. #endregion
  1919. //#region 窑车生产者
  1920. //// 查询新插入的生产数据ID
  1921. //string sqlKilnCar = "select SEQ_PM_KilnCarData_ID.Currval from dual";
  1922. //string idKilnCar = oracleTrConn.GetSqlResultToStr(sqlKilnCar);
  1923. //errMsg = AddKilnCarProducer(oracleTrConn, accountDate, Convert.ToInt32(idKilnCar), workUserID, sUserInfo);
  1924. //if (!string.IsNullOrEmpty(errMsg))
  1925. //{
  1926. // return errMsg;
  1927. //}
  1928. //#endregion
  1929. }
  1930. return errMsg;
  1931. }
  1932. catch (Exception ex)
  1933. {
  1934. throw ex;
  1935. }
  1936. }
  1937. /// <summary>
  1938. /// 卸窑车计件
  1939. /// </summary>
  1940. /// <param name="oracleTrConn">数据连接对象</param>
  1941. /// <param name="procedure">工序对象</param>
  1942. /// <param name="barcodeTable">条码信息</param>
  1943. /// <param name="sUserInfo">用户基本信息</param>
  1944. /// <param name="goodsID">返回的产品ID</param>
  1945. /// <param name="goodsCode">返回的产品Code</param>
  1946. /// <param name="goodsName">返回的产品名称</param>
  1947. /// <returns>string</returns>
  1948. /// <remarks>
  1949. /// 张国印 2014.10.04 新建
  1950. /// </remarks>
  1951. private static string AddUnloadingKilnCar(IDBTransaction oracleTrConn, ProcedureEntity procedure, DataTable barcodeTable, SUserInfo sUserInfo,
  1952. out int goodsID, out string goodsCode, out string goodsName)
  1953. {
  1954. try
  1955. {
  1956. goodsID = Constant.INT_IS_ZERO;
  1957. goodsCode = string.Empty;
  1958. goodsName = string.Empty;
  1959. string groutingUserCode = string.Empty;
  1960. // 获得账务日期
  1961. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  1962. string errMsg = string.Empty;
  1963. // 生产工号
  1964. int workUserID = Constant.INT_IS_ZERO;
  1965. // 生产工号Code
  1966. string workUserCode = string.Empty;
  1967. // 生产工号Name
  1968. string workUserName = string.Empty;
  1969. // 本批采集的批次号
  1970. string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  1971. string finishedloadbatchno = DateTime.Now.ToString("yyMMddHHmmss-") + centralizedBatchNo;
  1972. // 窑车批次号
  1973. string kilnCarBatchNo = null;//System.Guid.NewGuid().ToString().ToUpper();
  1974. // 窑车状态
  1975. string kilnCarStatus = string.Empty;
  1976. DataView dv = barcodeTable.DefaultView;
  1977. DataTable dtNewKiln = dv.ToTable(true, "kilnCarCode");
  1978. for (int i = 0; i < dtNewKiln.Rows.Count; i++)
  1979. {
  1980. // 窑车Code
  1981. //string kilnCarCode = barcodeTable.Rows[0]["kilnCarCode"].ToString();
  1982. DataRow[] dr = barcodeTable.Select("kilnCarCode='" + dtNewKiln.Rows[i]["kilnCarCode"].ToString() + "'");
  1983. string kilnCarCode = dr[0]["kilnCarCode"].ToString();
  1984. string Remarks = dr[0]["Remarks"].ToString();
  1985. #region 校验窑车是否可出窑炉
  1986. errMsg = CheckKilnCarrStatus(oracleTrConn, procedure.ProcedureID, kilnCarCode, procedure.ModelType, sUserInfo, out kilnCarStatus);
  1987. if (!string.IsNullOrEmpty(errMsg))
  1988. {
  1989. return errMsg;
  1990. }
  1991. #endregion
  1992. // 窑炉ID
  1993. //int kilnID = Convert.ToInt32(barcodeTable.Rows[0]["kilnID"].ToString());
  1994. int kilnID = Convert.ToInt32(dr[0]["kilnID"].ToString());
  1995. // 窑车ID
  1996. //int kilnCarID = Convert.ToInt32(barcodeTable.Rows[0]["KilnCarID"].ToString());
  1997. int kilnCarID = Convert.ToInt32(dr[0]["KilnCarID"].ToString());
  1998. // 主要目的防止输入窑车号,当前工序与该操作的工序不匹配,例如重烧入窑,在入窑工序上操作了
  1999. errMsg = GetKilnCarProcedureIDByKilnCarID(oracleTrConn, kilnCarID, Convert.ToInt32(procedure.ProcedureID));
  2000. if (!string.IsNullOrEmpty(errMsg))
  2001. {
  2002. return errMsg;
  2003. }
  2004. // 查询本次窑车产品的批次号
  2005. kilnCarBatchNo = GetKilnCarBatchNoByKilnCarID(oracleTrConn, kilnCarID);
  2006. #region 窑车表存在,查询本次窑车产品的批次号 并更改出窑车时间
  2007. //更改窑车状态表入窑时间
  2008. errMsg = UpdatekilnCarStatus(oracleTrConn, kilnCarID, Constant.ProcedureModelType.UnloadCar, sUserInfo, procedure, kilnCarBatchNo);
  2009. if (!string.IsNullOrEmpty(errMsg))
  2010. {
  2011. return errMsg;
  2012. }
  2013. #endregion
  2014. // 条码信息
  2015. DataView dvFilter = barcodeTable.DefaultView;
  2016. dvFilter.RowFilter = "kilnCarCode='" + dtNewKiln.Rows[i]["kilnCarCode"].ToString() + "'";
  2017. DataTable dtNew = dvFilter.ToTable();
  2018. int? maxClassesSettingID = null;
  2019. // 条码信息
  2020. //foreach (DataRow barcodeRow in barcodeTable.Rows)
  2021. foreach (DataRow barcodeRow in dtNew.Rows)
  2022. {
  2023. // 条码
  2024. string barcode = barcodeRow["Barcode"].ToString();
  2025. // 生产工号
  2026. workUserID = Convert.ToInt32(barcodeRow["UserID"]);
  2027. workUserCode = barcodeRow["UserCode"].ToString();
  2028. workUserName = barcodeRow["UserName"].ToString();
  2029. // 查询新插入的生产数据ID
  2030. string sql = "select SEQ_PM_ProductionData_ID.nextval from dual";
  2031. string idStr = oracleTrConn.GetSqlResultToStr(sql);
  2032. int productionDataID = 0;
  2033. if (!string.IsNullOrEmpty(idStr))
  2034. {
  2035. productionDataID = int.Parse(idStr);
  2036. }
  2037. else
  2038. {
  2039. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  2040. }
  2041. int? ClassesSettingID = null;//班次配置ID
  2042. #region 添加生产者数据
  2043. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID);
  2044. if (!string.IsNullOrEmpty(errMsg))
  2045. {
  2046. return errMsg;
  2047. }
  2048. #endregion
  2049. maxClassesSettingID = ClassesSettingID;
  2050. #region 添加生产数据
  2051. ProductionDataEntity productionData = new ProductionDataEntity();
  2052. #region 属性赋值
  2053. productionData.ClassesSettingID = ClassesSettingID;
  2054. productionData.ProductionDataID = Convert.ToInt32(idStr);
  2055. productionData.Barcode = barcode;
  2056. productionData.CentralizedBatchNo = centralizedBatchNo;
  2057. productionData.ProductionLineID = procedure.ProductionLineID;
  2058. productionData.ProductionLineCode = procedure.ProductionlineCode;
  2059. productionData.ProductionLineName = procedure.ProductionlineName;
  2060. productionData.CompleteProcedureID = procedure.ProcedureID;
  2061. productionData.ProcedureCode = procedure.ProcedureCode;
  2062. productionData.ProcedureName = procedure.ProcedureName;
  2063. productionData.ProcedureModel = procedure.ProcedureModel;
  2064. productionData.ModelType = procedure.ModelType;
  2065. productionData.NodeType = procedure.NodeType;
  2066. productionData.DefectFlag = (int)Constant.DefectFlag.No;
  2067. productionData.ReworkProcedureID = null;
  2068. productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, barcode);
  2069. productionData.IsReFire = (int)Constant.ReFireFlag.No;
  2070. productionData.GoodsGrade = (int)Constant.GoodsGrade.Good;
  2071. productionData.PieceType = procedure.PieceType;
  2072. ////// string sqlReFire = @"select
  2073. ////// isrefire
  2074. ////// from tp_pm_inproduction where barcode=:barcode
  2075. ////// ";
  2076. ////// OracleParameter[] ReFireparas = new OracleParameter[] {
  2077. ////// new OracleParameter(":barcode",barcode),
  2078. ////// };
  2079. ////// DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas);
  2080. ////// if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0)
  2081. ////// {
  2082. ////// if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0)
  2083. ////// {
  2084. ////// productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]);
  2085. ////// }
  2086. ////// }
  2087. productionData.OrganizationID = procedure.OrganizationID;
  2088. productionData.GoodsID = Convert.ToInt32(barcodeRow["GoodsID"]);
  2089. productionData.GoodsCode = barcodeRow["GoodsCode"].ToString();
  2090. productionData.GoodsName = barcodeRow["GoodsName"].ToString();
  2091. productionData.UserID = workUserID;
  2092. productionData.UserCode = barcodeRow["UserCode"].ToString();
  2093. productionData.UserName = barcodeRow["UserName"].ToString();
  2094. #region 窑炉窑车属性
  2095. productionData.KilnID = Convert.ToInt32(barcodeRow["KilnID"].ToString());
  2096. productionData.KilnCode = barcodeRow["KilnCode"].ToString();
  2097. productionData.KilnName = barcodeRow["KilnName"].ToString();
  2098. productionData.KilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString());
  2099. productionData.KilnCarCode = barcodeRow["KilnCarCode"].ToString();
  2100. productionData.KilnCarName = barcodeRow["KilnCarName"].ToString();
  2101. productionData.KilnCarBatchNo = kilnCarBatchNo;
  2102. productionData.KilnCarPosition = Convert.ToInt32(barcodeRow["KilnCarPosition"].ToString());
  2103. productionData.Remarks = barcodeRow["Remarks"].ToString();
  2104. #endregion
  2105. #endregion
  2106. string OutSpecialRepairflag = "0";//干补标识
  2107. errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag);
  2108. if (!string.IsNullOrEmpty(errMsg))
  2109. {
  2110. return errMsg;
  2111. }
  2112. #endregion
  2113. if (procedure.NodeType == Constant.ProcedureNodeType.Middle.GetHashCode())
  2114. {
  2115. #region 中间工序 修改在产产品数据的当前工序,清空返工工序字段
  2116. InProductionEntity addInProductionEntity = new InProductionEntity();
  2117. addInProductionEntity.BarCode = barcode;
  2118. //流程工序ID
  2119. addInProductionEntity.FlowProcedureID = procedure.ProcedureID;
  2120. // 当前工序
  2121. addInProductionEntity.ProcedureID = procedure.ProcedureID;
  2122. // 生产数据ID
  2123. addInProductionEntity.ProductionDataID = productionDataID;
  2124. // 工序模型
  2125. addInProductionEntity.ProcedureModel = procedure.ProcedureModel;
  2126. // 工序类别
  2127. addInProductionEntity.ModelType = procedure.ModelType;
  2128. // 生产工号
  2129. addInProductionEntity.UserID = workUserID;
  2130. // 缺陷标识
  2131. addInProductionEntity.DefectFlag = (int)Constant.DefectFlag.No;
  2132. #region 更新在产表窑车窑炉字段
  2133. addInProductionEntity.KilnID = Convert.ToInt32(barcodeRow["KilnID"].ToString());
  2134. addInProductionEntity.KilnCode = barcodeRow["KilnCode"].ToString();
  2135. addInProductionEntity.KilnName = barcodeRow["KilnName"].ToString();
  2136. addInProductionEntity.KilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString());
  2137. addInProductionEntity.KilnCarCode = barcodeRow["KilnCarCode"].ToString();
  2138. addInProductionEntity.KilnCarName = barcodeRow["KilnCarName"].ToString();
  2139. addInProductionEntity.KilnCarBatchNo = kilnCarBatchNo;
  2140. addInProductionEntity.KilnCarPosition = Convert.ToInt32(barcodeRow["KilnCarPosition"].ToString());
  2141. #endregion
  2142. // 执行修改
  2143. errMsg = UpdateInProduction(oracleTrConn, addInProductionEntity, sUserInfo);
  2144. // 执行失败
  2145. if (!string.IsNullOrEmpty(errMsg))
  2146. {
  2147. return errMsg;
  2148. }
  2149. #endregion
  2150. }
  2151. else if (procedure.NodeType == Constant.ProcedureNodeType.End.GetHashCode())
  2152. {
  2153. #region 结束工序 添加成品数据 删除在产产品数据
  2154. FinishedProductEntity finishedProduct = new FinishedProductEntity();
  2155. finishedProduct.BarCode = barcode;
  2156. errMsg = AddFinishedProduct(oracleTrConn, finishedProduct, sUserInfo, finishedloadbatchno);
  2157. if (!string.IsNullOrEmpty(errMsg))
  2158. {
  2159. return errMsg;
  2160. }
  2161. InProductionEntity delInProductionEntity = new InProductionEntity();
  2162. delInProductionEntity.BarCode = barcode;
  2163. // 执行删除 在产数据
  2164. errMsg = DeleteInProduction(oracleTrConn, delInProductionEntity, true, sUserInfo);
  2165. // 执行失败
  2166. if (!string.IsNullOrEmpty(errMsg))
  2167. {
  2168. return errMsg;
  2169. }
  2170. #endregion
  2171. }
  2172. //#region 添加生产者数据
  2173. //errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo);
  2174. //if (!string.IsNullOrEmpty(errMsg))
  2175. //{
  2176. // return errMsg;
  2177. //}
  2178. //#endregion
  2179. }
  2180. #region 插入窑车生产数据表
  2181. errMsg = AddKilnCarData(oracleTrConn,
  2182. accountDate,
  2183. kilnCarID,
  2184. kilnCarBatchNo,
  2185. workUserID,
  2186. workUserCode,
  2187. workUserName,
  2188. Remarks,
  2189. sUserInfo, maxClassesSettingID);
  2190. if (!string.IsNullOrEmpty(errMsg))
  2191. {
  2192. return errMsg;
  2193. }
  2194. #endregion
  2195. //#region 窑车生产者
  2196. //// 查询新插入的生产数据ID
  2197. //string sqlKilnCar = "select SEQ_PM_KilnCarData_ID.Currval from dual";
  2198. //string idKilnCar = oracleTrConn.GetSqlResultToStr(sqlKilnCar);
  2199. //errMsg = AddKilnCarProducer(oracleTrConn, accountDate, Convert.ToInt32(idKilnCar), workUserID, sUserInfo);
  2200. //if (!string.IsNullOrEmpty(errMsg))
  2201. //{
  2202. // return errMsg;
  2203. //}
  2204. //#endregion
  2205. #region 删除TP_PM_KilnCarGoods数据 按照窑车ID
  2206. errMsg = DeleteKilnCarGoodsByKilnCarID(oracleTrConn, kilnCarID);
  2207. if (!string.IsNullOrEmpty(errMsg))
  2208. {
  2209. return errMsg;
  2210. }
  2211. #endregion
  2212. }
  2213. return errMsg;
  2214. }
  2215. catch (Exception ex)
  2216. {
  2217. throw ex;
  2218. }
  2219. }
  2220. /// <summary>
  2221. /// 窑车补件计件
  2222. /// </summary>
  2223. /// <param name="oracleTrConn">数据连接对象</param>
  2224. /// <param name="procedure">工序对象</param>
  2225. /// <param name="barcodeTable">条码信息</param>
  2226. /// <param name="sUserInfo">用户基本信息</param>
  2227. /// <param name="goodsID">返回的产品ID</param>
  2228. /// <param name="goodsCode">返回的产品Code</param>
  2229. /// <param name="goodsName">返回的产品名称</param>
  2230. /// <returns>string</returns>
  2231. /// <remarks>
  2232. /// 张国印 2014.10.05 新建
  2233. /// </remarks>
  2234. private static string AddKilnCarSupplement(IDBTransaction oracleTrConn, ProcedureEntity procedure, DataTable barcodeTable, SUserInfo sUserInfo,
  2235. out int goodsID, out string goodsCode, out string goodsName)
  2236. {
  2237. try
  2238. {
  2239. goodsID = Constant.INT_IS_ZERO;
  2240. goodsCode = null;
  2241. goodsName = null;
  2242. string groutingUserCode = string.Empty;
  2243. // 获得账务日期
  2244. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  2245. string errMsg = "";
  2246. // 生产工号
  2247. int workUserID = Constant.INT_IS_ZERO;
  2248. // 生产工号Code
  2249. string workUserCode = string.Empty;
  2250. // 生产工号Name
  2251. string workUserName = string.Empty;
  2252. // 本批采集的批次号
  2253. string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  2254. // 窑车Code
  2255. string kilnCarCode = barcodeTable.Rows[0]["kilnCarCode"].ToString();
  2256. // 窑车批次号
  2257. string kilnCarBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  2258. // 窑车状态
  2259. string kilnCarStatus = string.Empty;
  2260. #region 校验窑车是否可装车
  2261. errMsg = CheckKilnCarrStatus(oracleTrConn, procedure.ProcedureID, kilnCarCode, procedure.ModelType, sUserInfo, out kilnCarStatus);
  2262. if (!string.IsNullOrEmpty(errMsg))
  2263. {
  2264. return errMsg;
  2265. }
  2266. #endregion
  2267. // 窑炉ID
  2268. //int kilnID = Convert.ToInt32(barcodeTable.Rows[0]["kilnID"].ToString());
  2269. //// 窑车ID
  2270. //int kilnCarID = Convert.ToInt32(barcodeTable.Rows[0]["KilnCarID"].ToString());
  2271. int kilnID = 0;
  2272. // 窑车ID
  2273. int kilnCarID = 0;
  2274. int j = 0;
  2275. // 查询窑车位置
  2276. string sqlKilnCarPosition = "SELECT DICTIONARYID FROM TP_MST_DataDictionary WHERE DictionaryType = 'TPC003' ORDER BY DICTIONARYID";
  2277. DataTable dtKilnCarPosition = oracleTrConn.GetSqlResultToDt(sqlKilnCarPosition);
  2278. // 查询窑车位置
  2279. string sqlKilnCarGoods = "SELECT DICTIONARYID FROM TP_MST_DataDictionary WHERE DictionaryType = 'TPC003' AND DICTIONARYID > :Position ORDER BY DICTIONARYID";
  2280. OracleParameter[] paras = new OracleParameter[] {
  2281. new OracleParameter(":Position",OracleDbType.Int32,dtKilnCarPosition.Rows[0]["DICTIONARYID"],ParameterDirection.Input)
  2282. };
  2283. DataTable dtKilnCarGoods = oracleTrConn.GetSqlResultToDt(sqlKilnCarPosition);
  2284. // 条码信息
  2285. foreach (DataRow barcodeRow in barcodeTable.Rows)
  2286. {
  2287. kilnID = Convert.ToInt32(barcodeRow["kilnID"]);
  2288. kilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString());
  2289. //窑车表存在,查询本次窑车产品的批次号 并更改装窑车时间
  2290. kilnCarBatchNo = GetKilnCarBatchNoByKilnCarID(oracleTrConn, kilnCarID);
  2291. // 条码
  2292. string barcode = barcodeRow["Barcode"].ToString();
  2293. // 生产工号
  2294. workUserID = Convert.ToInt32(barcodeRow["UserID"]);
  2295. workUserCode = barcodeRow["UserCode"].ToString();
  2296. workUserName = barcodeRow["UserName"].ToString();
  2297. //#region 校验条码有效性
  2298. //errMsg = CheckBarcode(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo);
  2299. //if (!string.IsNullOrEmpty(errMsg))
  2300. //{
  2301. // return errMsg;
  2302. //}
  2303. //#endregion
  2304. if (procedure.CollectType == 1)
  2305. {
  2306. #region 校验条码有效性
  2307. errMsg = CheckBarcode(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo);
  2308. if (!string.IsNullOrEmpty(errMsg))
  2309. {
  2310. return errMsg;
  2311. }
  2312. #endregion
  2313. }
  2314. else
  2315. {
  2316. string sqlGroutingInfo = @"select tp_pm_groutingdailydetail.goodsid,
  2317. tp_pm_groutingdailydetail.goodscode,
  2318. tp_pm_groutingdailydetail.goodsname,
  2319. tp_pm_groutingdailydetail.usercode as groutingUserCode
  2320. from tp_pm_groutingdailydetail where barcode=:barcode
  2321. ";
  2322. OracleParameter[] ReFireparas = new OracleParameter[] {
  2323. new OracleParameter(":barcode",barcode),
  2324. };
  2325. DataSet dsGrouting = oracleTrConn.GetSqlResultToDs(sqlGroutingInfo, ReFireparas);
  2326. if (dsGrouting != null && dsGrouting.Tables[0].Rows.Count > 0)
  2327. {
  2328. goodsID = Convert.ToInt32(dsGrouting.Tables[0].Rows[0]["goodsid"]);
  2329. goodsCode = dsGrouting.Tables[0].Rows[0]["goodscode"].ToString();
  2330. goodsName = dsGrouting.Tables[0].Rows[0]["goodsName"].ToString();
  2331. groutingUserCode = dsGrouting.Tables[0].Rows[0]["groutingUserCode"].ToString();
  2332. }
  2333. }
  2334. // 查询新插入的生产数据ID
  2335. string sql = "select SEQ_PM_ProductionData_ID.nextval from dual";
  2336. string idStr = oracleTrConn.GetSqlResultToStr(sql);
  2337. int productionDataID = 0;
  2338. if (!string.IsNullOrEmpty(idStr))
  2339. {
  2340. productionDataID = int.Parse(idStr);
  2341. }
  2342. else
  2343. {
  2344. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  2345. }
  2346. int? ClassesSettingID = null;//班次配置ID
  2347. #region 添加生产者数据
  2348. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID);
  2349. if (!string.IsNullOrEmpty(errMsg))
  2350. {
  2351. return errMsg;
  2352. }
  2353. #endregion
  2354. #region 添加生产数据
  2355. ProductionDataEntity productionData = new ProductionDataEntity();
  2356. #region 属性赋值
  2357. productionData.ClassesSettingID = ClassesSettingID;
  2358. productionData.ProductionDataID = Convert.ToInt32(idStr);
  2359. productionData.Barcode = barcode;
  2360. productionData.CentralizedBatchNo = centralizedBatchNo;
  2361. productionData.ProductionLineID = procedure.ProductionLineID;
  2362. productionData.ProductionLineCode = procedure.ProductionlineCode;
  2363. productionData.ProductionLineName = procedure.ProductionlineName;
  2364. productionData.CompleteProcedureID = procedure.ProcedureID;
  2365. productionData.ProcedureCode = procedure.ProcedureCode;
  2366. productionData.ProcedureName = procedure.ProcedureName;
  2367. productionData.ProcedureModel = procedure.ProcedureModel;
  2368. productionData.ModelType = procedure.ModelType;
  2369. productionData.NodeType = procedure.NodeType;
  2370. productionData.DefectFlag = (int)Constant.DefectFlag.No;
  2371. productionData.ReworkProcedureID = null;
  2372. productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, barcode);
  2373. productionData.IsReFire = (int)Constant.ReFireFlag.No;
  2374. productionData.GoodsGrade = (int)Constant.GoodsGrade.Good;
  2375. productionData.OrganizationID = procedure.OrganizationID;
  2376. productionData.GoodsID = goodsID;
  2377. productionData.GoodsCode = goodsCode;
  2378. productionData.GoodsName = goodsName;
  2379. productionData.UserID = workUserID;
  2380. productionData.UserCode = barcodeRow["UserCode"].ToString();
  2381. productionData.UserName = barcodeRow["UserName"].ToString();
  2382. productionData.PieceType = procedure.PieceType;
  2383. #region 窑炉窑车属性
  2384. productionData.KilnID = Convert.ToInt32(barcodeRow["KilnID"].ToString());
  2385. productionData.KilnCode = barcodeRow["KilnCode"].ToString();
  2386. productionData.KilnName = barcodeRow["KilnName"].ToString();
  2387. productionData.KilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString());
  2388. productionData.KilnCarCode = barcodeRow["KilnCarCode"].ToString();
  2389. productionData.KilnCarName = barcodeRow["KilnCarName"].ToString();
  2390. productionData.KilnCarBatchNo = kilnCarBatchNo;
  2391. productionData.KilnCarPosition = Convert.ToInt32(barcodeRow["KilnCarPosition"].ToString());
  2392. #endregion
  2393. #endregion
  2394. string OutSpecialRepairflag = "0";//干补标识
  2395. errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag);
  2396. if (!string.IsNullOrEmpty(errMsg))
  2397. {
  2398. return errMsg;
  2399. }
  2400. #endregion
  2401. #region 修改在产产品数据的当前工序,清空返工工序字段
  2402. InProductionEntity addInProductionEntity = new InProductionEntity();
  2403. addInProductionEntity.BarCode = barcode;
  2404. //流程工序
  2405. addInProductionEntity.FlowProcedureID = procedure.ProcedureID;
  2406. // 当前工序
  2407. //addInProductionEntity.CompleteProcedureID = procedure.ProcedureID;
  2408. addInProductionEntity.ProcedureID = procedure.ProcedureID;
  2409. //生产数据ID
  2410. addInProductionEntity.ProductionDataID = productionDataID;
  2411. // 工序模型
  2412. addInProductionEntity.ProcedureModel = procedure.ProcedureModel;
  2413. // 工序类别
  2414. addInProductionEntity.ModelType = procedure.ModelType;
  2415. // 生产工号
  2416. addInProductionEntity.UserID = workUserID;
  2417. // 缺陷标识
  2418. addInProductionEntity.DefectFlag = (int)Constant.DefectFlag.No;
  2419. #region 更新在产表窑车窑炉字段
  2420. addInProductionEntity.KilnID = Convert.ToInt32(barcodeRow["KilnID"].ToString());
  2421. addInProductionEntity.KilnCode = barcodeRow["KilnCode"].ToString();
  2422. addInProductionEntity.KilnName = barcodeRow["KilnName"].ToString();
  2423. addInProductionEntity.KilnCarID = Convert.ToInt32(barcodeRow["KilnCarID"].ToString());
  2424. addInProductionEntity.KilnCarCode = barcodeRow["KilnCarCode"].ToString();
  2425. addInProductionEntity.KilnCarName = barcodeRow["KilnCarName"].ToString();
  2426. addInProductionEntity.KilnCarBatchNo = kilnCarBatchNo;
  2427. addInProductionEntity.KilnCarPosition = Convert.ToInt32(dtKilnCarGoods.Rows[j]["DICTIONARYID"]);
  2428. #endregion
  2429. // 执行修改
  2430. errMsg = UpdateInProduction(oracleTrConn, addInProductionEntity, sUserInfo);
  2431. // 执行失败
  2432. if (!string.IsNullOrEmpty(errMsg))
  2433. {
  2434. return errMsg;
  2435. }
  2436. #endregion
  2437. //#region 添加生产者数据
  2438. //errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo);
  2439. //if (!string.IsNullOrEmpty(errMsg))
  2440. //{
  2441. // return errMsg;
  2442. //}
  2443. //#endregion
  2444. #region 插入窑车产品表
  2445. errMsg = AddKilnCarGoods(oracleTrConn,
  2446. barcode,
  2447. kilnCarID,
  2448. goodsID,
  2449. productionData.KilnCarPosition.Value,
  2450. kilnCarBatchNo,
  2451. workUserID,
  2452. workUserCode,
  2453. workUserName,
  2454. sUserInfo);
  2455. if (!string.IsNullOrEmpty(errMsg))
  2456. {
  2457. return errMsg;
  2458. }
  2459. #endregion
  2460. }
  2461. return errMsg;
  2462. }
  2463. catch (Exception ex)
  2464. {
  2465. throw ex;
  2466. }
  2467. }
  2468. /// <summary>
  2469. /// 插入窑车生产数据表(装车)
  2470. /// </summary>
  2471. /// <param name="oracleTrConn">连接对象</param>
  2472. /// <param name="accountDate">账务日期</param>
  2473. /// <param name="kilnCarID">窑车ID</param>
  2474. /// <param name="kilnCarBatchNo">窑车批次号</param>
  2475. /// <param name="workUserID">生产工号ID</param>
  2476. /// <param name="workUserCode">生产工号Code</param>
  2477. /// <param name="workUserName">生产工号Name</param>
  2478. /// <param name="sUserInfo">用户基本信息</param>
  2479. /// <returns>string</returns>
  2480. private static string AddKilnCarDataCreateTime(IDBTransaction oracleTrConn,
  2481. DateTime accountDate,
  2482. int kilnCarID,
  2483. string kilnCarBatchNo,
  2484. int workUserID,
  2485. string workUserCode,
  2486. string workUserName,
  2487. string remarks,
  2488. DateTime? createtime,
  2489. SUserInfo sUserInfo)
  2490. {
  2491. #region SQL
  2492. string sql = "insert into tp_pm_kilncardata"
  2493. + " (kilncarbatchno,"
  2494. + " kilncarid,"
  2495. + " kilnid,"
  2496. + " productionlineid,"
  2497. + " procedureid,"
  2498. + " procedurecode,"
  2499. + " procedurename,"
  2500. + " proceduremodel,"
  2501. + " modeltype,"
  2502. + " piecetype,"
  2503. + " kilncarstatus,"
  2504. + " UserID,"
  2505. + " UserCode,"
  2506. + " UserName,"
  2507. + " loadingtime,"
  2508. + " intokilntime,"
  2509. + " outkilntime,"
  2510. + " unloadingtime,"
  2511. + " accountdate,"
  2512. + " accountid,"
  2513. + " createuserid,"
  2514. + " updateuserid,"
  2515. + " createtime,"
  2516. + " remarks)"
  2517. + " select "
  2518. + " :pkilncarbatchno,"
  2519. + " kilncarid,"
  2520. + " kilnid,"
  2521. + " productionlineid,"
  2522. + " procedureid,"
  2523. + " procedurecode,"
  2524. + " procedurename,"
  2525. + " proceduremodel,"
  2526. + " modeltype,"
  2527. + " piecetype,"
  2528. + " kilncarstatus,"
  2529. + " :puserID,"
  2530. + " :puserCode,"
  2531. + " :puserName,"
  2532. + " loadingtime,"
  2533. + " intokilntime,"
  2534. + " outkilntime,"
  2535. + " unloadingtime,"
  2536. + " :paccountdate,"
  2537. + " :paccountid,"
  2538. + " :pcreateuserid,"
  2539. + " :pupdateuserid,"
  2540. + " :createtime,"
  2541. + " :remarks"
  2542. + " from tp_pm_kilncarstatus"
  2543. + " where kilncarid = :pkilncarid";
  2544. #endregion
  2545. #region 参数
  2546. OracleParameter[] paras = new OracleParameter[] {
  2547. new OracleParameter(":pkilncarbatchno",OracleDbType.Varchar2,kilnCarBatchNo,ParameterDirection.Input),
  2548. new OracleParameter(":puserID",OracleDbType.Int32,workUserID,ParameterDirection.Input),
  2549. new OracleParameter(":puserCode",OracleDbType.Varchar2,workUserCode,ParameterDirection.Input),
  2550. new OracleParameter(":puserName",OracleDbType.Varchar2,workUserName,ParameterDirection.Input),
  2551. new OracleParameter(":paccountdate",OracleDbType.Date,accountDate,ParameterDirection.Input),
  2552. new OracleParameter(":paccountid",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  2553. new OracleParameter(":pcreateuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  2554. new OracleParameter(":pupdateuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  2555. new OracleParameter(":pkilncarid",OracleDbType.Int32,kilnCarID,ParameterDirection.Input),
  2556. new OracleParameter(":remarks",OracleDbType.Varchar2,remarks,ParameterDirection.Input),
  2557. new OracleParameter(":createtime",OracleDbType.Date,Convert.ToDateTime(createtime),ParameterDirection.Input),
  2558. };
  2559. #endregion
  2560. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  2561. // 保存失败
  2562. if (result != Constant.INT_IS_ONE)
  2563. {
  2564. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  2565. }
  2566. // 保存成功返回null
  2567. return null;
  2568. }
  2569. /// <summary>
  2570. /// 插入窑车生产数据表
  2571. /// </summary>
  2572. /// <param name="oracleTrConn">连接对象</param>
  2573. /// <param name="accountDate">账务日期</param>
  2574. /// <param name="kilnCarID">窑车ID</param>
  2575. /// <param name="kilnCarBatchNo">窑车批次号</param>
  2576. /// <param name="workUserID">生产工号ID</param>
  2577. /// <param name="workUserCode">生产工号Code</param>
  2578. /// <param name="workUserName">生产工号Name</param>
  2579. /// <param name="sUserInfo">用户基本信息</param>
  2580. /// <returns>string</returns>
  2581. private static string AddKilnCarData(IDBTransaction oracleTrConn,
  2582. DateTime accountDate,
  2583. int kilnCarID,
  2584. string kilnCarBatchNo,
  2585. int workUserID,
  2586. string workUserCode,
  2587. string workUserName,
  2588. string remarks,
  2589. SUserInfo sUserInfo, int? ClassesSettingID)
  2590. {
  2591. #region SQL
  2592. string sql = "insert into tp_pm_kilncardata"
  2593. + " (kilncarbatchno,"
  2594. + " kilncarid,"
  2595. + " kilnid,"
  2596. + " productionlineid,"
  2597. + " procedureid,"
  2598. + " procedurecode,"
  2599. + " procedurename,"
  2600. + " proceduremodel,"
  2601. + " modeltype,"
  2602. + " piecetype,"
  2603. + " kilncarstatus,"
  2604. + " UserID,"
  2605. + " UserCode,"
  2606. + " UserName,"
  2607. + " loadingtime,"
  2608. + " intokilntime,"
  2609. + " outkilntime,"
  2610. + " unloadingtime,"
  2611. + " accountdate,"
  2612. + " accountid,"
  2613. + " createuserid,"
  2614. + " updateuserid,"
  2615. + " classesSettingID,"
  2616. + " remarks)"
  2617. + " select "
  2618. + " :pkilncarbatchno,"
  2619. + " kilncarid,"
  2620. + " kilnid,"
  2621. + " productionlineid,"
  2622. + " procedureid,"
  2623. + " procedurecode,"
  2624. + " procedurename,"
  2625. + " proceduremodel,"
  2626. + " modeltype,"
  2627. + " piecetype,"
  2628. + " kilncarstatus,"
  2629. + " :puserID,"
  2630. + " :puserCode,"
  2631. + " :puserName,"
  2632. + " loadingtime,"
  2633. + " intokilntime,"
  2634. + " outkilntime,"
  2635. + " unloadingtime,"
  2636. + " :paccountdate,"
  2637. + " :paccountid,"
  2638. + " :pcreateuserid,"
  2639. + " :pupdateuserid,"
  2640. + " :classesSettingID,"
  2641. + " :remarks"
  2642. + " from tp_pm_kilncarstatus"
  2643. + " where kilncarid = :pkilncarid";
  2644. #endregion
  2645. #region 参数
  2646. OracleParameter[] paras = new OracleParameter[] {
  2647. new OracleParameter(":classesSettingID",OracleDbType.Int32,ClassesSettingID,ParameterDirection.Input),
  2648. new OracleParameter(":pkilncarbatchno",OracleDbType.Varchar2,kilnCarBatchNo,ParameterDirection.Input),
  2649. new OracleParameter(":puserID",OracleDbType.Int32,workUserID,ParameterDirection.Input),
  2650. new OracleParameter(":puserCode",OracleDbType.Varchar2,workUserCode,ParameterDirection.Input),
  2651. new OracleParameter(":puserName",OracleDbType.Varchar2,workUserName,ParameterDirection.Input),
  2652. new OracleParameter(":paccountdate",OracleDbType.Date,accountDate,ParameterDirection.Input),
  2653. new OracleParameter(":paccountid",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  2654. new OracleParameter(":pcreateuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  2655. new OracleParameter(":pupdateuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  2656. new OracleParameter(":pkilncarid",OracleDbType.Int32,kilnCarID,ParameterDirection.Input),
  2657. new OracleParameter(":remarks",OracleDbType.Varchar2,remarks,ParameterDirection.Input),
  2658. };
  2659. #endregion
  2660. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  2661. // 保存失败
  2662. if (result != Constant.INT_IS_ONE)
  2663. {
  2664. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  2665. }
  2666. // 保存成功返回null
  2667. return null;
  2668. }
  2669. /// <summary>
  2670. /// 插入窑车产品表
  2671. /// </summary>
  2672. /// <param name="oracleTrConn">连接对象</param>
  2673. /// <param name="barcode">条码</param>
  2674. /// <param name="kilnCarID">窑车号</param>
  2675. /// <param name="goodsID">产品ID</param>
  2676. /// <param name="KilnCarPosition">窑车位置</param>
  2677. /// <param name="kilnCarBatchNo">装车批次</param>
  2678. /// <param name="sUserInfo">用户基本信息</param>
  2679. /// <returns>string</returns>
  2680. private static string AddKilnCarGoods(IDBTransaction oracleTrConn, string barcode, int kilnCarID, int goodsID, int KilnCarPosition, string kilnCarBatchNo, int workUserID,
  2681. string workUserCode,
  2682. string workUserName, SUserInfo sUserInfo)
  2683. {
  2684. string sqlExist = "select 1 from tp_pm_kilncargoods where barcode=:barcode and accountid=:accountid";
  2685. OracleParameter[] parasExist = new OracleParameter[] {
  2686. new OracleParameter(":barcode",barcode),
  2687. new OracleParameter(":accountid",sUserInfo.AccountID),
  2688. };
  2689. oracleTrConn.ExecuteNonQuery(sqlExist, parasExist);
  2690. DataSet dsExist = oracleTrConn.GetSqlResultToDs(sqlExist, parasExist);
  2691. if (dsExist != null && dsExist.Tables[0].Rows.Count == 0)
  2692. {
  2693. string sql = "insert into tp_pm_kilncargoods"
  2694. + " (barcode,"
  2695. + " kilncarid,"
  2696. + " goodsid,"
  2697. + " kilncarposition,"
  2698. + " kilncarbatchno,"
  2699. + " accountid,"
  2700. + " userid,"
  2701. + " usercode,"
  2702. + " username,"
  2703. + " createuserid,"
  2704. + " updateuserid)"
  2705. + " values"
  2706. + " (:barcode,"
  2707. + " :kilncarid,"
  2708. + " :goodsid,"
  2709. + " :kilncarposition,"
  2710. + " :kilncarbatchno,"
  2711. + " :accountid,"
  2712. + " :userid,"
  2713. + " :usercode,"
  2714. + " :username,"
  2715. + " :createuserid,"
  2716. + " :updateuserid)";
  2717. #region 参数
  2718. OracleParameter[] paras = new OracleParameter[] {
  2719. new OracleParameter(":barcode",barcode),
  2720. new OracleParameter(":kilncarid",kilnCarID),
  2721. new OracleParameter(":goodsid",goodsID),
  2722. new OracleParameter(":kilncarposition",KilnCarPosition),
  2723. new OracleParameter(":kilncarbatchno",kilnCarBatchNo),
  2724. new OracleParameter(":accountid",sUserInfo.AccountID),
  2725. new OracleParameter(":createuserid",sUserInfo.UserID),
  2726. new OracleParameter(":updateuserid",sUserInfo.UserID),
  2727. new OracleParameter(":userid",workUserID),
  2728. new OracleParameter(":usercode",workUserCode),
  2729. new OracleParameter(":username",workUserName),
  2730. };
  2731. #endregion
  2732. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  2733. // 保存失败
  2734. if (result != Constant.INT_IS_ONE)
  2735. {
  2736. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  2737. }
  2738. }
  2739. // 保存成功返回null
  2740. return null;
  2741. }
  2742. /// <summary>
  2743. /// 查询本次批次号
  2744. /// </summary>
  2745. /// <param name="oracleTrConn">连接对象</param>
  2746. /// <param name="kilnCarID">窑车ID</param>
  2747. /// <returns>string</returns>
  2748. private static string GetKilnCarBatchNoByKilnCarID(IDBTransaction oracleTrConn, int kilnCarID)
  2749. {
  2750. string sql = "SELECT Max(KilnCarBatchNo) FROM TP_PM_KilnCarGoods where KilnCarID = :kilnCarID";
  2751. #region 参数
  2752. OracleParameter[] paras = new OracleParameter[] {
  2753. new OracleParameter(":kilnCarID",kilnCarID),
  2754. };
  2755. #endregion
  2756. string batchNo = oracleTrConn.GetSqlResultToStr(sql, paras);
  2757. if (!string.IsNullOrEmpty(batchNo))
  2758. {
  2759. return batchNo;
  2760. }
  2761. else
  2762. {
  2763. // 自动生成窑车烧成批次号
  2764. //return System.Guid.NewGuid().ToString().ToUpper();
  2765. return GetFiredKilnCarBatchNo(oracleTrConn, kilnCarID);
  2766. }
  2767. }
  2768. /// <summary>
  2769. /// 自动生成窑车烧成批次号
  2770. /// </summary>
  2771. /// <param name="oracleTrConn"></param>
  2772. /// <param name="kilnCarID"></param>
  2773. /// <returns></returns>
  2774. public static string GetFiredKilnCarBatchNo(IDBTransaction oracleTrConn, int kilnCarID)
  2775. {
  2776. DateTime now = DateTime.Now.Date;
  2777. string sqlString = "select k.kilnid, k.kilncode, k.fireddate, k.firedbatchno, kc.kilncarcode\n" +
  2778. " from TP_MST_Kiln k\n" +
  2779. " inner join tp_mst_kilncar kc\n" +
  2780. " on k.kilnid = kc.kilnid\n" +
  2781. " where kc.kilncarid = :kilncarid\n" +
  2782. //" and k.fireddate = :fireddate"
  2783. " for update";
  2784. OracleParameter[] paras = new OracleParameter[] {
  2785. new OracleParameter(":kilncarid",kilnCarID),
  2786. //new OracleParameter(":fireddate",now),
  2787. };
  2788. DataTable dt = oracleTrConn.GetSqlResultToDt(sqlString, paras);
  2789. if (dt == null || dt.Rows.Count == 0)
  2790. {
  2791. // 窑车、窑炉不存在
  2792. return null;
  2793. }
  2794. int kilnid = Convert.ToInt32(dt.Rows[0]["kilnid"]);
  2795. string kilncode = dt.Rows[0]["kilncode"] + "";
  2796. string kilncarcode = dt.Rows[0]["kilncarcode"] + "";
  2797. int firedbatchno = 0;
  2798. if (dt.Rows[0]["fireddate"] == null || dt.Rows[0]["fireddate"] == DBNull.Value)
  2799. {
  2800. firedbatchno = -1;
  2801. }
  2802. else
  2803. {
  2804. DateTime fireddate = Convert.ToDateTime(dt.Rows[0]["fireddate"]);
  2805. if (now > fireddate)
  2806. {
  2807. firedbatchno = -1;
  2808. }
  2809. }
  2810. if (firedbatchno < 0)
  2811. {
  2812. // 当日第一车
  2813. sqlString = "update TP_MST_Kiln k\n" +
  2814. " set k.fireddate = :fireddate, k.firedbatchno = 1\n" +
  2815. " where k.kilnid = :kilnid";
  2816. paras = new OracleParameter[] {
  2817. new OracleParameter(":kilnid",kilnid),
  2818. new OracleParameter(":fireddate",now),
  2819. };
  2820. oracleTrConn.ExecuteNonQuery(sqlString, paras);
  2821. return $"{kilncode}#{kilncarcode}#{now.ToString("yyyyMMdd")}#001";
  2822. }
  2823. firedbatchno = Convert.ToInt32(dt.Rows[0]["firedbatchno"]) + 1;
  2824. sqlString = "update TP_MST_Kiln k\n" +
  2825. " set k.firedbatchno = k.firedbatchno + 1\n" +
  2826. " where k.kilnid = :kilnid";
  2827. paras = new OracleParameter[] {
  2828. new OracleParameter(":kilnid",kilnid),
  2829. };
  2830. oracleTrConn.ExecuteNonQuery(sqlString, paras);
  2831. return $"{kilncode}#{kilncarcode}#{now.ToString("yyyyMMdd")}#{firedbatchno.ToString("000")}";
  2832. }
  2833. /// <summary>
  2834. /// 插入窑车状态表
  2835. /// </summary>
  2836. /// <param name="oracleTrConn">连接对象</param>
  2837. /// <param name="procedure">工序ID</param>
  2838. /// <param name="kilnCarID">窑车ID</param>
  2839. /// <param name="kilnID">窑炉ID</param>
  2840. /// <param name="sUserInfo">用户基本信息</param>
  2841. /// <returns>string</returns>
  2842. private static string AddkilnCarStatus(IDBTransaction oracleTrConn, ProcedureEntity procedure, int kilnCarID, int kilnID, string kilnCarBatchNo, SUserInfo sUserInfo)
  2843. {
  2844. #region SQL
  2845. string sql = " insert into tp_pm_kilncarstatus "
  2846. + " (kilncarid, "
  2847. + " kilnid, "
  2848. + " productionlineid, "
  2849. + " procedureid, "
  2850. + " procedurecode, "
  2851. + " procedurename, "
  2852. + " proceduremodel, "
  2853. + " modeltype, "
  2854. + " piecetype, "
  2855. + " kilncarstatus, "
  2856. + " loadingtime, "
  2857. + " accountid, "
  2858. + " createuserid, "
  2859. + " updateuserid,kilnCarBatchNo) "
  2860. + " values "
  2861. + " (:kilncarid, "
  2862. + " :kilnid, "
  2863. + " :productionlineid, "
  2864. + " :procedureid, "
  2865. + " :procedurecode, "
  2866. + " :procedurename, "
  2867. + " :proceduremodel, "
  2868. + " :modeltype, "
  2869. + " :piecetype, "
  2870. + " '0', "
  2871. + " sysdate, "
  2872. + " :accountid, "
  2873. + " :createuserid, "
  2874. + " :updateuserid,:kilnCarBatchNo)";
  2875. #endregion
  2876. #region 参数
  2877. OracleParameter[] paras = new OracleParameter[] {
  2878. new OracleParameter(":kilncarid",kilnCarID),
  2879. new OracleParameter(":kilnid",kilnID),
  2880. new OracleParameter(":productionlineid",procedure.ProductionLineID),
  2881. new OracleParameter(":procedureid",procedure.ProcedureID),
  2882. new OracleParameter(":procedurecode",procedure.ProcedureCode),
  2883. new OracleParameter(":procedurename",procedure.ProcedureName),
  2884. new OracleParameter(":proceduremodel",procedure.ProcedureModel),
  2885. new OracleParameter(":modeltype",procedure.ModelType),
  2886. new OracleParameter(":piecetype",procedure.PieceType),
  2887. new OracleParameter(":accountID",sUserInfo.AccountID),
  2888. new OracleParameter(":createuserid",sUserInfo.UserID),
  2889. new OracleParameter(":updateuserid",sUserInfo.UserID),
  2890. new OracleParameter(":kilnCarBatchNo",kilnCarBatchNo),
  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. // 保存成功返回null
  2900. return null;
  2901. }
  2902. /// <summary>
  2903. /// 更新窑车状态表中的对应的时间
  2904. /// </summary>
  2905. /// <param name="oracleTrConn">数据连接</param>
  2906. /// <param name="kilnCarID">窑车ID</param>
  2907. /// <param name="pModelType">操作类型</param>
  2908. /// <param name="sUserInfo">用户基本信息</param>
  2909. /// <returns>
  2910. /// 张国印 2014.10.04 新建
  2911. /// </returns>
  2912. private static string UpdatekilnCarStatus(IDBTransaction oracleTrConn, int kilnCarID, Constant.ProcedureModelType pModelType, SUserInfo sUserInfo, ProcedureEntity procedure, string kilnCarBatchNo)
  2913. {
  2914. if (pModelType == Constant.ProcedureModelType.LoadCar)
  2915. {
  2916. //procedure.ProcedureID,
  2917. //procedure.ProcedureCode,
  2918. //procedure.ProcedureName,
  2919. //procedure.ModelType
  2920. #region 装窑车操作时,更新tp_pm_kilncarstatus的装车时间
  2921. #region SQL语句和参数
  2922. string sql = " Update tp_pm_kilncarstatus Set"
  2923. + " KilnCarStatus = :pKilnCarStatus, "
  2924. + " LoadingTime = sysdate, "
  2925. + " IntoKilnTime = null, "
  2926. + " OutKilnTime = null, "
  2927. + " UnloadingTime = null, "
  2928. + " UpdateUserID = :pUpdateUserID, "
  2929. + " ProcedureID = :ProcedureID, "
  2930. + " ProcedureCode = :ProcedureCode, "
  2931. + " ProcedureName = :ProcedureName, "
  2932. + " ModelType = :ModelType, "
  2933. + " kilnCarBatchNo = :kilnCarBatchNo "
  2934. + " Where KilnCarID = :pKilnCarID And AccountID = :pAccountID";
  2935. OracleParameter[] paras = new OracleParameter[]
  2936. {
  2937. new OracleParameter(":pKilnCarStatus", OracleDbType.Int32, 0, ParameterDirection.Input),
  2938. new OracleParameter(":pUpdateUserID", OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input),
  2939. new OracleParameter(":pKilnCarID", OracleDbType.Int32, kilnCarID, ParameterDirection.Input),
  2940. new OracleParameter(":pAccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  2941. new OracleParameter(":ProcedureID", OracleDbType.Int32, procedure.ProcedureID, ParameterDirection.Input),
  2942. new OracleParameter(":ProcedureCode", OracleDbType.Varchar2, procedure.ProcedureCode, ParameterDirection.Input),
  2943. new OracleParameter(":ProcedureName", OracleDbType.Varchar2, procedure.ProcedureName, ParameterDirection.Input),
  2944. new OracleParameter(":ModelType", OracleDbType.Int32, procedure.ModelType, ParameterDirection.Input),
  2945. new OracleParameter(":kilnCarBatchNo", OracleDbType.Varchar2, kilnCarBatchNo, ParameterDirection.Input),
  2946. };
  2947. #endregion
  2948. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  2949. // 保存失败
  2950. if (result != Constant.INT_IS_ONE)
  2951. {
  2952. return string.Format(Messages.MSG_CMN_W001, "窑车状态", "保存");
  2953. }
  2954. #endregion
  2955. }
  2956. else if (pModelType == Constant.ProcedureModelType.IntoKiln)
  2957. {
  2958. #region 入窑操作时,更新tp_pm_kilncarstatus的入窑时间
  2959. #region SQL语句和参数
  2960. string sql = " Update tp_pm_kilncarstatus Set"
  2961. + " KilnCarStatus = :pKilnCarStatus, "
  2962. + " IntoKilnTime = sysdate, "
  2963. + " UpdateUserID = :pUpdateUserID, "
  2964. + " ProcedureID = :ProcedureID, "
  2965. + " ProcedureCode = :ProcedureCode, "
  2966. + " ProcedureName = :ProcedureName, "
  2967. + " ModelType = :ModelType "
  2968. + " Where KilnCarID = :pKilnCarID And AccountID = :pAccountID";
  2969. OracleParameter[] paras = new OracleParameter[]
  2970. {
  2971. new OracleParameter(":pKilnCarStatus", OracleDbType.Int32, 1, ParameterDirection.Input),
  2972. new OracleParameter(":pUpdateUserID", OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input),
  2973. new OracleParameter(":pKilnCarID", OracleDbType.Int32, kilnCarID, ParameterDirection.Input),
  2974. new OracleParameter(":pAccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  2975. new OracleParameter(":ProcedureID", OracleDbType.Int32, procedure.ProcedureID, ParameterDirection.Input),
  2976. new OracleParameter(":ProcedureCode", OracleDbType.Varchar2, procedure.ProcedureCode, ParameterDirection.Input),
  2977. new OracleParameter(":ProcedureName", OracleDbType.Varchar2, procedure.ProcedureName, ParameterDirection.Input),
  2978. new OracleParameter(":ModelType", OracleDbType.Int32, procedure.ModelType, ParameterDirection.Input),
  2979. };
  2980. #endregion
  2981. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  2982. // 保存失败
  2983. if (result != Constant.INT_IS_ONE)
  2984. {
  2985. return string.Format(Messages.MSG_CMN_W001, "窑车状态", "保存");
  2986. }
  2987. #endregion
  2988. }
  2989. else if (pModelType == Constant.ProcedureModelType.OutKiln)
  2990. {
  2991. #region 出窑操作时,更新tp_pm_kilncarstatus的出窑时间
  2992. #region SQL语句和参数
  2993. string sql = " Update tp_pm_kilncarstatus Set"
  2994. + " OutKilnTime = sysdate, "
  2995. + " UpdateUserID = :pUpdateUserID, "
  2996. + " ProcedureID = :ProcedureID, "
  2997. + " ProcedureCode = :ProcedureCode, "
  2998. + " ProcedureName = :ProcedureName, "
  2999. + " ModelType = :ModelType "
  3000. + " Where KilnCarID = :pKilnCarID And AccountID = :pAccountID";
  3001. OracleParameter[] paras = new OracleParameter[]
  3002. {
  3003. new OracleParameter(":pUpdateUserID", OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input),
  3004. new OracleParameter(":pKilnCarID", OracleDbType.Int32, kilnCarID, ParameterDirection.Input),
  3005. new OracleParameter(":pAccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  3006. new OracleParameter(":ProcedureID", OracleDbType.Int32, procedure.ProcedureID, ParameterDirection.Input),
  3007. new OracleParameter(":ProcedureCode", OracleDbType.Varchar2, procedure.ProcedureCode, ParameterDirection.Input),
  3008. new OracleParameter(":ProcedureName", OracleDbType.Varchar2, procedure.ProcedureName, ParameterDirection.Input),
  3009. new OracleParameter(":ModelType", OracleDbType.Int32, procedure.ModelType, ParameterDirection.Input),
  3010. };
  3011. #endregion
  3012. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  3013. // 保存失败
  3014. if (result != Constant.INT_IS_ONE)
  3015. {
  3016. return string.Format(Messages.MSG_CMN_W001, "窑车状态", "保存");
  3017. }
  3018. #endregion
  3019. }
  3020. else if (pModelType == Constant.ProcedureModelType.UnloadCar)
  3021. {
  3022. #region 卸窑车操作时,更新tp_pm_kilncarstatus的卸窑车时间
  3023. #region SQL语句和参数
  3024. string sql = " Update tp_pm_kilncarstatus Set"
  3025. + " KilnCarStatus = :pKilnCarStatus, "
  3026. //+ " LoadingTime = null, "
  3027. //+ " IntoKilnTime = null, "
  3028. //+ " OutKilnTime = null, "
  3029. + " UnloadingTime = sysdate, "
  3030. + " UpdateUserID = :pUpdateUserID, "
  3031. + " ProcedureID = :ProcedureID, "
  3032. + " ProcedureCode = :ProcedureCode, "
  3033. + " ProcedureName = :ProcedureName, "
  3034. + " ModelType = :ModelType "
  3035. + " Where KilnCarID = :pKilnCarID And AccountID = :pAccountID";
  3036. OracleParameter[] paras = new OracleParameter[]
  3037. {
  3038. new OracleParameter(":pKilnCarStatus", OracleDbType.Int32, 0, ParameterDirection.Input),
  3039. new OracleParameter(":pUpdateUserID", OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input),
  3040. new OracleParameter(":pKilnCarID", OracleDbType.Int32, kilnCarID, ParameterDirection.Input),
  3041. new OracleParameter(":pAccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  3042. new OracleParameter(":ProcedureID", OracleDbType.Int32, procedure.ProcedureID, ParameterDirection.Input),
  3043. new OracleParameter(":ProcedureCode", OracleDbType.Varchar2, procedure.ProcedureCode, ParameterDirection.Input),
  3044. new OracleParameter(":ProcedureName", OracleDbType.Varchar2, procedure.ProcedureName, ParameterDirection.Input),
  3045. new OracleParameter(":ModelType", OracleDbType.Int32, procedure.ModelType, ParameterDirection.Input),
  3046. };
  3047. #endregion
  3048. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  3049. // 保存失败
  3050. if (result != Constant.INT_IS_ONE)
  3051. {
  3052. return string.Format(Messages.MSG_CMN_W001, "窑车状态", "保存");
  3053. }
  3054. #endregion
  3055. }
  3056. // 保存成功返回null
  3057. return string.Empty;
  3058. }
  3059. /// <summary>
  3060. /// 校验窑车是否可用
  3061. /// </summary>
  3062. /// <param name="oracleTrConn">连接对象</param>
  3063. /// <param name="pProcedureId">工序ID</param>
  3064. /// <param name="kilnCarCode">窑车号</param>
  3065. /// <param name="pModelType">操作类型</param>
  3066. /// <param name="sUserInfo">用户基本信息</param>
  3067. /// <param name="kilnCarStatus">窑车状态</param>
  3068. /// <returns>string</returns>
  3069. private static string CheckKilnCarrStatus(IDBTransaction oracleTrConn, int pProcedureId, string kilnCarCode, int pModelType, SUserInfo sUserInfo, out string kilnCarStatus)
  3070. {
  3071. kilnCarStatus = string.Empty;
  3072. OracleParameter[] paras = new OracleParameter[]{
  3073. new OracleParameter("in_accountID",OracleDbType.Int32, sUserInfo.AccountID,ParameterDirection.Input),
  3074. new OracleParameter("in_kilnCarCode",OracleDbType.NVarchar2, kilnCarCode,ParameterDirection.Input),
  3075. new OracleParameter("in_modelType",OracleDbType.Int32, pModelType,ParameterDirection.Input),
  3076. new OracleParameter("out_errMsg",OracleDbType.NVarchar2,2000,null,ParameterDirection.Output),
  3077. new OracleParameter("out_result",OracleDbType.RefCursor, ParameterDirection.Output),
  3078. new OracleParameter("in_procedureid",OracleDbType.Int32, pProcedureId,ParameterDirection.Input),
  3079. // 验证能否卸窑
  3080. new OracleParameter("in_UserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input),
  3081. };
  3082. DataSet returnDataSet = oracleTrConn.ExecStoredProcedure("PRO_PM_CheckKilnCar", paras);
  3083. string errMsg = paras[3].Value.ToString() == "null" ? string.Empty : paras[3].Value.ToString();
  3084. if (string.IsNullOrEmpty(errMsg))
  3085. {
  3086. if (pModelType == (int)Constant.ProcedureModelType.LoadCar)
  3087. {
  3088. kilnCarStatus = returnDataSet.Tables[0].Rows[0]["KilnCarStatus"].ToString();
  3089. }
  3090. }
  3091. return errMsg;
  3092. }
  3093. /// <summary>
  3094. /// 添加生产者
  3095. /// </summary>
  3096. /// <param name="oracleTrConn">连接对象</param>
  3097. /// <param name="accountDate">账务日期</param>
  3098. /// <param name="productionDataID">生产数据ID</param>
  3099. /// <param name="workUserID">生产工号ID</param>
  3100. /// <param name="workUserCode">生产工号Code</param>
  3101. /// <param name="sUserInfo">用户基本信息</param>
  3102. /// <returns>string</returns>
  3103. private static string AddProducer(IDBTransaction oracleTrConn, DateTime accountDate, int productionDataID, int workUserID, string workUserCode, SUserInfo sUserInfo, ref int? ClassesSettingID)
  3104. {
  3105. // 参数
  3106. OracleParameter[] paras;
  3107. #region 查询班次配置表是否有数据
  3108. string sql = "select max(ClassesSettingID)"
  3109. + " from tp_pc_classessetting"
  3110. + " where Valueflag =1 and AccountID = :accountID"
  3111. + " and UserID = :userID"
  3112. + " and AccountDate = :accountDate";
  3113. paras = new OracleParameter[] {
  3114. new OracleParameter(":accountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  3115. new OracleParameter(":userID",OracleDbType.Int32,workUserID,ParameterDirection.Input),
  3116. new OracleParameter(":accountDate",OracleDbType.Date,accountDate,ParameterDirection.Input),
  3117. };
  3118. string countStr = oracleTrConn.GetSqlResultToStr(sql, paras);
  3119. int classesSettingID = 0;
  3120. #endregion
  3121. #region 没有班次配置数据,将工号所属员工插入班次配置表中
  3122. if (string.IsNullOrEmpty(countStr) || Constant.INT_IS_ZERO == int.Parse(countStr))
  3123. {
  3124. // 查询新插入的班次配置表ID
  3125. sql = "select SEQ_PC_ClassesSetting_ID.nextval from dual";
  3126. string idStr = oracleTrConn.GetSqlResultToStr(sql);
  3127. // 新插入的班次配置表ID
  3128. if (!string.IsNullOrEmpty(idStr))
  3129. {
  3130. classesSettingID = int.Parse(idStr);
  3131. }
  3132. else
  3133. {
  3134. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  3135. }
  3136. ClassesSettingID = Convert.ToInt32(classesSettingID);
  3137. #region 班次配置总表
  3138. sql = "insert into tp_pc_classessetting"
  3139. + " (ClassesSettingID,accountdate, "
  3140. + " userid, "
  3141. + " usercode, "
  3142. + " accountid, "
  3143. + " createuserid, "
  3144. + " updateuserid,ORGANIZATIONID)"
  3145. + " select "
  3146. + " :classesSettingID, "
  3147. + " :accountdate, "
  3148. + " USERID, "
  3149. + " UserCode, "
  3150. + " accountid,"
  3151. + " :createuserid,"
  3152. + " :updateuserid,ORGANIZATIONID"
  3153. + " from TP_MST_User"
  3154. + " where UserID = :userID";
  3155. paras = new OracleParameter[] {
  3156. new OracleParameter(":classesSettingID",OracleDbType.Int32,classesSettingID,ParameterDirection.Input),
  3157. new OracleParameter(":accountDate",OracleDbType.Date,accountDate,ParameterDirection.Input),
  3158. new OracleParameter(":createuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  3159. new OracleParameter(":updateuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  3160. new OracleParameter(":userID",OracleDbType.Int32,workUserID,ParameterDirection.Input),
  3161. };
  3162. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  3163. // 失败
  3164. if (result != Constant.INT_IS_ONE)
  3165. {
  3166. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  3167. }
  3168. #endregion
  3169. #region 班次配置明细SQL
  3170. sql = " insert into tp_pc_classesdetail"
  3171. + " (classessettingid,"
  3172. + " accountdate,"
  3173. + " userid,"
  3174. + " usercode,"
  3175. + " UJobsID,"
  3176. + " staffid,"
  3177. + " SJobsID,"
  3178. + " staffstatus,"
  3179. + " accountid,"
  3180. + " createuserid,"
  3181. + " updateuserid,Uorganizationid,Sorganizationid)"
  3182. + " select "
  3183. + " :classessettingid,"
  3184. + " :accountdate,"
  3185. + " userStaff.Userid,"
  3186. + " :usercode,"
  3187. + " userStaff.Ujobsid,"
  3188. + " userStaff.Staffid,"
  3189. + " staff.Jobs,"
  3190. + " staff.staffstatus,"
  3191. + " :accountID,"
  3192. + " :createuserid,"
  3193. + " :updateuserid,user2.organizationid,staff.organizationid"
  3194. + " from TP_MST_UserStaff userStaff"
  3195. + " inner join tp_hr_staff staff on staff.staffid = userStaff.Staffid"
  3196. + " inner join tp_mst_user user2 on userStaff.userid = user2.userid"
  3197. + " where (staff.StaffStatus = 1 or staff.StaffStatus = 2)"
  3198. + " and staff.ValueFlag = 1"
  3199. + " and staff.AccountID = :accountID"
  3200. + " and userStaff.UserID = :userID";
  3201. paras = new OracleParameter[] {
  3202. new OracleParameter(":classessettingid",OracleDbType.Int32,classesSettingID,ParameterDirection.Input),
  3203. new OracleParameter(":accountdate",OracleDbType.Date,accountDate,ParameterDirection.Input),
  3204. new OracleParameter(":usercode",OracleDbType.Varchar2,workUserCode,ParameterDirection.Input),
  3205. new OracleParameter(":accountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  3206. new OracleParameter(":createuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  3207. new OracleParameter(":updateuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  3208. new OracleParameter(":accountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  3209. new OracleParameter(":userID",OracleDbType.Int32,workUserID,ParameterDirection.Input),
  3210. };
  3211. result = oracleTrConn.ExecuteNonQuery(sql, paras);
  3212. // 失败
  3213. if (result == Constant.INT_IS_ZERO)
  3214. {
  3215. return string.Format(Messages.MSG_CMN_W007, "生产工号[" + workUserCode + "]没有配置生产员工");
  3216. }
  3217. #endregion
  3218. }
  3219. else
  3220. {
  3221. ClassesSettingID = int.Parse(countStr);
  3222. }
  3223. #endregion
  3224. //#region 将班次配置表中的数据插入生产者表中
  3225. //sql = "insert into tp_pm_producer"
  3226. // + " (productiondataid,"
  3227. // + " staffid,"
  3228. // + " userid,"
  3229. // + " usercode,"
  3230. // + " UJobsID,"
  3231. // + " staffstatus,"
  3232. // + " SJobsID,"
  3233. // + " classessettingid"
  3234. // + " )"
  3235. // + " select :productiondataid,"
  3236. // + " staffid,"
  3237. // + " userid,"
  3238. // + " usercode,"
  3239. // + " UJobsID,"
  3240. // + " staffstatus,"
  3241. // + " SJobsID,"
  3242. // + " :classessettingid"
  3243. // + " from tp_pc_classesdetail"
  3244. // + " where ValueFlag = 1"
  3245. // + " and classessettingid = (select max(ClassesSettingID)"
  3246. // + " from TP_PC_ClassesSetting"
  3247. // + " where ValueFlag = 1 and AccountDate=:accountDate"
  3248. // + " and UserID = :userID)";
  3249. //paras = new OracleParameter[] {
  3250. // new OracleParameter(":productiondataid",OracleDbType.Int32,productionDataID,ParameterDirection.Input),
  3251. // new OracleParameter(":classessettingid",OracleDbType.Int32,classesSettingID.ToString()=="0"?null:classesSettingID.ToString(),ParameterDirection.Input),
  3252. // new OracleParameter(":accountDate",OracleDbType.Date,accountDate,ParameterDirection.Input),
  3253. // new OracleParameter(":userID",OracleDbType.Int32,workUserID,ParameterDirection.Input),
  3254. // };
  3255. //int resultCount = oracleTrConn.ExecuteNonQuery(sql, paras);
  3256. //// 失败
  3257. //if (resultCount == Constant.INT_IS_ZERO)
  3258. //{
  3259. // return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  3260. //}
  3261. //#endregion
  3262. return null;
  3263. }
  3264. /// <summary>
  3265. /// 窑车生产者
  3266. /// </summary>
  3267. /// <param name="oracleTrConn">连接对象</param>
  3268. /// <param name="accountDate">账务日期</param>
  3269. /// <param name="kilnCarDataID">窑车生产数据ID</param>
  3270. /// <param name="workUserID">生产工号ID</param>
  3271. /// <param name="sUserInfo">用户基本信息</param>
  3272. /// <returns>string</returns>
  3273. private static string AddKilnCarProducer(IDBTransaction oracleTrConn, DateTime accountDate, int kilnCarDataID, int workUserID, SUserInfo sUserInfo)
  3274. {
  3275. // 参数
  3276. OracleParameter[] paras;
  3277. #region 将班次配置表中的数据插入生产者表中
  3278. string sql = "insert into TP_PM_KilnCarProducer"
  3279. + " (KilnCarDataID,"
  3280. + " staffid,"
  3281. + " userid,"
  3282. + " usercode,"
  3283. + " Ujobsid,"
  3284. + " staffstatus,"
  3285. + " Sjobsid,"
  3286. + " classessettingid"
  3287. + " )"
  3288. + " select :kilnCarDataID,"
  3289. + " staffid,"
  3290. + " userid,"
  3291. + " usercode,"
  3292. + " Ujobsid,"
  3293. + " staffstatus,"
  3294. + " Sjobsid,"
  3295. + " classessettingid"
  3296. + " from tp_pc_classesdetail"
  3297. + " where ValueFlag = 1"
  3298. + " and classessettingid = (select max(ClassesSettingID)"
  3299. + " from TP_PC_ClassesSetting"
  3300. + " where ValueFlag = 1 and AccountDate=:accountDate"
  3301. + " and UserID = :userID)";
  3302. paras = new OracleParameter[] {
  3303. new OracleParameter(":kilnCarDataID",OracleDbType.Int32,kilnCarDataID,ParameterDirection.Input),
  3304. new OracleParameter(":accountDate",OracleDbType.Date,accountDate,ParameterDirection.Input),
  3305. new OracleParameter(":userID",OracleDbType.Int32,workUserID,ParameterDirection.Input),
  3306. };
  3307. int resultCount = oracleTrConn.ExecuteNonQuery(sql, paras);
  3308. // 失败
  3309. if (resultCount == Constant.INT_IS_ZERO)
  3310. {
  3311. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  3312. }
  3313. #endregion
  3314. return null;
  3315. }
  3316. /// <summary>
  3317. /// 添加生产数据
  3318. /// </summary>
  3319. /// <param name="oracleTrConn">连接对象</param>
  3320. /// <param name="accountDate">账务日期</param>
  3321. /// <param name="productionData">生产数据</param>
  3322. /// <param name="sUserInfo">用户基本信息</param>
  3323. /// <returns>string</returns>
  3324. /// <remarks>
  3325. /// 陈冰 2014.09.18 新建
  3326. /// </remarks>
  3327. private static string AddProductionDataCreateTime(IDBTransaction oracleTrConn, DateTime accountDate, ProductionDataEntity productionData, SUserInfo sUserInfo, out string OutSpecialRepairflag)
  3328. {
  3329. #region 查出产品注浆日期,注浆工号ID,注浆工号编码,注浆次数,注浆模具编号,模具编号
  3330. // string selectSql = @"select TP_PM_GroutingProduct.GroutingDate,
  3331. // TP_PM_GroutingProduct.GroutingUserID,
  3332. // TP_PM_GroutingProduct.GroutingUserCode,
  3333. // TP_PM_GroutingProduct.GroutingNum,
  3334. // TP_PM_GroutingProduct.GroutingMouldCode,
  3335. // TP_PM_GroutingProduct.MouldCode,
  3336. // TP_PM_GroutingDaily.GroutingDailyID,
  3337. // TP_PM_GroutingDailyDetail.GroutingDailyDetailID,
  3338. // TP_PM_GroutingDaily.GroutingLineID,
  3339. // TP_PM_GroutingDaily.GroutingLineCode,
  3340. // TP_PM_GroutingDaily.GroutingLineName,
  3341. // TP_PM_GroutingDaily.GMouldTypeID,
  3342. // TP_PM_GroutingDaily.CanManyTimes,
  3343. // TP_PM_GroutingDailyDetail.GroutingLineDetailID
  3344. // from TP_PM_GroutingProduct
  3345. // left join TP_PM_GroutingDaily
  3346. // on TP_PM_GroutingProduct.GroutingDailyID=TP_PM_GroutingDaily.GroutingDailyID
  3347. // left join TP_PM_GroutingDailyDetail
  3348. // on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_GroutingDailyDetail.GroutingDailyID
  3349. // where TP_PM_GroutingProduct.barcode=:barcode";
  3350. //这地方连了两张表,为了成检的时候,次品在次新增
  3351. string returnVal = "";
  3352. string selectSql = @"select
  3353. GroutingDate,
  3354. GroutingUserID,
  3355. GroutingUserCode,
  3356. GroutingNum,
  3357. GroutingMouldCode,
  3358. MouldCode,
  3359. GroutingDailyID,
  3360. GroutingDailyDetailID,
  3361. GroutingLineID,
  3362. GroutingLineCode,
  3363. GroutingLineName,
  3364. GMouldTypeID,
  3365. CanManyTimes,
  3366. GroutingLineDetailID,
  3367. SpecialRepairflag
  3368. from tp_pm_inproduction where barcode=:barcode
  3369. union
  3370. select
  3371. GroutingDate,
  3372. GroutingUserID,
  3373. GroutingUserCode,
  3374. GroutingNum,
  3375. GroutingMouldCode,
  3376. MouldCode,
  3377. GroutingDailyID,
  3378. GroutingDailyDetailID,
  3379. GroutingLineID,
  3380. GroutingLineCode,
  3381. GroutingLineName,
  3382. GMouldTypeID,
  3383. CanManyTimes,
  3384. GroutingLineDetailID,
  3385. SpecialRepairflag
  3386. from TP_PM_InProductionTrash where barcode=:barcode
  3387. ";
  3388. OracleParameter[] selectparas = new OracleParameter[] {
  3389. new OracleParameter(":barcode",productionData.Barcode),
  3390. };
  3391. DataSet dsGroutingProduct = oracleTrConn.GetSqlResultToDs(selectSql, selectparas);
  3392. DateTime GroutingDate = new DateTime();
  3393. int GroutingUserID = 0, SpecialRepairflag = 0;
  3394. string GroutingUserCode = "";
  3395. int GroutingNum = 0;
  3396. string GroutingMouldCode = "";
  3397. string MouldCode = "";
  3398. //注浆日报ID
  3399. int GroutingDailyID = 0;
  3400. //注浆日报明细ID
  3401. int GroutingDailyDetailID = 0;
  3402. //成型生产线ID
  3403. int GroutingLineID = 0;
  3404. //成型生产线编码
  3405. string GroutingLineCode = "";
  3406. // 成型生产线名称
  3407. string GroutingLineName = "";
  3408. //成型线类型ID
  3409. int GMouldTypeID = 0;
  3410. // 能否多次注浆
  3411. int CanManyTimes = 0;
  3412. // 成型生产线明细ID
  3413. int GroutingLineDetailID = 0;
  3414. if (dsGroutingProduct != null && dsGroutingProduct.Tables[0].Rows.Count > 0)
  3415. {
  3416. GroutingDate = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
  3417. GroutingUserID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingUserID"]);
  3418. GroutingUserCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"].ToString();
  3419. GroutingNum = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"]);
  3420. GroutingMouldCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingMouldCode"].ToString();
  3421. MouldCode = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"].ToString();
  3422. GroutingDailyID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyID"]);
  3423. GroutingDailyDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyDetailID"]);
  3424. GroutingLineID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineID"]);
  3425. GroutingLineCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineCode"].ToString();
  3426. GroutingLineName = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineName"].ToString();
  3427. GMouldTypeID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GMouldTypeID"]);
  3428. CanManyTimes = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["CanManyTimes"]);
  3429. GroutingLineDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineDetailID"]);
  3430. SpecialRepairflag = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["SpecialRepairflag"]);
  3431. returnVal = SpecialRepairflag.ToString();
  3432. }
  3433. #endregion
  3434. #region 更新窑炉窑车属性
  3435. if (productionData.ModelType != 1 && productionData.ModelType != 2 && productionData.ModelType != 3 && productionData.ModelType != 4)
  3436. {
  3437. DataSet ds = GetKilnCarInfo(oracleTrConn, productionData.Barcode, sUserInfo);
  3438. if (ds != null)
  3439. {
  3440. if (ds.Tables[0].Rows[0]["KilnID"].ToString() != "") //表示以前有过窑炉相关信息
  3441. {
  3442. productionData.KilnID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnID"]);
  3443. productionData.KilnCode = ds.Tables[0].Rows[0]["KilnCode"].ToString();
  3444. productionData.KilnName = ds.Tables[0].Rows[0]["KilnName"].ToString();
  3445. productionData.KilnCarID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarID"]);
  3446. productionData.KilnCarCode = ds.Tables[0].Rows[0]["KilnCarCode"].ToString();
  3447. productionData.KilnCarName = ds.Tables[0].Rows[0]["KilnCarName"].ToString();
  3448. productionData.KilnCarBatchNo = ds.Tables[0].Rows[0]["KilnCarBatchNo"].ToString();
  3449. productionData.KilnCarPosition = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarPosition"]);
  3450. }
  3451. }
  3452. }
  3453. #endregion
  3454. //string sql = "select createtime from TP_PM_KilnCarGoods"
  3455. // + " where KilnCarID=:KilnCarID and AccountID=:AccountID";
  3456. //OracleParameter[] paras = new OracleParameter[] {
  3457. // new OracleParameter(":KilnCarID",productionData.KilnCarID),
  3458. // new OracleParameter(":AccountID",sUserInfo.AccountID),
  3459. //};
  3460. //DataSet dsReturn = oracleTrConn.GetSqlResultToDs(sql, paras);
  3461. //if (dsReturn != null && dsReturn.Tables[0].Rows.Count > 0)
  3462. //{
  3463. // sql = "update TP_PM_ProductionData set "
  3464. // + " CreateTime=:CreateTime"
  3465. // + " where barcode=:barcode and ProcedureID=:ProcedureID and KilnCarID=:KilnCarID and AccountID=:AccountID";
  3466. // paras = new OracleParameter[] {
  3467. // new OracleParameter(":CreateTime",Convert.ToDateTime(dsReturn.Tables[0].Rows[0]["CreateTime"])),
  3468. // new OracleParameter(":barcode",productionData.Barcode),
  3469. // new OracleParameter(":ProcedureID",productionData.CompleteProcedureID),
  3470. // new OracleParameter(":KilnCarID",productionData.KilnCarID),
  3471. // new OracleParameter(":AccountID",sUserInfo.AccountID),
  3472. // };
  3473. // int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  3474. //}
  3475. #region SQL
  3476. string sql = "insert into tp_pm_productiondata"
  3477. + " ("
  3478. + " barcode,"
  3479. + " centralizedbatchno,"
  3480. + " productionlineid,"
  3481. + " productionlinecode,"
  3482. + " productionlinename,"
  3483. + " procedureid,"
  3484. + " procedurecode,"
  3485. + " procedurename,"
  3486. + " proceduremodel,"
  3487. + " modeltype,"
  3488. + " piecetype,"
  3489. + " isreworked,"
  3490. + " nodetype,"
  3491. + " ispublicbody,"
  3492. + " isrefire,"
  3493. + " organizationid,"
  3494. + " goodsid,"
  3495. + " goodscode,"
  3496. + " goodsname,"
  3497. + " userid,"
  3498. + " usercode,"
  3499. + " username,"
  3500. + " kilnid,"
  3501. + " kilncode,"
  3502. + " kilnname,"
  3503. + " kilncarid,"
  3504. + " kilncarcode,"
  3505. + " kilncarname,"
  3506. + " kilncarbatchno,"
  3507. + " kilncarposition,"
  3508. + " reworkprocedureid,"
  3509. + " reworkprocedurecode,"
  3510. + " reworkprocedurename,"
  3511. + " remarks,"
  3512. + " accountdate,"
  3513. + " accountid,"
  3514. + " GoodsLevelID,"
  3515. + " GoodsLevelTypeID,"
  3516. + " createuserid,"
  3517. + " updateuserid,"
  3518. + " GroutingDate,"
  3519. + " GroutingUserID,"
  3520. + " GroutingUserCode,"
  3521. + " GroutingNum,"
  3522. + " GroutingMouldCode,"
  3523. + " MouldCode,"
  3524. + "GroutingDailyID,"
  3525. + "GroutingDailyDetailID,"
  3526. + "GroutingLineID,"
  3527. + " GroutingLineCode,"
  3528. + "GroutingLineName,"
  3529. + "GMouldTypeID,"
  3530. + "CanManyTimes,"
  3531. + "GroutingLineDetailID,"
  3532. + "CreateTime,SpecialRepairflag"
  3533. + ")"
  3534. + " values"
  3535. + " ("
  3536. + " :barcode,"
  3537. + " :centralizedbatchno,"
  3538. + " :productionlineid,"
  3539. + " :productionlinecode,"
  3540. + " :productionlinename,"
  3541. + " :procedureid,"
  3542. + " :procedurecode,"
  3543. + " :procedurename,"
  3544. + " :proceduremodel,"
  3545. + " :modeltype,"
  3546. + " :piecetype,"
  3547. + " :isreworked,"
  3548. + " :nodetype,"
  3549. + " :ispublicbody,"
  3550. + " :isrefire,"
  3551. + " :organizationid,"
  3552. + " :goodsid,"
  3553. + " :goodscode,"
  3554. + " :goodsname,"
  3555. + " :userid,"
  3556. + " :usercode,"
  3557. + " :username,"
  3558. + " :kilnid,"
  3559. + " :kilncode,"
  3560. + " :kilnname,"
  3561. + " :kilncarid,"
  3562. + " :kilncarcode,"
  3563. + " :kilncarname,"
  3564. + " :kilncarbatchno,"
  3565. + " :kilncarposition,"
  3566. + " :reworkprocedureid,"
  3567. + " :reworkprocedurecode,"
  3568. + " :reworkprocedurename,"
  3569. + " :remarks,"
  3570. + " :accountdata,"
  3571. + " :accountid,"
  3572. + " :GoodsLevelID,"
  3573. + " :GoodsLevelTypeID,"
  3574. + " :createuserid,"
  3575. + " :updateuserid,"
  3576. + " :groutingdate,"
  3577. + " :groutinguserid,"
  3578. + " :groutingusercode,"
  3579. + " :groutingnum,"
  3580. + " :groutingmouldcode,"
  3581. + " :mouldcode,"
  3582. + ":groutingdailyid,"
  3583. + ":groutingdailydetailid,"
  3584. + ":groutinglineid,"
  3585. + " :groutinglinecode,"
  3586. + ":groutinglinename,"
  3587. + ":gmouldtypeid,"
  3588. + ":canmanytimes,"
  3589. + ":groutinglinedetailid,"
  3590. + ":CreateTime,:SpecialRepairflag"
  3591. + ")";
  3592. #endregion
  3593. #region OracleParameter
  3594. OracleParameter[] paras = new OracleParameter[] {
  3595. new OracleParameter(":barcode",productionData.Barcode),
  3596. new OracleParameter(":centralizedbatchno",productionData.CentralizedBatchNo),
  3597. new OracleParameter(":productionlineid",productionData.ProductionLineID),
  3598. new OracleParameter(":productionlinecode",productionData.ProductionLineCode),
  3599. new OracleParameter(":productionlinename",productionData.ProductionLineName),
  3600. new OracleParameter(":procedureid",productionData.CompleteProcedureID),
  3601. new OracleParameter(":procedurecode",productionData.ProcedureCode),
  3602. new OracleParameter(":procedurename",productionData.ProcedureName),
  3603. new OracleParameter(":proceduremodel",productionData.ProcedureModel),
  3604. new OracleParameter(":modeltype",productionData.ModelType),
  3605. new OracleParameter(":piecetype",productionData.PieceType),
  3606. new OracleParameter(":isreworked",productionData.IsReworked),
  3607. new OracleParameter(":nodetype",productionData.NodeType),
  3608. new OracleParameter(":ispublicbody",productionData.IsPublicBody),
  3609. new OracleParameter(":isrefire",productionData.IsReFire),
  3610. new OracleParameter(":organizationid",productionData.OrganizationID),
  3611. new OracleParameter(":goodsid",productionData.GoodsID),
  3612. new OracleParameter(":goodscode",productionData.GoodsCode),
  3613. new OracleParameter(":goodsname",productionData.GoodsName),
  3614. new OracleParameter(":userid",productionData.UserID),
  3615. new OracleParameter(":usercode",productionData.UserCode),
  3616. new OracleParameter(":username",productionData.UserName),
  3617. new OracleParameter(":kilnid",productionData.KilnID),
  3618. new OracleParameter(":kilncode",productionData.KilnCode),
  3619. new OracleParameter(":kilnname",productionData.KilnName),
  3620. new OracleParameter(":kilncarid",productionData.KilnCarID),
  3621. new OracleParameter(":kilncarcode",productionData.KilnCarCode),
  3622. new OracleParameter(":kilncarname",productionData.KilnCarName),
  3623. new OracleParameter(":kilncarbatchno",productionData.KilnCarBatchNo),
  3624. new OracleParameter(":kilncarposition",productionData.KilnCarPosition),
  3625. new OracleParameter(":reworkprocedureid",productionData.ReworkProcedureID),
  3626. new OracleParameter(":reworkprocedurecode",productionData.ReworkProcedureCode),
  3627. new OracleParameter(":reworkprocedurename",productionData.ReworkProcedureName),
  3628. new OracleParameter(":remarks",productionData.Remarks),
  3629. new OracleParameter(":accountdata",accountDate),
  3630. new OracleParameter(":accountid",sUserInfo.AccountID),
  3631. new OracleParameter(":GoodsLevelID",productionData.GoodsLevelID),
  3632. new OracleParameter(":GoodsLevelTypeID",productionData.GoodsLevelTypeID),
  3633. new OracleParameter(":createuserid",sUserInfo.UserID),
  3634. new OracleParameter(":updateuserid",sUserInfo.UserID),
  3635. new OracleParameter(":groutingdate",GroutingDate),
  3636. new OracleParameter(":groutinguserid",GroutingUserID),
  3637. new OracleParameter(":groutingusercode",GroutingUserCode),
  3638. new OracleParameter(":groutingnum",GroutingNum),
  3639. new OracleParameter(":groutingmouldcode",GroutingMouldCode),
  3640. new OracleParameter(":mouldcode",MouldCode),
  3641. new OracleParameter(":groutingdailyid",GroutingDailyID),
  3642. new OracleParameter(":groutingdailydetailid",GroutingDailyDetailID),
  3643. new OracleParameter(":groutinglineid",GroutingLineID),
  3644. new OracleParameter(":groutinglinecode",GroutingLineCode),
  3645. new OracleParameter(":groutinglinename",GroutingLineName),
  3646. new OracleParameter(":gmouldtypeid",GMouldTypeID),
  3647. new OracleParameter(":canmanytimes",CanManyTimes),
  3648. new OracleParameter(":groutinglinedetailid",GroutingLineDetailID),
  3649. new OracleParameter(":CreateTime",productionData.CreateTime),
  3650. new OracleParameter(":specialRepairflag",SpecialRepairflag),
  3651. };
  3652. #endregion
  3653. foreach (OracleParameter para in paras)
  3654. {
  3655. if (string.IsNullOrEmpty(para.Value + ""))
  3656. {
  3657. para.Value = DBNull.Value;
  3658. }
  3659. }
  3660. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  3661. OutSpecialRepairflag = returnVal;
  3662. // 失败
  3663. if (result != Constant.INT_IS_ONE)
  3664. {
  3665. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  3666. }
  3667. // 成功返回null
  3668. return null;
  3669. }
  3670. /// <summary>
  3671. /// 添加生产数据
  3672. /// </summary>
  3673. /// <param name="oracleTrConn">连接对象</param>
  3674. /// <param name="accountDate">账务日期</param>
  3675. /// <param name="productionData">生产数据</param>
  3676. /// <param name="sUserInfo">用户基本信息</param>
  3677. /// <param name="isSendBody">是否交坯</param>
  3678. /// <returns>string</returns>
  3679. /// <remarks>
  3680. /// 陈冰 2014.09.18 新建
  3681. /// xuwei 2019-09-17 修改
  3682. /// </remarks>
  3683. private static string AddProductionDataDeliverMud(IDBTransaction oracleTrConn, DateTime accountDate, ProductionDataEntity productionData, SUserInfo sUserInfo, out string OutSpecialRepairflag
  3684. , out DataSet outGroutingProduct, bool isSendBody = false)
  3685. {
  3686. #region 查出产品注浆日期,注浆工号ID,注浆工号编码,注浆次数,注浆模具编号,模具编号
  3687. string selectSql = "";
  3688. string returnVal = "";
  3689. //xuwei fix 2019-09-23 修正非交坯时 productionData.GroutingDailyDetailID 为空无法得到结果
  3690. //改用 条码查询
  3691. //selectSql = @"select GroutingDate,
  3692. // ClassesSettingID,
  3693. // UserID as GroutingUserID,
  3694. // UserCode as GroutingUserCode,
  3695. // GroutingCount as GroutingNum,
  3696. // GroutingMouldCode,
  3697. // MouldCode,
  3698. // GroutingDailyID,
  3699. // GroutingDailyDetailID,
  3700. // GroutingLineID,
  3701. // GroutingLineCode,
  3702. // GroutingLineName,
  3703. // GroutingLineDetailID,
  3704. // SpecialRepairflag,
  3705. // goodsid,
  3706. // goodscode,
  3707. // goodsname,
  3708. // GMouldTypeID,
  3709. // CanManyTimes,
  3710. // LogoID
  3711. // from tp_pm_GroutingDailyDetail
  3712. // where tp_pm_GroutingDailyDetail.GroutingDailyDetailID=:GroutingDailyDetailID";
  3713. //OracleParameter[] selectparas1 = new OracleParameter[] {
  3714. // new OracleParameter(":GroutingDailyDetailID",productionData.GroutingDailyDetailID),
  3715. //};
  3716. selectSql = @"select GroutingDate,
  3717. ClassesSettingID,
  3718. UserID as GroutingUserID,
  3719. UserCode as GroutingUserCode,
  3720. GroutingCount as GroutingNum,
  3721. GroutingMouldCode,
  3722. MouldCode,
  3723. GroutingDailyID,
  3724. GroutingDailyDetailID,
  3725. GroutingLineID,
  3726. GroutingLineCode,
  3727. GroutingLineName,
  3728. GroutingLineDetailID,
  3729. SpecialRepairflag,
  3730. goodsid,
  3731. goodscode,
  3732. goodsname,
  3733. GMouldTypeID,
  3734. CanManyTimes,
  3735. LogoID
  3736. from tp_pm_GroutingDailyDetail
  3737. where tp_pm_GroutingDailyDetail.Barcode=:Barcode";
  3738. OracleParameter[] selectparas1 = new OracleParameter[] {
  3739. new OracleParameter(":Barcode",productionData.Barcode),
  3740. };
  3741. //xuwei fix end
  3742. DataSet dsGroutingProduct = oracleTrConn.GetSqlResultToDs(selectSql, selectparas1);
  3743. DateTime GroutingDate = new DateTime();
  3744. int GroutingUserID = 0, GroutingNum = 0, GroutingDailyID = 0, GroutingDailyDetailID = 0, GroutingLineID = 0, GMouldTypeID = 0, CanManyTimes = 0, GroutingLineDetailID = 0, SpecialRepairflag = 0;
  3745. string GroutingUserCode = "", GroutingMouldCode = "", MouldCode = "", GroutingLineCode = "", GroutingLineName = "";
  3746. int? ClassesSettingID = null;
  3747. int? LogoID = null;
  3748. if (dsGroutingProduct != null && dsGroutingProduct.Tables[0].Rows.Count > 0)
  3749. {
  3750. GroutingDate = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
  3751. GroutingUserID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingUserID"]);
  3752. GroutingUserCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"].ToString();
  3753. GroutingNum = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"]);
  3754. GroutingMouldCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingMouldCode"].ToString();
  3755. MouldCode = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"].ToString();
  3756. GroutingDailyID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyID"]);
  3757. GroutingDailyDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyDetailID"]);
  3758. GroutingLineID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineID"]);
  3759. GroutingLineCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineCode"].ToString();
  3760. GroutingLineName = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineName"].ToString();
  3761. GMouldTypeID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GMouldTypeID"]);
  3762. CanManyTimes = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["CanManyTimes"]);
  3763. GroutingLineDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineDetailID"]);
  3764. SpecialRepairflag = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["SpecialRepairflag"]);
  3765. returnVal = SpecialRepairflag.ToString();
  3766. if (productionData.IsPublicBody.ToString() != "1")
  3767. ClassesSettingID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["ClassesSettingID"]);
  3768. else
  3769. ClassesSettingID = productionData.ClassesSettingID == null ? Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["ClassesSettingID"]) : productionData.ClassesSettingID;
  3770. if (dsGroutingProduct.Tables[0].Rows[0]["LogoID"] != DBNull.Value)
  3771. {
  3772. LogoID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["LogoID"]);
  3773. }
  3774. //xuwei fix begin
  3775. //2019-09-17
  3776. //更新注浆日报(交坯处理)
  3777. if (isSendBody)
  3778. {
  3779. selectSql = "update TP_PM_GroutingDailyDetail set ispublicbody=:ispublicbody, DELIVERFLAG=1,DELIVERTIME=sysdate,deliveruserid=:deliveruserid,deliverusercode=:deliverusercode where GroutingDailyDetailID=" + GroutingDailyDetailID;
  3780. OracleParameter[] paras2 = new OracleParameter[] {
  3781. new OracleParameter(":deliveruserid",productionData.UserID),
  3782. new OracleParameter(":deliverusercode",productionData.UserCode),
  3783. new OracleParameter(":ispublicbody",productionData.IsPublicBody),
  3784. };
  3785. oracleTrConn.ExecuteNonQuery(selectSql, paras2);
  3786. }
  3787. //更新 注浆日报 在产标识(BEGINNINGFLAG)
  3788. selectSql = "update TP_PM_GroutingDailyDetail set BEGINNINGFLAG = '1' where Barcode='" + productionData.Barcode + "'";
  3789. oracleTrConn.ExecuteNonQuery(selectSql);
  3790. //xuwei end
  3791. }
  3792. outGroutingProduct = dsGroutingProduct;
  3793. #endregion
  3794. #region 更新窑炉窑车属性
  3795. //if (productionData.ModelType != 1 && productionData.ModelType != 2 && productionData.ModelType != 3 && productionData.ModelType != 4)
  3796. //{
  3797. // DataSet ds = GetKilnCarInfo(oracleTrConn, productionData.Barcode, sUserInfo);
  3798. // if (ds != null)
  3799. // {
  3800. // if (ds.Tables[0].Rows[0]["KilnID"].ToString() != "") //表示以前有过窑炉相关信息
  3801. // {
  3802. // productionData.KilnID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnID"]);
  3803. // productionData.KilnCode = ds.Tables[0].Rows[0]["KilnCode"].ToString();
  3804. // productionData.KilnName = ds.Tables[0].Rows[0]["KilnName"].ToString();
  3805. // productionData.KilnCarID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarID"]);
  3806. // productionData.KilnCarCode = ds.Tables[0].Rows[0]["KilnCarCode"].ToString();
  3807. // productionData.KilnCarName = ds.Tables[0].Rows[0]["KilnCarName"].ToString();
  3808. // productionData.KilnCarBatchNo = ds.Tables[0].Rows[0]["KilnCarBatchNo"].ToString();
  3809. // productionData.KilnCarPosition = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarPosition"]);
  3810. // }
  3811. // }
  3812. //}
  3813. #endregion
  3814. #region SQL
  3815. string sql = "insert into tp_pm_productiondataIn"
  3816. + " (productiondataid,"
  3817. + " barcode,"
  3818. + " centralizedbatchno,"
  3819. + " productionlineid,"
  3820. + " productionlinecode,"
  3821. + " productionlinename,"
  3822. + " procedureid,"
  3823. + " procedurecode,"
  3824. + " procedurename,"
  3825. + " proceduremodel,"
  3826. + " modeltype,"
  3827. + " piecetype,"
  3828. + " isreworked,"
  3829. + " nodetype,"
  3830. + " ispublicbody,"
  3831. + " isrefire,"
  3832. + " organizationid,"
  3833. + " goodsid,"
  3834. + " goodscode,"
  3835. + " goodsname,"
  3836. + " userid,"
  3837. + " usercode,"
  3838. + " username,"
  3839. + " kilnid,"
  3840. + " kilncode,"
  3841. + " kilnname,"
  3842. + " kilncarid,"
  3843. + " kilncarcode,"
  3844. + " kilncarname,"
  3845. + " kilncarbatchno,"
  3846. + " kilncarposition,"
  3847. + " reworkprocedureid,"
  3848. + " reworkprocedurecode,"
  3849. + " reworkprocedurename,"
  3850. + " remarks,"
  3851. + " accountdate,"
  3852. + " accountid,"
  3853. + " GoodsLevelID,"
  3854. + " GoodsLevelTypeID,"
  3855. + " createuserid,"
  3856. + " updateuserid,"
  3857. + " GroutingDate,"
  3858. + " GroutingUserID,"
  3859. + " GroutingUserCode,"
  3860. + " GroutingNum,"
  3861. + " GroutingMouldCode,"
  3862. + " MouldCode,"
  3863. + "GroutingDailyID,"
  3864. + "GroutingDailyDetailID,"
  3865. + "GroutingLineID,"
  3866. + " GroutingLineCode,"
  3867. + "GroutingLineName,"
  3868. + "GMouldTypeID,"
  3869. + "CanManyTimes,"
  3870. + "GroutingLineDetailID,"
  3871. + "SpecialRepairflag,"
  3872. + "ClassesSettingID,"
  3873. + "LogoID"
  3874. + ")"
  3875. + " values"
  3876. + " (:productiondataid,"
  3877. + " :barcode,"
  3878. + " :centralizedbatchno,"
  3879. + " :productionlineid,"
  3880. + " :productionlinecode,"
  3881. + " :productionlinename,"
  3882. + " :procedureid,"
  3883. + " :procedurecode,"
  3884. + " :procedurename,"
  3885. + " :proceduremodel,"
  3886. + " :modeltype,"
  3887. + " :piecetype,"
  3888. + " :isreworked,"
  3889. + " :nodetype,"
  3890. + " :ispublicbody,"
  3891. + " :isrefire,"
  3892. + " :organizationid,"
  3893. + " :goodsid,"
  3894. + " :goodscode,"
  3895. + " :goodsname,"
  3896. + " :userid,"
  3897. + " :usercode,"
  3898. + " :username,"
  3899. + " :kilnid,"
  3900. + " :kilncode,"
  3901. + " :kilnname,"
  3902. + " :kilncarid,"
  3903. + " :kilncarcode,"
  3904. + " :kilncarname,"
  3905. + " :kilncarbatchno,"
  3906. + " :kilncarposition,"
  3907. + " :reworkprocedureid,"
  3908. + " :reworkprocedurecode,"
  3909. + " :reworkprocedurename,"
  3910. + " :remarks,"
  3911. + " :accountdata,"
  3912. + " :accountid,"
  3913. + " :GoodsLevelID,"
  3914. + " :GoodsLevelTypeID,"
  3915. + " :createuserid,"
  3916. + " :updateuserid,"
  3917. + " :groutingdate,"
  3918. + " :groutinguserid,"
  3919. + " :groutingusercode,"
  3920. + " :groutingnum,"
  3921. + " :groutingmouldcode,"
  3922. + " :mouldcode,"
  3923. + ":groutingdailyid,"
  3924. + ":groutingdailydetailid,"
  3925. + ":groutinglineid,"
  3926. + " :groutinglinecode,"
  3927. + ":groutinglinename,"
  3928. + ":gmouldtypeid,"
  3929. + ":canmanytimes,"
  3930. + ":groutinglinedetailid,"
  3931. + ":specialRepairflag,"
  3932. + ":classesSettingID,"
  3933. + ":LogoID"
  3934. + ")";
  3935. #endregion
  3936. #region OracleParameter
  3937. OracleParameter[] paras = new OracleParameter[] {
  3938. new OracleParameter(":classesSettingID",ClassesSettingID),
  3939. new OracleParameter(":productiondataid",productionData.ProductionDataID),
  3940. new OracleParameter(":barcode",productionData.Barcode),
  3941. new OracleParameter(":centralizedbatchno",productionData.CentralizedBatchNo),
  3942. new OracleParameter(":productionlineid",productionData.ProductionLineID),
  3943. new OracleParameter(":productionlinecode",productionData.ProductionLineCode),
  3944. new OracleParameter(":productionlinename",productionData.ProductionLineName),
  3945. new OracleParameter(":procedureid",productionData.CompleteProcedureID),
  3946. new OracleParameter(":procedurecode",productionData.ProcedureCode),
  3947. new OracleParameter(":procedurename",productionData.ProcedureName),
  3948. new OracleParameter(":proceduremodel",productionData.ProcedureModel),
  3949. new OracleParameter(":modeltype",productionData.ModelType),
  3950. new OracleParameter(":piecetype",productionData.PieceType),
  3951. new OracleParameter(":isreworked",productionData.IsReworked),
  3952. new OracleParameter(":nodetype",productionData.NodeType),
  3953. new OracleParameter(":ispublicbody",productionData.IsPublicBody),
  3954. new OracleParameter(":isrefire",productionData.IsReFire),
  3955. new OracleParameter(":organizationid",productionData.OrganizationID),
  3956. new OracleParameter(":goodsid",productionData.GoodsID),
  3957. new OracleParameter(":goodscode",productionData.GoodsCode),
  3958. new OracleParameter(":goodsname",productionData.GoodsName),
  3959. new OracleParameter(":userid",productionData.UserID),
  3960. new OracleParameter(":usercode",productionData.UserCode),
  3961. new OracleParameter(":username",productionData.UserName),
  3962. new OracleParameter(":kilnid",productionData.KilnID),
  3963. new OracleParameter(":kilncode",productionData.KilnCode),
  3964. new OracleParameter(":kilnname",productionData.KilnName),
  3965. new OracleParameter(":kilncarid",productionData.KilnCarID),
  3966. new OracleParameter(":kilncarcode",productionData.KilnCarCode),
  3967. new OracleParameter(":kilncarname",productionData.KilnCarName),
  3968. new OracleParameter(":kilncarbatchno",productionData.KilnCarBatchNo),
  3969. new OracleParameter(":kilncarposition",productionData.KilnCarPosition),
  3970. new OracleParameter(":reworkprocedureid",productionData.ReworkProcedureID),
  3971. new OracleParameter(":reworkprocedurecode",productionData.ReworkProcedureCode),
  3972. new OracleParameter(":reworkprocedurename",productionData.ReworkProcedureName),
  3973. new OracleParameter(":remarks",productionData.Remarks),
  3974. new OracleParameter(":accountdata",accountDate),
  3975. new OracleParameter(":accountid",sUserInfo.AccountID),
  3976. new OracleParameter(":GoodsLevelID",productionData.GoodsLevelID),
  3977. new OracleParameter(":GoodsLevelTypeID",productionData.GoodsLevelTypeID),
  3978. new OracleParameter(":createuserid",sUserInfo.UserID),
  3979. new OracleParameter(":updateuserid",sUserInfo.UserID),
  3980. new OracleParameter(":groutingdate",GroutingDate),
  3981. new OracleParameter(":groutinguserid",GroutingUserID),
  3982. new OracleParameter(":groutingusercode",GroutingUserCode),
  3983. new OracleParameter(":groutingnum",GroutingNum),
  3984. new OracleParameter(":groutingmouldcode",GroutingMouldCode),
  3985. new OracleParameter(":mouldcode",MouldCode),
  3986. new OracleParameter(":groutingdailyid",GroutingDailyID),
  3987. new OracleParameter(":groutingdailydetailid",GroutingDailyDetailID),
  3988. new OracleParameter(":groutinglineid",GroutingLineID),
  3989. new OracleParameter(":groutinglinecode",GroutingLineCode),
  3990. new OracleParameter(":groutinglinename",GroutingLineName),
  3991. new OracleParameter(":gmouldtypeid",GMouldTypeID),
  3992. new OracleParameter(":canmanytimes",CanManyTimes),
  3993. new OracleParameter(":groutinglinedetailid",GroutingLineDetailID),
  3994. new OracleParameter(":specialRepairflag",SpecialRepairflag),
  3995. new OracleParameter(":LogoID",LogoID),
  3996. };
  3997. #endregion
  3998. foreach (OracleParameter para in paras)
  3999. {
  4000. if (string.IsNullOrEmpty(para.Value + ""))
  4001. {
  4002. para.Value = DBNull.Value;
  4003. }
  4004. }
  4005. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  4006. OutSpecialRepairflag = returnVal;
  4007. // 失败
  4008. if (result != Constant.INT_IS_ONE)
  4009. {
  4010. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  4011. }
  4012. // 成功返回null
  4013. return null;
  4014. }
  4015. /// <summary>
  4016. /// 添加生产数据
  4017. /// </summary>
  4018. /// <param name="oracleTrConn">连接对象</param>
  4019. /// <param name="accountDate">账务日期</param>
  4020. /// <param name="productionData">生产数据</param>
  4021. /// <param name="sUserInfo">用户基本信息</param>
  4022. /// <param name="isSendBody">是否交坯</param>
  4023. /// <returns>string</returns>
  4024. /// <remarks>
  4025. /// 陈冰 2014.09.18 新建
  4026. /// </remarks>
  4027. private static string AddProductionData(IDBTransaction oracleTrConn, DateTime accountDate, ProductionDataEntity productionData, SUserInfo sUserInfo, out string OutSpecialRepairflag, bool isSendBody = false)
  4028. {
  4029. #region 查出产品注浆日期,注浆工号ID,注浆工号编码,注浆次数,注浆模具编号,模具编号
  4030. string selectSql = "";
  4031. string returnVal = "";
  4032. if (productionData.NodeType == (int)Constant.ProcedureNodeType.Begin)//开始节点时从注浆登记取值
  4033. {
  4034. // wangxin 20150409 删除掉TP_PM_GroutingProduct表后,进行的修改
  4035. // selectSql = @"select TP_PM_GroutingDaily.GroutingDate,
  4036. // TP_PM_GroutingDailyDetail.UserID as GroutingUserID,
  4037. // TP_PM_GroutingDailyDetail.UserCode as GroutingUserCode,
  4038. // TP_PM_GroutingDailyDetail.GroutingCount as GroutingNum,
  4039. // TP_PM_GroutingDailyDetail.GroutingMouldCode,
  4040. // TP_PM_GroutingDailyDetail.MouldCode,
  4041. // TP_PM_GroutingDailyDetail.GroutingDailyID,
  4042. // TP_PM_GroutingDailyDetail.GroutingDailyDetailID,
  4043. // TP_PM_GroutingDailyDetail.GroutingLineID,
  4044. // TP_PM_GroutingDailyDetail.GroutingLineCode,
  4045. // TP_PM_GroutingDailyDetail.GroutingLineName,
  4046. // TP_PM_GroutingDaily.GMouldTypeID,
  4047. // TP_PM_GroutingDaily.CanManyTimes,
  4048. // TP_PM_GroutingDailyDetail.GroutingLineDetailID,
  4049. // TP_PM_GroutingDailyDetail.SpecialRepairflag
  4050. // from TP_PM_GroutingDaily
  4051. // inner join TP_PM_GroutingDailyDetail
  4052. // on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_GroutingDailyDetail.GroutingDailyID
  4053. // where TP_PM_GroutingDailyDetail.barcode=:barcode";
  4054. selectSql = @"select TP_PM_GroutingDailyDetail.GroutingDate,
  4055. TP_PM_GroutingDailyDetail.UserID as GroutingUserID,
  4056. TP_PM_GroutingDailyDetail.UserCode as GroutingUserCode,
  4057. TP_PM_GroutingDailyDetail.GroutingCount as GroutingNum,
  4058. TP_PM_GroutingDailyDetail.GroutingMouldCode,
  4059. TP_PM_GroutingDailyDetail.MouldCode,
  4060. TP_PM_GroutingDailyDetail.GroutingDailyID,
  4061. TP_PM_GroutingDailyDetail.GroutingDailyDetailID,
  4062. TP_PM_GroutingDailyDetail.GroutingLineID,
  4063. TP_PM_GroutingDailyDetail.GroutingLineCode,
  4064. TP_PM_GroutingDailyDetail.GroutingLineName,
  4065. TP_PM_GroutingDailyDetail.GroutingLineDetailID,
  4066. TP_PM_GroutingDailyDetail.SpecialRepairflag,
  4067. (select GMouldTypeID
  4068. from TP_PM_GroutingDaily
  4069. where TP_PM_GroutingDaily.GroutingDailyID =
  4070. TP_PM_GroutingDailyDetail.GroutingDailyID) as GMouldTypeID,
  4071. (select CanManyTimes
  4072. from TP_PM_GroutingDaily
  4073. where TP_PM_GroutingDaily.GroutingDailyID =
  4074. TP_PM_GroutingDailyDetail.GroutingDailyID) as CanManyTimes,
  4075. 0 as IsReFire
  4076. from TP_PM_GroutingDailyDetail
  4077. where TP_PM_GroutingDailyDetail.barcode=:barcode";
  4078. }
  4079. else
  4080. {
  4081. //这地方连了两张表,为了成检的时候,次品在次新增
  4082. // selectSql = @"select
  4083. // GroutingDate,
  4084. // GroutingUserID,
  4085. // GroutingUserCode,
  4086. // GroutingNum,
  4087. // GroutingMouldCode,
  4088. // MouldCode,
  4089. // GroutingDailyID,
  4090. // GroutingDailyDetailID,
  4091. // GroutingLineID,
  4092. // GroutingLineCode,
  4093. // GroutingLineName,
  4094. // GMouldTypeID,
  4095. // CanManyTimes,
  4096. // GroutingLineDetailID,
  4097. // SpecialRepairflag,
  4098. // IsReFire
  4099. //
  4100. // from tp_pm_inproduction where barcode=:barcode
  4101. // union
  4102. // select
  4103. // GroutingDate,
  4104. // GroutingUserID,
  4105. // GroutingUserCode,
  4106. // GroutingNum,
  4107. // GroutingMouldCode,
  4108. // MouldCode,
  4109. // GroutingDailyID,
  4110. // GroutingDailyDetailID,
  4111. // GroutingLineID,
  4112. // GroutingLineCode,
  4113. // GroutingLineName,
  4114. // GMouldTypeID,
  4115. // CanManyTimes,
  4116. // GroutingLineDetailID,
  4117. // SpecialRepairflag,
  4118. // IsReFire
  4119. // from TP_PM_InProductionTrash where barcode=:barcode
  4120. // ";
  4121. selectSql = @"select
  4122. ip.GroutingDate,
  4123. ip.GroutingUserID,
  4124. ip.GroutingUserCode,
  4125. ip.GroutingNum,
  4126. ip.GroutingMouldCode,
  4127. ip.MouldCode,
  4128. ip.GroutingDailyID,
  4129. ip.GroutingDailyDetailID,
  4130. ip.GroutingLineID,
  4131. ip.GroutingLineCode,
  4132. ip.GroutingLineName,
  4133. ip.GMouldTypeID,
  4134. ip.CanManyTimes,
  4135. ip.GroutingLineDetailID,
  4136. ip.SpecialRepairflag,
  4137. ip.IsReFire,
  4138. ip.logoid,
  4139. gdd.ClassesSettingID
  4140. from tp_pm_inproduction ip inner join TP_PM_GroutingDailyDetail gdd on ip.GroutingDailyDetailID=gdd.GroutingDailyDetailID
  4141. where ip.barcode=:barcode
  4142. ";
  4143. }
  4144. OracleParameter[] selectparas = new OracleParameter[] {
  4145. new OracleParameter(":barcode",productionData.Barcode),
  4146. };
  4147. DataSet dsGroutingProduct = oracleTrConn.GetSqlResultToDs(selectSql, selectparas);
  4148. DateTime GroutingDate = new DateTime();
  4149. int GroutingUserID = 0, GroutingNum = 0, GroutingDailyID = 0, GroutingDailyDetailID = 0, GroutingLineID = 0, GMouldTypeID = 0, CanManyTimes = 0, GroutingLineDetailID = 0, SpecialRepairflag = 0;
  4150. string GroutingUserCode = "", GroutingMouldCode = "", MouldCode = "", GroutingLineCode = "", GroutingLineName = "";
  4151. int IsReFire = 0;
  4152. int? logoID = null;
  4153. if (dsGroutingProduct != null && dsGroutingProduct.Tables[0].Rows.Count > 0)
  4154. {
  4155. GroutingDate = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
  4156. GroutingUserID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingUserID"]);
  4157. GroutingUserCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"].ToString();
  4158. GroutingNum = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"]);
  4159. GroutingMouldCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingMouldCode"].ToString();
  4160. MouldCode = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"].ToString();
  4161. GroutingDailyID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyID"]);
  4162. GroutingDailyDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyDetailID"]);
  4163. GroutingLineID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineID"]);
  4164. GroutingLineCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineCode"].ToString();
  4165. GroutingLineName = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineName"].ToString();
  4166. GMouldTypeID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GMouldTypeID"]);
  4167. CanManyTimes = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["CanManyTimes"]);
  4168. GroutingLineDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineDetailID"]);
  4169. SpecialRepairflag = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["SpecialRepairflag"]);
  4170. IsReFire = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["IsReFire"]);
  4171. if (IsReFire > 0) //大于零代表重烧过
  4172. {
  4173. productionData.IsReFire = IsReFire;
  4174. productionData.DefectFlag = (int)Constant.GoodsLevelType.Defect;
  4175. }
  4176. if (dsGroutingProduct.Tables[0].Rows[0]["logoID"].ToString() != "")
  4177. {
  4178. logoID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["logoID"]);
  4179. }
  4180. //if (productionData.LogoID != null) //当前工序有商标
  4181. //{
  4182. // if (logoID != productionData.LogoID && productionData.LogoID != 0)
  4183. // {
  4184. // logoID = productionData.LogoID;
  4185. // //根据明细ID.update
  4186. // selectSql = "update TP_PM_GroutingDailyDetail set logoid=:logoid where GroutingDailyDetailID=" + GroutingDailyDetailID;
  4187. // OracleParameter[] paras2 = new OracleParameter[] {
  4188. // new OracleParameter(":logoid",productionData.LogoID)
  4189. // };
  4190. // oracleTrConn.ExecuteNonQuery(selectSql, paras2);
  4191. // }
  4192. //}
  4193. //xuwei add begin
  4194. //2019-09-17
  4195. //更新注浆日报(交坯处理)
  4196. if (isSendBody)
  4197. {
  4198. if (productionData.IsPublicBody.ToString() != "1" || productionData.ClassesSettingID == null)
  4199. productionData.ClassesSettingID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["ClassesSettingID"]);
  4200. selectSql = "update TP_PM_GroutingDailyDetail set ispublicbody=:ispublicbody, DELIVERFLAG=1,DELIVERTIME=sysdate,deliveruserid=:deliveruserid,deliverusercode=:deliverusercode where GroutingDailyDetailID=" + GroutingDailyDetailID;
  4201. OracleParameter[] paras2 = new OracleParameter[] {
  4202. new OracleParameter(":deliveruserid",productionData.UserID),
  4203. new OracleParameter(":deliverusercode",productionData.UserCode),
  4204. new OracleParameter(":ispublicbody",productionData.IsPublicBody),
  4205. };
  4206. oracleTrConn.ExecuteNonQuery(selectSql, paras2);
  4207. }
  4208. returnVal = SpecialRepairflag.ToString();
  4209. }
  4210. #endregion
  4211. #region 更新窑炉窑车属性
  4212. if (productionData.ModelType != 1 && productionData.ModelType != 2 && productionData.ModelType != 3 && productionData.ModelType != 4)
  4213. {
  4214. DataSet ds = GetKilnCarInfo(oracleTrConn, productionData.Barcode, sUserInfo);
  4215. if (ds != null)
  4216. {
  4217. if (ds.Tables[0].Rows[0]["KilnID"].ToString() != "") //表示以前有过窑炉相关信息
  4218. {
  4219. productionData.KilnID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnID"]);
  4220. productionData.KilnCode = ds.Tables[0].Rows[0]["KilnCode"].ToString();
  4221. productionData.KilnName = ds.Tables[0].Rows[0]["KilnName"].ToString();
  4222. productionData.KilnCarID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarID"]);
  4223. productionData.KilnCarCode = ds.Tables[0].Rows[0]["KilnCarCode"].ToString();
  4224. productionData.KilnCarName = ds.Tables[0].Rows[0]["KilnCarName"].ToString();
  4225. productionData.KilnCarBatchNo = ds.Tables[0].Rows[0]["KilnCarBatchNo"].ToString();
  4226. productionData.KilnCarPosition = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarPosition"]);
  4227. }
  4228. }
  4229. }
  4230. #endregion
  4231. #region SQL
  4232. string sql = "insert into tp_pm_productiondataIn"
  4233. + " (productiondataid,"
  4234. + " barcode,"
  4235. + " centralizedbatchno,"
  4236. + " productionlineid,"
  4237. + " productionlinecode,"
  4238. + " productionlinename,"
  4239. + " procedureid,"
  4240. + " procedurecode,"
  4241. + " procedurename,"
  4242. + " proceduremodel,"
  4243. + " modeltype,"
  4244. + " piecetype,"
  4245. + " isreworked,"
  4246. + " nodetype,"
  4247. + " ispublicbody,"
  4248. + " isrefire,"
  4249. + " organizationid,"
  4250. + " goodsid,"
  4251. + " goodscode,"
  4252. + " goodsname,"
  4253. + " userid,"
  4254. + " usercode,"
  4255. + " username,"
  4256. + " kilnid,"
  4257. + " kilncode,"
  4258. + " kilnname,"
  4259. + " kilncarid,"
  4260. + " kilncarcode,"
  4261. + " kilncarname,"
  4262. + " kilncarbatchno,"
  4263. + " kilncarposition,"
  4264. + " reworkprocedureid,"
  4265. + " reworkprocedurecode,"
  4266. + " reworkprocedurename,"
  4267. + " remarks,"
  4268. + " accountdate,"
  4269. + " accountid,"
  4270. + " GoodsLevelID,"
  4271. + " GoodsLevelTypeID,"
  4272. + " createuserid,"
  4273. + " updateuserid,"
  4274. + " GroutingDate,"
  4275. + " GroutingUserID,"
  4276. + " GroutingUserCode,"
  4277. + " GroutingNum,"
  4278. + " GroutingMouldCode,"
  4279. + " MouldCode,"
  4280. + "GroutingDailyID,"
  4281. + "GroutingDailyDetailID,"
  4282. + "GroutingLineID,"
  4283. + " GroutingLineCode,"
  4284. + "GroutingLineName,"
  4285. + "GMouldTypeID,"
  4286. + "CanManyTimes,"
  4287. + "GroutingLineDetailID,"
  4288. + "SpecialRepairflag,"
  4289. + "ClassesSettingID,"
  4290. + "LogoID"
  4291. + ")"
  4292. + " values"
  4293. + " (:productiondataid,"
  4294. + " :barcode,"
  4295. + " :centralizedbatchno,"
  4296. + " :productionlineid,"
  4297. + " :productionlinecode,"
  4298. + " :productionlinename,"
  4299. + " :procedureid,"
  4300. + " :procedurecode,"
  4301. + " :procedurename,"
  4302. + " :proceduremodel,"
  4303. + " :modeltype,"
  4304. + " :piecetype,"
  4305. + " :isreworked,"
  4306. + " :nodetype,"
  4307. + " :ispublicbody,"
  4308. + " :isrefire,"
  4309. + " :organizationid,"
  4310. + " :goodsid,"
  4311. + " :goodscode,"
  4312. + " :goodsname,"
  4313. + " :userid,"
  4314. + " :usercode,"
  4315. + " :username,"
  4316. + " :kilnid,"
  4317. + " :kilncode,"
  4318. + " :kilnname,"
  4319. + " :kilncarid,"
  4320. + " :kilncarcode,"
  4321. + " :kilncarname,"
  4322. + " :kilncarbatchno,"
  4323. + " :kilncarposition,"
  4324. + " :reworkprocedureid,"
  4325. + " :reworkprocedurecode,"
  4326. + " :reworkprocedurename,"
  4327. + " :remarks,"
  4328. + " :accountdata,"
  4329. + " :accountid,"
  4330. + " :GoodsLevelID,"
  4331. + " :GoodsLevelTypeID,"
  4332. + " :createuserid,"
  4333. + " :updateuserid,"
  4334. + " :groutingdate,"
  4335. + " :groutinguserid,"
  4336. + " :groutingusercode,"
  4337. + " :groutingnum,"
  4338. + " :groutingmouldcode,"
  4339. + " :mouldcode,"
  4340. + ":groutingdailyid,"
  4341. + ":groutingdailydetailid,"
  4342. + ":groutinglineid,"
  4343. + " :groutinglinecode,"
  4344. + ":groutinglinename,"
  4345. + ":gmouldtypeid,"
  4346. + ":canmanytimes,"
  4347. + ":groutinglinedetailid,"
  4348. + ":specialRepairflag,"
  4349. + ":classesSettingID,"
  4350. + ":logoID"
  4351. + ")";
  4352. #endregion
  4353. #region OracleParameter
  4354. OracleParameter[] paras = new OracleParameter[] {
  4355. new OracleParameter(":classesSettingID",productionData.ClassesSettingID),
  4356. new OracleParameter(":productiondataid",productionData.ProductionDataID),
  4357. new OracleParameter(":barcode",productionData.Barcode),
  4358. new OracleParameter(":centralizedbatchno",productionData.CentralizedBatchNo),
  4359. new OracleParameter(":productionlineid",productionData.ProductionLineID),
  4360. new OracleParameter(":productionlinecode",productionData.ProductionLineCode),
  4361. new OracleParameter(":productionlinename",productionData.ProductionLineName),
  4362. new OracleParameter(":procedureid",productionData.CompleteProcedureID),
  4363. new OracleParameter(":procedurecode",productionData.ProcedureCode),
  4364. new OracleParameter(":procedurename",productionData.ProcedureName),
  4365. new OracleParameter(":proceduremodel",productionData.ProcedureModel),
  4366. new OracleParameter(":modeltype",productionData.ModelType),
  4367. new OracleParameter(":piecetype",productionData.PieceType),
  4368. new OracleParameter(":isreworked",productionData.IsReworked),
  4369. new OracleParameter(":nodetype",productionData.NodeType),
  4370. new OracleParameter(":ispublicbody",productionData.IsPublicBody),
  4371. new OracleParameter(":isrefire",productionData.IsReFire),
  4372. new OracleParameter(":organizationid",productionData.OrganizationID),
  4373. new OracleParameter(":goodsid",productionData.GoodsID),
  4374. new OracleParameter(":goodscode",productionData.GoodsCode),
  4375. new OracleParameter(":goodsname",productionData.GoodsName),
  4376. new OracleParameter(":userid",productionData.UserID),
  4377. new OracleParameter(":usercode",productionData.UserCode),
  4378. new OracleParameter(":username",productionData.UserName),
  4379. new OracleParameter(":kilnid",productionData.KilnID),
  4380. new OracleParameter(":kilncode",productionData.KilnCode),
  4381. new OracleParameter(":kilnname",productionData.KilnName),
  4382. new OracleParameter(":kilncarid",productionData.KilnCarID),
  4383. new OracleParameter(":kilncarcode",productionData.KilnCarCode),
  4384. new OracleParameter(":kilncarname",productionData.KilnCarName),
  4385. new OracleParameter(":kilncarbatchno",productionData.KilnCarBatchNo),
  4386. new OracleParameter(":kilncarposition",productionData.KilnCarPosition),
  4387. new OracleParameter(":reworkprocedureid",productionData.ReworkProcedureID),
  4388. new OracleParameter(":reworkprocedurecode",productionData.ReworkProcedureCode),
  4389. new OracleParameter(":reworkprocedurename",productionData.ReworkProcedureName),
  4390. new OracleParameter(":remarks",productionData.Remarks),
  4391. new OracleParameter(":accountdata",accountDate),
  4392. new OracleParameter(":accountid",sUserInfo.AccountID),
  4393. new OracleParameter(":GoodsLevelID",productionData.GoodsLevelID),
  4394. new OracleParameter(":GoodsLevelTypeID",productionData.GoodsLevelTypeID),
  4395. new OracleParameter(":createuserid",sUserInfo.UserID),
  4396. new OracleParameter(":updateuserid",sUserInfo.UserID),
  4397. new OracleParameter(":groutingdate",GroutingDate),
  4398. new OracleParameter(":groutinguserid",GroutingUserID),
  4399. new OracleParameter(":groutingusercode",GroutingUserCode),
  4400. new OracleParameter(":groutingnum",GroutingNum),
  4401. new OracleParameter(":groutingmouldcode",GroutingMouldCode),
  4402. new OracleParameter(":mouldcode",MouldCode),
  4403. new OracleParameter(":groutingdailyid",GroutingDailyID),
  4404. new OracleParameter(":groutingdailydetailid",GroutingDailyDetailID),
  4405. new OracleParameter(":groutinglineid",GroutingLineID),
  4406. new OracleParameter(":groutinglinecode",GroutingLineCode),
  4407. new OracleParameter(":groutinglinename",GroutingLineName),
  4408. new OracleParameter(":gmouldtypeid",GMouldTypeID),
  4409. new OracleParameter(":canmanytimes",CanManyTimes),
  4410. new OracleParameter(":groutinglinedetailid",GroutingLineDetailID),
  4411. new OracleParameter(":specialRepairflag",SpecialRepairflag),
  4412. new OracleParameter(":logoID",logoID),
  4413. };
  4414. #endregion
  4415. foreach (OracleParameter para in paras)
  4416. {
  4417. if (string.IsNullOrEmpty(para.Value + ""))
  4418. {
  4419. para.Value = DBNull.Value;
  4420. }
  4421. }
  4422. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  4423. OutSpecialRepairflag = returnVal;
  4424. // 失败
  4425. if (result != Constant.INT_IS_ONE)
  4426. {
  4427. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  4428. }
  4429. // 成功返回null
  4430. return null;
  4431. }
  4432. /// <summary>
  4433. /// 添加生产数据(单独为成检所做,因为成检可以从次品到其它,需要读一标识,别的不需要连接回收站表)
  4434. /// </summary>
  4435. /// <param name="oracleTrConn">连接对象</param>
  4436. /// <param name="accountDate">账务日期</param>
  4437. /// <param name="productionData">生产数据</param>
  4438. /// <param name="sUserInfo">用户基本信息</param>
  4439. /// <returns>string</returns>
  4440. /// <remarks>
  4441. /// 陈冰 2014.09.18 新建
  4442. /// </remarks>
  4443. private static string AddFinishCheckProductionData(IDBTransaction oracleTrConn, DateTime accountDate, ProductionDataEntity productionData, SUserInfo sUserInfo, out string OutSpecialRepairflag)
  4444. {
  4445. #region 查出产品注浆日期,注浆工号ID,注浆工号编码,注浆次数,注浆模具编号,模具编号
  4446. string selectSql = "";
  4447. string returnVal = "";
  4448. if (productionData.NodeType == (int)Constant.ProcedureNodeType.Begin)//开始节点时从注浆登记取值
  4449. {
  4450. // wangxin 20150409 删除掉TP_PM_GroutingProduct表后,进行的修改
  4451. // selectSql = @"select TP_PM_GroutingDaily.GroutingDate,
  4452. // TP_PM_GroutingDailyDetail.UserID as GroutingUserID,
  4453. // TP_PM_GroutingDailyDetail.UserCode as GroutingUserCode,
  4454. // TP_PM_GroutingDailyDetail.GroutingCount as GroutingNum,
  4455. // TP_PM_GroutingDailyDetail.GroutingMouldCode,
  4456. // TP_PM_GroutingDailyDetail.MouldCode,
  4457. // TP_PM_GroutingDailyDetail.GroutingDailyID,
  4458. // TP_PM_GroutingDailyDetail.GroutingDailyDetailID,
  4459. // TP_PM_GroutingDailyDetail.GroutingLineID,
  4460. // TP_PM_GroutingDailyDetail.GroutingLineCode,
  4461. // TP_PM_GroutingDailyDetail.GroutingLineName,
  4462. // TP_PM_GroutingDaily.GMouldTypeID,
  4463. // TP_PM_GroutingDaily.CanManyTimes,
  4464. // TP_PM_GroutingDailyDetail.GroutingLineDetailID,
  4465. // TP_PM_GroutingDailyDetail.SpecialRepairflag
  4466. // from TP_PM_GroutingDaily
  4467. // inner join TP_PM_GroutingDailyDetail
  4468. // on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_GroutingDailyDetail.GroutingDailyID
  4469. // where TP_PM_GroutingDailyDetail.barcode=:barcode";
  4470. selectSql = @"select TP_PM_GroutingDailyDetail.GroutingDate,
  4471. TP_PM_GroutingDailyDetail.UserID as GroutingUserID,
  4472. TP_PM_GroutingDailyDetail.UserCode as GroutingUserCode,
  4473. TP_PM_GroutingDailyDetail.GroutingCount as GroutingNum,
  4474. TP_PM_GroutingDailyDetail.GroutingMouldCode,
  4475. TP_PM_GroutingDailyDetail.MouldCode,
  4476. TP_PM_GroutingDailyDetail.GroutingDailyID,
  4477. TP_PM_GroutingDailyDetail.GroutingDailyDetailID,
  4478. TP_PM_GroutingDailyDetail.GroutingLineID,
  4479. TP_PM_GroutingDailyDetail.GroutingLineCode,
  4480. TP_PM_GroutingDailyDetail.GroutingLineName,
  4481. TP_PM_GroutingDailyDetail.GroutingLineDetailID,
  4482. TP_PM_GroutingDailyDetail.SpecialRepairflag,
  4483. (select GMouldTypeID
  4484. from TP_PM_GroutingDaily
  4485. where TP_PM_GroutingDaily.GroutingDailyID =
  4486. TP_PM_GroutingDailyDetail.GroutingDailyID) as GMouldTypeID,
  4487. (select CanManyTimes
  4488. from TP_PM_GroutingDaily
  4489. where TP_PM_GroutingDaily.GroutingDailyID =
  4490. TP_PM_GroutingDailyDetail.GroutingDailyID) as CanManyTimes,
  4491. 0 as IsReFire
  4492. from TP_PM_GroutingDailyDetail
  4493. where TP_PM_GroutingDailyDetail.barcode=:barcode";
  4494. }
  4495. else
  4496. {
  4497. //这地方连了两张表,为了成检的时候,次品在次新增
  4498. selectSql = @"select
  4499. GroutingDate,
  4500. GroutingUserID,
  4501. GroutingUserCode,
  4502. GroutingNum,
  4503. GroutingMouldCode,
  4504. MouldCode,
  4505. GroutingDailyID,
  4506. GroutingDailyDetailID,
  4507. GroutingLineID,
  4508. GroutingLineCode,
  4509. GroutingLineName,
  4510. GMouldTypeID,
  4511. CanManyTimes,
  4512. GroutingLineDetailID,
  4513. SpecialRepairflag,
  4514. IsReFire,
  4515. Logoid
  4516. from tp_pm_inproduction where barcode=:barcode
  4517. union
  4518. select
  4519. GroutingDate,
  4520. GroutingUserID,
  4521. GroutingUserCode,
  4522. GroutingNum,
  4523. GroutingMouldCode,
  4524. MouldCode,
  4525. GroutingDailyID,
  4526. GroutingDailyDetailID,
  4527. GroutingLineID,
  4528. GroutingLineCode,
  4529. GroutingLineName,
  4530. GMouldTypeID,
  4531. CanManyTimes,
  4532. GroutingLineDetailID,
  4533. SpecialRepairflag,
  4534. IsReFire,
  4535. logoid
  4536. from TP_PM_InProductionTrash where barcode=:barcode
  4537. ";
  4538. }
  4539. OracleParameter[] selectparas = new OracleParameter[] {
  4540. new OracleParameter(":barcode",productionData.Barcode),
  4541. };
  4542. DataSet dsGroutingProduct = oracleTrConn.GetSqlResultToDs(selectSql, selectparas);
  4543. DateTime GroutingDate = new DateTime();
  4544. int GroutingUserID = 0, GroutingNum = 0, GroutingDailyID = 0, GroutingDailyDetailID = 0, GroutingLineID = 0, GMouldTypeID = 0, CanManyTimes = 0, GroutingLineDetailID = 0, SpecialRepairflag = 0;
  4545. string GroutingUserCode = "", GroutingMouldCode = "", MouldCode = "", GroutingLineCode = "", GroutingLineName = "";
  4546. int IsReFire = 0;
  4547. int? logoid = null;
  4548. if (dsGroutingProduct != null && dsGroutingProduct.Tables[0].Rows.Count > 0)
  4549. {
  4550. GroutingDate = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
  4551. GroutingUserID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingUserID"]);
  4552. GroutingUserCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"].ToString();
  4553. GroutingNum = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"]);
  4554. GroutingMouldCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingMouldCode"].ToString();
  4555. MouldCode = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"].ToString();
  4556. GroutingDailyID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyID"]);
  4557. GroutingDailyDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyDetailID"]);
  4558. GroutingLineID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineID"]);
  4559. GroutingLineCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineCode"].ToString();
  4560. GroutingLineName = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineName"].ToString();
  4561. GMouldTypeID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GMouldTypeID"]);
  4562. CanManyTimes = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["CanManyTimes"]);
  4563. GroutingLineDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineDetailID"]);
  4564. SpecialRepairflag = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["SpecialRepairflag"]);
  4565. IsReFire = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["IsReFire"]);
  4566. if (dsGroutingProduct.Tables[0].Rows[0]["logoid"].ToString() != "")
  4567. {
  4568. logoid = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["logoid"]);
  4569. }
  4570. if (IsReFire > 0) //大于零代表重烧过
  4571. {
  4572. productionData.IsReFire = IsReFire;
  4573. productionData.DefectFlag = (int)Constant.GoodsLevelType.Defect;
  4574. }
  4575. returnVal = SpecialRepairflag.ToString();
  4576. }
  4577. #endregion
  4578. #region 更新窑炉窑车属性
  4579. if (productionData.ModelType != 1 && productionData.ModelType != 2 && productionData.ModelType != 3 && productionData.ModelType != 4)
  4580. {
  4581. DataSet ds = GetFinishCheckKilnCarInfo(oracleTrConn, productionData.Barcode, sUserInfo);
  4582. if (ds != null)
  4583. {
  4584. if (ds.Tables[0].Rows[0]["KilnID"].ToString() != "") //表示以前有过窑炉相关信息
  4585. {
  4586. productionData.KilnID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnID"]);
  4587. productionData.KilnCode = ds.Tables[0].Rows[0]["KilnCode"].ToString();
  4588. productionData.KilnName = ds.Tables[0].Rows[0]["KilnName"].ToString();
  4589. productionData.KilnCarID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarID"]);
  4590. productionData.KilnCarCode = ds.Tables[0].Rows[0]["KilnCarCode"].ToString();
  4591. productionData.KilnCarName = ds.Tables[0].Rows[0]["KilnCarName"].ToString();
  4592. productionData.KilnCarBatchNo = ds.Tables[0].Rows[0]["KilnCarBatchNo"].ToString();
  4593. productionData.KilnCarPosition = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarPosition"]);
  4594. }
  4595. }
  4596. }
  4597. #endregion
  4598. if (Convert.ToInt32(productionData.GoodsLevelTypeID) == 6) //判断重烧必须有返工工序
  4599. {
  4600. if (productionData.ReworkProcedureID == null || Convert.ToInt32(productionData.ReworkProcedureID) == 0)
  4601. {
  4602. OutSpecialRepairflag = "";
  4603. return string.Format("产品分级【重烧】必须填写返工工序", "条码", "保存");
  4604. }
  4605. }
  4606. DateTime? checkTime = null;
  4607. if (productionData.IsPDA != null)
  4608. {
  4609. if (productionData.PDACheckTime != null)
  4610. {
  4611. // PDA端
  4612. if (productionData.PDACheckTime.ToString() != string.Empty)
  4613. {
  4614. checkTime = Convert.ToDateTime(productionData.PDACheckTime);
  4615. }
  4616. }
  4617. }
  4618. else
  4619. {
  4620. if (productionData.CheckTime != null)
  4621. {
  4622. // PDA端
  4623. if (productionData.CheckTime.ToString() != string.Empty)
  4624. {
  4625. checkTime = Convert.ToDateTime(productionData.CheckTime);
  4626. }
  4627. }
  4628. }
  4629. #region SQL
  4630. string sql = "insert into tp_pm_productiondataIn"
  4631. + " (productiondataid,"
  4632. + " barcode,"
  4633. + " centralizedbatchno,"
  4634. + " productionlineid,"
  4635. + " productionlinecode,"
  4636. + " productionlinename,"
  4637. + " procedureid,"
  4638. + " procedurecode,"
  4639. + " procedurename,"
  4640. + " proceduremodel,"
  4641. + " modeltype,"
  4642. + " piecetype,"
  4643. + " isreworked,"
  4644. + " nodetype,"
  4645. + " ispublicbody,"
  4646. + " isrefire,"
  4647. + " organizationid,"
  4648. + " goodsid,"
  4649. + " goodscode,"
  4650. + " goodsname,"
  4651. + " userid,"
  4652. + " usercode,"
  4653. + " username,"
  4654. + " kilnid,"
  4655. + " kilncode,"
  4656. + " kilnname,"
  4657. + " kilncarid,"
  4658. + " kilncarcode,"
  4659. + " kilncarname,"
  4660. + " kilncarbatchno,"
  4661. + " kilncarposition,"
  4662. + " reworkprocedureid,"
  4663. + " reworkprocedurecode,"
  4664. + " reworkprocedurename,"
  4665. + " remarks,"
  4666. + " accountdate,"
  4667. + " accountid,"
  4668. + " GoodsLevelID,"
  4669. + " GoodsLevelTypeID,"
  4670. + " createuserid,"
  4671. + " updateuserid,"
  4672. + " GroutingDate,"
  4673. + " GroutingUserID,"
  4674. + " GroutingUserCode,"
  4675. + " GroutingNum,"
  4676. + " GroutingMouldCode,"
  4677. + " MouldCode,"
  4678. + "GroutingDailyID,"
  4679. + "GroutingDailyDetailID,"
  4680. + "GroutingLineID,"
  4681. + " GroutingLineCode,"
  4682. + "GroutingLineName,"
  4683. + "GMouldTypeID,"
  4684. + "CanManyTimes,"
  4685. + "GroutingLineDetailID,"
  4686. + "SpecialRepairflag,"
  4687. + "ClassesSettingID,"
  4688. + "LogoID,"
  4689. + "CheckTime"
  4690. + ")"
  4691. + " values"
  4692. + " (:productiondataid,"
  4693. + " :barcode,"
  4694. + " :centralizedbatchno,"
  4695. + " :productionlineid,"
  4696. + " :productionlinecode,"
  4697. + " :productionlinename,"
  4698. + " :procedureid,"
  4699. + " :procedurecode,"
  4700. + " :procedurename,"
  4701. + " :proceduremodel,"
  4702. + " :modeltype,"
  4703. + " :piecetype,"
  4704. + " :isreworked,"
  4705. + " :nodetype,"
  4706. + " :ispublicbody,"
  4707. + " :isrefire,"
  4708. + " :organizationid,"
  4709. + " :goodsid,"
  4710. + " :goodscode,"
  4711. + " :goodsname,"
  4712. + " :userid,"
  4713. + " :usercode,"
  4714. + " :username,"
  4715. + " :kilnid,"
  4716. + " :kilncode,"
  4717. + " :kilnname,"
  4718. + " :kilncarid,"
  4719. + " :kilncarcode,"
  4720. + " :kilncarname,"
  4721. + " :kilncarbatchno,"
  4722. + " :kilncarposition,"
  4723. + " :reworkprocedureid,"
  4724. + " :reworkprocedurecode,"
  4725. + " :reworkprocedurename,"
  4726. + " :remarks,"
  4727. + " :accountdata,"
  4728. + " :accountid,"
  4729. + " :GoodsLevelID,"
  4730. + " :GoodsLevelTypeID,"
  4731. + " :createuserid,"
  4732. + " :updateuserid,"
  4733. + " :groutingdate,"
  4734. + " :groutinguserid,"
  4735. + " :groutingusercode,"
  4736. + " :groutingnum,"
  4737. + " :groutingmouldcode,"
  4738. + " :mouldcode,"
  4739. + ":groutingdailyid,"
  4740. + ":groutingdailydetailid,"
  4741. + ":groutinglineid,"
  4742. + " :groutinglinecode,"
  4743. + ":groutinglinename,"
  4744. + ":gmouldtypeid,"
  4745. + ":canmanytimes,"
  4746. + ":groutinglinedetailid,"
  4747. + ":specialRepairflag,"
  4748. + ":classesSettingID,"
  4749. + ":logoid,";
  4750. if (checkTime == null)
  4751. {
  4752. sql = sql + "sysdate";
  4753. }
  4754. else
  4755. {
  4756. sql = sql + ":checkTime";
  4757. }
  4758. sql = sql + ")";
  4759. #endregion
  4760. #region OracleParameter
  4761. OracleParameter[] paras = null;
  4762. if (checkTime != null)
  4763. {
  4764. paras = new OracleParameter[] {
  4765. new OracleParameter(":classesSettingID",productionData.ClassesSettingID),
  4766. new OracleParameter(":productiondataid",productionData.ProductionDataID),
  4767. new OracleParameter(":barcode",productionData.Barcode),
  4768. new OracleParameter(":centralizedbatchno",productionData.CentralizedBatchNo),
  4769. new OracleParameter(":productionlineid",productionData.ProductionLineID),
  4770. new OracleParameter(":productionlinecode",productionData.ProductionLineCode),
  4771. new OracleParameter(":productionlinename",productionData.ProductionLineName),
  4772. new OracleParameter(":procedureid",productionData.CompleteProcedureID),
  4773. new OracleParameter(":procedurecode",productionData.ProcedureCode),
  4774. new OracleParameter(":procedurename",productionData.ProcedureName),
  4775. new OracleParameter(":proceduremodel",productionData.ProcedureModel),
  4776. new OracleParameter(":modeltype",productionData.ModelType),
  4777. new OracleParameter(":piecetype",productionData.PieceType),
  4778. new OracleParameter(":isreworked",productionData.IsReworked),
  4779. new OracleParameter(":nodetype",productionData.NodeType),
  4780. new OracleParameter(":ispublicbody",productionData.IsPublicBody),
  4781. new OracleParameter(":isrefire",productionData.IsReFire),
  4782. new OracleParameter(":organizationid",productionData.OrganizationID),
  4783. new OracleParameter(":goodsid",productionData.GoodsID),
  4784. new OracleParameter(":goodscode",productionData.GoodsCode),
  4785. new OracleParameter(":goodsname",productionData.GoodsName),
  4786. new OracleParameter(":userid",productionData.UserID),
  4787. new OracleParameter(":usercode",productionData.UserCode),
  4788. new OracleParameter(":username",productionData.UserName),
  4789. new OracleParameter(":kilnid",productionData.KilnID),
  4790. new OracleParameter(":kilncode",productionData.KilnCode),
  4791. new OracleParameter(":kilnname",productionData.KilnName),
  4792. new OracleParameter(":kilncarid",productionData.KilnCarID),
  4793. new OracleParameter(":kilncarcode",productionData.KilnCarCode),
  4794. new OracleParameter(":kilncarname",productionData.KilnCarName),
  4795. new OracleParameter(":kilncarbatchno",productionData.KilnCarBatchNo),
  4796. new OracleParameter(":kilncarposition",productionData.KilnCarPosition),
  4797. new OracleParameter(":reworkprocedureid",productionData.ReworkProcedureID),
  4798. new OracleParameter(":reworkprocedurecode",productionData.ReworkProcedureCode),
  4799. new OracleParameter(":reworkprocedurename",productionData.ReworkProcedureName),
  4800. new OracleParameter(":remarks",productionData.Remarks),
  4801. new OracleParameter(":accountdata",accountDate),
  4802. new OracleParameter(":accountid",sUserInfo.AccountID),
  4803. new OracleParameter(":GoodsLevelID",productionData.GoodsLevelID),
  4804. new OracleParameter(":GoodsLevelTypeID",productionData.GoodsLevelTypeID),
  4805. new OracleParameter(":createuserid",sUserInfo.UserID),
  4806. new OracleParameter(":updateuserid",sUserInfo.UserID),
  4807. new OracleParameter(":groutingdate",GroutingDate),
  4808. new OracleParameter(":groutinguserid",GroutingUserID),
  4809. new OracleParameter(":groutingusercode",GroutingUserCode),
  4810. new OracleParameter(":groutingnum",GroutingNum),
  4811. new OracleParameter(":groutingmouldcode",GroutingMouldCode),
  4812. new OracleParameter(":mouldcode",MouldCode),
  4813. new OracleParameter(":groutingdailyid",GroutingDailyID),
  4814. new OracleParameter(":groutingdailydetailid",GroutingDailyDetailID),
  4815. new OracleParameter(":groutinglineid",GroutingLineID),
  4816. new OracleParameter(":groutinglinecode",GroutingLineCode),
  4817. new OracleParameter(":groutinglinename",GroutingLineName),
  4818. new OracleParameter(":gmouldtypeid",GMouldTypeID),
  4819. new OracleParameter(":canmanytimes",CanManyTimes),
  4820. new OracleParameter(":groutinglinedetailid",GroutingLineDetailID),
  4821. new OracleParameter(":specialRepairflag",SpecialRepairflag),
  4822. new OracleParameter(":logoid",logoid),
  4823. new OracleParameter(":checkTime",checkTime),
  4824. };
  4825. }
  4826. else
  4827. {
  4828. paras = new OracleParameter[] {
  4829. new OracleParameter(":classesSettingID",productionData.ClassesSettingID),
  4830. new OracleParameter(":productiondataid",productionData.ProductionDataID),
  4831. new OracleParameter(":barcode",productionData.Barcode),
  4832. new OracleParameter(":centralizedbatchno",productionData.CentralizedBatchNo),
  4833. new OracleParameter(":productionlineid",productionData.ProductionLineID),
  4834. new OracleParameter(":productionlinecode",productionData.ProductionLineCode),
  4835. new OracleParameter(":productionlinename",productionData.ProductionLineName),
  4836. new OracleParameter(":procedureid",productionData.CompleteProcedureID),
  4837. new OracleParameter(":procedurecode",productionData.ProcedureCode),
  4838. new OracleParameter(":procedurename",productionData.ProcedureName),
  4839. new OracleParameter(":proceduremodel",productionData.ProcedureModel),
  4840. new OracleParameter(":modeltype",productionData.ModelType),
  4841. new OracleParameter(":piecetype",productionData.PieceType),
  4842. new OracleParameter(":isreworked",productionData.IsReworked),
  4843. new OracleParameter(":nodetype",productionData.NodeType),
  4844. new OracleParameter(":ispublicbody",productionData.IsPublicBody),
  4845. new OracleParameter(":isrefire",productionData.IsReFire),
  4846. new OracleParameter(":organizationid",productionData.OrganizationID),
  4847. new OracleParameter(":goodsid",productionData.GoodsID),
  4848. new OracleParameter(":goodscode",productionData.GoodsCode),
  4849. new OracleParameter(":goodsname",productionData.GoodsName),
  4850. new OracleParameter(":userid",productionData.UserID),
  4851. new OracleParameter(":usercode",productionData.UserCode),
  4852. new OracleParameter(":username",productionData.UserName),
  4853. new OracleParameter(":kilnid",productionData.KilnID),
  4854. new OracleParameter(":kilncode",productionData.KilnCode),
  4855. new OracleParameter(":kilnname",productionData.KilnName),
  4856. new OracleParameter(":kilncarid",productionData.KilnCarID),
  4857. new OracleParameter(":kilncarcode",productionData.KilnCarCode),
  4858. new OracleParameter(":kilncarname",productionData.KilnCarName),
  4859. new OracleParameter(":kilncarbatchno",productionData.KilnCarBatchNo),
  4860. new OracleParameter(":kilncarposition",productionData.KilnCarPosition),
  4861. new OracleParameter(":reworkprocedureid",productionData.ReworkProcedureID),
  4862. new OracleParameter(":reworkprocedurecode",productionData.ReworkProcedureCode),
  4863. new OracleParameter(":reworkprocedurename",productionData.ReworkProcedureName),
  4864. new OracleParameter(":remarks",productionData.Remarks),
  4865. new OracleParameter(":accountdata",accountDate),
  4866. new OracleParameter(":accountid",sUserInfo.AccountID),
  4867. new OracleParameter(":GoodsLevelID",productionData.GoodsLevelID),
  4868. new OracleParameter(":GoodsLevelTypeID",productionData.GoodsLevelTypeID),
  4869. new OracleParameter(":createuserid",sUserInfo.UserID),
  4870. new OracleParameter(":updateuserid",sUserInfo.UserID),
  4871. new OracleParameter(":groutingdate",GroutingDate),
  4872. new OracleParameter(":groutinguserid",GroutingUserID),
  4873. new OracleParameter(":groutingusercode",GroutingUserCode),
  4874. new OracleParameter(":groutingnum",GroutingNum),
  4875. new OracleParameter(":groutingmouldcode",GroutingMouldCode),
  4876. new OracleParameter(":mouldcode",MouldCode),
  4877. new OracleParameter(":groutingdailyid",GroutingDailyID),
  4878. new OracleParameter(":groutingdailydetailid",GroutingDailyDetailID),
  4879. new OracleParameter(":groutinglineid",GroutingLineID),
  4880. new OracleParameter(":groutinglinecode",GroutingLineCode),
  4881. new OracleParameter(":groutinglinename",GroutingLineName),
  4882. new OracleParameter(":gmouldtypeid",GMouldTypeID),
  4883. new OracleParameter(":canmanytimes",CanManyTimes),
  4884. new OracleParameter(":groutinglinedetailid",GroutingLineDetailID),
  4885. new OracleParameter(":specialRepairflag",SpecialRepairflag),
  4886. new OracleParameter(":logoid",logoid),
  4887. };
  4888. }
  4889. #endregion
  4890. foreach (OracleParameter para in paras)
  4891. {
  4892. if (string.IsNullOrEmpty(para.Value + ""))
  4893. {
  4894. para.Value = DBNull.Value;
  4895. }
  4896. }
  4897. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  4898. OutSpecialRepairflag = returnVal;
  4899. // 失败
  4900. if (result != Constant.INT_IS_ONE)
  4901. {
  4902. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  4903. }
  4904. // 成功返回null
  4905. return null;
  4906. }
  4907. /// <summary>
  4908. /// 删除在产数据
  4909. /// </summary>
  4910. /// <param name="oracleTrConn">连接对象</param>
  4911. /// <param name="delInProductionEntity">在产数据对象</param>
  4912. /// <returns>string</returns>
  4913. /// <remarks>
  4914. /// 陈冰 2014.09.18 新建
  4915. /// </remarks>
  4916. private static string DeleteInProduction(IDBTransaction oracleTrConn, InProductionEntity delInProductionEntity, bool FinishedProduct, SUserInfo sUserInfo)
  4917. {
  4918. OracleParameter[] paras = new OracleParameter[] {
  4919. new OracleParameter(":barcode",delInProductionEntity.BarCode),
  4920. };
  4921. int result = 0;
  4922. //删除在产表之前,插入到产品回收表中
  4923. if (!FinishedProduct)//如果不是产成品的时候,就是报废,产成品的时候不添加这个表里,只删除在产数据
  4924. {
  4925. OracleParameter[] parasPDA = new OracleParameter[] {
  4926. new OracleParameter(":CreateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  4927. new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  4928. new OracleParameter(":barcode",delInProductionEntity.BarCode),
  4929. new OracleParameter(":FlowProcedureID",delInProductionEntity.CompleteProcedureID),
  4930. };
  4931. string sqlInsert = @"insert into TP_PM_InProductionTrash
  4932. (
  4933. BarCode,
  4934. ProductionLineID,
  4935. ProductionLineCode,
  4936. ProductionLineName,
  4937. ProcedureModel,
  4938. ModelType,
  4939. DefectFlag,
  4940. ReworkProcedureID,
  4941. IsPublicBody,
  4942. IsReFire,
  4943. GoodsLevelID,
  4944. GoodsLevelTypeID,
  4945. GoodsID,
  4946. GoodsCode,
  4947. GoodsName,
  4948. UserID,
  4949. GroutingDailyID,
  4950. GroutingDailyDetailID,
  4951. GroutingDate,
  4952. GroutingLineID,
  4953. GroutingLineCode,
  4954. GroutingLineName,
  4955. GMouldTypeID,
  4956. CanManyTimes,
  4957. GroutingLineDetailID,
  4958. GroutingMouldCode,
  4959. MouldCode,
  4960. GroutingUserID,
  4961. GroutingUserCode,
  4962. GroutingNum,
  4963. Remarks,
  4964. KilnID,
  4965. KilnCode,
  4966. KilnName,
  4967. KilnCarID,
  4968. KilnCarCode,
  4969. KilnCarName,
  4970. KilnCarBatchNo,
  4971. KilnCarPosition,
  4972. AccountID,
  4973. ValueFlag,
  4974. CreateTime,
  4975. CreateUserID,
  4976. UpdateUserID,
  4977. SpecialRepairflag,
  4978. FlowProcedureID,
  4979. FlowProcedureTime,
  4980. ProcedureID,
  4981. ProcedureTime,
  4982. ProductionDataID,
  4983. logoid, ISREWORKFLAG, SEMICHECKID
  4984. )
  4985. select
  4986. BarCode,
  4987. ProductionLineID,
  4988. ProductionLineCode,
  4989. ProductionLineName,
  4990. ProcedureModel,
  4991. ModelType,
  4992. DefectFlag,
  4993. ReworkProcedureID,
  4994. IsPublicBody,
  4995. IsReFire,
  4996. GoodsLevelID,
  4997. GoodsLevelTypeID,
  4998. GoodsID,
  4999. GoodsCode,
  5000. GoodsName,
  5001. UserID,
  5002. GroutingDailyID,
  5003. GroutingDailyDetailID,
  5004. GroutingDate,
  5005. GroutingLineID,
  5006. GroutingLineCode,
  5007. GroutingLineName,
  5008. GMouldTypeID,
  5009. CanManyTimes,
  5010. GroutingLineDetailID,
  5011. GroutingMouldCode,
  5012. MouldCode,
  5013. GroutingUserID,
  5014. GroutingUserCode,
  5015. GroutingNum,
  5016. Remarks,
  5017. KilnID,
  5018. KilnCode,
  5019. KilnName,
  5020. KilnCarID,
  5021. KilnCarCode,
  5022. KilnCarName,
  5023. KilnCarBatchNo,
  5024. KilnCarPosition,
  5025. AccountID,
  5026. ValueFlag,
  5027. CreateTime,
  5028. :CreateUserID,
  5029. :UpdateUserID,
  5030. SpecialRepairflag,
  5031. :FlowProcedureID,
  5032. FlowProcedureTime,
  5033. :FlowProcedureID,
  5034. ProcedureTime,
  5035. ProductionDataID,
  5036. logoid, ISREWORKFLAG, SEMICHECKID
  5037. from TP_PM_InProduction
  5038. where barcode=:barcode
  5039. ";
  5040. result = oracleTrConn.ExecuteNonQuery(sqlInsert, parasPDA);
  5041. }
  5042. string sql = "delete tp_pm_inproduction where barcode = :barcode";
  5043. result += oracleTrConn.ExecuteNonQuery(sql, paras);
  5044. // 删除失败
  5045. //if (result != Constant.INT_IS_TWO)//删除在产的同时,应该往产品加收表里插入,这样就是影响行数为2,以前是1
  5046. if (result == Constant.INT_IS_ZERO)
  5047. {
  5048. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  5049. }
  5050. // 成功返回null
  5051. return null;
  5052. }
  5053. /// <summary>
  5054. /// 删除在产数据
  5055. /// </summary>
  5056. /// <param name="oracleTrConn">连接对象</param>
  5057. /// <param name="delInProductionEntity">在产数据对象</param>
  5058. /// <returns>string</returns>
  5059. /// <remarks>
  5060. /// 陈冰 2014.09.18 新建
  5061. /// </remarks>
  5062. private static string DeletePDAInProduction(IDBTransaction oracleTrConn, InProductionEntity delInProductionEntity, bool FinishedProduct, SUserInfo sUserInfo)
  5063. {
  5064. OracleParameter[] paras = new OracleParameter[] {
  5065. new OracleParameter(":barcode",delInProductionEntity.BarCode),
  5066. };
  5067. int result = 0;
  5068. //删除在产表之前,插入到产品回收表中
  5069. if (!FinishedProduct)//如果不是产成品的时候,就是报废,产成品的时候不添加这个表里,只删除在产数据
  5070. {
  5071. OracleParameter[] parasPDA = new OracleParameter[] {
  5072. new OracleParameter(":barcode",delInProductionEntity.BarCode),
  5073. new OracleParameter(":FlowProcedureID",delInProductionEntity.CompleteProcedureID),
  5074. new OracleParameter(":CreateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  5075. new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  5076. new OracleParameter(":ProductionDataID",OracleDbType.Int32,delInProductionEntity.ProductionDataID,ParameterDirection.Input),
  5077. new OracleParameter(":GoodsLevelID",OracleDbType.Int32,delInProductionEntity.GoodsLevelID,ParameterDirection.Input),
  5078. new OracleParameter(":GoodsLevelTypeID",OracleDbType.Int32,delInProductionEntity.GoodsLevelTypeID,ParameterDirection.Input),
  5079. };
  5080. //删除在产表前,在产表生产数据ID更新下,如不更新这样就不准了,例如,次品到次品 第一次不会影响,因为第一次TP_PM_InProductionTrash表里没有
  5081. // 如果第二次走次品到次品,才有效,下面的sqlInsert则没有效,因为在产表里没有数据插入不到回收表
  5082. string sqlupdate = "update TP_PM_InProductionTrash set ProductionDataID=:ProductionDataID where barcode=:barcode";
  5083. OracleParameter[] parasupdate = new OracleParameter[] {
  5084. new OracleParameter(":barcode",delInProductionEntity.BarCode),
  5085. new OracleParameter(":ProductionDataID",delInProductionEntity.ProductionDataID),
  5086. };
  5087. oracleTrConn.ExecuteNonQuery(sqlupdate, parasupdate);
  5088. string sqlInsert = @"insert into TP_PM_InProductionTrash
  5089. (
  5090. BarCode,
  5091. ProductionLineID,
  5092. ProductionLineCode,
  5093. ProductionLineName,
  5094. ProcedureModel,
  5095. ModelType,
  5096. DefectFlag,
  5097. ReworkProcedureID,
  5098. IsPublicBody,
  5099. IsReFire,
  5100. GoodsLevelID,
  5101. GoodsLevelTypeID,
  5102. GoodsID,
  5103. GoodsCode,
  5104. GoodsName,
  5105. UserID,
  5106. GroutingDailyID,
  5107. GroutingDailyDetailID,
  5108. GroutingDate,
  5109. GroutingLineID,
  5110. GroutingLineCode,
  5111. GroutingLineName,
  5112. GMouldTypeID,
  5113. CanManyTimes,
  5114. GroutingLineDetailID,
  5115. GroutingMouldCode,
  5116. MouldCode,
  5117. GroutingUserID,
  5118. GroutingUserCode,
  5119. GroutingNum,
  5120. Remarks,
  5121. KilnID,
  5122. KilnCode,
  5123. KilnName,
  5124. KilnCarID,
  5125. KilnCarCode,
  5126. KilnCarName,
  5127. KilnCarBatchNo,
  5128. KilnCarPosition,
  5129. AccountID,
  5130. ValueFlag,
  5131. CreateUserID,
  5132. UpdateUserID,
  5133. SpecialRepairflag,
  5134. FlowProcedureID,
  5135. FlowProcedureTime,
  5136. ProcedureID,
  5137. ProcedureTime,
  5138. ProductionDataID,
  5139. logoid, ISREWORKFLAG, SEMICHECKID
  5140. )
  5141. select
  5142. BarCode,
  5143. ProductionLineID,
  5144. ProductionLineCode,
  5145. ProductionLineName,
  5146. ProcedureModel,
  5147. ModelType,
  5148. DefectFlag,
  5149. ReworkProcedureID,
  5150. IsPublicBody,
  5151. IsReFire,
  5152. :GoodsLevelID,
  5153. :GoodsLevelTypeID,
  5154. GoodsID,
  5155. GoodsCode,
  5156. GoodsName,
  5157. UserID,
  5158. GroutingDailyID,
  5159. GroutingDailyDetailID,
  5160. GroutingDate,
  5161. GroutingLineID,
  5162. GroutingLineCode,
  5163. GroutingLineName,
  5164. GMouldTypeID,
  5165. CanManyTimes,
  5166. GroutingLineDetailID,
  5167. GroutingMouldCode,
  5168. MouldCode,
  5169. GroutingUserID,
  5170. GroutingUserCode,
  5171. GroutingNum,
  5172. Remarks,
  5173. KilnID,
  5174. KilnCode,
  5175. KilnName,
  5176. KilnCarID,
  5177. KilnCarCode,
  5178. KilnCarName,
  5179. KilnCarBatchNo,
  5180. KilnCarPosition,
  5181. AccountID,
  5182. ValueFlag,
  5183. :CreateUserID,
  5184. :UpdateUserID,
  5185. SpecialRepairflag,
  5186. :FlowProcedureID,
  5187. FlowProcedureTime,
  5188. :FlowProcedureID,
  5189. ProcedureTime,
  5190. :ProductionDataID,
  5191. logoid, ISREWORKFLAG, SEMICHECKID
  5192. from TP_PM_InProduction
  5193. where barcode=:barcode
  5194. ";
  5195. result = oracleTrConn.ExecuteNonQuery(sqlInsert, parasPDA);
  5196. }
  5197. string sql = "delete tp_pm_inproduction where barcode = :barcode";
  5198. result += oracleTrConn.ExecuteNonQuery(sql, paras);
  5199. // 删除失败
  5200. //if (result != Constant.INT_IS_TWO)//删除在产的同时,应该往产品加收表里插入,这样就是影响行数为2,以前是1
  5201. if (result == Constant.INT_IS_ZERO)
  5202. {
  5203. //return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  5204. }
  5205. // 成功返回null
  5206. return null;
  5207. }
  5208. /// <summary>
  5209. /// 根据窑车ID 删除窑车产品
  5210. /// </summary>
  5211. /// <param name="oracleTrConn">数据连接</param>
  5212. /// <param name="pKilnCarID">窑车ID</param>
  5213. /// <returns>
  5214. /// 张国印 2014.10.04 新建
  5215. /// </returns>
  5216. private static string DeleteKilnCarGoodsByKilnCarID(IDBTransaction oracleTrConn, int pKilnCarID)
  5217. {
  5218. string sql = "delete TP_PM_KilnCarGoods where KilnCarID = :pKilnCarID";
  5219. OracleParameter[] paras = new OracleParameter[] {
  5220. new OracleParameter(":pKilnCarID", OracleDbType.Int32, pKilnCarID, ParameterDirection.Input),
  5221. };
  5222. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  5223. // 删除失败
  5224. if (result <= Constant.INT_IS_ZERO)
  5225. {
  5226. return string.Format(Messages.MSG_CMN_W001, "窑车产品", "保存");
  5227. }
  5228. // 成功返回null
  5229. return null;
  5230. }
  5231. /// <summary>
  5232. /// 添加产成品
  5233. /// </summary>
  5234. /// <param name="oracleTrConn">连接对象</param>
  5235. /// <param name="finishedProduct">产成品对象</param>
  5236. /// <param name="sUserInfo">用户基本信息</param>
  5237. /// <returns>string</returns>
  5238. /// <remarks>
  5239. /// 陈冰 2014.09.18 新建
  5240. /// </remarks>
  5241. private static string AddFinishedProduct(IDBTransaction oracleTrConn,
  5242. FinishedProductEntity finishedProduct, SUserInfo sUserInfo
  5243. , string finishedloadbatchno)
  5244. {
  5245. List<OracleParameter> paras = new List<OracleParameter>();
  5246. string sql = "";
  5247. #region
  5248. // add 2015/11/16
  5249. // if (finishedProduct.LogoID != null && Convert.ToInt32(finishedProduct.LogoID) > 0)
  5250. // {
  5251. // #region SQL
  5252. // //废弃
  5253. // sql = " insert into tp_pm_finishedproduct"
  5254. // + " (barcode, "
  5255. // + " productionlineid, "
  5256. // + " productionlinecode, "
  5257. // + " productionlinename, "
  5258. // + " ispublicbody, "
  5259. // + " isrefire, "
  5260. // + " GoodsLevelID, "
  5261. // + " GoodsLevelTypeID, "
  5262. // + " goodsid, "
  5263. // + " goodscode, "
  5264. // + " goodsname, "
  5265. // + " groutingdailyid, "
  5266. // + " groutingdailydetailid, "
  5267. // + " groutingdate, "
  5268. // + " groutinglineid, "
  5269. // + " groutinglinecode, "
  5270. // + " groutinglinename, "
  5271. // + " gmouldtypeid, "
  5272. // + " groutinglinedetailid, "
  5273. // + " groutingmouldcode, "
  5274. // + " mouldcode, "
  5275. // + " accountdate, "
  5276. // + " accountid, "
  5277. // + " createuserid, "
  5278. // + " updateuserid,"
  5279. // + " groutinguserid, "
  5280. // + " groutingusercode, "
  5281. // + " groutingnum, "
  5282. // + " kilnid, "
  5283. // + " kilncode, "
  5284. // + " kilnname, "
  5285. // + " kilncarid, "
  5286. // + " kilncarcode, "
  5287. // + " kilncarname, "
  5288. // + " kilncarbatchno, "
  5289. // + " kilncarposition, "
  5290. // + " specialRepairflag, "
  5291. // + " logoid "
  5292. // + ") "
  5293. // + " select barcode, "
  5294. // + " productionlineid, "
  5295. // + " productionlinecode, "
  5296. // + " productionlinename, "
  5297. // + " ispublicbody, "
  5298. // + " isrefire, ";
  5299. // #region 产品等级
  5300. // //if (finishedProduct.GoodsGrade == null)
  5301. // //{
  5302. // // sql = sql + " goodsgrade,";
  5303. // //}
  5304. // //// 最后一个工序如果是检验工序,可更改产品等级
  5305. // //else
  5306. // //{
  5307. // // sql = sql + " :goodsgrade, ";
  5308. // // paras.Add(new OracleParameter(":goodsgrade", finishedProduct.GoodsGrade));
  5309. // //}
  5310. // //如果包装时,产成品未走过成检,则直接视为正品
  5311. // int? GoodsLevelTypeID = null;
  5312. // int? GoodsLevelID = null;
  5313. // if (finishedProduct.GoodsLevelID == null)
  5314. // {
  5315. // string sqlQuery = @"select GoodsLevelID,GoodsLevelTypeID from TP_MST_GoodsLevel where GoodsLevelTypeID=
  5316. // (
  5317. // select distinct GoodsLevelTypeID from tp_pm_inproduction where Barcode='" + finishedProduct.BarCode + "'" +
  5318. // ") and AccountID=" + sUserInfo.AccountID;
  5319. // DataSet ds = oracleTrConn.GetSqlResultToDs(sqlQuery);
  5320. // if (ds != null && ds.Tables[0].Rows.Count > 0)
  5321. // {
  5322. // if (ds.Tables[0].Rows[0]["GoodsLevelID"].ToString() != "")
  5323. // {
  5324. // if (Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]) == 5)//副品
  5325. // {
  5326. // GoodsLevelTypeID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]);
  5327. // GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]);
  5328. // }
  5329. // else
  5330. // {
  5331. // string sqlQuery2 = @"select GoodsLevelID,GoodsLevelTypeID from TP_MST_GoodsLevel where GoodsLevelTypeID=4 and AccountID=" + sUserInfo.AccountID;
  5332. // ds = oracleTrConn.GetSqlResultToDs(sqlQuery2);
  5333. // if (ds.Tables[0].Rows[0]["GoodsLevelID"].ToString() != "")
  5334. // {
  5335. // GoodsLevelTypeID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]);
  5336. // GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]);
  5337. // }
  5338. // }
  5339. // }
  5340. // }
  5341. // else
  5342. // {
  5343. // string sqlQuery2 = @"select GoodsLevelID,GoodsLevelTypeID from TP_MST_GoodsLevel where GoodsLevelTypeID=4 and AccountID=" + sUserInfo.AccountID;
  5344. // ds = oracleTrConn.GetSqlResultToDs(sqlQuery2);
  5345. // if (ds.Tables[0].Rows[0]["GoodsLevelID"].ToString() != "")
  5346. // {
  5347. // GoodsLevelTypeID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]);
  5348. // GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]);
  5349. // }
  5350. // }
  5351. // }
  5352. // if (finishedProduct.GoodsLevelID == null)
  5353. // {
  5354. // //sql = sql + " GoodsLevelID,";
  5355. // // 包装后,这个值并没有,这里的值除了在检验的时候会给赋值,其它工序应该没有设置,所以查询了一次
  5356. // ////// sql = sql + @"
  5357. // ////// (select GoodsLevelID from TP_MST_GoodsLevel where GoodsLevelTypeID=
  5358. // ////// (
  5359. // ////// select distinct GoodsLevelTypeID from tp_pm_inproduction where Barcode=:barcode
  5360. // ////// ) and AccountID=:AccountID),";
  5361. // sql = sql + GoodsLevelID.ToString() + " ,";
  5362. // }
  5363. // // 最后一个工序如果是检验工序,可更改产品等级
  5364. // else
  5365. // {
  5366. // sql = sql + " :GoodsLevelID, ";
  5367. // paras.Add(new OracleParameter(":GoodsLevelID", finishedProduct.GoodsLevelID));
  5368. // }
  5369. // if (finishedProduct.GoodsLevelTypeID == null)
  5370. // {
  5371. // //sql = sql + " GoodsLevelTypeID,";
  5372. // sql = sql + GoodsLevelTypeID.ToString() + " ,";
  5373. // }
  5374. // // 最后一个工序如果是检验工序,可更改产品等级
  5375. // else
  5376. // {
  5377. // sql = sql + " :GoodsLevelTypeID, ";
  5378. // paras.Add(new OracleParameter(":GoodsLevelTypeID", finishedProduct.GoodsLevelTypeID));
  5379. // }
  5380. // #endregion
  5381. // sql = sql + " goodsid, "
  5382. // + " goodscode, "
  5383. // + " goodsname, "
  5384. // + " groutingdailyid, "
  5385. // + " groutingdailydetailid, "
  5386. // + " groutingdate, "
  5387. // + " groutinglineid, "
  5388. // + " groutinglinecode, "
  5389. // + " groutinglinename, "
  5390. // + " gmouldtypeid, "
  5391. // + " groutinglinedetailid, "
  5392. // + " groutingmouldcode, "
  5393. // + " mouldcode, "
  5394. // + " fun_cmn_getaccountdate(accountid), "
  5395. // + " accountid, "
  5396. // + " :createuserid, "
  5397. // + " :updateuserid, "
  5398. // + " groutinguserid, "
  5399. // + " groutingusercode, "
  5400. // + " groutingnum, "
  5401. // + " kilnid, "
  5402. // + " kilncode, "
  5403. // + " kilnname, "
  5404. // + " kilncarid, "
  5405. // + " kilncarcode, "
  5406. // + " kilncarname, "
  5407. // + " kilncarbatchno, "
  5408. // + " kilncarposition, "
  5409. // + " specialRepairflag, "
  5410. // + " :logoid "
  5411. // + " from tp_pm_inproduction "
  5412. // + " where Barcode=:barcode";
  5413. // #endregion
  5414. // paras.Add(new OracleParameter(":createuserid", sUserInfo.UserID));
  5415. // paras.Add(new OracleParameter(":updateuserid", sUserInfo.UserID));
  5416. // paras.Add(new OracleParameter(":barcode", finishedProduct.BarCode));
  5417. // paras.Add(new OracleParameter(":logoid", finishedProduct.LogoID));
  5418. // // end 2015/11/16
  5419. // }
  5420. // else
  5421. // {
  5422. #endregion
  5423. #region SQL
  5424. //废弃
  5425. sql = " insert into tp_pm_finishedproduct"
  5426. + " (barcode, "
  5427. + " productionlineid, "
  5428. + " productionlinecode, "
  5429. + " productionlinename, "
  5430. + " ispublicbody, "
  5431. + " isrefire, "
  5432. + " GoodsLevelID, "
  5433. + " GoodsLevelTypeID, "
  5434. + " goodsid, "
  5435. + " goodscode, "
  5436. + " goodsname, "
  5437. + " groutingdailyid, "
  5438. + " groutingdailydetailid, "
  5439. + " groutingdate, "
  5440. + " groutinglineid, "
  5441. + " groutinglinecode, "
  5442. + " groutinglinename, "
  5443. + " gmouldtypeid, "
  5444. + " groutinglinedetailid, "
  5445. + " groutingmouldcode, "
  5446. + " mouldcode, "
  5447. + " accountdate, "
  5448. + " accountid, "
  5449. + " createuserid, "
  5450. + " updateuserid,"
  5451. + " groutinguserid, "
  5452. + " groutingusercode, "
  5453. + " groutingnum, "
  5454. + " kilnid, "
  5455. + " kilncode, "
  5456. + " kilnname, "
  5457. + " kilncarid, "
  5458. + " kilncarcode, "
  5459. + " kilncarname, "
  5460. + " kilncarbatchno, "
  5461. + " kilncarposition, "
  5462. + " specialRepairflag, "
  5463. + " logoid,OnlyCode ,finishedloadbatchno"
  5464. + ") "
  5465. + " select barcode, "
  5466. + " productionlineid, "
  5467. + " productionlinecode, "
  5468. + " productionlinename, "
  5469. + " ispublicbody, "
  5470. + " isrefire, ";
  5471. #region 产品等级
  5472. //if (finishedProduct.GoodsGrade == null)
  5473. //{
  5474. // sql = sql + " goodsgrade,";
  5475. //}
  5476. //// 最后一个工序如果是检验工序,可更改产品等级
  5477. //else
  5478. //{
  5479. // sql = sql + " :goodsgrade, ";
  5480. // paras.Add(new OracleParameter(":goodsgrade", finishedProduct.GoodsGrade));
  5481. //}
  5482. //如果包装时,产成品未走过成检,则直接视为正品
  5483. int? GoodsLevelTypeID = null;
  5484. int? GoodsLevelID = null;
  5485. if (finishedProduct.GoodsLevelID == null)
  5486. {
  5487. string sqlQuery = @"select GoodsLevelID,GoodsLevelTypeID from TP_MST_GoodsLevel where GoodsLevelTypeID=
  5488. (
  5489. select distinct GoodsLevelTypeID from tp_pm_inproduction where Barcode='" + finishedProduct.BarCode + "'" +
  5490. ") and AccountID=" + sUserInfo.AccountID;
  5491. DataSet ds = oracleTrConn.GetSqlResultToDs(sqlQuery);
  5492. if (ds != null && ds.Tables[0].Rows.Count > 0)
  5493. {
  5494. if (ds.Tables[0].Rows[0]["GoodsLevelID"].ToString() != "")
  5495. {
  5496. if (Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]) == 5)//副品
  5497. {
  5498. GoodsLevelTypeID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]);
  5499. GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]);
  5500. }
  5501. else if (Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]) == 4)//正品
  5502. {
  5503. string sqlQuery2 = @"select GoodsLevelID,GoodsLevelTypeID from TP_MST_GoodsLevel where GoodsLevelTypeID=4 and AccountID=" + sUserInfo.AccountID;
  5504. ds = oracleTrConn.GetSqlResultToDs(sqlQuery2);
  5505. if (ds.Tables[0].Rows[0]["GoodsLevelID"].ToString() != "")
  5506. {
  5507. GoodsLevelTypeID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]);
  5508. GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]);
  5509. }
  5510. }
  5511. else
  5512. {
  5513. GoodsLevelTypeID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]);
  5514. GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]);
  5515. }
  5516. }
  5517. }
  5518. else
  5519. {
  5520. string sqlQuery2 = @"select GoodsLevelID,GoodsLevelTypeID from TP_MST_GoodsLevel where GoodsLevelTypeID=4 and AccountID=" + sUserInfo.AccountID;
  5521. ds = oracleTrConn.GetSqlResultToDs(sqlQuery2);
  5522. if (ds.Tables[0].Rows[0]["GoodsLevelID"].ToString() != "")
  5523. {
  5524. GoodsLevelTypeID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]);
  5525. GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]);
  5526. }
  5527. }
  5528. }
  5529. if (finishedProduct.GoodsLevelID == null)
  5530. {
  5531. //sql = sql + " GoodsLevelID,";
  5532. // 包装后,这个值并没有,这里的值除了在检验的时候会给赋值,其它工序应该没有设置,所以查询了一次
  5533. ////// sql = sql + @"
  5534. ////// (select GoodsLevelID from TP_MST_GoodsLevel where GoodsLevelTypeID=
  5535. ////// (
  5536. ////// select distinct GoodsLevelTypeID from tp_pm_inproduction where Barcode=:barcode
  5537. ////// ) and AccountID=:AccountID),";
  5538. sql = sql + GoodsLevelID.ToString() + " ,";
  5539. }
  5540. // 最后一个工序如果是检验工序,可更改产品等级
  5541. else
  5542. {
  5543. sql = sql + " :GoodsLevelID, ";
  5544. paras.Add(new OracleParameter(":GoodsLevelID", finishedProduct.GoodsLevelID));
  5545. }
  5546. if (finishedProduct.GoodsLevelTypeID == null)
  5547. {
  5548. //sql = sql + " GoodsLevelTypeID,";
  5549. sql = sql + GoodsLevelTypeID.ToString() + " ,";
  5550. }
  5551. // 最后一个工序如果是检验工序,可更改产品等级
  5552. else
  5553. {
  5554. sql = sql + " :GoodsLevelTypeID, ";
  5555. paras.Add(new OracleParameter(":GoodsLevelTypeID", finishedProduct.GoodsLevelTypeID));
  5556. }
  5557. #endregion
  5558. sql = sql + " goodsid, "
  5559. + " goodscode, "
  5560. + " goodsname, "
  5561. + " groutingdailyid, "
  5562. + " groutingdailydetailid, "
  5563. + " groutingdate, "
  5564. + " groutinglineid, "
  5565. + " groutinglinecode, "
  5566. + " groutinglinename, "
  5567. + " gmouldtypeid, "
  5568. + " groutinglinedetailid, "
  5569. + " groutingmouldcode, "
  5570. + " mouldcode, "
  5571. + " fun_cmn_getaccountdate(accountid), "
  5572. + " accountid, "
  5573. + " :createuserid, "
  5574. + " :updateuserid, "
  5575. + " groutinguserid, "
  5576. + " groutingusercode, "
  5577. + " groutingnum, "
  5578. + " kilnid, "
  5579. + " kilncode, "
  5580. + " kilnname, "
  5581. + " kilncarid, "
  5582. + " kilncarcode, "
  5583. + " kilncarname, "
  5584. + " kilncarbatchno, "
  5585. + " kilncarposition, "
  5586. + " specialRepairflag, "
  5587. + " logoid, "
  5588. + " (select OnlyCode from tp_pm_groutingdailydetail where barcode=:barcode), :finishedloadbatchno"
  5589. + " from tp_pm_inproduction "
  5590. + " where Barcode=:barcode";
  5591. #endregion
  5592. paras.Add(new OracleParameter(":createuserid", sUserInfo.UserID));
  5593. paras.Add(new OracleParameter(":updateuserid", sUserInfo.UserID));
  5594. paras.Add(new OracleParameter(":barcode", finishedProduct.BarCode));
  5595. paras.Add(new OracleParameter(":finishedloadbatchno", finishedloadbatchno));
  5596. //}
  5597. //paras.Add(new OracleParameter(":AccountID", sUserInfo.AccountID));
  5598. int result = oracleTrConn.ExecuteNonQuery(sql, paras.ToArray());
  5599. // 保存失败
  5600. if (result != Constant.INT_IS_ONE)
  5601. {
  5602. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  5603. }
  5604. // 保存成功返回null
  5605. return null;
  5606. }
  5607. /// <summary>
  5608. /// 添加在产产品数据
  5609. /// </summary>
  5610. /// <param name="oracleTrConn">连接对象</param>
  5611. /// <param name="inProduction">在产产品实体类</param>
  5612. /// <param name="sUserInfo">用户基本信息</param>
  5613. /// <param name="isSendBody">是否交坯</param>
  5614. /// <returns>string</returns>
  5615. /// <remarks>
  5616. /// 陈冰 2014.09.18 新建
  5617. /// </remarks>
  5618. private static string AddInProduction(IDBTransaction oracleTrConn, InProductionEntity inProduction, SUserInfo sUserInfo, DataSet _dsDataset, bool isSendBody = false)
  5619. {
  5620. #region SQL
  5621. string sqlExist = "select 1 from tp_pm_inproduction where barcode = :barcode ";
  5622. OracleParameter[] parasExist = new OracleParameter[] {
  5623. new OracleParameter(":barcode",inProduction.BarCode.Trim()),
  5624. };
  5625. DataSet dsresult = oracleTrConn.GetSqlResultToDs(sqlExist, parasExist);
  5626. if (dsresult != null && dsresult.Tables[0].Rows.Count == 0)
  5627. {
  5628. // 获取生产线ID,生产线名称,生产编码
  5629. string sql = @"select TP_PC_ProductionLine.ProductionLineID,TP_PC_ProductionLine.ProductionLineCode,TP_PC_ProductionLine.ProductionLineName
  5630. from TP_PC_Procedure inner join TP_PC_ProductionLine
  5631. on TP_PC_Procedure.ProductionLineID=TP_PC_ProductionLine.ProductionLineID
  5632. where TP_PC_Procedure.ProcedureID=:ProcedureID
  5633. ";
  5634. OracleParameter[] paras = new OracleParameter[] {
  5635. new OracleParameter(":ProcedureID",inProduction.FlowProcedureID),
  5636. };
  5637. dsresult = oracleTrConn.GetSqlResultToDs(sql, paras);
  5638. #region 获取生产线信息
  5639. int ProductionLineID = 0;//生产线ID
  5640. string ProductionLineCode = "", ProductionLineName = "";//生产线名称,编码
  5641. if (dsresult != null && dsresult.Tables[0].Rows.Count > 0)
  5642. {
  5643. ProductionLineID = Convert.ToInt32(dsresult.Tables[0].Rows[0]["ProductionLineID"]);
  5644. ProductionLineCode = dsresult.Tables[0].Rows[0]["ProductionLineCode"].ToString();
  5645. ProductionLineName = dsresult.Tables[0].Rows[0]["ProductionLineName"].ToString();
  5646. }
  5647. #endregion
  5648. #region 获取注浆信息
  5649. // sql = @"select
  5650. // TP_PM_GroutingDailyDetail.UserID as GroutingUserID,
  5651. // TP_PM_GroutingDailyDetail.UserCode as GroutingUserCode,
  5652. // TP_PM_GroutingDailyDetail.GroutingCount as GroutingNum,
  5653. // TP_PM_GroutingDailyDetail.GroutingMouldCode,
  5654. // TP_PM_GroutingDailyDetail.MouldCode,
  5655. // TP_PM_GroutingDailyDetail.GroutingDailyID,
  5656. // TP_PM_GroutingDailyDetail.GroutingDailyDetailID,
  5657. // TP_PM_GroutingDailyDetail.GroutingLineID,
  5658. // TP_PM_GroutingDailyDetail.GroutingLineCode,
  5659. // TP_PM_GroutingDailyDetail.GroutingLineName,
  5660. // TP_PM_GroutingDaily.GMouldTypeID,
  5661. // TP_PM_GroutingDaily.CanManyTimes,
  5662. // TP_PM_GroutingDailyDetail.GroutingLineDetailID,
  5663. // TP_PM_GroutingDailyDetail.SpecialRepairflag,
  5664. // TP_PM_GroutingDailyDetail.GoodsID,
  5665. // TP_PM_GroutingDailyDetail.GoodsCode,
  5666. // TP_PM_GroutingDailyDetail.GoodsName,
  5667. // TP_PM_GroutingDailyDetail.GroutingDate
  5668. // from TP_PM_GroutingDaily
  5669. // inner join TP_PM_GroutingDailyDetail
  5670. // on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_GroutingDailyDetail.GroutingDailyID
  5671. // where TP_PM_GroutingDailyDetail.barcode=:barcode";
  5672. // sql = @"select
  5673. // UserID as GroutingUserID,
  5674. // UserCode as GroutingUserCode,
  5675. // GroutingCount as GroutingNum,
  5676. // GroutingMouldCode,
  5677. // MouldCode,
  5678. // GroutingDailyID,
  5679. // GroutingDailyDetailID,
  5680. // GroutingLineID,
  5681. // GroutingLineCode,
  5682. // GroutingLineName,
  5683. // GroutingLineDetailID,
  5684. // SpecialRepairflag,
  5685. // GoodsID,
  5686. // GoodsCode,
  5687. // GoodsName,
  5688. // GroutingDate,
  5689. // (select GMouldTypeID
  5690. // from TP_PM_GroutingDaily
  5691. // where TP_PM_GroutingDaily.GroutingDailyID =
  5692. // TP_PM_GroutingDailyDetail.GroutingDailyID) as GMouldTypeID,
  5693. // (select CanManyTimes
  5694. // from TP_PM_GroutingDaily
  5695. // where TP_PM_GroutingDaily.GroutingDailyID =
  5696. // TP_PM_GroutingDailyDetail.GroutingDailyID) as CanManyTimes
  5697. // from TP_PM_GroutingDailyDetail
  5698. // where TP_PM_GroutingDailyDetail.barcode=:barcode";
  5699. // sql = @"select
  5700. // GroutingUserID,
  5701. // GroutingUserCode,
  5702. // GroutingNum,
  5703. // GroutingMouldCode,
  5704. // MouldCode,
  5705. // GroutingDailyID,
  5706. // GroutingDailyDetailID,
  5707. // GroutingLineID,
  5708. // GroutingLineCode,
  5709. // GroutingLineName,
  5710. // GroutingLineDetailID,
  5711. // SpecialRepairflag,
  5712. // GoodsID,
  5713. // GoodsCode,
  5714. // GoodsName,
  5715. // GroutingDate,
  5716. // GMouldTypeID
  5717. // CanManyTimes
  5718. // from tp_pm_productiondata
  5719. // where tp_pm_productiondata.barcode=:barcode";
  5720. // paras = new OracleParameter[] {
  5721. // new OracleParameter(":barcode",inProduction.BarCode),
  5722. // };
  5723. dsresult = _dsDataset;
  5724. //dsresult = oracleTrConn.GetSqlResultToDs(sql, paras);
  5725. // 产品ID, 注浆登记ID, 注浆明细ID, 成型线ID 成型线类型ID 能否多次注浆 成型生产线明细ID
  5726. int goodsid = 0, groutingDailyID = 0, groutingdailydetailid = 0, groutinglineid = 0, gMouldTypeID = 0, canManyTimes = 0, groutingLineDetailID = 0;
  5727. // 产品编码, 产品名称 成型线编码 成型线名称 注浆模具编号 模具编号
  5728. string goodsCode = "", goodsName = "", groutingLineCode = "", groutingLineName = "", groutingmouldcode = "", mouldCode = "";
  5729. DateTime? groutingdate = null; // 注浆日期
  5730. int groutingUserID = 0, groutingNum = 0; //注浆工号ID,注浆次数
  5731. string groutingUserCode = "";//注浆工号
  5732. int? LogoID = null;
  5733. if (dsresult != null && dsresult.Tables[0].Rows.Count > 0)
  5734. {
  5735. goodsid = Convert.ToInt32(dsresult.Tables[0].Rows[0]["GoodsID"]);
  5736. groutingDailyID = Convert.ToInt32(dsresult.Tables[0].Rows[0]["GroutingDailyID"]);
  5737. groutingdailydetailid = Convert.ToInt32(dsresult.Tables[0].Rows[0]["GroutingDailyDetailID"]);
  5738. groutinglineid = Convert.ToInt32(dsresult.Tables[0].Rows[0]["GroutingLineID"]);
  5739. groutingLineDetailID = Convert.ToInt32(dsresult.Tables[0].Rows[0]["GroutingLineDetailID"]);
  5740. groutingdate = Convert.ToDateTime(dsresult.Tables[0].Rows[0]["GroutingDate"]);
  5741. goodsCode = dsresult.Tables[0].Rows[0]["GoodsCode"].ToString();
  5742. goodsName = dsresult.Tables[0].Rows[0]["GoodsName"].ToString();
  5743. groutingLineCode = dsresult.Tables[0].Rows[0]["GroutingLineCode"].ToString();
  5744. groutingLineName = dsresult.Tables[0].Rows[0]["GroutingLineName"].ToString();
  5745. groutingmouldcode = dsresult.Tables[0].Rows[0]["GroutingMouldCode"].ToString();
  5746. mouldCode = dsresult.Tables[0].Rows[0]["MouldCode"].ToString();
  5747. groutingUserCode = dsresult.Tables[0].Rows[0]["GroutingUserCode"].ToString();
  5748. groutingUserID = Convert.ToInt32(dsresult.Tables[0].Rows[0]["GroutingUserID"]);
  5749. gMouldTypeID = Convert.ToInt32(dsresult.Tables[0].Rows[0]["GMouldTypeID"]);
  5750. canManyTimes = Convert.ToInt32(dsresult.Tables[0].Rows[0]["CanManyTimes"]);
  5751. groutingNum = Convert.ToInt32(dsresult.Tables[0].Rows[0]["GroutingNum"]);
  5752. if (dsresult.Tables[0].Rows[0]["logoid"].ToString() != "")
  5753. {
  5754. LogoID = Convert.ToInt32(dsresult.Tables[0].Rows[0]["logoid"]);
  5755. }
  5756. }
  5757. #endregion
  5758. sql = " insert into tp_pm_inproduction"
  5759. + " ( barcode,"
  5760. + " productionlineid,"
  5761. + " productionlinecode,"
  5762. + " productionlinename,"
  5763. + " proceduremodel,"
  5764. + " modeltype,"
  5765. + " ispublicbody,"
  5766. + " goodsid,"
  5767. + " goodscode,"
  5768. + " goodsname,"
  5769. + " userid,"
  5770. + " groutingdailyid,"
  5771. + " groutingdailydetailid,"
  5772. + " groutingdate,"
  5773. + " groutinglineid,"
  5774. + " groutinglinecode,"
  5775. + " groutinglinename,"
  5776. + " gmouldtypeid,"
  5777. + " canmanytimes,"
  5778. + " groutinglinedetailid,"
  5779. + " groutingmouldcode,"
  5780. + " mouldcode,"
  5781. + " accountid,"
  5782. + " createuserid,"
  5783. + " updateuserid,GoodsLevelTypeID,"
  5784. + " GroutingUserID,"
  5785. + " GroutingUserCode,"
  5786. + " GroutingNum,"
  5787. + " SpecialRepairflag,"
  5788. + " FlowProcedureID,"
  5789. + " FlowProcedureTime,"
  5790. + " ProcedureID,"
  5791. + " ProcedureTime,"
  5792. + " ProductionDataID,logoid"
  5793. + " ) values ("
  5794. + " :barcode,"
  5795. + " :productionlineid,"
  5796. + " :productionlinecode,"
  5797. + " :productionlinename,"
  5798. + " :procedureModel,"
  5799. + " :modelType,"
  5800. + " :isPublicBody,"
  5801. + " :goodsid,"
  5802. + " :goodscode,"
  5803. + " :goodsname,"
  5804. + " :userID,"
  5805. + " :groutingdailyid,"
  5806. + " :groutingdailydetailid,"
  5807. + " :groutingdate,"
  5808. + " :groutinglineid,"
  5809. + " :groutinglinecode,"
  5810. + " :groutinglinename,"
  5811. + " :gmouldtypeid,"
  5812. + " :canmanytimes,"
  5813. + " :groutinglinedetailid,"
  5814. + " :groutingmouldcode,"
  5815. + " :mouldcode,"
  5816. + " :accountID,"
  5817. + " :createUserID,"
  5818. + " :updateUserID,"
  5819. + " null,"
  5820. + " :groutinguserid,"
  5821. + " :groutingusercode,"
  5822. + " :groutingnum,"
  5823. + " :specialRepairflag,"
  5824. + " :flowProcedureID,"
  5825. + " sysdate,"
  5826. + " :procedureID,"
  5827. + " sysdate,"
  5828. + " :productionDataID,:logoid"
  5829. + " ) ";
  5830. #endregion
  5831. paras = new OracleParameter[] {
  5832. new OracleParameter(":procedureModel",inProduction.ProcedureModel),
  5833. new OracleParameter(":modelType",inProduction.ModelType),
  5834. new OracleParameter(":isPublicBody",inProduction.IsPublicBody),
  5835. new OracleParameter(":userID",inProduction.UserID),
  5836. new OracleParameter(":accountID",sUserInfo.AccountID),
  5837. new OracleParameter(":createUserID",sUserInfo.UserID),
  5838. new OracleParameter(":updateUserID",sUserInfo.UserID),
  5839. new OracleParameter(":barcode",inProduction.BarCode),
  5840. new OracleParameter(":specialRepairflag",inProduction.SpecialRepairflag),
  5841. new OracleParameter(":productionlineid",ProductionLineID),//---开始赋值
  5842. new OracleParameter(":productionlinecode",ProductionLineCode),
  5843. new OracleParameter(":productionlinename",ProductionLineName),
  5844. new OracleParameter(":goodsid",goodsid),
  5845. new OracleParameter(":goodscode",goodsCode),
  5846. new OracleParameter(":goodsname",goodsName),
  5847. new OracleParameter(":groutingdailyid",groutingDailyID),
  5848. new OracleParameter(":groutingdailydetailid",groutingdailydetailid),
  5849. new OracleParameter(":groutingdate",groutingdate),
  5850. new OracleParameter(":groutinglineid",groutinglineid),
  5851. new OracleParameter(":groutinglinecode",groutingLineCode),
  5852. new OracleParameter(":groutinglinename",groutingLineName),
  5853. new OracleParameter(":gmouldtypeid",gMouldTypeID),
  5854. new OracleParameter(":canmanytimes",canManyTimes),
  5855. new OracleParameter(":groutinglinedetailid",groutingLineDetailID),
  5856. new OracleParameter(":groutingmouldcode",groutingmouldcode),
  5857. new OracleParameter(":mouldcode",mouldCode),
  5858. new OracleParameter(":groutinguserid",groutingUserID),
  5859. new OracleParameter(":groutingusercode",groutingUserCode),
  5860. new OracleParameter(":groutingnum",groutingNum),
  5861. new OracleParameter(":flowProcedureID",inProduction.FlowProcedureID),
  5862. new OracleParameter(":procedureID",inProduction.FlowProcedureID),
  5863. new OracleParameter(":productionDataID",inProduction.ProductionDataID),
  5864. new OracleParameter(":logoid",LogoID),
  5865. };
  5866. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  5867. // 保存失败
  5868. if (result != Constant.INT_IS_ONE)
  5869. {
  5870. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  5871. }
  5872. //xuwei fix begin
  5873. //2019-09-17
  5874. //更新用过条码
  5875. //交坯=4,在产=3
  5876. string barcodeStatus = isSendBody ? "4" : "3";
  5877. string updateUsedBarCode = "update TP_PM_USEDBARCODE set barcodestatus=" + barcodeStatus + " where barcode='" + inProduction.BarCode + "'";
  5878. oracleTrConn.ExecuteNonQuery(updateUsedBarCode);
  5879. //xuwei end
  5880. }
  5881. // 保存成功返回null
  5882. return null;
  5883. }
  5884. /// <summary>
  5885. /// 根据最大生产数据ID,获取窑车窑炉等信息
  5886. /// </summary>
  5887. /// <param name="oracleTrConn"></param>
  5888. /// <param name="barcode"></param>
  5889. /// <param name="sUserInfo"></param>
  5890. /// <returns></returns>
  5891. private static DataSet GetFinishCheckKilnCarInfo(IDBTransaction oracleTrConn, string barcode, SUserInfo sUserInfo)
  5892. {
  5893. string sql = @"select
  5894. KilnID,
  5895. KilnCode,
  5896. KilnName,
  5897. KilnCarID,
  5898. KilnCarCode,
  5899. KilnCarName,
  5900. to_char(KilnCarBatchNo) as KilnCarBatchNo,
  5901. KilnCarPosition
  5902. from tp_pm_inproduction where barcode=:barcode
  5903. union
  5904. select
  5905. KilnID,
  5906. KilnCode,
  5907. KilnName,
  5908. KilnCarID,
  5909. KilnCarCode,
  5910. KilnCarName,
  5911. to_char(KilnCarBatchNo) as KilnCarBatchNo,
  5912. KilnCarPosition
  5913. from TP_PM_InProductionTrash where barcode=:barcode
  5914. ";
  5915. try
  5916. {
  5917. IDataParameter[] paras = new OracleParameter[]
  5918. {
  5919. new OracleParameter(":barcode", OracleDbType.Varchar2, barcode, ParameterDirection.Input),
  5920. };
  5921. DataSet returnDs = oracleTrConn.GetSqlResultToDs(sql, paras);
  5922. if (returnDs != null
  5923. && returnDs.Tables.Count > Constant.INT_IS_ZERO
  5924. && returnDs.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  5925. {
  5926. return returnDs;
  5927. }
  5928. else
  5929. {
  5930. return null;
  5931. }
  5932. }
  5933. catch (Exception ex)
  5934. {
  5935. throw ex;
  5936. }
  5937. }
  5938. /// <summary>
  5939. /// 根据最大生产数据ID,获取窑车窑炉等信息
  5940. /// </summary>
  5941. /// <param name="oracleTrConn"></param>
  5942. /// <param name="barcode"></param>
  5943. /// <param name="sUserInfo"></param>
  5944. /// <returns></returns>
  5945. private static DataSet GetKilnCarInfo(IDBTransaction oracleTrConn, string barcode, SUserInfo sUserInfo)
  5946. {
  5947. // string sql = @"select * from tp_pm_productiondata where Productiondataid=
  5948. // (
  5949. // select nvl(max(Productiondataid),0) Productiondataid from tp_pm_productiondata where barcode=:barcode
  5950. // )";
  5951. // string sql = @"select
  5952. // KilnID,
  5953. // KilnCode,
  5954. // KilnName,
  5955. // KilnCarID,
  5956. // KilnCarCode,
  5957. // KilnCarName,
  5958. // to_char(KilnCarBatchNo) as KilnCarBatchNo,
  5959. // KilnCarPosition
  5960. // from tp_pm_inproduction where barcode=:barcode
  5961. // union
  5962. // select
  5963. // KilnID,
  5964. // KilnCode,
  5965. // KilnName,
  5966. // KilnCarID,
  5967. // KilnCarCode,
  5968. // KilnCarName,
  5969. // to_char(KilnCarBatchNo) as KilnCarBatchNo,
  5970. // KilnCarPosition
  5971. // from TP_PM_InProductionTrash where barcode=:barcode
  5972. //";
  5973. string sql = @"select
  5974. KilnID,
  5975. KilnCode,
  5976. KilnName,
  5977. KilnCarID,
  5978. KilnCarCode,
  5979. KilnCarName,
  5980. to_char(KilnCarBatchNo) as KilnCarBatchNo,
  5981. KilnCarPosition
  5982. from tp_pm_inproduction where barcode=:barcode
  5983. ";
  5984. try
  5985. {
  5986. IDataParameter[] paras = new OracleParameter[]
  5987. {
  5988. new OracleParameter(":barcode", OracleDbType.Varchar2, barcode, ParameterDirection.Input),
  5989. };
  5990. DataSet returnDs = oracleTrConn.GetSqlResultToDs(sql, paras);
  5991. if (returnDs != null
  5992. && returnDs.Tables.Count > Constant.INT_IS_ZERO
  5993. && returnDs.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  5994. {
  5995. return returnDs;
  5996. }
  5997. else
  5998. {
  5999. return null;
  6000. }
  6001. }
  6002. catch (Exception ex)
  6003. {
  6004. throw ex;
  6005. }
  6006. }
  6007. /// <summary>
  6008. /// 修改在产数据
  6009. /// </summary>
  6010. /// <param name="oracleTrConn">连接对象</param>
  6011. /// <param name="inProduction">在产数据实体类</param>
  6012. /// <param name="sUserInfo">用户基本信息</param>
  6013. /// <returns>string</returns>
  6014. /// <remarks>
  6015. /// 陈冰 2014.09.18 新建
  6016. /// </remarks>
  6017. private static string UpdateInProduction(IDBTransaction oracleTrConn, InProductionEntity inProduction, SUserInfo sUserInfo)
  6018. {
  6019. List<OracleParameter> paras = new List<OracleParameter>();
  6020. //paras.Add(new OracleParameter(":completeProcedureID", inProduction.CompleteProcedureID));
  6021. paras.Add(new OracleParameter(":procedureModel", inProduction.ProcedureModel));
  6022. paras.Add(new OracleParameter(":modelType", inProduction.ModelType));
  6023. paras.Add(new OracleParameter(":defectFlag", inProduction.DefectFlag));
  6024. paras.Add(new OracleParameter(":reworkProcedureID", inProduction.ReworkProcedureID));
  6025. paras.Add(new OracleParameter(":flowprocedureid", inProduction.FlowProcedureID));
  6026. paras.Add(new OracleParameter(":procedureID", inProduction.ProcedureID));
  6027. paras.Add(new OracleParameter(":productionDataID", inProduction.ProductionDataID));
  6028. #region SQL
  6029. string sql = " update TP_PM_InProduction "
  6030. //+ " set CompleteProcedureID = :completeProcedureID,"
  6031. + "set ProcedureModel = :procedureModel,"
  6032. + " ModelType = :modelType,"
  6033. + " DefectFlag = :defectFlag,"
  6034. + " flowprocedureid = :flowprocedureid,"
  6035. + " flowproceduretime = sysdate,"
  6036. + " procedureID = :procedureID,"
  6037. + " procedureTime = sysdate,"
  6038. + " productionDataID = :productionDataID,"
  6039. // + " GoodsLevelTypeID = :GoodsLevelTypeID,"
  6040. // 扫码后,返修标识清除
  6041. + " isreworkflag = '0',"
  6042. + " ReworkProcedureID = :reworkProcedureID,";
  6043. #region 只有交坯工序是才传值更改公坯字段
  6044. if (inProduction.IsPublicBody != null)
  6045. {
  6046. sql = sql + " IsPublicBody = :isPublicBody,";
  6047. paras.Add(new OracleParameter(":isPublicBody", inProduction.IsPublicBody));
  6048. }
  6049. #endregion
  6050. #region 只有走特定返工工序时才更改重烧字段
  6051. if (inProduction.IsReFire != null)
  6052. {
  6053. sql = sql + " IsReFire = :isReFire,";
  6054. paras.Add(new OracleParameter(":isReFire", inProduction.IsReFire));
  6055. }
  6056. #endregion
  6057. #region 只有成检时才更新产品分级字段
  6058. //if (inProduction.GoodsGrade != null)
  6059. //{
  6060. // sql = sql + " GoodsGrade = :goodsGrade,";
  6061. // paras.Add(new OracleParameter(":goodsGrade", inProduction.GoodsGrade));
  6062. //}
  6063. if (inProduction.GoodsLevelID != null)
  6064. {
  6065. sql = sql + " GoodsLevelID = :GoodsLevelID,";
  6066. paras.Add(new OracleParameter(":GoodsLevelID", inProduction.GoodsLevelID));
  6067. }
  6068. if (inProduction.GoodsLevelTypeID != null)
  6069. {
  6070. sql = sql + " GoodsLevelTypeID = :GoodsLevelTypeID,";
  6071. paras.Add(new OracleParameter(":GoodsLevelTypeID", inProduction.GoodsLevelTypeID));
  6072. }
  6073. #region 更新窑炉窑车属性
  6074. if (inProduction.ModelType == 1 || inProduction.ModelType == 2 || inProduction.ModelType == 3 || inProduction.ModelType == 4 || inProduction.ModelType == 6)
  6075. {
  6076. sql = sql + " KilnID = :KilnID,";
  6077. paras.Add(new OracleParameter(":KilnID", inProduction.KilnID));
  6078. sql = sql + " KilnCode = :KilnCode,";
  6079. paras.Add(new OracleParameter(":KilnCode", inProduction.KilnCode));
  6080. sql = sql + " KilnName = :KilnName,";
  6081. paras.Add(new OracleParameter(":KilnName", inProduction.KilnName));
  6082. sql = sql + " KilnCarID = :KilnCarID,";
  6083. paras.Add(new OracleParameter(":KilnCarID", inProduction.KilnCarID));
  6084. sql = sql + " KilnCarCode = :KilnCarCode,";
  6085. paras.Add(new OracleParameter(":KilnCarCode", inProduction.KilnCarCode));
  6086. sql = sql + " KilnCarName = :KilnCarName,";
  6087. paras.Add(new OracleParameter(":KilnCarName", inProduction.KilnCarName));
  6088. sql = sql + " KilnCarBatchNo = :KilnCarBatchNo,";
  6089. paras.Add(new OracleParameter(":KilnCarBatchNo", inProduction.KilnCarBatchNo));
  6090. sql = sql + " KilnCarPosition = :KilnCarPosition,";
  6091. paras.Add(new OracleParameter(":KilnCarPosition", inProduction.KilnCarPosition));
  6092. }
  6093. else
  6094. {
  6095. //
  6096. ////////DataSet ds = GetKilnCarInfo(oracleTrConn, inProduction.BarCode, sUserInfo);
  6097. ////////if (ds != null)
  6098. ////////{
  6099. //////// if (ds.Tables[0].Rows[0]["KilnID"].ToString() != "") //表示以前有过窑炉相关信息
  6100. //////// {
  6101. //////// sql = sql + " KilnID = :KilnID,";
  6102. //////// paras.Add(new OracleParameter(":KilnID", Convert.ToInt32(ds.Tables[0].Rows[0]["KilnID"])));
  6103. //////// sql = sql + " KilnCode = :KilnCode,";
  6104. //////// paras.Add(new OracleParameter(":KilnCode", ds.Tables[0].Rows[0]["KilnCode"].ToString()));
  6105. //////// sql = sql + " KilnName = :KilnName,";
  6106. //////// paras.Add(new OracleParameter(":KilnName", ds.Tables[0].Rows[0]["KilnName"].ToString()));
  6107. //////// sql = sql + " KilnCarID = :KilnCarID,";
  6108. //////// paras.Add(new OracleParameter(":KilnCarID", Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarID"])));
  6109. //////// sql = sql + " KilnCarCode = :KilnCarCode,";
  6110. //////// paras.Add(new OracleParameter(":KilnCarCode", ds.Tables[0].Rows[0]["KilnCarCode"].ToString()));
  6111. //////// sql = sql + " KilnCarName = :KilnCarName,";
  6112. //////// paras.Add(new OracleParameter(":KilnCarName", ds.Tables[0].Rows[0]["KilnCarName"].ToString()));
  6113. //////// sql = sql + " KilnCarBatchNo = :KilnCarBatchNo,";
  6114. //////// paras.Add(new OracleParameter(":KilnCarBatchNo", ds.Tables[0].Rows[0]["KilnCarBatchNo"].ToString()));
  6115. //////// sql = sql + " KilnCarPosition = :KilnCarPosition,";
  6116. //////// paras.Add(new OracleParameter(":KilnCarPosition", Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarPosition"])));
  6117. //////// }
  6118. ////////}
  6119. }
  6120. #endregion
  6121. #endregion
  6122. #region 更新在产商标
  6123. if (inProduction.LogoID != null)
  6124. {
  6125. sql = sql + " LogoID = :LogoID,";
  6126. paras.Add(new OracleParameter(":LogoID", inProduction.LogoID));
  6127. }
  6128. #endregion
  6129. sql = sql + " UserID = :userID,"
  6130. + " UpdateUserID = :updateUserID"
  6131. + " where Barcode = :barCode";
  6132. #endregion
  6133. paras.Add(new OracleParameter(":userID", inProduction.UserID));
  6134. paras.Add(new OracleParameter(":updateUserID", sUserInfo.UserID));
  6135. paras.Add(new OracleParameter(":barCode", inProduction.BarCode));
  6136. foreach (var para in paras)
  6137. {
  6138. if (para.Value + "" == "")
  6139. {
  6140. para.Value = DBNull.Value;
  6141. }
  6142. }
  6143. int result = oracleTrConn.ExecuteNonQuery(sql, paras.ToArray());
  6144. // 保存失败
  6145. if (result != Constant.INT_IS_ONE)
  6146. {
  6147. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  6148. }
  6149. // 保存成功返回null
  6150. return null;
  6151. }
  6152. /// <summary>
  6153. /// 校验条码有效
  6154. /// </summary>
  6155. /// <param name="oracleTrConn">连接对象</param>
  6156. /// <param name="procedureID">工序ID</param>
  6157. /// <param name="barcode">条码</param>
  6158. /// <param name="goodsID">返回的产品ID</param>
  6159. /// <param name="goodsCode">返回的产品Code</param>
  6160. /// <param name="goodsName">返回的产品名称</param>
  6161. /// <param name="groutingUserID">返回的注浆者ID</param>
  6162. /// <returns>string</returns>
  6163. /// <remarks>
  6164. /// 陈冰 2014.09.18 新建
  6165. /// </remarks>
  6166. private static string CheckBarcode(IDBTransaction oracleTrConn,
  6167. int procedureID,
  6168. string barcode,
  6169. out int goodsID,
  6170. out string goodsCode,
  6171. out string goodsName,
  6172. out string groutingUserCode,
  6173. SUserInfo sUserInfo
  6174. )
  6175. {
  6176. try
  6177. {
  6178. OracleParameter[] paras = new OracleParameter[]{
  6179. new OracleParameter("in_procedureid",OracleDbType.Int32,procedureID,ParameterDirection.Input),
  6180. new OracleParameter("in_barcode",OracleDbType.Varchar2,barcode,ParameterDirection.Input),
  6181. new OracleParameter("out_errMsg",OracleDbType.Varchar2,2000,"",ParameterDirection.Output),
  6182. new OracleParameter("out_goodsID",OracleDbType.Int32,ParameterDirection.Output),
  6183. new OracleParameter("out_goodsCode",OracleDbType.Varchar2,50,"",ParameterDirection.Output),
  6184. new OracleParameter("out_goodsName",OracleDbType.Varchar2,50,"",ParameterDirection.Output),
  6185. new OracleParameter("out_groutingUserCode",OracleDbType.NVarchar2,50,null,ParameterDirection.Output),
  6186. new OracleParameter("out_errMsg_Status",OracleDbType.Varchar2,50,"",ParameterDirection.Output),
  6187. };
  6188. oracleTrConn.ExecStoredProcedure("PRO_PM_CheckBarcode", paras);
  6189. if (!"null".Equals(paras[3].Value + ""))
  6190. {
  6191. goodsID = Convert.ToInt32(paras[3].Value + "");
  6192. }
  6193. else
  6194. {
  6195. goodsID = 0;
  6196. }
  6197. goodsCode = paras[4].Value + "";
  6198. goodsName = paras[5].Value + "";
  6199. if (!"null".Equals(paras[6].Value + ""))
  6200. {
  6201. groutingUserCode = paras[6].Value + "";
  6202. }
  6203. else
  6204. {
  6205. groutingUserCode = null;
  6206. }
  6207. if ("null".Equals(paras[2].Value + ""))
  6208. {
  6209. return null;
  6210. }
  6211. return paras[2].Value.ToString().Replace("\\n\\r", "\n\r");
  6212. }
  6213. catch (Exception ex)
  6214. {
  6215. throw ex;
  6216. }
  6217. }
  6218. /// <summary>
  6219. /// 查询工序信息
  6220. /// </summary>
  6221. /// <param name="oracleTrConn">连接对象</param>
  6222. /// <param name="procedureID">工序ID</param>
  6223. /// <returns>工序实体</returns>
  6224. private static ProcedureEntity GetProcedurByID(IDBTransaction oracleTrConn, int procedureID)
  6225. {
  6226. ProcedureEntity procedureEntity = new ProcedureEntity();
  6227. string procsql = "pro_pm_searchProcedurbyID";
  6228. try
  6229. {
  6230. IDataParameter[] paras = new OracleParameter[]
  6231. {
  6232. new OracleParameter("in_procedureID", OracleDbType.Int32, procedureID, ParameterDirection.Input),
  6233. new OracleParameter("out_result", OracleDbType.RefCursor, ParameterDirection.Output)
  6234. };
  6235. DataSet returnDs = oracleTrConn.ExecStoredProcedure(procsql, paras);
  6236. if (returnDs != null
  6237. && returnDs.Tables.Count > Constant.INT_IS_ZERO
  6238. && returnDs.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  6239. {
  6240. DataRow row = returnDs.Tables[0].Rows[0];
  6241. // 转实体
  6242. procedureEntity = DataConvert.DataRowConvertToObject<ProcedureEntity>(row);
  6243. return procedureEntity;
  6244. }
  6245. else
  6246. {
  6247. return null;
  6248. }
  6249. }
  6250. catch (Exception ex)
  6251. {
  6252. throw ex;
  6253. }
  6254. }
  6255. #endregion
  6256. #region 检验
  6257. /// <summary>
  6258. /// 保存条码信息
  6259. /// </summary>
  6260. /// <param name="procedureID">工序ID</param>
  6261. /// <param name="productionDataEntitys">生产数据集</param>
  6262. /// <param name="sUserInfo">用户基本信息</param>
  6263. /// <returns>string</returns>
  6264. public static string AddCheckBarcode(int procedureID, ProductionDataEntity[] productionDataEntitys, SUserInfo sUserInfo)
  6265. {
  6266. string errMsg = "";
  6267. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  6268. try
  6269. {
  6270. oracleTrConn.Connect();
  6271. #region 查询工序信息
  6272. ProcedureEntity procedure = GetProcedurByID(oracleTrConn, procedureID);
  6273. #endregion
  6274. #region 标准检验(半成品)
  6275. if (procedure.ModelType == (int)Constant.ProcedureModelType.Normal)
  6276. {
  6277. errMsg = AddNormalCheck(oracleTrConn, procedure, productionDataEntitys, sUserInfo);
  6278. }
  6279. #endregion
  6280. #region 成品检验
  6281. else if (procedure.ModelType == (int)Constant.ProcedureModelType.QualityStatistics)
  6282. {
  6283. errMsg = AddFinishCheckPDA(oracleTrConn, procedure, productionDataEntitys, sUserInfo);
  6284. }
  6285. #endregion
  6286. #region 半检 与成检相同处理 xuwei add 2019-12-12
  6287. else if (procedure.ModelType == (int)Constant.ProcedureModelType.SemiQualityStatistics)
  6288. {
  6289. errMsg = AddFinishCheckPDA(oracleTrConn, procedure, productionDataEntitys, sUserInfo);
  6290. }
  6291. #endregion
  6292. #region 入窑前检验
  6293. else if (procedure.ModelType == (int)Constant.ProcedureModelType.IntoKilnCheck)
  6294. {
  6295. errMsg = AddIntoKilnCheck(oracleTrConn, procedure, productionDataEntitys, sUserInfo);
  6296. }
  6297. #endregion
  6298. // 没有错误 提交事务
  6299. if (string.IsNullOrEmpty(errMsg))
  6300. {
  6301. oracleTrConn.Commit();
  6302. }
  6303. }
  6304. catch (Exception ex)
  6305. {
  6306. oracleTrConn.Rollback();
  6307. throw ex;
  6308. }
  6309. finally
  6310. {
  6311. // 释放资源
  6312. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  6313. {
  6314. oracleTrConn.Disconnect();
  6315. }
  6316. }
  6317. return errMsg;
  6318. }
  6319. /// <summary>
  6320. /// 入窑前检验
  6321. /// </summary>
  6322. /// <param name="oracleTrConn">连接对象</param>
  6323. /// <param name="procedure">工序</param>
  6324. /// <param name="productionDataEntitys">生产数据集</param>
  6325. /// <param name="sUserInfo">用户基本信息</param>
  6326. /// <returns>string</returns>
  6327. private static string AddIntoKilnCheck(IDBTransaction oracleTrConn, ProcedureEntity procedure, ProductionDataEntity[] productionDataEntitys, SUserInfo sUserInfo)
  6328. {
  6329. string errMsg = "";
  6330. // 获得账务日期
  6331. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  6332. // 本批采集的批次号
  6333. string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  6334. #region 查询产品分级
  6335. string sqlGoodsLevel = "select GoodsLevelID,GoodsLevelTypeID from TP_MST_GoodsLevel where AccountID=:accountID and ValueFlag=1";
  6336. DataTable goodsLevelTable = oracleTrConn.GetSqlResultToDt(sqlGoodsLevel, new OracleParameter[] { new OracleParameter(":accountID", sUserInfo.AccountID) });
  6337. #endregion
  6338. foreach (ProductionDataEntity productionData in productionDataEntitys)
  6339. {
  6340. if (string.IsNullOrEmpty(productionData.Barcode))
  6341. {
  6342. throw new Exception("传入的条码号为空");
  6343. }
  6344. if (productionData.ProductionDataID != 0)
  6345. {
  6346. errMsg = DeleteSubstandardToSubstandardByID(oracleTrConn, productionData.ProductionDataID, productionData.Barcode, sUserInfo);
  6347. if (!string.IsNullOrEmpty(errMsg))
  6348. {
  6349. return errMsg;
  6350. }
  6351. // 删除报废条码
  6352. string updateScrapSql = @"update tp_pm_scrapproduct set ValueFlag=0
  6353. where tp_pm_scrapproduct.barcode=:barcode";
  6354. OracleParameter[] ScrapProductparas = new OracleParameter[]{
  6355. new OracleParameter(":barcode",OracleDbType.Varchar2, productionData.Barcode,ParameterDirection.Input),
  6356. };
  6357. oracleTrConn.ExecuteNonQuery(updateScrapSql, ScrapProductparas);
  6358. string sqlInsInProdString = @"insert into TP_PM_InProduction(BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME,
  6359. PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID,
  6360. ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME,
  6361. USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE,
  6362. GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID,
  6363. CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE,
  6364. REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME,
  6365. CREATEUSERID, UPDATETIME, UPDATEUSERID,
  6366. ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG,
  6367. GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM,
  6368. KILNID, KILNCODE, KILNNAME, KILNCARID,
  6369. KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID
  6370. ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,logoid,IsReworkFlag,SemiCheckID)
  6371. select BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME,
  6372. PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID,
  6373. ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME,
  6374. USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE,
  6375. GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID,
  6376. CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE,
  6377. REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME,
  6378. CREATEUSERID, UPDATETIME, :UpdateUserID,
  6379. ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG,
  6380. GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM,
  6381. KILNID, KILNCODE, KILNNAME, KILNCARID,
  6382. KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID ,
  6383. FlowProcedureTime,ProcedureID,sysdate,ProductionDataID,logoid,IsReworkFlag,SemiCheckID
  6384. from TP_PM_InProductionTrash where barcode=:barcode ";
  6385. OracleParameter[] InProductparas = new OracleParameter[]{
  6386. new OracleParameter(":UpdateUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input),
  6387. new OracleParameter(":barcode",OracleDbType.Varchar2, productionData.Barcode,ParameterDirection.Input),
  6388. };
  6389. oracleTrConn.ExecuteNonQuery(sqlInsInProdString, InProductparas);
  6390. //删除回收站中的条码
  6391. string sqlDelInProductTrashString = "delete from TP_PM_InProductionTrash where barcode=:barcode ";
  6392. OracleParameter[] TrashProductparas = new OracleParameter[]{
  6393. new OracleParameter(":barcode",OracleDbType.Varchar2, productionData.Barcode,ParameterDirection.Input)
  6394. };
  6395. oracleTrConn.ExecuteNonQuery(sqlDelInProductTrashString, TrashProductparas);
  6396. }
  6397. int goodsID = Constant.INT_IS_ZERO;
  6398. string goodsCode = string.Empty;
  6399. string goodsName = string.Empty;
  6400. // 注浆者工号
  6401. string groutingUserCode = string.Empty;
  6402. #region 校验条码有效性
  6403. errMsg = CheckBarcode(oracleTrConn, procedure.ProcedureID, productionData.Barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo);
  6404. if (!string.IsNullOrEmpty(errMsg))
  6405. {
  6406. if (productionData.ProductionDataID == 0)
  6407. return errMsg;
  6408. }
  6409. #endregion
  6410. #region 获得产品分级ID
  6411. DataRow[] dr = goodsLevelTable.Select("GoodsLevelTypeID=" + productionData.GoodsLevelTypeID);
  6412. // 获得产品分级ID
  6413. productionData.GoodsLevelID = Convert.ToInt32(dr[0]["GoodsLevelID"]);
  6414. #endregion
  6415. // 查询新插入的生产数据ID
  6416. string sql = "select SEQ_PM_ProductionData_ID.nextval from dual";
  6417. string idStr = oracleTrConn.GetSqlResultToStr(sql);
  6418. int productionDataID = 0;
  6419. if (!string.IsNullOrEmpty(idStr))
  6420. {
  6421. productionDataID = int.Parse(idStr);
  6422. }
  6423. else
  6424. {
  6425. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  6426. }
  6427. int? ClassesSettingID = null;//班次配置ID
  6428. #region 添加生产者数据
  6429. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, productionData.UserID, productionData.UserName, sUserInfo, ref ClassesSettingID);
  6430. if (!string.IsNullOrEmpty(errMsg))
  6431. {
  6432. return errMsg;
  6433. }
  6434. #endregion
  6435. #region 添加生产数据
  6436. #region 属性赋值
  6437. productionData.ClassesSettingID = ClassesSettingID;
  6438. productionData.ProductionDataID = Convert.ToInt32(idStr);
  6439. productionData.CentralizedBatchNo = centralizedBatchNo;
  6440. productionData.ProductionLineID = procedure.ProductionLineID;
  6441. productionData.ProductionLineCode = procedure.ProductionlineCode;
  6442. productionData.ProductionLineName = procedure.ProductionlineName;
  6443. productionData.ProcedureID = procedure.ProcedureID;
  6444. productionData.ProcedureCode = procedure.ProcedureCode;
  6445. productionData.ProcedureName = procedure.ProcedureName;
  6446. productionData.ProcedureModel = procedure.ProcedureModel;
  6447. productionData.ModelType = procedure.ModelType;
  6448. productionData.NodeType = procedure.NodeType;
  6449. productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, productionData.Barcode);
  6450. productionData.IsReFire = (int)Constant.ReFireFlag.No;
  6451. productionData.GoodsGrade = (int)Constant.GoodsGrade.Good;
  6452. productionData.OrganizationID = procedure.OrganizationID;
  6453. productionData.GoodsID = goodsID;
  6454. productionData.GoodsCode = goodsCode;
  6455. productionData.GoodsName = goodsName;
  6456. productionData.GoodsLevelID = productionData.GoodsLevelID;
  6457. productionData.GoodsLevelTypeID = productionData.GoodsLevelTypeID;
  6458. //如果报废给此产品最状态赋值 wangxin 2015/4/1 因为删除掉了生产数据表中的产品最终状态
  6459. ////if (productionData.ProductionDefects != null)
  6460. ////{
  6461. //// foreach (ProductionDefectEntity productionDefect in productionData.ProductionDefects)
  6462. //// {
  6463. //// if ((string.IsNullOrEmpty(productionDefect.ScrapResponFlag) ? "0" : productionDefect.ScrapResponFlag) == "1")
  6464. //// {
  6465. //// productionData.GoodsEnding = productionData.GoodsLevelTypeID.ToString();
  6466. //// break;
  6467. //// }
  6468. //// }
  6469. ////}
  6470. ////if (productionData.GoodsLevelTypeID == (int)Constant.GoodsLevelType.Waste)
  6471. ////{
  6472. //// productionData.GoodsEnding = Constant.GoodsLevelType.Waste.GetHashCode().ToString();
  6473. ////}
  6474. ////// string sqlReFire = @"select
  6475. ////// isrefire
  6476. ////// from tp_pm_inproduction where barcode=:barcode
  6477. ////// ";
  6478. ////// OracleParameter[] ReFireparas = new OracleParameter[] {
  6479. ////// new OracleParameter(":barcode",productionData.Barcode),
  6480. ////// };
  6481. ////// DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas);
  6482. ////// //DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire);
  6483. ////// if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0)
  6484. ////// {
  6485. ////// if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0)
  6486. ////// {
  6487. ////// productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]);
  6488. ////// }
  6489. ////// }
  6490. #endregion
  6491. string OutSpecialRepairflag = "0";//干补标识
  6492. //errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag);
  6493. errMsg = AddProductionDataWaster(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag);
  6494. if (!string.IsNullOrEmpty(errMsg))
  6495. {
  6496. return errMsg;
  6497. }
  6498. #endregion
  6499. //#region 添加生产者数据
  6500. //errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, productionData.UserID, productionData.UserName, sUserInfo);
  6501. //if (!string.IsNullOrEmpty(errMsg))
  6502. //{
  6503. // return errMsg;
  6504. //}
  6505. //#endregion
  6506. #region 条码有缺陷
  6507. // 废品标识
  6508. bool scrapFlag = false;
  6509. // 存在缺陷 插入缺陷表
  6510. if (productionData.ProductionDefects != null)
  6511. {
  6512. foreach (ProductionDefectEntity productionDefect in productionData.ProductionDefects)
  6513. {
  6514. #region 保存缺陷
  6515. productionDefect.ProductionDataID = productionDataID;
  6516. productionDefect.BarCode = productionData.Barcode;
  6517. productionDefect.ProductionLineID = procedure.ProductionLineID;
  6518. productionDefect.ProductionLineCode = procedure.ProductionlineCode;
  6519. productionDefect.ProductionLineName = procedure.ProductionlineName;
  6520. productionDefect.ProcedureID = procedure.ProcedureID;
  6521. productionDefect.ProcedureCode = procedure.ProcedureCode;
  6522. productionDefect.ProcedureName = procedure.ProcedureName;
  6523. productionDefect.UserID = productionData.UserID;
  6524. productionDefect.UserCode = productionData.UserCode;
  6525. productionDefect.UserName = productionData.UserName;
  6526. productionDefect.GoodsID = productionData.GoodsID;
  6527. productionDefect.GoodsCode = productionData.GoodsCode;
  6528. productionDefect.GoodsName = productionData.GoodsName;
  6529. productionData.Remarks = productionData.Remarks;
  6530. productionDefect.ScrapResponFlag
  6531. = string.IsNullOrEmpty(productionDefect.ScrapResponFlag) ? "0" : productionDefect.ScrapResponFlag;
  6532. // 保存缺陷
  6533. errMsg = AddDefect(oracleTrConn, productionDefect, sUserInfo);
  6534. if (!string.IsNullOrEmpty(errMsg))
  6535. {
  6536. return errMsg;
  6537. }
  6538. #endregion
  6539. #region 缺陷列表中只有一个报废工序 添加废弃产品 删除在产产品数据
  6540. if (!scrapFlag && productionDefect.ScrapResponFlag == "1")
  6541. {
  6542. scrapFlag = true;
  6543. #region 添加废弃产品 删除在产产品数据
  6544. #region 添加废弃产品
  6545. ScrapProductEntity scrapProduct = new ScrapProductEntity();
  6546. #region 属性赋值
  6547. scrapProduct.BarCode = productionData.Barcode;
  6548. scrapProduct.ScrapType = Constant.ScrapType.Waste.GetHashCode();
  6549. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  6550. {
  6551. scrapProduct.ResponType = Constant.ScrapResponType.NoPerson.GetHashCode();
  6552. }
  6553. else
  6554. {
  6555. scrapProduct.ResponType = Constant.ScrapResponType.Procedure.GetHashCode();
  6556. }
  6557. scrapProduct.ScrapDate = accountDate;
  6558. scrapProduct.Rreason = Constant.SCRAPTYPE_WASTE;
  6559. scrapProduct.Remarks = productionDefect.Remarks;
  6560. scrapProduct.AuditStatus = Constant.AuditStatus.Agree.GetHashCode();
  6561. scrapProduct.Auditor = sUserInfo.UserID;
  6562. scrapProduct.AuditlDate = accountDate;
  6563. scrapProduct.AccountDate = accountDate;
  6564. scrapProduct.GoodsLevelID = productionData.GoodsLevelID;
  6565. scrapProduct.GoodsLevelTypeID = productionData.GoodsLevelTypeID;
  6566. scrapProduct.IsPublicBody = productionData.IsPublicBody;
  6567. string sqlScrapProduct = "select SEQ_PM_ScrapProduct_ID.nextval from dual";
  6568. string idStrScrapProduct = oracleTrConn.GetSqlResultToStr(sqlScrapProduct);
  6569. scrapProduct.ScrapProductID = Convert.ToInt32(idStrScrapProduct);
  6570. scrapProduct.ScrapType = 1;
  6571. #endregion
  6572. // 保存报废
  6573. errMsg = AddScrapProduct(oracleTrConn, scrapProduct, sUserInfo);
  6574. // 保存失败
  6575. if (!string.IsNullOrEmpty(errMsg))
  6576. {
  6577. return errMsg;
  6578. }
  6579. #endregion
  6580. #region 添加责任工序
  6581. //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的
  6582. //xuwei fix 2019-09-26 使用通用方法判定
  6583. if (IsNodeBegin<IDBTransaction>(oracleTrConn, productionData.Barcode) == 1)
  6584. procedure.NodeType = (int)Constant.ProcedureNodeType.Begin;
  6585. if (procedure.NodeType != Constant.ProcedureNodeType.Begin.GetHashCode())
  6586. {
  6587. //string sqlScrapProduct = "select SEQ_PM_ScrapProduct_ID.Currval from dual";
  6588. //string idStrScrapProduct = oracleTrConn.GetSqlResultToStr(sqlScrapProduct);
  6589. ResponProcedureEntity responProce = new ResponProcedureEntity();
  6590. #region 属性赋值
  6591. responProce.BarCode = productionData.Barcode;
  6592. responProce.ProductionDataID = productionDataID;
  6593. responProce.ProductionLineID = productionDefect.ProductionLineID;
  6594. responProce.ProductionLineCode = productionDefect.ProductionLineCode;
  6595. responProce.ProductionLineName = productionDefect.ProductionLineName;
  6596. responProce.ProcedureID = productionDefect.DefectProcedureID;
  6597. responProce.ProcedureCode = productionDefect.DefectProcedureCode;
  6598. responProce.ProcedureName = productionDefect.DefectProcedureName;
  6599. responProce.UserID = productionDefect.DefectUserID;
  6600. responProce.UserCode = productionDefect.DefectUserCode;
  6601. responProce.UserName = productionDefect.DefectUserName;
  6602. responProce.Remarks = productionDefect.Remarks;
  6603. responProce.ScrapProductID = Convert.ToInt32(idStrScrapProduct);
  6604. #endregion
  6605. // 保存责任工序
  6606. errMsg = AddResponProcedure(oracleTrConn, responProce, productionDefect, sUserInfo);
  6607. // 保存失败
  6608. if (!string.IsNullOrEmpty(errMsg))
  6609. {
  6610. return errMsg;
  6611. }
  6612. }
  6613. #endregion
  6614. #region 删除在产产品数据
  6615. InProductionEntity delInProductionEntity = new InProductionEntity();
  6616. delInProductionEntity.BarCode = productionData.Barcode;
  6617. delInProductionEntity.CompleteProcedureID = productionData.ProcedureID;
  6618. // 执行删除 在产数据
  6619. errMsg = DeleteInProduction(oracleTrConn, delInProductionEntity, false, sUserInfo);
  6620. // 执行失败
  6621. // if (!string.IsNullOrEmpty(errMsg)) 注释日期2015-12-28
  6622. // {
  6623. // return errMsg;
  6624. // }
  6625. #endregion
  6626. #endregion
  6627. }
  6628. #endregion
  6629. }
  6630. }
  6631. #endregion
  6632. // 条码有缺陷或者报废
  6633. //wangxin 20150414
  6634. //if (scrapFlag || productionData.GoodsLevelTypeID == Constant.GoodsLevelType.Defect.GetHashCode())
  6635. //{
  6636. #region 有缺陷 删除条码对应窑车产品
  6637. if (productionData.DefectFlag == Constant.GoodsLevelType.Defect.GetHashCode())
  6638. {
  6639. errMsg = DeleteKilnCarGoods(oracleTrConn, productionData.Barcode);
  6640. if (!string.IsNullOrEmpty(errMsg))
  6641. {
  6642. return errMsg;
  6643. }
  6644. }
  6645. #endregion
  6646. //}
  6647. //wangxin 20150414 end
  6648. // 条码没有报废
  6649. if (!scrapFlag)
  6650. {
  6651. #region 修改在产产品数据的当前工序
  6652. InProductionEntity inProductionEntity = new InProductionEntity();
  6653. inProductionEntity.BarCode = productionData.Barcode;
  6654. //流程工序
  6655. inProductionEntity.FlowProcedureID = procedure.ProcedureID;
  6656. // 当前工序
  6657. //inProductionEntity.CompleteProcedureID = procedure.ProcedureID;
  6658. inProductionEntity.ProcedureID = procedure.ProcedureID;
  6659. // 生产数据ID
  6660. inProductionEntity.ProductionDataID = productionDataID;
  6661. // 工序模型
  6662. inProductionEntity.ProcedureModel = procedure.ProcedureModel;
  6663. // 工序类别
  6664. inProductionEntity.ModelType = procedure.ModelType;
  6665. // 生产工号
  6666. inProductionEntity.UserID = productionData.UserID;
  6667. // 缺陷标识
  6668. inProductionEntity.DefectFlag = productionData.DefectFlag;
  6669. // 返工工序ID
  6670. inProductionEntity.ReworkProcedureID = productionData.ReworkProcedureID;
  6671. inProductionEntity.GoodsLevelID = productionData.GoodsLevelID;
  6672. inProductionEntity.GoodsLevelTypeID = productionData.GoodsLevelTypeID;
  6673. inProductionEntity.IsPublicBody = productionData.IsPublicBody;
  6674. // 执行修改
  6675. errMsg = UpdateInProduction(oracleTrConn, inProductionEntity, sUserInfo);
  6676. // 执行失败
  6677. if (!string.IsNullOrEmpty(errMsg))
  6678. {
  6679. return errMsg;
  6680. }
  6681. #endregion
  6682. }
  6683. }
  6684. return errMsg;
  6685. }
  6686. /// <summary>
  6687. /// 删除窑车产品
  6688. /// </summary>
  6689. /// <param name="oracleTrConn">数据连接</param>
  6690. /// <param name="barcode">产品条码</param>
  6691. /// <returns>string</returns>
  6692. private static string DeleteKilnCarGoods(IDBTransaction oracleTrConn, string barcode)
  6693. {
  6694. string sql = "delete TP_PM_KilnCarGoods where BarCode = :barcode";
  6695. OracleParameter[] paras = new OracleParameter[] { new OracleParameter(":barcode", barcode) };
  6696. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  6697. // 保存失败
  6698. if (result != Constant.INT_IS_ONE)
  6699. {
  6700. //return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  6701. }
  6702. return null;
  6703. }
  6704. /// <summary>
  6705. /// 添加成品编辑
  6706. /// </summary>
  6707. /// <param name="oracleTrConn">数据连接</param>
  6708. /// <param name="procedure">工序对象</param>
  6709. /// <param name="productionDataEntitys">生产数据集</param>
  6710. /// <param name="sUserInfo">用户基本信息</param>
  6711. /// <returns>string</returns>
  6712. //private static string AddFinishCheck(IDBTransaction oracleTrConn, ProcedureEntity procedure, ProductionDataEntity[] productionDataEntitys, SUserInfo sUserInfo)
  6713. //{
  6714. // string errMsg = "";
  6715. // // 获得账务日期
  6716. // DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  6717. // // 本批采集的批次号
  6718. // string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  6719. // foreach (ProductionDataEntity productionData in productionDataEntitys)
  6720. // {
  6721. // if (string.IsNullOrEmpty(productionData.Barcode))
  6722. // {
  6723. // throw new Exception("传入的条码号为空");
  6724. // }
  6725. // int goodsID = Constant.INT_IS_ZERO;
  6726. // string goodsCode = string.Empty;
  6727. // string goodsName = string.Empty;
  6728. // // 注浆者工号
  6729. // string groutingUserCode = string.Empty;
  6730. // // 次品标识
  6731. // bool substandardFlag = false;
  6732. // #region 校验条码有效性
  6733. // errMsg = CheckBarcode(oracleTrConn, procedure.ProcedureID, productionData.Barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo);
  6734. // if (!string.IsNullOrEmpty(errMsg))
  6735. // {
  6736. // if (productionData.ProductionDataID == 0)
  6737. // return errMsg;
  6738. // }
  6739. // #endregion
  6740. // #region 添加生产数据
  6741. // #region 属性赋值
  6742. // productionData.CentralizedBatchNo = centralizedBatchNo;
  6743. // productionData.ProductionLineID = procedure.ProductionLineID;
  6744. // productionData.ProductionLineCode = procedure.ProductionlineCode;
  6745. // productionData.ProductionLineName = procedure.ProductionlineName;
  6746. // productionData.CompleteProcedureID = procedure.ProcedureID;
  6747. // productionData.ProcedureCode = procedure.ProcedureCode;
  6748. // productionData.ProcedureName = procedure.ProcedureName;
  6749. // productionData.ProcedureModel = procedure.ProcedureModel;
  6750. // productionData.ModelType = procedure.ModelType;
  6751. // productionData.IsPublicBody = (int)Constant.PublicBodyFlag.No;
  6752. // // 重烧
  6753. // if (productionData.GoodsLevelTypeID == (int)Constant.GoodsLevelType.ReFire)
  6754. // {
  6755. // //productionData.GoodsLevelID = null;
  6756. // productionData.IsReFire = (int)Constant.ReFireFlag.No;
  6757. // }
  6758. // // 次品
  6759. // else if (productionData.GoodsLevelTypeID == (int)Constant.GoodsLevelType.Reject)
  6760. // {
  6761. // //productionData.GoodsLevelID = null;
  6762. // substandardFlag = true;
  6763. // }
  6764. // // 查询新插入的生产数据ID
  6765. // if (productionData.GoodsLevelTypeID != (int)Constant.GoodsLevelType.ReFire)
  6766. // {
  6767. // //不加条件valueflag,是因为,成检后重烧走过之后,在次重烧,以后也是重烧状态
  6768. // //string sqlReFire = "select * from tp_PM_ProductionData where ProductionData=(select max(ProductionDataid) from ProductionData where barcode=" + productionData.Barcode + " and ProcedureID=" + productionData.ProcedureID + ")";
  6769. // string sqlReFire = "select * from tp_PM_ProductionData where ProductionDataid=(select max(ProductionDataid) from tp_PM_ProductionData where barcode='" + productionData.Barcode + "')";
  6770. // DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire);
  6771. // if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0)
  6772. // {
  6773. // productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]);
  6774. // }
  6775. // }
  6776. // productionData.OrganizationID = procedure.OrganizationID;
  6777. // productionData.GoodsID = goodsID;
  6778. // productionData.GoodsCode = goodsCode;
  6779. // productionData.GoodsName = goodsName;
  6780. // productionData.GoodsLevelID = productionData.GoodsLevelID;
  6781. // productionData.GoodsLevelTypeID = productionData.GoodsLevelTypeID;
  6782. // //if (productionData.GoodsLevelTypeID == (int)Constant.GoodsLevelType.Reject)
  6783. // //{
  6784. // // productionData.GoodsEnding = Constant.GoodsLevelType.Reject.GetHashCode().ToString();
  6785. // //}
  6786. // #endregion
  6787. // string OutSpecialRepairflag = "0";//干补标识
  6788. // errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag);
  6789. // if (!string.IsNullOrEmpty(errMsg))
  6790. // {
  6791. // return errMsg;
  6792. // }
  6793. // // 查询新插入的生产数据ID
  6794. // string sql = "select SEQ_PM_ProductionData_ID.Currval from dual";
  6795. // string idStr = oracleTrConn.GetSqlResultToStr(sql);
  6796. // // 新插入的班次配置表ID
  6797. // int productionDataID = 0;
  6798. // if (!string.IsNullOrEmpty(idStr))
  6799. // {
  6800. // productionDataID = int.Parse(idStr);
  6801. // }
  6802. // else
  6803. // {
  6804. // return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  6805. // }
  6806. // #endregion
  6807. // #region 添加生产者数据
  6808. // int? ClassesSettingID = null;//班次配置ID
  6809. // errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, productionData.UserID, productionData.UserName, sUserInfo, ref ClassesSettingID);
  6810. // if (!string.IsNullOrEmpty(errMsg))
  6811. // {
  6812. // return errMsg;
  6813. // }
  6814. // #endregion
  6815. // #region 条码有缺陷
  6816. // #region 是次品 添加废弃产品
  6817. // if (substandardFlag)
  6818. // {
  6819. // #region 添加废弃产品
  6820. // ScrapProductEntity scrapProduct = new ScrapProductEntity();
  6821. // #region 属性赋值
  6822. // scrapProduct.BarCode = productionData.Barcode;
  6823. // scrapProduct.ScrapType = Constant.ScrapType.Substandard.GetHashCode();
  6824. // scrapProduct.ResponType = Constant.ScrapResponType.Procedure.GetHashCode();
  6825. // scrapProduct.ScrapDate = accountDate;
  6826. // scrapProduct.Rreason = Constant.SCRAPTYPE_SUBSTANDARD;
  6827. // scrapProduct.AuditStatus = Constant.AuditStatus.Agree.GetHashCode();
  6828. // scrapProduct.Auditor = sUserInfo.UserID;
  6829. // scrapProduct.AuditlDate = accountDate;
  6830. // scrapProduct.AccountDate = accountDate;
  6831. // scrapProduct.GoodsLevelID = productionData.GoodsLevelID;
  6832. // scrapProduct.GoodsLevelTypeID = productionData.GoodsLevelTypeID;
  6833. // #endregion
  6834. // // 保存报废
  6835. // errMsg = AddScrapProduct(oracleTrConn, scrapProduct, sUserInfo);
  6836. // // 保存失败
  6837. // if (!string.IsNullOrEmpty(errMsg))
  6838. // {
  6839. // return errMsg;
  6840. // }
  6841. // #endregion
  6842. // }
  6843. // #endregion
  6844. // // 存在缺陷 插入缺陷表
  6845. // if (productionData.ProductionDefects != null)
  6846. // {
  6847. // foreach (ProductionDefectEntity productionDefect in productionData.ProductionDefects)
  6848. // {
  6849. // #region 保存缺陷
  6850. // productionDefect.ProductionDataID = productionDataID;
  6851. // productionDefect.BarCode = productionData.Barcode;
  6852. // productionDefect.ProductionLineID = procedure.ProductionLineID;
  6853. // productionDefect.ProductionLineCode = procedure.ProductionlineCode;
  6854. // productionDefect.ProductionLineName = procedure.ProductionlineName;
  6855. // productionDefect.ProcedureID = procedure.ProcedureID;
  6856. // productionDefect.ProcedureCode = procedure.ProcedureCode;
  6857. // productionDefect.ProcedureName = procedure.ProcedureName;
  6858. // productionDefect.UserID = productionData.UserID;
  6859. // productionDefect.UserCode = productionData.UserCode;
  6860. // productionDefect.UserName = productionData.UserName;
  6861. // productionDefect.GoodsID = productionData.GoodsID;
  6862. // productionDefect.GoodsCode = productionData.GoodsCode;
  6863. // productionDefect.GoodsName = productionData.GoodsName;
  6864. // productionData.Remarks = productionData.Remarks;
  6865. // productionDefect.ScrapResponFlag
  6866. // = string.IsNullOrEmpty(productionDefect.ScrapResponFlag) ? "0" : productionDefect.ScrapResponFlag;
  6867. // // 保存缺陷
  6868. // errMsg = AddDefect(oracleTrConn, productionDefect, sUserInfo);
  6869. // if (!string.IsNullOrEmpty(errMsg))
  6870. // {
  6871. // return errMsg;
  6872. // }
  6873. // #endregion
  6874. // #region 是次品 添加废弃责任工序
  6875. // if (substandardFlag)
  6876. // {
  6877. // #region 添加责任工序
  6878. // ResponProcedureEntity responProce = new ResponProcedureEntity();
  6879. // // 查询新插入的废弃ID
  6880. // string ResponProceduresql = "select SEQ_PM_ScrapProduct_ID.Currval from dual";
  6881. // string ResponProcedureidStr = oracleTrConn.GetSqlResultToStr(ResponProceduresql);
  6882. // #region 属性赋值
  6883. // responProce.BarCode = productionData.Barcode;
  6884. // responProce.ProductionDataID = productionDataID;
  6885. // responProce.ProductionLineID = productionDefect.ProductionLineID;
  6886. // responProce.ProductionLineCode = productionDefect.ProductionLineCode;
  6887. // responProce.ProductionLineName = productionDefect.ProductionLineName;
  6888. // responProce.ProcedureID = productionDefect.DefectProcedureID;
  6889. // responProce.ProcedureCode = productionDefect.DefectProcedureCode;
  6890. // responProce.ProcedureName = productionDefect.DefectProcedureName;
  6891. // responProce.UserID = productionDefect.DefectUserID;
  6892. // responProce.UserCode = productionDefect.DefectUserCode;
  6893. // responProce.UserName = productionDefect.DefectUserName;
  6894. // responProce.Remarks = productionDefect.Remarks;
  6895. // responProce.ScrapProductID = Convert.ToInt32(ResponProcedureidStr);
  6896. // #endregion
  6897. // // 保存责任工序
  6898. // errMsg = AddResponProcedure(oracleTrConn, responProce, productionDefect, sUserInfo);
  6899. // // 保存失败
  6900. // if (!string.IsNullOrEmpty(errMsg))
  6901. // {
  6902. // return errMsg;
  6903. // }
  6904. // #endregion
  6905. // }
  6906. // #endregion
  6907. // }
  6908. // }
  6909. // #endregion
  6910. // #region 条码是次品 删除在产产品数据
  6911. // if (substandardFlag)
  6912. // {
  6913. // #region 删除在产产品数据
  6914. // InProductionEntity delInProductionEntity = new InProductionEntity();
  6915. // delInProductionEntity.BarCode = productionData.Barcode;
  6916. // // 执行删除 在产数据
  6917. // errMsg = DeleteInProduction(oracleTrConn, delInProductionEntity, false, sUserInfo);
  6918. // // 执行失败
  6919. // if (!string.IsNullOrEmpty(errMsg))
  6920. // {
  6921. // return errMsg;
  6922. // }
  6923. // #endregion
  6924. // }
  6925. // #endregion
  6926. // #region 条码不是次品
  6927. // if (!substandardFlag)
  6928. // {
  6929. // #region 中间工序/重烧 修改在产产品数据
  6930. // if (procedure.NodeType == (int)Constant.ProcedureNodeType.Middle
  6931. // || productionData.IsReFire == Constant.GoodsGrade.ReFire.GetHashCode())
  6932. // {
  6933. // #region 修改在产产品数据的当前工序
  6934. // InProductionEntity inProductionEntity = new InProductionEntity();
  6935. // inProductionEntity.BarCode = productionData.Barcode;
  6936. // // 当前工序
  6937. // inProductionEntity.CompleteProcedureID = procedure.ProcedureID;
  6938. // // 工序模型
  6939. // inProductionEntity.ProcedureModel = procedure.ProcedureModel;
  6940. // // 工序类别
  6941. // inProductionEntity.ModelType = procedure.ModelType;
  6942. // // 生产工号
  6943. // inProductionEntity.UserID = productionData.UserID;
  6944. // // 重烧
  6945. // inProductionEntity.IsReFire = productionData.IsReFire;
  6946. // // 缺陷
  6947. // inProductionEntity.DefectFlag = productionData.DefectFlag;
  6948. // // 产品分级
  6949. // inProductionEntity.GoodsGrade = productionData.GoodsGrade;
  6950. // // 返工工序ID
  6951. // inProductionEntity.ReworkProcedureID = productionData.ReworkProcedureID;
  6952. // inProductionEntity.GoodsLevelID = productionData.GoodsLevelID;
  6953. // inProductionEntity.GoodsLevelTypeID = productionData.GoodsLevelTypeID;
  6954. // // 执行修改
  6955. // errMsg = UpdateInProduction(oracleTrConn, inProductionEntity, sUserInfo);
  6956. // // 执行失败
  6957. // if (!string.IsNullOrEmpty(errMsg))
  6958. // {
  6959. // return errMsg;
  6960. // }
  6961. // #endregion
  6962. // }
  6963. // #endregion
  6964. // #region 结束工序 添加成品数据 删除在产产品数据
  6965. // else if (procedure.NodeType == (int)Constant.ProcedureNodeType.End)
  6966. // {
  6967. // #region 添加成品数据 删除在产产品数据
  6968. // FinishedProductEntity finishedProduct = new FinishedProductEntity();
  6969. // finishedProduct.BarCode = productionData.Barcode;
  6970. // errMsg = AddFinishedProduct(oracleTrConn, finishedProduct, sUserInfo);
  6971. // if (!string.IsNullOrEmpty(errMsg))
  6972. // {
  6973. // return errMsg;
  6974. // }
  6975. // InProductionEntity delInProductionEntity = new InProductionEntity();
  6976. // delInProductionEntity.BarCode = productionData.Barcode;
  6977. // // 执行删除 在产数据
  6978. // errMsg = DeleteInProduction(oracleTrConn, delInProductionEntity, true, sUserInfo);
  6979. // // 执行失败
  6980. // if (!string.IsNullOrEmpty(errMsg))
  6981. // {
  6982. // return errMsg;
  6983. // }
  6984. // #endregion
  6985. // }
  6986. // #endregion
  6987. // }
  6988. // #endregion
  6989. // }
  6990. // return errMsg;
  6991. //}
  6992. /// <summary>
  6993. /// 保存标准检验
  6994. /// </summary>
  6995. /// <param name="oracleTrConn">连接对象</param>
  6996. /// <param name="procedure">工序信息</param>
  6997. /// <param name="productionDataEntitys">生产数据集合</param>
  6998. /// <param name="sUserInfo">用户基本信息</param>
  6999. /// <returns>string</returns>
  7000. private static string AddNormalCheck(IDBTransaction oracleTrConn, ProcedureEntity procedure, ProductionDataEntity[] productionDataEntitys, SUserInfo sUserInfo)
  7001. {
  7002. string errMsg = "";
  7003. // 获得账务日期
  7004. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  7005. // 本批采集的批次号
  7006. string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  7007. string finishedloadbatchno = DateTime.Now.ToString("yyMMddHHmmss-") + centralizedBatchNo;
  7008. #region 查询产品分级
  7009. string sqlGoodsLevel = "select GoodsLevelID,GoodsLevelTypeID from TP_MST_GoodsLevel where AccountID=:accountID and ValueFlag=1";
  7010. DataTable goodsLevelTable = oracleTrConn.GetSqlResultToDt(sqlGoodsLevel, new OracleParameter[] { new OracleParameter(":accountID", sUserInfo.AccountID) });
  7011. #endregion
  7012. foreach (ProductionDataEntity productionData in productionDataEntitys)
  7013. {
  7014. if (string.IsNullOrEmpty(productionData.Barcode))
  7015. {
  7016. throw new Exception("传入的条码号为空");
  7017. }
  7018. if (productionData.ProductionDataID != 0)
  7019. {
  7020. errMsg = DeleteSubstandardToSubstandardByID(oracleTrConn, productionData.ProductionDataID, productionData.Barcode, sUserInfo);
  7021. if (!string.IsNullOrEmpty(errMsg))
  7022. {
  7023. return errMsg;
  7024. }
  7025. // 删除报废条码
  7026. string updateScrapSql = @"update tp_pm_scrapproduct set ValueFlag=0
  7027. where tp_pm_scrapproduct.barcode=:barcode";
  7028. OracleParameter[] ScrapProductparas = new OracleParameter[]{
  7029. new OracleParameter(":barcode",OracleDbType.Varchar2, productionData.Barcode,ParameterDirection.Input),
  7030. };
  7031. oracleTrConn.ExecuteNonQuery(updateScrapSql, ScrapProductparas);
  7032. string sqlInsInProdString = @"insert into TP_PM_InProduction(BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME,
  7033. PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID,
  7034. ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME,
  7035. USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE,
  7036. GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID,
  7037. CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE,
  7038. REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME,
  7039. CREATEUSERID, UPDATETIME, UPDATEUSERID,
  7040. ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG,
  7041. GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM,
  7042. KILNID, KILNCODE, KILNNAME, KILNCARID,
  7043. KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID
  7044. ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,logoid,IsReworkFlag,SemiCheckID)
  7045. select BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME,
  7046. PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID,
  7047. ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME,
  7048. USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE,
  7049. GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID,
  7050. CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE,
  7051. REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME,
  7052. CREATEUSERID, UPDATETIME, :UpdateUserID,
  7053. ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG,
  7054. GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM,
  7055. KILNID, KILNCODE, KILNNAME, KILNCARID,
  7056. KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID ,
  7057. FlowProcedureTime,ProcedureID,sysdate,ProductionDataID,logoid,IsReworkFlag,SemiCheckID
  7058. from TP_PM_InProductionTrash where barcode=:barcode ";
  7059. OracleParameter[] InProductparas = new OracleParameter[]{
  7060. new OracleParameter(":UpdateUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input),
  7061. new OracleParameter(":barcode",OracleDbType.Varchar2, productionData.Barcode,ParameterDirection.Input),
  7062. };
  7063. oracleTrConn.ExecuteNonQuery(sqlInsInProdString, InProductparas);
  7064. //删除回收站中的条码
  7065. string sqlDelInProductTrashString = "delete from TP_PM_InProductionTrash where barcode=:barcode ";
  7066. OracleParameter[] TrashProductparas = new OracleParameter[]{
  7067. new OracleParameter(":barcode",OracleDbType.Varchar2, productionData.Barcode,ParameterDirection.Input)
  7068. };
  7069. oracleTrConn.ExecuteNonQuery(sqlDelInProductTrashString, TrashProductparas);
  7070. }
  7071. int goodsID = Constant.INT_IS_ZERO;
  7072. string goodsCode = string.Empty;
  7073. string goodsName = string.Empty;
  7074. // 注浆者工号
  7075. string groutingUserCode = string.Empty;
  7076. #region 校验条码有效性
  7077. errMsg = CheckBarcode(oracleTrConn, procedure.ProcedureID, productionData.Barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo);
  7078. if (!string.IsNullOrEmpty(errMsg))
  7079. {
  7080. if (productionData.ProductionDataID == 0)
  7081. return errMsg;
  7082. }
  7083. #endregion
  7084. // 查询新插入的生产数据ID
  7085. string sql = "select SEQ_PM_ProductionData_ID.nextval from dual";
  7086. string idStr = oracleTrConn.GetSqlResultToStr(sql);
  7087. int? ClassesSettingID = null;//班次配置ID
  7088. // 新插入的班次配置表ID
  7089. int productionDataID = 0;
  7090. if (!string.IsNullOrEmpty(idStr))
  7091. {
  7092. productionDataID = int.Parse(idStr);
  7093. }
  7094. else
  7095. {
  7096. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  7097. }
  7098. #region 添加生产者数据
  7099. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, productionData.UserID, productionData.UserName, sUserInfo, ref ClassesSettingID);
  7100. if (!string.IsNullOrEmpty(errMsg))
  7101. {
  7102. return errMsg;
  7103. }
  7104. #endregion
  7105. #region 添加生产数据
  7106. #region 属性赋值
  7107. productionData.ClassesSettingID = ClassesSettingID;
  7108. productionData.ProductionDataID = Convert.ToInt32(idStr);
  7109. productionData.CentralizedBatchNo = centralizedBatchNo;
  7110. productionData.ProductionLineID = procedure.ProductionLineID;
  7111. productionData.ProductionLineCode = procedure.ProductionlineCode;
  7112. productionData.ProductionLineName = procedure.ProductionlineName;
  7113. productionData.CompleteProcedureID = procedure.ProcedureID;
  7114. productionData.ProcedureID = procedure.ProcedureID;
  7115. productionData.ProcedureCode = procedure.ProcedureCode;
  7116. productionData.ProcedureName = procedure.ProcedureName;
  7117. productionData.ProcedureModel = procedure.ProcedureModel;
  7118. productionData.ModelType = procedure.ModelType;
  7119. productionData.NodeType = procedure.NodeType;
  7120. productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, productionData.Barcode);
  7121. productionData.IsReFire = (int)Constant.ReFireFlag.No;
  7122. productionData.GoodsGrade = (int)Constant.GoodsGrade.Good;
  7123. productionData.OrganizationID = procedure.OrganizationID;
  7124. productionData.GoodsID = goodsID;
  7125. productionData.GoodsCode = goodsCode;
  7126. productionData.GoodsName = goodsName;
  7127. productionData.GoodsLevelID = productionData.GoodsLevelID;
  7128. productionData.GoodsLevelTypeID = productionData.GoodsLevelTypeID;
  7129. ////////如果报废给此产品最状态赋值
  7130. //////if (productionData.ProductionDefects != null)
  7131. //////{
  7132. ////// foreach (ProductionDefectEntity productionDefect in productionData.ProductionDefects)
  7133. ////// {
  7134. ////// if ((string.IsNullOrEmpty(productionDefect.ScrapResponFlag) ? "0" : productionDefect.ScrapResponFlag) == "1")
  7135. ////// {
  7136. ////// productionData.GoodsEnding = productionData.GoodsLevelTypeID.ToString();
  7137. ////// break;
  7138. ////// }
  7139. ////// }
  7140. //////}
  7141. //////if (productionData.GoodsLevelTypeID == (int)Constant.GoodsLevelType.Waste)
  7142. //////{
  7143. ////// productionData.GoodsEnding = Constant.GoodsLevelType.Waste.GetHashCode().ToString();
  7144. //////}
  7145. ////// string sqlReFire = @"select
  7146. ////// isrefire
  7147. ////// from tp_pm_inproduction where barcode=:barcode
  7148. ////// ";
  7149. ////// OracleParameter[] ReFireparas = new OracleParameter[] {
  7150. ////// new OracleParameter(":barcode",productionData.Barcode),
  7151. ////// };
  7152. ////// DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas);
  7153. ////// if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0)
  7154. ////// {
  7155. ////// if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0)
  7156. ////// {
  7157. ////// productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]);
  7158. ////// }
  7159. ////// }
  7160. #endregion
  7161. string OutSpecialRepairflag = "0";//干补标识
  7162. DataSet outDataSet = null;
  7163. //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的
  7164. //xuwei fix 2019-09-26 使用通用方法判定
  7165. // 2019-1016
  7166. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  7167. {
  7168. int isNodeBegin = IsNodeBegin<IDBTransaction>(oracleTrConn, productionData.Barcode);
  7169. if (isNodeBegin == 0)
  7170. {
  7171. procedure.NodeType = (int)Constant.ProcedureNodeType.Middle;
  7172. }
  7173. }
  7174. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  7175. {
  7176. errMsg = AddProductionDataDeliverMud(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag, out outDataSet);
  7177. }
  7178. else
  7179. {
  7180. errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag);
  7181. }
  7182. if (!string.IsNullOrEmpty(errMsg))
  7183. {
  7184. return errMsg;
  7185. }
  7186. if (productionData.ProductionDefects == null || productionData.ProductionDefects.Count == 0)
  7187. {
  7188. productionData.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  7189. }
  7190. #endregion
  7191. #region 获得产品分级ID
  7192. DataRow[] dr = goodsLevelTable.Select("GoodsLevelTypeID=" + productionData.GoodsLevelTypeID);
  7193. // 获得产品分级ID
  7194. productionData.GoodsLevelID = Convert.ToInt32(dr[0]["GoodsLevelID"]);
  7195. #endregion
  7196. #region 开始节点
  7197. //xuwei remove 2019-09-26 此处应该是重复判定 移除
  7198. //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的
  7199. //xuwei fix 2019-09-26 使用通用方法判定
  7200. //int isNodeBegin = IsNodeBegin<IDBTransaction>(oracleTrConn, productionData.Barcode);
  7201. // 2019-1016
  7202. //if (isNodeBegin == 1) procedure.NodeType = (int)Constant.ProcedureNodeType.Begin;
  7203. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  7204. {
  7205. #region 添加在产产品数据
  7206. InProductionEntity addInProductionEntity = new InProductionEntity();
  7207. addInProductionEntity.ProductionDataID = productionData.ProductionDataID;
  7208. addInProductionEntity.BarCode = productionData.Barcode;
  7209. //流程工序
  7210. addInProductionEntity.FlowProcedureID = procedure.ProcedureID;
  7211. // 当前工序
  7212. //addInProductionEntity.CompleteProcedureID = procedure.ProcedureID;
  7213. addInProductionEntity.ProcedureID = procedure.ProcedureID;
  7214. //生产数据ID
  7215. addInProductionEntity.ProductionDataID = productionDataID;
  7216. // 工序模型
  7217. addInProductionEntity.ProcedureModel = procedure.ProcedureModel;
  7218. // 工序类别
  7219. addInProductionEntity.ModelType = procedure.ModelType;
  7220. // 正常坯
  7221. addInProductionEntity.IsPublicBody = (int)Constant.PublicBodyFlag.No;
  7222. #endregion
  7223. // 生产工号
  7224. addInProductionEntity.UserID = productionData.UserID;
  7225. // 执行添加
  7226. errMsg = AddInProduction(oracleTrConn, addInProductionEntity, sUserInfo, outDataSet);
  7227. // 执行失败
  7228. if (!string.IsNullOrEmpty(errMsg))
  7229. {
  7230. return errMsg;
  7231. }
  7232. }
  7233. #endregion
  7234. #region 条码有缺陷
  7235. // 废品标识
  7236. bool scrapFlag = false;
  7237. // 存在缺陷 插入缺陷表
  7238. if (productionData.ProductionDefects != null)
  7239. {
  7240. foreach (ProductionDefectEntity productionDefect in productionData.ProductionDefects)
  7241. {
  7242. #region 保存缺陷
  7243. productionDefect.ProductionDataID = productionDataID;
  7244. productionDefect.BarCode = productionData.Barcode;
  7245. productionDefect.ProductionLineID = procedure.ProductionLineID;
  7246. productionDefect.ProductionLineCode = procedure.ProductionlineCode;
  7247. productionDefect.ProductionLineName = procedure.ProductionlineName;
  7248. productionDefect.ProcedureID = procedure.ProcedureID;
  7249. productionDefect.ProcedureCode = procedure.ProcedureCode;
  7250. productionDefect.ProcedureName = procedure.ProcedureName;
  7251. productionDefect.UserID = productionData.UserID;
  7252. productionDefect.UserCode = productionData.UserCode;
  7253. productionDefect.UserName = productionData.UserName;
  7254. productionDefect.GoodsID = productionData.GoodsID;
  7255. productionDefect.GoodsCode = productionData.GoodsCode;
  7256. productionDefect.GoodsName = productionData.GoodsName;
  7257. productionDefect.Remarks = productionData.Remarks;
  7258. productionDefect.ScrapResponFlag
  7259. = string.IsNullOrEmpty(productionDefect.ScrapResponFlag) ? "0" : productionDefect.ScrapResponFlag;
  7260. // 保存缺陷
  7261. errMsg = AddDefect(oracleTrConn, productionDefect, sUserInfo);
  7262. if (!string.IsNullOrEmpty(errMsg))
  7263. {
  7264. return errMsg;
  7265. }
  7266. #endregion
  7267. #region 缺陷列表中只有一个报废工序 添加废弃产品 删除在产产品数据
  7268. if (!scrapFlag && productionDefect.ScrapResponFlag == "1")
  7269. {
  7270. scrapFlag = true;
  7271. #region 添加废弃产品 删除在产产品数据
  7272. #region 添加废弃产品
  7273. ScrapProductEntity scrapProduct = new ScrapProductEntity();
  7274. #region 属性赋值
  7275. scrapProduct.BarCode = productionData.Barcode;
  7276. scrapProduct.ScrapType = Constant.ScrapType.Waste.GetHashCode();
  7277. //xuwei remove 2019-09-26 此处是重复判定移除
  7278. //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的
  7279. //xuwei fix 2019-09-26 使用通用方法判定
  7280. //int isNodeBegin = IsNodeBegin<IDBTransaction>(oracleTrConn, productionData.Barcode);
  7281. // 2019-1016
  7282. //if (isNodeBegin == 1) procedure.NodeType = (int)Constant.ProcedureNodeType.Begin;
  7283. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  7284. {
  7285. scrapProduct.ResponType = Constant.ScrapResponType.NoPerson.GetHashCode();
  7286. }
  7287. else
  7288. {
  7289. scrapProduct.ResponType = Constant.ScrapResponType.Procedure.GetHashCode();
  7290. }
  7291. scrapProduct.ScrapDate = accountDate;
  7292. scrapProduct.Rreason = Constant.SCRAPTYPE_WASTE;
  7293. scrapProduct.Remarks = productionDefect.Remarks;
  7294. scrapProduct.AuditStatus = Constant.AuditStatus.Agree.GetHashCode();
  7295. scrapProduct.Auditor = sUserInfo.UserID;
  7296. scrapProduct.AuditlDate = accountDate;
  7297. scrapProduct.AccountDate = accountDate;
  7298. scrapProduct.GoodsLevelID = productionData.GoodsLevelID;
  7299. scrapProduct.GoodsLevelTypeID = productionData.GoodsLevelTypeID;
  7300. string sqlScrapProduct = "select SEQ_PM_ScrapProduct_ID.nextval from dual";
  7301. string idStrScrapProduct = oracleTrConn.GetSqlResultToStr(sqlScrapProduct);
  7302. scrapProduct.ScrapProductID = Convert.ToInt32(idStrScrapProduct);
  7303. scrapProduct.ScrapType = 1;
  7304. scrapProduct.IsQualityStatistics = 1;
  7305. scrapProduct.ProductionDataID = productionData.ProductionDataID;
  7306. #endregion
  7307. // 保存报废
  7308. errMsg = AddScrapProduct(oracleTrConn, scrapProduct, sUserInfo);
  7309. // 保存失败
  7310. if (!string.IsNullOrEmpty(errMsg))
  7311. {
  7312. return errMsg;
  7313. }
  7314. #endregion
  7315. #region 添加责任工序
  7316. //xuwei remove 2019-09-26 此处是重复判定移除
  7317. //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的
  7318. //xuwei fix 2019-09-26 使用通用方法判定
  7319. //int isNodeBegin = IsNodeBegin<IDBTransaction>(oracleTrConn, productionData.Barcode);
  7320. // 2019-1016
  7321. //if (isNodeBegin == 1) procedure.NodeType = (int)Constant.ProcedureNodeType.Begin;
  7322. // 不是开始工序时。需要添加责任工序
  7323. if (procedure.NodeType != Constant.ProcedureNodeType.Begin.GetHashCode())
  7324. {
  7325. //string sqlScrapProduct = "select SEQ_PM_ScrapProduct_ID.Currval from dual";
  7326. //string idStrScrapProduct = oracleTrConn.GetSqlResultToStr(sqlScrapProduct);
  7327. ResponProcedureEntity responProce = new ResponProcedureEntity();
  7328. #region 属性赋值
  7329. responProce.BarCode = productionData.Barcode;
  7330. responProce.ProductionDataID = productionDataID;
  7331. responProce.ProductionLineID = productionDefect.ProductionLineID;
  7332. responProce.ProductionLineCode = productionDefect.ProductionLineCode;
  7333. responProce.ProductionLineName = productionDefect.ProductionLineName;
  7334. responProce.ProcedureID = productionDefect.DefectProcedureID;
  7335. responProce.ProcedureCode = productionDefect.DefectProcedureCode;
  7336. responProce.ProcedureName = productionDefect.DefectProcedureName;
  7337. responProce.UserID = productionDefect.DefectUserID;
  7338. responProce.UserCode = productionDefect.DefectUserCode;
  7339. responProce.UserName = productionDefect.DefectUserName;
  7340. responProce.Remarks = productionDefect.Remarks;
  7341. responProce.ScrapProductID = Convert.ToInt32(idStrScrapProduct);
  7342. #endregion
  7343. // 保存责任工序
  7344. errMsg = AddResponProcedure(oracleTrConn, responProce, productionDefect, sUserInfo);
  7345. // 保存失败
  7346. if (!string.IsNullOrEmpty(errMsg))
  7347. {
  7348. return errMsg;
  7349. }
  7350. }
  7351. #endregion
  7352. #region 删除在产产品数据
  7353. InProductionEntity delInProductionEntity = new InProductionEntity();
  7354. delInProductionEntity.BarCode = productionData.Barcode;
  7355. delInProductionEntity.CompleteProcedureID = productionData.ProcedureID;
  7356. // 执行删除 在产数据
  7357. errMsg = DeleteInProduction(oracleTrConn, delInProductionEntity, false, sUserInfo);
  7358. // 执行失败
  7359. if (!string.IsNullOrEmpty(errMsg))
  7360. {
  7361. return errMsg;
  7362. }
  7363. #endregion
  7364. #endregion
  7365. }
  7366. #endregion
  7367. }
  7368. }
  7369. #endregion
  7370. #region 条码没有报废
  7371. if (!scrapFlag)
  7372. {
  7373. #region 检验出缺陷 并且不是废品 修改在产产品数据
  7374. //xuwei remove 2019-09-26 此处是重复判定移除
  7375. //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的
  7376. //xuwei fix 2019-09-26 使用通用方法判定
  7377. //int isNodeBegin = IsNodeBegin<IDBTransaction>(oracleTrConn, productionData.Barcode);
  7378. // 2019-1016
  7379. //if (isNodeBegin == 1) procedure.NodeType = (int)Constant.ProcedureNodeType.Begin;
  7380. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Middle
  7381. || procedure.NodeType == (int)Constant.ProcedureNodeType.Begin
  7382. || productionData.GoodsLevelTypeID == Constant.GoodsLevelType.Defect.GetHashCode())
  7383. {
  7384. #region 修改在产产品数据的当前工序
  7385. InProductionEntity inProductionEntity = new InProductionEntity();
  7386. inProductionEntity.ProductionDataID = Convert.ToInt32(idStr);
  7387. inProductionEntity.BarCode = productionData.Barcode;
  7388. // 当前工序
  7389. inProductionEntity.ProcedureID = procedure.ProcedureID;
  7390. inProductionEntity.FlowProcedureID = procedure.ProcedureID;
  7391. // 工序模型
  7392. inProductionEntity.ProcedureModel = procedure.ProcedureModel;
  7393. // 工序类别
  7394. inProductionEntity.ModelType = procedure.ModelType;
  7395. // 生产工号
  7396. inProductionEntity.UserID = productionData.UserID;
  7397. // 缺陷标识
  7398. inProductionEntity.DefectFlag = productionData.DefectFlag;
  7399. // 返工工序ID
  7400. inProductionEntity.ReworkProcedureID = productionData.ReworkProcedureID;
  7401. inProductionEntity.GoodsLevelTypeID = productionData.GoodsLevelTypeID;
  7402. inProductionEntity.GoodsLevelID = productionData.GoodsLevelID;
  7403. // 执行修改
  7404. errMsg = UpdateInProduction(oracleTrConn, inProductionEntity, sUserInfo);
  7405. // 执行失败
  7406. if (!string.IsNullOrEmpty(errMsg))
  7407. {
  7408. return errMsg;
  7409. }
  7410. #endregion
  7411. }
  7412. #endregion
  7413. #region 结束工序、没有缺陷 添加成品数据 删除在产产品数据
  7414. //else if (procedure.NodeType == (int)Constant.ProcedureNodeType.End
  7415. // && productionData.DefectFlag == Constant.DefectFlag.No.GetHashCode())
  7416. else if (procedure.NodeType == (int)Constant.ProcedureNodeType.End
  7417. && productionData.GoodsLevelTypeID == Constant.GoodsLevelType.NoDefects.GetHashCode())
  7418. {
  7419. #region 添加成品数据 删除在产产品数据
  7420. FinishedProductEntity finishedProduct = new FinishedProductEntity();
  7421. finishedProduct.BarCode = productionData.Barcode;
  7422. errMsg = AddFinishedProduct(oracleTrConn, finishedProduct, sUserInfo, finishedloadbatchno);
  7423. if (!string.IsNullOrEmpty(errMsg))
  7424. {
  7425. return errMsg;
  7426. }
  7427. InProductionEntity delInProductionEntity = new InProductionEntity();
  7428. delInProductionEntity.BarCode = productionData.Barcode;
  7429. // 执行删除 在产数据
  7430. errMsg = DeleteInProduction(oracleTrConn, delInProductionEntity, true, sUserInfo);
  7431. // 执行失败
  7432. if (!string.IsNullOrEmpty(errMsg))
  7433. {
  7434. return errMsg;
  7435. }
  7436. #endregion
  7437. }
  7438. #endregion
  7439. }
  7440. #endregion
  7441. }
  7442. return errMsg;
  7443. }
  7444. ///// <summary>
  7445. ///// 报废更新产品数据最终状态
  7446. ///// </summary>
  7447. ///// <param name="oracleTrConn">连接对象</param>
  7448. ///// <param name="barcode">产品条码</param>
  7449. ///// <param name="sUserInfo">用记基本信息</param>
  7450. ///// <returns>string</returns>
  7451. ///// <remarks>
  7452. ///// 王鑫 2015.01.07 新建
  7453. ///// </remarks>
  7454. //private static string UpdateProductionDataGoodsEnding(IDBTransaction oracleTrConn, int productionDataID, int? goodsEnding, SUserInfo sUserInfo)
  7455. //{
  7456. // string sql = "update TP_PM_ProductionData set GoodsEnding=:goodsEnding where ProductionDataID = :productionDataID and AccountID=:accountid";
  7457. // OracleParameter[] paras = new OracleParameter[] {
  7458. // new OracleParameter(":goodsEnding",goodsEnding),
  7459. // new OracleParameter(":productionDataID",productionDataID),
  7460. // new OracleParameter(":accountid",sUserInfo.AccountID),
  7461. // };
  7462. // int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  7463. // // 更新失败
  7464. // if (result <= Constant.INT_IS_ZERO)
  7465. // {
  7466. // return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  7467. // }
  7468. // // 成功返回null
  7469. // return null;
  7470. //}
  7471. /// <summary>
  7472. /// 添加责任工序
  7473. /// </summary>
  7474. /// <param name="oracleTrConn">连接对象</param>
  7475. /// <param name="responProce">责任工序</param>
  7476. /// <param name="productionDefect">缺陷数据</param>
  7477. /// <param name="sUserInfo">用户基本信息</param>
  7478. /// <returns>string</returns>
  7479. private static string AddResponProcedure(IDBTransaction oracleTrConn, ResponProcedureEntity responProce, ProductionDefectEntity productionDefect, SUserInfo sUserInfo)
  7480. {
  7481. OracleParameter[] oracleParameters = null;
  7482. string sql = null;
  7483. int result = 0;
  7484. // 查询新插入ID
  7485. if (productionDefect.DefectProcedureID != null)
  7486. {
  7487. sql = "select SEQ_PM_ResponProcedure_ID.nextval from dual";
  7488. string idStr = oracleTrConn.GetSqlResultToStr(sql);
  7489. if (!string.IsNullOrEmpty(idStr))
  7490. {
  7491. responProce.ResponProcedureID = int.Parse(idStr);
  7492. }
  7493. else
  7494. {
  7495. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  7496. }
  7497. #region SQL
  7498. sql = "insert into tp_pm_responprocedure"
  7499. + " (ResponProcedureID,"
  7500. + " scrapproductid,"
  7501. + " barcode,"
  7502. + " productiondataid,"
  7503. + " productionlineid,"
  7504. + " productionlinecode,"
  7505. + " productionlinename,"
  7506. + " procedureid,"
  7507. + " procedurecode,"
  7508. + " procedurename,"
  7509. + " userid,"
  7510. + " usercode,"
  7511. + " username,"
  7512. + " remarks,"
  7513. + " accountid,"
  7514. + " createuserid,"
  7515. + " updateuserid)"
  7516. + " values"
  7517. + " ("
  7518. + " :ResponProcedureID,"
  7519. + " :scrapproductid,"
  7520. + " :barcode,"
  7521. + " :productiondataid,"
  7522. + " :productionlineid,"
  7523. + " :productionlinecode,"
  7524. + " :productionlinename,"
  7525. + " :procedureid,"
  7526. + " :procedurecode,"
  7527. + " :procedurename,"
  7528. + " :userid,"
  7529. + " :usercode,"
  7530. + " :username,"
  7531. + " :remarks,"
  7532. + " :accountid,"
  7533. + " :createuserid,"
  7534. + " :updateuserid)";
  7535. #endregion
  7536. #region 参数
  7537. oracleParameters = new OracleParameter[] {
  7538. new OracleParameter(":ResponProcedureID",responProce.ResponProcedureID),
  7539. new OracleParameter(":scrapproductid",responProce.ScrapProductID),
  7540. new OracleParameter(":barcode",responProce.BarCode),
  7541. new OracleParameter(":productiondataid",responProce.ProductionDataID),
  7542. new OracleParameter(":productionlineid",responProce.ProductionLineID),
  7543. new OracleParameter(":productionlinecode",responProce.ProductionLineCode),
  7544. new OracleParameter(":productionlinename",responProce.ProductionLineName),
  7545. new OracleParameter(":procedureid",responProce.ProcedureID),
  7546. new OracleParameter(":procedurecode",responProce.ProcedureCode),
  7547. new OracleParameter(":procedurename",responProce.ProcedureName),
  7548. new OracleParameter(":userid",responProce.UserID),
  7549. new OracleParameter(":usercode",responProce.UserCode),
  7550. new OracleParameter(":username",responProce.UserName),
  7551. new OracleParameter(":remarks",responProce.Remarks),
  7552. new OracleParameter(":accountid",sUserInfo.AccountID),
  7553. new OracleParameter(":createuserid",sUserInfo.UserID),
  7554. new OracleParameter(":updateuserid",sUserInfo.UserID),
  7555. };
  7556. #endregion
  7557. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  7558. // 保存失败
  7559. if (result != Constant.INT_IS_ONE)
  7560. {
  7561. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  7562. }
  7563. //// 查询新插入ID
  7564. //sql = "select SEQ_PM_ResponProcedure_ID.Currval from dual";
  7565. //string idStr = oracleTrConn.GetSqlResultToStr(sql);
  7566. //if (!string.IsNullOrEmpty(idStr))
  7567. //{
  7568. // responProce.ResponProcedureID = int.Parse(idStr);
  7569. //}
  7570. //else
  7571. //{
  7572. // return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  7573. //}
  7574. }
  7575. #region 插入责任人
  7576. foreach (DefectResponsibleEntity defectResponsible in productionDefect.DefectResponsibles)
  7577. {
  7578. #region SQL
  7579. sql = "insert into tp_pm_scrapresponsible"
  7580. + " (barcode,"
  7581. + " scrapproductid,"
  7582. + " staffid,"
  7583. + " userid,"
  7584. + " usercode,"
  7585. + " ujobsid,"
  7586. + " sjobsid,"
  7587. + " staffstatus,"
  7588. + " accountid,"
  7589. + " createuserid,"
  7590. + " updateuserid,"
  7591. + " responprocedureid,"
  7592. + " respontype)"
  7593. + " values"
  7594. + " (:barcode,"
  7595. + " :scrapproductid,"
  7596. + " :staffid,"
  7597. + " :userid,"
  7598. + " :usercode,"
  7599. + " :ujobsid,"
  7600. + " :sjobsid,"
  7601. + " :staffstatus,"
  7602. + " :accountid,"
  7603. + " :createuserid,"
  7604. + " :updateuserid,"
  7605. + " :responprocedureid,"
  7606. + " :respontype)";
  7607. #endregion
  7608. #region 参数
  7609. oracleParameters = new OracleParameter[] {
  7610. new OracleParameter(":scrapproductid",responProce.ScrapProductID),
  7611. new OracleParameter(":barcode",responProce.BarCode),
  7612. new OracleParameter(":staffid",defectResponsible.StaffID),
  7613. new OracleParameter(":userid",defectResponsible.UserID),
  7614. new OracleParameter(":usercode",defectResponsible.UserCode),
  7615. new OracleParameter(":ujobsid",defectResponsible.UJobsID),
  7616. new OracleParameter(":sjobsid",defectResponsible.SJobsID),
  7617. new OracleParameter(":staffstatus",defectResponsible.StaffStatus),
  7618. new OracleParameter(":accountid",sUserInfo.AccountID),
  7619. new OracleParameter(":createuserid",sUserInfo.UserID),
  7620. new OracleParameter(":updateuserid",sUserInfo.UserID),
  7621. new OracleParameter(":responprocedureid",responProce.ResponProcedureID),
  7622. new OracleParameter(":respontype",Constant.ScrapResponType.Procedure.GetHashCode()),
  7623. };
  7624. #endregion
  7625. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  7626. // 保存失败
  7627. if (result != Constant.INT_IS_ONE)
  7628. {
  7629. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  7630. }
  7631. }
  7632. #endregion
  7633. return null;
  7634. }
  7635. /// <summary>
  7636. /// 保存废弃产品
  7637. /// </summary>
  7638. /// <param name="oracleTrConn">连接对象</param>
  7639. /// <param name="scrapProduct">报废产品</param>
  7640. /// <param name="sUserInfo">用户基本信息</param>
  7641. /// <returns>string</returns>
  7642. private static string AddScrapProductRejectToReject(IDBTransaction oracleTrConn, ScrapProductEntity scrapProduct, SUserInfo sUserInfo)
  7643. {
  7644. #region sql
  7645. string sql = "insert into tp_pm_scrapproduct"
  7646. + " (scrapproductid,barcode,"
  7647. + " productionlineid,"
  7648. + " productionlinecode,"
  7649. + " productionlinename,"
  7650. + " goodsid,"
  7651. + " goodscode,"
  7652. + " goodsname,"
  7653. + " groutingdailyid,"
  7654. + " groutingdailydetailid,"
  7655. + " groutingdate,"
  7656. + " groutinglineid,"
  7657. + " groutinglinecode,"
  7658. + " groutinglinename,"
  7659. + " gmouldtypeid,"
  7660. + " groutinglinedetailid,"
  7661. + " groutingmouldcode,"
  7662. + " mouldcode,"
  7663. + " scrapdate,"
  7664. + " rreason,"
  7665. + " remarks,"
  7666. + " auditstatus,"
  7667. + " auditor,"
  7668. + " auditdate,"
  7669. + " accountdate,"
  7670. + " accountid,"
  7671. + " createuserid,"
  7672. + " updateuserid,"
  7673. + " respontype,GoodsLevelID,GoodsLevelTypeID,"
  7674. + " auditopinion,"
  7675. + " GroutingUserID,"
  7676. + " GroutingUserCode,"
  7677. + " GroutingNum,"
  7678. + " IsPublicBody,"
  7679. + " IsReFire,"
  7680. + " kilnid,"
  7681. + " kilncode,"
  7682. + " kilnname,"
  7683. + " kilncarid,"
  7684. + " kilncarcode,"
  7685. + " kilncarname,"
  7686. + " kilncarbatchno,"
  7687. + " kilncarposition,"
  7688. + " specialRepairflag,"
  7689. + " logoid,ProductionDataID, "
  7690. + " ProcedureID, "
  7691. + " ProcedureCode, "
  7692. + " ProcedureName, "
  7693. + " ScrapType "
  7694. + ")"
  7695. + " select :scrapproductid,trash.barcode,"
  7696. + " trash.productionlineid,"
  7697. + " trash.productionlinecode,"
  7698. + " trash.productionlinename,"
  7699. + " trash.goodsid,"
  7700. + " trash.goodscode,"
  7701. + " trash.goodsname,"
  7702. + " trash.groutingdailyid,"
  7703. + " trash.groutingdailydetailid,"
  7704. + " trash.groutingdate,"
  7705. + " trash.groutinglineid,"
  7706. + " trash.groutinglinecode,"
  7707. + " trash.groutinglinename,"
  7708. + " trash.gmouldtypeid,"
  7709. + " trash.groutinglinedetailid,"
  7710. + " trash.groutingmouldcode,"
  7711. + " trash.mouldcode,"
  7712. + " :scrapdate,"
  7713. + " :rreason,"
  7714. + " :remarks,"
  7715. + " :auditstatus,"
  7716. + " :auditor,"
  7717. // + " :auditdate,"
  7718. + " sysdate,"
  7719. + " :accountdate,"
  7720. + " trash.accountid,"
  7721. + " :createuserid,"
  7722. + " :updateuserid,"
  7723. + " :respontype,:GoodsLevelID,:GoodsLevelTypeID,"
  7724. + " :auditopinion,"
  7725. + " trash.GroutingUserID,"
  7726. + " trash.GroutingUserCode,"
  7727. + " trash.GroutingNum,"
  7728. + " trash.IsPublicBody,"
  7729. + " trash.IsReFire,"
  7730. + " trash.kilnid,"
  7731. + " trash.kilncode,"
  7732. + " trash.kilnname,"
  7733. + " trash.kilncarid,"
  7734. + " trash.kilncarcode,"
  7735. + " trash.kilncarname,"
  7736. + " trash.kilncarbatchno,"
  7737. + " trash.kilncarposition,"
  7738. + " trash.specialRepairflag,"
  7739. + " trash.logoid,:ProductionDataID,"
  7740. + " TP_PC_Procedure.ProcedureID, "
  7741. + " TP_PC_Procedure.ProcedureCode, "
  7742. + " TP_PC_Procedure.ProcedureName, "
  7743. + " :ScrapType "
  7744. + " from tp_pm_inproductiontrash trash"
  7745. + " left join TP_PC_Procedure on trash.FlowProcedureID=TP_PC_Procedure.ProcedureID"
  7746. + " where trash.barcode = :barcode";
  7747. #endregion
  7748. #region 参数
  7749. OracleParameter[] oracleParameters = null;
  7750. oracleParameters = new OracleParameter[] {
  7751. new OracleParameter(":scrapproductid",OracleDbType.Int32,scrapProduct.ScrapProductID,ParameterDirection.Input),
  7752. new OracleParameter(":scrapdate",OracleDbType.Date,scrapProduct.ScrapDate,ParameterDirection.Input),
  7753. new OracleParameter(":rreason",OracleDbType.Varchar2,scrapProduct.Rreason,ParameterDirection.Input),
  7754. new OracleParameter(":remarks",OracleDbType.Varchar2,scrapProduct.Remarks,ParameterDirection.Input),
  7755. new OracleParameter(":auditstatus",OracleDbType.Int32,scrapProduct.AuditStatus,ParameterDirection.Input),
  7756. new OracleParameter(":auditor",OracleDbType.Int32,scrapProduct.Auditor,ParameterDirection.Input),
  7757. //new OracleParameter(":auditdate",OracleDbType.Date,scrapProduct.AuditlDate,ParameterDirection.Input),
  7758. new OracleParameter(":accountdate",OracleDbType.Date,scrapProduct.AccountDate,ParameterDirection.Input),
  7759. new OracleParameter(":createuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  7760. new OracleParameter(":updateuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  7761. new OracleParameter(":respontype",OracleDbType.Varchar2,scrapProduct.ResponType,ParameterDirection.Input),
  7762. new OracleParameter(":auditopinion",OracleDbType.Varchar2,scrapProduct.AuditOpinion,ParameterDirection.Input),
  7763. new OracleParameter(":barcode",OracleDbType.Varchar2,scrapProduct.BarCode,ParameterDirection.Input),
  7764. new OracleParameter(":GoodsLevelID",OracleDbType.Int32,scrapProduct.GoodsLevelID,ParameterDirection.Input),
  7765. new OracleParameter(":GoodsLevelTypeID",OracleDbType.Int32,scrapProduct.GoodsLevelTypeID,ParameterDirection.Input),
  7766. new OracleParameter(":ScrapType",OracleDbType.Int32,scrapProduct.ScrapType,ParameterDirection.Input),
  7767. new OracleParameter(":ProductionDataID",OracleDbType.Int32,scrapProduct.ProductionDataID,ParameterDirection.Input),
  7768. };
  7769. #endregion
  7770. int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  7771. // result += oracleTrConn.ExecuteNonQuery(sql2, oracleParameters);
  7772. //// 保存失败
  7773. //if (result != Constant.INT_IS_ONE)
  7774. //{
  7775. // return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  7776. //}
  7777. return null;
  7778. }
  7779. /// <summary>
  7780. /// 保存废弃产品
  7781. /// </summary>
  7782. /// <param name="oracleTrConn">连接对象</param>
  7783. /// <param name="scrapProduct">报废产品</param>
  7784. /// <param name="sUserInfo">用户基本信息</param>
  7785. /// <returns>string</returns>
  7786. private static string AddScrapProduct(IDBTransaction oracleTrConn, ScrapProductEntity scrapProduct, SUserInfo sUserInfo)
  7787. {
  7788. #region sql
  7789. string sql = "insert into tp_pm_scrapproduct"
  7790. + " (scrapproductid,barcode,"
  7791. + " productionlineid,"
  7792. + " productionlinecode,"
  7793. + " productionlinename,"
  7794. + " goodsid,"
  7795. + " goodscode,"
  7796. + " goodsname,"
  7797. + " groutingdailyid,"
  7798. + " groutingdailydetailid,"
  7799. + " groutingdate,"
  7800. + " groutinglineid,"
  7801. + " groutinglinecode,"
  7802. + " groutinglinename,"
  7803. + " gmouldtypeid,"
  7804. + " groutinglinedetailid,"
  7805. + " groutingmouldcode,"
  7806. + " mouldcode,"
  7807. + " scrapdate,"
  7808. + " rreason,"
  7809. + " remarks,"
  7810. + " auditstatus,"
  7811. + " auditor,"
  7812. + " auditdate,"
  7813. + " accountdate,"
  7814. + " accountid,"
  7815. + " createuserid,"
  7816. + " updateuserid,"
  7817. + " respontype,GoodsLevelID,GoodsLevelTypeID,"
  7818. + " auditopinion,"
  7819. + " GroutingUserID,"
  7820. + " GroutingUserCode,"
  7821. + " GroutingNum,"
  7822. + " IsPublicBody,"
  7823. + " IsReFire,"
  7824. + " kilnid,"
  7825. + " kilncode,"
  7826. + " kilnname,"
  7827. + " kilncarid,"
  7828. + " kilncarcode,"
  7829. + " kilncarname,"
  7830. + " kilncarbatchno,"
  7831. + " kilncarposition,"
  7832. + " specialRepairflag,"
  7833. + " logoid,"
  7834. + " ProductionDataID, "
  7835. + " ProcedureID, "
  7836. + " ProcedureCode, "
  7837. + " ProcedureName, "
  7838. + " ScrapType "
  7839. + ")"
  7840. + " select :scrapproductid,barcode,"
  7841. + " InProduction.productionlineid,"
  7842. + " InProduction.productionlinecode,"
  7843. + " InProduction.productionlinename,"
  7844. + " InProduction.goodsid,"
  7845. + " InProduction.goodscode,"
  7846. + " InProduction.goodsname,"
  7847. + " InProduction.groutingdailyid,"
  7848. + " InProduction.groutingdailydetailid,"
  7849. + " InProduction.groutingdate,"
  7850. + " InProduction.groutinglineid,"
  7851. + " InProduction.groutinglinecode,"
  7852. + " InProduction.groutinglinename,"
  7853. + " InProduction.gmouldtypeid,"
  7854. + " InProduction.groutinglinedetailid,"
  7855. + " InProduction.groutingmouldcode,"
  7856. + " InProduction.mouldcode,"
  7857. + " :scrapdate,"
  7858. + " :rreason,"
  7859. + " :remarks,"
  7860. + " :auditstatus,"
  7861. + " :auditor,"
  7862. // + " :auditdate,"
  7863. + " sysdate,"
  7864. + " :accountdate,"
  7865. + " InProduction.accountid,"
  7866. + " :createuserid,"
  7867. + " :updateuserid,"
  7868. + " :respontype,:GoodsLevelID,:GoodsLevelTypeID,"
  7869. + " :auditopinion,"
  7870. + " InProduction.GroutingUserID,"
  7871. + " InProduction.GroutingUserCode,"
  7872. + " InProduction.GroutingNum,"
  7873. + " InProduction.IsPublicBody,"
  7874. + " InProduction.IsReFire,"
  7875. + " InProduction.kilnid,"
  7876. + " InProduction.kilncode,"
  7877. + " InProduction.kilnname,"
  7878. + " InProduction.kilncarid,"
  7879. + " InProduction.kilncarcode,"
  7880. + " InProduction.kilncarname,"
  7881. + " InProduction.kilncarbatchno,"
  7882. + " InProduction.kilncarposition,"
  7883. + " InProduction.specialRepairflag,"
  7884. + " InProduction.logoid,";
  7885. if (scrapProduct.IsQualityStatistics == null)
  7886. {
  7887. sql += " InProduction.ProductionDataID,";
  7888. }
  7889. else
  7890. {
  7891. sql += " :ProductionDataID,";
  7892. }
  7893. sql += " TP_PC_Procedure.ProcedureID, "
  7894. + " TP_PC_Procedure.ProcedureCode, "
  7895. + " TP_PC_Procedure.ProcedureName, "
  7896. + " :ScrapType"
  7897. + " from TP_PM_InProduction InProduction"
  7898. + " left join TP_PC_Procedure on InProduction.FlowProcedureID=TP_PC_Procedure.ProcedureID"
  7899. + " where InProduction.barcode = :barcode";
  7900. #endregion
  7901. #region 参数
  7902. OracleParameter[] oracleParameters = null;
  7903. if (scrapProduct.IsQualityStatistics == null)
  7904. {
  7905. oracleParameters = new OracleParameter[] {
  7906. new OracleParameter(":scrapproductid",OracleDbType.Int32,scrapProduct.ScrapProductID,ParameterDirection.Input),
  7907. new OracleParameter(":scrapdate",OracleDbType.Date,scrapProduct.ScrapDate,ParameterDirection.Input),
  7908. new OracleParameter(":rreason",OracleDbType.Varchar2,scrapProduct.Rreason,ParameterDirection.Input),
  7909. new OracleParameter(":remarks",OracleDbType.Varchar2,scrapProduct.Remarks,ParameterDirection.Input),
  7910. new OracleParameter(":auditstatus",OracleDbType.Int32,scrapProduct.AuditStatus,ParameterDirection.Input),
  7911. new OracleParameter(":auditor",OracleDbType.Int32,scrapProduct.Auditor,ParameterDirection.Input),
  7912. //new OracleParameter(":auditdate",OracleDbType.Date,scrapProduct.AuditlDate,ParameterDirection.Input),
  7913. new OracleParameter(":accountdate",OracleDbType.Date,scrapProduct.AccountDate,ParameterDirection.Input),
  7914. new OracleParameter(":createuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  7915. new OracleParameter(":updateuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  7916. new OracleParameter(":respontype",OracleDbType.Varchar2,scrapProduct.ResponType,ParameterDirection.Input),
  7917. new OracleParameter(":auditopinion",OracleDbType.Varchar2,scrapProduct.AuditOpinion,ParameterDirection.Input),
  7918. new OracleParameter(":barcode",OracleDbType.Varchar2,scrapProduct.BarCode,ParameterDirection.Input),
  7919. new OracleParameter(":GoodsLevelID",OracleDbType.Int32,scrapProduct.GoodsLevelID,ParameterDirection.Input),
  7920. new OracleParameter(":GoodsLevelTypeID",OracleDbType.Int32,scrapProduct.GoodsLevelTypeID,ParameterDirection.Input),
  7921. new OracleParameter(":ScrapType",OracleDbType.Int32,scrapProduct.ScrapType,ParameterDirection.Input),
  7922. };
  7923. }
  7924. else
  7925. {
  7926. oracleParameters = new OracleParameter[] {
  7927. new OracleParameter(":scrapproductid",OracleDbType.Int32,scrapProduct.ScrapProductID,ParameterDirection.Input),
  7928. new OracleParameter(":scrapdate",OracleDbType.Date,scrapProduct.ScrapDate,ParameterDirection.Input),
  7929. new OracleParameter(":rreason",OracleDbType.Varchar2,scrapProduct.Rreason,ParameterDirection.Input),
  7930. new OracleParameter(":remarks",OracleDbType.Varchar2,scrapProduct.Remarks,ParameterDirection.Input),
  7931. new OracleParameter(":auditstatus",OracleDbType.Int32,scrapProduct.AuditStatus,ParameterDirection.Input),
  7932. new OracleParameter(":auditor",OracleDbType.Int32,scrapProduct.Auditor,ParameterDirection.Input),
  7933. //new OracleParameter(":auditdate",OracleDbType.Date,scrapProduct.AuditlDate,ParameterDirection.Input),
  7934. new OracleParameter(":accountdate",OracleDbType.Date,scrapProduct.AccountDate,ParameterDirection.Input),
  7935. new OracleParameter(":createuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  7936. new OracleParameter(":updateuserid",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  7937. new OracleParameter(":respontype",OracleDbType.Varchar2,scrapProduct.ResponType,ParameterDirection.Input),
  7938. new OracleParameter(":auditopinion",OracleDbType.Varchar2,scrapProduct.AuditOpinion,ParameterDirection.Input),
  7939. new OracleParameter(":barcode",OracleDbType.Varchar2,scrapProduct.BarCode,ParameterDirection.Input),
  7940. new OracleParameter(":GoodsLevelID",OracleDbType.Int32,scrapProduct.GoodsLevelID,ParameterDirection.Input),
  7941. new OracleParameter(":GoodsLevelTypeID",OracleDbType.Int32,scrapProduct.GoodsLevelTypeID,ParameterDirection.Input),
  7942. new OracleParameter(":ScrapType",OracleDbType.Int32,scrapProduct.ScrapType,ParameterDirection.Input),
  7943. new OracleParameter(":ProductionDataID",OracleDbType.Int32,scrapProduct.ProductionDataID,ParameterDirection.Input),
  7944. };
  7945. }
  7946. #endregion
  7947. int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  7948. if (result == 0)
  7949. {
  7950. sql = "insert into tp_pm_scrapproduct"
  7951. + " (scrapproductid,barcode,"
  7952. + " productionlineid,"
  7953. + " productionlinecode,"
  7954. + " productionlinename,"
  7955. + " goodsid,"
  7956. + " goodscode,"
  7957. + " goodsname,"
  7958. + " groutingdailyid,"
  7959. + " groutingdailydetailid,"
  7960. + " groutingdate,"
  7961. + " groutinglineid,"
  7962. + " groutinglinecode,"
  7963. + " groutinglinename,"
  7964. + " gmouldtypeid,"
  7965. + " groutinglinedetailid,"
  7966. + " groutingmouldcode,"
  7967. + " mouldcode,"
  7968. + " scrapdate,"
  7969. + " rreason,"
  7970. + " remarks,"
  7971. + " auditstatus,"
  7972. + " auditor,"
  7973. + " auditdate,"
  7974. + " accountdate,"
  7975. + " accountid,"
  7976. + " createuserid,"
  7977. + " updateuserid,"
  7978. + " respontype,GoodsLevelID,GoodsLevelTypeID,"
  7979. + " auditopinion,"
  7980. + " GroutingUserID,"
  7981. + " GroutingUserCode,"
  7982. + " GroutingNum,"
  7983. + " IsPublicBody,"
  7984. + " IsReFire,"
  7985. + " kilnid,"
  7986. + " kilncode,"
  7987. + " kilnname,"
  7988. + " kilncarid,"
  7989. + " kilncarcode,"
  7990. + " kilncarname,"
  7991. + " kilncarbatchno,"
  7992. + " kilncarposition,"
  7993. + " specialRepairflag,"
  7994. + " logoid,"
  7995. + " ProductionDataID,"
  7996. + " ProcedureID, "
  7997. + " ProcedureCode, "
  7998. + " ProcedureName, "
  7999. + " ScrapType "
  8000. + ")"
  8001. + " select :scrapproductid,trash.barcode,"
  8002. + " trash.productionlineid,"
  8003. + " trash.productionlinecode,"
  8004. + " trash.productionlinename,"
  8005. + " trash.goodsid,"
  8006. + " trash.goodscode,"
  8007. + " trash.goodsname,"
  8008. + " trash.groutingdailyid,"
  8009. + " trash.groutingdailydetailid,"
  8010. + " trash.groutingdate,"
  8011. + " trash.groutinglineid,"
  8012. + " trash.groutinglinecode,"
  8013. + " trash.groutinglinename,"
  8014. + " trash.gmouldtypeid,"
  8015. + " trash.groutinglinedetailid,"
  8016. + " trash.groutingmouldcode,"
  8017. + " trash.mouldcode,"
  8018. + " :scrapdate,"
  8019. + " :rreason,"
  8020. + " :remarks,"
  8021. + " :auditstatus,"
  8022. + " :auditor,"
  8023. //+ " :auditdate,"
  8024. + " sysdate,"
  8025. + " :accountdate,"
  8026. + " trash.accountid,"
  8027. + " :createuserid,"
  8028. + " :updateuserid,"
  8029. + " :respontype,:GoodsLevelID,:GoodsLevelTypeID,"
  8030. + " :auditopinion,"
  8031. + " trash.GroutingUserID,"
  8032. + " trash.GroutingUserCode,"
  8033. + " trash.GroutingNum,"
  8034. + " trash.IsPublicBody,"
  8035. + " trash.IsReFire,"
  8036. + " trash.kilnid,"
  8037. + " trash.kilncode,"
  8038. + " trash.kilnname,"
  8039. + " trash.kilncarid,"
  8040. + " trash.kilncarcode,"
  8041. + " trash.kilncarname,"
  8042. + " trash.kilncarbatchno,"
  8043. + " trash.kilncarposition,"
  8044. + " trash.specialRepairflag,"
  8045. + " trash.logoid,";
  8046. if (scrapProduct.IsQualityStatistics == null)
  8047. {
  8048. sql += " trash.ProductionDataID,";
  8049. }
  8050. else
  8051. {
  8052. sql += " :ProductionDataID,";
  8053. }
  8054. sql += //" trash.ProductionDataID," +
  8055. " TP_PC_Procedure.ProcedureID, "
  8056. + " TP_PC_Procedure.ProcedureCode, "
  8057. + " TP_PC_Procedure.ProcedureName, "
  8058. + " :ScrapType "
  8059. + " from TP_PM_InProductionTrash trash"
  8060. + " left join TP_PC_Procedure on trash.FlowProcedureID=TP_PC_Procedure.ProcedureID"
  8061. + " where trash.barcode = :barcode";
  8062. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  8063. }
  8064. // result += oracleTrConn.ExecuteNonQuery(sql2, oracleParameters);
  8065. //// 保存失败
  8066. //if (result != Constant.INT_IS_ONE)
  8067. //{
  8068. // return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  8069. //}
  8070. return null;
  8071. }
  8072. /// <summary>
  8073. /// 保存缺陷
  8074. /// </summary>
  8075. /// <param name="oracleTrConn">连接对象</param>
  8076. /// <param name="productionDefect">缺陷数据</param>
  8077. /// <param name="sUserInfo">用户基本信息</param>
  8078. /// <returns>string</returns>
  8079. private static string AddDefect(IDBTransaction oracleTrConn, ProductionDefectEntity productionDefect, SUserInfo sUserInfo)
  8080. {
  8081. // 查询新插入的生产数据ID
  8082. string sql = "select SEQ_PM_Defect_DefectID.nextval from dual";
  8083. string idStr = oracleTrConn.GetSqlResultToStr(sql);
  8084. int productionDefectID = 0;
  8085. if (!string.IsNullOrEmpty(idStr))
  8086. {
  8087. productionDefectID = int.Parse(idStr);
  8088. }
  8089. else
  8090. {
  8091. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  8092. }
  8093. #region SQL
  8094. sql = "insert into tp_pm_defect"
  8095. + " ( ProductionDefectID,"
  8096. + " productiondataid,"
  8097. + " barcode,"
  8098. + " productionlineid,"
  8099. + " productionlinecode,"
  8100. + " productionlinename,"
  8101. + " procedureid,"
  8102. + " procedurecode,"
  8103. + " procedurename,"
  8104. + " userid,"
  8105. + " usercode,"
  8106. + " username,"
  8107. + " goodsid,"
  8108. + " goodscode,"
  8109. + " goodsname,"
  8110. + " defectid,"
  8111. + " defectcode,"
  8112. + " defectname,"
  8113. + " defectpositionid,"
  8114. + " defectpositioncode,"
  8115. + " defectpositionname,"
  8116. + " scrapResponFlag,"
  8117. + " defectproductiondataid,"
  8118. + " defectprocedureid,"
  8119. + " defectprocedurecode,"
  8120. + " defectprocedurename,"
  8121. + " defectuserid,"
  8122. + " defectusercode,"
  8123. + " defectusername,"
  8124. + " defectjobs,"
  8125. + " remarks,"
  8126. + " accountid,"
  8127. + " createuserid,"
  8128. + " defectfine,"
  8129. + " misseduserid,"
  8130. + " missedusercode,"
  8131. + " missedusername,"
  8132. + " updateuserid,SpecialDefect,DefectDeductionNum,CheckTime)"
  8133. + " values"
  8134. + " ("
  8135. + " :ProductionDefectID,"
  8136. + " :productiondataid,"
  8137. + " :barcode,"
  8138. + " :productionlineid,"
  8139. + " :productionlinecode,"
  8140. + " :productionlinename,"
  8141. + " :procedureid,"
  8142. + " :procedurecode,"
  8143. + " :procedurename,"
  8144. + " :userid,"
  8145. + " :usercode,"
  8146. + " :username,"
  8147. + " :goodsid,"
  8148. + " :goodscode,"
  8149. + " :goodsname,"
  8150. + " :defectid,"
  8151. + " :defectcode,"
  8152. + " :defectname,"
  8153. + " :defectpositionid,"
  8154. + " :defectpositioncode,"
  8155. + " :defectpositionname,"
  8156. + " :scrapResponFlag,"
  8157. + " :defectproductiondataid,"
  8158. + " :defectprocedureid,"
  8159. + " :defectprocedurecode,"
  8160. + " :defectprocedurename,"
  8161. + " :defectuserid,"
  8162. + " :defectusercode,"
  8163. + " :defectusername,"
  8164. + " :defectjobs,"
  8165. + " :remarks,"
  8166. + " :accountid,"
  8167. + " :createuserid,"
  8168. + " :defectfine,"
  8169. + " :misseduserid,"
  8170. + " :missedusercode,"
  8171. + " :missedusername,"
  8172. + " :updateuserid,:SpecialDefect,:DefectDeductionNum,:CheckTime)";
  8173. #endregion
  8174. #region 参数
  8175. OracleParameter[] oracleParameters = null;
  8176. if (productionDefect.IsPDA == null)
  8177. {
  8178. oracleParameters = new OracleParameter[] {
  8179. new OracleParameter(":ProductionDefectID",productionDefectID),
  8180. new OracleParameter(":productiondataid",productionDefect.ProductionDataID),
  8181. new OracleParameter(":barcode",productionDefect.BarCode),
  8182. new OracleParameter(":productionlineid",productionDefect.ProductionLineID),
  8183. new OracleParameter(":productionlinecode",productionDefect.ProductionLineCode),
  8184. new OracleParameter(":productionlinename",productionDefect.ProductionLineName),
  8185. new OracleParameter(":procedureid",productionDefect.ProcedureID),
  8186. new OracleParameter(":procedurecode",productionDefect.ProcedureCode),
  8187. new OracleParameter(":procedurename",productionDefect.ProcedureName),
  8188. new OracleParameter(":userid",productionDefect.UserID),
  8189. new OracleParameter(":usercode",productionDefect.UserCode),
  8190. new OracleParameter(":username",productionDefect.UserName),
  8191. new OracleParameter(":goodsid",productionDefect.GoodsID),
  8192. new OracleParameter(":goodscode",productionDefect.GoodsCode),
  8193. new OracleParameter(":goodsname",productionDefect.GoodsName),
  8194. new OracleParameter(":defectid",productionDefect.DefectID),
  8195. new OracleParameter(":defectcode",productionDefect.DefectCode),
  8196. new OracleParameter(":defectname",productionDefect.DefectName),
  8197. new OracleParameter(":defectpositionid",productionDefect.DefectPositionID),
  8198. new OracleParameter(":defectpositioncode",productionDefect.DefectPositionCode),
  8199. new OracleParameter(":defectpositionname",productionDefect.DefectPositionName),
  8200. new OracleParameter(":scrapResponFlag",productionDefect.ScrapResponFlag),
  8201. new OracleParameter(":defectproductiondataid",productionDefect.DefectProductionDataID),
  8202. new OracleParameter(":defectprocedureid",productionDefect.DefectProcedureID),
  8203. new OracleParameter(":defectprocedurecode",productionDefect.DefectProcedureCode),
  8204. new OracleParameter(":defectprocedurename",productionDefect.DefectProcedureName),
  8205. new OracleParameter(":defectuserid",productionDefect.DefectUserID),
  8206. new OracleParameter(":defectusercode",productionDefect.DefectUserCode),
  8207. new OracleParameter(":defectusername",productionDefect.DefectUserName),
  8208. new OracleParameter(":defectjobs",productionDefect.DefectJobs),
  8209. new OracleParameter(":remarks",productionDefect.Remarks),
  8210. new OracleParameter(":accountid",sUserInfo.AccountID),
  8211. new OracleParameter(":createuserid",sUserInfo.UserID),
  8212. new OracleParameter(":defectfine",productionDefect.DefectFine),
  8213. new OracleParameter(":misseduserid",productionDefect.MissedUserID),
  8214. new OracleParameter(":missedusercode",productionDefect.MissedUserCode),
  8215. new OracleParameter(":missedusername",productionDefect.MissedUserName),
  8216. new OracleParameter(":updateuserid",sUserInfo.UserID),
  8217. new OracleParameter(":SpecialDefect",productionDefect.SpecialDefect==null?"0":productionDefect.SpecialDefect),
  8218. new OracleParameter(":DefectDeductionNum",productionDefect.DefectDeductionNum==null?0:productionDefect.DefectDeductionNum),
  8219. new OracleParameter(":CheckTime",productionDefect.CheckTime.ToString()==string.Empty?null:productionDefect.CheckTime),
  8220. };
  8221. }
  8222. else
  8223. {
  8224. DateTime? pdaCheckTime = null;
  8225. if (productionDefect.PDACheckTime != null)
  8226. {
  8227. if (productionDefect.PDACheckTime.ToString() != string.Empty)
  8228. {
  8229. pdaCheckTime = Convert.ToDateTime(productionDefect.PDACheckTime);
  8230. }
  8231. }
  8232. oracleParameters = new OracleParameter[] {
  8233. new OracleParameter(":ProductionDefectID",productionDefectID),
  8234. new OracleParameter(":productiondataid",productionDefect.ProductionDataID),
  8235. new OracleParameter(":barcode",productionDefect.BarCode),
  8236. new OracleParameter(":productionlineid",productionDefect.ProductionLineID),
  8237. new OracleParameter(":productionlinecode",productionDefect.ProductionLineCode),
  8238. new OracleParameter(":productionlinename",productionDefect.ProductionLineName),
  8239. new OracleParameter(":procedureid",productionDefect.ProcedureID),
  8240. new OracleParameter(":procedurecode",productionDefect.ProcedureCode),
  8241. new OracleParameter(":procedurename",productionDefect.ProcedureName),
  8242. new OracleParameter(":userid",productionDefect.UserID),
  8243. new OracleParameter(":usercode",productionDefect.UserCode),
  8244. new OracleParameter(":username",productionDefect.UserName),
  8245. new OracleParameter(":goodsid",productionDefect.GoodsID),
  8246. new OracleParameter(":goodscode",productionDefect.GoodsCode),
  8247. new OracleParameter(":goodsname",productionDefect.GoodsName),
  8248. new OracleParameter(":defectid",productionDefect.DefectID),
  8249. new OracleParameter(":defectcode",productionDefect.DefectCode),
  8250. new OracleParameter(":defectname",productionDefect.DefectName),
  8251. new OracleParameter(":defectpositionid",productionDefect.DefectPositionID),
  8252. new OracleParameter(":defectpositioncode",productionDefect.DefectPositionCode),
  8253. new OracleParameter(":defectpositionname",productionDefect.DefectPositionName),
  8254. new OracleParameter(":scrapResponFlag",productionDefect.ScrapResponFlag),
  8255. new OracleParameter(":defectproductiondataid",productionDefect.DefectProductionDataID),
  8256. new OracleParameter(":defectprocedureid",productionDefect.DefectProcedureID),
  8257. new OracleParameter(":defectprocedurecode",productionDefect.DefectProcedureCode),
  8258. new OracleParameter(":defectprocedurename",productionDefect.DefectProcedureName),
  8259. new OracleParameter(":defectuserid",productionDefect.DefectUserID),
  8260. new OracleParameter(":defectusercode",productionDefect.DefectUserCode),
  8261. new OracleParameter(":defectusername",productionDefect.DefectUserName),
  8262. new OracleParameter(":defectjobs",productionDefect.DefectJobs),
  8263. new OracleParameter(":remarks",productionDefect.Remarks),
  8264. new OracleParameter(":accountid",sUserInfo.AccountID),
  8265. new OracleParameter(":createuserid",sUserInfo.UserID),
  8266. new OracleParameter(":defectfine",productionDefect.DefectFine),
  8267. new OracleParameter(":misseduserid",productionDefect.MissedUserID),
  8268. new OracleParameter(":missedusercode",productionDefect.MissedUserCode),
  8269. new OracleParameter(":missedusername",productionDefect.MissedUserName),
  8270. new OracleParameter(":updateuserid",sUserInfo.UserID),
  8271. new OracleParameter(":SpecialDefect",productionDefect.SpecialDefect==null?"0":productionDefect.SpecialDefect),
  8272. new OracleParameter(":DefectDeductionNum",productionDefect.DefectDeductionNum==null?0:productionDefect.DefectDeductionNum),
  8273. new OracleParameter(":CheckTime",pdaCheckTime),
  8274. };
  8275. }
  8276. #endregion
  8277. int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  8278. // 保存失败
  8279. if (result != Constant.INT_IS_ONE)
  8280. {
  8281. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  8282. }
  8283. //// 查询新插入的生产数据ID
  8284. //sql = "select SEQ_PM_Defect_DefectID.Currval from dual";
  8285. //string idStr = oracleTrConn.GetSqlResultToStr(sql);
  8286. //int productionDefectID = 0;
  8287. //if (!string.IsNullOrEmpty(idStr))
  8288. //{
  8289. // productionDefectID = int.Parse(idStr);
  8290. //}
  8291. //else
  8292. //{
  8293. // return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  8294. //}
  8295. #region 插入生产缺陷责任者
  8296. if (productionDefect.DefectResponsibles != null)
  8297. {
  8298. foreach (DefectResponsibleEntity DefectResponsible in productionDefect.DefectResponsibles)
  8299. {
  8300. #region SQL
  8301. sql = "insert into tp_pm_defectresponsible"
  8302. + " (productiondefectid,"
  8303. + " staffid,"
  8304. + " userid,"
  8305. + " usercode,"
  8306. + " Ujobsid,"
  8307. + " SJobsID,"
  8308. + " staffstatus,"
  8309. + " accountid,"
  8310. + " createuserid,"
  8311. + " updateuserid)"
  8312. + " values"
  8313. + " (:productiondefectid,"
  8314. + " :staffid,"
  8315. + " :userid,"
  8316. + " :usercode,"
  8317. + " :ujobsid,"
  8318. + " :sjobsid,"
  8319. + " :staffstatus,"
  8320. + " :accountid,"
  8321. + " :createuserid,"
  8322. + " :updateuserid)";
  8323. #endregion
  8324. #region 参数
  8325. oracleParameters = new OracleParameter[] {
  8326. new OracleParameter(":productiondefectid",productionDefectID),
  8327. new OracleParameter(":staffid",DefectResponsible.StaffID),
  8328. new OracleParameter(":userid",DefectResponsible.UserID),
  8329. new OracleParameter(":usercode",DefectResponsible.UserCode),
  8330. new OracleParameter(":ujobsid",DefectResponsible.UJobsID),
  8331. new OracleParameter(":sjobsid",DefectResponsible.SJobsID),
  8332. new OracleParameter(":staffstatus",DefectResponsible.StaffStatus),
  8333. new OracleParameter(":accountid",sUserInfo.AccountID),
  8334. new OracleParameter(":createuserid",sUserInfo.UserID),
  8335. new OracleParameter(":updateuserid",sUserInfo.UserID),
  8336. };
  8337. #endregion
  8338. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  8339. // 保存失败
  8340. if (result != Constant.INT_IS_ONE)
  8341. {
  8342. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  8343. }
  8344. }
  8345. }
  8346. #endregion
  8347. #region 插入生产漏检缺陷责任者
  8348. if (productionDefect.DefectMissedResponsibles != null)
  8349. {
  8350. foreach (DefectMissedResponsibleEntity DefectMissedResponsible in productionDefect.DefectMissedResponsibles)
  8351. {
  8352. #region SQL
  8353. sql = "insert into TP_PM_DefectMissedResponsible"
  8354. + " (productiondefectid,"
  8355. + " staffid,"
  8356. + " userid,"
  8357. + " usercode,"
  8358. + " Ujobsid,"
  8359. + " SJobsID,"
  8360. + " staffstatus,"
  8361. + " accountid,"
  8362. + " createuserid,"
  8363. + " updateuserid)"
  8364. + " values"
  8365. + " (:productiondefectid,"
  8366. + " :staffid,"
  8367. + " :userid,"
  8368. + " :usercode,"
  8369. + " :ujobsid,"
  8370. + " :sjobsid,"
  8371. + " :staffstatus,"
  8372. + " :accountid,"
  8373. + " :createuserid,"
  8374. + " :updateuserid)";
  8375. #endregion
  8376. #region 参数
  8377. oracleParameters = new OracleParameter[] {
  8378. new OracleParameter(":productiondefectid",productionDefectID),
  8379. new OracleParameter(":staffid",DefectMissedResponsible.StaffID),
  8380. new OracleParameter(":userid",DefectMissedResponsible.UserID),
  8381. new OracleParameter(":usercode",DefectMissedResponsible.UserCode),
  8382. new OracleParameter(":ujobsid",DefectMissedResponsible.UJobsID),
  8383. new OracleParameter(":sjobsid",DefectMissedResponsible.SJobsID),
  8384. new OracleParameter(":staffstatus",DefectMissedResponsible.StaffStatus),
  8385. new OracleParameter(":accountid",sUserInfo.AccountID),
  8386. new OracleParameter(":createuserid",sUserInfo.UserID),
  8387. new OracleParameter(":updateuserid",sUserInfo.UserID),
  8388. };
  8389. #endregion
  8390. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  8391. // 保存失败
  8392. if (result != Constant.INT_IS_ONE)
  8393. {
  8394. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  8395. }
  8396. }
  8397. }
  8398. #endregion
  8399. #region 添加图片
  8400. if (productionDefect.DefectImages != null)
  8401. {
  8402. DateTime upTime = DateTime.Now;
  8403. foreach (DefectImageEntity defectImage in productionDefect.DefectImages)
  8404. {
  8405. // 图片路径为空。上传图片返回路径
  8406. if (string.IsNullOrEmpty(defectImage.ImagePath))
  8407. {
  8408. defectImage.ImagePath = CommonModuleLogic.CommonModuleLogic
  8409. .UpLoadImg(Constant.SYSTEM_MODULE_PM, upTime, defectImage.Image);
  8410. defectImage.ThumbnailPath = CommonModuleLogic.CommonModuleLogic
  8411. .ConvertThumbnail(Constant.SYSTEM_MODULE_PM, upTime, defectImage.Image);
  8412. }
  8413. else
  8414. {
  8415. // 安卓端上传的图片
  8416. defectImage.ImagePath = CommonModuleLogic.CommonModuleLogic
  8417. .MoveImg(Constant.SYSTEM_MODULE_PM, upTime, defectImage.ImagePath);
  8418. defectImage.ThumbnailPath = CommonModuleLogic.CommonModuleLogic
  8419. .ConvertThumbnail(Constant.SYSTEM_MODULE_PM, upTime, defectImage.ImagePath);
  8420. }
  8421. #region 保存图片
  8422. sql = "insert into tp_pm_defectimage"
  8423. + " ("
  8424. + " productiondefectid,"
  8425. + " barcode,"
  8426. + " thumbnailpath,"
  8427. + " imagepath,"
  8428. + " accountid,"
  8429. + " createuserid,"
  8430. + " updateuserid)"
  8431. + " values"
  8432. + " ("
  8433. + " :productiondefectid,"
  8434. + " :barcode,"
  8435. + " :thumbnailpath,"
  8436. + " :imagepath,"
  8437. + " :accountid,"
  8438. + " :createuserid,"
  8439. + " :updateuserid)";
  8440. oracleParameters = new OracleParameter[] {
  8441. new OracleParameter(":productiondefectid",productionDefectID),
  8442. new OracleParameter(":barcode",productionDefect.BarCode),
  8443. new OracleParameter(":thumbnailpath",defectImage.ThumbnailPath),
  8444. new OracleParameter(":imagepath",defectImage.ImagePath),
  8445. new OracleParameter(":accountid",sUserInfo.AccountID),
  8446. new OracleParameter(":createuserid",sUserInfo.UserID),
  8447. new OracleParameter(":updateuserid",sUserInfo.UserID),
  8448. };
  8449. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  8450. // 保存失败
  8451. if (result != Constant.INT_IS_ONE)
  8452. {
  8453. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  8454. }
  8455. #endregion
  8456. }
  8457. }
  8458. #endregion
  8459. // 保存成功返回null
  8460. return null;
  8461. }
  8462. #endregion
  8463. #region 进度考核奖惩
  8464. /// <summary>
  8465. /// 根据传入的实体保存 进度考核奖惩记录
  8466. /// </summary>
  8467. /// <param name="pAdminRAPEntity">进度考核奖惩实体</param>
  8468. /// <param name="sUserInfo">用户基本信息</param>
  8469. /// <param name="pStatus">新增还是编辑枚举</param>
  8470. /// <returns>PMResultEntity操作结果状态信息</returns>
  8471. public static PMResultEntity SaveStaffProgressRAPInfo(PMProgressRAPEntity pProgressRAPEntity, SUserInfo sUserInfo, WCFConstant.FormMode pStatus)
  8472. {
  8473. PMResultEntity resultEnity = new PMResultEntity();
  8474. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  8475. try
  8476. {
  8477. if (pProgressRAPEntity == null)
  8478. {
  8479. resultEnity.OperateStatus = 0;
  8480. return resultEnity;
  8481. }
  8482. oracleTrConn.Connect();
  8483. if (pStatus == WCFConstant.FormMode.Add)
  8484. {
  8485. string strSeq = oracleTrConn.GetSqlResultToStr("Select SEQ_PM_ProgressRAP_RAPID.nextval from dual");
  8486. #region 新建时插入数据
  8487. string strSql1 = "Insert Into TP_PM_ProgressRAP (RAPID,"
  8488. + "STAFFID"
  8489. + ",RAPTYPE"
  8490. + ",REASON"
  8491. + ",RAPDATE"
  8492. + ",RAPAMOUNT"
  8493. + ",REMARKS"
  8494. + ",AUDITSTATUS"
  8495. + ",ACCOUNTID"
  8496. + ",CREATEUSERID"
  8497. + ",UPDATEUSERID)"
  8498. + " Values ("
  8499. + ":RAPID"
  8500. + ",:pSTAFFID"
  8501. + ",:pRAPTYPE"
  8502. + ",:pREASON"
  8503. + ",:pRAPDATE"
  8504. + ",:pRAPAMOUNT"
  8505. + ",:pREMARKS"
  8506. + ",:pAUDITSTATUS"
  8507. + ",:pACCOUNTID"
  8508. + ",:pCREATEUSERID"
  8509. + ",:pUPDATEUSERID"
  8510. + ")";
  8511. OracleParameter[] parmetersSql1 = new OracleParameter[]
  8512. {
  8513. new OracleParameter(":RAPID", OracleDbType.Int32, Convert.ToInt32(strSeq) , ParameterDirection.Input),
  8514. new OracleParameter(":pSTAFFID", OracleDbType.Int32, pProgressRAPEntity.StaffID , ParameterDirection.Input),
  8515. new OracleParameter(":pRAPTYPE", OracleDbType.Double, pProgressRAPEntity.RAPType , ParameterDirection.Input),
  8516. new OracleParameter(":pREASON", OracleDbType.Varchar2, pProgressRAPEntity.Reason , ParameterDirection.Input),
  8517. new OracleParameter(":pRAPDATE", OracleDbType.Date, pProgressRAPEntity.RAPDate , ParameterDirection.Input),
  8518. new OracleParameter(":pRAPAMOUNT", OracleDbType.Double, pProgressRAPEntity.RAPAmount , ParameterDirection.Input),
  8519. new OracleParameter(":pREMARKS", OracleDbType.Varchar2, pProgressRAPEntity.Remarks , ParameterDirection.Input),
  8520. new OracleParameter(":pAUDITSTATUS", OracleDbType.Int32, 0 , ParameterDirection.Input),
  8521. new OracleParameter(":pACCOUNTID", OracleDbType.Int32, sUserInfo.AccountID , ParameterDirection.Input),
  8522. new OracleParameter(":pCREATEUSERID", OracleDbType.Int32, sUserInfo.UserID , ParameterDirection.Input),
  8523. new OracleParameter(":pUPDATEUSERID", OracleDbType.Int32, sUserInfo.UserID , ParameterDirection.Input),
  8524. };
  8525. #endregion
  8526. resultEnity.OperateStatus = oracleTrConn.ExecuteNonQuery(strSql1, parmetersSql1);
  8527. //string strSeq = oracleTrConn.GetSqlResultToStr("Select SEQ_PM_ProgressRAP_RAPID.Currval from dual");
  8528. resultEnity.OperateKey = Convert.ToInt32(strSeq);
  8529. }
  8530. else
  8531. {
  8532. #region 判断数据是否可以编辑
  8533. string strSlq2 = "Select max(AuditStatus) From TP_PM_ProgressRAP Where RAPID = :pRAPID And OPTimeStamp = :pOPTimeStamp";
  8534. OracleParameter[] parmetersSql2 = new OracleParameter[]
  8535. {
  8536. new OracleParameter(":pRAPID", OracleDbType.Int32, pProgressRAPEntity.RAPID , ParameterDirection.Input),
  8537. new OracleParameter(":pOPTimeStamp", OracleDbType.TimeStamp, pProgressRAPEntity.OPTimeStamp , ParameterDirection.Input),
  8538. };
  8539. string strAuditStatus = oracleTrConn.GetSqlResultToStr(strSlq2, parmetersSql2);
  8540. if (string.IsNullOrEmpty(strAuditStatus))
  8541. {
  8542. oracleTrConn.Rollback();
  8543. oracleTrConn.Disconnect();
  8544. resultEnity.OperateStatus = -2;
  8545. return resultEnity;
  8546. }
  8547. if (!"0".Equals(strAuditStatus))
  8548. {
  8549. //不是待审批状态
  8550. oracleTrConn.Rollback();
  8551. oracleTrConn.Disconnect();
  8552. resultEnity.OperateStatus = -1;
  8553. return resultEnity;
  8554. }
  8555. #endregion
  8556. #region 编辑时更新数据
  8557. string strSql3 = "Update TP_PM_ProgressRAP Set "
  8558. + "RAPTYPE = :pRAPTYPE"
  8559. + ",REASON = :pREASON"
  8560. + ",RAPDATE = :pRAPDATE"
  8561. + ",RAPAMOUNT = :pRAPAMOUNT"
  8562. + ",REMARKS = :pREMARKS"
  8563. + ",UPDATEUSERID = :pUPDATEUSERID"
  8564. + " Where RAPID = :pRAPID And STAFFID = :pSTAFFID And AccountID = :pAccountID";
  8565. OracleParameter[] parmetersSql3 = new OracleParameter[]
  8566. {
  8567. new OracleParameter(":pRAPTYPE", OracleDbType.Double, pProgressRAPEntity.RAPType , ParameterDirection.Input),
  8568. new OracleParameter(":pREASON", OracleDbType.Varchar2, pProgressRAPEntity.Reason , ParameterDirection.Input),
  8569. new OracleParameter(":pRAPDATE", OracleDbType.Date, pProgressRAPEntity.RAPDate , ParameterDirection.Input),
  8570. new OracleParameter(":pRAPAMOUNT", OracleDbType.Double, pProgressRAPEntity.RAPAmount , ParameterDirection.Input),
  8571. new OracleParameter(":pREMARKS", OracleDbType.Varchar2, pProgressRAPEntity.Remarks , ParameterDirection.Input),
  8572. new OracleParameter(":pUPDATEUSERID", OracleDbType.Int32, sUserInfo.UserID , ParameterDirection.Input),
  8573. new OracleParameter(":pRAPID", OracleDbType.Int32, pProgressRAPEntity.RAPID , ParameterDirection.Input),
  8574. new OracleParameter(":pSTAFFID", OracleDbType.Int32, pProgressRAPEntity.StaffID , ParameterDirection.Input),
  8575. new OracleParameter(":pAccountID", OracleDbType.Int32, sUserInfo.AccountID , ParameterDirection.Input),
  8576. };
  8577. #endregion
  8578. resultEnity.OperateStatus = oracleTrConn.ExecuteNonQuery(strSql3, parmetersSql3);
  8579. resultEnity.OperateKey = pProgressRAPEntity.RAPID;
  8580. }
  8581. oracleTrConn.Commit();
  8582. oracleTrConn.Disconnect();
  8583. return resultEnity;
  8584. }
  8585. catch (Exception ex)
  8586. {
  8587. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  8588. {
  8589. oracleTrConn.Rollback();
  8590. oracleTrConn.Disconnect();
  8591. }
  8592. throw ex;
  8593. }
  8594. finally
  8595. {
  8596. if (oracleTrConn.ConnState == ConnectionState.Open)
  8597. {
  8598. oracleTrConn.Disconnect();
  8599. }
  8600. }
  8601. }
  8602. /// <summary>
  8603. /// 进度考核奖惩审批
  8604. /// </summary>
  8605. /// <param name="pAdminRAPEntity">进度考核奖惩实体</param>
  8606. /// <param name="pState">审批状态 True 通过 False 不通过</param>
  8607. /// <param name="sUserInfo">用户基本信息</param>
  8608. /// <returns>PMResultEntity操作结果状态信息</returns>
  8609. public static PMResultEntity SaveStaffProgressRAPApprovalInfo(PMProgressRAPEntity pProgressRAPEntity, bool pState, SUserInfo sUserInfo)
  8610. {
  8611. PMResultEntity resultEnity = new PMResultEntity();
  8612. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  8613. try
  8614. {
  8615. if (pProgressRAPEntity == null)
  8616. {
  8617. resultEnity.OperateStatus = 0;
  8618. return resultEnity;
  8619. }
  8620. oracleTrConn.Connect();
  8621. #region 判断数据是否可以编辑
  8622. string strSlq1 = "Select max(AuditStatus) From TP_PM_ProgressRAP Where RAPID = :pRAPID And OPTimeStamp = :pOPTimeStamp";
  8623. OracleParameter[] parmetersSql1 = new OracleParameter[]
  8624. {
  8625. new OracleParameter(":pRAPID", OracleDbType.Int32, pProgressRAPEntity.RAPID , ParameterDirection.Input),
  8626. new OracleParameter(":pOPTimeStamp", OracleDbType.TimeStamp, pProgressRAPEntity.OPTimeStamp , ParameterDirection.Input),
  8627. };
  8628. string strAuditStatus = oracleTrConn.GetSqlResultToStr(strSlq1, parmetersSql1);
  8629. if (string.IsNullOrEmpty(strAuditStatus))
  8630. {
  8631. oracleTrConn.Rollback();
  8632. oracleTrConn.Disconnect();
  8633. resultEnity.OperateStatus = -2;
  8634. return resultEnity;
  8635. }
  8636. if (!"0".Equals(strAuditStatus))
  8637. {
  8638. //不是待审批状态
  8639. oracleTrConn.Rollback();
  8640. oracleTrConn.Disconnect();
  8641. resultEnity.OperateStatus = -1;
  8642. return resultEnity;
  8643. }
  8644. #endregion
  8645. #region 更新审批数据
  8646. int intAuditStatus = 2; //2:审核未通过
  8647. if (pState)
  8648. {
  8649. intAuditStatus = 1; //1:审核通过;
  8650. }
  8651. string strSql2 = "Update TP_PM_ProgressRAP Set "
  8652. + "AUDITSTATUS = :pAUDITSTATUS"
  8653. + ",AUDITOR = :pAUDITOR"
  8654. + ",AuditlDate = sysdate"
  8655. + ",ACCOUNTDATE = FUN_CMN_GetAccountDate(:pAccountID1)"
  8656. + ",UPDATEUSERID = :pUPDATEUSERID"
  8657. + " Where RAPID = :pRAPID And AccountID = :pAccountID";
  8658. OracleParameter[] parmetersSql2 = new OracleParameter[]
  8659. {
  8660. new OracleParameter(":pAUDITSTATUS", OracleDbType.Int32,intAuditStatus, ParameterDirection.Input),
  8661. new OracleParameter(":pAUDITOR", OracleDbType.Int32, sUserInfo.UserID , ParameterDirection.Input),
  8662. new OracleParameter(":pAccountID1", OracleDbType.Int32, sUserInfo.AccountID , ParameterDirection.Input),
  8663. new OracleParameter(":pUPDATEUSERID", OracleDbType.Int32, sUserInfo.UserID , ParameterDirection.Input),
  8664. new OracleParameter(":pRAPID", OracleDbType.Int32, pProgressRAPEntity.RAPID , ParameterDirection.Input),
  8665. new OracleParameter(":pAccountID", OracleDbType.Int32, sUserInfo.AccountID , ParameterDirection.Input),
  8666. };
  8667. #endregion
  8668. resultEnity.OperateStatus = oracleTrConn.ExecuteNonQuery(strSql2, parmetersSql2);
  8669. resultEnity.OperateKey = pProgressRAPEntity.RAPID;
  8670. oracleTrConn.Commit();
  8671. oracleTrConn.Disconnect();
  8672. return resultEnity;
  8673. }
  8674. catch (Exception ex)
  8675. {
  8676. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  8677. {
  8678. oracleTrConn.Rollback();
  8679. oracleTrConn.Disconnect();
  8680. }
  8681. throw ex;
  8682. }
  8683. finally
  8684. {
  8685. if (oracleTrConn.ConnState == ConnectionState.Open)
  8686. {
  8687. oracleTrConn.Disconnect();
  8688. }
  8689. }
  8690. }
  8691. /// <summary>
  8692. /// 设置进度考核奖惩停用
  8693. /// </summary>
  8694. /// <param name="pRAPID">进度考核奖惩编号</param>
  8695. /// <param name="sUserInfo">用户基本信息</param>
  8696. /// <returns>PMResultEntity操作结果状态信息</returns>
  8697. public static PMResultEntity SetStaffProgressRAPValueFlag(int pRAPID, SUserInfo sUserInfo)
  8698. {
  8699. PMResultEntity resultEnity = new PMResultEntity();
  8700. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  8701. try
  8702. {
  8703. oracleTrConn.Connect();
  8704. string sql = "Select max(SettlementFlag) From TP_PM_ProgressRAP Where RAPID =" + pRAPID + " And AuditStatus = 0 And ValueFlag = 1";
  8705. string strSettlementFlag = oracleTrConn.GetSqlResultToStr(sql);
  8706. if (!string.IsNullOrEmpty(strSettlementFlag))
  8707. {
  8708. if ("1".Equals(strSettlementFlag)) //工资结算标识 1:已经结算 0:未结算
  8709. {
  8710. oracleTrConn.Rollback();
  8711. oracleTrConn.Disconnect();
  8712. resultEnity.OperateStatus = -3;
  8713. return resultEnity;
  8714. }
  8715. string sqlString = "Update TP_PM_ProgressRAP Set ValueFlag = 0,UpdateUserID = :pUpdateUserID"
  8716. + " Where RAPID = :pRAPID And AccountID = :pAccountID";
  8717. OracleParameter[] parmetersSql = new OracleParameter[]
  8718. {
  8719. new OracleParameter(":pUpdateUserID", OracleDbType.Int32,sUserInfo.UserID, ParameterDirection.Input),
  8720. new OracleParameter(":pRAPID", OracleDbType.Int32, pRAPID , ParameterDirection.Input),
  8721. new OracleParameter(":pAccountID", OracleDbType.Int32, sUserInfo.AccountID , ParameterDirection.Input),
  8722. };
  8723. resultEnity.OperateStatus = oracleTrConn.ExecuteNonQuery(sqlString, parmetersSql);
  8724. oracleTrConn.Commit();
  8725. oracleTrConn.Disconnect();
  8726. return resultEnity;
  8727. }
  8728. else
  8729. {
  8730. oracleTrConn.Rollback();
  8731. oracleTrConn.Disconnect();
  8732. resultEnity.OperateStatus = -2;
  8733. return resultEnity;
  8734. }
  8735. }
  8736. catch (Exception ex)
  8737. {
  8738. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  8739. {
  8740. oracleTrConn.Rollback();
  8741. oracleTrConn.Disconnect();
  8742. }
  8743. throw ex;
  8744. }
  8745. finally
  8746. {
  8747. if (oracleTrConn.ConnState == ConnectionState.Open)
  8748. {
  8749. oracleTrConn.Disconnect();
  8750. }
  8751. }
  8752. }
  8753. #endregion
  8754. #endregion
  8755. #region 私有方法
  8756. /// <summary>
  8757. /// 将窑车号下的条码转换成Table
  8758. /// </summary>
  8759. /// <param name="oracleTrConn">数据连接</param>
  8760. /// <param name="productionTable">手机传入的Table</param>
  8761. /// <param name="sUserInfo">用户基本信息</param>
  8762. /// <returns>DataTable</returns>
  8763. private static DataTable CarNoInfoConvertToTable(IDBTransaction oracleTrConn, DataTable productionTable, SUserInfo sUserInfo)
  8764. {
  8765. if (productionTable != null
  8766. && productionTable.Rows.Count > Constant.INT_IS_ZERO)
  8767. {
  8768. DataRow row = productionTable.Rows[Constant.INT_IS_ZERO];
  8769. string sql = "select carGoods.Barcode,"
  8770. + " carGoods.KilnCarID,"
  8771. + " car.KilncarCode,"
  8772. + " car.KilncarName,"
  8773. + " kiln.kilnid,"
  8774. + " kiln.kilnCode,"
  8775. + " kiln.kilnName,"
  8776. + " carGoods.Kilncarposition,"
  8777. + " carGoods.KilnCarBatchNo,"
  8778. + " carGoods.GoodsID,"
  8779. + " goods.GoodsCode,"
  8780. + " goods.GoodsName,"
  8781. + " :userID as UserID,"
  8782. + " :userCode as UserCode,"
  8783. + " :userName as UserName,"
  8784. + " :Remarks as Remarks"
  8785. + " from TP_PM_KilnCarGoods carGoods"
  8786. + " inner join TP_MST_KilnCar car on car.KilnCarID = carGoods.KilnCarID"
  8787. + " inner join TP_MST_Kiln kiln on kiln.KilnID = car.KilnID"
  8788. + " inner join TP_MST_Goods goods on goods.goodsid = carGoods.GoodsID"
  8789. + " where car.kilncarcode = :kilncarcode and carGoods.AccountID = :accountID";
  8790. OracleParameter[] oracleParameters = new OracleParameter[] {
  8791. new OracleParameter(":userID",row["UserID"].ToString()),
  8792. new OracleParameter(":userCode",row["UserCode"].ToString()),
  8793. new OracleParameter(":userName",row["UserName"].ToString()),
  8794. new OracleParameter(":kilncarcode",row["KilnCarCode"].ToString()),
  8795. new OracleParameter(":accountID",sUserInfo.AccountID),
  8796. new OracleParameter(":Remarks",row["Remarks"].ToString()),
  8797. };
  8798. DataSet ds = oracleTrConn.GetSqlResultToDs(sql, oracleParameters);
  8799. if (ds != null
  8800. && ds.Tables.Count > Constant.INT_IS_ZERO
  8801. && ds.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  8802. {
  8803. return ds.Tables[0];
  8804. }
  8805. return productionTable;
  8806. }
  8807. return productionTable;
  8808. }
  8809. #endregion
  8810. #region PDA端保存条码
  8811. /// <summary>
  8812. /// 添加成品编辑
  8813. /// </summary>
  8814. /// <param name="oracleTrConn">数据连接</param>
  8815. /// <param name="procedure">工序对象</param>
  8816. /// <param name="productionDataEntitys">生产数据集</param>
  8817. /// <param name="sUserInfo">用户基本信息</param>
  8818. /// <returns>string</returns>
  8819. private static string AddFinishCheckPDA(IDBTransaction oracleTrConn, ProcedureEntity procedure, ProductionDataEntity[] productionDataEntitys, SUserInfo sUserInfo)
  8820. {
  8821. string errMsg = "";
  8822. // 获得账务日期
  8823. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  8824. // 本批采集的批次号
  8825. string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  8826. string finishedloadbatchno = DateTime.Now.ToString("yyMMddHHmmss-") + centralizedBatchNo;
  8827. foreach (ProductionDataEntity productionData in productionDataEntitys)
  8828. {
  8829. bool RejectToReject = false;
  8830. if (string.IsNullOrEmpty(productionData.Barcode))
  8831. {
  8832. throw new Exception("传入的条码号为空");
  8833. }
  8834. int goodsID = Constant.INT_IS_ZERO;
  8835. string goodsCode = string.Empty;
  8836. string goodsName = string.Empty;
  8837. // 注浆者工号
  8838. string groutingUserCode = string.Empty;
  8839. // 次品标识
  8840. bool substandardFlag = false;
  8841. #region 校验条码有效性
  8842. errMsg = CheckBarcode(oracleTrConn, procedure.ProcedureID, productionData.Barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo);
  8843. if (!string.IsNullOrEmpty(errMsg))
  8844. {
  8845. // 编辑重烧时,会提示不可到达;编辑次品时,会提示已经报废
  8846. //if (productionData.ProductionDataID == 0)
  8847. //if (!errMsg.Contains("次品"))
  8848. return errMsg;
  8849. }
  8850. #endregion
  8851. int isInProduction = 1;
  8852. #region 修改条码
  8853. if (productionData.ProductionDataID > 0) //表示编辑条码
  8854. {
  8855. #region 验证改判有效期
  8856. // 前台已有相关验证,但还是产生了超期改判,后台保存前增加验证。
  8857. string sqlString = "select pdin.createtime from tp_pm_productiondatain pdin where pdin.productiondataid = " + productionData.ProductionDataID;
  8858. DateTime createtime = Convert.ToDateTime(oracleTrConn.GetSqlResultToObj(sqlString)).Date;
  8859. // 参数验证用服务端当前设置
  8860. sqlString = "SELECT sst.settingvalue\n" +
  8861. " FROM tp_mst_systemsetting sst\n" +
  8862. " WHERE sst.accountid = " + sUserInfo.AccountID + "\n" +
  8863. " AND sst.settingcode = 'S_PM_009'";
  8864. string strValue = oracleTrConn.GetSqlResultToStr(sqlString);
  8865. int days = 0;
  8866. int pDays = 0;
  8867. if (int.TryParse(strValue, out pDays))
  8868. {
  8869. days = pDays;
  8870. }
  8871. if (days != 0 && createtime <= DateTime.Now.Date.AddDays(-days))
  8872. {
  8873. return string.Format(Messages.MSG_S_PM_009, createtime.ToString("yyyy-MM-dd"), days.ToString(), createtime.AddDays(days - 1).ToString("yyyy-MM-dd"));
  8874. }
  8875. #endregion
  8876. //
  8877. string sqlOPTimeStamp = "";
  8878. OracleParameter[] parmetersSql = null;
  8879. #region 验证在产时间戳
  8880. if (productionData.OPTimeStampPDA == null) // 表示PC端,因为只有安卓端才给此数据字段给值
  8881. {
  8882. sqlOPTimeStamp = @"select
  8883. 1
  8884. from TP_PM_InProduction
  8885. where
  8886. TP_PM_InProduction.BarCode=:BarCode and TP_PM_InProduction.OPTimeStamp = :OPTimeStamp
  8887. union
  8888. select
  8889. 0
  8890. from Tp_Pm_Inproductiontrash
  8891. where
  8892. Tp_Pm_Inproductiontrash.BarCode=:BarCode and Tp_Pm_Inproductiontrash.OPTimeStamp = :OPTimeStamp ";
  8893. parmetersSql = new OracleParameter[]
  8894. {
  8895. new OracleParameter(":OPTimeStamp", OracleDbType.TimeStamp, productionData.OPTimeStamp, ParameterDirection.Input),
  8896. new OracleParameter(":BarCode", OracleDbType.NVarchar2, productionData.Barcode, ParameterDirection.Input),
  8897. };
  8898. }
  8899. else
  8900. {
  8901. sqlOPTimeStamp = @"select
  8902. 1
  8903. from TP_PM_InProduction
  8904. where
  8905. TP_PM_InProduction.BarCode=:BarCode and TP_PM_InProduction.OPTimeStamp =TO_TIMESTAMP(to_char(:OPTimeStamp),'DD-MM-YYHH12.MI.SS.FFAM')
  8906. union
  8907. select
  8908. 0
  8909. from Tp_Pm_Inproductiontrash
  8910. where
  8911. Tp_Pm_Inproductiontrash.BarCode=:BarCode and Tp_Pm_Inproductiontrash.OPTimeStamp =TO_TIMESTAMP(to_char(:OPTimeStamp),'DD-MM-YYHH12.MI.SS.FFAM')";
  8912. parmetersSql = new OracleParameter[]
  8913. {
  8914. new OracleParameter(":OPTimeStamp", OracleDbType.NVarchar2, productionData.OPTimeStampPDA, ParameterDirection.Input),
  8915. new OracleParameter(":BarCode", OracleDbType.NVarchar2, productionData.Barcode, ParameterDirection.Input),
  8916. };
  8917. }
  8918. DataSet returnDataset = oracleTrConn.GetSqlResultToDs(sqlOPTimeStamp, parmetersSql);
  8919. if (returnDataset != null
  8920. && returnDataset.Tables[0].Rows.Count == 0)
  8921. {
  8922. return "数据已经被修改,请重新进行编辑";
  8923. }
  8924. isInProduction = Convert.ToInt32(returnDataset.Tables[0].Rows[0][0]);
  8925. #endregion
  8926. //如果原来是 次品 / 废品 xuwei modify 2019-12-13 加入 废品识别
  8927. if (productionData.OrgGoodsLevelTypeID == Constant.GoodsLevelType.Reject.GetHashCode()
  8928. ||
  8929. productionData.OrgGoodsLevelTypeID == Constant.GoodsLevelType.Waste.GetHashCode()
  8930. )
  8931. {
  8932. //改为 次品 废品 xuwei modify 2019-12-13 加入废品识别
  8933. if (productionData.GoodsLevelTypeID == Constant.GoodsLevelType.Reject.GetHashCode()
  8934. ||
  8935. productionData.GoodsLevelTypeID == Constant.GoodsLevelType.Waste.GetHashCode()
  8936. )
  8937. {
  8938. // 删除生产数据及相关表与报损表
  8939. errMsg = DeleteSubstandardToSubstandardByID(oracleTrConn, productionData.ProductionDataID, productionData.Barcode, sUserInfo);
  8940. if (!string.IsNullOrEmpty(errMsg))
  8941. {
  8942. return errMsg;
  8943. }
  8944. RejectToReject = true;
  8945. } //改为不是 次品 废品 xuwei modify 2019-12-13 加入废品识别
  8946. else if (productionData.GoodsLevelTypeID != Constant.GoodsLevelType.Reject.GetHashCode()
  8947. ||
  8948. productionData.GoodsLevelTypeID != Constant.GoodsLevelType.Waste.GetHashCode()
  8949. )
  8950. {
  8951. // 删除生产数据及相关表与报损表
  8952. errMsg = DeleteSubstandardToOtherByID(oracleTrConn, productionData.ProductionDataID, productionData.Barcode, sUserInfo);
  8953. if (!string.IsNullOrEmpty(errMsg))
  8954. {
  8955. return errMsg;
  8956. }
  8957. }
  8958. }
  8959. else
  8960. {
  8961. // 原来产品分级不是次品
  8962. errMsg = DeleteNormalToOtherByID(oracleTrConn, productionData.ProductionDataID, productionData.Barcode, sUserInfo);
  8963. if (!string.IsNullOrEmpty(errMsg))
  8964. {
  8965. return errMsg;
  8966. }
  8967. }
  8968. }
  8969. else // wangx 2016-12-13 防止同时两个人新建数据,加判断条件
  8970. {
  8971. string sqlCurrrentProcedure = @"select Flowprocedureid from tp_pm_inproduction where BarCode=:BarCode";
  8972. OracleParameter[] parmetersSql = null;
  8973. parmetersSql = new OracleParameter[]
  8974. {
  8975. new OracleParameter(":BarCode", OracleDbType.NVarchar2, productionData.Barcode, ParameterDirection.Input),
  8976. };
  8977. DataSet returnDataset = oracleTrConn.GetSqlResultToDs(sqlCurrrentProcedure, parmetersSql);
  8978. // 判定次品时,在产表中已经没有条码数据 modify by chenxy 2017-07-03 begin
  8979. //if (returnDataset != null
  8980. // && returnDataset.Tables[0].Rows.Count > 0)
  8981. //{
  8982. // if (Convert.ToInt32(returnDataset.Tables[0].Rows[0]["Flowprocedureid"]) == procedure.ProcedureID)
  8983. // {
  8984. // return "【此条码生产数据已被修改,请重开画面后再扫描】";
  8985. // }
  8986. //}
  8987. if (returnDataset == null ||
  8988. returnDataset.Tables.Count == 0 ||
  8989. returnDataset.Tables[0].Rows.Count == 0 ||
  8990. Convert.ToInt32(returnDataset.Tables[0].Rows[0]["Flowprocedureid"]) == procedure.ProcedureID
  8991. )
  8992. {
  8993. return "【此条码生产数据已被修改,请重新扫描此条码】";
  8994. }
  8995. // 判定次品时,在产表中已经没有条码数据 modify by chenxy 2017-07-03 end
  8996. }
  8997. #endregion
  8998. // 查询新插入的生产数据ID
  8999. string sql = "select SEQ_PM_ProductionData_ID.nextval from dual";
  9000. string idStr = oracleTrConn.GetSqlResultToStr(sql);
  9001. int productionDataID = 0;
  9002. if (!string.IsNullOrEmpty(idStr))
  9003. {
  9004. productionDataID = int.Parse(idStr);
  9005. }
  9006. else
  9007. {
  9008. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  9009. }
  9010. int? ClassesSettingID = null;//班次配置ID
  9011. #region 添加生产者数据
  9012. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, productionData.UserID, productionData.UserName, sUserInfo, ref ClassesSettingID);
  9013. if (!string.IsNullOrEmpty(errMsg))
  9014. {
  9015. return errMsg;
  9016. }
  9017. #endregion
  9018. #region 添加生产数据
  9019. #region 属性赋值
  9020. productionData.ClassesSettingID = ClassesSettingID;
  9021. productionData.ProductionDataID = Convert.ToInt32(idStr);
  9022. productionData.CentralizedBatchNo = centralizedBatchNo;
  9023. productionData.ProductionLineID = procedure.ProductionLineID;
  9024. productionData.ProductionLineCode = procedure.ProductionlineCode;
  9025. productionData.ProductionLineName = procedure.ProductionlineName;
  9026. productionData.CompleteProcedureID = procedure.ProcedureID;
  9027. productionData.ProcedureCode = procedure.ProcedureCode;
  9028. productionData.ProcedureName = procedure.ProcedureName;
  9029. productionData.ProcedureModel = procedure.ProcedureModel;
  9030. productionData.ModelType = procedure.ModelType;
  9031. productionData.NodeType = procedure.NodeType;
  9032. productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, productionData.Barcode);
  9033. // 重烧
  9034. if (productionData.GoodsLevelTypeID == (int)Constant.GoodsLevelType.ReFire)
  9035. {
  9036. //productionData.GoodsLevelID = null;
  9037. //productionData.IsReFire = (int)Constant.GoodsLevelType.ReFire;
  9038. productionData.IsReFire = (int)Constant.ReFireFlag.No;//产品分级的时候,并不标记,走过重烧第一个结点之后,更新此字段
  9039. }
  9040. // 次品 废品 xuwei 2019-12-13 加入 废品识别
  9041. else if (productionData.GoodsLevelTypeID == (int)Constant.GoodsLevelType.Reject
  9042. ||
  9043. productionData.GoodsLevelTypeID == (int)Constant.GoodsLevelType.Waste
  9044. )
  9045. {
  9046. //productionData.GoodsLevelID = null;
  9047. substandardFlag = true;
  9048. }
  9049. // 查询新插入的生产数据ID
  9050. //if (productionData.GoodsLevelTypeID != (int)Constant.GoodsLevelType.ReFire)
  9051. // {
  9052. //不加条件valueflag,是因为,成检后重烧走过之后,在次重烧,以后也是重烧状态
  9053. //string sqlReFire = "select * from tp_PM_ProductionData where ProductionData=(select max(ProductionDataid) from ProductionData where barcode=" + productionData.Barcode + " and ProcedureID=" + productionData.ProcedureID + ")";
  9054. //if (productionData.GoodsLevelTypeID != (int)Constant.GoodsLevelType.ReFire)
  9055. // {
  9056. ////// string sqlReFire = @"select
  9057. ////// isrefire
  9058. ////// from tp_pm_inproduction where barcode=:barcode
  9059. ////// union
  9060. ////// select
  9061. ////// isrefire
  9062. ////// from TP_PM_InProductionTrash where barcode=:barcode
  9063. ////// ";
  9064. ////// OracleParameter[] ReFireparas = new OracleParameter[] {
  9065. ////// new OracleParameter(":barcode", productionData.Barcode),
  9066. ////// };
  9067. ////// DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas);
  9068. ////// if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0)
  9069. ////// {
  9070. ////// productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]);
  9071. ////// }
  9072. // }
  9073. productionData.OrganizationID = procedure.OrganizationID;
  9074. productionData.GoodsID = goodsID;
  9075. productionData.GoodsCode = goodsCode;
  9076. productionData.GoodsName = goodsName;
  9077. productionData.GoodsLevelID = productionData.GoodsLevelID;
  9078. productionData.GoodsLevelTypeID = productionData.GoodsLevelTypeID;
  9079. //if (productionData.GoodsLevelTypeID == (int)Constant.GoodsLevelType.Reject)
  9080. //{
  9081. // productionData.GoodsEnding = Constant.GoodsLevelType.Reject.GetHashCode().ToString();
  9082. //}
  9083. //else
  9084. //{
  9085. // productionData.GoodsEnding = null;
  9086. //}
  9087. #endregion
  9088. string OutSpecialRepairflag = "0";//干补标识
  9089. //errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag);
  9090. errMsg = AddFinishCheckProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag);
  9091. if (!string.IsNullOrEmpty(errMsg))
  9092. {
  9093. return errMsg;
  9094. }
  9095. #endregion
  9096. //#region 添加生产者数据
  9097. //errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, productionData.UserID, productionData.UserName, sUserInfo);
  9098. //if (!string.IsNullOrEmpty(errMsg))
  9099. //{
  9100. // return errMsg;
  9101. //}
  9102. //#endregion
  9103. #region 条码有缺陷
  9104. #region 是次品 添加废弃产品
  9105. string ResponProcedureidStr = "";
  9106. if (substandardFlag)
  9107. {
  9108. #region 修改在产产品数据的当前工序,防止直接报损在产工序没有改过来,记录的是上一个工序
  9109. string updateInInProductionForScrap = @"Update tp_pm_inproduction
  9110. set FlowProcedureID=:flowProcedureID,ProcedureID=:flowProcedureID where barcode=:barcode";
  9111. List<OracleParameter> paras = new List<OracleParameter>();
  9112. paras.Add(new OracleParameter(":barcode", productionData.Barcode));
  9113. paras.Add(new OracleParameter(":flowProcedureID", procedure.ProcedureID));
  9114. oracleTrConn.ExecuteNonQuery(updateInInProductionForScrap, paras.ToArray());
  9115. #endregion
  9116. #region 添加废弃产品
  9117. ScrapProductEntity scrapProduct = new ScrapProductEntity();
  9118. #region 属性赋值
  9119. scrapProduct.BarCode = productionData.Barcode;
  9120. scrapProduct.ScrapType = Constant.ScrapType.Substandard.GetHashCode();
  9121. scrapProduct.ResponType = Constant.ScrapResponType.Procedure.GetHashCode();
  9122. scrapProduct.ScrapDate = accountDate;
  9123. scrapProduct.Rreason = Constant.SCRAPTYPE_SUBSTANDARD;
  9124. scrapProduct.AuditStatus = Constant.AuditStatus.Agree.GetHashCode();
  9125. scrapProduct.Auditor = sUserInfo.UserID;
  9126. scrapProduct.AuditlDate = accountDate;
  9127. scrapProduct.AccountDate = accountDate;
  9128. scrapProduct.GoodsLevelID = productionData.GoodsLevelID;
  9129. scrapProduct.GoodsLevelTypeID = productionData.GoodsLevelTypeID;
  9130. scrapProduct.IsPublicBody = productionData.IsPublicBody;
  9131. // 查询新插入的废弃ID
  9132. string ResponProceduresql = "select SEQ_PM_ScrapProduct_ID.nextval from dual";
  9133. ResponProcedureidStr = oracleTrConn.GetSqlResultToStr(ResponProceduresql);
  9134. scrapProduct.ScrapProductID = Convert.ToInt32(ResponProcedureidStr);
  9135. scrapProduct.ScrapType = 1;
  9136. scrapProduct.IsQualityStatistics = 1;//新加的,因为这个报损方法是共通的,用于区别是哪里传进去的
  9137. scrapProduct.ProductionDataID = productionData.ProductionDataID;
  9138. #endregion
  9139. if (!RejectToReject) //不是次品到次品 wangxin 20150417
  9140. {
  9141. // 保存报废
  9142. errMsg = AddScrapProduct(oracleTrConn, scrapProduct, sUserInfo);
  9143. }
  9144. else
  9145. {
  9146. if (isInProduction == 1)
  9147. {
  9148. errMsg = AddScrapProduct(oracleTrConn, scrapProduct, sUserInfo);
  9149. }
  9150. else
  9151. {
  9152. // 保存报废
  9153. errMsg = AddScrapProductRejectToReject(oracleTrConn, scrapProduct, sUserInfo);
  9154. }
  9155. }
  9156. //不是次品到次品 wangxin 20150417
  9157. // 保存失败
  9158. if (!string.IsNullOrEmpty(errMsg))
  9159. {
  9160. return errMsg;
  9161. }
  9162. #endregion
  9163. }
  9164. #endregion
  9165. // 存在缺陷 插入缺陷表
  9166. if (productionData.ProductionDefects != null)
  9167. {
  9168. foreach (ProductionDefectEntity productionDefect in productionData.ProductionDefects)
  9169. {
  9170. #region 保存缺陷
  9171. productionDefect.ProductionDataID = productionDataID;
  9172. productionDefect.BarCode = productionData.Barcode;
  9173. productionDefect.ProductionLineID = procedure.ProductionLineID;
  9174. productionDefect.ProductionLineCode = procedure.ProductionlineCode;
  9175. productionDefect.ProductionLineName = procedure.ProductionlineName;
  9176. productionDefect.ProcedureID = procedure.ProcedureID;
  9177. productionDefect.ProcedureCode = procedure.ProcedureCode;
  9178. productionDefect.ProcedureName = procedure.ProcedureName;
  9179. productionDefect.UserID = productionData.UserID;
  9180. productionDefect.UserCode = productionData.UserCode;
  9181. productionDefect.UserName = productionData.UserName;
  9182. productionDefect.GoodsID = productionData.GoodsID;
  9183. productionDefect.GoodsCode = productionData.GoodsCode;
  9184. productionDefect.GoodsName = productionData.GoodsName;
  9185. productionData.Remarks = productionData.Remarks;
  9186. productionDefect.ScrapResponFlag
  9187. = string.IsNullOrEmpty(productionDefect.ScrapResponFlag) ? "0" : productionDefect.ScrapResponFlag;
  9188. // 保存缺陷
  9189. errMsg = AddDefect(oracleTrConn, productionDefect, sUserInfo);
  9190. if (!string.IsNullOrEmpty(errMsg))
  9191. {
  9192. return errMsg;
  9193. }
  9194. #endregion
  9195. #region 是次品 添加废弃责任工序
  9196. if (substandardFlag)
  9197. {
  9198. //if (productionDefect.DefectProcedureID != null)
  9199. {
  9200. #region 添加责任工序
  9201. ResponProcedureEntity responProce = new ResponProcedureEntity();
  9202. //// 查询新插入的废弃ID
  9203. //string ResponProceduresql = "select SEQ_PM_ScrapProduct_ID.Currval from dual";
  9204. //string ResponProcedureidStr = oracleTrConn.GetSqlResultToStr(ResponProceduresql);
  9205. #region 属性赋值
  9206. responProce.BarCode = productionData.Barcode;
  9207. responProce.ProductionDataID = productionDataID;
  9208. responProce.ProductionLineID = productionDefect.ProductionLineID;
  9209. responProce.ProductionLineCode = productionDefect.ProductionLineCode;
  9210. responProce.ProductionLineName = productionDefect.ProductionLineName;
  9211. responProce.ProcedureID = productionDefect.DefectProcedureID;
  9212. responProce.ProcedureCode = productionDefect.DefectProcedureCode;
  9213. responProce.ProcedureName = productionDefect.DefectProcedureName;
  9214. responProce.UserID = productionDefect.DefectUserID;
  9215. responProce.UserCode = productionDefect.DefectUserCode;
  9216. responProce.UserName = productionDefect.DefectUserName;
  9217. responProce.Remarks = productionDefect.Remarks;
  9218. responProce.ScrapProductID = Convert.ToInt32(ResponProcedureidStr);
  9219. #endregion
  9220. // 保存责任工序
  9221. errMsg = AddResponProcedure(oracleTrConn, responProce, productionDefect, sUserInfo);
  9222. // 保存失败
  9223. if (!string.IsNullOrEmpty(errMsg))
  9224. {
  9225. return errMsg;
  9226. }
  9227. #endregion
  9228. }
  9229. }
  9230. #endregion
  9231. }
  9232. }
  9233. #endregion
  9234. #region 条码是次品 删除在产产品数据
  9235. if (substandardFlag)
  9236. {
  9237. #region 删除在产产品数据
  9238. InProductionEntity delInProductionEntity = new InProductionEntity();
  9239. delInProductionEntity.BarCode = productionData.Barcode;
  9240. delInProductionEntity.CompleteProcedureID = procedure.ProcedureID;
  9241. delInProductionEntity.ProductionDataID = productionDataID;
  9242. delInProductionEntity.GoodsLevelID = productionData.GoodsLevelID;
  9243. delInProductionEntity.GoodsLevelTypeID = productionData.GoodsLevelTypeID;
  9244. // 执行删除 在产数据
  9245. errMsg = DeletePDAInProduction(oracleTrConn, delInProductionEntity, false, sUserInfo);
  9246. // 执行失败
  9247. if (!string.IsNullOrEmpty(errMsg))
  9248. {
  9249. return errMsg;
  9250. }
  9251. #endregion
  9252. }
  9253. #endregion
  9254. #region 条码不是次品
  9255. if (!substandardFlag)
  9256. {
  9257. #region 中间工序/重烧 修改在产产品数据
  9258. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Middle
  9259. || productionData.IsReFire == Constant.GoodsGrade.ReFire.GetHashCode())
  9260. {
  9261. #region 修改在产产品数据的当前工序
  9262. InProductionEntity inProductionEntity = new InProductionEntity();
  9263. inProductionEntity.BarCode = productionData.Barcode;
  9264. //流程工序
  9265. inProductionEntity.FlowProcedureID = procedure.ProcedureID;
  9266. // 当前工序
  9267. //inProductionEntity.CompleteProcedureID = procedure.ProcedureID;
  9268. inProductionEntity.ProcedureID = procedure.ProcedureID;
  9269. //生产数据ID
  9270. inProductionEntity.ProductionDataID = productionDataID;
  9271. // 工序模型
  9272. inProductionEntity.ProcedureModel = procedure.ProcedureModel;
  9273. // 工序类别
  9274. inProductionEntity.ModelType = procedure.ModelType;
  9275. // 生产工号
  9276. inProductionEntity.UserID = productionData.UserID;
  9277. // 重烧
  9278. inProductionEntity.IsReFire = productionData.IsReFire;
  9279. // 缺陷
  9280. inProductionEntity.DefectFlag = productionData.DefectFlag;
  9281. // 产品分级
  9282. inProductionEntity.GoodsGrade = productionData.GoodsGrade;
  9283. // 返工工序ID
  9284. inProductionEntity.ReworkProcedureID = productionData.ReworkProcedureID;
  9285. inProductionEntity.GoodsLevelID = productionData.GoodsLevelID;
  9286. inProductionEntity.GoodsLevelTypeID = productionData.GoodsLevelTypeID;
  9287. inProductionEntity.IsPublicBody = productionData.IsPublicBody;
  9288. // 执行修改
  9289. errMsg = UpdateInProduction(oracleTrConn, inProductionEntity, sUserInfo);
  9290. // 执行失败
  9291. if (!string.IsNullOrEmpty(errMsg))
  9292. {
  9293. return errMsg;
  9294. }
  9295. #endregion
  9296. }
  9297. #endregion
  9298. #region 结束工序 添加成品数据 删除在产产品数据
  9299. else if (procedure.NodeType == (int)Constant.ProcedureNodeType.End)
  9300. {
  9301. #region 添加成品数据 删除在产产品数据
  9302. FinishedProductEntity finishedProduct = new FinishedProductEntity();
  9303. finishedProduct.BarCode = productionData.Barcode;
  9304. errMsg = AddFinishedProduct(oracleTrConn, finishedProduct, sUserInfo, finishedloadbatchno);
  9305. if (!string.IsNullOrEmpty(errMsg))
  9306. {
  9307. return errMsg;
  9308. }
  9309. InProductionEntity delInProductionEntity = new InProductionEntity();
  9310. delInProductionEntity.BarCode = productionData.Barcode;
  9311. // 执行删除 在产数据
  9312. errMsg = DeleteInProduction(oracleTrConn, delInProductionEntity, true, sUserInfo);
  9313. // 执行失败
  9314. if (!string.IsNullOrEmpty(errMsg))
  9315. {
  9316. return errMsg;
  9317. }
  9318. #endregion
  9319. }
  9320. #endregion
  9321. }
  9322. #endregion
  9323. #region 写入检验标识 CheckFlag 用于计件 xuwei 2020-04-21
  9324. oracleTrConn.ExecuteNonQuery(@"
  9325. UPDATE
  9326. TP_PM_PRODUCTIONDATA SET CHECKFLAG = :CHECKFLAG
  9327. WHERE
  9328. PRODUCTIONDATAID = :PRODUCTIONDATAID
  9329. ",
  9330. new OracleParameter[] {
  9331. new OracleParameter(":CHECKFLAG",productionData.CheckFlag),
  9332. new OracleParameter(":PRODUCTIONDATAID",productionDataID)
  9333. }
  9334. );
  9335. #endregion
  9336. }
  9337. return errMsg;
  9338. }
  9339. /// <summary>
  9340. /// 编辑后删除生产数据
  9341. /// </summary>
  9342. /// <param name="productionDataID">生产数据ID</param>
  9343. /// <returns>int</returns>
  9344. public static string DeleteSubstandardToSubstandardByID(IDBTransaction oracleTrConn, int productionDataID, string barcode, SUserInfo sUserInfo)
  9345. {
  9346. int deleteRow = 0;
  9347. try
  9348. {
  9349. string sqlString5 = @"update TP_PM_DefectMissedResponsible set ValueFlag=0, UpdateUserID=:UpdateUserID
  9350. where TP_PM_DefectMissedResponsible.Productiondefectid in
  9351. (
  9352. select ProductionDefectID from TP_PM_Defect where TP_PM_Defect.Productiondataid=:ProductionDataID
  9353. )";
  9354. string sqlString4 = @"update TP_PM_ProductionDataIn set ValueFlag=0, UpdateUserID=:UpdateUserID
  9355. where
  9356. TP_PM_ProductionDataIn.Productiondataid=:ProductionDataID
  9357. ";
  9358. string sqlString3 = @"update TP_PM_Defect set ValueFlag=0, UpdateUserID=:UpdateUserID
  9359. where TP_PM_Defect.Productiondataid =:ProductionDataID";
  9360. string sqlString2 = @"update TP_PM_DefectResponsible set ValueFlag=0, UpdateUserID=:UpdateUserID
  9361. where TP_PM_DefectResponsible.Productiondefectid in
  9362. (
  9363. select ProductionDefectID from TP_PM_Defect where TP_PM_Defect.Productiondataid=:ProductionDataID
  9364. )";
  9365. string sqlString = @"update TP_PM_DefectImage set ValueFlag=0, UpdateUserID=:UpdateUserID
  9366. where TP_PM_DefectImage.Productiondefectid in
  9367. (
  9368. select ProductionDefectID from TP_PM_Defect where TP_PM_Defect.Productiondataid=:ProductionDataID
  9369. )";
  9370. // string sqlScrapProduct = @"update TP_PM_ScrapProduct set ValueFlag=0 where barcode=:barcode";
  9371. string sqlScrapProduct = @"update TP_PM_ScrapProduct set ValueFlag=0, UpdateUserID=:UpdateUserID where ScrapProductID=(
  9372. select max(ScrapProductID) from TP_PM_ScrapProduct where barcode=:barcode)";
  9373. OracleParameter[] paras = new OracleParameter[]{
  9374. new OracleParameter(":ProductionDataID",OracleDbType.Int32, productionDataID,ParameterDirection.Input),
  9375. new OracleParameter(":UpdateUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input),
  9376. };
  9377. OracleParameter[] ScrapProductparas = new OracleParameter[]{
  9378. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  9379. new OracleParameter(":UpdateUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input),
  9380. };
  9381. deleteRow += oracleTrConn.ExecuteNonQuery(sqlString, paras);
  9382. deleteRow += oracleTrConn.ExecuteNonQuery(sqlString2, paras);
  9383. deleteRow += oracleTrConn.ExecuteNonQuery(sqlString3, paras);
  9384. deleteRow += oracleTrConn.ExecuteNonQuery(sqlString4, paras);
  9385. deleteRow += oracleTrConn.ExecuteNonQuery(sqlString5, paras);
  9386. deleteRow += oracleTrConn.ExecuteNonQuery(sqlScrapProduct, ScrapProductparas);
  9387. // 有错误
  9388. if (deleteRow == 0)
  9389. {
  9390. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  9391. }
  9392. return null;
  9393. }
  9394. catch (Exception ex)
  9395. {
  9396. throw ex;
  9397. }
  9398. }
  9399. /// <summary>
  9400. /// 编辑后删除生产数据
  9401. /// </summary>
  9402. /// <param name="productionDataID">生产数据ID</param>
  9403. /// <returns>int</returns>
  9404. public static string DeleteSubstandardToOtherByID(IDBTransaction oracleTrConn, int productionDataID, string barcode, SUserInfo sUserInfo)
  9405. {
  9406. int deleteRow = 0;
  9407. try
  9408. {
  9409. string sqlString5 = @"update TP_PM_DefectMissedResponsible set ValueFlag=0, UpdateUserID=:UpdateUserID
  9410. where TP_PM_DefectMissedResponsible.Productiondefectid in
  9411. (
  9412. select ProductionDefectID from TP_PM_Defect where TP_PM_Defect.Productiondataid=:ProductionDataID
  9413. )";
  9414. string sqlString4 = @"update TP_PM_ProductionDataIn set ValueFlag=0, UpdateUserID=:UpdateUserID
  9415. where
  9416. TP_PM_ProductionDataIn.Productiondataid=:ProductionDataID
  9417. ";
  9418. string sqlString3 = @"update TP_PM_Defect set ValueFlag=0, UpdateUserID=:UpdateUserID
  9419. where TP_PM_Defect.Productiondataid =:ProductionDataID";
  9420. string sqlString2 = @"update TP_PM_DefectResponsible set ValueFlag=0, UpdateUserID=:UpdateUserID
  9421. where TP_PM_DefectResponsible.Productiondefectid in
  9422. (
  9423. select ProductionDefectID from TP_PM_Defect where TP_PM_Defect.Productiondataid=:ProductionDataID
  9424. )";
  9425. string sqlString = @"update TP_PM_DefectImage set ValueFlag=0, UpdateUserID=:UpdateUserID
  9426. where TP_PM_DefectImage.Productiondefectid in
  9427. (
  9428. select ProductionDefectID from TP_PM_Defect where TP_PM_Defect.Productiondataid=:ProductionDataID
  9429. )";
  9430. //string sqlScrapProduct = @"update TP_PM_ScrapProduct set ValueFlag=0 where barcode=:barcode";
  9431. string sqlScrapProduct = @"update TP_PM_ScrapProduct set ValueFlag=0, UpdateUserID=:UpdateUserID where ScrapProductID=(
  9432. select max(ScrapProductID) from TP_PM_ScrapProduct where barcode=:barcode)";
  9433. string sqlExist = "select 1 from tp_pm_inproduction where barcode = :barcode ";
  9434. string sqlInsert = @"insert into TP_PM_InProduction
  9435. (
  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. )
  9490. select
  9491. BarCode,
  9492. ProductionLineID,
  9493. ProductionLineCode,
  9494. ProductionLineName,
  9495. ProcedureModel,
  9496. ModelType,
  9497. DefectFlag,
  9498. ReworkProcedureID,
  9499. IsPublicBody,
  9500. IsReFire,
  9501. GoodsLevelID,
  9502. GoodsLevelTypeID,
  9503. GoodsID,
  9504. GoodsCode,
  9505. GoodsName,
  9506. UserID,
  9507. GroutingDailyID,
  9508. GroutingDailyDetailID,
  9509. GroutingDate,
  9510. GroutingLineID,
  9511. GroutingLineCode,
  9512. GroutingLineName,
  9513. GMouldTypeID,
  9514. CanManyTimes,
  9515. GroutingLineDetailID,
  9516. GroutingMouldCode,
  9517. MouldCode,
  9518. GroutingUserID,
  9519. GroutingUserCode,
  9520. GroutingNum,
  9521. Remarks,
  9522. KilnID,
  9523. KilnCode,
  9524. KilnName,
  9525. KilnCarID,
  9526. KilnCarCode,
  9527. KilnCarName,
  9528. KilnCarBatchNo,
  9529. KilnCarPosition,
  9530. AccountID,
  9531. ValueFlag,
  9532. CreateTime,
  9533. CreateUserID,
  9534. UpdateTime,
  9535. UpdateUserID,
  9536. OPTimeStamp,
  9537. SpecialRepairflag,
  9538. FlowProcedureID,
  9539. FlowProcedureTime,
  9540. ProcedureID,
  9541. ProcedureTime,
  9542. ProductionDataID,
  9543. logoid, ISREWORKFLAG, SEMICHECKID
  9544. from TP_PM_InProductionTrash
  9545. where barcode=:barcode
  9546. ";
  9547. string sqlDelete = @"delete from TP_PM_InProductionTrash where barcode=:barcode";
  9548. OracleParameter[] paras = new OracleParameter[]{
  9549. new OracleParameter(":ProductionDataID",OracleDbType.Int32, productionDataID,ParameterDirection.Input),
  9550. new OracleParameter(":UpdateUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input),
  9551. };
  9552. OracleParameter[] ScrapProductparas = new OracleParameter[]{
  9553. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  9554. new OracleParameter(":UpdateUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input),
  9555. };
  9556. OracleParameter[] Existparas = new OracleParameter[]{
  9557. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  9558. };
  9559. deleteRow += oracleTrConn.ExecuteNonQuery(sqlString, paras);
  9560. deleteRow += oracleTrConn.ExecuteNonQuery(sqlString2, paras);
  9561. deleteRow += oracleTrConn.ExecuteNonQuery(sqlString3, paras);
  9562. deleteRow += oracleTrConn.ExecuteNonQuery(sqlString4, paras);
  9563. deleteRow += oracleTrConn.ExecuteNonQuery(sqlString5, paras);
  9564. deleteRow += oracleTrConn.ExecuteNonQuery(sqlScrapProduct, ScrapProductparas);
  9565. DataSet dsresult = oracleTrConn.GetSqlResultToDs(sqlExist, Existparas);
  9566. if (dsresult != null && dsresult.Tables[0].Rows.Count == 0)
  9567. {
  9568. deleteRow += oracleTrConn.ExecuteNonQuery(sqlInsert, Existparas);
  9569. }
  9570. deleteRow += oracleTrConn.ExecuteNonQuery(sqlDelete, Existparas);
  9571. // 有错误
  9572. if (deleteRow == 0)
  9573. {
  9574. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  9575. }
  9576. return null;
  9577. }
  9578. catch (Exception ex)
  9579. {
  9580. throw ex;
  9581. }
  9582. }
  9583. /// <summary>
  9584. /// 编辑后删除生产数据
  9585. /// </summary>
  9586. /// <param name="productionDataID">生产数据ID</param>
  9587. /// <returns>int</returns>
  9588. public static string DeleteNormalToOtherByID(IDBTransaction oracleTrConn, int productionDataID, string barcode, SUserInfo sUserInfo)
  9589. {
  9590. int deleteRow = 0;
  9591. try
  9592. {
  9593. string sqlString5 = @"update TP_PM_DefectMissedResponsible set ValueFlag=0, UpdateUserID=:UpdateUserID
  9594. where TP_PM_DefectMissedResponsible.Productiondefectid in
  9595. (
  9596. select ProductionDefectID from TP_PM_Defect where TP_PM_Defect.Productiondataid=:ProductionDataID
  9597. )";
  9598. string sqlString4 = @"update TP_PM_ProductionDataIn set ValueFlag=0, UpdateUserID=:UpdateUserID
  9599. where
  9600. TP_PM_ProductionDataIn.Productiondataid=:ProductionDataID
  9601. ";
  9602. string sqlString3 = @"update TP_PM_Defect set ValueFlag=0, UpdateUserID=:UpdateUserID
  9603. where TP_PM_Defect.Productiondataid =:ProductionDataID";
  9604. string sqlString2 = @"update TP_PM_DefectResponsible set ValueFlag=0, UpdateUserID=:UpdateUserID
  9605. where TP_PM_DefectResponsible.Productiondefectid in
  9606. (
  9607. select ProductionDefectID from TP_PM_Defect where TP_PM_Defect.Productiondataid=:ProductionDataID
  9608. )";
  9609. string sqlString = @"update TP_PM_DefectImage set ValueFlag=0, UpdateUserID=:UpdateUserID
  9610. where TP_PM_DefectImage.Productiondefectid in
  9611. (
  9612. select ProductionDefectID from TP_PM_Defect where TP_PM_Defect.Productiondataid=:ProductionDataID
  9613. )";
  9614. OracleParameter[] paras = new OracleParameter[]{
  9615. new OracleParameter(":ProductionDataID",OracleDbType.Int32, productionDataID,ParameterDirection.Input),
  9616. new OracleParameter(":UpdateUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input),
  9617. };
  9618. deleteRow += oracleTrConn.ExecuteNonQuery(sqlString, paras);
  9619. deleteRow += oracleTrConn.ExecuteNonQuery(sqlString2, paras);
  9620. deleteRow += oracleTrConn.ExecuteNonQuery(sqlString3, paras);
  9621. deleteRow += oracleTrConn.ExecuteNonQuery(sqlString4, paras);
  9622. deleteRow += oracleTrConn.ExecuteNonQuery(sqlString5, paras);
  9623. // 有错误
  9624. if (deleteRow == 0)
  9625. {
  9626. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  9627. }
  9628. return null;
  9629. }
  9630. catch (Exception ex)
  9631. {
  9632. throw ex;
  9633. }
  9634. }
  9635. /// <summary>
  9636. /// 保存条码信息
  9637. /// </summary>
  9638. /// <param name="procedureID">工序ID</param>
  9639. /// <param name="productionDataEntitys">生产数据集</param>
  9640. /// <param name="sUserInfo">用户基本信息</param>
  9641. /// <returns>string</returns>
  9642. public static string AddCheckBarcodePDA(int procedureID, ProductionDataEntity[] productionDataEntitys, SUserInfo sUserInfo)
  9643. {
  9644. string errMsg = "";
  9645. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  9646. try
  9647. {
  9648. oracleTrConn.Connect();
  9649. #region 查询工序信息
  9650. ProcedureEntity procedure = GetProcedurByID(oracleTrConn, procedureID);
  9651. #endregion
  9652. #region 标准检验(半成品)
  9653. if (procedure.ModelType == (int)Constant.ProcedureModelType.Normal)
  9654. {
  9655. errMsg = AddNormalCheck(oracleTrConn, procedure, productionDataEntitys, sUserInfo);
  9656. }
  9657. #endregion
  9658. #region 成品检验
  9659. else if (procedure.ModelType == (int)Constant.ProcedureModelType.QualityStatistics)
  9660. {
  9661. errMsg = AddFinishCheckPDA(oracleTrConn, procedure, productionDataEntitys, sUserInfo);
  9662. }
  9663. #endregion
  9664. #region 半检 xuwei add 2019-12-13
  9665. else if (procedure.ModelType == (int)Constant.ProcedureModelType.SemiQualityStatistics)
  9666. {
  9667. errMsg = AddFinishCheckPDA(oracleTrConn, procedure, productionDataEntitys, sUserInfo);
  9668. }
  9669. #endregion
  9670. #region 入窑前检验
  9671. else if (procedure.ModelType == (int)Constant.ProcedureModelType.IntoKilnCheck)
  9672. {
  9673. errMsg = AddIntoKilnCheck(oracleTrConn, procedure, productionDataEntitys, sUserInfo);
  9674. }
  9675. #endregion
  9676. // 没有错误 提交事务
  9677. if (string.IsNullOrEmpty(errMsg))
  9678. {
  9679. oracleTrConn.Commit();
  9680. }
  9681. }
  9682. catch (Exception ex)
  9683. {
  9684. oracleTrConn.Rollback();
  9685. throw ex;
  9686. }
  9687. finally
  9688. {
  9689. // 释放资源
  9690. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  9691. {
  9692. oracleTrConn.Disconnect();
  9693. }
  9694. }
  9695. return errMsg;
  9696. }
  9697. #endregion
  9698. /// <summary>
  9699. /// 校验干补条码有效
  9700. /// </summary>
  9701. /// <param name="oracleTrConn">连接对象</param>
  9702. /// <param name="procedureID">工序ID</param>
  9703. /// <param name="barcode">条码</param>
  9704. /// <param name="goodsID">返回的产品ID</param>
  9705. /// <param name="goodsCode">返回的产品Code</param>
  9706. /// <param name="goodsName">返回的产品名称</param>
  9707. /// <param name="groutingUserID">返回的注浆者ID</param>
  9708. /// <returns>string</returns>
  9709. /// <remarks>
  9710. /// 袁新成 2015.3.27 新建
  9711. /// </remarks>
  9712. private static string CheckDryRepairBarcode(IDBTransaction oracleTrConn,
  9713. int procedureID,
  9714. string barcode,
  9715. out int goodsID,
  9716. out string goodsCode,
  9717. out string goodsName,
  9718. out string groutingUserCode,
  9719. SUserInfo sUserInfo
  9720. )
  9721. {
  9722. try
  9723. {
  9724. OracleParameter[] paras = new OracleParameter[]{
  9725. new OracleParameter("in_procedureid",OracleDbType.Int32,procedureID,ParameterDirection.Input),
  9726. new OracleParameter("in_barcode",OracleDbType.Varchar2,barcode,ParameterDirection.Input),
  9727. new OracleParameter("out_errMsg",OracleDbType.Varchar2,2000,"",ParameterDirection.Output),
  9728. new OracleParameter("out_goodsID",OracleDbType.Int32,ParameterDirection.Output),
  9729. new OracleParameter("out_goodsCode",OracleDbType.Varchar2,50,"",ParameterDirection.Output),
  9730. new OracleParameter("out_goodsName",OracleDbType.Varchar2,50,"",ParameterDirection.Output),
  9731. new OracleParameter("out_groutingUserCode",OracleDbType.NVarchar2,50,null,ParameterDirection.Output),
  9732. };
  9733. oracleTrConn.ExecStoredProcedure("pro_pm_checkdryrepairbarcode", paras);
  9734. if (!"null".Equals(paras[3].Value + ""))
  9735. {
  9736. goodsID = Convert.ToInt32(paras[3].Value + "");
  9737. }
  9738. else
  9739. {
  9740. goodsID = 0;
  9741. }
  9742. goodsCode = paras[4].Value + "";
  9743. goodsName = paras[5].Value + "";
  9744. if (!"null".Equals(paras[6].Value + ""))
  9745. {
  9746. groutingUserCode = paras[6].Value + "";
  9747. }
  9748. else
  9749. {
  9750. groutingUserCode = null;
  9751. }
  9752. if ("null".Equals(paras[2].Value + ""))
  9753. {
  9754. return null;
  9755. }
  9756. return paras[2].Value.ToString().Replace("\\n\\r", "\n\r");
  9757. }
  9758. catch (Exception ex)
  9759. {
  9760. throw ex;
  9761. }
  9762. }
  9763. /// <summary>
  9764. /// 干补标准计件
  9765. /// </summary>
  9766. /// <param name="oracleTrConn">数据连接对象</param>
  9767. /// <param name="procedure">工序对象</param>
  9768. /// <param name="barcodeTable">条码信息</param>
  9769. /// <param name="sUserInfo">用户基本信息</param>
  9770. /// <param name="goodsID">返回的产品ID</param>
  9771. /// <param name="goodsCode">返回的产品Code</param>
  9772. /// <param name="goodsName">返回的产品名称</param>
  9773. /// <param name="groutingUserID">返回的注浆者ID</param>
  9774. /// <returns>string</returns>
  9775. /// <remarks>
  9776. /// 袁新成 2015.3.26 新建
  9777. /// </remarks>
  9778. private static string AddDryRepairWorkPiece(IDBTransaction oracleTrConn,
  9779. ProcedureEntity procedure,
  9780. DataTable barcodeTable,
  9781. SUserInfo sUserInfo,
  9782. out int goodsID,
  9783. out string goodsCode,
  9784. out string goodsName,
  9785. out string groutingUserCode, out string logoCode, out string logoName, out string groutingdate)
  9786. {
  9787. try
  9788. {
  9789. int deleteRow = 0;
  9790. goodsID = Constant.INT_IS_ZERO;
  9791. goodsCode = null;
  9792. goodsName = null;
  9793. groutingUserCode = string.Empty; //Constant.INT_IS_ZERO;
  9794. // 获得账务日期
  9795. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  9796. string errMsg = string.Empty;
  9797. // 本批采集的批次号
  9798. string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  9799. // 条码信息
  9800. string logoName_Temp = "";
  9801. string logoCode_Temp = "";
  9802. string groutingdate_Temp = "";
  9803. foreach (DataRow barcodeRow in barcodeTable.Rows)
  9804. {
  9805. // 条码
  9806. string barcode = barcodeRow["Barcode"].ToString();
  9807. if (string.IsNullOrEmpty(barcode))
  9808. {
  9809. throw new Exception("传入的条码号为空");
  9810. }
  9811. // 生产工号
  9812. int workUserID = Convert.ToInt32(barcodeRow["UserID"]);
  9813. // 生产工号
  9814. string workUserCode = barcodeRow["UserCode"].ToString();
  9815. //#region 校验条码有效性
  9816. //errMsg = CheckDryRepairBarcode(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo);
  9817. //if (!string.IsNullOrEmpty(errMsg))
  9818. //{
  9819. // return errMsg;
  9820. //}
  9821. //#endregion
  9822. if (procedure.CollectType == 1)
  9823. {
  9824. #region 校验条码有效性
  9825. errMsg = CheckDryRepairBarcode(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo);
  9826. if (!string.IsNullOrEmpty(errMsg))
  9827. {
  9828. logoName = "";
  9829. logoCode = "";
  9830. groutingdate = "";
  9831. return errMsg;
  9832. }
  9833. #endregion
  9834. }
  9835. else
  9836. {
  9837. string sqlGroutingInfo = @"select tp_pm_groutingdailydetail.goodsid,
  9838. tp_pm_groutingdailydetail.goodscode,
  9839. tp_pm_groutingdailydetail.goodsname,
  9840. tp_pm_groutingdailydetail.usercode as groutingUserCode,
  9841. tp_pm_groutingdailydetail.groutingdate,
  9842. tp_mst_logo.logoid,
  9843. tp_mst_logo.logocode,
  9844. tp_mst_logo.logoname
  9845. from tp_pm_groutingdailydetail
  9846. left join tp_mst_logo
  9847. on tp_pm_groutingdailydetail.logoid=tp_mst_logo.logoid
  9848. where tp_pm_groutingdailydetail.barcode=:barcode
  9849. ";
  9850. OracleParameter[] paras = new OracleParameter[] {
  9851. new OracleParameter(":barcode",barcode),
  9852. };
  9853. DataSet dsGrouting = oracleTrConn.GetSqlResultToDs(sqlGroutingInfo, paras);
  9854. if (dsGrouting != null && dsGrouting.Tables[0].Rows.Count > 0)
  9855. {
  9856. goodsID = Convert.ToInt32(dsGrouting.Tables[0].Rows[0]["goodsid"]);
  9857. goodsCode = dsGrouting.Tables[0].Rows[0]["goodscode"].ToString();
  9858. goodsName = dsGrouting.Tables[0].Rows[0]["goodsName"].ToString();
  9859. groutingUserCode = dsGrouting.Tables[0].Rows[0]["groutingUserCode"].ToString();
  9860. logoName = dsGrouting.Tables[0].Rows[0]["logoName"].ToString();
  9861. logoCode = dsGrouting.Tables[0].Rows[0]["logoCode"].ToString();
  9862. groutingdate = dsGrouting.Tables[0].Rows[0]["groutingdate"].ToString();
  9863. logoName_Temp = logoName;
  9864. logoCode_Temp = logoCode;
  9865. groutingdate_Temp = groutingdate;
  9866. }
  9867. }
  9868. #region 数据处理
  9869. #region 处理废弃数据并转回收数据为在产数据
  9870. string querysql = @"select GOODSLEVELID from TP_MST_GOODSLEVEL where GOODSLEVELTYPEID=9 and ACCOUNTID=:accountid and VALUEFLAG=1";
  9871. OracleParameter[] queryparas = new OracleParameter[]{
  9872. new OracleParameter(":accountid",OracleDbType.Varchar2, sUserInfo.AccountID,ParameterDirection.Input)
  9873. };
  9874. DataSet returnDs = oracleTrConn.GetSqlResultToDs(querysql, queryparas);
  9875. if (returnDs == null || returnDs.Tables[0].Rows.Count == 0)
  9876. {
  9877. errMsg = "未设定干补等级";
  9878. logoName = "";
  9879. logoCode = "";
  9880. groutingdate = "";
  9881. return errMsg;
  9882. }
  9883. string goodsLevelID = returnDs.Tables[0].Rows[0][0].ToString();
  9884. //第一步,废弃数据的产品分级类别由 8损坯13不合格14不合格(返) 改为 9干补,产品分级=此账套相应的设置
  9885. /*string sqlUpdateLevelTypeString = @"update TP_PM_ScrapProduct set GOODSLEVELID=:GOODSLEVELID, GoodsLevelTypeID=9,SpecialRepairFlag=1,
  9886. SpecialRepairUserID=:SpecialRepairUserID,SpecialRepairUserCode=:SpecialRepairUserCode,SpecialRepairTime=sysdate,
  9887. UpdateUserID=:UpdateUserID
  9888. where BarCode=:barcode
  9889. and CreateTime=(select max(CreateTime) from TP_PM_ScrapProduct where BarCode=:barcode1 and ValueFlag=1)
  9890. and ValueFlag=1 and GoodsLevelTypeID=(select max(GoodsLevelTypeID) from TP_PM_ScrapProduct where BarCode=:barcode1 and ValueFlag=1) ";
  9891. */
  9892. // and ValueFlag=1 and GoodsLevelTypeID=8 ";
  9893. string sqlUpdateLevelTypeString = @"update TP_PM_ScrapProduct set GOODSLEVELID=:GOODSLEVELID, GoodsLevelTypeID=9,
  9894. SpecialRepairUserID=:SpecialRepairUserID,SpecialRepairUserCode=:SpecialRepairUserCode,SpecialRepairTime=sysdate,
  9895. UpdateUserID=:UpdateUserID
  9896. where BarCode=:barcode
  9897. and CreateTime=(select max(CreateTime) from TP_PM_ScrapProduct where BarCode=:barcode1 and ValueFlag=1)
  9898. and ValueFlag=1 and GoodsLevelTypeID in (8, 13, 14) ";
  9899. OracleParameter[] ScrapProductparas = new OracleParameter[]{
  9900. new OracleParameter(":GOODSLEVELID",OracleDbType.Int32,int.Parse(goodsLevelID),ParameterDirection.Input),
  9901. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  9902. new OracleParameter(":barcode1",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  9903. new OracleParameter(":SpecialRepairUserID",OracleDbType.Int32,workUserID,ParameterDirection.Input),
  9904. new OracleParameter(":SpecialRepairUserCode",OracleDbType.Varchar2,workUserCode,ParameterDirection.Input),
  9905. new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  9906. };
  9907. //modify wangx 20150623
  9908. OracleParameter[] sqlUpdateparas = new OracleParameter[]{
  9909. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  9910. };
  9911. //string sqlUpdate = "update TP_PM_InCheckedDetail set SpecialRepairFlag=1 where barcode=:barcode";
  9912. //oracleTrConn.ExecuteNonQuery(sqlUpdate, sqlUpdateparas);
  9913. string sqlUpdate = "update TP_PM_ProductionDataIn set SpecialRepairFlag=1 where barcode=:barcode";
  9914. oracleTrConn.ExecuteNonQuery(sqlUpdate, sqlUpdateparas);
  9915. //modify wangx 20150623 end
  9916. #region
  9917. //第五步,插入干补工序的生产数据(同其他计件工序),设置干补标识,产品分级类别=9干补,产品分级=此账套相应的设置
  9918. // 查询新插入的生产数据ID
  9919. string sql = "select SEQ_PM_ProductionData_ID.nextval from dual";
  9920. string idStr = oracleTrConn.GetSqlResultToStr(sql);
  9921. int productionDataID = 0;
  9922. if (!string.IsNullOrEmpty(idStr))
  9923. {
  9924. productionDataID = int.Parse(idStr);
  9925. }
  9926. else
  9927. {
  9928. logoName = "";
  9929. logoCode = "";
  9930. groutingdate = "";
  9931. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  9932. }
  9933. int? ClassesSettingID = null;//班次配置ID
  9934. #region 第五步 添加生产者数据
  9935. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID);
  9936. if (!string.IsNullOrEmpty(errMsg))
  9937. {
  9938. logoName = "";
  9939. logoCode = "";
  9940. groutingdate = "";
  9941. return errMsg;
  9942. }
  9943. #endregion
  9944. ProductionDataEntity productionData = new ProductionDataEntity();
  9945. #region 属性赋值
  9946. productionData.ClassesSettingID = ClassesSettingID;
  9947. productionData.ProductionDataID = Convert.ToInt32(idStr);
  9948. productionData.Barcode = barcode;
  9949. productionData.CentralizedBatchNo = centralizedBatchNo;
  9950. productionData.ProductionLineID = procedure.ProductionLineID;
  9951. productionData.ProductionLineCode = procedure.ProductionlineCode;
  9952. productionData.ProductionLineName = procedure.ProductionlineName;
  9953. productionData.CompleteProcedureID = procedure.ProcedureID;
  9954. productionData.ProcedureCode = procedure.ProcedureCode;
  9955. productionData.ProcedureName = procedure.ProcedureName;
  9956. productionData.ProcedureModel = procedure.ProcedureModel;
  9957. productionData.ModelType = procedure.ModelType;
  9958. productionData.NodeType = procedure.NodeType;
  9959. productionData.DefectFlag = (int)Constant.DefectFlag.No;
  9960. productionData.ReworkProcedureID = null;
  9961. productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, barcode);
  9962. productionData.IsReFire = (int)Constant.ReFireFlag.No;
  9963. //设置干补标识,产品分级类别=9干补
  9964. productionData.GoodsLevelTypeID = 9;
  9965. productionData.GoodsLevelID = int.Parse(goodsLevelID);
  9966. productionData.GoodsGrade = (int)Constant.GoodsGrade.Good;
  9967. productionData.OrganizationID = procedure.OrganizationID;
  9968. productionData.GoodsID = goodsID;
  9969. productionData.GoodsCode = goodsCode;
  9970. productionData.GoodsName = goodsName;
  9971. productionData.UserID = workUserID;
  9972. productionData.UserCode = barcodeRow["UserCode"].ToString();
  9973. productionData.UserName = barcodeRow["UserName"].ToString();
  9974. productionData.PieceType = procedure.PieceType;
  9975. if (barcodeRow["LogoID"].ToString() != "")
  9976. {
  9977. productionData.LogoID = Convert.ToInt32(barcodeRow["LogoID"]);
  9978. }
  9979. string sqlReFire = @"select
  9980. isrefire,
  9981. logoid
  9982. from tp_pm_inproduction where barcode=:barcode
  9983. union
  9984. select
  9985. isrefire,
  9986. logoid
  9987. from TP_PM_InProductionTrash where barcode=:barcode
  9988. union
  9989. select
  9990. isrefire,
  9991. logoid
  9992. from TP_PM_FinishedProduct where barcode=:barcode ";
  9993. OracleParameter[] ReFireparas = new OracleParameter[] {
  9994. new OracleParameter(":barcode",barcode),
  9995. };
  9996. DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas);
  9997. if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0)
  9998. {
  9999. if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0)
  10000. {
  10001. productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]);
  10002. }
  10003. if (dsReFire.Tables[0].Rows[0]["logoid"].ToString() != "")
  10004. {
  10005. productionData.LogoID = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["LogoID"]);
  10006. }
  10007. }
  10008. #endregion 属性赋值
  10009. string OutSpecialRepairflag = "0";//干补标识
  10010. productionData.SpecialRepairflag = 1;
  10011. errMsg = AddDryRepairProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag);
  10012. if (!string.IsNullOrEmpty(errMsg))
  10013. {
  10014. logoName = "";
  10015. logoCode = "";
  10016. groutingdate = "";
  10017. return errMsg;
  10018. }
  10019. #endregion
  10020. //第二步,回收站中数据回到在产中,设置干补标识。
  10021. string sqlInsInProdString = @"insert into TP_PM_InProduction(BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME,
  10022. PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID,
  10023. ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME,
  10024. USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE,
  10025. GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID,
  10026. CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE,
  10027. REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME,
  10028. CREATEUSERID, UPDATETIME, UPDATEUSERID,
  10029. ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG,
  10030. GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM,
  10031. KILNID, KILNCODE, KILNNAME, KILNCARID,
  10032. KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID
  10033. ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,logoid, ISREWORKFLAG, SEMICHECKID)
  10034. select BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME,
  10035. :PROCEDUREMODEL, :MODELTYPE, REWORKPROCEDUREID,
  10036. ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME,
  10037. USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE,
  10038. GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID,
  10039. CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE,
  10040. REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME,
  10041. CREATEUSERID, UPDATETIME, :UpdateUserID,
  10042. ISREFIRE, null, null, DEFECTFLAG,
  10043. GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM,
  10044. KILNID, KILNCODE, KILNNAME, KILNCARID,
  10045. KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,1,FlowProcedureID ,
  10046. FlowProcedureTime,:ProcedureID,sysdate,:ProductionDataID,logoid, ISREWORKFLAG, SEMICHECKID
  10047. from TP_PM_InProductionTrash where barcode=:barcode ";
  10048. OracleParameter[] InProductparas = new OracleParameter[]{
  10049. new OracleParameter(":UpdateUserID",OracleDbType.Int32, workUserID,ParameterDirection.Input),
  10050. // new OracleParameter(":GOODSLEVELID",OracleDbType.Int32,int.Parse(goodsLevelID),ParameterDirection.Input),
  10051. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  10052. new OracleParameter(":ProcedureID",OracleDbType.Int32,procedure.ProcedureID,ParameterDirection.Input),
  10053. new OracleParameter(":PROCEDUREMODEL",OracleDbType.Varchar2,procedure.ProcedureModel,ParameterDirection.Input),
  10054. new OracleParameter(":MODELTYPE",OracleDbType.Int32,procedure.ModelType,ParameterDirection.Input),
  10055. new OracleParameter(":ProductionDataID",OracleDbType.Int32,productionDataID,ParameterDirection.Input)
  10056. };
  10057. //第三步,删除回收站中的条码
  10058. string sqlDelInProductTrashString = "delete from TP_PM_InProductionTrash where barcode=:barcode ";
  10059. OracleParameter[] TrashProductparas = new OracleParameter[]{
  10060. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input)
  10061. };
  10062. //第四步,更新注浆表干补标识
  10063. // string sqlUpGroutingDeilString = @"update TP_PM_GroutingDailyDetail set SpecialRepairFlag=1
  10064. // where GroutingDailyDetailID=(select GroutingDailyDetailID from TP_PM_GROUTINGPRODUCT
  10065. // where barcode=:barcode)";
  10066. string sqlUpGroutingDeilString = @"update TP_PM_GroutingDailyDetail set SpecialRepairFlag=1
  10067. where barcode=:barcode";
  10068. OracleParameter[] GroutingProductparas = new OracleParameter[]{
  10069. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input)
  10070. };
  10071. // string sqlUpCompleteString = @"update TP_PM_FINISHEDPRODUCT set SpecialRepairFlag=1
  10072. // where barcode=:barcode ";
  10073. // OracleParameter[] CompleteProductparas = new OracleParameter[]{
  10074. // new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input)
  10075. // };
  10076. deleteRow += oracleTrConn.ExecuteNonQuery(sqlUpdateLevelTypeString, ScrapProductparas);
  10077. deleteRow += oracleTrConn.ExecuteNonQuery(sqlInsInProdString, InProductparas);
  10078. deleteRow += oracleTrConn.ExecuteNonQuery(sqlDelInProductTrashString, TrashProductparas);
  10079. deleteRow += oracleTrConn.ExecuteNonQuery(sqlUpGroutingDeilString, GroutingProductparas);
  10080. //deleteRow += oracleTrConn.ExecuteNonQuery(sqlUpCompleteString, CompleteProductparas); //由于成品后,不能报损,所以这个执行去掉
  10081. // 失败
  10082. if (deleteRow == Constant.INT_IS_ZERO)
  10083. {
  10084. logoName = "";
  10085. logoCode = "";
  10086. groutingdate = "";
  10087. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  10088. }
  10089. #endregion
  10090. //#region 第五步 添加生产者数据
  10091. //errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo);
  10092. //if (!string.IsNullOrEmpty(errMsg))
  10093. //{
  10094. // return errMsg;
  10095. //}
  10096. //#endregion
  10097. //第五步,回添加生产数据 modify wangx 2015/07/20 新添加的代码
  10098. sql = "select 1 from tp_pm_productiondatain where barcode=:barcode and valueflag=1";
  10099. OracleParameter[] Paras = new OracleParameter[] {
  10100. new OracleParameter(":barcode",OracleDbType.Varchar2,
  10101. barcode,ParameterDirection.Input)
  10102. };
  10103. DataSet ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  10104. if (ds.Tables[0].Rows.Count == 0)
  10105. {
  10106. // 2 生产数据恢复到在产生产数据
  10107. sql = @"insert into tp_pm_productiondatain
  10108. (
  10109. ProductionDataID,
  10110. BarCode,
  10111. CentralizedBatchNo,
  10112. ProductionLineID,
  10113. ProductionLineCode,
  10114. ProductionLineName,
  10115. ProcedureID,
  10116. ProcedureCode,
  10117. ProcedureName,
  10118. ProcedureModel,
  10119. ModelType,
  10120. PieceType,
  10121. IsReworked,
  10122. NodeType,
  10123. IsPublicBody,
  10124. IsReFire,
  10125. GoodsLevelID,
  10126. GoodsLevelTypeID,
  10127. SpecialRepairFlag,
  10128. OrganizationID,
  10129. GoodsID,
  10130. GoodsCode,
  10131. GoodsName,
  10132. UserID,
  10133. UserCode,
  10134. UserName,
  10135. ClassesSettingID,
  10136. KilnID,
  10137. KilnCode,
  10138. KilnName,
  10139. KilnCarID,
  10140. KilnCarCode,
  10141. KilnCarName,
  10142. KilnCarBatchNo,
  10143. KilnCarPosition,
  10144. ReworkProcedureID,
  10145. ReworkProcedureCode,
  10146. ReworkProcedureName,
  10147. GroutingDailyID,
  10148. GroutingDailyDetailID,
  10149. GroutingLineID,
  10150. GroutingLineCode,
  10151. GroutingLineName,
  10152. GMouldTypeID,
  10153. CanManyTimes,
  10154. GroutingLineDetailID,
  10155. GroutingDate,
  10156. GroutingMouldCode,
  10157. MouldCode,
  10158. GroutingUserID,
  10159. GroutingUserCode,
  10160. GroutingNum,
  10161. Remarks,
  10162. AccountDate,
  10163. SettlementFlag,
  10164. AccountID,
  10165. ValueFlag,
  10166. CreateTime,
  10167. CreateUserID,
  10168. UpdateTime,
  10169. UpdateUserID,
  10170. OPTimeStamp,
  10171. TriggerFlag,
  10172. logoid,
  10173. BackOutTime,BackOutUserID,BackOutUserCode
  10174. )
  10175. select
  10176. ProductionDataID,
  10177. BarCode,
  10178. CentralizedBatchNo,
  10179. ProductionLineID,
  10180. ProductionLineCode,
  10181. ProductionLineName,
  10182. ProcedureID,
  10183. ProcedureCode,
  10184. ProcedureName,
  10185. ProcedureModel,
  10186. ModelType,
  10187. PieceType,
  10188. IsReworked,
  10189. NodeType,
  10190. IsPublicBody,
  10191. IsReFire,
  10192. GoodsLevelID,
  10193. GoodsLevelTypeID,
  10194. SpecialRepairFlag,
  10195. OrganizationID,
  10196. GoodsID,
  10197. GoodsCode,
  10198. GoodsName,
  10199. UserID,
  10200. UserCode,
  10201. UserName,
  10202. ClassesSettingID,
  10203. KilnID,
  10204. KilnCode,
  10205. KilnName,
  10206. KilnCarID,
  10207. KilnCarCode,
  10208. KilnCarName,
  10209. KilnCarBatchNo,
  10210. KilnCarPosition,
  10211. ReworkProcedureID,
  10212. ReworkProcedureCode,
  10213. ReworkProcedureName,
  10214. GroutingDailyID,
  10215. GroutingDailyDetailID,
  10216. GroutingLineID,
  10217. GroutingLineCode,
  10218. GroutingLineName,
  10219. GMouldTypeID,
  10220. CanManyTimes,
  10221. GroutingLineDetailID,
  10222. GroutingDate,
  10223. GroutingMouldCode,
  10224. MouldCode,
  10225. GroutingUserID,
  10226. GroutingUserCode,
  10227. GroutingNum,
  10228. Remarks,
  10229. AccountDate,
  10230. SettlementFlag,
  10231. AccountID,
  10232. ValueFlag,
  10233. CreateTime,
  10234. CreateUserID,
  10235. UpdateTime,
  10236. UpdateUserID,
  10237. OPTimeStamp,
  10238. 1,
  10239. logoid,
  10240. BackOutTime,BackOutUserID,BackOutUserCode
  10241. from TP_PM_ProductionData where valueflag=1 and barcode=:barcode
  10242. ";
  10243. oracleTrConn.ExecuteNonQuery(sql, Paras);
  10244. }
  10245. //第五步,回添加生产数据 modify wangx 2015/07/20 新添加的代码 end
  10246. #endregion 数据处理
  10247. }
  10248. logoName = logoName_Temp;
  10249. logoCode = logoCode_Temp;
  10250. groutingdate = groutingdate_Temp;
  10251. return errMsg;
  10252. }
  10253. catch (Exception ex)
  10254. {
  10255. throw ex;
  10256. }
  10257. }
  10258. /// <summary>
  10259. /// 添加干补生产数据
  10260. /// </summary>
  10261. /// <param name="oracleTrConn">连接对象</param>
  10262. /// <param name="accountDate">账务日期</param>
  10263. /// <param name="productionData">生产数据</param>
  10264. /// <param name="sUserInfo">用户基本信息</param>
  10265. /// <returns>string</returns>
  10266. /// <remarks>
  10267. /// 袁新成 2015.04.1 新建
  10268. /// </remarks>
  10269. private static string AddDryRepairProductionData(IDBTransaction oracleTrConn, DateTime accountDate, ProductionDataEntity productionData, SUserInfo sUserInfo, out string OutSpecialRepairflag)
  10270. {
  10271. #region 查出产品注浆日期,注浆工号ID,注浆工号编码,注浆次数,注浆模具编号,模具编号
  10272. string selectSql = "";
  10273. string returnVal = "";
  10274. //这地方连了两张表,为了成检的时候,次品在次新增
  10275. selectSql = @"select
  10276. GroutingDate,
  10277. GroutingUserID,
  10278. GroutingUserCode,
  10279. GroutingNum,
  10280. GroutingMouldCode,
  10281. MouldCode,
  10282. GroutingDailyID,
  10283. GroutingDailyDetailID,
  10284. GroutingLineID,
  10285. GroutingLineCode,
  10286. GroutingLineName,
  10287. GMouldTypeID,
  10288. CanManyTimes,
  10289. GroutingLineDetailID,
  10290. SpecialRepairflag
  10291. from tp_pm_inproduction where barcode=:barcode
  10292. union
  10293. select
  10294. GroutingDate,
  10295. GroutingUserID,
  10296. GroutingUserCode,
  10297. GroutingNum,
  10298. GroutingMouldCode,
  10299. MouldCode,
  10300. GroutingDailyID,
  10301. GroutingDailyDetailID,
  10302. GroutingLineID,
  10303. GroutingLineCode,
  10304. GroutingLineName,
  10305. GMouldTypeID,
  10306. CanManyTimes,
  10307. GroutingLineDetailID,
  10308. SpecialRepairflag
  10309. from TP_PM_InProductionTrash where barcode=:barcode
  10310. ";
  10311. OracleParameter[] selectparas = new OracleParameter[] {
  10312. new OracleParameter(":barcode",productionData.Barcode),
  10313. };
  10314. DataSet dsGroutingProduct = oracleTrConn.GetSqlResultToDs(selectSql, selectparas);
  10315. if (dsGroutingProduct == null || dsGroutingProduct.Tables[0].Rows.Count == 0)
  10316. {
  10317. selectSql = @"select TP_PM_GroutingDaily.GroutingDate,
  10318. TP_PM_GroutingDailyDetail.UserID as GroutingUserID,
  10319. TP_PM_GroutingDailyDetail.UserCode as GroutingUserCode,
  10320. TP_PM_GroutingDailyDetail.GroutingCount as GroutingNum,
  10321. TP_PM_GroutingDailyDetail.GroutingMouldCode,
  10322. TP_PM_GroutingDailyDetail.MouldCode,
  10323. TP_PM_GroutingDailyDetail.GroutingDailyID,
  10324. TP_PM_GroutingDailyDetail.GroutingDailyDetailID,
  10325. TP_PM_GroutingDailyDetail.GroutingLineID,
  10326. TP_PM_GroutingDailyDetail.GroutingLineCode,
  10327. TP_PM_GroutingDailyDetail.GroutingLineName,
  10328. TP_PM_GroutingDaily.GMouldTypeID,
  10329. TP_PM_GroutingDaily.CanManyTimes,
  10330. TP_PM_GroutingDailyDetail.GroutingLineDetailID,
  10331. TP_PM_GroutingDailyDetail.SpecialRepairflag
  10332. from TP_PM_GroutingDaily
  10333. left join TP_PM_GroutingDailyDetail
  10334. on TP_PM_GroutingDaily.GroutingDailyID=TP_PM_GroutingDailyDetail.GroutingDailyID
  10335. where TP_PM_GroutingDailyDetail.barcode=:barcode
  10336. ";
  10337. dsGroutingProduct = oracleTrConn.GetSqlResultToDs(selectSql, selectparas);
  10338. }
  10339. DateTime GroutingDate = new DateTime();
  10340. int GroutingUserID = 0, GroutingNum = 0, GroutingDailyID = 0, GroutingDailyDetailID = 0, GroutingLineID = 0, GMouldTypeID = 0, CanManyTimes = 0, GroutingLineDetailID = 0, SpecialRepairflag = 0;
  10341. string GroutingUserCode = "", GroutingMouldCode = "", MouldCode = "", GroutingLineCode = "", GroutingLineName = "";
  10342. if (dsGroutingProduct != null && dsGroutingProduct.Tables[0].Rows.Count > 0)
  10343. {
  10344. GroutingDate = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
  10345. GroutingUserID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingUserID"]);
  10346. GroutingUserCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"].ToString();
  10347. GroutingNum = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"]);
  10348. GroutingMouldCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingMouldCode"].ToString();
  10349. MouldCode = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"].ToString();
  10350. GroutingDailyID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyID"]);
  10351. GroutingDailyDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyDetailID"]);
  10352. GroutingLineID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineID"]);
  10353. GroutingLineCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineCode"].ToString();
  10354. GroutingLineName = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineName"].ToString();
  10355. GMouldTypeID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GMouldTypeID"]);
  10356. CanManyTimes = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["CanManyTimes"]);
  10357. GroutingLineDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineDetailID"]);
  10358. SpecialRepairflag = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["SpecialRepairflag"]);
  10359. returnVal = SpecialRepairflag.ToString();
  10360. }
  10361. #endregion
  10362. #region 更新窑炉窑车属性
  10363. if (productionData.ModelType != 1 && productionData.ModelType != 2 && productionData.ModelType != 3 && productionData.ModelType != 4)
  10364. {
  10365. DataSet ds = GetDryRepairKilnCarInfo(oracleTrConn, productionData.Barcode, sUserInfo);
  10366. if (ds != null)
  10367. {
  10368. if (ds.Tables[0].Rows[0]["KilnID"].ToString() != "") //表示以前有过窑炉相关信息
  10369. {
  10370. productionData.KilnID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnID"]);
  10371. productionData.KilnCode = ds.Tables[0].Rows[0]["KilnCode"].ToString();
  10372. productionData.KilnName = ds.Tables[0].Rows[0]["KilnName"].ToString();
  10373. productionData.KilnCarID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarID"]);
  10374. productionData.KilnCarCode = ds.Tables[0].Rows[0]["KilnCarCode"].ToString();
  10375. productionData.KilnCarName = ds.Tables[0].Rows[0]["KilnCarName"].ToString();
  10376. productionData.KilnCarBatchNo = ds.Tables[0].Rows[0]["KilnCarBatchNo"].ToString();
  10377. productionData.KilnCarPosition = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarPosition"]);
  10378. }
  10379. }
  10380. }
  10381. #endregion
  10382. #region SQL
  10383. string sql = "insert into tp_pm_productiondataIn"
  10384. + " (productiondataid,"
  10385. + " barcode,"
  10386. + " centralizedbatchno,"
  10387. + " productionlineid,"
  10388. + " productionlinecode,"
  10389. + " productionlinename,"
  10390. + " procedureid,"
  10391. + " procedurecode,"
  10392. + " procedurename,"
  10393. + " proceduremodel,"
  10394. + " modeltype,"
  10395. + " piecetype,"
  10396. + " isreworked,"
  10397. + " nodetype,"
  10398. + " ispublicbody,"
  10399. + " isrefire,"
  10400. + " organizationid,"
  10401. + " goodsid,"
  10402. + " goodscode,"
  10403. + " goodsname,"
  10404. + " userid,"
  10405. + " usercode,"
  10406. + " username,"
  10407. + " kilnid,"
  10408. + " kilncode,"
  10409. + " kilnname,"
  10410. + " kilncarid,"
  10411. + " kilncarcode,"
  10412. + " kilncarname,"
  10413. + " kilncarbatchno,"
  10414. + " kilncarposition,"
  10415. + " reworkprocedureid,"
  10416. + " reworkprocedurecode,"
  10417. + " reworkprocedurename,"
  10418. + " remarks,"
  10419. + " accountdate,"
  10420. + " accountid,"
  10421. + " GoodsLevelID,"
  10422. + " GoodsLevelTypeID,"
  10423. + " createuserid,"
  10424. + " updateuserid,"
  10425. + " GroutingDate,"
  10426. + " GroutingUserID,"
  10427. + " GroutingUserCode,"
  10428. + " GroutingNum,"
  10429. + " GroutingMouldCode,"
  10430. + " MouldCode,"
  10431. + "GroutingDailyID,"
  10432. + "GroutingDailyDetailID,"
  10433. + "GroutingLineID,"
  10434. + " GroutingLineCode,"
  10435. + "GroutingLineName,"
  10436. + "GMouldTypeID,"
  10437. + "CanManyTimes,"
  10438. + "GroutingLineDetailID,"
  10439. + "SpecialRepairflag,"
  10440. + "ClassesSettingID,"
  10441. + "LogoID"
  10442. + ")"
  10443. + " values"
  10444. + " (:productiondataid,"
  10445. + " :barcode,"
  10446. + " :centralizedbatchno,"
  10447. + " :productionlineid,"
  10448. + " :productionlinecode,"
  10449. + " :productionlinename,"
  10450. + " :procedureid,"
  10451. + " :procedurecode,"
  10452. + " :procedurename,"
  10453. + " :proceduremodel,"
  10454. + " :modeltype,"
  10455. + " :piecetype,"
  10456. + " :isreworked,"
  10457. + " :nodetype,"
  10458. + " :ispublicbody,"
  10459. + " :isrefire,"
  10460. + " :organizationid,"
  10461. + " :goodsid,"
  10462. + " :goodscode,"
  10463. + " :goodsname,"
  10464. + " :userid,"
  10465. + " :usercode,"
  10466. + " :username,"
  10467. + " :kilnid,"
  10468. + " :kilncode,"
  10469. + " :kilnname,"
  10470. + " :kilncarid,"
  10471. + " :kilncarcode,"
  10472. + " :kilncarname,"
  10473. + " :kilncarbatchno,"
  10474. + " :kilncarposition,"
  10475. + " :reworkprocedureid,"
  10476. + " :reworkprocedurecode,"
  10477. + " :reworkprocedurename,"
  10478. + " :remarks,"
  10479. + " :accountdata,"
  10480. + " :accountid,"
  10481. + " :GoodsLevelID,"
  10482. + " :GoodsLevelTypeID,"
  10483. + " :createuserid,"
  10484. + " :updateuserid,"
  10485. + " :groutingdate,"
  10486. + " :groutinguserid,"
  10487. + " :groutingusercode,"
  10488. + " :groutingnum,"
  10489. + " :groutingmouldcode,"
  10490. + " :mouldcode,"
  10491. + ":groutingdailyid,"
  10492. + ":groutingdailydetailid,"
  10493. + ":groutinglineid,"
  10494. + " :groutinglinecode,"
  10495. + ":groutinglinename,"
  10496. + ":gmouldtypeid,"
  10497. + ":canmanytimes,"
  10498. + ":groutinglinedetailid,"
  10499. + ":specialRepairflag,"
  10500. + ":classesSettingID,"
  10501. + ":logoID"
  10502. + ")";
  10503. #endregion
  10504. #region OracleParameter
  10505. OracleParameter[] paras = new OracleParameter[] {
  10506. new OracleParameter(":productiondataid",productionData.ProductionDataID),
  10507. new OracleParameter(":barcode",productionData.Barcode),
  10508. new OracleParameter(":centralizedbatchno",productionData.CentralizedBatchNo),
  10509. new OracleParameter(":productionlineid",productionData.ProductionLineID),
  10510. new OracleParameter(":productionlinecode",productionData.ProductionLineCode),
  10511. new OracleParameter(":productionlinename",productionData.ProductionLineName),
  10512. new OracleParameter(":procedureid",productionData.CompleteProcedureID),
  10513. new OracleParameter(":procedurecode",productionData.ProcedureCode),
  10514. new OracleParameter(":procedurename",productionData.ProcedureName),
  10515. new OracleParameter(":proceduremodel",productionData.ProcedureModel),
  10516. new OracleParameter(":modeltype",productionData.ModelType),
  10517. new OracleParameter(":piecetype",productionData.PieceType),
  10518. new OracleParameter(":isreworked",productionData.IsReworked),
  10519. new OracleParameter(":nodetype",productionData.NodeType),
  10520. new OracleParameter(":ispublicbody",productionData.IsPublicBody),
  10521. new OracleParameter(":isrefire",productionData.IsReFire),
  10522. new OracleParameter(":organizationid",productionData.OrganizationID),
  10523. new OracleParameter(":goodsid",productionData.GoodsID),
  10524. new OracleParameter(":goodscode",productionData.GoodsCode),
  10525. new OracleParameter(":goodsname",productionData.GoodsName),
  10526. new OracleParameter(":userid",productionData.UserID),
  10527. new OracleParameter(":usercode",productionData.UserCode),
  10528. new OracleParameter(":username",productionData.UserName),
  10529. new OracleParameter(":kilnid",productionData.KilnID),
  10530. new OracleParameter(":kilncode",productionData.KilnCode),
  10531. new OracleParameter(":kilnname",productionData.KilnName),
  10532. new OracleParameter(":kilncarid",productionData.KilnCarID),
  10533. new OracleParameter(":kilncarcode",productionData.KilnCarCode),
  10534. new OracleParameter(":kilncarname",productionData.KilnCarName),
  10535. new OracleParameter(":kilncarbatchno",productionData.KilnCarBatchNo),
  10536. new OracleParameter(":kilncarposition",productionData.KilnCarPosition),
  10537. new OracleParameter(":reworkprocedureid",productionData.ReworkProcedureID),
  10538. new OracleParameter(":reworkprocedurecode",productionData.ReworkProcedureCode),
  10539. new OracleParameter(":reworkprocedurename",productionData.ReworkProcedureName),
  10540. new OracleParameter(":remarks",productionData.Remarks),
  10541. new OracleParameter(":accountdata",accountDate),
  10542. new OracleParameter(":accountid",sUserInfo.AccountID),
  10543. new OracleParameter(":GoodsLevelID",productionData.GoodsLevelID),
  10544. new OracleParameter(":GoodsLevelTypeID",productionData.GoodsLevelTypeID),
  10545. new OracleParameter(":createuserid",sUserInfo.UserID),
  10546. new OracleParameter(":updateuserid",sUserInfo.UserID),
  10547. new OracleParameter(":groutingdate",GroutingDate),
  10548. new OracleParameter(":groutinguserid",GroutingUserID),
  10549. new OracleParameter(":groutingusercode",GroutingUserCode),
  10550. new OracleParameter(":groutingnum",GroutingNum),
  10551. new OracleParameter(":groutingmouldcode",GroutingMouldCode),
  10552. new OracleParameter(":mouldcode",MouldCode),
  10553. new OracleParameter(":groutingdailyid",GroutingDailyID),
  10554. new OracleParameter(":groutingdailydetailid",GroutingDailyDetailID),
  10555. new OracleParameter(":groutinglineid",GroutingLineID),
  10556. new OracleParameter(":groutinglinecode",GroutingLineCode),
  10557. new OracleParameter(":groutinglinename",GroutingLineName),
  10558. new OracleParameter(":gmouldtypeid",GMouldTypeID),
  10559. new OracleParameter(":canmanytimes",CanManyTimes),
  10560. new OracleParameter(":groutinglinedetailid",GroutingLineDetailID),
  10561. new OracleParameter(":specialRepairflag",productionData.SpecialRepairflag),
  10562. new OracleParameter(":classesSettingID",productionData.ClassesSettingID),
  10563. new OracleParameter(":logoID",productionData.LogoID),
  10564. };
  10565. #endregion
  10566. foreach (OracleParameter para in paras)
  10567. {
  10568. if (string.IsNullOrEmpty(para.Value + ""))
  10569. {
  10570. para.Value = DBNull.Value;
  10571. }
  10572. }
  10573. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  10574. OutSpecialRepairflag = returnVal;
  10575. // 失败
  10576. if (result != Constant.INT_IS_ONE)
  10577. {
  10578. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  10579. }
  10580. // 成功返回null
  10581. return null;
  10582. }
  10583. /// <summary>
  10584. /// 根据最大生产数据ID,获取窑车窑炉等信息
  10585. /// </summary>
  10586. /// <param name="oracleTrConn"></param>
  10587. /// <param name="barcode"></param>
  10588. /// <param name="sUserInfo"></param>
  10589. /// <returns></returns>
  10590. private static DataSet GetDryRepairKilnCarInfo(IDBTransaction oracleTrConn, string barcode, SUserInfo sUserInfo)
  10591. {
  10592. // string sql = @"select * from tp_pm_productiondata where Productiondataid=
  10593. // (
  10594. // select nvl(max(Productiondataid),0) Productiondataid from tp_pm_productiondata where barcode=:barcode
  10595. // )";
  10596. string sql = @"select
  10597. KilnID,
  10598. KilnCode,
  10599. KilnName,
  10600. KilnCarID,
  10601. KilnCarCode,
  10602. KilnCarName,
  10603. to_char(KilnCarBatchNo) as KilnCarBatchNo,
  10604. KilnCarPosition
  10605. from tp_pm_inproduction where barcode=:barcode
  10606. union
  10607. select
  10608. KilnID,
  10609. KilnCode,
  10610. KilnName,
  10611. KilnCarID,
  10612. KilnCarCode,
  10613. KilnCarName,
  10614. to_char(KilnCarBatchNo) as KilnCarBatchNo,
  10615. KilnCarPosition
  10616. from TP_PM_InProductionTrash where barcode=:barcode
  10617. ";
  10618. try
  10619. {
  10620. IDataParameter[] paras = new OracleParameter[]
  10621. {
  10622. new OracleParameter(":barcode", OracleDbType.Varchar2, barcode, ParameterDirection.Input),
  10623. };
  10624. DataSet returnDs = oracleTrConn.GetSqlResultToDs(sql, paras);
  10625. if (returnDs != null
  10626. && returnDs.Tables.Count > Constant.INT_IS_ZERO
  10627. && returnDs.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  10628. {
  10629. return returnDs;
  10630. }
  10631. else
  10632. {
  10633. sql = @"select
  10634. KilnID,
  10635. KilnCode,
  10636. KilnName,
  10637. KilnCarID,
  10638. KilnCarCode,
  10639. KilnCarName,
  10640. to_char(KilnCarBatchNo) as KilnCarBatchNo,
  10641. KilnCarPosition
  10642. from TP_PM_FINISHEDPRODUCT where barcode=:barcode";
  10643. returnDs = oracleTrConn.GetSqlResultToDs(sql, paras);
  10644. if (returnDs != null
  10645. && returnDs.Tables.Count > Constant.INT_IS_ZERO
  10646. && returnDs.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  10647. {
  10648. return returnDs;
  10649. }
  10650. else
  10651. {
  10652. return null;
  10653. }
  10654. }
  10655. }
  10656. catch (Exception ex)
  10657. {
  10658. throw ex;
  10659. }
  10660. }
  10661. /// <summary>
  10662. /// 更新漏扫的成型工号
  10663. /// </summary>
  10664. /// <param name="groutingUserCode">成型工号</param>
  10665. /// <param name="missingID">漏扫ID</param>
  10666. /// <param name="sUserInfo">用户基本信息</param>
  10667. /// <returns>int</returns>
  10668. public static int UpdateGroutingUserCodeByMissingID(string groutingUserCode, int missingID, SUserInfo sUserInfo)
  10669. {
  10670. int UpdateRow = 0;
  10671. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  10672. try
  10673. {
  10674. oracleTrConn.Connect();
  10675. //string sql = "select userid from tp_mst_user where usercode=:usercode and valueflag=1 and isworker=1 and accountid=:accountid";
  10676. //OracleParameter[] paras = new OracleParameter[]{
  10677. // new OracleParameter(":usercode",OracleDbType.Varchar2, groutingUserCode,ParameterDirection.Input),
  10678. // new OracleParameter(":accountid", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  10679. //};
  10680. //DataSet returnDataset = oracleTrConn.GetSqlResultToDs(sql, paras);
  10681. //if (returnDataset != null && returnDataset.Tables[0].Rows.Count == 0)
  10682. //{
  10683. // oracleTrConn.Commit();
  10684. // UpdateRow = -1;
  10685. // return UpdateRow;//成型工号无效
  10686. //}
  10687. // 20150605 wangxin begin
  10688. string[] subGroutingUserCode = groutingUserCode.Trim(',').Split(',');
  10689. bool isError = false;
  10690. int FirstUserID = 0;
  10691. string sql = "";
  10692. OracleParameter[] paras = null;
  10693. DataSet returnDataset = null;
  10694. for (int i = 0; i < subGroutingUserCode.Length; i++)
  10695. {
  10696. sql = "select userid from tp_mst_user where usercode=:usercode and valueflag=1 and isworker=1 and accountid=:accountid";
  10697. paras = new OracleParameter[]{
  10698. new OracleParameter(":usercode",OracleDbType.Varchar2, subGroutingUserCode[i],ParameterDirection.Input),
  10699. new OracleParameter(":accountid", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  10700. };
  10701. returnDataset = oracleTrConn.GetSqlResultToDs(sql, paras);
  10702. if (returnDataset != null && returnDataset.Tables[0].Rows.Count == 0)
  10703. {
  10704. isError = true;
  10705. break;
  10706. }
  10707. if (i == 0)
  10708. {
  10709. FirstUserID = Convert.ToInt32(returnDataset.Tables[0].Rows[0]["userid"]);
  10710. }
  10711. }
  10712. if (isError)
  10713. {
  10714. oracleTrConn.Commit();
  10715. UpdateRow = -1;
  10716. return UpdateRow;//成型工号无效
  10717. }
  10718. // 20150605 wangxin end
  10719. sql = "update TP_PM_BarCodeMissing set Missuserid=:Missuserid, Missusercode=:Missusercode where missid=:missid";
  10720. paras = new OracleParameter[]{
  10721. //new OracleParameter(":Missuserid",OracleDbType.Int32,Convert.ToInt32(returnDataset.Tables[0].Rows[0]["userid"]),ParameterDirection.Input),
  10722. new OracleParameter(":Missuserid",OracleDbType.Int32,FirstUserID,ParameterDirection.Input),
  10723. new OracleParameter(":Missusercode", OracleDbType.Varchar2, groutingUserCode.Trim(','), ParameterDirection.Input),
  10724. new OracleParameter(":missid", OracleDbType.Int32, missingID, ParameterDirection.Input),
  10725. };
  10726. UpdateRow = oracleTrConn.ExecuteNonQuery(sql, paras);
  10727. if (UpdateRow > 0)
  10728. {
  10729. oracleTrConn.Commit();
  10730. }
  10731. else
  10732. {
  10733. oracleTrConn.Rollback();
  10734. }
  10735. }
  10736. catch (Exception ex)
  10737. {
  10738. oracleTrConn.Rollback();
  10739. throw ex;
  10740. }
  10741. finally
  10742. {
  10743. // 释放资源
  10744. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  10745. {
  10746. oracleTrConn.Disconnect();
  10747. }
  10748. }
  10749. return UpdateRow;
  10750. }
  10751. /// <summary>
  10752. /// 在入窑工序检验窑车号是否存在
  10753. /// </summary>
  10754. /// <param name="kilncarcode">窑车编码</param>
  10755. /// <param name="procedureid">工序ID</param>
  10756. /// <param name="sUserInfo">用户基本信息</param>
  10757. /// <returns></returns>
  10758. public static int CheckKilnCarByIntoCar(string kilncarcode, int procedureid, SUserInfo sUserInfo)
  10759. {
  10760. int UpdateRow = 0;
  10761. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  10762. try
  10763. {
  10764. oracleTrConn.Connect();
  10765. // 判断窑车编码是否有效
  10766. string sql = "select kilncarid from tp_mst_kilncar where kilncarcode=:kilncarcode and valueflag=1 and accountid=:accountid";
  10767. OracleParameter[] paras = new OracleParameter[]{
  10768. new OracleParameter(":kilncarcode",OracleDbType.Varchar2, kilncarcode,ParameterDirection.Input),
  10769. new OracleParameter(":accountid", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  10770. };
  10771. DataSet dsExists = oracleTrConn.GetSqlResultToDs(sql, paras);
  10772. int kilncarid = 0;
  10773. if (dsExists != null && dsExists.Tables[0].Rows.Count == 0)
  10774. {
  10775. oracleTrConn.Commit();
  10776. UpdateRow = -99;
  10777. return UpdateRow;//窑车编码无效
  10778. }
  10779. kilncarid = Convert.ToInt32(dsExists.Tables[0].Rows[0]["kilncarid"]);//窑车ID
  10780. //判断此窑车号有无产品
  10781. sql = "select barcode,KilnCarBatchNo from TP_PM_KilnCarGoods where KilnCarID=:KilnCarID and accountid=:accountid and valueflag=1";
  10782. paras = new OracleParameter[]{
  10783. new OracleParameter(":KilnCarID",OracleDbType.Int32, kilncarid,ParameterDirection.Input),
  10784. new OracleParameter(":accountid", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  10785. };
  10786. DataSet dsGoods = oracleTrConn.GetSqlResultToDs(sql, paras);
  10787. if (dsGoods != null && dsGoods.Tables[0].Rows.Count == 0)
  10788. {
  10789. oracleTrConn.Commit();
  10790. UpdateRow = -98;
  10791. return UpdateRow;//窑车己无产品
  10792. }
  10793. // 判断窑车编码是否在入窑工序
  10794. sql = "select 1 from TP_PM_InProduction where KilnCarID=:KilnCarID and accountid=:accountid and valueflag=1 and FlowProcedureID=:FlowProcedureID";
  10795. paras = new OracleParameter[]{
  10796. new OracleParameter(":KilnCarID",OracleDbType.Int32, kilncarid,ParameterDirection.Input),
  10797. new OracleParameter(":accountid", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  10798. new OracleParameter(":FlowProcedureID", OracleDbType.Int32, procedureid, ParameterDirection.Input),
  10799. };
  10800. dsExists = oracleTrConn.GetSqlResultToDs(sql, paras);
  10801. if (dsExists != null && dsExists.Tables[0].Rows.Count == 0)
  10802. {
  10803. oracleTrConn.Commit();
  10804. UpdateRow = -97;
  10805. return UpdateRow;//窑车号没有入窑,不可以撤销
  10806. }
  10807. int KilnCarDataID = 0;//窑车生产数据ID
  10808. string KilnCarBatchNo = "";
  10809. // 遍历窑车产品
  10810. bool isError = false;//默认没有错误
  10811. for (int i = 0; i < dsGoods.Tables[0].Rows.Count; i++)
  10812. {
  10813. #region 先查询生产数据最后3条
  10814. string sqlString = @"select ProductionDataID,
  10815. ProcedureID,
  10816. ProcedureModel,
  10817. ModelType,
  10818. ReworkProcedureID,
  10819. UserID
  10820. from (select ProductionDataID,
  10821. ProcedureID,
  10822. ProcedureModel,
  10823. ModelType,
  10824. ReworkProcedureID,
  10825. UserID
  10826. from Tp_Pm_ProductiondataIn
  10827. where barcode = :barcode
  10828. and valueflag = 1 and ModelType<>1 and ModelType<>2
  10829. order by ProductionDataID desc)
  10830. where rownum <=1";//where rownum <=3";
  10831. paras = new OracleParameter[]{
  10832. new OracleParameter(":barcode",OracleDbType.Varchar2, dsGoods.Tables[0].Rows[i]["barcode"].ToString(),ParameterDirection.Input),
  10833. };
  10834. DataSet productionData = oracleTrConn.GetSqlResultToDs(sqlString, paras);
  10835. if (productionData == null
  10836. || productionData.Tables.Count == Constant.INT_IS_ZERO
  10837. || productionData.Tables[0].Rows.Count != Constant.INT_IS_ONE)
  10838. {
  10839. //errMsg = Messages.MSG_PM_W016;
  10840. isError = true;
  10841. break;
  10842. }
  10843. #endregion
  10844. #region 回滚在产数据
  10845. sqlString = @"update TP_PM_InProduction
  10846. set FlowProcedureID = :flowProcedureID,
  10847. ProcedureModel = :procedureModel,
  10848. ProcedureID = :flowProcedureID,
  10849. ModelType = :modelType,
  10850. ReworkProcedureID = :reworkProcedureID,
  10851. UserID = :userID,
  10852. updateuserid = :updateuserid
  10853. where barcode = :barcode";
  10854. paras = new OracleParameter[]{
  10855. new OracleParameter(":flowProcedureID",OracleDbType.Int32,
  10856. productionData.Tables[0].Rows[0]["ProcedureID"],ParameterDirection.Input),//2-->1
  10857. new OracleParameter(":procedureModel",OracleDbType.Int32,
  10858. productionData.Tables[0].Rows[0]["procedureModel"],ParameterDirection.Input),
  10859. new OracleParameter(":modelType",OracleDbType.Int32,
  10860. productionData.Tables[0].Rows[0]["modelType"],ParameterDirection.Input),
  10861. new OracleParameter(":reworkProcedureID",OracleDbType.Int32,
  10862. productionData.Tables[0].Rows[0]["reworkProcedureID"],ParameterDirection.Input),
  10863. new OracleParameter(":userID",OracleDbType.Int32,
  10864. productionData.Tables[0].Rows[0]["userID"],ParameterDirection.Input),
  10865. new OracleParameter(":updateuserid",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input),
  10866. new OracleParameter(":barcode",OracleDbType.Varchar2, dsGoods.Tables[0].Rows[i]["barcode"].ToString(),ParameterDirection.Input),
  10867. };
  10868. UpdateRow = oracleTrConn.ExecuteNonQuery(sqlString, paras);
  10869. if (UpdateRow == Constant.INT_IS_ZERO)
  10870. {
  10871. // 保存失败
  10872. isError = true;
  10873. break;
  10874. }
  10875. #endregion
  10876. #region 删除生产者和最后一条生产数据
  10877. //sqlString = "delete TP_PM_Producer where ProductionDataID=:productionDataID";
  10878. paras = new OracleParameter[]{
  10879. new OracleParameter(":productionDataID",OracleDbType.Int32,
  10880. productionData.Tables[0].Rows[0]["productionDataID"],ParameterDirection.Input),
  10881. //new OracleParameter(":productionDataID2",OracleDbType.Int32,
  10882. // productionData.Tables[0].Rows[0]["productionDataID"],ParameterDirection.Input),
  10883. new OracleParameter(":barcode",OracleDbType.Varchar2,
  10884. dsGoods.Tables[0].Rows[i]["barcode"].ToString(),ParameterDirection.Input),
  10885. };
  10886. //modify 2015/05/13 wangx GoodsLevelTypeID=12 撤销入窑
  10887. sqlString = "select GoodsLevelID,GoodsLevelName,GoodsLevelTypeID from TP_MST_GoodsLevel where GoodsLevelTypeID=12 and AccountID=" + sUserInfo.AccountID + " and ValueFlag=1";
  10888. DataSet dsGoodsLevel = oracleTrConn.GetSqlResultToDs(sqlString, null);
  10889. int? GoodsLevelID = null;
  10890. if (dsGoodsLevel != null && dsGoodsLevel.Tables[0].Rows.Count > 0)
  10891. {
  10892. GoodsLevelID = Convert.ToInt32(dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelID"]);
  10893. }
  10894. //modify end
  10895. sqlString = "update TP_PM_ProductionDataIn set valueflag=0 ,updateuserid=" + sUserInfo.UserID;
  10896. if (GoodsLevelID != null)
  10897. {
  10898. sqlString += ",GoodsLevelID=" + GoodsLevelID;
  10899. sqlString += ",GoodsLevelTypeID=12";
  10900. }
  10901. //sqlString += " where ProductionDataID=:productionDataID or ProductionDataID=:productionDataID2";
  10902. sqlString += " where barcode=:barcode and ProductionDataID>:productionDataID "; //or ProductionDataID=:productionDataID2
  10903. UpdateRow = oracleTrConn.ExecuteNonQuery(sqlString, paras);
  10904. if (UpdateRow == Constant.INT_IS_ZERO)
  10905. {
  10906. // 保存失败
  10907. isError = true;
  10908. break;
  10909. }
  10910. #endregion
  10911. #region 删除窑车产品
  10912. sqlString = "delete TP_PM_KilnCarGoods where BarCode=:barCode";
  10913. paras = new OracleParameter[]{
  10914. new OracleParameter(":barCode",OracleDbType.Varchar2,
  10915. dsGoods.Tables[0].Rows[i]["barcode"],ParameterDirection.Input),
  10916. };
  10917. UpdateRow = oracleTrConn.ExecuteNonQuery(sqlString, paras);
  10918. if (UpdateRow == Constant.INT_IS_ZERO)
  10919. {
  10920. // 保存失败
  10921. isError = true;
  10922. break;
  10923. }
  10924. #endregion
  10925. #region 读取窑车生产数据,进行撤销
  10926. sql = @"select KilnCarDataID, ProductionLineID,ProcedureID,
  10927. ProcedureCode,ProcedureName,ProcedureModel,ModelType,PieceType
  10928. from TP_PM_KilnCarData where KilnCarID=:KilnCarID and accountid=:accountid and valueflag=1 and KilnCarBatchNo=:KilnCarBatchNo order by KilnCarDataID ";
  10929. paras = new OracleParameter[]{
  10930. new OracleParameter(":KilnCarID",OracleDbType.Int32,
  10931. kilncarid,ParameterDirection.Input),
  10932. new OracleParameter(":accountid",OracleDbType.Int32,
  10933. sUserInfo.AccountID,ParameterDirection.Input),
  10934. new OracleParameter(":KilnCarBatchNo",OracleDbType.Varchar2,
  10935. dsGoods.Tables[0].Rows[i]["KilnCarBatchNo"].ToString(),ParameterDirection.Input),
  10936. };
  10937. KilnCarBatchNo = dsGoods.Tables[0].Rows[i]["KilnCarBatchNo"].ToString();
  10938. dsExists = oracleTrConn.GetSqlResultToDs(sql, paras);
  10939. if (dsExists != null && dsExists.Tables[0].Rows.Count > 0)
  10940. {
  10941. //最后窑车生产数据ID赋值 撤二步骤
  10942. KilnCarDataID = Convert.ToInt32(dsExists.Tables[0].Rows[0]["KilnCarDataID"]);
  10943. sqlString = @"update TP_PM_KilnCarStatus set
  10944. ProductionLineID=:ProductionLineID
  10945. ,ProcedureID=:ProcedureID
  10946. ,ProcedureCode=:ProcedureCode
  10947. ,ProcedureName=:ProcedureName
  10948. ,ProcedureModel=:ProcedureModel
  10949. ,ModelType=:ModelType
  10950. ,PieceType=:PieceType
  10951. ,KilnCarStatus=0,LoadingTime=null,IntoKilnTime=null,OutKilnTime=null,UnloadingTime=null
  10952. where KilnCarID=:KilnCarID";
  10953. paras = new OracleParameter[]{
  10954. new OracleParameter(":ProductionLineID",OracleDbType.Int32,
  10955. dsExists.Tables[0].Rows[0]["ProductionLineID"],ParameterDirection.Input),
  10956. new OracleParameter(":ProcedureID",OracleDbType.Int32,
  10957. dsExists.Tables[0].Rows[0]["ProcedureID"],ParameterDirection.Input),
  10958. new OracleParameter(":ProcedureCode",OracleDbType.Varchar2,
  10959. dsExists.Tables[0].Rows[0]["ProcedureCode"].ToString(),ParameterDirection.Input),
  10960. new OracleParameter(":ProcedureModel",OracleDbType.Varchar2,
  10961. dsExists.Tables[0].Rows[0]["ProcedureModel"].ToString(),ParameterDirection.Input),
  10962. new OracleParameter(":ModelType",OracleDbType.Int32,
  10963. Convert.ToInt32(dsExists.Tables[0].Rows[0]["ModelType"]),ParameterDirection.Input),
  10964. new OracleParameter(":PieceType",OracleDbType.Varchar2,
  10965. dsExists.Tables[0].Rows[0]["PieceType"].ToString(),ParameterDirection.Input),
  10966. new OracleParameter(":KilnCarID",OracleDbType.Int32,
  10967. kilncarid,ParameterDirection.Input),
  10968. new OracleParameter(":ProcedureName",OracleDbType.Varchar2,
  10969. dsExists.Tables[0].Rows[0]["ProcedureName"].ToString(),ParameterDirection.Input),
  10970. };
  10971. UpdateRow = oracleTrConn.ExecuteNonQuery(sqlString, paras);
  10972. if (UpdateRow == Constant.INT_IS_ZERO)
  10973. {
  10974. // 保存失败
  10975. isError = true;
  10976. break;
  10977. }
  10978. }
  10979. #endregion
  10980. }
  10981. //modify wangx 20150606 begin
  10982. string updateSql = "update TP_PM_KilnCarData set valueflag=0,UpdateUserID=" + sUserInfo.UserID + " where KilnCarDataID>=" + KilnCarDataID + " and KilnCarBatchNo=" + KilnCarBatchNo;
  10983. int row = oracleTrConn.ExecuteNonQuery(updateSql);
  10984. //modify wangx 20150606 end
  10985. if (isError) //有错误消息
  10986. {
  10987. UpdateRow = -1;//失败
  10988. oracleTrConn.Rollback();
  10989. }
  10990. else
  10991. {
  10992. UpdateRow = 1;//成功
  10993. oracleTrConn.Commit();
  10994. }
  10995. }
  10996. catch (Exception ex)
  10997. {
  10998. oracleTrConn.Rollback();
  10999. throw ex;
  11000. }
  11001. finally
  11002. {
  11003. // 释放资源
  11004. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  11005. {
  11006. oracleTrConn.Disconnect();
  11007. }
  11008. }
  11009. return UpdateRow;
  11010. }
  11011. /// <summary>
  11012. /// 在入窑工序检验窑车号是否存在
  11013. /// </summary>
  11014. /// <param name="kilncarcode">窑车编码</param>
  11015. /// <param name="procedureid">工序ID</param>
  11016. /// <param name="sUserInfo">用户基本信息</param>
  11017. /// <returns></returns>
  11018. public static int CheckKilnCarByIntoCar2(string kilncarcode, int procedureid, SUserInfo sUserInfo)
  11019. {
  11020. int UpdateRow = 0;
  11021. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  11022. try
  11023. {
  11024. oracleTrConn.Connect();
  11025. // 判断窑车编码是否有效
  11026. string sql = "select kilncarid from tp_mst_kilncar where kilncarcode=:kilncarcode and valueflag=1 and accountid=:accountid";
  11027. OracleParameter[] paras = new OracleParameter[]{
  11028. new OracleParameter(":kilncarcode",OracleDbType.Varchar2, kilncarcode,ParameterDirection.Input),
  11029. new OracleParameter(":accountid", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  11030. };
  11031. DataSet dsExists = oracleTrConn.GetSqlResultToDs(sql, paras);
  11032. int kilncarid = 0;
  11033. if (dsExists != null && dsExists.Tables[0].Rows.Count == 0)
  11034. {
  11035. oracleTrConn.Commit();
  11036. UpdateRow = -99;
  11037. return UpdateRow;//窑车编码无效
  11038. }
  11039. kilncarid = Convert.ToInt32(dsExists.Tables[0].Rows[0]["kilncarid"]);//窑车ID
  11040. //判断此窑车号有无产品
  11041. sql = "select barcode,KilnCarBatchNo from TP_PM_KilnCarGoods where KilnCarID=:KilnCarID and accountid=:accountid and valueflag=1";
  11042. paras = new OracleParameter[]{
  11043. new OracleParameter(":KilnCarID",OracleDbType.Int32, kilncarid,ParameterDirection.Input),
  11044. new OracleParameter(":accountid", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  11045. };
  11046. DataSet dsGoods = oracleTrConn.GetSqlResultToDs(sql, paras);
  11047. if (dsGoods != null && dsGoods.Tables[0].Rows.Count == 0)
  11048. {
  11049. oracleTrConn.Commit();
  11050. UpdateRow = -98;
  11051. return UpdateRow;//窑车己无产品
  11052. }
  11053. // 判断窑车编码是否在入窑工序
  11054. sql = "select 1 from TP_PM_InProduction where KilnCarID=:KilnCarID and accountid=:accountid and valueflag=1 and FlowProcedureID=:FlowProcedureID";
  11055. paras = new OracleParameter[]{
  11056. new OracleParameter(":KilnCarID",OracleDbType.Int32, kilncarid,ParameterDirection.Input),
  11057. new OracleParameter(":accountid", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input),
  11058. new OracleParameter(":FlowProcedureID", OracleDbType.Int32, procedureid, ParameterDirection.Input),
  11059. };
  11060. dsExists = oracleTrConn.GetSqlResultToDs(sql, paras);
  11061. if (dsExists != null && dsExists.Tables[0].Rows.Count == 0)
  11062. {
  11063. oracleTrConn.Commit();
  11064. UpdateRow = -97;
  11065. return UpdateRow;//窑车号没有入窑,不可以撤销
  11066. }
  11067. int KilnCarDataID = 0;//窑车生产数据ID
  11068. // 遍历窑车产品
  11069. bool isError = false;//默认没有错误
  11070. for (int i = 0; i < dsGoods.Tables[0].Rows.Count; i++)
  11071. {
  11072. #region 先查询生产数据最后3条
  11073. string sqlString = @"select ProductionDataID,
  11074. ProcedureID,
  11075. ProcedureModel,
  11076. ModelType,
  11077. ReworkProcedureID,
  11078. UserID,
  11079. logoid
  11080. from (select ProductionDataID,
  11081. ProcedureID,
  11082. ProcedureModel,
  11083. ModelType,
  11084. ReworkProcedureID,
  11085. UserID,
  11086. logoid
  11087. from Tp_Pm_ProductiondataIn
  11088. where barcode = :barcode
  11089. and valueflag = 1 and ModelType<>2
  11090. order by ProductionDataID desc)
  11091. where rownum <=1";
  11092. paras = new OracleParameter[]{
  11093. new OracleParameter(":barcode",OracleDbType.Varchar2, dsGoods.Tables[0].Rows[i]["barcode"].ToString(),ParameterDirection.Input),
  11094. };
  11095. DataSet productionData = oracleTrConn.GetSqlResultToDs(sqlString, paras);
  11096. if (productionData == null
  11097. || productionData.Tables.Count == Constant.INT_IS_ZERO
  11098. || productionData.Tables[0].Rows.Count != Constant.INT_IS_ONE)
  11099. {
  11100. //errMsg = Messages.MSG_PM_W016;
  11101. isError = true;
  11102. break;
  11103. }
  11104. #endregion
  11105. #region 回滚在产数据
  11106. sqlString = @"update TP_PM_InProduction
  11107. set FlowProcedureID = :flowProcedureID,
  11108. ProcedureModel = :procedureModel,
  11109. ProcedureID = :flowProcedureID,
  11110. ModelType = :modelType,
  11111. ReworkProcedureID = :reworkProcedureID,
  11112. UserID = :userID,
  11113. updateuserid = :updateuserid,
  11114. logoid = :logoid
  11115. where barcode = :barcode";
  11116. paras = new OracleParameter[]{
  11117. new OracleParameter(":flowProcedureID",OracleDbType.Int32,
  11118. productionData.Tables[0].Rows[0]["ProcedureID"],ParameterDirection.Input),//2-->1
  11119. new OracleParameter(":procedureModel",OracleDbType.Int32,
  11120. productionData.Tables[0].Rows[0]["procedureModel"],ParameterDirection.Input),
  11121. new OracleParameter(":modelType",OracleDbType.Int32,
  11122. productionData.Tables[0].Rows[0]["modelType"],ParameterDirection.Input),
  11123. new OracleParameter(":reworkProcedureID",OracleDbType.Int32,
  11124. productionData.Tables[0].Rows[0]["reworkProcedureID"],ParameterDirection.Input),
  11125. new OracleParameter(":userID",OracleDbType.Int32,
  11126. productionData.Tables[0].Rows[0]["userID"],ParameterDirection.Input),
  11127. new OracleParameter(":updateuserid",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input),
  11128. new OracleParameter(":barcode",OracleDbType.Varchar2, dsGoods.Tables[0].Rows[i]["barcode"].ToString(),ParameterDirection.Input),
  11129. new OracleParameter(":logoid",OracleDbType.Int32, productionData.Tables[0].Rows[0]["logoid"].ToString()==""?null:productionData.Tables[0].Rows[0]["logoid"],ParameterDirection.Input),
  11130. };
  11131. UpdateRow = oracleTrConn.ExecuteNonQuery(sqlString, paras);
  11132. if (UpdateRow == Constant.INT_IS_ZERO)
  11133. {
  11134. // 保存失败
  11135. isError = true;
  11136. break;
  11137. }
  11138. #endregion
  11139. #region 删除生产者和最后一条生产数据
  11140. //sqlString = "delete TP_PM_Producer where ProductionDataID=:productionDataID";
  11141. paras = new OracleParameter[]{
  11142. new OracleParameter(":productionDataID",OracleDbType.Int32,
  11143. productionData.Tables[0].Rows[0]["productionDataID"],ParameterDirection.Input),
  11144. new OracleParameter(":barcode",OracleDbType.Varchar2,
  11145. dsGoods.Tables[0].Rows[i]["barcode"].ToString(),ParameterDirection.Input),
  11146. };
  11147. //modify 2015/05/13 wangx GoodsLevelTypeID=12 撤销入窑
  11148. sqlString = "select GoodsLevelID,GoodsLevelName,GoodsLevelTypeID from TP_MST_GoodsLevel where GoodsLevelTypeID=12 and AccountID=" + sUserInfo.AccountID + " and ValueFlag=1";
  11149. DataSet dsGoodsLevel = oracleTrConn.GetSqlResultToDs(sqlString, null);
  11150. int? GoodsLevelID = null;
  11151. if (dsGoodsLevel != null && dsGoodsLevel.Tables[0].Rows.Count > 0)
  11152. {
  11153. GoodsLevelID = Convert.ToInt32(dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelID"]);
  11154. }
  11155. //modify end
  11156. sqlString = "update TP_PM_ProductionDataIn set valueflag=0,updateuserid= " + sUserInfo.UserID;
  11157. if (GoodsLevelID != null)
  11158. {
  11159. sqlString += ",GoodsLevelID=" + GoodsLevelID;
  11160. sqlString += ",GoodsLevelTypeID=12";
  11161. }
  11162. //sqlString += " where ProductionDataID=:productionDataID or ProductionDataID=:productionDataID2";
  11163. sqlString += " where barcode=:barcode and ProductionDataID>:productionDataID "; //or ProductionDataID=:productionDataID2
  11164. UpdateRow = oracleTrConn.ExecuteNonQuery(sqlString, paras);
  11165. if (UpdateRow == Constant.INT_IS_ZERO)
  11166. {
  11167. // 保存失败
  11168. isError = true;
  11169. break;
  11170. }
  11171. #endregion
  11172. //#region 删除窑车产品
  11173. //sqlString = "delete TP_PM_KilnCarGoods where BarCode=:barCode";
  11174. //paras = new OracleParameter[]{
  11175. // new OracleParameter(":barCode",OracleDbType.Varchar2,
  11176. // dsGoods.Tables[0].Rows[i]["barcode"],ParameterDirection.Input),
  11177. //};
  11178. //UpdateRow = oracleTrConn.ExecuteNonQuery(sqlString, paras);
  11179. //if (UpdateRow == Constant.INT_IS_ZERO)
  11180. //{
  11181. // // 保存失败
  11182. // isError = true;
  11183. // break;
  11184. //}
  11185. //#endregion
  11186. #region 读取窑车生产数据,进行撤销
  11187. sql = @"select KilnCarDataID, ProductionLineID,ProcedureID,
  11188. ProcedureCode,ProcedureName,ProcedureModel,ModelType,PieceType
  11189. from TP_PM_KilnCarData where KilnCarID=:KilnCarID and accountid=:accountid and valueflag=1 and KilnCarBatchNo=:KilnCarBatchNo order by KilnCarDataID ";
  11190. paras = new OracleParameter[]{
  11191. new OracleParameter(":KilnCarID",OracleDbType.Int32,
  11192. kilncarid,ParameterDirection.Input),
  11193. new OracleParameter(":accountid",OracleDbType.Int32,
  11194. sUserInfo.AccountID,ParameterDirection.Input),
  11195. new OracleParameter(":KilnCarBatchNo",OracleDbType.Varchar2,
  11196. dsGoods.Tables[0].Rows[i]["KilnCarBatchNo"].ToString(),ParameterDirection.Input),
  11197. };
  11198. dsExists = oracleTrConn.GetSqlResultToDs(sql, paras);
  11199. if (dsExists != null && dsExists.Tables[0].Rows.Count > 0)
  11200. {
  11201. //最后窑车生产数据ID赋值
  11202. KilnCarDataID = Convert.ToInt32(dsExists.Tables[0].Rows[dsExists.Tables[0].Rows.Count - 1]["KilnCarDataID"]);
  11203. sqlString = @"update TP_PM_KilnCarStatus set
  11204. ProductionLineID=:ProductionLineID
  11205. ,ProcedureID=:ProcedureID
  11206. ,ProcedureCode=:ProcedureCode
  11207. ,ProcedureName=:ProcedureName
  11208. ,ProcedureModel=:ProcedureModel
  11209. ,ModelType=:ModelType
  11210. ,PieceType=:PieceType
  11211. ,KilnCarStatus=0,IntoKilnTime=null,OutKilnTime=null,UnloadingTime=null
  11212. where KilnCarID=:KilnCarID";
  11213. paras = new OracleParameter[]{
  11214. new OracleParameter(":ProductionLineID",OracleDbType.Int32,
  11215. dsExists.Tables[0].Rows[0]["ProductionLineID"],ParameterDirection.Input),
  11216. new OracleParameter(":ProcedureID",OracleDbType.Int32,
  11217. dsExists.Tables[0].Rows[0]["ProcedureID"],ParameterDirection.Input),
  11218. new OracleParameter(":ProcedureCode",OracleDbType.Varchar2,
  11219. dsExists.Tables[0].Rows[0]["ProcedureCode"].ToString(),ParameterDirection.Input),
  11220. new OracleParameter(":ProcedureModel",OracleDbType.Varchar2,
  11221. dsExists.Tables[0].Rows[0]["ProcedureModel"].ToString(),ParameterDirection.Input),
  11222. new OracleParameter(":ModelType",OracleDbType.Int32,
  11223. Convert.ToInt32(dsExists.Tables[0].Rows[0]["ModelType"]),ParameterDirection.Input),
  11224. new OracleParameter(":PieceType",OracleDbType.Varchar2,
  11225. dsExists.Tables[0].Rows[0]["PieceType"].ToString(),ParameterDirection.Input),
  11226. new OracleParameter(":KilnCarID",OracleDbType.Int32,
  11227. kilncarid,ParameterDirection.Input),
  11228. new OracleParameter(":ProcedureName",OracleDbType.Varchar2,
  11229. dsExists.Tables[0].Rows[0]["ProcedureName"].ToString(),ParameterDirection.Input),
  11230. };
  11231. UpdateRow = oracleTrConn.ExecuteNonQuery(sqlString, paras);
  11232. if (UpdateRow == Constant.INT_IS_ZERO)
  11233. {
  11234. // 保存失败
  11235. isError = true;
  11236. break;
  11237. }
  11238. }
  11239. #endregion
  11240. }
  11241. //modify wangx 20150606 begin
  11242. string updateSql = "update TP_PM_KilnCarData set valueflag=0,UpdateUserID=" + sUserInfo.UserID + " where KilnCarDataID=" + KilnCarDataID;
  11243. int row = oracleTrConn.ExecuteNonQuery(updateSql);
  11244. //modify wangx 20150606 end
  11245. if (isError) //有错误消息
  11246. {
  11247. UpdateRow = -1;//失败
  11248. oracleTrConn.Rollback();
  11249. }
  11250. else
  11251. {
  11252. UpdateRow = 1;//成功
  11253. oracleTrConn.Commit();
  11254. }
  11255. }
  11256. catch (Exception ex)
  11257. {
  11258. oracleTrConn.Rollback();
  11259. throw ex;
  11260. }
  11261. finally
  11262. {
  11263. // 释放资源
  11264. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  11265. {
  11266. oracleTrConn.Disconnect();
  11267. }
  11268. }
  11269. return UpdateRow;
  11270. }
  11271. /// <summary>
  11272. /// 保存盘点单
  11273. /// </summary>
  11274. /// <param name="inProductionEntity"></param>
  11275. /// <param name="remarks"></param>
  11276. /// <param name="sUserInfo"></param>
  11277. /// <returns></returns>
  11278. public static int SaveInChecked(InProductionEntity[] inProductionEntity, string remarks, SUserInfo sUserInfo)
  11279. {
  11280. int returnRows = 0;
  11281. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  11282. try
  11283. {
  11284. if (inProductionEntity[0].ReworkProcedureID == 0)
  11285. {
  11286. //盘点单号
  11287. string InCheckedNo = string.Format("IPC{0}", DateTime.Now.ToString("yyyyMMddHHmmss"));
  11288. //获得账务日期
  11289. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  11290. //备注
  11291. string Remarks = remarks;
  11292. oracleTrConn.Connect();
  11293. //盘点单ID
  11294. string sql = "select SEQ_PM_InChecked_ID.nextval from dual";
  11295. int InCheckedID = Convert.ToInt32(oracleTrConn.GetSqlResultToStr(sql));
  11296. #region 插入盘点单主表信息
  11297. sql = @"insert into TP_PM_InChecked
  11298. (
  11299. InCheckedID,
  11300. InCheckedNo,
  11301. AccountDate,
  11302. Remarks,
  11303. AccountID,
  11304. CreateUserID,
  11305. UpdateUserID,
  11306. INCHECKNAME
  11307. ) values
  11308. ( :InCheckedID,
  11309. :InCheckedNo,
  11310. :AccountDate,
  11311. :Remarks,
  11312. :AccountID,
  11313. :CreateUserID,
  11314. :UpdateUserID,
  11315. :INCHECKNAME
  11316. )";
  11317. OracleParameter[] Paras = new OracleParameter[] {
  11318. new OracleParameter(":InCheckedID",OracleDbType.Int32,
  11319. InCheckedID,ParameterDirection.Input),
  11320. new OracleParameter(":InCheckedNo",OracleDbType.NVarchar2,
  11321. InCheckedNo,ParameterDirection.Input),
  11322. new OracleParameter(":AccountDate",OracleDbType.Date,
  11323. accountDate,ParameterDirection.Input),
  11324. new OracleParameter(":Remarks",OracleDbType.NVarchar2,
  11325. Remarks,ParameterDirection.Input),
  11326. new OracleParameter(":AccountID",OracleDbType.Int32,
  11327. sUserInfo.AccountID,ParameterDirection.Input),
  11328. new OracleParameter(":CreateUserID",OracleDbType.Int32,
  11329. sUserInfo.UserID,ParameterDirection.Input),
  11330. new OracleParameter(":UpdateUserID",OracleDbType.Int32,
  11331. sUserInfo.UserID,ParameterDirection.Input),
  11332. new OracleParameter(":INCHECKNAME",OracleDbType.NVarchar2,
  11333. inProductionEntity[0].CompleteProcedureName,ParameterDirection.Input),
  11334. };
  11335. returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  11336. #endregion
  11337. //string barcodes = "";
  11338. List<OracleParameter> parameters = null;
  11339. //int row = 0;
  11340. //foreach (InProductionEntity entity in inProductionEntity)
  11341. //{
  11342. // barcodes += entity.BarCode + ",";
  11343. // row++;
  11344. // if (row > 15) //为了15查数据库一次
  11345. // {
  11346. // barcodes = barcodes.TrimEnd(',') + '|';
  11347. // row = 0;//重置
  11348. // }
  11349. //}
  11350. //barcodes = barcodes.TrimEnd(',');
  11351. //string[] subsplit = barcodes.Split('|');
  11352. // foreach (InProductionEntity entity in inProductionEntity)foreach (InProductionEntity entity in inProductionEntity)
  11353. //foreach (string entity in subsplit)
  11354. //{
  11355. //barcodes += entity.BarCode + ",";
  11356. //barcodes = barcodes.TrimEnd(','); //在产产品是唯一的,直接根据条码查询,并插入到盘点明细
  11357. sql = @"
  11358. insert into TP_PM_InCheckedDetail
  11359. (
  11360. InCheckedID,
  11361. BarCode,
  11362. InCheckedNo,
  11363. ProductionLineID,
  11364. ProductionLineCode,
  11365. ProductionLineName,
  11366. ProcedureID,
  11367. ProcedureTime,
  11368. ProcedureModel,
  11369. ModelType,
  11370. DefectFlag,
  11371. ReworkProcedureID,
  11372. IsPublicBody,
  11373. IsReFire,
  11374. SpecialRepairFlag,
  11375. GoodsLevelID,
  11376. GoodsLevelTypeID,
  11377. GoodsID,
  11378. GoodsCode,
  11379. GoodsName,
  11380. UserID,
  11381. GroutingDailyID,
  11382. GroutingDailyDetailID,
  11383. GroutingDate,
  11384. GroutingLineID,
  11385. GroutingLineCode,
  11386. GroutingLineName,
  11387. GMouldTypeID,
  11388. CanManyTimes,
  11389. GroutingLineDetailID,
  11390. GroutingMouldCode,
  11391. MouldCode,
  11392. GroutingUserID,
  11393. GroutingUserCode,
  11394. GroutingNum,
  11395. Remarks,
  11396. KilnID,
  11397. KilnCode,
  11398. KilnName,
  11399. KilnCarID,
  11400. KilnCarCode,
  11401. KilnCarName,
  11402. KilnCarBatchNo,
  11403. KilnCarPosition,
  11404. AccountID,
  11405. CreateUserID,
  11406. UpdateUserID,
  11407. valueflag,
  11408. logoid,
  11409. ISREWORKFLAG,INSCRAPFLAG
  11410. )
  11411. select
  11412. :InCheckedID,
  11413. inp.BarCode,
  11414. :InCheckedNo,
  11415. inp.ProductionLineID,
  11416. inp.ProductionLineCode,
  11417. inp.ProductionLineName,
  11418. inp.ProcedureID,
  11419. inp.ProcedureTime,
  11420. inp.ProcedureModel,
  11421. inp.ModelType,
  11422. inp.DefectFlag,
  11423. inp.ReworkProcedureID,
  11424. inp.IsPublicBody,
  11425. inp.IsReFire,
  11426. inp.SpecialRepairFlag,
  11427. inp.GoodsLevelID,
  11428. inp.GoodsLevelTypeID,
  11429. inp.GoodsID,
  11430. inp.GoodsCode,
  11431. inp.GoodsName,
  11432. inp.UserID,
  11433. inp.GroutingDailyID,
  11434. inp.GroutingDailyDetailID,
  11435. inp.GroutingDate,
  11436. inp.GroutingLineID,
  11437. inp.GroutingLineCode,
  11438. inp.GroutingLineName,
  11439. inp.GMouldTypeID,
  11440. inp.CanManyTimes,
  11441. inp.GroutingLineDetailID,
  11442. inp.GroutingMouldCode,
  11443. inp.MouldCode,
  11444. inp.GroutingUserID,
  11445. inp.GroutingUserCode,
  11446. inp.GroutingNum,
  11447. inp.Remarks,
  11448. inp.KilnID,
  11449. inp.KilnCode,
  11450. inp.KilnName,
  11451. inp.KilnCarID,
  11452. inp.KilnCarCode,
  11453. inp.KilnCarName,
  11454. inp.KilnCarBatchNo,
  11455. inp.KilnCarPosition,
  11456. :AccountID,
  11457. :CreateUserID,
  11458. :UpdateUserID,
  11459. 1,
  11460. inp.logoid,
  11461. inp.ISREWORKFLAG,inp.INSCRAPFLAG
  11462. from TP_PM_InProduction inp
  11463. LEFT JOIN tp_mst_goods g
  11464. ON g.goodsid = inp.goodsid
  11465. LEFT JOIN tp_mst_goodsType gt
  11466. ON gt.goodstypeid = g.goodstypeid
  11467. where 1=1
  11468. ";
  11469. //sql += "AND instr(','||:ProcedureIDS||',',','||TP_PM_InProduction.ProcedureID||',')>0 ";
  11470. parameters = new List<OracleParameter>();
  11471. // 工序IDS
  11472. if (!string.IsNullOrEmpty(inProductionEntity[0].ProcedureIDS))
  11473. {
  11474. sql += "AND instr(','||:ProcedureIDS||',',','||inp.FlowProcedureID||',')>0 ";
  11475. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, inProductionEntity[0].ProcedureIDS, ParameterDirection.Input));
  11476. }
  11477. // 完成日期
  11478. if (inProductionEntity[0].StartCompleteDate != null)
  11479. {
  11480. sql = sql + " AND inp.ProcedureTime >= :Createdate AND inp.ProcedureTime <= :EndDate ";
  11481. parameters.Add(new OracleParameter(":Createdate", OracleDbType.Date, inProductionEntity[0].StartCompleteDate, ParameterDirection.Input));
  11482. parameters.Add(new OracleParameter(":EndDate", OracleDbType.Date, inProductionEntity[0].EndCompleteDate, ParameterDirection.Input));
  11483. }
  11484. // 编码IDS
  11485. if (!string.IsNullOrEmpty(inProductionEntity[0].GoodsCodeList))
  11486. {
  11487. sql += "AND instr(','||:GoodsIDS||',',','||inp.GoodsID||',')>0 ";
  11488. parameters.Add(new OracleParameter(":GoodsIDS", OracleDbType.NVarchar2, inProductionEntity[0].GoodsCodeList, ParameterDirection.Input));
  11489. }
  11490. // 产品类型
  11491. if (!string.IsNullOrEmpty(inProductionEntity[0].GoodsTypeCode))
  11492. {
  11493. sql += "AND instr(gt.goodstypecode, :GoodsTypeCode)=1 ";
  11494. parameters.Add(new OracleParameter(":GoodsTypeCode", OracleDbType.NVarchar2, inProductionEntity[0].GoodsTypeCode, ParameterDirection.Input));
  11495. }
  11496. parameters.Add(new OracleParameter(":InCheckedID", OracleDbType.Int32, InCheckedID, ParameterDirection.Input));
  11497. parameters.Add(new OracleParameter(":InCheckedNo", OracleDbType.Varchar2, InCheckedNo, ParameterDirection.Input));
  11498. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input));
  11499. parameters.Add(new OracleParameter(":CreateUserID", OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input));
  11500. parameters.Add(new OracleParameter(":UpdateUserID", OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input));
  11501. returnRows += oracleTrConn.ExecuteNonQuery(sql, parameters.ToArray());
  11502. #region 插入盘点工号列表
  11503. foreach (DataRow r in inProductionEntity[0].UserTable.Rows)
  11504. {
  11505. if (r["userid"] != DBNull.Value)
  11506. {
  11507. sql = @" Insert into tp_pm_incheckeduser
  11508. (
  11509. incheckedid,
  11510. userCode,
  11511. userid
  11512. )
  11513. values
  11514. (
  11515. :inchecked,
  11516. :userCode,
  11517. :userid
  11518. )
  11519. ";
  11520. Paras = new OracleParameter[] {
  11521. new OracleParameter(":inchecked",OracleDbType.Int32,
  11522. InCheckedID,ParameterDirection.Input),
  11523. new OracleParameter(":userCode",OracleDbType.NVarchar2,
  11524. r["userCode"],ParameterDirection.Input),
  11525. new OracleParameter(":userid",OracleDbType.Int32,
  11526. r["userid"],ParameterDirection.Input),
  11527. };
  11528. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  11529. }
  11530. }
  11531. #endregion
  11532. }
  11533. else
  11534. {
  11535. string sql = @"Update TP_PM_InChecked set Incheckname=:Incheckname,Remarks=:Remarks,updateuserid=:updateuserid where InCheckedID=:InCheckedID";
  11536. OracleParameter[] Paras = new OracleParameter[] {
  11537. new OracleParameter(":InCheckedID",OracleDbType.Int32,
  11538. inProductionEntity[0].ReworkProcedureID,ParameterDirection.Input),
  11539. new OracleParameter(":Incheckname",OracleDbType.NVarchar2,
  11540. inProductionEntity[0].CompleteProcedureName,ParameterDirection.Input),
  11541. new OracleParameter(":Remarks",OracleDbType.NVarchar2,
  11542. remarks,ParameterDirection.Input),
  11543. new OracleParameter(":updateuserid",OracleDbType.Int32,
  11544. sUserInfo.UserID,ParameterDirection.Input),
  11545. };
  11546. returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  11547. sql = @"delete from tp_pm_incheckeduser where InCheckedID=:InCheckedID";
  11548. Paras = new OracleParameter[] {
  11549. new OracleParameter(":InCheckedID",OracleDbType.Int32,
  11550. inProductionEntity[0].ReworkProcedureID,ParameterDirection.Input),
  11551. };
  11552. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  11553. #region 插入盘点工号列表
  11554. foreach (DataRow r in inProductionEntity[0].UserTable.Rows)
  11555. {
  11556. if (string.IsNullOrEmpty(r["userCode"].ToString()) ||
  11557. string.IsNullOrEmpty(r["userid"].ToString()))
  11558. {
  11559. continue;
  11560. }
  11561. sql = @" Insert into tp_pm_incheckeduser
  11562. (
  11563. incheckedid,
  11564. userCode,
  11565. userid
  11566. )
  11567. values
  11568. (
  11569. :inchecked,
  11570. :userCode,
  11571. :userid
  11572. )
  11573. ";
  11574. Paras = new OracleParameter[] {
  11575. new OracleParameter(":inchecked",OracleDbType.Int32,
  11576. inProductionEntity[0].ReworkProcedureID,ParameterDirection.Input),
  11577. new OracleParameter(":userCode",OracleDbType.NVarchar2,
  11578. r["userCode"],ParameterDirection.Input),
  11579. new OracleParameter(":userid",OracleDbType.Int32,
  11580. r["userid"],ParameterDirection.Input),
  11581. };
  11582. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  11583. }
  11584. #endregion
  11585. }
  11586. if (returnRows == 0)
  11587. {
  11588. oracleTrConn.Rollback();
  11589. oracleTrConn.Disconnect();
  11590. }
  11591. else
  11592. {
  11593. oracleTrConn.Commit();
  11594. oracleTrConn.Disconnect();
  11595. }
  11596. }
  11597. catch (Exception ex)
  11598. {
  11599. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  11600. {
  11601. oracleTrConn.Rollback();
  11602. oracleTrConn.Disconnect();
  11603. }
  11604. throw ex;
  11605. }
  11606. finally
  11607. {
  11608. if (oracleTrConn.ConnState == ConnectionState.Open)
  11609. {
  11610. oracleTrConn.Disconnect();
  11611. }
  11612. }
  11613. return returnRows;
  11614. }
  11615. /// <summary>
  11616. /// 更新盘点单
  11617. /// </summary>
  11618. /// <param name="InCheckedID">盘点单号</param>
  11619. /// <param name="BarCode">产品条码</param>
  11620. /// <param name="sUserInfo">用户基本信息</param>
  11621. /// <returns></returns>
  11622. public static int UpdateInChecked(int InCheckedID, string BarCode, SUserInfo sUserInfo)
  11623. {
  11624. int returnRows = 0;
  11625. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  11626. try
  11627. {
  11628. // 转换条码
  11629. string sqlString = @"select FUN_CMN_GetBarCode(:barcode,null,:accountid) From DUAL";
  11630. OracleParameter[] paras1 = new OracleParameter[]{
  11631. new OracleParameter(":barcode",OracleDbType.Varchar2, BarCode,ParameterDirection.Input),
  11632. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID,ParameterDirection.Input),
  11633. };
  11634. BarCode = oracleTrConn.GetSqlResultToStr(sqlString, paras1);
  11635. string sql = @"select 1 from TP_PM_InProduction where barcode=:barcode";
  11636. OracleParameter[] Paras = new OracleParameter[] {
  11637. new OracleParameter(":barcode",OracleDbType.NVarchar2,
  11638. BarCode,ParameterDirection.Input)
  11639. };
  11640. DataSet ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  11641. if (ds != null && ds.Tables[0].Rows.Count == 0)
  11642. {
  11643. returnRows = -2;//该产品不在生产线
  11644. return returnRows;
  11645. }
  11646. sql = @"select InCheckedFlag,CHECKEDUSERID as Userid from TP_PM_InCheckedDetail where InCheckedID=:InCheckedID and BarCode=:BarCode and Valueflag=1";
  11647. Paras = new OracleParameter[] {
  11648. new OracleParameter(":InCheckedID",OracleDbType.Int32,
  11649. InCheckedID,ParameterDirection.Input),
  11650. new OracleParameter(":BarCode",OracleDbType.NVarchar2,
  11651. BarCode,ParameterDirection.Input)
  11652. };
  11653. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  11654. if (ds != null && ds.Tables[0].Rows.Count == 0)
  11655. {
  11656. sql = @"select InCheckedNo from TP_PM_InChecked where InCheckedID=:InCheckedID";
  11657. Paras = new OracleParameter[] {
  11658. new OracleParameter(":InCheckedID",OracleDbType.Int32,
  11659. InCheckedID,ParameterDirection.Input),
  11660. };
  11661. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  11662. string InCheckedNo = ds.Tables[0].Rows[0]["InCheckedNo"].ToString();//肯定会有盘点单号,所以就没有加判断
  11663. //在产不在生产线上,属于盘赢
  11664. sql = @"
  11665. insert into TP_PM_InCheckedDetail
  11666. (
  11667. InCheckedID,
  11668. BarCode,
  11669. InCheckedNo,
  11670. ProductionLineID,
  11671. ProductionLineCode,
  11672. ProductionLineName,
  11673. ProcedureID,
  11674. ProcedureTime,
  11675. ProcedureModel,
  11676. ModelType,
  11677. DefectFlag,
  11678. ReworkProcedureID,
  11679. IsPublicBody,
  11680. IsReFire,
  11681. SpecialRepairFlag,
  11682. GoodsLevelID,
  11683. GoodsLevelTypeID,
  11684. GoodsID,
  11685. GoodsCode,
  11686. GoodsName,
  11687. UserID,
  11688. GroutingDailyID,
  11689. GroutingDailyDetailID,
  11690. GroutingDate,
  11691. GroutingLineID,
  11692. GroutingLineCode,
  11693. GroutingLineName,
  11694. GMouldTypeID,
  11695. CanManyTimes,
  11696. GroutingLineDetailID,
  11697. GroutingMouldCode,
  11698. MouldCode,
  11699. GroutingUserID,
  11700. GroutingUserCode,
  11701. GroutingNum,
  11702. Remarks,
  11703. KilnID,
  11704. KilnCode,
  11705. KilnName,
  11706. KilnCarID,
  11707. KilnCarCode,
  11708. KilnCarName,
  11709. KilnCarBatchNo,
  11710. KilnCarPosition,
  11711. AccountID,
  11712. CreateUserID,
  11713. UpdateUserID,
  11714. InCheckedFlag,
  11715. CheckedDate,
  11716. CheckedUserID,
  11717. logoid
  11718. )
  11719. select
  11720. :InCheckedID,
  11721. BarCode,
  11722. :InCheckedNo,
  11723. ProductionLineID,
  11724. ProductionLineCode,
  11725. ProductionLineName,
  11726. ProcedureID,
  11727. ProcedureTime,
  11728. ProcedureModel,
  11729. ModelType,
  11730. DefectFlag,
  11731. ReworkProcedureID,
  11732. IsPublicBody,
  11733. IsReFire,
  11734. SpecialRepairFlag,
  11735. GoodsLevelID,
  11736. GoodsLevelTypeID,
  11737. GoodsID,
  11738. GoodsCode,
  11739. GoodsName,
  11740. UserID,
  11741. GroutingDailyID,
  11742. GroutingDailyDetailID,
  11743. GroutingDate,
  11744. GroutingLineID,
  11745. GroutingLineCode,
  11746. GroutingLineName,
  11747. GMouldTypeID,
  11748. CanManyTimes,
  11749. GroutingLineDetailID,
  11750. GroutingMouldCode,
  11751. MouldCode,
  11752. GroutingUserID,
  11753. GroutingUserCode,
  11754. GroutingNum,
  11755. Remarks,
  11756. KilnID,
  11757. KilnCode,
  11758. KilnName,
  11759. KilnCarID,
  11760. KilnCarCode,
  11761. KilnCarName,
  11762. KilnCarBatchNo,
  11763. KilnCarPosition,
  11764. :AccountID,
  11765. :CreateUserID,
  11766. :UpdateUserID,
  11767. :InCheckedFlag,
  11768. sysdate,
  11769. :CheckedUserID,
  11770. logoid
  11771. from TP_PM_InProduction where 1=1
  11772. ";
  11773. ;
  11774. List<OracleParameter> parameters = new List<OracleParameter>();
  11775. sql += "AND instr(','||:barcode||',',','||TP_PM_InProduction.barcode||',')>0 ";
  11776. parameters.Add(new OracleParameter(":InCheckedID", OracleDbType.Int32, InCheckedID, ParameterDirection.Input));
  11777. parameters.Add(new OracleParameter(":InCheckedNo", OracleDbType.Varchar2, InCheckedNo, ParameterDirection.Input));
  11778. parameters.Add(new OracleParameter(":barcode", OracleDbType.NVarchar2, BarCode, ParameterDirection.Input));
  11779. parameters.Add(new OracleParameter(":AccountID", OracleDbType.Int32, sUserInfo.AccountID, ParameterDirection.Input));
  11780. parameters.Add(new OracleParameter(":CreateUserID", OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input));
  11781. parameters.Add(new OracleParameter(":UpdateUserID", OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input));
  11782. parameters.Add(new OracleParameter(":InCheckedFlag", OracleDbType.Int32, Constant.InCheckedFlag.InCheckedWin.GetHashCode(), ParameterDirection.Input));
  11783. parameters.Add(new OracleParameter(":CheckedUserID", OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input));
  11784. returnRows += oracleTrConn.ExecuteNonQuery(sql, parameters.ToArray());
  11785. returnRows = 10;
  11786. }
  11787. else
  11788. {
  11789. int InCheckedFlag = Convert.ToInt32(ds.Tables[0].Rows[0]["InCheckedFlag"]);
  11790. if (InCheckedFlag == 1)
  11791. {
  11792. if (Convert.ToInt32(ds.Tables[0].Rows[0]["Userid"]) != sUserInfo.UserID)
  11793. {
  11794. returnRows = -22;//己被其他工号盘点
  11795. }
  11796. else
  11797. {
  11798. returnRows = -24;//己被自己工号盘点
  11799. }
  11800. return returnRows;
  11801. }
  11802. else if (InCheckedFlag == 2)
  11803. {
  11804. if (Convert.ToInt32(ds.Tables[0].Rows[0]["Userid"]) != sUserInfo.UserID)
  11805. {
  11806. returnRows = -23;//己被其他工号盘盈
  11807. }
  11808. else
  11809. {
  11810. returnRows = -25;//己被自己工号盘盈
  11811. }
  11812. return returnRows;
  11813. }
  11814. sql = "update TP_PM_InCheckedDetail set InCheckedFlag=:InCheckedFlag,CheckedDate=sysdate,CheckedUserID=:CheckedUserID,UpdateUserID=:UpdateUserID where InCheckedID=:InCheckedID and BarCode=:BarCode and InCheckedFlag=:whereInCheckedFlag";
  11815. Paras = new OracleParameter[] {
  11816. new OracleParameter(":CheckedUserID",OracleDbType.Int32,
  11817. sUserInfo.UserID,ParameterDirection.Input),
  11818. new OracleParameter(":InCheckedFlag",OracleDbType.Int32,
  11819. Constant.InCheckedFlag.InCheckeded,ParameterDirection.Input),
  11820. new OracleParameter(":InCheckedID",OracleDbType.Int32,
  11821. InCheckedID,ParameterDirection.Input),
  11822. new OracleParameter(":BarCode",OracleDbType.NVarchar2,
  11823. BarCode,ParameterDirection.Input),
  11824. new OracleParameter(":whereInCheckedFlag",OracleDbType.Int32,
  11825. Constant.InCheckedFlag.InCheckedNo,ParameterDirection.Input),
  11826. new OracleParameter(":UpdateUserID",OracleDbType.Int32,
  11827. sUserInfo.UserID,ParameterDirection.Input),
  11828. };
  11829. returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  11830. returnRows = 1;//防止多次盘点此条码,下面在回滚回来,代码是有作用
  11831. }
  11832. if (returnRows == 0)
  11833. {
  11834. oracleTrConn.Rollback();
  11835. oracleTrConn.Disconnect();
  11836. }
  11837. else
  11838. {
  11839. oracleTrConn.Commit();
  11840. oracleTrConn.Disconnect();
  11841. }
  11842. }
  11843. catch (Exception ex)
  11844. {
  11845. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  11846. {
  11847. oracleTrConn.Rollback();
  11848. oracleTrConn.Disconnect();
  11849. }
  11850. throw ex;
  11851. }
  11852. finally
  11853. {
  11854. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  11855. {
  11856. oracleTrConn.Disconnect();
  11857. }
  11858. }
  11859. return returnRows;
  11860. }
  11861. /// <summary>
  11862. /// 停用盘点单
  11863. /// </summary>
  11864. /// <param name="InCheckedID">盘点单号</param>
  11865. /// <returns></returns>
  11866. public static int DisableInChecked(int InCheckedID, SUserInfo sUserInfo)
  11867. {
  11868. int returnRows = 0;
  11869. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  11870. try
  11871. {
  11872. string sql = "update TP_PM_InChecked set valueflag='0', updateuserid=:updateuserid where InCheckedID=:InCheckedID and valueflag='1'";
  11873. OracleParameter[] Paras = new OracleParameter[] {
  11874. new OracleParameter(":InCheckedID",OracleDbType.Int32,
  11875. InCheckedID,ParameterDirection.Input),
  11876. new OracleParameter(":updateuserid",OracleDbType.Int32,
  11877. sUserInfo.UserID,ParameterDirection.Input)
  11878. };
  11879. returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  11880. if (returnRows == 0)
  11881. {
  11882. oracleTrConn.Rollback();
  11883. oracleTrConn.Disconnect();
  11884. }
  11885. else
  11886. {
  11887. oracleTrConn.Commit();
  11888. oracleTrConn.Disconnect();
  11889. }
  11890. }
  11891. catch (Exception ex)
  11892. {
  11893. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  11894. {
  11895. oracleTrConn.Rollback();
  11896. oracleTrConn.Disconnect();
  11897. }
  11898. throw ex;
  11899. }
  11900. finally
  11901. {
  11902. if (oracleTrConn.ConnState == ConnectionState.Open)
  11903. {
  11904. oracleTrConn.Disconnect();
  11905. }
  11906. }
  11907. return returnRows;
  11908. }
  11909. /// <summary>
  11910. /// 撤销包装
  11911. /// </summary>
  11912. /// <param name="barcode">产品条码</param>
  11913. /// <returns></returns>
  11914. public static ServiceResultEntity AddChancelFinishedproduct(string barcode, SUserInfo sUserInfo)
  11915. {
  11916. ServiceResultEntity entity = new ServiceResultEntity();
  11917. int returnRows = 0;
  11918. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  11919. try
  11920. {
  11921. //xuwei add 2019-10-15 修正 撤销包装时 副品变正品
  11922. int goodsLevelID;
  11923. int goodsLevelTypeID;
  11924. //xuwei end
  11925. // 转换注浆条码
  11926. barcode = CommonModuleLogic.CommonModuleLogic.GetBarcode(oracleTrConn, barcode, sUserInfo);
  11927. DateTime? createTime = null;
  11928. // 1 条码是否在产成品表中
  11929. string sql = "select createTime,FHUserCode,GoodsCode,GoodsLevelID,GoodsLevelTypeID from tp_pm_finishedproduct where barcode=:barcode and valueflag=1";
  11930. OracleParameter[] Paras = new OracleParameter[] {
  11931. new OracleParameter(":barcode",OracleDbType.Varchar2,
  11932. barcode,ParameterDirection.Input)
  11933. };
  11934. DataSet ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  11935. if (ds.Tables[0].Rows.Count == 0)
  11936. {
  11937. //不存在产成品
  11938. returnRows = -1;
  11939. oracleTrConn.Rollback();
  11940. oracleTrConn.Disconnect();
  11941. entity.Result = returnRows;
  11942. return entity;
  11943. }
  11944. else
  11945. {
  11946. //wangx 2017-02-10 已经交接不允许撤销
  11947. if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["FHUserCode"].ToString()))
  11948. {
  11949. entity.Result = -200; //已交接,不能再次进行交接
  11950. entity.Message = "此产品【" + ds.Tables[0].Rows[0]["GoodsCode"].ToString() + "】已交接,不能进行该操作";
  11951. oracleTrConn.Rollback();
  11952. oracleTrConn.Disconnect();
  11953. return entity;
  11954. }
  11955. //wangx 2017-02-10 end
  11956. createTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["createTime"]); // 成品时间
  11957. //xuwei add 2019-10-15 修正 撤销包装时 副品变正品
  11958. goodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]);
  11959. goodsLevelTypeID = Convert.ToInt32(ds.Tables[0].Rows[0]["goodsLevelTypeID"]);
  11960. //xuwei end
  11961. }
  11962. #region 是否启用成品撤销限制天数
  11963. if (createTime != null)
  11964. {
  11965. sql = "select settingvalue from TP_MST_SystemSetting where settingcode=:settingcode and accountid=:accountid";
  11966. Paras = new OracleParameter[] {
  11967. new OracleParameter(":settingcode",OracleDbType.Varchar2,
  11968. Constant.SettingType.S_PM_005.ToString(),ParameterDirection.Input),
  11969. new OracleParameter(":accountid",OracleDbType.Int32,
  11970. sUserInfo.AccountID,ParameterDirection.Input)
  11971. };
  11972. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  11973. if (ds != null && ds.Tables[0].Rows.Count > 0)
  11974. {
  11975. if (Convert.ToInt32(ds.Tables[0].Rows[0]["settingvalue"]) > 0)
  11976. {
  11977. // 开启了限制
  11978. ServiceResultEntity resultEntity = PMModuleLogic.BarcodeAllowCancel(Convert.ToDateTime(createTime),
  11979. Convert.ToInt32(ds.Tables[0].Rows[0]["settingvalue"]), Constant.SettingType.S_PM_005.ToString(), sUserInfo);
  11980. if (Convert.ToInt32(resultEntity.Result) < 0)
  11981. {
  11982. //超过成品撤销限制天数
  11983. returnRows = -200;
  11984. oracleTrConn.Rollback();
  11985. oracleTrConn.Disconnect();
  11986. entity.Result = returnRows;
  11987. entity.Message = resultEntity.Message;
  11988. return entity;
  11989. }
  11990. }
  11991. }
  11992. }
  11993. #endregion
  11994. sql = "select 1 from tp_pm_productiondatain where barcode=:barcode and valueflag=1";
  11995. Paras = new OracleParameter[] {
  11996. new OracleParameter(":barcode",OracleDbType.Varchar2,
  11997. barcode,ParameterDirection.Input)
  11998. };
  11999. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  12000. if (ds.Tables[0].Rows.Count == 0)
  12001. {
  12002. // 2 生产数据恢复到在产生产数据 xuwei 不用处理
  12003. sql = @"insert into tp_pm_productiondatain
  12004. (
  12005. ProductionDataID,
  12006. BarCode,
  12007. CentralizedBatchNo,
  12008. ProductionLineID,
  12009. ProductionLineCode,
  12010. ProductionLineName,
  12011. ProcedureID,
  12012. ProcedureCode,
  12013. ProcedureName,
  12014. ProcedureModel,
  12015. ModelType,
  12016. PieceType,
  12017. IsReworked,
  12018. NodeType,
  12019. IsPublicBody,
  12020. IsReFire,
  12021. GoodsLevelID,
  12022. GoodsLevelTypeID,
  12023. SpecialRepairFlag,
  12024. OrganizationID,
  12025. GoodsID,
  12026. GoodsCode,
  12027. GoodsName,
  12028. UserID,
  12029. UserCode,
  12030. UserName,
  12031. ClassesSettingID,
  12032. KilnID,
  12033. KilnCode,
  12034. KilnName,
  12035. KilnCarID,
  12036. KilnCarCode,
  12037. KilnCarName,
  12038. KilnCarBatchNo,
  12039. KilnCarPosition,
  12040. ReworkProcedureID,
  12041. ReworkProcedureCode,
  12042. ReworkProcedureName,
  12043. GroutingDailyID,
  12044. GroutingDailyDetailID,
  12045. GroutingLineID,
  12046. GroutingLineCode,
  12047. GroutingLineName,
  12048. GMouldTypeID,
  12049. CanManyTimes,
  12050. GroutingLineDetailID,
  12051. GroutingDate,
  12052. GroutingMouldCode,
  12053. MouldCode,
  12054. GroutingUserID,
  12055. GroutingUserCode,
  12056. GroutingNum,
  12057. Remarks,
  12058. AccountDate,
  12059. SettlementFlag,
  12060. AccountID,
  12061. ValueFlag,
  12062. CreateTime,
  12063. CreateUserID,
  12064. UpdateTime,
  12065. UpdateUserID,
  12066. OPTimeStamp,
  12067. TriggerFlag,
  12068. LogoID,
  12069. BackOutTime,BackOutUserID,BackOutUserCode,CheckTime
  12070. )
  12071. select
  12072. ProductionDataID,
  12073. BarCode,
  12074. CentralizedBatchNo,
  12075. ProductionLineID,
  12076. ProductionLineCode,
  12077. ProductionLineName,
  12078. ProcedureID,
  12079. ProcedureCode,
  12080. ProcedureName,
  12081. ProcedureModel,
  12082. ModelType,
  12083. PieceType,
  12084. IsReworked,
  12085. NodeType,
  12086. IsPublicBody,
  12087. IsReFire,
  12088. GoodsLevelID,
  12089. GoodsLevelTypeID,
  12090. SpecialRepairFlag,
  12091. OrganizationID,
  12092. GoodsID,
  12093. GoodsCode,
  12094. GoodsName,
  12095. UserID,
  12096. UserCode,
  12097. UserName,
  12098. ClassesSettingID,
  12099. KilnID,
  12100. KilnCode,
  12101. KilnName,
  12102. KilnCarID,
  12103. KilnCarCode,
  12104. KilnCarName,
  12105. KilnCarBatchNo,
  12106. KilnCarPosition,
  12107. ReworkProcedureID,
  12108. ReworkProcedureCode,
  12109. ReworkProcedureName,
  12110. GroutingDailyID,
  12111. GroutingDailyDetailID,
  12112. GroutingLineID,
  12113. GroutingLineCode,
  12114. GroutingLineName,
  12115. GMouldTypeID,
  12116. CanManyTimes,
  12117. GroutingLineDetailID,
  12118. GroutingDate,
  12119. GroutingMouldCode,
  12120. MouldCode,
  12121. GroutingUserID,
  12122. GroutingUserCode,
  12123. GroutingNum,
  12124. Remarks,
  12125. AccountDate,
  12126. SettlementFlag,
  12127. AccountID,
  12128. ValueFlag,
  12129. CreateTime,
  12130. CreateUserID,
  12131. UpdateTime,
  12132. UpdateUserID,
  12133. OPTimeStamp,
  12134. 1,
  12135. LogoID,
  12136. BackOutTime,BackOutUserID,BackOutUserCode,CheckTime
  12137. from TP_PM_ProductionData where valueflag=1 and barcode=:barcode
  12138. ";
  12139. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  12140. }
  12141. // 3 停用在产生产数据包装数据
  12142. sql = "update TP_PM_ProductionDataIn set valueflag=0,updateuserID=" + sUserInfo.UserID
  12143. + " where ProductionDataID=(select max(ProductionDataID) from TP_PM_ProductionDataIn where barcode=:barcode and valueflag=1)";
  12144. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  12145. // 4 插入在产数据
  12146. //xuwei fix 2019-10-15 修正 撤销包装时 副品变正品
  12147. sql = $@"insert into TP_PM_InProduction
  12148. (
  12149. BarCode,
  12150. ProductionLineID,
  12151. ProductionLineCode,
  12152. ProductionLineName,
  12153. FlowProcedureID,
  12154. FlowProcedureTime,
  12155. ProcedureID,
  12156. ProcedureTime,
  12157. ProductionDataID,
  12158. ProcedureModel,
  12159. ModelType,
  12160. DefectFlag,
  12161. ReworkProcedureID,
  12162. IsPublicBody,
  12163. IsReFire,
  12164. SpecialRepairFlag,
  12165. GoodsLevelID,
  12166. 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. )
  12203. select
  12204. BarCode,
  12205. ProductionLineID,
  12206. ProductionLineCode,
  12207. ProductionLineName,
  12208. ProcedureID,
  12209. CreateTime,
  12210. ProcedureID,
  12211. CreateTime,
  12212. ProductionDataID,
  12213. ProcedureModel,
  12214. ModelType,
  12215. 0,
  12216. ReworkProcedureID,
  12217. IsPublicBody,
  12218. IsReFire,
  12219. SpecialRepairFlag,
  12220. {goodsLevelID} AS GoodsLevelID,
  12221. {goodsLevelTypeID} AS GoodsLevelTypeID,
  12222. GoodsID,
  12223. GoodsCode,
  12224. GoodsName,
  12225. UserID,
  12226. GroutingDailyID,
  12227. GroutingDailyDetailID,
  12228. GroutingDate,
  12229. GroutingLineID,
  12230. GroutingLineCode,
  12231. GroutingLineName,
  12232. GMouldTypeID,
  12233. CanManyTimes,
  12234. GroutingLineDetailID,
  12235. GroutingMouldCode,
  12236. MouldCode,
  12237. GroutingUserID,
  12238. GroutingUserCode,
  12239. GroutingNum,
  12240. Remarks,
  12241. KilnID,
  12242. KilnCode,
  12243. KilnName,
  12244. KilnCarID,
  12245. KilnCarCode,
  12246. KilnCarName,
  12247. KilnCarBatchNo,
  12248. KilnCarPosition,
  12249. AccountID,
  12250. ValueFlag,
  12251. CreateTime,
  12252. CreateUserID,
  12253. UpdateTime,
  12254. UpdateUserID,
  12255. OPTimeStamp,
  12256. LogoID
  12257. from TP_PM_ProductionData where TP_PM_ProductionData.ProductionDataID=(select max(ProductionDataID) from TP_PM_ProductionData where barcode=:barcode and valueflag=1)";
  12258. //xuwei end
  12259. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  12260. // 5 删除产成品表
  12261. sql = "delete from tp_pm_finishedproduct where barcode=:barcode and valueflag=1";
  12262. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  12263. if (returnRows <= 0)
  12264. {
  12265. oracleTrConn.Rollback();
  12266. oracleTrConn.Disconnect();
  12267. }
  12268. else
  12269. {
  12270. oracleTrConn.Commit();
  12271. oracleTrConn.Disconnect();
  12272. }
  12273. }
  12274. catch (Exception ex)
  12275. {
  12276. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  12277. {
  12278. oracleTrConn.Rollback();
  12279. oracleTrConn.Disconnect();
  12280. }
  12281. throw ex;
  12282. }
  12283. finally
  12284. {
  12285. if (oracleTrConn.ConnState == ConnectionState.Open)
  12286. {
  12287. oracleTrConn.Disconnect();
  12288. }
  12289. }
  12290. entity.Result = returnRows;
  12291. return entity;
  12292. }
  12293. /// <summary>
  12294. /// 公坯设定
  12295. /// </summary>
  12296. /// <param name="barcode">产品条码</param>
  12297. /// <returns></returns>
  12298. public static int AddPublicBodyProduct(string barcode, SUserInfo sUserInfo)
  12299. {
  12300. int returnRows = 0;
  12301. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  12302. try
  12303. {
  12304. // 1 条码是否在在产表中
  12305. string sql = "select ispublicbody from tp_pm_inproduction where barcode=:barcode and valueflag=1";
  12306. OracleParameter[] Paras = new OracleParameter[] {
  12307. new OracleParameter(":barcode",OracleDbType.Varchar2,
  12308. barcode,ParameterDirection.Input)
  12309. };
  12310. DataSet ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  12311. if (ds.Tables[0].Rows.Count == 0)
  12312. {
  12313. //不存在生产线上,
  12314. returnRows = -1;
  12315. oracleTrConn.Rollback();
  12316. oracleTrConn.Disconnect();
  12317. return returnRows;
  12318. }
  12319. else
  12320. {
  12321. if (ds.Tables[0].Rows[0]["ispublicbody"].ToString() == "1")
  12322. {
  12323. returnRows = -2;
  12324. oracleTrConn.Rollback();
  12325. oracleTrConn.Disconnect();
  12326. return returnRows;
  12327. }
  12328. }
  12329. // 2 TP_PM_GroutingDailyDetail 在产盘点明细
  12330. sql = "update TP_PM_GroutingDailyDetail set ispublicbody=1 where barcode=:barcode";
  12331. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  12332. // 3 TP_PM_InCheckedDetail
  12333. sql = "update TP_PM_InCheckedDetail set ispublicbody=1 where barcode=:barcode";
  12334. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  12335. // 4 TP_PM_InProduction
  12336. sql = "update TP_PM_InProduction set ispublicbody=1 where barcode=:barcode";
  12337. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  12338. // 5 TP_PM_InProductionTrash
  12339. sql = "update TP_PM_InProductionTrash set ispublicbody=1 where barcode=:barcode";
  12340. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  12341. // 6 TP_PM_ProductionDataIn
  12342. sql = "update TP_PM_ProductionDataIn set ispublicbody=1 where barcode=:barcode";
  12343. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  12344. // 7 TP_PM_ScrapProduct
  12345. sql = "update TP_PM_ScrapProduct set ispublicbody=1 where barcode=:barcode";
  12346. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  12347. if (returnRows <= 0)
  12348. {
  12349. oracleTrConn.Rollback();
  12350. oracleTrConn.Disconnect();
  12351. }
  12352. else
  12353. {
  12354. oracleTrConn.Commit();
  12355. oracleTrConn.Disconnect();
  12356. }
  12357. }
  12358. catch (Exception ex)
  12359. {
  12360. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  12361. {
  12362. oracleTrConn.Rollback();
  12363. oracleTrConn.Disconnect();
  12364. }
  12365. throw ex;
  12366. }
  12367. finally
  12368. {
  12369. if (oracleTrConn.ConnState == ConnectionState.Open)
  12370. {
  12371. oracleTrConn.Disconnect();
  12372. }
  12373. }
  12374. return returnRows;
  12375. }
  12376. /// <summary>
  12377. /// 交坯保存校验(首节点)
  12378. /// </summary>
  12379. /// <param name="oracleTrConn">连接对象</param>
  12380. /// <param name="procedureID">工序ID</param>
  12381. /// <param name="barcode">条码</param>
  12382. /// <param name="goodsID">返回的产品ID</param>
  12383. /// <param name="goodsCode">返回的产品Code</param>
  12384. /// <param name="goodsName">返回的产品名称</param>
  12385. /// <param name="groutingUserID">返回的注浆者ID</param>
  12386. /// <returns>string</returns>
  12387. /// <remarks>
  12388. /// 陈冰 2014.09.18 新建
  12389. /// </remarks>
  12390. private static string CheckBarcodeDeliverMud(IDBTransaction oracleTrConn,
  12391. int procedureID,
  12392. string barcode,
  12393. out int goodsID,
  12394. out string goodsCode,
  12395. out string goodsName,
  12396. out string groutingUserCode,
  12397. SUserInfo sUserInfo, ref int? GroutingDailyDetailID
  12398. )
  12399. {
  12400. try
  12401. {
  12402. string sql = "select barcodestatus,barcode,GroutingDailyDetailid from TP_PM_USEDBARCODE where barcode=:barcode";
  12403. OracleParameter[] paras = new OracleParameter[]{
  12404. new OracleParameter("barcode",OracleDbType.NVarchar2,barcode,ParameterDirection.Input),
  12405. };
  12406. DataSet ds = oracleTrConn.GetSqlResultToDs(sql, paras);
  12407. string ErrorMessage = "";
  12408. if (ds != null && ds.Tables[0].Rows.Count == 0)
  12409. {
  12410. ErrorMessage = "无效条码";
  12411. }
  12412. else
  12413. {
  12414. //不等于空的时候
  12415. if (ds.Tables[0].Rows[0]["barcodestatus"].ToString() == "-1")
  12416. {
  12417. sql = "select max(newbarcode) from TP_PM_BarCodeRecord where BarCode='" + ds.Tables[0].Rows[0]["barcode"].ToString() + "'";
  12418. string newbarcode = oracleTrConn.GetSqlResultToStr(sql);
  12419. ErrorMessage = "条码已被替换,新条码为" + newbarcode;
  12420. }
  12421. else if (ds.Tables[0].Rows[0]["barcodestatus"].ToString() == "2")
  12422. {
  12423. ErrorMessage = "产品开模时已损坏";
  12424. }
  12425. // 已经交坯
  12426. else if (ds.Tables[0].Rows[0]["barcodestatus"].ToString() == "3" ||
  12427. ds.Tables[0].Rows[0]["barcodestatus"].ToString() == "4")
  12428. {
  12429. //ErrorMessage = "产品已交坯";
  12430. ErrorMessage = "产品已在产";
  12431. }
  12432. }
  12433. string sqlString = @"select
  12434. GroutingDailyDetailid,
  12435. GoodsID,
  12436. GoodsCode,
  12437. GoodsName,
  12438. UserCode as GroutingUserCode,
  12439. groutingcount as GroutingNum,
  12440. GroutingMouldCode as MouldCode,
  12441. ispublicbody,
  12442. Groutingdate,
  12443. SpecialRepairFlag
  12444. from
  12445. tp_pm_GroutingDailyDetail
  12446. where tp_pm_GroutingDailyDetail.groutingdailydetailid=:groutingdailydetailid";
  12447. paras = new OracleParameter[]{
  12448. new OracleParameter(":groutingdailydetailid",ds.Tables[0].Rows[0]["GroutingDailyDetailid"].ToString()),
  12449. };
  12450. ds = oracleTrConn.GetSqlResultToDs(sqlString, paras);
  12451. goodsID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsID"]);
  12452. goodsCode = ds.Tables[0].Rows[0]["GoodsCode"].ToString();
  12453. goodsName = ds.Tables[0].Rows[0]["GoodsName"].ToString();
  12454. groutingUserCode = ds.Tables[0].Rows[0]["GroutingUserCode"].ToString();
  12455. GroutingDailyDetailID = Convert.ToInt32(ds.Tables[0].Rows[0]["GroutingDailyDetailID"]);
  12456. string sqlExistGoods = "select count(GoodsID) from TP_PC_ProcedureGoods where GoodsID=:GoodsID and ProcedureID=:ProcedureID";
  12457. paras = new OracleParameter[]{
  12458. new OracleParameter(":GoodsID",ds.Tables[0].Rows[0]["GoodsID"].ToString()),
  12459. new OracleParameter(":ProcedureID",procedureID),
  12460. };
  12461. DataSet dsGoods = oracleTrConn.GetSqlResultToDs(sqlExistGoods, paras);
  12462. if (dsGoods.Tables[0].Rows[0][0].ToString() != "1")
  12463. {
  12464. ErrorMessage = @"条码[" + barcode +
  12465. "]不可以经过该工序\n\r原因:条码对应的产品编码[" +
  12466. ds.Tables[0].Rows[0]["GoodsCode"].ToString() + "]没有在该工序中配置";
  12467. }
  12468. return ErrorMessage;
  12469. }
  12470. catch (Exception ex)
  12471. {
  12472. throw ex;
  12473. }
  12474. }
  12475. /// <summary>
  12476. /// 标准计件(单点采集)
  12477. /// </summary>
  12478. /// <param name="oracleTrConn">数据连接对象</param>
  12479. /// <param name="procedure">工序对象</param>
  12480. /// <param name="barcodeTable">条码信息</param>
  12481. /// <param name="sUserInfo">用户基本信息</param>
  12482. /// <param name="goodsID">返回的产品ID</param>
  12483. /// <param name="goodsCode">返回的产品Code</param>
  12484. /// <param name="goodsName">返回的产品名称</param>
  12485. /// <param name="groutingUserID">返回的注浆者ID</param>
  12486. /// <returns>string</returns>
  12487. /// <remarks>
  12488. /// 陈冰 2014.09.18 新建
  12489. /// </remarks>
  12490. private static string AddNormalWorkPiece2(IDBTransaction oracleTrConn,
  12491. ProcedureEntity procedure,
  12492. DataTable barcodeTable,
  12493. SUserInfo sUserInfo,
  12494. out int goodsID,
  12495. out string goodsCode,
  12496. out string goodsName,
  12497. out string groutingUserCode)
  12498. {
  12499. try
  12500. {
  12501. goodsID = Constant.INT_IS_ZERO;
  12502. goodsCode = null;
  12503. goodsName = null;
  12504. groutingUserCode = string.Empty; //Constant.INT_IS_ZERO;
  12505. // 获得账务日期
  12506. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  12507. string errMsg = string.Empty;
  12508. // 本批采集的批次号
  12509. string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  12510. string finishedloadbatchno = DateTime.Now.ToString("yyMMddHHmmss-") + centralizedBatchNo;
  12511. // 条码信息
  12512. foreach (DataRow barcodeRow in barcodeTable.Rows)
  12513. {
  12514. // 条码
  12515. string barcode = barcodeRow["Barcode"].ToString();
  12516. if (string.IsNullOrEmpty(barcode))
  12517. {
  12518. throw new Exception("传入的条码号为空");
  12519. }
  12520. // 生产工号
  12521. int workUserID = Convert.ToInt32(barcodeRow["UserID"]);
  12522. // 生产工号
  12523. string workUserCode = barcodeRow["UserCode"].ToString();
  12524. //生产数据ID
  12525. string sql = "select SEQ_PM_ProductionData_ID.nextval from dual";
  12526. int productionDataID = Convert.ToInt32(oracleTrConn.GetSqlResultToStr(sql));
  12527. int? GroutingDailyDetailID = null;//注浆明细ID
  12528. if (procedure.CollectType == 1)
  12529. {
  12530. // ccc todo
  12531. //if (procedure.ModelType == (int)Constant.ProcedureModelType.DeliverMud)//是交坯节点,并且不是公坯的
  12532. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  12533. {
  12534. #region 校验条码有效性
  12535. errMsg = CheckBarcodeDeliverMud(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo, ref GroutingDailyDetailID);
  12536. if (!string.IsNullOrEmpty(errMsg))
  12537. {
  12538. return errMsg;
  12539. }
  12540. #endregion
  12541. }
  12542. else
  12543. {
  12544. #region 校验条码有效性
  12545. errMsg = CheckBarcode(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo);
  12546. if (!string.IsNullOrEmpty(errMsg))
  12547. {
  12548. return errMsg;
  12549. }
  12550. #endregion
  12551. }
  12552. }
  12553. else
  12554. {
  12555. // string sqlGroutingInfo = @"select tp_pm_groutingdailydetail.goodsid,
  12556. // tp_pm_groutingdailydetail.goodscode,
  12557. // tp_pm_groutingdailydetail.goodsname,
  12558. // tp_pm_groutingdailydetail.usercode as groutingUserCode
  12559. // from tp_pm_groutingdailydetail where barcode=:barcode
  12560. // ";
  12561. string sqlGroutingInfo = "";
  12562. // sqlGroutingInfo = @"select tp_pm_groutingdailydetail.goodsid,
  12563. // tp_pm_groutingdailydetail.goodscode,
  12564. // tp_pm_groutingdailydetail.goodsname,
  12565. // tp_pm_groutingdailydetail.usercode as groutingUserCode
  12566. // from tp_pm_groutingdailydetail where barcode=:barcode
  12567. // ";
  12568. //if (procedure.NodeType == (int)Constant.ProcedureNodeType.End)
  12569. //{
  12570. sqlGroutingInfo = @"select tp_pm_groutingdailydetail.goodsid,
  12571. tp_pm_groutingdailydetail.goodscode,
  12572. tp_pm_groutingdailydetail.goodsname,
  12573. tp_pm_groutingdailydetail.usercode as groutingUserCode
  12574. from tp_pm_groutingdailydetail where groutingdailydetailid in
  12575. (select groutingdailydetailid from TP_PM_USEDBARCODE where barcode=:barcode)
  12576. ";
  12577. //}
  12578. OracleParameter[] ReFireparas = new OracleParameter[] {
  12579. new OracleParameter(":barcode",barcode),
  12580. };
  12581. DataSet dsGrouting = oracleTrConn.GetSqlResultToDs(sqlGroutingInfo, ReFireparas);
  12582. if (dsGrouting != null && dsGrouting.Tables[0].Rows.Count > 0)
  12583. {
  12584. goodsID = Convert.ToInt32(dsGrouting.Tables[0].Rows[0]["goodsid"]);
  12585. goodsCode = dsGrouting.Tables[0].Rows[0]["goodscode"].ToString();
  12586. goodsName = dsGrouting.Tables[0].Rows[0]["goodsName"].ToString();
  12587. groutingUserCode = dsGrouting.Tables[0].Rows[0]["groutingUserCode"].ToString();
  12588. }
  12589. }
  12590. int? ClassesSettingID = null;//班次配置ID
  12591. #region 添加生产者数据
  12592. if (procedure.ModelType == (int)Constant.ProcedureModelType.DeliverMud)//是交坯节点,并且不是公坯的
  12593. {
  12594. string GroutingUserCode = barcodeRow["GroutingUserCode"].ToString();
  12595. if (GroutingUserCode.ToLower() == workUserCode.ToLower())
  12596. {
  12597. //errMsg = AddProducerDeliverAdobe(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo);
  12598. }
  12599. else
  12600. {
  12601. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID);
  12602. }
  12603. }
  12604. else
  12605. {
  12606. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID);
  12607. }
  12608. if (!string.IsNullOrEmpty(errMsg))
  12609. {
  12610. return errMsg;
  12611. }
  12612. #endregion
  12613. #region 添加生产数据
  12614. ProductionDataEntity productionData = new ProductionDataEntity();
  12615. #region 属性赋值
  12616. productionData.GroutingDailyDetailID = GroutingDailyDetailID;//只有交坯的时候用到
  12617. productionData.ClassesSettingID = ClassesSettingID;
  12618. productionData.ProductionDataID = productionDataID;
  12619. productionData.Barcode = barcode;
  12620. productionData.CentralizedBatchNo = centralizedBatchNo;
  12621. productionData.ProductionLineID = procedure.ProductionLineID;
  12622. productionData.ProductionLineCode = procedure.ProductionlineCode;
  12623. productionData.ProductionLineName = procedure.ProductionlineName;
  12624. productionData.CompleteProcedureID = procedure.ProcedureID;
  12625. productionData.ProcedureCode = procedure.ProcedureCode;
  12626. productionData.ProcedureName = procedure.ProcedureName;
  12627. productionData.ProcedureModel = procedure.ProcedureModel;
  12628. productionData.ModelType = procedure.ModelType;
  12629. productionData.NodeType = procedure.NodeType;
  12630. productionData.PieceType = procedure.PieceType;
  12631. if (procedure.IsSpecialRework == 0)
  12632. {
  12633. productionData.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  12634. //不加条件valueflag,是因为,成检后重烧走过之后,在次重烧,以后也是重烧状态
  12635. //string sqlReFire = "select * from tp_PM_ProductionData where ProductionDataid=(select max(ProductionDataid) from tp_PM_ProductionData where barcode='" + productionData.Barcode + "')";
  12636. //xuwei 2019-09-18 交坯节点判定 0引用 不做处理
  12637. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)//是交坯节点,肯定不会是重烧
  12638. {
  12639. productionData.IsReFire = (int)Constant.ReFireFlag.No;
  12640. productionData.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  12641. }
  12642. ////// else
  12643. ////// {
  12644. ////// string sqlReFire = @"select
  12645. ////// isrefire
  12646. ////// from tp_pm_inproduction where barcode=:barcode
  12647. ////// ";
  12648. ////// OracleParameter[] ReFireparas = new OracleParameter[] {
  12649. ////// new OracleParameter(":barcode",barcode),
  12650. ////// };
  12651. ////// DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas);
  12652. ////// if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0)
  12653. ////// {
  12654. ////// if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0)
  12655. ////// {
  12656. ////// productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]);
  12657. ////// //if (productionData.IsReFire == 6) wangxin modify 20150422 因为已经大于0,定是重烧,即有缺陷
  12658. ////// //{
  12659. ////// productionData.DefectFlag = (int)Constant.GoodsLevelType.Defect;
  12660. ////// //}
  12661. ////// }
  12662. ////// }
  12663. ////// }
  12664. }
  12665. else
  12666. {
  12667. productionData.IsReFire = (int)Constant.GoodsLevelType.ReFire;
  12668. productionData.DefectFlag = (int)Constant.GoodsLevelType.Defect;
  12669. }
  12670. productionData.ReworkProcedureID = null;
  12671. #region 交坯判断
  12672. // 交坯节点
  12673. if (barcodeTable.Columns.Contains("IsPublicBody"))
  12674. {
  12675. productionData.IsPublicBody = Convert.ToInt32(barcodeRow["IsPublicBody"]);
  12676. }
  12677. // 非交坯节点
  12678. else
  12679. {
  12680. // 正常坯
  12681. productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, barcode);
  12682. }
  12683. #endregion
  12684. productionData.OrganizationID = procedure.OrganizationID;
  12685. productionData.GoodsID = goodsID;
  12686. productionData.GoodsCode = goodsCode;
  12687. productionData.GoodsName = goodsName;
  12688. productionData.UserID = workUserID;
  12689. productionData.UserCode = barcodeRow["UserCode"].ToString();
  12690. productionData.UserName = barcodeRow["UserName"].ToString();
  12691. #endregion
  12692. string OutSpecialRepairflag = "0";//干补标识
  12693. DataSet outDataSet = null;
  12694. //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的
  12695. //xuwei fix 2019-09-26 使用通用方法判定
  12696. // 2019-1016
  12697. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  12698. {
  12699. int isNodeBegin = IsNodeBegin<IDBTransaction>(oracleTrConn, productionData.Barcode);
  12700. if (isNodeBegin == 0)
  12701. {
  12702. procedure.NodeType = (int)Constant.ProcedureNodeType.Middle;
  12703. }
  12704. }
  12705. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  12706. {
  12707. errMsg = AddProductionDataDeliverMud(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag, out outDataSet);
  12708. }
  12709. else
  12710. {
  12711. errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag);
  12712. }
  12713. if (!string.IsNullOrEmpty(errMsg))
  12714. {
  12715. return errMsg;
  12716. }
  12717. #endregion
  12718. #region 开始节点
  12719. //xuwei remove 2019-09-26 此处为重复判定移除
  12720. //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的
  12721. //xuwei fix 2019-09-26 使用通用方法判定
  12722. //int isNodeBegin = IsNodeBegin<IDBTransaction>(oracleTrConn, productionData.Barcode);
  12723. // 2019-1016
  12724. //if (isNodeBegin == 1) procedure.NodeType = (int)Constant.ProcedureNodeType.Begin;
  12725. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  12726. {
  12727. #region 添加在产产品数据
  12728. InProductionEntity addInProductionEntity = new InProductionEntity();
  12729. addInProductionEntity.BarCode = barcode;
  12730. //流程工序ID
  12731. addInProductionEntity.FlowProcedureID = procedure.ProcedureID;
  12732. // 当前工序
  12733. addInProductionEntity.ProcedureID = procedure.ProcedureID;
  12734. //addInProductionEntity.CompleteProcedureID = procedure.ProcedureID;
  12735. // 工序模型
  12736. addInProductionEntity.ProcedureModel = procedure.ProcedureModel;
  12737. // 工序类别
  12738. addInProductionEntity.ModelType = procedure.ModelType;
  12739. addInProductionEntity.SpecialRepairflag = Convert.ToInt32(OutSpecialRepairflag);//干补标识
  12740. addInProductionEntity.ProductionDataID = productionDataID;
  12741. #region 交坯判断
  12742. addInProductionEntity.IsPublicBody = productionData.IsPublicBody;// 生产数据已经判断是否为公坯
  12743. #endregion
  12744. // 生产工号
  12745. addInProductionEntity.UserID = workUserID;
  12746. // 执行添加
  12747. errMsg = AddInProduction(oracleTrConn, addInProductionEntity, sUserInfo, outDataSet);
  12748. // 执行失败
  12749. if (!string.IsNullOrEmpty(errMsg))
  12750. {
  12751. return errMsg;
  12752. }
  12753. #endregion
  12754. }
  12755. #endregion
  12756. #region 中间节点
  12757. else if (procedure.NodeType == (int)Constant.ProcedureNodeType.Middle)
  12758. {
  12759. #region 修改在产产品数据的当前工序,清空返工工序字段
  12760. InProductionEntity addInProductionEntity = new InProductionEntity();
  12761. addInProductionEntity.BarCode = barcode;
  12762. //流程工序ID
  12763. addInProductionEntity.FlowProcedureID = procedure.ProcedureID;
  12764. // 当前工序
  12765. addInProductionEntity.ProcedureID = procedure.ProcedureID;
  12766. //当前生产数据ID
  12767. addInProductionEntity.ProductionDataID = productionDataID;
  12768. // 工序模型
  12769. addInProductionEntity.ProcedureModel = procedure.ProcedureModel;
  12770. // 工序类别
  12771. addInProductionEntity.ModelType = procedure.ModelType;
  12772. // 生产工号
  12773. addInProductionEntity.UserID = workUserID;
  12774. // 缺陷标识
  12775. // addInProductionEntity.DefectFlag = (int)Constant.DefectFlag.No;
  12776. //addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefect;
  12777. if (procedure.IsSpecialRework == 0)
  12778. {
  12779. addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  12780. }
  12781. else
  12782. {
  12783. addInProductionEntity.IsReFire = (int)Constant.GoodsLevelType.ReFire;
  12784. addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  12785. }
  12786. #region 交坯判断
  12787. addInProductionEntity.IsPublicBody = productionData.IsPublicBody;// 生产数据已经判断是否为公坯
  12788. #endregion
  12789. // 执行修改
  12790. errMsg = UpdateInProduction(oracleTrConn, addInProductionEntity, sUserInfo);
  12791. // 执行失败
  12792. if (!string.IsNullOrEmpty(errMsg))
  12793. {
  12794. return errMsg;
  12795. }
  12796. #endregion
  12797. }
  12798. #endregion
  12799. #region 结束节点
  12800. else
  12801. {
  12802. #region 添加成品数据 删除在产产品数据
  12803. FinishedProductEntity finishedProduct = new FinishedProductEntity();
  12804. finishedProduct.BarCode = barcode;
  12805. errMsg = AddFinishedProduct(oracleTrConn, finishedProduct, sUserInfo, finishedloadbatchno);
  12806. if (!string.IsNullOrEmpty(errMsg))
  12807. {
  12808. return errMsg;
  12809. }
  12810. InProductionEntity delInProductionEntity = new InProductionEntity();
  12811. delInProductionEntity.BarCode = barcode;
  12812. // 执行删除 在产数据
  12813. errMsg = DeleteInProduction(oracleTrConn, delInProductionEntity, true, sUserInfo);
  12814. // 执行失败
  12815. if (!string.IsNullOrEmpty(errMsg))
  12816. {
  12817. return errMsg;
  12818. }
  12819. #endregion
  12820. }
  12821. #endregion
  12822. }
  12823. return errMsg;
  12824. }
  12825. catch (Exception ex)
  12826. {
  12827. throw ex;
  12828. }
  12829. }
  12830. /// <summary>
  12831. /// 标准计件
  12832. /// </summary>
  12833. /// <param name="oracleTrConn">数据连接对象</param>
  12834. /// <param name="procedure">工序对象</param>
  12835. /// <param name="barcodeTable">条码信息</param>
  12836. /// <param name="sUserInfo">用户基本信息</param>
  12837. /// <param name="goodsID">返回的产品ID</param>
  12838. /// <param name="goodsCode">返回的产品Code</param>
  12839. /// <param name="goodsName">返回的产品名称</param>
  12840. /// <param name="groutingUserID">返回的注浆者ID</param>
  12841. /// <returns>string</returns>
  12842. /// <remarks>
  12843. /// 陈冰 2014.09.18 新建
  12844. /// </remarks>
  12845. private static string AddNormalWorkPieceSinglePoint(IDBTransaction oracleTrConn,
  12846. ProcedureEntity procedure,
  12847. DataTable barcodeTable,
  12848. SUserInfo sUserInfo,
  12849. int goodsID,
  12850. string goodsCode,
  12851. string goodsName,
  12852. string groutingUserCode,
  12853. int? arvGroutingDailyDetailID,
  12854. bool isSendBody = false)
  12855. {
  12856. try
  12857. {
  12858. //goodsID = Constant.INT_IS_ZERO;
  12859. //goodsCode = null;
  12860. //goodsName = null;
  12861. //groutingUserCode = string.Empty; //Constant.INT_IS_ZERO;
  12862. // 获得账务日期
  12863. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  12864. string errMsg = string.Empty;
  12865. // 本批采集的批次号
  12866. string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  12867. string finishedloadbatchno = DateTime.Now.ToString("yyMMddHHmmss-") + centralizedBatchNo;
  12868. // 条码信息
  12869. foreach (DataRow barcodeRow in barcodeTable.Rows)
  12870. {
  12871. // 条码
  12872. string barcode = barcodeRow["Barcode"].ToString();
  12873. if (string.IsNullOrEmpty(barcode))
  12874. {
  12875. throw new Exception("传入的条码号为空");
  12876. }
  12877. // 生产工号
  12878. int workUserID = Convert.ToInt32(barcodeRow["UserID"]);
  12879. // 生产工号
  12880. string workUserCode = barcodeRow["UserCode"].ToString();
  12881. //生产数据ID
  12882. string sql = "select SEQ_PM_ProductionData_ID.nextval from dual";
  12883. int productionDataID = Convert.ToInt32(oracleTrConn.GetSqlResultToStr(sql));
  12884. int? GroutingDailyDetailID = arvGroutingDailyDetailID;//注浆明细ID
  12885. if (procedure.CollectType == 1)
  12886. {
  12887. // ccc todo
  12888. //if (procedure.ModelType == (int)Constant.ProcedureModelType.DeliverMud)//是交坯节点,并且不是公坯的
  12889. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  12890. {
  12891. #region 校验条码有效性
  12892. errMsg = CheckBarcodeDeliverMud(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo, ref GroutingDailyDetailID);
  12893. if (!string.IsNullOrEmpty(errMsg))
  12894. {
  12895. return errMsg;
  12896. }
  12897. #endregion
  12898. }
  12899. else
  12900. {
  12901. #region 校验条码有效性
  12902. errMsg = CheckBarcode(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo);
  12903. if (!string.IsNullOrEmpty(errMsg))
  12904. {
  12905. return errMsg;
  12906. }
  12907. #endregion
  12908. }
  12909. }
  12910. else
  12911. {
  12912. // string sqlGroutingInfo = "";
  12913. // sqlGroutingInfo = @"select tp_pm_groutingdailydetail.goodsid,
  12914. // tp_pm_groutingdailydetail.goodscode,
  12915. // tp_pm_groutingdailydetail.goodsname,
  12916. // tp_pm_groutingdailydetail.usercode as groutingUserCode,
  12917. // tp_pm_groutingdailydetail.GroutingDailyDetailID
  12918. // from tp_pm_groutingdailydetail where groutingdailydetailid in
  12919. // (select groutingdailydetailid from TP_PM_USEDBARCODE where barcode=:barcode)
  12920. // ";
  12921. // OracleParameter[] ReFireparas = new OracleParameter[] {
  12922. // new OracleParameter(":barcode",barcode),
  12923. // };
  12924. // DataSet dsGrouting = oracleTrConn.GetSqlResultToDs(sqlGroutingInfo, ReFireparas);
  12925. // if (dsGrouting != null && dsGrouting.Tables[0].Rows.Count > 0)
  12926. // {
  12927. // GroutingDailyDetailID = Convert.ToInt32(dsGrouting.Tables[0].Rows[0]["GroutingDailyDetailID"]);
  12928. // goodsID = Convert.ToInt32(dsGrouting.Tables[0].Rows[0]["goodsid"]);
  12929. // goodsCode = dsGrouting.Tables[0].Rows[0]["goodscode"].ToString();
  12930. // goodsName = dsGrouting.Tables[0].Rows[0]["goodsName"].ToString();
  12931. // groutingUserCode = dsGrouting.Tables[0].Rows[0]["groutingUserCode"].ToString();
  12932. // }
  12933. }
  12934. int? ClassesSettingID = null;//班次配置ID
  12935. #region 添加生产者数据
  12936. if (procedure.ModelType == (int)Constant.ProcedureModelType.DeliverMud)//是交坯节点,并且不是公坯的
  12937. {
  12938. string GroutingUserCode = barcodeRow["GroutingUserCode"].ToString();
  12939. if (GroutingUserCode.ToLower() == workUserCode.ToLower())
  12940. {
  12941. //errMsg = AddProducerDeliverAdobe(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo);
  12942. }
  12943. else
  12944. {
  12945. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID);
  12946. }
  12947. }
  12948. else
  12949. {
  12950. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID);
  12951. }
  12952. if (!string.IsNullOrEmpty(errMsg))
  12953. {
  12954. return errMsg;
  12955. }
  12956. #endregion
  12957. #region 添加生产数据
  12958. ProductionDataEntity productionData = new ProductionDataEntity();
  12959. if (barcodeTable.Columns.Contains("Remarks"))
  12960. {
  12961. productionData.Remarks = barcodeRow["Remarks"] + "";
  12962. }
  12963. #region 属性赋值
  12964. productionData.GroutingDailyDetailID = GroutingDailyDetailID;//只有交坯的时候用到
  12965. productionData.ClassesSettingID = ClassesSettingID;
  12966. productionData.ProductionDataID = productionDataID;
  12967. productionData.Barcode = barcode;
  12968. productionData.CentralizedBatchNo = centralizedBatchNo;
  12969. productionData.ProductionLineID = procedure.ProductionLineID;
  12970. productionData.ProductionLineCode = procedure.ProductionlineCode;
  12971. productionData.ProductionLineName = procedure.ProductionlineName;
  12972. productionData.CompleteProcedureID = procedure.ProcedureID;
  12973. productionData.ProcedureCode = procedure.ProcedureCode;
  12974. productionData.ProcedureName = procedure.ProcedureName;
  12975. productionData.ProcedureModel = procedure.ProcedureModel;
  12976. productionData.ModelType = procedure.ModelType;
  12977. productionData.NodeType = procedure.NodeType;
  12978. productionData.PieceType = procedure.PieceType;
  12979. if (barcodeRow["LogoID"].ToString() != "")
  12980. {
  12981. productionData.LogoID = Convert.ToInt32(barcodeRow["LogoID"]);
  12982. }
  12983. if (procedure.IsSpecialRework == 0)
  12984. {
  12985. productionData.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  12986. //不加条件valueflag,是因为,成检后重烧走过之后,在次重烧,以后也是重烧状态
  12987. //string sqlReFire = "select * from tp_PM_ProductionData where ProductionDataid=(select max(ProductionDataid) from tp_PM_ProductionData where barcode='" + productionData.Barcode + "')";
  12988. //xuwei fix 2019-09-18 交坯节点判定修改
  12989. //if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)//是交坯节点,肯定不会是重烧
  12990. if (isSendBody)//是交坯节点,肯定不会是重烧
  12991. {
  12992. productionData.IsReFire = (int)Constant.ReFireFlag.No;
  12993. productionData.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  12994. }
  12995. ////// else
  12996. ////// {
  12997. ////// string sqlReFire = @"select
  12998. ////// isrefire
  12999. ////// from tp_pm_inproduction where barcode=:barcode
  13000. ////// ";
  13001. ////// OracleParameter[] ReFireparas = new OracleParameter[] {
  13002. ////// new OracleParameter(":barcode",barcode),
  13003. ////// };
  13004. ////// DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas);
  13005. ////// if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0)
  13006. ////// {
  13007. ////// if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0)
  13008. ////// {
  13009. ////// productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]);
  13010. ////// //if (productionData.IsReFire == 6) wangxin modify 20150422 因为已经大于0,定是重烧,即有缺陷
  13011. ////// //{
  13012. ////// productionData.DefectFlag = (int)Constant.GoodsLevelType.Defect;
  13013. ////// //}
  13014. ////// }
  13015. ////// }
  13016. ////// }
  13017. }
  13018. else
  13019. {
  13020. productionData.IsReFire = (int)Constant.GoodsLevelType.ReFire;
  13021. productionData.DefectFlag = (int)Constant.GoodsLevelType.Defect;
  13022. }
  13023. productionData.ReworkProcedureID = null;
  13024. #region 交坯判断
  13025. // 交坯节点
  13026. if (barcodeTable.Columns.Contains("IsPublicBody"))
  13027. {
  13028. productionData.IsPublicBody = Convert.ToInt32(barcodeRow["IsPublicBody"]);
  13029. }
  13030. // 非交坯节点
  13031. else
  13032. {
  13033. // 正常坯
  13034. productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, barcode);
  13035. }
  13036. #endregion
  13037. productionData.OrganizationID = procedure.OrganizationID;
  13038. productionData.GoodsID = goodsID;
  13039. productionData.GoodsCode = goodsCode;
  13040. productionData.GoodsName = goodsName;
  13041. //xuwei fix 2022-05-27 重新获取goodsID,goodsCode,goodsName(用于barcodeTable多个barcode)
  13042. DataTable goodsDt = oracleTrConn.GetSqlResultToDt(@"
  13043. SELECT
  13044. GDD.GOODSID,
  13045. GDD.GOODSCODE,
  13046. GDD.GOODSNAME
  13047. FROM
  13048. TP_PM_GROUTINGDAILYDETAIL GDD
  13049. WHERE
  13050. GDD.VALUEFLAG = 1
  13051. AND GDD.BARCODE = :BARCODE
  13052. ", new OracleParameter[] {
  13053. new OracleParameter(":BARCODE",barcode)
  13054. });
  13055. if (goodsDt.Rows.Count > 0)
  13056. {
  13057. productionData.GoodsID = Convert.ToInt32(goodsDt.Rows[0]["GOODSID"]);
  13058. productionData.GoodsCode = goodsDt.Rows[0]["GOODSCODE"].ToString();
  13059. productionData.GoodsName = goodsDt.Rows[0]["GOODSNAME"].ToString();
  13060. }
  13061. //xuwei end
  13062. productionData.UserID = workUserID;
  13063. productionData.UserCode = barcodeRow["UserCode"].ToString();
  13064. productionData.UserName = barcodeRow["UserName"].ToString();
  13065. #endregion
  13066. string OutSpecialRepairflag = "0";//干补标识
  13067. DataSet outDataSet = null;
  13068. //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的
  13069. //xuwei fix 2019-09-26 使用通用方法判定
  13070. // 2019-1016
  13071. //int isNodeBegin = IsNodeBegin<IDBTransaction>(oracleTrConn, productionData.Barcode);
  13072. //if (isNodeBegin == 1) procedure.NodeType = (int)Constant.ProcedureNodeType.Begin;
  13073. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  13074. {
  13075. int isNodeBegin = IsNodeBegin<IDBTransaction>(oracleTrConn, productionData.Barcode);
  13076. if (isNodeBegin == 0)
  13077. {
  13078. procedure.NodeType = (int)Constant.ProcedureNodeType.Middle;
  13079. }
  13080. }
  13081. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  13082. {
  13083. //xuwei fix 2019-09-17 加入最后一个参数 isSendBody识别交坯
  13084. errMsg = AddProductionDataDeliverMud(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag, out outDataSet, isSendBody);
  13085. }
  13086. else
  13087. {
  13088. //xuwei fix 2019-09-17 加入最后一个参数 isSendBody识别交坯
  13089. errMsg = AddProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag, isSendBody);
  13090. }
  13091. if (!string.IsNullOrEmpty(errMsg))
  13092. {
  13093. return errMsg;
  13094. }
  13095. #endregion
  13096. #region 开始节点
  13097. if (procedure.NodeType == (int)Constant.ProcedureNodeType.Begin)
  13098. {
  13099. #region 添加在产产品数据
  13100. InProductionEntity addInProductionEntity = new InProductionEntity();
  13101. addInProductionEntity.BarCode = barcode;
  13102. //流程工序ID
  13103. addInProductionEntity.FlowProcedureID = procedure.ProcedureID;
  13104. // 当前工序
  13105. addInProductionEntity.ProcedureID = procedure.ProcedureID;
  13106. //addInProductionEntity.CompleteProcedureID = procedure.ProcedureID;
  13107. // 工序模型
  13108. addInProductionEntity.ProcedureModel = procedure.ProcedureModel;
  13109. // 工序类别
  13110. addInProductionEntity.ModelType = procedure.ModelType;
  13111. addInProductionEntity.SpecialRepairflag = Convert.ToInt32(OutSpecialRepairflag);//干补标识
  13112. addInProductionEntity.ProductionDataID = productionDataID;
  13113. #region 交坯判断
  13114. addInProductionEntity.IsPublicBody = productionData.IsPublicBody;// 生产数据已经判断是否为公坯
  13115. #endregion
  13116. // 生产工号
  13117. addInProductionEntity.UserID = workUserID;
  13118. // 执行添加
  13119. //xuwei fix 2019-09-17 加入最后一个参数 isSendBody识别交坯
  13120. errMsg = AddInProduction(oracleTrConn, addInProductionEntity, sUserInfo, outDataSet, isSendBody);
  13121. // 执行失败
  13122. if (!string.IsNullOrEmpty(errMsg))
  13123. {
  13124. return errMsg;
  13125. }
  13126. #endregion
  13127. }
  13128. #endregion
  13129. #region 中间节点
  13130. else if (procedure.NodeType == (int)Constant.ProcedureNodeType.Middle)
  13131. {
  13132. #region 修改在产产品数据的当前工序,清空返工工序字段
  13133. InProductionEntity addInProductionEntity = new InProductionEntity();
  13134. addInProductionEntity.BarCode = barcode;
  13135. //流程工序ID
  13136. addInProductionEntity.FlowProcedureID = procedure.ProcedureID;
  13137. // 当前工序
  13138. addInProductionEntity.ProcedureID = procedure.ProcedureID;
  13139. //当前生产数据ID
  13140. addInProductionEntity.ProductionDataID = productionDataID;
  13141. // 工序模型
  13142. addInProductionEntity.ProcedureModel = procedure.ProcedureModel;
  13143. // 工序类别
  13144. addInProductionEntity.ModelType = procedure.ModelType;
  13145. // 生产工号
  13146. addInProductionEntity.UserID = workUserID;
  13147. // 缺陷标识
  13148. // addInProductionEntity.DefectFlag = (int)Constant.DefectFlag.No;
  13149. //addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefect;
  13150. if (procedure.IsSpecialRework == 0)
  13151. {
  13152. addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  13153. }
  13154. else
  13155. {
  13156. addInProductionEntity.IsReFire = (int)Constant.GoodsLevelType.ReFire;
  13157. addInProductionEntity.DefectFlag = (int)Constant.GoodsLevelType.NoDefects;
  13158. }
  13159. addInProductionEntity.LogoID = productionData.LogoID == 0 ? null : productionData.LogoID;
  13160. #region 交坯判断
  13161. addInProductionEntity.IsPublicBody = productionData.IsPublicBody;// 生产数据已经判断是否为公坯
  13162. #endregion
  13163. // 执行修改
  13164. errMsg = UpdateInProduction(oracleTrConn, addInProductionEntity, sUserInfo);
  13165. // 执行失败
  13166. if (!string.IsNullOrEmpty(errMsg))
  13167. {
  13168. return errMsg;
  13169. }
  13170. #endregion
  13171. }
  13172. #endregion
  13173. #region 结束节点
  13174. else
  13175. {
  13176. #region 添加成品数据 删除在产产品数据
  13177. FinishedProductEntity finishedProduct = new FinishedProductEntity();
  13178. finishedProduct.BarCode = barcode;
  13179. finishedProduct.LogoID = productionData.LogoID;
  13180. errMsg = AddFinishedProduct(oracleTrConn, finishedProduct, sUserInfo, finishedloadbatchno);
  13181. if (!string.IsNullOrEmpty(errMsg))
  13182. {
  13183. return errMsg;
  13184. }
  13185. InProductionEntity delInProductionEntity = new InProductionEntity();
  13186. delInProductionEntity.BarCode = barcode;
  13187. // 执行删除 在产数据
  13188. errMsg = DeleteInProduction(oracleTrConn, delInProductionEntity, true, sUserInfo);
  13189. // 执行失败
  13190. if (!string.IsNullOrEmpty(errMsg))
  13191. {
  13192. return errMsg;
  13193. }
  13194. #endregion
  13195. }
  13196. #endregion
  13197. }
  13198. return errMsg;
  13199. }
  13200. catch (Exception ex)
  13201. {
  13202. throw ex;
  13203. }
  13204. }
  13205. /// <summary>
  13206. /// 清除在产残留数据(清除选择)
  13207. /// </summary>
  13208. /// <param name="barcodes">产品条码集</param>
  13209. /// <returns></returns>
  13210. public static int SaveClearInproduction(string barcodes, SUserInfo sUserInfo)
  13211. {
  13212. int returnRows = 0;
  13213. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13214. try
  13215. {
  13216. string sql = "";
  13217. string[] subbarcode = barcodes.Split(',');
  13218. OracleParameter[] Paras = null;
  13219. for (int i = 0; i < subbarcode.Length; i++)
  13220. {
  13221. // 0.登窑、入窑、出窑工序的产品不能清除
  13222. sql = "select p.modeltype from tp_pm_inproduction p where p.barcode = :barcode";
  13223. Paras = new OracleParameter[] {
  13224. new OracleParameter(":barcode",OracleDbType.NVarchar2,
  13225. subbarcode[i],ParameterDirection.Input)
  13226. };
  13227. string modeltype = oracleTrConn.GetSqlResultToStr(sql, Paras);
  13228. if (!string.IsNullOrWhiteSpace(modeltype))
  13229. {
  13230. Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType pmt =
  13231. (Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType)Convert.ToInt32(modeltype);
  13232. if (pmt == Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType.LoadCar ||
  13233. pmt == Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType.IntoKiln ||
  13234. pmt == Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType.OutKiln)
  13235. {
  13236. continue;
  13237. }
  13238. }
  13239. // 返工标识或者是报损标识不允许清除 2016-07-12
  13240. sql = "select IsReworkFlag,InScrapFlag from tp_pm_inproduction p where p.barcode = :barcode";
  13241. Paras = new OracleParameter[] {
  13242. new OracleParameter(":barcode",OracleDbType.NVarchar2,
  13243. subbarcode[i],ParameterDirection.Input)
  13244. };
  13245. DataSet ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  13246. if (ds != null && ds.Tables[0].Rows.Count > 0)
  13247. {
  13248. // chenxy 2019-10-02 半检返修 IsReworkFlag=2
  13249. //if (ds.Tables[0].Rows[0]["IsReworkFlag"].ToString() == "1")
  13250. if (ds.Tables[0].Rows[0]["IsReworkFlag"].ToString() != "0")
  13251. {
  13252. returnRows = -1;
  13253. break;
  13254. }
  13255. if (ds.Tables[0].Rows[0]["InScrapFlag"].ToString() == "1")
  13256. {
  13257. returnRows = -2;
  13258. break;
  13259. }
  13260. }
  13261. // 返工标识或者是报损标识不允许清除 end
  13262. //把在产数据插入到在产临时表中。(数据来源标识0:在产表)
  13263. sql = @"insert into tp_pm_inproduction_tmp
  13264. (
  13265. BARCODE,
  13266. PRODUCTIONLINEID,
  13267. PRODUCTIONLINECODE,
  13268. PRODUCTIONLINENAME,
  13269. PROCEDUREMODEL,
  13270. MODELTYPE,
  13271. REWORKPROCEDUREID,
  13272. ISPUBLICBODY,
  13273. GOODSID,
  13274. GOODSCODE,
  13275. GOODSNAME,
  13276. USERID,
  13277. GROUTINGDAILYID,
  13278. GROUTINGDAILYDETAILID,
  13279. GROUTINGDATE,
  13280. GROUTINGLINEID,
  13281. GROUTINGLINECODE,
  13282. GROUTINGLINENAME,
  13283. GMOULDTYPEID,
  13284. CANMANYTIMES,
  13285. GROUTINGLINEDETAILID,
  13286. GROUTINGMOULDCODE,
  13287. MOULDCODE,
  13288. REMARKS,
  13289. ACCOUNTID,
  13290. VALUEFLAG,
  13291. CREATETIME,
  13292. CREATEUSERID,
  13293. UPDATETIME,
  13294. UPDATEUSERID,
  13295. OPTIMESTAMP,
  13296. ISREFIRE,
  13297. GOODSLEVELID,
  13298. GOODSLEVELTYPEID,
  13299. DEFECTFLAG,
  13300. GROUTINGUSERID,
  13301. GROUTINGUSERCODE,
  13302. GROUTINGNUM,
  13303. KILNID,
  13304. KILNCODE,
  13305. KILNNAME,
  13306. KILNCARID,
  13307. KILNCARCODE,
  13308. KILNCARNAME,
  13309. KILNCARBATCHNO,
  13310. KILNCARPOSITION,
  13311. SPECIALREPAIRFLAG,
  13312. FLOWPROCEDUREID,
  13313. FLOWPROCEDURETIME,
  13314. PROCEDUREID,
  13315. PROCEDURETIME,
  13316. PRODUCTIONDATAID,
  13317. trashflag,
  13318. Deletedtime,
  13319. logoid,
  13320. IsReworkFlag,
  13321. SemiCheckID,
  13322. DELETEDUSERID,
  13323. DELETEDUSERCODE
  13324. )
  13325. select
  13326. BARCODE,
  13327. PRODUCTIONLINEID,
  13328. PRODUCTIONLINECODE,
  13329. PRODUCTIONLINENAME,
  13330. PROCEDUREMODEL,
  13331. MODELTYPE,
  13332. REWORKPROCEDUREID,
  13333. ISPUBLICBODY,
  13334. GOODSID,
  13335. GOODSCODE,
  13336. GOODSNAME,
  13337. USERID,
  13338. GROUTINGDAILYID,
  13339. GROUTINGDAILYDETAILID,
  13340. GROUTINGDATE,
  13341. GROUTINGLINEID,
  13342. GROUTINGLINECODE,
  13343. GROUTINGLINENAME,
  13344. GMOULDTYPEID,
  13345. CANMANYTIMES,
  13346. GROUTINGLINEDETAILID,
  13347. GROUTINGMOULDCODE,
  13348. MOULDCODE,
  13349. REMARKS,
  13350. ACCOUNTID,
  13351. VALUEFLAG,
  13352. CREATETIME,
  13353. CREATEUSERID,
  13354. UPDATETIME,
  13355. UPDATEUSERID,
  13356. OPTIMESTAMP,
  13357. ISREFIRE,
  13358. GOODSLEVELID,
  13359. GOODSLEVELTYPEID,
  13360. DEFECTFLAG,
  13361. GROUTINGUSERID,
  13362. GROUTINGUSERCODE,
  13363. GROUTINGNUM,
  13364. KILNID,
  13365. KILNCODE,
  13366. KILNNAME,
  13367. KILNCARID,
  13368. KILNCARCODE,
  13369. KILNCARNAME,
  13370. KILNCARBATCHNO,
  13371. KILNCARPOSITION,
  13372. SPECIALREPAIRFLAG,
  13373. FLOWPROCEDUREID,
  13374. FLOWPROCEDURETIME,
  13375. PROCEDUREID,
  13376. PROCEDURETIME,
  13377. PRODUCTIONDATAID,
  13378. INSCRAPFLAG,
  13379. sysdate,
  13380. logoid,
  13381. IsReworkFlag,
  13382. SemiCheckID,
  13383. " + sUserInfo.UserID + ",'" + sUserInfo.UserCode +
  13384. "' from tp_pm_inproduction p where p.barcode = :barcode";
  13385. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  13386. //删除在产数据
  13387. sql = "delete from tp_pm_inproduction p where p.barcode =:barcode";
  13388. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  13389. //删除在产生产数据
  13390. sql = "delete from tp_pm_productiondatain p where p.barcode =:barcode";
  13391. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  13392. }
  13393. if (returnRows <= 0)
  13394. {
  13395. oracleTrConn.Rollback();
  13396. oracleTrConn.Disconnect();
  13397. }
  13398. else
  13399. {
  13400. oracleTrConn.Commit();
  13401. oracleTrConn.Disconnect();
  13402. }
  13403. }
  13404. catch (Exception ex)
  13405. {
  13406. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  13407. {
  13408. oracleTrConn.Rollback();
  13409. oracleTrConn.Disconnect();
  13410. }
  13411. throw ex;
  13412. }
  13413. finally
  13414. {
  13415. if (oracleTrConn.ConnState == ConnectionState.Open)
  13416. {
  13417. oracleTrConn.Disconnect();
  13418. }
  13419. }
  13420. return returnRows;
  13421. }
  13422. #region 清除在产残留数据(批量)
  13423. /// <summary>
  13424. /// 清除在产残留数据(批量清除)
  13425. /// </summary>
  13426. /// <param name="barcodes">产品条码集</param>
  13427. /// <returns></returns>
  13428. public static int SaveClearAllInproduction(SUserInfo user, RPT010401_SE se)
  13429. {
  13430. int returnRows = 0;
  13431. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13432. try
  13433. {
  13434. List<OracleParameter> parameters = new List<OracleParameter>();
  13435. StringBuilder sql = new StringBuilder(GetClearInproductionData(user.AccountID));
  13436. if (se != null)
  13437. {
  13438. //生产线IDS
  13439. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  13440. {
  13441. sql.Append(" AND instr(','||:ProductionLineIDS||',',','||TP_PM_InProduction.ProductionLineID||',')>0 ");
  13442. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  13443. }
  13444. //完成工序IDS
  13445. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  13446. {
  13447. sql.Append(" AND instr(','||:ProcedureIDS||',',','||TP_PM_InProduction.ProcedureID||',')>0 ");
  13448. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  13449. }
  13450. // 生产时间--开始
  13451. if (se.UpdateTimeStart.HasValue)
  13452. {
  13453. sql.Append(" AND TP_PM_InProduction.Proceduretime >= :UpdateTimeStart ");
  13454. parameters.Add(new OracleParameter(":UpdateTimeStart", OracleDbType.Date, se.UpdateTimeStart.Value, ParameterDirection.Input));
  13455. }
  13456. // 生产时间--结束
  13457. if (se.UpdateTimeEnd.HasValue)
  13458. {
  13459. sql.Append(" AND TP_PM_InProduction.Proceduretime <= :UpdateTimeEnd ");
  13460. parameters.Add(new OracleParameter(":UpdateTimeEnd", OracleDbType.Date, se.UpdateTimeEnd.Value, ParameterDirection.Input));
  13461. }
  13462. // 是否清除报损待审产品
  13463. if (se.inscrapflag == 0)
  13464. {
  13465. sql.Append(" AND TP_PM_InProduction.inscrapflag=0 ");
  13466. }
  13467. else
  13468. {
  13469. sql.Append(" AND TP_PM_InProduction.inscrapflag in (0,1) ");
  13470. }
  13471. // 是否清除返工产品
  13472. if (se.IsReworkFlag == 0)
  13473. {
  13474. sql.Append(" AND TP_PM_InProduction.IsReworkFlag=0 ");
  13475. }
  13476. else
  13477. {
  13478. // chenxy 2019-10-02 半检返修 IsReworkFlag=2
  13479. //sql.Append(" AND TP_PM_InProduction.IsReworkFlag in (0,1) ");
  13480. }
  13481. }
  13482. //把在产数据插入到在产临时表中。(数据来源标识0:在产表)
  13483. string updatsql1 = @"insert into tp_pm_inproduction_tmp
  13484. (
  13485. BARCODE,
  13486. PRODUCTIONLINEID,
  13487. PRODUCTIONLINECODE,
  13488. PRODUCTIONLINENAME,
  13489. PROCEDUREMODEL,
  13490. MODELTYPE,
  13491. REWORKPROCEDUREID,
  13492. ISPUBLICBODY,
  13493. GOODSID,
  13494. GOODSCODE,
  13495. GOODSNAME,
  13496. USERID,
  13497. GROUTINGDAILYID,
  13498. GROUTINGDAILYDETAILID,
  13499. GROUTINGDATE,
  13500. GROUTINGLINEID,
  13501. GROUTINGLINECODE,
  13502. GROUTINGLINENAME,
  13503. GMOULDTYPEID,
  13504. CANMANYTIMES,
  13505. GROUTINGLINEDETAILID,
  13506. GROUTINGMOULDCODE,
  13507. MOULDCODE,
  13508. REMARKS,
  13509. ACCOUNTID,
  13510. VALUEFLAG,
  13511. CREATETIME,
  13512. CREATEUSERID,
  13513. UPDATETIME,
  13514. UPDATEUSERID,
  13515. OPTIMESTAMP,
  13516. ISREFIRE,
  13517. GOODSLEVELID,
  13518. GOODSLEVELTYPEID,
  13519. DEFECTFLAG,
  13520. GROUTINGUSERID,
  13521. GROUTINGUSERCODE,
  13522. GROUTINGNUM,
  13523. KILNID,
  13524. KILNCODE,
  13525. KILNNAME,
  13526. KILNCARID,
  13527. KILNCARCODE,
  13528. KILNCARNAME,
  13529. KILNCARBATCHNO,
  13530. KILNCARPOSITION,
  13531. SPECIALREPAIRFLAG,
  13532. FLOWPROCEDUREID,
  13533. FLOWPROCEDURETIME,
  13534. PROCEDUREID,
  13535. PROCEDURETIME,
  13536. PRODUCTIONDATAID,
  13537. trashflag,
  13538. Deletedtime,
  13539. logoid,
  13540. IsReworkFlag,
  13541. SemiCheckID,
  13542. DELETEDUSERID,
  13543. DELETEDUSERCODE
  13544. )
  13545. select
  13546. BARCODE,
  13547. PRODUCTIONLINEID,
  13548. PRODUCTIONLINECODE,
  13549. PRODUCTIONLINENAME,
  13550. PROCEDUREMODEL,
  13551. MODELTYPE,
  13552. REWORKPROCEDUREID,
  13553. ISPUBLICBODY,
  13554. GOODSID,
  13555. GOODSCODE,
  13556. GOODSNAME,
  13557. USERID,
  13558. GROUTINGDAILYID,
  13559. GROUTINGDAILYDETAILID,
  13560. GROUTINGDATE,
  13561. GROUTINGLINEID,
  13562. GROUTINGLINECODE,
  13563. GROUTINGLINENAME,
  13564. GMOULDTYPEID,
  13565. CANMANYTIMES,
  13566. GROUTINGLINEDETAILID,
  13567. GROUTINGMOULDCODE,
  13568. MOULDCODE,
  13569. REMARKS,
  13570. ACCOUNTID,
  13571. VALUEFLAG,
  13572. CREATETIME,
  13573. CREATEUSERID,
  13574. UPDATETIME,
  13575. UPDATEUSERID,
  13576. OPTIMESTAMP,
  13577. ISREFIRE,
  13578. GOODSLEVELID,
  13579. GOODSLEVELTYPEID,
  13580. DEFECTFLAG,
  13581. GROUTINGUSERID,
  13582. GROUTINGUSERCODE,
  13583. GROUTINGNUM,
  13584. KILNID,
  13585. KILNCODE,
  13586. KILNNAME,
  13587. KILNCARID,
  13588. KILNCARCODE,
  13589. KILNCARNAME,
  13590. KILNCARBATCHNO,
  13591. KILNCARPOSITION,
  13592. SPECIALREPAIRFLAG,
  13593. FLOWPROCEDUREID,
  13594. FLOWPROCEDURETIME,
  13595. PROCEDUREID,
  13596. PROCEDURETIME,
  13597. PRODUCTIONDATAID,
  13598. INSCRAPFLAG,
  13599. sysdate,
  13600. logoid,
  13601. IsReworkFlag,
  13602. SemiCheckID,"
  13603. + user.UserID + ",'" + user.UserCode +
  13604. "' from tp_pm_inproduction p where p.barcode in (" + sql.ToString() + ")";
  13605. returnRows += oracleTrConn.ExecuteNonQuery(updatsql1, parameters.ToArray());
  13606. //删除在产数据
  13607. updatsql1 = "delete from tp_pm_inproduction p where p.barcode in (" + sql.ToString() + ")";
  13608. returnRows += oracleTrConn.ExecuteNonQuery(updatsql1, parameters.ToArray());
  13609. //删除在产生产数据
  13610. updatsql1 = "delete from tp_pm_productiondatain p where p.barcode in (" + sql.ToString() + ")";
  13611. returnRows += oracleTrConn.ExecuteNonQuery(updatsql1, parameters.ToArray());
  13612. if (returnRows == 0)
  13613. {
  13614. oracleTrConn.Rollback();
  13615. oracleTrConn.Disconnect();
  13616. }
  13617. else
  13618. {
  13619. oracleTrConn.Commit();
  13620. oracleTrConn.Disconnect();
  13621. }
  13622. }
  13623. catch (Exception ex)
  13624. {
  13625. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  13626. {
  13627. oracleTrConn.Rollback();
  13628. oracleTrConn.Disconnect();
  13629. }
  13630. throw ex;
  13631. }
  13632. return returnRows;
  13633. }
  13634. /// <summary>
  13635. /// 获取批量数据
  13636. /// </summary>
  13637. /// <returns></returns>
  13638. private static string GetClearInproductionData(int accountid)
  13639. {
  13640. string selSql =
  13641. "SELECT " +
  13642. " TP_PM_InProduction.BarCode " +
  13643. " FROM TP_PM_InProduction " +
  13644. " Where TP_PM_InProduction.ValueFlag = '1' " +
  13645. " and TP_PM_InProduction.modeltype not in (1,2,3)" +
  13646. " and TP_PM_InProduction.AccountID= " + accountid;
  13647. return selSql;
  13648. }
  13649. #endregion
  13650. #region
  13651. /// <summary>
  13652. /// 清除在产加收站残留数据(清除选择)
  13653. /// </summary>
  13654. /// <param name="barcodes">产品条码集</param>
  13655. /// <returns></returns>
  13656. public static int SaveClearInproductionTrash(string barcodes, SUserInfo user)
  13657. {
  13658. int returnRows = 0;
  13659. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13660. try
  13661. {
  13662. string sql = "";
  13663. string[] subbarcode = barcodes.Split(',');
  13664. OracleParameter[] Paras = null;
  13665. for (int i = 0; i < subbarcode.Length; i++)
  13666. {
  13667. Paras = new OracleParameter[] {
  13668. new OracleParameter(":barcode",OracleDbType.NVarchar2,
  13669. subbarcode[i],ParameterDirection.Input)
  13670. };
  13671. //把在产数据插入到在产临时表中。(数据来源标识0:在产表)
  13672. sql = @"insert into tp_pm_inproduction_tmp
  13673. (
  13674. BARCODE,
  13675. PRODUCTIONLINEID,
  13676. PRODUCTIONLINECODE,
  13677. PRODUCTIONLINENAME,
  13678. PROCEDUREMODEL,
  13679. MODELTYPE,
  13680. REWORKPROCEDUREID,
  13681. ISPUBLICBODY,
  13682. GOODSID,
  13683. GOODSCODE,
  13684. GOODSNAME,
  13685. USERID,
  13686. GROUTINGDAILYID,
  13687. GROUTINGDAILYDETAILID,
  13688. GROUTINGDATE,
  13689. GROUTINGLINEID,
  13690. GROUTINGLINECODE,
  13691. GROUTINGLINENAME,
  13692. GMOULDTYPEID,
  13693. CANMANYTIMES,
  13694. GROUTINGLINEDETAILID,
  13695. GROUTINGMOULDCODE,
  13696. MOULDCODE,
  13697. REMARKS,
  13698. ACCOUNTID,
  13699. VALUEFLAG,
  13700. CREATETIME,
  13701. CREATEUSERID,
  13702. UPDATETIME,
  13703. UPDATEUSERID,
  13704. OPTIMESTAMP,
  13705. ISREFIRE,
  13706. GOODSLEVELID,
  13707. GOODSLEVELTYPEID,
  13708. DEFECTFLAG,
  13709. GROUTINGUSERID,
  13710. GROUTINGUSERCODE,
  13711. GROUTINGNUM,
  13712. KILNID,
  13713. KILNCODE,
  13714. KILNNAME,
  13715. KILNCARID,
  13716. KILNCARCODE,
  13717. KILNCARNAME,
  13718. KILNCARBATCHNO,
  13719. KILNCARPOSITION,
  13720. SPECIALREPAIRFLAG,
  13721. FLOWPROCEDUREID,
  13722. FLOWPROCEDURETIME,
  13723. PROCEDUREID,
  13724. PROCEDURETIME,
  13725. PRODUCTIONDATAID,
  13726. trashflag,
  13727. Deletedtime,
  13728. logoid,
  13729. IsReworkFlag,
  13730. SemiCheckID,
  13731. DELETEDUSERID,
  13732. DELETEDUSERCODE
  13733. )
  13734. select
  13735. BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME,
  13736. PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID,
  13737. ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME,
  13738. USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE,
  13739. GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID,
  13740. CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE,
  13741. REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME,
  13742. CREATEUSERID, UPDATETIME, UPDATEUSERID,optimestamp,
  13743. ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG,
  13744. GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM,
  13745. KILNID, KILNCODE, KILNNAME, KILNCARID,
  13746. KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID
  13747. ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,1,sysdate,logoid,IsReworkFlag,SemiCheckID,"
  13748. + user.UserID + ",'" + user.UserCode +
  13749. "' from TP_PM_InProductionTrash p where p.barcode = :barcode";
  13750. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  13751. //删除在产回收站数据
  13752. sql = "delete from TP_PM_InProductionTrash p where p.barcode =:barcode";
  13753. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  13754. //删除在产生产数据
  13755. sql = "delete from tp_pm_productiondatain p where p.barcode =:barcode";
  13756. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  13757. }
  13758. if (returnRows == 0)
  13759. {
  13760. oracleTrConn.Rollback();
  13761. oracleTrConn.Disconnect();
  13762. }
  13763. else
  13764. {
  13765. oracleTrConn.Commit();
  13766. oracleTrConn.Disconnect();
  13767. }
  13768. }
  13769. catch (Exception ex)
  13770. {
  13771. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  13772. {
  13773. oracleTrConn.Rollback();
  13774. oracleTrConn.Disconnect();
  13775. }
  13776. throw ex;
  13777. }
  13778. finally
  13779. {
  13780. if (oracleTrConn.ConnState == ConnectionState.Open)
  13781. {
  13782. oracleTrConn.Disconnect();
  13783. }
  13784. }
  13785. return returnRows;
  13786. }
  13787. #endregion
  13788. #region 清除在产回收站残留数据(批量)
  13789. /// <summary>
  13790. /// 清除在产残留数据(批量清除)
  13791. /// </summary>
  13792. /// <param name="barcodes">产品条码集</param>
  13793. /// <returns></returns>
  13794. public static int SaveClearAllInproductionTrash(SUserInfo user, FPM2110_SE se)
  13795. {
  13796. int returnRows = 0;
  13797. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13798. try
  13799. {
  13800. List<OracleParameter> parameters = new List<OracleParameter>();
  13801. StringBuilder sql = new StringBuilder(GetClearInproductionTrashData(user.AccountID));
  13802. if (se != null)
  13803. {
  13804. //生产线IDS
  13805. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  13806. {
  13807. sql.Append(" AND instr(','||:ProductionLineIDS||',',','||TP_PM_InProductionTrash.ProductionLineID||',')>0 ");
  13808. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  13809. }
  13810. //完成工序IDS
  13811. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  13812. {
  13813. sql.Append(" AND instr(','||:ProcedureIDS||',',','||TP_PM_InProductionTrash.ProcedureID||',')>0 ");
  13814. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  13815. }
  13816. // 生产时间--开始
  13817. if (se.UpdateTimeStart.HasValue)
  13818. {
  13819. sql.Append(" AND TP_PM_InProductionTrash.Proceduretime >= :UpdateTimeStart ");
  13820. parameters.Add(new OracleParameter(":UpdateTimeStart", OracleDbType.Date, se.UpdateTimeStart.Value, ParameterDirection.Input));
  13821. }
  13822. // 生产时间--结束
  13823. if (se.UpdateTimeEnd.HasValue)
  13824. {
  13825. sql.Append(" AND TP_PM_InProductionTrash.Proceduretime <= :UpdateTimeEnd ");
  13826. parameters.Add(new OracleParameter(":UpdateTimeEnd", OracleDbType.Date, se.UpdateTimeEnd.Value, ParameterDirection.Input));
  13827. }
  13828. //报废日期开始
  13829. if (se.ScrapDataStart.HasValue)
  13830. {
  13831. sql.Append(" AND TP_PM_SCRAPPRODUCT.SCRAPDATE >= trunc(:ScrapDateStart) ");
  13832. parameters.Add(new OracleParameter(":ScrapDateStart", OracleDbType.Date, se.ScrapDataStart.Value, ParameterDirection.Input));
  13833. }
  13834. //报废日期结束
  13835. if (se.ScrapDataEnd.HasValue)
  13836. {
  13837. sql.Append(" AND TP_PM_SCRAPPRODUCT.SCRAPDATE <= trunc(:ScrapDateEnd)");
  13838. parameters.Add(new OracleParameter(":ScrapDateEnd", OracleDbType.Date, se.ScrapDataEnd.Value, ParameterDirection.Input));
  13839. }
  13840. // 产品分级
  13841. sql.Append(" AND TP_PM_SCRAPPRODUCT.GOODSLEVELTYPEID = :GooddLevelTypeID ");
  13842. parameters.Add(new OracleParameter(":GooddLevelTypeID", OracleDbType.Int32, se.GooddLevelTypeID, ParameterDirection.Input));
  13843. }
  13844. //把在产数据插入到在产临时表中。(数据来源标识0:在产表)
  13845. string updatsql1 = @"insert into tp_pm_inproduction_tmp
  13846. (
  13847. BARCODE,
  13848. PRODUCTIONLINEID,
  13849. PRODUCTIONLINECODE,
  13850. PRODUCTIONLINENAME,
  13851. PROCEDUREMODEL,
  13852. MODELTYPE,
  13853. REWORKPROCEDUREID,
  13854. ISPUBLICBODY,
  13855. GOODSID,
  13856. GOODSCODE,
  13857. GOODSNAME,
  13858. USERID,
  13859. GROUTINGDAILYID,
  13860. GROUTINGDAILYDETAILID,
  13861. GROUTINGDATE,
  13862. GROUTINGLINEID,
  13863. GROUTINGLINECODE,
  13864. GROUTINGLINENAME,
  13865. GMOULDTYPEID,
  13866. CANMANYTIMES,
  13867. GROUTINGLINEDETAILID,
  13868. GROUTINGMOULDCODE,
  13869. MOULDCODE,
  13870. REMARKS,
  13871. ACCOUNTID,
  13872. VALUEFLAG,
  13873. CREATETIME,
  13874. CREATEUSERID,
  13875. UPDATETIME,
  13876. UPDATEUSERID,
  13877. OPTIMESTAMP,
  13878. ISREFIRE,
  13879. GOODSLEVELID,
  13880. GOODSLEVELTYPEID,
  13881. DEFECTFLAG,
  13882. GROUTINGUSERID,
  13883. GROUTINGUSERCODE,
  13884. GROUTINGNUM,
  13885. KILNID,
  13886. KILNCODE,
  13887. KILNNAME,
  13888. KILNCARID,
  13889. KILNCARCODE,
  13890. KILNCARNAME,
  13891. KILNCARBATCHNO,
  13892. KILNCARPOSITION,
  13893. SPECIALREPAIRFLAG,
  13894. FLOWPROCEDUREID,
  13895. FLOWPROCEDURETIME,
  13896. PROCEDUREID,
  13897. PROCEDURETIME,
  13898. PRODUCTIONDATAID,
  13899. trashflag,
  13900. Deletedtime,
  13901. logoid,
  13902. IsReworkFlag,
  13903. SemiCheckID,
  13904. DELETEDUSERID,
  13905. DELETEDUSERCODE
  13906. )
  13907. select
  13908. BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME,
  13909. PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID,
  13910. ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME,
  13911. USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE,
  13912. GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID,
  13913. CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE,
  13914. REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME,
  13915. CREATEUSERID, UPDATETIME, UPDATEUSERID,optimestamp,
  13916. ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG,
  13917. GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM,
  13918. KILNID, KILNCODE, KILNNAME, KILNCARID,
  13919. KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID
  13920. ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,1,sysdate,logoid,IsReworkFlag,SemiCheckID,"
  13921. + user.UserID + ",'" + user.UserCode +
  13922. "' from TP_PM_InProductionTrash p where p.barcode in (" + sql.ToString() + ")";
  13923. returnRows += oracleTrConn.ExecuteNonQuery(updatsql1, parameters.ToArray());
  13924. //删除在产数据
  13925. updatsql1 = "delete from TP_PM_InProductionTrash p where p.barcode in (" + sql.ToString() + ")";
  13926. returnRows += oracleTrConn.ExecuteNonQuery(updatsql1, parameters.ToArray());
  13927. //删除在产生产数据
  13928. updatsql1 = "delete from tp_pm_productiondatain p where p.barcode in (" + sql.ToString() + ")";
  13929. returnRows += oracleTrConn.ExecuteNonQuery(updatsql1, parameters.ToArray());
  13930. if (returnRows == 0)
  13931. {
  13932. oracleTrConn.Rollback();
  13933. oracleTrConn.Disconnect();
  13934. }
  13935. else
  13936. {
  13937. oracleTrConn.Commit();
  13938. oracleTrConn.Disconnect();
  13939. }
  13940. }
  13941. catch (Exception ex)
  13942. {
  13943. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  13944. {
  13945. oracleTrConn.Rollback();
  13946. oracleTrConn.Disconnect();
  13947. }
  13948. throw ex;
  13949. }
  13950. finally
  13951. {
  13952. if (oracleTrConn.ConnState == ConnectionState.Open)
  13953. {
  13954. oracleTrConn.Disconnect();
  13955. }
  13956. }
  13957. return returnRows;
  13958. }
  13959. /// <summary>
  13960. /// 获取批量数据
  13961. /// </summary>
  13962. /// <returns></returns>
  13963. private static string GetClearInproductionTrashData(int accountid)
  13964. {
  13965. string selSql =
  13966. "SELECT " +
  13967. " TP_PM_InProductionTrash.BarCode " +
  13968. " FROM TP_PM_InProductionTrash " +
  13969. " left join tp_pm_scrapproduct " +
  13970. " on tp_pm_scrapproduct.barcode=TP_PM_InProductionTrash.barcode " +
  13971. " Where 1=1 and TP_PM_InProductionTrash.ValueFlag = 1 " +
  13972. " and TP_PM_InProductionTrash.AccountID= " + accountid;
  13973. return selSql;
  13974. }
  13975. #endregion
  13976. /// <summary>
  13977. /// 清除在产临时表残留数据(清除选择)
  13978. /// </summary>
  13979. /// <param name="barcodes">产品条码集</param>
  13980. /// <returns></returns>
  13981. public static int SaveClearInproductionTmp(string barcodes)
  13982. {
  13983. int returnRows = 0;
  13984. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  13985. try
  13986. {
  13987. string sql = "";
  13988. string[] subbarcode = barcodes.Split(',');
  13989. OracleParameter[] Paras = null;
  13990. for (int i = 0; i < subbarcode.Length; i++)
  13991. {
  13992. Paras = new OracleParameter[] {
  13993. new OracleParameter(":barcode",OracleDbType.NVarchar2,
  13994. subbarcode[i],ParameterDirection.Input)
  13995. };
  13996. //删除在产临时表数据
  13997. sql = "delete from TP_PM_InProduction_Tmp p where p.barcode =:barcode";
  13998. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  13999. }
  14000. if (returnRows == 0)
  14001. {
  14002. oracleTrConn.Rollback();
  14003. oracleTrConn.Disconnect();
  14004. }
  14005. else
  14006. {
  14007. oracleTrConn.Commit();
  14008. oracleTrConn.Disconnect();
  14009. }
  14010. }
  14011. catch (Exception ex)
  14012. {
  14013. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  14014. {
  14015. oracleTrConn.Rollback();
  14016. oracleTrConn.Disconnect();
  14017. }
  14018. throw ex;
  14019. }
  14020. finally
  14021. {
  14022. if (oracleTrConn.ConnState == ConnectionState.Open)
  14023. {
  14024. oracleTrConn.Disconnect();
  14025. }
  14026. }
  14027. return returnRows;
  14028. }
  14029. #region 清除在产回收站残留数据(批量)
  14030. /// <summary>
  14031. /// 清除在产残留数据(批量清除)
  14032. /// </summary>
  14033. /// <param name="barcodes">产品条码集</param>
  14034. /// <returns></returns>
  14035. public static int SaveClearAllInproductionTmp(SUserInfo user, FPM2112_SE se)
  14036. {
  14037. int returnRows = 0;
  14038. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  14039. try
  14040. {
  14041. List<OracleParameter> parameters = new List<OracleParameter>();
  14042. StringBuilder sql = new StringBuilder(GetClearInproductionTmpData(user.AccountID));
  14043. if (se != null)
  14044. {
  14045. //生产线IDS
  14046. if (!string.IsNullOrEmpty(se.ProductionLineIDS))
  14047. {
  14048. sql.Append(" AND instr(','||:ProductionLineIDS||',',','||TP_PM_InProduction_Tmp.ProductionLineID||',')>0 ");
  14049. parameters.Add(new OracleParameter(":ProductionLineIDS", OracleDbType.NVarchar2, se.ProductionLineIDS, ParameterDirection.Input));
  14050. }
  14051. //完成工序IDS
  14052. if (!string.IsNullOrEmpty(se.ProcedureIDS))
  14053. {
  14054. sql.Append(" AND instr(','||:ProcedureIDS||',',','||TP_PM_InProduction_Tmp.ProcedureID||',')>0 ");
  14055. parameters.Add(new OracleParameter(":ProcedureIDS", OracleDbType.NVarchar2, se.ProcedureIDS, ParameterDirection.Input));
  14056. }
  14057. // 生产时间--开始
  14058. if (se.UpdateTimeStart.HasValue)
  14059. {
  14060. sql.Append(" AND TP_PM_InProduction_Tmp.Proceduretime >= :UpdateTimeStart ");
  14061. parameters.Add(new OracleParameter(":UpdateTimeStart", OracleDbType.Date, se.UpdateTimeStart.Value, ParameterDirection.Input));
  14062. }
  14063. // 生产时间--结束
  14064. if (se.UpdateTimeEnd.HasValue)
  14065. {
  14066. sql.Append(" AND TP_PM_InProduction_Tmp.Proceduretime <= :UpdateTimeEnd ");
  14067. parameters.Add(new OracleParameter(":UpdateTimeEnd", OracleDbType.Date, se.UpdateTimeEnd.Value, ParameterDirection.Input));
  14068. }
  14069. //报废日期开始
  14070. if (se.ScrapDataStart.HasValue)
  14071. {
  14072. sql.Append(" AND TP_PM_SCRAPPRODUCT.SCRAPDATE >= trunc(:ScrapDateStart) ");
  14073. parameters.Add(new OracleParameter(":ScrapDateStart", OracleDbType.Date, se.ScrapDataStart.Value, ParameterDirection.Input));
  14074. }
  14075. //报废日期结束
  14076. if (se.ScrapDataEnd.HasValue)
  14077. {
  14078. sql.Append(" AND TP_PM_SCRAPPRODUCT.SCRAPDATE <= trunc(:ScrapDateEnd)");
  14079. parameters.Add(new OracleParameter(":ScrapDateEnd", OracleDbType.Date, se.ScrapDataEnd.Value, ParameterDirection.Input));
  14080. }
  14081. if (se.GooddLevelTypeID != null)
  14082. {
  14083. // 产品分级
  14084. sql.Append(" AND TP_PM_SCRAPPRODUCT.GOODSLEVELTYPEID = :GooddLevelTypeID ");
  14085. parameters.Add(new OracleParameter(":GooddLevelTypeID", OracleDbType.Int32, se.GooddLevelTypeID, ParameterDirection.Input));
  14086. }
  14087. //在产or 回收站
  14088. sql.Append(" AND TP_PM_InProduction_Tmp.TrashFlag = :TrashFlag ");
  14089. parameters.Add(new OracleParameter(":TrashFlag", OracleDbType.Int32, se.TrashFlag, ParameterDirection.Input));
  14090. }
  14091. //删除在产临时表数据
  14092. string updatsql1 = "delete from TP_PM_InProduction_Tmp p where p.barcode in (" + sql.ToString() + ")";
  14093. returnRows += oracleTrConn.ExecuteNonQuery(updatsql1, parameters.ToArray());
  14094. if (returnRows == 0)
  14095. {
  14096. oracleTrConn.Rollback();
  14097. oracleTrConn.Disconnect();
  14098. }
  14099. else
  14100. {
  14101. oracleTrConn.Commit();
  14102. oracleTrConn.Disconnect();
  14103. }
  14104. }
  14105. catch (Exception ex)
  14106. {
  14107. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  14108. {
  14109. oracleTrConn.Rollback();
  14110. oracleTrConn.Disconnect();
  14111. }
  14112. throw ex;
  14113. }
  14114. finally
  14115. {
  14116. if (oracleTrConn.ConnState == ConnectionState.Open)
  14117. {
  14118. oracleTrConn.Disconnect();
  14119. }
  14120. }
  14121. return returnRows;
  14122. }
  14123. /// <summary>
  14124. /// 获取批量数据
  14125. /// </summary>
  14126. /// <returns></returns>
  14127. private static string GetClearInproductionTmpData(int accountid)
  14128. {
  14129. string selSql =
  14130. "SELECT " +
  14131. " TP_PM_InProduction_Tmp.BarCode " +
  14132. " FROM TP_PM_InProduction_Tmp " +
  14133. " left join tp_pm_scrapproduct " +
  14134. " on tp_pm_scrapproduct.barcode=TP_PM_InProduction_Tmp.barcode " +
  14135. " Where 1=1 and TP_PM_InProduction_Tmp.ValueFlag = 1 " +
  14136. " and TP_PM_InProduction_Tmp.AccountID= " + accountid;
  14137. return selSql;
  14138. }
  14139. #endregion
  14140. #region 恢复数据
  14141. /// <summary>
  14142. /// 恢复数据
  14143. /// </summary>
  14144. /// <param name="barcodes">产品条码集</param>
  14145. /// <returns></returns>
  14146. public static int ResetBarCode(string barcode)
  14147. {
  14148. int returnRows = 0;
  14149. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  14150. try
  14151. {
  14152. string sql = "select trashflag from Tp_Pm_Inproduction_Tmp where barcode=:barcode";
  14153. OracleParameter[] Paras = Paras = new OracleParameter[] {
  14154. new OracleParameter(":barcode",OracleDbType.NVarchar2,
  14155. barcode,ParameterDirection.Input)
  14156. };
  14157. DataSet ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  14158. if (ds != null && ds.Tables[0].Rows.Count == 0)
  14159. {
  14160. oracleTrConn.Rollback();
  14161. oracleTrConn.Disconnect();
  14162. return -1; //此条码没有清除,不能恢复
  14163. }
  14164. if (ds.Tables[0].Rows[0]["trashflag"].ToString() == "0") //在产删除
  14165. {
  14166. sql = @"insert into tp_pm_inproduction select
  14167. BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME,
  14168. PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID,
  14169. ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME,
  14170. USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE,
  14171. GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID,
  14172. CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE,
  14173. REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME,
  14174. CREATEUSERID, UPDATETIME, UPDATEUSERID,optimestamp,
  14175. ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG,
  14176. GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM,
  14177. KILNID, KILNCODE, KILNNAME, KILNCARID,
  14178. KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID
  14179. ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,0,logoid,IsReworkFlag,SemiCheckID
  14180. from TP_PM_InProduction_Tmp p where p.barcode = :barcode";
  14181. }
  14182. else
  14183. {
  14184. sql = @"insert into tp_pm_inproductiontrash select
  14185. BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME,
  14186. PROCEDUREMODEL, MODELTYPE,
  14187. defectflag,
  14188. REWORKPROCEDUREID,
  14189. ISPUBLICBODY,
  14190. ISRefire,
  14191. GOODSLEVELID, GOODSLEVELTYPEID,
  14192. GOODSID, GOODSCODE, GOODSNAME,
  14193. USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE,
  14194. GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID,
  14195. CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE,
  14196. GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM,
  14197. REMARKS,
  14198. KILNID, KILNCODE, KILNNAME, KILNCARID,
  14199. KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,
  14200. ACCOUNTID, VALUEFLAG, CREATETIME,
  14201. CREATEUSERID, UPDATETIME, UPDATEUSERID,optimestamp,
  14202. SpecialRepairFlag,FlowProcedureID
  14203. ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,logoid,IsReworkFlag,SemiCheckID
  14204. from TP_PM_InProduction_Tmp p where p.barcode = :barcode";
  14205. }
  14206. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  14207. //将生产数据表中的数据插入到在产生产数据表中
  14208. sql = @"insert into tp_pm_productiondatain
  14209. select
  14210. pd.PRODUCTIONDATAID,
  14211. pd.BARCODE,
  14212. pd.CENTRALIZEDBATCHNO,
  14213. pd.PRODUCTIONLINEID,
  14214. pd.PRODUCTIONLINECODE,
  14215. pd.PRODUCTIONLINENAME,
  14216. pd.PROCEDUREID,
  14217. pd.PROCEDURECODE,
  14218. pd.PROCEDURENAME,
  14219. pd.PROCEDUREMODEL,
  14220. pd.MODELTYPE,
  14221. pd.PIECETYPE,
  14222. pd.ISREWORKED,
  14223. pd.NODETYPE,
  14224. pd.ISPUBLICBODY,
  14225. pd.ISREFIRE,
  14226. pd.ORGANIZATIONID,
  14227. pd.GOODSID,
  14228. pd.GOODSCODE,
  14229. pd.GOODSNAME,
  14230. pd.USERID,
  14231. pd.USERCODE,
  14232. pd.USERNAME,
  14233. pd.KILNID,
  14234. pd.KILNCODE,
  14235. pd.KILNNAME,
  14236. pd.KILNCARID,
  14237. pd.KILNCARCODE,
  14238. pd.KILNCARNAME,
  14239. pd.KILNCARBATCHNO,
  14240. pd.KILNCARPOSITION,
  14241. pd.REWORKPROCEDUREID,
  14242. pd.REWORKPROCEDURECODE,
  14243. pd.REWORKPROCEDURENAME,
  14244. pd.REMARKS,pd.ACCOUNTDATE,pd.SETTLEMENTFLAG,pd.ACCOUNTID,pd.VALUEFLAG,
  14245. pd.CREATETIME,pd.CREATEUSERID,pd.UPDATETIME,pd.UPDATEUSERID,pd.OPTIMESTAMP,
  14246. pd.GOODSLEVELID,pd.GOODSLEVELTYPEID,pd.GROUTINGDATE,pd.GROUTINGMOULDCODE,pd.MOULDCODE,
  14247. pd.GROUTINGUSERID,pd.GROUTINGUSERCODE,pd.GROUTINGNUM,pd.GROUTINGDAILYID,pd.GROUTINGDAILYDETAILID,
  14248. pd.GROUTINGLINEID,pd.GROUTINGLINECODE,pd.GROUTINGLINENAME,pd.GMOULDTYPEID,pd.CANMANYTIMES,
  14249. pd.GROUTINGLINEDETAILID,pd.SPECIALREPAIRFLAG,pd.CLASSESSETTINGID,
  14250. '1',pd.LOGOID,
  14251. pd.BackOutTime,pd.BackOutUserID,pd.BackOutUserCode,pd.checktime
  14252. from tp_pm_productiondata pd
  14253. where pd.barcode = :barcode
  14254. and pd.productiondataid not in
  14255. (select pp.productiondataid
  14256. from tp_pm_productiondatain pp
  14257. where pp.barcode = :barcode)";
  14258. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  14259. //删除在产临时表数据
  14260. sql = "delete from TP_PM_InProduction_Tmp p where p.barcode =:barcode";
  14261. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  14262. if (returnRows == 0)
  14263. {
  14264. oracleTrConn.Rollback();
  14265. oracleTrConn.Disconnect();
  14266. }
  14267. else
  14268. {
  14269. oracleTrConn.Commit();
  14270. oracleTrConn.Disconnect();
  14271. }
  14272. }
  14273. catch (Exception ex)
  14274. {
  14275. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  14276. {
  14277. oracleTrConn.Rollback();
  14278. oracleTrConn.Disconnect();
  14279. }
  14280. throw ex;
  14281. }
  14282. finally
  14283. {
  14284. if (oracleTrConn.ConnState == ConnectionState.Open)
  14285. {
  14286. oracleTrConn.Disconnect();
  14287. }
  14288. }
  14289. return returnRows;
  14290. }
  14291. /// <summary>
  14292. /// 批量恢复数据
  14293. /// </summary>
  14294. /// <param name="barcodes">产品条码集</param>
  14295. /// <returns></returns>
  14296. public static int ResetSelectedBarCode(string barcodes)
  14297. {
  14298. int returnRows = 0;
  14299. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  14300. try
  14301. {
  14302. string sql = "";
  14303. string[] subbarcode = barcodes.Split(',');
  14304. OracleParameter[] Paras = null;
  14305. DataSet ds = null;
  14306. for (int i = 0; i < subbarcode.Length; i++)
  14307. {
  14308. sql = "select trashflag from Tp_Pm_Inproduction_Tmp where barcode=:barcode";
  14309. Paras = Paras = new OracleParameter[] {
  14310. new OracleParameter(":barcode",OracleDbType.NVarchar2,
  14311. subbarcode[i],ParameterDirection.Input)
  14312. };
  14313. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  14314. if (ds != null && ds.Tables[0].Rows.Count == 0)
  14315. {
  14316. oracleTrConn.Rollback();
  14317. oracleTrConn.Disconnect();
  14318. return -1; //此条码没有清除,不能恢复
  14319. }
  14320. if (ds.Tables[0].Rows[0]["trashflag"].ToString() == "0") //在产删除
  14321. {
  14322. sql = @"insert into tp_pm_inproduction select
  14323. BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME,
  14324. PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID,
  14325. ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME,
  14326. USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE,
  14327. GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID,
  14328. CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE,
  14329. REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME,
  14330. CREATEUSERID, UPDATETIME, UPDATEUSERID,optimestamp,
  14331. ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG,
  14332. GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM,
  14333. KILNID, KILNCODE, KILNNAME, KILNCARID,
  14334. KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID
  14335. ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,0,logoid,IsReworkFlag,SemiCheckID
  14336. from TP_PM_InProduction_Tmp p where p.barcode = :barcode";
  14337. }
  14338. else
  14339. {
  14340. sql = @"insert into tp_pm_inproductiontrash select
  14341. BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME,
  14342. PROCEDUREMODEL, MODELTYPE,
  14343. defectflag,
  14344. REWORKPROCEDUREID,
  14345. ISPUBLICBODY,
  14346. ISRefire,
  14347. GOODSLEVELID, GOODSLEVELTYPEID,
  14348. GOODSID, GOODSCODE, GOODSNAME,
  14349. USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE,
  14350. GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID,
  14351. CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE,
  14352. GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM,
  14353. REMARKS,
  14354. KILNID, KILNCODE, KILNNAME, KILNCARID,
  14355. KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,
  14356. ACCOUNTID, VALUEFLAG, CREATETIME,
  14357. CREATEUSERID, UPDATETIME, UPDATEUSERID,optimestamp,
  14358. SpecialRepairFlag,FlowProcedureID
  14359. ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,logoid,IsReworkFlag,SemiCheckID
  14360. from TP_PM_InProduction_Tmp p where p.barcode = :barcode";
  14361. }
  14362. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  14363. //将生产数据表中的数据插入到在产生产数据表中
  14364. sql = @"insert into tp_pm_productiondatain
  14365. select pd.PRODUCTIONDATAID,
  14366. pd.BARCODE,
  14367. pd.CENTRALIZEDBATCHNO,
  14368. pd.PRODUCTIONLINEID,
  14369. pd.PRODUCTIONLINECODE,
  14370. pd.PRODUCTIONLINENAME,
  14371. pd.PROCEDUREID,
  14372. pd.PROCEDURECODE,
  14373. pd.PROCEDURENAME,
  14374. pd.PROCEDUREMODEL,
  14375. pd.MODELTYPE,
  14376. pd.PIECETYPE,
  14377. pd.ISREWORKED,
  14378. pd.NODETYPE,
  14379. pd.ISPUBLICBODY,
  14380. pd.ISREFIRE,
  14381. pd.ORGANIZATIONID,
  14382. pd.GOODSID,
  14383. pd.GOODSCODE,
  14384. pd.GOODSNAME,
  14385. pd.USERID,
  14386. pd.USERCODE,
  14387. pd.USERNAME,
  14388. pd.KILNID,
  14389. pd.KILNCODE,
  14390. pd.KILNNAME,
  14391. pd.KILNCARID,
  14392. pd.KILNCARCODE,
  14393. pd.KILNCARNAME,
  14394. pd.KILNCARBATCHNO,
  14395. pd.KILNCARPOSITION,
  14396. pd.REWORKPROCEDUREID,
  14397. pd.REWORKPROCEDURECODE,
  14398. pd.REWORKPROCEDURENAME,
  14399. pd.REMARKS,pd.ACCOUNTDATE,pd.SETTLEMENTFLAG,pd.ACCOUNTID,pd.VALUEFLAG,
  14400. pd.CREATETIME,pd.CREATEUSERID,pd.UPDATETIME,pd.UPDATEUSERID,pd.OPTIMESTAMP,
  14401. pd.GOODSLEVELID,pd.GOODSLEVELTYPEID,pd.GROUTINGDATE,pd.GROUTINGMOULDCODE,pd.MOULDCODE,
  14402. pd.GROUTINGUSERID,pd.GROUTINGUSERCODE,pd.GROUTINGNUM,pd.GROUTINGDAILYID,pd.GROUTINGDAILYDETAILID,
  14403. pd.GROUTINGLINEID,pd.GROUTINGLINECODE,pd.GROUTINGLINENAME,pd.GMOULDTYPEID,pd.CANMANYTIMES,
  14404. pd.GROUTINGLINEDETAILID,pd.SPECIALREPAIRFLAG,pd.CLASSESSETTINGID,
  14405. '1',pd.LOGOID,
  14406. pd.BackOutTime,pd.BackOutUserID,pd.BackOutUserCode,pd.checktime
  14407. from tp_pm_productiondata pd
  14408. where pd.barcode = :barcode
  14409. and pd.productiondataid not in
  14410. (select pp.productiondataid
  14411. from tp_pm_productiondatain pp
  14412. where pp.barcode = :barcode)";
  14413. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  14414. //删除在产临时表数据
  14415. sql = "delete from TP_PM_InProduction_Tmp p where p.barcode =:barcode";
  14416. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  14417. }
  14418. if (returnRows == 0)
  14419. {
  14420. oracleTrConn.Rollback();
  14421. oracleTrConn.Disconnect();
  14422. }
  14423. else
  14424. {
  14425. oracleTrConn.Commit();
  14426. oracleTrConn.Disconnect();
  14427. }
  14428. }
  14429. catch (Exception ex)
  14430. {
  14431. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  14432. {
  14433. oracleTrConn.Rollback();
  14434. oracleTrConn.Disconnect();
  14435. }
  14436. throw ex;
  14437. }
  14438. finally
  14439. {
  14440. if (oracleTrConn.ConnState == ConnectionState.Open)
  14441. {
  14442. oracleTrConn.Disconnect();
  14443. }
  14444. }
  14445. return returnRows;
  14446. }
  14447. #endregion
  14448. /// <summary>
  14449. /// 撤销特殊工序撤销
  14450. /// </summary>
  14451. /// <param name="barcode">产品条码</param>
  14452. /// <returns></returns>
  14453. public static ServiceResultEntity AddChancelBarCode(string barcode, SUserInfo sUserInfo)
  14454. {
  14455. ServiceResultEntity entity = new ServiceResultEntity();
  14456. int returnRows = 0;
  14457. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  14458. try
  14459. {
  14460. // 转换注浆条码
  14461. barcode = CommonModuleLogic.CommonModuleLogic.GetBarcode(oracleTrConn, barcode, sUserInfo);
  14462. DateTime? flowProcedureTime = null;
  14463. // 1 条码是否有效
  14464. string sql = "select 1 from TP_PM_GroutingDailyDetail where barcode=:barcode and valueflag=1";
  14465. OracleParameter[] Paras = new OracleParameter[] {
  14466. new OracleParameter(":barcode",OracleDbType.Varchar2,
  14467. barcode,ParameterDirection.Input)
  14468. };
  14469. DataSet ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  14470. if (ds.Tables[0].Rows.Count == 0)
  14471. {
  14472. //无效条码
  14473. returnRows = -1;
  14474. oracleTrConn.Rollback();
  14475. oracleTrConn.Disconnect();
  14476. entity.Result = returnRows;
  14477. return entity;
  14478. }
  14479. // 2.看看是否在产,如果在产看看是否已经损坯标识
  14480. int? ProcedureID = null;
  14481. // 撤销时,需要判定当前工序,而不是流程工序,干补时,当前工序是干补,流程工序是报损时的工序。
  14482. //sql = "select InScrapFlag,flowProcedureID,IsReworkFlag,flowProcedureTime from TP_PM_InProduction where barcode=:barcode and valueflag=1";
  14483. sql = "select InScrapFlag,ProcedureID,IsReworkFlag,ProcedureTime from TP_PM_InProduction where barcode=:barcode and valueflag=1";
  14484. Paras = new OracleParameter[] {
  14485. new OracleParameter(":barcode",OracleDbType.Varchar2,
  14486. barcode,ParameterDirection.Input)
  14487. };
  14488. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  14489. if (ds.Tables[0].Rows.Count == 0) //不存在在产信息
  14490. {
  14491. // 不在产,看看是否有成品
  14492. sql = @"select 1 from TP_PM_FinishedProduct where barcode=:barcode";
  14493. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  14494. if (ds.Tables[0].Rows.Count > 0)
  14495. {
  14496. //生产完成
  14497. returnRows = -2;
  14498. oracleTrConn.Rollback();
  14499. oracleTrConn.Disconnect();
  14500. entity.Result = returnRows;
  14501. return entity;
  14502. }
  14503. else
  14504. {
  14505. //条码不在生产线上
  14506. returnRows = -7;
  14507. oracleTrConn.Rollback();
  14508. oracleTrConn.Disconnect();
  14509. entity.Result = returnRows;
  14510. return entity;
  14511. }
  14512. }
  14513. else
  14514. {
  14515. if (ds.Tables[0].Rows[0]["InScrapFlag"].ToString() == "1")
  14516. {
  14517. //申请报废
  14518. returnRows = -3;
  14519. oracleTrConn.Rollback();
  14520. oracleTrConn.Disconnect();
  14521. entity.Result = returnRows;
  14522. return entity;
  14523. }
  14524. // chenxy 2019-10-02 半检返修 IsReworkFlag=2
  14525. //if (ds.Tables[0].Rows[0]["IsReworkFlag"].ToString() == "1")
  14526. if (ds.Tables[0].Rows[0]["IsReworkFlag"].ToString() != "0")
  14527. {
  14528. //申请报废
  14529. returnRows = -9;
  14530. oracleTrConn.Rollback();
  14531. oracleTrConn.Disconnect();
  14532. entity.Result = returnRows;
  14533. return entity;
  14534. }
  14535. //ProcedureID = Convert.ToInt32(ds.Tables[0].Rows[0]["flowProcedureID"]); //条码完成工序
  14536. //flowProcedureTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["flowProcedureTime"]); // 流程工序时间
  14537. ProcedureID = Convert.ToInt32(ds.Tables[0].Rows[0]["ProcedureID"]); //条码完成工序
  14538. flowProcedureTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["ProcedureTime"]); // 完成工序时间
  14539. }
  14540. // 此工序所在条码是否是特殊工序,即可以撤销工序
  14541. sql = "select UnDoFlag from tp_pc_procedure where procedureid=:procdureid and valueflag=1";
  14542. Paras = new OracleParameter[] {
  14543. new OracleParameter(":procdureid",OracleDbType.Int32,
  14544. ProcedureID,ParameterDirection.Input)
  14545. };
  14546. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  14547. if (ds != null && ds.Tables[0].Rows.Count > 0)
  14548. {
  14549. if (ds.Tables[0].Rows[0]["UnDoFlag"].ToString() != "1")
  14550. {
  14551. //此条码所在工序不允许进行撤销
  14552. returnRows = -4;
  14553. oracleTrConn.Rollback();
  14554. oracleTrConn.Disconnect();
  14555. entity.Result = returnRows;
  14556. return entity;
  14557. }
  14558. }
  14559. // 计件撤销 应该不用验证是否回收了 by chenxiaoye 2020-02-28
  14560. //// 如果不合格,查询报损表里是否回收
  14561. //sql = "select recyclingflag from TP_PM_ScrapProduct "
  14562. // + " where BarCode=:BarCode and CreateTime=(select max(CreateTime) "
  14563. // + " from TP_PM_ScrapProduct "
  14564. // + " where BarCode=:BarCode and ValueFlag=1)"
  14565. // + " and ValueFlag=1";
  14566. //Paras = new OracleParameter[]{
  14567. // new OracleParameter(":BarCode",OracleDbType.NVarchar2,barcode,ParameterDirection.Input),
  14568. // };
  14569. //DataSet dsResult2 = oracleTrConn.GetSqlResultToDs(sql, Paras);
  14570. //if (dsResult2 != null && dsResult2.Tables[0].Rows.Count > 0)
  14571. //{
  14572. // if (Convert.ToInt32(dsResult2.Tables[0].Rows[0]["recyclingflag"]) > 0)
  14573. // {
  14574. // returnRows = -200;
  14575. // oracleTrConn.Rollback();
  14576. // oracleTrConn.Disconnect();
  14577. // entity.Result = returnRows;
  14578. // entity.Message = "此产品已经回收,不能撤销";
  14579. // return entity;
  14580. // }
  14581. //}
  14582. // 计件撤销 应该不用验证是否回收了 by chenxiaoye 2020-02-28
  14583. // 判断是否有撤销范围权限
  14584. sql = @"select 1 from TP_MST_UserPurview where UserID=:UserID and (PurviewID=:PurviewID or PurviewID=-1) and PurviewType=13";
  14585. Paras = new OracleParameter[] {
  14586. new OracleParameter(":PurviewID",OracleDbType.Int32,
  14587. ProcedureID,ParameterDirection.Input),
  14588. new OracleParameter(":UserID",OracleDbType.Int32,
  14589. sUserInfo.UserID,ParameterDirection.Input)
  14590. };
  14591. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  14592. if (ds != null && ds.Tables[0].Rows.Count == 0)
  14593. {
  14594. //此用户无此工序撤销权限
  14595. returnRows = -8;
  14596. oracleTrConn.Rollback();
  14597. oracleTrConn.Disconnect();
  14598. entity.Result = returnRows;
  14599. return entity;
  14600. }
  14601. //
  14602. #region 是否启用撤销限制天数
  14603. if (flowProcedureTime != null)
  14604. {
  14605. sql = "select settingvalue from TP_MST_SystemSetting where settingcode=:settingcode and accountid=:accountid";
  14606. Paras = new OracleParameter[] {
  14607. new OracleParameter(":settingcode",OracleDbType.Varchar2,
  14608. Constant.SettingType.S_PM_004.ToString(),ParameterDirection.Input),
  14609. new OracleParameter(":accountid",OracleDbType.Int32,
  14610. sUserInfo.AccountID,ParameterDirection.Input)
  14611. };
  14612. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  14613. if (ds != null && ds.Tables[0].Rows.Count > 0)
  14614. {
  14615. if (Convert.ToInt32(ds.Tables[0].Rows[0]["settingvalue"]) > 0)
  14616. {
  14617. // 开启了限制
  14618. ServiceResultEntity resultEntity = PMModuleLogic.BarcodeAllowCancel(Convert.ToDateTime(flowProcedureTime),
  14619. Convert.ToInt32(ds.Tables[0].Rows[0]["settingvalue"]), Constant.SettingType.S_PM_004.ToString(), sUserInfo);
  14620. if (Convert.ToInt32(resultEntity.Result) < 0)
  14621. {
  14622. //计件撤销限制天数
  14623. returnRows = -200;
  14624. oracleTrConn.Rollback();
  14625. oracleTrConn.Disconnect();
  14626. entity.Result = returnRows;
  14627. entity.Message = resultEntity.Message;
  14628. return entity;
  14629. }
  14630. }
  14631. }
  14632. }
  14633. #endregion
  14634. // 进行撤销
  14635. string sqlString = @"select ProductionDataID,
  14636. ProcedureID,
  14637. ProcedureModel,
  14638. ModelType,
  14639. ReworkProcedureID,
  14640. UserID,
  14641. logoid,
  14642. (select max(ProcedureID) from Tp_Pm_ProductiondataIn inpp where inpp.barcode = :barcode and inpp.ProductionDataID > t.ProductionDataID and ModelType=8 and valueflag='1') p8id --干补
  14643. from (select ProductionDataID,
  14644. ProcedureID,
  14645. ProcedureModel,
  14646. ModelType,
  14647. ReworkProcedureID,
  14648. UserID,
  14649. logoid
  14650. from Tp_Pm_ProductiondataIn
  14651. where barcode = :barcode
  14652. and valueflag = 1 and ModelType<>8
  14653. order by ProductionDataID desc) t
  14654. where rownum <= 2";
  14655. Paras = new OracleParameter[]{
  14656. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  14657. };
  14658. DataSet productionData = oracleTrConn.GetSqlResultToDs(sqlString, Paras);
  14659. if (productionData == null
  14660. || productionData.Tables.Count == Constant.INT_IS_ZERO
  14661. //|| productionData.Tables[0].Rows.Count != Constant.INT_IS_TWO
  14662. )
  14663. {
  14664. // 条码至少要有2次数据采集
  14665. //条码没有此工序前数据
  14666. returnRows = -5;
  14667. oracleTrConn.Rollback();
  14668. oracleTrConn.Disconnect();
  14669. entity.Result = returnRows;
  14670. return entity;
  14671. }
  14672. //xuwei fix 2019-09-25 tables只有一行记录 rows[1]无记录 改成rows[0]?
  14673. object pid = productionData.Tables[0].Rows[productionData.Tables[0].Rows.Count - 1]["p8id"];
  14674. if (pid == null || pid == DBNull.Value)
  14675. {
  14676. pid = productionData.Tables[0].Rows[productionData.Tables[0].Rows.Count - 1]["ProcedureID"];
  14677. }
  14678. #region 回滚在产数据
  14679. //xuwei fix 2019-09-23 加条件限制 如果是首节点 删除在产产品数据 否则 更新在产产品数据
  14680. if (productionData.Tables[0].Rows.Count == 1)
  14681. {
  14682. sqlString = "delete from TP_PM_InProduction where barcode=:barcode"; //wangxin 20150406
  14683. //sqlString += " where ProductionDataID=:productionDataID";
  14684. //新添加的 begin
  14685. Paras = new OracleParameter[]{
  14686. new OracleParameter(":barcode",OracleDbType.Varchar2,
  14687. barcode,ParameterDirection.Input),
  14688. };
  14689. int rows = oracleTrConn.ExecuteNonQuery(sqlString, Paras);
  14690. returnRows += rows;
  14691. if (rows == Constant.INT_IS_ZERO)
  14692. {
  14693. // 保存失败
  14694. //没有任何影响行
  14695. returnRows = -6;
  14696. oracleTrConn.Rollback();
  14697. oracleTrConn.Disconnect();
  14698. entity.Result = returnRows;
  14699. return entity;
  14700. }
  14701. //xuwei add 2019-09-23 更新回生产状态 BEGINNINGFLAG = '0'
  14702. oracleTrConn.ExecuteNonQuery($"update TP_PM_GroutingDailyDetail set BEGINNINGFLAG = '0' where BARCODE = '{barcode}'");
  14703. //xuwei fix 2019-09-25 加条件判断 如果是首节点 回退到注浆1
  14704. sql = $"update TP_PM_USEDBARCODE set barcodestatus=1 where BarCode='{barcode}'";
  14705. rows = oracleTrConn.ExecuteNonQuery(sql);
  14706. returnRows += rows;
  14707. }
  14708. else
  14709. {
  14710. //xuwei 下述代码为原代码 并未判定首节点
  14711. sqlString = @"update TP_PM_InProduction
  14712. set FlowProcedureID = :flowProcedureID,
  14713. ProcedureModel = :procedureModel,
  14714. ProcedureID = :ProcedureID,
  14715. ModelType = :modelType,
  14716. ReworkProcedureID = :reworkProcedureID,
  14717. UserID = :userID,
  14718. updateuserid = :updateuserid,
  14719. ProductionDataID = :ProductionDataID
  14720. --logoid = :logoid
  14721. where barcode = :barcode";
  14722. Paras = new OracleParameter[]{
  14723. new OracleParameter(":flowProcedureID",OracleDbType.Int32,
  14724. productionData.Tables[0].Rows[1]["ProcedureID"],ParameterDirection.Input),//1--->0
  14725. new OracleParameter(":ProcedureID",OracleDbType.Int32,
  14726. pid,ParameterDirection.Input),
  14727. new OracleParameter(":procedureModel",OracleDbType.Int32,
  14728. productionData.Tables[0].Rows[1]["procedureModel"],ParameterDirection.Input),
  14729. new OracleParameter(":modelType",OracleDbType.Int32,
  14730. productionData.Tables[0].Rows[1]["modelType"],ParameterDirection.Input),
  14731. new OracleParameter(":reworkProcedureID",OracleDbType.Int32,
  14732. productionData.Tables[0].Rows[1]["reworkProcedureID"],ParameterDirection.Input),
  14733. new OracleParameter(":userID",OracleDbType.Int32,
  14734. productionData.Tables[0].Rows[1]["userID"],ParameterDirection.Input),
  14735. new OracleParameter(":updateuserid",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input),
  14736. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  14737. new OracleParameter(":ProductionDataID",OracleDbType.Int32,
  14738. productionData.Tables[0].Rows[1]["ProductionDataID"],ParameterDirection.Input)
  14739. //new OracleParameter(":logoid",OracleDbType.Int32,
  14740. // productionData.Tables[0].Rows[1]["logoid"].ToString()==""?null:productionData.Tables[0].Rows[1]["logoid"],ParameterDirection.Input),
  14741. };
  14742. int rows = oracleTrConn.ExecuteNonQuery(sqlString, Paras);
  14743. returnRows += rows;
  14744. if (rows == Constant.INT_IS_ZERO)
  14745. {
  14746. // 保存失败
  14747. //没有任何影响行
  14748. returnRows = -6;
  14749. oracleTrConn.Rollback();
  14750. oracleTrConn.Disconnect();
  14751. entity.Result = returnRows;
  14752. return entity;
  14753. }
  14754. }
  14755. //modify end
  14756. sqlString = "update Tp_Pm_ProductiondataIn set valueflag=0 ,updateuserid=" + sUserInfo.UserID; //wangxin 20150406
  14757. //sqlString += " where ProductionDataID=:productionDataID";
  14758. //新添加的 begin
  14759. Paras = new OracleParameter[]{
  14760. new OracleParameter(":productionDataID",OracleDbType.Int32,
  14761. Convert.ToInt32(productionData.Tables[0].Rows[0]["productionDataID"]),ParameterDirection.Input),
  14762. new OracleParameter(":barcode",OracleDbType.Varchar2,
  14763. barcode,ParameterDirection.Input),
  14764. };
  14765. //新添加的 end
  14766. sqlString += " where ProductionDataID=:productionDataID and barcode=:barcode";
  14767. int rutenRows = oracleTrConn.ExecuteNonQuery(sqlString, Paras);
  14768. returnRows += rutenRows;
  14769. if (rutenRows == Constant.INT_IS_ZERO)
  14770. {
  14771. // 保存失败
  14772. //没有任何影响行
  14773. returnRows = -6;
  14774. oracleTrConn.Rollback();
  14775. oracleTrConn.Disconnect();
  14776. entity.Result = returnRows;
  14777. return entity;
  14778. }
  14779. #endregion
  14780. if (returnRows <= 0)
  14781. {
  14782. oracleTrConn.Rollback();
  14783. oracleTrConn.Disconnect();
  14784. }
  14785. else
  14786. {
  14787. oracleTrConn.Commit();
  14788. oracleTrConn.Disconnect();
  14789. }
  14790. }
  14791. catch (Exception ex)
  14792. {
  14793. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  14794. {
  14795. oracleTrConn.Rollback();
  14796. oracleTrConn.Disconnect();
  14797. }
  14798. throw ex;
  14799. }
  14800. finally
  14801. {
  14802. if (oracleTrConn.ConnState == ConnectionState.Open)
  14803. {
  14804. oracleTrConn.Disconnect();
  14805. }
  14806. }
  14807. entity.Result = returnRows;
  14808. return entity;
  14809. }
  14810. /// <summary>
  14811. /// 交坯特殊工序撤销
  14812. /// </summary>
  14813. /// <param name="barcode">产品条码</param>
  14814. /// <returns></returns>
  14815. public static ServiceResultEntity AddChancelDeliverMudBarCode(string barcode, SUserInfo sUserInfo)
  14816. {
  14817. ServiceResultEntity entity = new ServiceResultEntity();
  14818. int returnRows = 0;
  14819. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  14820. try
  14821. {
  14822. DateTime? deliverTime = null;
  14823. // 1 条码是否有效
  14824. string sql = "select DeliverTime from TP_PM_GroutingDailyDetail where barcode=:barcode and valueflag=1";
  14825. OracleParameter[] Paras = new OracleParameter[] {
  14826. new OracleParameter(":barcode",OracleDbType.Varchar2,
  14827. barcode,ParameterDirection.Input)
  14828. };
  14829. DataSet ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  14830. if (ds.Tables[0].Rows.Count == 0)
  14831. {
  14832. //无效条码
  14833. returnRows = -1;
  14834. oracleTrConn.Rollback();
  14835. oracleTrConn.Disconnect();
  14836. entity.Result = returnRows;
  14837. return entity;
  14838. }
  14839. else
  14840. {
  14841. if (ds.Tables[0].Rows[0]["DeliverTime"].ToString() != "")
  14842. {
  14843. deliverTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["DeliverTime"]);
  14844. }
  14845. }
  14846. // 2.看看是否在产,如果在产看看是否已经损坯标识
  14847. int? ProcedureID = null;
  14848. //xuwei fix 2019-09-27 选出交坏判定字段
  14849. //sql = "select InScrapFlag,flowProcedureID,IsReworkFlag,Specialrepairflag from TP_PM_InProduction where barcode=:barcode and valueflag=1";
  14850. sql = "select MODELTYPE,InScrapFlag,flowProcedureID,IsReworkFlag,Specialrepairflag from TP_PM_InProduction where barcode=:barcode and valueflag=1";
  14851. Paras = new OracleParameter[] {
  14852. new OracleParameter(":barcode",OracleDbType.Varchar2,
  14853. barcode,ParameterDirection.Input)
  14854. };
  14855. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  14856. if (ds.Tables[0].Rows.Count == 0) //不存在在产信息
  14857. {
  14858. // 不在产,看看是否有成品
  14859. sql = @"select 1 from TP_PM_FinishedProduct where barcode=:barcode";
  14860. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  14861. if (ds.Tables[0].Rows.Count > 0)
  14862. {
  14863. //生产完成
  14864. returnRows = -2;
  14865. oracleTrConn.Rollback();
  14866. oracleTrConn.Disconnect();
  14867. entity.Result = returnRows;
  14868. return entity;
  14869. }
  14870. else
  14871. {
  14872. //条码不在生产线上
  14873. returnRows = -7;
  14874. oracleTrConn.Rollback();
  14875. oracleTrConn.Disconnect();
  14876. entity.Result = returnRows;
  14877. return entity;
  14878. }
  14879. }
  14880. else
  14881. {
  14882. //xuwei add 2019-09-27 如果是非交坯工序不能在此节点撤销 5是交坯模型
  14883. if (ds.Tables[0].Rows[0]["MODELTYPE"].ToString() != "5")
  14884. {
  14885. //非交坯工序,不能交坯撤销
  14886. returnRows = -200;
  14887. oracleTrConn.Rollback();
  14888. oracleTrConn.Disconnect();
  14889. entity.Result = returnRows;
  14890. entity.Message = "非交坯工序,不能交坯撤销";
  14891. return entity;
  14892. }
  14893. //xuwei end
  14894. if (ds.Tables[0].Rows[0]["Specialrepairflag"].ToString() == "1")
  14895. {
  14896. //干补后不允许撤销
  14897. returnRows = -200;
  14898. oracleTrConn.Rollback();
  14899. oracleTrConn.Disconnect();
  14900. entity.Result = returnRows;
  14901. entity.Message = "干补后不允许撤销";
  14902. return entity;
  14903. }
  14904. if (ds.Tables[0].Rows[0]["InScrapFlag"].ToString() == "1")
  14905. {
  14906. //申请报废
  14907. returnRows = -3;
  14908. oracleTrConn.Rollback();
  14909. oracleTrConn.Disconnect();
  14910. entity.Result = returnRows;
  14911. return entity;
  14912. }
  14913. // chenxy 2019-10-02 半检返修 IsReworkFlag=2
  14914. //if (ds.Tables[0].Rows[0]["IsReworkFlag"].ToString() == "1")
  14915. if (ds.Tables[0].Rows[0]["IsReworkFlag"].ToString() != "0")
  14916. {
  14917. //申请报废
  14918. returnRows = -8;
  14919. oracleTrConn.Rollback();
  14920. oracleTrConn.Disconnect();
  14921. entity.Result = returnRows;
  14922. return entity;
  14923. }
  14924. ProcedureID = Convert.ToInt32(ds.Tables[0].Rows[0]["flowProcedureID"]); //条码完成工序
  14925. }
  14926. //// 此工序所在条码是否是特殊工序,即可以撤销工序
  14927. //sql = "select UnDoFlag from tp_pc_procedure where procedureid=:procdureid and valueflag=1";
  14928. //Paras = new OracleParameter[] {
  14929. // new OracleParameter(":procdureid",OracleDbType.Int32,
  14930. // ProcedureID,ParameterDirection.Input)
  14931. //};
  14932. //ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  14933. //if (ds != null && ds.Tables[0].Rows.Count > 0)
  14934. //{
  14935. // if (ds.Tables[0].Rows[0]["UnDoFlag"].ToString() != "1")
  14936. // {
  14937. // //此条码所在工序不允许进行撤销
  14938. // returnRows = -4;
  14939. // oracleTrConn.Rollback();
  14940. // oracleTrConn.Disconnect();
  14941. // return returnRows;
  14942. // }
  14943. //}
  14944. #region 是否启用交坯撤销限制天数
  14945. if (deliverTime != null)
  14946. {
  14947. sql = "select settingvalue from TP_MST_SystemSetting where settingcode=:settingcode and accountid=:accountid";
  14948. Paras = new OracleParameter[] {
  14949. new OracleParameter(":settingcode",OracleDbType.Varchar2,
  14950. Constant.SettingType.S_PM_003.ToString(),ParameterDirection.Input),
  14951. new OracleParameter(":accountid",OracleDbType.Int32,
  14952. sUserInfo.AccountID,ParameterDirection.Input)
  14953. };
  14954. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  14955. if (ds != null && ds.Tables[0].Rows.Count > 0)
  14956. {
  14957. if (Convert.ToInt32(ds.Tables[0].Rows[0]["settingvalue"]) > 0)
  14958. {
  14959. // 开启了限制
  14960. ServiceResultEntity resultEntity = PMModuleLogic.BarcodeAllowCancel(Convert.ToDateTime(deliverTime),
  14961. Convert.ToInt32(ds.Tables[0].Rows[0]["settingvalue"]), Constant.SettingType.S_PM_003.ToString(), sUserInfo);
  14962. if (Convert.ToInt32(resultEntity.Result) < 0)
  14963. {
  14964. //超过交坯撤销限制天数
  14965. returnRows = -200;
  14966. oracleTrConn.Rollback();
  14967. oracleTrConn.Disconnect();
  14968. entity.Result = returnRows;
  14969. entity.Message = resultEntity.Message;
  14970. return entity;
  14971. }
  14972. }
  14973. }
  14974. }
  14975. #endregion
  14976. // 进行撤销
  14977. string sqlString = @"select ProductionDataID,
  14978. ProcedureID,
  14979. ProcedureModel,
  14980. ModelType,
  14981. ReworkProcedureID,
  14982. UserID,
  14983. (select max(ProcedureID) from Tp_Pm_ProductiondataIn inpp where inpp.barcode = :barcode and inpp.ProductionDataID > t.ProductionDataID and ModelType=8 and valueflag='1') p8id --干补
  14984. from (select ProductionDataID,
  14985. ProcedureID,
  14986. ProcedureModel,
  14987. ModelType,
  14988. ReworkProcedureID,
  14989. UserID
  14990. from Tp_Pm_ProductiondataIn
  14991. where barcode = :barcode
  14992. and valueflag = 1 and ModelType<>8
  14993. order by ProductionDataID desc) t
  14994. where rownum <= 2";
  14995. Paras = new OracleParameter[]{
  14996. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  14997. };
  14998. DataSet productionData = oracleTrConn.GetSqlResultToDs(sqlString, Paras);
  14999. if (productionData == null
  15000. || productionData.Tables.Count == Constant.INT_IS_ZERO
  15001. )
  15002. {
  15003. // 条码至少要有1次数据采集
  15004. //条码没有此工序前数据
  15005. returnRows = -5; //条码至少要有1次数据采集
  15006. oracleTrConn.Rollback();
  15007. oracleTrConn.Disconnect();
  15008. entity.Result = returnRows;
  15009. return entity;
  15010. }
  15011. //if (productionData.Tables[0].Rows.Count != Constant.INT_IS_ONE)
  15012. //{
  15013. // // 条码至少要有1次数据采集
  15014. // //条码没有此工序前数据
  15015. // returnRows = -55; //条码已经经过多个工序,不允许撤销
  15016. // oracleTrConn.Rollback();
  15017. // oracleTrConn.Disconnect();
  15018. // entity.Result = returnRows;
  15019. // return entity;
  15020. //}
  15021. //xuwei fix 2019-09-25 tables只有一行记录 rows[1]无记录 改成rows[0]?
  15022. object pid = productionData.Tables[0].Rows[productionData.Tables[0].Rows.Count - 1]["p8id"];
  15023. if (pid == null || pid == DBNull.Value)
  15024. {
  15025. pid = productionData.Tables[0].Rows[productionData.Tables[0].Rows.Count - 1]["ProcedureID"];
  15026. }
  15027. #region 回滚在产数据
  15028. // sqlString = @"update TP_PM_InProduction
  15029. // set FlowProcedureID = :flowProcedureID,
  15030. // ProcedureModel = :procedureModel,
  15031. // ProcedureID = :flowProcedureID,
  15032. // ModelType = :modelType,
  15033. // ReworkProcedureID = :reworkProcedureID,
  15034. // UserID = :userID,
  15035. // updateuserid = :updateuserid
  15036. // where barcode = :barcode";
  15037. // Paras = new OracleParameter[]{
  15038. // new OracleParameter(":flowProcedureID",OracleDbType.Int32,
  15039. // productionData.Tables[0].Rows[1]["ProcedureID"],ParameterDirection.Input),//1--->0
  15040. // new OracleParameter(":procedureModel",OracleDbType.Int32,
  15041. // productionData.Tables[0].Rows[1]["procedureModel"],ParameterDirection.Input),
  15042. // new OracleParameter(":modelType",OracleDbType.Int32,
  15043. // productionData.Tables[0].Rows[1]["modelType"],ParameterDirection.Input),
  15044. // new OracleParameter(":reworkProcedureID",OracleDbType.Int32,
  15045. // productionData.Tables[0].Rows[1]["reworkProcedureID"],ParameterDirection.Input),
  15046. // new OracleParameter(":userID",OracleDbType.Int32,
  15047. // productionData.Tables[0].Rows[1]["userID"],ParameterDirection.Input),
  15048. // new OracleParameter(":updateuserid",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input),
  15049. // new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  15050. // };
  15051. // int rutenRows = oracleTrConn.ExecuteNonQuery(sqlString, Paras);
  15052. // returnRows += rutenRows;
  15053. // if (rutenRows == Constant.INT_IS_ZERO)
  15054. // {
  15055. // // 保存失败
  15056. // //没有任何影响行
  15057. // returnRows = -6;
  15058. // oracleTrConn.Rollback();
  15059. // oracleTrConn.Disconnect();
  15060. // return returnRows;
  15061. // }
  15062. int rutenRows = 0;
  15063. //modify end
  15064. sqlString = "update Tp_Pm_ProductiondataIn set valueflag=0 ,updateuserid=" + sUserInfo.UserID; //wangxin 20150406
  15065. //sqlString += " where ProductionDataID=:productionDataID";
  15066. //新添加的 begin
  15067. Paras = new OracleParameter[]{
  15068. new OracleParameter(":productionDataID",OracleDbType.Int32,
  15069. Convert.ToInt32(productionData.Tables[0].Rows[0]["productionDataID"]),ParameterDirection.Input),
  15070. new OracleParameter(":barcode",OracleDbType.Varchar2,
  15071. barcode,ParameterDirection.Input),
  15072. };
  15073. //新添加的 end
  15074. sqlString += " where ProductionDataID=:productionDataID and barcode=:barcode";
  15075. rutenRows = oracleTrConn.ExecuteNonQuery(sqlString, Paras);
  15076. returnRows += rutenRows;
  15077. if (rutenRows == Constant.INT_IS_ZERO)
  15078. {
  15079. // 保存失败
  15080. //没有任何影响行
  15081. returnRows = -6;
  15082. oracleTrConn.Rollback();
  15083. oracleTrConn.Disconnect();
  15084. entity.Result = returnRows;
  15085. return entity;
  15086. }
  15087. //modify end
  15088. //xuwei fix 2019-09-23 加条件限制 如果是首节点 删除在产产品数据
  15089. if (productionData.Tables[0].Rows.Count == 1)
  15090. {
  15091. sqlString = "delete from TP_PM_InProduction where barcode=:barcode"; //wangxin 20150406
  15092. //sqlString += " where ProductionDataID=:productionDataID";
  15093. //新添加的 begin
  15094. Paras = new OracleParameter[]{
  15095. new OracleParameter(":barcode",OracleDbType.Varchar2,
  15096. barcode,ParameterDirection.Input),
  15097. };
  15098. rutenRows = oracleTrConn.ExecuteNonQuery(sqlString, Paras);
  15099. returnRows += rutenRows;
  15100. if (rutenRows == Constant.INT_IS_ZERO)
  15101. {
  15102. // 保存失败
  15103. //没有任何影响行
  15104. returnRows = -6;
  15105. oracleTrConn.Rollback();
  15106. oracleTrConn.Disconnect();
  15107. entity.Result = returnRows;
  15108. return entity;
  15109. }
  15110. //xuwei add 2019-09-23 更新回生产状态 BEGINNINGFLAG = '0'
  15111. oracleTrConn.ExecuteNonQuery($"update TP_PM_GroutingDailyDetail set BEGINNINGFLAG = '0' where BARCODE = '{barcode}'");
  15112. }
  15113. else
  15114. {
  15115. //xuwei 下述代码为原代码 并未判定首节点
  15116. sqlString = @"update TP_PM_InProduction
  15117. set FlowProcedureID = :flowProcedureID,
  15118. ProcedureModel = :procedureModel,
  15119. ProcedureID = :ProcedureID,
  15120. ModelType = :modelType,
  15121. ReworkProcedureID = :reworkProcedureID,
  15122. UserID = :userID,
  15123. updateuserid = :updateuserid,
  15124. ProductionDataID = :ProductionDataID
  15125. --logoid = :logoid
  15126. where barcode = :barcode";
  15127. Paras = new OracleParameter[]{
  15128. new OracleParameter(":flowProcedureID",OracleDbType.Int32,
  15129. productionData.Tables[0].Rows[1]["ProcedureID"],ParameterDirection.Input),//1--->0
  15130. new OracleParameter(":ProcedureID",OracleDbType.Int32,
  15131. pid,ParameterDirection.Input),
  15132. new OracleParameter(":procedureModel",OracleDbType.Int32,
  15133. productionData.Tables[0].Rows[1]["procedureModel"],ParameterDirection.Input),
  15134. new OracleParameter(":modelType",OracleDbType.Int32,
  15135. productionData.Tables[0].Rows[1]["modelType"],ParameterDirection.Input),
  15136. new OracleParameter(":reworkProcedureID",OracleDbType.Int32,
  15137. productionData.Tables[0].Rows[1]["reworkProcedureID"],ParameterDirection.Input),
  15138. new OracleParameter(":userID",OracleDbType.Int32,
  15139. productionData.Tables[0].Rows[1]["userID"],ParameterDirection.Input),
  15140. new OracleParameter(":updateuserid",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input),
  15141. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  15142. new OracleParameter(":ProductionDataID",OracleDbType.Int32,
  15143. productionData.Tables[0].Rows[1]["ProductionDataID"],ParameterDirection.Input)
  15144. //new OracleParameter(":logoid",OracleDbType.Int32,
  15145. // productionData.Tables[0].Rows[1]["logoid"].ToString()==""?null:productionData.Tables[0].Rows[1]["logoid"],ParameterDirection.Input),
  15146. };
  15147. int rows = oracleTrConn.ExecuteNonQuery(sqlString, Paras);
  15148. returnRows += rows;
  15149. if (rows == Constant.INT_IS_ZERO)
  15150. {
  15151. // 保存失败
  15152. //没有任何影响行
  15153. returnRows = -6;
  15154. oracleTrConn.Rollback();
  15155. oracleTrConn.Disconnect();
  15156. entity.Result = returnRows;
  15157. return entity;
  15158. }
  15159. }
  15160. #endregion
  15161. // 更新注浆明交坯标识把已经交坯改回,正常交坯
  15162. 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
  15163. Paras = new OracleParameter[]{
  15164. new OracleParameter(":barcode",OracleDbType.Varchar2,
  15165. barcode,ParameterDirection.Input),
  15166. };
  15167. rutenRows = oracleTrConn.ExecuteNonQuery(sqlString, Paras);
  15168. returnRows += rutenRows;
  15169. // TODO 回退到注浆 1 还是 在产 3
  15170. //xuwei fix 2019-09-23 加条件判断 如果是首节点 回退到注浆1 否则回退到在产 3
  15171. if (productionData.Tables[0].Rows.Count == 1)
  15172. {
  15173. sql = "update TP_PM_USEDBARCODE set barcodestatus=1 where BarCode=:barcode";
  15174. }
  15175. else
  15176. {
  15177. sql = "update TP_PM_USEDBARCODE set barcodestatus=3 where BarCode=:barcode";
  15178. }
  15179. Paras = new OracleParameter[]{
  15180. new OracleParameter(":barcode",OracleDbType.Varchar2,
  15181. barcode,ParameterDirection.Input),
  15182. };
  15183. rutenRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  15184. returnRows += rutenRows;
  15185. if (returnRows <= 0)
  15186. {
  15187. oracleTrConn.Rollback();
  15188. oracleTrConn.Disconnect();
  15189. }
  15190. else
  15191. {
  15192. oracleTrConn.Commit();
  15193. oracleTrConn.Disconnect();
  15194. }
  15195. }
  15196. catch (Exception ex)
  15197. {
  15198. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  15199. {
  15200. oracleTrConn.Rollback();
  15201. oracleTrConn.Disconnect();
  15202. }
  15203. throw ex;
  15204. }
  15205. finally
  15206. {
  15207. if (oracleTrConn.ConnState == ConnectionState.Open)
  15208. {
  15209. oracleTrConn.Disconnect();
  15210. }
  15211. }
  15212. entity.Result = returnRows;
  15213. return entity;
  15214. }
  15215. #region
  15216. /// <summary>
  15217. /// 清除未盘点残留数据(清除选择)
  15218. /// </summary>
  15219. /// <param name="inCheckedID">盘点单ID</param>
  15220. /// <param name="barcodes">条码集</param>
  15221. /// <returns></returns>
  15222. public static int SaveClearInChecked(int inCheckedID, string barcodes, SUserInfo sUserInfo)
  15223. {
  15224. int returnRows = 0;
  15225. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  15226. try
  15227. {
  15228. string sql = "";
  15229. string[] subbarcodes = barcodes.Split(',');
  15230. OracleParameter[] Paras = null;
  15231. for (int i = 0; i < subbarcodes.Length; i++)
  15232. {
  15233. // 0.登窑、入窑、出窑工序的产品不能清除
  15234. sql = "select p.modeltype from tp_pm_inproduction p where p.barcode = :barcode";
  15235. Paras = new OracleParameter[] {
  15236. new OracleParameter(":barcode",OracleDbType.NVarchar2,
  15237. subbarcodes[i],ParameterDirection.Input),
  15238. };
  15239. string modeltype = oracleTrConn.GetSqlResultToStr(sql, Paras);
  15240. if (!string.IsNullOrWhiteSpace(modeltype))
  15241. {
  15242. Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType pmt =
  15243. (Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType)Convert.ToInt32(modeltype);
  15244. if (pmt == Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType.LoadCar ||
  15245. pmt == Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType.IntoKiln ||
  15246. pmt == Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType.OutKiln ||
  15247. pmt == Dongke.IBOSS.PRD.Basics.BaseResources.Constant.ProcedureModelType.CarAdd)
  15248. {
  15249. continue;
  15250. }
  15251. }
  15252. // 返工标识或者是报损标识不允许清除 2016-07-12
  15253. sql = "select IsReworkFlag,InScrapFlag from tp_pm_inproduction p where p.barcode = :barcode";
  15254. Paras = new OracleParameter[] {
  15255. new OracleParameter(":barcode",OracleDbType.NVarchar2,
  15256. subbarcodes[i],ParameterDirection.Input)
  15257. };
  15258. DataSet ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  15259. if (ds != null && ds.Tables[0].Rows.Count > 0)
  15260. {
  15261. // chenxy 2019-10-02 半检返修 IsReworkFlag=2
  15262. //if (ds.Tables[0].Rows[0]["IsReworkFlag"].ToString() == "1")
  15263. if (ds.Tables[0].Rows[0]["IsReworkFlag"].ToString() != "0")
  15264. {
  15265. returnRows = -1;
  15266. break;
  15267. }
  15268. if (ds.Tables[0].Rows[0]["InScrapFlag"].ToString() == "1")
  15269. {
  15270. returnRows = -2;
  15271. break;
  15272. }
  15273. }
  15274. // 1.清除未盘点数据
  15275. 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'";
  15276. Paras = new OracleParameter[] {
  15277. new OracleParameter(":barcode",OracleDbType.NVarchar2,
  15278. subbarcodes[i],ParameterDirection.Input),
  15279. new OracleParameter(":InCheckedID",OracleDbType.Int32,
  15280. inCheckedID,ParameterDirection.Input)
  15281. };
  15282. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  15283. // 2. 把在产数据插入到在产临时表中。(数据来源标识0:在产表)
  15284. // sql = @"insert into tp_pm_inproduction_tmp
  15285. // select * from tp_pm_inproduction p where p.barcode = :barcode";
  15286. sql = "INSERT INTO tp_pm_inproduction_tmp\n" +
  15287. " (barcode\n" +
  15288. " ,productionlineid\n" +
  15289. " ,productionlinecode\n" +
  15290. " ,productionlinename\n" +
  15291. " ,proceduremodel\n" +
  15292. " ,modeltype\n" +
  15293. " ,reworkprocedureid\n" +
  15294. " ,ispublicbody\n" +
  15295. " ,goodsid\n" +
  15296. " ,goodscode\n" +
  15297. " ,goodsname\n" +
  15298. " ,userid\n" +
  15299. " ,groutingdailyid\n" +
  15300. " ,groutingdailydetailid\n" +
  15301. " ,groutingdate\n" +
  15302. " ,groutinglineid\n" +
  15303. " ,groutinglinecode\n" +
  15304. " ,groutinglinename\n" +
  15305. " ,gmouldtypeid\n" +
  15306. " ,canmanytimes\n" +
  15307. " ,groutinglinedetailid\n" +
  15308. " ,groutingmouldcode\n" +
  15309. " ,mouldcode\n" +
  15310. " ,remarks\n" +
  15311. " ,accountid\n" +
  15312. " ,valueflag\n" +
  15313. " ,createtime\n" +
  15314. " ,createuserid\n" +
  15315. " ,updatetime\n" +
  15316. " ,updateuserid\n" +
  15317. " ,optimestamp\n" +
  15318. " ,isrefire\n" +
  15319. " ,goodslevelid\n" +
  15320. " ,goodsleveltypeid\n" +
  15321. " ,defectflag\n" +
  15322. " ,groutinguserid\n" +
  15323. " ,groutingusercode\n" +
  15324. " ,groutingnum\n" +
  15325. " ,kilnid\n" +
  15326. " ,kilncode\n" +
  15327. " ,kilnname\n" +
  15328. " ,kilncarid\n" +
  15329. " ,kilncarcode\n" +
  15330. " ,kilncarname\n" +
  15331. " ,kilncarbatchno\n" +
  15332. " ,kilncarposition\n" +
  15333. " ,specialrepairflag\n" +
  15334. " ,flowprocedureid\n" +
  15335. " ,flowproceduretime\n" +
  15336. " ,procedureid\n" +
  15337. " ,proceduretime\n" +
  15338. " ,productiondataid\n" +
  15339. " ,deleteduserid\n" +
  15340. " ,deletedusercode\n" +
  15341. " --,trashflag\n" +
  15342. " --,deletedtime\n" +
  15343. " ,logoid)\n" +
  15344. " SELECT barcode\n" +
  15345. " ,productionlineid\n" +
  15346. " ,productionlinecode\n" +
  15347. " ,productionlinename\n" +
  15348. " ,proceduremodel\n" +
  15349. " ,modeltype\n" +
  15350. " ,reworkprocedureid\n" +
  15351. " ,ispublicbody\n" +
  15352. " ,goodsid\n" +
  15353. " ,goodscode\n" +
  15354. " ,goodsname\n" +
  15355. " ,userid\n" +
  15356. " ,groutingdailyid\n" +
  15357. " ,groutingdailydetailid\n" +
  15358. " ,groutingdate\n" +
  15359. " ,groutinglineid\n" +
  15360. " ,groutinglinecode\n" +
  15361. " ,groutinglinename\n" +
  15362. " ,gmouldtypeid\n" +
  15363. " ,canmanytimes\n" +
  15364. " ,groutinglinedetailid\n" +
  15365. " ,groutingmouldcode\n" +
  15366. " ,mouldcode\n" +
  15367. " ,remarks\n" +
  15368. " ,accountid\n" +
  15369. " ,valueflag\n" +
  15370. " ,createtime\n" +
  15371. " ,createuserid\n" +
  15372. " ,updatetime\n" +
  15373. " ,updateuserid\n" +
  15374. " ,optimestamp\n" +
  15375. " ,isrefire\n" +
  15376. " ,goodslevelid\n" +
  15377. " ,goodsleveltypeid\n" +
  15378. " ,defectflag\n" +
  15379. " ,groutinguserid\n" +
  15380. " ,groutingusercode\n" +
  15381. " ,groutingnum\n" +
  15382. " ,kilnid\n" +
  15383. " ,kilncode\n" +
  15384. " ,kilnname\n" +
  15385. " ,kilncarid\n" +
  15386. " ,kilncarcode\n" +
  15387. " ,kilncarname\n" +
  15388. " ,kilncarbatchno\n" +
  15389. " ,kilncarposition\n" +
  15390. " ,specialrepairflag\n" +
  15391. " ,flowprocedureid\n" +
  15392. " ,flowproceduretime\n" +
  15393. " ,procedureid\n" +
  15394. " ,proceduretime\n" +
  15395. " ,productiondataid\n" +
  15396. " ,:deleteduserid\n" +
  15397. " ,:deletedusercode\n" +
  15398. " --,inscrapflag\n" +
  15399. " ,logoid\n" +
  15400. " FROM tp_pm_inproduction p\n" +
  15401. " WHERE p.barcode = :barcode\n" +
  15402. " AND p.modeltype not in (1,2,3,6)\n" +
  15403. // chenxy 2019-10-02 半检返修 IsReworkFlag=2
  15404. //" AND p.IsReworkFlag <> '1' AND p.InScrapFlag <> '1' \n" +
  15405. " AND p.IsReworkFlag = '0' AND p.InScrapFlag = '0' \n" +
  15406. "";
  15407. Paras = new OracleParameter[] {
  15408. new OracleParameter(":barcode",OracleDbType.NVarchar2,
  15409. subbarcodes[i],ParameterDirection.Input),
  15410. new OracleParameter(":deleteduserid",OracleDbType.Int32,
  15411. sUserInfo.UserID,ParameterDirection.Input),
  15412. new OracleParameter(":deletedusercode",OracleDbType.NVarchar2,
  15413. sUserInfo.UserCode,ParameterDirection.Input),
  15414. };
  15415. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  15416. // 3 删除在产数据
  15417. // chenxy 2019-10-02 半检返修 IsReworkFlag=2
  15418. //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'";
  15419. 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'";
  15420. Paras = new OracleParameter[] {
  15421. new OracleParameter(":barcode",OracleDbType.NVarchar2,
  15422. subbarcodes[i],ParameterDirection.Input),
  15423. };
  15424. returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  15425. if (returnRows > 0)
  15426. {
  15427. // 4. 删除在产生产数据
  15428. sql = @" delete from tp_pm_productiondatain p where p.barcode = :barcode";
  15429. Paras = new OracleParameter[] {
  15430. new OracleParameter(":barcode",OracleDbType.NVarchar2,
  15431. subbarcodes[i],ParameterDirection.Input),
  15432. };
  15433. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  15434. }
  15435. }
  15436. if (returnRows <= 0)
  15437. {
  15438. oracleTrConn.Rollback();
  15439. oracleTrConn.Disconnect();
  15440. }
  15441. else
  15442. {
  15443. oracleTrConn.Commit();
  15444. oracleTrConn.Disconnect();
  15445. }
  15446. }
  15447. catch (Exception ex)
  15448. {
  15449. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  15450. {
  15451. oracleTrConn.Rollback();
  15452. oracleTrConn.Disconnect();
  15453. }
  15454. throw ex;
  15455. }
  15456. finally
  15457. {
  15458. if (oracleTrConn.ConnState == ConnectionState.Open)
  15459. {
  15460. oracleTrConn.Disconnect();
  15461. }
  15462. }
  15463. return returnRows;
  15464. }
  15465. /// <summary>
  15466. /// 清除未盘点残留数据(根据条件进行选择)
  15467. /// </summary>
  15468. /// <param name="inCheckedID">盘点单ID</param>
  15469. /// <param name="procedureIDs">完成工序集</param>
  15470. /// <param name="goodsCodes">产品编码集</param>
  15471. /// <returns></returns>
  15472. public static int SaveClearInCheckedAll(int inCheckedID, string procedureIDs, string goodsCodes, DateTime? startDateTime, DateTime? endDateTime, SUserInfo sUserInfo)
  15473. {
  15474. int returnRows = 0;
  15475. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  15476. try
  15477. {
  15478. OracleParameter[] Paras = null;
  15479. string Insql = "";
  15480. // 1 查出根据条件进行未盘点数据
  15481. // 0.登窑、入窑、出窑工序的产品不能清除
  15482. Insql = @"select p.barcode from TP_PM_INCHECKEDDETAIL p "
  15483. + " inner join tp_pm_inproduction pin on pin.barcode = p.barcode and p.PROCEDUREID = pin.PROCEDUREID"
  15484. + " 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'";
  15485. if (!string.IsNullOrEmpty(procedureIDs))
  15486. {
  15487. Insql += " and p.PROCEDUREID in (" + procedureIDs + ")";
  15488. }
  15489. if (!string.IsNullOrEmpty(goodsCodes))
  15490. {
  15491. Insql += " and p.GoodsID in (" + goodsCodes + ")";
  15492. }
  15493. if (startDateTime != null)
  15494. {
  15495. Insql += Insql + " AND pin.ProcedureTime >= :Createdate AND pin.ProcedureTime <= :EndDate ";
  15496. Paras = new OracleParameter[] {
  15497. new OracleParameter(":InCheckedID",OracleDbType.Int32,inCheckedID,ParameterDirection.Input),
  15498. new OracleParameter(":Createdate", OracleDbType.Date, startDateTime, ParameterDirection.Input),
  15499. new OracleParameter(":EndDate", OracleDbType.Date, endDateTime, ParameterDirection.Input),
  15500. };
  15501. }
  15502. else
  15503. {
  15504. Paras = new OracleParameter[] {
  15505. new OracleParameter(":InCheckedID",OracleDbType.Int32,inCheckedID,ParameterDirection.Input),
  15506. };
  15507. }
  15508. string sql = "";
  15509. // 1.清除未盘点数据
  15510. 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'";
  15511. //Paras = new OracleParameter[] {
  15512. // new OracleParameter(":InCheckedID",OracleDbType.Int32,
  15513. // inCheckedID,ParameterDirection.Input)
  15514. // };
  15515. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  15516. // 2. 把在产数据插入到在产临时表中。(数据来源标识0:在产表)
  15517. sql = @"insert into tp_pm_inproduction_tmp
  15518. (
  15519. BARCODE,
  15520. PRODUCTIONLINEID,
  15521. PRODUCTIONLINECODE,
  15522. PRODUCTIONLINENAME,
  15523. PROCEDUREMODEL,
  15524. MODELTYPE,
  15525. REWORKPROCEDUREID,
  15526. ISPUBLICBODY,
  15527. GOODSID,
  15528. GOODSCODE,
  15529. GOODSNAME,
  15530. USERID,
  15531. GROUTINGDAILYID,
  15532. GROUTINGDAILYDETAILID,
  15533. GROUTINGDATE,
  15534. GROUTINGLINEID,
  15535. GROUTINGLINECODE,
  15536. GROUTINGLINENAME,
  15537. GMOULDTYPEID,
  15538. CANMANYTIMES,
  15539. GROUTINGLINEDETAILID,
  15540. GROUTINGMOULDCODE,
  15541. MOULDCODE,
  15542. REMARKS,
  15543. ACCOUNTID,
  15544. VALUEFLAG,
  15545. CREATETIME,
  15546. CREATEUSERID,
  15547. UPDATETIME,
  15548. UPDATEUSERID,
  15549. OPTIMESTAMP,
  15550. ISREFIRE,
  15551. GOODSLEVELID,
  15552. GOODSLEVELTYPEID,
  15553. DEFECTFLAG,
  15554. GROUTINGUSERID,
  15555. GROUTINGUSERCODE,
  15556. GROUTINGNUM,
  15557. KILNID,
  15558. KILNCODE,
  15559. KILNNAME,
  15560. KILNCARID,
  15561. KILNCARCODE,
  15562. KILNCARNAME,
  15563. KILNCARBATCHNO,
  15564. KILNCARPOSITION,
  15565. SPECIALREPAIRFLAG,
  15566. FLOWPROCEDUREID,
  15567. FLOWPROCEDURETIME,
  15568. PROCEDUREID,
  15569. PROCEDURETIME,
  15570. PRODUCTIONDATAID,
  15571. trashflag,
  15572. Deletedtime,
  15573. logoid,
  15574. IsReworkFlag,
  15575. SemiCheckID,
  15576. DELETEDUSERID,
  15577. DELETEDUSERCODE
  15578. )
  15579. select
  15580. BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME,
  15581. PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID,
  15582. ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME,
  15583. USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE,
  15584. GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID,
  15585. CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE,
  15586. REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME,
  15587. CREATEUSERID, UPDATETIME, UPDATEUSERID,optimestamp,
  15588. ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG,
  15589. GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM,
  15590. KILNID, KILNCODE, KILNNAME, KILNCARID,
  15591. KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID
  15592. ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,0,sysdate,logoid,ISREWORKFLAG,SEMICHECKID,"
  15593. + sUserInfo.UserID + ",'" + sUserInfo.UserCode +
  15594. "' from tp_pm_inproduction pp where pp.barcode in (" + Insql + ")";
  15595. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  15596. // 4. 删除在产生产数据
  15597. sql = @" delete from tp_pm_productiondatain pp where pp.barcode in(" + Insql + ")";
  15598. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  15599. // 3 删除在产数据
  15600. sql = @" delete from tp_pm_inproduction pp where pp.barcode in(" + Insql + ")";
  15601. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  15602. sql = @" update TP_PM_INCHECKEDDETAIL p set p.INCHECKEDFLAG = '3' where p.INCHECKEDFLAG='9' and p.InCheckedID=" + inCheckedID;
  15603. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  15604. if (returnRows == 0)
  15605. {
  15606. oracleTrConn.Rollback();
  15607. oracleTrConn.Disconnect();
  15608. }
  15609. else
  15610. {
  15611. oracleTrConn.Commit();
  15612. oracleTrConn.Disconnect();
  15613. }
  15614. }
  15615. catch (Exception ex)
  15616. {
  15617. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  15618. {
  15619. oracleTrConn.Rollback();
  15620. oracleTrConn.Disconnect();
  15621. }
  15622. throw ex;
  15623. }
  15624. finally
  15625. {
  15626. if (oracleTrConn.ConnState == ConnectionState.Open)
  15627. {
  15628. oracleTrConn.Disconnect();
  15629. }
  15630. }
  15631. return returnRows;
  15632. }
  15633. /// <summary>
  15634. /// 设置条码商标
  15635. /// </summary>
  15636. /// <returns></returns>
  15637. public static int SaveBarCodeLogo(string barcode, int logoid, SUserInfo sUserInfo)
  15638. {
  15639. int returnRows = 0;
  15640. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  15641. try
  15642. {
  15643. // 转换条码
  15644. string sqlString = @"select FUN_CMN_GetBarCode(:barcode,null,:accountid) From DUAL";
  15645. OracleParameter[] paras1 = new OracleParameter[]{
  15646. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  15647. new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID,ParameterDirection.Input),
  15648. };
  15649. barcode = oracleTrConn.GetSqlResultToStr(sqlString, paras1);
  15650. OracleParameter[] Paras = null;
  15651. object oldLogoID = null;
  15652. object pid = null;
  15653. string sql = "";
  15654. //sql = @"select logoid from tp_pm_groutingdailydetail where barcode=:barcode";
  15655. //oldLogoID = oracleTrConn.GetSqlResultToObj(sql, new OracleParameter[]{
  15656. // new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input)
  15657. // });
  15658. sql = @"select g.logoid, f.fhuserid from tp_pm_groutingdailydetail g
  15659. left join tp_pm_finishedproduct f on g.barcode = f.barcode
  15660. where g.barcode=:barcode";
  15661. DataTable dt = oracleTrConn.GetSqlResultToDt(sql, new OracleParameter[]{
  15662. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input)
  15663. });
  15664. if (dt != null && dt.Rows.Count > 0)
  15665. {
  15666. oldLogoID = dt.Rows[0]["logoid"];
  15667. object fhuserid = dt.Rows[0]["fhuserid"];
  15668. if (oldLogoID == null || oldLogoID == DBNull.Value)
  15669. {
  15670. // 条码不存在
  15671. return -2;
  15672. }
  15673. if (fhuserid != null && fhuserid != DBNull.Value)
  15674. {
  15675. // "已交接的产品不能变更商标";
  15676. return -3;
  15677. }
  15678. }
  15679. // 1.更新注浆明细
  15680. sql = @"update tp_pm_groutingdailydetail set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode";
  15681. Paras = new OracleParameter[] {
  15682. new OracleParameter(":logoid",OracleDbType.Int32,
  15683. logoid,ParameterDirection.Input),
  15684. new OracleParameter(":updateuserid",OracleDbType.Int32,
  15685. sUserInfo.UserID,ParameterDirection.Input),
  15686. new OracleParameter(":barcode",OracleDbType.Varchar2,
  15687. barcode,ParameterDirection.Input)
  15688. };
  15689. returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  15690. // 2.在产产品
  15691. sql = @"update tp_pm_inproduction set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode";
  15692. //Paras = new OracleParameter[] {
  15693. // new OracleParameter(":logoid",OracleDbType.Int32,
  15694. // logoid,ParameterDirection.Input),
  15695. // new OracleParameter(":updateuserid",OracleDbType.Int32,
  15696. // sUserInfo.UserID,ParameterDirection.Input),
  15697. // new OracleParameter(":barcode",OracleDbType.Varchar2,
  15698. // barcode,ParameterDirection.Input)
  15699. // };
  15700. returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  15701. if (returnRows > 0)
  15702. {
  15703. sql = @"select ProcedureID from tp_pm_inproduction where barcode=:barcode";
  15704. pid = oracleTrConn.GetSqlResultToObj(sql, new OracleParameter[]{
  15705. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input)
  15706. });
  15707. }
  15708. // 3.在产回收站
  15709. sql = @"update tp_pm_inproductiontrash set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode";
  15710. //Paras = new OracleParameter[] {
  15711. // new OracleParameter(":logoid",OracleDbType.Int32,
  15712. // logoid,ParameterDirection.Input),
  15713. // new OracleParameter(":updateuserid",OracleDbType.Int32,
  15714. // sUserInfo.UserID,ParameterDirection.Input),
  15715. // new OracleParameter(":barcode",OracleDbType.Varchar2,
  15716. // barcode,ParameterDirection.Input)
  15717. // };
  15718. returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  15719. // 4.在产临时表
  15720. sql = @"update tp_pm_inproduction_tmp set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode";
  15721. //Paras = new OracleParameter[] {
  15722. // new OracleParameter(":logoid",OracleDbType.Int32,
  15723. // logoid,ParameterDirection.Input),
  15724. // new OracleParameter(":updateuserid",OracleDbType.Int32,
  15725. // sUserInfo.UserID,ParameterDirection.Input),
  15726. // new OracleParameter(":barcode",OracleDbType.Varchar2,
  15727. // barcode,ParameterDirection.Input)
  15728. // };
  15729. returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  15730. // 5.成品表
  15731. sql = @"update tp_pm_finishedproduct set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode";
  15732. //Paras = new OracleParameter[] {
  15733. // new OracleParameter(":logoid",OracleDbType.Int32,
  15734. // logoid,ParameterDirection.Input),
  15735. // new OracleParameter(":updateuserid",OracleDbType.Int32,
  15736. // sUserInfo.UserID,ParameterDirection.Input),
  15737. // new OracleParameter(":barcode",OracleDbType.Varchar2,
  15738. // barcode,ParameterDirection.Input)
  15739. // };
  15740. returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  15741. // 6 在产盘点明细
  15742. sql = @"update TP_PM_InCheckedDetail set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode";
  15743. //Paras = new OracleParameter[] {
  15744. // new OracleParameter(":logoid",OracleDbType.Int32,
  15745. // logoid,ParameterDirection.Input),
  15746. // new OracleParameter(":updateuserid",OracleDbType.Int32,
  15747. // sUserInfo.UserID,ParameterDirection.Input),
  15748. // new OracleParameter(":barcode",OracleDbType.Varchar2,
  15749. // barcode,ParameterDirection.Input)
  15750. // };
  15751. // ? returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  15752. // 7 半成品检验登记
  15753. sql = @"update TP_PM_SemiCheck set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode";
  15754. //Paras = new OracleParameter[] {
  15755. // new OracleParameter(":logoid",OracleDbType.Int32,
  15756. // logoid,ParameterDirection.Input),
  15757. // new OracleParameter(":updateuserid",OracleDbType.Int32,
  15758. // sUserInfo.UserID,ParameterDirection.Input),
  15759. // new OracleParameter(":barcode",OracleDbType.Varchar2,
  15760. // barcode,ParameterDirection.Input)
  15761. // };
  15762. // ? returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  15763. // 8 废弃产品
  15764. sql = @"update TP_PM_ScrapProduct set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode";
  15765. //Paras = new OracleParameter[] {
  15766. // new OracleParameter(":logoid",OracleDbType.Int32,
  15767. // logoid,ParameterDirection.Input),
  15768. // new OracleParameter(":updateuserid",OracleDbType.Int32,
  15769. // sUserInfo.UserID,ParameterDirection.Input),
  15770. // new OracleParameter(":barcode",OracleDbType.Varchar2,
  15771. // barcode,ParameterDirection.Input)
  15772. // };
  15773. // ? returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  15774. // 9 在产生产数据
  15775. sql = @"update TP_PM_ProductionDataIn set Triggerflag=1, logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode";
  15776. //Paras = new OracleParameter[] {
  15777. // new OracleParameter(":logoid",OracleDbType.Int32,
  15778. // logoid,ParameterDirection.Input),
  15779. // new OracleParameter(":updateuserid",OracleDbType.Int32,
  15780. // sUserInfo.UserID,ParameterDirection.Input),
  15781. // new OracleParameter(":barcode",OracleDbType.Varchar2,
  15782. // barcode,ParameterDirection.Input)
  15783. // };
  15784. // ? returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  15785. // 10 生产数据
  15786. sql = @"update TP_PM_ProductionData set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode";
  15787. //Paras = new OracleParameter[] {
  15788. // new OracleParameter(":logoid",OracleDbType.Int32,
  15789. // logoid,ParameterDirection.Input),
  15790. // new OracleParameter(":updateuserid",OracleDbType.Int32,
  15791. // sUserInfo.UserID,ParameterDirection.Input),
  15792. // new OracleParameter(":barcode",OracleDbType.Varchar2,
  15793. // barcode,ParameterDirection.Input)
  15794. // };
  15795. // ? returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  15796. // 变更履历
  15797. sql =
  15798. "INSERT INTO TP_PM_LOGOCHANGEDRECORD\n" +
  15799. " (BARCODE\n" +
  15800. " ,OLDLOGOID\n" +
  15801. " ,NEWLOGOID\n" +
  15802. " ,PROCEDUREID\n" +
  15803. " ,REMARKS\n" +
  15804. " ,ACCOUNTID\n" +
  15805. " ,CREATETIME\n" +
  15806. " ,CREATEUSERID)\n" +
  15807. "VALUES\n" +
  15808. " (:BARCODE\n" +
  15809. " ,:OLDLOGOID\n" +
  15810. " ,:NEWLOGOID\n" +
  15811. " ,:PROCEDUREID\n" +
  15812. " ,NULL\n" +
  15813. " ,:ACCOUNTID\n" +
  15814. " ,SYSDATE\n" +
  15815. " ,:CREATEUSERID)";
  15816. Paras = new OracleParameter[] {
  15817. new OracleParameter(":OLDLOGOID",OracleDbType.Int32,
  15818. oldLogoID,ParameterDirection.Input),
  15819. new OracleParameter(":NEWLOGOID",OracleDbType.Int32,
  15820. logoid,ParameterDirection.Input),
  15821. new OracleParameter(":PROCEDUREID",OracleDbType.Int32,
  15822. pid,ParameterDirection.Input),
  15823. new OracleParameter(":ACCOUNTID",OracleDbType.Int32,
  15824. sUserInfo.AccountID,ParameterDirection.Input),
  15825. new OracleParameter(":CREATEUSERID",OracleDbType.Int32,
  15826. sUserInfo.UserID,ParameterDirection.Input),
  15827. new OracleParameter(":BARCODE",OracleDbType.Varchar2,
  15828. barcode,ParameterDirection.Input)
  15829. };
  15830. returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  15831. //if (returnRows == 0)
  15832. //{
  15833. // oracleTrConn.Rollback();
  15834. // oracleTrConn.Disconnect();
  15835. //}
  15836. //else
  15837. {
  15838. oracleTrConn.Commit();
  15839. oracleTrConn.Disconnect();
  15840. }
  15841. }
  15842. catch (Exception ex)
  15843. {
  15844. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  15845. {
  15846. oracleTrConn.Rollback();
  15847. oracleTrConn.Disconnect();
  15848. }
  15849. throw ex;
  15850. }
  15851. return returnRows;
  15852. }
  15853. /// <summary>
  15854. /// 设置条码商标 釉料
  15855. /// </summary>
  15856. /// <returns></returns>
  15857. public static int SaveBarCodeLogoAndGlazetype(string barcode, int logoid, int glazetypeid,
  15858. SUserInfo sUserInfo)
  15859. {
  15860. int returnRows = 0;
  15861. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  15862. try
  15863. {
  15864. // 转换条码
  15865. //string sqlString = @"select FUN_CMN_GetBarCode(:barcode,null,:accountid) From DUAL";
  15866. //OracleParameter[] paras1 = new OracleParameter[]{
  15867. // new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  15868. // new OracleParameter(":accountid",OracleDbType.Int32, sUserInfo.AccountID,ParameterDirection.Input),
  15869. // };
  15870. //barcode = oracleTrConn.GetSqlResultToStr(sqlString, paras1);
  15871. OracleParameter[] Paras = null;
  15872. string sql = "select g.groutingdailydetailid, g.logoid, g.glazetypeid, t.PROCEDUREID from tp_pm_groutingdailydetail g \n" +
  15873. " left join tp_pm_inproduction t on t.barcode = g.barcode\n" +
  15874. "where g.barcode = :barcode";
  15875. Paras = new OracleParameter[] {
  15876. new OracleParameter(":barcode",OracleDbType.NVarchar2,
  15877. barcode,ParameterDirection.Input), };
  15878. DataTable dt = oracleTrConn.GetSqlResultToDt(sql, Paras);
  15879. if (dt == null || dt.Rows.Count == 0)
  15880. {
  15881. return -2;
  15882. }
  15883. // 釉料变更履历
  15884. sql = "insert into TP_PM_GlazetypeRecord\n" +
  15885. //"values\n" + xuwei update 2020-01-02
  15886. " (GROUTINGDAILYDETAILID\n" +
  15887. " ,OldGlazetypeid\n" +
  15888. " ,NewGlazetypeid\n" +
  15889. " ,ProcedureID\n" +
  15890. " ,Remarks\n" +
  15891. " ,AccountID\n" +
  15892. " ,CreateUserID)\n" +
  15893. "values\n" +
  15894. " (:GROUTINGDAILYDETAILID\n" +
  15895. " ,:OldGlazetypeid\n" +
  15896. " ,:NewGlazetypeid\n" +
  15897. " ,:ProcedureID\n" +
  15898. " ,:Remarks\n" +
  15899. " ,:AccountID\n" +
  15900. " ,:CreateUserID)";
  15901. Paras = new OracleParameter[] {
  15902. new OracleParameter(":GROUTINGDAILYDETAILID",OracleDbType.Int32,
  15903. dt.Rows[0]["GROUTINGDAILYDETAILID"],ParameterDirection.Input),
  15904. new OracleParameter(":OldGlazetypeid",OracleDbType.Int32,
  15905. dt.Rows[0]["glazetypeid"],ParameterDirection.Input),
  15906. new OracleParameter(":NewGlazetypeid",OracleDbType.Int32,
  15907. glazetypeid,ParameterDirection.Input),
  15908. new OracleParameter(":ProcedureID",OracleDbType.Int32,
  15909. dt.Rows[0]["PROCEDUREID"],ParameterDirection.Input),
  15910. new OracleParameter(":Remarks",OracleDbType.NVarchar2,
  15911. null,ParameterDirection.Input),
  15912. new OracleParameter(":AccountID",OracleDbType.Int32,
  15913. sUserInfo.AccountID,ParameterDirection.Input),
  15914. new OracleParameter(":CreateUserID",OracleDbType.Int32,
  15915. sUserInfo.UserID,ParameterDirection.Input),
  15916. };
  15917. returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  15918. // 变更履历
  15919. sql =
  15920. "INSERT INTO TP_PM_LOGOCHANGEDRECORD\n" +
  15921. " (BARCODE\n" +
  15922. " ,OLDLOGOID\n" +
  15923. " ,NEWLOGOID\n" +
  15924. //" ,PROCEDUREID\n" +
  15925. " ,REMARKS\n" +
  15926. " ,ACCOUNTID\n" +
  15927. " ,CREATETIME\n" +
  15928. " ,CREATEUSERID)\n" +
  15929. "VALUES\n" +
  15930. " (:BARCODE\n" +
  15931. " ,:OLDLOGOID\n" +
  15932. " ,:NEWLOGOID\n" +
  15933. //" ,:PROCEDUREID\n" +
  15934. " ,NULL\n" +
  15935. " ,:ACCOUNTID\n" +
  15936. " ,SYSDATE\n" +
  15937. " ,:CREATEUSERID)";
  15938. Paras = new OracleParameter[] {
  15939. new OracleParameter(":OLDLOGOID",OracleDbType.Int32,
  15940. dt.Rows[0]["LOGOID"],ParameterDirection.Input),
  15941. new OracleParameter(":NEWLOGOID",OracleDbType.Int32,
  15942. logoid,ParameterDirection.Input),
  15943. //new OracleParameter(":PROCEDUREID",OracleDbType.Int32,
  15944. // pid,ParameterDirection.Input),
  15945. new OracleParameter(":ACCOUNTID",OracleDbType.Int32,
  15946. sUserInfo.AccountID,ParameterDirection.Input),
  15947. new OracleParameter(":CREATEUSERID",OracleDbType.Int32,
  15948. sUserInfo.UserID,ParameterDirection.Input),
  15949. new OracleParameter(":BARCODE",OracleDbType.Varchar2,
  15950. barcode,ParameterDirection.Input)
  15951. };
  15952. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  15953. // 1.更新注浆明细
  15954. sql = "update tp_pm_groutingdailydetail set logoid=:logoid, glazetypeid =:glazetypeid, updateuserid=:updateuserid where barcode=:barcode";
  15955. Paras = new OracleParameter[] {
  15956. new OracleParameter(":logoid",OracleDbType.Int32,
  15957. logoid,ParameterDirection.Input),
  15958. new OracleParameter(":glazetypeid",OracleDbType.Int32,
  15959. glazetypeid,ParameterDirection.Input),
  15960. new OracleParameter(":updateuserid",OracleDbType.Int32,
  15961. sUserInfo.UserID,ParameterDirection.Input),
  15962. new OracleParameter(":barcode",OracleDbType.Varchar2,
  15963. barcode,ParameterDirection.Input)
  15964. };
  15965. returnRows = oracleTrConn.ExecuteNonQuery(sql, Paras);
  15966. // 1.更新在产
  15967. sql = @"update TP_PM_INPRODUCTION set logoid=:logoid,
  15968. --glazetypeid =:glazetypeid,
  15969. updateuserid=:updateuserid where barcode=:barcode";
  15970. Paras = new OracleParameter[] {
  15971. new OracleParameter(":logoid",OracleDbType.Int32,
  15972. logoid,ParameterDirection.Input),
  15973. //new OracleParameter(":glazetypeid",OracleDbType.Int32,
  15974. // glazetypeid,ParameterDirection.Input),
  15975. new OracleParameter(":updateuserid",OracleDbType.Int32,
  15976. sUserInfo.UserID,ParameterDirection.Input),
  15977. new OracleParameter(":barcode",OracleDbType.Varchar2,
  15978. barcode,ParameterDirection.Input)
  15979. };
  15980. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  15981. oracleTrConn.Commit();
  15982. }
  15983. catch (Exception ex)
  15984. {
  15985. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  15986. {
  15987. oracleTrConn.Rollback();
  15988. }
  15989. throw ex;
  15990. }
  15991. finally { oracleTrConn.Disconnect(); }
  15992. return returnRows;
  15993. }
  15994. /// <summary>
  15995. /// 设置条码商标 釉料
  15996. /// </summary>
  15997. /// <returns></returns>
  15998. public static int SaveBarCodesLogoAndGlazetype(string barcodesstr, int logoid, int glazetypeid,
  15999. int procedureID, SUserInfo sUserInfo)
  16000. {
  16001. int returnRows = 0;
  16002. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  16003. try
  16004. {
  16005. OracleParameter[] Paras = null;
  16006. string sql = "select g.groutingdailydetailid, g.logoid, g.glazetypeid, t.PROCEDUREID from tp_pm_groutingdailydetail g \n" +
  16007. " left join tp_pm_inproduction t on t.barcode = g.barcode\n" +
  16008. "where g.barcode = :barcode";
  16009. string sql0 = "select g.groutingdailydetailid, g.logoid, g.glazetypeid from tp_pm_groutingdailydetail g \n" +
  16010. "where g.barcode = :barcode";
  16011. // 釉料变更履历
  16012. string sql1 = "insert into TP_PM_GlazetypeRecord\n" +
  16013. //"values\n" + xuwei update 2020-01-02
  16014. " (GROUTINGDAILYDETAILID\n" +
  16015. " ,OldGlazetypeid\n" +
  16016. " ,NewGlazetypeid\n" +
  16017. " ,ProcedureID\n" +
  16018. " ,Remarks\n" +
  16019. " ,AccountID\n" +
  16020. " ,CreateUserID)\n" +
  16021. "values\n" +
  16022. " (:GROUTINGDAILYDETAILID\n" +
  16023. " ,:OldGlazetypeid\n" +
  16024. " ,:NewGlazetypeid\n" +
  16025. " ,:ProcedureID\n" +
  16026. " ,:Remarks\n" +
  16027. " ,:AccountID\n" +
  16028. " ,:CreateUserID)";
  16029. // 变更履历
  16030. string sqllogo =
  16031. "INSERT INTO TP_PM_LOGOCHANGEDRECORD\n" +
  16032. " (BARCODE\n" +
  16033. " ,OLDLOGOID\n" +
  16034. " ,NEWLOGOID\n" +
  16035. //" ,PROCEDUREID\n" +
  16036. " ,REMARKS\n" +
  16037. " ,ACCOUNTID\n" +
  16038. " ,CREATETIME\n" +
  16039. " ,CREATEUSERID)\n" +
  16040. "VALUES\n" +
  16041. " (:BARCODE\n" +
  16042. " ,:OLDLOGOID\n" +
  16043. " ,:NEWLOGOID\n" +
  16044. //" ,:PROCEDUREID\n" +
  16045. " ,NULL\n" +
  16046. " ,:ACCOUNTID\n" +
  16047. " ,SYSDATE\n" +
  16048. " ,:CREATEUSERID)";
  16049. string sql2 = "update tp_pm_groutingdailydetail set logoid=:logoid, glazetypeid =:glazetypeid, updateuserid=:updateuserid where barcode=:barcode";
  16050. // 1.更新在产
  16051. string sqlin = @"update TP_PM_INPRODUCTION set logoid=:logoid,
  16052. --glazetypeid =:glazetypeid,
  16053. updateuserid=:updateuserid where barcode=:barcode";
  16054. //xuwei add 2020-01-02
  16055. string[] barcodes = barcodesstr.Split(',');
  16056. foreach (string barcode in barcodes)
  16057. {
  16058. Paras = new OracleParameter[] {
  16059. new OracleParameter(":barcode",OracleDbType.NVarchar2,
  16060. barcode,ParameterDirection.Input), };
  16061. DataTable dt = null;
  16062. if (procedureID > 0)
  16063. {
  16064. dt = oracleTrConn.GetSqlResultToDt(sql0, Paras);
  16065. }
  16066. else
  16067. {
  16068. dt = oracleTrConn.GetSqlResultToDt(sql, Paras);
  16069. }
  16070. if (dt == null || dt.Rows.Count == 0)
  16071. {
  16072. //continue;
  16073. return -2;
  16074. }
  16075. Paras = new OracleParameter[] {
  16076. new OracleParameter(":GROUTINGDAILYDETAILID",OracleDbType.Int32,
  16077. dt.Rows[0]["GROUTINGDAILYDETAILID"],ParameterDirection.Input),
  16078. new OracleParameter(":OldGlazetypeid",OracleDbType.Int32,
  16079. dt.Rows[0]["glazetypeid"],ParameterDirection.Input),
  16080. new OracleParameter(":NewGlazetypeid",OracleDbType.Int32,
  16081. glazetypeid,ParameterDirection.Input),
  16082. new OracleParameter(":ProcedureID",OracleDbType.Int32,
  16083. (procedureID > 0 ? procedureID : dt.Rows[0]["PROCEDUREID"]),ParameterDirection.Input),
  16084. new OracleParameter(":Remarks",OracleDbType.NVarchar2,
  16085. null,ParameterDirection.Input),
  16086. new OracleParameter(":AccountID",OracleDbType.Int32,
  16087. sUserInfo.AccountID,ParameterDirection.Input),
  16088. new OracleParameter(":CreateUserID",OracleDbType.Int32,
  16089. sUserInfo.UserID,ParameterDirection.Input),
  16090. };
  16091. oracleTrConn.ExecuteNonQuery(sql1, Paras);
  16092. // 商标履历
  16093. Paras = new OracleParameter[] {
  16094. new OracleParameter(":OLDLOGOID",OracleDbType.Int32,
  16095. dt.Rows[0]["LOGOID"],ParameterDirection.Input),
  16096. new OracleParameter(":NEWLOGOID",OracleDbType.Int32,
  16097. logoid,ParameterDirection.Input),
  16098. //new OracleParameter(":PROCEDUREID",OracleDbType.Int32,
  16099. // pid,ParameterDirection.Input),
  16100. new OracleParameter(":ACCOUNTID",OracleDbType.Int32,
  16101. sUserInfo.AccountID,ParameterDirection.Input),
  16102. new OracleParameter(":CREATEUSERID",OracleDbType.Int32,
  16103. sUserInfo.UserID,ParameterDirection.Input),
  16104. new OracleParameter(":BARCODE",OracleDbType.Varchar2,
  16105. barcode,ParameterDirection.Input)
  16106. };
  16107. returnRows += oracleTrConn.ExecuteNonQuery(sqllogo, Paras);
  16108. // 1.更新注浆明细
  16109. Paras = new OracleParameter[] {
  16110. new OracleParameter(":logoid",OracleDbType.Int32,
  16111. logoid,ParameterDirection.Input),
  16112. new OracleParameter(":glazetypeid",OracleDbType.Int32,
  16113. glazetypeid,ParameterDirection.Input),
  16114. new OracleParameter(":updateuserid",OracleDbType.Int32,
  16115. sUserInfo.UserID,ParameterDirection.Input),
  16116. new OracleParameter(":barcode",OracleDbType.Varchar2,
  16117. barcode,ParameterDirection.Input)
  16118. };
  16119. returnRows += oracleTrConn.ExecuteNonQuery(sql2, Paras);
  16120. // 1.更新在产
  16121. Paras = new OracleParameter[] {
  16122. new OracleParameter(":logoid",OracleDbType.Int32,
  16123. logoid,ParameterDirection.Input),
  16124. //new OracleParameter(":glazetypeid",OracleDbType.Int32,
  16125. // glazetypeid,ParameterDirection.Input),
  16126. new OracleParameter(":updateuserid",OracleDbType.Int32,
  16127. sUserInfo.UserID,ParameterDirection.Input),
  16128. new OracleParameter(":barcode",OracleDbType.Varchar2,
  16129. barcode,ParameterDirection.Input)
  16130. };
  16131. returnRows = oracleTrConn.ExecuteNonQuery(sqlin, Paras);
  16132. }
  16133. oracleTrConn.Commit();
  16134. }
  16135. catch (Exception ex)
  16136. {
  16137. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  16138. {
  16139. oracleTrConn.Rollback();
  16140. }
  16141. throw ex;
  16142. }
  16143. finally { oracleTrConn.Disconnect(); }
  16144. return returnRows;
  16145. }
  16146. /// <summary>
  16147. /// 设置产成品商标
  16148. /// </summary>
  16149. /// <param name="barcodes"></param>
  16150. /// <param name="logoid"></param>
  16151. /// <param name="sUserInfo"></param>
  16152. /// <returns></returns>
  16153. public static int SetFinishedLogo(string[] barcodes, int logoid, SUserInfo sUserInfo)
  16154. {
  16155. int returnRows = 0;
  16156. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  16157. try
  16158. {
  16159. OracleParameter[] Paras = null;
  16160. object oldLogoID = null;
  16161. object gdid = null;
  16162. //object pid = null;
  16163. string sql = "";
  16164. DataTable dataTable = null;
  16165. foreach (string barcode in barcodes)
  16166. {
  16167. sql = @"select groutingdailydetailid, logoid from tp_pm_groutingdailydetail where barcode=:barcode";
  16168. dataTable = oracleTrConn.GetSqlResultToDt(sql, new OracleParameter[]{
  16169. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input)
  16170. });
  16171. if (dataTable == null || dataTable.Rows.Count == 0)
  16172. {
  16173. continue;
  16174. }
  16175. gdid = dataTable.Rows[0]["groutingdailydetailid"];
  16176. oldLogoID = dataTable.Rows[0]["logoid"];
  16177. // 1.更新注浆明细
  16178. sql = @"update tp_pm_groutingdailydetail set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode";
  16179. Paras = new OracleParameter[] {
  16180. new OracleParameter(":logoid",OracleDbType.Int32,
  16181. logoid,ParameterDirection.Input),
  16182. new OracleParameter(":updateuserid",OracleDbType.Int32,
  16183. sUserInfo.UserID,ParameterDirection.Input),
  16184. new OracleParameter(":barcode",OracleDbType.Varchar2,
  16185. barcode,ParameterDirection.Input)
  16186. };
  16187. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  16188. // 5.成品表
  16189. sql = @"update tp_pm_finishedproduct set logoid=:logoid,updateuserid=:updateuserid where barcode=:barcode";
  16190. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  16191. // 变更履历
  16192. sql =
  16193. "INSERT INTO TP_PM_LOGOCHANGEDRECORD\n" +
  16194. " (BARCODE\n" +
  16195. " ,OLDLOGOID\n" +
  16196. " ,NEWLOGOID\n" +
  16197. //" ,PROCEDUREID\n" +
  16198. " ,REMARKS\n" +
  16199. " ,ACCOUNTID\n" +
  16200. " ,CREATETIME\n" +
  16201. " ,CREATEUSERID)\n" +
  16202. "VALUES\n" +
  16203. " (:BARCODE\n" +
  16204. " ,:OLDLOGOID\n" +
  16205. " ,:NEWLOGOID\n" +
  16206. //" ,:PROCEDUREID\n" +
  16207. " ,NULL\n" +
  16208. " ,:ACCOUNTID\n" +
  16209. " ,SYSDATE\n" +
  16210. " ,:CREATEUSERID)";
  16211. Paras = new OracleParameter[] {
  16212. new OracleParameter(":OLDLOGOID",OracleDbType.Int32,
  16213. oldLogoID,ParameterDirection.Input),
  16214. new OracleParameter(":NEWLOGOID",OracleDbType.Int32,
  16215. logoid,ParameterDirection.Input),
  16216. //new OracleParameter(":PROCEDUREID",OracleDbType.Int32,
  16217. // pid,ParameterDirection.Input),
  16218. new OracleParameter(":ACCOUNTID",OracleDbType.Int32,
  16219. sUserInfo.AccountID,ParameterDirection.Input),
  16220. new OracleParameter(":CREATEUSERID",OracleDbType.Int32,
  16221. sUserInfo.UserID,ParameterDirection.Input),
  16222. new OracleParameter(":BARCODE",OracleDbType.Varchar2,
  16223. barcode,ParameterDirection.Input)
  16224. };
  16225. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  16226. }
  16227. //if (returnRows == 0)
  16228. //{
  16229. // oracleTrConn.Rollback();
  16230. // oracleTrConn.Disconnect();
  16231. //}
  16232. //else
  16233. {
  16234. oracleTrConn.Commit();
  16235. oracleTrConn.Disconnect();
  16236. }
  16237. }
  16238. catch (Exception ex)
  16239. {
  16240. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  16241. {
  16242. oracleTrConn.Rollback();
  16243. oracleTrConn.Disconnect();
  16244. }
  16245. throw ex;
  16246. }
  16247. return returnRows;
  16248. }
  16249. /// <summary>
  16250. /// 设置产成品订单
  16251. /// </summary>
  16252. /// <param name="barcodes"></param>
  16253. /// <param name="orderid"></param>
  16254. /// <param name="sUserInfo"></param>
  16255. /// <returns></returns>
  16256. public static int SetHandoveredOrder(string[] barcodes, int orderID, SUserInfo sUserInfo)
  16257. {
  16258. int returnRows = 0;
  16259. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  16260. try
  16261. {
  16262. string sql = @"update tp_pm_finishedproduct set FHOrderID=:FHOrderID,updateuserid=:updateuserid where barcode=:barcode and FHOrderID is not null";
  16263. OracleParameter[] Paras = new OracleParameter[] {
  16264. new OracleParameter(":barcode",OracleDbType.Varchar2,
  16265. "",ParameterDirection.Input),
  16266. new OracleParameter(":FHOrderID",OracleDbType.Int32,
  16267. orderID,ParameterDirection.Input),
  16268. new OracleParameter(":updateuserid",OracleDbType.Int32,
  16269. sUserInfo.UserID,ParameterDirection.Input)
  16270. };
  16271. foreach (string barcode in barcodes)
  16272. {
  16273. Paras[0].Value = barcode;
  16274. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  16275. }
  16276. oracleTrConn.Commit();
  16277. oracleTrConn.Disconnect();
  16278. }
  16279. catch (Exception ex)
  16280. {
  16281. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  16282. {
  16283. oracleTrConn.Rollback();
  16284. oracleTrConn.Disconnect();
  16285. }
  16286. throw ex;
  16287. }
  16288. return returnRows;
  16289. }
  16290. #endregion
  16291. /// <summary>
  16292. /// 添加生产数据
  16293. /// </summary>
  16294. /// <param name="oracleTrConn">连接对象</param>
  16295. /// <param name="accountDate">账务日期</param>
  16296. /// <param name="productionData">生产数据</param>
  16297. /// <param name="sUserInfo">用户基本信息</param>
  16298. /// <returns>string</returns>
  16299. /// <remarks>
  16300. /// 陈冰 2014.09.18 新建
  16301. /// </remarks>
  16302. private static string AddProductionDataWaster(IDBTransaction oracleTrConn, DateTime accountDate, ProductionDataEntity productionData, SUserInfo sUserInfo, out string OutSpecialRepairflag)
  16303. {
  16304. #region 查出产品注浆日期,注浆工号ID,注浆工号编码,注浆次数,注浆模具编号,模具编号
  16305. string selectSql = "";
  16306. string returnVal = "";
  16307. //xuwei fix 2019-09-24 按新规则重新校准NodeType.Begin使后续NodeType.Begin判定是准确的
  16308. //xuwei fix 2019-09-26 使用通用方法判定
  16309. // 2019-1016
  16310. //int isNodeBegin = IsNodeBegin<IDBTransaction>(oracleTrConn, productionData.Barcode);
  16311. //if (isNodeBegin == 1) productionData.NodeType = (int)Constant.ProcedureNodeType.Begin;
  16312. if (productionData.NodeType == (int)Constant.ProcedureNodeType.Begin)
  16313. {
  16314. int isNodeBegin = IsNodeBegin<IDBTransaction>(oracleTrConn, productionData.Barcode);
  16315. if (isNodeBegin == 0)
  16316. {
  16317. productionData.NodeType = (int)Constant.ProcedureNodeType.Middle;
  16318. }
  16319. }
  16320. if (productionData.NodeType == (int)Constant.ProcedureNodeType.Begin)//开始节点时从注浆登记取值
  16321. {
  16322. selectSql = @"select TP_PM_GroutingDailyDetail.GroutingDate,
  16323. TP_PM_GroutingDailyDetail.UserID as GroutingUserID,
  16324. TP_PM_GroutingDailyDetail.UserCode as GroutingUserCode,
  16325. TP_PM_GroutingDailyDetail.GroutingCount as GroutingNum,
  16326. TP_PM_GroutingDailyDetail.GroutingMouldCode,
  16327. TP_PM_GroutingDailyDetail.MouldCode,
  16328. TP_PM_GroutingDailyDetail.GroutingDailyID,
  16329. TP_PM_GroutingDailyDetail.GroutingDailyDetailID,
  16330. TP_PM_GroutingDailyDetail.GroutingLineID,
  16331. TP_PM_GroutingDailyDetail.GroutingLineCode,
  16332. TP_PM_GroutingDailyDetail.GroutingLineName,
  16333. TP_PM_GroutingDailyDetail.GroutingLineDetailID,
  16334. TP_PM_GroutingDailyDetail.SpecialRepairflag,
  16335. (select GMouldTypeID
  16336. from TP_PM_GroutingDaily
  16337. where TP_PM_GroutingDaily.GroutingDailyID =
  16338. TP_PM_GroutingDailyDetail.GroutingDailyID) as GMouldTypeID,
  16339. (select CanManyTimes
  16340. from TP_PM_GroutingDaily
  16341. where TP_PM_GroutingDaily.GroutingDailyID =
  16342. TP_PM_GroutingDailyDetail.GroutingDailyID) as CanManyTimes,
  16343. 0 as IsReFire
  16344. from TP_PM_GroutingDailyDetail
  16345. where TP_PM_GroutingDailyDetail.barcode=:barcode";
  16346. }
  16347. else
  16348. {
  16349. selectSql = @"select
  16350. GroutingDate,
  16351. userid as GroutingUserID,
  16352. usercode as GroutingUserCode,
  16353. Groutingcount as GroutingNum,
  16354. GroutingMouldCode,
  16355. MouldCode,
  16356. GroutingDailyID,
  16357. GroutingDailyDetailID,
  16358. GroutingLineID,
  16359. GroutingLineCode,
  16360. GroutingLineName,
  16361. GMouldTypeID,
  16362. CanManyTimes,
  16363. GroutingLineDetailID,
  16364. SpecialRepairflag,
  16365. 0 as IsReFire,
  16366. logoid
  16367. from TP_PM_GroutingDailyDetail where barcode=:barcode
  16368. ";
  16369. }
  16370. OracleParameter[] selectparas = new OracleParameter[] {
  16371. new OracleParameter(":barcode",productionData.Barcode),
  16372. };
  16373. DataSet dsGroutingProduct = oracleTrConn.GetSqlResultToDs(selectSql, selectparas);
  16374. DateTime GroutingDate = new DateTime();
  16375. int GroutingUserID = 0, GroutingNum = 0, GroutingDailyID = 0, GroutingDailyDetailID = 0, GroutingLineID = 0, GMouldTypeID = 0, CanManyTimes = 0, GroutingLineDetailID = 0, SpecialRepairflag = 0;
  16376. string GroutingUserCode = "", GroutingMouldCode = "", MouldCode = "", GroutingLineCode = "", GroutingLineName = "";
  16377. int IsReFire = 0;
  16378. int? logoID = null;
  16379. if (dsGroutingProduct != null && dsGroutingProduct.Tables[0].Rows.Count > 0)
  16380. {
  16381. GroutingDate = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
  16382. GroutingUserID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingUserID"]);
  16383. GroutingUserCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"].ToString();
  16384. GroutingNum = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"]);
  16385. GroutingMouldCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingMouldCode"].ToString();
  16386. MouldCode = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"].ToString();
  16387. GroutingDailyID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyID"]);
  16388. GroutingDailyDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingDailyDetailID"]);
  16389. GroutingLineID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineID"]);
  16390. GroutingLineCode = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineCode"].ToString();
  16391. GroutingLineName = dsGroutingProduct.Tables[0].Rows[0]["GroutingLineName"].ToString();
  16392. GMouldTypeID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GMouldTypeID"]);
  16393. CanManyTimes = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["CanManyTimes"]);
  16394. GroutingLineDetailID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["GroutingLineDetailID"]);
  16395. SpecialRepairflag = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["SpecialRepairflag"]);
  16396. IsReFire = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["IsReFire"]);
  16397. if (IsReFire > 0) //大于零代表重烧过
  16398. {
  16399. productionData.IsReFire = IsReFire;
  16400. productionData.DefectFlag = (int)Constant.GoodsLevelType.Defect;
  16401. }
  16402. if (dsGroutingProduct.Tables[0].Rows[0]["logoID"].ToString() != "")
  16403. {
  16404. logoID = Convert.ToInt32(dsGroutingProduct.Tables[0].Rows[0]["logoID"]);
  16405. }
  16406. //if (productionData.LogoID != null) //当前工序有商标
  16407. //{
  16408. // if (logoID != productionData.LogoID && productionData.LogoID != 0)
  16409. // {
  16410. // logoID = productionData.LogoID;
  16411. // //根据明细ID.update
  16412. // selectSql = "update TP_PM_GroutingDailyDetail set logoid=:logoid where GroutingDailyDetailID=" + GroutingDailyDetailID;
  16413. // OracleParameter[] paras2 = new OracleParameter[] {
  16414. // new OracleParameter(":logoid",productionData.LogoID)
  16415. // };
  16416. // oracleTrConn.ExecuteNonQuery(selectSql, paras2);
  16417. // }
  16418. //}
  16419. returnVal = SpecialRepairflag.ToString();
  16420. }
  16421. #endregion
  16422. #region 更新窑炉窑车属性
  16423. if (productionData.ModelType != 1 && productionData.ModelType != 2 && productionData.ModelType != 3 && productionData.ModelType != 4)
  16424. {
  16425. DataSet ds = GetKilnCarInfo(oracleTrConn, productionData.Barcode, sUserInfo);
  16426. if (ds != null)
  16427. {
  16428. if (ds.Tables[0].Rows[0]["KilnID"].ToString() != "") //表示以前有过窑炉相关信息
  16429. {
  16430. productionData.KilnID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnID"]);
  16431. productionData.KilnCode = ds.Tables[0].Rows[0]["KilnCode"].ToString();
  16432. productionData.KilnName = ds.Tables[0].Rows[0]["KilnName"].ToString();
  16433. productionData.KilnCarID = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarID"]);
  16434. productionData.KilnCarCode = ds.Tables[0].Rows[0]["KilnCarCode"].ToString();
  16435. productionData.KilnCarName = ds.Tables[0].Rows[0]["KilnCarName"].ToString();
  16436. productionData.KilnCarBatchNo = ds.Tables[0].Rows[0]["KilnCarBatchNo"].ToString();
  16437. productionData.KilnCarPosition = Convert.ToInt32(ds.Tables[0].Rows[0]["KilnCarPosition"]);
  16438. }
  16439. }
  16440. }
  16441. #endregion
  16442. #region SQL
  16443. string sql = "insert into tp_pm_productiondataIn"
  16444. + " (productiondataid,"
  16445. + " barcode,"
  16446. + " centralizedbatchno,"
  16447. + " productionlineid,"
  16448. + " productionlinecode,"
  16449. + " productionlinename,"
  16450. + " procedureid,"
  16451. + " procedurecode,"
  16452. + " procedurename,"
  16453. + " proceduremodel,"
  16454. + " modeltype,"
  16455. + " piecetype,"
  16456. + " isreworked,"
  16457. + " nodetype,"
  16458. + " ispublicbody,"
  16459. + " isrefire,"
  16460. + " organizationid,"
  16461. + " goodsid,"
  16462. + " goodscode,"
  16463. + " goodsname,"
  16464. + " userid,"
  16465. + " usercode,"
  16466. + " username,"
  16467. + " kilnid,"
  16468. + " kilncode,"
  16469. + " kilnname,"
  16470. + " kilncarid,"
  16471. + " kilncarcode,"
  16472. + " kilncarname,"
  16473. + " kilncarbatchno,"
  16474. + " kilncarposition,"
  16475. + " reworkprocedureid,"
  16476. + " reworkprocedurecode,"
  16477. + " reworkprocedurename,"
  16478. + " remarks,"
  16479. + " accountdate,"
  16480. + " accountid,"
  16481. + " GoodsLevelID,"
  16482. + " GoodsLevelTypeID,"
  16483. + " createuserid,"
  16484. + " updateuserid,"
  16485. + " GroutingDate,"
  16486. + " GroutingUserID,"
  16487. + " GroutingUserCode,"
  16488. + " GroutingNum,"
  16489. + " GroutingMouldCode,"
  16490. + " MouldCode,"
  16491. + "GroutingDailyID,"
  16492. + "GroutingDailyDetailID,"
  16493. + "GroutingLineID,"
  16494. + " GroutingLineCode,"
  16495. + "GroutingLineName,"
  16496. + "GMouldTypeID,"
  16497. + "CanManyTimes,"
  16498. + "GroutingLineDetailID,"
  16499. + "SpecialRepairflag,"
  16500. + "ClassesSettingID,"
  16501. + "LogoID"
  16502. + ")"
  16503. + " values"
  16504. + " (:productiondataid,"
  16505. + " :barcode,"
  16506. + " :centralizedbatchno,"
  16507. + " :productionlineid,"
  16508. + " :productionlinecode,"
  16509. + " :productionlinename,"
  16510. + " :procedureid,"
  16511. + " :procedurecode,"
  16512. + " :procedurename,"
  16513. + " :proceduremodel,"
  16514. + " :modeltype,"
  16515. + " :piecetype,"
  16516. + " :isreworked,"
  16517. + " :nodetype,"
  16518. + " :ispublicbody,"
  16519. + " :isrefire,"
  16520. + " :organizationid,"
  16521. + " :goodsid,"
  16522. + " :goodscode,"
  16523. + " :goodsname,"
  16524. + " :userid,"
  16525. + " :usercode,"
  16526. + " :username,"
  16527. + " :kilnid,"
  16528. + " :kilncode,"
  16529. + " :kilnname,"
  16530. + " :kilncarid,"
  16531. + " :kilncarcode,"
  16532. + " :kilncarname,"
  16533. + " :kilncarbatchno,"
  16534. + " :kilncarposition,"
  16535. + " :reworkprocedureid,"
  16536. + " :reworkprocedurecode,"
  16537. + " :reworkprocedurename,"
  16538. + " :remarks,"
  16539. + " :accountdata,"
  16540. + " :accountid,"
  16541. + " :GoodsLevelID,"
  16542. + " :GoodsLevelTypeID,"
  16543. + " :createuserid,"
  16544. + " :updateuserid,"
  16545. + " :groutingdate,"
  16546. + " :groutinguserid,"
  16547. + " :groutingusercode,"
  16548. + " :groutingnum,"
  16549. + " :groutingmouldcode,"
  16550. + " :mouldcode,"
  16551. + ":groutingdailyid,"
  16552. + ":groutingdailydetailid,"
  16553. + ":groutinglineid,"
  16554. + " :groutinglinecode,"
  16555. + ":groutinglinename,"
  16556. + ":gmouldtypeid,"
  16557. + ":canmanytimes,"
  16558. + ":groutinglinedetailid,"
  16559. + ":specialRepairflag,"
  16560. + ":classesSettingID,"
  16561. + ":logoID"
  16562. + ")";
  16563. #endregion
  16564. #region OracleParameter
  16565. OracleParameter[] paras = new OracleParameter[] {
  16566. new OracleParameter(":classesSettingID",productionData.ClassesSettingID),
  16567. new OracleParameter(":productiondataid",productionData.ProductionDataID),
  16568. new OracleParameter(":barcode",productionData.Barcode),
  16569. new OracleParameter(":centralizedbatchno",productionData.CentralizedBatchNo),
  16570. new OracleParameter(":productionlineid",productionData.ProductionLineID),
  16571. new OracleParameter(":productionlinecode",productionData.ProductionLineCode),
  16572. new OracleParameter(":productionlinename",productionData.ProductionLineName),
  16573. new OracleParameter(":procedureid",productionData.ProcedureID),
  16574. new OracleParameter(":procedurecode",productionData.ProcedureCode),
  16575. new OracleParameter(":procedurename",productionData.ProcedureName),
  16576. new OracleParameter(":proceduremodel",productionData.ProcedureModel),
  16577. new OracleParameter(":modeltype",productionData.ModelType),
  16578. new OracleParameter(":piecetype",productionData.PieceType),
  16579. new OracleParameter(":isreworked",productionData.IsReworked),
  16580. new OracleParameter(":nodetype",productionData.NodeType),
  16581. new OracleParameter(":ispublicbody",productionData.IsPublicBody),
  16582. new OracleParameter(":isrefire",productionData.IsReFire),
  16583. new OracleParameter(":organizationid",productionData.OrganizationID),
  16584. new OracleParameter(":goodsid",productionData.GoodsID),
  16585. new OracleParameter(":goodscode",productionData.GoodsCode),
  16586. new OracleParameter(":goodsname",productionData.GoodsName),
  16587. new OracleParameter(":userid",productionData.UserID),
  16588. new OracleParameter(":usercode",productionData.UserCode),
  16589. new OracleParameter(":username",productionData.UserName),
  16590. new OracleParameter(":kilnid",productionData.KilnID),
  16591. new OracleParameter(":kilncode",productionData.KilnCode),
  16592. new OracleParameter(":kilnname",productionData.KilnName),
  16593. new OracleParameter(":kilncarid",productionData.KilnCarID),
  16594. new OracleParameter(":kilncarcode",productionData.KilnCarCode),
  16595. new OracleParameter(":kilncarname",productionData.KilnCarName),
  16596. new OracleParameter(":kilncarbatchno",productionData.KilnCarBatchNo),
  16597. new OracleParameter(":kilncarposition",productionData.KilnCarPosition),
  16598. new OracleParameter(":reworkprocedureid",productionData.ReworkProcedureID),
  16599. new OracleParameter(":reworkprocedurecode",productionData.ReworkProcedureCode),
  16600. new OracleParameter(":reworkprocedurename",productionData.ReworkProcedureName),
  16601. new OracleParameter(":remarks",productionData.Remarks),
  16602. new OracleParameter(":accountdata",accountDate),
  16603. new OracleParameter(":accountid",sUserInfo.AccountID),
  16604. new OracleParameter(":GoodsLevelID",productionData.GoodsLevelID),
  16605. new OracleParameter(":GoodsLevelTypeID",productionData.GoodsLevelTypeID),
  16606. new OracleParameter(":createuserid",sUserInfo.UserID),
  16607. new OracleParameter(":updateuserid",sUserInfo.UserID),
  16608. new OracleParameter(":groutingdate",GroutingDate),
  16609. new OracleParameter(":groutinguserid",GroutingUserID),
  16610. new OracleParameter(":groutingusercode",GroutingUserCode),
  16611. new OracleParameter(":groutingnum",GroutingNum),
  16612. new OracleParameter(":groutingmouldcode",GroutingMouldCode),
  16613. new OracleParameter(":mouldcode",MouldCode),
  16614. new OracleParameter(":groutingdailyid",GroutingDailyID),
  16615. new OracleParameter(":groutingdailydetailid",GroutingDailyDetailID),
  16616. new OracleParameter(":groutinglineid",GroutingLineID),
  16617. new OracleParameter(":groutinglinecode",GroutingLineCode),
  16618. new OracleParameter(":groutinglinename",GroutingLineName),
  16619. new OracleParameter(":gmouldtypeid",GMouldTypeID),
  16620. new OracleParameter(":canmanytimes",CanManyTimes),
  16621. new OracleParameter(":groutinglinedetailid",GroutingLineDetailID),
  16622. new OracleParameter(":specialRepairflag",SpecialRepairflag),
  16623. new OracleParameter(":logoID",logoID),
  16624. };
  16625. #endregion
  16626. foreach (OracleParameter para in paras)
  16627. {
  16628. if (string.IsNullOrEmpty(para.Value + ""))
  16629. {
  16630. para.Value = DBNull.Value;
  16631. }
  16632. }
  16633. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  16634. OutSpecialRepairflag = returnVal;
  16635. // 失败
  16636. if (result != Constant.INT_IS_ONE)
  16637. {
  16638. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  16639. }
  16640. // 成功返回null
  16641. return null;
  16642. }
  16643. #region 保存半检登记
  16644. /// <summary>
  16645. /// 保存半检登记
  16646. /// </summary>
  16647. /// <param name="entity">半检实体类</param>
  16648. /// <param name="sUserInfo">用户基本信息</param>
  16649. /// <returns>ServiceResultEntity</returns>
  16650. /// <remarks>
  16651. /// 王鑫 2016.06.27 新建
  16652. /// </remarks>
  16653. public static ServiceResultEntity AddSemiCheck(SemiCheckEntity[] entityobj, SUserInfo sUserInfo)
  16654. {
  16655. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  16656. oracleTrConn.IgnoreCase = false;
  16657. ServiceResultEntity resultEntity = new ServiceResultEntity();
  16658. try
  16659. {
  16660. oracleTrConn.Connect();
  16661. SemiCheckEntity entity = entityobj[0];
  16662. string errMsg = "";
  16663. if (entity.SemiCheckCategory == 1) // 半检登记
  16664. {
  16665. errMsg = AddNormalSemiCheck(oracleTrConn, entity, sUserInfo);
  16666. }
  16667. else if (entity.SemiCheckCategory == 2)// 复检登记
  16668. {
  16669. errMsg = AddReSemiCheck(oracleTrConn, entity, sUserInfo);
  16670. }
  16671. else if (entity.SemiCheckCategory == 3)// 撤销复检
  16672. {
  16673. errMsg = AddCancelSemiCheck(oracleTrConn, entity, sUserInfo);
  16674. }
  16675. // 没有错误 提交事务
  16676. if (string.IsNullOrEmpty(errMsg))
  16677. {
  16678. oracleTrConn.Commit();
  16679. }
  16680. else
  16681. {
  16682. resultEntity.Message = errMsg;
  16683. }
  16684. }
  16685. catch (Exception ex)
  16686. {
  16687. oracleTrConn.Rollback();
  16688. throw ex;
  16689. }
  16690. finally
  16691. {
  16692. // 释放资源
  16693. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  16694. {
  16695. oracleTrConn.Disconnect();
  16696. }
  16697. }
  16698. return resultEntity;
  16699. }
  16700. #endregion
  16701. /// <summary>
  16702. /// 半检数据
  16703. /// </summary>
  16704. /// <param name="oracleTrConn">数据连接对象</param>
  16705. /// <param name="entity">半检实体类</param>
  16706. /// <param name="sUserInfo">用户基本信息</param>
  16707. /// <returns>string</returns>
  16708. /// <remarks>
  16709. /// 王鑫 2016.06.27 新建
  16710. /// </remarks>
  16711. private static string AddNormalSemiCheck(IDBTransaction oracleTrConn,
  16712. SemiCheckEntity entity,
  16713. SUserInfo sUserInfo)
  16714. {
  16715. try
  16716. {
  16717. // 获得账务日期
  16718. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  16719. string errMsg = string.Empty;
  16720. // 本批采集的批次号
  16721. string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  16722. // 条码
  16723. string barcode = entity.BarCode;
  16724. if (string.IsNullOrEmpty(barcode))
  16725. {
  16726. throw new Exception("传入的条码号为空");
  16727. }
  16728. // 半检工号ID
  16729. int workUserID = Convert.ToInt32(entity.SemiCheckUserID);
  16730. // 半检工号编码
  16731. string workUserCode = entity.SemiCheckUserCode;
  16732. // 查询新插入的半检数据ID
  16733. string sql = "select SEQ_PM_SemiCheck_ID.nextval from dual";
  16734. string idStr = "";
  16735. if (entity.SemiCheckEditType == 1) //新增
  16736. {
  16737. idStr = oracleTrConn.GetSqlResultToStr(sql);
  16738. }
  16739. else if (entity.SemiCheckEditType == 2) //编辑返工
  16740. {
  16741. if (entity.SemiCheckType != "0") //正常
  16742. {
  16743. idStr = oracleTrConn.GetSqlResultToStr(sql);
  16744. }
  16745. }
  16746. else if (entity.SemiCheckEditType == 3) //编辑不合格
  16747. {
  16748. if (entity.SemiCheckType != "0") //正常
  16749. {
  16750. idStr = oracleTrConn.GetSqlResultToStr(sql);
  16751. }
  16752. }
  16753. // 保存时再验证,前台已有缺陷不能为空的验证,但还是产生了无责任和缺陷记录的数据,后台保存时增加验证。
  16754. if (!string.IsNullOrEmpty(idStr) && (entity.SemiCheckDefects == null || entity.SemiCheckDefects.Count == 0))
  16755. {
  16756. errMsg = "缺陷责任记录不能为空";
  16757. return errMsg;
  16758. }
  16759. if (entity.SemiCheckEditType == 1) //新增
  16760. {
  16761. #region 校验条码有效性
  16762. errMsg = CheckBarcodeByNew(oracleTrConn, barcode, sUserInfo);
  16763. if (!string.IsNullOrEmpty(errMsg))
  16764. {
  16765. return errMsg;
  16766. }
  16767. #endregion
  16768. #region 添加半检数据
  16769. entity.SemiCheckID = Convert.ToInt32(idStr);
  16770. if (entity.SemiCheckType == "2")
  16771. {
  16772. errMsg = AddSemiCheckDataNoPass(oracleTrConn, entity, sUserInfo);
  16773. // 注浆明细 产品等级
  16774. sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=13,updateuserid=:updateuserid
  16775. where barcode=:barcode";
  16776. OracleParameter[] oracleParameters = new OracleParameter[] {
  16777. new OracleParameter(":accountid", sUserInfo.AccountID),
  16778. new OracleParameter(":barcode",entity.BarCode),
  16779. new OracleParameter(":updateuserid",sUserInfo.UserID),
  16780. };
  16781. oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  16782. }
  16783. else
  16784. {
  16785. errMsg = AddSemiCheckData(oracleTrConn, entity, sUserInfo);
  16786. if (entity.SemiCheckType == "1")
  16787. {
  16788. // 注浆明细 产品等级
  16789. sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=2,updateuserid=:updateuserid
  16790. where barcode=:barcode";
  16791. OracleParameter[] oracleParameters = new OracleParameter[] {
  16792. new OracleParameter(":accountid", sUserInfo.AccountID),
  16793. new OracleParameter(":barcode",entity.BarCode),
  16794. new OracleParameter(":updateuserid",sUserInfo.UserID),
  16795. };
  16796. oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  16797. }
  16798. else
  16799. {
  16800. // 注浆明细 产品等级
  16801. sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=1,updateuserid=:updateuserid
  16802. where barcode=:barcode";
  16803. OracleParameter[] oracleParameters = new OracleParameter[] {
  16804. new OracleParameter(":accountid", sUserInfo.AccountID),
  16805. new OracleParameter(":barcode",entity.BarCode),
  16806. new OracleParameter(":updateuserid",sUserInfo.UserID),
  16807. };
  16808. oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  16809. }
  16810. }
  16811. if (!string.IsNullOrEmpty(errMsg))
  16812. {
  16813. return errMsg;
  16814. }
  16815. #endregion
  16816. #region 条码有缺陷
  16817. #region 是次品 添加废弃产品
  16818. string ResponProcedureidStr = "";
  16819. if (entity.SemiCheckType == "2") //新建时不合格,直接报损
  16820. {
  16821. #region 添加废弃产品
  16822. ScrapProductEntity scrapProduct = new ScrapProductEntity();
  16823. #region 属性赋值
  16824. scrapProduct.BarCode = entity.BarCode;
  16825. scrapProduct.ScrapType = Constant.ScrapType.Substandard.GetHashCode();
  16826. // 不能责任人吗? TODO 单独责任时,没有插入废品数据。
  16827. //scrapProduct.ResponType = Constant.ScrapResponType.Procedure.GetHashCode();
  16828. scrapProduct.ResponType = (int)Constant.ScrapResponType.Person;
  16829. scrapProduct.ScrapDate = accountDate;// sysdate
  16830. scrapProduct.Rreason = Constant.SCRAPTYPE_NOPASS;
  16831. scrapProduct.AuditStatus = Constant.AuditStatus.Agree.GetHashCode();
  16832. scrapProduct.Auditor = sUserInfo.UserID;
  16833. scrapProduct.AuditlDate = accountDate;// sysdate
  16834. scrapProduct.AccountDate = accountDate;
  16835. sql = "select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=13 and accountid=" + sUserInfo.AccountID;
  16836. DataSet ds = oracleTrConn.GetSqlResultToDs(sql);
  16837. if (ds != null && ds.Tables[0].Rows.Count > 0)
  16838. {
  16839. scrapProduct.GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]);
  16840. }
  16841. scrapProduct.GoodsLevelTypeID = 13;
  16842. //scrapProduct.IsPublicBody = IsPubilcByBarCode(oracleTrConn, entity.BarCode);
  16843. // 查询新插入的废弃ID
  16844. string ResponProceduresql = "select SEQ_PM_ScrapProduct_ID.nextval from dual";
  16845. ResponProcedureidStr = oracleTrConn.GetSqlResultToStr(ResponProceduresql);
  16846. scrapProduct.ScrapProductID = Convert.ToInt32(ResponProcedureidStr);
  16847. scrapProduct.ScrapType = 2;
  16848. #endregion
  16849. // 保存报废
  16850. errMsg = AddScrapProduct(oracleTrConn, scrapProduct, sUserInfo);
  16851. // 保存失败
  16852. if (!string.IsNullOrEmpty(errMsg))
  16853. {
  16854. return errMsg;
  16855. }
  16856. #endregion
  16857. }
  16858. #endregion
  16859. // 存在缺陷 插入缺陷表
  16860. if (entity.SemiCheckDefects != null)
  16861. {
  16862. int row = 0;
  16863. foreach (SemiCheckDefectEntity semiCheckDefect in entity.SemiCheckDefects)
  16864. {
  16865. if (row == 0)
  16866. {
  16867. #region 保存缺陷
  16868. semiCheckDefect.SemiCheckID = Convert.ToInt32(idStr);
  16869. semiCheckDefect.ScrapResponFlag
  16870. = string.IsNullOrEmpty(semiCheckDefect.ScrapResponFlag) ? "0" : semiCheckDefect.ScrapResponFlag;
  16871. // 保存缺陷
  16872. errMsg = AddSemiCheckDefect(oracleTrConn, semiCheckDefect, sUserInfo);
  16873. if (!string.IsNullOrEmpty(errMsg))
  16874. {
  16875. return errMsg;
  16876. }
  16877. #endregion
  16878. #region 是不合格 添加废弃责任工序
  16879. if (entity.SemiCheckType == "2")
  16880. {
  16881. //if (semiCheckDefect.DefectProcedureID != null)
  16882. {
  16883. #region 添加责任工序
  16884. ResponProcedureEntity responProce = new ResponProcedureEntity();
  16885. // 新建-不合格 获取生产线及生产数据ID
  16886. sql = "select ProductionLineID,ProductionLineCode,ProductionLineName,ProductionDataID from TP_PM_InProduction where barcode=:barcode";
  16887. OracleParameter[] oracleParameters = new OracleParameter[] {
  16888. new OracleParameter(":barcode",entity.BarCode),
  16889. };
  16890. DataSet ds = oracleTrConn.GetSqlResultToDs(sql, oracleParameters);
  16891. if (ds != null && ds.Tables[0].Rows.Count > 0)
  16892. {
  16893. responProce.ProductionDataID = Convert.ToInt32(ds.Tables[0].Rows[0]["ProductionDataID"]);
  16894. responProce.ProductionLineID = Convert.ToInt32(ds.Tables[0].Rows[0]["ProductionLineID"]);
  16895. responProce.ProductionLineCode = ds.Tables[0].Rows[0]["ProductionLineCode"].ToString();
  16896. responProce.ProductionLineName = ds.Tables[0].Rows[0]["ProductionLineName"].ToString();
  16897. }
  16898. //新建-不合格 获取生产线及生产数据ID end
  16899. #region 属性赋值
  16900. responProce.BarCode = entity.BarCode;
  16901. responProce.ProcedureID = semiCheckDefect.DefectProcedureID;
  16902. responProce.ProcedureCode = semiCheckDefect.DefectProcedureCode;
  16903. responProce.ProcedureName = semiCheckDefect.DefectProcedureName;
  16904. responProce.UserID = semiCheckDefect.DefectUserID;
  16905. responProce.UserCode = semiCheckDefect.DefectUserCode;
  16906. responProce.UserName = semiCheckDefect.DefectUserName;
  16907. responProce.Remarks = semiCheckDefect.Remarks;
  16908. responProce.ScrapProductID = Convert.ToInt32(ResponProcedureidStr);
  16909. #endregion
  16910. // 保存责任工序
  16911. errMsg = AddSemiCheckResponProcedure(oracleTrConn, responProce, semiCheckDefect, sUserInfo);
  16912. // 保存失败
  16913. if (!string.IsNullOrEmpty(errMsg))
  16914. {
  16915. return errMsg;
  16916. }
  16917. #endregion
  16918. }
  16919. }
  16920. #endregion
  16921. }
  16922. row++;
  16923. }
  16924. }
  16925. #endregion
  16926. #region 条码是不合格 删除在产产品数据
  16927. if (entity.SemiCheckType == "2") //新建时不合格
  16928. {
  16929. // 1.在产表产品设置产品等级【13不合格】,半检登记ID=记录的半检登记ID。
  16930. sql = @"update TP_PM_InProduction set GoodsLevelID=
  16931. (
  16932. select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=13 and accountid=:accountid
  16933. )
  16934. ,GoodsLevelTypeID=13,SemiCheckID=:SemiCheckID,updateuserid=:updateuserid
  16935. where barcode=:barcode";
  16936. OracleParameter[] oracleParameters = new OracleParameter[] {
  16937. //new OracleParameter(":GoodsLevelID",entity.GoodsLevelID),
  16938. //new OracleParameter(":GoodsLevelTypeID",entity.GoodsLevelTypeID),
  16939. new OracleParameter(":accountid",sUserInfo.AccountID),
  16940. new OracleParameter(":SemiCheckID",Convert.ToInt32(idStr)),
  16941. new OracleParameter(":barcode",entity.BarCode),
  16942. // new OracleParameter(":createuserid",sUserInfo.UserID),
  16943. new OracleParameter(":updateuserid",sUserInfo.UserID),
  16944. };
  16945. int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  16946. // 2.将在产数据保存到在产回收站表中(产品等级【13不合格】,半检登记ID=记录的半检登记ID)。
  16947. string sqlInsert = @"insert into TP_PM_InProductionTrash
  16948. (
  16949. BarCode,
  16950. ProductionLineID,
  16951. ProductionLineCode,
  16952. ProductionLineName,
  16953. ProcedureModel,
  16954. ModelType,
  16955. DefectFlag,
  16956. ReworkProcedureID,
  16957. IsPublicBody,
  16958. IsReFire,
  16959. GoodsLevelID,
  16960. GoodsLevelTypeID,
  16961. GoodsID,
  16962. GoodsCode,
  16963. GoodsName,
  16964. UserID,
  16965. GroutingDailyID,
  16966. GroutingDailyDetailID,
  16967. GroutingDate,
  16968. GroutingLineID,
  16969. GroutingLineCode,
  16970. GroutingLineName,
  16971. GMouldTypeID,
  16972. CanManyTimes,
  16973. GroutingLineDetailID,
  16974. GroutingMouldCode,
  16975. MouldCode,
  16976. GroutingUserID,
  16977. GroutingUserCode,
  16978. GroutingNum,
  16979. Remarks,
  16980. KilnID,
  16981. KilnCode,
  16982. KilnName,
  16983. KilnCarID,
  16984. KilnCarCode,
  16985. KilnCarName,
  16986. KilnCarBatchNo,
  16987. KilnCarPosition,
  16988. AccountID,
  16989. ValueFlag,
  16990. CreateUserID,
  16991. UpdateUserID,
  16992. SpecialRepairflag,
  16993. FlowProcedureID,
  16994. FlowProcedureTime,
  16995. ProcedureID,
  16996. ProcedureTime,
  16997. ProductionDataID,
  16998. logoid,
  16999. ISREWORKFLAG, SEMICHECKID
  17000. )
  17001. select
  17002. BarCode,
  17003. ProductionLineID,
  17004. ProductionLineCode,
  17005. ProductionLineName,
  17006. ProcedureModel,
  17007. ModelType,
  17008. DefectFlag,
  17009. ReworkProcedureID,
  17010. IsPublicBody,
  17011. IsReFire,
  17012. -- GoodsLevelID,
  17013. --GoodsLevelTypeID,
  17014. (
  17015. select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=13 and accountid=:accountid
  17016. )
  17017. ,13,
  17018. GoodsID,
  17019. GoodsCode,
  17020. GoodsName,
  17021. UserID,
  17022. GroutingDailyID,
  17023. GroutingDailyDetailID,
  17024. GroutingDate,
  17025. GroutingLineID,
  17026. GroutingLineCode,
  17027. GroutingLineName,
  17028. GMouldTypeID,
  17029. CanManyTimes,
  17030. GroutingLineDetailID,
  17031. GroutingMouldCode,
  17032. MouldCode,
  17033. GroutingUserID,
  17034. GroutingUserCode,
  17035. GroutingNum,
  17036. Remarks,
  17037. KilnID,
  17038. KilnCode,
  17039. KilnName,
  17040. KilnCarID,
  17041. KilnCarCode,
  17042. KilnCarName,
  17043. KilnCarBatchNo,
  17044. KilnCarPosition,
  17045. AccountID,
  17046. ValueFlag,
  17047. :CreateUserID,
  17048. :UpdateUserID,
  17049. SpecialRepairflag,
  17050. FlowProcedureID,
  17051. FlowProcedureTime,
  17052. FlowProcedureID,
  17053. ProcedureTime,
  17054. ProductionDataID,
  17055. logoid,
  17056. ISREWORKFLAG, SEMICHECKID
  17057. from TP_PM_InProduction
  17058. where barcode=:barcode
  17059. ";
  17060. oracleParameters = new OracleParameter[] {
  17061. new OracleParameter(":barcode",entity.BarCode),
  17062. new OracleParameter(":CreateUserID",sUserInfo.UserID),
  17063. new OracleParameter(":UpdateUserID",sUserInfo.UserID),
  17064. new OracleParameter(":accountid",sUserInfo.AccountID),
  17065. };
  17066. result += oracleTrConn.ExecuteNonQuery(sqlInsert, oracleParameters);
  17067. // 删除在产数据
  17068. sql = "delete tp_pm_inproduction where barcode = :barcode";
  17069. oracleParameters = new OracleParameter[] {
  17070. new OracleParameter(":barcode",entity.BarCode),
  17071. };
  17072. result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17073. }
  17074. else if (entity.SemiCheckType == "1") //返工
  17075. {
  17076. sql = @"update TP_PM_InProduction set GoodsLevelTypeID=2,IsReworkFlag=1,SemiCheckID=:SemiCheckID,updateuserid=:updateuserid
  17077. where barcode=:barcode";
  17078. OracleParameter[] oracleParameters = new OracleParameter[] {
  17079. new OracleParameter(":SemiCheckID",Convert.ToInt32(idStr)),
  17080. new OracleParameter(":barcode",entity.BarCode),
  17081. new OracleParameter(":updateuserid",sUserInfo.UserID),
  17082. };
  17083. int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17084. }
  17085. #endregion
  17086. }
  17087. else if (entity.SemiCheckEditType == 2) //编辑返工
  17088. {
  17089. #region 校验条码有效性
  17090. errMsg = CheckBarcodeByEditRework(oracleTrConn, barcode, sUserInfo);
  17091. if (!string.IsNullOrEmpty(errMsg))
  17092. {
  17093. return errMsg;
  17094. }
  17095. #endregion
  17096. #region 删除当前半检数据
  17097. errMsg = SetSemiCheckDataValueFlag(oracleTrConn, entity, sUserInfo);
  17098. if (!string.IsNullOrEmpty(errMsg))
  17099. {
  17100. return errMsg;
  17101. }
  17102. #endregion
  17103. if (entity.SemiCheckType != "0") //正常
  17104. {
  17105. #region 添加半检数据
  17106. entity.SemiCheckID = Convert.ToInt32(idStr);
  17107. errMsg = AddSemiCheckData(oracleTrConn, entity, sUserInfo);
  17108. if (!string.IsNullOrEmpty(errMsg))
  17109. {
  17110. return errMsg;
  17111. }
  17112. #endregion
  17113. }
  17114. #region 条码有缺陷
  17115. #region 是次品 添加废弃产品
  17116. string ResponProcedureidStr = "";
  17117. if (entity.SemiCheckType == "2") //新建时不合格,直接报损
  17118. {
  17119. #region 添加废弃产品
  17120. ScrapProductEntity scrapProduct = new ScrapProductEntity();
  17121. #region 属性赋值
  17122. scrapProduct.BarCode = entity.BarCode;
  17123. scrapProduct.ScrapType = Constant.ScrapType.Substandard.GetHashCode();
  17124. scrapProduct.ResponType = Constant.ScrapResponType.Procedure.GetHashCode();
  17125. scrapProduct.ScrapDate = accountDate;
  17126. scrapProduct.Rreason = Constant.SCRAPTYPE_NOPASS;
  17127. scrapProduct.AuditStatus = Constant.AuditStatus.Agree.GetHashCode();
  17128. scrapProduct.Auditor = sUserInfo.UserID;
  17129. scrapProduct.AuditlDate = accountDate;
  17130. scrapProduct.AccountDate = accountDate;
  17131. //scrapProduct.GoodsLevelID = entity.GoodsLevelID;
  17132. //scrapProduct.GoodsLevelTypeID = entity.GoodsLevelTypeID;
  17133. sql = "select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=13 and accountid=" + sUserInfo.AccountID;
  17134. DataSet ds = oracleTrConn.GetSqlResultToDs(sql);
  17135. if (ds != null && ds.Tables[0].Rows.Count > 0)
  17136. {
  17137. scrapProduct.GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]);
  17138. }
  17139. scrapProduct.GoodsLevelTypeID = 13;
  17140. scrapProduct.IsPublicBody = IsPubilcByBarCode(oracleTrConn, entity.BarCode);
  17141. // 查询新插入的废弃ID
  17142. string ResponProceduresql = "select SEQ_PM_ScrapProduct_ID.nextval from dual";
  17143. ResponProcedureidStr = oracleTrConn.GetSqlResultToStr(ResponProceduresql);
  17144. scrapProduct.ScrapProductID = Convert.ToInt32(ResponProcedureidStr);
  17145. scrapProduct.ScrapType = 2;
  17146. #endregion
  17147. // 保存报废
  17148. errMsg = AddScrapProduct(oracleTrConn, scrapProduct, sUserInfo);
  17149. // 保存失败
  17150. if (!string.IsNullOrEmpty(errMsg))
  17151. {
  17152. return errMsg;
  17153. }
  17154. #endregion
  17155. }
  17156. #endregion
  17157. // 存在缺陷 插入缺陷表
  17158. if (entity.SemiCheckDefects != null)
  17159. {
  17160. foreach (SemiCheckDefectEntity semiCheckDefect in entity.SemiCheckDefects)
  17161. {
  17162. #region 保存缺陷
  17163. semiCheckDefect.SemiCheckID = Convert.ToInt32(idStr);
  17164. semiCheckDefect.ScrapResponFlag
  17165. = string.IsNullOrEmpty(semiCheckDefect.ScrapResponFlag) ? "0" : semiCheckDefect.ScrapResponFlag;
  17166. // 保存缺陷
  17167. errMsg = AddSemiCheckDefect(oracleTrConn, semiCheckDefect, sUserInfo);
  17168. if (!string.IsNullOrEmpty(errMsg))
  17169. {
  17170. return errMsg;
  17171. }
  17172. #endregion
  17173. #region 是不合格 添加废弃责任工序
  17174. if (entity.SemiCheckType == "2")
  17175. {
  17176. //if (semiCheckDefect.DefectProcedureID != null)
  17177. {
  17178. #region 添加责任工序
  17179. ResponProcedureEntity responProce = new ResponProcedureEntity();
  17180. // 获取生产线及生产数据ID
  17181. sql = "select ProductionLineID,ProductionLineCode,ProductionLineName,ProductionDataID from TP_PM_InProduction where barcode=:barcode";
  17182. OracleParameter[] oracleParameters = new OracleParameter[] {
  17183. new OracleParameter(":barcode",entity.BarCode),
  17184. };
  17185. DataSet ds = oracleTrConn.GetSqlResultToDs(sql, oracleParameters);
  17186. if (ds != null && ds.Tables[0].Rows.Count > 0)
  17187. {
  17188. responProce.ProductionDataID = Convert.ToInt32(ds.Tables[0].Rows[0]["ProductionDataID"]);
  17189. responProce.ProductionLineID = Convert.ToInt32(ds.Tables[0].Rows[0]["ProductionLineID"]);
  17190. responProce.ProductionLineCode = ds.Tables[0].Rows[0]["ProductionLineCode"].ToString();
  17191. responProce.ProductionLineName = ds.Tables[0].Rows[0]["ProductionLineName"].ToString();
  17192. }
  17193. //获取生产线及生产数据ID end
  17194. #region 属性赋值
  17195. responProce.BarCode = entity.BarCode;
  17196. responProce.ProcedureID = semiCheckDefect.DefectProcedureID;
  17197. responProce.ProcedureCode = semiCheckDefect.DefectProcedureCode;
  17198. responProce.ProcedureName = semiCheckDefect.DefectProcedureName;
  17199. responProce.UserID = semiCheckDefect.DefectUserID;
  17200. responProce.UserCode = semiCheckDefect.DefectUserCode;
  17201. responProce.UserName = semiCheckDefect.DefectUserName;
  17202. responProce.Remarks = semiCheckDefect.Remarks;
  17203. responProce.ScrapProductID = Convert.ToInt32(ResponProcedureidStr);
  17204. #endregion
  17205. // 保存责任工序
  17206. errMsg = AddSemiCheckResponProcedure(oracleTrConn, responProce, semiCheckDefect, sUserInfo);
  17207. // 保存失败
  17208. if (!string.IsNullOrEmpty(errMsg))
  17209. {
  17210. return errMsg;
  17211. }
  17212. #endregion
  17213. }
  17214. }
  17215. #endregion
  17216. }
  17217. }
  17218. #endregion
  17219. #region 条码是不合格 删除在产产品数据
  17220. if (entity.SemiCheckType == "2") //编辑时不合格
  17221. {
  17222. // 1.在产表产品设置产品等级【13不合格】,半检登记ID=记录的半检登记ID。
  17223. sql = @"update TP_PM_InProduction set GoodsLevelID= (
  17224. select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=13 and accountid=:accountid
  17225. ),GoodsLevelTypeID=13,SemiCheckID=:SemiCheckID,IsReworkFlag=0,
  17226. updateuserid=:updateuserid
  17227. where barcode=:barcode";
  17228. OracleParameter[] oracleParameters = new OracleParameter[] {
  17229. //new OracleParameter(":GoodsLevelID",entity.GoodsLevelID),
  17230. //new OracleParameter(":GoodsLevelTypeID",entity.GoodsLevelTypeID),
  17231. new OracleParameter(":SemiCheckID",Convert.ToInt32(idStr)),
  17232. new OracleParameter(":barcode",entity.BarCode),
  17233. //new OracleParameter(":createuserid",sUserInfo.UserID),
  17234. new OracleParameter(":updateuserid",sUserInfo.UserID),
  17235. new OracleParameter(":accountid",sUserInfo.AccountID),
  17236. };
  17237. int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17238. // 注浆明细 产品等级
  17239. sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=13,updateuserid=:updateuserid
  17240. where barcode=:barcode";
  17241. oracleParameters = new OracleParameter[] {
  17242. new OracleParameter(":accountid", sUserInfo.AccountID),
  17243. new OracleParameter(":barcode",entity.BarCode),
  17244. new OracleParameter(":updateuserid",sUserInfo.UserID),
  17245. };
  17246. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17247. // 2.将在产数据保存到在产回收站表中(产品等级【13不合格】,半检登记ID=记录的半检登记ID)。
  17248. string sqlInsert = @"insert into TP_PM_InProductionTrash
  17249. (
  17250. BarCode,
  17251. ProductionLineID,
  17252. ProductionLineCode,
  17253. ProductionLineName,
  17254. ProcedureModel,
  17255. ModelType,
  17256. DefectFlag,
  17257. ReworkProcedureID,
  17258. IsPublicBody,
  17259. IsReFire,
  17260. GoodsLevelID,
  17261. GoodsLevelTypeID,
  17262. GoodsID,
  17263. GoodsCode,
  17264. GoodsName,
  17265. UserID,
  17266. GroutingDailyID,
  17267. GroutingDailyDetailID,
  17268. GroutingDate,
  17269. GroutingLineID,
  17270. GroutingLineCode,
  17271. GroutingLineName,
  17272. GMouldTypeID,
  17273. CanManyTimes,
  17274. GroutingLineDetailID,
  17275. GroutingMouldCode,
  17276. MouldCode,
  17277. GroutingUserID,
  17278. GroutingUserCode,
  17279. GroutingNum,
  17280. Remarks,
  17281. KilnID,
  17282. KilnCode,
  17283. KilnName,
  17284. KilnCarID,
  17285. KilnCarCode,
  17286. KilnCarName,
  17287. KilnCarBatchNo,
  17288. KilnCarPosition,
  17289. AccountID,
  17290. ValueFlag,
  17291. CreateUserID,
  17292. UpdateUserID,
  17293. SpecialRepairflag,
  17294. FlowProcedureID,
  17295. FlowProcedureTime,
  17296. ProcedureID,
  17297. ProcedureTime,
  17298. ProductionDataID,
  17299. logoid, SEMICHECKID
  17300. )
  17301. select
  17302. BarCode,
  17303. ProductionLineID,
  17304. ProductionLineCode,
  17305. ProductionLineName,
  17306. ProcedureModel,
  17307. ModelType,
  17308. DefectFlag,
  17309. ReworkProcedureID,
  17310. IsPublicBody,
  17311. IsReFire,
  17312. -- GoodsLevelID,
  17313. --GoodsLevelTypeID,
  17314. (
  17315. select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=13 and accountid=:accountid
  17316. )
  17317. ,13,
  17318. GoodsID,
  17319. GoodsCode,
  17320. GoodsName,
  17321. UserID,
  17322. GroutingDailyID,
  17323. GroutingDailyDetailID,
  17324. GroutingDate,
  17325. GroutingLineID,
  17326. GroutingLineCode,
  17327. GroutingLineName,
  17328. GMouldTypeID,
  17329. CanManyTimes,
  17330. GroutingLineDetailID,
  17331. GroutingMouldCode,
  17332. MouldCode,
  17333. GroutingUserID,
  17334. GroutingUserCode,
  17335. GroutingNum,
  17336. Remarks,
  17337. KilnID,
  17338. KilnCode,
  17339. KilnName,
  17340. KilnCarID,
  17341. KilnCarCode,
  17342. KilnCarName,
  17343. KilnCarBatchNo,
  17344. KilnCarPosition,
  17345. AccountID,
  17346. ValueFlag,
  17347. :CreateUserID,
  17348. :UpdateUserID,
  17349. SpecialRepairflag,
  17350. FlowProcedureID,
  17351. FlowProcedureTime,
  17352. FlowProcedureID,
  17353. ProcedureTime,
  17354. ProductionDataID,
  17355. logoid,
  17356. :SemiCheckID
  17357. from TP_PM_InProduction
  17358. where barcode=:barcode
  17359. ";
  17360. oracleParameters = new OracleParameter[] {
  17361. new OracleParameter(":barcode",entity.BarCode),
  17362. new OracleParameter(":CreateUserID",sUserInfo.UserID),
  17363. new OracleParameter(":UpdateUserID",sUserInfo.UserID),
  17364. new OracleParameter(":SemiCheckID",entity.SemiCheckID),
  17365. new OracleParameter(":accountid",sUserInfo.AccountID),
  17366. };
  17367. result += oracleTrConn.ExecuteNonQuery(sqlInsert, oracleParameters);
  17368. // 删除在产数据
  17369. sql = "delete tp_pm_inproduction where barcode = :barcode";
  17370. oracleParameters = new OracleParameter[] {
  17371. new OracleParameter(":barcode",entity.BarCode),
  17372. };
  17373. result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17374. }
  17375. else if (entity.SemiCheckType == "1") //返工
  17376. {
  17377. sql = @"update TP_PM_InProduction set GoodsLevelTypeID=2,IsReworkFlag=1,SemiCheckID=:SemiCheckID,updateuserid=:updateuserid
  17378. where barcode=:barcode";
  17379. OracleParameter[] oracleParameters = new OracleParameter[] {
  17380. new OracleParameter(":SemiCheckID",Convert.ToInt32(idStr)),
  17381. new OracleParameter(":barcode",entity.BarCode),
  17382. new OracleParameter(":updateuserid",sUserInfo.UserID),
  17383. };
  17384. int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17385. // 注浆明细 产品等级
  17386. sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=2,updateuserid=:updateuserid
  17387. where barcode=:barcode";
  17388. oracleParameters = new OracleParameter[] {
  17389. new OracleParameter(":accountid", sUserInfo.AccountID),
  17390. new OracleParameter(":barcode",entity.BarCode),
  17391. new OracleParameter(":updateuserid",sUserInfo.UserID),
  17392. };
  17393. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17394. }
  17395. else if (entity.SemiCheckType == "0") //正常
  17396. {
  17397. sql = @"update TP_PM_InProduction set GoodsLevelTypeID=1,IsReworkFlag=0,SemiCheckID=null,updateuserid=:updateuserid
  17398. where barcode=:barcode";
  17399. OracleParameter[] oracleParameters = new OracleParameter[] {
  17400. new OracleParameter(":barcode",entity.BarCode),
  17401. new OracleParameter(":updateuserid",sUserInfo.UserID),
  17402. };
  17403. int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17404. // 注浆明细 产品等级
  17405. sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=1,updateuserid=:updateuserid
  17406. where barcode=:barcode";
  17407. oracleParameters = new OracleParameter[] {
  17408. new OracleParameter(":accountid", sUserInfo.AccountID),
  17409. new OracleParameter(":barcode",entity.BarCode),
  17410. new OracleParameter(":updateuserid",sUserInfo.UserID),
  17411. };
  17412. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17413. }
  17414. #endregion
  17415. }
  17416. else if (entity.SemiCheckEditType == 3) //编辑不合格
  17417. {
  17418. #region 校验条码有效性
  17419. errMsg = CheckBarcodeByEditNoPass(oracleTrConn, barcode, sUserInfo);
  17420. if (!string.IsNullOrEmpty(errMsg))
  17421. {
  17422. return errMsg;
  17423. }
  17424. #endregion
  17425. #region 删除当前半检数据
  17426. errMsg = SetSemiCheckDataValueFlag(oracleTrConn, entity, sUserInfo);
  17427. if (!string.IsNullOrEmpty(errMsg))
  17428. {
  17429. return errMsg;
  17430. }
  17431. #endregion
  17432. if (entity.SemiCheckType != "0") //正常
  17433. {
  17434. #region 添加半检数据
  17435. entity.SemiCheckID = Convert.ToInt32(idStr);
  17436. errMsg = AddSemiCheckDataTrash(oracleTrConn, entity, sUserInfo);
  17437. if (!string.IsNullOrEmpty(errMsg))
  17438. {
  17439. return errMsg;
  17440. }
  17441. #endregion
  17442. }
  17443. #region 条码是不合格 删除在产产品数据
  17444. OracleParameter[] spParameters = null;
  17445. int spResult = 0;
  17446. if (entity.SemiCheckType == "2") //编辑时不合格
  17447. {
  17448. #region 1.废弃产品表中对应的总单数据和明细数据valueflag='0'。
  17449. string sqlString = "select max(sp.scrapproductid) scrapproductid\n" +
  17450. " from TP_PM_ScrapProduct sp\n" +
  17451. " where sp.barcode = :barcode\n" +
  17452. " and sp.auditstatus = 1\n" +
  17453. " and sp.valueflag = '1'\n" +
  17454. " and sp.scraptype = '2'";
  17455. spParameters = new OracleParameter[] {
  17456. new OracleParameter(":barcode",entity.BarCode),
  17457. };
  17458. string scrapproductid = oracleTrConn.GetSqlResultToStr(sqlString, spParameters);
  17459. sqlString = @"update TP_PM_ScrapProduct set valueflag='0', updateuserid=:updateuserid, backouttime=sysdate where scrapproductid=:scrapproductid";
  17460. spParameters = new OracleParameter[] {
  17461. new OracleParameter(":updateuserid",sUserInfo.UserID),
  17462. new OracleParameter(":scrapproductid",scrapproductid),
  17463. };
  17464. spResult = oracleTrConn.ExecuteNonQuery(sqlString, spParameters);
  17465. sqlString = @"update TP_PM_ResponProcedure set valueflag='0', updateuserid=:updateuserid where scrapproductid=:scrapproductid";
  17466. //oracleParameters = new OracleParameter[] {
  17467. // new OracleParameter(":barcode",entity.BarCode),
  17468. //};
  17469. spResult += oracleTrConn.ExecuteNonQuery(sqlString, spParameters);
  17470. //sql = @"update TP_PM_ScrapProduct set valueflag='0' where barcode=:barcode";
  17471. //OracleParameter[] oracleParameters = new OracleParameter[] {
  17472. // new OracleParameter(":barcode",entity.BarCode),
  17473. //};
  17474. //int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17475. //sql = @"update TP_PM_ResponProcedure set valueflag='0' where barcode=:barcode";
  17476. //oracleParameters = new OracleParameter[] {
  17477. // new OracleParameter(":barcode",entity.BarCode),
  17478. //};
  17479. //result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17480. ////sql = @"update TP_PM_ScrapResponsible set valueflag='0' where barcode=:barcode";
  17481. ////oracleParameters = new OracleParameter[] {
  17482. //// new OracleParameter(":barcode",entity.BarCode),
  17483. ////};
  17484. ////result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17485. #endregion
  17486. #region 2.修改在产回收站表中的数据(产品等级【13不合格】,半检登记ID=新记录的半检登记ID)。
  17487. sql = @"update TP_PM_InProductionTrash set GoodsLevelID= (
  17488. select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=13 and accountid=:accountid
  17489. ),GoodsLevelTypeID=13,SemiCheckID=:SemiCheckID where barcode=:barcode";
  17490. OracleParameter[] oracleParameters = new OracleParameter[] {
  17491. new OracleParameter(":barcode",entity.BarCode),
  17492. new OracleParameter(":accountid",sUserInfo.AccountID),
  17493. //new OracleParameter(":GoodsLevelTypeID",entity.GoodsLevelTypeID),
  17494. new OracleParameter(":SemiCheckID",entity.SemiCheckID),
  17495. };
  17496. int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17497. // 注浆明细 产品等级
  17498. sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=13,updateuserid=:updateuserid
  17499. where barcode=:barcode";
  17500. oracleParameters = new OracleParameter[] {
  17501. new OracleParameter(":accountid", sUserInfo.AccountID),
  17502. new OracleParameter(":barcode",entity.BarCode),
  17503. new OracleParameter(":updateuserid",sUserInfo.UserID),
  17504. };
  17505. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17506. #endregion
  17507. #region 条码有缺陷
  17508. #region 是次品 添加废弃产品
  17509. string ResponProcedureidStr = "";
  17510. if (entity.SemiCheckType == "2") //新建时不合格,直接报损
  17511. {
  17512. #region 添加废弃产品
  17513. ScrapProductEntity scrapProduct = new ScrapProductEntity();
  17514. #region 属性赋值
  17515. scrapProduct.BarCode = entity.BarCode;
  17516. scrapProduct.ScrapType = Constant.ScrapType.Substandard.GetHashCode();
  17517. scrapProduct.ResponType = Constant.ScrapResponType.Procedure.GetHashCode();
  17518. scrapProduct.ScrapDate = accountDate;
  17519. scrapProduct.Rreason = Constant.SCRAPTYPE_NOPASS;
  17520. scrapProduct.AuditStatus = Constant.AuditStatus.Agree.GetHashCode();
  17521. scrapProduct.Auditor = sUserInfo.UserID;
  17522. scrapProduct.AuditlDate = accountDate;
  17523. scrapProduct.AccountDate = accountDate;
  17524. sql = "select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=13 and accountid=" + sUserInfo.AccountID;
  17525. DataSet ds = oracleTrConn.GetSqlResultToDs(sql);
  17526. if (ds != null && ds.Tables[0].Rows.Count > 0)
  17527. {
  17528. scrapProduct.GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]);
  17529. }
  17530. scrapProduct.GoodsLevelTypeID = 13;
  17531. //scrapProduct.GoodsLevelID = entity.GoodsLevelID;
  17532. //scrapProduct.GoodsLevelTypeID = entity.GoodsLevelTypeID;
  17533. scrapProduct.IsPublicBody = IsPubilcByBarCode(oracleTrConn, entity.BarCode);
  17534. // 查询新插入的废弃ID
  17535. string ResponProceduresql = "select SEQ_PM_ScrapProduct_ID.nextval from dual";
  17536. ResponProcedureidStr = oracleTrConn.GetSqlResultToStr(ResponProceduresql);
  17537. scrapProduct.ScrapProductID = Convert.ToInt32(ResponProcedureidStr);
  17538. scrapProduct.ScrapType = 2;
  17539. #endregion
  17540. // 保存报废
  17541. errMsg = AddScrapProduct(oracleTrConn, scrapProduct, sUserInfo);
  17542. // 保存失败
  17543. if (!string.IsNullOrEmpty(errMsg))
  17544. {
  17545. return errMsg;
  17546. }
  17547. #endregion
  17548. }
  17549. #endregion
  17550. // 存在缺陷 插入缺陷表
  17551. if (entity.SemiCheckDefects != null)
  17552. {
  17553. foreach (SemiCheckDefectEntity semiCheckDefect in entity.SemiCheckDefects)
  17554. {
  17555. #region 保存缺陷
  17556. semiCheckDefect.SemiCheckID = Convert.ToInt32(idStr);
  17557. semiCheckDefect.ScrapResponFlag
  17558. = string.IsNullOrEmpty(semiCheckDefect.ScrapResponFlag) ? "0" : semiCheckDefect.ScrapResponFlag;
  17559. // 保存缺陷
  17560. errMsg = AddSemiCheckDefect(oracleTrConn, semiCheckDefect, sUserInfo);
  17561. if (!string.IsNullOrEmpty(errMsg))
  17562. {
  17563. return errMsg;
  17564. }
  17565. #endregion
  17566. #region 是不合格 添加废弃责任工序
  17567. if (entity.SemiCheckType == "2")
  17568. {
  17569. //if (semiCheckDefect.DefectProcedureID != null)
  17570. {
  17571. #region 添加责任工序
  17572. ResponProcedureEntity responProce = new ResponProcedureEntity();
  17573. // 取生产线及生产数据ID
  17574. sql = "select ProductionLineID,ProductionLineCode,ProductionLineName,ProductionDataID from TP_PM_InProductionTrash where barcode=:barcode";
  17575. oracleParameters = new OracleParameter[] {
  17576. new OracleParameter(":barcode",entity.BarCode),
  17577. };
  17578. DataSet ds = oracleTrConn.GetSqlResultToDs(sql, oracleParameters);
  17579. if (ds != null && ds.Tables[0].Rows.Count > 0)
  17580. {
  17581. responProce.ProductionDataID = Convert.ToInt32(ds.Tables[0].Rows[0]["ProductionDataID"]);
  17582. responProce.ProductionLineID = Convert.ToInt32(ds.Tables[0].Rows[0]["ProductionLineID"]);
  17583. responProce.ProductionLineCode = ds.Tables[0].Rows[0]["ProductionLineCode"].ToString();
  17584. responProce.ProductionLineName = ds.Tables[0].Rows[0]["ProductionLineName"].ToString();
  17585. }
  17586. //获取生产线及生产数据ID end
  17587. #region 属性赋值
  17588. responProce.BarCode = entity.BarCode;
  17589. //responProce.ProductionDataID = semiCheckDefect.ProductionDataID;
  17590. //responProce.ProductionLineID = semiCheckDefect.ProductionLineID;
  17591. //responProce.ProductionLineCode = semiCheckDefect.ProductionLineCode;
  17592. //responProce.ProductionLineName = semiCheckDefect.ProductionLineName;
  17593. responProce.ProcedureID = semiCheckDefect.DefectProcedureID;
  17594. responProce.ProcedureCode = semiCheckDefect.DefectProcedureCode;
  17595. responProce.ProcedureName = semiCheckDefect.DefectProcedureName;
  17596. responProce.UserID = semiCheckDefect.DefectUserID;
  17597. responProce.UserCode = semiCheckDefect.DefectUserCode;
  17598. responProce.UserName = semiCheckDefect.DefectUserName;
  17599. responProce.Remarks = semiCheckDefect.Remarks;
  17600. responProce.ScrapProductID = Convert.ToInt32(ResponProcedureidStr);
  17601. #endregion
  17602. // 保存责任工序
  17603. errMsg = AddSemiCheckResponProcedure(oracleTrConn, responProce, semiCheckDefect, sUserInfo);
  17604. // 保存失败
  17605. if (!string.IsNullOrEmpty(errMsg))
  17606. {
  17607. return errMsg;
  17608. }
  17609. #endregion
  17610. }
  17611. }
  17612. #endregion
  17613. }
  17614. }
  17615. #endregion
  17616. }
  17617. else if (entity.SemiCheckType == "1") //返工
  17618. {
  17619. #region 1.从在产回收站中把数据恢复到在产表中。
  17620. string sqlInsert = @"insert into TP_PM_InProduction
  17621. (
  17622. BarCode,
  17623. ProductionLineID,
  17624. ProductionLineCode,
  17625. ProductionLineName,
  17626. ProcedureModel,
  17627. ModelType,
  17628. DefectFlag,
  17629. ReworkProcedureID,
  17630. IsPublicBody,
  17631. IsReFire,
  17632. GoodsLevelID,
  17633. GoodsLevelTypeID,
  17634. GoodsID,
  17635. GoodsCode,
  17636. GoodsName,
  17637. UserID,
  17638. GroutingDailyID,
  17639. GroutingDailyDetailID,
  17640. GroutingDate,
  17641. GroutingLineID,
  17642. GroutingLineCode,
  17643. GroutingLineName,
  17644. GMouldTypeID,
  17645. CanManyTimes,
  17646. GroutingLineDetailID,
  17647. GroutingMouldCode,
  17648. MouldCode,
  17649. GroutingUserID,
  17650. GroutingUserCode,
  17651. GroutingNum,
  17652. Remarks,
  17653. KilnID,
  17654. KilnCode,
  17655. KilnName,
  17656. KilnCarID,
  17657. KilnCarCode,
  17658. KilnCarName,
  17659. KilnCarBatchNo,
  17660. KilnCarPosition,
  17661. AccountID,
  17662. ValueFlag,
  17663. CreateUserID,
  17664. UpdateUserID,
  17665. SpecialRepairflag,
  17666. FlowProcedureID,
  17667. FlowProcedureTime,
  17668. ProcedureID,
  17669. ProcedureTime,
  17670. ProductionDataID,
  17671. logoid,
  17672. IsReworkFlag,
  17673. SemiCheckID
  17674. )
  17675. select
  17676. BarCode,
  17677. ProductionLineID,
  17678. ProductionLineCode,
  17679. ProductionLineName,
  17680. ProcedureModel,
  17681. ModelType,
  17682. DefectFlag,
  17683. ReworkProcedureID,
  17684. IsPublicBody,
  17685. IsReFire,
  17686. null,
  17687. 2,
  17688. GoodsID,
  17689. GoodsCode,
  17690. GoodsName,
  17691. UserID,
  17692. GroutingDailyID,
  17693. GroutingDailyDetailID,
  17694. GroutingDate,
  17695. GroutingLineID,
  17696. GroutingLineCode,
  17697. GroutingLineName,
  17698. GMouldTypeID,
  17699. CanManyTimes,
  17700. GroutingLineDetailID,
  17701. GroutingMouldCode,
  17702. MouldCode,
  17703. GroutingUserID,
  17704. GroutingUserCode,
  17705. GroutingNum,
  17706. Remarks,
  17707. KilnID,
  17708. KilnCode,
  17709. KilnName,
  17710. KilnCarID,
  17711. KilnCarCode,
  17712. KilnCarName,
  17713. KilnCarBatchNo,
  17714. KilnCarPosition,
  17715. AccountID,
  17716. ValueFlag,
  17717. :CreateUserID,
  17718. :UpdateUserID,
  17719. SpecialRepairflag,
  17720. FlowProcedureID,
  17721. FlowProcedureTime,
  17722. FlowProcedureID,
  17723. ProcedureTime,
  17724. ProductionDataID,
  17725. logoid,
  17726. 1,
  17727. :SemiCheckID
  17728. from TP_PM_InProductionTrash
  17729. where barcode=:barcode
  17730. ";
  17731. OracleParameter[] oracleParameters = new OracleParameter[] {
  17732. new OracleParameter(":barcode",entity.BarCode),
  17733. new OracleParameter(":SemiCheckID",entity.SemiCheckID),
  17734. new OracleParameter(":CreateUserID",sUserInfo.UserID),
  17735. new OracleParameter(":UpdateUserID",sUserInfo.UserID),
  17736. };
  17737. int result = oracleTrConn.ExecuteNonQuery(sqlInsert, oracleParameters);
  17738. // 注浆明细 产品等级
  17739. sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=2,updateuserid=:updateuserid
  17740. where barcode=:barcode";
  17741. oracleParameters = new OracleParameter[] {
  17742. new OracleParameter(":accountid", sUserInfo.AccountID),
  17743. new OracleParameter(":barcode",entity.BarCode),
  17744. new OracleParameter(":updateuserid",sUserInfo.UserID),
  17745. };
  17746. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17747. #endregion
  17748. #region 2.废弃产品表中对应的总单数据和明细数据valueflag='0'。
  17749. string sqlString = "select max(sp.scrapproductid) scrapproductid\n" +
  17750. " from TP_PM_ScrapProduct sp\n" +
  17751. " where sp.barcode = :barcode\n" +
  17752. " and sp.auditstatus = 1\n" +
  17753. " and sp.valueflag = '1'\n" +
  17754. " and sp.scraptype = '2'";
  17755. spParameters = new OracleParameter[] {
  17756. new OracleParameter(":barcode",entity.BarCode),
  17757. };
  17758. string scrapproductid = oracleTrConn.GetSqlResultToStr(sqlString, spParameters);
  17759. sqlString = @"update TP_PM_ScrapProduct set valueflag='0', updateuserid=:updateuserid, backouttime=sysdate where scrapproductid=:scrapproductid";
  17760. spParameters = new OracleParameter[] {
  17761. new OracleParameter(":updateuserid",sUserInfo.UserID),
  17762. new OracleParameter(":scrapproductid",scrapproductid),
  17763. };
  17764. spResult = oracleTrConn.ExecuteNonQuery(sqlString, spParameters);
  17765. sqlString = @"update TP_PM_ResponProcedure set valueflag='0', updateuserid=:updateuserid where scrapproductid=:scrapproductid";
  17766. //oracleParameters = new OracleParameter[] {
  17767. // new OracleParameter(":barcode",entity.BarCode),
  17768. //};
  17769. spResult += oracleTrConn.ExecuteNonQuery(sqlString, spParameters);
  17770. //sql = @"update TP_PM_ScrapProduct set valueflag='0' where barcode=:barcode";
  17771. //oracleParameters = new OracleParameter[] {
  17772. // new OracleParameter(":barcode",entity.BarCode),
  17773. //};
  17774. //result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17775. //sql = @"update TP_PM_ResponProcedure set valueflag='0' where barcode=:barcode";
  17776. //oracleParameters = new OracleParameter[] {
  17777. // new OracleParameter(":barcode",entity.BarCode),
  17778. //};
  17779. //result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17780. ////sql = @"update TP_PM_ScrapResponsible set valueflag='0' where barcode=:barcode";
  17781. ////oracleParameters = new OracleParameter[] {
  17782. //// new OracleParameter(":barcode",entity.BarCode),
  17783. ////};
  17784. ////result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17785. #endregion
  17786. #region 3.删除在产产品数据
  17787. sql = "delete from TP_PM_InProductionTrash where barcode=:barcode";
  17788. oracleParameters = new OracleParameter[] {
  17789. new OracleParameter(":barcode",entity.BarCode),
  17790. };
  17791. result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17792. #endregion
  17793. #region 4.更新半检数据产品分级
  17794. sql = "update TP_PM_SemiCheck set GoodsLevelID=null,GoodsLevelTypeID=null where SemiCheckID=:SemiCheckID";
  17795. oracleParameters = new OracleParameter[] {
  17796. new OracleParameter(":SemiCheckID",idStr),
  17797. };
  17798. result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17799. #endregion
  17800. #region 存在缺陷 插入缺陷表
  17801. if (entity.SemiCheckDefects != null)
  17802. {
  17803. foreach (SemiCheckDefectEntity semiCheckDefect in entity.SemiCheckDefects)
  17804. {
  17805. #region 保存缺陷
  17806. semiCheckDefect.SemiCheckID = Convert.ToInt32(idStr);
  17807. semiCheckDefect.ScrapResponFlag
  17808. = string.IsNullOrEmpty(semiCheckDefect.ScrapResponFlag) ? "0" : semiCheckDefect.ScrapResponFlag;
  17809. // 保存缺陷
  17810. errMsg = AddSemiCheckDefect(oracleTrConn, semiCheckDefect, sUserInfo);
  17811. if (!string.IsNullOrEmpty(errMsg))
  17812. {
  17813. return errMsg;
  17814. }
  17815. #endregion
  17816. }
  17817. }
  17818. #endregion
  17819. }
  17820. else if (entity.SemiCheckType == "0") //正常
  17821. {
  17822. #region 1.从在产回收站中把数据恢复到在产表中。
  17823. string sqlInsert = @"insert into TP_PM_InProduction
  17824. (
  17825. BarCode,
  17826. ProductionLineID,
  17827. ProductionLineCode,
  17828. ProductionLineName,
  17829. ProcedureModel,
  17830. ModelType,
  17831. DefectFlag,
  17832. ReworkProcedureID,
  17833. IsPublicBody,
  17834. IsReFire,
  17835. GoodsLevelID,
  17836. GoodsLevelTypeID,
  17837. GoodsID,
  17838. GoodsCode,
  17839. GoodsName,
  17840. UserID,
  17841. GroutingDailyID,
  17842. GroutingDailyDetailID,
  17843. GroutingDate,
  17844. GroutingLineID,
  17845. GroutingLineCode,
  17846. GroutingLineName,
  17847. GMouldTypeID,
  17848. CanManyTimes,
  17849. GroutingLineDetailID,
  17850. GroutingMouldCode,
  17851. MouldCode,
  17852. GroutingUserID,
  17853. GroutingUserCode,
  17854. GroutingNum,
  17855. Remarks,
  17856. KilnID,
  17857. KilnCode,
  17858. KilnName,
  17859. KilnCarID,
  17860. KilnCarCode,
  17861. KilnCarName,
  17862. KilnCarBatchNo,
  17863. KilnCarPosition,
  17864. AccountID,
  17865. ValueFlag,
  17866. CreateUserID,
  17867. UpdateUserID,
  17868. SpecialRepairflag,
  17869. FlowProcedureID,
  17870. FlowProcedureTime,
  17871. ProcedureID,
  17872. ProcedureTime,
  17873. ProductionDataID,
  17874. logoid,
  17875. IsReworkFlag,
  17876. SemiCheckID
  17877. )
  17878. select
  17879. BarCode,
  17880. ProductionLineID,
  17881. ProductionLineCode,
  17882. ProductionLineName,
  17883. ProcedureModel,
  17884. ModelType,
  17885. DefectFlag,
  17886. ReworkProcedureID,
  17887. IsPublicBody,
  17888. IsReFire,
  17889. null,
  17890. 1,
  17891. GoodsID,
  17892. GoodsCode,
  17893. GoodsName,
  17894. UserID,
  17895. GroutingDailyID,
  17896. GroutingDailyDetailID,
  17897. GroutingDate,
  17898. GroutingLineID,
  17899. GroutingLineCode,
  17900. GroutingLineName,
  17901. GMouldTypeID,
  17902. CanManyTimes,
  17903. GroutingLineDetailID,
  17904. GroutingMouldCode,
  17905. MouldCode,
  17906. GroutingUserID,
  17907. GroutingUserCode,
  17908. GroutingNum,
  17909. Remarks,
  17910. KilnID,
  17911. KilnCode,
  17912. KilnName,
  17913. KilnCarID,
  17914. KilnCarCode,
  17915. KilnCarName,
  17916. KilnCarBatchNo,
  17917. KilnCarPosition,
  17918. AccountID,
  17919. ValueFlag,
  17920. :CreateUserID,
  17921. :UpdateUserID,
  17922. SpecialRepairflag,
  17923. FlowProcedureID,
  17924. FlowProcedureTime,
  17925. FlowProcedureID,
  17926. ProcedureTime,
  17927. ProductionDataID,
  17928. logoid,
  17929. 0,
  17930. null
  17931. from TP_PM_InProductionTrash
  17932. where barcode=:barcode
  17933. ";
  17934. OracleParameter[] oracleParameters = new OracleParameter[] {
  17935. new OracleParameter(":barcode",entity.BarCode),
  17936. new OracleParameter(":CreateUserID",sUserInfo.UserID),
  17937. new OracleParameter(":UpdateUserID",sUserInfo.UserID),
  17938. };
  17939. int result = oracleTrConn.ExecuteNonQuery(sqlInsert, oracleParameters);
  17940. // 注浆明细 产品等级
  17941. sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=1,updateuserid=:updateuserid
  17942. where barcode=:barcode";
  17943. oracleParameters = new OracleParameter[] {
  17944. new OracleParameter(":accountid", sUserInfo.AccountID),
  17945. new OracleParameter(":barcode",entity.BarCode),
  17946. new OracleParameter(":updateuserid",sUserInfo.UserID),
  17947. };
  17948. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17949. #endregion
  17950. #region 2.废弃产品表中对应的总单数据和明细数据valueflag='0'。
  17951. string sqlString = "select max(sp.scrapproductid) scrapproductid\n" +
  17952. " from TP_PM_ScrapProduct sp\n" +
  17953. " where sp.barcode = :barcode\n" +
  17954. " and sp.auditstatus = 1\n" +
  17955. " and sp.valueflag = '1'\n" +
  17956. " and sp.scraptype = '2'";
  17957. spParameters = new OracleParameter[] {
  17958. new OracleParameter(":barcode",entity.BarCode),
  17959. };
  17960. string scrapproductid = oracleTrConn.GetSqlResultToStr(sqlString, spParameters);
  17961. sqlString = @"update TP_PM_ScrapProduct set valueflag='0', updateuserid=:updateuserid, backouttime=sysdate where scrapproductid=:scrapproductid";
  17962. spParameters = new OracleParameter[] {
  17963. new OracleParameter(":updateuserid",sUserInfo.UserID),
  17964. new OracleParameter(":scrapproductid",scrapproductid),
  17965. };
  17966. spResult = oracleTrConn.ExecuteNonQuery(sqlString, spParameters);
  17967. sqlString = @"update TP_PM_ResponProcedure set valueflag='0', updateuserid=:updateuserid where scrapproductid=:scrapproductid";
  17968. //oracleParameters = new OracleParameter[] {
  17969. // new OracleParameter(":barcode",entity.BarCode),
  17970. //};
  17971. spResult += oracleTrConn.ExecuteNonQuery(sqlString, spParameters);
  17972. //sql = @"update TP_PM_ScrapProduct set valueflag='0' where barcode=:barcode";
  17973. //oracleParameters = new OracleParameter[] {
  17974. // new OracleParameter(":barcode",entity.BarCode),
  17975. //};
  17976. //result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17977. //sql = @"update TP_PM_ResponProcedure set valueflag='0' where barcode=:barcode";
  17978. //oracleParameters = new OracleParameter[] {
  17979. // new OracleParameter(":barcode",entity.BarCode),
  17980. //};
  17981. //result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17982. ////sql = @"update TP_PM_ScrapResponsible set valueflag='0' where barcode=:barcode";
  17983. ////oracleParameters = new OracleParameter[] {
  17984. //// new OracleParameter(":barcode",entity.BarCode),
  17985. ////};
  17986. ////result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17987. #endregion
  17988. #region 3.删除在产回收站产品数据
  17989. sql = "delete from TP_PM_InProductionTrash where barcode=:barcode";
  17990. oracleParameters = new OracleParameter[] {
  17991. new OracleParameter(":barcode",entity.BarCode),
  17992. };
  17993. result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  17994. #endregion
  17995. }
  17996. #endregion
  17997. }
  17998. return errMsg;
  17999. }
  18000. catch (Exception ex)
  18001. {
  18002. throw ex;
  18003. }
  18004. }
  18005. /// <summary>
  18006. /// 校验条码有效(新建)
  18007. /// </summary>
  18008. /// <param name="oracleTrConn">连接对象</param>
  18009. /// <param name="barcode">条码</param>
  18010. /// <param name="sUserInfo">登录用户信息</param>
  18011. /// <returns>string</returns>
  18012. /// <remarks>
  18013. /// 王鑫 2016.06.27 新建
  18014. /// </remarks>
  18015. private static string CheckBarcodeByNew(IDBTransaction oracleTrConn,
  18016. string barcode,
  18017. SUserInfo sUserInfo
  18018. )
  18019. {
  18020. try
  18021. {
  18022. OracleParameter[] paras = new OracleParameter[]{
  18023. new OracleParameter(":barcode",OracleDbType.Varchar2,barcode,ParameterDirection.Input),
  18024. };
  18025. // 重复登记的问题 for update
  18026. string sql = @"
  18027. select InScrapFlag,
  18028. KilnCarID,
  18029. KilnCarName,
  18030. IsReworkFlag,
  18031. SemiCheckID from TP_PM_InProduction where barcode=:barcode for update
  18032. ";
  18033. DataSet dsResult = oracleTrConn.GetSqlResultToDs(sql, paras);
  18034. if (dsResult != null && dsResult.Tables[0].Rows.Count > 0)
  18035. {
  18036. if (dsResult.Tables[0].Rows[0]["InScrapFlag"].ToString() == "1")
  18037. {
  18038. return "条码[" + barcode + "]已经报损待审批";
  18039. }
  18040. if (!string.IsNullOrEmpty(dsResult.Tables[0].Rows[0]["KilnCarID"].ToString()))
  18041. {
  18042. return "条码[" + barcode + "]已经在窑车[" + dsResult.Tables[0].Rows[0]["KilnCarName"].ToString() + "]";
  18043. ;
  18044. }
  18045. // chenxy 2019-10-02 半检返修 IsReworkFlag=2
  18046. if (dsResult.Tables[0].Rows[0]["IsReworkFlag"].ToString() == "1")
  18047. {
  18048. return "条码[" + barcode + "]已经半检返工中";
  18049. }
  18050. if (dsResult.Tables[0].Rows[0]["IsReworkFlag"].ToString() == "2")
  18051. {
  18052. return "条码[" + barcode + "]已经半检返修中";
  18053. }
  18054. }
  18055. else
  18056. {
  18057. return "条码[" + barcode + "]不在在产流程";
  18058. }
  18059. return null;
  18060. }
  18061. catch (Exception ex)
  18062. {
  18063. throw ex;
  18064. }
  18065. }
  18066. /// <summary>
  18067. /// 校验条码有效(编辑返工)
  18068. /// </summary>
  18069. /// <param name="oracleTrConn">连接对象</param>
  18070. /// <param name="barcode">条码</param>
  18071. /// <param name="sUserInfo">登录用户信息</param>
  18072. /// <returns>string</returns>
  18073. /// <remarks>
  18074. /// 王鑫 2016.06.27 新建
  18075. /// </remarks>
  18076. private static string CheckBarcodeByEditRework(IDBTransaction oracleTrConn,
  18077. string barcode,
  18078. SUserInfo sUserInfo
  18079. )
  18080. {
  18081. try
  18082. {
  18083. OracleParameter[] paras = new OracleParameter[]{
  18084. new OracleParameter(":barcode",OracleDbType.Varchar2,barcode,ParameterDirection.Input),
  18085. };
  18086. // 重复登记的问题 for update
  18087. string sql = @"
  18088. select InScrapFlag,
  18089. KilnCarID,
  18090. KilnCarName,
  18091. IsReworkFlag,
  18092. SemiCheckID from TP_PM_InProduction where barcode=:barcode for update
  18093. ";
  18094. DataSet dsResult = oracleTrConn.GetSqlResultToDs(sql, paras);
  18095. if (dsResult != null && dsResult.Tables[0].Rows.Count > 0)
  18096. {
  18097. if (dsResult.Tables[0].Rows[0]["InScrapFlag"].ToString() == "1")
  18098. {
  18099. return "条码[" + barcode + "]已经报损待审批";
  18100. }
  18101. if (!string.IsNullOrEmpty(dsResult.Tables[0].Rows[0]["KilnCarID"].ToString()))
  18102. {
  18103. return "条码[" + barcode + "]已经在窑车[" + dsResult.Tables[0].Rows[0]["KilnCarName"].ToString() + "]";
  18104. ;
  18105. }
  18106. // chenxy 2019-10-02 半检返修 IsReworkFlag=2
  18107. if (dsResult.Tables[0].Rows[0]["IsReworkFlag"].ToString() != "1")
  18108. {
  18109. return "条码[" + barcode + "]不在返工中";
  18110. }
  18111. }
  18112. else
  18113. {
  18114. return "条码[" + barcode + "]不在在产流程";
  18115. }
  18116. return null;
  18117. }
  18118. catch (Exception ex)
  18119. {
  18120. throw ex;
  18121. }
  18122. }
  18123. /// <summary>
  18124. /// 校验条码有效(编辑不合格)
  18125. /// </summary>
  18126. /// <param name="oracleTrConn">连接对象</param>
  18127. /// <param name="barcode">条码</param>
  18128. /// <param name="sUserInfo">登录用户信息</param>
  18129. /// <returns>string</returns>
  18130. /// <remarks>
  18131. /// 王鑫 2016.06.27 新建
  18132. /// </remarks>
  18133. private static string CheckBarcodeByEditNoPass(IDBTransaction oracleTrConn,
  18134. string barcode,
  18135. SUserInfo sUserInfo
  18136. )
  18137. {
  18138. try
  18139. {
  18140. OracleParameter[] paras = new OracleParameter[]{
  18141. new OracleParameter(":barcode",OracleDbType.Varchar2,barcode,ParameterDirection.Input),
  18142. };
  18143. // 重复登记的问题 for update
  18144. string sql = @" select 1 from TP_PM_InProductionTrash where barcode=:barcode and GoodsLevelTypeID=13 for update";
  18145. DataSet dsResult = oracleTrConn.GetSqlResultToDs(sql, paras);
  18146. if (dsResult != null && dsResult.Tables[0].Rows.Count == 0)
  18147. {
  18148. return "条码[" + barcode + "]不在在产回收站中";
  18149. }
  18150. return null;
  18151. }
  18152. catch (Exception ex)
  18153. {
  18154. throw ex;
  18155. }
  18156. }
  18157. /// <summary>
  18158. /// 添加半成品检验数据
  18159. /// </summary>
  18160. /// <param name="oracleTrConn">连接对象</param>
  18161. /// <param name="accountDate">账务日期</param>
  18162. /// <param name="productionData">生产数据</param>
  18163. /// <param name="sUserInfo">用户基本信息</param>
  18164. /// <returns>string</returns>
  18165. /// <remarks>
  18166. /// 陈冰 2014.09.18 新建
  18167. /// </remarks>
  18168. private static string AddSemiCheckData(IDBTransaction oracleTrConn, SemiCheckEntity entity, SUserInfo sUserInfo)
  18169. {
  18170. #region SQL
  18171. string sql = "insert into tp_pm_semicheck"
  18172. + " (semicheckid,"
  18173. + " barcode,"
  18174. + " productionlineid,"
  18175. + " procedureid,"
  18176. + " proceduretime,"
  18177. + " proceduremodel,"
  18178. + " modeltype,"
  18179. + " organizationid,"
  18180. + " goodsid,"
  18181. + " goodscode,"
  18182. + " userid,"
  18183. + " usercode,"
  18184. + " productiondataid,"
  18185. + " logoid,"
  18186. + " ispublicbody,"
  18187. + " specialrepairflag,"
  18188. + " goodslevelid,"
  18189. + " goodsleveltypeid,"
  18190. + " groutingdailyid,"
  18191. + " groutingdailydetailid,"
  18192. + " groutinglineid,"
  18193. + " groutinglinecode,"
  18194. + " groutinglinename,"
  18195. + " gmouldtypeid,"
  18196. + " canmanytimes,"
  18197. + " groutinglinedetailid,"
  18198. + " groutingdate,"
  18199. + " groutingmouldcode,"
  18200. + " mouldcode,"
  18201. + " groutinguserid,"
  18202. + " groutingusercode,"
  18203. + " groutingnum,"
  18204. + " semichecktype,"
  18205. + " semicheckuserID,"
  18206. + " semicheckusercode,"
  18207. + " semichecktime,"
  18208. + " remarks,"
  18209. + " accountid,"
  18210. + " createuserid,"
  18211. + " updateuserid,"
  18212. + " reworkprocedureid,"
  18213. + " reworkprocedurecode,"
  18214. + " reworkuserid,"
  18215. + " reworkusercode"
  18216. + ")"
  18217. + " select"
  18218. + " :semicheckid,"
  18219. + " TP_PM_InProduction.barcode,"
  18220. + " TP_PM_InProduction.productionlineid,"
  18221. + " TP_PM_InProduction.procedureid,"
  18222. + " TP_PM_InProduction.proceduretime,"
  18223. + " TP_PM_InProduction.proceduremodel,"
  18224. + " TP_PM_InProduction.modeltype,"
  18225. + " tp_pc_procedure.organizationid,"
  18226. + " TP_PM_InProduction.goodsid,"
  18227. + " TP_PM_InProduction.goodscode,"
  18228. + " TP_PM_InProduction.userid,"
  18229. + " tp_mst_user.usercode,"
  18230. + " TP_PM_InProduction.productiondataid,"
  18231. + " TP_PM_InProduction.logoid,"
  18232. + " TP_PM_InProduction.ispublicbody,"
  18233. + " TP_PM_InProduction.specialrepairflag,"
  18234. + " TP_PM_InProduction.goodslevelid,"
  18235. + " TP_PM_InProduction.goodsleveltypeid,"
  18236. + " TP_PM_InProduction.groutingdailyid,"
  18237. + " TP_PM_InProduction.groutingdailydetailid,"
  18238. + " TP_PM_InProduction.groutinglineid,"
  18239. + " TP_PM_InProduction.groutinglinecode,"
  18240. + " TP_PM_InProduction.groutinglinename,"
  18241. + " TP_PM_InProduction.gmouldtypeid,"
  18242. + " TP_PM_InProduction.canmanytimes,"
  18243. + " TP_PM_InProduction.groutinglinedetailid,"
  18244. + " TP_PM_InProduction.groutingdate,"
  18245. + " TP_PM_InProduction.groutingmouldcode,"
  18246. + " TP_PM_InProduction.mouldcode,"
  18247. + " TP_PM_InProduction.groutinguserid,"
  18248. + " TP_PM_InProduction.groutingusercode,"
  18249. + " TP_PM_InProduction.groutingnum,"
  18250. + " :semichecktype,"
  18251. + " :semicheckuserID,"
  18252. + " :semicheckusercode,"
  18253. + " sysdate,"
  18254. + " :remarks,"
  18255. + " :accountid,"
  18256. + " :createuserid,"
  18257. + " :updateuserid,"
  18258. + " :reworkprocedureid,"
  18259. + " :reworkprocedurecode,"
  18260. + " :reworkuserid,"
  18261. + " :reworkusercode"
  18262. + " from TP_PM_InProduction left join tp_mst_user on TP_PM_InProduction.UserID=tp_mst_user.userid "
  18263. + " left join tp_pc_procedure on TP_PM_InProduction.ProcedureID=tp_pc_procedure.ProcedureID "
  18264. + " where TP_PM_InProduction.barcode=:barcode";
  18265. #endregion
  18266. #region OracleParameter
  18267. OracleParameter[] paras = new OracleParameter[] {
  18268. new OracleParameter(":semicheckid",entity.SemiCheckID),
  18269. new OracleParameter(":semichecktype",entity.SemiCheckType),
  18270. new OracleParameter(":semicheckuserID",entity.SemiCheckUserID),
  18271. new OracleParameter(":semicheckusercode",entity.SemiCheckUserCode),
  18272. new OracleParameter(":remarks",entity.Remarks),
  18273. new OracleParameter(":accountid",sUserInfo.AccountID),
  18274. new OracleParameter(":createuserid",sUserInfo.UserID),
  18275. new OracleParameter(":updateuserid",sUserInfo.UserID),
  18276. new OracleParameter(":barcode",entity.BarCode),
  18277. new OracleParameter(":reworkprocedureid",entity.ReworkProcedureID),
  18278. new OracleParameter(":reworkprocedurecode",entity.ReworkProcedureCode),
  18279. new OracleParameter(":reworkuserid",entity.ReworkUserID),
  18280. new OracleParameter(":reworkusercode",entity.ReworkUserCode),
  18281. };
  18282. #endregion
  18283. foreach (OracleParameter para in paras)
  18284. {
  18285. if (string.IsNullOrEmpty(para.Value + ""))
  18286. {
  18287. para.Value = DBNull.Value;
  18288. }
  18289. }
  18290. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  18291. // 失败
  18292. if (result != Constant.INT_IS_ONE)
  18293. {
  18294. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  18295. }
  18296. // 成功返回null
  18297. return null;
  18298. }
  18299. /// <summary>
  18300. /// 添加半成品检验数据(不合格)
  18301. /// </summary>
  18302. /// <param name="oracleTrConn">连接对象</param>
  18303. /// <param name="accountDate">账务日期</param>
  18304. /// <param name="productionData">生产数据</param>
  18305. /// <param name="sUserInfo">用户基本信息</param>
  18306. /// <returns>string</returns>
  18307. /// <remarks>
  18308. /// 陈冰 2014.09.18 新建
  18309. /// </remarks>
  18310. private static string AddSemiCheckDataNoPass(IDBTransaction oracleTrConn, SemiCheckEntity entity, SUserInfo sUserInfo)
  18311. {
  18312. #region SQL
  18313. string sql = "insert into tp_pm_semicheck"
  18314. + " (semicheckid,"
  18315. + " barcode,"
  18316. + " productionlineid,"
  18317. + " procedureid,"
  18318. + " proceduretime,"
  18319. + " proceduremodel,"
  18320. + " modeltype,"
  18321. + " organizationid,"
  18322. + " goodsid,"
  18323. + " goodscode,"
  18324. + " userid,"
  18325. + " usercode,"
  18326. + " productiondataid,"
  18327. + " logoid,"
  18328. + " ispublicbody,"
  18329. + " specialrepairflag,"
  18330. + " goodslevelid,"
  18331. + " goodsleveltypeid,"
  18332. + " groutingdailyid,"
  18333. + " groutingdailydetailid,"
  18334. + " groutinglineid,"
  18335. + " groutinglinecode,"
  18336. + " groutinglinename,"
  18337. + " gmouldtypeid,"
  18338. + " canmanytimes,"
  18339. + " groutinglinedetailid,"
  18340. + " groutingdate,"
  18341. + " groutingmouldcode,"
  18342. + " mouldcode,"
  18343. + " groutinguserid,"
  18344. + " groutingusercode,"
  18345. + " groutingnum,"
  18346. + " semichecktype,"
  18347. + " semicheckuserID,"
  18348. + " semicheckusercode,"
  18349. + " semichecktime,"
  18350. + " remarks,"
  18351. + " accountid,"
  18352. + " createuserid,"
  18353. + " updateuserid,"
  18354. + " reworkprocedureid,"
  18355. + " reworkprocedurecode,"
  18356. + " reworkuserid,"
  18357. + " reworkusercode"
  18358. + ")"
  18359. + " select"
  18360. + " :semicheckid,"
  18361. + " TP_PM_InProduction.barcode,"
  18362. + " TP_PM_InProduction.productionlineid,"
  18363. + " TP_PM_InProduction.procedureid,"
  18364. + " TP_PM_InProduction.proceduretime,"
  18365. + " TP_PM_InProduction.proceduremodel,"
  18366. + " TP_PM_InProduction.modeltype,"
  18367. + " tp_pc_procedure.organizationid,"
  18368. + " TP_PM_InProduction.goodsid,"
  18369. + " TP_PM_InProduction.goodscode,"
  18370. + " TP_PM_InProduction.userid,"
  18371. + " tp_mst_user.usercode,"
  18372. + " TP_PM_InProduction.productiondataid,"
  18373. + " TP_PM_InProduction.logoid,"
  18374. + " TP_PM_InProduction.ispublicbody,"
  18375. + " TP_PM_InProduction.specialrepairflag,"
  18376. + " (select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=13 and accountid=:accountid),"
  18377. + " 13,"
  18378. + " TP_PM_InProduction.groutingdailyid,"
  18379. + " TP_PM_InProduction.groutingdailydetailid,"
  18380. + " TP_PM_InProduction.groutinglineid,"
  18381. + " TP_PM_InProduction.groutinglinecode,"
  18382. + " TP_PM_InProduction.groutinglinename,"
  18383. + " TP_PM_InProduction.gmouldtypeid,"
  18384. + " TP_PM_InProduction.canmanytimes,"
  18385. + " TP_PM_InProduction.groutinglinedetailid,"
  18386. + " TP_PM_InProduction.groutingdate,"
  18387. + " TP_PM_InProduction.groutingmouldcode,"
  18388. + " TP_PM_InProduction.mouldcode,"
  18389. + " TP_PM_InProduction.groutinguserid,"
  18390. + " TP_PM_InProduction.groutingusercode,"
  18391. + " TP_PM_InProduction.groutingnum,"
  18392. + " :semichecktype,"
  18393. + " :semicheckuserID,"
  18394. + " :semicheckusercode,"
  18395. + " sysdate,"
  18396. + " :remarks,"
  18397. + " :accountid,"
  18398. + " :createuserid,"
  18399. + " :updateuserid,"
  18400. + " :reworkprocedureid,"
  18401. + " :reworkprocedurecode,"
  18402. + " :reworkuserid,"
  18403. + " :reworkusercode"
  18404. + " from TP_PM_InProduction left join tp_mst_user on TP_PM_InProduction.UserID=tp_mst_user.userid "
  18405. + " left join tp_pc_procedure on TP_PM_InProduction.ProcedureID=tp_pc_procedure.ProcedureID "
  18406. + " where TP_PM_InProduction.barcode=:barcode";
  18407. #endregion
  18408. #region OracleParameter
  18409. OracleParameter[] paras = new OracleParameter[] {
  18410. new OracleParameter(":semicheckid",entity.SemiCheckID),
  18411. new OracleParameter(":semichecktype",entity.SemiCheckType),
  18412. new OracleParameter(":semicheckuserID",entity.SemiCheckUserID),
  18413. new OracleParameter(":semicheckusercode",entity.SemiCheckUserCode),
  18414. new OracleParameter(":remarks",entity.Remarks),
  18415. new OracleParameter(":accountid",sUserInfo.AccountID),
  18416. new OracleParameter(":createuserid",sUserInfo.UserID),
  18417. new OracleParameter(":updateuserid",sUserInfo.UserID),
  18418. new OracleParameter(":accountid",sUserInfo.AccountID),
  18419. new OracleParameter(":barcode",entity.BarCode),
  18420. new OracleParameter(":reworkprocedureid",entity.ReworkProcedureID),
  18421. new OracleParameter(":reworkprocedurecode",entity.ReworkProcedureCode),
  18422. new OracleParameter(":reworkuserid",entity.ReworkUserID),
  18423. new OracleParameter(":reworkusercode",entity.ReworkUserCode),
  18424. };
  18425. #endregion
  18426. foreach (OracleParameter para in paras)
  18427. {
  18428. if (string.IsNullOrEmpty(para.Value + ""))
  18429. {
  18430. para.Value = DBNull.Value;
  18431. }
  18432. }
  18433. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  18434. // 失败
  18435. if (result != Constant.INT_IS_ONE)
  18436. {
  18437. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  18438. }
  18439. // 成功返回null
  18440. return null;
  18441. }
  18442. /// <summary>
  18443. /// 添加半成品检验数据
  18444. /// </summary>
  18445. /// <param name="oracleTrConn">连接对象</param>
  18446. /// <param name="accountDate">账务日期</param>
  18447. /// <param name="productionData">生产数据</param>
  18448. /// <param name="sUserInfo">用户基本信息</param>
  18449. /// <returns>string</returns>
  18450. /// <remarks>
  18451. /// 陈冰 2014.09.18 新建
  18452. /// </remarks>
  18453. private static string AddSemiCheckDataTrash(IDBTransaction oracleTrConn, SemiCheckEntity entity, SUserInfo sUserInfo)
  18454. {
  18455. #region SQL
  18456. string sql = "insert into tp_pm_semicheck"
  18457. + " (semicheckid,"
  18458. + " barcode,"
  18459. + " productionlineid,"
  18460. + " procedureid,"
  18461. + " proceduretime,"
  18462. + " proceduremodel,"
  18463. + " modeltype,"
  18464. + " organizationid,"
  18465. + " goodsid,"
  18466. + " goodscode,"
  18467. + " userid,"
  18468. + " usercode,"
  18469. + " productiondataid,"
  18470. + " logoid,"
  18471. + " ispublicbody,"
  18472. + " specialrepairflag,"
  18473. + " goodslevelid,"
  18474. + " goodsleveltypeid,"
  18475. + " groutingdailyid,"
  18476. + " groutingdailydetailid,"
  18477. + " groutinglineid,"
  18478. + " groutinglinecode,"
  18479. + " groutinglinename,"
  18480. + " gmouldtypeid,"
  18481. + " canmanytimes,"
  18482. + " groutinglinedetailid,"
  18483. + " groutingdate,"
  18484. + " groutingmouldcode,"
  18485. + " mouldcode,"
  18486. + " groutinguserid,"
  18487. + " groutingusercode,"
  18488. + " groutingnum,"
  18489. + " semichecktype,"
  18490. + " semicheckuserID,"
  18491. + " semicheckusercode,"
  18492. + " semichecktime,"
  18493. + " remarks,"
  18494. + " accountid,"
  18495. + " createuserid,"
  18496. + " updateuserid,"
  18497. + " reworkprocedureid,"
  18498. + " reworkprocedurecode,"
  18499. + " reworkuserid,"
  18500. + " reworkusercode"
  18501. + ")"
  18502. + " select"
  18503. + " :semicheckid,"
  18504. + " trash.barcode,"
  18505. + " trash.productionlineid,"
  18506. + " trash.procedureid,"
  18507. + " trash.proceduretime,"
  18508. + " trash.proceduremodel,"
  18509. + " trash.modeltype,"
  18510. + " tp_pc_procedure.organizationid,"
  18511. + " trash.goodsid,"
  18512. + " trash.goodscode,"
  18513. + " trash.userid,"
  18514. + " tp_mst_user.usercode,"
  18515. + " trash.productiondataid,"
  18516. + " trash.logoid,"
  18517. + " trash.ispublicbody,"
  18518. + " trash.specialrepairflag,"
  18519. + " trash.goodslevelid,"
  18520. + " trash.goodsleveltypeid,"
  18521. + " trash.groutingdailyid,"
  18522. + " trash.groutingdailydetailid,"
  18523. + " trash.groutinglineid,"
  18524. + " trash.groutinglinecode,"
  18525. + " trash.groutinglinename,"
  18526. + " trash.gmouldtypeid,"
  18527. + " trash.canmanytimes,"
  18528. + " trash.groutinglinedetailid,"
  18529. + " trash.groutingdate,"
  18530. + " trash.groutingmouldcode,"
  18531. + " trash.mouldcode,"
  18532. + " trash.groutinguserid,"
  18533. + " trash.groutingusercode,"
  18534. + " trash.groutingnum,"
  18535. + " :semichecktype,"
  18536. + " :semicheckuserID,"
  18537. + " :semicheckusercode,"
  18538. + " sysdate,"
  18539. + " :remarks,"
  18540. + " :accountid,"
  18541. + " :createuserid,"
  18542. + " :updateuserid,"
  18543. + " :reworkprocedureid,"
  18544. + " :reworkprocedurecode,"
  18545. + " :reworkuserid,"
  18546. + " :reworkusercode"
  18547. + " from TP_PM_InProductionTrash trash left join tp_mst_user on trash.UserID=tp_mst_user.userid "
  18548. + " left join tp_pc_procedure on trash.ProcedureID=tp_pc_procedure.ProcedureID "
  18549. + " where trash.barcode=:barcode";
  18550. #endregion
  18551. #region OracleParameter
  18552. OracleParameter[] paras = new OracleParameter[] {
  18553. new OracleParameter(":semicheckid",entity.SemiCheckID),
  18554. new OracleParameter(":semichecktype",entity.SemiCheckType),
  18555. new OracleParameter(":semicheckuserID",entity.SemiCheckUserID),
  18556. new OracleParameter(":semicheckusercode",entity.SemiCheckUserCode),
  18557. new OracleParameter(":remarks",entity.Remarks),
  18558. new OracleParameter(":accountid",sUserInfo.AccountID),
  18559. new OracleParameter(":createuserid",sUserInfo.UserID),
  18560. new OracleParameter(":updateuserid",sUserInfo.UserID),
  18561. new OracleParameter(":barcode",entity.BarCode),
  18562. new OracleParameter(":reworkprocedureid",entity.ReworkProcedureID),
  18563. new OracleParameter(":reworkprocedurecode",entity.ReworkProcedureCode),
  18564. new OracleParameter(":reworkuserid",entity.ReworkUserID),
  18565. new OracleParameter(":reworkusercode",entity.ReworkUserCode),
  18566. };
  18567. #endregion
  18568. foreach (OracleParameter para in paras)
  18569. {
  18570. if (string.IsNullOrEmpty(para.Value + ""))
  18571. {
  18572. para.Value = DBNull.Value;
  18573. }
  18574. }
  18575. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  18576. // 失败
  18577. if (result != Constant.INT_IS_ONE)
  18578. {
  18579. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  18580. }
  18581. // 成功返回null
  18582. return null;
  18583. }
  18584. /// <summary>
  18585. /// 添加半成品检验数据
  18586. /// </summary>
  18587. /// <param name="oracleTrConn">连接对象</param>
  18588. /// <param name="accountDate">账务日期</param>
  18589. /// <param name="productionData">生产数据</param>
  18590. /// <param name="sUserInfo">用户基本信息</param>
  18591. /// <returns>string</returns>
  18592. /// <remarks>
  18593. /// 陈冰 2014.09.18 新建
  18594. /// </remarks>
  18595. private static string SetSemiCheckDataValueFlag(IDBTransaction oracleTrConn, SemiCheckEntity entity, SUserInfo sUserInfo)
  18596. {
  18597. #region SQL
  18598. string sql = @"update TP_PM_SemiCheck
  18599. set BackOutUserID=:BackOutUserID,
  18600. BackOutUserCode=:BackOutUserCode,
  18601. BackOutFlag=1,
  18602. BackOutTime=sysdate,
  18603. ValueFlag='0',
  18604. updateuserid=:updateuserid
  18605. where semicheckid=:semicheckid";
  18606. #region OracleParameter
  18607. OracleParameter[] paras = new OracleParameter[] {
  18608. new OracleParameter(":semicheckid",entity.SemiCheckID),
  18609. new OracleParameter(":updateuserid",sUserInfo.UserID),
  18610. new OracleParameter(":BackOutUserID",sUserInfo.UserID),
  18611. new OracleParameter(":BackOutUserCode",sUserInfo.UserCode),
  18612. };
  18613. #endregion
  18614. int result = oracleTrConn.ExecuteNonQuery(sql, paras);
  18615. string sql2 = @"update TP_PM_SemiCheckDefect
  18616. set
  18617. ValueFlag='0',
  18618. updateuserid=:updateuserid
  18619. where semicheckid=:semicheckid";
  18620. string sql3 = @"update TP_PM_SCDefectResponsible
  18621. set
  18622. ValueFlag='0',
  18623. updateuserid=:updateuserid
  18624. where semicheckid=:semicheckid";
  18625. #endregion
  18626. #region OracleParameter
  18627. paras = new OracleParameter[] {
  18628. new OracleParameter(":semicheckid",entity.SemiCheckID),
  18629. new OracleParameter(":updateuserid",sUserInfo.UserID),
  18630. };
  18631. #endregion
  18632. foreach (OracleParameter para in paras)
  18633. {
  18634. if (string.IsNullOrEmpty(para.Value + ""))
  18635. {
  18636. para.Value = DBNull.Value;
  18637. }
  18638. }
  18639. result += oracleTrConn.ExecuteNonQuery(sql2, paras);
  18640. result += oracleTrConn.ExecuteNonQuery(sql3, paras);
  18641. // 失败
  18642. if (result == Constant.INT_IS_ZERO)
  18643. {
  18644. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  18645. }
  18646. // 成功返回null
  18647. return null;
  18648. }
  18649. /// <summary>
  18650. /// 保存半检缺陷
  18651. /// </summary>
  18652. /// <param name="oracleTrConn">连接对象</param>
  18653. /// <param name="productionDefect">缺陷数据</param>
  18654. /// <param name="sUserInfo">用户基本信息</param>
  18655. /// <returns>string</returns>
  18656. private static string AddSemiCheckDefect(IDBTransaction oracleTrConn, SemiCheckDefectEntity semiCheckDefect, SUserInfo sUserInfo)
  18657. {
  18658. // 查询新插入的半检缺陷ID
  18659. string sql = "select SEQ_PM_SemiCheckDefect_ID.nextval from dual";
  18660. string idStr = oracleTrConn.GetSqlResultToStr(sql);
  18661. int semiCheckDefectID = 0;
  18662. if (!string.IsNullOrEmpty(idStr))
  18663. {
  18664. semiCheckDefectID = int.Parse(idStr);
  18665. }
  18666. else
  18667. {
  18668. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  18669. }
  18670. #region SQL
  18671. sql = "insert into TP_PM_SemiCheckDefect"
  18672. + " (semicheckdefectid,"
  18673. + " semicheckid,"
  18674. + " defectid,"
  18675. + " defectcode,"
  18676. + " defectname,"
  18677. + " defectpositionid,"
  18678. + " defectpositioncode,"
  18679. + " defectpositionname,"
  18680. + " scrapResponFlag,"
  18681. + " defectproductiondataid,"
  18682. + " defectprocedureid,"
  18683. + " defectuserid,"
  18684. + " defectusercode,"
  18685. + " remarks,"
  18686. + " accountid,"
  18687. + " createuserid,"
  18688. + " updateuserid)"
  18689. + " values"
  18690. + " ("
  18691. + " :semicheckdefectid,"
  18692. + " :semicheckid,"
  18693. + " :defectid,"
  18694. + " :defectcode,"
  18695. + " :defectname,"
  18696. + " :defectpositionid,"
  18697. + " :defectpositioncode,"
  18698. + " :defectpositionname,"
  18699. + " :scrapResponFlag,"
  18700. + " :defectproductiondataid,"
  18701. + " :defectprocedureid,"
  18702. + " :defectuserid,"
  18703. + " :defectusercode,"
  18704. + " :remarks,"
  18705. + " :accountid,"
  18706. + " :createuserid,"
  18707. + " :updateuserid)";
  18708. #endregion
  18709. #region 参数
  18710. OracleParameter[] oracleParameters = new OracleParameter[] {
  18711. new OracleParameter(":semicheckdefectid",semiCheckDefectID),
  18712. new OracleParameter(":semicheckid",semiCheckDefect.SemiCheckID),
  18713. new OracleParameter(":defectid",semiCheckDefect.DefectID),
  18714. new OracleParameter(":defectcode",semiCheckDefect.DefectCode),
  18715. new OracleParameter(":defectname",semiCheckDefect.DefectName),
  18716. new OracleParameter(":defectpositionid",semiCheckDefect.DefectPositionID),
  18717. new OracleParameter(":defectpositioncode",semiCheckDefect.DefectPositionCode),
  18718. new OracleParameter(":defectpositionname",semiCheckDefect.DefectPositionName),
  18719. new OracleParameter(":scrapResponFlag",semiCheckDefect.ScrapResponFlag),
  18720. new OracleParameter(":defectproductiondataid",semiCheckDefect.DefectProductionDataID),
  18721. new OracleParameter(":defectprocedureid",semiCheckDefect.DefectProcedureID),
  18722. new OracleParameter(":defectuserid",semiCheckDefect.DefectUserID),
  18723. new OracleParameter(":defectusercode",semiCheckDefect.DefectUserCode),
  18724. new OracleParameter(":remarks",semiCheckDefect.Remarks),
  18725. new OracleParameter(":accountid",sUserInfo.AccountID),
  18726. new OracleParameter(":createuserid",sUserInfo.UserID),
  18727. new OracleParameter(":updateuserid",sUserInfo.UserID),
  18728. };
  18729. #endregion
  18730. int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  18731. // 保存失败
  18732. if (result != Constant.INT_IS_ONE)
  18733. {
  18734. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  18735. }
  18736. #region 插入生产缺陷责任者
  18737. if (semiCheckDefect.DefectResponsibles != null)
  18738. {
  18739. foreach (SemiCheckResponsibleEntity DefectResponsible in semiCheckDefect.DefectResponsibles)
  18740. {
  18741. #region SQL
  18742. sql = "insert into TP_PM_SCDefectResponsible"
  18743. + " (semicheckdefectid,"
  18744. + " staffid,"
  18745. + " semicheckid,"
  18746. + " userid,"
  18747. + " usercode,"
  18748. + " Ujobsid,"
  18749. + " SJobsID,"
  18750. + " staffstatus,"
  18751. + " accountid,"
  18752. + " createuserid,"
  18753. + " updateuserid)"
  18754. + " values"
  18755. + " (:semicheckdefectid,"
  18756. + " :staffid,"
  18757. + " :semicheckid,"
  18758. + " :userid,"
  18759. + " :usercode,"
  18760. + " :ujobsid,"
  18761. + " :sjobsid,"
  18762. + " :staffstatus,"
  18763. + " :accountid,"
  18764. + " :createuserid,"
  18765. + " :updateuserid)";
  18766. #endregion
  18767. #region 参数
  18768. oracleParameters = new OracleParameter[] {
  18769. new OracleParameter(":semicheckdefectid",semiCheckDefectID),
  18770. new OracleParameter(":staffid",DefectResponsible.StaffID),
  18771. new OracleParameter(":semicheckid",semiCheckDefect.SemiCheckID),
  18772. new OracleParameter(":userid",DefectResponsible.UserID),
  18773. new OracleParameter(":usercode",DefectResponsible.UserCode),
  18774. new OracleParameter(":ujobsid",DefectResponsible.UJobsID),
  18775. new OracleParameter(":sjobsid",DefectResponsible.SJobsID),
  18776. new OracleParameter(":staffstatus",DefectResponsible.StaffStatus),
  18777. new OracleParameter(":accountid",sUserInfo.AccountID),
  18778. new OracleParameter(":createuserid",sUserInfo.UserID),
  18779. new OracleParameter(":updateuserid",sUserInfo.UserID),
  18780. };
  18781. #endregion
  18782. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  18783. // 保存失败
  18784. if (result != Constant.INT_IS_ONE)
  18785. {
  18786. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  18787. }
  18788. }
  18789. }
  18790. #endregion
  18791. return null;
  18792. }
  18793. /// <summary>
  18794. /// 添加责任工序
  18795. /// </summary>
  18796. /// <param name="oracleTrConn">连接对象</param>
  18797. /// <param name="responProce">责任工序</param>
  18798. /// <param name="productionDefect">缺陷数据</param>
  18799. /// <param name="sUserInfo">用户基本信息</param>
  18800. /// <returns>string</returns>
  18801. private static string AddSemiCheckResponProcedure(IDBTransaction oracleTrConn, ResponProcedureEntity responProce, SemiCheckDefectEntity productionDefect, SUserInfo sUserInfo)
  18802. {
  18803. OracleParameter[] oracleParameters = null;
  18804. string sql = null;
  18805. int result = 0;
  18806. // 查询新插入ID
  18807. if (responProce.ProcedureID != null)
  18808. {
  18809. sql = "select SEQ_PM_ResponProcedure_ID.nextval from dual";
  18810. string idStr = oracleTrConn.GetSqlResultToStr(sql);
  18811. if (!string.IsNullOrEmpty(idStr))
  18812. {
  18813. responProce.ResponProcedureID = int.Parse(idStr);
  18814. }
  18815. else
  18816. {
  18817. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  18818. }
  18819. #region SQL
  18820. sql = "insert into tp_pm_responprocedure"
  18821. + " (ResponProcedureID,"
  18822. + " scrapproductid,"
  18823. + " barcode,"
  18824. + " productiondataid,"
  18825. + " productionlineid,"
  18826. + " productionlinecode,"
  18827. + " productionlinename,"
  18828. + " procedureid,"
  18829. + " procedurecode,"
  18830. + " procedurename,"
  18831. + " userid,"
  18832. + " usercode,"
  18833. + " username,"
  18834. + " remarks,"
  18835. + " accountid,"
  18836. + " createuserid,"
  18837. + " updateuserid)"
  18838. + " values"
  18839. + " ("
  18840. + " :ResponProcedureID,"
  18841. + " :scrapproductid,"
  18842. + " :barcode,"
  18843. + " :productiondataid,"
  18844. + " :productionlineid,"
  18845. + " :productionlinecode,"
  18846. + " :productionlinename,"
  18847. + " :procedureid,"
  18848. + " :procedurecode,"
  18849. + " :procedurename,"
  18850. + " :userid,"
  18851. + " :usercode,"
  18852. + " :username,"
  18853. + " :remarks,"
  18854. + " :accountid,"
  18855. + " :createuserid,"
  18856. + " :updateuserid)";
  18857. #endregion
  18858. #region 参数
  18859. oracleParameters = new OracleParameter[] {
  18860. new OracleParameter(":ResponProcedureID",responProce.ResponProcedureID),
  18861. new OracleParameter(":scrapproductid",responProce.ScrapProductID),
  18862. new OracleParameter(":barcode",responProce.BarCode),
  18863. new OracleParameter(":productiondataid",responProce.ProductionDataID),
  18864. new OracleParameter(":productionlineid",responProce.ProductionLineID),
  18865. new OracleParameter(":productionlinecode",responProce.ProductionLineCode),
  18866. new OracleParameter(":productionlinename",responProce.ProductionLineName),
  18867. new OracleParameter(":procedureid",responProce.ProcedureID),
  18868. new OracleParameter(":procedurecode",responProce.ProcedureCode),
  18869. new OracleParameter(":procedurename",responProce.ProcedureName),
  18870. new OracleParameter(":userid",responProce.UserID),
  18871. new OracleParameter(":usercode",responProce.UserCode),
  18872. new OracleParameter(":username",responProce.UserName),
  18873. new OracleParameter(":remarks",responProce.Remarks),
  18874. new OracleParameter(":accountid",sUserInfo.AccountID),
  18875. new OracleParameter(":createuserid",sUserInfo.UserID),
  18876. new OracleParameter(":updateuserid",sUserInfo.UserID),
  18877. };
  18878. #endregion
  18879. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  18880. // 保存失败
  18881. if (result != Constant.INT_IS_ONE)
  18882. {
  18883. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  18884. }
  18885. //// 查询新插入ID
  18886. //sql = "select SEQ_PM_ResponProcedure_ID.Currval from dual";
  18887. //string idStr = oracleTrConn.GetSqlResultToStr(sql);
  18888. //if (!string.IsNullOrEmpty(idStr))
  18889. //{
  18890. // responProce.ResponProcedureID = int.Parse(idStr);
  18891. //}
  18892. //else
  18893. //{
  18894. // return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  18895. //}
  18896. }
  18897. #region 插入责任人
  18898. foreach (SemiCheckResponsibleEntity defectResponsible in productionDefect.DefectResponsibles)
  18899. {
  18900. #region SQL
  18901. sql = "insert into tp_pm_scrapresponsible"
  18902. + " (barcode,"
  18903. + " scrapproductid,"
  18904. + " staffid,"
  18905. + " userid,"
  18906. + " usercode,"
  18907. + " ujobsid,"
  18908. + " sjobsid,"
  18909. + " staffstatus,"
  18910. + " accountid,"
  18911. + " createuserid,"
  18912. + " updateuserid,"
  18913. + " responprocedureid,"
  18914. + " respontype)"
  18915. + " values"
  18916. + " (:barcode,"
  18917. + " :scrapproductid,"
  18918. + " :staffid,"
  18919. + " :userid,"
  18920. + " :usercode,"
  18921. + " :ujobsid,"
  18922. + " :sjobsid,"
  18923. + " :staffstatus,"
  18924. + " :accountid,"
  18925. + " :createuserid,"
  18926. + " :updateuserid,"
  18927. + " :responprocedureid,"
  18928. + " :respontype)";
  18929. #endregion
  18930. #region 参数
  18931. oracleParameters = new OracleParameter[] {
  18932. new OracleParameter(":scrapproductid",responProce.ScrapProductID),
  18933. new OracleParameter(":barcode",responProce.BarCode),
  18934. new OracleParameter(":staffid",defectResponsible.StaffID),
  18935. new OracleParameter(":userid",defectResponsible.UserID),
  18936. new OracleParameter(":usercode",defectResponsible.UserCode),
  18937. new OracleParameter(":ujobsid",defectResponsible.UJobsID),
  18938. new OracleParameter(":sjobsid",defectResponsible.SJobsID),
  18939. new OracleParameter(":staffstatus",defectResponsible.StaffStatus),
  18940. new OracleParameter(":accountid",sUserInfo.AccountID),
  18941. new OracleParameter(":createuserid",sUserInfo.UserID),
  18942. new OracleParameter(":updateuserid",sUserInfo.UserID),
  18943. new OracleParameter(":responprocedureid",responProce.ResponProcedureID),
  18944. new OracleParameter(":respontype", (responProce.ResponProcedureID == null? (int)Constant.ScrapResponType.Person:(int)Constant.ScrapResponType.Procedure)),
  18945. };
  18946. #endregion
  18947. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  18948. // 保存失败
  18949. if (result != Constant.INT_IS_ONE)
  18950. {
  18951. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  18952. }
  18953. }
  18954. #endregion
  18955. return null;
  18956. }
  18957. #region 复检
  18958. /// <summary>
  18959. /// 复检数据
  18960. /// </summary>
  18961. /// <param name="oracleTrConn">数据连接对象</param>
  18962. /// <param name="entity">半检实体类</param>
  18963. /// <param name="sUserInfo">用户基本信息</param>
  18964. /// <returns>string</returns>
  18965. /// <remarks>
  18966. /// 王鑫 2016.06.28 新建
  18967. /// </remarks>
  18968. private static string AddReSemiCheck(IDBTransaction oracleTrConn,
  18969. SemiCheckEntity entity,
  18970. SUserInfo sUserInfo)
  18971. {
  18972. try
  18973. {
  18974. // 获得账务日期
  18975. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  18976. string errMsg = string.Empty;
  18977. #region 校验条码有效性
  18978. errMsg = CheckBarcodeByEditRework(oracleTrConn, entity.BarCode, sUserInfo);
  18979. if (!string.IsNullOrEmpty(errMsg))
  18980. {
  18981. return errMsg;
  18982. }
  18983. #endregion
  18984. //------------------------------
  18985. #region 条码是不合格 删除在产产品数据
  18986. if (entity.ReSemiCheckType == "2") //编辑时不合格
  18987. {
  18988. #region 修改半检登记的复检状态=2不合格(返)、复检工号=当前工号、复检时间=sysdate。
  18989. string sqlUpdate = @"update TP_PM_SemiCheck set ReSemiCheckType='2' ,ReSemiCheckUserID=:ReSemiCheckUserID,
  18990. ReSemiCheckUserCode=:ReSemiCheckUserCode,ReSemiCheckTime=sysdate,updateuserid=:updateuserid where SemiCheckID=:SemiCheckID";
  18991. OracleParameter[] oracleParameters = new OracleParameter[] {
  18992. new OracleParameter(":ReSemiCheckUserID",sUserInfo.UserID),
  18993. new OracleParameter(":ReSemiCheckUserCode",sUserInfo.UserCode),
  18994. new OracleParameter(":SemiCheckID",entity.SemiCheckID),
  18995. new OracleParameter(":updateuserid",sUserInfo.UserID),
  18996. };
  18997. int result = oracleTrConn.ExecuteNonQuery(sqlUpdate, oracleParameters);
  18998. // 保存失败
  18999. if (result != Constant.INT_IS_ONE)
  19000. {
  19001. errMsg = string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  19002. }
  19003. #endregion
  19004. #region 条码有缺陷
  19005. #region 是次品 添加废弃产品
  19006. string ResponProcedureidStr = "";
  19007. if (entity.ReSemiCheckType == "2") //新建时不合格,直接报损
  19008. {
  19009. #region 添加废弃产品
  19010. ScrapProductEntity scrapProduct = new ScrapProductEntity();
  19011. #region 属性赋值
  19012. scrapProduct.BarCode = entity.BarCode;
  19013. scrapProduct.ScrapType = Constant.ScrapType.Substandard.GetHashCode();
  19014. scrapProduct.ResponType = Constant.ScrapResponType.Procedure.GetHashCode();
  19015. scrapProduct.ScrapDate = accountDate;
  19016. scrapProduct.Rreason = Constant.SCRAPTYPE_NOPASSREWORK;
  19017. scrapProduct.AuditStatus = Constant.AuditStatus.Agree.GetHashCode();
  19018. scrapProduct.Auditor = sUserInfo.UserID;
  19019. scrapProduct.AuditlDate = accountDate;
  19020. scrapProduct.AccountDate = accountDate;
  19021. sqlUpdate = "select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=14 and accountid=" + sUserInfo.AccountID;
  19022. DataSet ds = oracleTrConn.GetSqlResultToDs(sqlUpdate);
  19023. if (ds != null && ds.Tables[0].Rows.Count > 0)
  19024. {
  19025. scrapProduct.GoodsLevelID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelID"]);
  19026. }
  19027. scrapProduct.GoodsLevelTypeID = 14;
  19028. //scrapProduct.GoodsLevelID = entity.GoodsLevelID;
  19029. //scrapProduct.GoodsLevelTypeID = entity.GoodsLevelTypeID;
  19030. scrapProduct.IsPublicBody = IsPubilcByBarCode(oracleTrConn, entity.BarCode);
  19031. // 查询新插入的废弃ID
  19032. string ResponProceduresql = "select SEQ_PM_ScrapProduct_ID.nextval from dual";
  19033. ResponProcedureidStr = oracleTrConn.GetSqlResultToStr(ResponProceduresql);
  19034. scrapProduct.ScrapProductID = Convert.ToInt32(ResponProcedureidStr);
  19035. scrapProduct.ScrapType = 3;
  19036. #endregion
  19037. // 保存报废
  19038. errMsg = AddScrapProduct(oracleTrConn, scrapProduct, sUserInfo);
  19039. // 保存失败
  19040. if (!string.IsNullOrEmpty(errMsg))
  19041. {
  19042. return errMsg;
  19043. }
  19044. #endregion
  19045. }
  19046. #endregion
  19047. // 存在缺陷 插入缺陷表
  19048. if (entity.SemiCheckDefects != null)
  19049. {
  19050. foreach (SemiCheckDefectEntity semiCheckDefect in entity.SemiCheckDefects)
  19051. {
  19052. #region 保存缺陷
  19053. //semiCheckDefect.SemiCheckID = Convert.ToInt32(semiCheckDefect.SemiCheckID);
  19054. //semiCheckDefect.ScrapResponFlag
  19055. // = string.IsNullOrEmpty(semiCheckDefect.ScrapResponFlag) ? "0" : semiCheckDefect.ScrapResponFlag;
  19056. //// 保存缺陷
  19057. //errMsg = AddSemiCheckDefect(oracleTrConn, semiCheckDefect, sUserInfo);
  19058. //if (!string.IsNullOrEmpty(errMsg))
  19059. //{
  19060. // return errMsg;
  19061. //}
  19062. #endregion
  19063. #region 是不合格 添加废弃责任工序
  19064. if (entity.ReSemiCheckType == "2")
  19065. {
  19066. //if (semiCheckDefect.DefectProcedureID != null)
  19067. {
  19068. #region 添加责任工序
  19069. ResponProcedureEntity responProce = new ResponProcedureEntity();
  19070. #region 属性赋值
  19071. responProce.BarCode = entity.BarCode;
  19072. // 新建-不合格 获取生产线及生产数据ID
  19073. sqlUpdate = "select ProductionLineID,ProductionLineCode,ProductionLineName,ProductionDataID from TP_PM_InProduction where barcode=:barcode";
  19074. oracleParameters = new OracleParameter[] {
  19075. new OracleParameter(":barcode",entity.BarCode),
  19076. };
  19077. DataSet ds = oracleTrConn.GetSqlResultToDs(sqlUpdate, oracleParameters);
  19078. if (ds != null && ds.Tables[0].Rows.Count > 0)
  19079. {
  19080. responProce.ProductionDataID = Convert.ToInt32(ds.Tables[0].Rows[0]["ProductionDataID"]);
  19081. responProce.ProductionLineID = Convert.ToInt32(ds.Tables[0].Rows[0]["ProductionLineID"]);
  19082. responProce.ProductionLineCode = ds.Tables[0].Rows[0]["ProductionLineCode"].ToString();
  19083. responProce.ProductionLineName = ds.Tables[0].Rows[0]["ProductionLineName"].ToString();
  19084. }
  19085. //responProce.ProductionDataID = semiCheckDefect.ProductionDataID;
  19086. //responProce.ProductionLineID = semiCheckDefect.ProductionLineID;
  19087. //responProce.ProductionLineCode = semiCheckDefect.ProductionLineCode;
  19088. //responProce.ProductionLineName = semiCheckDefect.ProductionLineName;
  19089. responProce.ProcedureID = semiCheckDefect.DefectProcedureID;
  19090. responProce.ProcedureCode = semiCheckDefect.DefectProcedureCode;
  19091. responProce.ProcedureName = semiCheckDefect.DefectProcedureName;
  19092. responProce.UserID = semiCheckDefect.DefectUserID;
  19093. responProce.UserCode = semiCheckDefect.DefectUserCode;
  19094. responProce.UserName = semiCheckDefect.DefectUserName;
  19095. responProce.Remarks = semiCheckDefect.Remarks;
  19096. responProce.ScrapProductID = Convert.ToInt32(ResponProcedureidStr);
  19097. #endregion
  19098. // 保存责任工序
  19099. errMsg = AddSemiCheckResponProcedure(oracleTrConn, responProce, semiCheckDefect, sUserInfo);
  19100. // 保存失败
  19101. if (!string.IsNullOrEmpty(errMsg))
  19102. {
  19103. return errMsg;
  19104. }
  19105. #endregion
  19106. }
  19107. }
  19108. #endregion
  19109. }
  19110. }
  19111. #endregion
  19112. // 1.在产表产品设置产品等级【14不合格返】。
  19113. string sql = @"update TP_PM_InProduction set GoodsLevelID=
  19114. (
  19115. select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=14 and accountid=:accountid
  19116. ),GoodsLevelTypeID=14,updateuserid=:updateuserid
  19117. where barcode=:barcode";
  19118. oracleParameters = new OracleParameter[] {
  19119. new OracleParameter(":accountid", sUserInfo.AccountID),
  19120. // new OracleParameter(":updateuserid",scrapProduct.GoodsLevelTypeID),
  19121. new OracleParameter(":barcode",entity.BarCode),
  19122. new OracleParameter(":updateuserid",sUserInfo.UserID),
  19123. };
  19124. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  19125. // 注浆明细 产品等级
  19126. sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=14,updateuserid=:updateuserid
  19127. where barcode=:barcode";
  19128. oracleParameters = new OracleParameter[] {
  19129. new OracleParameter(":accountid", sUserInfo.AccountID),
  19130. new OracleParameter(":barcode",entity.BarCode),
  19131. new OracleParameter(":updateuserid",sUserInfo.UserID),
  19132. };
  19133. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  19134. // 2.将在产数据保存到在产回收站表中(产品等级【14不合格返】)。
  19135. string sqlInsert = @"insert into TP_PM_InProductionTrash
  19136. (
  19137. BarCode,
  19138. ProductionLineID,
  19139. ProductionLineCode,
  19140. ProductionLineName,
  19141. ProcedureModel,
  19142. ModelType,
  19143. DefectFlag,
  19144. ReworkProcedureID,
  19145. IsPublicBody,
  19146. IsReFire,
  19147. GoodsLevelID,
  19148. GoodsLevelTypeID,
  19149. GoodsID,
  19150. GoodsCode,
  19151. GoodsName,
  19152. UserID,
  19153. GroutingDailyID,
  19154. GroutingDailyDetailID,
  19155. GroutingDate,
  19156. GroutingLineID,
  19157. GroutingLineCode,
  19158. GroutingLineName,
  19159. GMouldTypeID,
  19160. CanManyTimes,
  19161. GroutingLineDetailID,
  19162. GroutingMouldCode,
  19163. MouldCode,
  19164. GroutingUserID,
  19165. GroutingUserCode,
  19166. GroutingNum,
  19167. Remarks,
  19168. KilnID,
  19169. KilnCode,
  19170. KilnName,
  19171. KilnCarID,
  19172. KilnCarCode,
  19173. KilnCarName,
  19174. KilnCarBatchNo,
  19175. KilnCarPosition,
  19176. AccountID,
  19177. ValueFlag,
  19178. CreateUserID,
  19179. UpdateUserID,
  19180. SpecialRepairflag,
  19181. FlowProcedureID,
  19182. FlowProcedureTime,
  19183. ProcedureID,
  19184. ProcedureTime,
  19185. ProductionDataID,
  19186. logoid,ISREWORKFLAG,
  19187. SemiCheckID
  19188. )
  19189. select
  19190. BarCode,
  19191. ProductionLineID,
  19192. ProductionLineCode,
  19193. ProductionLineName,
  19194. ProcedureModel,
  19195. ModelType,
  19196. DefectFlag,
  19197. ReworkProcedureID,
  19198. IsPublicBody,
  19199. IsReFire,
  19200. --GoodsLevelID,
  19201. --GoodsLevelTypeID,
  19202. (
  19203. select GoodsLevelID from tp_mst_goodslevel where GoodsLevelTypeID=14 and accountid=:accountid
  19204. ),14,
  19205. GoodsID,
  19206. GoodsCode,
  19207. GoodsName,
  19208. UserID,
  19209. GroutingDailyID,
  19210. GroutingDailyDetailID,
  19211. GroutingDate,
  19212. GroutingLineID,
  19213. GroutingLineCode,
  19214. GroutingLineName,
  19215. GMouldTypeID,
  19216. CanManyTimes,
  19217. GroutingLineDetailID,
  19218. GroutingMouldCode,
  19219. MouldCode,
  19220. GroutingUserID,
  19221. GroutingUserCode,
  19222. GroutingNum,
  19223. Remarks,
  19224. KilnID,
  19225. KilnCode,
  19226. KilnName,
  19227. KilnCarID,
  19228. KilnCarCode,
  19229. KilnCarName,
  19230. KilnCarBatchNo,
  19231. KilnCarPosition,
  19232. AccountID,
  19233. ValueFlag,
  19234. :CreateUserID,
  19235. :UpdateUserID,
  19236. SpecialRepairflag,
  19237. FlowProcedureID,
  19238. FlowProcedureTime,
  19239. FlowProcedureID,
  19240. ProcedureTime,
  19241. ProductionDataID,
  19242. logoid,ISREWORKFLAG,
  19243. SemiCheckID
  19244. from TP_PM_InProduction
  19245. where barcode=:barcode
  19246. ";
  19247. oracleParameters = new OracleParameter[] {
  19248. new OracleParameter(":barcode",entity.BarCode),
  19249. new OracleParameter(":CreateUserID",sUserInfo.UserID),
  19250. new OracleParameter(":UpdateUserID",sUserInfo.UserID),
  19251. new OracleParameter(":accountid", sUserInfo.AccountID),
  19252. };
  19253. result += oracleTrConn.ExecuteNonQuery(sqlInsert, oracleParameters);
  19254. // 删除在产数据
  19255. sql = "delete tp_pm_inproduction where barcode = :barcode";
  19256. oracleParameters = new OracleParameter[] {
  19257. new OracleParameter(":barcode",entity.BarCode),
  19258. };
  19259. result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  19260. }
  19261. else if (entity.ReSemiCheckType == "1") //正常
  19262. {
  19263. #region 修改半检登记的复检状态=1合格(返)、复检工号=当前工号、复检时间=sysdate。
  19264. string sqlUpdate = @"update TP_PM_SemiCheck set ReSemiCheckType='1' ,ReSemiCheckUserID=:ReSemiCheckUserID,
  19265. ReSemiCheckUserCode=:ReSemiCheckUserCode,ReSemiCheckTime=sysdate,updateuserid=:updateuserid where SemiCheckID=:SemiCheckID";
  19266. OracleParameter[] oracleParameters = new OracleParameter[] {
  19267. new OracleParameter(":ReSemiCheckUserID",sUserInfo.UserID),
  19268. new OracleParameter(":ReSemiCheckUserCode",sUserInfo.UserCode),
  19269. new OracleParameter(":SemiCheckID",entity.SemiCheckID),
  19270. new OracleParameter(":updateuserid",sUserInfo.UserID),
  19271. };
  19272. int result = oracleTrConn.ExecuteNonQuery(sqlUpdate, oracleParameters);
  19273. // 保存失败
  19274. if (result != Constant.INT_IS_ONE)
  19275. {
  19276. errMsg = string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  19277. }
  19278. #endregion
  19279. #region 3.修改在产产品数据,在产表产品设置非返工状态(IsReworkFlag = '0'),半检登记ID=null(半检登记ID不变)。
  19280. string sql = "update tp_pm_inproduction set GoodsLevelTypeID=1, IsReworkFlag='0',UpdateUserID=:UpdateUserID where barcode = :barcode";
  19281. oracleParameters = new OracleParameter[] {
  19282. new OracleParameter(":barcode",entity.BarCode),
  19283. new OracleParameter(":UpdateUserID",sUserInfo.UserID),
  19284. };
  19285. result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  19286. // 注浆明细 产品等级
  19287. sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=1,updateuserid=:updateuserid
  19288. where barcode=:barcode";
  19289. oracleParameters = new OracleParameter[] {
  19290. new OracleParameter(":accountid", sUserInfo.AccountID),
  19291. new OracleParameter(":barcode",entity.BarCode),
  19292. new OracleParameter(":updateuserid",sUserInfo.UserID),
  19293. };
  19294. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  19295. #endregion
  19296. }
  19297. #endregion
  19298. //------------------------------
  19299. return errMsg;
  19300. }
  19301. catch (Exception ex)
  19302. {
  19303. throw ex;
  19304. }
  19305. }
  19306. #endregion
  19307. #region 撤销复检
  19308. /// <summary>
  19309. /// 撤销复检数据
  19310. /// </summary>
  19311. /// <param name="oracleTrConn">数据连接对象</param>
  19312. /// <param name="entity">半检实体类</param>
  19313. /// <param name="sUserInfo">用户基本信息</param>
  19314. /// <returns>string</returns>
  19315. /// <remarks>
  19316. /// 王鑫 2016.06.28 新建
  19317. /// </remarks>
  19318. private static string AddCancelSemiCheck(IDBTransaction oracleTrConn,
  19319. SemiCheckEntity entity,
  19320. SUserInfo sUserInfo)
  19321. {
  19322. try
  19323. {
  19324. // 获得账务日期
  19325. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  19326. string errMsg = string.Empty;
  19327. string sql = null;
  19328. #region 校验条码有效性
  19329. if (entity.ReSemiCheckType == "1") //撤销合格
  19330. {
  19331. errMsg = CheckBarcodeByCancelReSemiCheckPass(oracleTrConn, entity.BarCode, sUserInfo);
  19332. }
  19333. else if (entity.ReSemiCheckType == "2") //撤销不合格
  19334. {
  19335. errMsg = CheckBarcodeByCancelReSemiCheckNoPass(oracleTrConn, entity.BarCode, sUserInfo);
  19336. }
  19337. if (!string.IsNullOrEmpty(errMsg))
  19338. {
  19339. return errMsg;
  19340. }
  19341. #endregion
  19342. if (entity.ReSemiCheckType == "1") //撤销合格
  19343. {
  19344. #region 在产表产品设置返工状态(IsReworkFlag = '1')。
  19345. sql = "update tp_pm_inproduction set GoodsLevelTypeID=2, IsReworkFlag='1',UpdateUserID=:UpdateUserID where barcode = :barcode";
  19346. OracleParameter[] oracleParameters = new OracleParameter[] {
  19347. new OracleParameter(":barcode",entity.BarCode),
  19348. new OracleParameter(":UpdateUserID",sUserInfo.UserID),
  19349. };
  19350. int result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  19351. // 注浆明细 产品等级
  19352. sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=2,updateuserid=:updateuserid
  19353. where barcode=:barcode";
  19354. oracleParameters = new OracleParameter[] {
  19355. new OracleParameter(":accountid", sUserInfo.AccountID),
  19356. new OracleParameter(":barcode",entity.BarCode),
  19357. new OracleParameter(":updateuserid",sUserInfo.UserID),
  19358. };
  19359. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  19360. #endregion
  19361. #region .半检登记的复检状态=0未复检,复检工号=null,复检时间=null。
  19362. // 复检撤销不需要记录撤销标识 - chenxy
  19363. string sqlUpdate = @"update TP_PM_SemiCheck set ReSemiCheckType='0' ,ReSemiCheckUserID=null,
  19364. ReSemiCheckUserCode=null,ReSemiCheckTime=null,updateuserid=:updateuserid
  19365. --,BackOutFlag=1,BackOutTime=sysdate,BackOutUserID=:BackOutUserID,BackOutUserCode=:BackOutUserCode
  19366. where SemiCheckID=:SemiCheckID";
  19367. oracleParameters = new OracleParameter[] {
  19368. new OracleParameter(":SemiCheckID",entity.SemiCheckID),
  19369. new OracleParameter(":updateuserid",sUserInfo.UserID),
  19370. //new OracleParameter(":BackOutUserID",sUserInfo.UserID),
  19371. //new OracleParameter(":BackOutUserCode",sUserInfo.UserCode),
  19372. };
  19373. result = oracleTrConn.ExecuteNonQuery(sqlUpdate, oracleParameters);
  19374. // 保存失败
  19375. if (result != Constant.INT_IS_ONE)
  19376. {
  19377. errMsg = string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  19378. }
  19379. #endregion
  19380. }
  19381. else if (entity.ReSemiCheckType == "2") //撤销不合格
  19382. {
  19383. #region 从在产回收站中把数据恢复到在产表中。
  19384. string sqlInsert = @"insert into TP_PM_InProduction
  19385. (
  19386. BarCode,
  19387. ProductionLineID,
  19388. ProductionLineCode,
  19389. ProductionLineName,
  19390. ProcedureModel,
  19391. ModelType,
  19392. DefectFlag,
  19393. ReworkProcedureID,
  19394. IsPublicBody,
  19395. IsReFire,
  19396. GoodsLevelID,
  19397. GoodsLevelTypeID,
  19398. GoodsID,
  19399. GoodsCode,
  19400. GoodsName,
  19401. UserID,
  19402. GroutingDailyID,
  19403. GroutingDailyDetailID,
  19404. GroutingDate,
  19405. GroutingLineID,
  19406. GroutingLineCode,
  19407. GroutingLineName,
  19408. GMouldTypeID,
  19409. CanManyTimes,
  19410. GroutingLineDetailID,
  19411. GroutingMouldCode,
  19412. MouldCode,
  19413. GroutingUserID,
  19414. GroutingUserCode,
  19415. GroutingNum,
  19416. Remarks,
  19417. KilnID,
  19418. KilnCode,
  19419. KilnName,
  19420. KilnCarID,
  19421. KilnCarCode,
  19422. KilnCarName,
  19423. KilnCarBatchNo,
  19424. KilnCarPosition,
  19425. AccountID,
  19426. ValueFlag,
  19427. CreateUserID,
  19428. UpdateUserID,
  19429. SpecialRepairflag,
  19430. FlowProcedureID,
  19431. FlowProcedureTime,
  19432. ProcedureID,
  19433. ProcedureTime,
  19434. ProductionDataID,
  19435. logoid,ISREWORKFLAG,
  19436. SemiCheckID
  19437. )
  19438. select
  19439. BarCode,
  19440. ProductionLineID,
  19441. ProductionLineCode,
  19442. ProductionLineName,
  19443. ProcedureModel,
  19444. ModelType,
  19445. DefectFlag,
  19446. ReworkProcedureID,
  19447. IsPublicBody,
  19448. IsReFire,
  19449. GoodsLevelID,
  19450. GoodsLevelTypeID,
  19451. GoodsID,
  19452. GoodsCode,
  19453. GoodsName,
  19454. UserID,
  19455. GroutingDailyID,
  19456. GroutingDailyDetailID,
  19457. GroutingDate,
  19458. GroutingLineID,
  19459. GroutingLineCode,
  19460. GroutingLineName,
  19461. GMouldTypeID,
  19462. CanManyTimes,
  19463. GroutingLineDetailID,
  19464. GroutingMouldCode,
  19465. MouldCode,
  19466. GroutingUserID,
  19467. GroutingUserCode,
  19468. GroutingNum,
  19469. Remarks,
  19470. KilnID,
  19471. KilnCode,
  19472. KilnName,
  19473. KilnCarID,
  19474. KilnCarCode,
  19475. KilnCarName,
  19476. KilnCarBatchNo,
  19477. KilnCarPosition,
  19478. AccountID,
  19479. ValueFlag,
  19480. :CreateUserID,
  19481. :UpdateUserID,
  19482. SpecialRepairflag,
  19483. FlowProcedureID,
  19484. FlowProcedureTime,
  19485. FlowProcedureID,
  19486. ProcedureTime,
  19487. ProductionDataID,
  19488. logoid,ISREWORKFLAG,
  19489. SemiCheckID
  19490. from TP_PM_InProductionTrash
  19491. where barcode=:barcode
  19492. ";
  19493. OracleParameter[] oracleParameters = new OracleParameter[] {
  19494. new OracleParameter(":barcode",entity.BarCode),
  19495. new OracleParameter(":CreateUserID",sUserInfo.UserID),
  19496. new OracleParameter(":UpdateUserID",sUserInfo.UserID),
  19497. };
  19498. int result = oracleTrConn.ExecuteNonQuery(sqlInsert, oracleParameters);
  19499. #endregion
  19500. #region 1.废弃产品表中对应的总单数据和明细数据valueflag='0'。
  19501. OracleParameter[] spParameters = null;
  19502. int spResult = 0;
  19503. string sqlString = "select max(sp.scrapproductid) scrapproductid\n" +
  19504. " from TP_PM_ScrapProduct sp\n" +
  19505. " where sp.barcode = :barcode\n" +
  19506. " and sp.auditstatus = 1\n" +
  19507. " and sp.valueflag = '1'\n" +
  19508. " and sp.scraptype = '3'";
  19509. spParameters = new OracleParameter[] {
  19510. new OracleParameter(":barcode",entity.BarCode),
  19511. };
  19512. string scrapproductid = oracleTrConn.GetSqlResultToStr(sqlString, spParameters);
  19513. sqlString = @"update TP_PM_ScrapProduct set valueflag='0', updateuserid=:updateuserid, backouttime=sysdate where scrapproductid=:scrapproductid";
  19514. spParameters = new OracleParameter[] {
  19515. new OracleParameter(":updateuserid",sUserInfo.UserID),
  19516. new OracleParameter(":scrapproductid",scrapproductid),
  19517. };
  19518. spResult = oracleTrConn.ExecuteNonQuery(sqlString, spParameters);
  19519. sqlString = @"update TP_PM_ResponProcedure set valueflag='0', updateuserid=:updateuserid where scrapproductid=:scrapproductid";
  19520. //oracleParameters = new OracleParameter[] {
  19521. // new OracleParameter(":barcode",entity.BarCode),
  19522. //};
  19523. spResult += oracleTrConn.ExecuteNonQuery(sqlString, spParameters);
  19524. //string sql = @"update TP_PM_ScrapProduct set valueflag='0' where barcode=:barcode";
  19525. //oracleParameters = new OracleParameter[] {
  19526. // new OracleParameter(":barcode",entity.BarCode),
  19527. // };
  19528. //result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  19529. //sql = @"update TP_PM_ResponProcedure set valueflag='0' where barcode=:barcode";
  19530. //oracleParameters = new OracleParameter[] {
  19531. // new OracleParameter(":barcode",entity.BarCode),
  19532. // };
  19533. //result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  19534. ////sql = @"update TP_PM_ScrapResponsible set valueflag='0' where barcode=:barcode";
  19535. ////oracleParameters = new OracleParameter[] {
  19536. //// new OracleParameter(":barcode",entity.BarCode),
  19537. //// };
  19538. ////result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  19539. #endregion
  19540. #region 删除在产回收站数据
  19541. sql = "delete TP_PM_InProductionTrash where barcode = :barcode";
  19542. oracleParameters = new OracleParameter[] {
  19543. new OracleParameter(":barcode",entity.BarCode),
  19544. };
  19545. result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  19546. #endregion
  19547. #region .在产表产品设置返工状态(IsReworkFlag = '1')。
  19548. sql = "update tp_pm_inproduction set GoodsLevelTypeID=2,IsReworkFlag='1',UpdateUserID=:UpdateUserID where barcode = :barcode";
  19549. oracleParameters = new OracleParameter[] {
  19550. new OracleParameter(":barcode",entity.BarCode),
  19551. new OracleParameter(":UpdateUserID",sUserInfo.UserID),
  19552. };
  19553. result += oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  19554. // 注浆明细 产品等级
  19555. sql = @"update tp_pm_groutingdailydetail set GoodsLevelTypeID=2,updateuserid=:updateuserid
  19556. where barcode=:barcode";
  19557. oracleParameters = new OracleParameter[] {
  19558. new OracleParameter(":accountid", sUserInfo.AccountID),
  19559. new OracleParameter(":barcode",entity.BarCode),
  19560. new OracleParameter(":updateuserid",sUserInfo.UserID),
  19561. };
  19562. result = oracleTrConn.ExecuteNonQuery(sql, oracleParameters);
  19563. #endregion
  19564. #region 6.半检登记的复检状态=0未复检,复检工号=null,复检时间=null。
  19565. // 复检撤销不需要记录撤销标识 - chenxy
  19566. string sqlUpdate = @"update TP_PM_SemiCheck set ReSemiCheckType='0' ,ReSemiCheckUserID=null,
  19567. ReSemiCheckUserCode=null,ReSemiCheckTime=null,updateuserid=:updateuserid
  19568. --,BackOutFlag=1,BackOutTime=sysdate,BackOutUserID=:BackOutUserID,BackOutUserCode=:BackOutUserCode
  19569. where SemiCheckID=:SemiCheckID";
  19570. oracleParameters = new OracleParameter[] {
  19571. //new OracleParameter(":ReSemiCheckUserID",entity.ReSemiCheckUserID),
  19572. //new OracleParameter(":ReSemiCheckUserCode",entity.ReSemiCheckUserCode),
  19573. new OracleParameter(":SemiCheckID",entity.SemiCheckID),
  19574. new OracleParameter(":updateuserid",sUserInfo.UserID),
  19575. //new OracleParameter(":BackOutUserID",sUserInfo.UserID),
  19576. //new OracleParameter(":BackOutUserCode",sUserInfo.UserCode),
  19577. };
  19578. result = oracleTrConn.ExecuteNonQuery(sqlUpdate, oracleParameters);
  19579. // 保存失败
  19580. if (result != Constant.INT_IS_ONE)
  19581. {
  19582. errMsg = string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  19583. }
  19584. #endregion
  19585. }
  19586. return errMsg;
  19587. }
  19588. catch (Exception ex)
  19589. {
  19590. throw ex;
  19591. }
  19592. }
  19593. #endregion
  19594. /// <summary>
  19595. /// 校验条码有效(撤销复检-不合格)
  19596. /// </summary>
  19597. /// <param name="oracleTrConn">连接对象</param>
  19598. /// <param name="barcode">条码</param>
  19599. /// <param name="sUserInfo">登录用户信息</param>
  19600. /// <returns>string</returns>
  19601. /// <remarks>
  19602. /// 王鑫 2016.06.28 新建
  19603. /// </remarks>
  19604. private static string CheckBarcodeByCancelReSemiCheckNoPass(IDBTransaction oracleTrConn,
  19605. string barcode,
  19606. SUserInfo sUserInfo
  19607. )
  19608. {
  19609. try
  19610. {
  19611. OracleParameter[] paras = new OracleParameter[]{
  19612. new OracleParameter(":barcode",OracleDbType.Varchar2,barcode,ParameterDirection.Input),
  19613. };
  19614. string sql = @"
  19615. select 1 from TP_PM_InProductionTrash where barcode=:barcode and GoodsLevelTypeID=14 and SemiCheckID is not null
  19616. ";
  19617. DataSet dsResult = oracleTrConn.GetSqlResultToDs(sql, paras);
  19618. if (dsResult != null && dsResult.Tables[0].Rows.Count == 0)
  19619. {
  19620. return "条码[" + barcode + "]不在在产回收站中";
  19621. }
  19622. return null;
  19623. }
  19624. catch (Exception ex)
  19625. {
  19626. throw ex;
  19627. }
  19628. }
  19629. /// <summary>
  19630. /// 校验条码有效(撤销复检-合格)
  19631. /// </summary>
  19632. /// <param name="oracleTrConn">连接对象</param>
  19633. /// <param name="barcode">条码</param>
  19634. /// <param name="sUserInfo">登录用户信息</param>
  19635. /// <returns>string</returns>
  19636. /// <remarks>
  19637. /// 王鑫 2016.06.28 新建
  19638. /// </remarks>
  19639. private static string CheckBarcodeByCancelReSemiCheckPass(IDBTransaction oracleTrConn,
  19640. string barcode,
  19641. SUserInfo sUserInfo
  19642. )
  19643. {
  19644. try
  19645. {
  19646. OracleParameter[] paras = new OracleParameter[]{
  19647. new OracleParameter(":barcode",OracleDbType.Varchar2,barcode,ParameterDirection.Input),
  19648. };
  19649. string sql = @"
  19650. select InScrapFlag,
  19651. KilnCarID,
  19652. KilnCarName,
  19653. IsReworkFlag,
  19654. SemiCheckID from TP_PM_InProduction where barcode=:barcode
  19655. ";
  19656. DataSet dsResult = oracleTrConn.GetSqlResultToDs(sql, paras);
  19657. if (dsResult != null && dsResult.Tables[0].Rows.Count > 0)
  19658. {
  19659. if (dsResult.Tables[0].Rows[0]["InScrapFlag"].ToString() == "1")
  19660. {
  19661. return "条码[" + barcode + "]已经报损待审批";
  19662. }
  19663. if (!string.IsNullOrEmpty(dsResult.Tables[0].Rows[0]["KilnCarID"].ToString()))
  19664. {
  19665. return "条码[" + barcode + "]已经在窑车[" + dsResult.Tables[0].Rows[0]["KilnCarName"].ToString() + "]";
  19666. }
  19667. // chenxy 2019-10-02 半检返修 IsReworkFlag=2
  19668. if (dsResult.Tables[0].Rows[0]["IsReworkFlag"].ToString() == "1")
  19669. {
  19670. return "条码[" + barcode + "]是半检返工状态";
  19671. }
  19672. if (dsResult.Tables[0].Rows[0]["IsReworkFlag"].ToString() == "2")
  19673. {
  19674. return "条码[" + barcode + "]是半检返修状态";
  19675. }
  19676. if (string.IsNullOrEmpty(dsResult.Tables[0].Rows[0]["SemiCheckID"].ToString()))
  19677. {
  19678. return "条码[" + barcode + "]已经做过其他操作,不能撤销";
  19679. }
  19680. }
  19681. else
  19682. {
  19683. return "条码[" + barcode + "]不在在产流程";
  19684. }
  19685. return null;
  19686. }
  19687. catch (Exception ex)
  19688. {
  19689. throw ex;
  19690. }
  19691. }
  19692. #region 生产订单 wangx 2017-2-7
  19693. /// <summary>
  19694. /// 保存订单
  19695. /// </summary>
  19696. /// <param name="order"></param>
  19697. /// <param name="sUserInfo"></param>
  19698. /// <returns></returns>
  19699. public static ServiceResultEntity SaveOrder(OrderEntity order, SUserInfo sUserInfo)
  19700. {
  19701. ServiceResultEntity entity = new ServiceResultEntity();
  19702. int returnRows = 0;
  19703. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  19704. try
  19705. {
  19706. string sql = string.Empty;
  19707. OracleParameter[] Paras = null;
  19708. DataSet ds = null;
  19709. #region 查询订单号是否有重复
  19710. sql = "select OrderID from TP_PM_Order where OrderNo=:OrderNo and AccountID=:AccountID";
  19711. Paras = new OracleParameter[] {
  19712. new OracleParameter(":OrderNo",OracleDbType.Varchar2,
  19713. order.OrderNo,ParameterDirection.Input),
  19714. new OracleParameter(":AccountID",OracleDbType.Int32,
  19715. sUserInfo.AccountID,ParameterDirection.Input)
  19716. };
  19717. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  19718. if (ds != null && ds.Tables[0].Rows.Count > 0)
  19719. {
  19720. if (order.OrderID == 0 || (order.OrderID != Convert.ToInt32(ds.Tables[0].Rows[0]["OrderID"])))
  19721. {
  19722. //重复订单号
  19723. returnRows = -1;
  19724. oracleTrConn.Rollback();
  19725. oracleTrConn.Disconnect();
  19726. entity.Result = returnRows;
  19727. entity.Message = "系统存在相同的生产订单号!";
  19728. return entity;
  19729. }
  19730. }
  19731. #endregion
  19732. #region 调用SAP接口
  19733. string EV_MATNR = string.Empty;
  19734. string EV_WERKS = string.Empty;
  19735. string EV_MAKTX = string.Empty;
  19736. decimal EV_KWMENG = 0;
  19737. if (!string.IsNullOrEmpty(order.VBELN) && !string.IsNullOrEmpty(order.POSNR))
  19738. {
  19739. // 调用SAP接口,获取工厂号和物料号
  19740. string postString = "{\"IV_VBELN\":\"" + order.VBELN + "\",\"IV_POSNR\":\"" + order.POSNR.PadLeft(6, '0') + "\"}";
  19741. // 配置文件
  19742. INIUtility ini = INIUtility.Instance(INIUtility.IniFile.SAP_HEGII);
  19743. string Url138 = ini.ReadIniData("SAP_NEW_INFO", "Url138");
  19744. // 测试
  19745. // string Url138 = "http://hgs4podev.hegii.com:50200/RESTAdapter/DKMES/ZSDFM138";
  19746. // 正式
  19747. //string Url138 = "http://hgs4podev.hegii.com:8000/RESTAdapter/DKMES/ZSDFM138";
  19748. string result = string.Empty;
  19749. string ZTYPE = string.Empty;
  19750. string ZMSG = string.Empty;
  19751. try
  19752. {
  19753. result = PostData(Url138, postString, "POST");
  19754. ZTYPE = JObject.Parse(result)["ZTYPE"].ToString();
  19755. EV_MATNR = JObject.Parse(result)["EV_MATNR"].ToString();
  19756. EV_WERKS = JObject.Parse(result)["EV_WERKS"].ToString();
  19757. EV_MAKTX = JObject.Parse(result)["EV_MAKTX"].ToString();
  19758. decimal.TryParse(JObject.Parse(result)["EV_KWMENG"].ToString(), out EV_KWMENG);
  19759. }
  19760. catch (Exception ex)
  19761. {
  19762. entity.Result = -1;
  19763. entity.Message = "ZSDFM138接口获取失败," + ex.Message;
  19764. return entity;
  19765. }
  19766. if ("E".Equals("ZTYPE"))
  19767. {
  19768. entity.Result = -1;
  19769. entity.Message = ZMSG;
  19770. return entity;
  19771. }
  19772. if (string.IsNullOrEmpty(EV_MATNR))
  19773. {
  19774. entity.Result = -1;
  19775. entity.Message += "订单未匹配到物料编码\n";
  19776. }
  19777. if (!string.IsNullOrEmpty(entity.Message))
  19778. {
  19779. return entity;
  19780. }
  19781. }
  19782. #endregion
  19783. #region 添加、编辑生产订单
  19784. if (order.OrderID == 0)
  19785. {
  19786. string sqlText = "SELECT SEQ_PM_Order_OrderID.NEXTVAL FROM dual";
  19787. int newOrderID = int.Parse(oracleTrConn.GetSqlResultToStr(sqlText));
  19788. sql = @"
  19789. Insert into TP_PM_Order
  19790. (OrderID,
  19791. OrderNo,
  19792. OrderDate,
  19793. Remarks,
  19794. AccountID,
  19795. ValueFlag,
  19796. DisplayNo,
  19797. CreateTime,
  19798. CreateUserID,
  19799. UpdateTime,
  19800. UpdateUserID,
  19801. VBELN,
  19802. POSNR,
  19803. SUMMARY)
  19804. Values
  19805. (:OrderID,
  19806. :OrderNo,
  19807. :OrderDate,
  19808. :Remarks,
  19809. :AccountID,
  19810. :ValueFlag,
  19811. :DisplayNo,
  19812. sysdate,
  19813. :CreateUserID,
  19814. sysdate,
  19815. :UpdateUserID,
  19816. :VBELN,
  19817. :POSNR,
  19818. :SUMMARY) ";
  19819. Paras = new OracleParameter[] {
  19820. new OracleParameter(":OrderID",OracleDbType.Int32,newOrderID,ParameterDirection.Input),
  19821. new OracleParameter(":OrderNo",OracleDbType.Varchar2,order.OrderNo,ParameterDirection.Input),
  19822. new OracleParameter(":OrderDate",OracleDbType.Date,order.OrderDate,ParameterDirection.Input),
  19823. new OracleParameter(":Remarks",OracleDbType.Varchar2,order.Remarks,ParameterDirection.Input),
  19824. new OracleParameter(":ValueFlag",OracleDbType.Int32,order.ValueFlag,ParameterDirection.Input),
  19825. new OracleParameter(":DisplayNo",OracleDbType.Int32,order.DisplayNo,ParameterDirection.Input),
  19826. new OracleParameter(":CreateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  19827. new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  19828. new OracleParameter(":AccountID",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  19829. new OracleParameter(":VBELN",OracleDbType.Varchar2,order.VBELN,ParameterDirection.Input),
  19830. new OracleParameter(":POSNR",OracleDbType.Varchar2,order.POSNR,ParameterDirection.Input),
  19831. new OracleParameter(":SUMMARY",OracleDbType.Varchar2,order.Summary,ParameterDirection.Input),
  19832. };
  19833. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  19834. order.OrderID = newOrderID;
  19835. }
  19836. else
  19837. {
  19838. sql = @"
  19839. Update TP_PM_Order
  19840. set OrderNo=:OrderNo,
  19841. OrderDate=:OrderDate,
  19842. Remarks=:Remarks,
  19843. ValueFlag=:ValueFlag,
  19844. DisplayNo=:DisplayNo,
  19845. VBELN=:VBELN,
  19846. POSNR=:POSNR,
  19847. SUMMARY=:SUMMARY,
  19848. UpdateUserID=:UpdateUserID
  19849. where OrderID=:OrderID ";
  19850. Paras = new OracleParameter[] {
  19851. new OracleParameter(":OrderID",OracleDbType.Int32,order.OrderID,ParameterDirection.Input),
  19852. new OracleParameter(":OrderNo",OracleDbType.Varchar2,order.OrderNo,ParameterDirection.Input),
  19853. new OracleParameter(":OrderDate",OracleDbType.Date,order.OrderDate,ParameterDirection.Input),
  19854. new OracleParameter(":Remarks",OracleDbType.Varchar2,order.Remarks,ParameterDirection.Input),
  19855. new OracleParameter(":ValueFlag",OracleDbType.Int32,order.ValueFlag,ParameterDirection.Input),
  19856. new OracleParameter(":DisplayNo",OracleDbType.Int32,order.DisplayNo,ParameterDirection.Input),
  19857. new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  19858. new OracleParameter(":VBELN",OracleDbType.Varchar2,order.VBELN,ParameterDirection.Input),
  19859. new OracleParameter(":POSNR",OracleDbType.Varchar2,order.POSNR,ParameterDirection.Input),
  19860. new OracleParameter(":SUMMARY",OracleDbType.Varchar2,order.Summary,ParameterDirection.Input),
  19861. };
  19862. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  19863. }
  19864. #endregion
  19865. #region 保存订单明细
  19866. // 删除明细
  19867. sql = "DELETE FROM tp_pm_orderdetail od WHERE od.orderid = :orderid";
  19868. Paras = new OracleParameter[] { new OracleParameter(":orderid", order.OrderID) };
  19869. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  19870. // 新建明细
  19871. if (!string.IsNullOrEmpty(EV_MATNR))
  19872. {
  19873. sql = @"
  19874. INSERT INTO TP_PM_ORDERDETAIL
  19875. (ORDERID,
  19876. MATERIALCODE,
  19877. MAKTX,
  19878. KWMENG,
  19879. ACCOUNTID,
  19880. CREATEUSERID)
  19881. VALUES
  19882. (:ORDERID,
  19883. :MATERIALCODE,
  19884. :MAKTX,
  19885. :KWMENG,
  19886. :ACCOUNTID,
  19887. :CREATEUSERID) ";
  19888. Paras = new OracleParameter[]
  19889. {
  19890. new OracleParameter(":ORDERID", order.OrderID),
  19891. new OracleParameter(":MATERIALCODE", EV_MATNR),
  19892. new OracleParameter(":MAKTX", EV_MAKTX),
  19893. new OracleParameter(":KWMENG", EV_KWMENG),
  19894. new OracleParameter(":ACCOUNTID",sUserInfo.AccountID),
  19895. new OracleParameter(":CREATEUSERID",sUserInfo.UserID),
  19896. };
  19897. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  19898. }
  19899. #endregion
  19900. if (returnRows <= 0)
  19901. {
  19902. oracleTrConn.Rollback();
  19903. oracleTrConn.Disconnect();
  19904. }
  19905. else
  19906. {
  19907. oracleTrConn.Commit();
  19908. oracleTrConn.Disconnect();
  19909. }
  19910. }
  19911. catch (Exception ex)
  19912. {
  19913. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  19914. {
  19915. oracleTrConn.Rollback();
  19916. oracleTrConn.Disconnect();
  19917. }
  19918. throw ex;
  19919. }
  19920. finally
  19921. {
  19922. if (oracleTrConn.ConnState == ConnectionState.Open)
  19923. {
  19924. oracleTrConn.Disconnect();
  19925. }
  19926. }
  19927. entity.Result = returnRows;
  19928. return entity;
  19929. }
  19930. /// <summary>
  19931. /// 启用、停用订单标识
  19932. /// </summary>
  19933. /// <param name="order"></param>
  19934. /// <param name="sUserInfo"></param>
  19935. /// <returns></returns>
  19936. public static ServiceResultEntity ChangeOrderFlag(OrderEntity order, SUserInfo sUserInfo)
  19937. {
  19938. ServiceResultEntity entity = new ServiceResultEntity();
  19939. int returnRows = 0;
  19940. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  19941. try
  19942. {
  19943. string sql = string.Empty;
  19944. OracleParameter[] Paras = null;
  19945. #region 调用SAP接口
  19946. string EV_MATNR = string.Empty;
  19947. string EV_WERKS = string.Empty;
  19948. string EV_MAKTX = string.Empty;
  19949. decimal EV_KWMENG = 0;
  19950. if (order.ValueFlag == 1)
  19951. {
  19952. sql = "select * from TP_PM_Order where OrderID = :OrderID";
  19953. Paras = new OracleParameter[]
  19954. {
  19955. new OracleParameter(":OrderID",OracleDbType.Int32, order.OrderID,ParameterDirection.Input)
  19956. };
  19957. DataTable dtOrder = oracleTrConn.GetSqlResultToDt(sql, Paras);
  19958. if (dtOrder.Rows.Count == 0)
  19959. {
  19960. entity.Result = -1;
  19961. entity.Message = "未查到当前订单";
  19962. return entity;
  19963. }
  19964. if (!dtOrder.Rows[0]["ORDERNO"].ToString().StartsWith("HEGII"))
  19965. {
  19966. // 调用SAP接口,获取工厂号和物料号
  19967. string postString = "{\"IV_VBELN\":\"" + dtOrder.Rows[0]["VBELN"] + "\",\"IV_POSNR\":\"" + dtOrder.Rows[0]["POSNR"].ToString().PadLeft(6, '0') + "\"}";
  19968. // 配置文件
  19969. INIUtility ini = INIUtility.Instance(INIUtility.IniFile.SAP_HEGII);
  19970. string Url138 = ini.ReadIniData("SAP_NEW_INFO", "Url138");
  19971. // 测试
  19972. // string Url138 = "http://hgs4podev.hegii.com:50200/RESTAdapter/DKMES/ZSDFM138";
  19973. // 正式
  19974. //string Url138 = "http://hgs4podev.hegii.com:8000/RESTAdapter/DKMES/ZSDFM138";
  19975. string result = string.Empty;
  19976. string ZTYPE = string.Empty;
  19977. string ZMSG = string.Empty;
  19978. try
  19979. {
  19980. result = PostData(Url138, postString, "POST");
  19981. ZTYPE = JObject.Parse(result)["ZTYPE"].ToString();
  19982. EV_MATNR = JObject.Parse(result)["EV_MATNR"].ToString();
  19983. EV_WERKS = JObject.Parse(result)["EV_WERKS"].ToString();
  19984. EV_MAKTX = JObject.Parse(result)["EV_MAKTX"].ToString();
  19985. decimal.TryParse(JObject.Parse(result)["EV_KWMENG"].ToString(), out EV_KWMENG);
  19986. }
  19987. catch (Exception ex)
  19988. {
  19989. entity.Result = -1;
  19990. entity.Message = "ZSDFM138接口获取失败," + ex.Message;
  19991. return entity;
  19992. }
  19993. if ("E".Equals("ZTYPE"))
  19994. {
  19995. entity.Result = -1;
  19996. entity.Message = ZMSG;
  19997. return entity;
  19998. }
  19999. if (string.IsNullOrEmpty(EV_MATNR))
  20000. {
  20001. entity.Result = -1;
  20002. entity.Message += "订单未匹配到物料编码\n";
  20003. }
  20004. if (!string.IsNullOrEmpty(entity.Message))
  20005. {
  20006. return entity;
  20007. }
  20008. // 删除明细
  20009. sql = "DELETE FROM tp_pm_orderdetail od WHERE od.orderid = :orderid";
  20010. Paras = new OracleParameter[] { new OracleParameter(":orderid", order.OrderID) };
  20011. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  20012. // 新建明细
  20013. if (!string.IsNullOrEmpty(EV_MATNR))
  20014. {
  20015. sql = @"
  20016. INSERT INTO TP_PM_ORDERDETAIL
  20017. (ORDERID,
  20018. MATERIALCODE,
  20019. MAKTX,
  20020. KWMENG,
  20021. ACCOUNTID,
  20022. CREATEUSERID)
  20023. VALUES
  20024. (:ORDERID,
  20025. :MATERIALCODE,
  20026. :MAKTX,
  20027. :KWMENG,
  20028. :ACCOUNTID,
  20029. :CREATEUSERID) ";
  20030. Paras = new OracleParameter[]
  20031. {
  20032. new OracleParameter(":ORDERID", order.OrderID),
  20033. new OracleParameter(":MATERIALCODE", EV_MATNR),
  20034. new OracleParameter(":MAKTX", EV_MAKTX),
  20035. new OracleParameter(":KWMENG", EV_KWMENG),
  20036. new OracleParameter(":ACCOUNTID", sUserInfo.AccountID),
  20037. new OracleParameter(":CREATEUSERID", sUserInfo.UserID),
  20038. };
  20039. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  20040. }
  20041. }
  20042. }
  20043. #endregion
  20044. #region 添加、编辑生产订单
  20045. sql = @"
  20046. Update TP_PM_Order
  20047. set ValueFlag=:ValueFlag,
  20048. UpdateUserID=:UpdateUserID
  20049. where OrderID=:OrderID ";
  20050. Paras = new OracleParameter[]
  20051. {
  20052. new OracleParameter(":ValueFlag",OracleDbType.Int32,order.ValueFlag,ParameterDirection.Input),
  20053. new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  20054. new OracleParameter(":OrderID",OracleDbType.Int32,order.OrderID,ParameterDirection.Input),
  20055. };
  20056. returnRows += oracleTrConn.ExecuteNonQuery(sql, Paras);
  20057. #endregion
  20058. if (returnRows <= 0)
  20059. {
  20060. oracleTrConn.Rollback();
  20061. oracleTrConn.Disconnect();
  20062. }
  20063. else
  20064. {
  20065. oracleTrConn.Commit();
  20066. oracleTrConn.Disconnect();
  20067. }
  20068. }
  20069. catch (Exception ex)
  20070. {
  20071. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  20072. {
  20073. oracleTrConn.Rollback();
  20074. oracleTrConn.Disconnect();
  20075. }
  20076. throw ex;
  20077. }
  20078. entity.Result = returnRows;
  20079. return entity;
  20080. }
  20081. #endregion
  20082. #region 保存交接
  20083. /// <summary>
  20084. /// 保存交接校验
  20085. /// </summary>
  20086. /// <param name="orderid"></param>
  20087. /// <param name="dtData"></param>
  20088. /// <param name="sUserInfo"></param>
  20089. /// <returns></returns>
  20090. public static ServiceResultEntity SaveFinishedHandover(int orderid, DataTable dtData, SUserInfo sUserInfo)
  20091. {
  20092. DateTime now = DateTime.Now;
  20093. ServiceResultEntity sre = new ServiceResultEntity();
  20094. string logid_bg = "0";
  20095. OracleParameter[] Paras = null;
  20096. // 条码串
  20097. string fifter = " AND (bar.barcode = '";
  20098. foreach (DataRow row in dtData.Rows)
  20099. {
  20100. fifter += row["barcode"] + "' OR bar.barcode = '";
  20101. }
  20102. fifter = fifter.Substring(0, fifter.Length - 18) + ")";
  20103. IDBTransaction oracleTrConn2 = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  20104. try
  20105. {
  20106. #region 判断订单是否有明细
  20107. DataTable dtMaterialcode = null;
  20108. string sql = @"
  20109. SELECT O.ORDERNO,
  20110. OD.MATERIALCODE
  20111. FROM TP_PM_ORDER O
  20112. LEFT JOIN TP_PM_ORDERDETAIL OD
  20113. ON OD.ORDERID = O.ORDERID
  20114. AND OD.VALUEFLAG = '1'
  20115. WHERE O.ORDERID = :ORDERID ";
  20116. Paras = new OracleParameter[]
  20117. {
  20118. new OracleParameter(":ORDERID", orderid)
  20119. };
  20120. bool isExistsDetail = true;
  20121. DataTable dtOrder = oracleTrConn2.GetSqlResultToDt(sql, Paras);
  20122. // hegii订单不校验
  20123. if ((dtOrder.Rows[0]["ORDERNO"] + "").StartsWith("HEGII"))
  20124. {
  20125. isExistsDetail = false;
  20126. }
  20127. #endregion
  20128. for (int i = 0; i < dtData.Rows.Count; i++)
  20129. {
  20130. if (isExistsDetail)
  20131. {
  20132. #region 校验产品是否在订单里
  20133. sql = @"
  20134. SELECT GDD.MATERIALCODE
  20135. FROM TP_PM_GROUTINGDAILYDETAIL GDD
  20136. WHERE GDD.BARCODE = :BARCODE ";
  20137. Paras = new OracleParameter[]
  20138. {
  20139. new OracleParameter(":orderid", orderid),
  20140. new OracleParameter(":barcode", dtData.Rows[i]["barcode"].ToString())
  20141. };
  20142. dtMaterialcode = oracleTrConn2.GetSqlResultToDt(sql, Paras);
  20143. if (dtMaterialcode == null || dtMaterialcode.Rows.Count == 0)
  20144. {
  20145. sre.Result = -2;
  20146. sre.Message = $"当前产品条码{dtData.Rows[i]["barcode"]}不存在";
  20147. return sre;
  20148. }
  20149. if (string.IsNullOrWhiteSpace(dtMaterialcode.Rows[0]["materialcode"] + ""))
  20150. {
  20151. sre.Result = -2;
  20152. sre.Message = $"当前产品条码{dtData.Rows[i]["barcode"]}没有物料编码,不能上传数据";
  20153. return sre;
  20154. }
  20155. // 如果订单包含了物料编码,判断是否相同
  20156. if (!string.IsNullOrEmpty(dtOrder.Rows[0]["MATERIALCODE"] + ""))
  20157. {
  20158. if (!(dtMaterialcode.Rows[0]["MATERIALCODE"] + "").Equals(dtOrder.Rows[0]["MATERIALCODE"] + ""))
  20159. {
  20160. sre.Result = -2;
  20161. sre.Message = "此订单不包含物料编码【" + dtMaterialcode.Rows[0]["MATERIALCODE"] + "】,不能上传数据";
  20162. return sre;
  20163. }
  20164. }
  20165. #endregion
  20166. }
  20167. #region 产品是否在产成表中
  20168. sql = "select FHUserCode,GoodsCode,GoodsID from TP_PM_FinishedProduct where Barcode=:Barcode";
  20169. Paras = new OracleParameter[]{
  20170. new OracleParameter(":Barcode",OracleDbType.Varchar2, dtData.Rows[i]["barcode"].ToString(),ParameterDirection.Input),
  20171. };
  20172. DataSet ds = oracleTrConn2.GetSqlResultToDs(sql, Paras);
  20173. if (ds != null && ds.Tables[0].Rows.Count > 0)
  20174. {
  20175. #region 是否交接过
  20176. string fhUserCode = ds.Tables[0].Rows[0]["FHUserCode"].ToString();
  20177. if (!string.IsNullOrEmpty(fhUserCode))
  20178. {
  20179. sre.Result = -2; //已交接,不能再次进行交接
  20180. sre.Message = "此产品【" + dtData.Rows[i]["barcode"].ToString() + "】已交接,不能再次进行交接";
  20181. return sre;
  20182. }
  20183. #endregion
  20184. }
  20185. else
  20186. {
  20187. #region 不是产成品
  20188. sre.Result = -1; //不是产成品
  20189. sre.Message = "此产品【" + dtData.Rows[i]["barcode"].ToString() + "】不是产成品";
  20190. return sre;
  20191. #endregion
  20192. }
  20193. #endregion
  20194. }
  20195. sql = @"
  20196. SELECT COUNT(DISTINCT FINISHEDLOADBATCHNO) CC
  20197. FROM TP_PM_FINISHEDPRODUCT BAR
  20198. WHERE 1 = 1 " + fifter;
  20199. string cc = oracleTrConn2.GetSqlResultToStr(sql);
  20200. if (!"1".Equals(cc))
  20201. {
  20202. sre.Result = -2;
  20203. sre.Message = "不允许多板一起交接";
  20204. return sre;
  20205. }
  20206. sql = @"
  20207. SELECT DISTINCT BGLOGID
  20208. FROM TP_PM_FINISHEDPRODUCT BAR
  20209. WHERE 1 = 1 " + fifter;
  20210. string currentBGlogid = oracleTrConn2.GetSqlResultToStr(sql);
  20211. if (string.IsNullOrEmpty(currentBGlogid))
  20212. {
  20213. logid_bg = oracleTrConn2.GetSqlResultToStr("select SEQ_TSAP_DATALOG_BG.Nextval from dual");
  20214. sql = @"
  20215. UPDATE TP_PM_FINISHEDPRODUCT BAR
  20216. SET BAR.BGLOGIDCX = NULL
  20217. ,BAR.BGLOGID = " + logid_bg + @"
  20218. WHERE 1 = 1 " + fifter;
  20219. int r2 = oracleTrConn2.ExecuteNonQuery(sql);
  20220. }
  20221. else
  20222. {
  20223. logid_bg = currentBGlogid;
  20224. }
  20225. oracleTrConn2.Commit();
  20226. oracleTrConn2.Disconnect();
  20227. }
  20228. catch (Exception ex)
  20229. {
  20230. throw ex;
  20231. }
  20232. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  20233. try
  20234. {
  20235. #region 产成品交接
  20236. if (dtData == null || dtData.Rows.Count == 0)
  20237. {
  20238. sre.Result = -2;
  20239. sre.Message = "条码信息不能为空";
  20240. return sre;
  20241. }
  20242. string sql = string.Empty;
  20243. DataSet ds = null;
  20244. oracleTrConn.Connect();
  20245. // 包装装板,产成品交接不限制
  20246. string GoodsModel = string.Empty;
  20247. int? logoID = null;
  20248. string logoName = string.Empty;
  20249. int PlateLimitNum = 0;
  20250. //string _isEnable_S_PM_011 = "0";
  20251. // 2.产成品交接是否限制同型号
  20252. string _isEnable_S_PM_012 = "0";
  20253. // 3.产成品交接是否限制每板装板数量(必须先启用限制同型号);
  20254. string _isEnable_S_PM_013 = "0";
  20255. // 读取系统设置
  20256. sql = "select settingcode,settingvalue from tp_mst_systemsetting where settingcode in ('S_PM_011','S_PM_012','S_PM_013') and accountid=" + sUserInfo.AccountID;
  20257. ds = oracleTrConn.GetSqlResultToDs(sql);
  20258. foreach (DataRow dr in ds.Tables[0].Rows)
  20259. {
  20260. if (dr["settingcode"].ToString() == "S_PM_012")
  20261. {
  20262. _isEnable_S_PM_012 = dr["settingcode"].ToString();
  20263. }
  20264. }
  20265. //本批交接的批次号
  20266. #region 判断订单是否有明细
  20267. string fhBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  20268. //DataTable dtMaterialcode = null;
  20269. //sql = "SELECT COUNT(1) AS detailcount\n" +
  20270. // " FROM tp_pm_orderdetail od\n" +
  20271. // " WHERE od.orderid = :orderid and od.valueflag = '1'";
  20272. //Paras = new OracleParameter[]
  20273. //{
  20274. // new OracleParameter(":orderid", orderid)
  20275. //};
  20276. //bool isExistsDetail = true;
  20277. //object detailcount = oracleTrConn.GetSqlResultToObj(sql, Paras);
  20278. //if (detailcount == null || detailcount == DBNull.Value || Convert.ToInt32(detailcount) == 0)
  20279. //{
  20280. // isExistsDetail = false;
  20281. //}
  20282. #endregion
  20283. for (int i = 0; i < dtData.Rows.Count; i++)
  20284. {
  20285. //if (isExistsDetail)
  20286. //{
  20287. // #region 校验产品是否在订单里
  20288. // //sql = "SELECT gdd.materialcode\n" +
  20289. // //" ,od.materialcode AS ordermaterialcode\n" +
  20290. // //" FROM tp_pm_groutingdailydetail gdd\n" +
  20291. // //" LEFT JOIN tp_pm_orderdetail od\n" +
  20292. // //" ON gdd.materialcode = od.materialcode\n" +
  20293. // //" AND od.orderid = :orderid\n" +
  20294. // //" AND od.valueflag = '1'\n" +
  20295. // //" WHERE gdd.barcode = :barcode";
  20296. // sql = "SELECT gdd.materialcode\n" +
  20297. // " ,(select od.materialcode from tp_pm_orderdetail od where od.orderid = :orderid AND od.valueflag = '1' and gdd.materialcode = od.materialcode) " +
  20298. // " AS ordermaterialcode\n" +
  20299. // " FROM tp_pm_groutingdailydetail gdd\n" +
  20300. // " WHERE gdd.barcode = :barcode";
  20301. // Paras = new OracleParameter[]
  20302. // {
  20303. // new OracleParameter(":orderid", orderid),
  20304. // new OracleParameter(":barcode", dtData.Rows[i]["barcode"].ToString())
  20305. // };
  20306. // dtMaterialcode = oracleTrConn.GetSqlResultToDt(sql, Paras);
  20307. // if (dtMaterialcode == null || dtMaterialcode.Rows.Count == 0)
  20308. // {
  20309. // sre.Result = -2;
  20310. // sre.Message = $"当前产品条码{dtData.Rows[i]["barcode"]}不存在";
  20311. // return sre;
  20312. // }
  20313. // if (string.IsNullOrWhiteSpace(dtMaterialcode.Rows[0]["materialcode"] + ""))
  20314. // {
  20315. // sre.Result = -2;
  20316. // sre.Message = $"当前产品条码{dtData.Rows[i]["barcode"]}没有物料编码,不能上传数据";
  20317. // return sre;
  20318. // }
  20319. // if (string.IsNullOrWhiteSpace(dtMaterialcode.Rows[0]["ordermaterialcode"] + ""))
  20320. // {
  20321. // sre.Result = -2;
  20322. // sre.Message = "此订单不包含【" + dtMaterialcode.Rows[0]["materialcode"] + "】物料,不能上传数据";
  20323. // return sre;
  20324. // }
  20325. // #endregion
  20326. //}
  20327. #region 产品是否在产成表中
  20328. sql = "select FHUserCode,GoodsCode,GoodsID from TP_PM_FinishedProduct where Barcode=:Barcode";
  20329. Paras = new OracleParameter[]{
  20330. new OracleParameter(":Barcode",OracleDbType.Varchar2, dtData.Rows[i]["barcode"].ToString(),ParameterDirection.Input),
  20331. };
  20332. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  20333. if (ds != null && ds.Tables[0].Rows.Count > 0)
  20334. {
  20335. #region 是否交接过
  20336. string fhUserCode = ds.Tables[0].Rows[0]["FHUserCode"].ToString();
  20337. if (!string.IsNullOrEmpty(fhUserCode))
  20338. {
  20339. sre.Result = -2; //已交接,不能再次进行交接
  20340. sre.Message = "此产品【" + dtData.Rows[i]["barcode"].ToString() + "】已交接,不能再次进行交接";
  20341. return sre;
  20342. }
  20343. #endregion
  20344. }
  20345. else
  20346. {
  20347. #region 不是产成品
  20348. sre.Result = -1; //不是产成品
  20349. sre.Message = "此产品【" + dtData.Rows[i]["barcode"].ToString() + "】不是产成品";
  20350. return sre;
  20351. #endregion
  20352. }
  20353. #endregion
  20354. //包装装板,产成品交接不限制
  20355. if (i == 0)
  20356. {
  20357. #region 记录产品型号,最大限制数量,商标
  20358. GoodsModel = dtData.Rows[i]["GoodsModel"].ToString();
  20359. logoID = Convert.ToInt32(dtData.Rows[i]["logoID"]);
  20360. logoName = dtData.Rows[i]["logoName"].ToString();
  20361. sql = "select PlateLimitNum from TP_MST_Goods where GoodsID=:GoodsID";
  20362. Paras = new OracleParameter[]{
  20363. new OracleParameter(":GoodsID",OracleDbType.Int32, ds.Tables[0].Rows[0]["GoodsID"],ParameterDirection.Input),
  20364. };
  20365. ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  20366. if (ds != null && ds.Tables[0].Rows.Count > 0)
  20367. {
  20368. if (_isEnable_S_PM_013 == "1" && _isEnable_S_PM_012 == "1")
  20369. {
  20370. PlateLimitNum = Convert.ToInt32(ds.Tables[0].Rows[0]["PlateLimitNum"]);
  20371. }
  20372. }
  20373. #endregion
  20374. }
  20375. else
  20376. {
  20377. //#region 启用限制同商标
  20378. //if (_isEnable_S_PM_011 == "1")
  20379. //{
  20380. // if (Convert.ToInt32(dtData.Rows[0]["logoid"]) != logoID)
  20381. // {
  20382. // sre.Result = -3;
  20383. // sre.Message = "此产品【" + dtData.Rows[i]["barcode"] + "】的商标【"
  20384. // + dtData.Rows[0]["logoname"] + "】与此批次商标【" + logoName + "】不同,不能进行该操作。 ";
  20385. // isError = true;
  20386. // break;
  20387. // }
  20388. //}
  20389. //#endregion
  20390. #region 启用限制同型号
  20391. if (_isEnable_S_PM_012 == "1")
  20392. {
  20393. if (dtData.Rows[0]["GoodsModel"].ToString() != GoodsModel)
  20394. {
  20395. sre.Result = -4;
  20396. sre.Message = "此产品【" + dtData.Rows[i]["barcode"] + "】的型号【"
  20397. + dtData.Rows[0]["GoodsModel"] + "】与此批次型号【" + GoodsModel + "】不同,不能进行该操作。 ";
  20398. break;
  20399. }
  20400. }
  20401. }
  20402. #endregion
  20403. /* 包装装板,产成品交接不限制
  20404. #region 产品列表是否大于限制条数
  20405. if (PlateLimitNum > 0)
  20406. {
  20407. if (dtData.Rows.Count > PlateLimitNum)
  20408. {
  20409. sre.Result = -5;
  20410. sre.Message = "产品列表数量大于每板装板数量【" + PlateLimitNum + "】";
  20411. isError = true;
  20412. break;
  20413. }
  20414. }
  20415. #endregion
  20416. }
  20417. */
  20418. #region 更新产成品相关信息
  20419. sql = @"update TP_PM_FinishedProduct
  20420. set FHUserID=:FHUserID,
  20421. FHUserCode=:FHUserCode,
  20422. FHBatchNo=:FHBatchNo,
  20423. FHTime=sysdate,
  20424. FHOrderID=:FHOrderID,
  20425. UpdateUserID=:UpdateUserID
  20426. where Barcode=:Barcode";
  20427. Paras = new OracleParameter[]{
  20428. new OracleParameter(":Barcode",OracleDbType.Varchar2, dtData.Rows[i]["barcode"].ToString(),ParameterDirection.Input),
  20429. new OracleParameter(":FHUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input),
  20430. new OracleParameter(":UpdateUserID",OracleDbType.Int32, sUserInfo.UserID,ParameterDirection.Input),
  20431. new OracleParameter(":FHUserCode",OracleDbType.Varchar2, sUserInfo.UserCode,ParameterDirection.Input),
  20432. new OracleParameter(":FHBatchNo",OracleDbType.Varchar2, fhBatchNo,ParameterDirection.Input),
  20433. new OracleParameter(":FHOrderID",OracleDbType.Int32, orderid,ParameterDirection.Input),
  20434. };
  20435. oracleTrConn.ExecuteNonQuery(sql, Paras);
  20436. #endregion
  20437. }
  20438. #endregion
  20439. #region 同步SAP
  20440. #region 同步日志
  20441. object isExists;
  20442. string sqlString = string.Empty;
  20443. OracleParameter[] oracleParameter = null;
  20444. int r = 0;
  20445. //// 条码串
  20446. //string fifter = " AND (bar.barcode = '";
  20447. //foreach (DataRow row in dtData.Rows)
  20448. //{
  20449. // fifter += row["barcode"] + "' OR bar.barcode = '";
  20450. //}
  20451. //fifter = fifter.Substring(0, fifter.Length - 18) + ")";
  20452. //sqlString = "SELECT 1\n" +
  20453. //" FROM tp_pm_groutingdailydetail bar\n" +
  20454. //" WHERE bar.issync = '1'\n" + fifter;
  20455. //object isExists = oracleTrConn.GetSqlResultToObj(sqlString, oracleParameter);
  20456. //if (isExists != null)
  20457. //{
  20458. // sre.Result = -2;
  20459. // sre.Message = "当前产品已经同步过,不能重复同步。";
  20460. // return sre;
  20461. //}
  20462. DateTime date = DateTime.Now;
  20463. string yyyymmdd = date.ToString("yyyyMMdd");
  20464. sqlString = "select workcode from tp_mst_account where rownum = 1";
  20465. string workcode = oracleTrConn.GetSqlResultToStr(sqlString);
  20466. //DateTime datebegin = date.Date;
  20467. //DateTime dateend = date.Date.AddDays(1);
  20468. //sqlString =
  20469. //"SELECT :yyyymmdd AS yyyymmdd\n" +
  20470. //" ,SYSDATE AS createtime\n" +
  20471. //" ,tt.goodscode\n" +
  20472. //" ,tt.sapcode\n" +
  20473. //" ,tt.usercode\n" +
  20474. //" ,tt.ordercode\n" +
  20475. //" ,tt.orderitem\n" +
  20476. //" ,tt.zscs\n" +
  20477. //" ,to_char(tt.outputnum) AS outputnum\n" +
  20478. //" ,to_char(tt.recoverynum) AS recoverynum\n" +
  20479. //" FROM (SELECT t.goodscode\n" +
  20480. //" ,t.sapcode\n" +
  20481. //" ,t.usercode\n" +
  20482. //" ,t.ordercode\n" +
  20483. //" ,t.orderitem\n" +
  20484. //" ,t.zscs\n" +
  20485. //" ,SUM(decode(t.recyclingflag, '1', 0, decode(t.datatype, 51, 1, -1))) outputnum\n" +
  20486. //" ,SUM(decode(t.recyclingflag, '0', 0, decode(t.datatype, 51, 1, -1))) recoverynum\n" +
  20487. //" FROM (SELECT gh.goodscode\n" +
  20488. //" ,gh.sapcode\n" +
  20489. //" ,u.usercode\n" +
  20490. //" ,o.orderno\n" +
  20491. //" ,bar.recyclingflag\n" +
  20492. //" ,gh.datatype\n" +
  20493. //" ,'' zscs\n" +
  20494. ////" ,case when g.goods_line_type = 1 or gl.highpressureflag = '1' then 'G' else 'L' end zscs\n" +
  20495. //" ,CASE\n" +
  20496. //" WHEN o.orderid IS NULL\n" +
  20497. //" OR o.orderno LIKE 'HEGII%' THEN\n" +
  20498. //" ' '\n" +
  20499. //" WHEN instr(o.orderno, '/') = 0 THEN\n" +
  20500. //" to_char(o.orderno)\n" +
  20501. //" ELSE\n" +
  20502. //" to_char(substr(o.orderno, 1, instr(o.orderno, '/') - 1))\n" +
  20503. //" END ordercode -- 销售凭证\n" +
  20504. //" ,CASE\n" +
  20505. //" WHEN o.orderid IS NULL\n" +
  20506. //" OR o.orderno LIKE 'HEGII%'\n" +
  20507. //" OR instr(o.orderno, '/') = 0 THEN\n" +
  20508. //" '0'\n" +
  20509. //" WHEN instr(o.orderno, '#') = 0 THEN\n" +
  20510. //" to_char(substr(o.orderno, instr(o.orderno, '/') + 1))\n" +
  20511. //" ELSE\n" +
  20512. //" to_char(substr(o.orderno\n" +
  20513. //" ,instr(o.orderno, '/') + 1\n" +
  20514. //" ,instr(o.orderno, '#') - instr(o.orderno, '/') - 1))\n" +
  20515. //" END orderitem -- 销售凭证项目\n" +
  20516. //" FROM (SELECT gch.goodscode\n" +
  20517. //" ,gch.sapcode\n" +
  20518. //" ,decode(gch.datatype, 53, 51, gch.datatype) datatype\n" +
  20519. //" ,gch.userid\n" +
  20520. //" ,gch.groutingdailydetailid\n" +
  20521. //" ,gch.otherid\n" +
  20522. //" FROM tp_pm_goodschangehistory gch\n" +
  20523. //" WHERE gch.datatype IN (51, 52, 53)\n" +
  20524. //" UNION ALL\n" +
  20525. //" SELECT gch.goodscode\n" +
  20526. //" ,gch.sapcode\n" +
  20527. //" ,52 datatype\n" +
  20528. //" ,gch.userid\n" +
  20529. //" ,gch.groutingdailydetailid\n" +
  20530. //" ,gch.goodsidafter\n" +
  20531. //" FROM tp_pm_goodschangehistory gch\n" +
  20532. //" WHERE gch.datatype = 53) gh\n" +
  20533. //" INNER JOIN tp_mst_user u\n" +
  20534. //" ON u.userid = gh.userid\n" +
  20535. //" INNER JOIN tp_pm_groutingdailydetail bar\n" +
  20536. //" ON bar.groutingdailydetailid = gh.groutingdailydetailid\n" + fifter +
  20537. ////" AND bar.barcode IN (" + fifter + ")\n" +
  20538. //" INNER JOIN tp_pc_groutingline gl\n" +
  20539. //" ON gl.groutinglineid = bar.groutinglineid\n" +
  20540. //" INNER JOIN tp_mst_goods g\n" +
  20541. //" ON g.goodsid = bar.goodsid\n" +
  20542. //" LEFT JOIN tp_pm_order o\n" +
  20543. //" ON o.orderid = gh.otherid) t\n" +
  20544. //" GROUP BY t.goodscode\n" +
  20545. //" ,t.sapcode\n" +
  20546. //" ,t.usercode\n" +
  20547. //" ,t.ordercode\n" +
  20548. //" ,t.orderitem,t.zscs) tt\n" +
  20549. //" WHERE tt.outputnum <> 0\n" +
  20550. //" OR tt.recoverynum <> 0\n" +
  20551. //" ORDER BY tt.goodscode\n" +
  20552. //" ,tt.sapcode\n" +
  20553. //" ,tt.usercode\n" +
  20554. //" ,tt.ordercode\n" +
  20555. //" ,tt.orderitem,tt.zscs";
  20556. sqlString =
  20557. "SELECT :yyyymmdd AS yyyymmdd\n" +
  20558. " ,SYSDATE AS createtime\n" +
  20559. " ,tt.goodscode\n" +
  20560. " ,tt.sapcode\n" +
  20561. " ,tt.usercode\n" +
  20562. " ,tt.ordercode\n" +
  20563. " ,tt.orderitem\n" +
  20564. " ,tt.zscs\n" +
  20565. " ,to_char(tt.outputnum) AS outputnum\n" +
  20566. " ,to_char(tt.recoverynum) AS recoverynum\n" +
  20567. " FROM (SELECT t.goodscode\n" +
  20568. " ,t.sapcode\n" +
  20569. " ,t.usercode\n" +
  20570. " ,t.ordercode\n" +
  20571. " ,t.orderitem\n" +
  20572. " ,t.zscs\n" +
  20573. //" ,SUM(decode(t.recyclingflag, '1', 0, decode(t.datatype, 51, 1, -1))) outputnum\n" +
  20574. //" ,SUM(decode(t.recyclingflag, '0', 0, decode(t.datatype, 51, 1, -1))) recoverynum\n" +
  20575. " ,SUM(decode(t.recyclingflag, '1', 0, 1)) outputnum\n" +
  20576. " ,SUM(decode(t.recyclingflag, '0', 0, 1)) recoverynum\n" +
  20577. " FROM (SELECT bar.goodscode\n" +
  20578. //" ,gh.sapcode\n" +
  20579. //" ,u.usercode\n" +
  20580. " ,bar.materialcode sapcode\n" +
  20581. " ,gh.fhusercode usercode\n" +
  20582. " ,o.orderno\n" +
  20583. " ,bar.recyclingflag\n" +
  20584. //" ,gh.datatype\n" +
  20585. " ,'' zscs\n" +
  20586. //" ,case when g.goods_line_type = 1 or gl.highpressureflag = '1' then 'G' else 'L' end zscs\n" +
  20587. " ,CASE\n" +
  20588. " WHEN o.orderid IS NULL\n" +
  20589. " OR o.orderno LIKE 'HEGII%' THEN\n" +
  20590. " ' '\n" +
  20591. " WHEN instr(o.orderno, '/') = 0 THEN\n" +
  20592. " to_char(o.orderno)\n" +
  20593. " ELSE\n" +
  20594. " to_char(substr(o.orderno, 1, instr(o.orderno, '/') - 1))\n" +
  20595. " END ordercode -- 销售凭证\n" +
  20596. " ,CASE\n" +
  20597. " WHEN o.orderid IS NULL\n" +
  20598. " OR o.orderno LIKE 'HEGII%'\n" +
  20599. " OR instr(o.orderno, '/') = 0 THEN\n" +
  20600. " '0'\n" +
  20601. " WHEN instr(o.orderno, '#') = 0 THEN\n" +
  20602. " to_char(substr(o.orderno, instr(o.orderno, '/') + 1))\n" +
  20603. " ELSE\n" +
  20604. " to_char(substr(o.orderno\n" +
  20605. " ,instr(o.orderno, '/') + 1\n" +
  20606. " ,instr(o.orderno, '#') - instr(o.orderno, '/') - 1))\n" +
  20607. " END orderitem -- 销售凭证项目\n" +
  20608. " FROM tp_pm_groutingdailydetail bar\n" +
  20609. //" INNER JOIN tp_mst_user u\n" +
  20610. //" ON u.userid = gh.userid\n" +
  20611. " INNER JOIN tp_pm_finishedproduct gh\n" +
  20612. " ON bar.groutingdailydetailid = gh.groutingdailydetailid\n" +
  20613. //" AND bar.barcode IN (" + fifter + ")\n" +
  20614. //" INNER JOIN tp_pc_groutingline gl\n" +
  20615. //" ON gl.groutinglineid = bar.groutinglineid\n" +
  20616. //" INNER JOIN tp_mst_goods g\n" +
  20617. //" ON g.goodsid = bar.goodsid\n" +
  20618. " LEFT JOIN tp_pm_order o\n" +
  20619. " ON o.orderid = gh.fhorderid where 1=1 " + fifter + ") t\n" +
  20620. " GROUP BY t.goodscode\n" +
  20621. " ,t.sapcode\n" +
  20622. " ,t.usercode\n" +
  20623. " ,t.ordercode\n" +
  20624. " ,t.orderitem,t.zscs) tt\n" +
  20625. " WHERE tt.outputnum <> 0\n" +
  20626. " OR tt.recoverynum <> 0\n" +
  20627. " ORDER BY tt.goodscode\n" +
  20628. " ,tt.sapcode\n" +
  20629. " ,tt.usercode\n" +
  20630. " ,tt.ordercode\n" +
  20631. " ,tt.orderitem,tt.zscs";
  20632. oracleParameter = new OracleParameter[]
  20633. {
  20634. new OracleParameter(":yyyymmdd", yyyymmdd)
  20635. };
  20636. DataTable workData = oracleTrConn.GetSqlResultToDt(sqlString, oracleParameter);
  20637. // 同步日志ID
  20638. string logid = oracleTrConn.GetSqlResultToStr("select SEQ_SAP_HEGII_DataLog_ID.Nextval from dual");
  20639. //string msg = "data:" + datebegin.ToString("yyyyMMdd-HHmm") + "~" +
  20640. // dateend.ToString("yyyyMMdd-HHmm");
  20641. string msg = $"整板条码[{logid}]:" + dtData.Rows[0]["barcode"];
  20642. sqlString = "insert into tsap_hegii_datalog\n" +
  20643. " (LogID\n" +
  20644. " ,LogType\n" +
  20645. " ,BeginTime\n" +
  20646. " ,YYYYMMDD\n" +
  20647. " ,WorkCode\n" +
  20648. " ,DataCode\n" +
  20649. " ,DataStuts\n" +
  20650. " ,DataMSG\n" +
  20651. " ,CreateUserID\n" +
  20652. " ,DataLogID)\n" +
  20653. "values\n" +
  20654. " (:LogID\n" +
  20655. " ,'2'\n" +
  20656. " ,sysdate\n" +
  20657. " ,:YYYYMMDD\n" +
  20658. " ,:WorkCode\n" +
  20659. " ,'60'\n" +
  20660. " ,'S'\n" +
  20661. " ,:DataMSG\n" +
  20662. " ,:CreateUserID\n" +
  20663. " ,:LogID)";
  20664. oracleParameter = new OracleParameter[]
  20665. {
  20666. new OracleParameter(":LogID",OracleDbType.Int32, logid, ParameterDirection.Input),
  20667. new OracleParameter(":CreateUserID",OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input),
  20668. new OracleParameter(":YYYYMMDD",OracleDbType.Varchar2, yyyymmdd, ParameterDirection.Input),
  20669. new OracleParameter(":WorkCode",OracleDbType.Varchar2, workcode, ParameterDirection.Input),
  20670. new OracleParameter(":DataMSG",OracleDbType.Varchar2, msg, ParameterDirection.Input),
  20671. };
  20672. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  20673. #endregion
  20674. #region 同步条码明细
  20675. sqlString =
  20676. "INSERT INTO tsap_hegii_finishedproduct\n" +
  20677. " (yyyymmdd\n" +
  20678. " ,workcode\n" +
  20679. " ,barcode\n" +
  20680. " ,outcode\n" +
  20681. " ,goodscode\n" +
  20682. " ,sapcode\n" +
  20683. " ,sapflbatchno\n" +
  20684. " ,sapfhundoflag\n" +
  20685. " ,ordercode\n" +
  20686. " ,orderitem, LOGID,securitycode,ZTYPE)\n" +
  20687. " SELECT :yyyymmdd\n" +
  20688. " ,:workcode\n" +
  20689. " ,bar.barcode\n" +
  20690. " ,nvl(gdd.outlabelcode, (g.materialcode || :workcode || gdd.onlycode))\n" +
  20691. " ,gdd.goodscode\n" +
  20692. " ,nvl(gdd.materialcode, nvl(g.materialcode, g.goodscode))\n" +
  20693. " ,nvl(bar.finishedloadbatchno, bar.fhbatchno)\n" +
  20694. //" ,decode(gdd.sapfhundoflag, '1', 'X', ' ')\n" +
  20695. " ,' '\n" +
  20696. " ,CASE\n" +
  20697. //" WHEN :workcode IN ('5010', '5011')\n" +
  20698. //" WHEN :workcode <> '5020'\n" +
  20699. //" OR o.orderid IS NULL\n" +
  20700. " WHEN o.orderid IS NULL\n" +
  20701. " OR o.orderno LIKE 'HEGII%' THEN\n" +
  20702. " NULL\n" +
  20703. " WHEN instr(o.orderno, '/') = 0 THEN\n" +
  20704. " to_char(o.orderno)\n" +
  20705. " ELSE\n" +
  20706. " to_char(substr(o.orderno, 1, instr(o.orderno, '/') - 1))\n" +
  20707. " END ordercode -- 销售凭证\n" +
  20708. " ,CASE\n" +
  20709. //" WHEN :workcode IN ('5010', '5011')\n" +
  20710. //" WHEN :workcode <> '5020'\n" +
  20711. //" OR o.orderid IS NULL\n" +
  20712. " WHEN o.orderid IS NULL\n" +
  20713. " OR o.orderno LIKE 'HEGII%'\n" +
  20714. " OR instr(o.orderno, '/') = 0 THEN\n" +
  20715. " '0'\n" +
  20716. " WHEN instr(o.orderno, '#') = 0 THEN\n" +
  20717. " to_char(substr(o.orderno, instr(o.orderno, '/') + 1))\n" +
  20718. " ELSE\n" +
  20719. " to_char(substr(o.orderno\n" +
  20720. " ,instr(o.orderno, '/') + 1\n" +
  20721. " ,instr(o.orderno, '#') - instr(o.orderno, '/') - 1))\n" +
  20722. " END orderitem -- 销售凭证项目\n" +
  20723. " ,:LOGID,gdd.securitycode,'S'\n" +
  20724. " FROM tp_pm_finishedproduct bar\n" +
  20725. " INNER JOIN tp_pm_groutingdailydetail gdd\n" +
  20726. " ON gdd.barcode = bar.barcode\n" +
  20727. " INNER JOIN tp_mst_goods g\n" +
  20728. " ON g.goodsid = gdd.goodsid\n" +
  20729. " LEFT JOIN tp_pm_order o\n" +
  20730. " ON o.orderid = bar.fhorderid\n" +
  20731. " WHERE 1 = 1 " + fifter;
  20732. //" WHERE :FHBatchNo = fhBatchNo";
  20733. oracleParameter = new OracleParameter[]
  20734. {
  20735. //new OracleParameter(":FHBatchNo",OracleDbType.Varchar2, fhBatchNo,ParameterDirection.Input),
  20736. new OracleParameter(":yyyymmdd", yyyymmdd),
  20737. new OracleParameter(":workcode", workcode),
  20738. new OracleParameter(":LOGID", logid)
  20739. };
  20740. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  20741. sqlString =
  20742. "select bar.yyyymmdd\n" +
  20743. " ,bar.workcode\n" +
  20744. " ,bar.barcode\n" +
  20745. " ,bar.outcode\n" +
  20746. " ,bar.goodscode\n" +
  20747. " ,bar.sapcode\n" +
  20748. " ,bar.sapflbatchno\n" +
  20749. " ,bar.sapfhundoflag\n" +
  20750. " ,bar.ordercode\n" +
  20751. " ,bar.orderitem\n" +
  20752. " ,bar.securitycode\n" +
  20753. //" from tsap_hegii_finishedproduct bar where ztype is null " + fifter +
  20754. " from tsap_hegii_finishedproduct bar where LOGID=:LOGID " +
  20755. " order by bar.sapflbatchno, bar.barcode";
  20756. oracleParameter = new OracleParameter[]
  20757. {
  20758. new OracleParameter(":LOGID", logid)
  20759. };
  20760. DataTable fpData = oracleTrConn.GetSqlResultToDt(sqlString, oracleParameter);
  20761. #region 注销
  20762. //// 单次传输最大条数
  20763. //int maxCount = 100000;
  20764. //List<Zppfm010> sapParameterList = new List<Zppfm010>();
  20765. //if (fpData != null && fpData.Rows.Count > 0)
  20766. //{
  20767. // int index = 0;
  20768. // //Zppfm010 sapParameter = new Zppfm010();
  20769. // //sapParameter.Zsum = maxCount;
  20770. // //sapParameter.TableIn = new Zspp110[sapParameter.Zsum];
  20771. // List<ZSPP110> tableInList = new List<ZSPP110>();
  20772. // foreach (DataRow item in fpData.Rows)
  20773. // {
  20774. // if (index >= maxCount)
  20775. // {
  20776. // Zppfm010 sapItem = new Zppfm010();
  20777. // sapItem.ZSUM = tableInList.Count;
  20778. // sapItem.TABLE_IN = tableInList.ToArray();
  20779. // sapParameterList.Add(sapItem);
  20780. // index = 0;
  20781. // tableInList.Clear();
  20782. // }
  20783. // ZSPP110 info110 = new ZSPP110();
  20784. // // 时间戳
  20785. // info110.ZSCNU = yyyymmdd;
  20786. // // 工厂
  20787. // info110.WERKS = workcode;
  20788. // // 生产条码
  20789. // info110.ZSCTM = item["barcode"].ToString();
  20790. // //生产防伪码 xuwei add 2021-12-09
  20791. // // info110.SECURITYCODE = item["securitycode"].ToString();
  20792. // // 包装条码
  20793. // info110.ZBZTM = item["outcode"].ToString();
  20794. // // 产品编码
  20795. // info110.ZCPBM = item["goodscode"].ToString();
  20796. // // 物料编号
  20797. // info110.MATNR = item["sapcode"].ToString();
  20798. // // 包装整板标识
  20799. // info110.ZBZBS = item["sapflbatchno"].ToString();
  20800. // // 重新绑定标识
  20801. // info110.ZCXBD = item["sapfhundoflag"].ToString();
  20802. // // 销售凭证
  20803. // info110.KDAUF = item["ordercode"].ToString();
  20804. // // 销售凭证项目
  20805. // info110.KDPOS = item["orderitem"].ToString();
  20806. // info110.UZEIT = date.ToString("HH:mm:ss");
  20807. // info110.ZCODEN = "";
  20808. // info110.ZCODEYZM = "";
  20809. // //if (info110.WERKS == "5011" && info110.ZCPBM == "K047L")
  20810. // //{
  20811. // // continue;
  20812. // //}
  20813. // tableInList.Add(info110);
  20814. // index++;
  20815. // }
  20816. // Zppfm010 sapParameter010 = new Zppfm010();
  20817. // sapParameter010.ZSUM = tableInList.Count;
  20818. // sapParameter010.TABLE_IN = tableInList.ToArray();
  20819. // sapParameterList.Add(sapParameter010);
  20820. // index = 0;
  20821. // tableInList.Clear();
  20822. //}
  20823. //else
  20824. //{
  20825. // Zppfm010 sapParameter010 = new Zppfm010();
  20826. // sapParameter010.ZSUM = 0;
  20827. // sapParameter010.TABLE_IN = new ZSPP110[sapParameter010.ZSUM];
  20828. // sapParameterList.Add(sapParameter010);
  20829. //}
  20830. #endregion
  20831. //2022年9月23日13:06:25 添加时间限制,10月1号零点整不再传输原接口产量数据
  20832. // 停用时间
  20833. //DateTime setTime = Convert.ToDateTime(oracleTrConn.GetSqlResultToObj("SELECT OLDSYNCTIME FROM TP_SYS_SAPCONFIG"));
  20834. //if (now < setTime)
  20835. //{
  20836. //foreach (Zppfm010 sapParameter010 in sapParameterList)
  20837. //{
  20838. // ZPPFM010Response result010 = SAPDataLogic.HGSAPDK_ZPPFM010(sapParameter010, yyyymmdd);
  20839. // //sre.Message = result010.ZMSG;
  20840. // sre.Message = $"{result010.ZMSG}({sapParameter010.ZSUM})";
  20841. // sre.Result = result010.ZTYPE;
  20842. // if (result010.TABLE_OUT != null && result010.TABLE_OUT.Length > 0)
  20843. // {
  20844. // 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";
  20845. // foreach (ZSPP110 item in result010.TABLE_OUT)
  20846. // {
  20847. // oracleParameter = new OracleParameter[]
  20848. // {
  20849. // new OracleParameter(":ZTYPE",OracleDbType.Varchar2, item.ZTYPE, ParameterDirection.Input),
  20850. // new OracleParameter(":ZMSG",OracleDbType.Varchar2, item.ZMSG, ParameterDirection.Input),
  20851. // new OracleParameter(":barcode",OracleDbType.Varchar2, item.ZSCTM, ParameterDirection.Input),
  20852. // new OracleParameter(":sapflbatchno",OracleDbType.Varchar2, item.ZBZBS, ParameterDirection.Input),
  20853. // new OracleParameter(":logid", logid)
  20854. // };
  20855. // r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  20856. // }
  20857. // }
  20858. // if (result010.ZTYPE != "S")
  20859. // {
  20860. // sre.Result = -2;
  20861. // sre.Message = "同步条码失败," + result010.ZMSG;
  20862. // return sre;
  20863. // }
  20864. //}
  20865. //}
  20866. #endregion
  20867. #region 同步产量
  20868. // 潮州 暂时不同步产量 2020-10-25 chenxy
  20869. //Zppfm008 sapParameter = new Zppfm008();
  20870. if (workData != null && workData.Rows.Count > 0)
  20871. {
  20872. //sapParameter.ZSUM = workData.Rows.Count;
  20873. //sapParameter.TABLE_IN = new ZSPP100[sapParameter.ZSUM];
  20874. sqlString = "insert into TSAP_HEGII_WorkData\n" +
  20875. " (YYYYMMDD\n" +
  20876. " ,WorkCode\n" +
  20877. " ,DataCode\n" +
  20878. " ,GoodsCode\n" +
  20879. " ,SAPCode\n" +
  20880. " ,UserCode\n" +
  20881. " ,OutputNum\n" +
  20882. " ,RECOVERYNUM\n" +
  20883. " ,ORDERCODE\n" +
  20884. " ,ORDERITEM\n" +
  20885. " ,zscs\n" +
  20886. " ,LogID,createtime)\n" +
  20887. "values\n" +
  20888. " ('" + yyyymmdd + "'\n" +
  20889. " ,'" + workcode + "'\n" +
  20890. " ,'60'\n" +
  20891. " ,:GoodsCode\n" +
  20892. " ,:SAPCode\n" +
  20893. " ,:UserCode\n" +
  20894. " ,:OutputNum\n" +
  20895. " ,:RECOVERYNUM\n" +
  20896. " ,:ORDERCODE\n" +
  20897. " ,:ORDERITEM\n" +
  20898. " ,:zscs\n" +
  20899. " ," + logid + ",:createtime)";
  20900. int index = 0;
  20901. foreach (DataRow item in workData.Rows)
  20902. {
  20903. //ZSPP100 info100 = new ZSPP100();
  20904. //// 工厂
  20905. //info100.WERKS = workcode;
  20906. //// 型号
  20907. //info100.GROES = item["GoodsCode"].ToString();
  20908. //// 物料编号
  20909. //info100.MATNR = item["SAPCode"].ToString();
  20910. //// 生产工号
  20911. //info100.ZGHNU = item["UserCode"].ToString();
  20912. //// 数据节点
  20913. //info100.ZJDNU = "60";
  20914. //// 时间戳
  20915. //info100.ZSCNU = yyyymmdd;
  20916. //// 销售凭证
  20917. //info100.VBELN = item["ORDERCODE"].ToString().Trim();
  20918. //// 销售凭证项目
  20919. //info100.POSNR = item["ORDERITEM"].ToString();
  20920. //// 产量
  20921. //info100.ZCLNG = item["OutputNum"].ToString();
  20922. //// 损坯
  20923. //info100.ZSPNG = "0";
  20924. //// 清除
  20925. //info100.ZQCNG = "0";
  20926. //// 回收
  20927. //info100.ZHSNG = item["RECOVERYNUM"].ToString();
  20928. //// 干补
  20929. //info100.ZGBNG = "0";
  20930. //// 注浆类型 G高压 L普通
  20931. //info100.ZSCS = item["ZSCS"].ToString();
  20932. //info100.ZKSSJ = now.ToString("HHmmss");
  20933. //info100.ZJSRQ = Convert.ToDecimal(now.ToString("yyyyMMddHHmmss"));
  20934. oracleParameter = new OracleParameter[]
  20935. {
  20936. new OracleParameter(":GoodsCode",OracleDbType.Varchar2, item["GoodsCode"], ParameterDirection.Input),
  20937. new OracleParameter(":SAPCode",OracleDbType.Varchar2, item["SAPCode"], ParameterDirection.Input),
  20938. new OracleParameter(":UserCode",OracleDbType.Varchar2, item["UserCode"], ParameterDirection.Input),
  20939. new OracleParameter(":OutputNum",OracleDbType.Varchar2, item["OutputNum"], ParameterDirection.Input),
  20940. new OracleParameter(":RECOVERYNUM",OracleDbType.Varchar2, item["RECOVERYNUM"], ParameterDirection.Input),
  20941. new OracleParameter(":ORDERCODE",OracleDbType.Varchar2, item["ORDERCODE"], ParameterDirection.Input),
  20942. new OracleParameter(":ORDERITEM",OracleDbType.Varchar2, item["ORDERITEM"], ParameterDirection.Input),
  20943. new OracleParameter(":ZSCS",OracleDbType.Varchar2, item["ZSCS"], ParameterDirection.Input),
  20944. new OracleParameter(":createtime",OracleDbType.Date, item["createtime"], ParameterDirection.Input),
  20945. };
  20946. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  20947. //sapParameter.TABLE_IN[index++] = info100;
  20948. }
  20949. }
  20950. //else
  20951. //{
  20952. // sapParameter.ZSUM = 0;
  20953. // sapParameter.TABLE_IN = new ZSPP100[sapParameter.ZSUM];
  20954. //}
  20955. //2022年9月23日13:06:25 添加时间限制,10月1号零点整不再传输原接口产量数据
  20956. //if (now < setTime)
  20957. //{
  20958. //ZPPFM008Response result = SAPDataLogic.HGSAPDK_ZPPFM008(sapParameter, yyyymmdd, "60");
  20959. ////if (result.Ztype == "E")
  20960. ////{
  20961. //// sqlString = "update tsap_hegii_datalog t set t.EndTime = sysdate, DataStuts = 'E', DataMSG = DataMSG||:msg where logid = :logid";
  20962. //// oracleParameter = new OracleParameter[]
  20963. //// {
  20964. //// new OracleParameter(":msg",OracleDbType.Varchar2, result.Zmsg, ParameterDirection.Input),
  20965. //// new OracleParameter(":logid",OracleDbType.Int32, logid, ParameterDirection.Input),
  20966. //// };
  20967. //// r = oracleConn.ExecuteNonQuery(sqlString, oracleParameter);
  20968. ////}
  20969. ////else
  20970. //if (result.TABLE_OUT != null && result.TABLE_OUT.Length > 0)
  20971. //{
  20972. // sqlString = "update TSAP_HEGII_WorkData t set t.ZTime =sysdate, ZTYPE = :ZTYPE, ZMSG = :ZMSG where logid = " + logid +
  20973. // " \n and YYYYMMDD='" + yyyymmdd + "' and WorkCode='" + workcode +
  20974. // "' and DataCode='60' and GoodsCode=:GoodsCode and SAPCode=:SAPCode and UserCode=:UserCode \n" +
  20975. // "and OrderCode=:OrderCode and OrderItem=:OrderItem";
  20976. // foreach (ZSPP100 item in result.TABLE_OUT)
  20977. // {
  20978. // string posnr = item.POSNR.TrimStart('0');
  20979. // oracleParameter = new OracleParameter[]
  20980. // {
  20981. // new OracleParameter(":ZTYPE",OracleDbType.Varchar2, item.ZTYPE, ParameterDirection.Input),
  20982. // new OracleParameter(":ZMSG",OracleDbType.Varchar2, item.ZMSG, ParameterDirection.Input),
  20983. // new OracleParameter(":GoodsCode",OracleDbType.Varchar2, item.GROES, ParameterDirection.Input),
  20984. // new OracleParameter(":SAPCode",OracleDbType.Varchar2, item.MATNR, ParameterDirection.Input),
  20985. // new OracleParameter(":UserCode",OracleDbType.Varchar2, item.ZGHNU, ParameterDirection.Input),
  20986. // new OracleParameter(":OrderCode",OracleDbType.Varchar2, (string.IsNullOrEmpty(item.VBELN) ? " " : item.VBELN), ParameterDirection.Input),
  20987. // new OracleParameter(":OrderItem",OracleDbType.Varchar2, (string.IsNullOrEmpty(posnr) ? "0" : posnr), ParameterDirection.Input),
  20988. // };
  20989. // r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  20990. // }
  20991. // //:msg||chr(13)||DataMSG
  20992. // result.ZMSG = $"{result.ZMSG}({sapParameter.ZSUM})";
  20993. // sqlString = "update tsap_hegii_datalog t set t.EndTime = sysdate, DataStuts = :DataStuts, DataMSG =nvl2(:msg,:msg||' '||chr(13)||DataMSG,DataMSG) where logid = :logid";
  20994. // oracleParameter = new OracleParameter[]
  20995. // {
  20996. // new OracleParameter(":DataStuts",OracleDbType.Varchar2, result.ZTYPE, ParameterDirection.Input),
  20997. // new OracleParameter(":msg",OracleDbType.Varchar2, result.ZMSG, ParameterDirection.Input),
  20998. // new OracleParameter(":logid",OracleDbType.Int32, logid, ParameterDirection.Input),
  20999. // };
  21000. // r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  21001. //}
  21002. //if (result.ZTYPE != "S")
  21003. //{
  21004. // sre.Result = -2;
  21005. // sre.Message = "同步产量失败," + result.ZMSG;
  21006. // return sre;
  21007. //}
  21008. //sqlString =
  21009. //"UPDATE tp_pm_groutingdailydetail bar\n" +
  21010. //" SET bar.issync = '1'\n" +
  21011. //" WHERE 1 = 1" + fifter;
  21012. //r = oracleTrConn.ExecuteNonQuery(sqlString);
  21013. //}
  21014. //else
  21015. //{
  21016. //}
  21017. #endregion
  21018. #region 调新报工接口
  21019. workcode = "5200"; //原5012
  21020. sqlString = @"
  21021. SELECT TO_CHAR(SYSDATE, 'YYYYMMDD') AS YYYYMMDD,
  21022. SYSDATE AS CREATETIME,
  21023. TT.GOODSCODE GROES,
  21024. TT.SAPCODE MATNR,
  21025. TT.USERCODE ZGHNU,
  21026. TT.ORDERCODE VBELN,
  21027. TT.ORDERITEM POSNR,
  21028. 'C' AS ZSCMS,
  21029. 'T' AS ZSCS,
  21030. TO_CHAR(TT.OUTPUTNUM) AS ZCLNG,
  21031. TO_CHAR(TT.RECOVERYNUM) AS ZHSNG,
  21032. :WORKCODE AS WERKS,
  21033. '60' ZJDNU,
  21034. TO_CHAR(SYSDATE, 'YYYYMMDD') ZSCNU,
  21035. TO_CHAR(SYSDATE, 'HH24MISS') ZKSSJ,
  21036. TO_CHAR(SYSDATE, 'YYYYMMDDHH24MISS') ZJSRQ,
  21037. '0' ZSPNG,
  21038. '0' ZQCNG,
  21039. '0' ZGBNG,
  21040. TO_CHAR(TT.WORKSHOP) ZSCCJ,
  21041. '60' DATACODE,
  21042. TT.CHARG
  21043. FROM (SELECT T.GOODSCODE,
  21044. T.SAPCODE,
  21045. T.USERCODE,
  21046. T.ORDERCODE,
  21047. T.ORDERITEM,
  21048. T.WORKSHOP,
  21049. T.CHARG,
  21050. SUM(DECODE(T.RECYCLINGFLAG, '1', 0, 1)) OUTPUTNUM,
  21051. SUM(DECODE(T.RECYCLINGFLAG, '0', 0, 1)) RECOVERYNUM
  21052. FROM (SELECT BAR.GOODSCODE,
  21053. BAR.MATERIALCODE SAPCODE,
  21054. GH.FHUSERCODE USERCODE,
  21055. O.ORDERNO,
  21056. BAR.RECYCLINGFLAG,
  21057. CASE
  21058. WHEN O.ORDERID IS NULL
  21059. OR O.ORDERNO LIKE 'HEGII%' THEN
  21060. ' '
  21061. WHEN INSTR(O.ORDERNO, '/') = 0 THEN
  21062. TO_CHAR(O.ORDERNO)
  21063. ELSE
  21064. TO_CHAR(SUBSTR(O.ORDERNO, 1, INSTR(O.ORDERNO, '/') - 1))
  21065. END ORDERCODE -- 销售凭证
  21066. ,
  21067. CASE
  21068. WHEN O.ORDERID IS NULL
  21069. OR O.ORDERNO LIKE 'HEGII%'
  21070. OR INSTR(O.ORDERNO, '/') = 0 THEN
  21071. '0'
  21072. WHEN INSTR(O.ORDERNO, '#') = 0 THEN
  21073. TO_CHAR(SUBSTR(O.ORDERNO, INSTR(O.ORDERNO, '/') + 1))
  21074. ELSE
  21075. TO_CHAR(SUBSTR(O.ORDERNO
  21076. ,INSTR(O.ORDERNO, '/') + 1
  21077. ,INSTR(O.ORDERNO, '#') - INSTR(O.ORDERNO, '/') - 1))
  21078. END ORDERITEM,
  21079. 1 AS WORKSHOP,
  21080. -- TO_CHAR(GH.FHTIME, 'yyyymm') AS CHARG
  21081. TO_CHAR(GH.FHTIME, 'yymm') || :WORKCODE || 'E' AS CHARG
  21082. FROM TP_PM_GROUTINGDAILYDETAIL BAR
  21083. INNER JOIN TP_PM_FINISHEDPRODUCT GH
  21084. ON BAR.GROUTINGDAILYDETAILID = GH.GROUTINGDAILYDETAILID
  21085. INNER JOIN TP_MST_GOODS G
  21086. ON G.GOODSID = BAR.GOODSID
  21087. INNER JOIN TP_MST_GOODSTYPE GT
  21088. ON GT.GOODSTYPEID = G.GOODSTYPEID
  21089. LEFT JOIN TP_PM_ORDER O
  21090. ON O.ORDERID = GH.FHORDERID
  21091. WHERE 1 = 1 " + fifter + @") T
  21092. GROUP BY T.GOODSCODE,
  21093. T.SAPCODE,
  21094. T.USERCODE,
  21095. T.ORDERCODE,
  21096. T.ORDERITEM,
  21097. T.WORKSHOP,
  21098. T.CHARG) TT
  21099. WHERE TT.OUTPUTNUM <> 0
  21100. OR TT.RECOVERYNUM <> 0
  21101. ORDER BY TT.GOODSCODE,
  21102. TT.SAPCODE,
  21103. TT.USERCODE,
  21104. TT.ORDERCODE,
  21105. TT.ORDERITEM,
  21106. TT.WORKSHOP,
  21107. TT.CHARG ";
  21108. oracleParameter = new OracleParameter[]
  21109. {
  21110. new OracleParameter(":WORKCODE", workcode)
  21111. };
  21112. DataTable workData5000 = oracleTrConn.GetSqlResultToDt(sqlString, oracleParameter);
  21113. sqlString = "insert into TSAP_HEGII_DATALOG_BG\n" +
  21114. " (LogID\n" +
  21115. " ,LogType\n" +
  21116. " ,BeginTime\n" +
  21117. " ,YYYYMMDD\n" +
  21118. " ,WorkCode\n" +
  21119. " ,DataCode\n" +
  21120. " ,DataStuts\n" +
  21121. " ,DataMSG\n" +
  21122. " ,DATALOGID\n" +
  21123. " ,EXECUTEDATEBEGIN\n" +
  21124. " ,EXECUTEDATEEND,SAPGUID)\n" +
  21125. "values\n" +
  21126. " (:LogID\n" +
  21127. " ,'2'\n" +
  21128. " ,sysdate\n" +
  21129. " ,:YYYYMMDD\n" +
  21130. " ,:WORKCODE\n" +
  21131. " ,'60'\n" +
  21132. " ,'F'\n" +
  21133. " ,:DataMSG\n" +
  21134. " ,:LogID\n" +
  21135. " ,sysdate\n" +
  21136. " ,sysdate,sys_guid())";
  21137. oracleParameter = new OracleParameter[]
  21138. {
  21139. new OracleParameter(":LogID",OracleDbType.Int32, logid_bg, ParameterDirection.Input),
  21140. new OracleParameter(":YYYYMMDD",OracleDbType.Varchar2, yyyymmdd, ParameterDirection.Input),
  21141. new OracleParameter(":WORKCODE",OracleDbType.Varchar2, workcode, ParameterDirection.Input),
  21142. new OracleParameter(":DataMSG",OracleDbType.Varchar2, "", ParameterDirection.Input),
  21143. };
  21144. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  21145. sqlString = "insert into TSAP_HEGII_WORKDATA_BG\n" +
  21146. " (YYYYMMDD\n" +
  21147. " ,WorkCode\n" +
  21148. " ,DataCode\n" +
  21149. " ,GoodsCode\n" +
  21150. " ,SAPCode\n" +
  21151. " ,UserCode\n" +
  21152. " ,WORKSHOP\n" +
  21153. " ,OutputNum\n" +
  21154. " ,RECOVERYNUM\n" +
  21155. " ,ORDERCODE\n" +
  21156. " ,ORDERITEM\n" +
  21157. " ,testmouldflag\n" +
  21158. " ,zscs\n" +
  21159. " ,LogID,createtime,workdataid,charg)\n" +
  21160. "values\n" +
  21161. " ('" + yyyymmdd + "'\n" +
  21162. " ,:WORKCODE\n" +
  21163. " ,'60'\n" +
  21164. " ,:GoodsCode\n" +
  21165. " ,:SAPCode\n" +
  21166. " ,:UserCode\n" +
  21167. " ,:ZSCCJ\n" +
  21168. " ,:OutputNum\n" +
  21169. " ,:RECOVERYNUM\n" +
  21170. " ,:ORDERCODE\n" +
  21171. " ,:ORDERITEM\n" +
  21172. " ,:testmouldflag\n" +
  21173. " ,:zscs\n" +
  21174. " ," + logid_bg + ",:createtime,:workdataid,:charg)";
  21175. foreach (DataRow item in workData5000.Rows)
  21176. {
  21177. string workdataid = oracleTrConn.GetSqlResultToStr("select SEQ_HEGII_WORKDATA_BG.Nextval from dual");
  21178. oracleParameter = new OracleParameter[]
  21179. {
  21180. new OracleParameter(":WORKCODE", workcode),
  21181. new OracleParameter(":GoodsCode", item["GROES"].ToString()),
  21182. new OracleParameter(":SAPCode", item["MATNR"].ToString()),
  21183. new OracleParameter(":UserCode", item["ZGHNU"].ToString()),
  21184. new OracleParameter(":ZSCCJ", item["ZSCCJ"].ToString()),
  21185. new OracleParameter(":OutputNum", item["ZCLNG"].ToString()),
  21186. new OracleParameter(":RECOVERYNUM", item["ZHSNG"].ToString()),
  21187. new OracleParameter(":ORDERCODE", item["VBELN"].ToString()),
  21188. new OracleParameter(":ORDERITEM", item["POSNR"].ToString()),
  21189. new OracleParameter(":testmouldflag", item["ZSCMS"].ToString()),
  21190. new OracleParameter(":zscs", item["ZSCS"].ToString()),
  21191. new OracleParameter(":createtime", OracleDbType.Date,item["createtime"], ParameterDirection.Input),
  21192. new OracleParameter(":workdataid", workdataid),
  21193. new OracleParameter(":charg", item["CHARG"].ToString()),
  21194. };
  21195. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  21196. }
  21197. //sqlString = "SELECT TO_CHAR(wd.yyyymmdd) yyyymmdd\n" +
  21198. // " ,wd.WORKCODE AS WERKS\n" +
  21199. // " ,TO_CHAR(wd.goodscode) GROES\n" +
  21200. // " ,TO_CHAR(wd.sapcode) MATNR\n" +
  21201. // " ,TO_CHAR(wd.usercode) ZGHNU\n" +
  21202. // " ,TO_CHAR(wd.datacode) ZJDNU\n" +
  21203. // " ,to_char(sysdate, 'YYYYMMDD' ) ZSCNU\n" +
  21204. // " ,to_char(sysdate, 'HH24MISS' ) ZKSSJ\n" +
  21205. // " ,to_char(sysdate, 'YYYYMMDDHH24MISS' ) ZJSRQ\n" +
  21206. // " ,TO_CHAR(wd.ordercode) VBELN\n" +
  21207. // " ,TO_CHAR(wd.orderitem) POSNR\n" +
  21208. // " ,TO_CHAR(wd.outputnum) ZCLNG\n" +
  21209. // " ,TO_CHAR(wd.scrapnum) ZSPNG\n" +
  21210. // " ,TO_CHAR(wd.cleanupnum) ZQCNG\n" +
  21211. // " ,TO_CHAR(wd.recoverynum) ZHSNG\n" +
  21212. // " ,TO_CHAR(wd.repairnum) ZGBNG\n" +
  21213. // " ,TO_CHAR(wd.testmouldflag) ZSCMS\n" +
  21214. // " -- ,TO_CHAR(wd.zscs) zscs\n" +
  21215. // " ,'T' AS ZSCS\n" +
  21216. // " ,TO_CHAR(wd.WORKSHOP) ZSCCJ\n" +
  21217. // " ,WD.CHARG\n" +
  21218. // " ,TO_CHAR(60) datacode\n" +
  21219. // " ,'5200' || WD.CHARG || LPAD(DL.LOGID, 10,'0') AS ZID\n" +
  21220. // " FROM tsap_hegii_workdata_bg wd\n" +
  21221. // " INNER JOIN TSAP_HEGII_DATALOG_BG DL\n" +
  21222. // " ON wd.LOGID = DL.LOGID \n" +
  21223. // " WHERE wd.logid = :logid";
  21224. //OracleParameter[] par = null;
  21225. //par = new OracleParameter[]
  21226. //{
  21227. // new OracleParameter(":logid", OracleDbType.Int32, logid_bg, ParameterDirection.Input),
  21228. //};
  21229. //DataTable dtt = oracleTrConn.GetSqlResultToDt(sqlString, par);
  21230. //int num = dtt.Rows.Count;
  21231. //string sq = "select SAP_INI_BG from TP_SYS_SAPCONFIG";
  21232. //string SAP_ING_NEW = oracleTrConn.GetSqlResultToStr(sq);
  21233. //if (SAP_ING_NEW == "1")
  21234. ////if (true)
  21235. //{
  21236. // // 调用SAP接口
  21237. // string postString = "{\"ZSUM\":" + num.ToString() + ",\"TABLE_IN\":{\"item\":" + JsonHelper.ToJson(ModelConvertHelper<BGToSAP>.ConvertToModel(dtt)) + "}}";
  21238. // INIUtility ini = INIUtility.Instance(INIUtility.IniFile.SAP_HEGII);
  21239. // string url030 = ini.ReadIniData("SAP_NEW_INFO", "Url030");
  21240. // //string url030 = "http://hgs4podev.hegii.com:50200/RESTAdapter/DKMES/ZPPFM030";
  21241. // string result = string.Empty;
  21242. // try
  21243. // {
  21244. // result = SAPDataLogic.PostData(url030, postString, "POST");
  21245. // if (JObject.Parse(result)["TABLE_OUT"] != null && JObject.Parse(result)["TABLE_OUT"].ToString().Length > 0)
  21246. // {
  21247. // sqlString = "update TSAP_HEGII_WorkData_bg t set t.ZTime =sysdate, ZTYPE = :ZTYPE, ZMSG = :ZMSG where logid = " + logid_bg +
  21248. // " \n and YYYYMMDD='" + yyyymmdd + "' and WorkCode='" + workcode +
  21249. // "' and DataCode='60' and GoodsCode=:GoodsCode and SAPCode=:SAPCode and UserCode=:UserCode \n" +
  21250. // "and OrderCode=:OrderCode and OrderItem=:OrderItem";
  21251. // Dictionary<string, object> obj = JsonConvert.DeserializeObject<Dictionary<string, object>>(result);
  21252. // object TABLE_OUT;
  21253. // obj.TryGetValue("TABLE_OUT", out TABLE_OUT);
  21254. // obj = JsonConvert.DeserializeObject<Dictionary<string, object>>(TABLE_OUT + "");
  21255. // object item1;
  21256. // obj.TryGetValue("item", out item1);
  21257. // JArray arr = JArray.FromObject(item1);
  21258. // foreach (JObject item60 in arr)
  21259. // {
  21260. // string posnr = item60["POSNR"].ToString().TrimStart('0');
  21261. // oracleParameter = new OracleParameter[]
  21262. // {
  21263. // new OracleParameter(":ZTYPE",OracleDbType.Varchar2, item60["ZTYPE"].ToString(), ParameterDirection.Input),
  21264. // new OracleParameter(":ZMSG",OracleDbType.Varchar2, item60["ZMSG"].ToString(), ParameterDirection.Input),
  21265. // new OracleParameter(":GoodsCode",OracleDbType.Varchar2, item60["GROES"].ToString(), ParameterDirection.Input),
  21266. // new OracleParameter(":SAPCode",OracleDbType.Varchar2, item60["MATNR"].ToString(), ParameterDirection.Input),
  21267. // new OracleParameter(":UserCode",OracleDbType.Varchar2, item60["ZGHNU"].ToString(), ParameterDirection.Input),
  21268. // new OracleParameter(":OrderCode",OracleDbType.Varchar2, (string.IsNullOrEmpty(item60["VBELN"].ToString()) ? " " : item60["VBELN"].ToString()), ParameterDirection.Input),
  21269. // new OracleParameter(":Orderitem",OracleDbType.Varchar2, ((string.IsNullOrEmpty(posnr)) ? "0" : posnr), ParameterDirection.Input),
  21270. // };
  21271. // r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  21272. // }
  21273. // //:msg||chr(13)||DataMSG
  21274. // JObject.Parse(result)["ZMSG"] = $"{JObject.Parse(result)["ZMSG"]}(" + num + ")";
  21275. // sqlString = "update tsap_hegii_datalog_bg t set t.EndTime = sysdate, DataStuts = :DataStuts, DataMSG =nvl2(:msg,:msg||' '||chr(13)||DataMSG,DataMSG) where logid = :logid";
  21276. // oracleParameter = new OracleParameter[]
  21277. // {
  21278. // new OracleParameter(":DataStuts",OracleDbType.Varchar2, JObject.Parse(result)["ZTYPE"].ToString(), ParameterDirection.Input),
  21279. // new OracleParameter(":msg",OracleDbType.Varchar2, JObject.Parse(result)["ZMSG"].ToString(), ParameterDirection.Input),
  21280. // new OracleParameter(":logid",OracleDbType.Int32, logid_bg, ParameterDirection.Input),
  21281. // };
  21282. // r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  21283. // }
  21284. // if (JObject.Parse(result)["ZTYPE"].ToString() != "S")
  21285. // {
  21286. // sre.Result = -2;
  21287. // sre.Message = "同步产量失败," + JObject.Parse(result)["ZMSG"].ToString();
  21288. // return sre;
  21289. // }
  21290. // }
  21291. // catch (Exception ex)
  21292. // {
  21293. // sre.Result = -2;
  21294. // sre.Message = "sap030接口同步失败," + ex.Message;
  21295. // return sre;
  21296. // ////:msg||chr(13)||DataMSG
  21297. // //sqlString = "update tsap_hegii_datalog_bg t set t.EndTime = sysdate, DataStuts = :DataStuts, DataMSG =nvl2(:msg,:msg||' '||chr(13)||DataMSG,DataMSG) where logid = :logid";
  21298. // //oracleParameter = new OracleParameter[]
  21299. // //{
  21300. // // new OracleParameter(":DataStuts",OracleDbType.Varchar2, "E", ParameterDirection.Input),
  21301. // // new OracleParameter(":msg",OracleDbType.Varchar2, ex.Message, ParameterDirection.Input),
  21302. // // new OracleParameter(":logid",OracleDbType.Int32, logid_bg, ParameterDirection.Input),
  21303. // //};
  21304. // //r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  21305. // }
  21306. // //sqlString =
  21307. // //"UPDATE tp_pm_groutingdailydetail bar\n" +
  21308. // //" SET bar.issync = '1'\n" +
  21309. // //" WHERE 1 = 1" + fifter;
  21310. // //r = oracleTrConn.ExecuteNonQuery(sqlString);
  21311. //}
  21312. sqlString = "update TSAP_HEGII_WorkData t set t.ZTime =sysdate, ZTYPE = 'S' where logid = " + logid +
  21313. " \n and YYYYMMDD='" + yyyymmdd + "' and WorkCode='" + workcode +
  21314. "' and DataCode='60' and GoodsCode=:GoodsCode and SAPCode=:SAPCode \n" +
  21315. "and OrderCode=:OrderCode and OrderItem=:OrderItem";
  21316. foreach (DataRow row in fpData.Rows)
  21317. {
  21318. string posnr = (row["ORDERITEM"] + "").TrimStart('0');
  21319. oracleParameter = new OracleParameter[]
  21320. {
  21321. new OracleParameter(":GoodsCode",OracleDbType.Varchar2, row["GoodsCode"], ParameterDirection.Input),
  21322. new OracleParameter(":SAPCode",OracleDbType.Varchar2, row["SAPCode"], ParameterDirection.Input),
  21323. //new OracleParameter(":UserCode",OracleDbType.Varchar2, row["UserCode"], ParameterDirection.Input),
  21324. new OracleParameter(":OrderCode",OracleDbType.Varchar2, (string.IsNullOrEmpty(row["OrderCode"] + "") ? " " :row["OrderCode"]), ParameterDirection.Input),
  21325. new OracleParameter(":OrderItem",OracleDbType.Varchar2, (string.IsNullOrEmpty(posnr) ? "0" : posnr), ParameterDirection.Input),
  21326. };
  21327. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  21328. }
  21329. #endregion
  21330. #endregion
  21331. #region 同步WMS系统
  21332. if (fpData.Rows.Count > 0)
  21333. {
  21334. //string message = WMSDataLogic.PushWMS(fpData, now);
  21335. // 同步日志
  21336. sqlString = @"
  21337. INSERT INTO TP_WMS_LOG
  21338. (LOGTYPE,
  21339. SPS,
  21340. SKU,
  21341. SERIALNO,
  21342. ADDDAY,
  21343. ADDTIME,
  21344. CODEI,
  21345. UDF1,
  21346. UDF2,
  21347. LPN,
  21348. RETURNDESC,
  21349. ACCOUNTID,
  21350. CREATETIME,
  21351. UPDATETIME,
  21352. CREATEUSERID,
  21353. UPDATEUSERID,
  21354. BGLOGID)
  21355. VALUES
  21356. (:LOGTYPE,
  21357. :SPS,
  21358. :SKU,
  21359. :SERIALNO,
  21360. :ADDDAY,
  21361. :ADDTIME,
  21362. :CODEI,
  21363. :UDF1,
  21364. :UDF2,
  21365. :LPN,
  21366. :RETURNDESC,
  21367. :ACCOUNTID,
  21368. :CREATETIME,
  21369. :CREATETIME,
  21370. :USERID,
  21371. :USERID,
  21372. :BGLOGID) ";
  21373. string orderitem;
  21374. foreach (DataRow row in fpData.Rows)
  21375. {
  21376. orderitem = row["orderitem"] + "";
  21377. if (string.IsNullOrEmpty(orderitem) || "0".Equals(orderitem))
  21378. {
  21379. orderitem = "000000";
  21380. }
  21381. oracleParameter = new OracleParameter[]
  21382. {
  21383. new OracleParameter(":LOGTYPE",OracleDbType.Int32, 1, ParameterDirection.Input),
  21384. new OracleParameter(":SPS",OracleDbType.Varchar2, workcode, ParameterDirection.Input),
  21385. new OracleParameter(":SKU",OracleDbType.Varchar2, row["sapcode"], ParameterDirection.Input),
  21386. new OracleParameter(":SERIALNO",OracleDbType.Varchar2, row["outcode"], ParameterDirection.Input),
  21387. new OracleParameter(":ADDDAY",OracleDbType.Varchar2, now.ToString("yyyyMMdd"), ParameterDirection.Input),
  21388. new OracleParameter(":ADDTIME",OracleDbType.Varchar2, now.ToString("HHmmss"), ParameterDirection.Input),
  21389. new OracleParameter(":CODEI",OracleDbType.Varchar2, row["barcode"], ParameterDirection.Input),
  21390. new OracleParameter(":UDF1",OracleDbType.Varchar2, row["ordercode"], ParameterDirection.Input),
  21391. new OracleParameter(":UDF2",OracleDbType.Varchar2, orderitem, ParameterDirection.Input),
  21392. new OracleParameter(":LPN",OracleDbType.Varchar2, row["sapflbatchno"], ParameterDirection.Input),
  21393. new OracleParameter(":RETURNDESC",OracleDbType.Varchar2, "未同步", ParameterDirection.Input),
  21394. new OracleParameter(":ACCOUNTID",OracleDbType.Varchar2, sUserInfo.AccountID, ParameterDirection.Input),
  21395. new OracleParameter(":CREATETIME",OracleDbType.Date, now, ParameterDirection.Input),
  21396. new OracleParameter(":USERID",OracleDbType.Varchar2, sUserInfo.UserID, ParameterDirection.Input),
  21397. new OracleParameter(":BGLOGID", OracleDbType.Int32, logid_bg, ParameterDirection.Input)
  21398. };
  21399. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  21400. }
  21401. }
  21402. #endregion
  21403. #region 释放包材库库存
  21404. //INIUtility ini = INIUtility.Instance(INIUtility.IniFile.SAP_HEGII);
  21405. //string packingURL = ini.ReadIniData("SAP_HEGII", "PackingURL");
  21406. //foreach (DataRow row in workData.Rows)
  21407. //{
  21408. // string url = packingURL + row["sapcode"] + "&num=" + row["outputnum"];
  21409. // WebRequest req = WebRequest.Create(url);
  21410. // req.Method = "GET";
  21411. // Stream stream = req.GetResponse().GetResponseStream();
  21412. // StreamReader reader = new StreamReader(stream);
  21413. // JObject json = JObject.Parse(reader.ReadToEnd());
  21414. // if (json["success"].ToString() == "false")
  21415. // {
  21416. // sre.Result = -2;
  21417. // sre.Message = json["message"].ToString();
  21418. // return sre;
  21419. // }
  21420. //}
  21421. #endregion
  21422. sre.Result = 1;
  21423. oracleTrConn.Commit();
  21424. oracleTrConn.Disconnect();
  21425. return sre;
  21426. }
  21427. catch (Exception ex)
  21428. {
  21429. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  21430. {
  21431. oracleTrConn.Rollback();
  21432. oracleTrConn.Disconnect();
  21433. }
  21434. throw ex;
  21435. }
  21436. finally
  21437. {
  21438. if (oracleTrConn.ConnState == ConnectionState.Open)
  21439. {
  21440. oracleTrConn.Disconnect();
  21441. }
  21442. }
  21443. }
  21444. /// <summary>
  21445. /// 撤销整板交接
  21446. /// </summary>
  21447. /// <param name="orderid"></param>
  21448. /// <param name="dtData"></param>
  21449. /// <param name="sUserInfo"></param>
  21450. /// <returns></returns>
  21451. public static ServiceResultEntity BackFinishedHandover(DataTable dtData, SUserInfo sUserInfo)
  21452. {
  21453. DateTime now = DateTime.Now;
  21454. ServiceResultEntity sre = new ServiceResultEntity();
  21455. if (dtData == null || dtData.Rows.Count == 0)
  21456. {
  21457. sre.Result = -2;
  21458. sre.Message = "条码信息不能为空";
  21459. return sre;
  21460. }
  21461. string logid_bg = "0";
  21462. OracleParameter[] Paras = null;
  21463. // 条码串
  21464. string fifter = " AND (bar.barcode = '";
  21465. foreach (DataRow row in dtData.Rows)
  21466. {
  21467. fifter += row["barcode"] + "' OR bar.barcode = '";
  21468. }
  21469. fifter = fifter.Substring(0, fifter.Length - 18) + ")";
  21470. IDBTransaction oracleTrConn2 = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  21471. try
  21472. {
  21473. #region 相关校验
  21474. string sql = "";
  21475. // 本批交接的批次号
  21476. for (int i = 0; i < dtData.Rows.Count; i++)
  21477. {
  21478. // 1.判断产品是否在产成品表中
  21479. sql = @"select
  21480. FHUserID,
  21481. FHUserCode,
  21482. GoodsID,
  21483. GoodsCode,
  21484. GoodsName
  21485. from TP_PM_FinishedProduct
  21486. where BarCode=:BarCode";
  21487. Paras = new OracleParameter[]
  21488. {
  21489. new OracleParameter(":BarCode",OracleDbType.NVarchar2,dtData.Rows[i]["barcode"],ParameterDirection.Input),
  21490. };
  21491. DataSet dsResult = oracleTrConn2.GetSqlResultToDs(sql, Paras);
  21492. if (dsResult != null && dsResult.Tables[0].Rows.Count > 0)
  21493. {
  21494. // 在产成品表中
  21495. #region 是否交接过
  21496. string fhUserCode = dsResult.Tables[0].Rows[0]["FHUserCode"].ToString();
  21497. if (string.IsNullOrEmpty(fhUserCode))
  21498. {
  21499. sre.Result = -1; //未交接,不能撤销
  21500. sre.Message = "此产品【" + dtData.Rows[i]["barcode"] + "】未交接,不能进行该操作";
  21501. return sre;
  21502. }
  21503. #endregion
  21504. }
  21505. else
  21506. {
  21507. sre.Result = -2; //不能产成品,不能撤销
  21508. sql = "select GoodsCode from TP_PM_GroutingDailyDetail where BarCode=:BarCode";
  21509. dsResult = oracleTrConn2.GetSqlResultToDs(sql, Paras);
  21510. if (dsResult != null && dsResult.Tables[0].Rows.Count > 0)
  21511. {
  21512. sre.Message = "此产品【" + dtData.Rows[i]["barcode"] + "】不是产成品,不能进行该操作";
  21513. }
  21514. else
  21515. {
  21516. sre.Message = "此条码【" + dtData.Rows[i]["barcode"] + "】无效,不能进行该操作";
  21517. }
  21518. return sre;
  21519. }
  21520. }
  21521. #endregion
  21522. sql = @"
  21523. SELECT DISTINCT BGLOGIDCX
  21524. FROM TP_PM_FINISHEDPRODUCT BAR
  21525. WHERE 1 = 1 " + fifter;
  21526. string currentBGlogid = oracleTrConn2.GetSqlResultToStr(sql);
  21527. if (string.IsNullOrEmpty(currentBGlogid))
  21528. {
  21529. logid_bg = oracleTrConn2.GetSqlResultToStr("select SEQ_TSAP_DATALOG_BG.Nextval from dual");
  21530. sql = @"
  21531. UPDATE TP_PM_FINISHEDPRODUCT BAR
  21532. SET BAR.BGLOGID = NULL
  21533. ,BAR.BGLOGIDCX = " + logid_bg + @"
  21534. WHERE 1 = 1 " + fifter;
  21535. int r2 = oracleTrConn2.ExecuteNonQuery(sql);
  21536. }
  21537. else
  21538. {
  21539. logid_bg = currentBGlogid;
  21540. }
  21541. oracleTrConn2.Commit();
  21542. oracleTrConn2.Disconnect();
  21543. }
  21544. catch (Exception ex)
  21545. {
  21546. throw ex;
  21547. }
  21548. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  21549. try
  21550. {
  21551. if (dtData == null || dtData.Rows.Count == 0)
  21552. {
  21553. sre.Result = -2;
  21554. sre.Message = "条码信息不能为空";
  21555. return sre;
  21556. }
  21557. string sql = string.Empty;
  21558. oracleTrConn.Connect();
  21559. #region 相关校验
  21560. // 本批交接的批次号
  21561. for (int i = 0; i < dtData.Rows.Count; i++)
  21562. {
  21563. // 1.判断产品是否在产成品表中
  21564. sql = @"select
  21565. FHUserID,
  21566. FHUserCode,
  21567. GoodsID,
  21568. GoodsCode,
  21569. GoodsName
  21570. from TP_PM_FinishedProduct
  21571. where BarCode=:BarCode";
  21572. Paras = new OracleParameter[]
  21573. {
  21574. new OracleParameter(":BarCode",OracleDbType.NVarchar2,dtData.Rows[i]["barcode"],ParameterDirection.Input),
  21575. };
  21576. DataSet dsResult = oracleTrConn.GetSqlResultToDs(sql, Paras);
  21577. if (dsResult != null && dsResult.Tables[0].Rows.Count > 0)
  21578. {
  21579. // 在产成品表中
  21580. #region 是否交接过
  21581. string fhUserCode = dsResult.Tables[0].Rows[0]["FHUserCode"].ToString();
  21582. if (string.IsNullOrEmpty(fhUserCode))
  21583. {
  21584. sre.Result = -1; //未交接,不能撤销
  21585. sre.Message = "此产品【" + dtData.Rows[i]["barcode"] + "】未交接,不能进行该操作";
  21586. return sre;
  21587. }
  21588. #endregion
  21589. }
  21590. else
  21591. {
  21592. sre.Result = -2; //不能产成品,不能撤销
  21593. sql = "select GoodsCode from TP_PM_GroutingDailyDetail where BarCode=:BarCode";
  21594. dsResult = oracleTrConn.GetSqlResultToDs(sql, Paras);
  21595. if (dsResult != null && dsResult.Tables[0].Rows.Count > 0)
  21596. {
  21597. sre.Message = "此产品【" + dtData.Rows[i]["barcode"] + "】不是产成品,不能进行该操作";
  21598. }
  21599. else
  21600. {
  21601. sre.Message = "此条码【" + dtData.Rows[i]["barcode"] + "】无效,不能进行该操作";
  21602. }
  21603. return sre;
  21604. }
  21605. }
  21606. #endregion
  21607. #region 同步SAP
  21608. #region 取相关数据
  21609. object isExists;
  21610. string sqlString = string.Empty;
  21611. OracleParameter[] oracleParameter = null;
  21612. int r = 0;
  21613. //// 条码串
  21614. //string fifter = " AND (bar.barcode = '";
  21615. //foreach (DataRow row in dtData.Rows)
  21616. //{
  21617. // fifter += row["barcode"] + "' OR bar.barcode = '";
  21618. //}
  21619. //fifter = fifter.Substring(0, fifter.Length - 18) + ")";
  21620. //sqlString = "SELECT 1\n" +
  21621. //" FROM tp_pm_groutingdailydetail bar\n" +
  21622. //" WHERE bar.issync IS NULL" + fifter;
  21623. //object isExists = oracleTrConn.GetSqlResultToObj(sqlString, oracleParameter);
  21624. //if (isExists != null)
  21625. //{
  21626. // sre.Result = -2;
  21627. // sre.Message = "当前产品已经撤销,不能重复同步。";
  21628. // return sre;
  21629. //}
  21630. DateTime date = DateTime.Now;
  21631. string yyyymmdd = date.ToString("yyyyMMdd");
  21632. sqlString = "select workcode from tp_mst_account where rownum = 1";
  21633. string workcode = oracleTrConn.GetSqlResultToStr(sqlString);
  21634. sqlString =
  21635. "SELECT :yyyymmdd AS yyyymmdd\n" +
  21636. " ,SYSDATE AS createtime\n" +
  21637. " ,tt.goodscode\n" +
  21638. " ,tt.sapcode\n" +
  21639. " ,tt.usercode\n" +
  21640. " ,tt.ordercode\n" +
  21641. " ,tt.orderitem\n" +
  21642. " ,tt.zscs\n" +
  21643. " ,to_char(tt.outputnum) AS outputnum\n" +
  21644. " ,to_char(tt.recoverynum) AS recoverynum\n" +
  21645. " FROM (SELECT t.goodscode\n" +
  21646. " ,t.sapcode\n" +
  21647. " ,t.usercode\n" +
  21648. " ,t.ordercode\n" +
  21649. " ,t.orderitem\n" +
  21650. " ,t.zscs\n" +
  21651. " ,0-SUM(decode(t.recyclingflag, '1', 0, 1)) outputnum\n" +
  21652. " ,0-SUM(decode(t.recyclingflag, '0', 0, 1)) recoverynum\n" +
  21653. " FROM (SELECT bar.goodscode\n" +
  21654. " ,bar.materialcode sapcode\n" +
  21655. " ,gh.fhusercode usercode\n" +
  21656. " ,o.orderno\n" +
  21657. " ,bar.recyclingflag\n" +
  21658. " ,'' zscs\n" +
  21659. " ,CASE\n" +
  21660. " WHEN o.orderid IS NULL\n" +
  21661. " OR o.orderno LIKE 'HEGII%' THEN\n" +
  21662. " ' '\n" +
  21663. " WHEN instr(o.orderno, '/') = 0 THEN\n" +
  21664. " to_char(o.orderno)\n" +
  21665. " ELSE\n" +
  21666. " to_char(substr(o.orderno, 1, instr(o.orderno, '/') - 1))\n" +
  21667. " END ordercode -- 销售凭证\n" +
  21668. " ,CASE\n" +
  21669. " WHEN o.orderid IS NULL\n" +
  21670. " OR o.orderno LIKE 'HEGII%'\n" +
  21671. " OR instr(o.orderno, '/') = 0 THEN\n" +
  21672. " '0'\n" +
  21673. " WHEN instr(o.orderno, '#') = 0 THEN\n" +
  21674. " to_char(substr(o.orderno, instr(o.orderno, '/') + 1))\n" +
  21675. " ELSE\n" +
  21676. " to_char(substr(o.orderno\n" +
  21677. " ,instr(o.orderno, '/') + 1\n" +
  21678. " ,instr(o.orderno, '#') - instr(o.orderno, '/') - 1))\n" +
  21679. " END orderitem -- 销售凭证项目\n" +
  21680. " FROM tp_pm_groutingdailydetail bar\n" +
  21681. " INNER JOIN tp_pm_finishedproduct gh\n" +
  21682. " ON bar.groutingdailydetailid = gh.groutingdailydetailid\n" +
  21683. " LEFT JOIN tp_pm_order o\n" +
  21684. " ON o.orderid = gh.fhorderid where 1=1 " + fifter + ") t\n" +
  21685. " GROUP BY t.goodscode\n" +
  21686. " ,t.sapcode\n" +
  21687. " ,t.usercode\n" +
  21688. " ,t.ordercode\n" +
  21689. " ,t.orderitem,t.zscs) tt\n" +
  21690. " WHERE tt.outputnum <> 0\n" +
  21691. " OR tt.recoverynum <> 0\n" +
  21692. " ORDER BY tt.goodscode\n" +
  21693. " ,tt.sapcode\n" +
  21694. " ,tt.usercode\n" +
  21695. " ,tt.ordercode\n" +
  21696. " ,tt.orderitem,tt.zscs";
  21697. oracleParameter = new OracleParameter[]
  21698. {
  21699. new OracleParameter(":yyyymmdd", yyyymmdd)
  21700. };
  21701. DataTable workData = oracleTrConn.GetSqlResultToDt(sqlString, oracleParameter);
  21702. string logid = oracleTrConn.GetSqlResultToStr("select SEQ_SAP_HEGII_DataLog_ID.Nextval from dual");
  21703. string msg = $"整板撤销[{logid}]:" + dtData.Rows[0]["barcode"];
  21704. sqlString = "insert into tsap_hegii_datalog\n" +
  21705. " (LogID\n" +
  21706. " ,LogType\n" +
  21707. " ,BeginTime\n" +
  21708. " ,YYYYMMDD\n" +
  21709. " ,WorkCode\n" +
  21710. " ,DataCode\n" +
  21711. " ,DataStuts\n" +
  21712. " ,DataMSG\n" +
  21713. " ,CreateUserID\n" +
  21714. " ,DataLogID)\n" +
  21715. "values\n" +
  21716. " (:LogID\n" +
  21717. " ,'2'\n" +
  21718. " ,sysdate\n" +
  21719. " ,:YYYYMMDD\n" +
  21720. " ,:WorkCode\n" +
  21721. " ,'60'\n" +
  21722. " ,'S'\n" +
  21723. " ,:DataMSG\n" +
  21724. " ,:CreateUserID\n" +
  21725. " ,:LogID)";
  21726. oracleParameter = new OracleParameter[]
  21727. {
  21728. new OracleParameter(":LogID",OracleDbType.Int32, logid, ParameterDirection.Input),
  21729. new OracleParameter(":CreateUserID",OracleDbType.Int32, sUserInfo.UserID, ParameterDirection.Input),
  21730. new OracleParameter(":YYYYMMDD",OracleDbType.Varchar2, yyyymmdd, ParameterDirection.Input),
  21731. new OracleParameter(":WorkCode",OracleDbType.Varchar2, workcode, ParameterDirection.Input),
  21732. new OracleParameter(":DataMSG",OracleDbType.Varchar2, msg, ParameterDirection.Input),
  21733. };
  21734. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  21735. #endregion
  21736. #region 同步条码明细(注销)
  21737. sqlString =
  21738. "select bar.yyyymmdd\n" +
  21739. " ,bar.workcode\n" +
  21740. " ,bar.barcode\n" +
  21741. " ,bar.outcode\n" +
  21742. " ,bar.goodscode\n" +
  21743. " ,bar.sapcode\n" +
  21744. " ,bar.sapflbatchno\n" +
  21745. " ,bar.sapfhundoflag\n" +
  21746. " ,bar.ordercode\n" +
  21747. " ,bar.orderitem\n" +
  21748. // 保留条码同步履历 2020-10-14 by chenxy ztype = 'S'
  21749. //" from tsap_hegii_finishedproduct bar where 1 = 1" + fifter +
  21750. " from tsap_hegii_finishedproduct bar where ztype = 'S' " + fifter +
  21751. " order by bar.sapflbatchno, bar.barcode";
  21752. DataTable fpData = oracleTrConn.GetSqlResultToDt(sqlString, oracleParameter);
  21753. #region 注销
  21754. //// 单次传输最大条数
  21755. //int maxCount = 100000;
  21756. //List<Zppfm010> sapParameterList = new List<Zppfm010>();
  21757. //if (fpData != null && fpData.Rows.Count > 0)
  21758. //{
  21759. // int index = 0;
  21760. // //Zppfm010 sapParameter = new Zppfm010();
  21761. // //sapParameter.Zsum = maxCount;
  21762. // //sapParameter.TableIn = new Zspp110[sapParameter.Zsum];
  21763. // List<ZSPP110> tableInList = new List<ZSPP110>();
  21764. // foreach (DataRow item in fpData.Rows)
  21765. // {
  21766. // if (index >= maxCount)
  21767. // {
  21768. // Zppfm010 sapItem = new Zppfm010();
  21769. // sapItem.ZSUM = tableInList.Count;
  21770. // sapItem.TABLE_IN = tableInList.ToArray();
  21771. // sapParameterList.Add(sapItem);
  21772. // index = 0;
  21773. // tableInList.Clear();
  21774. // }
  21775. // ZSPP110 info110 = new ZSPP110();
  21776. // // 时间戳
  21777. // info110.ZSCNU = yyyymmdd;
  21778. // // 工厂
  21779. // info110.WERKS = workcode;
  21780. // // 生产条码
  21781. // info110.ZSCTM = item["barcode"].ToString();
  21782. // // 包装条码
  21783. // info110.ZBZTM = item["outcode"].ToString();
  21784. // // 产品编码
  21785. // info110.ZCPBM = item["goodscode"].ToString();
  21786. // // 物料编号
  21787. // info110.MATNR = item["sapcode"].ToString();
  21788. // // 包装整板标识
  21789. // info110.ZBZBS = item["sapflbatchno"].ToString();
  21790. // // 重新绑定标识
  21791. // info110.ZCXBD = "X";
  21792. // // 销售凭证
  21793. // info110.KDAUF = item["ordercode"].ToString();
  21794. // // 销售凭证项目
  21795. // info110.KDPOS = item["orderitem"].ToString();
  21796. // info110.UZEIT = date.ToString("HH:mm:ss");
  21797. // info110.ZCODEN = "";
  21798. // info110.ZCODEYZM = "";
  21799. // //if (info110.WERKS == "5011" && info110.ZCPBM == "K047L")
  21800. // //{
  21801. // // continue;
  21802. // //}
  21803. // tableInList.Add(info110);
  21804. // index++;
  21805. // }
  21806. // Zppfm010 sapParameter010 = new Zppfm010();
  21807. // sapParameter010.ZSUM = tableInList.Count;
  21808. // sapParameter010.TABLE_IN = tableInList.ToArray();
  21809. // sapParameterList.Add(sapParameter010);
  21810. // index = 0;
  21811. // tableInList.Clear();
  21812. //}
  21813. //else
  21814. //{
  21815. // Zppfm010 sapParameter010 = new Zppfm010();
  21816. // sapParameter010.ZSUM = 0;
  21817. // sapParameter010.TABLE_IN = new ZSPP110[sapParameter010.ZSUM];
  21818. // sapParameterList.Add(sapParameter010);
  21819. //}
  21820. #endregion
  21821. //2022年9月23日13:06:25 添加时间限制,10月1号零点整不再传输原接口产量数据
  21822. // 当前时间
  21823. //DateTime setTime = Convert.ToDateTime(oracleTrConn.GetSqlResultToObj("SELECT OLDSYNCTIME FROM TP_SYS_SAPCONFIG"));
  21824. //if (now < setTime)
  21825. //{
  21826. // //foreach (Zppfm010 sapParameter010 in sapParameterList)
  21827. // //{
  21828. // // ZPPFM010Response result010 = SAPDataLogic.HGSAPDK_ZPPFM010(sapParameter010, yyyymmdd);
  21829. // // //sre.Message = result010.ZMSG;
  21830. // // sre.Message = $"{result010.ZMSG}({sapParameter010.ZSUM})";
  21831. // // sre.Result = result010.ZTYPE;
  21832. // // if (result010.TABLE_OUT != null && result010.TABLE_OUT.Length > 0)
  21833. // // {
  21834. // // // 保留条码同步履历 2020-10-14 by chenxy ztype = 'S'
  21835. // // //sqlString = "update tsap_hegii_finishedproduct t set t.ZTime =sysdate, ZTYPE = nvl(:ZTYPE,'S'), ZMSG = :ZMSG where barcode=:barcode and sapflbatchno=:sapflbatchno";
  21836. // // sqlString = "update tsap_hegii_finishedproduct t set t.ZTime =sysdate, ZTYPE = 'D', ZMSG = :ZMSG where barcode=:barcode and ztype = 'S' and sapflbatchno=:sapflbatchno";
  21837. // // foreach (ZSPP110 item in result010.TABLE_OUT)
  21838. // // {
  21839. // // oracleParameter = new OracleParameter[]
  21840. // // {
  21841. // // new OracleParameter(":ZTYPE",OracleDbType.Varchar2, item.ZTYPE, ParameterDirection.Input),
  21842. // // new OracleParameter(":ZMSG",OracleDbType.Varchar2, item.ZMSG, ParameterDirection.Input),
  21843. // // new OracleParameter(":barcode",OracleDbType.Varchar2, item.ZSCTM, ParameterDirection.Input),
  21844. // // new OracleParameter(":sapflbatchno",OracleDbType.Varchar2, item.ZBZBS, ParameterDirection.Input),
  21845. // // };
  21846. // // r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  21847. // // }
  21848. // // }
  21849. // // if (result010.ZTYPE != "S")
  21850. // // {
  21851. // // sre.Result = -2;
  21852. // // sre.Message = "同步条码失败," + result010.ZMSG;
  21853. // // return sre;
  21854. // // }
  21855. // //}
  21856. //}
  21857. //else
  21858. //{
  21859. //}
  21860. sqlString = "update tsap_hegii_finishedproduct t set t.ZTime =sysdate, ZTYPE = 'D' where barcode=:barcode and ztype = 'S' and sapflbatchno=:sapflbatchno";
  21861. foreach (DataRow row in fpData.Rows)
  21862. {
  21863. oracleParameter = new OracleParameter[]
  21864. {
  21865. new OracleParameter(":barcode",OracleDbType.Varchar2, row["barcode"], ParameterDirection.Input),
  21866. new OracleParameter(":sapflbatchno",OracleDbType.Varchar2, row["sapflbatchno"], ParameterDirection.Input),
  21867. };
  21868. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  21869. }
  21870. // 删除已同步条码
  21871. // 保留条码同步履历 2020-10-14 by chenxy ztype = 'S'
  21872. //sql = "Delete from tsap_hegii_finishedproduct bar where 1 = 1" + fifter;
  21873. //r = oracleTrConn.ExecuteNonQuery(sql);
  21874. #endregion
  21875. #region 同步产量
  21876. // 潮州 暂时不同步产量 2020-10-25 chenxy
  21877. //Zppfm008 sapParameter = new Zppfm008();
  21878. if (workData != null && workData.Rows.Count > 0)
  21879. {
  21880. //sapParameter.ZSUM = workData.Rows.Count;
  21881. //sapParameter.TABLE_IN = new ZSPP100[sapParameter.ZSUM];
  21882. sqlString = "insert into TSAP_HEGII_WorkData\n" +
  21883. " (YYYYMMDD\n" +
  21884. " ,WorkCode\n" +
  21885. " ,DataCode\n" +
  21886. " ,GoodsCode\n" +
  21887. " ,SAPCode\n" +
  21888. " ,UserCode\n" +
  21889. " ,OutputNum\n" +
  21890. " ,RECOVERYNUM\n" +
  21891. " ,ORDERCODE\n" +
  21892. " ,ORDERITEM\n" +
  21893. " ,zscs\n" +
  21894. " ,LogID,createtime)\n" +
  21895. "values\n" +
  21896. " ('" + yyyymmdd + "'\n" +
  21897. " ,'" + workcode + "'\n" +
  21898. " ,'60'\n" +
  21899. " ,:GoodsCode\n" +
  21900. " ,:SAPCode\n" +
  21901. " ,:UserCode\n" +
  21902. " ,:OutputNum\n" +
  21903. " ,:RECOVERYNUM\n" +
  21904. " ,:ORDERCODE\n" +
  21905. " ,:ORDERITEM\n" +
  21906. " ,:zscs\n" +
  21907. " ," + logid + ",:createtime)";
  21908. int index = 0;
  21909. foreach (DataRow item in workData.Rows)
  21910. {
  21911. //ZSPP100 info100 = new ZSPP100();
  21912. //// 工厂
  21913. //info100.WERKS = workcode;
  21914. //// 型号
  21915. //info100.GROES = item["GoodsCode"].ToString();
  21916. //// 物料编号
  21917. //info100.MATNR = item["SAPCode"].ToString();
  21918. //// 生产工号
  21919. //info100.ZGHNU = item["UserCode"].ToString();
  21920. //// 数据节点
  21921. //info100.ZJDNU = "60";
  21922. //// 时间戳
  21923. //info100.ZSCNU = yyyymmdd;
  21924. //// 销售凭证
  21925. //info100.VBELN = item["ORDERCODE"].ToString().Trim();
  21926. //// 销售凭证项目
  21927. //info100.POSNR = item["ORDERITEM"].ToString();
  21928. //// 产量
  21929. //info100.ZCLNG = item["OutputNum"].ToString();
  21930. //// 损坯
  21931. //info100.ZSPNG = "0";
  21932. //// 清除
  21933. //info100.ZQCNG = "0";
  21934. //// 回收
  21935. //info100.ZHSNG = item["RECOVERYNUM"].ToString();
  21936. //// 干补
  21937. //info100.ZGBNG = "0";
  21938. //// 注浆类型 G高压 L普通
  21939. //info100.ZSCS = item["ZSCS"].ToString();
  21940. //info100.ZKSSJ = now.ToString("HHmmss");
  21941. //info100.ZJSRQ = Convert.ToDecimal(now.ToString("yyyyMMddHHmmss"));
  21942. oracleParameter = new OracleParameter[]
  21943. {
  21944. new OracleParameter(":GoodsCode",OracleDbType.Varchar2, item["GoodsCode"], ParameterDirection.Input),
  21945. new OracleParameter(":SAPCode",OracleDbType.Varchar2, item["SAPCode"], ParameterDirection.Input),
  21946. new OracleParameter(":UserCode",OracleDbType.Varchar2, item["UserCode"], ParameterDirection.Input),
  21947. new OracleParameter(":OutputNum",OracleDbType.Varchar2, item["OutputNum"], ParameterDirection.Input),
  21948. new OracleParameter(":RECOVERYNUM",OracleDbType.Varchar2, item["RECOVERYNUM"], ParameterDirection.Input),
  21949. new OracleParameter(":ORDERCODE",OracleDbType.Varchar2, item["ORDERCODE"], ParameterDirection.Input),
  21950. new OracleParameter(":ORDERITEM",OracleDbType.Varchar2, item["ORDERITEM"], ParameterDirection.Input),
  21951. new OracleParameter(":ZSCS",OracleDbType.Varchar2, item["ZSCS"], ParameterDirection.Input),
  21952. new OracleParameter(":createtime",OracleDbType.Date, item["createtime"], ParameterDirection.Input),
  21953. };
  21954. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  21955. //sapParameter.TABLE_IN[index++] = info100;
  21956. }
  21957. }
  21958. //else
  21959. //{
  21960. // sapParameter.ZSUM = 0;
  21961. // sapParameter.TABLE_IN = new ZSPP100[sapParameter.ZSUM];
  21962. //}
  21963. //2022年9月23日13:06:25 添加时间限制,10月1号零点整不再传输原接口产量数据
  21964. // 当前时间
  21965. //if (now < setTime)
  21966. //{
  21967. //ZPPFM008Response result = SAPDataLogic.HGSAPDK_ZPPFM008(sapParameter, yyyymmdd, "60");
  21968. ////if (result.Ztype == "E")
  21969. ////{
  21970. //// sqlString = "update tsap_hegii_datalog t set t.EndTime = sysdate, DataStuts = 'E', DataMSG = DataMSG||:msg where logid = :logid";
  21971. //// oracleParameter = new OracleParameter[]
  21972. //// {
  21973. //// new OracleParameter(":msg",OracleDbType.Varchar2, result.Zmsg, ParameterDirection.Input),
  21974. //// new OracleParameter(":logid",OracleDbType.Int32, logid, ParameterDirection.Input),
  21975. //// };
  21976. //// r = oracleConn.ExecuteNonQuery(sqlString, oracleParameter);
  21977. ////}
  21978. ////else
  21979. //if (result.TABLE_OUT != null && result.TABLE_OUT.Length > 0)
  21980. //{
  21981. // sqlString = "update TSAP_HEGII_WorkData t set t.ZTime =sysdate, ZTYPE = :ZTYPE, ZMSG = :ZMSG where logid = " + logid +
  21982. // " \n and YYYYMMDD='" + yyyymmdd + "' and WorkCode='" + workcode +
  21983. // "' and DataCode='60' and GoodsCode=:GoodsCode and SAPCode=:SAPCode and UserCode=:UserCode \n" +
  21984. // "and OrderCode=:OrderCode and OrderItem=:OrderItem";
  21985. // foreach (ZSPP100 item in result.TABLE_OUT)
  21986. // {
  21987. // string posnr = item.POSNR.TrimStart('0');
  21988. // oracleParameter = new OracleParameter[]
  21989. // {
  21990. // new OracleParameter(":ZTYPE",OracleDbType.Varchar2, item.ZTYPE, ParameterDirection.Input),
  21991. // new OracleParameter(":ZMSG",OracleDbType.Varchar2, item.ZMSG, ParameterDirection.Input),
  21992. // new OracleParameter(":GoodsCode",OracleDbType.Varchar2, item.GROES, ParameterDirection.Input),
  21993. // new OracleParameter(":SAPCode",OracleDbType.Varchar2, item.MATNR, ParameterDirection.Input),
  21994. // new OracleParameter(":UserCode",OracleDbType.Varchar2, item.ZGHNU, ParameterDirection.Input),
  21995. // new OracleParameter(":OrderCode",OracleDbType.Varchar2, (string.IsNullOrEmpty(item.VBELN) ? " " : item.VBELN), ParameterDirection.Input),
  21996. // new OracleParameter(":OrderItem",OracleDbType.Varchar2, (string.IsNullOrEmpty(posnr) ? "0" : posnr), ParameterDirection.Input),
  21997. // };
  21998. // r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  21999. // }
  22000. // //:msg||chr(13)||DataMSG
  22001. // result.ZMSG = $"{result.ZMSG}({sapParameter.ZSUM})";
  22002. // sqlString = "update tsap_hegii_datalog t set t.EndTime = sysdate, DataStuts = :DataStuts, DataMSG =nvl2(:msg,:msg||' '||chr(13)||DataMSG,DataMSG) where logid = :logid";
  22003. // oracleParameter = new OracleParameter[]
  22004. // {
  22005. // new OracleParameter(":DataStuts",OracleDbType.Varchar2, result.ZTYPE, ParameterDirection.Input),
  22006. // new OracleParameter(":msg",OracleDbType.Varchar2, result.ZMSG, ParameterDirection.Input),
  22007. // new OracleParameter(":logid",OracleDbType.Int32, logid, ParameterDirection.Input),
  22008. // };
  22009. // r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  22010. //}
  22011. //if (result.ZTYPE != "S")
  22012. //{
  22013. // sre.Result = -2;
  22014. // sre.Message = "同步产量失败," + result.ZMSG;
  22015. // return sre;
  22016. //}
  22017. //sqlString =
  22018. //"UPDATE tp_pm_groutingdailydetail bar\n" +
  22019. //" SET bar.issync = NULL\n" +
  22020. //" WHERE 1 = 1" + fifter;
  22021. //r = oracleTrConn.ExecuteNonQuery(sqlString);
  22022. //}
  22023. //else
  22024. //{
  22025. //}
  22026. #endregion
  22027. #region 调新报工接口
  22028. workcode = "5200";
  22029. sqlString = @"
  22030. SELECT TO_CHAR(SYSDATE, 'YYYYMMDD') AS YYYYMMDD,
  22031. SYSDATE AS CREATETIME,
  22032. TT.GOODSCODE GROES,
  22033. TT.SAPCODE MATNR,
  22034. TT.USERCODE ZGHNU,
  22035. TT.ORDERCODE VBELN,
  22036. TT.ORDERITEM POSNR,
  22037. 'C' AS ZSCMS,
  22038. 'T' AS ZSCS,
  22039. TO_CHAR(TT.OUTPUTNUM) AS ZCLNG,
  22040. TO_CHAR(TT.RECOVERYNUM) AS ZHSNG,
  22041. TO_CHAR(5200) WERKS,
  22042. '60' ZJDNU,
  22043. TO_CHAR(SYSDATE, 'YYYYMMDD') ZSCNU,
  22044. TO_CHAR(SYSDATE, 'HH24MISS') ZKSSJ,
  22045. TO_CHAR(SYSDATE, 'YYYYMMDDHH24MISS') ZJSRQ,
  22046. '0' ZSPNG,
  22047. '0' ZQCNG,
  22048. '0' ZGBNG,
  22049. TO_CHAR(TT.WORKSHOP) ZSCCJ,
  22050. '0' DATACODE,
  22051. TT.CHARG
  22052. FROM (SELECT T.GOODSCODE,
  22053. T.SAPCODE,
  22054. T.USERCODE,
  22055. T.ORDERCODE,
  22056. T.ORDERITEM,
  22057. T.WORKSHOP,
  22058. T.CHARG,
  22059. 0 - SUM(DECODE(T.RECYCLINGFLAG, '1', 0, 1)) OUTPUTNUM,
  22060. 0 - SUM(DECODE(T.RECYCLINGFLAG, '0', 0, 1)) RECOVERYNUM
  22061. FROM (SELECT BAR.GOODSCODE,
  22062. BAR.MATERIALCODE SAPCODE,
  22063. GH.FHUSERCODE USERCODE,
  22064. O.ORDERNO,
  22065. BAR.RECYCLINGFLAG,
  22066. CASE
  22067. WHEN O.ORDERID IS NULL
  22068. OR O.ORDERNO LIKE 'HEGII%' THEN
  22069. ' '
  22070. WHEN INSTR(O.ORDERNO, '/') = 0 THEN
  22071. TO_CHAR(O.ORDERNO)
  22072. ELSE
  22073. TO_CHAR(SUBSTR(O.ORDERNO, 1, INSTR(O.ORDERNO, '/') - 1))
  22074. END ORDERCODE -- 销售凭证
  22075. ,
  22076. CASE
  22077. WHEN O.ORDERID IS NULL
  22078. OR O.ORDERNO LIKE 'HEGII%'
  22079. OR INSTR(O.ORDERNO, '/') = 0 THEN
  22080. '0'
  22081. WHEN INSTR(O.ORDERNO, '#') = 0 THEN
  22082. TO_CHAR(SUBSTR(O.ORDERNO, INSTR(O.ORDERNO, '/') + 1))
  22083. ELSE
  22084. TO_CHAR(SUBSTR(O.ORDERNO
  22085. ,INSTR(O.ORDERNO, '/') + 1
  22086. ,INSTR(O.ORDERNO, '#') - INSTR(O.ORDERNO, '/') - 1))
  22087. END ORDERITEM,
  22088. 1 AS WORKSHOP,
  22089. -- TO_CHAR(GH.FHTIME, 'yyyymm') AS CHARG
  22090. TO_CHAR(GH.FHTIME, 'yymm') || :WORKCODE || 'E' AS CHARG
  22091. FROM TP_PM_GROUTINGDAILYDETAIL BAR
  22092. INNER JOIN TP_PM_FINISHEDPRODUCT GH
  22093. ON BAR.GROUTINGDAILYDETAILID = GH.GROUTINGDAILYDETAILID
  22094. INNER JOIN TP_MST_GOODS G
  22095. ON G.GOODSID = BAR.GOODSID
  22096. INNER JOIN TP_MST_GOODSTYPE GT
  22097. ON GT.GOODSTYPEID = G.GOODSTYPEID
  22098. LEFT JOIN TP_PM_ORDER O
  22099. ON O.ORDERID = GH.FHORDERID
  22100. WHERE 1 = 1 " + fifter + @") T
  22101. GROUP BY T.GOODSCODE,
  22102. T.SAPCODE,
  22103. T.USERCODE,
  22104. T.ORDERCODE,
  22105. T.ORDERITEM,
  22106. T.WORKSHOP,
  22107. T.CHARG) TT
  22108. WHERE TT.OUTPUTNUM <> 0
  22109. OR TT.RECOVERYNUM <> 0
  22110. ORDER BY TT.GOODSCODE,
  22111. TT.SAPCODE,
  22112. TT.USERCODE,
  22113. TT.ORDERCODE,
  22114. TT.ORDERITEM,
  22115. TT.WORKSHOP,
  22116. TT.CHARG ";
  22117. oracleParameter = new OracleParameter[]
  22118. {
  22119. new OracleParameter(":WORKCODE", workcode)
  22120. };
  22121. DataTable workData5000 = oracleTrConn.GetSqlResultToDt(sqlString, oracleParameter);
  22122. //string logid_bg = oracleTrConn.GetSqlResultToStr("select SEQ_TSAP_DATALOG_BG.Nextval from dual");
  22123. sqlString = "insert into tsap_hegii_datalog_bg\n" +
  22124. " (LogID\n" +
  22125. " ,LogType\n" +
  22126. " ,BeginTime\n" +
  22127. " ,YYYYMMDD\n" +
  22128. " ,WorkCode\n" +
  22129. " ,DataCode\n" +
  22130. " ,DataStuts\n" +
  22131. " ,DataMSG\n" +
  22132. " ,DATALOGID\n" +
  22133. " ,EXECUTEDATEBEGIN\n" +
  22134. " ,EXECUTEDATEEND,SAPGUID)\n" +
  22135. "values\n" +
  22136. " (:LogID\n" +
  22137. " ,'2'\n" +
  22138. " ,sysdate\n" +
  22139. " ,:YYYYMMDD\n" +
  22140. " ,'5200'\n" +
  22141. " ,'60'\n" +
  22142. " ,'F'\n" +
  22143. " ,:DataMSG\n" +
  22144. " ,:LogID\n" +
  22145. " ,sysdate\n" +
  22146. " ,sysdate,sys_guid())";
  22147. oracleParameter = new OracleParameter[]
  22148. {
  22149. new OracleParameter(":LogID",OracleDbType.Int32, logid_bg, ParameterDirection.Input),
  22150. new OracleParameter(":YYYYMMDD",OracleDbType.Varchar2, yyyymmdd, ParameterDirection.Input),
  22151. new OracleParameter(":DataMSG",OracleDbType.Varchar2, "", ParameterDirection.Input),
  22152. };
  22153. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  22154. sqlString = "insert into TSAP_HEGII_WORKDATA_BG\n" +
  22155. " (YYYYMMDD\n" +
  22156. " ,WorkCode\n" +
  22157. " ,DataCode\n" +
  22158. " ,GoodsCode\n" +
  22159. " ,SAPCode\n" +
  22160. " ,UserCode\n" +
  22161. " ,WORKSHOP\n" +
  22162. " ,OutputNum\n" +
  22163. " ,RECOVERYNUM\n" +
  22164. " ,ORDERCODE\n" +
  22165. " ,ORDERITEM\n" +
  22166. " ,testmouldflag\n" +
  22167. " ,zscs\n" +
  22168. " ,LogID,createtime,workdataid,charg)\n" +
  22169. "values\n" +
  22170. " ('" + yyyymmdd + "'\n" +
  22171. " ,'5200'\n" +
  22172. " ,'60'\n" +
  22173. " ,:GoodsCode\n" +
  22174. " ,:SAPCode\n" +
  22175. " ,:UserCode\n" +
  22176. " ,:ZSCCJ\n" +
  22177. " ,:OutputNum\n" +
  22178. " ,:RECOVERYNUM\n" +
  22179. " ,:ORDERCODE\n" +
  22180. " ,:ORDERITEM\n" +
  22181. " ,:testmouldflag\n" +
  22182. " ,:zscs\n" +
  22183. " ," + logid_bg + ",:createtime,:workdataid,:charg)";
  22184. foreach (DataRow item in workData5000.Rows)
  22185. {
  22186. string workdataid = oracleTrConn.GetSqlResultToStr("select SEQ_HEGII_WORKDATA_BG.Nextval from dual");
  22187. oracleParameter = new OracleParameter[]
  22188. {
  22189. new OracleParameter(":GoodsCode", item["GROES"].ToString()),
  22190. new OracleParameter(":SAPCode", item["MATNR"].ToString()),
  22191. new OracleParameter(":UserCode", item["ZGHNU"].ToString()),
  22192. new OracleParameter(":ZSCCJ", item["ZSCCJ"].ToString()),
  22193. new OracleParameter(":OutputNum", item["ZCLNG"].ToString()),
  22194. new OracleParameter(":RECOVERYNUM", item["ZHSNG"].ToString()),
  22195. new OracleParameter(":ORDERCODE", item["VBELN"].ToString()),
  22196. new OracleParameter(":ORDERITEM", item["POSNR"].ToString()),
  22197. new OracleParameter(":testmouldflag", item["ZSCMS"].ToString()),
  22198. new OracleParameter(":zscs", item["ZSCS"].ToString()),
  22199. new OracleParameter(":createtime", OracleDbType.Date,item["createtime"], ParameterDirection.Input),
  22200. new OracleParameter(":workdataid", workdataid),
  22201. new OracleParameter(":charg", item["CHARG"].ToString()),
  22202. };
  22203. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  22204. }
  22205. //sqlString = "SELECT TO_CHAR(wd.yyyymmdd) yyyymmdd\n" +
  22206. // " ,TO_CHAR(5200) WERKS\n" +
  22207. // " ,TO_CHAR(wd.goodscode) GROES\n" +
  22208. // " ,TO_CHAR(wd.sapcode) MATNR\n" +
  22209. // " ,TO_CHAR(wd.usercode) ZGHNU\n" +
  22210. // " ,TO_CHAR(wd.datacode) ZJDNU\n" +
  22211. // " ,to_char(sysdate, 'YYYYMMDD' ) ZSCNU\n" +
  22212. // " ,to_char(sysdate, 'HH24MISS' ) ZKSSJ\n" +
  22213. // " ,to_char(sysdate, 'YYYYMMDDHH24MISS' ) ZJSRQ\n" +
  22214. // " ,TO_CHAR(wd.ordercode) VBELN\n" +
  22215. // " ,TO_CHAR(wd.orderitem) POSNR\n" +
  22216. // " ,TO_CHAR(wd.outputnum) ZCLNG\n" +
  22217. // " ,TO_CHAR(wd.scrapnum) ZSPNG\n" +
  22218. // " ,TO_CHAR(wd.cleanupnum) ZQCNG\n" +
  22219. // " ,TO_CHAR(wd.recoverynum) ZHSNG\n" +
  22220. // " ,TO_CHAR(wd.repairnum) ZGBNG\n" +
  22221. // " ,TO_CHAR(wd.testmouldflag) ZSCMS\n" +
  22222. // " -- ,TO_CHAR(wd.zscs) zscs\n" +
  22223. // " ,'T' AS zscs\n" +
  22224. // " ,TO_CHAR(wd.WORKSHOP) ZSCCJ\n" +
  22225. // " ,WD.CHARG\n" +
  22226. // " ,TO_CHAR(60) datacode\n" +
  22227. // " ,'5200' || WD.CHARG || LPAD(DL.LOGID, 10,'0') AS ZID\n" +
  22228. // " FROM tsap_hegii_workdata_bg wd\n" +
  22229. // " INNER JOIN TSAP_HEGII_DATALOG_BG DL\n" +
  22230. // " ON wd.LOGID = DL.LOGID \n" +
  22231. // " WHERE wd.logid = :logid";
  22232. //OracleParameter[] par = null;
  22233. //par = new OracleParameter[]
  22234. //{
  22235. // new OracleParameter(":logid", OracleDbType.Int32, logid_bg, ParameterDirection.Input),
  22236. //};
  22237. //DataTable dtt = oracleTrConn.GetSqlResultToDt(sqlString, par);
  22238. //int num = dtt.Rows.Count;
  22239. //string sq = "select SAP_INI_BG from TP_SYS_SAPCONFIG";
  22240. //string SAP_ING_NEW = oracleTrConn.GetSqlResultToStr(sq);
  22241. //if (SAP_ING_NEW == "1")
  22242. ////if (true)
  22243. //{
  22244. // // 调用SAP接口
  22245. // string postString = "{\"ZSUM\":" + num.ToString() + ",\"TABLE_IN\":{\"item\":" + JsonHelper.ToJson(ModelConvertHelper<BGToSAP>.ConvertToModel(dtt)) + "}}";
  22246. // INIUtility ini = INIUtility.Instance(INIUtility.IniFile.SAP_HEGII);
  22247. // string url030 = ini.ReadIniData("SAP_NEW_INFO", "Url030");
  22248. // //string url030 = "http://hgs4podev.hegii.com:50200/RESTAdapter/DKMES/ZPPFM030";
  22249. // string result = string.Empty;
  22250. // try
  22251. // {
  22252. // result = SAPDataLogic.PostData(url030, postString, "POST");
  22253. // if (JObject.Parse(result)["TABLE_OUT"] != null && JObject.Parse(result)["TABLE_OUT"].ToString().Length > 0)
  22254. // {
  22255. // sqlString = "update TSAP_HEGII_WorkData_bg t set t.ZTime =sysdate, ZTYPE = :ZTYPE, ZMSG = :ZMSG where logid = " + logid_bg +
  22256. // " \n and YYYYMMDD='" + yyyymmdd + "' and WorkCode='" + workcode +
  22257. // "' and DataCode='60' and GoodsCode=:GoodsCode and SAPCode=:SAPCode and UserCode=:UserCode \n" +
  22258. // "and OrderCode=:OrderCode and OrderItem=:OrderItem";
  22259. // Dictionary<string, object> obj = JsonConvert.DeserializeObject<Dictionary<string, object>>(result);
  22260. // object TABLE_OUT;
  22261. // obj.TryGetValue("TABLE_OUT", out TABLE_OUT);
  22262. // obj = JsonConvert.DeserializeObject<Dictionary<string, object>>(TABLE_OUT + "");
  22263. // object item1;
  22264. // obj.TryGetValue("item", out item1);
  22265. // JArray arr = JArray.FromObject(item1);
  22266. // foreach (JObject item60 in arr)
  22267. // {
  22268. // string posnr = item60["POSNR"].ToString().TrimStart('0');
  22269. // oracleParameter = new OracleParameter[]
  22270. // {
  22271. // new OracleParameter(":ZTYPE",OracleDbType.Varchar2, item60["ZTYPE"].ToString(), ParameterDirection.Input),
  22272. // new OracleParameter(":ZMSG",OracleDbType.Varchar2, item60["ZMSG"].ToString(), ParameterDirection.Input),
  22273. // new OracleParameter(":GoodsCode",OracleDbType.Varchar2, item60["GROES"].ToString(), ParameterDirection.Input),
  22274. // new OracleParameter(":SAPCode",OracleDbType.Varchar2, item60["MATNR"].ToString(), ParameterDirection.Input),
  22275. // new OracleParameter(":UserCode",OracleDbType.Varchar2, item60["ZGHNU"].ToString(), ParameterDirection.Input),
  22276. // new OracleParameter(":OrderCode",OracleDbType.Varchar2, (string.IsNullOrEmpty(item60["VBELN"].ToString()) ? " " : item60["VBELN"].ToString()), ParameterDirection.Input),
  22277. // new OracleParameter(":Orderitem",OracleDbType.Varchar2, ((string.IsNullOrEmpty(posnr)) ? "0" : posnr), ParameterDirection.Input),
  22278. // };
  22279. // r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  22280. // }
  22281. // //:msg||chr(13)||DataMSG
  22282. // JObject.Parse(result)["ZMSG"] = $"{JObject.Parse(result)["ZMSG"]}({num})";
  22283. // sqlString = "update tsap_hegii_datalog_bg t set t.EndTime = sysdate, DataStuts = :DataStuts, DataMSG =nvl2(:msg,:msg||' '||chr(13)||DataMSG,DataMSG) where logid = :logid";
  22284. // oracleParameter = new OracleParameter[]
  22285. // {
  22286. // new OracleParameter(":DataStuts",OracleDbType.Varchar2, JObject.Parse(result)["ZTYPE"].ToString(), ParameterDirection.Input),
  22287. // new OracleParameter(":msg",OracleDbType.Varchar2, JObject.Parse(result)["ZMSG"].ToString(), ParameterDirection.Input),
  22288. // new OracleParameter(":logid",OracleDbType.Int32, logid_bg, ParameterDirection.Input),
  22289. // };
  22290. // r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  22291. // }
  22292. // if (JObject.Parse(result)["ZTYPE"].ToString() != "S")
  22293. // {
  22294. // sre.Result = -2;
  22295. // sre.Message = "同步产量失败," + JObject.Parse(result)["ZMSG"].ToString();
  22296. // return sre;
  22297. // }
  22298. // //sqlString =
  22299. // //"UPDATE tp_pm_groutingdailydetail bar\n" +
  22300. // //" SET bar.issync = '1'\n" +
  22301. // //" WHERE 1 = 1" + fifter;
  22302. // }
  22303. // catch (Exception ex)
  22304. // {
  22305. // sre.Result = -2;
  22306. // sre.Message = "sap030接口同步失败," + ex.Message;
  22307. // return sre;
  22308. // ////:msg||chr(13)||DataMSG
  22309. // //sqlString = "update tsap_hegii_datalog_bg t set t.EndTime = sysdate, DataStuts = :DataStuts, DataMSG =nvl2(:msg,:msg||' '||chr(13)||DataMSG,DataMSG) where logid = :logid";
  22310. // //oracleParameter = new OracleParameter[]
  22311. // //{
  22312. // // new OracleParameter(":DataStuts",OracleDbType.Varchar2, "E", ParameterDirection.Input),
  22313. // // new OracleParameter(":msg",OracleDbType.Varchar2, ex.Message, ParameterDirection.Input),
  22314. // // new OracleParameter(":logid",OracleDbType.Int32, logid_bg, ParameterDirection.Input),
  22315. // //};
  22316. // //r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  22317. // }
  22318. // //r = oracleTrConn.ExecuteNonQuery(sqlString);
  22319. //}
  22320. #endregion
  22321. #endregion
  22322. #region 产成品交接撤销
  22323. // 本批交接的批次号
  22324. for (int i = 0; i < dtData.Rows.Count; i++)
  22325. {
  22326. #region 查询产品相关信息
  22327. // 撤销记录
  22328. sql = "INSERT INTO TP_PM_FHUndo\n" +
  22329. " (GroutingDailyDetailID\n" +
  22330. " ,GoodsLevelTypeID\n" +
  22331. " ,FHUserID\n" +
  22332. " ,FHUserCode\n" +
  22333. " ,FHBatchNo\n" +
  22334. " ,FHTime\n" +
  22335. " ,FHOrderID\n" +
  22336. " ,OnlyCode\n" +
  22337. " ,FINISHEDLOADBATCHNO\n" +
  22338. " ,AccountID\n" +
  22339. " ,CreateUserID)\n" +
  22340. " SELECT t.groutingdailydetailid\n" +
  22341. " ,t.GoodsLevelTypeID\n" +
  22342. " ,t.fhuserid\n" +
  22343. " ,t.fhusercode\n" +
  22344. " ,t.fhbatchno\n" +
  22345. " ,t.fhtime\n" +
  22346. " ,t.FHOrderID\n" +
  22347. " ,t.onlycode\n" +
  22348. " ,t.FINISHEDLOADBATCHNO\n" +
  22349. " ,t.AccountID\n" +
  22350. " ,:UpdateUserID\n" +
  22351. " FROM TP_PM_FinishedProduct t\n" +
  22352. " WHERE t.barcode = :BarCode";
  22353. Paras = new OracleParameter[]
  22354. {
  22355. new OracleParameter(":BarCode",OracleDbType.NVarchar2,dtData.Rows[i]["barcode"],ParameterDirection.Input),
  22356. new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  22357. };
  22358. int resultRow = oracleTrConn.ExecuteNonQuery(sql, Paras);
  22359. // SAP同步后再成品交接撤销的,记录撤销标识
  22360. string sapsql = null;
  22361. //string sapsql = "select count(*) from tsap_hegii_FinishedProduct t where t.barcode = :BarCode and ztype='S' and rownum=1 ";
  22362. OracleParameter[] sapparas = new OracleParameter[]
  22363. {
  22364. new OracleParameter(":BarCode",OracleDbType.NVarchar2,dtData.Rows[i]["barcode"],ParameterDirection.Input),
  22365. };
  22366. //int sapcount = Convert.ToInt32(oracleTrConn.GetSqlResultToObj(sapsql, sapparas));
  22367. //if (sapcount > 0)
  22368. {
  22369. sapsql = "update tp_pm_groutingdailydetail set SAPFHUndoFlag = '1' where barcode=:BarCode";
  22370. oracleTrConn.ExecuteNonQuery(sapsql, sapparas);
  22371. }
  22372. // 保留条码同步履历 2020-10-14 by chenxy ztype = 'S'
  22373. //sapsql = "update tsap_hegii_FinishedProduct set ztype = 'D' where barcode=:BarCode and (ztype is null or ztype not in ('S','D'))";
  22374. //sapsql = "update tsap_hegii_FinishedProduct set ztype = 'D' where barcode=:BarCode and (ztype is null or ztype = 'S')";
  22375. oracleTrConn.ExecuteNonQuery(sapsql, sapparas);
  22376. sql = @"Update TP_PM_FinishedProduct
  22377. set FHUserID=null,
  22378. FHUserCode=null,
  22379. FHBatchNo=null,
  22380. FHTime=null,
  22381. FHOrderID=null,
  22382. --FINISHEDLOADBATCHNO=null,
  22383. UpdateUserID=:UpdateUserID
  22384. where BarCode=:BarCode";
  22385. resultRow = oracleTrConn.ExecuteNonQuery(sql, Paras);
  22386. #endregion
  22387. }
  22388. #endregion
  22389. #region 同步WMS系统
  22390. if (fpData.Rows.Count > 0)
  22391. {
  22392. //string message = WMSDataLogic.BackPushWMS(fpData, now);
  22393. // 同步日志
  22394. sqlString = @"
  22395. INSERT INTO TP_WMS_LOG
  22396. (LOGTYPE,
  22397. SPS,
  22398. SKU,
  22399. SERIALNO,
  22400. ADDDAY,
  22401. ADDTIME,
  22402. CODEI,
  22403. UDF1,
  22404. UDF2,
  22405. LPN,
  22406. RETURNDESC,
  22407. ACCOUNTID,
  22408. CREATETIME,
  22409. UPDATETIME,
  22410. CREATEUSERID,
  22411. UPDATEUSERID,
  22412. BGLOGID)
  22413. VALUES
  22414. (:LOGTYPE,
  22415. :SPS,
  22416. :SKU,
  22417. :SERIALNO,
  22418. :ADDDAY,
  22419. :ADDTIME,
  22420. :CODEI,
  22421. :UDF1,
  22422. :UDF2,
  22423. :LPN,
  22424. :RETURNDESC,
  22425. :ACCOUNTID,
  22426. :CREATETIME,
  22427. :CREATETIME,
  22428. :USERID,
  22429. :USERID,
  22430. :BGLOGID) ";
  22431. string orderitem;
  22432. foreach (DataRow row in fpData.Rows)
  22433. {
  22434. orderitem = row["orderitem"] + "";
  22435. if (string.IsNullOrEmpty(orderitem) || "0".Equals(orderitem))
  22436. {
  22437. orderitem = "000000";
  22438. }
  22439. oracleParameter = new OracleParameter[]
  22440. {
  22441. new OracleParameter(":LOGTYPE",OracleDbType.Int32, 2, ParameterDirection.Input),
  22442. new OracleParameter(":SPS",OracleDbType.Varchar2, workcode, ParameterDirection.Input),
  22443. new OracleParameter(":SKU",OracleDbType.Varchar2, row["sapcode"], ParameterDirection.Input),
  22444. new OracleParameter(":SERIALNO",OracleDbType.Varchar2, row["outcode"], ParameterDirection.Input),
  22445. new OracleParameter(":ADDDAY",OracleDbType.Varchar2, now.ToString("yyyyMMdd"), ParameterDirection.Input),
  22446. new OracleParameter(":ADDTIME",OracleDbType.Varchar2, now.ToString("HHmmss"), ParameterDirection.Input),
  22447. new OracleParameter(":CODEI",OracleDbType.Varchar2, row["barcode"], ParameterDirection.Input),
  22448. new OracleParameter(":UDF1",OracleDbType.Varchar2, row["ordercode"], ParameterDirection.Input),
  22449. new OracleParameter(":UDF2",OracleDbType.Varchar2, orderitem, ParameterDirection.Input),
  22450. new OracleParameter(":LPN",OracleDbType.Varchar2, row["sapflbatchno"], ParameterDirection.Input),
  22451. new OracleParameter(":RETURNDESC",OracleDbType.Varchar2, "未同步", ParameterDirection.Input),
  22452. new OracleParameter(":ACCOUNTID",OracleDbType.Varchar2, sUserInfo.AccountID, ParameterDirection.Input),
  22453. new OracleParameter(":CREATETIME",OracleDbType.Date, now, ParameterDirection.Input),
  22454. new OracleParameter(":USERID",OracleDbType.Varchar2, sUserInfo.UserID, ParameterDirection.Input),
  22455. new OracleParameter(":BGLOGID", OracleDbType.Int32, logid_bg, ParameterDirection.Input)
  22456. };
  22457. r = oracleTrConn.ExecuteNonQuery(sqlString, oracleParameter);
  22458. }
  22459. }
  22460. #endregion
  22461. #region 回收包材库库存
  22462. //INIUtility ini = INIUtility.Instance(INIUtility.IniFile.SAP_HEGII);
  22463. //string packingURL = ini.ReadIniData("SAP_HEGII", "PackingURL");
  22464. //foreach (DataRow row in workData.Rows)
  22465. //{
  22466. // string url = packingURL + row["sapcode"] + "&num=" + row["outputnum"];
  22467. // WebRequest req = WebRequest.Create(url);
  22468. // req.Method = "GET";
  22469. // Stream stream = req.GetResponse().GetResponseStream();
  22470. // StreamReader reader = new StreamReader(stream);
  22471. // JObject json = JObject.Parse(reader.ReadToEnd());
  22472. // if (json["success"].ToString() == "false")
  22473. // {
  22474. // sre.Result = -2;
  22475. // sre.Message = json["message"].ToString();
  22476. // return sre;
  22477. // }
  22478. //}
  22479. #endregion
  22480. sre.Result = 1;
  22481. oracleTrConn.Commit();
  22482. oracleTrConn.Disconnect();
  22483. return sre;
  22484. }
  22485. catch (Exception ex)
  22486. {
  22487. if (oracleTrConn.ConnState == System.Data.ConnectionState.Open)
  22488. {
  22489. oracleTrConn.Rollback();
  22490. oracleTrConn.Disconnect();
  22491. }
  22492. throw ex;
  22493. }
  22494. finally
  22495. {
  22496. if (oracleTrConn.ConnState == ConnectionState.Open)
  22497. {
  22498. oracleTrConn.Disconnect();
  22499. }
  22500. }
  22501. }
  22502. #endregion
  22503. /// <summary>
  22504. /// 撤销产成品交接
  22505. /// </summary>
  22506. /// <param name="barcode"></param>
  22507. /// <param name="sUserInfo"></param>
  22508. /// <returns></returns>
  22509. public static ServiceResultEntity SaveCancelFinishedHandoverByBarcode(string barcode, SUserInfo sUserInfo)
  22510. {
  22511. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  22512. try
  22513. {
  22514. ServiceResultEntity resultEntity = new ServiceResultEntity();
  22515. // 1.判断产品是否在产成品表中
  22516. string sql = @"select
  22517. FHUserID,
  22518. FHUserCode,
  22519. GoodsID,
  22520. GoodsCode,
  22521. GoodsName
  22522. from TP_PM_FinishedProduct
  22523. where BarCode=:BarCode";
  22524. OracleParameter[] paras = new OracleParameter[]{
  22525. new OracleParameter(":BarCode",OracleDbType.NVarchar2,barcode,ParameterDirection.Input),
  22526. };
  22527. DataSet dsResult = oracleTrConn.GetSqlResultToDs(sql, paras);
  22528. if (dsResult != null && dsResult.Tables[0].Rows.Count > 0)
  22529. {
  22530. // 在产成品表中
  22531. #region 是否交接过
  22532. string fhUserCode = dsResult.Tables[0].Rows[0]["FHUserCode"].ToString();
  22533. if (string.IsNullOrEmpty(fhUserCode))
  22534. {
  22535. resultEntity.Result = -1; //未交接,不能撤销
  22536. resultEntity.Message = "此产品【" + barcode + "】未交接,不能进行该操作";
  22537. return resultEntity;
  22538. }
  22539. #endregion
  22540. }
  22541. else
  22542. {
  22543. resultEntity.Result = -2; //不能产成品,不能撤销
  22544. sql = "select GoodsCode from TP_PM_GroutingDailyDetail where BarCode=:BarCode";
  22545. dsResult = oracleTrConn.GetSqlResultToDs(sql, paras);
  22546. if (dsResult != null && dsResult.Tables[0].Rows.Count > 0)
  22547. {
  22548. resultEntity.Message = "此产品【" + barcode + "】不是产成品,不能进行该操作";
  22549. }
  22550. else
  22551. {
  22552. resultEntity.Message = "此条码【" + barcode + "】无效,不能进行该操作";
  22553. }
  22554. return resultEntity;
  22555. }
  22556. #region 查询产品相关信息
  22557. // 撤销记录
  22558. string sqlString = "INSERT INTO TP_PM_FHUndo\n" +
  22559. " (GroutingDailyDetailID\n" +
  22560. " ,GoodsLevelTypeID\n" +
  22561. " ,FHUserID\n" +
  22562. " ,FHUserCode\n" +
  22563. " ,FHBatchNo\n" +
  22564. " ,FHTime\n" +
  22565. " ,FHOrderID\n" +
  22566. " ,OnlyCode\n" +
  22567. " ,FINISHEDLOADBATCHNO\n" +
  22568. " ,AccountID\n" +
  22569. " ,CreateUserID)\n" +
  22570. " SELECT t.groutingdailydetailid\n" +
  22571. " ,t.GoodsLevelTypeID\n" +
  22572. " ,t.fhuserid\n" +
  22573. " ,t.fhusercode\n" +
  22574. " ,t.fhbatchno\n" +
  22575. " ,t.fhtime\n" +
  22576. " ,t.FHOrderID\n" +
  22577. " ,t.onlycode\n" +
  22578. " ,t.FINISHEDLOADBATCHNO\n" +
  22579. " ,t.AccountID\n" +
  22580. " ,:UpdateUserID\n" +
  22581. " FROM TP_PM_FinishedProduct t\n" +
  22582. " WHERE t.barcode = :BarCode";
  22583. paras = new OracleParameter[]{
  22584. new OracleParameter(":BarCode",OracleDbType.NVarchar2,barcode,ParameterDirection.Input),
  22585. new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  22586. };
  22587. int resultRow = oracleTrConn.ExecuteNonQuery(sqlString, paras);
  22588. // SAP同步后再成品交接撤销的,记录撤销标识
  22589. string sapsql = "select count(*) from tsap_hegii_FinishedProduct t where t.barcode = :BarCode and ztype='S' and rownum=1 ";
  22590. OracleParameter[] sapparas = new OracleParameter[]{
  22591. new OracleParameter(":BarCode",OracleDbType.NVarchar2,barcode,ParameterDirection.Input),
  22592. };
  22593. int sapcount = Convert.ToInt32(oracleTrConn.GetSqlResultToObj(sapsql, sapparas));
  22594. if (sapcount > 0)
  22595. {
  22596. sapsql = "update tp_pm_groutingdailydetail set SAPFHUndoFlag = '1' where barcode=:BarCode";
  22597. oracleTrConn.ExecuteNonQuery(sapsql, sapparas);
  22598. }
  22599. sapsql = "update tsap_hegii_FinishedProduct set ztype = 'D' where barcode=:BarCode and (ztype is null or ztype not in ('S','D'))";
  22600. oracleTrConn.ExecuteNonQuery(sapsql, sapparas);
  22601. sql = @"Update TP_PM_FinishedProduct
  22602. set FHUserID=null,
  22603. FHUserCode=null,
  22604. FHBatchNo=null,
  22605. FHTime=null,
  22606. FHOrderID=null,FINISHEDLOADBATCHNO=null,
  22607. UpdateUserID=:UpdateUserID
  22608. where BarCode=:BarCode";
  22609. resultRow = oracleTrConn.ExecuteNonQuery(sql, paras);
  22610. if (resultRow == 0)
  22611. {
  22612. oracleTrConn.Rollback();
  22613. oracleTrConn.Disconnect();
  22614. }
  22615. else
  22616. {
  22617. resultEntity.Result = 1;
  22618. oracleTrConn.Commit();
  22619. oracleTrConn.Disconnect();
  22620. }
  22621. #endregion
  22622. return resultEntity;
  22623. }
  22624. catch (Exception ex)
  22625. {
  22626. throw ex;
  22627. }
  22628. }
  22629. /// <summary>
  22630. /// 更改产成品交接订单号
  22631. /// </summary>
  22632. /// <param name="barcode"></param>
  22633. /// <param name="orderid"></param>
  22634. /// <param name="sUserInfo"></param>
  22635. /// <returns></returns>
  22636. public static ServiceResultEntity SaveChangeFinishedHandoverByBarcode(string barcode, int orderid, SUserInfo sUserInfo)
  22637. {
  22638. IDBTransaction oracleTrConn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
  22639. try
  22640. {
  22641. ServiceResultEntity resultEntity = new ServiceResultEntity();
  22642. // 1.判断产品是否在产成品表中
  22643. string sql = @"select
  22644. FHUserID,
  22645. FHUserCode,
  22646. GoodsID,
  22647. GoodsCode,
  22648. GoodsName
  22649. from TP_PM_FinishedProduct
  22650. where BarCode=:BarCode";
  22651. OracleParameter[] paras = new OracleParameter[]{
  22652. new OracleParameter(":BarCode",OracleDbType.NVarchar2,barcode,ParameterDirection.Input),
  22653. };
  22654. DataSet dsResult = oracleTrConn.GetSqlResultToDs(sql, paras);
  22655. if (dsResult != null && dsResult.Tables[0].Rows.Count > 0)
  22656. {
  22657. // 在产成品表中
  22658. #region 是否交接过
  22659. string fhUserCode = dsResult.Tables[0].Rows[0]["FHUserCode"].ToString();
  22660. if (string.IsNullOrEmpty(fhUserCode))
  22661. {
  22662. resultEntity.Result = -1; //未交接,不能撤销
  22663. resultEntity.Message = "此产品【" + barcode + "】未交接,不能进行该操作";
  22664. return resultEntity;
  22665. }
  22666. #endregion
  22667. }
  22668. else
  22669. {
  22670. resultEntity.Result = -2; //不能产成品,不能撤销
  22671. sql = "select GoodsCode from TP_PM_GroutingDailyDetail where BarCode=:BarCode";
  22672. dsResult = oracleTrConn.GetSqlResultToDs(sql, paras);
  22673. if (dsResult != null && dsResult.Tables[0].Rows.Count > 0)
  22674. {
  22675. resultEntity.Message = "此产品【" + barcode + "】不是产成品,不能进行该操作";
  22676. }
  22677. else
  22678. {
  22679. resultEntity.Message = "此条码【" + barcode + "】无效,不能进行该操作";
  22680. }
  22681. return resultEntity;
  22682. }
  22683. #region 查询产品相关信息
  22684. sql = @"Update TP_PM_FinishedProduct
  22685. set
  22686. FHOrderID=:FHOrderID,
  22687. UpdateUserID=:UpdateUserID
  22688. where BarCode=:BarCode";
  22689. paras = new OracleParameter[]{
  22690. new OracleParameter(":BarCode",OracleDbType.NVarchar2,barcode,ParameterDirection.Input),
  22691. new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  22692. new OracleParameter(":FHOrderID",OracleDbType.Int32,orderid,ParameterDirection.Input),
  22693. };
  22694. int resultRow = oracleTrConn.ExecuteNonQuery(sql, paras);
  22695. if (resultRow == 0)
  22696. {
  22697. oracleTrConn.Rollback();
  22698. oracleTrConn.Disconnect();
  22699. }
  22700. else
  22701. {
  22702. resultEntity.Result = 1;
  22703. oracleTrConn.Commit();
  22704. oracleTrConn.Disconnect();
  22705. }
  22706. #endregion
  22707. return resultEntity;
  22708. }
  22709. catch (Exception ex)
  22710. {
  22711. throw ex;
  22712. }
  22713. }
  22714. /// <summary>
  22715. /// 回收标准计件
  22716. /// </summary>
  22717. /// <param name="oracleTrConn">数据连接对象</param>
  22718. /// <param name="procedure">工序对象</param>
  22719. /// <param name="barcodeTable">条码信息</param>
  22720. /// <param name="sUserInfo">用户基本信息</param>
  22721. /// <param name="goodsID">返回的产品ID</param>
  22722. /// <param name="goodsCode">返回的产品Code</param>
  22723. /// <param name="goodsName">返回的产品名称</param>
  22724. /// <param name="groutingUserID">返回的注浆者ID</param>
  22725. /// <returns>string</returns>
  22726. /// <remarks>
  22727. /// 王鑫 2017.7.20 新建
  22728. /// </remarks>
  22729. private static string AddRecydingFlagWorkPiece(IDBTransaction oracleTrConn,
  22730. ProcedureEntity procedure,
  22731. DataTable barcodeTable,
  22732. SUserInfo sUserInfo,
  22733. out int goodsID,
  22734. out string goodsCode,
  22735. out string goodsName,
  22736. out string groutingUserCode, out string logoCode, out string logoName, out string groutingdate)
  22737. {
  22738. try
  22739. {
  22740. int deleteRow = 0;
  22741. goodsID = Constant.INT_IS_ZERO;
  22742. goodsCode = null;
  22743. goodsName = null;
  22744. groutingUserCode = string.Empty; //Constant.INT_IS_ZERO;
  22745. // 获得账务日期
  22746. DateTime accountDate = CommonModuleLogic.CommonModuleLogic.GetAccountDate(oracleTrConn, sUserInfo);
  22747. string errMsg = string.Empty;
  22748. // 本批采集的批次号
  22749. string centralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();
  22750. // 条码信息
  22751. string logoName_Temp = "";
  22752. string logoCode_Temp = "";
  22753. string groutingdate_Temp = "";
  22754. foreach (DataRow barcodeRow in barcodeTable.Rows)
  22755. {
  22756. // 条码
  22757. string barcode = barcodeRow["Barcode"].ToString();
  22758. if (string.IsNullOrEmpty(barcode))
  22759. {
  22760. throw new Exception("传入的条码号为空");
  22761. }
  22762. // 生产工号
  22763. int workUserID = Convert.ToInt32(barcodeRow["UserID"]);
  22764. // 生产工号
  22765. string workUserCode = barcodeRow["UserCode"].ToString();
  22766. //#region 校验条码有效性
  22767. //errMsg = CheckDryRepairBarcode(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo);
  22768. //if (!string.IsNullOrEmpty(errMsg))
  22769. //{
  22770. // return errMsg;
  22771. //}
  22772. //#endregion
  22773. if (procedure.CollectType == 1)
  22774. {
  22775. #region 校验条码有效性
  22776. errMsg = CheckRecyclingFlagBarcode(oracleTrConn, procedure.ProcedureID, barcode, out goodsID, out goodsCode, out goodsName, out groutingUserCode, sUserInfo);
  22777. if (!string.IsNullOrEmpty(errMsg))
  22778. {
  22779. logoName = "";
  22780. logoCode = "";
  22781. groutingdate = "";
  22782. return errMsg;
  22783. }
  22784. #endregion
  22785. }
  22786. else
  22787. {
  22788. string sqlGroutingInfo = @"select tp_pm_groutingdailydetail.goodsid,
  22789. tp_pm_groutingdailydetail.goodscode,
  22790. tp_pm_groutingdailydetail.goodsname,
  22791. tp_pm_groutingdailydetail.usercode as groutingUserCode,
  22792. tp_pm_groutingdailydetail.groutingdate,
  22793. tp_mst_logo.logoid,
  22794. tp_mst_logo.logocode,
  22795. tp_mst_logo.logoname
  22796. from tp_pm_groutingdailydetail
  22797. left join tp_mst_logo
  22798. on tp_pm_groutingdailydetail.logoid=tp_mst_logo.logoid
  22799. where tp_pm_groutingdailydetail.barcode=:barcode
  22800. ";
  22801. OracleParameter[] paras = new OracleParameter[] {
  22802. new OracleParameter(":barcode",barcode),
  22803. };
  22804. DataSet dsGrouting = oracleTrConn.GetSqlResultToDs(sqlGroutingInfo, paras);
  22805. if (dsGrouting != null && dsGrouting.Tables[0].Rows.Count > 0)
  22806. {
  22807. goodsID = Convert.ToInt32(dsGrouting.Tables[0].Rows[0]["goodsid"]);
  22808. goodsCode = dsGrouting.Tables[0].Rows[0]["goodscode"].ToString();
  22809. goodsName = dsGrouting.Tables[0].Rows[0]["goodsName"].ToString();
  22810. groutingUserCode = dsGrouting.Tables[0].Rows[0]["groutingUserCode"].ToString();
  22811. logoName = dsGrouting.Tables[0].Rows[0]["logoName"].ToString();
  22812. logoCode = dsGrouting.Tables[0].Rows[0]["logoCode"].ToString();
  22813. groutingdate = dsGrouting.Tables[0].Rows[0]["groutingdate"].ToString();
  22814. logoName_Temp = logoName;
  22815. logoCode_Temp = logoCode;
  22816. groutingdate_Temp = groutingdate;
  22817. }
  22818. }
  22819. #region 数据处理
  22820. #region 处理废弃数据并转回收数据为在产数据
  22821. //////string querysql = @"select GOODSLEVELID from TP_MST_GOODSLEVEL where GOODSLEVELTYPEID=9 and ACCOUNTID=:accountid and VALUEFLAG=1";
  22822. //////OracleParameter[] queryparas = new OracleParameter[]{
  22823. ////// new OracleParameter(":accountid",OracleDbType.Varchar2, sUserInfo.AccountID,ParameterDirection.Input)
  22824. //////};
  22825. //////DataSet returnDs = oracleTrConn.GetSqlResultToDs(querysql, queryparas);
  22826. //////if (returnDs == null || returnDs.Tables[0].Rows.Count == 0)
  22827. //////{
  22828. ////// errMsg = "未设定干补等级";
  22829. ////// logoName = "";
  22830. ////// logoCode = "";
  22831. ////// groutingdate = "";
  22832. ////// return errMsg;
  22833. //////}
  22834. //////string goodsLevelID = returnDs.Tables[0].Rows[0][0].ToString();
  22835. //第一步,废弃数据的产品分级类别由 8损坯13不合格14不合格(返) 改为 9干补,产品分级=此账套相应的设置
  22836. /*string sqlUpdateLevelTypeString = @"update TP_PM_ScrapProduct set GOODSLEVELID=:GOODSLEVELID, GoodsLevelTypeID=9,SpecialRepairFlag=1,
  22837. SpecialRepairUserID=:SpecialRepairUserID,SpecialRepairUserCode=:SpecialRepairUserCode,SpecialRepairTime=sysdate,
  22838. UpdateUserID=:UpdateUserID
  22839. where BarCode=:barcode
  22840. and CreateTime=(select max(CreateTime) from TP_PM_ScrapProduct where BarCode=:barcode1 and ValueFlag=1)
  22841. and ValueFlag=1 and GoodsLevelTypeID=(select max(GoodsLevelTypeID) from TP_PM_ScrapProduct where BarCode=:barcode1 and ValueFlag=1) ";
  22842. */
  22843. // and ValueFlag=1 and GoodsLevelTypeID=8 ";
  22844. ////// string sqlUpdateLevelTypeString = @"update TP_PM_ScrapProduct set GOODSLEVELID=:GOODSLEVELID, GoodsLevelTypeID=9,
  22845. ////// SpecialRepairUserID=:SpecialRepairUserID,SpecialRepairUserCode=:SpecialRepairUserCode,SpecialRepairTime=sysdate,
  22846. ////// UpdateUserID=:UpdateUserID
  22847. ////// where BarCode=:barcode
  22848. ////// and CreateTime=(select max(CreateTime) from TP_PM_ScrapProduct where BarCode=:barcode1 and ValueFlag=1)
  22849. ////// and ValueFlag=1 and GoodsLevelTypeID in (8, 13, 14) ";
  22850. string sqlUpdateLevelTypeString = @"update TP_PM_ScrapProduct set RecyclingFlag=1,
  22851. UpdateUserID=:UpdateUserID,RecyclingUserID=:RecyclingUserID,RecyclingUserCode=:RecyclingUserCode,
  22852. RecyclingTime=sysdate
  22853. where BarCode=:barcode
  22854. and CreateTime=(select max(CreateTime) from TP_PM_ScrapProduct where BarCode=:barcode and ValueFlag=1)
  22855. and ValueFlag=1 ";
  22856. OracleParameter[] ScrapProductparas = new OracleParameter[]{
  22857. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  22858. new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  22859. new OracleParameter(":RecyclingUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  22860. new OracleParameter(":RecyclingUserCode",OracleDbType.Varchar2, sUserInfo.UserCode,ParameterDirection.Input),
  22861. };
  22862. oracleTrConn.ExecuteNonQuery(sqlUpdateLevelTypeString, ScrapProductparas);
  22863. string sqlUpdateGROUTString = @"update TP_PM_GROUTINGDAILYDETAIL set RecyclingFlag=1,
  22864. UpdateUserID=:UpdateUserID
  22865. where BarCode=:barcode ";
  22866. OracleParameter[] GROUTparas = new OracleParameter[]{
  22867. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  22868. new OracleParameter(":UpdateUserID",OracleDbType.Int32,sUserInfo.UserID,ParameterDirection.Input),
  22869. };
  22870. oracleTrConn.ExecuteNonQuery(sqlUpdateGROUTString, GROUTparas);
  22871. //modify wangx 20150623
  22872. //////OracleParameter[] sqlUpdateparas = new OracleParameter[]{
  22873. ////// new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  22874. //////};
  22875. //string sqlUpdate = "update TP_PM_InCheckedDetail set SpecialRepairFlag=1 where barcode=:barcode";
  22876. //oracleTrConn.ExecuteNonQuery(sqlUpdate, sqlUpdateparas);
  22877. //////string sqlUpdate = "update TP_PM_ProductionDataIn set SpecialRepairFlag=1 where barcode=:barcode";
  22878. //////oracleTrConn.ExecuteNonQuery(sqlUpdate, sqlUpdateparas);
  22879. //modify wangx 20150623 end
  22880. #region
  22881. //第五步,插入回收工序的生产数据(同其他计件工序),设置干补标识,产品分级类别=9干补,产品分级=此账套相应的设置
  22882. // 查询新插入的生产数据ID
  22883. string sql = "select SEQ_PM_ProductionData_ID.nextval from dual";
  22884. string idStr = oracleTrConn.GetSqlResultToStr(sql);
  22885. int productionDataID = 0;
  22886. if (!string.IsNullOrEmpty(idStr))
  22887. {
  22888. productionDataID = int.Parse(idStr);
  22889. }
  22890. else
  22891. {
  22892. logoName = "";
  22893. logoCode = "";
  22894. groutingdate = "";
  22895. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  22896. }
  22897. int? ClassesSettingID = null;//班次配置ID
  22898. #region 第五步 添加生产者数据
  22899. errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo, ref ClassesSettingID);
  22900. if (!string.IsNullOrEmpty(errMsg))
  22901. {
  22902. logoName = "";
  22903. logoCode = "";
  22904. groutingdate = "";
  22905. return errMsg;
  22906. }
  22907. #endregion
  22908. ProductionDataEntity productionData = new ProductionDataEntity();
  22909. #region 属性赋值
  22910. productionData.ClassesSettingID = ClassesSettingID;
  22911. productionData.ProductionDataID = Convert.ToInt32(idStr);
  22912. productionData.Barcode = barcode;
  22913. productionData.CentralizedBatchNo = centralizedBatchNo;
  22914. productionData.ProductionLineID = procedure.ProductionLineID;
  22915. productionData.ProductionLineCode = procedure.ProductionlineCode;
  22916. productionData.ProductionLineName = procedure.ProductionlineName;
  22917. productionData.CompleteProcedureID = procedure.ProcedureID;
  22918. productionData.ProcedureCode = procedure.ProcedureCode;
  22919. productionData.ProcedureName = procedure.ProcedureName;
  22920. productionData.ProcedureModel = procedure.ProcedureModel;
  22921. productionData.ModelType = procedure.ModelType;
  22922. productionData.NodeType = procedure.NodeType;
  22923. productionData.DefectFlag = (int)Constant.DefectFlag.No;
  22924. productionData.ReworkProcedureID = null;
  22925. productionData.IsPublicBody = IsPubilcByBarCode(oracleTrConn, barcode);
  22926. productionData.IsReFire = (int)Constant.ReFireFlag.No;
  22927. //设置干补标识,产品分级类别=9干补
  22928. ////productionData.GoodsLevelTypeID = 9;
  22929. //productionData.GoodsLevelID = int.Parse(goodsLevelID);
  22930. //productionData.GoodsGrade = (int)Constant.GoodsGrade.Good;
  22931. productionData.OrganizationID = procedure.OrganizationID;
  22932. productionData.GoodsID = goodsID;
  22933. productionData.GoodsCode = goodsCode;
  22934. productionData.GoodsName = goodsName;
  22935. productionData.UserID = workUserID;
  22936. productionData.UserCode = barcodeRow["UserCode"].ToString();
  22937. productionData.UserName = barcodeRow["UserName"].ToString();
  22938. productionData.PieceType = procedure.PieceType;
  22939. if (barcodeRow["LogoID"].ToString() != "")
  22940. {
  22941. productionData.LogoID = Convert.ToInt32(barcodeRow["LogoID"]);
  22942. }
  22943. string sqlReFire = @"select
  22944. isrefire,
  22945. logoid,GoodsLevelID,GoodsLevelTypeID
  22946. from tp_pm_inproduction where barcode=:barcode
  22947. union
  22948. select
  22949. isrefire,
  22950. logoid,GoodsLevelID,GoodsLevelTypeID
  22951. from TP_PM_InProductionTrash where barcode=:barcode
  22952. union
  22953. select
  22954. isrefire,
  22955. logoid,GoodsLevelID,GoodsLevelTypeID
  22956. from TP_PM_FinishedProduct where barcode=:barcode ";
  22957. OracleParameter[] ReFireparas = new OracleParameter[] {
  22958. new OracleParameter(":barcode",barcode),
  22959. };
  22960. DataSet dsReFire = oracleTrConn.GetSqlResultToDs(sqlReFire, ReFireparas);
  22961. if (dsReFire != null && dsReFire.Tables[0].Rows.Count > 0)
  22962. {
  22963. if (Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]) > 0)
  22964. {
  22965. productionData.IsReFire = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["IsReFire"]);
  22966. }
  22967. if (dsReFire.Tables[0].Rows[0]["logoid"].ToString() != "")
  22968. {
  22969. productionData.LogoID = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["LogoID"]);
  22970. }
  22971. if (dsReFire.Tables[0].Rows[0]["GoodsLevelTypeID"].ToString() != string.Empty)
  22972. {
  22973. productionData.GoodsLevelTypeID = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["GoodsLevelTypeID"]);
  22974. productionData.GoodsLevelID = Convert.ToInt32(dsReFire.Tables[0].Rows[0]["GoodsLevelID"]);
  22975. }
  22976. }
  22977. #endregion 属性赋值
  22978. productionData.SpecialRepairflag = 0;
  22979. string OutSpecialRepairflag = "0";// 没有什么特殊的,同干补保存生产数据共用同一个方法
  22980. errMsg = AddDryRepairProductionData(oracleTrConn, accountDate, productionData, sUserInfo, out OutSpecialRepairflag);
  22981. if (!string.IsNullOrEmpty(errMsg))
  22982. {
  22983. logoName = "";
  22984. logoCode = "";
  22985. groutingdate = "";
  22986. return errMsg;
  22987. }
  22988. #endregion
  22989. //第二步,回收站中数据回到在产中,设置干补标识。
  22990. string sqlInsInProdString = @"insert into TP_PM_InProduction(BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME,
  22991. PROCEDUREMODEL, MODELTYPE, REWORKPROCEDUREID,
  22992. ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME,
  22993. USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE,
  22994. GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID,
  22995. CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE,
  22996. REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME,
  22997. CREATEUSERID, UPDATETIME, UPDATEUSERID,
  22998. ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, DEFECTFLAG,
  22999. GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM,
  23000. KILNID, KILNCODE, KILNNAME, KILNCARID,
  23001. KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,FlowProcedureID
  23002. ,FlowProcedureTime,ProcedureID,ProcedureTime,ProductionDataID,logoid, ISREWORKFLAG, SEMICHECKID)
  23003. select BARCODE, PRODUCTIONLINEID, PRODUCTIONLINECODE, PRODUCTIONLINENAME,
  23004. :PROCEDUREMODEL, :MODELTYPE, null,
  23005. ISPUBLICBODY, GOODSID, GOODSCODE, GOODSNAME,
  23006. USERID, GROUTINGDAILYID, GROUTINGDAILYDETAILID, GROUTINGDATE,
  23007. GROUTINGLINEID, GROUTINGLINECODE, GROUTINGLINENAME, GMOULDTYPEID,
  23008. CANMANYTIMES, GROUTINGLINEDETAILID, GROUTINGMOULDCODE, MOULDCODE,
  23009. REMARKS, ACCOUNTID, VALUEFLAG, CREATETIME,
  23010. CREATEUSERID, UPDATETIME, :UpdateUserID,
  23011. ISREFIRE, GOODSLEVELID, GOODSLEVELTYPEID, 1,
  23012. GROUTINGUSERID, GROUTINGUSERCODE, GROUTINGNUM,
  23013. KILNID, KILNCODE, KILNNAME, KILNCARID,
  23014. KILNCARCODE, KILNCARNAME, KILNCARBATCHNO, KILNCARPOSITION,SpecialRepairFlag,:ProcedureID ,--FlowProcedureID
  23015. FlowProcedureTime,:ProcedureID,sysdate,:ProductionDataID,logoid, ISREWORKFLAG, SEMICHECKID
  23016. from TP_PM_InProductionTrash where barcode=:barcode ";
  23017. OracleParameter[] InProductparas = new OracleParameter[]{
  23018. new OracleParameter(":UpdateUserID",OracleDbType.Int32, workUserID,ParameterDirection.Input),
  23019. ////new OracleParameter(":GOODSLEVELID",OracleDbType.Int32,int.Parse(goodsLevelID),ParameterDirection.Input),
  23020. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input),
  23021. new OracleParameter(":ProcedureID",OracleDbType.Int32,procedure.ProcedureID,ParameterDirection.Input),
  23022. new OracleParameter(":PROCEDUREMODEL",OracleDbType.Varchar2,procedure.ProcedureModel,ParameterDirection.Input),
  23023. new OracleParameter(":MODELTYPE",OracleDbType.Int32,procedure.ModelType,ParameterDirection.Input),
  23024. new OracleParameter(":ProductionDataID",OracleDbType.Int32,productionDataID,ParameterDirection.Input)
  23025. };
  23026. //第三步,删除回收站中的条码
  23027. string sqlDelInProductTrashString = "delete from TP_PM_InProductionTrash where barcode=:barcode ";
  23028. OracleParameter[] TrashProductparas = new OracleParameter[]{
  23029. new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input)
  23030. };
  23031. //第四步,更新注浆表干补标识
  23032. // string sqlUpGroutingDeilString = @"update TP_PM_GroutingDailyDetail set SpecialRepairFlag=1
  23033. // where GroutingDailyDetailID=(select GroutingDailyDetailID from TP_PM_GROUTINGPRODUCT
  23034. // where barcode=:barcode)";
  23035. ////// string sqlUpGroutingDeilString = @"update TP_PM_GroutingDailyDetail set SpecialRepairFlag=1
  23036. ////// where barcode=:barcode";
  23037. ////// OracleParameter[] GroutingProductparas = new OracleParameter[]{
  23038. ////// new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input)
  23039. ////// };
  23040. // string sqlUpCompleteString = @"update TP_PM_FINISHEDPRODUCT set SpecialRepairFlag=1
  23041. // where barcode=:barcode ";
  23042. // OracleParameter[] CompleteProductparas = new OracleParameter[]{
  23043. // new OracleParameter(":barcode",OracleDbType.Varchar2, barcode,ParameterDirection.Input)
  23044. // };
  23045. deleteRow += oracleTrConn.ExecuteNonQuery(sqlUpdateLevelTypeString, ScrapProductparas);
  23046. deleteRow += oracleTrConn.ExecuteNonQuery(sqlInsInProdString, InProductparas);
  23047. deleteRow += oracleTrConn.ExecuteNonQuery(sqlDelInProductTrashString, TrashProductparas);
  23048. //deleteRow += oracleTrConn.ExecuteNonQuery(sqlUpGroutingDeilString, GroutingProductparas);
  23049. //deleteRow += oracleTrConn.ExecuteNonQuery(sqlUpCompleteString, CompleteProductparas); //由于成品后,不能报损,所以这个执行去掉
  23050. // 失败
  23051. if (deleteRow == Constant.INT_IS_ZERO)
  23052. {
  23053. logoName = "";
  23054. logoCode = "";
  23055. groutingdate = "";
  23056. return string.Format(Messages.MSG_CMN_W001, "条码", "保存");
  23057. }
  23058. #endregion
  23059. //#region 第五步 添加生产者数据
  23060. //errMsg = AddProducer(oracleTrConn, accountDate, productionDataID, workUserID, workUserCode, sUserInfo);
  23061. //if (!string.IsNullOrEmpty(errMsg))
  23062. //{
  23063. // return errMsg;
  23064. //}
  23065. //#endregion
  23066. //第五步,回添加生产数据 modify wangx 2015/07/20 新添加的代码
  23067. sql = "select 1 from tp_pm_productiondatain where barcode=:barcode and valueflag=1";
  23068. OracleParameter[] Paras = new OracleParameter[] {
  23069. new OracleParameter(":barcode",OracleDbType.Varchar2,
  23070. barcode,ParameterDirection.Input)
  23071. };
  23072. DataSet ds = oracleTrConn.GetSqlResultToDs(sql, Paras);
  23073. if (ds.Tables[0].Rows.Count == 0)
  23074. {
  23075. // 2 生产数据恢复到在产生产数据
  23076. sql = @"insert into tp_pm_productiondatain
  23077. (
  23078. ProductionDataID,
  23079. BarCode,
  23080. CentralizedBatchNo,
  23081. ProductionLineID,
  23082. ProductionLineCode,
  23083. ProductionLineName,
  23084. ProcedureID,
  23085. ProcedureCode,
  23086. ProcedureName,
  23087. ProcedureModel,
  23088. ModelType,
  23089. PieceType,
  23090. IsReworked,
  23091. NodeType,
  23092. IsPublicBody,
  23093. IsReFire,
  23094. GoodsLevelID,
  23095. GoodsLevelTypeID,
  23096. SpecialRepairFlag,
  23097. OrganizationID,
  23098. GoodsID,
  23099. GoodsCode,
  23100. GoodsName,
  23101. UserID,
  23102. UserCode,
  23103. UserName,
  23104. ClassesSettingID,
  23105. KilnID,
  23106. KilnCode,
  23107. KilnName,
  23108. KilnCarID,
  23109. KilnCarCode,
  23110. KilnCarName,
  23111. KilnCarBatchNo,
  23112. KilnCarPosition,
  23113. ReworkProcedureID,
  23114. ReworkProcedureCode,
  23115. ReworkProcedureName,
  23116. GroutingDailyID,
  23117. GroutingDailyDetailID,
  23118. GroutingLineID,
  23119. GroutingLineCode,
  23120. GroutingLineName,
  23121. GMouldTypeID,
  23122. CanManyTimes,
  23123. GroutingLineDetailID,
  23124. GroutingDate,
  23125. GroutingMouldCode,
  23126. MouldCode,
  23127. GroutingUserID,
  23128. GroutingUserCode,
  23129. GroutingNum,
  23130. Remarks,
  23131. AccountDate,
  23132. SettlementFlag,
  23133. AccountID,
  23134. ValueFlag,
  23135. CreateTime,
  23136. CreateUserID,
  23137. UpdateTime,
  23138. UpdateUserID,
  23139. OPTimeStamp,
  23140. TriggerFlag,
  23141. logoid,
  23142. BackOutTime,BackOutUserID,BackOutUserCode
  23143. )
  23144. select
  23145. ProductionDataID,
  23146. BarCode,
  23147. CentralizedBatchNo,
  23148. ProductionLineID,
  23149. ProductionLineCode,
  23150. ProductionLineName,
  23151. ProcedureID,
  23152. ProcedureCode,
  23153. ProcedureName,
  23154. ProcedureModel,
  23155. ModelType,
  23156. PieceType,
  23157. IsReworked,
  23158. NodeType,
  23159. IsPublicBody,
  23160. IsReFire,
  23161. GoodsLevelID,
  23162. GoodsLevelTypeID,
  23163. SpecialRepairFlag,
  23164. OrganizationID,
  23165. GoodsID,
  23166. GoodsCode,
  23167. GoodsName,
  23168. UserID,
  23169. UserCode,
  23170. UserName,
  23171. ClassesSettingID,
  23172. KilnID,
  23173. KilnCode,
  23174. KilnName,
  23175. KilnCarID,
  23176. KilnCarCode,
  23177. KilnCarName,
  23178. KilnCarBatchNo,
  23179. KilnCarPosition,
  23180. ReworkProcedureID,
  23181. ReworkProcedureCode,
  23182. ReworkProcedureName,
  23183. GroutingDailyID,
  23184. GroutingDailyDetailID,
  23185. GroutingLineID,
  23186. GroutingLineCode,
  23187. GroutingLineName,
  23188. GMouldTypeID,
  23189. CanManyTimes,
  23190. GroutingLineDetailID,
  23191. GroutingDate,
  23192. GroutingMouldCode,
  23193. MouldCode,
  23194. GroutingUserID,
  23195. GroutingUserCode,
  23196. GroutingNum,
  23197. Remarks,
  23198. AccountDate,
  23199. SettlementFlag,
  23200. AccountID,
  23201. ValueFlag,
  23202. CreateTime,
  23203. CreateUserID,
  23204. UpdateTime,
  23205. UpdateUserID,
  23206. OPTimeStamp,
  23207. 1,
  23208. logoid,
  23209. BackOutTime,BackOutUserID,BackOutUserCode
  23210. from TP_PM_ProductionData where valueflag=1 and barcode=:barcode
  23211. ";
  23212. oracleTrConn.ExecuteNonQuery(sql, Paras);
  23213. }
  23214. //第五步,回添加生产数据 modify wangx 2015/07/20 新添加的代码 end
  23215. #endregion 数据处理
  23216. }
  23217. logoName = logoName_Temp;
  23218. logoCode = logoCode_Temp;
  23219. groutingdate = groutingdate_Temp;
  23220. return errMsg;
  23221. }
  23222. catch (Exception ex)
  23223. {
  23224. throw ex;
  23225. }
  23226. }
  23227. /// <summary>
  23228. /// 校验回收条码有效
  23229. /// </summary>
  23230. /// <param name="oracleTrConn">连接对象</param>
  23231. /// <param name="procedureID">工序ID</param>
  23232. /// <param name="barcode">条码</param>
  23233. /// <param name="goodsID">返回的产品ID</param>
  23234. /// <param name="goodsCode">返回的产品Code</param>
  23235. /// <param name="goodsName">返回的产品名称</param>
  23236. /// <param name="groutingUserID">返回的注浆者ID</param>
  23237. /// <returns>string</returns>
  23238. /// <remarks>
  23239. /// 王鑫 2017.7.20 新建
  23240. /// </remarks>
  23241. private static string CheckRecyclingFlagBarcode(IDBTransaction oracleTrConn,
  23242. int procedureID,
  23243. string barcode,
  23244. out int goodsID,
  23245. out string goodsCode,
  23246. out string goodsName,
  23247. out string groutingUserCode,
  23248. SUserInfo sUserInfo
  23249. )
  23250. {
  23251. try
  23252. {
  23253. //OracleParameter[] paras = new OracleParameter[]{
  23254. // new OracleParameter("in_procedureid",OracleDbType.Int32,procedureID,ParameterDirection.Input),
  23255. // new OracleParameter("in_barcode",OracleDbType.Varchar2,barcode,ParameterDirection.Input),
  23256. // new OracleParameter("out_errMsg",OracleDbType.Varchar2,2000,"",ParameterDirection.Output),
  23257. // new OracleParameter("out_goodsID",OracleDbType.Int32,ParameterDirection.Output),
  23258. // new OracleParameter("out_goodsCode",OracleDbType.Varchar2,50,"",ParameterDirection.Output),
  23259. // new OracleParameter("out_goodsName",OracleDbType.Varchar2,50,"",ParameterDirection.Output),
  23260. // new OracleParameter("out_groutingUserCode",OracleDbType.NVarchar2,50,null,ParameterDirection.Output),
  23261. //};
  23262. //oracleTrConn.ExecStoredProcedure("pro_pm_checkdryrepairbarcode", paras);
  23263. //if (!"null".Equals(paras[3].Value + ""))
  23264. //{
  23265. // goodsID = Convert.ToInt32(paras[3].Value + "");
  23266. //}
  23267. //else
  23268. //{
  23269. // goodsID = 0;
  23270. //}
  23271. //goodsCode = paras[4].Value + "";
  23272. //goodsName = paras[5].Value + "";
  23273. //if (!"null".Equals(paras[6].Value + ""))
  23274. //{
  23275. // groutingUserCode = paras[6].Value + "";
  23276. //}
  23277. //else
  23278. //{
  23279. // groutingUserCode = null;
  23280. //}
  23281. //if ("null".Equals(paras[2].Value + ""))
  23282. //{
  23283. // return null;
  23284. //}
  23285. //return paras[2].Value.ToString().Replace("\\n\\r", "\n\r");
  23286. string errorMessage = string.Empty;
  23287. goodsID = 0;
  23288. goodsCode = string.Empty;
  23289. goodsName = string.Empty;
  23290. groutingUserCode = string.Empty;
  23291. string sqlString = @"select settingcode,settingvalue,settingdefaultvalues from tp_mst_systemsetting
  23292. where Accountid=:Accountid and settingcode in ('S_PM_017','S_PM_018','S_PM_019','S_PM_020')";
  23293. OracleParameter[] paras = new OracleParameter[]{
  23294. new OracleParameter("Accountid",OracleDbType.Int32,sUserInfo.AccountID,ParameterDirection.Input),
  23295. };
  23296. DataSet ds = oracleTrConn.GetSqlResultToDs(sqlString, paras);
  23297. #region 读出系统配置 17(损坯可否回收) 18(半检不合格可否回收) 19(复检不合格可否回收) 20(次品可否回收)
  23298. int S_PM_017_Value = 0, S_PM_018_Value = 0, S_PM_019_Value = 0, S_PM_020_Value = 0;
  23299. if (ds != null && ds.Tables[0].Rows.Count > 0)
  23300. {
  23301. foreach (DataRow r in ds.Tables[0].Rows)
  23302. {
  23303. if (r["settingcode"].ToString() == "S_PM_017")
  23304. {
  23305. S_PM_017_Value = Convert.ToInt32(r["settingvalue"]);
  23306. }
  23307. else if (r["settingcode"].ToString() == "S_PM_018")
  23308. {
  23309. S_PM_018_Value = Convert.ToInt32(r["settingvalue"]);
  23310. }
  23311. else if (r["settingcode"].ToString() == "S_PM_019")
  23312. {
  23313. S_PM_019_Value = Convert.ToInt32(r["settingvalue"]);
  23314. }
  23315. else if (r["settingcode"].ToString() == "S_PM_020")
  23316. {
  23317. S_PM_020_Value = Convert.ToInt32(r["settingvalue"]);
  23318. }
  23319. }
  23320. }
  23321. #endregion
  23322. #region 第1步 查当前工序在系统是否存在
  23323. sqlString = @"select NodeType,ModelType from tp_pc_procedure where procedureid=:procedureid and ValueFlag=1";
  23324. paras = new OracleParameter[]{
  23325. new OracleParameter(":procedureid",procedureID),
  23326. };
  23327. ds = oracleTrConn.GetSqlResultToDs(sqlString, paras);
  23328. if (ds == null || ds.Tables[0].Rows.Count == 0)
  23329. {
  23330. errorMessage = "当前工序在系统中不存在";
  23331. return errorMessage;
  23332. }
  23333. #endregion
  23334. #region 第2步 查产品是否有效
  23335. sqlString = @"select distinct GoodsID, GoodsCode,GoodsName,UserCode,DeliverFlag
  23336. from TP_PM_GroutingDailyDetail where BarCode=:barCode and ValueFlag=1 ";
  23337. paras = new OracleParameter[]{
  23338. new OracleParameter(":barCode",barcode),
  23339. };
  23340. ds = oracleTrConn.GetSqlResultToDs(sqlString, paras);
  23341. if (ds == null || ds.Tables[0].Rows.Count == 0)
  23342. {
  23343. // 是否被替换
  23344. string sql = @"select count(barcode),max(newbarcode) from TP_PM_BarCodeRecord where BarCode=:barcode";
  23345. OracleParameter[] paras2 = new OracleParameter[]{
  23346. new OracleParameter(":barCode",barcode) };
  23347. DataSet ds2 = oracleTrConn.GetSqlResultToDs(sql, paras2);
  23348. if (ds2 != null && Convert.ToInt32(ds2.Tables[0].Rows[0][0]) == 0)
  23349. {
  23350. // 无效条件
  23351. errorMessage = "无效条码[" + barcode + "]";
  23352. }
  23353. else
  23354. {
  23355. errorMessage = "条码[" + barcode + "]已经被[" + ds2.Tables[0].Rows[0][1] + "]替换";
  23356. }
  23357. }
  23358. else
  23359. {
  23360. if (Convert.ToInt32(ds.Tables[0].Rows[0]["DeliverFlag"]) != 1)
  23361. {
  23362. errorMessage = "条码[" + barcode + "]未交坯,不能回收";
  23363. }
  23364. else
  23365. {
  23366. goodsID = Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsID"]);
  23367. goodsName = ds.Tables[0].Rows[0]["goodsName"].ToString();
  23368. goodsCode = ds.Tables[0].Rows[0]["GoodsCode"].ToString();
  23369. groutingUserCode = ds.Tables[0].Rows[0]["UserCode"].ToString();
  23370. }
  23371. }
  23372. if (!string.IsNullOrEmpty(errorMessage))
  23373. {
  23374. return errorMessage;
  23375. }
  23376. #endregion
  23377. #region 第3步 查产品是否在当前工序配置
  23378. sqlString = @"select count(GoodsID) from TP_PC_ProcedureGoods where GoodsID=:GoodsID and ProcedureID=:ProcedureID";
  23379. paras = new OracleParameter[]{
  23380. new OracleParameter(":GoodsID",goodsID),
  23381. new OracleParameter(":ProcedureID",procedureID),
  23382. };
  23383. ds = oracleTrConn.GetSqlResultToDs(sqlString, paras);
  23384. if (Convert.ToInt32(ds.Tables[0].Rows[0][0]) != 1)
  23385. {
  23386. errorMessage =
  23387. @"条码[" + barcode + "]不可以经过该工序\n\r原因:条码对应的产品编码[" + goodsCode + "]没有在该工序中配置";
  23388. }
  23389. if (!string.IsNullOrEmpty(errorMessage))
  23390. {
  23391. return errorMessage;
  23392. }
  23393. #endregion
  23394. #region 第4步,校验在产产品不能回收
  23395. string sqlString2 = "select InScrapFlag,ISREWORKFLAG from tp_pm_inproduction where barcode=:barcode";
  23396. OracleParameter[] parasNew = new OracleParameter[]{
  23397. new OracleParameter(":barcode",barcode) };
  23398. DataSet dsNew = oracleTrConn.GetSqlResultToDs(sqlString2, parasNew);
  23399. if (dsNew != null && dsNew.Tables[0].Rows.Count > 0)
  23400. {
  23401. if (Convert.ToInt32(dsNew.Tables[0].Rows[0]["InScrapFlag"]) == 1)
  23402. {
  23403. errorMessage = "报损待审产品不能回收";
  23404. }
  23405. // chenxy 2019-10-02 半检返修 IsReworkFlag=2
  23406. else if (Convert.ToInt32(dsNew.Tables[0].Rows[0]["ISREWORKFLAG"]) == 1)
  23407. {
  23408. errorMessage = "半检返工中不能回收";
  23409. }
  23410. else if (Convert.ToInt32(dsNew.Tables[0].Rows[0]["ISREWORKFLAG"]) == 2)
  23411. {
  23412. errorMessage = "半检返工中不能回收";
  23413. }
  23414. else
  23415. {
  23416. errorMessage = "在产产品不能回收";
  23417. }
  23418. }
  23419. if (!string.IsNullOrEmpty(errorMessage))
  23420. {
  23421. return errorMessage;
  23422. }
  23423. #endregion
  23424. #region 第4步,校验报损表数据是否可以回收
  23425. sqlString = @"select GoodsLevelID,GoodsLevelTypeID,ScrapType,SpecialRepairFlag,RecyclingFlag,AuditStatus,SpecialRepairUserID from TP_PM_ScrapProduct where barcode=:barcode
  23426. and ValueFlag=1 and CreateTime=
  23427. (select max(CreateTime) from TP_PM_ScrapProduct where barcode=:barcode
  23428. and ValueFlag=1 )";
  23429. paras = new OracleParameter[]{
  23430. new OracleParameter(":barcode",barcode),
  23431. };
  23432. ds = oracleTrConn.GetSqlResultToDs(sqlString, paras);
  23433. if (ds == null || ds.Tables[0].Rows.Count == 0)
  23434. {
  23435. errorMessage = "不存在回收数据,不能回收";
  23436. }
  23437. else
  23438. {
  23439. if (Convert.ToInt32(ds.Tables[0].Rows[0]["AuditStatus"]) == 1 &&
  23440. Convert.ToInt32(ds.Tables[0].Rows[0]["GoodsLevelTypeID"]) != 9 &&
  23441. Convert.ToInt32(ds.Tables[0].Rows[0]["RecyclingFlag"]) == 0)
  23442. {
  23443. // 可回收
  23444. string sqlString3 = "select 1 from tp_pm_inproductiontrash where barcode=:barcode";
  23445. OracleParameter[] parasNewt = new OracleParameter[]{
  23446. new OracleParameter(":barcode",barcode) };
  23447. DataSet dsNewt = oracleTrConn.GetSqlResultToDs(sqlString3, parasNewt);
  23448. if (dsNewt == null || dsNewt.Tables[0].Rows.Count == 0)
  23449. {
  23450. errorMessage = "报损数据被清除,不能回收";
  23451. }
  23452. }
  23453. else
  23454. {
  23455. errorMessage = "不存在回收数据,不能回收";
  23456. }
  23457. if (!string.IsNullOrEmpty(errorMessage))
  23458. {
  23459. if (Convert.ToInt32(ds.Tables[0].Rows[0]["ScrapType"]) == 0)
  23460. {
  23461. // 损坯
  23462. if (S_PM_017_Value == 0)
  23463. {
  23464. errorMessage = "系统参数产品回收-报损未启用";
  23465. }
  23466. }
  23467. else if (Convert.ToInt32(ds.Tables[0].Rows[0]["ScrapType"]) == 1)
  23468. {
  23469. // 成检
  23470. if (S_PM_020_Value == 0)
  23471. {
  23472. errorMessage = "系统参数产品回收-次品未启用";
  23473. }
  23474. }
  23475. else if (Convert.ToInt32(ds.Tables[0].Rows[0]["ScrapType"]) == 2)
  23476. {
  23477. // 半检
  23478. if (S_PM_018_Value == 0)
  23479. {
  23480. errorMessage = "系统参数产品回收-半检不合格未启用";
  23481. }
  23482. }
  23483. else if (Convert.ToInt32(ds.Tables[0].Rows[0]["ScrapType"]) == 3)
  23484. {
  23485. // 复检
  23486. if (S_PM_019_Value == 0)
  23487. {
  23488. errorMessage = "系统参数产品回收-复检不合格未启用";
  23489. }
  23490. }
  23491. }
  23492. }
  23493. #endregion
  23494. return errorMessage;
  23495. }
  23496. catch (Exception ex)
  23497. {
  23498. throw ex;
  23499. }
  23500. }
  23501. /// <summary>
  23502. /// 按条码判定是否为首节点
  23503. /// 从TP_PM_GroutingDailyDetail表中的BEGINNINGFLAG字段判定是否为首节点
  23504. /// "0":非首节点,"1":首节点
  23505. /// </summary>
  23506. /// <param name="oracleTrConn">数据连接</param>
  23507. /// <param name="barCode">条码</param>
  23508. /// <returns>是否首节点</returns>
  23509. /// xuwei add 2019-09-23
  23510. //public static bool IsNodeBegin(IDBTransaction oracleTrConn, string barCode)
  23511. //{
  23512. // bool result = false;
  23513. // try
  23514. // {
  23515. // if (barCode != "")
  23516. // {
  23517. // string flag = oracleTrConn.GetSqlResultToStr($@"select BEGINNINGFLAG as flag
  23518. // from TP_PM_GroutingDailyDetail
  23519. // where BARCODE = {barCode}");
  23520. // if (flag == "") throw new Exception("条码无效!请检查!");
  23521. // result = flag == "0" ? true : false;
  23522. // }
  23523. // }
  23524. // catch (Exception ex)
  23525. // {
  23526. // throw ex;
  23527. // }
  23528. // return result;
  23529. //}
  23530. //public static bool IsNodeBegin(IDBConnection oracleTrConn, string barCode)
  23531. //{
  23532. // bool result = false;
  23533. // try
  23534. // {
  23535. // if (barCode != "")
  23536. // {
  23537. // string flag = oracleTrConn.GetSqlResultToStr($@"select BEGINNINGFLAG as flag
  23538. // from TP_PM_GroutingDailyDetail
  23539. // where BARCODE = {barCode}");
  23540. // if (flag == "") throw new Exception("条码无效!请检查!");
  23541. // result = flag == "0" ? true : false;
  23542. // }
  23543. // }
  23544. // catch (Exception ex)
  23545. // {
  23546. // throw ex;
  23547. // }
  23548. // return result;
  23549. //}
  23550. /// <summary>
  23551. /// 按条码判定是否为首节点(调整为复用方法)
  23552. /// 从TP_PM_GroutingDailyDetail表中的BEGINNINGFLAG字段判定是否为首节点
  23553. /// "0":非首节点,"1":首节点,"-1":条码无效
  23554. /// </summary>
  23555. /// <param name="oracleTrConn">数据连接</param>
  23556. /// <param name="barCode">条码</param>
  23557. /// <returns>是否首节点</returns>
  23558. /// xuwei add 2019-09-26
  23559. public static int IsNodeBegin<T>(T oracleTrConn, string barCode)
  23560. {
  23561. Type t = typeof(T);
  23562. int result = -1;
  23563. try
  23564. {
  23565. if (barCode != "")
  23566. {
  23567. OracleParameter[] parasNew = new OracleParameter[]{
  23568. new OracleParameter(":barcode",barCode) };
  23569. string flag = t.GetMethod("GetSqlResultToStr")
  23570. .Invoke(oracleTrConn, new object[] { $@"select BEGINNINGFLAG as flag
  23571. from TP_PM_GroutingDailyDetail
  23572. where BARCODE = :barcode", parasNew }).ToString();
  23573. //if (flag == "") throw new Exception("无效条码,请检查!");
  23574. //xuwei fix 2019-09-26 找不到和非首节点均返回0
  23575. // 返修指定首节点时,判断错误
  23576. if (string.IsNullOrWhiteSpace(flag))
  23577. {
  23578. return -1;
  23579. }
  23580. result = (flag == "0" ? 1 : 0);
  23581. }
  23582. }
  23583. catch (Exception ex)
  23584. {
  23585. throw ex;
  23586. }
  23587. return result;
  23588. }
  23589. }
  23590. }