AmsSaleOrderMapper.xml 191 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.steerinfo.dil.mapper.AmsSaleOrderMapper">
  4. <resultMap id="BaseResultMap" type="com.steerinfo.dil.model.AmsSaleOrder">
  5. <id column="SALE_ORDER_ID" jdbcType="DECIMAL" property="saleOrderId" />
  6. <result column="PLAN_ID" jdbcType="DECIMAL" property="planId" />
  7. <result column="SALE_NUMBER" jdbcType="VARCHAR" property="saleNumber" />
  8. <result column="SHIPPER_ID" jdbcType="DECIMAL" property="shipperId" />
  9. <result column="RECEIVE_ID" jdbcType="DECIMAL" property="receiveId" />
  10. <result column="SALE_ACCOUNT_BALANCE" jdbcType="DECIMAL" property="saleAccountBalance" />
  11. <result column="SALE_CURRENT_ORDER_AMOUNT" jdbcType="DECIMAL" property="saleCurrentOrderAmount" />
  12. <result column="SALE_HISTORICAL_ORDER_AMOUNT" jdbcType="DECIMAL" property="saleHistoricalOrderAmount" />
  13. <result column="SALE_ORDER_STATUS" jdbcType="DECIMAL" property="saleOrderStatus" />
  14. <result column="SALE_ORDER_RECEIVE_CUSTOMER" jdbcType="VARCHAR" property="saleOrderReceiveCustomer" />
  15. <result column="SALE_ORDER_ISSELF_MENTION" jdbcType="VARCHAR" property="saleOrderIsselfMention" />
  16. <result column="SALE_UNIT_PRICE" jdbcType="DECIMAL" property="saleUnitPrice" />
  17. <result column="SALE_ORDER_TAX" jdbcType="VARCHAR" property="saleOrderTax" />
  18. <result column="SALE_REMARK" jdbcType="VARCHAR" property="saleRemark" />
  19. <result column="INSERT_USERNAME" jdbcType="VARCHAR" property="insertUsername" />
  20. <result column="INSERT_TIME" jdbcType="TIMESTAMP" property="insertTime" />
  21. <result column="UPDATE_USERNAME" jdbcType="VARCHAR" property="updateUsername" />
  22. <result column="UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime" />
  23. <result column="INSERT_UPDATE_REMARK" jdbcType="VARCHAR" property="insertUpdateRemark" />
  24. <result column="DELETED" jdbcType="DECIMAL" property="deleted" />
  25. <result column="CLOSE_STATUS" jdbcType="DECIMAL" property="closeStatus" />
  26. <result column="SALER_ID" jdbcType="DECIMAL" property="salerId" />
  27. <result column="SALE_TYPE" jdbcType="DECIMAL" property="saleType" />
  28. </resultMap>
  29. <sql id="columns">
  30. SALE_ORDER_ID, PLAN_ID, SALE_NUMBER, SHIPPER_ID, RECEIVE_ID, SALE_ACCOUNT_BALANCE,
  31. SALE_CURRENT_ORDER_AMOUNT, SALE_HISTORICAL_ORDER_AMOUNT, SALE_ORDER_STATUS, SALE_ORDER_RECEIVE_CUSTOMER,
  32. SALE_ORDER_ISSELF_MENTION, SALE_UNIT_PRICE, SALE_ORDER_TAX, SALE_REMARK, INSERT_USERNAME,
  33. INSERT_TIME, UPDATE_USERNAME, UPDATE_TIME, INSERT_UPDATE_REMARK, DELETED, CLOSE_STATUS,
  34. SALER_ID, SALE_TYPE
  35. </sql>
  36. <sql id="columns_alias">
  37. t.SALE_ORDER_ID, t.PLAN_ID, t.SALE_NUMBER, t.SHIPPER_ID, t.RECEIVE_ID, t.SALE_ACCOUNT_BALANCE,
  38. t.SALE_CURRENT_ORDER_AMOUNT, t.SALE_HISTORICAL_ORDER_AMOUNT, t.SALE_ORDER_STATUS,
  39. t.SALE_ORDER_RECEIVE_CUSTOMER, t.SALE_ORDER_ISSELF_MENTION, t.SALE_UNIT_PRICE, t.SALE_ORDER_TAX,
  40. t.SALE_REMARK, t.INSERT_USERNAME, t.INSERT_TIME, t.UPDATE_USERNAME, t.UPDATE_TIME,
  41. t.INSERT_UPDATE_REMARK, t.DELETED, t.CLOSE_STATUS, t.SALER_ID, t.SALE_TYPE
  42. </sql>
  43. <sql id="select">
  44. SELECT <include refid="columns" /> FROM AMS_SALE_ORDER
  45. </sql>
  46. <sql id="select_alias">
  47. SELECT <include refid="columns_alias" /> FROM AMS_SALE_ORDER t
  48. </sql>
  49. <sql id="where">
  50. <where>
  51. <if test="saleOrderId != null">
  52. and SALE_ORDER_ID = #{saleOrderId}
  53. </if>
  54. <if test="planId != null">
  55. and PLAN_ID = #{planId}
  56. </if>
  57. <if test="saleNumber != null and saleNumber != ''">
  58. and SALE_NUMBER = #{saleNumber}
  59. </if>
  60. <if test="shipperId != null">
  61. and SHIPPER_ID = #{shipperId}
  62. </if>
  63. <if test="receiveId != null">
  64. and RECEIVE_ID = #{receiveId}
  65. </if>
  66. <if test="saleAccountBalance != null">
  67. and SALE_ACCOUNT_BALANCE = #{saleAccountBalance}
  68. </if>
  69. <if test="saleCurrentOrderAmount != null">
  70. and SALE_CURRENT_ORDER_AMOUNT = #{saleCurrentOrderAmount}
  71. </if>
  72. <if test="saleHistoricalOrderAmount != null">
  73. and SALE_HISTORICAL_ORDER_AMOUNT = #{saleHistoricalOrderAmount}
  74. </if>
  75. <if test="saleOrderStatus != null">
  76. and SALE_ORDER_STATUS = #{saleOrderStatus}
  77. </if>
  78. <if test="saleOrderReceiveCustomer != null and saleOrderReceiveCustomer != ''">
  79. and SALE_ORDER_RECEIVE_CUSTOMER = #{saleOrderReceiveCustomer}
  80. </if>
  81. <if test="saleOrderIsselfMention != null and saleOrderIsselfMention != ''">
  82. and SALE_ORDER_ISSELF_MENTION = #{saleOrderIsselfMention}
  83. </if>
  84. <if test="saleUnitPrice != null">
  85. and SALE_UNIT_PRICE = #{saleUnitPrice}
  86. </if>
  87. <if test="saleOrderTax != null and saleOrderTax != ''">
  88. and SALE_ORDER_TAX = #{saleOrderTax}
  89. </if>
  90. <if test="saleRemark != null and saleRemark != ''">
  91. and SALE_REMARK = #{saleRemark}
  92. </if>
  93. <if test="insertUsername != null and insertUsername != ''">
  94. and INSERT_USERNAME = #{insertUsername}
  95. </if>
  96. <if test="insertTime != null">
  97. and TO_CHAR(INSERT_TIME,'yyyy-MM-dd') = #{insertTime}
  98. </if>
  99. <if test="updateUsername != null and updateUsername != ''">
  100. and UPDATE_USERNAME = #{updateUsername}
  101. </if>
  102. <if test="updateTime != null">
  103. and TO_CHAR(UPDATE_TIME,'yyyy-MM-dd') = #{updateTime}
  104. </if>
  105. <if test="insertUpdateRemark != null and insertUpdateRemark != ''">
  106. and INSERT_UPDATE_REMARK = #{insertUpdateRemark}
  107. </if>
  108. <if test="deleted != null">
  109. and DELETED = #{deleted}
  110. </if>
  111. <if test="closeStatus != null">
  112. and CLOSE_STATUS = #{closeStatus}
  113. </if>
  114. <if test="salerId != null">
  115. and SALER_ID = #{salerId}
  116. </if>
  117. <if test="saleType != null">
  118. and SALE_TYPE = #{saleType}
  119. </if>
  120. </where>
  121. </sql>
  122. <sql id="whereLike">
  123. <where>
  124. <if test="saleOrderId != null">
  125. and SALE_ORDER_ID = #{saleOrderId}
  126. </if>
  127. <if test="planId != null">
  128. and PLAN_ID = #{planId}
  129. </if>
  130. <if test="saleNumber != null and saleNumber != ''">
  131. and SALE_NUMBER LIKE '%${saleNumber}%'
  132. </if>
  133. <if test="shipperId != null">
  134. and SHIPPER_ID = #{shipperId}
  135. </if>
  136. <if test="receiveId != null">
  137. and RECEIVE_ID = #{receiveId}
  138. </if>
  139. <if test="saleAccountBalance != null">
  140. and SALE_ACCOUNT_BALANCE = #{saleAccountBalance}
  141. </if>
  142. <if test="saleCurrentOrderAmount != null">
  143. and SALE_CURRENT_ORDER_AMOUNT = #{saleCurrentOrderAmount}
  144. </if>
  145. <if test="saleHistoricalOrderAmount != null">
  146. and SALE_HISTORICAL_ORDER_AMOUNT = #{saleHistoricalOrderAmount}
  147. </if>
  148. <if test="saleOrderStatus != null">
  149. and SALE_ORDER_STATUS = #{saleOrderStatus}
  150. </if>
  151. <if test="saleOrderReceiveCustomer != null and saleOrderReceiveCustomer != ''">
  152. and SALE_ORDER_RECEIVE_CUSTOMER LIKE '%${saleOrderReceiveCustomer}%'
  153. </if>
  154. <if test="saleOrderIsselfMention != null and saleOrderIsselfMention != ''">
  155. and SALE_ORDER_ISSELF_MENTION LIKE '%${saleOrderIsselfMention}%'
  156. </if>
  157. <if test="saleUnitPrice != null">
  158. and SALE_UNIT_PRICE = #{saleUnitPrice}
  159. </if>
  160. <if test="saleOrderTax != null and saleOrderTax != ''">
  161. and SALE_ORDER_TAX LIKE '%${saleOrderTax}%'
  162. </if>
  163. <if test="saleRemark != null and saleRemark != ''">
  164. and SALE_REMARK LIKE '%${saleRemark}%'
  165. </if>
  166. <if test="insertUsername != null and insertUsername != ''">
  167. and INSERT_USERNAME LIKE '%${insertUsername}%'
  168. </if>
  169. <if test="insertTime != null">
  170. and TO_CHAR(INSERT_TIME,'yyyy-MM-dd') = #{insertTime}
  171. </if>
  172. <if test="updateUsername != null and updateUsername != ''">
  173. and UPDATE_USERNAME LIKE '%${updateUsername}%'
  174. </if>
  175. <if test="updateTime != null">
  176. and TO_CHAR(UPDATE_TIME,'yyyy-MM-dd') = #{updateTime}
  177. </if>
  178. <if test="insertUpdateRemark != null and insertUpdateRemark != ''">
  179. and INSERT_UPDATE_REMARK LIKE '%${insertUpdateRemark}%'
  180. </if>
  181. <if test="deleted != null">
  182. and DELETED = #{deleted}
  183. </if>
  184. <if test="closeStatus != null">
  185. and CLOSE_STATUS = #{closeStatus}
  186. </if>
  187. <if test="salerId != null">
  188. and SALER_ID = #{salerId}
  189. </if>
  190. <if test="saleType != null">
  191. and SALE_TYPE = #{saleType}
  192. </if>
  193. </where>
  194. </sql>
  195. <delete id="deleteByPrimaryKey" parameterType="DECIMAL">
  196. delete from AMS_SALE_ORDER
  197. where SALE_ORDER_ID = #{saleOrderId,jdbcType=DECIMAL}
  198. </delete>
  199. <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
  200. delete from AMS_SALE_ORDER
  201. where 1!=1
  202. <if test="planId != null">
  203. or PLAN_ID = #{planId}
  204. </if>
  205. <if test="saleNumber != null and saleNumber != ''">
  206. or SALE_NUMBER = #{saleNumber}
  207. </if>
  208. <if test="shipperId != null">
  209. or SHIPPER_ID = #{shipperId}
  210. </if>
  211. <if test="receiveId != null">
  212. or RECEIVE_ID = #{receiveId}
  213. </if>
  214. <if test="saleAccountBalance != null">
  215. or SALE_ACCOUNT_BALANCE = #{saleAccountBalance}
  216. </if>
  217. <if test="saleCurrentOrderAmount != null">
  218. or SALE_CURRENT_ORDER_AMOUNT = #{saleCurrentOrderAmount}
  219. </if>
  220. <if test="saleHistoricalOrderAmount != null">
  221. or SALE_HISTORICAL_ORDER_AMOUNT = #{saleHistoricalOrderAmount}
  222. </if>
  223. <if test="saleOrderStatus != null">
  224. or SALE_ORDER_STATUS = #{saleOrderStatus}
  225. </if>
  226. <if test="saleOrderReceiveCustomer != null and saleOrderReceiveCustomer != ''">
  227. or SALE_ORDER_RECEIVE_CUSTOMER = #{saleOrderReceiveCustomer}
  228. </if>
  229. <if test="saleOrderIsselfMention != null and saleOrderIsselfMention != ''">
  230. or SALE_ORDER_ISSELF_MENTION = #{saleOrderIsselfMention}
  231. </if>
  232. <if test="saleUnitPrice != null">
  233. or SALE_UNIT_PRICE = #{saleUnitPrice}
  234. </if>
  235. <if test="saleOrderTax != null and saleOrderTax != ''">
  236. or SALE_ORDER_TAX = #{saleOrderTax}
  237. </if>
  238. <if test="saleRemark != null and saleRemark != ''">
  239. or SALE_REMARK = #{saleRemark}
  240. </if>
  241. <if test="insertUsername != null and insertUsername != ''">
  242. or INSERT_USERNAME = #{insertUsername}
  243. </if>
  244. <if test="insertTime != null">
  245. or TO_CHAR(INSERT_TIME,'yyyy-MM-dd') = '#{insertTime}'
  246. </if>
  247. <if test="updateUsername != null and updateUsername != ''">
  248. or UPDATE_USERNAME = #{updateUsername}
  249. </if>
  250. <if test="updateTime != null">
  251. or TO_CHAR(UPDATE_TIME,'yyyy-MM-dd') = '#{updateTime}'
  252. </if>
  253. <if test="insertUpdateRemark != null and insertUpdateRemark != ''">
  254. or INSERT_UPDATE_REMARK = #{insertUpdateRemark}
  255. </if>
  256. <if test="deleted != null">
  257. or DELETED = #{deleted}
  258. </if>
  259. <if test="closeStatus != null">
  260. or CLOSE_STATUS = #{closeStatus}
  261. </if>
  262. <if test="salerId != null">
  263. or SALER_ID = #{salerId}
  264. </if>
  265. <if test="saleType != null">
  266. or SALE_TYPE = #{saleType}
  267. </if>
  268. </delete>
  269. <insert id="insert" parameterType="com.steerinfo.dil.model.AmsSaleOrder">
  270. insert into AMS_SALE_ORDER (SALE_ORDER_ID, PLAN_ID, SALE_NUMBER,
  271. SHIPPER_ID, RECEIVE_ID, SALE_ACCOUNT_BALANCE,
  272. SALE_CURRENT_ORDER_AMOUNT, SALE_HISTORICAL_ORDER_AMOUNT,
  273. SALE_ORDER_STATUS, SALE_ORDER_RECEIVE_CUSTOMER,
  274. SALE_ORDER_ISSELF_MENTION, SALE_UNIT_PRICE,
  275. SALE_ORDER_TAX, SALE_REMARK, INSERT_USERNAME,
  276. INSERT_TIME, UPDATE_USERNAME, UPDATE_TIME,
  277. INSERT_UPDATE_REMARK, DELETED, CLOSE_STATUS,
  278. SALER_ID, SALE_TYPE)
  279. values (#{saleOrderId,jdbcType=DECIMAL}, #{planId,jdbcType=DECIMAL}, #{saleNumber,jdbcType=VARCHAR},
  280. #{shipperId,jdbcType=DECIMAL}, #{receiveId,jdbcType=DECIMAL}, #{saleAccountBalance,jdbcType=DECIMAL},
  281. #{saleCurrentOrderAmount,jdbcType=DECIMAL}, #{saleHistoricalOrderAmount,jdbcType=DECIMAL},
  282. #{saleOrderStatus,jdbcType=DECIMAL}, #{saleOrderReceiveCustomer,jdbcType=VARCHAR},
  283. #{saleOrderIsselfMention,jdbcType=VARCHAR}, #{saleUnitPrice,jdbcType=DECIMAL},
  284. #{saleOrderTax,jdbcType=VARCHAR}, #{saleRemark,jdbcType=VARCHAR}, #{insertUsername,jdbcType=VARCHAR},
  285. #{insertTime,jdbcType=TIMESTAMP}, #{updateUsername,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP},
  286. #{insertUpdateRemark,jdbcType=VARCHAR}, #{deleted,jdbcType=DECIMAL}, #{closeStatus,jdbcType=DECIMAL},
  287. #{salerId,jdbcType=DECIMAL}, #{saleType,jdbcType=DECIMAL})
  288. </insert>
  289. <insert id="insertSelective" parameterType="com.steerinfo.dil.model.AmsSaleOrder">
  290. insert into AMS_SALE_ORDER
  291. <trim prefix="(" suffix=")" suffixOverrides=",">
  292. <if test="saleOrderId != null">
  293. SALE_ORDER_ID,
  294. </if>
  295. <if test="planId != null">
  296. PLAN_ID,
  297. </if>
  298. <if test="saleNumber != null">
  299. SALE_NUMBER,
  300. </if>
  301. <if test="shipperId != null">
  302. SHIPPER_ID,
  303. </if>
  304. <if test="receiveId != null">
  305. RECEIVE_ID,
  306. </if>
  307. <if test="saleAccountBalance != null">
  308. SALE_ACCOUNT_BALANCE,
  309. </if>
  310. <if test="saleCurrentOrderAmount != null">
  311. SALE_CURRENT_ORDER_AMOUNT,
  312. </if>
  313. <if test="saleHistoricalOrderAmount != null">
  314. SALE_HISTORICAL_ORDER_AMOUNT,
  315. </if>
  316. <if test="saleOrderStatus != null">
  317. SALE_ORDER_STATUS,
  318. </if>
  319. <if test="saleOrderReceiveCustomer != null">
  320. SALE_ORDER_RECEIVE_CUSTOMER,
  321. </if>
  322. <if test="saleOrderIsselfMention != null">
  323. SALE_ORDER_ISSELF_MENTION,
  324. </if>
  325. <if test="saleUnitPrice != null">
  326. SALE_UNIT_PRICE,
  327. </if>
  328. <if test="saleOrderTax != null">
  329. SALE_ORDER_TAX,
  330. </if>
  331. <if test="saleRemark != null">
  332. SALE_REMARK,
  333. </if>
  334. <if test="insertUsername != null">
  335. INSERT_USERNAME,
  336. </if>
  337. <if test="insertTime != null">
  338. INSERT_TIME,
  339. </if>
  340. <if test="updateUsername != null">
  341. UPDATE_USERNAME,
  342. </if>
  343. <if test="updateTime != null">
  344. UPDATE_TIME,
  345. </if>
  346. <if test="insertUpdateRemark != null">
  347. INSERT_UPDATE_REMARK,
  348. </if>
  349. <if test="deleted != null">
  350. DELETED,
  351. </if>
  352. <if test="closeStatus != null">
  353. CLOSE_STATUS,
  354. </if>
  355. <if test="salerId != null">
  356. SALER_ID,
  357. </if>
  358. <if test="saleType != null">
  359. SALE_TYPE,
  360. </if>
  361. </trim>
  362. <trim prefix="values (" suffix=")" suffixOverrides=",">
  363. <if test="saleOrderId != null">
  364. #{saleOrderId,jdbcType=DECIMAL},
  365. </if>
  366. <if test="planId != null">
  367. #{planId,jdbcType=DECIMAL},
  368. </if>
  369. <if test="saleNumber != null">
  370. #{saleNumber,jdbcType=VARCHAR},
  371. </if>
  372. <if test="shipperId != null">
  373. #{shipperId,jdbcType=DECIMAL},
  374. </if>
  375. <if test="receiveId != null">
  376. #{receiveId,jdbcType=DECIMAL},
  377. </if>
  378. <if test="saleAccountBalance != null">
  379. #{saleAccountBalance,jdbcType=DECIMAL},
  380. </if>
  381. <if test="saleCurrentOrderAmount != null">
  382. #{saleCurrentOrderAmount,jdbcType=DECIMAL},
  383. </if>
  384. <if test="saleHistoricalOrderAmount != null">
  385. #{saleHistoricalOrderAmount,jdbcType=DECIMAL},
  386. </if>
  387. <if test="saleOrderStatus != null">
  388. #{saleOrderStatus,jdbcType=DECIMAL},
  389. </if>
  390. <if test="saleOrderReceiveCustomer != null">
  391. #{saleOrderReceiveCustomer,jdbcType=VARCHAR},
  392. </if>
  393. <if test="saleOrderIsselfMention != null">
  394. #{saleOrderIsselfMention,jdbcType=VARCHAR},
  395. </if>
  396. <if test="saleUnitPrice != null">
  397. #{saleUnitPrice,jdbcType=DECIMAL},
  398. </if>
  399. <if test="saleOrderTax != null">
  400. #{saleOrderTax,jdbcType=VARCHAR},
  401. </if>
  402. <if test="saleRemark != null">
  403. #{saleRemark,jdbcType=VARCHAR},
  404. </if>
  405. <if test="insertUsername != null">
  406. #{insertUsername,jdbcType=VARCHAR},
  407. </if>
  408. <if test="insertTime != null">
  409. #{insertTime,jdbcType=TIMESTAMP},
  410. </if>
  411. <if test="updateUsername != null">
  412. #{updateUsername,jdbcType=VARCHAR},
  413. </if>
  414. <if test="updateTime != null">
  415. #{updateTime,jdbcType=TIMESTAMP},
  416. </if>
  417. <if test="insertUpdateRemark != null">
  418. #{insertUpdateRemark,jdbcType=VARCHAR},
  419. </if>
  420. <if test="deleted != null">
  421. #{deleted,jdbcType=DECIMAL},
  422. </if>
  423. <if test="closeStatus != null">
  424. #{closeStatus,jdbcType=DECIMAL},
  425. </if>
  426. <if test="salerId != null">
  427. #{salerId,jdbcType=DECIMAL},
  428. </if>
  429. <if test="saleType != null">
  430. #{saleType,jdbcType=DECIMAL},
  431. </if>
  432. </trim>
  433. </insert>
  434. <update id="updateByPrimaryKey" parameterType="com.steerinfo.dil.model.AmsSaleOrder">
  435. update AMS_SALE_ORDER
  436. set PLAN_ID = #{planId,jdbcType=DECIMAL},
  437. SALE_NUMBER = #{saleNumber,jdbcType=VARCHAR},
  438. SHIPPER_ID = #{shipperId,jdbcType=DECIMAL},
  439. RECEIVE_ID = #{receiveId,jdbcType=DECIMAL},
  440. SALE_ACCOUNT_BALANCE = #{saleAccountBalance,jdbcType=DECIMAL},
  441. SALE_CURRENT_ORDER_AMOUNT = #{saleCurrentOrderAmount,jdbcType=DECIMAL},
  442. SALE_HISTORICAL_ORDER_AMOUNT = #{saleHistoricalOrderAmount,jdbcType=DECIMAL},
  443. SALE_ORDER_STATUS = #{saleOrderStatus,jdbcType=DECIMAL},
  444. SALE_ORDER_RECEIVE_CUSTOMER = #{saleOrderReceiveCustomer,jdbcType=VARCHAR},
  445. SALE_ORDER_ISSELF_MENTION = #{saleOrderIsselfMention,jdbcType=VARCHAR},
  446. SALE_UNIT_PRICE = #{saleUnitPrice,jdbcType=DECIMAL},
  447. SALE_ORDER_TAX = #{saleOrderTax,jdbcType=VARCHAR},
  448. SALE_REMARK = #{saleRemark,jdbcType=VARCHAR},
  449. INSERT_USERNAME = #{insertUsername,jdbcType=VARCHAR},
  450. INSERT_TIME = #{insertTime,jdbcType=TIMESTAMP},
  451. UPDATE_USERNAME = #{updateUsername,jdbcType=VARCHAR},
  452. UPDATE_TIME = #{updateTime,jdbcType=TIMESTAMP},
  453. INSERT_UPDATE_REMARK = #{insertUpdateRemark,jdbcType=VARCHAR},
  454. DELETED = #{deleted,jdbcType=DECIMAL},
  455. CLOSE_STATUS = #{closeStatus,jdbcType=DECIMAL},
  456. SALER_ID = #{salerId,jdbcType=DECIMAL},
  457. SALE_TYPE = #{saleType,jdbcType=DECIMAL}
  458. where SALE_ORDER_ID = #{saleOrderId,jdbcType=DECIMAL}
  459. </update>
  460. <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.dil.model.AmsSaleOrder">
  461. update AMS_SALE_ORDER
  462. <set>
  463. <if test="planId != null">
  464. PLAN_ID = #{planId,jdbcType=DECIMAL},
  465. </if>
  466. <if test="saleNumber != null">
  467. SALE_NUMBER = #{saleNumber,jdbcType=VARCHAR},
  468. </if>
  469. <if test="shipperId != null">
  470. SHIPPER_ID = #{shipperId,jdbcType=DECIMAL},
  471. </if>
  472. <if test="receiveId != null">
  473. RECEIVE_ID = #{receiveId,jdbcType=DECIMAL},
  474. </if>
  475. <if test="saleAccountBalance != null">
  476. SALE_ACCOUNT_BALANCE = #{saleAccountBalance,jdbcType=DECIMAL},
  477. </if>
  478. <if test="saleCurrentOrderAmount != null">
  479. SALE_CURRENT_ORDER_AMOUNT = #{saleCurrentOrderAmount,jdbcType=DECIMAL},
  480. </if>
  481. <if test="saleHistoricalOrderAmount != null">
  482. SALE_HISTORICAL_ORDER_AMOUNT = #{saleHistoricalOrderAmount,jdbcType=DECIMAL},
  483. </if>
  484. <if test="saleOrderStatus != null">
  485. SALE_ORDER_STATUS = #{saleOrderStatus,jdbcType=DECIMAL},
  486. </if>
  487. <if test="saleOrderReceiveCustomer != null">
  488. SALE_ORDER_RECEIVE_CUSTOMER = #{saleOrderReceiveCustomer,jdbcType=VARCHAR},
  489. </if>
  490. <if test="saleOrderIsselfMention != null">
  491. SALE_ORDER_ISSELF_MENTION = #{saleOrderIsselfMention,jdbcType=VARCHAR},
  492. </if>
  493. <if test="saleUnitPrice != null">
  494. SALE_UNIT_PRICE = #{saleUnitPrice,jdbcType=DECIMAL},
  495. </if>
  496. <if test="saleOrderTax != null">
  497. SALE_ORDER_TAX = #{saleOrderTax,jdbcType=VARCHAR},
  498. </if>
  499. <if test="saleRemark != null">
  500. SALE_REMARK = #{saleRemark,jdbcType=VARCHAR},
  501. </if>
  502. <if test="insertUsername != null">
  503. INSERT_USERNAME = #{insertUsername,jdbcType=VARCHAR},
  504. </if>
  505. <if test="insertTime != null">
  506. INSERT_TIME = #{insertTime,jdbcType=TIMESTAMP},
  507. </if>
  508. <if test="updateUsername != null">
  509. UPDATE_USERNAME = #{updateUsername,jdbcType=VARCHAR},
  510. </if>
  511. <if test="updateTime != null">
  512. UPDATE_TIME = #{updateTime,jdbcType=TIMESTAMP},
  513. </if>
  514. <if test="insertUpdateRemark != null">
  515. INSERT_UPDATE_REMARK = #{insertUpdateRemark,jdbcType=VARCHAR},
  516. </if>
  517. <if test="deleted != null">
  518. DELETED = #{deleted,jdbcType=DECIMAL},
  519. </if>
  520. <if test="closeStatus != null">
  521. CLOSE_STATUS = #{closeStatus,jdbcType=DECIMAL},
  522. </if>
  523. <if test="salerId != null">
  524. SALER_ID = #{salerId,jdbcType=DECIMAL},
  525. </if>
  526. <if test="saleType != null">
  527. SALE_TYPE = #{saleType,jdbcType=DECIMAL},
  528. </if>
  529. </set>
  530. where SALE_ORDER_ID = #{saleOrderId,jdbcType=DECIMAL}
  531. </update>
  532. <select id="selectByPrimaryKey" parameterType="DECIMAL" resultMap="BaseResultMap">
  533. <include refid="select" />
  534. where SALE_ORDER_ID = #{saleOrderId,jdbcType=DECIMAL}
  535. </select>
  536. <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
  537. <include refid="select" />
  538. <include refid="where" />
  539. </select>
  540. <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
  541. <include refid="select" />
  542. <include refid="whereLike" />
  543. </select>
  544. <insert id="batchInsert" parameterType="java.util.List">
  545. insert into AMS_SALE_ORDER
  546. (SALE_ORDER_ID,
  547. PLAN_ID, SALE_NUMBER, SHIPPER_ID,
  548. RECEIVE_ID, SALE_ACCOUNT_BALANCE,
  549. SALE_CURRENT_ORDER_AMOUNT, SALE_HISTORICAL_ORDER_AMOUNT,
  550. SALE_ORDER_STATUS, SALE_ORDER_RECEIVE_CUSTOMER,
  551. SALE_ORDER_ISSELF_MENTION, SALE_UNIT_PRICE,
  552. SALE_ORDER_TAX, SALE_REMARK, INSERT_USERNAME,
  553. INSERT_TIME, UPDATE_USERNAME,
  554. UPDATE_TIME, INSERT_UPDATE_REMARK,
  555. DELETED, CLOSE_STATUS, SALER_ID,
  556. SALE_TYPE)
  557. ( <foreach collection="list" item="item" separator="union all">
  558. select
  559. #{item.saleOrderId,jdbcType=DECIMAL},
  560. #{item.planId,jdbcType=DECIMAL}, #{item.saleNumber,jdbcType=VARCHAR}, #{item.shipperId,jdbcType=DECIMAL},
  561. #{item.receiveId,jdbcType=DECIMAL}, #{item.saleAccountBalance,jdbcType=DECIMAL},
  562. #{item.saleCurrentOrderAmount,jdbcType=DECIMAL}, #{item.saleHistoricalOrderAmount,jdbcType=DECIMAL},
  563. #{item.saleOrderStatus,jdbcType=DECIMAL}, #{item.saleOrderReceiveCustomer,jdbcType=VARCHAR},
  564. #{item.saleOrderIsselfMention,jdbcType=VARCHAR}, #{item.saleUnitPrice,jdbcType=DECIMAL},
  565. #{item.saleOrderTax,jdbcType=VARCHAR}, #{item.saleRemark,jdbcType=VARCHAR}, #{item.insertUsername,jdbcType=VARCHAR},
  566. #{item.insertTime,jdbcType=TIMESTAMP}, #{item.updateUsername,jdbcType=VARCHAR},
  567. #{item.updateTime,jdbcType=TIMESTAMP}, #{item.insertUpdateRemark,jdbcType=VARCHAR},
  568. #{item.deleted,jdbcType=DECIMAL}, #{item.closeStatus,jdbcType=DECIMAL}, #{item.salerId,jdbcType=DECIMAL},
  569. #{item.saleType,jdbcType=DECIMAL} from dual
  570. </foreach> )
  571. </insert>
  572. <update id="batchUpdate" parameterType="java.util.List">
  573. update AMS_SALE_ORDER
  574. set
  575. SALE_ORDER_ID=
  576. <foreach close="end" collection="list" index="index" item="item" open="case SALE_ORDER_ID" separator=" ">
  577. when #{item.saleOrderId,jdbcType=DECIMAL} then #{item.saleOrderId,jdbcType=DECIMAL}
  578. </foreach>
  579. ,PLAN_ID=
  580. <foreach close="end" collection="list" index="index" item="item" open="case SALE_ORDER_ID" separator=" ">
  581. when #{item.saleOrderId,jdbcType=DECIMAL} then #{item.planId,jdbcType=DECIMAL}
  582. </foreach>
  583. ,SALE_NUMBER=
  584. <foreach close="end" collection="list" index="index" item="item" open="case SALE_ORDER_ID" separator=" ">
  585. when #{item.saleOrderId,jdbcType=DECIMAL} then #{item.saleNumber,jdbcType=VARCHAR}
  586. </foreach>
  587. ,SHIPPER_ID=
  588. <foreach close="end" collection="list" index="index" item="item" open="case SALE_ORDER_ID" separator=" ">
  589. when #{item.saleOrderId,jdbcType=DECIMAL} then #{item.shipperId,jdbcType=DECIMAL}
  590. </foreach>
  591. ,RECEIVE_ID=
  592. <foreach close="end" collection="list" index="index" item="item" open="case SALE_ORDER_ID" separator=" ">
  593. when #{item.saleOrderId,jdbcType=DECIMAL} then #{item.receiveId,jdbcType=DECIMAL}
  594. </foreach>
  595. ,SALE_ACCOUNT_BALANCE=
  596. <foreach close="end" collection="list" index="index" item="item" open="case SALE_ORDER_ID" separator=" ">
  597. when #{item.saleOrderId,jdbcType=DECIMAL} then #{item.saleAccountBalance,jdbcType=DECIMAL}
  598. </foreach>
  599. ,SALE_CURRENT_ORDER_AMOUNT=
  600. <foreach close="end" collection="list" index="index" item="item" open="case SALE_ORDER_ID" separator=" ">
  601. when #{item.saleOrderId,jdbcType=DECIMAL} then #{item.saleCurrentOrderAmount,jdbcType=DECIMAL}
  602. </foreach>
  603. ,SALE_HISTORICAL_ORDER_AMOUNT=
  604. <foreach close="end" collection="list" index="index" item="item" open="case SALE_ORDER_ID" separator=" ">
  605. when #{item.saleOrderId,jdbcType=DECIMAL} then #{item.saleHistoricalOrderAmount,jdbcType=DECIMAL}
  606. </foreach>
  607. ,SALE_ORDER_STATUS=
  608. <foreach close="end" collection="list" index="index" item="item" open="case SALE_ORDER_ID" separator=" ">
  609. when #{item.saleOrderId,jdbcType=DECIMAL} then #{item.saleOrderStatus,jdbcType=DECIMAL}
  610. </foreach>
  611. ,SALE_ORDER_RECEIVE_CUSTOMER=
  612. <foreach close="end" collection="list" index="index" item="item" open="case SALE_ORDER_ID" separator=" ">
  613. when #{item.saleOrderId,jdbcType=DECIMAL} then #{item.saleOrderReceiveCustomer,jdbcType=VARCHAR}
  614. </foreach>
  615. ,SALE_ORDER_ISSELF_MENTION=
  616. <foreach close="end" collection="list" index="index" item="item" open="case SALE_ORDER_ID" separator=" ">
  617. when #{item.saleOrderId,jdbcType=DECIMAL} then #{item.saleOrderIsselfMention,jdbcType=VARCHAR}
  618. </foreach>
  619. ,SALE_UNIT_PRICE=
  620. <foreach close="end" collection="list" index="index" item="item" open="case SALE_ORDER_ID" separator=" ">
  621. when #{item.saleOrderId,jdbcType=DECIMAL} then #{item.saleUnitPrice,jdbcType=DECIMAL}
  622. </foreach>
  623. ,SALE_ORDER_TAX=
  624. <foreach close="end" collection="list" index="index" item="item" open="case SALE_ORDER_ID" separator=" ">
  625. when #{item.saleOrderId,jdbcType=DECIMAL} then #{item.saleOrderTax,jdbcType=VARCHAR}
  626. </foreach>
  627. ,SALE_REMARK=
  628. <foreach close="end" collection="list" index="index" item="item" open="case SALE_ORDER_ID" separator=" ">
  629. when #{item.saleOrderId,jdbcType=DECIMAL} then #{item.saleRemark,jdbcType=VARCHAR}
  630. </foreach>
  631. ,INSERT_USERNAME=
  632. <foreach close="end" collection="list" index="index" item="item" open="case SALE_ORDER_ID" separator=" ">
  633. when #{item.saleOrderId,jdbcType=DECIMAL} then #{item.insertUsername,jdbcType=VARCHAR}
  634. </foreach>
  635. ,INSERT_TIME=
  636. <foreach close="end" collection="list" index="index" item="item" open="case SALE_ORDER_ID" separator=" ">
  637. when #{item.saleOrderId,jdbcType=DECIMAL} then #{item.insertTime,jdbcType=TIMESTAMP}
  638. </foreach>
  639. ,UPDATE_USERNAME=
  640. <foreach close="end" collection="list" index="index" item="item" open="case SALE_ORDER_ID" separator=" ">
  641. when #{item.saleOrderId,jdbcType=DECIMAL} then #{item.updateUsername,jdbcType=VARCHAR}
  642. </foreach>
  643. ,UPDATE_TIME=
  644. <foreach close="end" collection="list" index="index" item="item" open="case SALE_ORDER_ID" separator=" ">
  645. when #{item.saleOrderId,jdbcType=DECIMAL} then #{item.updateTime,jdbcType=TIMESTAMP}
  646. </foreach>
  647. ,INSERT_UPDATE_REMARK=
  648. <foreach close="end" collection="list" index="index" item="item" open="case SALE_ORDER_ID" separator=" ">
  649. when #{item.saleOrderId,jdbcType=DECIMAL} then #{item.insertUpdateRemark,jdbcType=VARCHAR}
  650. </foreach>
  651. ,DELETED=
  652. <foreach close="end" collection="list" index="index" item="item" open="case SALE_ORDER_ID" separator=" ">
  653. when #{item.saleOrderId,jdbcType=DECIMAL} then #{item.deleted,jdbcType=DECIMAL}
  654. </foreach>
  655. ,CLOSE_STATUS=
  656. <foreach close="end" collection="list" index="index" item="item" open="case SALE_ORDER_ID" separator=" ">
  657. when #{item.saleOrderId,jdbcType=DECIMAL} then #{item.closeStatus,jdbcType=DECIMAL}
  658. </foreach>
  659. ,SALER_ID=
  660. <foreach close="end" collection="list" index="index" item="item" open="case SALE_ORDER_ID" separator=" ">
  661. when #{item.saleOrderId,jdbcType=DECIMAL} then #{item.salerId,jdbcType=DECIMAL}
  662. </foreach>
  663. ,SALE_TYPE=
  664. <foreach close="end" collection="list" index="index" item="item" open="case SALE_ORDER_ID" separator=" ">
  665. when #{item.saleOrderId,jdbcType=DECIMAL} then #{item.saleType,jdbcType=DECIMAL}
  666. </foreach>
  667. where SALE_ORDER_ID in
  668. <foreach close=")" collection="list" index="index" item="item" open="(" separator=",">
  669. #{item.saleOrderId,jdbcType=DECIMAL}
  670. </foreach>
  671. </update>
  672. <delete id="batchDelete" parameterType="java.util.List">
  673. delete from AMS_SALE_ORDER
  674. where SALE_ORDER_ID in
  675. <foreach close=")" collection="list" item="id" open="(" separator=",">
  676. #{id}
  677. </foreach>
  678. </delete>
  679. <!-- 友情提示!!!-->
  680. <!-- 请将自己写的代码放在此标签之下,方便以后粘贴复制。-->
  681. <sql id="orderBy">
  682. <if test="orderField != null and orderField != ''">
  683. order by "${orderField}"
  684. <if test="orderType != null and orderType != ''">
  685. ${orderType}
  686. </if>
  687. </if>
  688. <if test="orderField == null ">
  689. order by "insertTime" desc
  690. </if>
  691. </sql>
  692. <!--根据销售订单号排序-->
  693. <sql id="orderBy1">
  694. <if test="orderField != null and orderField != ''">
  695. order by "${orderField}"
  696. <if test="orderType != null and orderType != ''">
  697. ${orderType}
  698. </if>
  699. </if>
  700. <if test="orderField == null ">
  701. order by "saleNumber" desc
  702. </if>
  703. </sql>
  704. <select id="getSaleOrderInfo" parameterType="java.util.Map" resultType="java.util.LinkedHashMap">
  705. select * from(
  706. select a_s_order.SALE_ORDER_ID "saleOrderId",
  707. a_s_order.SALE_NUMBER "saleNumber",
  708. allmaterial_info.saleSum1 "materialTheoreticalWeight",
  709. allmaterial_info.saleSum2 "saleOrderMaterialNumber",
  710. r_shipper.SHIPPER_NAME "shipperName",
  711. r_consignee.CONSIGNEE_COMPANY_NAME "consigneeCompanyName",
  712. a_s_order.SALE_ORDER_ISSELF_MENTION "saleOrderIsselfMention",
  713. a_s_order.SALE_ACCOUNT_BALANCE "saleAccountBalance",
  714. a_s_order.SALE_CURRENT_ORDER_AMOUNT "saleCurrentOrderAmount",
  715. a_s_order.SALE_HISTORICAL_ORDER_AMOUNT "saleHistoricalOrderAmout",
  716. a_s_order.SALE_ORDER_RECEIVE_CUSTOMER "saleOrderReceiveCustomer",
  717. a_s_order.SALE_UNIT_PRICE "saleUnitPrice",
  718. a_s_order.SALE_ORDER_TAX "saleOrderTax",
  719. a_s_order.SALE_REMARK "saleRemark",
  720. a_s_order.INSERT_TIME "insertTime",
  721. from AMS_SALE_ORDER a_s_order
  722. left join (select sale_material.SALE_ORDER_ID saleOrderId,
  723. sum(tt.sum1) saleSum1,
  724. sum(tt.sum2) saleSum2
  725. from AMS_SALE_ORDER_MATERIAL sale_material
  726. left join
  727. (select truckno_material.SALE_ORDER_MATERIAL_ID s_order_material,
  728. sum(truckno_material.material_theoretical_weight) sum1,
  729. sum(truckno_material.sale_order_material_number) sum2
  730. from AMS_SALE_TRUCKNO_MATERIAL truckno_material group by
  731. truckno_material.SALE_ORDER_MATERIAL_ID) tt
  732. on tt.s_order_material = sale_material.SALE_ORDER_MATERIAL_ID
  733. group by
  734. sale_material.SALE_ORDER_ID) allmaterial_info
  735. on a_s_order.SALE_ORDER_ID=allmaterial_info.saleOrderId
  736. left join RMS_SHIPPER r_shipper
  737. on a_s_order.SHIPPER_ID=r_shipper.SHIPPER_ID
  738. left join RMS_CONSIGNEE r_consignee
  739. on a_s_order.RECEIVE_ID=r_consignee.CONSIGNEE_ID
  740. where a_s_order.SALE_ORDER_STATUS=0 and a_s_order.DELETED=0)
  741. <where>
  742. <if test="saleNumber != null">
  743. and
  744. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  745. "saleNumber" like '%${item}%'
  746. </foreach>
  747. </if>
  748. <if test="materialTheoreticalWeight != null">
  749. and
  750. <foreach collection="materialTheoreticalWeight" item="item" open="(" separator="or" close=")">
  751. "materialTheoreticalWeight" like '%${item}%'
  752. </foreach>
  753. </if>
  754. <if test="saleOrderMaterialNumber != null">
  755. and
  756. <foreach collection="saleOrderMaterialNumber" item="item" open="(" separator="or" close=")">
  757. "saleOrderMaterialNumber" like '%${item}%'
  758. </foreach>
  759. </if>
  760. <if test="shipperName != null">
  761. and
  762. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  763. "shipperName" like '%${item}%'
  764. </foreach>
  765. </if>
  766. <if test="consigneeCompanyName != null">
  767. and
  768. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  769. "consigneeCompanyName" like '%${item}%'
  770. </foreach>
  771. </if>
  772. <if test="saleOrderIsselfMention != null">
  773. and
  774. <foreach collection="saleOrderIsselfMention" item="item" open="(" separator="or" close=")">
  775. "saleOrderIsselfMention" like '%${item}%'
  776. </foreach>
  777. </if>
  778. <if test="saleAccountBalance != null">
  779. and
  780. <foreach collection="saleAccountBalance" item="item" open="(" separator="or" close=")">
  781. "saleAccountBalance" like '%${item}%'
  782. </foreach>
  783. </if>
  784. <if test="saleCurrentOrderAmount != null">
  785. and
  786. <foreach collection="saleCurrentOrderAmount" item="item" open="(" separator="or" close=")">
  787. "saleCurrentOrderAmount" like '%${item}%'
  788. </foreach>
  789. </if>
  790. <if test="saleHistoricalOrderAmout != null">
  791. and
  792. <foreach collection="saleHistoricalOrderAmout" item="item" open="(" separator="or" close=")">
  793. "saleHistoricalOrderAmout" like '%${item}%'
  794. </foreach>
  795. </if>
  796. <if test="saleOrderReceiveCustomer != null">
  797. and
  798. <foreach collection="saleOrderReceiveCustomer" item="item" open="(" separator="or" close=")">
  799. "saleOrderReceiveCustomer" like '%${item}%'
  800. </foreach>
  801. </if>
  802. <if test="saleUnitPrice != null">
  803. and
  804. <foreach collection="saleUnitPrice" item="item" open="(" separator="or" close=")">
  805. "saleUnitPrice" like '%${item}%'
  806. </foreach>
  807. </if>
  808. <if test="saleOrderTax != null">
  809. and
  810. <foreach collection="saleOrderTax" item="item" open="(" separator="or" close=")">
  811. "saleOrderTax" like '%${item}%'
  812. </foreach>
  813. </if>
  814. <if test="saleRemark != null">
  815. and
  816. <foreach collection="saleRemark" item="item" open="(" separator="or" close=")">
  817. "saleRemark" like '%${item}%'
  818. </foreach>
  819. </if>
  820. </where>
  821. <include refid="orderBy"></include>
  822. </select>
  823. <select id="getSaleOrderReported" parameterType="java.util.Map" resultType="java.util.LinkedHashMap">
  824. select * from(
  825. select a_s_order.SALE_ORDER_ID "saleOrderId",
  826. a_s_order.SALE_NUMBER "saleNumber",
  827. allmaterial_info.saleSum1 "materialTheoreticalWeight",
  828. allmaterial_info.saleSum2 "saleOrderMaterialNumber",
  829. r_shipper.SHIPPER_NAME "shipperName",
  830. r_consignee.CONSIGNEE_COMPANY_NAME "consigneeCompanyName",
  831. a_s_order.SALE_ORDER_ISSELF_MENTION "saleOrderIsselfMention",
  832. a_s_order.SALE_ACCOUNT_BALANCE "saleAccountBalance",
  833. a_s_order.SALE_CURRENT_ORDER_AMOUNT "saleCurrentOrderAmount",
  834. a_s_order.SALE_HISTORICAL_ORDER_AMOUNT "saleHistoricalOrderAmout",
  835. a_s_order.SALE_ORDER_RECEIVE_CUSTOMER "saleOrderReceiveCustomer",
  836. a_s_order.SALE_UNIT_PRICE "saleUnitPrice",
  837. a_s_order.SALE_ORDER_TAX "saleOrderTax",
  838. a_s_order.SALE_REMARK "saleRemark",
  839. a_s_order.INSERT_TIME "insertTime"
  840. from AMS_SALE_ORDER a_s_order
  841. left join (select sale_material.SALE_ORDER_ID saleOrderId,
  842. sum(tt.sum1) saleSum1,
  843. sum(tt.sum2) saleSum2
  844. from AMS_SALE_ORDER_MATERIAL sale_material
  845. left join
  846. (select truckno_material.SALE_ORDER_MATERIAL_ID s_order_material,
  847. sum(truckno_material.material_theoretical_weight) sum1,
  848. sum(truckno_material.sale_order_material_number) sum2
  849. from AMS_SALE_TRUCKNO_MATERIAL truckno_material group by
  850. truckno_material.SALE_ORDER_MATERIAL_ID) tt
  851. on tt.s_order_material = sale_material.SALE_ORDER_MATERIAL_ID
  852. group by
  853. sale_material.SALE_ORDER_ID) allmaterial_info
  854. on a_s_order.SALE_ORDER_ID=allmaterial_info.saleOrderId
  855. left join RMS_SHIPPER r_shipper
  856. on a_s_order.SHIPPER_ID=r_shipper.SHIPPER_ID
  857. left join RMS_CONSIGNEE r_consignee
  858. on a_s_order.RECEIVE_ID=r_consignee.CONSIGNEE_ID
  859. where a_s_order.SALE_ORDER_STATUS=1)
  860. <where>
  861. <if test="saleNumber != null">
  862. and
  863. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  864. "saleNumber" like '%${item}%'
  865. </foreach>
  866. </if>
  867. <if test="materialTheoreticalWeight != null">
  868. and
  869. <foreach collection="materialTheoreticalWeight" item="item" open="(" separator="or" close=")">
  870. "materialTheoreticalWeight" like '%${item}%'
  871. </foreach>
  872. </if>
  873. <if test="saleOrderMaterialNumber != null">
  874. and
  875. <foreach collection="saleOrderMaterialNumber" item="item" open="(" separator="or" close=")">
  876. "saleOrderMaterialNumber" like '%${item}%'
  877. </foreach>
  878. </if>
  879. <if test="shipperName != null">
  880. and
  881. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  882. "shipperName" like '%${item}%'
  883. </foreach>
  884. </if>
  885. <if test="consigneeCompanyName != null">
  886. and
  887. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  888. "consigneeCompanyName" like '%${item}%'
  889. </foreach>
  890. </if>
  891. <if test="saleOrderIsselfMention != null">
  892. and
  893. <foreach collection="saleOrderIsselfMention" item="item" open="(" separator="or" close=")">
  894. "saleOrderIsselfMention" like '%${item}%'
  895. </foreach>
  896. </if>
  897. <if test="saleAccountBalance != null">
  898. and
  899. <foreach collection="saleAccountBalance" item="item" open="(" separator="or" close=")">
  900. "saleAccountBalance" like '%${item}%'
  901. </foreach>
  902. </if>
  903. <if test="saleCurrentOrderAmount != null">
  904. and
  905. <foreach collection="saleCurrentOrderAmount" item="item" open="(" separator="or" close=")">
  906. "saleCurrentOrderAmount" like '%${item}%'
  907. </foreach>
  908. </if>
  909. <if test="saleHistoricalOrderAmout != null">
  910. and
  911. <foreach collection="saleHistoricalOrderAmout" item="item" open="(" separator="or" close=")">
  912. "saleHistoricalOrderAmout" like '%${item}%'
  913. </foreach>
  914. </if>
  915. <if test="saleOrderReceiveCustomer != null">
  916. and
  917. <foreach collection="saleOrderReceiveCustomer" item="item" open="(" separator="or" close=")">
  918. "saleOrderReceiveCustomer" like '%${item}%'
  919. </foreach>
  920. </if>
  921. <if test="saleUnitPrice != null">
  922. and
  923. <foreach collection="saleUnitPrice" item="item" open="(" separator="or" close=")">
  924. "saleUnitPrice" like '%${item}%'
  925. </foreach>
  926. </if>
  927. <if test="saleOrderTax != null">
  928. and
  929. <foreach collection="saleOrderTax" item="item" open="(" separator="or" close=")">
  930. "saleOrderTax" like '%${item}%'
  931. </foreach>
  932. </if>
  933. <if test="saleRemark != null">
  934. and
  935. <foreach collection="saleRemark" item="item" open="(" separator="or" close=")">
  936. "saleRemark" like '%${item}%'
  937. </foreach>
  938. </if>
  939. </where>
  940. <include refid="orderBy"></include>
  941. </select>
  942. <select id="getSaleOrderDetail" parameterType="java.util.Map" resultType="java.util.LinkedHashMap">
  943. select * from(
  944. select sale_material.SALE_ORDER_MATERIAL_ID "saleOrderMaterialId",
  945. sale_material.SALE_ORDER_MATERIAL_TRUCK_NO "saleOrderMaterialTruckNo",
  946. receive_address.ADDRESS_DELIVERY_ADDRESS "saleShippingAddress",
  947. sale_material.SALE_DATE_OF_RECEIPT "saleDateOfReceipt",
  948. sale_material.SALE_ORDER_CONSIGNEE "saleOrderConsignee",
  949. sale_material.SALE_ORDER_CONSIGNEE_TEL "saleOrderConsigneeTel",
  950. sale_material.INSERT_TIME "insertTime"
  951. from AMS_SALE_ORDER_MATERIAL sale_material
  952. left join AMS_SALE_ORDER a_s_order
  953. on sale_material.SALE_ORDER_ID=a_s_order.SALE_ORDER_ID
  954. left join RMS_RECEIVE_ADDRESS receive_address
  955. on sale_material.SALE_SHIPPING_ADDRESS_ID=receive_address.ADDRESS_ID
  956. where sale_material.SALE_ORDER_ID=#{saleOrderId} and sale_material.DELETED=0 and sale_material.UPDATED=0)
  957. <where>
  958. <if test="saleOrderMaterialTruckNo != null">
  959. and
  960. <foreach collection="saleOrderMaterialTruckNo" item="item" open="(" separator="or" close=")">
  961. "saleOrderMaterialTruckNo" like '%${item}%'
  962. </foreach>
  963. </if>
  964. <if test="materialName != null">
  965. and
  966. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  967. "materialName" like '%${item}%'
  968. </foreach>
  969. </if>
  970. <if test="materialSpecification != null">
  971. and
  972. <foreach collection="materialSpecification" item="item" open="(" separator="or" close=")">
  973. "materialSpecification" like '%${item}%'
  974. </foreach>
  975. </if>
  976. <if test="saleOrderMaterialNumber != null">
  977. and
  978. <foreach collection="saleOrderMaterialNumber" item="item" open="(" separator="or" close=")">
  979. "saleOrderMaterialNumber" like '%${item}%'
  980. </foreach>
  981. </if>
  982. <if test="materialTheoreticalWeight != null">
  983. and
  984. <foreach collection="materialTheoreticalWeight" item="item" open="(" separator="or" close=")">
  985. "materialTheoreticalWeight" like '%${item}%'
  986. </foreach>
  987. </if>
  988. <if test="saleShippingAddress != null">
  989. and
  990. <foreach collection="saleShippingAddress" item="item" open="(" separator="or" close=")">
  991. "saleShippingAddress" like '%${item}%'
  992. </foreach>
  993. </if>
  994. <if test="saleDateOfReceipt != null">
  995. and
  996. <foreach collection="saleDateOfReceipt" item="item" open="(" separator="or" close=")">
  997. "saleDateOfReceipt" like '%${item}%'
  998. </foreach>
  999. </if>
  1000. <if test="saleOrderConsignee != null">
  1001. and
  1002. <foreach collection="saleOrderConsignee" item="item" open="(" separator="or" close=")">
  1003. "saleOrderConsignee" like '%${item}%'
  1004. </foreach>
  1005. </if>
  1006. <if test="saleOrderConsigneeTel != null">
  1007. and
  1008. <foreach collection="saleOrderConsigneeTel" item="item" open="(" separator="or" close=")">
  1009. "saleOrderConsigneeTel" like '%${item}%'
  1010. </foreach>
  1011. </if>
  1012. </where>
  1013. <include refid="orderBy"></include>
  1014. </select>
  1015. <select id="getSaleOrderUpdateLog" parameterType="java.util.Map" resultType="java.util.LinkedHashMap">
  1016. select * from(
  1017. select
  1018. sale_material.SALE_ORDER_MATERIAL_TRUCK_NO "saleOrderMaterialTruckNo",
  1019. receive_address.ADDRESS_DELIVERY_ADDRESS "saleShippingAddress",
  1020. sale_material.SALE_DATE_OF_RECEIPT "saleDateOfReceipt",
  1021. sale_material.SALE_ORDER_CONSIGNEE "saleOrderConsignee",
  1022. sale_material.SALE_ORDER_CONSIGNEE_TEL "saleOrderConsigneeTel",
  1023. sale_material.INSERT_TIME "insertTime"
  1024. from AMS_SALE_ORDER_MATERIAL sale_material
  1025. left join AMS_SALE_ORDER a_s_order
  1026. on sale_material.SALE_ORDER_ID=a_s_order.SALE_ORDER_ID
  1027. left join RMS_RECEIVE_ADDRESS receive_address
  1028. on sale_material.SALE_SHIPPING_ADDRESS_ID=receive_address.ADDRESS_ID
  1029. where sale_material.SALE_ORDER_ID=#{saleOrderId} and sale_material.DELETED=0)
  1030. <where>
  1031. <if test="saleShippingAddress != null">
  1032. and
  1033. <foreach collection="saleShippingAddress" item="item" open="(" separator="or" close=")">
  1034. "saleShippingAddress" like '%${item}%'
  1035. </foreach>
  1036. </if>
  1037. <if test="saleDateOfReceipt != null">
  1038. and
  1039. <foreach collection="saleDateOfReceipt" item="item" open="(" separator="or" close=")">
  1040. "saleDateOfReceipt" like '%${item}%'
  1041. </foreach>
  1042. </if>
  1043. <if test="saleOrderConsignee != null">
  1044. and
  1045. <foreach collection="saleOrderConsignee" item="item" open="(" separator="or" close=")">
  1046. "saleOrderConsignee" like '%${item}%'
  1047. </foreach>
  1048. </if>
  1049. <if test="saleOrderConsigneeTel != null">
  1050. and
  1051. <foreach collection="saleOrderConsigneeTel" item="item" open="(" separator="or" close=")">
  1052. "saleOrderConsigneeTel" like '%${item}%'
  1053. </foreach>
  1054. </if>
  1055. </where>
  1056. <include refid="orderBy"></include>
  1057. </select>
  1058. <!--销售计划-->
  1059. <select id="getSalePlanName" resultType="java.util.LinkedHashMap">
  1060. select
  1061. a_s_plan.PLAN_ID "id",
  1062. a_s_plan.PLAN_ID "value",
  1063. a_s_plan.PLAN_NAME "label"
  1064. from AMS_SALE_PLAN a_s_plan
  1065. </select>
  1066. <!-- 收货客户-->
  1067. <select id="getShipperName" resultType="java.util.LinkedHashMap">
  1068. select
  1069. SHIPPER_ID "id",
  1070. SHIPPER_ID "value",
  1071. SHIPPER_NAME "label"
  1072. from RMS_SHIPPER
  1073. </select>
  1074. <!-- 收货客户-->
  1075. <select id="getConsigneeCompanyName" resultType="java.util.LinkedHashMap">
  1076. select
  1077. CONSIGNEE_ID "id",
  1078. CONSIGNEE_ID "value",
  1079. CONSIGNEE_COMPANY_NAME "label"
  1080. from RMS_CONSIGNEE
  1081. where rownum &lt; 20
  1082. </select>
  1083. <!-- <select id="selectMaxId" resultType="java.math.BigDecimal">-->
  1084. <!-- select max(SALE_ORDER_ID) from AMS_SALE_ORDER-->
  1085. <!-- </select>-->
  1086. <select id="selectBySaleOrderId" parameterType="java.math.BigDecimal" resultType="java.util.LinkedHashMap">
  1087. select
  1088. a_s_order.PLAN_ID "planId",
  1089. a_s_order.SHIPPER_ID "shipperId",
  1090. a_s_order.RECEIVE_ID "consigneeId",
  1091. a_s_order.SALE_ORDER_RECEIVE_CUSTOMER "saleOrderReceiveCustomer",
  1092. a_s_order.SALE_ORDER_ISSELF_MENTION "saleOrderIsselfMention",
  1093. a_s_order.SALE_REMARK "saleRemark"
  1094. from AMS_SALE_ORDER a_s_order
  1095. where a_s_order.SALE_ORDER_ID = #{saleOrderId}
  1096. </select>
  1097. <update id="deleteBySaleOrderId" parameterType="java.math.BigDecimal">
  1098. update AMS_SALE_ORDER_MATERIAL set DELETED = 1 where SALE_ORDER_ID = #{saleOrderId}
  1099. </update>
  1100. <select id="getAmsSaleOrderApproved" parameterType="java.util.Map" resultType="java.util.LinkedHashMap">
  1101. select * from(
  1102. select a_s_order.SALE_ORDER_ID "saleOrderId",
  1103. a_s_order.SALE_NUMBER "saleNumber",
  1104. allmaterial_info.saleSum1 "materialTheoreticalWeight",
  1105. allmaterial_info.saleSum2 "saleOrderMaterialNumber",
  1106. r_shipper.SHIPPER_NAME "shipperName",
  1107. r_consignee.CONSIGNEE_COMPANY_NAME "consigneeCompanyName",
  1108. r_consignee.CONSIGNEE_WARRANTY_AMOUNT "consigneeWarrantyAmount",
  1109. r_consignee.CONSIGNEE_WARRANTY_WEIGHT "consigneeWarrantyWeight",
  1110. a_s_order.SALE_ORDER_ISSELF_MENTION "saleOrderIsselfMention",
  1111. a_s_order.SALE_ACCOUNT_BALANCE "saleAccountBalance",
  1112. a_s_order.SALE_CURRENT_ORDER_AMOUNT "saleCurrentOrderAmount",
  1113. a_s_order.SALE_HISTORICAL_ORDER_AMOUNT "saleHistoricalOrderAmout",
  1114. a_s_order.SALE_ORDER_RECEIVE_CUSTOMER "saleOrderReceiveCustomer",
  1115. a_s_order.SALE_UNIT_PRICE "saleUnitPrice",
  1116. a_s_order.SALE_ORDER_TAX "saleOrderTax",
  1117. a_s_order.SALE_REMARK "saleRemark",
  1118. a_s_order.INSERT_TIME "insertTime"
  1119. from AMS_SALE_ORDER a_s_order
  1120. left join (select sale_material.SALE_ORDER_ID saleOrderId,
  1121. sum(tt.sum1) saleSum1,
  1122. sum(tt.sum2) saleSum2
  1123. from AMS_SALE_ORDER_MATERIAL sale_material
  1124. left join
  1125. (select truckno_material.SALE_ORDER_MATERIAL_ID s_order_material,
  1126. sum(truckno_material.material_theoretical_weight) sum1,
  1127. sum(truckno_material.sale_order_material_number) sum2
  1128. from AMS_SALE_TRUCKNO_MATERIAL truckno_material group by
  1129. truckno_material.SALE_ORDER_MATERIAL_ID) tt
  1130. on tt.s_order_material = sale_material.SALE_ORDER_MATERIAL_ID
  1131. group by
  1132. sale_material.SALE_ORDER_ID) allmaterial_info
  1133. on a_s_order.SALE_ORDER_ID=allmaterial_info.saleOrderId
  1134. left join RMS_SHIPPER r_shipper
  1135. on a_s_order.SHIPPER_ID=r_shipper.SHIPPER_ID
  1136. left join RMS_CONSIGNEE r_consignee
  1137. on a_s_order.RECEIVE_ID=r_consignee.CONSIGNEE_ID
  1138. where a_s_order.SALE_ORDER_STATUS=4)
  1139. <where>
  1140. <if test="saleNumber != null">
  1141. and
  1142. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  1143. "saleNumber" like '%${item}%'
  1144. </foreach>
  1145. </if>
  1146. <if test="materialTheoreticalWeight != null">
  1147. and
  1148. <foreach collection="materialTheoreticalWeight" item="item" open="(" separator="or" close=")">
  1149. "materialTheoreticalWeight" like '%${item}%'
  1150. </foreach>
  1151. </if>
  1152. <if test="saleOrderMaterialNumber != null">
  1153. and
  1154. <foreach collection="saleOrderMaterialNumber" item="item" open="(" separator="or" close=")">
  1155. "saleOrderMaterialNumber" like '%${item}%'
  1156. </foreach>
  1157. </if>
  1158. <if test="shipperName != null">
  1159. and
  1160. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  1161. "shipperName" like '%${item}%'
  1162. </foreach>
  1163. </if>
  1164. <if test="consigneeCompanyName != null">
  1165. and
  1166. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  1167. "consigneeCompanyName" like '%${item}%'
  1168. </foreach>
  1169. </if>
  1170. <if test="consigneeWarrantyAmount != null">
  1171. and
  1172. <foreach collection="consigneeWarrantyAmount" item="item" open="(" separator="or" close=")">
  1173. "consigneeWarrantyAmount" like '%${item}%'
  1174. </foreach>
  1175. </if>
  1176. <if test="consigneeWarrantyWeight != null">
  1177. and
  1178. <foreach collection="consigneeWarrantyWeight" item="item" open="(" separator="or" close=")">
  1179. "consigneeWarrantyWeight" like '%${item}%'
  1180. </foreach>
  1181. </if>
  1182. <if test="saleOrderIsselfMention != null">
  1183. and
  1184. <foreach collection="saleOrderIsselfMention" item="item" open="(" separator="or" close=")">
  1185. "saleOrderIsselfMention" like '%${item}%'
  1186. </foreach>
  1187. </if>
  1188. <if test="saleAccountBalance != null">
  1189. and
  1190. <foreach collection="saleAccountBalance" item="item" open="(" separator="or" close=")">
  1191. "saleAccountBalance" like '%${item}%'
  1192. </foreach>
  1193. </if>
  1194. <if test="saleCurrentOrderAmount != null">
  1195. and
  1196. <foreach collection="saleCurrentOrderAmount" item="item" open="(" separator="or" close=")">
  1197. "saleCurrentOrderAmount" like '%${item}%'
  1198. </foreach>
  1199. </if>
  1200. <if test="saleHistoricalOrderAmout != null">
  1201. and
  1202. <foreach collection="saleHistoricalOrderAmout" item="item" open="(" separator="or" close=")">
  1203. "saleHistoricalOrderAmout" like '%${item}%'
  1204. </foreach>
  1205. </if>
  1206. <if test="saleOrderReceiveCustomer != null">
  1207. and
  1208. <foreach collection="saleOrderReceiveCustomer" item="item" open="(" separator="or" close=")">
  1209. "saleOrderReceiveCustomer" like '%${item}%'
  1210. </foreach>
  1211. </if>
  1212. <if test="saleUnitPrice != null">
  1213. and
  1214. <foreach collection="saleUnitPrice" item="item" open="(" separator="or" close=")">
  1215. "saleUnitPrice" like '%${item}%'
  1216. </foreach>
  1217. </if>
  1218. <if test="saleOrderTax != null">
  1219. and
  1220. <foreach collection="saleOrderTax" item="item" open="(" separator="or" close=")">
  1221. "saleOrderTax" like '%${item}%'
  1222. </foreach>
  1223. </if>
  1224. <if test="saleRemark != null">
  1225. and
  1226. <foreach collection="saleRemark" item="item" open="(" separator="or" close=")">
  1227. "saleRemark" like '%${item}%'
  1228. </foreach>
  1229. </if>
  1230. </where>
  1231. <include refid="orderBy"></include>
  1232. </select>
  1233. <!-- 展示所有销售公司已审核的销售订单 -->
  1234. <select id="getSaleOrderList" parameterType="java.util.Map" resultType="java.util.Map">
  1235. select ADSO.DISPATCH_ID "dispatchId",
  1236. ASOM.SALE_ORDER_ID "saleOrderId",
  1237. ASOM.SALE_ORDER_MATERIAL_ID "saleOrderMaterialId",
  1238. ASO.SALE_NUMBER "saleNumber",
  1239. ASOM.SALE_ORDER_MATERIAL_TRUCK_NO "saleOrderMaterialTruckNo",
  1240. CONCAT(CONCAT(CONCAT(ADDRESS_PROVINCE, ADDRESS_DISTRICT), ADDRESS_TOWN),
  1241. RRP.ADDRESS_DELIVERY_ADDRESS) "addressDeliveryAddress",
  1242. TO_CHAR(ASOM.SALE_DATE_OF_RECEIPT, 'yyyy-mm-dd') "saleDateOfReceipt",
  1243. ASOM.SALE_ORDER_CONSIGNEE "saleOrderConsignee",
  1244. ASOM.SALE_ORDER_CONSIGNEE_TEL "saleOrderConsigneeTel",
  1245. RS.SHIPPER_NAME "shipperName",
  1246. RC.CONSIGNEE_COMPANY_NAME "consigneeCompanyName",
  1247. ASO.SALE_ORDER_ISSELF_MENTION "saleOrderIsselfMention",
  1248. ADSO.DISPATCH_TIME "dispatchTime",
  1249. ADSO.INSERT_TIME AS "insertTime"
  1250. FROM AMS_SALE_ORDER ASO
  1251. JOIN AMS_SALE_ORDER_MATERIAL ASOM
  1252. ON ASO.SALE_ORDER_ID = ASOM.SALE_ORDER_ID
  1253. LEFT JOIN AMS_DISPATCH_SALE_ORDER ADSO
  1254. ON ADSO.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  1255. LEFT JOIN RMS_RECEIVE_PLACE RRP
  1256. ON ASOM.SALE_SHIPPING_ADDRESS_ID = RRP.PLACE_ID
  1257. LEFT JOIN RMS_RECEIVE_ADDRESS RRA
  1258. ON RRP.ADDRESS_ID = RRA.ADDRESS_ID
  1259. LEFT JOIN RMS_SHIPPER RS
  1260. ON RS.SHIPPER_ID = ASO.SHIPPER_ID
  1261. LEFT JOIN RMS_CONSIGNEE RC
  1262. ON RC.CONSIGNEE_ID = ASO.RECEIVE_ID
  1263. WHERE ASO.SALE_ORDER_STATUS IN (2, 4)
  1264. AND ADSO.DISPATCH_STATUS = #{status}
  1265. AND ADSO.DISPATCH_TYPE = 0
  1266. order by ADSO.INSERT_TIME DESC
  1267. </select>
  1268. <select id="selectCarrierIdByprovince" resultType="java.math.BigDecimal" parameterType="java.util.Map">
  1269. SELECT RC.CARRIER_ID "carrierId"
  1270. FROM RMS_BID_AREA RBA
  1271. LEFT JOIN RMS_CARRIER RC
  1272. ON RBA.BID_AREA_ID=RC.CARRIER_BID_AREA_ID
  1273. WHERE RBA.BID_AREA_PROVINCE=#{province} AND RBA.BID_AREA_CITY=#{ditrict} AND RBA.BID_AREA_COUNTY=#{addressTown}
  1274. </select>
  1275. <select id="selectProvince" resultType="java.util.Map" parameterType="java.lang.Integer">
  1276. SELECT RRA.ADDRESS_PROVINCE "province",
  1277. RRA.ADDRESS_DISTRICT "ditrict",
  1278. RRA.ADDRESS_TOWN "addressTown"
  1279. FROM RMS_RECEIVE_ADDRESS RRA
  1280. WHERE RRA.ADDRESS_ID=#{addressId}
  1281. </select>
  1282. <!-- 销售公司查询已审核的销售订单 -->
  1283. <select id="getSaleOrderListBySaleCompany" parameterType="java.util.Map" resultType="java.util.Map">
  1284. select * from(
  1285. select a_s_order.SALE_ORDER_ID "saleOrderId",
  1286. a_s_order.SALE_NUMBER "saleNumber",
  1287. allmaterial_info.saleSum1 "materialTheoreticalWeight",
  1288. allmaterial_info.saleSum2 "saleOrderMaterialNumber",
  1289. r_shipper.SHIPPER_NAME "shipperName",
  1290. r_consignee.CONSIGNEE_COMPANY_NAME "consigneeCompanyName",
  1291. r_consignee.CONSIGNEE_WARRANTY_AMOUNT "consigneeWarrantyAmount",
  1292. r_consignee.CONSIGNEE_WARRANTY_WEIGHT "consigneeWarrantyWeight",
  1293. a_s_order.SALE_ORDER_ISSELF_MENTION "saleOrderIsselfMention",
  1294. a_s_order.SALE_ACCOUNT_BALANCE "saleAccountBalance",
  1295. a_s_order.SALE_CURRENT_ORDER_AMOUNT "saleCurrentOrderAmount",
  1296. a_s_order.SALE_HISTORICAL_ORDER_AMOUNT "saleHistoricalOrderAmout",
  1297. a_s_order.SALE_ORDER_RECEIVE_CUSTOMER "saleOrderReceiveCustomer",
  1298. a_s_order.SALE_UNIT_PRICE "saleUnitPrice",
  1299. a_s_order.SALE_ORDER_TAX "saleOrderTax",
  1300. a_s_order.SALE_REMARK "saleRemark",
  1301. a_s_order.INSERT_TIME "insertTime"
  1302. from AMS_SALE_ORDER a_s_order
  1303. left join (select sale_material.SALE_ORDER_ID saleOrderId,
  1304. sum(tt.sum1) saleSum1,
  1305. sum(tt.sum2) saleSum2
  1306. from AMS_SALE_ORDER_MATERIAL sale_material
  1307. left join
  1308. (select truckno_material.SALE_ORDER_MATERIAL_ID s_order_material,
  1309. sum(truckno_material.material_theoretical_weight) sum1,
  1310. sum(truckno_material.sale_order_material_number) sum2
  1311. from AMS_SALE_TRUCKNO_MATERIAL truckno_material group by
  1312. truckno_material.SALE_ORDER_MATERIAL_ID) tt
  1313. on tt.s_order_material = sale_material.SALE_ORDER_MATERIAL_ID
  1314. group by
  1315. sale_material.SALE_ORDER_ID) allmaterial_info
  1316. on a_s_order.SALE_ORDER_ID=allmaterial_info.saleOrderId
  1317. left join RMS_SHIPPER r_shipper
  1318. on a_s_order.SHIPPER_ID=r_shipper.SHIPPER_ID
  1319. left join RMS_CONSIGNEE r_consignee
  1320. on a_s_order.RECEIVE_ID=r_consignee.CONSIGNEE_ID
  1321. where a_s_order.SALE_ORDER_STATUS=2)
  1322. <where>
  1323. <if test="saleNumber != null">
  1324. and
  1325. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  1326. "saleNumber" like '%${item}%'
  1327. </foreach>
  1328. </if>
  1329. <if test="materialTheoreticalWeight != null">
  1330. and
  1331. <foreach collection="materialTheoreticalWeight" item="item" open="(" separator="or" close=")">
  1332. "materialTheoreticalWeight" like '%${item}%'
  1333. </foreach>
  1334. </if>
  1335. <if test="saleOrderMaterialNumber != null">
  1336. and
  1337. <foreach collection="saleOrderMaterialNumber" item="item" open="(" separator="or" close=")">
  1338. "saleOrderMaterialNumber" like '%${item}%'
  1339. </foreach>
  1340. </if>
  1341. <if test="shipperName != null">
  1342. and
  1343. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  1344. "shipperName" like '%${item}%'
  1345. </foreach>
  1346. </if>
  1347. <if test="consigneeCompanyName != null">
  1348. and
  1349. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  1350. "consigneeCompanyName" like '%${item}%'
  1351. </foreach>
  1352. </if>
  1353. <if test="consigneeWarrantyAmount != null">
  1354. and
  1355. <foreach collection="consigneeWarrantyAmount" item="item" open="(" separator="or" close=")">
  1356. "consigneeWarrantyAmount" like '%${item}%'
  1357. </foreach>
  1358. </if>
  1359. <if test="consigneeWarrantyWeight != null">
  1360. and
  1361. <foreach collection="consigneeWarrantyWeight" item="item" open="(" separator="or" close=")">
  1362. "consigneeWarrantyWeight" like '%${item}%'
  1363. </foreach>
  1364. </if>
  1365. <if test="saleOrderIsselfMention != null">
  1366. and
  1367. <foreach collection="saleOrderIsselfMention" item="item" open="(" separator="or" close=")">
  1368. "saleOrderIsselfMention" like '%${item}%'
  1369. </foreach>
  1370. </if>
  1371. <if test="saleAccountBalance != null">
  1372. and
  1373. <foreach collection="saleAccountBalance" item="item" open="(" separator="or" close=")">
  1374. "saleAccountBalance" like '%${item}%'
  1375. </foreach>
  1376. </if>
  1377. <if test="saleCurrentOrderAmount != null">
  1378. and
  1379. <foreach collection="saleCurrentOrderAmount" item="item" open="(" separator="or" close=")">
  1380. "saleCurrentOrderAmount" like '%${item}%'
  1381. </foreach>
  1382. </if>
  1383. <if test="saleHistoricalOrderAmout != null">
  1384. and
  1385. <foreach collection="saleHistoricalOrderAmout" item="item" open="(" separator="or" close=")">
  1386. "saleHistoricalOrderAmout" like '%${item}%'
  1387. </foreach>
  1388. </if>
  1389. <if test="saleOrderReceiveCustomer != null">
  1390. and
  1391. <foreach collection="saleOrderReceiveCustomer" item="item" open="(" separator="or" close=")">
  1392. "saleOrderReceiveCustomer" like '%${item}%'
  1393. </foreach>
  1394. </if>
  1395. <if test="saleUnitPrice != null">
  1396. and
  1397. <foreach collection="saleUnitPrice" item="item" open="(" separator="or" close=")">
  1398. "saleUnitPrice" like '%${item}%'
  1399. </foreach>
  1400. </if>
  1401. <if test="saleOrderTax != null">
  1402. and
  1403. <foreach collection="saleOrderTax" item="item" open="(" separator="or" close=")">
  1404. "saleOrderTax" like '%${item}%'
  1405. </foreach>
  1406. </if>
  1407. <if test="saleRemark != null">
  1408. and
  1409. <foreach collection="saleRemark" item="item" open="(" separator="or" close=")">
  1410. "saleRemark" like '%${item}%'
  1411. </foreach>
  1412. </if>
  1413. </where>
  1414. <include refid="orderBy"></include>
  1415. </select>
  1416. <!-- 通过收货地址,匹配对应的承运商-->
  1417. <select id="getCarrier" parameterType="java.lang.Integer" resultType="java.lang.Integer">
  1418. select rc.carrier_id from rms_receive_address rra LEFT join rms_carrier rc on rra.ADDRESS_ID = rc.CARRIER_BID_AREA_ID
  1419. WHERE rra.address_id = #{param}
  1420. </select>
  1421. <select id="selectInfoBySaleOrderId" resultType="java.util.Map" parameterType="java.math.BigDecimal">
  1422. select distinct ASO.SHIPPER_ID "shipperId",
  1423. ASO.RECEIVE_ID "reciveId",
  1424. ASO.SALE_ORDER_ISSELF_MENTION "saleOrderIsselfMention",
  1425. ASO.SALE_ORDER_RECEIVE_CUSTOMER "saleOrderReciveCustomer",
  1426. ASO.SALE_REMARK "saleRemark"
  1427. from AMS_SALE_ORDER ASO
  1428. left join AMS_SALE_ORDER_MATERIAL ASOM
  1429. on ASO.SALE_ORDER_ID=ASOM.SALE_ORDER_ID
  1430. left join AMS_SALE_TRUCKNO_MATERIAL ASTM
  1431. on ASTM.SALE_ORDER_MATERIAL_ID=ASOM.SALE_ORDER_MATERIAL_ID
  1432. left join RMS_MATERIAL RM
  1433. on RM.MATERIAL_ID=ASTM.MATERIAL_ID
  1434. where ASO.SALE_ORDER_ID=#{saleOrderId}
  1435. </select>
  1436. <!-- 根据销售订单id查找物资信息 -->
  1437. <select id="selectMaterialInfoBySaleOrderId" resultType="java.util.Map" parameterType="java.util.LinkedHashMap">
  1438. select distinct ASOM.SALE_ORDER_MATERIAL_TRUCK_NO "cxh",
  1439. ASTM.SALE_ORDER_MATERIAL_NUMBER "orderPlanWeight",
  1440. RM.MATERIAL_CODE "materialCode",
  1441. RM.MATERIAL_NAME "materialName",
  1442. CONCAT(CONCAT(RM.MATERIAL_SPECIFICATION, '('), CONCAT(RM.MATERIAL_MODEL, ')')) "Specification",
  1443. RM.MATERIAL_THEORETICAL_WEIGHT "materialTheoreticalWeight",
  1444. RM.MATERIAL_ID "materialId",
  1445. ASTM.SALE_ORDER_MATERIAL_ID "saleOrderMaterialId",
  1446. ASTM.TRUCKNO_MATERIAL_ID "trucknoMaterialId",
  1447. ASOM.SALE_DATE_OF_RECEIPT "saleDateOfReceipt",
  1448. ASOM.SALE_SHIPPING_ADDRESS_ID "saleShipperAddressId",
  1449. CONCAT( CONCAT( CONCAT( RRA.ADDRESS_PROVINCE, RRA.ADDRESS_DISTRICT ), RRA.ADDRESS_TOWN ), RRA.ADDRESS_DELIVERY_ADDRESS ) "saleShipperAddressName",
  1450. ASOM.SALE_ORDER_CONSIGNEE "saleOrderConsignee",
  1451. ASOM.SALE_ORDER_CONSIGNEE_TEL "saleOrderConsigneeTel"
  1452. from AMS_SALE_ORDER ASO
  1453. left join AMS_SALE_ORDER_MATERIAL ASOM
  1454. on ASO.SALE_ORDER_ID=ASOM.SALE_ORDER_ID
  1455. left join AMS_SALE_TRUCKNO_MATERIAL ASTM
  1456. on ASTM.SALE_ORDER_MATERIAL_ID=ASOM.SALE_ORDER_MATERIAL_ID
  1457. left join RMS_MATERIAL RM
  1458. on RM.MATERIAL_ID=ASTM.MATERIAL_ID
  1459. LEFT JOIN RMS_RECEIVE_ADDRESS RRA
  1460. ON ASOM.SALE_SHIPPING_ADDRESS_ID=RRA.ADDRESS_ID
  1461. where ASO.SALE_ORDER_ID=#{saleOrderId}
  1462. </select>
  1463. <select id="selectSaleOrderMaterialIdBySaleOrderId" resultType="java.util.Map" parameterType="java.math.BigDecimal">
  1464. select ASOM.SALE_ORDER_MATERIAL_ID "saleOrderMaterialId",
  1465. ASTM.TRUCKNO_MATERIAL_ID "TruckNoMaterialId"
  1466. from AMS_SALE_ORDER ASO
  1467. left join AMS_SALE_ORDER_MATERIAL ASOM
  1468. on ASO.SALE_ORDER_ID=ASOM.SALE_ORDER_ID
  1469. left join AMS_SALE_TRUCKNO_MATERIAL ASTM
  1470. on ASOM.SALE_ORDER_MATERIAL_ID=ASTM.SALE_ORDER_MATERIAL_ID
  1471. where ASO.SALE_ORDER_ID=#{saleOrderId}
  1472. </select>
  1473. <select id="getSaleOrderInfoes" parameterType="java.util.Map" resultType="java.util.LinkedHashMap">
  1474. select * from(
  1475. SELECT a_s_order.SALE_ORDER_ID "saleOrderId",
  1476. a_s_order.SALE_NUMBER "saleNumber",
  1477. r_shipper.SHIPPER_NAME "shipperName",
  1478. r_consignee.CONSIGNEE_COMPANY_NAME "consigneeCompanyName",
  1479. a_s_order.SALE_ORDER_ISSELF_MENTION "saleOrderIsselfMention",
  1480. a_s_order.SALE_ORDER_RECEIVE_CUSTOMER "saleOrderReceiveCustomer",
  1481. a_s_order.SALE_UNIT_PRICE "saleUnitPrice",
  1482. a_s_order.SALE_ORDER_TAX "saleOrderTax",
  1483. a_s_order.SALE_REMARK "saleRemark",
  1484. a_s_order.INSERT_TIME "insertTime",
  1485. RM.MATERIAL_NAME "materialName",
  1486. RM.MATERIAL_SPECIFICATION "materialSpecification",
  1487. RM.MATERIAL_MODEL "materialModel",
  1488. ASM.MATERIAL_NUMBER "materialNumber",
  1489. RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL "specificationModel",
  1490. RM.MATERIAL_NAME || RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL "nameSpecificationModel",
  1491. RRA.ADDRESS_PROVINCE || RRA.ADDRESS_DISTRICT || RRA.ADDRESS_TOWN ||
  1492. RRP.ADDRESS_DELIVERY_ADDRESS AS "addressPlace",
  1493. ASOM.SALE_ORDER_MATERIAL_ID AS "saleOrderMaterialId",
  1494. decode(ASM.IS_POUND_SALE, 0, '是' , '否') "isPoundSale",
  1495. ASOM.TRUCK_REMARK "trucRemark",
  1496. ASOM.SALE_ORDER_CONSIGNEE_TEL "consigneeTel"
  1497. FROM AMS_SALE_ORDER a_s_order
  1498. LEFT JOIN RMS_SHIPPER r_shipper
  1499. ON a_s_order.SHIPPER_ID = r_shipper.SHIPPER_ID
  1500. LEFT JOIN RMS_CONSIGNEE r_consignee
  1501. ON a_s_order.RECEIVE_ID = r_consignee.CONSIGNEE_ID
  1502. LEFT JOIN AMS_SALE_ORDER_MATERIAL ASOM
  1503. ON ASOM.SALE_ORDER_ID = a_s_order.SALE_ORDER_ID
  1504. LEFT JOIN RMS_RECEIVE_PLACE RRP
  1505. ON RRP.PLACE_ID = ASOM.SALE_SHIPPING_ADDRESS_ID
  1506. LEFT JOIN RMS_RECEIVE_ADDRESS RRA
  1507. ON RRA.ADDRESS_ID = RRP.ADDRESS_ID
  1508. LEFT JOIN AMS_SALE_TRUCKNO_MATERIAL ASTM
  1509. ON ASTM.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  1510. LEFT JOIN AMS_SALE_MATERIAL ASM
  1511. ON ASM.SALE_MATERIAL_ID = ASTM.MATERIAL_ID
  1512. LEFT JOIN RMS_MATERIAL RM
  1513. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  1514. LEFT JOIN RMS_SALER R_SALER
  1515. ON R_SALER.SALER_ID = a_s_order.SALER_ID
  1516. WHERE a_s_order.SALE_ORDER_STATUS = 0
  1517. AND a_s_order.DELETED = 0
  1518. AND ASM.DELETED IS NULL
  1519. <if test="con != null">
  1520. and (instr(r_consignee.CONSIGNEE_COMPANY_NAME, #{con}) > 0 or instr(a_s_order.SALE_NUMBER, #{con}) > 0)
  1521. </if>
  1522. <if test="consigneeSsoId != null" >
  1523. and r_consignee.CONSIGNEE_SSO_ID = #{consigneeSsoId}
  1524. </if>
  1525. <if test="saler != null " >
  1526. and R_SALER.INSERT_UPDATE_REMARK like #{saler}
  1527. </if>
  1528. <if test="oneDate != null">
  1529. and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= a_s_order.UPDATE_TIME
  1530. </if>
  1531. <if test="startDate != null">
  1532. and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= a_s_order.UPDATE_TIME
  1533. and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >= a_s_order.UPDATE_TIME
  1534. </if>
  1535. ORDER BY a_s_order.SALE_ORDER_ID DESC
  1536. )
  1537. <where>
  1538. <if test="saleNumber != null">
  1539. and
  1540. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  1541. "saleNumber" like '%${item}%'
  1542. </foreach>
  1543. </if>
  1544. <if test="materialName != null">
  1545. and
  1546. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  1547. "materialName" like '%${item}%'
  1548. </foreach>
  1549. </if>
  1550. <if test="specificationModel != null">
  1551. and
  1552. <foreach collection="specificationModel" item="item" open="(" separator="or" close=")">
  1553. "specificationModel" like '%${item}%'
  1554. </foreach>
  1555. </if>
  1556. <if test="materialModel != null">
  1557. and
  1558. <foreach collection="materialModel" item="item" open="(" separator="or" close=")">
  1559. "materialModel" like '%${item}%'
  1560. </foreach>
  1561. </if>
  1562. <if test="shipperName != null">
  1563. and
  1564. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  1565. "shipperName" like '%${item}%'
  1566. </foreach>
  1567. </if>
  1568. <if test="consigneeCompanyName != null">
  1569. and
  1570. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  1571. "consigneeCompanyName" like '%${item}%'
  1572. </foreach>
  1573. </if>
  1574. <if test="saleOrderIsselfMention != null">
  1575. and
  1576. <foreach collection="saleOrderIsselfMention" item="item" open="(" separator="or" close=")">
  1577. "saleOrderIsselfMention" like '%${item}%'
  1578. </foreach>
  1579. </if>
  1580. <if test="saleOrderReceiveCustomer != null">
  1581. and
  1582. <foreach collection="saleOrderReceiveCustomer" item="item" open="(" separator="or" close=")">
  1583. "saleOrderReceiveCustomer" like '%${item}%'
  1584. </foreach>
  1585. </if>
  1586. <if test="saleRemark != null">
  1587. and
  1588. <foreach collection="saleRemark" item="item" open="(" separator="or" close=")">
  1589. "saleRemark" like '%${item}%'
  1590. </foreach>
  1591. </if>
  1592. </where>
  1593. <include refid="orderBy1">
  1594. </include>
  1595. </select>
  1596. <select id="getSaleOrderReportedes" parameterType="java.util.Map" resultType="java.util.LinkedHashMap">
  1597. select * from(
  1598. select a_s_order.SALE_ORDER_ID "saleOrderId",
  1599. a_s_order.SALE_NUMBER "saleNumber",
  1600. r_shipper.SHIPPER_NAME "shipperName",
  1601. r_consignee.CONSIGNEE_COMPANY_NAME "consigneeCompanyName",
  1602. a_s_order.SALE_ORDER_ISSELF_MENTION "saleOrderIsselfMention",
  1603. a_s_order.SALE_ACCOUNT_BALANCE "saleAccountBalance",
  1604. a_s_order.SALE_CURRENT_ORDER_AMOUNT "saleCurrentOrderAmount",
  1605. a_s_order.SALE_HISTORICAL_ORDER_AMOUNT "saleHistoricalOrderAmout",
  1606. a_s_order.SALE_ORDER_RECEIVE_CUSTOMER "saleOrderReceiveCustomer",
  1607. a_s_order.SALE_UNIT_PRICE "saleUnitPrice",
  1608. a_s_order.SALE_ORDER_TAX "saleOrderTax",
  1609. a_s_order.SALE_REMARK "saleRemark",
  1610. a_s_order.INSERT_TIME "insertTime",
  1611. RM.MATERIAL_NAME "materialName",
  1612. RM.MATERIAL_SPECIFICATION "materialSpecification",
  1613. RM.MATERIAL_MODEL "materialModel",
  1614. RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL "specificationModel",
  1615. ASM.MATERIAL_NUMBER "materialNumber",
  1616. RM.MATERIAL_NAME || RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL "nameSpecificationModel",
  1617. RRA.ADDRESS_PROVINCE || RRA.ADDRESS_DISTRICT || RRA.ADDRESS_TOWN || RRP.ADDRESS_DELIVERY_ADDRESS AS "addressPlace"
  1618. from AMS_SALE_ORDER a_s_order
  1619. left join RMS_SHIPPER r_shipper
  1620. on a_s_order.SHIPPER_ID=r_shipper.SHIPPER_ID
  1621. left join RMS_CONSIGNEE r_consignee
  1622. on a_s_order.RECEIVE_ID=r_consignee.CONSIGNEE_ID
  1623. left join AMS_SALE_ORDER_MATERIAL ASOM
  1624. on asom.SALE_ORDER_ID = a_s_order.SALE_ORDER_ID
  1625. left join RMS_RECEIVE_PLACE RRP
  1626. on RRP.PLACE_ID = ASOM.SALE_SHIPPING_ADDRESS_ID
  1627. LEFT JOIN RMS_RECEIVE_ADDRESS RRA
  1628. ON RRP.ADDRESS_ID = RRA.ADDRESS_ID
  1629. LEFT JOIN AMS_SALE_TRUCKNO_MATERIAL ASTM
  1630. ON ASTM.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  1631. LEFT JOIN AMS_SALE_MATERIAL ASM
  1632. ON ASM.SALE_MATERIAL_ID = ASTM.MATERIAL_ID
  1633. LEFT JOIN RMS_MATERIAL RM
  1634. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  1635. LEFT JOIN RMS_SALER R_SALER
  1636. ON R_SALER.SALER_ID = a_s_order.SALER_ID
  1637. where a_s_order.SALE_ORDER_STATUS=1
  1638. and a_s_order.DELETED = 0
  1639. AND ASM.DELETED IS NULL
  1640. <if test="con != null">
  1641. and (instr(r_consignee.CONSIGNEE_COMPANY_NAME, #{con}) > 0 or instr(a_s_order.SALE_NUMBER, #{con}) > 0)
  1642. </if>
  1643. <if test="oneDate != null">
  1644. and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= a_s_order.UPDATE_TIME
  1645. </if>
  1646. <if test="startDate != null">
  1647. and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= a_s_order.UPDATE_TIME
  1648. and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >= a_s_order.UPDATE_TIME
  1649. </if>
  1650. <if test="consigneeSsoId != null">
  1651. and r_consignee.CONSIGNEE_SSO_ID = #{consigneeSsoId}
  1652. </if>
  1653. <if test="saler != null" >
  1654. and R_SALER.INSERT_UPDATE_REMARK like #{saler}
  1655. </if>
  1656. )
  1657. <where>
  1658. <if test="saleNumber != null">
  1659. and
  1660. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  1661. "saleNumber" like '%${item}%'
  1662. </foreach>
  1663. </if>
  1664. <if test="materialName != null">
  1665. and
  1666. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  1667. "materialName" like '%${item}%'
  1668. </foreach>
  1669. </if>
  1670. <if test="materialModel != null">
  1671. and
  1672. <foreach collection="materialModel" item="item" open="(" separator="or" close=")">
  1673. "materialModel" like '%${item}%'
  1674. </foreach>
  1675. </if>
  1676. <if test="materialSpecification != null">
  1677. and
  1678. <foreach collection="materialSpecification" item="item" open="(" separator="or" close=")">
  1679. "materialSpecification" like '%${item}%'
  1680. </foreach>
  1681. </if>
  1682. <if test="shipperName != null">
  1683. and
  1684. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  1685. "shipperName" like '%${item}%'
  1686. </foreach>
  1687. </if>
  1688. <if test="consigneeCompanyName != null">
  1689. and
  1690. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  1691. "consigneeCompanyName" like '%${item}%'
  1692. </foreach>
  1693. </if>
  1694. <if test="saleOrderIsselfMention != null">
  1695. and
  1696. <foreach collection="saleOrderIsselfMention" item="item" open="(" separator="or" close=")">
  1697. "saleOrderIsselfMention" like '%${item}%'
  1698. </foreach>
  1699. </if>
  1700. <if test="saleAccountBalance != null">
  1701. and
  1702. <foreach collection="saleAccountBalance" item="item" open="(" separator="or" close=")">
  1703. "saleAccountBalance" like '%${item}%'
  1704. </foreach>
  1705. </if>
  1706. <if test="saleCurrentOrderAmount != null">
  1707. and
  1708. <foreach collection="saleCurrentOrderAmount" item="item" open="(" separator="or" close=")">
  1709. "saleCurrentOrderAmount" like '%${item}%'
  1710. </foreach>
  1711. </if>
  1712. <if test="saleHistoricalOrderAmout != null">
  1713. and
  1714. <foreach collection="saleHistoricalOrderAmout" item="item" open="(" separator="or" close=")">
  1715. "saleHistoricalOrderAmout" like '%${item}%'
  1716. </foreach>
  1717. </if>
  1718. <if test="saleOrderReceiveCustomer != null">
  1719. and
  1720. <foreach collection="saleOrderReceiveCustomer" item="item" open="(" separator="or" close=")">
  1721. "saleOrderReceiveCustomer" like '%${item}%'
  1722. </foreach>
  1723. </if>
  1724. <if test="saleUnitPrice != null">
  1725. and
  1726. <foreach collection="saleUnitPrice" item="item" open="(" separator="or" close=")">
  1727. "saleUnitPrice" like '%${item}%'
  1728. </foreach>
  1729. </if>
  1730. <if test="saleOrderTax != null">
  1731. and
  1732. <foreach collection="saleOrderTax" item="item" open="(" separator="or" close=")">
  1733. "saleOrderTax" like '%${item}%'
  1734. </foreach>
  1735. </if>
  1736. <if test="saleRemark != null">
  1737. and
  1738. <foreach collection="saleRemark" item="item" open="(" separator="or" close=")">
  1739. "saleRemark" like '%${item}%'
  1740. </foreach>
  1741. </if>
  1742. </where>
  1743. <include refid="orderBy"></include>
  1744. </select>
  1745. <!-- 销售公司查询已审核的焦炭销售订单 -->
  1746. <select id="getCokeSaleOrderList" parameterType="java.util.Map" resultType="java.util.Map">
  1747. select * from(
  1748. select a_s_order.SALE_ORDER_ID "saleOrderId",
  1749. a_s_order.SALE_NUMBER "saleNumber",
  1750. r_shipper.SHIPPER_NAME "shipperName",
  1751. r_consignee.CONSIGNEE_COMPANY_NAME "consigneeCompanyName",
  1752. r_consignee.CONSIGNEE_WARRANTY_AMOUNT "consigneeWarrantyAmount",
  1753. r_consignee.CONSIGNEE_WARRANTY_WEIGHT "consigneeWarrantyWeight",
  1754. a_s_order.SALE_ORDER_ISSELF_MENTION "saleOrderIsselfMention",
  1755. a_s_order.SALE_ACCOUNT_BALANCE "saleAccountBalance",
  1756. a_s_order.SALE_CURRENT_ORDER_AMOUNT "saleCurrentOrderAmount",
  1757. a_s_order.SALE_HISTORICAL_ORDER_AMOUNT "saleHistoricalOrderAmout",
  1758. a_s_order.SALE_ORDER_RECEIVE_CUSTOMER "saleOrderReceiveCustomer",
  1759. a_s_order.SALE_UNIT_PRICE "saleUnitPrice",
  1760. a_s_order.SALE_ORDER_TAX "saleOrderTax",
  1761. a_s_order.SALE_REMARK "saleRemark",
  1762. a_s_order.INSERT_TIME "insertTime",
  1763. a_s_order.SALE_TYPE ,
  1764. DECODE(a_s_order.SALE_ORDER_STATUS,2,'销售已提交',4,'财务已审批') "statusStr",
  1765. RM.MATERIAL_NAME "materialName",
  1766. a_s_order.CLOSE_STATUS "closeStatus"
  1767. from AMS_SALE_ORDER a_s_order
  1768. left join RMS_SHIPPER r_shipper
  1769. on a_s_order.SHIPPER_ID=r_shipper.SHIPPER_ID
  1770. left join RMS_CONSIGNEE r_consignee
  1771. on a_s_order.RECEIVE_ID=r_consignee.CONSIGNEE_ID
  1772. left join AMS_SALE_MATERIAL ASM
  1773. on ASM.SALE_ORDER_ID = a_s_order.SALE_ORDER_ID
  1774. left join RMS_MATERIAL RM
  1775. on RM.MATERIAL_ID = ASM.MATERIAL_ID
  1776. where a_s_order.SALE_ORDER_STATUS in (2,4)
  1777. and a_s_order.CLOSE_STATUS is not null
  1778. and a_s_order.DELETED = 0
  1779. and a_s_order.SALE_TYPE is null
  1780. ) SSSR
  1781. <if test="con != null" >
  1782. where SSSR."consigneeCompanyName" LIKE #{con}
  1783. </if>
  1784. <if test="con != null" >
  1785. or SSSR."saleNumber" LIKE #{con}
  1786. </if>
  1787. <where>
  1788. <if test="saleNumber != null">
  1789. and
  1790. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  1791. "saleNumber" like '%${item}%'
  1792. </foreach>
  1793. </if>
  1794. <if test="materialName != null">
  1795. and
  1796. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  1797. "materialName" like '%${item}%'
  1798. </foreach>
  1799. </if>
  1800. <if test="statusStr != null">
  1801. and
  1802. <foreach collection="statusStr" item="item" open="(" separator="or" close=")">
  1803. "statusStr" like '%${item}%'
  1804. </foreach>
  1805. </if>
  1806. <if test="shipperName != null">
  1807. and
  1808. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  1809. "shipperName" like '%${item}%'
  1810. </foreach>
  1811. </if>
  1812. <if test="consigneeCompanyName != null">
  1813. and
  1814. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  1815. "consigneeCompanyName" like '%${item}%'
  1816. </foreach>
  1817. </if>
  1818. <if test="consigneeWarrantyAmount != null">
  1819. and
  1820. <foreach collection="consigneeWarrantyAmount" item="item" open="(" separator="or" close=")">
  1821. "consigneeWarrantyAmount" like '%${item}%'
  1822. </foreach>
  1823. </if>
  1824. <if test="consigneeWarrantyWeight != null">
  1825. and
  1826. <foreach collection="consigneeWarrantyWeight" item="item" open="(" separator="or" close=")">
  1827. "consigneeWarrantyWeight" like '%${item}%'
  1828. </foreach>
  1829. </if>
  1830. <if test="saleOrderIsselfMention != null">
  1831. and
  1832. <foreach collection="saleOrderIsselfMention" item="item" open="(" separator="or" close=")">
  1833. "saleOrderIsselfMention" like '%${item}%'
  1834. </foreach>
  1835. </if>
  1836. <if test="saleAccountBalance != null">
  1837. and
  1838. <foreach collection="saleAccountBalance" item="item" open="(" separator="or" close=")">
  1839. "saleAccountBalance" like '%${item}%'
  1840. </foreach>
  1841. </if>
  1842. <if test="saleCurrentOrderAmount != null">
  1843. and
  1844. <foreach collection="saleCurrentOrderAmount" item="item" open="(" separator="or" close=")">
  1845. "saleCurrentOrderAmount" like '%${item}%'
  1846. </foreach>
  1847. </if>
  1848. <if test="saleHistoricalOrderAmout != null">
  1849. and
  1850. <foreach collection="saleHistoricalOrderAmout" item="item" open="(" separator="or" close=")">
  1851. "saleHistoricalOrderAmout" like '%${item}%'
  1852. </foreach>
  1853. </if>
  1854. <if test="saleOrderReceiveCustomer != null">
  1855. and
  1856. <foreach collection="saleOrderReceiveCustomer" item="item" open="(" separator="or" close=")">
  1857. "saleOrderReceiveCustomer" like '%${item}%'
  1858. </foreach>
  1859. </if>
  1860. <if test="saleUnitPrice != null">
  1861. and
  1862. <foreach collection="saleUnitPrice" item="item" open="(" separator="or" close=")">
  1863. "saleUnitPrice" like '%${item}%'
  1864. </foreach>
  1865. </if>
  1866. <if test="saleOrderTax != null">
  1867. and
  1868. <foreach collection="saleOrderTax" item="item" open="(" separator="or" close=")">
  1869. "saleOrderTax" like '%${item}%'
  1870. </foreach>
  1871. </if>
  1872. <if test="saleRemark != null">
  1873. and
  1874. <foreach collection="saleRemark" item="item" open="(" separator="or" close=")">
  1875. "saleRemark" like '%${item}%'
  1876. </foreach>
  1877. </if>
  1878. </where>
  1879. <include refid="orderBy"></include>
  1880. </select>
  1881. <select id="getSaleOrderListBySaleCompanyes" parameterType="java.util.Map" resultType="java.util.Map">
  1882. select * from(
  1883. select a_s_order.SALE_ORDER_ID "saleOrderId",
  1884. a_s_order.SALE_NUMBER "saleNumber",
  1885. r_shipper.SHIPPER_NAME "shipperName",
  1886. r_consignee.CONSIGNEE_COMPANY_NAME "consigneeCompanyName",
  1887. r_consignee.CONSIGNEE_WARRANTY_AMOUNT "consigneeWarrantyAmount",
  1888. r_consignee.CONSIGNEE_WARRANTY_WEIGHT "consigneeWarrantyWeight",
  1889. a_s_order.SALE_ORDER_ISSELF_MENTION "saleOrderIsselfMention",
  1890. a_s_order.SALE_ACCOUNT_BALANCE "saleAccountBalance",
  1891. a_s_order.SALE_CURRENT_ORDER_AMOUNT "saleCurrentOrderAmount",
  1892. a_s_order.SALE_HISTORICAL_ORDER_AMOUNT "saleHistoricalOrderAmout",
  1893. a_s_order.SALE_ORDER_RECEIVE_CUSTOMER "saleOrderReceiveCustomer",
  1894. a_s_order.SALE_UNIT_PRICE "saleUnitPrice",
  1895. a_s_order.SALE_ORDER_TAX "saleOrderTax",
  1896. a_s_order.SALE_REMARK "saleRemark",
  1897. a_s_order.INSERT_TIME "insertTime",
  1898. DECODE(a_s_order.SALE_ORDER_STATUS,2,'销售已提交',4,'财务已审批') "statusStr",
  1899. RM.MATERIAL_NAME "materialName",
  1900. RM.MATERIAL_SPECIFICATION "materialSpecification",
  1901. RM.MATERIAL_MODEL "materialModel",
  1902. RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL "specificationModel",
  1903. ASM.MATERIAL_NUMBER "materialNumber",
  1904. RM.MATERIAL_NAME || RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL "nameSpecificationModel",
  1905. RRA.ADDRESS_PROVINCE || RRA.ADDRESS_DISTRICT || RRA.ADDRESS_TOWN || RRP.ADDRESS_DELIVERY_ADDRESS AS "addressPlace",
  1906. ASM.SALE_WAREHOUSE "saleWareHouse",
  1907. a_s_order.DELETED "deleted",
  1908. a_s_order.SHIPPER_ID "shipperId",
  1909. a_s_order.RECEIVE_ID "receiveId",
  1910. a_s_order.SALE_ORDER_ISSELF_MENTION "isSelfMention",
  1911. a_s_order.SALER_ID "salerId"
  1912. from AMS_SALE_ORDER a_s_order
  1913. left join RMS_SHIPPER r_shipper
  1914. on a_s_order.SHIPPER_ID=r_shipper.SHIPPER_ID
  1915. left join RMS_CONSIGNEE r_consignee
  1916. on a_s_order.RECEIVE_ID=r_consignee.CONSIGNEE_ID
  1917. left join AMS_SALE_ORDER_MATERIAL ASOM
  1918. on asom.SALE_ORDER_ID = a_s_order.SALE_ORDER_ID
  1919. left join RMS_RECEIVE_PLACE RRP
  1920. on RRP.PLACE_ID = ASOM.SALE_SHIPPING_ADDRESS_ID
  1921. LEFT JOIN RMS_RECEIVE_ADDRESS RRA
  1922. ON RRP.ADDRESS_ID = RRA.ADDRESS_ID
  1923. LEFT JOIN AMS_SALE_TRUCKNO_MATERIAL ASTM
  1924. ON ASTM.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  1925. LEFT JOIN AMS_SALE_MATERIAL ASM
  1926. ON ASM.SALE_MATERIAL_ID = ASTM.MATERIAL_ID
  1927. LEFT JOIN RMS_MATERIAL RM
  1928. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  1929. LEFT JOIN RMS_SALER R_SALER
  1930. ON R_SALER.SALER_ID = a_s_order.SALER_ID
  1931. where a_s_order.SALE_ORDER_STATUS in (2,4)
  1932. and a_s_order.CLOSE_STATUS is null
  1933. and ASM.DELETED IS NULL
  1934. and ASM.SALE_MATERIAL_ID IS NOT NULL
  1935. <if test="con != null">
  1936. and r_consignee.CONSIGNEE_COMPANY_NAME||a_s_order.SALE_NUMBER||rm.material_name||RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL like #{con}
  1937. </if>
  1938. <if test="oneDate != null">
  1939. and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= a_s_order.UPDATE_TIME
  1940. </if>
  1941. <if test="startDate != null">
  1942. and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= a_s_order.UPDATE_TIME
  1943. and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >= a_s_order.UPDATE_TIME
  1944. </if>
  1945. <if test="shipperId != null">
  1946. and a_s_order.SHIPPER_ID = #{shipperId}
  1947. </if>
  1948. <if test="saleType != null">
  1949. and a_s_order.SALE_TYPE = #{saleType}
  1950. </if>
  1951. <if test="saleType == null">
  1952. and a_s_order.SALE_TYPE is null
  1953. </if>
  1954. <if test="saler != null" >
  1955. and R_SALER.INSERT_UPDATE_REMARK like #{saler}
  1956. </if>
  1957. <if test="consigneeSsoId != null">
  1958. and r_consignee.CONSIGNEE_SSO_ID = #{consigneeSsoId}
  1959. </if>
  1960. ORDER BY a_s_order.UPDATE_TIME DESC
  1961. )
  1962. <where>
  1963. <if test="saleNumber != null">
  1964. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  1965. "saleNumber" like '%${item}%'
  1966. </foreach>
  1967. </if>
  1968. <if test="materialName != null">
  1969. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  1970. "materialName" like '%${item}%'
  1971. </foreach>
  1972. </if>
  1973. <if test="materialSpecification != null">
  1974. <foreach collection="materialSpecification" item="item" open="(" separator="or" close=")">
  1975. "materialSpecification" like '%${item}%'
  1976. </foreach>
  1977. </if>
  1978. <if test="materialModel != null">
  1979. <foreach collection="materialModel" item="item" open="(" separator="or" close=")">
  1980. "materialModel" like '%${item}%'
  1981. </foreach>
  1982. </if>
  1983. <if test="statusStr != null">
  1984. <foreach collection="statusStr" item="item" open="(" separator="or" close=")">
  1985. and "statusStr" like '%${item}%'
  1986. </foreach>
  1987. </if>
  1988. <!-- <if test="startTime != null">-->
  1989. <!-- and "insertTime" &gt;= to_date('${startTime}','yyyy-mm-dd')-->
  1990. <!-- </if>-->
  1991. <!-- <if test="endTime != null">-->
  1992. <!-- and "insertTime" &lt;= to_date('${endTime}','yyyy-mm-dd')-->
  1993. <!-- </if>-->
  1994. <if test="shipperName != null">
  1995. and
  1996. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  1997. "shipperName" like '%${item}%'
  1998. </foreach>
  1999. </if>
  2000. <if test="consigneeCompanyName != null">
  2001. and
  2002. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  2003. "consigneeCompanyName" like '%${item}%'
  2004. </foreach>
  2005. </if>
  2006. <if test="consigneeWarrantyAmount != null">
  2007. and
  2008. <foreach collection="consigneeWarrantyAmount" item="item" open="(" separator="or" close=")">
  2009. "consigneeWarrantyAmount" like '%${item}%'
  2010. </foreach>
  2011. </if>
  2012. <if test="consigneeWarrantyWeight != null">
  2013. and
  2014. <foreach collection="consigneeWarrantyWeight" item="item" open="(" separator="or" close=")">
  2015. "consigneeWarrantyWeight" like '%${item}%'
  2016. </foreach>
  2017. </if>
  2018. <if test="saleOrderIsselfMention != null">
  2019. and
  2020. <foreach collection="saleOrderIsselfMention" item="item" open="(" separator="or" close=")">
  2021. "saleOrderIsselfMention" like '%${item}%'
  2022. </foreach>
  2023. </if>
  2024. <if test="saleAccountBalance != null">
  2025. and
  2026. <foreach collection="saleAccountBalance" item="item" open="(" separator="or" close=")">
  2027. "saleAccountBalance" like '%${item}%'
  2028. </foreach>
  2029. </if>
  2030. <if test="saleCurrentOrderAmount != null">
  2031. and
  2032. <foreach collection="saleCurrentOrderAmount" item="item" open="(" separator="or" close=")">
  2033. "saleCurrentOrderAmount" like '%${item}%'
  2034. </foreach>
  2035. </if>
  2036. <if test="saleHistoricalOrderAmout != null">
  2037. and
  2038. <foreach collection="saleHistoricalOrderAmout" item="item" open="(" separator="or" close=")">
  2039. "saleHistoricalOrderAmout" like '%${item}%'
  2040. </foreach>
  2041. </if>
  2042. <if test="saleOrderReceiveCustomer != null">
  2043. and
  2044. <foreach collection="saleOrderReceiveCustomer" item="item" open="(" separator="or" close=")">
  2045. "saleOrderReceiveCustomer" like '%${item}%'
  2046. </foreach>
  2047. </if>
  2048. <if test="saleUnitPrice != null">
  2049. and
  2050. <foreach collection="saleUnitPrice" item="item" open="(" separator="or" close=")">
  2051. "saleUnitPrice" like '%${item}%'
  2052. </foreach>
  2053. </if>
  2054. <if test="saleOrderTax != null">
  2055. and
  2056. <foreach collection="saleOrderTax" item="item" open="(" separator="or" close=")">
  2057. "saleOrderTax" like '%${item}%'
  2058. </foreach>
  2059. </if>
  2060. <if test="saleRemark != null">
  2061. and
  2062. <foreach collection="saleRemark" item="item" open="(" separator="or" close=")">
  2063. "saleRemark" like '%${item}%'
  2064. </foreach>
  2065. </if>
  2066. </where>
  2067. </select>
  2068. <select id="getAmsSaleOrderApprovedes" parameterType="java.util.Map" resultType="java.util.LinkedHashMap">
  2069. select * from(
  2070. select a_s_order.SALE_ORDER_ID "saleOrderId",
  2071. a_s_order.SALE_NUMBER "saleNumber",
  2072. r_shipper.SHIPPER_NAME "shipperName",
  2073. r_consignee.CONSIGNEE_COMPANY_NAME "consigneeCompanyName",
  2074. r_consignee.CONSIGNEE_WARRANTY_AMOUNT "consigneeWarrantyAmount",
  2075. r_consignee.CONSIGNEE_WARRANTY_WEIGHT "consigneeWarrantyWeight",
  2076. a_s_order.SALE_ORDER_ISSELF_MENTION "saleOrderIsselfMention",
  2077. a_s_order.SALE_ACCOUNT_BALANCE "saleAccountBalance",
  2078. a_s_order.SALE_CURRENT_ORDER_AMOUNT "saleCurrentOrderAmount",
  2079. a_s_order.SALE_HISTORICAL_ORDER_AMOUNT "saleHistoricalOrderAmout",
  2080. a_s_order.SALE_ORDER_RECEIVE_CUSTOMER "saleOrderReceiveCustomer",
  2081. DECODE(a_s_order.SALE_ORDER_STATUS,2,'销售已提交',4,'财务已审批') "statusStr",
  2082. a_s_order.SALE_UNIT_PRICE "saleUnitPrice",
  2083. a_s_order.SALE_ORDER_TAX "saleOrderTax",
  2084. a_s_order.SALE_REMARK "saleRemark",
  2085. a_s_order.INSERT_TIME "insertTime"
  2086. from AMS_SALE_ORDER a_s_order
  2087. left join RMS_SHIPPER r_shipper
  2088. on a_s_order.SHIPPER_ID=r_shipper.SHIPPER_ID
  2089. left join RMS_CONSIGNEE r_consignee
  2090. on a_s_order.RECEIVE_ID=r_consignee.CONSIGNEE_ID
  2091. where a_s_order.SALE_ORDER_STATUS in (2,4)
  2092. AND a_s_order.SHIPPER_ID = 2
  2093. <if test="con != null">
  2094. and instr(r_consignee.CONSIGNEE_COMPANY_NAME, #{con}) > 0
  2095. </if>
  2096. )
  2097. <where>
  2098. <if test="saleNumber != null">
  2099. and
  2100. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  2101. "saleNumber" like '%${item}%'
  2102. </foreach>
  2103. </if>
  2104. <if test="statusStr != null">
  2105. and
  2106. <foreach collection="statusStr" item="item" open="(" separator="or" close=")">
  2107. "statusStr" like '%${item}%'
  2108. </foreach>
  2109. </if>
  2110. <if test="shipperName != null">
  2111. and
  2112. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  2113. "shipperName" like '%${item}%'
  2114. </foreach>
  2115. </if>
  2116. <if test="consigneeCompanyName != null">
  2117. and
  2118. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  2119. "consigneeCompanyName" like '%${item}%'
  2120. </foreach>
  2121. </if>
  2122. <if test="consigneeWarrantyAmount != null">
  2123. and
  2124. <foreach collection="consigneeWarrantyAmount" item="item" open="(" separator="or" close=")">
  2125. "consigneeWarrantyAmount" like '%${item}%'
  2126. </foreach>
  2127. </if>
  2128. <if test="consigneeWarrantyWeight != null">
  2129. and
  2130. <foreach collection="consigneeWarrantyWeight" item="item" open="(" separator="or" close=")">
  2131. "consigneeWarrantyWeight" like '%${item}%'
  2132. </foreach>
  2133. </if>
  2134. <if test="saleOrderIsselfMention != null">
  2135. and
  2136. <foreach collection="saleOrderIsselfMention" item="item" open="(" separator="or" close=")">
  2137. "saleOrderIsselfMention" like '%${item}%'
  2138. </foreach>
  2139. </if>
  2140. <if test="saleAccountBalance != null">
  2141. and
  2142. <foreach collection="saleAccountBalance" item="item" open="(" separator="or" close=")">
  2143. "saleAccountBalance" like '%${item}%'
  2144. </foreach>
  2145. </if>
  2146. <if test="saleCurrentOrderAmount != null">
  2147. and
  2148. <foreach collection="saleCurrentOrderAmount" item="item" open="(" separator="or" close=")">
  2149. "saleCurrentOrderAmount" like '%${item}%'
  2150. </foreach>
  2151. </if>
  2152. <if test="saleHistoricalOrderAmout != null">
  2153. and
  2154. <foreach collection="saleHistoricalOrderAmout" item="item" open="(" separator="or" close=")">
  2155. "saleHistoricalOrderAmout" like '%${item}%'
  2156. </foreach>
  2157. </if>
  2158. <if test="saleOrderReceiveCustomer != null">
  2159. and
  2160. <foreach collection="saleOrderReceiveCustomer" item="item" open="(" separator="or" close=")">
  2161. "saleOrderReceiveCustomer" like '%${item}%'
  2162. </foreach>
  2163. </if>
  2164. <if test="saleUnitPrice != null">
  2165. and
  2166. <foreach collection="saleUnitPrice" item="item" open="(" separator="or" close=")">
  2167. "saleUnitPrice" like '%${item}%'
  2168. </foreach>
  2169. </if>
  2170. <if test="saleOrderTax != null">
  2171. and
  2172. <foreach collection="saleOrderTax" item="item" open="(" separator="or" close=")">
  2173. "saleOrderTax" like '%${item}%'
  2174. </foreach>
  2175. </if>
  2176. <if test="saleRemark != null">
  2177. and
  2178. <foreach collection="saleRemark" item="item" open="(" separator="or" close=")">
  2179. "saleRemark" like '%${item}%'
  2180. </foreach>
  2181. </if>
  2182. </where>
  2183. <include refid="orderBy"></include>
  2184. </select>
  2185. <select id="getSaleOrderAndMaterialById" resultType="java.util.Map" parameterType="java.util.Map">
  2186. SELECT *
  2187. FROM (
  2188. SELECT
  2189. ASO.SALE_ORDER_ID AS "saleOrderId",
  2190. ASM.SALE_MATERIAL_ID AS "saleMaterialId",
  2191. RM.MATERIAL_ID AS "materialId",
  2192. ASO.SALE_NUMBER AS "saleNumber",
  2193. ASO.SALE_ORDER_ISSELF_MENTION AS "saleOrderIsselfMention",
  2194. ASO.SALE_REMARK AS "saleRemark",
  2195. RS.SHIPPER_NAME AS "shipperName",
  2196. RC.CONSIGNEE_COMPANY_NAME AS "consigneeCompanyName",
  2197. RM.MATERIAL_NAME AS "materialName",
  2198. ASM.MATERIAL_NUMBER AS "materialNumber",
  2199. ASM.MATERIAL_WEIGHT AS "materialWeight",
  2200. ASM.SALE_WAREHOUSE AS "saleWareHouse",
  2201. RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL AS "specificationModel",
  2202. RM.MATERIAL_CODE AS "materialCode",
  2203. nvl( sumWeight.weight, 0 ) + nvl( sumWeight2.weight, 0 ) + + nvl( sumWeight3.weight, 0 ) AS "totalWeight",
  2204. nvl( sumWeight.weight, 0 ) AS "netWeight",
  2205. nvl( sumWeight2.weight, 0 ) AS "weight",
  2206. nvl( carCount.coun, 0 ) + nvl( carCount1.coun, 0 ) AS "carCount"
  2207. FROM
  2208. AMS_SALE_ORDER ASO
  2209. LEFT JOIN RMS_SHIPPER RS ON ASO.SHIPPER_ID = RS.SHIPPER_ID
  2210. LEFT JOIN RMS_CONSIGNEE RC ON ASO.RECEIVE_ID = RC.CONSIGNEE_ID
  2211. LEFT JOIN AMS_SALE_MATERIAL ASM ON ASM.SALE_ORDER_ID = ASO.SALE_ORDER_ID
  2212. LEFT JOIN RMS_MATERIAL RM ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  2213. LEFT JOIN (
  2214. SELECT
  2215. sum( t_w_result.RESULT_NET_WEIGHT ) weight,
  2216. a_s_o_material.SALE_ORDER_ID SALE_ORDER_ID
  2217. FROM
  2218. AMS_SALE_ORDER_MATERIAL a_s_o_material
  2219. LEFT JOIN Omstruck_Order o_order ON a_s_o_material.SALE_ORDER_MATERIAL_ID = o_order.order_plan_id
  2220. LEFT JOIN Tmstruck_Total_Result t_t_result ON o_order.order_id = t_t_result.order_id
  2221. LEFT JOIN Tmstruck_Weight_Result t_w_result ON t_t_result.result_total_id = t_w_result.result_total_id
  2222. WHERE
  2223. o_order.ORDER_TYPE = 2
  2224. GROUP BY
  2225. a_s_o_Material.SALE_ORDER_ID
  2226. ) sumWeight ON sumWeight.SALE_ORDER_ID = ASO.SALE_ORDER_ID
  2227. LEFT JOIN (
  2228. SELECT
  2229. sum( o_o_material.ORDER_MATERIAL_WEIGHT ) weight,
  2230. a_s_o_Material.SALE_ORDER_ID SALE_ORDER_ID
  2231. FROM
  2232. AMS_SALE_ORDER_MATERIAL a_s_o_material
  2233. LEFT JOIN Omstruck_Order o_order ON a_s_o_material.SALE_ORDER_MATERIAL_ID = o_order.order_plan_id
  2234. LEFT JOIN Tmstruck_Total_Result t_t_result ON o_order.order_id = t_t_result.order_id
  2235. LEFT JOIN Tmstruck_Weight_Result t_w_result ON t_t_result.result_total_id = t_w_result.result_total_id
  2236. LEFT JOIN OMSTRUCK_ORDER_MATERIAL o_o_material ON o_order.order_id = o_o_material.ORDER_ID
  2237. WHERE
  2238. t_w_result.RESULT_NET_WEIGHT IS NULL
  2239. AND o_order.order_status IN ( 2, 5 )
  2240. AND o_order.ORDER_TYPE = 2
  2241. GROUP BY
  2242. a_s_o_Material.SALE_ORDER_ID
  2243. ) sumWeight2 ON sumWeight2.SALE_ORDER_ID = ASO.SALE_ORDER_ID
  2244. LEFT JOIN (
  2245. SELECT
  2246. sum( o_o_material.ORDER_MATERIAL_WEIGHT ) weight,
  2247. a_s_o_Material.SALE_ORDER_ID SALE_ORDER_ID
  2248. FROM
  2249. AMS_SALE_ORDER_MATERIAL a_s_o_material
  2250. LEFT JOIN Omstruck_Order o_order ON a_s_o_material.SALE_ORDER_MATERIAL_ID = o_order.order_plan_id
  2251. LEFT JOIN Tmstruck_Total_Result t_t_result ON o_order.order_id = t_t_result.order_id
  2252. LEFT JOIN Tmstruck_Weight_Result t_w_result ON t_t_result.result_total_id = t_w_result.result_total_id
  2253. LEFT JOIN OMSTRUCK_ORDER_MATERIAL o_o_material ON o_order.order_id = o_o_material.ORDER_ID
  2254. WHERE
  2255. t_w_result.RESULT_NET_WEIGHT IS NULL
  2256. AND o_order.order_status = 4
  2257. AND o_order.ORDER_TYPE = 2
  2258. AND a_s_o_material.SALE_DATE_OF_RECEIPT &lt; SYSDATE
  2259. GROUP BY
  2260. a_s_o_Material.SALE_ORDER_ID
  2261. ) sumWeight3 ON sumWeight3.SALE_ORDER_ID = ASO.SALE_ORDER_ID
  2262. LEFT JOIN (
  2263. SELECT
  2264. count( o_order.order_id ) coun,
  2265. a_s_o_Material.SALE_ORDER_ID SALE_ORDER_ID
  2266. FROM
  2267. AMS_SALE_ORDER_MATERIAL a_s_o_material
  2268. LEFT JOIN Omstruck_Order o_order ON a_s_o_material.SALE_ORDER_MATERIAL_ID = o_order.order_plan_id
  2269. LEFT JOIN Tmstruck_Total_Result t_t_result ON o_order.order_id = t_t_result.order_id
  2270. LEFT JOIN Tmstruck_Weight_Result t_w_result ON t_t_result.result_total_id = t_w_result.result_total_id
  2271. WHERE
  2272. o_order.order_status IN ( 2, 5 )
  2273. AND o_order.ORDER_TYPE = 2
  2274. GROUP BY
  2275. a_s_o_Material.SALE_ORDER_ID
  2276. ) carCount ON carCount.SALE_ORDER_ID = ASO.SALE_ORDER_ID
  2277. LEFT JOIN (
  2278. SELECT
  2279. count( o_order.order_id ) coun,
  2280. a_s_o_Material.SALE_ORDER_ID SALE_ORDER_ID
  2281. FROM
  2282. AMS_SALE_ORDER_MATERIAL a_s_o_material
  2283. LEFT JOIN Omstruck_Order o_order ON a_s_o_material.SALE_ORDER_MATERIAL_ID = o_order.order_plan_id
  2284. LEFT JOIN Tmstruck_Total_Result t_t_result ON o_order.order_id = t_t_result.order_id
  2285. LEFT JOIN Tmstruck_Weight_Result t_w_result ON t_t_result.result_total_id = t_w_result.result_total_id
  2286. WHERE
  2287. o_order.order_status = 4
  2288. AND o_order.ORDER_TYPE = 2
  2289. AND a_s_o_material.SALE_DATE_OF_RECEIPT &lt; SYSDATE
  2290. GROUP BY
  2291. a_s_o_Material.SALE_ORDER_ID
  2292. ) carCount1 ON carCount1.SALE_ORDER_ID = ASO.SALE_ORDER_ID
  2293. where ASO.SALE_ORDER_ID = #{saleOrderId}
  2294. )
  2295. <where>
  2296. <if test="saleNumber != null">
  2297. and
  2298. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  2299. "saleNumber" like '%${item}%'
  2300. </foreach>
  2301. </if>
  2302. <if test="shipperName != null">
  2303. and
  2304. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  2305. "shipperName" like '%${item}%'
  2306. </foreach>
  2307. </if>
  2308. <if test="consigneeCompanyName != null">
  2309. and
  2310. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  2311. "consigneeCompanyName" like '%${item}%'
  2312. </foreach>
  2313. </if>
  2314. <if test="materialName != null">
  2315. and
  2316. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  2317. "materialName" like '%${item}%'
  2318. </foreach>
  2319. </if>
  2320. <if test="specificationModel != null">
  2321. and
  2322. <foreach collection="specificationModel" item="item" open="(" separator="or" close=")">
  2323. "specificationModel" like '%${item}%'
  2324. </foreach>
  2325. </if>
  2326. <if test="materialCode != null">
  2327. and
  2328. <foreach collection="materialCode" item="item" open="(" separator="or" close=")">
  2329. "materialCode" like '%${item}%'
  2330. </foreach>
  2331. </if>
  2332. </where>
  2333. </select>
  2334. <select id="getSaleOrderAndMaterialById2" resultType="java.util.Map" parameterType="java.util.Map">
  2335. SELECT *
  2336. FROM (
  2337. select ASO.SALE_ORDER_ID as "saleOrderId",
  2338. ASM.SALE_MATERIAL_ID as "saleMaterialId",
  2339. RM.MATERIAL_ID as "materialId",
  2340. ASO.SALE_NUMBER as "saleNumber",
  2341. ASO.SALE_ORDER_ISSELF_MENTION as "saleOrderIsselfMention",
  2342. RS.SHIPPER_NAME as "shipperName",
  2343. RC.CONSIGNEE_COMPANY_NAME as "consigneeCompanyName",
  2344. RM.MATERIAL_NAME as "materialName",
  2345. ASM.MATERIAL_NUMBER as "materialNumber",
  2346. ASM.MATERIAL_WEIGHT as "materialWeight",
  2347. RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL as "specificationModel",
  2348. RM.MATERIAL_CODE as "materialCode"
  2349. from AMS_SALE_ORDER ASO
  2350. left join RMS_SHIPPER RS
  2351. on ASO.SHIPPER_ID = RS.SHIPPER_ID
  2352. left join RMS_CONSIGNEE RC
  2353. on ASO.RECEIVE_ID = RC.CONSIGNEE_ID
  2354. left join AMS_SALE_MATERIAL ASM
  2355. on ASM.SALE_ORDER_ID = ASO.SALE_ORDER_ID
  2356. left join RMS_MATERIAL RM
  2357. on RM.MATERIAL_ID = ASM.MATERIAL_ID
  2358. where ASO.SALE_ORDER_ID = #{saleOrderId}
  2359. )
  2360. <where>
  2361. <if test="saleNumber != null">
  2362. and
  2363. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  2364. "saleNumber" like '%${item}%'
  2365. </foreach>
  2366. </if>
  2367. <if test="shipperName != null">
  2368. and
  2369. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  2370. "shipperName" like '%${item}%'
  2371. </foreach>
  2372. </if>
  2373. <if test="consigneeCompanyName != null">
  2374. and
  2375. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  2376. "consigneeCompanyName" like '%${item}%'
  2377. </foreach>
  2378. </if>
  2379. <if test="materialName != null">
  2380. and
  2381. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  2382. "materialName" like '%${item}%'
  2383. </foreach>
  2384. </if>
  2385. <if test="specificationModel != null">
  2386. and
  2387. <foreach collection="specificationModel" item="item" open="(" separator="or" close=")">
  2388. "specificationModel" like '%${item}%'
  2389. </foreach>
  2390. </if>
  2391. <if test="materialCode != null">
  2392. and
  2393. <foreach collection="materialCode" item="item" open="(" separator="or" close=")">
  2394. "materialCode" like '%${item}%'
  2395. </foreach>
  2396. </if>
  2397. </where>
  2398. </select>
  2399. <select id="getSaleMaterial" parameterType="java.util.Map" resultType="java.util.Map">
  2400. SELECT * FROM (SELECT
  2401. RM.MATERIAL_NAME AS "materialName",
  2402. ASM.SALE_WAREHOUSE AS "saleWareHouse"
  2403. FROM AMS_SALE_MATERIAL ASM
  2404. LEFT JOIN RMS_MATERIAL RM
  2405. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  2406. WHERE ASM.SALE_ORDER_ID = #{saleOrderId}
  2407. <if test="con != null">
  2408. AND instr(RM.MATERIAL_NAME, #{con}) > 0
  2409. </if>
  2410. )
  2411. <where>
  2412. <if test="materialName != null">
  2413. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  2414. "materialName" like '%${item}%'
  2415. </foreach>
  2416. </if>
  2417. </where>
  2418. </select>
  2419. <select id="getNetWeight" parameterType="DECIMAL" resultType="DECIMAL">
  2420. SELECT SUM(twr.RESULT_NET_WEIGHT)
  2421. FROM AMS_SALE_ORDER_MATERIAL asom
  2422. left join OMSTRUCK_ORDER oo on oo.ORDER_PLAN_ID = asom.SALE_ORDER_MATERIAL_ID
  2423. left join TMSTRUCK_TOTAL_RESULT ttr on ttr.ORDER_ID = oo.ORDER_ID
  2424. left join TMSTRUCK_WEIGHT_RESULT twr on twr.RESULT_TOTAL_ID = ttr.RESULT_TOTAL_ID
  2425. where asom.sale_order_id = #{saleOrderId}
  2426. </select>
  2427. <select id="getCarNum" parameterType="DECIMAL" resultType="DECIMAL">
  2428. SELECT COUNT(ASOM.SALE_ORDER_MATERIAL_ID)
  2429. FROM AMS_SALE_ORDER_MATERIAL ASOM
  2430. WHERE ASOM.SALE_ORDER_ID = #{saleOrderId}
  2431. </select>
  2432. <select id="getTruckNoAndMaterial" parameterType="java.util.Map" resultType="java.util.Map" >
  2433. SELECT DISTINCT ASOM.SALE_ORDER_MATERIAL_TRUCK_NO AS "truckNo",
  2434. RM.MATERIAL_NAME AS "materialName",
  2435. ASM.MATERIAL_ID AS "materialId",
  2436. ASM.MATERIAL_NUMBER AS "materialNumber",
  2437. ASM.MATERIAL_WEIGHT AS "materialWeight",
  2438. ASOM.SALE_DATE_OF_RECEIPT AS "receiptDate",
  2439. RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL AS "materialModelSpecification",
  2440. RM.MATERIAL_CODE AS "materialCode",
  2441. RRA.ADDRESS_PROVINCE || RRA.ADDRESS_DISTRICT || RRA.ADDRESS_TOWN ||
  2442. RRP.ADDRESS_DELIVERY_ADDRESS AS "place",
  2443. ASOM.SALE_DATE_OF_RECEIPT AS "receiptDate",
  2444. ASOM.SALE_ORDER_CONSIGNEE_TEL AS "saleOrderConsigneeTel",
  2445. ASOM.SALE_ORDER_CONSIGNEE AS "saleOrderConsignee",
  2446. ASOM.SALE_ORDER_MATERIAL_ID AS "saleOrderMaterialId",
  2447. ASOM.SALE_SHIPPING_ADDRESS_ID AS "placeId",
  2448. RC.CAPACITY_NUMBER AS "capacityNumber",
  2449. ADSO.CARRIER_ID AS "carrierId",
  2450. RCA.CARRIER_NAME AS "carrierName",
  2451. ASOM.TRUCK_REMARK AS "truckRemark",
  2452. DECODE(ASO.SALE_ORDER_STATUS,1,'订单已上报',2,'销售已提交',4,'财务已审批') "statusStr"
  2453. FROM AMS_SALE_TRUCKNO_MATERIAL ASTM
  2454. LEFT JOIN AMS_SALE_ORDER_MATERIAL ASOM
  2455. ON ASOM.SALE_ORDER_MATERIAL_ID = ASTM.SALE_ORDER_MATERIAL_ID
  2456. LEFT JOIN AMS_SALE_ORDER ASO
  2457. ON ASO.SALE_ORDER_ID = ASOM.SALE_ORDER_ID
  2458. LEFT JOIN RMS_RECEIVE_PLACE RRP
  2459. ON RRP.PLACE_ID = ASOM.SALE_SHIPPING_ADDRESS_ID
  2460. LEFT JOIN RMS_RECEIVE_ADDRESS RRA
  2461. ON RRA.ADDRESS_ID = RRP.ADDRESS_ID
  2462. LEFT JOIN AMS_SALE_MATERIAL ASM
  2463. ON ASTM.MATERIAL_ID = ASM.SALE_MATERIAL_ID
  2464. LEFT JOIN RMS_MATERIAL RM
  2465. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  2466. LEFT JOIN OMSTRUCK_ORDER OO
  2467. ON OO.ORDER_PLAN_ID = ASOM.SALE_ORDER_MATERIAL_ID
  2468. AND NVL(OO.ORDER_TYPE,0) BETWEEN 0 AND 1
  2469. LEFT JOIN RMS_CAPACITY RC
  2470. ON RC.CAPACITY_ID = OO.CAPACITY_ID
  2471. LEFT JOIN AMS_DISPATCH_SALE_ORDER ADSO
  2472. ON ADSO.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  2473. LEFT JOIN RMS_CARRIER RCA
  2474. ON RCA.CARRIER_ID = ADSO.CARRIER_ID
  2475. WHERE ASOM.SALE_ORDER_ID = #{saleOrderId}
  2476. <if test="carrierSsoId != null">
  2477. AND RCA.CARRIER_SSO_ID = #{carrierSsoId}
  2478. </if>
  2479. AND OO.ORDER_ID IS NULL
  2480. AND ADSO.DISPATCH_ID IS NOT NULL
  2481. AND ASM.DELETED IS NULL
  2482. AND ASM.SALE_MATERIAL_ID IS NOT NULL
  2483. ORDER BY ASOM.SALE_ORDER_MATERIAL_TRUCK_NO ASC
  2484. </select>
  2485. <select id="getAddressByPlace" parameterType="DECIMAL" resultType="DECIMAL" >
  2486. SELECT RRP.ADDRESS_ID AS "adddressId"
  2487. FROM RMS_RECEIVE_PLACE RRP
  2488. WHERE RRP.PLACE_ID = #{placeId}
  2489. </select>
  2490. <select id="getCarrierByPlace" parameterType="DECIMAL" resultType="java.util.Map">
  2491. SELECT DISTINCT RC.CARRIER_ID AS "id",
  2492. RC.CARRIER_ID AS "value",
  2493. RC.CARRIER_NAME AS "label",
  2494. ACTP.PRICE_ID AS "priceId",
  2495. ACTP.PRICE_VALUE AS "priceValue"
  2496. FROM RMS_RECEIVE_PLACE RRP
  2497. LEFT JOIN AMS_CONTRACT_TRANSPORT_PRICE ACTP
  2498. ON ACTP.PLACE_ID = RRP.PLACE_ID
  2499. LEFT JOIN RMS_CARRIER RC
  2500. ON RC.CARRIER_ID = ACTP.CARRIER_ID
  2501. WHERE RRP.PLACE_ID = #{placeId}
  2502. AND ACTP.CARRIER_ID IS NOT NULL
  2503. AND ACTP.DELETED = 0
  2504. ORDER BY ACTP.PRICE_VALUE DESC
  2505. </select>
  2506. <select id="getPriceByCarrierAndPlace" parameterType="java.util.Map" resultType="java.util.Map">
  2507. SELECT ACTP.PRICE_ID AS "priceId",
  2508. ACTP.PRICE_VALUE AS "priceValue"
  2509. FROM AMS_CONTRACT_TRANSPORT_PRICE ACTP
  2510. WHERE ACTP.CARRIER_ID = #{carrierId}
  2511. AND ACTP.PLACE_ID = #{placeId}
  2512. AND ACTP.DELETED = 0
  2513. </select>
  2514. <select id="getSaleOrderListToCarrier" parameterType="java.util.Map" resultType="java.util.Map">
  2515. SELECT * FROM (
  2516. select DISTINCT * from(
  2517. select a_s_order.SALE_ORDER_ID "saleOrderId",
  2518. a_s_order.SALE_NUMBER "saleNumber",
  2519. r_shipper.SHIPPER_NAME "shipperName",
  2520. r_consignee.CONSIGNEE_COMPANY_NAME "consigneeCompanyName",
  2521. r_consignee.CONSIGNEE_WARRANTY_AMOUNT "consigneeWarrantyAmount",
  2522. r_consignee.CONSIGNEE_WARRANTY_WEIGHT "consigneeWarrantyWeight",
  2523. a_s_order.SALE_ORDER_ISSELF_MENTION "saleOrderIsselfMention",
  2524. a_s_order.SALE_ACCOUNT_BALANCE "saleAccountBalance",
  2525. a_s_order.SALE_CURRENT_ORDER_AMOUNT "saleCurrentOrderAmount",
  2526. a_s_order.SALE_HISTORICAL_ORDER_AMOUNT "saleHistoricalOrderAmout",
  2527. a_s_order.SALE_ORDER_RECEIVE_CUSTOMER "saleOrderReceiveCustomer",
  2528. a_s_order.SALE_UNIT_PRICE "saleUnitPrice",
  2529. a_s_order.SALE_ORDER_TAX "saleOrderTax",
  2530. a_s_order.SALE_REMARK "saleRemark",
  2531. a_s_order.INSERT_TIME "insertTime",
  2532. DECODE(a_s_order.SALE_ORDER_STATUS,1,'订单已上报',2,'销售已提交',4,'财务已审批') "statusStr",
  2533. a_s_order.UPDATE_TIME "updateTime",
  2534. RM.MATERIAL_NAME "materialName",
  2535. RM.MATERIAL_SPECIFICATION "materialSpecification",
  2536. RM.MATERIAL_MODEL "materialModel",
  2537. RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL "specificationModel",
  2538. ASM.MATERIAL_NUMBER "materialNumber",
  2539. RM.MATERIAL_NAME || RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL "nameSpecificationModel"
  2540. from AMS_SALE_ORDER a_s_order
  2541. left join RMS_SHIPPER r_shipper
  2542. on a_s_order.SHIPPER_ID=r_shipper.SHIPPER_ID
  2543. left join RMS_CONSIGNEE r_consignee
  2544. on a_s_order.RECEIVE_ID=r_consignee.CONSIGNEE_ID
  2545. LEFT JOIN AMS_SALE_ORDER_MATERIAL ASOM
  2546. ON ASOM.SALE_ORDER_ID = a_s_order.SALE_ORDER_ID
  2547. LEFT JOIN AMS_SALE_TRUCKNO_MATERIAL ASTM
  2548. ON ASTM.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  2549. LEFT JOIN AMS_DISPATCH_SALE_ORDER ADSO
  2550. ON ADSO.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  2551. LEFT JOIN RMS_CARRIER RC
  2552. ON RC.CARRIER_ID = ADSO.CARRIER_ID
  2553. LEFT JOIN OMSTRUCK_ORDER OO
  2554. ON OO.ORDER_PLAN_ID = ASOM.SALE_ORDER_MATERIAL_ID
  2555. AND NVL(OO.ORDER_TYPE,0) BETWEEN 0 AND 1
  2556. LEFT JOIN AMS_SALE_MATERIAL ASM
  2557. ON ASM.SALE_MATERIAL_ID = ASTM.MATERIAL_ID
  2558. LEFT JOIN RMS_MATERIAL RM
  2559. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  2560. where a_s_order.SALE_ORDER_STATUS in (1,2,4)
  2561. and a_s_order.CLOSE_STATUS is null
  2562. and a_s_order.DELETED = 0
  2563. and ADSO.DISPATCH_TYPE = 2
  2564. and OO.ORDER_ID IS NULL
  2565. AND ASM.DELETED IS NULL
  2566. AND ASM.SALE_MATERIAL_ID IS NOT NULL
  2567. <if test="oneDate != null">
  2568. and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt; = a_s_order.INSERT_TIME
  2569. </if>
  2570. <if test="startDate != null">
  2571. and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= a_s_order.INSERT_TIME
  2572. and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >= a_s_order.INSERT_TIME
  2573. </if>
  2574. <if test="carrierSsoId != null" >
  2575. and RC.CARRIER_SSO_ID = #{carrierSsoId}
  2576. </if>
  2577. ) "CARRIER"
  2578. <where>
  2579. <if test="con != null">
  2580. "CARRIER"."consigneeCompanyName" LIKE #{con} or "CARRIER"."saleNumber" LIKE #{con} or "CARRIER"."saleRemark" LIKE #{con}
  2581. </if>
  2582. </where>
  2583. )
  2584. <where>
  2585. <if test="saleNumber != null">
  2586. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  2587. "saleNumber" like '%${item}%'
  2588. </foreach>
  2589. </if>
  2590. <if test="materialName != null">
  2591. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  2592. "materialName" like '%${item}%'
  2593. </foreach>
  2594. </if>
  2595. <if test="materialSpecification != null">
  2596. <foreach collection="materialSpecification" item="item" open="(" separator="or" close=")">
  2597. "materialSpecification" like '%${item}%'
  2598. </foreach>
  2599. </if>
  2600. <if test="materialModel != null">
  2601. <foreach collection="materialModel" item="item" open="(" separator="or" close=")">
  2602. "materialModel" like '%${item}%'
  2603. </foreach>
  2604. </if>
  2605. <if test="shipperName != null">
  2606. and
  2607. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  2608. "shipperName" like '%${item}%'
  2609. </foreach>
  2610. </if>
  2611. <if test="consigneeCompanyName != null">
  2612. and
  2613. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  2614. "consigneeCompanyName" like '%${item}%'
  2615. </foreach>
  2616. </if>
  2617. <if test="consigneeWarrantyAmount != null">
  2618. and
  2619. <foreach collection="consigneeWarrantyAmount" item="item" open="(" separator="or" close=")">
  2620. "consigneeWarrantyAmount" like '%${item}%'
  2621. </foreach>
  2622. </if>
  2623. <if test="consigneeWarrantyWeight != null">
  2624. and
  2625. <foreach collection="consigneeWarrantyWeight" item="item" open="(" separator="or" close=")">
  2626. "consigneeWarrantyWeight" like '%${item}%'
  2627. </foreach>
  2628. </if>
  2629. <if test="saleOrderIsselfMention != null">
  2630. and
  2631. <foreach collection="saleOrderIsselfMention" item="item" open="(" separator="or" close=")">
  2632. "saleOrderIsselfMention" like '%${item}%'
  2633. </foreach>
  2634. </if>
  2635. <if test="saleAccountBalance != null">
  2636. and
  2637. <foreach collection="saleAccountBalance" item="item" open="(" separator="or" close=")">
  2638. "saleAccountBalance" like '%${item}%'
  2639. </foreach>
  2640. </if>
  2641. <if test="saleCurrentOrderAmount != null">
  2642. and
  2643. <foreach collection="saleCurrentOrderAmount" item="item" open="(" separator="or" close=")">
  2644. "saleCurrentOrderAmount" like '%${item}%'
  2645. </foreach>
  2646. </if>
  2647. <if test="saleHistoricalOrderAmout != null">
  2648. and
  2649. <foreach collection="saleHistoricalOrderAmout" item="item" open="(" separator="or" close=")">
  2650. "saleHistoricalOrderAmout" like '%${item}%'
  2651. </foreach>
  2652. </if>
  2653. <if test="saleOrderReceiveCustomer != null">
  2654. and
  2655. <foreach collection="saleOrderReceiveCustomer" item="item" open="(" separator="or" close=")">
  2656. "saleOrderReceiveCustomer" like '%${item}%'
  2657. </foreach>
  2658. </if>
  2659. <if test="saleUnitPrice != null">
  2660. and
  2661. <foreach collection="saleUnitPrice" item="item" open="(" separator="or" close=")">
  2662. "saleUnitPrice" like '%${item}%'
  2663. </foreach>
  2664. </if>
  2665. <if test="saleOrderTax != null">
  2666. and
  2667. <foreach collection="saleOrderTax" item="item" open="(" separator="or" close=")">
  2668. "saleOrderTax" like '%${item}%'
  2669. </foreach>
  2670. </if>
  2671. <if test="saleRemark != null">
  2672. and
  2673. <foreach collection="saleRemark" item="item" open="(" separator="or" close=")">
  2674. "saleRemark" like '%${item}%'
  2675. </foreach>
  2676. </if>
  2677. </where>
  2678. order by "updateTime" DESC
  2679. </select>
  2680. <select id="getSaleOrderListByCarrierSsoId" resultType="java.util.Map">
  2681. select * from(
  2682. select a_s_order.SALE_ORDER_ID "saleOrderId",
  2683. a_s_order.SALE_NUMBER "saleNumber",
  2684. r_shipper.SHIPPER_NAME "shipperName",
  2685. r_consignee.CONSIGNEE_COMPANY_NAME "consigneeCompanyName",
  2686. r_consignee.CONSIGNEE_WARRANTY_AMOUNT "consigneeWarrantyAmount",
  2687. r_consignee.CONSIGNEE_WARRANTY_WEIGHT "consigneeWarrantyWeight",
  2688. a_s_order.SALE_ORDER_ISSELF_MENTION "saleOrderIsselfMention",
  2689. a_s_order.SALE_ACCOUNT_BALANCE "saleAccountBalance",
  2690. a_s_order.SALE_CURRENT_ORDER_AMOUNT "saleCurrentOrderAmount",
  2691. a_s_order.SALE_HISTORICAL_ORDER_AMOUNT "saleHistoricalOrderAmout",
  2692. a_s_order.SALE_ORDER_RECEIVE_CUSTOMER "saleOrderReceiveCustomer",
  2693. a_s_order.SALE_UNIT_PRICE "saleUnitPrice",
  2694. a_s_order.SALE_ORDER_TAX "saleOrderTax",
  2695. a_s_order.SALE_REMARK "saleRemark",
  2696. a_s_order.INSERT_TIME "insertTime",
  2697. a_s_order.SALE_ORDER_STATUS "saleOrderStatus",
  2698. DECODE(a_s_order.SALE_ORDER_STATUS,2,'销售已提交',4,'财务已审批') "statusStr",
  2699. RM.MATERIAL_NAME "materialName",
  2700. RM.MATERIAL_SPECIFICATION "materialSpecification",
  2701. RM.MATERIAL_MODEL "materialModel",
  2702. RM.MATERIAL_NAME || RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL "nameSpecificationModel"
  2703. from AMS_SALE_ORDER_CARRIER a_s_o_carrier
  2704. left join RMS_CARRIER r_carrier
  2705. on r_carrier.CARRIER_ID=a_s_o_carrier.CARRIER_ID
  2706. left join AMS_SALE_ORDER a_s_order
  2707. on a_s_o_carrier.SALE_ORDER_ID=a_s_order.SALE_ORDER_ID
  2708. left join RMS_SHIPPER r_shipper
  2709. on a_s_order.SHIPPER_ID=r_shipper.SHIPPER_ID
  2710. left join RMS_CONSIGNEE r_consignee
  2711. on a_s_order.RECEIVE_ID=r_consignee.CONSIGNEE_ID
  2712. LEFT JOIN AMS_SALE_MATERIAL ASM
  2713. ON ASM.SALE_ORDER_ID = a_s_order.SALE_ORDER_ID
  2714. LEFT JOIN RMS_MATERIAL RM
  2715. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  2716. where a_s_order.SALE_ORDER_STATUS in (2,4)
  2717. and a_s_order.CLOSE_STATUS is null
  2718. and a_s_order.DELETED = 0
  2719. <if test="carrierSsoId != null">
  2720. and r_carrier.CARRIER_SSO_ID=#{carrierSsoId}
  2721. </if>
  2722. <if test="con != null">
  2723. and (instr(r_consignee.CONSIGNEE_COMPANY_NAME, #{con}) > 0 or instr(a_s_order.SALE_NUMBER, #{con}) > 0)
  2724. </if>
  2725. )
  2726. <where>
  2727. <if test="saleNumber != null">
  2728. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  2729. "saleNumber" like '%${item}%'
  2730. </foreach>
  2731. </if>
  2732. <if test="materialName != null">
  2733. and
  2734. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  2735. "materialName" like '%${item}%'
  2736. </foreach>
  2737. </if>
  2738. <if test="materialSpecification != null">
  2739. and
  2740. <foreach collection="materialSpecification" item="item" open="(" separator="or" close=")">
  2741. "materialSpecification" like '%${item}%'
  2742. </foreach>
  2743. </if>
  2744. <if test="materialModel != null">
  2745. and
  2746. <foreach collection="materialModel" item="item" open="(" separator="or" close=")">
  2747. "materialModel" like '%${item}%'
  2748. </foreach>
  2749. </if>
  2750. <if test="shipperName != null">
  2751. and
  2752. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  2753. "shipperName" like '%${item}%'
  2754. </foreach>
  2755. </if>
  2756. <if test="consigneeCompanyName != null">
  2757. and
  2758. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  2759. "consigneeCompanyName" like '%${item}%'
  2760. </foreach>
  2761. </if>
  2762. <if test="consigneeWarrantyAmount != null">
  2763. and
  2764. <foreach collection="consigneeWarrantyAmount" item="item" open="(" separator="or" close=")">
  2765. "consigneeWarrantyAmount" like '%${item}%'
  2766. </foreach>
  2767. </if>
  2768. <if test="consigneeWarrantyWeight != null">
  2769. and
  2770. <foreach collection="consigneeWarrantyWeight" item="item" open="(" separator="or" close=")">
  2771. "consigneeWarrantyWeight" like '%${item}%'
  2772. </foreach>
  2773. </if>
  2774. <if test="saleOrderIsselfMention != null">
  2775. and
  2776. <foreach collection="saleOrderIsselfMention" item="item" open="(" separator="or" close=")">
  2777. "saleOrderIsselfMention" like '%${item}%'
  2778. </foreach>
  2779. </if>
  2780. <if test="saleAccountBalance != null">
  2781. and
  2782. <foreach collection="saleAccountBalance" item="item" open="(" separator="or" close=")">
  2783. "saleAccountBalance" like '%${item}%'
  2784. </foreach>
  2785. </if>
  2786. <if test="saleCurrentOrderAmount != null">
  2787. and
  2788. <foreach collection="saleCurrentOrderAmount" item="item" open="(" separator="or" close=")">
  2789. "saleCurrentOrderAmount" like '%${item}%'
  2790. </foreach>
  2791. </if>
  2792. <if test="saleHistoricalOrderAmout != null">
  2793. and
  2794. <foreach collection="saleHistoricalOrderAmout" item="item" open="(" separator="or" close=")">
  2795. "saleHistoricalOrderAmout" like '%${item}%'
  2796. </foreach>
  2797. </if>
  2798. <if test="saleOrderReceiveCustomer != null">
  2799. and
  2800. <foreach collection="saleOrderReceiveCustomer" item="item" open="(" separator="or" close=")">
  2801. "saleOrderReceiveCustomer" like '%${item}%'
  2802. </foreach>
  2803. </if>
  2804. <if test="saleUnitPrice != null">
  2805. and
  2806. <foreach collection="saleUnitPrice" item="item" open="(" separator="or" close=")">
  2807. "saleUnitPrice" like '%${item}%'
  2808. </foreach>
  2809. </if>
  2810. <if test="saleOrderTax != null">
  2811. and
  2812. <foreach collection="saleOrderTax" item="item" open="(" separator="or" close=")">
  2813. "saleOrderTax" like '%${item}%'
  2814. </foreach>
  2815. </if>
  2816. <if test="saleRemark != null">
  2817. and
  2818. <foreach collection="saleRemark" item="item" open="(" separator="or" close=")">
  2819. "saleRemark" like '%${item}%'
  2820. </foreach>
  2821. </if>
  2822. </where>
  2823. <include refid="orderBy1"></include>
  2824. </select>
  2825. <select id="getSteelTruckNoList" parameterType="java.util.Map" resultType="java.util.Map">
  2826. SELECT *
  2827. FROM (
  2828. SELECT ASO.SALE_NUMBER AS "saleNumber",
  2829. ASOM.SALE_ORDER_MATERIAL_TRUCK_NO AS "truckNo",
  2830. RRA.ADDRESS_PROVINCE || RRA.ADDRESS_DISTRICT || RRA.ADDRESS_TOWN || RRP.ADDRESS_DELIVERY_ADDRESS AS
  2831. "addressDeliveryAddress",
  2832. ASOM.SALE_DATE_OF_RECEIPT AS "saleDateOfReceipt",
  2833. DECODE(ASO.SALE_ORDER_STATUS,1,'订单已上报',2, '销售已提交',4, '财务已审批')
  2834. AS "approvalStatus",
  2835. ASOM.SALE_ORDER_CONSIGNEE_TEL AS "saleOrderConsigneeTel",
  2836. RSH.SHIPPER_NAME AS "shipperName",
  2837. RCO.CONSIGNEE_COMPANY_NAME AS "consigneeCompanyName",
  2838. ASO.SALE_ORDER_ISSELF_MENTION AS "isselfMention",
  2839. ASOM.INSERT_TIME AS "insertTime",
  2840. ASOM.SALE_ORDER_MATERIAL_ID AS "saleOrderMaterialId",
  2841. ASO.SALE_ORDER_ID AS "saleOrderId",
  2842. RM.MATERIAL_NAME AS "materialName",
  2843. RM.MATERIAL_SPECIFICATION AS "materialSpecification",
  2844. RM.MATERIAL_MODEL AS "materialModel",
  2845. RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL AS "specificationModel",
  2846. ASM.MATERIAL_NUMBER AS "materialNumber",
  2847. RM.MATERIAL_NAME || RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL AS "nameSpecificationModel"
  2848. FROM AMS_SALE_ORDER_MATERIAL ASOM
  2849. LEFT JOIN AMS_SALE_ORDER ASO
  2850. ON ASO.SALE_ORDER_ID = ASOM.SALE_ORDER_ID
  2851. LEFT JOIN AMS_SALE_TRUCKNO_MATERIAL ASTM
  2852. ON ASTM.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  2853. LEFT JOIN RMS_RECEIVE_PLACE RRP
  2854. ON RRP.PLACE_ID = ASOM.SALE_SHIPPING_ADDRESS_ID
  2855. LEFT JOIN RMS_RECEIVE_ADDRESS RRA
  2856. ON RRA.ADDRESS_ID = RRP.ADDRESS_ID
  2857. LEFT JOIN RMS_SHIPPER RSH
  2858. ON RSH.SHIPPER_ID = ASO.SHIPPER_ID
  2859. LEFT JOIN RMS_CONSIGNEE RCO
  2860. ON RCO.CONSIGNEE_ID = ASO.RECEIVE_ID
  2861. LEFT JOIN AMS_DISPATCH_SALE_ORDER ADSO
  2862. ON ADSO.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  2863. LEFT JOIN AMS_SALE_MATERIAL ASM
  2864. ON ASM.SALE_MATERIAL_ID = ASTM.MATERIAL_ID
  2865. LEFT JOIN RMS_MATERIAL RM
  2866. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  2867. WHERE ASO.SALE_ORDER_STATUS IN (1,2,4)
  2868. AND ASOM.ISSUE_STATUS IS NULL
  2869. AND ADSO.CARRIER_ID IS NULL
  2870. AND ASO.DELETED = 0
  2871. AND ASM.DELETED IS NULL
  2872. AND ASM.SALE_MATERIAL_ID IS NOT NULL
  2873. <if test="oneDate != null">
  2874. and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt; = ASO.INSERT_TIME
  2875. </if>
  2876. <if test="startDate != null">
  2877. and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= ASO.INSERT_TIME
  2878. and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >= ASO.INSERT_TIME
  2879. </if>
  2880. <if test="con != null" >
  2881. AND RCO.CONSIGNEE_COMPANY_NAME LIKE #{con}
  2882. </if>
  2883. )
  2884. <where>
  2885. <if test="saleNumber != null">
  2886. and
  2887. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  2888. "saleNumber" like '%${item}%'
  2889. </foreach>
  2890. </if>
  2891. <if test="materialName != null">
  2892. and
  2893. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  2894. "materialName" like '%${item}%'
  2895. </foreach>
  2896. </if>
  2897. <if test="materialModel != null">
  2898. and
  2899. <foreach collection="materialModel" item="item" open="(" separator="or" close=")">
  2900. "materialModel" like '%${item}%'
  2901. </foreach>
  2902. </if>
  2903. <if test="materialSpecification != null">
  2904. and
  2905. <foreach collection="materialSpecification" item="item" open="(" separator="or" close=")">
  2906. "materialSpecification" like '%${item}%'
  2907. </foreach>
  2908. </if>
  2909. <if test="truckNo != null">
  2910. and
  2911. <foreach collection="truckNo" item="item" open="(" separator="or" close=")">
  2912. "truckNo" like '%${item}%'
  2913. </foreach>
  2914. </if>
  2915. <if test="addressDeliveryAddress != null">
  2916. and
  2917. <foreach collection="addressDeliveryAddress" item="item" open="(" separator="or" close=")">
  2918. "addressDeliveryAddress" like '%${item}%'
  2919. </foreach>
  2920. </if>
  2921. <if test="saleDateOfReceipt != null">
  2922. and
  2923. <foreach collection="saleDateOfReceipt" item="item" open="(" separator="or" close=")">
  2924. "saleDateOfReceipt" like '%${item}%'
  2925. </foreach>
  2926. </if>
  2927. <if test="saleOrderConsignee != null">
  2928. and
  2929. <foreach collection="saleOrderConsignee" item="item" open="(" separator="or" close=")">
  2930. "saleOrderConsignee" like '%${item}%'
  2931. </foreach>
  2932. </if>
  2933. <if test="saleOrderConsigneeTel != null">
  2934. and
  2935. <foreach collection="saleOrderConsigneeTel" item="item" open="(" separator="or" close=")">
  2936. "saleOrderConsigneeTel" like '%${item}%'
  2937. </foreach>
  2938. </if>
  2939. <if test="shipperName != null">
  2940. and
  2941. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  2942. "shipperName" like '%${item}%'
  2943. </foreach>
  2944. </if>
  2945. <if test="consigneeCompanyName != null">
  2946. and
  2947. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  2948. "consigneeCompanyName" like '%${item}%'
  2949. </foreach>
  2950. </if>
  2951. <if test="isselfMention != null">
  2952. and
  2953. <foreach collection="isselfMention" item="item" open="(" separator="or" close=")">
  2954. "isselfMention" like '%${item}%'
  2955. </foreach>
  2956. </if>
  2957. </where>
  2958. <include refid="orderBy"></include>
  2959. </select>
  2960. <select id="getTruckNoMaterial" resultType="java.util.Map" parameterType="DECIMAL" >
  2961. SELECT
  2962. RM.MATERIAL_ID AS "materialId",
  2963. RM.MATERIAL_NAME AS "materialName",
  2964. RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL AS "specificationModel",
  2965. RM.MATERIAL_CODE AS "materialCode",
  2966. ASTM.SALE_ORDER_MATERIAL_NUMBER AS "materialNumber"
  2967. FROM AMS_SALE_ORDER_MATERIAL ASOM
  2968. LEFT JOIN AMS_SALE_TRUCKNO_MATERIAL ASTM
  2969. ON ASTM.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  2970. LEFT JOIN AMS_SALE_MATERIAL ASM
  2971. ON ASM.SALE_MATERIAL_ID = ASTM.MATERIAL_ID
  2972. LEFT JOIN RMS_MATERIAL RM
  2973. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  2974. WHERE ASOM.SALE_ORDER_MATERIAL_ID = #{saleOrderMaterialId}
  2975. </select>
  2976. <select id="getCarrierTruckNoList" parameterType="java.util.Map" resultType="java.util.Map">
  2977. SELECT * FROM(
  2978. SELECT DISTINCT *
  2979. FROM (
  2980. SELECT ASO.SALE_NUMBER AS "saleNumber",
  2981. ASOM.SALE_ORDER_MATERIAL_TRUCK_NO AS "truckNo",
  2982. RRA.ADDRESS_PROVINCE || RRA.ADDRESS_DISTRICT || RRA.ADDRESS_TOWN || RRP.ADDRESS_DELIVERY_ADDRESS AS
  2983. "addressDeliveryAddress",
  2984. ASOM.SALE_DATE_OF_RECEIPT AS "saleDateOfReceipt",
  2985. DECODE(ASO.SALE_ORDER_STATUS,1,'订单已上报',2, '销售已提交',4, '财务已审批')
  2986. AS "approvalStatus",
  2987. ASOM.SALE_ORDER_CONSIGNEE_TEL AS "saleOrderConsigneeTel",
  2988. RSH.SHIPPER_NAME AS "shipperName",
  2989. RCO.CONSIGNEE_COMPANY_NAME AS "consigneeCompanyName",
  2990. ASO.SALE_ORDER_ISSELF_MENTION AS "isselfMention",
  2991. ASOM.INSERT_TIME AS "insertTime",
  2992. ASOM.SALE_ORDER_MATERIAL_ID AS "saleOrderMaterialId",
  2993. ASO.SALE_ORDER_ID AS "saleOrderId",
  2994. RCA.CARRIER_NAME AS "carrierName",
  2995. RM.MATERIAL_NAME || RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL AS "nameSpecificationModel",
  2996. RM.MATERIAL_NAME AS "materialName",
  2997. RM.MATERIAL_SPECIFICATION AS "materialSpecification",
  2998. RM.MATERIAL_MODEL AS "materialModel",
  2999. RM.MATERIAL_SPECIFICATION || MATERIAL_MODEL AS "specificationModel",
  3000. ASM.MATERIAL_NUMBER AS "materialNumber"
  3001. FROM AMS_SALE_ORDER_MATERIAL ASOM
  3002. LEFT JOIN AMS_SALE_ORDER ASO
  3003. ON ASO.SALE_ORDER_ID = ASOM.SALE_ORDER_ID
  3004. LEFT JOIN AMS_SALE_TRUCKNO_MATERIAL ASTM
  3005. ON ASTM.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  3006. LEFT JOIN RMS_RECEIVE_PLACE RRP
  3007. ON RRP.PLACE_ID = ASOM.SALE_SHIPPING_ADDRESS_ID
  3008. LEFT JOIN RMS_RECEIVE_ADDRESS RRA
  3009. ON RRA.ADDRESS_ID = RRP.ADDRESS_ID
  3010. LEFT JOIN RMS_SHIPPER RSH
  3011. ON RSH.SHIPPER_ID = ASO.SHIPPER_ID
  3012. LEFT JOIN RMS_CONSIGNEE RCO
  3013. ON RCO.CONSIGNEE_ID = ASO.RECEIVE_ID
  3014. LEFT JOIN AMS_DISPATCH_SALE_ORDER ADSO
  3015. ON ADSO.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  3016. LEFT JOIN OMSTRUCK_ORDER OO
  3017. ON OO.ORDER_PLAN_ID = ASOM.SALE_ORDER_MATERIAL_ID
  3018. AND NVL(OO.ORDER_TYPE,0) BETWEEN 0 AND 1
  3019. LEFT JOIN RMS_CARRIER RCA
  3020. ON RCA.CARRIER_ID = ADSO.CARRIER_ID
  3021. LEFT JOIN AMS_SALE_MATERIAL ASM
  3022. ON ASM.SALE_MATERIAL_ID = ASTM.MATERIAL_ID
  3023. LEFT JOIN RMS_MATERIAL RM
  3024. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  3025. WHERE ASO.SALE_ORDER_STATUS IN (2,4)
  3026. AND ASOM.ISSUE_STATUS IS NULL
  3027. AND ADSO.DISPATCH_TYPE = 2
  3028. AND OO.ORDER_ID IS NULL
  3029. AND ASO.DELETED = 0
  3030. AND ASM.DELETED IS NULL
  3031. AND ASM.SALE_MATERIAL_ID IS NOT NULL
  3032. <if test="oneDate != null">
  3033. and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt; = ASO.INSERT_TIME
  3034. </if>
  3035. <if test="startDate != null">
  3036. and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= ASO.INSERT_TIME
  3037. and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >= ASO.INSERT_TIME
  3038. </if>
  3039. ) "NOCAR"
  3040. <where>
  3041. <if test="con != null" >
  3042. "NOCAR"."carrierName" LIKE #{con} or "NOCAR"."consigneeCompanyName" LIKE #{con} or "NOCAR"."addressDeliveryAddress" LIKE #{con}
  3043. </if>
  3044. </where>
  3045. )
  3046. <where>
  3047. <if test="saleNumber != null">
  3048. and
  3049. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  3050. "saleNumber" like '%${item}%'
  3051. </foreach>
  3052. </if>
  3053. <if test="materialName != null">
  3054. and
  3055. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  3056. "materialName" like '%${item}%'
  3057. </foreach>
  3058. </if>
  3059. <if test="materialModel != null">
  3060. and
  3061. <foreach collection="materialModel" item="item" open="(" separator="or" close=")">
  3062. "materialModel" like '%${item}%'
  3063. </foreach>
  3064. </if>
  3065. <if test="materialSpecification != null">
  3066. and
  3067. <foreach collection="materialSpecification" item="item" open="(" separator="or" close=")">
  3068. "materialSpecification" like '%${item}%'
  3069. </foreach>
  3070. </if>
  3071. <if test="carrierName != null">
  3072. and
  3073. <foreach collection="carrierName" item="item" open="(" separator="or" close=")">
  3074. "carrierName" like '%${item}%'
  3075. </foreach>
  3076. </if>
  3077. <if test="truckNo != null">
  3078. and
  3079. <foreach collection="truckNo" item="item" open="(" separator="or" close=")">
  3080. "truckNo" like '%${item}%'
  3081. </foreach>
  3082. </if>
  3083. <if test="addressDeliveryAddress != null">
  3084. and
  3085. <foreach collection="addressDeliveryAddress" item="item" open="(" separator="or" close=")">
  3086. "addressDeliveryAddress" like '%${item}%'
  3087. </foreach>
  3088. </if>
  3089. <if test="saleDateOfReceipt != null">
  3090. and
  3091. <foreach collection="saleDateOfReceipt" item="item" open="(" separator="or" close=")">
  3092. "saleDateOfReceipt" like '%${item}%'
  3093. </foreach>
  3094. </if>
  3095. <if test="saleOrderConsignee != null">
  3096. and
  3097. <foreach collection="saleOrderConsignee" item="item" open="(" separator="or" close=")">
  3098. "saleOrderConsignee" like '%${item}%'
  3099. </foreach>
  3100. </if>
  3101. <if test="saleOrderConsigneeTel != null">
  3102. and
  3103. <foreach collection="saleOrderConsigneeTel" item="item" open="(" separator="or" close=")">
  3104. "saleOrderConsigneeTel" like '%${item}%'
  3105. </foreach>
  3106. </if>
  3107. <if test="shipperName != null">
  3108. and
  3109. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  3110. "shipperName" like '%${item}%'
  3111. </foreach>
  3112. </if>
  3113. <if test="consigneeCompanyName != null">
  3114. and
  3115. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  3116. "consigneeCompanyName" like '%${item}%'
  3117. </foreach>
  3118. </if>
  3119. <if test="isselfMention != null">
  3120. and
  3121. <foreach collection="isselfMention" item="item" open="(" separator="or" close=")">
  3122. "isselfMention" like '%${item}%'
  3123. </foreach>
  3124. </if>
  3125. </where>
  3126. <include refid="orderBy"></include>
  3127. </select>
  3128. <select id="getTruckNoMaterialAndCarrier" parameterType="DECIMAL" resultType="java.util.Map" >
  3129. SELECT DISTINCT ASOM.SALE_ORDER_MATERIAL_TRUCK_NO AS "truckNo",
  3130. RM.MATERIAL_NAME AS "materialName",
  3131. ASM.MATERIAL_ID AS "materialId",
  3132. ASM.MATERIAL_NUMBER AS "materialNumber",
  3133. ASM.MATERIAL_WEIGHT AS "materialWeight",
  3134. ASOM.SALE_DATE_OF_RECEIPT AS "receiptDate",
  3135. RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL AS "materialModelSpecification",
  3136. RM.MATERIAL_CODE AS "materialCode",
  3137. RRA.ADDRESS_PROVINCE || RRA.ADDRESS_DISTRICT || RRA.ADDRESS_TOWN ||
  3138. RRP.ADDRESS_DELIVERY_ADDRESS AS "place",
  3139. ASOM.SALE_DATE_OF_RECEIPT AS "receiptDate",
  3140. ASOM.SALE_ORDER_CONSIGNEE_TEL AS "saleOrderConsigneeTel",
  3141. ASOM.SALE_ORDER_CONSIGNEE AS "saleOrderConsignee",
  3142. ASOM.SALE_ORDER_MATERIAL_ID AS "saleOrderMaterialId",
  3143. ASOM.SALE_SHIPPING_ADDRESS_ID AS "placeId",
  3144. RC.CAPACITY_NUMBER AS "capacityNumber",
  3145. ADSO.CARRIER_ID AS "carrierId",
  3146. ASOM.TRUCK_REMARK AS "truckRemark"
  3147. FROM AMS_SALE_TRUCKNO_MATERIAL ASTM
  3148. LEFT JOIN AMS_SALE_ORDER_MATERIAL ASOM
  3149. ON ASOM.SALE_ORDER_MATERIAL_ID = ASTM.SALE_ORDER_MATERIAL_ID
  3150. LEFT JOIN RMS_RECEIVE_PLACE RRP
  3151. ON RRP.PLACE_ID = ASOM.SALE_SHIPPING_ADDRESS_ID
  3152. LEFT JOIN RMS_RECEIVE_ADDRESS RRA
  3153. ON RRA.ADDRESS_ID = RRP.ADDRESS_ID
  3154. LEFT JOIN AMS_SALE_MATERIAL ASM
  3155. ON ASTM.MATERIAL_ID = ASM.SALE_MATERIAL_ID
  3156. LEFT JOIN RMS_MATERIAL RM
  3157. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  3158. LEFT JOIN OMSTRUCK_ORDER OO
  3159. ON OO.ORDER_PLAN_ID = ASOM.SALE_ORDER_MATERIAL_ID
  3160. and NVL(OO.ORDER_TYPE,0) BETWEEN 0 AND 1
  3161. LEFT JOIN RMS_CAPACITY RC
  3162. ON RC.CAPACITY_ID = OO.CAPACITY_ID
  3163. LEFT JOIN AMS_DISPATCH_SALE_ORDER ADSO
  3164. ON ADSO.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  3165. WHERE ASOM.SALE_ORDER_MATERIAL_ID = #{saleOrderMaterialId}
  3166. and ASM.SALE_MATERIAL_ID IS NOT NULL
  3167. ORDER BY ASOM.SALE_ORDER_MATERIAL_TRUCK_NO ASC
  3168. </select>
  3169. <select id="getHaveCarTruckNoList" parameterType="java.util.Map" resultType="java.util.LinkedHashMap">
  3170. SELECT * FROM (
  3171. SELECT DISTINCT *
  3172. FROM (
  3173. SELECT ASO.SALE_NUMBER AS "saleNumber",
  3174. ASOM.SALE_ORDER_MATERIAL_TRUCK_NO AS "truckNo",
  3175. RRA.ADDRESS_PROVINCE || RRA.ADDRESS_DISTRICT || RRA.ADDRESS_TOWN || RRP.ADDRESS_DELIVERY_ADDRESS AS
  3176. "addressDeliveryAddress",
  3177. ASOM.SALE_DATE_OF_RECEIPT AS "saleDateOfReceipt",
  3178. DECODE(ASO.SALE_ORDER_STATUS,1,'订单已上报',2, '销售已提交',4, '财务已审批')
  3179. AS "approvalStatus",
  3180. ASOM.SALE_ORDER_CONSIGNEE_TEL AS "saleOrderConsigneeTel",
  3181. RSH.SHIPPER_NAME AS "shipperName",
  3182. RCO.CONSIGNEE_COMPANY_NAME AS "consigneeCompanyName",
  3183. ASO.SALE_ORDER_ISSELF_MENTION AS "isselfMention",
  3184. ASOM.INSERT_TIME AS "insertTime",
  3185. ASOM.SALE_ORDER_MATERIAL_ID AS "saleOrderMaterialId",
  3186. ASO.SALE_ORDER_ID AS "saleOrderId",
  3187. RCA.CARRIER_NAME AS "carrierName",
  3188. RM.MATERIAL_NAME AS "materialName",
  3189. RM.MATERIAL_SPECIFICATION AS "materialSpecification",
  3190. RM.MATERIAL_MODEL AS "materialModel",
  3191. RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL AS "specificationModel",
  3192. RM.MATERIAL_NAME || RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL AS "nameSpecificationModel",
  3193. RCP.CAPACITY_NUMBER AS "capacityNumber",
  3194. OO.DRIVER_TEL AS "drivelTel",
  3195. ASM.MATERIAL_NUMBER AS "materialNumber",
  3196. OO.ORDER_ID AS "orderId"
  3197. FROM AMS_SALE_ORDER_MATERIAL ASOM
  3198. LEFT JOIN AMS_SALE_ORDER ASO
  3199. ON ASO.SALE_ORDER_ID = ASOM.SALE_ORDER_ID
  3200. LEFT JOIN AMS_SALE_TRUCKNO_MATERIAL ASTM
  3201. ON ASTM.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  3202. LEFT JOIN RMS_RECEIVE_PLACE RRP
  3203. ON RRP.PLACE_ID = ASOM.SALE_SHIPPING_ADDRESS_ID
  3204. LEFT JOIN RMS_RECEIVE_ADDRESS RRA
  3205. ON RRA.ADDRESS_ID = RRP.ADDRESS_ID
  3206. LEFT JOIN RMS_SHIPPER RSH
  3207. ON RSH.SHIPPER_ID = ASO.SHIPPER_ID
  3208. LEFT JOIN RMS_CONSIGNEE RCO
  3209. ON RCO.CONSIGNEE_ID = ASO.RECEIVE_ID
  3210. LEFT JOIN AMS_DISPATCH_SALE_ORDER ADSO
  3211. ON ADSO.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  3212. LEFT JOIN OMSTRUCK_ORDER OO
  3213. ON OO.ORDER_PLAN_ID = ASOM.SALE_ORDER_MATERIAL_ID
  3214. LEFT JOIN RMS_CAPACITY RCP
  3215. ON RCP.CAPACITY_ID = OO.CAPACITY_ID
  3216. LEFT JOIN RMS_CARRIER RCA
  3217. ON RCA.CARRIER_ID = ADSO.CARRIER_ID
  3218. LEFT JOIN AMS_SALE_MATERIAL ASM
  3219. ON ASM.SALE_MATERIAL_ID = ASTM.MATERIAL_ID
  3220. LEFT JOIN RMS_MATERIAL RM
  3221. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  3222. WHERE OO.ORDER_TYPE = 1
  3223. AND ASO.SALE_ORDER_STATUS IN (2,4)
  3224. AND ASOM.ISSUE_STATUS IS NULL
  3225. AND ADSO.DISPATCH_TYPE = 2
  3226. AND OO.ORDER_ID IS NOT NULL
  3227. AND OO.ORDER_STATUS IN (4,5)
  3228. AND ASO.DELETED != 2
  3229. AND ASM.DELETED IS NULL
  3230. <if test="oneDate != null">
  3231. and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt; = ASOM.INSERT_TIME
  3232. </if>
  3233. <if test="startDate != null">
  3234. and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= ASOM.INSERT_TIME
  3235. and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >= ASOM.INSERT_TIME
  3236. </if>
  3237. ORDER BY ASOM.SALE_ORDER_MATERIAL_ID DESC
  3238. ) "HAVECAR"
  3239. <where>
  3240. <if test="con != null" >
  3241. "HAVECAR"."carrierName" LIKE #{con} or "HAVECAR"."consigneeCompanyName" LIKE #{con} or "HAVECAR"."addressDeliveryAddress" LIKE #{con}
  3242. </if>
  3243. </where>
  3244. )
  3245. <where>
  3246. <if test="saleNumber != null">
  3247. and
  3248. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  3249. "saleNumber" like '%${item}%'
  3250. </foreach>
  3251. </if>
  3252. <if test="materialName != null">
  3253. and
  3254. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  3255. "materialName" like '%${item}%'
  3256. </foreach>
  3257. </if>
  3258. <if test="materialSpecification != null">
  3259. and
  3260. <foreach collection="materialSpecification" item="item" open="(" separator="or" close=")">
  3261. "materialSpecification" like '%${item}%'
  3262. </foreach>
  3263. </if>
  3264. <if test="materialModel != null">
  3265. and
  3266. <foreach collection="materialModel" item="item" open="(" separator="or" close=")">
  3267. "materialModel" like '%${item}%'
  3268. </foreach>
  3269. </if>
  3270. <if test="materialName != null">
  3271. and
  3272. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  3273. "materialName" like '%${item}%'
  3274. </foreach>
  3275. </if>
  3276. <if test="carrierName != null">
  3277. and
  3278. <foreach collection="carrierName" item="item" open="(" separator="or" close=")">
  3279. "carrierName" like '%${item}%'
  3280. </foreach>
  3281. </if>
  3282. <if test="truckNo != null">
  3283. and
  3284. <foreach collection="truckNo" item="item" open="(" separator="or" close=")">
  3285. "truckNo" like '%${item}%'
  3286. </foreach>
  3287. </if>
  3288. <if test="addressDeliveryAddress != null">
  3289. and
  3290. <foreach collection="addressDeliveryAddress" item="item" open="(" separator="or" close=")">
  3291. "addressDeliveryAddress" like '%${item}%'
  3292. </foreach>
  3293. </if>
  3294. <if test="saleDateOfReceipt != null">
  3295. and
  3296. <foreach collection="saleDateOfReceipt" item="item" open="(" separator="or" close=")">
  3297. "saleDateOfReceipt" like '%${item}%'
  3298. </foreach>
  3299. </if>
  3300. <if test="saleOrderConsignee != null">
  3301. and
  3302. <foreach collection="saleOrderConsignee" item="item" open="(" separator="or" close=")">
  3303. "saleOrderConsignee" like '%${item}%'
  3304. </foreach>
  3305. </if>
  3306. <if test="saleOrderConsigneeTel != null">
  3307. and
  3308. <foreach collection="saleOrderConsigneeTel" item="item" open="(" separator="or" close=")">
  3309. "saleOrderConsigneeTel" like '%${item}%'
  3310. </foreach>
  3311. </if>
  3312. <if test="shipperName != null">
  3313. and
  3314. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  3315. "shipperName" like '%${item}%'
  3316. </foreach>
  3317. </if>
  3318. <if test="consigneeCompanyName != null">
  3319. and
  3320. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  3321. "consigneeCompanyName" like '%${item}%'
  3322. </foreach>
  3323. </if>
  3324. <if test="isselfMention != null">
  3325. and
  3326. <foreach collection="isselfMention" item="item" open="(" separator="or" close=")">
  3327. "isselfMention" like '%${item}%'
  3328. </foreach>
  3329. </if>
  3330. </where>
  3331. </select>
  3332. <select id="getOrderPrice" parameterType="java.util.Map" resultType="DECIMAL" >
  3333. SELECT ACTP.PRICE_ID AS "priceId"
  3334. FROM AMS_CONTRACT_TRANSPORT_PRICE ACTP
  3335. LEFT JOIN AMS_SALE_ORDER_MATERIAL ASOM
  3336. ON ASOM.SALE_SHIPPING_ADDRESS_ID = ACTP.PLACE_ID
  3337. WHERE ACTP.CARRIER_ID = #{carrierId}
  3338. AND ASOM.SALE_ORDER_MATERIAL_ID = #{saleOrderMaterialId}
  3339. AND ACTP.DELETED = 0
  3340. ORDER BY ACTP.INSERT_TIME DESC
  3341. FETCH NEXT 1 ROWS ONLY
  3342. </select>
  3343. <select id="selectConsigneeName" parameterType="DECIMAL" resultType="java.lang.String" >
  3344. SELECT RC.CONSIGNEE_COMPANY_NAME AS "consigneeName"
  3345. FROM RMS_CONSIGNEE RC
  3346. WHERE RC.CONSIGNEE_ID = #{receiveId}
  3347. </select>
  3348. <select id="selectCarrierId" resultType="DECIMAL" parameterType="java.lang.String">
  3349. SELECT RC.CARRIER_ID AS "carrierId"
  3350. FROM RMS_CARRIER RC
  3351. WHERE RC.CARRIER_NAME = #{consigneeName}
  3352. </select>
  3353. <select id="getSaleMapMessages" resultType="java.util.Map" parameterType="DECIMAL" >
  3354. SELECT ASO.SALE_ORDER_ISSELF_MENTION AS "isSelfMention",
  3355. ASO.SALE_REMARK AS "saleRemark",
  3356. ASO.SALE_ORDER_RECEIVE_CUSTOMER AS "saleOrderReceiveCustomer",
  3357. RSH.SHIPPER_ID AS "shipperId",
  3358. RSH.SHIPPER_NAME AS "shipperName",
  3359. RCO.CONSIGNEE_ID AS "receiveId",
  3360. RCO.CONSIGNEE_COMPANY_NAME AS "receiveName",
  3361. RSA.SALER_ID AS "salerId",
  3362. RSA.SALER_NAME AS "salerName"
  3363. FROM AMS_SALE_ORDER ASO
  3364. LEFT JOIN RMS_SHIPPER RSH
  3365. ON RSH.SHIPPER_ID = ASO.SHIPPER_ID
  3366. LEFT JOIN RMS_CONSIGNEE RCO
  3367. ON RCO.CONSIGNEE_ID = ASO.RECEIVE_ID
  3368. LEFT JOIN RMS_SALER RSA
  3369. ON RSA.SALER_ID = ASO.SALER_ID
  3370. WHERE ASO.SALE_ORDER_ID = #{saleOrderId}
  3371. </select>
  3372. <select id="getSaleListMessages" parameterType="DECIMAL" resultType="java.util.Map" >
  3373. SELECT ASOM.SALE_ORDER_MATERIAL_TRUCK_NO AS "truckNo",
  3374. RRP.ADDRESS_DELIVERY_ADDRESS AS "place",
  3375. RRA.ADDRESS_ID AS "shipperAddressId",
  3376. RRA.ADDRESS_PROVINCE || RRA.ADDRESS_DISTRICT || RRA.ADDRESS_TOWN AS "saleShipperAddressName",
  3377. ASOM.SALE_ORDER_CONSIGNEE AS "saleOrderConsignee",
  3378. ASOM.SALE_ORDER_CONSIGNEE_TEL AS "saleOrderConsigneeTel",
  3379. ASOM.SALE_DATE_OF_RECEIPT AS "saleDateOfReceipt",
  3380. ASM.MATERIAL_ID AS "materialId",
  3381. RM.MATERIAL_NAME AS "materialName",
  3382. RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL AS "Specification",
  3383. RM.MATERIAL_CODE AS "materialCode",
  3384. ASM.MATERIAL_NUMBER AS "materialNumber",
  3385. ASM.STEEL_METER AS "steelMeters",
  3386. ASM.IS_POUND_SALE AS "isPoundSale",
  3387. ASOM.TRUCK_REMARK AS "truckRemark"
  3388. FROM AMS_SALE_ORDER ASO
  3389. LEFT JOIN AMS_SALE_ORDER_MATERIAL ASOM
  3390. ON ASO.SALE_ORDER_ID = ASOM.SALE_ORDER_ID
  3391. LEFT JOIN AMS_SALE_TRUCKNO_MATERIAL ASTM
  3392. ON ASTM.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  3393. LEFT JOIN AMS_SALE_MATERIAL ASM
  3394. ON ASM.SALE_MATERIAL_ID = ASTM.MATERIAL_ID
  3395. LEFT JOIN RMS_MATERIAL RM
  3396. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  3397. LEFT JOIN RMS_RECEIVE_PLACE RRP
  3398. ON RRP.PLACE_ID = ASOM.SALE_SHIPPING_ADDRESS_ID
  3399. LEFT JOIN RMS_RECEIVE_ADDRESS RRA
  3400. ON RRA.ADDRESS_ID = RRP.ADDRESS_ID
  3401. WHERE asm.SALE_MATERIAL_ID is not null
  3402. and ASO.SALE_ORDER_ID = #{saleOrderId}
  3403. </select>
  3404. <select id="matchingAddressRecently" parameterType="DECIMAL" resultType="java.util.LinkedHashMap" >
  3405. SELECT
  3406. DISTINCT
  3407. RRP.PLACE_ID "placeId",
  3408. RRP.ADDRESS_DELIVERY_ADDRESS "place",
  3409. RRA.ADDRESS_ID "shipperAddressId",
  3410. RRA.ADDRESS_PROVINCE "addressProvince",
  3411. RRA.ADDRESS_DISTRICT "addressDistrict",
  3412. RRA.ADDRESS_TOWN "addressTown",
  3413. ASOM.SALE_ORDER_CONSIGNEE_TEL "saleOrderConsigneeTel",
  3414. RRA.ADDRESS_PROVINCE || RRA.ADDRESS_DISTRICT || RRA.ADDRESS_TOWN || RRP.ADDRESS_DELIVERY_ADDRESS "addressPlace",
  3415. max(ASOM.SALE_ORDER_MATERIAL_ID) as b
  3416. FROM AMS_SALE_ORDER ASO
  3417. LEFT JOIN AMS_SALE_ORDER_MATERIAL ASOM
  3418. ON ASO.SALE_ORDER_ID = ASOM.SALE_ORDER_ID
  3419. LEFT JOIN RMS_RECEIVE_PLACE RRP
  3420. ON RRP.PLACE_ID = ASOM.SALE_SHIPPING_ADDRESS_ID
  3421. LEFT JOIN RMS_RECEIVE_ADDRESS RRA
  3422. ON RRA.ADDRESS_ID = RRP.ADDRESS_ID
  3423. WHERE ASO.RECEIVE_ID = #{receiveId}
  3424. AND RRP.PLACE_ID IS NOT NULL
  3425. GROUP BY RRP.PLACE_ID , RRP.ADDRESS_DELIVERY_ADDRESS , RRA.ADDRESS_ID ,
  3426. RRA.ADDRESS_PROVINCE ,
  3427. RRA.ADDRESS_DISTRICT ,
  3428. RRA.ADDRESS_TOWN ,
  3429. ASOM.SALE_ORDER_CONSIGNEE_TEL
  3430. ORDER BY b DESC
  3431. </select>
  3432. <select id="getSalerByReceiveId" parameterType="DECIMAL" resultType="java.util.Map" >
  3433. SELECT DISTINCT *
  3434. FROM (
  3435. SELECT RS.SALER_NAME "salerName",
  3436. RS.SALER_ID "salerId"
  3437. FROM AMS_SALE_ORDER ASO
  3438. LEFT JOIN RMS_SALER RS
  3439. ON RS.SALER_ID = ASO.SALER_ID
  3440. WHERE ASO.RECEIVE_ID = #{receiveId}
  3441. AND RS.SALER_ID IS NOT NULL
  3442. AND ASO.SALE_TYPE = 1
  3443. ORDER BY ASO.SALE_ORDER_ID DESC
  3444. )
  3445. WHERE rownum <![CDATA[
  3446. <
  3447. ]]> 2
  3448. </select>
  3449. <select id="matchingDriverTelRecently" parameterType="java.lang.String" resultType="java.lang.String">
  3450. SELECT DISTINCT *
  3451. FROM (
  3452. SELECT OO.DRIVER_TEL "driverTel"
  3453. FROM RMS_CAPACITY RCA
  3454. LEFT JOIN OMSTRUCK_ORDER OO
  3455. ON OO.CAPACITY_ID = RCA.CAPACITY_ID
  3456. WHERE RCA.CAPACITY_NUMBER = #{capacityNumber}
  3457. AND OO.ORDER_TYPE = 1
  3458. AND OO.DRIVER_TEL IS NOT NULL
  3459. ORDER BY OO.ORDER_ID DESC
  3460. )
  3461. WHERE ROWNUM <![CDATA[
  3462. <
  3463. ]]> 2
  3464. </select>
  3465. <!-- 查询内转焦炭订单 -->
  3466. <select id="getCokeInwardOrderList" parameterType="java.util.Map" resultType="java.util.Map">
  3467. SELECT * FROM (
  3468. SELECT *from(
  3469. select
  3470. OO.ORDER_NUMBER "orderNumber",
  3471. ASO.SALE_NUMBER "saleNumber",
  3472. RC.CAPACITY_NUMBER "capacityNumber",
  3473. RC2.CONSIGNEE_COMPANY_NAME "consigneeCompanyName",
  3474. RRA.ADDRESS_PROVINCE || RRA.ADDRESS_DISTRICT || RRA.ADDRESS_TOWN "addressDeliveryAddress",
  3475. ACTP.PRICE_VALUE "priceValue",
  3476. ASOM.SALE_DATE_OF_RECEIPT "saleDateOfReceipt",
  3477. OO.ORDER_RECEIVE_REFUSE_TIME "orderReceiveRefuseTime",
  3478. RS.SHIPPER_NAME "shipperName",
  3479. OO.ORDER_ID "orderId",
  3480. RC3.CARRIER_NAME "carrierName"
  3481. FROM OMSTRUCK_ORDER OO
  3482. LEFT JOIN AMS_SALE_ORDER_MATERIAL ASOM
  3483. ON ASOM.SALE_ORDER_MATERIAL_ID=OO.ORDER_PLAN_ID
  3484. LEFT JOIN AMS_SALE_ORDER ASO
  3485. ON ASO.SALE_ORDER_ID=ASOM.SALE_ORDER_ID
  3486. LEFT JOIN AMS_DISPATCH_SALE_ORDER ADSO
  3487. ON ADSO.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  3488. LEFT JOIN RMS_CARRIER RC3
  3489. ON RC3.CARRIER_ID = ADSO.CARRIER_ID
  3490. LEFT JOIN RMS_CONSIGNEE RC2
  3491. ON RC2.CONSIGNEE_ID=ASO.RECEIVE_ID
  3492. LEFT JOIN RMS_CAPACITY RC
  3493. ON OO.CAPACITY_ID=RC.CAPACITY_ID
  3494. LEFT JOIN RMS_SHIPPER RS
  3495. ON RS.SHIPPER_ID=ASO.SHIPPER_ID
  3496. LEFT JOIN RMS_RECEIVE_ADDRESS RRA
  3497. ON RRA.ADDRESS_ID=ASOM.SALE_SHIPPING_ADDRESS_ID
  3498. LEFT JOIN AMS_CONTRACT_TRANSPORT_PRICE ACTP
  3499. ON OO.PRICE_ID=ACTP.PRICE_ID
  3500. WHERE OO.ORDER_TYPE = 2
  3501. AND ASO.SHIPPER_ID = 2
  3502. AND ASO.CLOSE_STATUS = 0
  3503. <where>
  3504. <if test="orderStatus!=null">
  3505. AND OO.ORDER_STATUS = #{orderStatus}
  3506. </if>
  3507. </where>
  3508. ) RRC
  3509. <if test="con != null">
  3510. WHERE RRC."consigneeCompanyName" LIKE #{con} or RRC."capacityNumber" LIKE #{con}
  3511. </if>
  3512. )
  3513. <where>
  3514. <if test="orderNumber != null">
  3515. <foreach collection="orderNumber" item="item" open="(" separator="or" close=")">
  3516. "orderNumber" like '%${item}%'
  3517. </foreach>
  3518. </if>
  3519. <if test="carrierName != null">
  3520. <foreach collection="carrierName" item="item" open="(" separator="or" close=")">
  3521. "carrierName" like '%${item}%'
  3522. </foreach>
  3523. </if>
  3524. <if test="saleNumber != null">
  3525. and
  3526. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  3527. "saleNumber" like '%${item}%'
  3528. </foreach>
  3529. </if>
  3530. <if test="capacityNumber != null">
  3531. and
  3532. <foreach collection="capacityNumber" item="item" open="(" separator="or" close=")">
  3533. "capacityNumber" like '%${item}%'
  3534. </foreach>
  3535. </if>
  3536. <if test="shipperName != null">
  3537. and
  3538. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  3539. "shipperName" like '%${item}%'
  3540. </foreach>
  3541. </if>
  3542. <if test="consigneeCompanyName != null">
  3543. and
  3544. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  3545. "consigneeCompanyName" like '%${item}%'
  3546. </foreach>
  3547. </if>
  3548. </where>
  3549. <include refid="orderBy">
  3550. </include>
  3551. <if test="orderField == null ">
  3552. order by "orderNumber" desc
  3553. </if>
  3554. </select>
  3555. <select id="getDispatchId" parameterType="DECIMAL" resultType="DECIMAL" >
  3556. SELECT ADSO.DISPATCH_ID AS "dispatchId"
  3557. FROM AMS_DISPATCH_SALE_ORDER ADSO
  3558. WHERE ADSO.SALE_ORDER_MATERIAL_ID = #{saleOrderMaterialId}
  3559. </select>
  3560. <select id="getSaleMaterialId" parameterType="DECIMAL" resultType="java.util.Map" >
  3561. SELECT ASTM.MATERIAL_ID AS "saleMaterialId",
  3562. ASM.EAS_PRIMARY_ID AS "closeEntryId"
  3563. FROM AMS_SALE_ORDER_MATERIAL ASOM
  3564. LEFT JOIN AMS_SALE_TRUCKNO_MATERIAL ASTM
  3565. ON ASTM.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  3566. LEFT JOIN AMS_SALE_MATERIAL ASM
  3567. ON ASM.SALE_MATERIAL_ID = ASTM.MATERIAL_ID
  3568. WHERE ASOM.SALE_ORDER_MATERIAL_ID = #{saleOrderMaterialId}
  3569. </select>
  3570. <select id="getSaleList" resultType="java.util.Map" >
  3571. SELECT ASTM.TRUCKNO_MATERIAL_ID "truckNoMaterialId",
  3572. ASM.SALE_MATERIAL_ID "saleMaterialId",
  3573. ASM.MATERIAL_ID "materialId"
  3574. FROM AMS_SALE_TRUCKNO_MATERIAL ASTM
  3575. LEFT JOIN AMS_SALE_MATERIAL ASM
  3576. ON ASM.SALE_MATERIAL_ID = ASTM.MATERIAL_ID
  3577. WHERE ASTM.SALE_ORDER_MATERIAL_ID = #{saleOrderMaterialId}
  3578. AND ASM.MATERIAL_ID = #{materialId}
  3579. </select>
  3580. <select id="getFuSaleOrderList" parameterType="java.util.Map" resultType="java.util.Map">
  3581. select * from(
  3582. select a_s_order.SALE_ORDER_ID "saleOrderId",
  3583. a_s_order.SALE_NUMBER "saleNumber",
  3584. r_shipper.SHIPPER_NAME "shipperName",
  3585. r_consignee.CONSIGNEE_COMPANY_NAME "consigneeCompanyName",
  3586. r_consignee.CONSIGNEE_WARRANTY_AMOUNT "consigneeWarrantyAmount",
  3587. r_consignee.CONSIGNEE_WARRANTY_WEIGHT "consigneeWarrantyWeight",
  3588. a_s_order.SALE_ORDER_ISSELF_MENTION "saleOrderIsselfMention",
  3589. a_s_order.SALE_ACCOUNT_BALANCE "saleAccountBalance",
  3590. a_s_order.SALE_CURRENT_ORDER_AMOUNT "saleCurrentOrderAmount",
  3591. a_s_order.SALE_HISTORICAL_ORDER_AMOUNT "saleHistoricalOrderAmout",
  3592. a_s_order.SALE_ORDER_RECEIVE_CUSTOMER "saleOrderReceiveCustomer",
  3593. a_s_order.SALE_UNIT_PRICE "saleUnitPrice",
  3594. a_s_order.SALE_ORDER_TAX "saleOrderTax",
  3595. a_s_order.SALE_REMARK "saleRemark",
  3596. a_s_order.INSERT_TIME "insertTime",
  3597. DECODE(a_s_order.SALE_ORDER_STATUS,2,'销售已提交',4,'财务已审批') "statusStr",
  3598. RM.MATERIAL_NAME "materialName",
  3599. ASM.MATERIAL_WEIGHT "materialWeight",
  3600. ASM.SALE_WAREHOUSE "saleWareHouse",
  3601. nvl(sumWeight.weight,0)+nvl(sumWeight2.weight,0) as "totalWeight",
  3602. nvl(sumWeight.weight ,0) as "netWeight",
  3603. nvl(sumWeight2.weight ,0) as "weight",
  3604. nvl(carCount.coun ,0) as "carCount",
  3605. RCA.CARRIER_NAME as "carrierName"
  3606. from AMS_SALE_ORDER a_s_order
  3607. left join RMS_SHIPPER r_shipper
  3608. on a_s_order.SHIPPER_ID=r_shipper.SHIPPER_ID
  3609. left join RMS_CONSIGNEE r_consignee
  3610. on a_s_order.RECEIVE_ID=r_consignee.CONSIGNEE_ID
  3611. LEFT JOIN AMS_SALE_MATERIAL ASM
  3612. ON ASM.SALE_ORDER_ID = a_s_order.SALE_ORDER_ID
  3613. LEFT JOIN AMS_SALE_ORDER_CARRIER ASOC
  3614. ON ASOC.SALE_ORDER_ID = a_s_order.SALE_ORDER_ID
  3615. LEFT JOIN RMS_CARRIER RCA
  3616. ON RCA.CARRIER_ID = ASOC.CARRIER_ID
  3617. LEFT JOIN RMS_MATERIAL RM
  3618. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  3619. left join (
  3620. select sum( t_w_result.RESULT_NET_WEIGHT) weight,a_s_o_material.SALE_ORDER_ID SALE_ORDER_ID
  3621. from AMS_SALE_ORDER_MATERIAL a_s_o_material
  3622. left join Omstruck_Order o_order
  3623. on a_s_o_material.SALE_ORDER_MATERIAL_ID=o_order.order_plan_id
  3624. left join Tmstruck_Total_Result t_t_result
  3625. on o_order.order_id=t_t_result.order_id
  3626. left join Tmstruck_Weight_Result t_w_result
  3627. on t_t_result.result_total_id=t_w_result.result_total_id
  3628. GROUP BY
  3629. a_s_o_Material.SALE_ORDER_ID
  3630. ) sumWeight
  3631. on sumWeight.SALE_ORDER_ID=a_s_order.SALE_ORDER_ID
  3632. left join (
  3633. select sum( o_o_material.ORDER_MATERIAL_WEIGHT) weight,a_s_o_Material.SALE_ORDER_ID SALE_ORDER_ID
  3634. from AMS_SALE_ORDER_MATERIAL a_s_o_material
  3635. left join Omstruck_Order o_order
  3636. on a_s_o_material.SALE_ORDER_MATERIAL_ID=o_order.order_plan_id
  3637. left join Tmstruck_Total_Result t_t_result
  3638. on o_order.order_id=t_t_result.order_id
  3639. left join Tmstruck_Weight_Result t_w_result
  3640. on t_t_result.result_total_id=t_w_result.result_total_id
  3641. left join OMSTRUCK_ORDER_MATERIAL o_o_material
  3642. on o_order.order_id=o_o_material.ORDER_ID
  3643. where t_w_result.RESULT_NET_WEIGHT is null and o_order.order_status in (2,4,5)
  3644. GROUP BY
  3645. a_s_o_Material.SALE_ORDER_ID
  3646. ) sumWeight2
  3647. on sumWeight2.SALE_ORDER_ID=a_s_order.SALE_ORDER_ID
  3648. left join (
  3649. select count(o_order.order_id) coun ,a_s_o_Material.SALE_ORDER_ID SALE_ORDER_ID
  3650. from AMS_SALE_ORDER_MATERIAL a_s_o_material
  3651. left join Omstruck_Order o_order
  3652. on a_s_o_material.SALE_ORDER_MATERIAL_ID=o_order.order_plan_id
  3653. left join Tmstruck_Total_Result t_t_result
  3654. on o_order.order_id=t_t_result.order_id
  3655. left join Tmstruck_Weight_Result t_w_result
  3656. on t_t_result.result_total_id=t_w_result.result_total_id
  3657. where t_w_result.RESULT_NET_WEIGHT is null and o_order.order_status in (2,4,5)
  3658. GROUP BY
  3659. a_s_o_Material.SALE_ORDER_ID
  3660. ) carCount
  3661. on carCount.SALE_ORDER_ID=a_s_order.SALE_ORDER_ID
  3662. where (ASM.SALE_WAREHOUSE = '副产品库'
  3663. or ASM.SALE_WAREHOUSE = '钒渣库')
  3664. and a_s_order.SALE_ORDER_STATUS in (2,4)
  3665. and a_s_order.CLOSE_STATUS is null
  3666. and a_s_order.DELETED = #{deleted}
  3667. and a_s_order.SHIPPER_ID = 1
  3668. and a_s_order.SALE_TYPE is null
  3669. <if test="con != null">
  3670. and (instr(r_consignee.CONSIGNEE_COMPANY_NAME, #{con}) > 0 or instr(a_s_order.SALE_NUMBER, #{con}) > 0)
  3671. </if>
  3672. <if test="consigneeSsoId != null">
  3673. and r_consignee.CONSIGNEE_SSO_ID = #{consigneeSsoId}
  3674. </if>
  3675. <if test="oneDate != null">
  3676. and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= a_s_order.UPDATE_TIME
  3677. </if>
  3678. <if test="startDate != null">
  3679. and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= a_s_order.UPDATE_TIME
  3680. and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >= a_s_order.UPDATE_TIME
  3681. </if>
  3682. ORDER BY a_s_order.UPDATE_TIME DESC
  3683. )
  3684. <where>
  3685. <if test="saleNumber != null">
  3686. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  3687. "saleNumber" like '%${item}%'
  3688. </foreach>
  3689. </if>
  3690. <if test="materialName != null">
  3691. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  3692. "materialName" like '%${item}%'
  3693. </foreach>
  3694. </if>
  3695. <if test="materialSpecification != null">
  3696. <foreach collection="materialSpecification" item="item" open="(" separator="or" close=")">
  3697. "materialSpecification" like '%${item}%'
  3698. </foreach>
  3699. </if>
  3700. <if test="materialModel != null">
  3701. <foreach collection="materialModel" item="item" open="(" separator="or" close=")">
  3702. "materialModel" like '%${item}%'
  3703. </foreach>
  3704. </if>
  3705. <if test="statusStr != null">
  3706. <foreach collection="statusStr" item="item" open="(" separator="or" close=")">
  3707. and "statusStr" like '%${item}%'
  3708. </foreach>
  3709. </if>
  3710. <if test="shipperName != null">
  3711. and
  3712. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  3713. "shipperName" like '%${item}%'
  3714. </foreach>
  3715. </if>
  3716. <if test="consigneeCompanyName != null">
  3717. and
  3718. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  3719. "consigneeCompanyName" like '%${item}%'
  3720. </foreach>
  3721. </if>
  3722. <if test="consigneeWarrantyAmount != null">
  3723. and
  3724. <foreach collection="consigneeWarrantyAmount" item="item" open="(" separator="or" close=")">
  3725. "consigneeWarrantyAmount" like '%${item}%'
  3726. </foreach>
  3727. </if>
  3728. <if test="consigneeWarrantyWeight != null">
  3729. and
  3730. <foreach collection="consigneeWarrantyWeight" item="item" open="(" separator="or" close=")">
  3731. "consigneeWarrantyWeight" like '%${item}%'
  3732. </foreach>
  3733. </if>
  3734. <if test="saleOrderIsselfMention != null">
  3735. and
  3736. <foreach collection="saleOrderIsselfMention" item="item" open="(" separator="or" close=")">
  3737. "saleOrderIsselfMention" like '%${item}%'
  3738. </foreach>
  3739. </if>
  3740. <if test="saleAccountBalance != null">
  3741. and
  3742. <foreach collection="saleAccountBalance" item="item" open="(" separator="or" close=")">
  3743. "saleAccountBalance" like '%${item}%'
  3744. </foreach>
  3745. </if>
  3746. <if test="saleCurrentOrderAmount != null">
  3747. and
  3748. <foreach collection="saleCurrentOrderAmount" item="item" open="(" separator="or" close=")">
  3749. "saleCurrentOrderAmount" like '%${item}%'
  3750. </foreach>
  3751. </if>
  3752. <if test="saleHistoricalOrderAmout != null">
  3753. and
  3754. <foreach collection="saleHistoricalOrderAmout" item="item" open="(" separator="or" close=")">
  3755. "saleHistoricalOrderAmout" like '%${item}%'
  3756. </foreach>
  3757. </if>
  3758. <if test="saleOrderReceiveCustomer != null">
  3759. and
  3760. <foreach collection="saleOrderReceiveCustomer" item="item" open="(" separator="or" close=")">
  3761. "saleOrderReceiveCustomer" like '%${item}%'
  3762. </foreach>
  3763. </if>
  3764. <if test="saleUnitPrice != null">
  3765. and
  3766. <foreach collection="saleUnitPrice" item="item" open="(" separator="or" close=")">
  3767. "saleUnitPrice" like '%${item}%'
  3768. </foreach>
  3769. </if>
  3770. <if test="saleOrderTax != null">
  3771. and
  3772. <foreach collection="saleOrderTax" item="item" open="(" separator="or" close=")">
  3773. "saleOrderTax" like '%${item}%'
  3774. </foreach>
  3775. </if>
  3776. <if test="saleRemark != null">
  3777. and
  3778. <foreach collection="saleRemark" item="item" open="(" separator="or" close=")">
  3779. "saleRemark" like '%${item}%'
  3780. </foreach>
  3781. </if>
  3782. </where>
  3783. </select>
  3784. <!-- 关闭未进厂的运单 -->
  3785. <update id="closeOrderNotIn" parameterType="DECIMAL" >
  3786. UPDATE OMSTRUCK_ORDER OO
  3787. SET OO.ORDER_STATUS = 7
  3788. WHERE OO.ORDER_ID IN (
  3789. SELECT OO.ORDER_ID "orderId"
  3790. FROM AMS_SALE_ORDER_MATERIAL ASOM
  3791. LEFT JOIN OMSTRUCK_ORDER OO
  3792. ON OO.ORDER_PLAN_ID = ASOM.SALE_ORDER_MATERIAL_ID
  3793. LEFT JOIN TMSTRUCK_TOTAL_RESULT TTR
  3794. ON TTR.ORDER_ID = OO.ORDER_ID
  3795. LEFT JOIN TMSTRUCK_ENFACTORY_RESULT TER
  3796. ON TER.RESULT_TOTAL_ID = TTR.RESULT_TOTAL_ID
  3797. WHERE ASOM.SALE_ORDER_ID = #{saleOrderId}
  3798. AND TER.RESULT_ENTRY_GATE_TIME IS NULL
  3799. AND OO.ORDER_ID IS NOT NULL
  3800. AND OO.ORDER_STATUS IN (4,5)
  3801. )
  3802. </update>
  3803. <select id="getCarMessageToEas" parameterType="DECIMAL" resultType="java.util.LinkedHashMap">
  3804. SELECT RCA.CAPACITY_NUMBER AS "r1c1",
  3805. OO.ORDER_NUMBER AS "r1c2",
  3806. RM.EAS_MATERIAL_ID AS "r1c3",
  3807. RM.MATERIAL_NAME AS "r1c4",
  3808. RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL AS "r1c5"
  3809. FROM OMSTRUCK_ORDER OO
  3810. LEFT JOIN OMSTRUCK_ORDER_MATERIAL OOM
  3811. ON OOM.ORDER_ID = OO.ORDER_ID
  3812. LEFT JOIN RMS_MATERIAL RM
  3813. ON RM.MATERIAL_ID = OOM.MATERIAL_ID
  3814. LEFT JOIN RMS_CAPACITY RCA
  3815. ON OO.CAPACITY_ID = RCA.CAPACITY_ID
  3816. LEFT JOIN AMS_SALE_ORDER_MATERIAL ASOM
  3817. ON ASOM.SALE_ORDER_MATERIAL_ID = OO.ORDER_PLAN_ID
  3818. LEFT JOIN AMS_SALE_ORDER ASO
  3819. ON ASO.SALE_ORDER_ID = ASOM.SALE_ORDER_ID
  3820. LEFT JOIN RMS_CONSIGNEE RC
  3821. ON ASO.RECEIVE_ID = RC.CONSIGNEE_ID
  3822. </select>
  3823. <select id="getSteelOrderDeletedList" resultType="java.util.Map" parameterType="java.util.Map">
  3824. select * from(
  3825. select a_s_order.SALE_ORDER_ID "saleOrderId",
  3826. a_s_order.SALE_NUMBER "saleNumber",
  3827. r_shipper.SHIPPER_NAME "shipperName",
  3828. r_consignee.CONSIGNEE_COMPANY_NAME "consigneeCompanyName",
  3829. r_consignee.CONSIGNEE_WARRANTY_AMOUNT "consigneeWarrantyAmount",
  3830. r_consignee.CONSIGNEE_WARRANTY_WEIGHT "consigneeWarrantyWeight",
  3831. a_s_order.SALE_ORDER_ISSELF_MENTION "saleOrderIsselfMention",
  3832. a_s_order.SALE_ACCOUNT_BALANCE "saleAccountBalance",
  3833. a_s_order.SALE_CURRENT_ORDER_AMOUNT "saleCurrentOrderAmount",
  3834. a_s_order.SALE_HISTORICAL_ORDER_AMOUNT "saleHistoricalOrderAmout",
  3835. a_s_order.SALE_ORDER_RECEIVE_CUSTOMER "saleOrderReceiveCustomer",
  3836. a_s_order.SALE_UNIT_PRICE "saleUnitPrice",
  3837. a_s_order.SALE_ORDER_TAX "saleOrderTax",
  3838. a_s_order.SALE_REMARK "saleRemark",
  3839. a_s_order.INSERT_TIME "insertTime",
  3840. DECODE(a_s_order.SALE_ORDER_STATUS,2,'销售已提交',4,'财务已审批') "statusStr",
  3841. RM.MATERIAL_NAME "materialName",
  3842. RM.MATERIAL_SPECIFICATION "materialSpecification",
  3843. RM.MATERIAL_MODEL "materialModel",
  3844. RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL "specificationModel",
  3845. ASM.MATERIAL_NUMBER "materialNumber",
  3846. RM.MATERIAL_NAME || RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL "nameSpecificationModel",
  3847. ASM.SALE_WAREHOUSE "saleWareHouse",
  3848. a_s_order.DELETED "deleted"
  3849. from AMS_SALE_ORDER a_s_order
  3850. left join RMS_SHIPPER r_shipper
  3851. on a_s_order.SHIPPER_ID=r_shipper.SHIPPER_ID
  3852. left join RMS_CONSIGNEE r_consignee
  3853. on a_s_order.RECEIVE_ID=r_consignee.CONSIGNEE_ID
  3854. LEFT JOIN AMS_SALE_MATERIAL ASM
  3855. ON ASM.SALE_ORDER_ID = a_s_order.SALE_ORDER_ID
  3856. LEFT JOIN RMS_MATERIAL RM
  3857. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  3858. LEFT JOIN RMS_SALER R_SALER
  3859. ON R_SALER.SALER_ID = a_s_order.SALER_ID
  3860. where a_s_order.SALE_ORDER_STATUS in (2,4)
  3861. and a_s_order.DELETED = 1
  3862. and a_s_order.SALE_TYPE = 1
  3863. <if test="con != null">
  3864. and (instr(r_consignee.CONSIGNEE_COMPANY_NAME, #{con}) > 0 or instr(a_s_order.SALE_NUMBER, #{con}) > 0)
  3865. </if>
  3866. <if test="saler != null" >
  3867. and R_SALER.SALER_NAME = #{saler}
  3868. </if>
  3869. <if test="oneDate != null">
  3870. and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= a_s_order.UPDATE_TIME
  3871. </if>
  3872. <if test="startDate != null">
  3873. and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= a_s_order.UPDATE_TIME
  3874. and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >= a_s_order.UPDATE_TIME
  3875. </if>
  3876. <if test="consigneeSsoId != null">
  3877. and r_consignee.CONSIGNEE_SSO_ID = #{consigneeSsoId}
  3878. </if>
  3879. ORDER BY a_s_order.UPDATE_TIME DESC
  3880. )
  3881. <where>
  3882. <if test="saleNumber != null">
  3883. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  3884. "saleNumber" like '%${item}%'
  3885. </foreach>
  3886. </if>
  3887. <if test="materialName != null">
  3888. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  3889. "materialName" like '%${item}%'
  3890. </foreach>
  3891. </if>
  3892. <if test="materialSpecification != null">
  3893. <foreach collection="materialSpecification" item="item" open="(" separator="or" close=")">
  3894. "materialSpecification" like '%${item}%'
  3895. </foreach>
  3896. </if>
  3897. <if test="materialModel != null">
  3898. <foreach collection="materialModel" item="item" open="(" separator="or" close=")">
  3899. "materialModel" like '%${item}%'
  3900. </foreach>
  3901. </if>
  3902. <if test="statusStr != null">
  3903. <foreach collection="statusStr" item="item" open="(" separator="or" close=")">
  3904. and "statusStr" like '%${item}%'
  3905. </foreach>
  3906. </if>
  3907. <!-- <if test="startTime != null">-->
  3908. <!-- and "insertTime" &gt;= to_date('${startTime}','yyyy-mm-dd')-->
  3909. <!-- </if>-->
  3910. <!-- <if test="endTime != null">-->
  3911. <!-- and "insertTime" &lt;= to_date('${endTime}','yyyy-mm-dd')-->
  3912. <!-- </if>-->
  3913. <if test="shipperName != null">
  3914. and
  3915. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  3916. "shipperName" like '%${item}%'
  3917. </foreach>
  3918. </if>
  3919. <if test="consigneeCompanyName != null">
  3920. and
  3921. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  3922. "consigneeCompanyName" like '%${item}%'
  3923. </foreach>
  3924. </if>
  3925. <if test="consigneeWarrantyAmount != null">
  3926. and
  3927. <foreach collection="consigneeWarrantyAmount" item="item" open="(" separator="or" close=")">
  3928. "consigneeWarrantyAmount" like '%${item}%'
  3929. </foreach>
  3930. </if>
  3931. <if test="consigneeWarrantyWeight != null">
  3932. and
  3933. <foreach collection="consigneeWarrantyWeight" item="item" open="(" separator="or" close=")">
  3934. "consigneeWarrantyWeight" like '%${item}%'
  3935. </foreach>
  3936. </if>
  3937. <if test="saleOrderIsselfMention != null">
  3938. and
  3939. <foreach collection="saleOrderIsselfMention" item="item" open="(" separator="or" close=")">
  3940. "saleOrderIsselfMention" like '%${item}%'
  3941. </foreach>
  3942. </if>
  3943. <if test="saleAccountBalance != null">
  3944. and
  3945. <foreach collection="saleAccountBalance" item="item" open="(" separator="or" close=")">
  3946. "saleAccountBalance" like '%${item}%'
  3947. </foreach>
  3948. </if>
  3949. <if test="saleCurrentOrderAmount != null">
  3950. and
  3951. <foreach collection="saleCurrentOrderAmount" item="item" open="(" separator="or" close=")">
  3952. "saleCurrentOrderAmount" like '%${item}%'
  3953. </foreach>
  3954. </if>
  3955. <if test="saleHistoricalOrderAmout != null">
  3956. and
  3957. <foreach collection="saleHistoricalOrderAmout" item="item" open="(" separator="or" close=")">
  3958. "saleHistoricalOrderAmout" like '%${item}%'
  3959. </foreach>
  3960. </if>
  3961. <if test="saleOrderReceiveCustomer != null">
  3962. and
  3963. <foreach collection="saleOrderReceiveCustomer" item="item" open="(" separator="or" close=")">
  3964. "saleOrderReceiveCustomer" like '%${item}%'
  3965. </foreach>
  3966. </if>
  3967. <if test="saleUnitPrice != null">
  3968. and
  3969. <foreach collection="saleUnitPrice" item="item" open="(" separator="or" close=")">
  3970. "saleUnitPrice" like '%${item}%'
  3971. </foreach>
  3972. </if>
  3973. <if test="saleOrderTax != null">
  3974. and
  3975. <foreach collection="saleOrderTax" item="item" open="(" separator="or" close=")">
  3976. "saleOrderTax" like '%${item}%'
  3977. </foreach>
  3978. </if>
  3979. <if test="saleRemark != null">
  3980. and
  3981. <foreach collection="saleRemark" item="item" open="(" separator="or" close=")">
  3982. "saleRemark" like '%${item}%'
  3983. </foreach>
  3984. </if>
  3985. </where>
  3986. </select>
  3987. <select id="getAllSteelSaleOrderList" parameterType="java.util.Map" resultType="java.util.Map" >
  3988. select * from(
  3989. select a_s_order.SALE_ORDER_ID "saleOrderId",
  3990. a_s_order.SALE_NUMBER "saleNumber",
  3991. r_shipper.SHIPPER_NAME "shipperName",
  3992. r_consignee.CONSIGNEE_COMPANY_NAME "consigneeCompanyName",
  3993. r_consignee.CONSIGNEE_WARRANTY_AMOUNT "consigneeWarrantyAmount",
  3994. r_consignee.CONSIGNEE_WARRANTY_WEIGHT "consigneeWarrantyWeight",
  3995. a_s_order.SALE_ORDER_ISSELF_MENTION "saleOrderIsselfMention",
  3996. a_s_order.SALE_ACCOUNT_BALANCE "saleAccountBalance",
  3997. a_s_order.SALE_CURRENT_ORDER_AMOUNT "saleCurrentOrderAmount",
  3998. a_s_order.SALE_HISTORICAL_ORDER_AMOUNT "saleHistoricalOrderAmout",
  3999. a_s_order.SALE_ORDER_RECEIVE_CUSTOMER "saleOrderReceiveCustomer",
  4000. a_s_order.SALE_UNIT_PRICE "saleUnitPrice",
  4001. a_s_order.SALE_ORDER_TAX "saleOrderTax",
  4002. a_s_order.SALE_REMARK "saleRemark",
  4003. a_s_order.INSERT_TIME "insertTime",
  4004. DECODE(a_s_order.SALE_ORDER_STATUS || a_s_order.DELETED,00,'未上传',10,'已上传',20,'销售已提交',40,'财务已审批',21,'反审核',41,'反审核',22,'已关闭',42,'已关闭') "statusStr",
  4005. RM.MATERIAL_NAME "materialName",
  4006. RM.MATERIAL_SPECIFICATION "materialSpecification",
  4007. RM.MATERIAL_MODEL "materialModel",
  4008. RM.MATERIAL_NAME || RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL "nameSpecificationModel",
  4009. ASM.SALE_WAREHOUSE "saleWareHouse"
  4010. from AMS_SALE_ORDER a_s_order
  4011. left join RMS_SHIPPER r_shipper
  4012. on a_s_order.SHIPPER_ID=r_shipper.SHIPPER_ID
  4013. left join RMS_CONSIGNEE r_consignee
  4014. on a_s_order.RECEIVE_ID=r_consignee.CONSIGNEE_ID
  4015. LEFT JOIN AMS_SALE_MATERIAL ASM
  4016. ON ASM.SALE_ORDER_ID = a_s_order.SALE_ORDER_ID
  4017. LEFT JOIN RMS_MATERIAL RM
  4018. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  4019. where a_s_order.CLOSE_STATUS is null
  4020. and a_s_order.DELETED = 0
  4021. <if test="con != null">
  4022. and (instr(r_consignee.CONSIGNEE_COMPANY_NAME, #{con}) > 0 or instr(a_s_order.SALE_NUMBER, #{con}) > 0)
  4023. </if>
  4024. <if test="shipperId != null">
  4025. and a_s_order.SHIPPER_ID = #{shipperId}
  4026. </if>
  4027. <if test="saleType != null">
  4028. and a_s_order.SALE_TYPE = #{saleType}
  4029. </if>
  4030. <if test="saleType == null">
  4031. and a_s_order.SALE_TYPE is null
  4032. </if>
  4033. <if test="consigneeSsoId != null">
  4034. and r_consignee.CONSIGNEE_SSO_ID = #{consigneeSsoId}
  4035. </if>
  4036. ORDER BY a_s_order.UPDATE_TIME DESC
  4037. )
  4038. <where>
  4039. <if test="saleNumber != null">
  4040. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  4041. "saleNumber" like '%${item}%'
  4042. </foreach>
  4043. </if>
  4044. <if test="materialName != null">
  4045. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  4046. "materialName" like '%${item}%'
  4047. </foreach>
  4048. </if>
  4049. <if test="materialSpecification != null">
  4050. <foreach collection="materialSpecification" item="item" open="(" separator="or" close=")">
  4051. "materialSpecification" like '%${item}%'
  4052. </foreach>
  4053. </if>
  4054. <if test="materialModel != null">
  4055. <foreach collection="materialModel" item="item" open="(" separator="or" close=")">
  4056. "materialModel" like '%${item}%'
  4057. </foreach>
  4058. </if>
  4059. <if test="statusStr != null">
  4060. <foreach collection="statusStr" item="item" open="(" separator="or" close=")">
  4061. and "statusStr" like '%${item}%'
  4062. </foreach>
  4063. </if>
  4064. <!-- <if test="startTime != null">-->
  4065. <!-- and "insertTime" &gt;= to_date('${startTime}','yyyy-mm-dd')-->
  4066. <!-- </if>-->
  4067. <!-- <if test="endTime != null">-->
  4068. <!-- and "insertTime" &lt;= to_date('${endTime}','yyyy-mm-dd')-->
  4069. <!-- </if>-->
  4070. <if test="shipperName != null">
  4071. and
  4072. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  4073. "shipperName" like '%${item}%'
  4074. </foreach>
  4075. </if>
  4076. <if test="consigneeCompanyName != null">
  4077. and
  4078. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  4079. "consigneeCompanyName" like '%${item}%'
  4080. </foreach>
  4081. </if>
  4082. <if test="consigneeWarrantyAmount != null">
  4083. and
  4084. <foreach collection="consigneeWarrantyAmount" item="item" open="(" separator="or" close=")">
  4085. "consigneeWarrantyAmount" like '%${item}%'
  4086. </foreach>
  4087. </if>
  4088. <if test="consigneeWarrantyWeight != null">
  4089. and
  4090. <foreach collection="consigneeWarrantyWeight" item="item" open="(" separator="or" close=")">
  4091. "consigneeWarrantyWeight" like '%${item}%'
  4092. </foreach>
  4093. </if>
  4094. <if test="saleOrderIsselfMention != null">
  4095. and
  4096. <foreach collection="saleOrderIsselfMention" item="item" open="(" separator="or" close=")">
  4097. "saleOrderIsselfMention" like '%${item}%'
  4098. </foreach>
  4099. </if>
  4100. <if test="saleAccountBalance != null">
  4101. and
  4102. <foreach collection="saleAccountBalance" item="item" open="(" separator="or" close=")">
  4103. "saleAccountBalance" like '%${item}%'
  4104. </foreach>
  4105. </if>
  4106. <if test="saleCurrentOrderAmount != null">
  4107. and
  4108. <foreach collection="saleCurrentOrderAmount" item="item" open="(" separator="or" close=")">
  4109. "saleCurrentOrderAmount" like '%${item}%'
  4110. </foreach>
  4111. </if>
  4112. <if test="saleHistoricalOrderAmout != null">
  4113. and
  4114. <foreach collection="saleHistoricalOrderAmout" item="item" open="(" separator="or" close=")">
  4115. "saleHistoricalOrderAmout" like '%${item}%'
  4116. </foreach>
  4117. </if>
  4118. <if test="saleOrderReceiveCustomer != null">
  4119. and
  4120. <foreach collection="saleOrderReceiveCustomer" item="item" open="(" separator="or" close=")">
  4121. "saleOrderReceiveCustomer" like '%${item}%'
  4122. </foreach>
  4123. </if>
  4124. <if test="saleUnitPrice != null">
  4125. and
  4126. <foreach collection="saleUnitPrice" item="item" open="(" separator="or" close=")">
  4127. "saleUnitPrice" like '%${item}%'
  4128. </foreach>
  4129. </if>
  4130. <if test="saleOrderTax != null">
  4131. and
  4132. <foreach collection="saleOrderTax" item="item" open="(" separator="or" close=")">
  4133. "saleOrderTax" like '%${item}%'
  4134. </foreach>
  4135. </if>
  4136. <if test="saleRemark != null">
  4137. and
  4138. <foreach collection="saleRemark" item="item" open="(" separator="or" close=")">
  4139. "saleRemark" like '%${item}%'
  4140. </foreach>
  4141. </if>
  4142. </where>
  4143. </select>
  4144. <!-- 修改厂内未装货车辆的运单车牌号 -->
  4145. <update id="updateCapacityNumberInFactory" parameterType="java.util.Map" >
  4146. UPDATE OMSTRUCK_ORDER OO
  4147. SET OO.CAPACITY_ID = #{capacityId},
  4148. OO.CAPACITYIDS=#{capacityids},
  4149. OO.insert_update_remark = '修改车牌号'
  4150. WHERE OO.ORDER_ID = #{orderId}
  4151. </update>
  4152. <update id="bindSaleArea">
  4153. UPDATE RMS_CONSIGNEE RC
  4154. SET RC.AREA_ID = #{saleAreaId}
  4155. WHERE RC.CONSIGNEE_ID = #{receiveId}
  4156. </update>
  4157. <select id="getCarrierByAddress" parameterType="DECIMAL" resultType="java.util.Map" >
  4158. SELECT DISTINCT ACTP.CARRIER_ID "carrierId"
  4159. FROM AMS_CONTRACT_TRANSPORT_PRICE ACTP
  4160. LEFT JOIN RMS_RECEIVE_PLACE RRP
  4161. ON RRP.PLACE_ID = ACTP.PLACE_ID
  4162. WHERE RRP.ADDRESS_ID = #{addressId}
  4163. and ACTP.DELETED = 0
  4164. </select>
  4165. <select id="getSaleCokeOrder" parameterType="java.util.Map" resultType="java.util.Map">
  4166. SELECT DISTINCT * FROM(
  4167. SELECT a_s_order.SALE_ORDER_ID "saleOrderId",
  4168. a_s_order.SALE_NUMBER "saleNumber",
  4169. r_shipper.SHIPPER_NAME "shipperName",
  4170. r_consignee.CONSIGNEE_COMPANY_NAME "consigneeCompanyName",
  4171. r_consignee.CONSIGNEE_WARRANTY_AMOUNT "consigneeWarrantyAmount",
  4172. r_consignee.CONSIGNEE_WARRANTY_WEIGHT "consigneeWarrantyWeight",
  4173. a_s_order.SALE_ORDER_ISSELF_MENTION "saleOrderIsselfMention",
  4174. a_s_order.SALE_ACCOUNT_BALANCE "saleAccountBalance",
  4175. a_s_order.SALE_CURRENT_ORDER_AMOUNT "saleCurrentOrderAmount",
  4176. a_s_order.SALE_HISTORICAL_ORDER_AMOUNT "saleHistoricalOrderAmout",
  4177. a_s_order.SALE_ORDER_RECEIVE_CUSTOMER "saleOrderReceiveCustomer",
  4178. a_s_order.SALE_UNIT_PRICE "saleUnitPrice",
  4179. a_s_order.SALE_ORDER_TAX "saleOrderTax",
  4180. a_s_order.SALE_REMARK "saleRemark",
  4181. a_s_order.INSERT_TIME "insertTime",
  4182. DECODE(a_s_order.SALE_ORDER_STATUS,2,'销售已提交',4,'财务已审批') "statusStr",
  4183. RM.MATERIAL_NAME "materialName",
  4184. ASM.MATERIAL_NUMBER "materialNumber",
  4185. ASM.SALE_WAREHOUSE "saleWareHouse",
  4186. a_s_order.DELETED "deleted",
  4187. a_s_order.SHIPPER_ID "shipperId",
  4188. a_s_order.RECEIVE_ID "receiveId",
  4189. a_s_order.SALE_ORDER_ISSELF_MENTION "isSelfMention"
  4190. from AMS_SALE_ORDER a_s_order
  4191. left join RMS_SHIPPER r_shipper
  4192. on a_s_order.SHIPPER_ID=r_shipper.SHIPPER_ID
  4193. left join RMS_CONSIGNEE r_consignee
  4194. on a_s_order.RECEIVE_ID=r_consignee.CONSIGNEE_ID
  4195. LEFT JOIN AMS_SALE_MATERIAL ASM
  4196. ON ASM.SALE_ORDER_ID = a_s_order.SALE_ORDER_ID
  4197. LEFT JOIN RMS_MATERIAL RM
  4198. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  4199. where a_s_order.SALE_ORDER_STATUS in (2,4)
  4200. and a_s_order.CLOSE_STATUS is null
  4201. and a_s_order.DELETED = 0
  4202. and ASM.DELETED IS NULL
  4203. <if test="con != null">
  4204. and (instr(r_consignee.CONSIGNEE_COMPANY_NAME, #{con}) > 0 or instr(a_s_order.SALE_NUMBER, #{con}) > 0 or instr(RM.MATERIAL_NAME, #{con}) > 0 )
  4205. </if>
  4206. <if test="oneDate != null">
  4207. and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= a_s_order.UPDATE_TIME
  4208. </if>
  4209. <if test="startDate != null">
  4210. and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= a_s_order.UPDATE_TIME
  4211. and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >= a_s_order.UPDATE_TIME
  4212. </if>
  4213. <if test="shipperId != null">
  4214. and a_s_order.SHIPPER_ID = #{shipperId}
  4215. </if>
  4216. <if test="consigneeSsoId != null">
  4217. and r_consignee.CONSIGNEE_SSO_ID = #{consigneeSsoId}
  4218. </if>
  4219. <if test="saleType == null">
  4220. and a_s_order.SALE_TYPE is null
  4221. </if>
  4222. ORDER BY a_s_order.UPDATE_TIME DESC
  4223. )
  4224. <where>
  4225. <if test="saleNumber != null">
  4226. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  4227. "saleNumber" like '%${item}%'
  4228. </foreach>
  4229. </if>
  4230. <if test="materialName != null">
  4231. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  4232. "materialName" like '%${item}%'
  4233. </foreach>
  4234. </if>
  4235. <if test="materialSpecification != null">
  4236. <foreach collection="materialSpecification" item="item" open="(" separator="or" close=")">
  4237. "materialSpecification" like '%${item}%'
  4238. </foreach>
  4239. </if>
  4240. <if test="materialModel != null">
  4241. <foreach collection="materialModel" item="item" open="(" separator="or" close=")">
  4242. "materialModel" like '%${item}%'
  4243. </foreach>
  4244. </if>
  4245. <if test="statusStr != null">
  4246. <foreach collection="statusStr" item="item" open="(" separator="or" close=")">
  4247. and "statusStr" like '%${item}%'
  4248. </foreach>
  4249. </if>
  4250. <!-- <if test="startTime != null">-->
  4251. <!-- and "insertTime" &gt;= to_date('${startTime}','yyyy-mm-dd')-->
  4252. <!-- </if>-->
  4253. <!-- <if test="endTime != null">-->
  4254. <!-- and "insertTime" &lt;= to_date('${endTime}','yyyy-mm-dd')-->
  4255. <!-- </if>-->
  4256. <if test="shipperName != null">
  4257. and
  4258. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  4259. "shipperName" like '%${item}%'
  4260. </foreach>
  4261. </if>
  4262. <if test="consigneeCompanyName != null">
  4263. and
  4264. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  4265. "consigneeCompanyName" like '%${item}%'
  4266. </foreach>
  4267. </if>
  4268. <if test="consigneeWarrantyAmount != null">
  4269. and
  4270. <foreach collection="consigneeWarrantyAmount" item="item" open="(" separator="or" close=")">
  4271. "consigneeWarrantyAmount" like '%${item}%'
  4272. </foreach>
  4273. </if>
  4274. <if test="consigneeWarrantyWeight != null">
  4275. and
  4276. <foreach collection="consigneeWarrantyWeight" item="item" open="(" separator="or" close=")">
  4277. "consigneeWarrantyWeight" like '%${item}%'
  4278. </foreach>
  4279. </if>
  4280. <if test="saleOrderIsselfMention != null">
  4281. and
  4282. <foreach collection="saleOrderIsselfMention" item="item" open="(" separator="or" close=")">
  4283. "saleOrderIsselfMention" like '%${item}%'
  4284. </foreach>
  4285. </if>
  4286. <if test="saleAccountBalance != null">
  4287. and
  4288. <foreach collection="saleAccountBalance" item="item" open="(" separator="or" close=")">
  4289. "saleAccountBalance" like '%${item}%'
  4290. </foreach>
  4291. </if>
  4292. <if test="saleCurrentOrderAmount != null">
  4293. and
  4294. <foreach collection="saleCurrentOrderAmount" item="item" open="(" separator="or" close=")">
  4295. "saleCurrentOrderAmount" like '%${item}%'
  4296. </foreach>
  4297. </if>
  4298. <if test="saleHistoricalOrderAmout != null">
  4299. and
  4300. <foreach collection="saleHistoricalOrderAmout" item="item" open="(" separator="or" close=")">
  4301. "saleHistoricalOrderAmout" like '%${item}%'
  4302. </foreach>
  4303. </if>
  4304. <if test="saleOrderReceiveCustomer != null">
  4305. and
  4306. <foreach collection="saleOrderReceiveCustomer" item="item" open="(" separator="or" close=")">
  4307. "saleOrderReceiveCustomer" like '%${item}%'
  4308. </foreach>
  4309. </if>
  4310. <if test="saleUnitPrice != null">
  4311. and
  4312. <foreach collection="saleUnitPrice" item="item" open="(" separator="or" close=")">
  4313. "saleUnitPrice" like '%${item}%'
  4314. </foreach>
  4315. </if>
  4316. <if test="saleOrderTax != null">
  4317. and
  4318. <foreach collection="saleOrderTax" item="item" open="(" separator="or" close=")">
  4319. "saleOrderTax" like '%${item}%'
  4320. </foreach>
  4321. </if>
  4322. <if test="saleRemark != null">
  4323. and
  4324. <foreach collection="saleRemark" item="item" open="(" separator="or" close=")">
  4325. "saleRemark" like '%${item}%'
  4326. </foreach>
  4327. </if>
  4328. </where>
  4329. </select>
  4330. <select id="findStatus" parameterType="DECIMAL" resultType="java.lang.Integer" >
  4331. SELECT ASO.SALE_ORDER_STATUS AS "saleStatus"
  4332. FROM AMS_SALE_ORDER_MATERIAL ASOM
  4333. LEFT JOIN AMS_SALE_ORDER ASO
  4334. ON ASO.SALE_ORDER_ID = ASOM.SALE_ORDER_ID
  4335. WHERE ASOM.SALE_ORDER_MATERIAL_ID = #{saleOrderMaterialId}
  4336. </select>
  4337. <select id="getPlaceId" parameterType="DECIMAL" resultType="DECIMAL" >
  4338. SELECT ASOM.SALE_SHIPPING_ADDRESS_ID "placeId"
  4339. FROM AMS_SALE_ORDER_MATERIAL ASOM
  4340. WHERE ASOM.SALE_ORDER_MATERIAL_ID = #{saleOrderMaterialId}
  4341. </select>
  4342. <select id="getAddressPriceList" parameterType="java.util.Map" resultType="java.util.Map" >
  4343. SELECT ACTP.PRICE_ID AS "priceId"
  4344. FROM AMS_CONTRACT_TRANSPORT_PRICE ACTP
  4345. LEFT JOIN RMS_RECEIVE_PLACE RRP
  4346. ON RRP.PLACE_ID = ACTP.PLACE_ID
  4347. WHERE ACTP.CARRIER_ID = #{carrierId}
  4348. AND RRP.ADDRESS_ID = #{addressId}
  4349. AND ACTP.DELETED = 0
  4350. ORDER BY ACTP.OLD_DATE DESC
  4351. NULLS LAST
  4352. </select>
  4353. <select id="findSelfMention" parameterType="DECIMAL" resultType="java.lang.String" >
  4354. SELECT ASO.SALE_ORDER_ISSELF_MENTION AS "selfMention"
  4355. FROM AMS_SALE_ORDER_MATERIAL ASOM
  4356. LEFT JOIN AMS_SALE_ORDER ASO
  4357. ON ASO.SALE_ORDER_ID = ASOM.SALE_ORDER_ID
  4358. WHERE ASOM.SALE_ORDER_MATERIAL_ID = #{saleOrderMaterialId}
  4359. </select>
  4360. <select id="findReceiveId" parameterType="java.lang.String" resultType="DECIMAL" >
  4361. SELECT RC.CONSIGNEE_ID AS "receiveId"
  4362. FROM RMS_CONSIGNEE RC
  4363. WHERE RC.CONSIGNEE_COMPANY_NAME = #{receiveName}
  4364. </select>
  4365. <select id="findSalerId" parameterType="java.lang.String" resultType="DECIMAL" >
  4366. SELECT RS.SALER_ID AS "salerId"
  4367. FROM RMS_SALER RS
  4368. WHERE RS.SALER_NAME = #{salerName}
  4369. </select>
  4370. <select id="findMaterialId" parameterType="java.util.Map" resultType="DECIMAL">
  4371. SELECT RM.MATERIAL_ID AS "materialId"
  4372. FROM RMS_MATERIAL RM
  4373. WHERE RM.MATERIAL_NAME = #{name}
  4374. AND RM.MATERIAL_SPECIFICATION = #{specification}
  4375. <if test="model != null">
  4376. AND RM.MATERIAL_MODEL = #{model}
  4377. </if>
  4378. </select>
  4379. <select id="findAddressId" parameterType="java.util.Map" resultType="DECIMAL" >
  4380. SELECT RRA.ADDRESS_ID AS "addressId"
  4381. FROM RMS_RECEIVE_ADDRESS RRA
  4382. WHERE RRA.ADDRESS_PROVINCE = #{province}
  4383. AND RRA.ADDRESS_DISTRICT = #{district}
  4384. AND RRA.ADDRESS_TOWN = #{town}
  4385. </select>
  4386. <select id="getSaleMaterialMessage" parameterType="DECIMAL" resultType="java.util.Map" >
  4387. SELECT ASM.MATERIAL_ID "materialId",
  4388. OO.ORDER_ID "orderId",
  4389. TTR.RESULT_TOTAL_ID "resultTotalId",
  4390. OO.ORDER_STATUS "orderStatus",
  4391. WOR.RESULT_ID "outBoundId",
  4392. ASM.MATERIAL_NUMBER "materialNumber"
  4393. FROM AMS_SALE_MATERIAL ASM
  4394. LEFT JOIN AMS_SALE_TRUCKNO_MATERIAL ASTM
  4395. ON ASTM.MATERIAL_ID = ASM.SALE_MATERIAL_ID
  4396. LEFT JOIN OMSTRUCK_ORDER OO
  4397. ON ASTM.SALE_ORDER_MATERIAL_ID = OO.ORDER_PLAN_ID
  4398. AND OO.ORDER_TYPE = 1
  4399. LEFT JOIN WMSP_OUTBOUND_RESULT WOR
  4400. ON WOR.BILL_LADING_ID = OO.ORDER_ID
  4401. LEFT JOIN TMSTRUCK_TOTAL_RESULT TTR
  4402. ON TTR.ORDER_ID = OO.ORDER_ID
  4403. WHERE ASM.SALE_MATERIAL_ID = #{saleMaterialId}
  4404. </select>
  4405. <select id="findOrderMaxNum" parameterType="DECIMAL" resultType="java.lang.Integer" >
  4406. SELECT TLFR.SEGMENT_SQE "maxNum"
  4407. FROM TMSTRUCK_LEAVE_FACTORY_RESULT TLFR
  4408. WHERE TLFR.RESULT_TOTAL_ID = #{resultTotalId}
  4409. </select>
  4410. <select id="getKucunList" resultType="java.util.Map" parameterType="java.util.Map">
  4411. SELECT * FROM (
  4412. SELECT ASO.SALE_NUMBER "saleNo", ASO.SALE_REMARK "saleRemark",
  4413. RAS1.ARRIVAL_NAME "sendStation",
  4414. RAS.ARRIVAL_NAME "toTheStation",
  4415. RM.MATERIAL_NAME "materialName",
  4416. RM.MATERIAL_SPECIFICATION||'('||RM.MATERIAL_MODEL||')' "materialSpa",
  4417. ASM.MATERIAL_NUMBER "materialNum",
  4418. ASM.MATERIAL_WEIGHT "materialWeight",
  4419. RDOINDEP.ORG_NAME "transInDep",
  4420. RDOOUTDEP.ORG_NAME "transOutDep",
  4421. RISWINOF.INWARD_WAREHOUSE_NAME "transInWarehouse",
  4422. RC.CONSIGNEE_COMPANY_NAME "receiveName",
  4423. ASO.SALE_ORDER_ID "saleOrderId",
  4424. RAS1.ARRIVAL_ID "sendStationId",
  4425. RAS.ARRIVAL_ID "toTheStationId",
  4426. ASM.IS_POUND_SALE "isPoundSale",
  4427. ASM.SALE_MATERIAL_ID "saleMaterialId",
  4428. TPAR.RESULT_ID "approveId"
  4429. FROM AMS_SALE_ORDER ASO
  4430. LEFT JOIN AMS_SALE_MATERIAL ASM
  4431. ON ASM.SALE_ORDER_ID = ASO.SALE_ORDER_ID
  4432. LEFT JOIN RMS_MATERIAL RM
  4433. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  4434. LEFT JOIN TMSTRAIN_PLEASE_APPROVE_RESULT TPAR
  4435. ON TPAR.RAIL_PLAN_ID = ASM.SALE_MATERIAL_ID
  4436. LEFT JOIN RMSTRAIN_ARRIVAL_SEND RAS
  4437. ON RAS.ARRIVAL_ID = TPAR.TO_THE_STATION_ID
  4438. LEFT JOIN RMSTRAIN_ARRIVAL_SEND RAS1
  4439. ON RAS1.ARRIVAL_ID = TPAR.SEND_STATION_ID
  4440. LEFT JOIN RMS_CONSIGNEE RC
  4441. ON RC.CONSIGNEE_ID = ASO.RECEIVE_ID
  4442. LEFT JOIN RMS_DEP_ORG RDOINDEP
  4443. ON RDOINDEP.ORG_CODE = ASO.TRANSFER_IN_DEP
  4444. LEFT JOIN RMS_DEP_ORG RDOOUTDEP
  4445. ON RDOOUTDEP.ORG_CODE = ASO.TRANSFER_OUT_DEP
  4446. LEFT JOIN RMS_INWARD_STEEL_WAREHOUSE RISWINOF
  4447. ON RISWINOF.INWARD_WAREHOUSE_CODE = ASM.TRANSFER_IN_OF_WAREHOUSE
  4448. WHERE ASO.SALE_TYPE = 4
  4449. <if test="oneDate != null">
  4450. and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt; = ASO.INSERT_TIME
  4451. </if>
  4452. <if test="startDate != null">
  4453. and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= ASO.INSERT_TIME
  4454. and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >= ASO.INSERT_TIME
  4455. </if>
  4456. <if test="remark != null">
  4457. and ASO.SALE_REMARK||RM.MATERIAL_NAME LIKE #{remark}
  4458. </if>
  4459. <if test="totheStation != null">
  4460. and RAS.ARRIVAL_NAME LIKE #{totheStation}
  4461. </if>
  4462. <if test="consigneeName != null">
  4463. and RC.CONSIGNEE_COMPANY_NAME like #{consigneeName}
  4464. </if>
  4465. <if test="transferIndep != null">
  4466. and RISWINDEP.INWARD_WAREHOUSE_NAME = #{transferIndep}
  4467. </if>
  4468. )
  4469. </select>
  4470. <select id="selectSaleAreaId" resultType="java.math.BigDecimal" parameterType="decimal">
  4471. SELECT RC.AREA_ID AS "areaId"
  4472. FROM RMS_CONSIGNEE RC
  4473. WHERE RC.CONSIGNEE_ID = #{receiveId}
  4474. </select>
  4475. <select id="selectSaleAreaIdByName" resultType="java.math.BigDecimal" parameterType="string">
  4476. SELECT RSA.AREA_ID FROM RMS_SALE_AREA RSA
  4477. WHERE RSA.AREA_NAME = #{saleAreaName}
  4478. </select>
  4479. <select id="getMoreCarrier" resultType="java.math.BigDecimal" parameterType="string">
  4480. SELECT count(RMCP.CARRIER_PLACE_ID) FROM RMS_MORE_CARRIER_PLACE RMCP
  4481. WHERE #{place} LIKE '%' || RMCP.CARRIER_PLACE_VALUE || '%'
  4482. </select>
  4483. <select id="getOrderIdByCapacity" resultType="java.util.Map">
  4484. select OO.order_ID "orderId",
  4485. RC.CAPACITY_NUMBER "capacityNumber",
  4486. TTR.RESULT_TOTAL_ID "resultTotalId",
  4487. TER.RESULT_ENTRY_GATE_TIME "isEn",
  4488. TLFR.RESULT_OUT_GATE_TIME "isLeave",
  4489. TAR.RESULT_ID "isArrival",
  4490. TRR.RESULT_ID "isReceipt"
  4491. from OMSTRUCK_ORDER OO
  4492. LEFT JOIN RMS_CAPACITY RC ON OO.CAPACITY_ID =RC.CAPACITY_ID
  4493. LEFT JOIN TMSTRUCK_TOTAL_RESULT TTR ON TTR.ORDER_ID=OO.ORDER_ID
  4494. LEFT JOIN TMSTRUCK_ENFACTORY_RESULT TER ON TER.RESULT_TOTAL_ID=TTR.RESULT_TOTAL_ID
  4495. LEFT JOIN TMSTRUCK_LEAVE_FACTORY_RESULT TLFR ON TLFR.RESULT_TOTAL_ID=TTR.RESULT_TOTAL_ID
  4496. LEFT JOIN TMSTRUCK_ARRIVAL_RESULT TAR ON TAR.RESULT_TOTAL_ID=TTR.RESULT_TOTAL_ID
  4497. LEFT JOIN TMSTRUCK_RECEIPT_RESULT TRR ON TRR.RESULT_TOTAL_ID=TTR.RESULT_TOTAL_ID
  4498. where RC.CAPACITY_NUMBER=#{capacityNumber} and OO.order_status=5
  4499. and oo.order_type = 1
  4500. fetch next 1 rows only
  4501. </select>
  4502. <select id="getOrderMes" resultType="java.util.Map" parameterType="java.util.Map">
  4503. SELECT TTR.RESULT_TOTAL_ID "resultTotalId",
  4504. OO.ORDER_STATUS "orderStatus"
  4505. FROM OMSTRUCK_ORDER OO
  4506. LEFT JOIN TMSTRUCK_TOTAL_RESULT TTR
  4507. ON TTR.ORDER_ID = OO.ORDER_ID
  4508. WHERE OO.ORDER_ID = #{orderId}
  4509. </select>
  4510. <select id="getId" resultType="java.math.BigDecimal">
  4511. select ASOM.SALE_ORDER_MATERIAL_ID "saleodermatetialid"
  4512. from AMS_SALE_ORDER_MATERIAL ASOM
  4513. LEFT JOIN AMS_SALE_ORDER ASO
  4514. ON ASO.SALE_ORDER_ID= ASOM.SALE_ORDER_ID
  4515. LEFT JOIN AMS_SALE_TRUCKNO_MATERIAL ASTM
  4516. ON ASTM.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  4517. LEFT JOIN AMS_SALE_MATERIAL ASM
  4518. ON ASM.SALE_MATERIAL_ID = ASTM.MATERIAL_ID
  4519. where ASO.sale_number=#{saleOrderNo}
  4520. and ASM.SALE_MATERIAL_ID =#{saleMaterialId}
  4521. </select>
  4522. <update id="updateForTel">
  4523. update AMS_SALE_ORDER_MATERIAL ASOM
  4524. set ASOM.SALE_ORDER_CONSIGNEE_TEL=#{consigneeTel}
  4525. WHERE ASOM.SALE_ORDER_MATERIAL_ID=#{saleodermatetialid}
  4526. </update>
  4527. <update id="updateSaleOrderStatus">
  4528. update AMS_SALE_ORDER ASO
  4529. set aso.DELETED = 2
  4530. WHERE ASO.SALE_NUMBER = #{saleNumber}
  4531. </update>
  4532. <select id="getDispachSwitch" resultType="java.lang.Integer">
  4533. SELECT IS_OK "isOk" FROM AMS_DISPATCH_SWITCH
  4534. fetch NEXT 1 rows only
  4535. </select>
  4536. </mapper>