AmsSaleOrderMapper.xml 187 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522
  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_ACCOUNT_BALANCE "saleAccountBalance",
  1481. a_s_order.SALE_CURRENT_ORDER_AMOUNT "saleCurrentOrderAmount",
  1482. a_s_order.SALE_HISTORICAL_ORDER_AMOUNT "saleHistoricalOrderAmout",
  1483. a_s_order.SALE_ORDER_RECEIVE_CUSTOMER "saleOrderReceiveCustomer",
  1484. a_s_order.SALE_UNIT_PRICE "saleUnitPrice",
  1485. a_s_order.SALE_ORDER_TAX "saleOrderTax",
  1486. a_s_order.SALE_REMARK "saleRemark",
  1487. a_s_order.INSERT_TIME "insertTime",
  1488. RM.MATERIAL_NAME "materialName",
  1489. RM.MATERIAL_SPECIFICATION "materialSpecification",
  1490. RM.MATERIAL_MODEL "materialModel",
  1491. ASM.MATERIAL_NUMBER "materialNumber",
  1492. RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL "specificationModel",
  1493. RM.MATERIAL_NAME || RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL "nameSpecificationModel",
  1494. RRA.ADDRESS_PROVINCE || RRA.ADDRESS_DISTRICT || RRA.ADDRESS_TOWN || RRP.ADDRESS_DELIVERY_ADDRESS AS "addressPlace",
  1495. ASOM.SALE_ORDER_MATERIAL_ID AS "saleOrderMaterialId"
  1496. from AMS_SALE_ORDER a_s_order
  1497. left join RMS_SHIPPER r_shipper
  1498. on a_s_order.SHIPPER_ID=r_shipper.SHIPPER_ID
  1499. left join RMS_CONSIGNEE r_consignee
  1500. on a_s_order.RECEIVE_ID=r_consignee.CONSIGNEE_ID
  1501. LEFT JOIN AMS_SALE_ORDER_MATERIAL ASOM
  1502. ON ASOM.SALE_ORDER_ID = a_s_order.SALE_ORDER_ID
  1503. LEFT JOIN RMS_RECEIVE_PLACE RRP
  1504. ON RRP.PLACE_ID = ASOM.SALE_SHIPPING_ADDRESS_ID
  1505. LEFT JOIN RMS_RECEIVE_ADDRESS RRA
  1506. ON RRA.ADDRESS_ID = RRP.ADDRESS_ID
  1507. LEFT JOIN AMS_SALE_TRUCKNO_MATERIAL ASTM
  1508. ON ASTM.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  1509. LEFT JOIN AMS_SALE_MATERIAL ASM
  1510. ON ASM.SALE_MATERIAL_ID = ASTM.MATERIAL_ID
  1511. LEFT JOIN RMS_MATERIAL RM
  1512. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  1513. LEFT JOIN RMS_SALER R_SALER
  1514. ON R_SALER.SALER_ID = a_s_order.SALER_ID
  1515. where a_s_order.SALE_ORDER_STATUS=0 and a_s_order.DELETED=0
  1516. and ASM.DELETED IS NULL
  1517. <if test="con != null">
  1518. and (instr(r_consignee.CONSIGNEE_COMPANY_NAME, #{con}) > 0 or instr(a_s_order.SALE_NUMBER, #{con}) > 0)
  1519. </if>
  1520. <if test="consigneeSsoId != null" >
  1521. and r_consignee.CONSIGNEE_SSO_ID = #{consigneeSsoId}
  1522. </if>
  1523. <if test="saler != null" >
  1524. and R_SALER.SALER_NAME = #{saler}
  1525. </if>
  1526. <if test="oneDate != null">
  1527. and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= a_s_order.UPDATE_TIME
  1528. </if>
  1529. <if test="startDate != null">
  1530. and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= a_s_order.UPDATE_TIME
  1531. and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >= a_s_order.UPDATE_TIME
  1532. </if>
  1533. )
  1534. <where>
  1535. <if test="saleNumber != null">
  1536. and
  1537. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  1538. "saleNumber" like '%${item}%'
  1539. </foreach>
  1540. </if>
  1541. <if test="materialName != null">
  1542. and
  1543. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  1544. "materialName" like '%${item}%'
  1545. </foreach>
  1546. </if>
  1547. <if test="specificationModel != null">
  1548. and
  1549. <foreach collection="specificationModel" item="item" open="(" separator="or" close=")">
  1550. "specificationModel" like '%${item}%'
  1551. </foreach>
  1552. </if>
  1553. <if test="materialModel != null">
  1554. and
  1555. <foreach collection="materialModel" item="item" open="(" separator="or" close=")">
  1556. "materialModel" like '%${item}%'
  1557. </foreach>
  1558. </if>
  1559. <if test="shipperName != null">
  1560. and
  1561. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  1562. "shipperName" like '%${item}%'
  1563. </foreach>
  1564. </if>
  1565. <if test="consigneeCompanyName != null">
  1566. and
  1567. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  1568. "consigneeCompanyName" like '%${item}%'
  1569. </foreach>
  1570. </if>
  1571. <if test="saleOrderIsselfMention != null">
  1572. and
  1573. <foreach collection="saleOrderIsselfMention" item="item" open="(" separator="or" close=")">
  1574. "saleOrderIsselfMention" like '%${item}%'
  1575. </foreach>
  1576. </if>
  1577. <if test="saleAccountBalance != null">
  1578. and
  1579. <foreach collection="saleAccountBalance" item="item" open="(" separator="or" close=")">
  1580. "saleAccountBalance" like '%${item}%'
  1581. </foreach>
  1582. </if>
  1583. <if test="saleCurrentOrderAmount != null">
  1584. and
  1585. <foreach collection="saleCurrentOrderAmount" item="item" open="(" separator="or" close=")">
  1586. "saleCurrentOrderAmount" like '%${item}%'
  1587. </foreach>
  1588. </if>
  1589. <if test="saleHistoricalOrderAmout != null">
  1590. and
  1591. <foreach collection="saleHistoricalOrderAmout" item="item" open="(" separator="or" close=")">
  1592. "saleHistoricalOrderAmout" like '%${item}%'
  1593. </foreach>
  1594. </if>
  1595. <if test="saleOrderReceiveCustomer != null">
  1596. and
  1597. <foreach collection="saleOrderReceiveCustomer" item="item" open="(" separator="or" close=")">
  1598. "saleOrderReceiveCustomer" like '%${item}%'
  1599. </foreach>
  1600. </if>
  1601. <if test="saleUnitPrice != null">
  1602. and
  1603. <foreach collection="saleUnitPrice" item="item" open="(" separator="or" close=")">
  1604. "saleUnitPrice" like '%${item}%'
  1605. </foreach>
  1606. </if>
  1607. <if test="saleOrderTax != null">
  1608. and
  1609. <foreach collection="saleOrderTax" item="item" open="(" separator="or" close=")">
  1610. "saleOrderTax" like '%${item}%'
  1611. </foreach>
  1612. </if>
  1613. <if test="saleRemark != null">
  1614. and
  1615. <foreach collection="saleRemark" item="item" open="(" separator="or" close=")">
  1616. "saleRemark" like '%${item}%'
  1617. </foreach>
  1618. </if>
  1619. </where>
  1620. <include refid="orderBy"></include>
  1621. </select>
  1622. <select id="getSaleOrderReportedes" parameterType="java.util.Map" resultType="java.util.LinkedHashMap">
  1623. select * from(
  1624. select a_s_order.SALE_ORDER_ID "saleOrderId",
  1625. a_s_order.SALE_NUMBER "saleNumber",
  1626. r_shipper.SHIPPER_NAME "shipperName",
  1627. r_consignee.CONSIGNEE_COMPANY_NAME "consigneeCompanyName",
  1628. a_s_order.SALE_ORDER_ISSELF_MENTION "saleOrderIsselfMention",
  1629. a_s_order.SALE_ACCOUNT_BALANCE "saleAccountBalance",
  1630. a_s_order.SALE_CURRENT_ORDER_AMOUNT "saleCurrentOrderAmount",
  1631. a_s_order.SALE_HISTORICAL_ORDER_AMOUNT "saleHistoricalOrderAmout",
  1632. a_s_order.SALE_ORDER_RECEIVE_CUSTOMER "saleOrderReceiveCustomer",
  1633. a_s_order.SALE_UNIT_PRICE "saleUnitPrice",
  1634. a_s_order.SALE_ORDER_TAX "saleOrderTax",
  1635. a_s_order.SALE_REMARK "saleRemark",
  1636. a_s_order.INSERT_TIME "insertTime",
  1637. RM.MATERIAL_NAME "materialName",
  1638. RM.MATERIAL_SPECIFICATION "materialSpecification",
  1639. RM.MATERIAL_MODEL "materialModel",
  1640. RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL "specificationModel",
  1641. ASM.MATERIAL_NUMBER "materialNumber",
  1642. RM.MATERIAL_NAME || RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL "nameSpecificationModel",
  1643. RRA.ADDRESS_PROVINCE || RRA.ADDRESS_DISTRICT || RRA.ADDRESS_TOWN || RRP.ADDRESS_DELIVERY_ADDRESS AS "addressPlace"
  1644. from AMS_SALE_ORDER a_s_order
  1645. left join RMS_SHIPPER r_shipper
  1646. on a_s_order.SHIPPER_ID=r_shipper.SHIPPER_ID
  1647. left join RMS_CONSIGNEE r_consignee
  1648. on a_s_order.RECEIVE_ID=r_consignee.CONSIGNEE_ID
  1649. left join AMS_SALE_ORDER_MATERIAL ASOM
  1650. on asom.SALE_ORDER_ID = a_s_order.SALE_ORDER_ID
  1651. left join RMS_RECEIVE_PLACE RRP
  1652. on RRP.PLACE_ID = ASOM.SALE_SHIPPING_ADDRESS_ID
  1653. LEFT JOIN RMS_RECEIVE_ADDRESS RRA
  1654. ON RRP.ADDRESS_ID = RRA.ADDRESS_ID
  1655. LEFT JOIN AMS_SALE_TRUCKNO_MATERIAL ASTM
  1656. ON ASTM.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  1657. LEFT JOIN AMS_SALE_MATERIAL ASM
  1658. ON ASM.SALE_MATERIAL_ID = ASTM.MATERIAL_ID
  1659. LEFT JOIN RMS_MATERIAL RM
  1660. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  1661. LEFT JOIN RMS_SALER R_SALER
  1662. ON R_SALER.SALER_ID = a_s_order.SALER_ID
  1663. where a_s_order.SALE_ORDER_STATUS=1
  1664. and a_s_order.DELETED = 0
  1665. AND ASM.DELETED IS NULL
  1666. <if test="con != null">
  1667. and (instr(r_consignee.CONSIGNEE_COMPANY_NAME, #{con}) > 0 or instr(a_s_order.SALE_NUMBER, #{con}) > 0)
  1668. </if>
  1669. <if test="oneDate != null">
  1670. and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= a_s_order.UPDATE_TIME
  1671. </if>
  1672. <if test="startDate != null">
  1673. and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= a_s_order.UPDATE_TIME
  1674. and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >= a_s_order.UPDATE_TIME
  1675. </if>
  1676. <if test="consigneeSsoId != null">
  1677. and r_consignee.CONSIGNEE_SSO_ID = #{consigneeSsoId}
  1678. </if>
  1679. <if test="saler != null" >
  1680. and R_SALER.SALER_NAME = #{saler}
  1681. </if>
  1682. )
  1683. <where>
  1684. <if test="saleNumber != null">
  1685. and
  1686. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  1687. "saleNumber" like '%${item}%'
  1688. </foreach>
  1689. </if>
  1690. <if test="materialName != null">
  1691. and
  1692. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  1693. "materialName" like '%${item}%'
  1694. </foreach>
  1695. </if>
  1696. <if test="materialModel != null">
  1697. and
  1698. <foreach collection="materialModel" item="item" open="(" separator="or" close=")">
  1699. "materialModel" like '%${item}%'
  1700. </foreach>
  1701. </if>
  1702. <if test="materialSpecification != null">
  1703. and
  1704. <foreach collection="materialSpecification" item="item" open="(" separator="or" close=")">
  1705. "materialSpecification" like '%${item}%'
  1706. </foreach>
  1707. </if>
  1708. <if test="shipperName != null">
  1709. and
  1710. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  1711. "shipperName" like '%${item}%'
  1712. </foreach>
  1713. </if>
  1714. <if test="consigneeCompanyName != null">
  1715. and
  1716. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  1717. "consigneeCompanyName" like '%${item}%'
  1718. </foreach>
  1719. </if>
  1720. <if test="saleOrderIsselfMention != null">
  1721. and
  1722. <foreach collection="saleOrderIsselfMention" item="item" open="(" separator="or" close=")">
  1723. "saleOrderIsselfMention" like '%${item}%'
  1724. </foreach>
  1725. </if>
  1726. <if test="saleAccountBalance != null">
  1727. and
  1728. <foreach collection="saleAccountBalance" item="item" open="(" separator="or" close=")">
  1729. "saleAccountBalance" like '%${item}%'
  1730. </foreach>
  1731. </if>
  1732. <if test="saleCurrentOrderAmount != null">
  1733. and
  1734. <foreach collection="saleCurrentOrderAmount" item="item" open="(" separator="or" close=")">
  1735. "saleCurrentOrderAmount" like '%${item}%'
  1736. </foreach>
  1737. </if>
  1738. <if test="saleHistoricalOrderAmout != null">
  1739. and
  1740. <foreach collection="saleHistoricalOrderAmout" item="item" open="(" separator="or" close=")">
  1741. "saleHistoricalOrderAmout" like '%${item}%'
  1742. </foreach>
  1743. </if>
  1744. <if test="saleOrderReceiveCustomer != null">
  1745. and
  1746. <foreach collection="saleOrderReceiveCustomer" item="item" open="(" separator="or" close=")">
  1747. "saleOrderReceiveCustomer" like '%${item}%'
  1748. </foreach>
  1749. </if>
  1750. <if test="saleUnitPrice != null">
  1751. and
  1752. <foreach collection="saleUnitPrice" item="item" open="(" separator="or" close=")">
  1753. "saleUnitPrice" like '%${item}%'
  1754. </foreach>
  1755. </if>
  1756. <if test="saleOrderTax != null">
  1757. and
  1758. <foreach collection="saleOrderTax" item="item" open="(" separator="or" close=")">
  1759. "saleOrderTax" like '%${item}%'
  1760. </foreach>
  1761. </if>
  1762. <if test="saleRemark != null">
  1763. and
  1764. <foreach collection="saleRemark" item="item" open="(" separator="or" close=")">
  1765. "saleRemark" like '%${item}%'
  1766. </foreach>
  1767. </if>
  1768. </where>
  1769. <include refid="orderBy"></include>
  1770. </select>
  1771. <!-- 销售公司查询已审核的焦炭销售订单 -->
  1772. <select id="getCokeSaleOrderList" parameterType="java.util.Map" resultType="java.util.Map">
  1773. select * from(
  1774. select a_s_order.SALE_ORDER_ID "saleOrderId",
  1775. a_s_order.SALE_NUMBER "saleNumber",
  1776. r_shipper.SHIPPER_NAME "shipperName",
  1777. r_consignee.CONSIGNEE_COMPANY_NAME "consigneeCompanyName",
  1778. r_consignee.CONSIGNEE_WARRANTY_AMOUNT "consigneeWarrantyAmount",
  1779. r_consignee.CONSIGNEE_WARRANTY_WEIGHT "consigneeWarrantyWeight",
  1780. a_s_order.SALE_ORDER_ISSELF_MENTION "saleOrderIsselfMention",
  1781. a_s_order.SALE_ACCOUNT_BALANCE "saleAccountBalance",
  1782. a_s_order.SALE_CURRENT_ORDER_AMOUNT "saleCurrentOrderAmount",
  1783. a_s_order.SALE_HISTORICAL_ORDER_AMOUNT "saleHistoricalOrderAmout",
  1784. a_s_order.SALE_ORDER_RECEIVE_CUSTOMER "saleOrderReceiveCustomer",
  1785. a_s_order.SALE_UNIT_PRICE "saleUnitPrice",
  1786. a_s_order.SALE_ORDER_TAX "saleOrderTax",
  1787. a_s_order.SALE_REMARK "saleRemark",
  1788. a_s_order.INSERT_TIME "insertTime",
  1789. a_s_order.SALE_TYPE ,
  1790. DECODE(a_s_order.SALE_ORDER_STATUS,2,'销售已提交',4,'财务已审批') "statusStr",
  1791. RM.MATERIAL_NAME "materialName",
  1792. a_s_order.CLOSE_STATUS "closeStatus"
  1793. from AMS_SALE_ORDER a_s_order
  1794. left join RMS_SHIPPER r_shipper
  1795. on a_s_order.SHIPPER_ID=r_shipper.SHIPPER_ID
  1796. left join RMS_CONSIGNEE r_consignee
  1797. on a_s_order.RECEIVE_ID=r_consignee.CONSIGNEE_ID
  1798. left join AMS_SALE_MATERIAL ASM
  1799. on ASM.SALE_ORDER_ID = a_s_order.SALE_ORDER_ID
  1800. left join RMS_MATERIAL RM
  1801. on RM.MATERIAL_ID = ASM.MATERIAL_ID
  1802. where a_s_order.SALE_ORDER_STATUS in (2,4)
  1803. and a_s_order.CLOSE_STATUS is not null
  1804. and a_s_order.DELETED = 0
  1805. and a_s_order.SALE_TYPE is null
  1806. ) SSSR
  1807. <if test="con != null" >
  1808. where SSSR."consigneeCompanyName" LIKE #{con}
  1809. </if>
  1810. <if test="con != null" >
  1811. or SSSR."saleNumber" LIKE #{con}
  1812. </if>
  1813. <where>
  1814. <if test="saleNumber != null">
  1815. and
  1816. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  1817. "saleNumber" like '%${item}%'
  1818. </foreach>
  1819. </if>
  1820. <if test="materialName != null">
  1821. and
  1822. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  1823. "materialName" like '%${item}%'
  1824. </foreach>
  1825. </if>
  1826. <if test="statusStr != null">
  1827. and
  1828. <foreach collection="statusStr" item="item" open="(" separator="or" close=")">
  1829. "statusStr" like '%${item}%'
  1830. </foreach>
  1831. </if>
  1832. <if test="shipperName != null">
  1833. and
  1834. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  1835. "shipperName" like '%${item}%'
  1836. </foreach>
  1837. </if>
  1838. <if test="consigneeCompanyName != null">
  1839. and
  1840. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  1841. "consigneeCompanyName" like '%${item}%'
  1842. </foreach>
  1843. </if>
  1844. <if test="consigneeWarrantyAmount != null">
  1845. and
  1846. <foreach collection="consigneeWarrantyAmount" item="item" open="(" separator="or" close=")">
  1847. "consigneeWarrantyAmount" like '%${item}%'
  1848. </foreach>
  1849. </if>
  1850. <if test="consigneeWarrantyWeight != null">
  1851. and
  1852. <foreach collection="consigneeWarrantyWeight" item="item" open="(" separator="or" close=")">
  1853. "consigneeWarrantyWeight" like '%${item}%'
  1854. </foreach>
  1855. </if>
  1856. <if test="saleOrderIsselfMention != null">
  1857. and
  1858. <foreach collection="saleOrderIsselfMention" item="item" open="(" separator="or" close=")">
  1859. "saleOrderIsselfMention" like '%${item}%'
  1860. </foreach>
  1861. </if>
  1862. <if test="saleAccountBalance != null">
  1863. and
  1864. <foreach collection="saleAccountBalance" item="item" open="(" separator="or" close=")">
  1865. "saleAccountBalance" like '%${item}%'
  1866. </foreach>
  1867. </if>
  1868. <if test="saleCurrentOrderAmount != null">
  1869. and
  1870. <foreach collection="saleCurrentOrderAmount" item="item" open="(" separator="or" close=")">
  1871. "saleCurrentOrderAmount" like '%${item}%'
  1872. </foreach>
  1873. </if>
  1874. <if test="saleHistoricalOrderAmout != null">
  1875. and
  1876. <foreach collection="saleHistoricalOrderAmout" item="item" open="(" separator="or" close=")">
  1877. "saleHistoricalOrderAmout" like '%${item}%'
  1878. </foreach>
  1879. </if>
  1880. <if test="saleOrderReceiveCustomer != null">
  1881. and
  1882. <foreach collection="saleOrderReceiveCustomer" item="item" open="(" separator="or" close=")">
  1883. "saleOrderReceiveCustomer" like '%${item}%'
  1884. </foreach>
  1885. </if>
  1886. <if test="saleUnitPrice != null">
  1887. and
  1888. <foreach collection="saleUnitPrice" item="item" open="(" separator="or" close=")">
  1889. "saleUnitPrice" like '%${item}%'
  1890. </foreach>
  1891. </if>
  1892. <if test="saleOrderTax != null">
  1893. and
  1894. <foreach collection="saleOrderTax" item="item" open="(" separator="or" close=")">
  1895. "saleOrderTax" like '%${item}%'
  1896. </foreach>
  1897. </if>
  1898. <if test="saleRemark != null">
  1899. and
  1900. <foreach collection="saleRemark" item="item" open="(" separator="or" close=")">
  1901. "saleRemark" like '%${item}%'
  1902. </foreach>
  1903. </if>
  1904. </where>
  1905. <include refid="orderBy"></include>
  1906. </select>
  1907. <select id="getSaleOrderListBySaleCompanyes" parameterType="java.util.Map" resultType="java.util.Map">
  1908. select * from(
  1909. select a_s_order.SALE_ORDER_ID "saleOrderId",
  1910. a_s_order.SALE_NUMBER "saleNumber",
  1911. r_shipper.SHIPPER_NAME "shipperName",
  1912. r_consignee.CONSIGNEE_COMPANY_NAME "consigneeCompanyName",
  1913. r_consignee.CONSIGNEE_WARRANTY_AMOUNT "consigneeWarrantyAmount",
  1914. r_consignee.CONSIGNEE_WARRANTY_WEIGHT "consigneeWarrantyWeight",
  1915. a_s_order.SALE_ORDER_ISSELF_MENTION "saleOrderIsselfMention",
  1916. a_s_order.SALE_ACCOUNT_BALANCE "saleAccountBalance",
  1917. a_s_order.SALE_CURRENT_ORDER_AMOUNT "saleCurrentOrderAmount",
  1918. a_s_order.SALE_HISTORICAL_ORDER_AMOUNT "saleHistoricalOrderAmout",
  1919. a_s_order.SALE_ORDER_RECEIVE_CUSTOMER "saleOrderReceiveCustomer",
  1920. a_s_order.SALE_UNIT_PRICE "saleUnitPrice",
  1921. a_s_order.SALE_ORDER_TAX "saleOrderTax",
  1922. a_s_order.SALE_REMARK "saleRemark",
  1923. a_s_order.INSERT_TIME "insertTime",
  1924. DECODE(a_s_order.SALE_ORDER_STATUS,2,'销售已提交',4,'财务已审批') "statusStr",
  1925. RM.MATERIAL_NAME "materialName",
  1926. RM.MATERIAL_SPECIFICATION "materialSpecification",
  1927. RM.MATERIAL_MODEL "materialModel",
  1928. RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL "specificationModel",
  1929. ASM.MATERIAL_NUMBER "materialNumber",
  1930. RM.MATERIAL_NAME || RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL "nameSpecificationModel",
  1931. RRA.ADDRESS_PROVINCE || RRA.ADDRESS_DISTRICT || RRA.ADDRESS_TOWN || RRP.ADDRESS_DELIVERY_ADDRESS AS "addressPlace",
  1932. ASM.SALE_WAREHOUSE "saleWareHouse",
  1933. a_s_order.DELETED "deleted",
  1934. a_s_order.SHIPPER_ID "shipperId",
  1935. a_s_order.RECEIVE_ID "receiveId",
  1936. a_s_order.SALE_ORDER_ISSELF_MENTION "isSelfMention",
  1937. a_s_order.SALER_ID "salerId"
  1938. from AMS_SALE_ORDER a_s_order
  1939. left join RMS_SHIPPER r_shipper
  1940. on a_s_order.SHIPPER_ID=r_shipper.SHIPPER_ID
  1941. left join RMS_CONSIGNEE r_consignee
  1942. on a_s_order.RECEIVE_ID=r_consignee.CONSIGNEE_ID
  1943. left join AMS_SALE_ORDER_MATERIAL ASOM
  1944. on asom.SALE_ORDER_ID = a_s_order.SALE_ORDER_ID
  1945. left join RMS_RECEIVE_PLACE RRP
  1946. on RRP.PLACE_ID = ASOM.SALE_SHIPPING_ADDRESS_ID
  1947. LEFT JOIN RMS_RECEIVE_ADDRESS RRA
  1948. ON RRP.ADDRESS_ID = RRA.ADDRESS_ID
  1949. LEFT JOIN AMS_SALE_TRUCKNO_MATERIAL ASTM
  1950. ON ASTM.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  1951. LEFT JOIN AMS_SALE_MATERIAL ASM
  1952. ON ASM.SALE_MATERIAL_ID = ASTM.MATERIAL_ID
  1953. LEFT JOIN RMS_MATERIAL RM
  1954. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  1955. LEFT JOIN RMS_SALER R_SALER
  1956. ON R_SALER.SALER_ID = a_s_order.SALER_ID
  1957. where a_s_order.SALE_ORDER_STATUS in (2,4)
  1958. and a_s_order.CLOSE_STATUS is null
  1959. and a_s_order.DELETED = 0
  1960. and ASM.DELETED IS NULL
  1961. <if test="con != null">
  1962. and (instr(r_consignee.CONSIGNEE_COMPANY_NAME, #{con}) > 0 or instr(a_s_order.SALE_NUMBER, #{con}) > 0)
  1963. </if>
  1964. <if test="oneDate != null">
  1965. and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= a_s_order.UPDATE_TIME
  1966. </if>
  1967. <if test="startDate != null">
  1968. and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= a_s_order.UPDATE_TIME
  1969. and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >= a_s_order.UPDATE_TIME
  1970. </if>
  1971. <if test="shipperId != null">
  1972. and a_s_order.SHIPPER_ID = #{shipperId}
  1973. </if>
  1974. <if test="saleType != null">
  1975. and a_s_order.SALE_TYPE = #{saleType}
  1976. </if>
  1977. <if test="saleType == null">
  1978. and a_s_order.SALE_TYPE is null
  1979. </if>
  1980. <if test="saler != null" >
  1981. and R_SALER.SALER_NAME = #{saler}
  1982. </if>
  1983. <if test="consigneeSsoId != null">
  1984. and r_consignee.CONSIGNEE_SSO_ID = #{consigneeSsoId}
  1985. </if>
  1986. ORDER BY a_s_order.UPDATE_TIME DESC
  1987. )
  1988. <where>
  1989. <if test="saleNumber != null">
  1990. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  1991. "saleNumber" like '%${item}%'
  1992. </foreach>
  1993. </if>
  1994. <if test="materialName != null">
  1995. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  1996. "materialName" like '%${item}%'
  1997. </foreach>
  1998. </if>
  1999. <if test="materialSpecification != null">
  2000. <foreach collection="materialSpecification" item="item" open="(" separator="or" close=")">
  2001. "materialSpecification" like '%${item}%'
  2002. </foreach>
  2003. </if>
  2004. <if test="materialModel != null">
  2005. <foreach collection="materialModel" item="item" open="(" separator="or" close=")">
  2006. "materialModel" like '%${item}%'
  2007. </foreach>
  2008. </if>
  2009. <if test="statusStr != null">
  2010. <foreach collection="statusStr" item="item" open="(" separator="or" close=")">
  2011. and "statusStr" like '%${item}%'
  2012. </foreach>
  2013. </if>
  2014. <!-- <if test="startTime != null">-->
  2015. <!-- and "insertTime" &gt;= to_date('${startTime}','yyyy-mm-dd')-->
  2016. <!-- </if>-->
  2017. <!-- <if test="endTime != null">-->
  2018. <!-- and "insertTime" &lt;= to_date('${endTime}','yyyy-mm-dd')-->
  2019. <!-- </if>-->
  2020. <if test="shipperName != null">
  2021. and
  2022. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  2023. "shipperName" like '%${item}%'
  2024. </foreach>
  2025. </if>
  2026. <if test="consigneeCompanyName != null">
  2027. and
  2028. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  2029. "consigneeCompanyName" like '%${item}%'
  2030. </foreach>
  2031. </if>
  2032. <if test="consigneeWarrantyAmount != null">
  2033. and
  2034. <foreach collection="consigneeWarrantyAmount" item="item" open="(" separator="or" close=")">
  2035. "consigneeWarrantyAmount" like '%${item}%'
  2036. </foreach>
  2037. </if>
  2038. <if test="consigneeWarrantyWeight != null">
  2039. and
  2040. <foreach collection="consigneeWarrantyWeight" item="item" open="(" separator="or" close=")">
  2041. "consigneeWarrantyWeight" like '%${item}%'
  2042. </foreach>
  2043. </if>
  2044. <if test="saleOrderIsselfMention != null">
  2045. and
  2046. <foreach collection="saleOrderIsselfMention" item="item" open="(" separator="or" close=")">
  2047. "saleOrderIsselfMention" like '%${item}%'
  2048. </foreach>
  2049. </if>
  2050. <if test="saleAccountBalance != null">
  2051. and
  2052. <foreach collection="saleAccountBalance" item="item" open="(" separator="or" close=")">
  2053. "saleAccountBalance" like '%${item}%'
  2054. </foreach>
  2055. </if>
  2056. <if test="saleCurrentOrderAmount != null">
  2057. and
  2058. <foreach collection="saleCurrentOrderAmount" item="item" open="(" separator="or" close=")">
  2059. "saleCurrentOrderAmount" like '%${item}%'
  2060. </foreach>
  2061. </if>
  2062. <if test="saleHistoricalOrderAmout != null">
  2063. and
  2064. <foreach collection="saleHistoricalOrderAmout" item="item" open="(" separator="or" close=")">
  2065. "saleHistoricalOrderAmout" like '%${item}%'
  2066. </foreach>
  2067. </if>
  2068. <if test="saleOrderReceiveCustomer != null">
  2069. and
  2070. <foreach collection="saleOrderReceiveCustomer" item="item" open="(" separator="or" close=")">
  2071. "saleOrderReceiveCustomer" like '%${item}%'
  2072. </foreach>
  2073. </if>
  2074. <if test="saleUnitPrice != null">
  2075. and
  2076. <foreach collection="saleUnitPrice" item="item" open="(" separator="or" close=")">
  2077. "saleUnitPrice" like '%${item}%'
  2078. </foreach>
  2079. </if>
  2080. <if test="saleOrderTax != null">
  2081. and
  2082. <foreach collection="saleOrderTax" item="item" open="(" separator="or" close=")">
  2083. "saleOrderTax" like '%${item}%'
  2084. </foreach>
  2085. </if>
  2086. <if test="saleRemark != null">
  2087. and
  2088. <foreach collection="saleRemark" item="item" open="(" separator="or" close=")">
  2089. "saleRemark" like '%${item}%'
  2090. </foreach>
  2091. </if>
  2092. </where>
  2093. </select>
  2094. <select id="getAmsSaleOrderApprovedes" parameterType="java.util.Map" resultType="java.util.LinkedHashMap">
  2095. select * from(
  2096. select a_s_order.SALE_ORDER_ID "saleOrderId",
  2097. a_s_order.SALE_NUMBER "saleNumber",
  2098. r_shipper.SHIPPER_NAME "shipperName",
  2099. r_consignee.CONSIGNEE_COMPANY_NAME "consigneeCompanyName",
  2100. r_consignee.CONSIGNEE_WARRANTY_AMOUNT "consigneeWarrantyAmount",
  2101. r_consignee.CONSIGNEE_WARRANTY_WEIGHT "consigneeWarrantyWeight",
  2102. a_s_order.SALE_ORDER_ISSELF_MENTION "saleOrderIsselfMention",
  2103. a_s_order.SALE_ACCOUNT_BALANCE "saleAccountBalance",
  2104. a_s_order.SALE_CURRENT_ORDER_AMOUNT "saleCurrentOrderAmount",
  2105. a_s_order.SALE_HISTORICAL_ORDER_AMOUNT "saleHistoricalOrderAmout",
  2106. a_s_order.SALE_ORDER_RECEIVE_CUSTOMER "saleOrderReceiveCustomer",
  2107. DECODE(a_s_order.SALE_ORDER_STATUS,2,'销售已提交',4,'财务已审批') "statusStr",
  2108. a_s_order.SALE_UNIT_PRICE "saleUnitPrice",
  2109. a_s_order.SALE_ORDER_TAX "saleOrderTax",
  2110. a_s_order.SALE_REMARK "saleRemark",
  2111. a_s_order.INSERT_TIME "insertTime"
  2112. from AMS_SALE_ORDER a_s_order
  2113. left join RMS_SHIPPER r_shipper
  2114. on a_s_order.SHIPPER_ID=r_shipper.SHIPPER_ID
  2115. left join RMS_CONSIGNEE r_consignee
  2116. on a_s_order.RECEIVE_ID=r_consignee.CONSIGNEE_ID
  2117. where a_s_order.SALE_ORDER_STATUS in (2,4)
  2118. AND a_s_order.SHIPPER_ID = 2
  2119. <if test="con != null">
  2120. and instr(r_consignee.CONSIGNEE_COMPANY_NAME, #{con}) > 0
  2121. </if>
  2122. )
  2123. <where>
  2124. <if test="saleNumber != null">
  2125. and
  2126. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  2127. "saleNumber" like '%${item}%'
  2128. </foreach>
  2129. </if>
  2130. <if test="statusStr != null">
  2131. and
  2132. <foreach collection="statusStr" item="item" open="(" separator="or" close=")">
  2133. "statusStr" like '%${item}%'
  2134. </foreach>
  2135. </if>
  2136. <if test="shipperName != null">
  2137. and
  2138. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  2139. "shipperName" like '%${item}%'
  2140. </foreach>
  2141. </if>
  2142. <if test="consigneeCompanyName != null">
  2143. and
  2144. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  2145. "consigneeCompanyName" like '%${item}%'
  2146. </foreach>
  2147. </if>
  2148. <if test="consigneeWarrantyAmount != null">
  2149. and
  2150. <foreach collection="consigneeWarrantyAmount" item="item" open="(" separator="or" close=")">
  2151. "consigneeWarrantyAmount" like '%${item}%'
  2152. </foreach>
  2153. </if>
  2154. <if test="consigneeWarrantyWeight != null">
  2155. and
  2156. <foreach collection="consigneeWarrantyWeight" item="item" open="(" separator="or" close=")">
  2157. "consigneeWarrantyWeight" like '%${item}%'
  2158. </foreach>
  2159. </if>
  2160. <if test="saleOrderIsselfMention != null">
  2161. and
  2162. <foreach collection="saleOrderIsselfMention" item="item" open="(" separator="or" close=")">
  2163. "saleOrderIsselfMention" like '%${item}%'
  2164. </foreach>
  2165. </if>
  2166. <if test="saleAccountBalance != null">
  2167. and
  2168. <foreach collection="saleAccountBalance" item="item" open="(" separator="or" close=")">
  2169. "saleAccountBalance" like '%${item}%'
  2170. </foreach>
  2171. </if>
  2172. <if test="saleCurrentOrderAmount != null">
  2173. and
  2174. <foreach collection="saleCurrentOrderAmount" item="item" open="(" separator="or" close=")">
  2175. "saleCurrentOrderAmount" like '%${item}%'
  2176. </foreach>
  2177. </if>
  2178. <if test="saleHistoricalOrderAmout != null">
  2179. and
  2180. <foreach collection="saleHistoricalOrderAmout" item="item" open="(" separator="or" close=")">
  2181. "saleHistoricalOrderAmout" like '%${item}%'
  2182. </foreach>
  2183. </if>
  2184. <if test="saleOrderReceiveCustomer != null">
  2185. and
  2186. <foreach collection="saleOrderReceiveCustomer" item="item" open="(" separator="or" close=")">
  2187. "saleOrderReceiveCustomer" like '%${item}%'
  2188. </foreach>
  2189. </if>
  2190. <if test="saleUnitPrice != null">
  2191. and
  2192. <foreach collection="saleUnitPrice" item="item" open="(" separator="or" close=")">
  2193. "saleUnitPrice" like '%${item}%'
  2194. </foreach>
  2195. </if>
  2196. <if test="saleOrderTax != null">
  2197. and
  2198. <foreach collection="saleOrderTax" item="item" open="(" separator="or" close=")">
  2199. "saleOrderTax" like '%${item}%'
  2200. </foreach>
  2201. </if>
  2202. <if test="saleRemark != null">
  2203. and
  2204. <foreach collection="saleRemark" item="item" open="(" separator="or" close=")">
  2205. "saleRemark" like '%${item}%'
  2206. </foreach>
  2207. </if>
  2208. </where>
  2209. <include refid="orderBy"></include>
  2210. </select>
  2211. <select id="getSaleOrderAndMaterialById" resultType="java.util.Map" parameterType="java.util.Map">
  2212. SELECT *
  2213. FROM (
  2214. select ASO.SALE_ORDER_ID as "saleOrderId",
  2215. ASM.SALE_MATERIAL_ID as "saleMaterialId",
  2216. RM.MATERIAL_ID as "materialId",
  2217. ASO.SALE_NUMBER as "saleNumber",
  2218. ASO.SALE_ORDER_ISSELF_MENTION as "saleOrderIsselfMention",
  2219. ASO.SALE_REMARK as "saleRemark",
  2220. RS.SHIPPER_NAME as "shipperName",
  2221. RC.CONSIGNEE_COMPANY_NAME as "consigneeCompanyName",
  2222. RM.MATERIAL_NAME as "materialName",
  2223. ASM.MATERIAL_NUMBER as "materialNumber",
  2224. ASM.MATERIAL_WEIGHT as "materialWeight",
  2225. ASM.SALE_WAREHOUSE as "saleWareHouse",
  2226. RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL as "specificationModel",
  2227. RM.MATERIAL_CODE as "materialCode",
  2228. nvl(sumWeight.weight,0)+nvl(sumWeight2.weight,0) as "totalWeight",
  2229. nvl(sumWeight.weight ,0) as "netWeight",
  2230. nvl(sumWeight2.weight ,0) as "weight",
  2231. nvl(carCount.coun ,0) as "carCount"
  2232. from AMS_SALE_ORDER ASO
  2233. left join RMS_SHIPPER RS
  2234. on ASO.SHIPPER_ID = RS.SHIPPER_ID
  2235. left join RMS_CONSIGNEE RC
  2236. on ASO.RECEIVE_ID = RC.CONSIGNEE_ID
  2237. left join AMS_SALE_MATERIAL ASM
  2238. on ASM.SALE_ORDER_ID = ASO.SALE_ORDER_ID
  2239. left join RMS_MATERIAL RM
  2240. on RM.MATERIAL_ID = ASM.MATERIAL_ID
  2241. left join (
  2242. select sum( t_w_result.RESULT_NET_WEIGHT) weight,a_s_o_material.SALE_ORDER_ID SALE_ORDER_ID
  2243. from AMS_SALE_ORDER_MATERIAL a_s_o_material
  2244. left join Omstruck_Order o_order
  2245. on a_s_o_material.SALE_ORDER_MATERIAL_ID=o_order.order_plan_id
  2246. left join Tmstruck_Total_Result t_t_result
  2247. on o_order.order_id=t_t_result.order_id
  2248. left join Tmstruck_Weight_Result t_w_result
  2249. on t_t_result.result_total_id=t_w_result.result_total_id
  2250. GROUP BY
  2251. a_s_o_Material.SALE_ORDER_ID
  2252. ) sumWeight
  2253. on sumWeight.SALE_ORDER_ID=ASO.SALE_ORDER_ID
  2254. left join (
  2255. select sum( o_o_material.ORDER_MATERIAL_WEIGHT) weight,a_s_o_Material.SALE_ORDER_ID SALE_ORDER_ID
  2256. from AMS_SALE_ORDER_MATERIAL a_s_o_material
  2257. left join Omstruck_Order o_order
  2258. on a_s_o_material.SALE_ORDER_MATERIAL_ID=o_order.order_plan_id
  2259. left join Tmstruck_Total_Result t_t_result
  2260. on o_order.order_id=t_t_result.order_id
  2261. left join Tmstruck_Weight_Result t_w_result
  2262. on t_t_result.result_total_id=t_w_result.result_total_id
  2263. left join OMSTRUCK_ORDER_MATERIAL o_o_material
  2264. on o_order.order_id=o_o_material.ORDER_ID
  2265. where t_w_result.RESULT_NET_WEIGHT is null and o_order.order_status in (2,4,5)
  2266. GROUP BY
  2267. a_s_o_Material.SALE_ORDER_ID
  2268. ) sumWeight2
  2269. on sumWeight2.SALE_ORDER_ID=ASO.SALE_ORDER_ID
  2270. left join (
  2271. select count(o_order.order_id) coun ,a_s_o_Material.SALE_ORDER_ID SALE_ORDER_ID
  2272. from AMS_SALE_ORDER_MATERIAL a_s_o_material
  2273. left join Omstruck_Order o_order
  2274. on a_s_o_material.SALE_ORDER_MATERIAL_ID=o_order.order_plan_id
  2275. left join Tmstruck_Total_Result t_t_result
  2276. on o_order.order_id=t_t_result.order_id
  2277. left join Tmstruck_Weight_Result t_w_result
  2278. on t_t_result.result_total_id=t_w_result.result_total_id
  2279. where o_order.order_status in (2,4,5)
  2280. GROUP BY
  2281. a_s_o_Material.SALE_ORDER_ID
  2282. ) carCount
  2283. on carCount.SALE_ORDER_ID=ASO.SALE_ORDER_ID
  2284. where ASO.SALE_ORDER_ID = #{saleOrderId}
  2285. )
  2286. <where>
  2287. <if test="saleNumber != null">
  2288. and
  2289. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  2290. "saleNumber" like '%${item}%'
  2291. </foreach>
  2292. </if>
  2293. <if test="shipperName != null">
  2294. and
  2295. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  2296. "shipperName" like '%${item}%'
  2297. </foreach>
  2298. </if>
  2299. <if test="consigneeCompanyName != null">
  2300. and
  2301. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  2302. "consigneeCompanyName" like '%${item}%'
  2303. </foreach>
  2304. </if>
  2305. <if test="materialName != null">
  2306. and
  2307. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  2308. "materialName" like '%${item}%'
  2309. </foreach>
  2310. </if>
  2311. <if test="specificationModel != null">
  2312. and
  2313. <foreach collection="specificationModel" item="item" open="(" separator="or" close=")">
  2314. "specificationModel" like '%${item}%'
  2315. </foreach>
  2316. </if>
  2317. <if test="materialCode != null">
  2318. and
  2319. <foreach collection="materialCode" item="item" open="(" separator="or" close=")">
  2320. "materialCode" like '%${item}%'
  2321. </foreach>
  2322. </if>
  2323. </where>
  2324. </select>
  2325. <select id="getSaleOrderAndMaterialById2" resultType="java.util.Map" parameterType="java.util.Map">
  2326. SELECT *
  2327. FROM (
  2328. select ASO.SALE_ORDER_ID as "saleOrderId",
  2329. ASM.SALE_MATERIAL_ID as "saleMaterialId",
  2330. RM.MATERIAL_ID as "materialId",
  2331. ASO.SALE_NUMBER as "saleNumber",
  2332. ASO.SALE_ORDER_ISSELF_MENTION as "saleOrderIsselfMention",
  2333. RS.SHIPPER_NAME as "shipperName",
  2334. RC.CONSIGNEE_COMPANY_NAME as "consigneeCompanyName",
  2335. RM.MATERIAL_NAME as "materialName",
  2336. ASM.MATERIAL_NUMBER as "materialNumber",
  2337. ASM.MATERIAL_WEIGHT as "materialWeight",
  2338. RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL as "specificationModel",
  2339. RM.MATERIAL_CODE as "materialCode"
  2340. from AMS_SALE_ORDER ASO
  2341. left join RMS_SHIPPER RS
  2342. on ASO.SHIPPER_ID = RS.SHIPPER_ID
  2343. left join RMS_CONSIGNEE RC
  2344. on ASO.RECEIVE_ID = RC.CONSIGNEE_ID
  2345. left join AMS_SALE_MATERIAL ASM
  2346. on ASM.SALE_ORDER_ID = ASO.SALE_ORDER_ID
  2347. left join RMS_MATERIAL RM
  2348. on RM.MATERIAL_ID = ASM.MATERIAL_ID
  2349. where ASO.SALE_ORDER_ID = #{saleOrderId}
  2350. )
  2351. <where>
  2352. <if test="saleNumber != null">
  2353. and
  2354. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  2355. "saleNumber" like '%${item}%'
  2356. </foreach>
  2357. </if>
  2358. <if test="shipperName != null">
  2359. and
  2360. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  2361. "shipperName" like '%${item}%'
  2362. </foreach>
  2363. </if>
  2364. <if test="consigneeCompanyName != null">
  2365. and
  2366. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  2367. "consigneeCompanyName" like '%${item}%'
  2368. </foreach>
  2369. </if>
  2370. <if test="materialName != null">
  2371. and
  2372. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  2373. "materialName" like '%${item}%'
  2374. </foreach>
  2375. </if>
  2376. <if test="specificationModel != null">
  2377. and
  2378. <foreach collection="specificationModel" item="item" open="(" separator="or" close=")">
  2379. "specificationModel" like '%${item}%'
  2380. </foreach>
  2381. </if>
  2382. <if test="materialCode != null">
  2383. and
  2384. <foreach collection="materialCode" item="item" open="(" separator="or" close=")">
  2385. "materialCode" like '%${item}%'
  2386. </foreach>
  2387. </if>
  2388. </where>
  2389. </select>
  2390. <select id="getSaleMaterial" parameterType="java.util.Map" resultType="java.util.Map">
  2391. SELECT * FROM (SELECT
  2392. RM.MATERIAL_NAME AS "materialName",
  2393. ASM.SALE_WAREHOUSE AS "saleWareHouse"
  2394. FROM AMS_SALE_MATERIAL ASM
  2395. LEFT JOIN RMS_MATERIAL RM
  2396. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  2397. WHERE ASM.SALE_ORDER_ID = #{saleOrderId}
  2398. <if test="con != null">
  2399. AND instr(RM.MATERIAL_NAME, #{con}) > 0
  2400. </if>
  2401. )
  2402. <where>
  2403. <if test="materialName != null">
  2404. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  2405. "materialName" like '%${item}%'
  2406. </foreach>
  2407. </if>
  2408. </where>
  2409. </select>
  2410. <select id="getNetWeight" parameterType="DECIMAL" resultType="DECIMAL">
  2411. SELECT SUM(twr.RESULT_NET_WEIGHT)
  2412. FROM AMS_SALE_ORDER_MATERIAL asom
  2413. left join OMSTRUCK_ORDER oo on oo.ORDER_PLAN_ID = asom.SALE_ORDER_MATERIAL_ID
  2414. left join TMSTRUCK_TOTAL_RESULT ttr on ttr.ORDER_ID = oo.ORDER_ID
  2415. left join TMSTRUCK_WEIGHT_RESULT twr on twr.RESULT_TOTAL_ID = ttr.RESULT_TOTAL_ID
  2416. where asom.sale_order_id = #{saleOrderId}
  2417. </select>
  2418. <select id="getCarNum" parameterType="DECIMAL" resultType="DECIMAL">
  2419. SELECT COUNT(ASOM.SALE_ORDER_MATERIAL_ID)
  2420. FROM AMS_SALE_ORDER_MATERIAL ASOM
  2421. WHERE ASOM.SALE_ORDER_ID = #{saleOrderId}
  2422. </select>
  2423. <select id="getTruckNoAndMaterial" parameterType="java.util.Map" resultType="java.util.Map" >
  2424. SELECT DISTINCT ASOM.SALE_ORDER_MATERIAL_TRUCK_NO AS "truckNo",
  2425. RM.MATERIAL_NAME AS "materialName",
  2426. ASM.MATERIAL_ID AS "materialId",
  2427. ASM.MATERIAL_NUMBER AS "materialNumber",
  2428. ASM.MATERIAL_WEIGHT AS "materialWeight",
  2429. ASOM.SALE_DATE_OF_RECEIPT AS "receiptDate",
  2430. RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL AS "materialModelSpecification",
  2431. RM.MATERIAL_CODE AS "materialCode",
  2432. RRA.ADDRESS_PROVINCE || RRA.ADDRESS_DISTRICT || RRA.ADDRESS_TOWN ||
  2433. RRP.ADDRESS_DELIVERY_ADDRESS AS "place",
  2434. ASOM.SALE_DATE_OF_RECEIPT AS "receiptDate",
  2435. ASOM.SALE_ORDER_CONSIGNEE_TEL AS "saleOrderConsigneeTel",
  2436. ASOM.SALE_ORDER_CONSIGNEE AS "saleOrderConsignee",
  2437. ASOM.SALE_ORDER_MATERIAL_ID AS "saleOrderMaterialId",
  2438. ASOM.SALE_SHIPPING_ADDRESS_ID AS "placeId",
  2439. RC.CAPACITY_NUMBER AS "capacityNumber",
  2440. ADSO.CARRIER_ID AS "carrierId",
  2441. RCA.CARRIER_NAME AS "carrierName",
  2442. ASOM.TRUCK_REMARK AS "truckRemark",
  2443. DECODE(ASO.SALE_ORDER_STATUS,1,'订单已上报',2,'销售已提交',4,'财务已审批') "statusStr"
  2444. FROM AMS_SALE_TRUCKNO_MATERIAL ASTM
  2445. LEFT JOIN AMS_SALE_ORDER_MATERIAL ASOM
  2446. ON ASOM.SALE_ORDER_MATERIAL_ID = ASTM.SALE_ORDER_MATERIAL_ID
  2447. LEFT JOIN AMS_SALE_ORDER ASO
  2448. ON ASO.SALE_ORDER_ID = ASOM.SALE_ORDER_ID
  2449. LEFT JOIN RMS_RECEIVE_PLACE RRP
  2450. ON RRP.PLACE_ID = ASOM.SALE_SHIPPING_ADDRESS_ID
  2451. LEFT JOIN RMS_RECEIVE_ADDRESS RRA
  2452. ON RRA.ADDRESS_ID = RRP.ADDRESS_ID
  2453. LEFT JOIN AMS_SALE_MATERIAL ASM
  2454. ON ASTM.MATERIAL_ID = ASM.SALE_MATERIAL_ID
  2455. LEFT JOIN RMS_MATERIAL RM
  2456. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  2457. LEFT JOIN OMSTRUCK_ORDER OO
  2458. ON OO.ORDER_PLAN_ID = ASOM.SALE_ORDER_MATERIAL_ID
  2459. LEFT JOIN RMS_CAPACITY RC
  2460. ON RC.CAPACITY_ID = OO.CAPACITY_ID
  2461. LEFT JOIN AMS_DISPATCH_SALE_ORDER ADSO
  2462. ON ADSO.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  2463. LEFT JOIN RMS_CARRIER RCA
  2464. ON RCA.CARRIER_ID = ADSO.CARRIER_ID
  2465. WHERE ASOM.SALE_ORDER_ID = #{saleOrderId}
  2466. <if test="carrierSsoId != null">
  2467. AND RCA.CARRIER_SSO_ID = #{carrierSsoId}
  2468. </if>
  2469. AND OO.ORDER_ID IS NULL
  2470. AND ADSO.DISPATCH_ID IS NOT NULL
  2471. AND ASM.DELETED IS NULL
  2472. ORDER BY ASOM.SALE_ORDER_MATERIAL_TRUCK_NO ASC
  2473. </select>
  2474. <select id="getAddressByPlace" parameterType="DECIMAL" resultType="DECIMAL" >
  2475. SELECT RRP.ADDRESS_ID AS "adddressId"
  2476. FROM RMS_RECEIVE_PLACE RRP
  2477. WHERE RRP.PLACE_ID = #{placeId}
  2478. </select>
  2479. <select id="getCarrierByPlace" parameterType="DECIMAL" resultType="java.util.Map">
  2480. SELECT DISTINCT RC.CARRIER_ID AS "id",
  2481. RC.CARRIER_ID AS "value",
  2482. RC.CARRIER_NAME AS "label",
  2483. ACTP.PRICE_ID AS "priceId",
  2484. ACTP.PRICE_VALUE AS "priceValue"
  2485. FROM RMS_RECEIVE_PLACE RRP
  2486. LEFT JOIN AMS_CONTRACT_TRANSPORT_PRICE ACTP
  2487. ON ACTP.PLACE_ID = RRP.PLACE_ID
  2488. LEFT JOIN RMS_CARRIER RC
  2489. ON RC.CARRIER_ID = ACTP.CARRIER_ID
  2490. WHERE RRP.PLACE_ID = #{placeId}
  2491. AND ACTP.CARRIER_ID IS NOT NULL
  2492. AND ACTP.DELETED = 0
  2493. ORDER BY ACTP.PRICE_VALUE DESC
  2494. </select>
  2495. <select id="getPriceByCarrierAndPlace" parameterType="java.util.Map" resultType="java.util.Map">
  2496. SELECT ACTP.PRICE_ID AS "priceId",
  2497. ACTP.PRICE_VALUE AS "priceValue"
  2498. FROM AMS_CONTRACT_TRANSPORT_PRICE ACTP
  2499. WHERE ACTP.CARRIER_ID = #{carrierId}
  2500. AND ACTP.PLACE_ID = #{placeId}
  2501. AND ACTP.DELETED = 0
  2502. </select>
  2503. <select id="getSaleOrderListToCarrier" parameterType="java.util.Map" resultType="java.util.Map">
  2504. SELECT * FROM (
  2505. select DISTINCT * from(
  2506. select a_s_order.SALE_ORDER_ID "saleOrderId",
  2507. a_s_order.SALE_NUMBER "saleNumber",
  2508. r_shipper.SHIPPER_NAME "shipperName",
  2509. r_consignee.CONSIGNEE_COMPANY_NAME "consigneeCompanyName",
  2510. r_consignee.CONSIGNEE_WARRANTY_AMOUNT "consigneeWarrantyAmount",
  2511. r_consignee.CONSIGNEE_WARRANTY_WEIGHT "consigneeWarrantyWeight",
  2512. a_s_order.SALE_ORDER_ISSELF_MENTION "saleOrderIsselfMention",
  2513. a_s_order.SALE_ACCOUNT_BALANCE "saleAccountBalance",
  2514. a_s_order.SALE_CURRENT_ORDER_AMOUNT "saleCurrentOrderAmount",
  2515. a_s_order.SALE_HISTORICAL_ORDER_AMOUNT "saleHistoricalOrderAmout",
  2516. a_s_order.SALE_ORDER_RECEIVE_CUSTOMER "saleOrderReceiveCustomer",
  2517. a_s_order.SALE_UNIT_PRICE "saleUnitPrice",
  2518. a_s_order.SALE_ORDER_TAX "saleOrderTax",
  2519. a_s_order.SALE_REMARK "saleRemark",
  2520. a_s_order.INSERT_TIME "insertTime",
  2521. DECODE(a_s_order.SALE_ORDER_STATUS,1,'订单已上报',2,'销售已提交',4,'财务已审批') "statusStr",
  2522. a_s_order.UPDATE_TIME "updateTime",
  2523. RM.MATERIAL_NAME "materialName",
  2524. RM.MATERIAL_SPECIFICATION "materialSpecification",
  2525. RM.MATERIAL_MODEL "materialModel",
  2526. RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL "specificationModel",
  2527. ASM.MATERIAL_NUMBER "materialNumber",
  2528. RM.MATERIAL_NAME || RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL "nameSpecificationModel"
  2529. from AMS_SALE_ORDER a_s_order
  2530. left join RMS_SHIPPER r_shipper
  2531. on a_s_order.SHIPPER_ID=r_shipper.SHIPPER_ID
  2532. left join RMS_CONSIGNEE r_consignee
  2533. on a_s_order.RECEIVE_ID=r_consignee.CONSIGNEE_ID
  2534. LEFT JOIN AMS_SALE_ORDER_MATERIAL ASOM
  2535. ON ASOM.SALE_ORDER_ID = a_s_order.SALE_ORDER_ID
  2536. LEFT JOIN AMS_SALE_TRUCKNO_MATERIAL ASTM
  2537. ON ASTM.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  2538. LEFT JOIN AMS_DISPATCH_SALE_ORDER ADSO
  2539. ON ADSO.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  2540. LEFT JOIN RMS_CARRIER RC
  2541. ON RC.CARRIER_ID = ADSO.CARRIER_ID
  2542. LEFT JOIN OMSTRUCK_ORDER OO
  2543. ON OO.ORDER_PLAN_ID = ASOM.SALE_ORDER_MATERIAL_ID
  2544. LEFT JOIN AMS_SALE_MATERIAL ASM
  2545. ON ASM.SALE_MATERIAL_ID = ASTM.MATERIAL_ID
  2546. LEFT JOIN RMS_MATERIAL RM
  2547. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  2548. where a_s_order.SALE_ORDER_STATUS in (1,2,4)
  2549. and a_s_order.CLOSE_STATUS is null
  2550. and a_s_order.DELETED = 0
  2551. and ADSO.DISPATCH_TYPE = 2
  2552. and OO.ORDER_ID IS NULL
  2553. AND ASM.DELETED IS NULL
  2554. <if test="oneDate != null">
  2555. and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt; = a_s_order.INSERT_TIME
  2556. </if>
  2557. <if test="startDate != null">
  2558. and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= a_s_order.INSERT_TIME
  2559. and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >= a_s_order.INSERT_TIME
  2560. </if>
  2561. <if test="carrierSsoId != null" >
  2562. and RC.CARRIER_SSO_ID = #{carrierSsoId}
  2563. </if>
  2564. ) "CARRIER"
  2565. <where>
  2566. <if test="con != null">
  2567. "CARRIER"."consigneeCompanyName" LIKE #{con} or "CARRIER"."saleNumber" LIKE #{con} or "CARRIER"."saleRemark" LIKE #{con}
  2568. </if>
  2569. </where>
  2570. )
  2571. <where>
  2572. <if test="saleNumber != null">
  2573. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  2574. "saleNumber" like '%${item}%'
  2575. </foreach>
  2576. </if>
  2577. <if test="materialName != null">
  2578. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  2579. "materialName" like '%${item}%'
  2580. </foreach>
  2581. </if>
  2582. <if test="materialSpecification != null">
  2583. <foreach collection="materialSpecification" item="item" open="(" separator="or" close=")">
  2584. "materialSpecification" like '%${item}%'
  2585. </foreach>
  2586. </if>
  2587. <if test="materialModel != null">
  2588. <foreach collection="materialModel" item="item" open="(" separator="or" close=")">
  2589. "materialModel" like '%${item}%'
  2590. </foreach>
  2591. </if>
  2592. <if test="shipperName != null">
  2593. and
  2594. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  2595. "shipperName" like '%${item}%'
  2596. </foreach>
  2597. </if>
  2598. <if test="consigneeCompanyName != null">
  2599. and
  2600. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  2601. "consigneeCompanyName" like '%${item}%'
  2602. </foreach>
  2603. </if>
  2604. <if test="consigneeWarrantyAmount != null">
  2605. and
  2606. <foreach collection="consigneeWarrantyAmount" item="item" open="(" separator="or" close=")">
  2607. "consigneeWarrantyAmount" like '%${item}%'
  2608. </foreach>
  2609. </if>
  2610. <if test="consigneeWarrantyWeight != null">
  2611. and
  2612. <foreach collection="consigneeWarrantyWeight" item="item" open="(" separator="or" close=")">
  2613. "consigneeWarrantyWeight" like '%${item}%'
  2614. </foreach>
  2615. </if>
  2616. <if test="saleOrderIsselfMention != null">
  2617. and
  2618. <foreach collection="saleOrderIsselfMention" item="item" open="(" separator="or" close=")">
  2619. "saleOrderIsselfMention" like '%${item}%'
  2620. </foreach>
  2621. </if>
  2622. <if test="saleAccountBalance != null">
  2623. and
  2624. <foreach collection="saleAccountBalance" item="item" open="(" separator="or" close=")">
  2625. "saleAccountBalance" like '%${item}%'
  2626. </foreach>
  2627. </if>
  2628. <if test="saleCurrentOrderAmount != null">
  2629. and
  2630. <foreach collection="saleCurrentOrderAmount" item="item" open="(" separator="or" close=")">
  2631. "saleCurrentOrderAmount" like '%${item}%'
  2632. </foreach>
  2633. </if>
  2634. <if test="saleHistoricalOrderAmout != null">
  2635. and
  2636. <foreach collection="saleHistoricalOrderAmout" item="item" open="(" separator="or" close=")">
  2637. "saleHistoricalOrderAmout" like '%${item}%'
  2638. </foreach>
  2639. </if>
  2640. <if test="saleOrderReceiveCustomer != null">
  2641. and
  2642. <foreach collection="saleOrderReceiveCustomer" item="item" open="(" separator="or" close=")">
  2643. "saleOrderReceiveCustomer" like '%${item}%'
  2644. </foreach>
  2645. </if>
  2646. <if test="saleUnitPrice != null">
  2647. and
  2648. <foreach collection="saleUnitPrice" item="item" open="(" separator="or" close=")">
  2649. "saleUnitPrice" like '%${item}%'
  2650. </foreach>
  2651. </if>
  2652. <if test="saleOrderTax != null">
  2653. and
  2654. <foreach collection="saleOrderTax" item="item" open="(" separator="or" close=")">
  2655. "saleOrderTax" like '%${item}%'
  2656. </foreach>
  2657. </if>
  2658. <if test="saleRemark != null">
  2659. and
  2660. <foreach collection="saleRemark" item="item" open="(" separator="or" close=")">
  2661. "saleRemark" like '%${item}%'
  2662. </foreach>
  2663. </if>
  2664. </where>
  2665. order by "updateTime" DESC
  2666. </select>
  2667. <select id="getSaleOrderListByCarrierSsoId" resultType="java.util.Map">
  2668. select * from(
  2669. select a_s_order.SALE_ORDER_ID "saleOrderId",
  2670. a_s_order.SALE_NUMBER "saleNumber",
  2671. r_shipper.SHIPPER_NAME "shipperName",
  2672. r_consignee.CONSIGNEE_COMPANY_NAME "consigneeCompanyName",
  2673. r_consignee.CONSIGNEE_WARRANTY_AMOUNT "consigneeWarrantyAmount",
  2674. r_consignee.CONSIGNEE_WARRANTY_WEIGHT "consigneeWarrantyWeight",
  2675. a_s_order.SALE_ORDER_ISSELF_MENTION "saleOrderIsselfMention",
  2676. a_s_order.SALE_ACCOUNT_BALANCE "saleAccountBalance",
  2677. a_s_order.SALE_CURRENT_ORDER_AMOUNT "saleCurrentOrderAmount",
  2678. a_s_order.SALE_HISTORICAL_ORDER_AMOUNT "saleHistoricalOrderAmout",
  2679. a_s_order.SALE_ORDER_RECEIVE_CUSTOMER "saleOrderReceiveCustomer",
  2680. a_s_order.SALE_UNIT_PRICE "saleUnitPrice",
  2681. a_s_order.SALE_ORDER_TAX "saleOrderTax",
  2682. a_s_order.SALE_REMARK "saleRemark",
  2683. a_s_order.INSERT_TIME "insertTime",
  2684. a_s_order.SALE_ORDER_STATUS "saleOrderStatus",
  2685. DECODE(a_s_order.SALE_ORDER_STATUS,2,'销售已提交',4,'财务已审批') "statusStr",
  2686. RM.MATERIAL_NAME "materialName",
  2687. RM.MATERIAL_SPECIFICATION "materialSpecification",
  2688. RM.MATERIAL_MODEL "materialModel",
  2689. RM.MATERIAL_NAME || RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL "nameSpecificationModel"
  2690. from AMS_SALE_ORDER_CARRIER a_s_o_carrier
  2691. left join RMS_CARRIER r_carrier
  2692. on r_carrier.CARRIER_ID=a_s_o_carrier.CARRIER_ID
  2693. left join AMS_SALE_ORDER a_s_order
  2694. on a_s_o_carrier.SALE_ORDER_ID=a_s_order.SALE_ORDER_ID
  2695. left join RMS_SHIPPER r_shipper
  2696. on a_s_order.SHIPPER_ID=r_shipper.SHIPPER_ID
  2697. left join RMS_CONSIGNEE r_consignee
  2698. on a_s_order.RECEIVE_ID=r_consignee.CONSIGNEE_ID
  2699. LEFT JOIN AMS_SALE_MATERIAL ASM
  2700. ON ASM.SALE_ORDER_ID = a_s_order.SALE_ORDER_ID
  2701. LEFT JOIN RMS_MATERIAL RM
  2702. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  2703. where a_s_order.SALE_ORDER_STATUS in (2,4)
  2704. and a_s_order.CLOSE_STATUS is null
  2705. and a_s_order.DELETED = 0
  2706. <if test="carrierSsoId != null">
  2707. and r_carrier.CARRIER_SSO_ID=#{carrierSsoId}
  2708. </if>
  2709. <if test="con != null">
  2710. and (instr(r_consignee.CONSIGNEE_COMPANY_NAME, #{con}) > 0 or instr(a_s_order.SALE_NUMBER, #{con}) > 0)
  2711. </if>
  2712. )
  2713. <where>
  2714. <if test="saleNumber != null">
  2715. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  2716. "saleNumber" like '%${item}%'
  2717. </foreach>
  2718. </if>
  2719. <if test="materialName != null">
  2720. and
  2721. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  2722. "materialName" like '%${item}%'
  2723. </foreach>
  2724. </if>
  2725. <if test="materialSpecification != null">
  2726. and
  2727. <foreach collection="materialSpecification" item="item" open="(" separator="or" close=")">
  2728. "materialSpecification" like '%${item}%'
  2729. </foreach>
  2730. </if>
  2731. <if test="materialModel != null">
  2732. and
  2733. <foreach collection="materialModel" item="item" open="(" separator="or" close=")">
  2734. "materialModel" like '%${item}%'
  2735. </foreach>
  2736. </if>
  2737. <if test="shipperName != null">
  2738. and
  2739. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  2740. "shipperName" like '%${item}%'
  2741. </foreach>
  2742. </if>
  2743. <if test="consigneeCompanyName != null">
  2744. and
  2745. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  2746. "consigneeCompanyName" like '%${item}%'
  2747. </foreach>
  2748. </if>
  2749. <if test="consigneeWarrantyAmount != null">
  2750. and
  2751. <foreach collection="consigneeWarrantyAmount" item="item" open="(" separator="or" close=")">
  2752. "consigneeWarrantyAmount" like '%${item}%'
  2753. </foreach>
  2754. </if>
  2755. <if test="consigneeWarrantyWeight != null">
  2756. and
  2757. <foreach collection="consigneeWarrantyWeight" item="item" open="(" separator="or" close=")">
  2758. "consigneeWarrantyWeight" like '%${item}%'
  2759. </foreach>
  2760. </if>
  2761. <if test="saleOrderIsselfMention != null">
  2762. and
  2763. <foreach collection="saleOrderIsselfMention" item="item" open="(" separator="or" close=")">
  2764. "saleOrderIsselfMention" like '%${item}%'
  2765. </foreach>
  2766. </if>
  2767. <if test="saleAccountBalance != null">
  2768. and
  2769. <foreach collection="saleAccountBalance" item="item" open="(" separator="or" close=")">
  2770. "saleAccountBalance" like '%${item}%'
  2771. </foreach>
  2772. </if>
  2773. <if test="saleCurrentOrderAmount != null">
  2774. and
  2775. <foreach collection="saleCurrentOrderAmount" item="item" open="(" separator="or" close=")">
  2776. "saleCurrentOrderAmount" like '%${item}%'
  2777. </foreach>
  2778. </if>
  2779. <if test="saleHistoricalOrderAmout != null">
  2780. and
  2781. <foreach collection="saleHistoricalOrderAmout" item="item" open="(" separator="or" close=")">
  2782. "saleHistoricalOrderAmout" like '%${item}%'
  2783. </foreach>
  2784. </if>
  2785. <if test="saleOrderReceiveCustomer != null">
  2786. and
  2787. <foreach collection="saleOrderReceiveCustomer" item="item" open="(" separator="or" close=")">
  2788. "saleOrderReceiveCustomer" like '%${item}%'
  2789. </foreach>
  2790. </if>
  2791. <if test="saleUnitPrice != null">
  2792. and
  2793. <foreach collection="saleUnitPrice" item="item" open="(" separator="or" close=")">
  2794. "saleUnitPrice" like '%${item}%'
  2795. </foreach>
  2796. </if>
  2797. <if test="saleOrderTax != null">
  2798. and
  2799. <foreach collection="saleOrderTax" item="item" open="(" separator="or" close=")">
  2800. "saleOrderTax" like '%${item}%'
  2801. </foreach>
  2802. </if>
  2803. <if test="saleRemark != null">
  2804. and
  2805. <foreach collection="saleRemark" item="item" open="(" separator="or" close=")">
  2806. "saleRemark" like '%${item}%'
  2807. </foreach>
  2808. </if>
  2809. </where>
  2810. <include refid="orderBy1"></include>
  2811. </select>
  2812. <select id="getSteelTruckNoList" parameterType="java.util.Map" resultType="java.util.Map">
  2813. SELECT *
  2814. FROM (
  2815. SELECT ASO.SALE_NUMBER AS "saleNumber",
  2816. ASOM.SALE_ORDER_MATERIAL_TRUCK_NO AS "truckNo",
  2817. RRA.ADDRESS_PROVINCE || RRA.ADDRESS_DISTRICT || RRA.ADDRESS_TOWN || RRP.ADDRESS_DELIVERY_ADDRESS AS
  2818. "addressDeliveryAddress",
  2819. ASOM.SALE_DATE_OF_RECEIPT AS "saleDateOfReceipt",
  2820. DECODE(ASO.SALE_ORDER_STATUS,1,'订单已上报',2, '销售已提交',4, '财务已审批')
  2821. AS "approvalStatus",
  2822. ASOM.SALE_ORDER_CONSIGNEE_TEL AS "saleOrderConsigneeTel",
  2823. RSH.SHIPPER_NAME AS "shipperName",
  2824. RCO.CONSIGNEE_COMPANY_NAME AS "consigneeCompanyName",
  2825. ASO.SALE_ORDER_ISSELF_MENTION AS "isselfMention",
  2826. ASOM.INSERT_TIME AS "insertTime",
  2827. ASOM.SALE_ORDER_MATERIAL_ID AS "saleOrderMaterialId",
  2828. ASO.SALE_ORDER_ID AS "saleOrderId",
  2829. RM.MATERIAL_NAME AS "materialName",
  2830. RM.MATERIAL_SPECIFICATION AS "materialSpecification",
  2831. RM.MATERIAL_MODEL AS "materialModel",
  2832. RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL AS "specificationModel",
  2833. ASM.MATERIAL_NUMBER AS "materialNumber",
  2834. RM.MATERIAL_NAME || RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL AS "nameSpecificationModel"
  2835. FROM AMS_SALE_ORDER_MATERIAL ASOM
  2836. LEFT JOIN AMS_SALE_ORDER ASO
  2837. ON ASO.SALE_ORDER_ID = ASOM.SALE_ORDER_ID
  2838. LEFT JOIN AMS_SALE_TRUCKNO_MATERIAL ASTM
  2839. ON ASTM.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  2840. LEFT JOIN RMS_RECEIVE_PLACE RRP
  2841. ON RRP.PLACE_ID = ASOM.SALE_SHIPPING_ADDRESS_ID
  2842. LEFT JOIN RMS_RECEIVE_ADDRESS RRA
  2843. ON RRA.ADDRESS_ID = RRP.ADDRESS_ID
  2844. LEFT JOIN RMS_SHIPPER RSH
  2845. ON RSH.SHIPPER_ID = ASO.SHIPPER_ID
  2846. LEFT JOIN RMS_CONSIGNEE RCO
  2847. ON RCO.CONSIGNEE_ID = ASO.RECEIVE_ID
  2848. LEFT JOIN AMS_DISPATCH_SALE_ORDER ADSO
  2849. ON ADSO.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  2850. LEFT JOIN AMS_SALE_MATERIAL ASM
  2851. ON ASM.SALE_MATERIAL_ID = ASTM.MATERIAL_ID
  2852. LEFT JOIN RMS_MATERIAL RM
  2853. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  2854. WHERE ASO.SALE_ORDER_STATUS IN (1,2,4)
  2855. AND ASOM.ISSUE_STATUS IS NULL
  2856. AND ADSO.CARRIER_ID IS NULL
  2857. AND ASO.DELETED = 0
  2858. AND ASM.DELETED IS NULL
  2859. <if test="oneDate != null">
  2860. and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt; = ASO.INSERT_TIME
  2861. </if>
  2862. <if test="startDate != null">
  2863. and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= ASO.INSERT_TIME
  2864. and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >= ASO.INSERT_TIME
  2865. </if>
  2866. <if test="con != null" >
  2867. AND RCO.CONSIGNEE_COMPANY_NAME LIKE #{con}
  2868. </if>
  2869. )
  2870. <where>
  2871. <if test="saleNumber != null">
  2872. and
  2873. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  2874. "saleNumber" like '%${item}%'
  2875. </foreach>
  2876. </if>
  2877. <if test="materialName != null">
  2878. and
  2879. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  2880. "materialName" like '%${item}%'
  2881. </foreach>
  2882. </if>
  2883. <if test="materialModel != null">
  2884. and
  2885. <foreach collection="materialModel" item="item" open="(" separator="or" close=")">
  2886. "materialModel" like '%${item}%'
  2887. </foreach>
  2888. </if>
  2889. <if test="materialSpecification != null">
  2890. and
  2891. <foreach collection="materialSpecification" item="item" open="(" separator="or" close=")">
  2892. "materialSpecification" like '%${item}%'
  2893. </foreach>
  2894. </if>
  2895. <if test="truckNo != null">
  2896. and
  2897. <foreach collection="truckNo" item="item" open="(" separator="or" close=")">
  2898. "truckNo" like '%${item}%'
  2899. </foreach>
  2900. </if>
  2901. <if test="addressDeliveryAddress != null">
  2902. and
  2903. <foreach collection="addressDeliveryAddress" item="item" open="(" separator="or" close=")">
  2904. "addressDeliveryAddress" like '%${item}%'
  2905. </foreach>
  2906. </if>
  2907. <if test="saleDateOfReceipt != null">
  2908. and
  2909. <foreach collection="saleDateOfReceipt" item="item" open="(" separator="or" close=")">
  2910. "saleDateOfReceipt" like '%${item}%'
  2911. </foreach>
  2912. </if>
  2913. <if test="saleOrderConsignee != null">
  2914. and
  2915. <foreach collection="saleOrderConsignee" item="item" open="(" separator="or" close=")">
  2916. "saleOrderConsignee" like '%${item}%'
  2917. </foreach>
  2918. </if>
  2919. <if test="saleOrderConsigneeTel != null">
  2920. and
  2921. <foreach collection="saleOrderConsigneeTel" item="item" open="(" separator="or" close=")">
  2922. "saleOrderConsigneeTel" like '%${item}%'
  2923. </foreach>
  2924. </if>
  2925. <if test="shipperName != null">
  2926. and
  2927. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  2928. "shipperName" like '%${item}%'
  2929. </foreach>
  2930. </if>
  2931. <if test="consigneeCompanyName != null">
  2932. and
  2933. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  2934. "consigneeCompanyName" like '%${item}%'
  2935. </foreach>
  2936. </if>
  2937. <if test="isselfMention != null">
  2938. and
  2939. <foreach collection="isselfMention" item="item" open="(" separator="or" close=")">
  2940. "isselfMention" like '%${item}%'
  2941. </foreach>
  2942. </if>
  2943. </where>
  2944. <include refid="orderBy"></include>
  2945. </select>
  2946. <select id="getTruckNoMaterial" resultType="java.util.Map" parameterType="DECIMAL" >
  2947. SELECT
  2948. RM.MATERIAL_ID AS "materialId",
  2949. RM.MATERIAL_NAME AS "materialName",
  2950. RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL AS "specificationModel",
  2951. RM.MATERIAL_CODE AS "materialCode",
  2952. ASTM.SALE_ORDER_MATERIAL_NUMBER AS "materialNumber"
  2953. FROM AMS_SALE_ORDER_MATERIAL ASOM
  2954. LEFT JOIN AMS_SALE_TRUCKNO_MATERIAL ASTM
  2955. ON ASTM.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  2956. LEFT JOIN AMS_SALE_MATERIAL ASM
  2957. ON ASM.SALE_MATERIAL_ID = ASTM.MATERIAL_ID
  2958. LEFT JOIN RMS_MATERIAL RM
  2959. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  2960. WHERE ASOM.SALE_ORDER_MATERIAL_ID = #{saleOrderMaterialId}
  2961. </select>
  2962. <select id="getCarrierTruckNoList" parameterType="java.util.Map" resultType="java.util.Map">
  2963. SELECT * FROM(
  2964. SELECT DISTINCT *
  2965. FROM (
  2966. SELECT ASO.SALE_NUMBER AS "saleNumber",
  2967. ASOM.SALE_ORDER_MATERIAL_TRUCK_NO AS "truckNo",
  2968. RRA.ADDRESS_PROVINCE || RRA.ADDRESS_DISTRICT || RRA.ADDRESS_TOWN || RRP.ADDRESS_DELIVERY_ADDRESS AS
  2969. "addressDeliveryAddress",
  2970. ASOM.SALE_DATE_OF_RECEIPT AS "saleDateOfReceipt",
  2971. DECODE(ASO.SALE_ORDER_STATUS,1,'订单已上报',2, '销售已提交',4, '财务已审批')
  2972. AS "approvalStatus",
  2973. ASOM.SALE_ORDER_CONSIGNEE_TEL AS "saleOrderConsigneeTel",
  2974. RSH.SHIPPER_NAME AS "shipperName",
  2975. RCO.CONSIGNEE_COMPANY_NAME AS "consigneeCompanyName",
  2976. ASO.SALE_ORDER_ISSELF_MENTION AS "isselfMention",
  2977. ASOM.INSERT_TIME AS "insertTime",
  2978. ASOM.SALE_ORDER_MATERIAL_ID AS "saleOrderMaterialId",
  2979. ASO.SALE_ORDER_ID AS "saleOrderId",
  2980. RCA.CARRIER_NAME AS "carrierName",
  2981. RM.MATERIAL_NAME || RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL AS "nameSpecificationModel",
  2982. RM.MATERIAL_NAME AS "materialName",
  2983. RM.MATERIAL_SPECIFICATION AS "materialSpecification",
  2984. RM.MATERIAL_MODEL AS "materialModel",
  2985. RM.MATERIAL_SPECIFICATION || MATERIAL_MODEL AS "specificationModel",
  2986. ASM.MATERIAL_NUMBER AS "materialNumber"
  2987. FROM AMS_SALE_ORDER_MATERIAL ASOM
  2988. LEFT JOIN AMS_SALE_ORDER ASO
  2989. ON ASO.SALE_ORDER_ID = ASOM.SALE_ORDER_ID
  2990. LEFT JOIN AMS_SALE_TRUCKNO_MATERIAL ASTM
  2991. ON ASTM.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  2992. LEFT JOIN RMS_RECEIVE_PLACE RRP
  2993. ON RRP.PLACE_ID = ASOM.SALE_SHIPPING_ADDRESS_ID
  2994. LEFT JOIN RMS_RECEIVE_ADDRESS RRA
  2995. ON RRA.ADDRESS_ID = RRP.ADDRESS_ID
  2996. LEFT JOIN RMS_SHIPPER RSH
  2997. ON RSH.SHIPPER_ID = ASO.SHIPPER_ID
  2998. LEFT JOIN RMS_CONSIGNEE RCO
  2999. ON RCO.CONSIGNEE_ID = ASO.RECEIVE_ID
  3000. LEFT JOIN AMS_DISPATCH_SALE_ORDER ADSO
  3001. ON ADSO.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  3002. LEFT JOIN OMSTRUCK_ORDER OO
  3003. ON OO.ORDER_PLAN_ID = ASOM.SALE_ORDER_MATERIAL_ID
  3004. LEFT JOIN RMS_CARRIER RCA
  3005. ON RCA.CARRIER_ID = ADSO.CARRIER_ID
  3006. LEFT JOIN AMS_SALE_MATERIAL ASM
  3007. ON ASM.SALE_MATERIAL_ID = ASTM.MATERIAL_ID
  3008. LEFT JOIN RMS_MATERIAL RM
  3009. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  3010. WHERE ASO.SALE_ORDER_STATUS IN (2,4)
  3011. AND ASOM.ISSUE_STATUS IS NULL
  3012. AND ADSO.DISPATCH_TYPE = 2
  3013. AND OO.ORDER_ID IS NULL
  3014. AND ASO.DELETED = 0
  3015. AND ASM.DELETED IS NULL
  3016. <if test="oneDate != null">
  3017. and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt; = ASO.INSERT_TIME
  3018. </if>
  3019. <if test="startDate != null">
  3020. and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= ASO.INSERT_TIME
  3021. and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >= ASO.INSERT_TIME
  3022. </if>
  3023. ) "NOCAR"
  3024. <where>
  3025. <if test="con != null" >
  3026. "NOCAR"."carrierName" LIKE #{con} or "NOCAR"."consigneeCompanyName" LIKE #{con} or "NOCAR"."addressDeliveryAddress" LIKE #{con}
  3027. </if>
  3028. </where>
  3029. )
  3030. <where>
  3031. <if test="saleNumber != null">
  3032. and
  3033. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  3034. "saleNumber" like '%${item}%'
  3035. </foreach>
  3036. </if>
  3037. <if test="materialName != null">
  3038. and
  3039. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  3040. "materialName" like '%${item}%'
  3041. </foreach>
  3042. </if>
  3043. <if test="materialModel != null">
  3044. and
  3045. <foreach collection="materialModel" item="item" open="(" separator="or" close=")">
  3046. "materialModel" like '%${item}%'
  3047. </foreach>
  3048. </if>
  3049. <if test="materialSpecification != null">
  3050. and
  3051. <foreach collection="materialSpecification" item="item" open="(" separator="or" close=")">
  3052. "materialSpecification" like '%${item}%'
  3053. </foreach>
  3054. </if>
  3055. <if test="carrierName != null">
  3056. and
  3057. <foreach collection="carrierName" item="item" open="(" separator="or" close=")">
  3058. "carrierName" like '%${item}%'
  3059. </foreach>
  3060. </if>
  3061. <if test="truckNo != null">
  3062. and
  3063. <foreach collection="truckNo" item="item" open="(" separator="or" close=")">
  3064. "truckNo" like '%${item}%'
  3065. </foreach>
  3066. </if>
  3067. <if test="addressDeliveryAddress != null">
  3068. and
  3069. <foreach collection="addressDeliveryAddress" item="item" open="(" separator="or" close=")">
  3070. "addressDeliveryAddress" like '%${item}%'
  3071. </foreach>
  3072. </if>
  3073. <if test="saleDateOfReceipt != null">
  3074. and
  3075. <foreach collection="saleDateOfReceipt" item="item" open="(" separator="or" close=")">
  3076. "saleDateOfReceipt" like '%${item}%'
  3077. </foreach>
  3078. </if>
  3079. <if test="saleOrderConsignee != null">
  3080. and
  3081. <foreach collection="saleOrderConsignee" item="item" open="(" separator="or" close=")">
  3082. "saleOrderConsignee" like '%${item}%'
  3083. </foreach>
  3084. </if>
  3085. <if test="saleOrderConsigneeTel != null">
  3086. and
  3087. <foreach collection="saleOrderConsigneeTel" item="item" open="(" separator="or" close=")">
  3088. "saleOrderConsigneeTel" like '%${item}%'
  3089. </foreach>
  3090. </if>
  3091. <if test="shipperName != null">
  3092. and
  3093. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  3094. "shipperName" like '%${item}%'
  3095. </foreach>
  3096. </if>
  3097. <if test="consigneeCompanyName != null">
  3098. and
  3099. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  3100. "consigneeCompanyName" like '%${item}%'
  3101. </foreach>
  3102. </if>
  3103. <if test="isselfMention != null">
  3104. and
  3105. <foreach collection="isselfMention" item="item" open="(" separator="or" close=")">
  3106. "isselfMention" like '%${item}%'
  3107. </foreach>
  3108. </if>
  3109. </where>
  3110. <include refid="orderBy"></include>
  3111. </select>
  3112. <select id="getTruckNoMaterialAndCarrier" parameterType="DECIMAL" resultType="java.util.Map" >
  3113. SELECT DISTINCT ASOM.SALE_ORDER_MATERIAL_TRUCK_NO AS "truckNo",
  3114. RM.MATERIAL_NAME AS "materialName",
  3115. ASM.MATERIAL_ID AS "materialId",
  3116. ASM.MATERIAL_NUMBER AS "materialNumber",
  3117. ASM.MATERIAL_WEIGHT AS "materialWeight",
  3118. ASOM.SALE_DATE_OF_RECEIPT AS "receiptDate",
  3119. RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL AS "materialModelSpecification",
  3120. RM.MATERIAL_CODE AS "materialCode",
  3121. RRA.ADDRESS_PROVINCE || RRA.ADDRESS_DISTRICT || RRA.ADDRESS_TOWN ||
  3122. RRP.ADDRESS_DELIVERY_ADDRESS AS "place",
  3123. ASOM.SALE_DATE_OF_RECEIPT AS "receiptDate",
  3124. ASOM.SALE_ORDER_CONSIGNEE_TEL AS "saleOrderConsigneeTel",
  3125. ASOM.SALE_ORDER_CONSIGNEE AS "saleOrderConsignee",
  3126. ASOM.SALE_ORDER_MATERIAL_ID AS "saleOrderMaterialId",
  3127. ASOM.SALE_SHIPPING_ADDRESS_ID AS "placeId",
  3128. RC.CAPACITY_NUMBER AS "capacityNumber",
  3129. ADSO.CARRIER_ID AS "carrierId",
  3130. ASOM.TRUCK_REMARK AS "truckRemark"
  3131. FROM AMS_SALE_TRUCKNO_MATERIAL ASTM
  3132. LEFT JOIN AMS_SALE_ORDER_MATERIAL ASOM
  3133. ON ASOM.SALE_ORDER_MATERIAL_ID = ASTM.SALE_ORDER_MATERIAL_ID
  3134. LEFT JOIN RMS_RECEIVE_PLACE RRP
  3135. ON RRP.PLACE_ID = ASOM.SALE_SHIPPING_ADDRESS_ID
  3136. LEFT JOIN RMS_RECEIVE_ADDRESS RRA
  3137. ON RRA.ADDRESS_ID = RRP.ADDRESS_ID
  3138. LEFT JOIN AMS_SALE_MATERIAL ASM
  3139. ON ASTM.MATERIAL_ID = ASM.SALE_MATERIAL_ID
  3140. LEFT JOIN RMS_MATERIAL RM
  3141. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  3142. LEFT JOIN OMSTRUCK_ORDER OO
  3143. ON OO.ORDER_PLAN_ID = ASOM.SALE_ORDER_MATERIAL_ID
  3144. LEFT JOIN RMS_CAPACITY RC
  3145. ON RC.CAPACITY_ID = OO.CAPACITY_ID
  3146. LEFT JOIN AMS_DISPATCH_SALE_ORDER ADSO
  3147. ON ADSO.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  3148. WHERE ASOM.SALE_ORDER_MATERIAL_ID = #{saleOrderMaterialId}
  3149. ORDER BY ASOM.SALE_ORDER_MATERIAL_TRUCK_NO ASC
  3150. </select>
  3151. <select id="getHaveCarTruckNoList" parameterType="java.util.Map" resultType="java.util.LinkedHashMap">
  3152. SELECT * FROM (
  3153. SELECT DISTINCT *
  3154. FROM (
  3155. SELECT ASO.SALE_NUMBER AS "saleNumber",
  3156. ASOM.SALE_ORDER_MATERIAL_TRUCK_NO AS "truckNo",
  3157. RRA.ADDRESS_PROVINCE || RRA.ADDRESS_DISTRICT || RRA.ADDRESS_TOWN || RRP.ADDRESS_DELIVERY_ADDRESS AS
  3158. "addressDeliveryAddress",
  3159. ASOM.SALE_DATE_OF_RECEIPT AS "saleDateOfReceipt",
  3160. DECODE(ASO.SALE_ORDER_STATUS,1,'订单已上报',2, '销售已提交',4, '财务已审批')
  3161. AS "approvalStatus",
  3162. ASOM.SALE_ORDER_CONSIGNEE_TEL AS "saleOrderConsigneeTel",
  3163. RSH.SHIPPER_NAME AS "shipperName",
  3164. RCO.CONSIGNEE_COMPANY_NAME AS "consigneeCompanyName",
  3165. ASO.SALE_ORDER_ISSELF_MENTION AS "isselfMention",
  3166. ASOM.INSERT_TIME AS "insertTime",
  3167. ASOM.SALE_ORDER_MATERIAL_ID AS "saleOrderMaterialId",
  3168. ASO.SALE_ORDER_ID AS "saleOrderId",
  3169. RCA.CARRIER_NAME AS "carrierName",
  3170. RM.MATERIAL_NAME AS "materialName",
  3171. RM.MATERIAL_SPECIFICATION AS "materialSpecification",
  3172. RM.MATERIAL_MODEL AS "materialModel",
  3173. RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL AS "specificationModel",
  3174. RM.MATERIAL_NAME || RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL AS "nameSpecificationModel",
  3175. RCP.CAPACITY_NUMBER AS "capacityNumber",
  3176. OO.DRIVER_TEL AS "drivelTel",
  3177. ASM.MATERIAL_NUMBER AS "materialNumber",
  3178. OO.ORDER_ID AS "orderId"
  3179. FROM AMS_SALE_ORDER_MATERIAL ASOM
  3180. LEFT JOIN AMS_SALE_ORDER ASO
  3181. ON ASO.SALE_ORDER_ID = ASOM.SALE_ORDER_ID
  3182. LEFT JOIN AMS_SALE_TRUCKNO_MATERIAL ASTM
  3183. ON ASTM.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  3184. LEFT JOIN RMS_RECEIVE_PLACE RRP
  3185. ON RRP.PLACE_ID = ASOM.SALE_SHIPPING_ADDRESS_ID
  3186. LEFT JOIN RMS_RECEIVE_ADDRESS RRA
  3187. ON RRA.ADDRESS_ID = RRP.ADDRESS_ID
  3188. LEFT JOIN RMS_SHIPPER RSH
  3189. ON RSH.SHIPPER_ID = ASO.SHIPPER_ID
  3190. LEFT JOIN RMS_CONSIGNEE RCO
  3191. ON RCO.CONSIGNEE_ID = ASO.RECEIVE_ID
  3192. LEFT JOIN AMS_DISPATCH_SALE_ORDER ADSO
  3193. ON ADSO.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  3194. LEFT JOIN OMSTRUCK_ORDER OO
  3195. ON OO.ORDER_PLAN_ID = ASOM.SALE_ORDER_MATERIAL_ID
  3196. LEFT JOIN RMS_CAPACITY RCP
  3197. ON RCP.CAPACITY_ID = OO.CAPACITY_ID
  3198. LEFT JOIN RMS_CARRIER RCA
  3199. ON RCA.CARRIER_ID = ADSO.CARRIER_ID
  3200. LEFT JOIN AMS_SALE_MATERIAL ASM
  3201. ON ASM.SALE_MATERIAL_ID = ASTM.MATERIAL_ID
  3202. LEFT JOIN RMS_MATERIAL RM
  3203. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  3204. WHERE OO.ORDER_TYPE = 1
  3205. AND ASO.SALE_ORDER_STATUS IN (2,4)
  3206. AND ASOM.ISSUE_STATUS IS NULL
  3207. AND ADSO.DISPATCH_TYPE = 2
  3208. AND OO.ORDER_ID IS NOT NULL
  3209. AND OO.ORDER_STATUS IN (4,5)
  3210. AND ASO.DELETED != 2
  3211. AND ASM.DELETED IS NULL
  3212. <if test="oneDate != null">
  3213. and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt; = ASOM.INSERT_TIME
  3214. </if>
  3215. <if test="startDate != null">
  3216. and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= ASOM.INSERT_TIME
  3217. and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >= ASOM.INSERT_TIME
  3218. </if>
  3219. ORDER BY ASOM.SALE_ORDER_MATERIAL_ID DESC
  3220. ) "HAVECAR"
  3221. <where>
  3222. <if test="con != null" >
  3223. "HAVECAR"."carrierName" LIKE #{con} or "HAVECAR"."consigneeCompanyName" LIKE #{con} or "HAVECAR"."addressDeliveryAddress" LIKE #{con}
  3224. </if>
  3225. </where>
  3226. )
  3227. <where>
  3228. <if test="saleNumber != null">
  3229. and
  3230. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  3231. "saleNumber" like '%${item}%'
  3232. </foreach>
  3233. </if>
  3234. <if test="materialName != null">
  3235. and
  3236. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  3237. "materialName" like '%${item}%'
  3238. </foreach>
  3239. </if>
  3240. <if test="materialSpecification != null">
  3241. and
  3242. <foreach collection="materialSpecification" item="item" open="(" separator="or" close=")">
  3243. "materialSpecification" like '%${item}%'
  3244. </foreach>
  3245. </if>
  3246. <if test="materialModel != null">
  3247. and
  3248. <foreach collection="materialModel" item="item" open="(" separator="or" close=")">
  3249. "materialModel" 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="carrierName != null">
  3259. and
  3260. <foreach collection="carrierName" item="item" open="(" separator="or" close=")">
  3261. "carrierName" like '%${item}%'
  3262. </foreach>
  3263. </if>
  3264. <if test="truckNo != null">
  3265. and
  3266. <foreach collection="truckNo" item="item" open="(" separator="or" close=")">
  3267. "truckNo" like '%${item}%'
  3268. </foreach>
  3269. </if>
  3270. <if test="addressDeliveryAddress != null">
  3271. and
  3272. <foreach collection="addressDeliveryAddress" item="item" open="(" separator="or" close=")">
  3273. "addressDeliveryAddress" like '%${item}%'
  3274. </foreach>
  3275. </if>
  3276. <if test="saleDateOfReceipt != null">
  3277. and
  3278. <foreach collection="saleDateOfReceipt" item="item" open="(" separator="or" close=")">
  3279. "saleDateOfReceipt" like '%${item}%'
  3280. </foreach>
  3281. </if>
  3282. <if test="saleOrderConsignee != null">
  3283. and
  3284. <foreach collection="saleOrderConsignee" item="item" open="(" separator="or" close=")">
  3285. "saleOrderConsignee" like '%${item}%'
  3286. </foreach>
  3287. </if>
  3288. <if test="saleOrderConsigneeTel != null">
  3289. and
  3290. <foreach collection="saleOrderConsigneeTel" item="item" open="(" separator="or" close=")">
  3291. "saleOrderConsigneeTel" like '%${item}%'
  3292. </foreach>
  3293. </if>
  3294. <if test="shipperName != null">
  3295. and
  3296. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  3297. "shipperName" like '%${item}%'
  3298. </foreach>
  3299. </if>
  3300. <if test="consigneeCompanyName != null">
  3301. and
  3302. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  3303. "consigneeCompanyName" like '%${item}%'
  3304. </foreach>
  3305. </if>
  3306. <if test="isselfMention != null">
  3307. and
  3308. <foreach collection="isselfMention" item="item" open="(" separator="or" close=")">
  3309. "isselfMention" like '%${item}%'
  3310. </foreach>
  3311. </if>
  3312. </where>
  3313. </select>
  3314. <select id="getOrderPrice" parameterType="java.util.Map" resultType="DECIMAL" >
  3315. SELECT ACTP.PRICE_ID AS "priceId"
  3316. FROM AMS_CONTRACT_TRANSPORT_PRICE ACTP
  3317. LEFT JOIN AMS_SALE_ORDER_MATERIAL ASOM
  3318. ON ASOM.SALE_SHIPPING_ADDRESS_ID = ACTP.PLACE_ID
  3319. WHERE ACTP.CARRIER_ID = #{carrierId}
  3320. AND ASOM.SALE_ORDER_MATERIAL_ID = #{saleOrderMaterialId}
  3321. </select>
  3322. <select id="selectConsigneeName" parameterType="DECIMAL" resultType="java.lang.String" >
  3323. SELECT RC.CONSIGNEE_COMPANY_NAME AS "consigneeName"
  3324. FROM RMS_CONSIGNEE RC
  3325. WHERE RC.CONSIGNEE_ID = #{receiveId}
  3326. </select>
  3327. <select id="selectCarrierId" resultType="DECIMAL" parameterType="java.lang.String">
  3328. SELECT RC.CARRIER_ID AS "carrierId"
  3329. FROM RMS_CARRIER RC
  3330. WHERE RC.CARRIER_NAME = #{consigneeName}
  3331. </select>
  3332. <select id="getSaleMapMessages" resultType="java.util.Map" parameterType="DECIMAL" >
  3333. SELECT ASO.SALE_ORDER_ISSELF_MENTION AS "isSelfMention",
  3334. ASO.SALE_REMARK AS "saleRemark",
  3335. ASO.SALE_ORDER_RECEIVE_CUSTOMER AS "saleOrderReceiveCustomer",
  3336. RSH.SHIPPER_ID AS "shipperId",
  3337. RSH.SHIPPER_NAME AS "shipperName",
  3338. RCO.CONSIGNEE_ID AS "receiveId",
  3339. RCO.CONSIGNEE_COMPANY_NAME AS "receiveName",
  3340. RSA.SALER_ID AS "salerId",
  3341. RSA.SALER_NAME AS "salerName"
  3342. FROM AMS_SALE_ORDER ASO
  3343. LEFT JOIN RMS_SHIPPER RSH
  3344. ON RSH.SHIPPER_ID = ASO.SHIPPER_ID
  3345. LEFT JOIN RMS_CONSIGNEE RCO
  3346. ON RCO.CONSIGNEE_ID = ASO.RECEIVE_ID
  3347. LEFT JOIN RMS_SALER RSA
  3348. ON RSA.SALER_ID = ASO.SALER_ID
  3349. WHERE ASO.SALE_ORDER_ID = #{saleOrderId}
  3350. </select>
  3351. <select id="getSaleListMessages" parameterType="DECIMAL" resultType="java.util.Map" >
  3352. SELECT ASOM.SALE_ORDER_MATERIAL_TRUCK_NO AS "truckNo",
  3353. RRP.ADDRESS_DELIVERY_ADDRESS AS "place",
  3354. RRA.ADDRESS_ID AS "shipperAddressId",
  3355. RRA.ADDRESS_PROVINCE || RRA.ADDRESS_DISTRICT || RRA.ADDRESS_TOWN AS "saleShipperAddressName",
  3356. ASOM.SALE_ORDER_CONSIGNEE AS "saleOrderConsignee",
  3357. ASOM.SALE_ORDER_CONSIGNEE_TEL AS "saleOrderConsigneeTel",
  3358. ASOM.SALE_DATE_OF_RECEIPT AS "saleDateOfReceipt",
  3359. ASM.MATERIAL_ID AS "materialId",
  3360. RM.MATERIAL_NAME AS "materialName",
  3361. RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL AS "Specification",
  3362. RM.MATERIAL_CODE AS "materialCode",
  3363. ASM.MATERIAL_NUMBER AS "materialNumber",
  3364. ASM.STEEL_METER AS "steelMeters",
  3365. ASM.IS_POUND_SALE AS "isPoundSale"
  3366. FROM AMS_SALE_ORDER ASO
  3367. LEFT JOIN AMS_SALE_ORDER_MATERIAL ASOM
  3368. ON ASO.SALE_ORDER_ID = ASOM.SALE_ORDER_ID
  3369. LEFT JOIN AMS_SALE_TRUCKNO_MATERIAL ASTM
  3370. ON ASTM.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  3371. LEFT JOIN AMS_SALE_MATERIAL ASM
  3372. ON ASM.SALE_MATERIAL_ID = ASTM.MATERIAL_ID
  3373. LEFT JOIN RMS_MATERIAL RM
  3374. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  3375. LEFT JOIN RMS_RECEIVE_PLACE RRP
  3376. ON RRP.PLACE_ID = ASOM.SALE_SHIPPING_ADDRESS_ID
  3377. LEFT JOIN RMS_RECEIVE_ADDRESS RRA
  3378. ON RRA.ADDRESS_ID = RRP.ADDRESS_ID
  3379. WHERE ASO.SALE_ORDER_ID = #{saleOrderId}
  3380. </select>
  3381. <select id="matchingAddressRecently" parameterType="DECIMAL" resultType="java.util.Map" >
  3382. SELECT DISTINCT *
  3383. FROM (SELECT RRP.PLACE_ID "placeId",
  3384. RRP.ADDRESS_DELIVERY_ADDRESS "place",
  3385. RRA.ADDRESS_ID "shipperAddressId",
  3386. RRA.ADDRESS_PROVINCE "addressProvince",
  3387. RRA.ADDRESS_DISTRICT "addressDistrict",
  3388. RRA.ADDRESS_TOWN "addressTown",
  3389. ASOM.SALE_ORDER_CONSIGNEE_TEL "saleOrderConsigneeTel",
  3390. RRA.ADDRESS_PROVINCE || RRA.ADDRESS_DISTRICT || RRA.ADDRESS_TOWN || RRP.ADDRESS_DELIVERY_ADDRESS "addressPlace"
  3391. FROM AMS_SALE_ORDER ASO
  3392. LEFT JOIN AMS_SALE_ORDER_MATERIAL ASOM
  3393. ON ASO.SALE_ORDER_ID = ASOM.SALE_ORDER_ID
  3394. LEFT JOIN RMS_RECEIVE_PLACE RRP
  3395. ON RRP.PLACE_ID = ASOM.SALE_SHIPPING_ADDRESS_ID
  3396. LEFT JOIN RMS_RECEIVE_ADDRESS RRA
  3397. ON RRA.ADDRESS_ID = RRP.ADDRESS_ID
  3398. WHERE ASO.RECEIVE_ID = #{receiveId}
  3399. AND RRP.PLACE_ID IS NOT NULL
  3400. ORDER BY ASOM.SALE_ORDER_MATERIAL_ID DESC
  3401. )
  3402. </select>
  3403. <select id="getSalerByReceiveId" parameterType="DECIMAL" resultType="java.util.Map" >
  3404. SELECT DISTINCT *
  3405. FROM (
  3406. SELECT RS.SALER_NAME "salerName",
  3407. RS.SALER_ID "salerId"
  3408. FROM AMS_SALE_ORDER ASO
  3409. LEFT JOIN RMS_SALER RS
  3410. ON RS.SALER_ID = ASO.SALER_ID
  3411. WHERE ASO.RECEIVE_ID = #{receiveId}
  3412. AND RS.SALER_ID IS NOT NULL
  3413. AND ASO.SALE_TYPE = 1
  3414. ORDER BY ASO.SALE_ORDER_ID DESC
  3415. )
  3416. WHERE rownum <![CDATA[
  3417. <
  3418. ]]> 2
  3419. </select>
  3420. <select id="matchingDriverTelRecently" parameterType="java.lang.String" resultType="java.lang.String">
  3421. SELECT DISTINCT *
  3422. FROM (
  3423. SELECT OO.DRIVER_TEL "driverTel"
  3424. FROM RMS_CAPACITY RCA
  3425. LEFT JOIN OMSTRUCK_ORDER OO
  3426. ON OO.CAPACITY_ID = RCA.CAPACITY_ID
  3427. WHERE RCA.CAPACITY_NUMBER = #{capacityNumber}
  3428. AND OO.ORDER_TYPE = 1
  3429. ORDER BY OO.ORDER_ID
  3430. )
  3431. WHERE ROWNUM <![CDATA[
  3432. <
  3433. ]]> 2
  3434. </select>
  3435. <!-- 查询内转焦炭订单 -->
  3436. <select id="getCokeInwardOrderList" parameterType="java.util.Map" resultType="java.util.Map">
  3437. SELECT * FROM (
  3438. SELECT *from(
  3439. select
  3440. OO.ORDER_NUMBER "orderNumber",
  3441. ASO.SALE_NUMBER "saleNumber",
  3442. RC.CAPACITY_NUMBER "capacityNumber",
  3443. RC2.CONSIGNEE_COMPANY_NAME "consigneeCompanyName",
  3444. RRA.ADDRESS_PROVINCE || RRA.ADDRESS_DISTRICT || RRA.ADDRESS_TOWN "addressDeliveryAddress",
  3445. ACTP.PRICE_VALUE "priceValue",
  3446. ASOM.SALE_DATE_OF_RECEIPT "saleDateOfReceipt",
  3447. OO.ORDER_RECEIVE_REFUSE_TIME "orderReceiveRefuseTime",
  3448. RS.SHIPPER_NAME "shipperName",
  3449. OO.ORDER_ID "orderId",
  3450. RC3.CARRIER_NAME "carrierName"
  3451. FROM OMSTRUCK_ORDER OO
  3452. LEFT JOIN AMS_SALE_ORDER_MATERIAL ASOM
  3453. ON ASOM.SALE_ORDER_MATERIAL_ID=OO.ORDER_PLAN_ID
  3454. LEFT JOIN AMS_SALE_ORDER ASO
  3455. ON ASO.SALE_ORDER_ID=ASOM.SALE_ORDER_ID
  3456. LEFT JOIN AMS_DISPATCH_SALE_ORDER ADSO
  3457. ON ADSO.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  3458. LEFT JOIN RMS_CARRIER RC3
  3459. ON RC3.CARRIER_ID = ADSO.CARRIER_ID
  3460. LEFT JOIN RMS_CONSIGNEE RC2
  3461. ON RC2.CONSIGNEE_ID=ASO.RECEIVE_ID
  3462. LEFT JOIN RMS_CAPACITY RC
  3463. ON OO.CAPACITY_ID=RC.CAPACITY_ID
  3464. LEFT JOIN RMS_SHIPPER RS
  3465. ON RS.SHIPPER_ID=ASO.SHIPPER_ID
  3466. LEFT JOIN RMS_RECEIVE_ADDRESS RRA
  3467. ON RRA.ADDRESS_ID=ASOM.SALE_SHIPPING_ADDRESS_ID
  3468. LEFT JOIN AMS_CONTRACT_TRANSPORT_PRICE ACTP
  3469. ON OO.PRICE_ID=ACTP.PRICE_ID
  3470. WHERE OO.ORDER_TYPE = 2
  3471. AND ASO.SHIPPER_ID = 2
  3472. AND ASO.CLOSE_STATUS = 0
  3473. <where>
  3474. <if test="orderStatus!=null">
  3475. AND OO.ORDER_STATUS = #{orderStatus}
  3476. </if>
  3477. </where>
  3478. ) RRC
  3479. <if test="con != null">
  3480. WHERE RRC."consigneeCompanyName" LIKE #{con} or RRC."capacityNumber" LIKE #{con}
  3481. </if>
  3482. )
  3483. <where>
  3484. <if test="orderNumber != null">
  3485. <foreach collection="orderNumber" item="item" open="(" separator="or" close=")">
  3486. "orderNumber" like '%${item}%'
  3487. </foreach>
  3488. </if>
  3489. <if test="carrierName != null">
  3490. <foreach collection="carrierName" item="item" open="(" separator="or" close=")">
  3491. "carrierName" like '%${item}%'
  3492. </foreach>
  3493. </if>
  3494. <if test="saleNumber != null">
  3495. and
  3496. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  3497. "saleNumber" like '%${item}%'
  3498. </foreach>
  3499. </if>
  3500. <if test="capacityNumber != null">
  3501. and
  3502. <foreach collection="capacityNumber" item="item" open="(" separator="or" close=")">
  3503. "capacityNumber" like '%${item}%'
  3504. </foreach>
  3505. </if>
  3506. <if test="shipperName != null">
  3507. and
  3508. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  3509. "shipperName" like '%${item}%'
  3510. </foreach>
  3511. </if>
  3512. <if test="consigneeCompanyName != null">
  3513. and
  3514. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  3515. "consigneeCompanyName" like '%${item}%'
  3516. </foreach>
  3517. </if>
  3518. </where>
  3519. <include refid="orderBy">
  3520. </include>
  3521. <if test="orderField == null ">
  3522. order by "orderNumber" desc
  3523. </if>
  3524. </select>
  3525. <select id="getDispatchId" parameterType="DECIMAL" resultType="DECIMAL" >
  3526. SELECT ADSO.DISPATCH_ID AS "dispatchId"
  3527. FROM AMS_DISPATCH_SALE_ORDER ADSO
  3528. WHERE ADSO.SALE_ORDER_MATERIAL_ID = #{saleOrderMaterialId}
  3529. </select>
  3530. <select id="getSaleMaterialId" parameterType="DECIMAL" resultType="java.util.Map" >
  3531. SELECT ASTM.MATERIAL_ID AS "saleMaterialId",
  3532. ASM.EAS_PRIMARY_ID AS "closeEntryId"
  3533. FROM AMS_SALE_ORDER_MATERIAL ASOM
  3534. LEFT JOIN AMS_SALE_TRUCKNO_MATERIAL ASTM
  3535. ON ASTM.SALE_ORDER_MATERIAL_ID = ASOM.SALE_ORDER_MATERIAL_ID
  3536. LEFT JOIN AMS_SALE_MATERIAL ASM
  3537. ON ASM.SALE_MATERIAL_ID = ASTM.MATERIAL_ID
  3538. WHERE ASOM.SALE_ORDER_MATERIAL_ID = #{saleOrderMaterialId}
  3539. </select>
  3540. <select id="getSaleList" resultType="java.util.Map" >
  3541. SELECT ASTM.TRUCKNO_MATERIAL_ID "truckNoMaterialId",
  3542. ASM.SALE_MATERIAL_ID "saleMaterialId",
  3543. ASM.MATERIAL_ID "materialId"
  3544. FROM AMS_SALE_TRUCKNO_MATERIAL ASTM
  3545. LEFT JOIN AMS_SALE_MATERIAL ASM
  3546. ON ASM.SALE_MATERIAL_ID = ASTM.MATERIAL_ID
  3547. WHERE ASTM.SALE_ORDER_MATERIAL_ID = #{saleOrderMaterialId}
  3548. AND ASM.MATERIAL_ID = #{materialId}
  3549. </select>
  3550. <select id="getFuSaleOrderList" parameterType="java.util.Map" resultType="java.util.Map">
  3551. select * from(
  3552. select a_s_order.SALE_ORDER_ID "saleOrderId",
  3553. a_s_order.SALE_NUMBER "saleNumber",
  3554. r_shipper.SHIPPER_NAME "shipperName",
  3555. r_consignee.CONSIGNEE_COMPANY_NAME "consigneeCompanyName",
  3556. r_consignee.CONSIGNEE_WARRANTY_AMOUNT "consigneeWarrantyAmount",
  3557. r_consignee.CONSIGNEE_WARRANTY_WEIGHT "consigneeWarrantyWeight",
  3558. a_s_order.SALE_ORDER_ISSELF_MENTION "saleOrderIsselfMention",
  3559. a_s_order.SALE_ACCOUNT_BALANCE "saleAccountBalance",
  3560. a_s_order.SALE_CURRENT_ORDER_AMOUNT "saleCurrentOrderAmount",
  3561. a_s_order.SALE_HISTORICAL_ORDER_AMOUNT "saleHistoricalOrderAmout",
  3562. a_s_order.SALE_ORDER_RECEIVE_CUSTOMER "saleOrderReceiveCustomer",
  3563. a_s_order.SALE_UNIT_PRICE "saleUnitPrice",
  3564. a_s_order.SALE_ORDER_TAX "saleOrderTax",
  3565. a_s_order.SALE_REMARK "saleRemark",
  3566. a_s_order.INSERT_TIME "insertTime",
  3567. DECODE(a_s_order.SALE_ORDER_STATUS,2,'销售已提交',4,'财务已审批') "statusStr",
  3568. RM.MATERIAL_NAME "materialName",
  3569. ASM.MATERIAL_WEIGHT "materialWeight",
  3570. ASM.SALE_WAREHOUSE "saleWareHouse",
  3571. nvl(sumWeight.weight,0)+nvl(sumWeight2.weight,0) as "totalWeight",
  3572. nvl(sumWeight.weight ,0) as "netWeight",
  3573. nvl(sumWeight2.weight ,0) as "weight",
  3574. nvl(carCount.coun ,0) as "carCount",
  3575. RCA.CARRIER_NAME as "carrierName"
  3576. from AMS_SALE_ORDER a_s_order
  3577. left join RMS_SHIPPER r_shipper
  3578. on a_s_order.SHIPPER_ID=r_shipper.SHIPPER_ID
  3579. left join RMS_CONSIGNEE r_consignee
  3580. on a_s_order.RECEIVE_ID=r_consignee.CONSIGNEE_ID
  3581. LEFT JOIN AMS_SALE_MATERIAL ASM
  3582. ON ASM.SALE_ORDER_ID = a_s_order.SALE_ORDER_ID
  3583. LEFT JOIN AMS_SALE_ORDER_CARRIER ASOC
  3584. ON ASOC.SALE_ORDER_ID = a_s_order.SALE_ORDER_ID
  3585. LEFT JOIN RMS_CARRIER RCA
  3586. ON RCA.CARRIER_ID = ASOC.CARRIER_ID
  3587. LEFT JOIN RMS_MATERIAL RM
  3588. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  3589. left join (
  3590. select sum( t_w_result.RESULT_NET_WEIGHT) weight,a_s_o_material.SALE_ORDER_ID SALE_ORDER_ID
  3591. from AMS_SALE_ORDER_MATERIAL a_s_o_material
  3592. left join Omstruck_Order o_order
  3593. on a_s_o_material.SALE_ORDER_MATERIAL_ID=o_order.order_plan_id
  3594. left join Tmstruck_Total_Result t_t_result
  3595. on o_order.order_id=t_t_result.order_id
  3596. left join Tmstruck_Weight_Result t_w_result
  3597. on t_t_result.result_total_id=t_w_result.result_total_id
  3598. GROUP BY
  3599. a_s_o_Material.SALE_ORDER_ID
  3600. ) sumWeight
  3601. on sumWeight.SALE_ORDER_ID=a_s_order.SALE_ORDER_ID
  3602. left join (
  3603. select sum( o_o_material.ORDER_MATERIAL_WEIGHT) weight,a_s_o_Material.SALE_ORDER_ID SALE_ORDER_ID
  3604. from AMS_SALE_ORDER_MATERIAL a_s_o_material
  3605. left join Omstruck_Order o_order
  3606. on a_s_o_material.SALE_ORDER_MATERIAL_ID=o_order.order_plan_id
  3607. left join Tmstruck_Total_Result t_t_result
  3608. on o_order.order_id=t_t_result.order_id
  3609. left join Tmstruck_Weight_Result t_w_result
  3610. on t_t_result.result_total_id=t_w_result.result_total_id
  3611. left join OMSTRUCK_ORDER_MATERIAL o_o_material
  3612. on o_order.order_id=o_o_material.ORDER_ID
  3613. where t_w_result.RESULT_NET_WEIGHT is null and o_order.order_status in (2,4,5)
  3614. GROUP BY
  3615. a_s_o_Material.SALE_ORDER_ID
  3616. ) sumWeight2
  3617. on sumWeight2.SALE_ORDER_ID=a_s_order.SALE_ORDER_ID
  3618. left join (
  3619. select count(o_order.order_id) coun ,a_s_o_Material.SALE_ORDER_ID SALE_ORDER_ID
  3620. from AMS_SALE_ORDER_MATERIAL a_s_o_material
  3621. left join Omstruck_Order o_order
  3622. on a_s_o_material.SALE_ORDER_MATERIAL_ID=o_order.order_plan_id
  3623. left join Tmstruck_Total_Result t_t_result
  3624. on o_order.order_id=t_t_result.order_id
  3625. left join Tmstruck_Weight_Result t_w_result
  3626. on t_t_result.result_total_id=t_w_result.result_total_id
  3627. where t_w_result.RESULT_NET_WEIGHT is null and o_order.order_status in (2,4,5)
  3628. GROUP BY
  3629. a_s_o_Material.SALE_ORDER_ID
  3630. ) carCount
  3631. on carCount.SALE_ORDER_ID=a_s_order.SALE_ORDER_ID
  3632. where (ASM.SALE_WAREHOUSE = '副产品库'
  3633. or ASM.SALE_WAREHOUSE = '钒渣库')
  3634. and a_s_order.SALE_ORDER_STATUS in (2,4)
  3635. and a_s_order.CLOSE_STATUS is null
  3636. and a_s_order.DELETED = #{deleted}
  3637. and a_s_order.SHIPPER_ID = 1
  3638. and a_s_order.SALE_TYPE is null
  3639. <if test="con != null">
  3640. and (instr(r_consignee.CONSIGNEE_COMPANY_NAME, #{con}) > 0 or instr(a_s_order.SALE_NUMBER, #{con}) > 0)
  3641. </if>
  3642. <if test="consigneeSsoId != null">
  3643. and r_consignee.CONSIGNEE_SSO_ID = #{consigneeSsoId}
  3644. </if>
  3645. <if test="oneDate != null">
  3646. and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= a_s_order.UPDATE_TIME
  3647. </if>
  3648. <if test="startDate != null">
  3649. and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= a_s_order.UPDATE_TIME
  3650. and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >= a_s_order.UPDATE_TIME
  3651. </if>
  3652. ORDER BY a_s_order.UPDATE_TIME DESC
  3653. )
  3654. <where>
  3655. <if test="saleNumber != null">
  3656. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  3657. "saleNumber" like '%${item}%'
  3658. </foreach>
  3659. </if>
  3660. <if test="materialName != null">
  3661. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  3662. "materialName" like '%${item}%'
  3663. </foreach>
  3664. </if>
  3665. <if test="materialSpecification != null">
  3666. <foreach collection="materialSpecification" item="item" open="(" separator="or" close=")">
  3667. "materialSpecification" like '%${item}%'
  3668. </foreach>
  3669. </if>
  3670. <if test="materialModel != null">
  3671. <foreach collection="materialModel" item="item" open="(" separator="or" close=")">
  3672. "materialModel" like '%${item}%'
  3673. </foreach>
  3674. </if>
  3675. <if test="statusStr != null">
  3676. <foreach collection="statusStr" item="item" open="(" separator="or" close=")">
  3677. and "statusStr" like '%${item}%'
  3678. </foreach>
  3679. </if>
  3680. <if test="shipperName != null">
  3681. and
  3682. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  3683. "shipperName" like '%${item}%'
  3684. </foreach>
  3685. </if>
  3686. <if test="consigneeCompanyName != null">
  3687. and
  3688. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  3689. "consigneeCompanyName" like '%${item}%'
  3690. </foreach>
  3691. </if>
  3692. <if test="consigneeWarrantyAmount != null">
  3693. and
  3694. <foreach collection="consigneeWarrantyAmount" item="item" open="(" separator="or" close=")">
  3695. "consigneeWarrantyAmount" like '%${item}%'
  3696. </foreach>
  3697. </if>
  3698. <if test="consigneeWarrantyWeight != null">
  3699. and
  3700. <foreach collection="consigneeWarrantyWeight" item="item" open="(" separator="or" close=")">
  3701. "consigneeWarrantyWeight" like '%${item}%'
  3702. </foreach>
  3703. </if>
  3704. <if test="saleOrderIsselfMention != null">
  3705. and
  3706. <foreach collection="saleOrderIsselfMention" item="item" open="(" separator="or" close=")">
  3707. "saleOrderIsselfMention" like '%${item}%'
  3708. </foreach>
  3709. </if>
  3710. <if test="saleAccountBalance != null">
  3711. and
  3712. <foreach collection="saleAccountBalance" item="item" open="(" separator="or" close=")">
  3713. "saleAccountBalance" like '%${item}%'
  3714. </foreach>
  3715. </if>
  3716. <if test="saleCurrentOrderAmount != null">
  3717. and
  3718. <foreach collection="saleCurrentOrderAmount" item="item" open="(" separator="or" close=")">
  3719. "saleCurrentOrderAmount" like '%${item}%'
  3720. </foreach>
  3721. </if>
  3722. <if test="saleHistoricalOrderAmout != null">
  3723. and
  3724. <foreach collection="saleHistoricalOrderAmout" item="item" open="(" separator="or" close=")">
  3725. "saleHistoricalOrderAmout" like '%${item}%'
  3726. </foreach>
  3727. </if>
  3728. <if test="saleOrderReceiveCustomer != null">
  3729. and
  3730. <foreach collection="saleOrderReceiveCustomer" item="item" open="(" separator="or" close=")">
  3731. "saleOrderReceiveCustomer" like '%${item}%'
  3732. </foreach>
  3733. </if>
  3734. <if test="saleUnitPrice != null">
  3735. and
  3736. <foreach collection="saleUnitPrice" item="item" open="(" separator="or" close=")">
  3737. "saleUnitPrice" like '%${item}%'
  3738. </foreach>
  3739. </if>
  3740. <if test="saleOrderTax != null">
  3741. and
  3742. <foreach collection="saleOrderTax" item="item" open="(" separator="or" close=")">
  3743. "saleOrderTax" like '%${item}%'
  3744. </foreach>
  3745. </if>
  3746. <if test="saleRemark != null">
  3747. and
  3748. <foreach collection="saleRemark" item="item" open="(" separator="or" close=")">
  3749. "saleRemark" like '%${item}%'
  3750. </foreach>
  3751. </if>
  3752. </where>
  3753. </select>
  3754. <!-- 关闭未进厂的运单 -->
  3755. <update id="closeOrderNotIn" parameterType="DECIMAL" >
  3756. UPDATE OMSTRUCK_ORDER OO
  3757. SET OO.ORDER_STATUS = 7
  3758. WHERE OO.ORDER_ID IN (
  3759. SELECT OO.ORDER_ID "orderId"
  3760. FROM AMS_SALE_ORDER_MATERIAL ASOM
  3761. LEFT JOIN OMSTRUCK_ORDER OO
  3762. ON OO.ORDER_PLAN_ID = ASOM.SALE_ORDER_MATERIAL_ID
  3763. LEFT JOIN TMSTRUCK_TOTAL_RESULT TTR
  3764. ON TTR.ORDER_ID = OO.ORDER_ID
  3765. LEFT JOIN TMSTRUCK_ENFACTORY_RESULT TER
  3766. ON TER.RESULT_TOTAL_ID = TTR.RESULT_TOTAL_ID
  3767. WHERE ASOM.SALE_ORDER_ID = #{saleOrderId}
  3768. AND TER.RESULT_ENTRY_GATE_TIME IS NULL
  3769. AND OO.ORDER_ID IS NOT NULL
  3770. AND OO.ORDER_STATUS IN (4,5)
  3771. )
  3772. </update>
  3773. <select id="getCarMessageToEas" parameterType="DECIMAL" resultType="java.util.LinkedHashMap">
  3774. SELECT RCA.CAPACITY_NUMBER AS "r1c1",
  3775. OO.ORDER_NUMBER AS "r1c2",
  3776. RM.EAS_MATERIAL_ID AS "r1c3",
  3777. RM.MATERIAL_NAME AS "r1c4",
  3778. RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL AS "r1c5"
  3779. FROM OMSTRUCK_ORDER OO
  3780. LEFT JOIN OMSTRUCK_ORDER_MATERIAL OOM
  3781. ON OOM.ORDER_ID = OO.ORDER_ID
  3782. LEFT JOIN RMS_MATERIAL RM
  3783. ON RM.MATERIAL_ID = OOM.MATERIAL_ID
  3784. LEFT JOIN RMS_CAPACITY RCA
  3785. ON OO.CAPACITY_ID = RCA.CAPACITY_ID
  3786. LEFT JOIN AMS_SALE_ORDER_MATERIAL ASOM
  3787. ON ASOM.SALE_ORDER_MATERIAL_ID = OO.ORDER_PLAN_ID
  3788. LEFT JOIN AMS_SALE_ORDER ASO
  3789. ON ASO.SALE_ORDER_ID = ASOM.SALE_ORDER_ID
  3790. LEFT JOIN RMS_CONSIGNEE RC
  3791. ON ASO.RECEIVE_ID = RC.CONSIGNEE_ID
  3792. </select>
  3793. <select id="getSteelOrderDeletedList" resultType="java.util.Map" parameterType="java.util.Map">
  3794. select * from(
  3795. select a_s_order.SALE_ORDER_ID "saleOrderId",
  3796. a_s_order.SALE_NUMBER "saleNumber",
  3797. r_shipper.SHIPPER_NAME "shipperName",
  3798. r_consignee.CONSIGNEE_COMPANY_NAME "consigneeCompanyName",
  3799. r_consignee.CONSIGNEE_WARRANTY_AMOUNT "consigneeWarrantyAmount",
  3800. r_consignee.CONSIGNEE_WARRANTY_WEIGHT "consigneeWarrantyWeight",
  3801. a_s_order.SALE_ORDER_ISSELF_MENTION "saleOrderIsselfMention",
  3802. a_s_order.SALE_ACCOUNT_BALANCE "saleAccountBalance",
  3803. a_s_order.SALE_CURRENT_ORDER_AMOUNT "saleCurrentOrderAmount",
  3804. a_s_order.SALE_HISTORICAL_ORDER_AMOUNT "saleHistoricalOrderAmout",
  3805. a_s_order.SALE_ORDER_RECEIVE_CUSTOMER "saleOrderReceiveCustomer",
  3806. a_s_order.SALE_UNIT_PRICE "saleUnitPrice",
  3807. a_s_order.SALE_ORDER_TAX "saleOrderTax",
  3808. a_s_order.SALE_REMARK "saleRemark",
  3809. a_s_order.INSERT_TIME "insertTime",
  3810. DECODE(a_s_order.SALE_ORDER_STATUS,2,'销售已提交',4,'财务已审批') "statusStr",
  3811. RM.MATERIAL_NAME "materialName",
  3812. RM.MATERIAL_SPECIFICATION "materialSpecification",
  3813. RM.MATERIAL_MODEL "materialModel",
  3814. RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL "specificationModel",
  3815. ASM.MATERIAL_NUMBER "materialNumber",
  3816. RM.MATERIAL_NAME || RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL "nameSpecificationModel",
  3817. ASM.SALE_WAREHOUSE "saleWareHouse",
  3818. a_s_order.DELETED "deleted"
  3819. from AMS_SALE_ORDER a_s_order
  3820. left join RMS_SHIPPER r_shipper
  3821. on a_s_order.SHIPPER_ID=r_shipper.SHIPPER_ID
  3822. left join RMS_CONSIGNEE r_consignee
  3823. on a_s_order.RECEIVE_ID=r_consignee.CONSIGNEE_ID
  3824. LEFT JOIN AMS_SALE_MATERIAL ASM
  3825. ON ASM.SALE_ORDER_ID = a_s_order.SALE_ORDER_ID
  3826. LEFT JOIN RMS_MATERIAL RM
  3827. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  3828. LEFT JOIN RMS_SALER R_SALER
  3829. ON R_SALER.SALER_ID = a_s_order.SALER_ID
  3830. where a_s_order.SALE_ORDER_STATUS in (2,4)
  3831. and a_s_order.DELETED = 1
  3832. and a_s_order.SALE_TYPE = 1
  3833. <if test="con != null">
  3834. and (instr(r_consignee.CONSIGNEE_COMPANY_NAME, #{con}) > 0 or instr(a_s_order.SALE_NUMBER, #{con}) > 0)
  3835. </if>
  3836. <if test="saler != null" >
  3837. and R_SALER.SALER_NAME = #{saler}
  3838. </if>
  3839. <if test="oneDate != null">
  3840. and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= a_s_order.UPDATE_TIME
  3841. </if>
  3842. <if test="startDate != null">
  3843. and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= a_s_order.UPDATE_TIME
  3844. and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >= a_s_order.UPDATE_TIME
  3845. </if>
  3846. <if test="consigneeSsoId != null">
  3847. and r_consignee.CONSIGNEE_SSO_ID = #{consigneeSsoId}
  3848. </if>
  3849. ORDER BY a_s_order.UPDATE_TIME DESC
  3850. )
  3851. <where>
  3852. <if test="saleNumber != null">
  3853. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  3854. "saleNumber" like '%${item}%'
  3855. </foreach>
  3856. </if>
  3857. <if test="materialName != null">
  3858. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  3859. "materialName" like '%${item}%'
  3860. </foreach>
  3861. </if>
  3862. <if test="materialSpecification != null">
  3863. <foreach collection="materialSpecification" item="item" open="(" separator="or" close=")">
  3864. "materialSpecification" like '%${item}%'
  3865. </foreach>
  3866. </if>
  3867. <if test="materialModel != null">
  3868. <foreach collection="materialModel" item="item" open="(" separator="or" close=")">
  3869. "materialModel" like '%${item}%'
  3870. </foreach>
  3871. </if>
  3872. <if test="statusStr != null">
  3873. <foreach collection="statusStr" item="item" open="(" separator="or" close=")">
  3874. and "statusStr" like '%${item}%'
  3875. </foreach>
  3876. </if>
  3877. <!-- <if test="startTime != null">-->
  3878. <!-- and "insertTime" &gt;= to_date('${startTime}','yyyy-mm-dd')-->
  3879. <!-- </if>-->
  3880. <!-- <if test="endTime != null">-->
  3881. <!-- and "insertTime" &lt;= to_date('${endTime}','yyyy-mm-dd')-->
  3882. <!-- </if>-->
  3883. <if test="shipperName != null">
  3884. and
  3885. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  3886. "shipperName" like '%${item}%'
  3887. </foreach>
  3888. </if>
  3889. <if test="consigneeCompanyName != null">
  3890. and
  3891. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  3892. "consigneeCompanyName" like '%${item}%'
  3893. </foreach>
  3894. </if>
  3895. <if test="consigneeWarrantyAmount != null">
  3896. and
  3897. <foreach collection="consigneeWarrantyAmount" item="item" open="(" separator="or" close=")">
  3898. "consigneeWarrantyAmount" like '%${item}%'
  3899. </foreach>
  3900. </if>
  3901. <if test="consigneeWarrantyWeight != null">
  3902. and
  3903. <foreach collection="consigneeWarrantyWeight" item="item" open="(" separator="or" close=")">
  3904. "consigneeWarrantyWeight" like '%${item}%'
  3905. </foreach>
  3906. </if>
  3907. <if test="saleOrderIsselfMention != null">
  3908. and
  3909. <foreach collection="saleOrderIsselfMention" item="item" open="(" separator="or" close=")">
  3910. "saleOrderIsselfMention" like '%${item}%'
  3911. </foreach>
  3912. </if>
  3913. <if test="saleAccountBalance != null">
  3914. and
  3915. <foreach collection="saleAccountBalance" item="item" open="(" separator="or" close=")">
  3916. "saleAccountBalance" like '%${item}%'
  3917. </foreach>
  3918. </if>
  3919. <if test="saleCurrentOrderAmount != null">
  3920. and
  3921. <foreach collection="saleCurrentOrderAmount" item="item" open="(" separator="or" close=")">
  3922. "saleCurrentOrderAmount" like '%${item}%'
  3923. </foreach>
  3924. </if>
  3925. <if test="saleHistoricalOrderAmout != null">
  3926. and
  3927. <foreach collection="saleHistoricalOrderAmout" item="item" open="(" separator="or" close=")">
  3928. "saleHistoricalOrderAmout" like '%${item}%'
  3929. </foreach>
  3930. </if>
  3931. <if test="saleOrderReceiveCustomer != null">
  3932. and
  3933. <foreach collection="saleOrderReceiveCustomer" item="item" open="(" separator="or" close=")">
  3934. "saleOrderReceiveCustomer" like '%${item}%'
  3935. </foreach>
  3936. </if>
  3937. <if test="saleUnitPrice != null">
  3938. and
  3939. <foreach collection="saleUnitPrice" item="item" open="(" separator="or" close=")">
  3940. "saleUnitPrice" like '%${item}%'
  3941. </foreach>
  3942. </if>
  3943. <if test="saleOrderTax != null">
  3944. and
  3945. <foreach collection="saleOrderTax" item="item" open="(" separator="or" close=")">
  3946. "saleOrderTax" like '%${item}%'
  3947. </foreach>
  3948. </if>
  3949. <if test="saleRemark != null">
  3950. and
  3951. <foreach collection="saleRemark" item="item" open="(" separator="or" close=")">
  3952. "saleRemark" like '%${item}%'
  3953. </foreach>
  3954. </if>
  3955. </where>
  3956. </select>
  3957. <select id="getAllSteelSaleOrderList" parameterType="java.util.Map" resultType="java.util.Map" >
  3958. select * from(
  3959. select a_s_order.SALE_ORDER_ID "saleOrderId",
  3960. a_s_order.SALE_NUMBER "saleNumber",
  3961. r_shipper.SHIPPER_NAME "shipperName",
  3962. r_consignee.CONSIGNEE_COMPANY_NAME "consigneeCompanyName",
  3963. r_consignee.CONSIGNEE_WARRANTY_AMOUNT "consigneeWarrantyAmount",
  3964. r_consignee.CONSIGNEE_WARRANTY_WEIGHT "consigneeWarrantyWeight",
  3965. a_s_order.SALE_ORDER_ISSELF_MENTION "saleOrderIsselfMention",
  3966. a_s_order.SALE_ACCOUNT_BALANCE "saleAccountBalance",
  3967. a_s_order.SALE_CURRENT_ORDER_AMOUNT "saleCurrentOrderAmount",
  3968. a_s_order.SALE_HISTORICAL_ORDER_AMOUNT "saleHistoricalOrderAmout",
  3969. a_s_order.SALE_ORDER_RECEIVE_CUSTOMER "saleOrderReceiveCustomer",
  3970. a_s_order.SALE_UNIT_PRICE "saleUnitPrice",
  3971. a_s_order.SALE_ORDER_TAX "saleOrderTax",
  3972. a_s_order.SALE_REMARK "saleRemark",
  3973. a_s_order.INSERT_TIME "insertTime",
  3974. DECODE(a_s_order.SALE_ORDER_STATUS || a_s_order.DELETED,00,'未上传',10,'已上传',20,'销售已提交',40,'财务已审批',21,'反审核',41,'反审核',22,'已关闭',42,'已关闭') "statusStr",
  3975. RM.MATERIAL_NAME "materialName",
  3976. RM.MATERIAL_SPECIFICATION "materialSpecification",
  3977. RM.MATERIAL_MODEL "materialModel",
  3978. RM.MATERIAL_NAME || RM.MATERIAL_SPECIFICATION || RM.MATERIAL_MODEL "nameSpecificationModel",
  3979. ASM.SALE_WAREHOUSE "saleWareHouse"
  3980. from AMS_SALE_ORDER a_s_order
  3981. left join RMS_SHIPPER r_shipper
  3982. on a_s_order.SHIPPER_ID=r_shipper.SHIPPER_ID
  3983. left join RMS_CONSIGNEE r_consignee
  3984. on a_s_order.RECEIVE_ID=r_consignee.CONSIGNEE_ID
  3985. LEFT JOIN AMS_SALE_MATERIAL ASM
  3986. ON ASM.SALE_ORDER_ID = a_s_order.SALE_ORDER_ID
  3987. LEFT JOIN RMS_MATERIAL RM
  3988. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  3989. where a_s_order.CLOSE_STATUS is null
  3990. and a_s_order.DELETED = 0
  3991. <if test="con != null">
  3992. and (instr(r_consignee.CONSIGNEE_COMPANY_NAME, #{con}) > 0 or instr(a_s_order.SALE_NUMBER, #{con}) > 0)
  3993. </if>
  3994. <if test="shipperId != null">
  3995. and a_s_order.SHIPPER_ID = #{shipperId}
  3996. </if>
  3997. <if test="saleType != null">
  3998. and a_s_order.SALE_TYPE = #{saleType}
  3999. </if>
  4000. <if test="saleType == null">
  4001. and a_s_order.SALE_TYPE is null
  4002. </if>
  4003. <if test="consigneeSsoId != null">
  4004. and r_consignee.CONSIGNEE_SSO_ID = #{consigneeSsoId}
  4005. </if>
  4006. ORDER BY a_s_order.UPDATE_TIME DESC
  4007. )
  4008. <where>
  4009. <if test="saleNumber != null">
  4010. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  4011. "saleNumber" like '%${item}%'
  4012. </foreach>
  4013. </if>
  4014. <if test="materialName != null">
  4015. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  4016. "materialName" like '%${item}%'
  4017. </foreach>
  4018. </if>
  4019. <if test="materialSpecification != null">
  4020. <foreach collection="materialSpecification" item="item" open="(" separator="or" close=")">
  4021. "materialSpecification" like '%${item}%'
  4022. </foreach>
  4023. </if>
  4024. <if test="materialModel != null">
  4025. <foreach collection="materialModel" item="item" open="(" separator="or" close=")">
  4026. "materialModel" like '%${item}%'
  4027. </foreach>
  4028. </if>
  4029. <if test="statusStr != null">
  4030. <foreach collection="statusStr" item="item" open="(" separator="or" close=")">
  4031. and "statusStr" like '%${item}%'
  4032. </foreach>
  4033. </if>
  4034. <!-- <if test="startTime != null">-->
  4035. <!-- and "insertTime" &gt;= to_date('${startTime}','yyyy-mm-dd')-->
  4036. <!-- </if>-->
  4037. <!-- <if test="endTime != null">-->
  4038. <!-- and "insertTime" &lt;= to_date('${endTime}','yyyy-mm-dd')-->
  4039. <!-- </if>-->
  4040. <if test="shipperName != null">
  4041. and
  4042. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  4043. "shipperName" like '%${item}%'
  4044. </foreach>
  4045. </if>
  4046. <if test="consigneeCompanyName != null">
  4047. and
  4048. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  4049. "consigneeCompanyName" like '%${item}%'
  4050. </foreach>
  4051. </if>
  4052. <if test="consigneeWarrantyAmount != null">
  4053. and
  4054. <foreach collection="consigneeWarrantyAmount" item="item" open="(" separator="or" close=")">
  4055. "consigneeWarrantyAmount" like '%${item}%'
  4056. </foreach>
  4057. </if>
  4058. <if test="consigneeWarrantyWeight != null">
  4059. and
  4060. <foreach collection="consigneeWarrantyWeight" item="item" open="(" separator="or" close=")">
  4061. "consigneeWarrantyWeight" like '%${item}%'
  4062. </foreach>
  4063. </if>
  4064. <if test="saleOrderIsselfMention != null">
  4065. and
  4066. <foreach collection="saleOrderIsselfMention" item="item" open="(" separator="or" close=")">
  4067. "saleOrderIsselfMention" like '%${item}%'
  4068. </foreach>
  4069. </if>
  4070. <if test="saleAccountBalance != null">
  4071. and
  4072. <foreach collection="saleAccountBalance" item="item" open="(" separator="or" close=")">
  4073. "saleAccountBalance" like '%${item}%'
  4074. </foreach>
  4075. </if>
  4076. <if test="saleCurrentOrderAmount != null">
  4077. and
  4078. <foreach collection="saleCurrentOrderAmount" item="item" open="(" separator="or" close=")">
  4079. "saleCurrentOrderAmount" like '%${item}%'
  4080. </foreach>
  4081. </if>
  4082. <if test="saleHistoricalOrderAmout != null">
  4083. and
  4084. <foreach collection="saleHistoricalOrderAmout" item="item" open="(" separator="or" close=")">
  4085. "saleHistoricalOrderAmout" like '%${item}%'
  4086. </foreach>
  4087. </if>
  4088. <if test="saleOrderReceiveCustomer != null">
  4089. and
  4090. <foreach collection="saleOrderReceiveCustomer" item="item" open="(" separator="or" close=")">
  4091. "saleOrderReceiveCustomer" like '%${item}%'
  4092. </foreach>
  4093. </if>
  4094. <if test="saleUnitPrice != null">
  4095. and
  4096. <foreach collection="saleUnitPrice" item="item" open="(" separator="or" close=")">
  4097. "saleUnitPrice" like '%${item}%'
  4098. </foreach>
  4099. </if>
  4100. <if test="saleOrderTax != null">
  4101. and
  4102. <foreach collection="saleOrderTax" item="item" open="(" separator="or" close=")">
  4103. "saleOrderTax" like '%${item}%'
  4104. </foreach>
  4105. </if>
  4106. <if test="saleRemark != null">
  4107. and
  4108. <foreach collection="saleRemark" item="item" open="(" separator="or" close=")">
  4109. "saleRemark" like '%${item}%'
  4110. </foreach>
  4111. </if>
  4112. </where>
  4113. </select>
  4114. <!-- 修改厂内未装货车辆的运单车牌号 -->
  4115. <update id="updateCapacityNumberInFactory" parameterType="java.util.Map" >
  4116. UPDATE OMSTRUCK_ORDER OO
  4117. SET OO.CAPACITY_ID = #{capacityId}
  4118. WHERE OO.ORDER_ID = #{orderId}
  4119. </update>
  4120. <select id="getCarrierByAddress" parameterType="DECIMAL" resultType="java.util.Map" >
  4121. SELECT DISTINCT ACTP.CARRIER_ID "carrierId"
  4122. FROM AMS_CONTRACT_TRANSPORT_PRICE ACTP
  4123. LEFT JOIN RMS_RECEIVE_PLACE RRP
  4124. ON RRP.PLACE_ID = ACTP.PLACE_ID
  4125. WHERE RRP.ADDRESS_ID = #{addressId}
  4126. </select>
  4127. <select id="getSaleCokeOrder" parameterType="java.util.Map" resultType="java.util.Map">
  4128. SELECT DISTINCT * FROM(
  4129. SELECT a_s_order.SALE_ORDER_ID "saleOrderId",
  4130. a_s_order.SALE_NUMBER "saleNumber",
  4131. r_shipper.SHIPPER_NAME "shipperName",
  4132. r_consignee.CONSIGNEE_COMPANY_NAME "consigneeCompanyName",
  4133. r_consignee.CONSIGNEE_WARRANTY_AMOUNT "consigneeWarrantyAmount",
  4134. r_consignee.CONSIGNEE_WARRANTY_WEIGHT "consigneeWarrantyWeight",
  4135. a_s_order.SALE_ORDER_ISSELF_MENTION "saleOrderIsselfMention",
  4136. a_s_order.SALE_ACCOUNT_BALANCE "saleAccountBalance",
  4137. a_s_order.SALE_CURRENT_ORDER_AMOUNT "saleCurrentOrderAmount",
  4138. a_s_order.SALE_HISTORICAL_ORDER_AMOUNT "saleHistoricalOrderAmout",
  4139. a_s_order.SALE_ORDER_RECEIVE_CUSTOMER "saleOrderReceiveCustomer",
  4140. a_s_order.SALE_UNIT_PRICE "saleUnitPrice",
  4141. a_s_order.SALE_ORDER_TAX "saleOrderTax",
  4142. a_s_order.SALE_REMARK "saleRemark",
  4143. a_s_order.INSERT_TIME "insertTime",
  4144. DECODE(a_s_order.SALE_ORDER_STATUS,2,'销售已提交',4,'财务已审批') "statusStr",
  4145. RM.MATERIAL_NAME "materialName",
  4146. ASM.MATERIAL_NUMBER "materialNumber",
  4147. ASM.SALE_WAREHOUSE "saleWareHouse",
  4148. a_s_order.DELETED "deleted",
  4149. a_s_order.SHIPPER_ID "shipperId",
  4150. a_s_order.RECEIVE_ID "receiveId",
  4151. a_s_order.SALE_ORDER_ISSELF_MENTION "isSelfMention"
  4152. from AMS_SALE_ORDER a_s_order
  4153. left join RMS_SHIPPER r_shipper
  4154. on a_s_order.SHIPPER_ID=r_shipper.SHIPPER_ID
  4155. left join RMS_CONSIGNEE r_consignee
  4156. on a_s_order.RECEIVE_ID=r_consignee.CONSIGNEE_ID
  4157. LEFT JOIN AMS_SALE_MATERIAL ASM
  4158. ON ASM.SALE_ORDER_ID = a_s_order.SALE_ORDER_ID
  4159. LEFT JOIN RMS_MATERIAL RM
  4160. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  4161. where a_s_order.SALE_ORDER_STATUS in (2,4)
  4162. and a_s_order.CLOSE_STATUS is null
  4163. and a_s_order.DELETED = 0
  4164. and ASM.DELETED IS NULL
  4165. <if test="con != null">
  4166. 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 )
  4167. </if>
  4168. <if test="oneDate != null">
  4169. and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= a_s_order.UPDATE_TIME
  4170. </if>
  4171. <if test="startDate != null">
  4172. and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= a_s_order.UPDATE_TIME
  4173. and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >= a_s_order.UPDATE_TIME
  4174. </if>
  4175. <if test="shipperId != null">
  4176. and a_s_order.SHIPPER_ID = #{shipperId}
  4177. </if>
  4178. <if test="consigneeSsoId != null">
  4179. and r_consignee.CONSIGNEE_SSO_ID = #{consigneeSsoId}
  4180. </if>
  4181. <if test="saleType == null">
  4182. and a_s_order.SALE_TYPE is null
  4183. </if>
  4184. ORDER BY a_s_order.UPDATE_TIME DESC
  4185. )
  4186. <where>
  4187. <if test="saleNumber != null">
  4188. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  4189. "saleNumber" like '%${item}%'
  4190. </foreach>
  4191. </if>
  4192. <if test="materialName != null">
  4193. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  4194. "materialName" like '%${item}%'
  4195. </foreach>
  4196. </if>
  4197. <if test="materialSpecification != null">
  4198. <foreach collection="materialSpecification" item="item" open="(" separator="or" close=")">
  4199. "materialSpecification" like '%${item}%'
  4200. </foreach>
  4201. </if>
  4202. <if test="materialModel != null">
  4203. <foreach collection="materialModel" item="item" open="(" separator="or" close=")">
  4204. "materialModel" like '%${item}%'
  4205. </foreach>
  4206. </if>
  4207. <if test="statusStr != null">
  4208. <foreach collection="statusStr" item="item" open="(" separator="or" close=")">
  4209. and "statusStr" like '%${item}%'
  4210. </foreach>
  4211. </if>
  4212. <!-- <if test="startTime != null">-->
  4213. <!-- and "insertTime" &gt;= to_date('${startTime}','yyyy-mm-dd')-->
  4214. <!-- </if>-->
  4215. <!-- <if test="endTime != null">-->
  4216. <!-- and "insertTime" &lt;= to_date('${endTime}','yyyy-mm-dd')-->
  4217. <!-- </if>-->
  4218. <if test="shipperName != null">
  4219. and
  4220. <foreach collection="shipperName" item="item" open="(" separator="or" close=")">
  4221. "shipperName" like '%${item}%'
  4222. </foreach>
  4223. </if>
  4224. <if test="consigneeCompanyName != null">
  4225. and
  4226. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  4227. "consigneeCompanyName" like '%${item}%'
  4228. </foreach>
  4229. </if>
  4230. <if test="consigneeWarrantyAmount != null">
  4231. and
  4232. <foreach collection="consigneeWarrantyAmount" item="item" open="(" separator="or" close=")">
  4233. "consigneeWarrantyAmount" like '%${item}%'
  4234. </foreach>
  4235. </if>
  4236. <if test="consigneeWarrantyWeight != null">
  4237. and
  4238. <foreach collection="consigneeWarrantyWeight" item="item" open="(" separator="or" close=")">
  4239. "consigneeWarrantyWeight" like '%${item}%'
  4240. </foreach>
  4241. </if>
  4242. <if test="saleOrderIsselfMention != null">
  4243. and
  4244. <foreach collection="saleOrderIsselfMention" item="item" open="(" separator="or" close=")">
  4245. "saleOrderIsselfMention" like '%${item}%'
  4246. </foreach>
  4247. </if>
  4248. <if test="saleAccountBalance != null">
  4249. and
  4250. <foreach collection="saleAccountBalance" item="item" open="(" separator="or" close=")">
  4251. "saleAccountBalance" like '%${item}%'
  4252. </foreach>
  4253. </if>
  4254. <if test="saleCurrentOrderAmount != null">
  4255. and
  4256. <foreach collection="saleCurrentOrderAmount" item="item" open="(" separator="or" close=")">
  4257. "saleCurrentOrderAmount" like '%${item}%'
  4258. </foreach>
  4259. </if>
  4260. <if test="saleHistoricalOrderAmout != null">
  4261. and
  4262. <foreach collection="saleHistoricalOrderAmout" item="item" open="(" separator="or" close=")">
  4263. "saleHistoricalOrderAmout" like '%${item}%'
  4264. </foreach>
  4265. </if>
  4266. <if test="saleOrderReceiveCustomer != null">
  4267. and
  4268. <foreach collection="saleOrderReceiveCustomer" item="item" open="(" separator="or" close=")">
  4269. "saleOrderReceiveCustomer" like '%${item}%'
  4270. </foreach>
  4271. </if>
  4272. <if test="saleUnitPrice != null">
  4273. and
  4274. <foreach collection="saleUnitPrice" item="item" open="(" separator="or" close=")">
  4275. "saleUnitPrice" like '%${item}%'
  4276. </foreach>
  4277. </if>
  4278. <if test="saleOrderTax != null">
  4279. and
  4280. <foreach collection="saleOrderTax" item="item" open="(" separator="or" close=")">
  4281. "saleOrderTax" like '%${item}%'
  4282. </foreach>
  4283. </if>
  4284. <if test="saleRemark != null">
  4285. and
  4286. <foreach collection="saleRemark" item="item" open="(" separator="or" close=")">
  4287. "saleRemark" like '%${item}%'
  4288. </foreach>
  4289. </if>
  4290. </where>
  4291. </select>
  4292. <select id="findStatus" parameterType="DECIMAL" resultType="java.lang.Integer" >
  4293. SELECT ASO.SALE_ORDER_STATUS AS "saleStatus"
  4294. FROM AMS_SALE_ORDER_MATERIAL ASOM
  4295. LEFT JOIN AMS_SALE_ORDER ASO
  4296. ON ASO.SALE_ORDER_ID = ASOM.SALE_ORDER_ID
  4297. WHERE ASOM.SALE_ORDER_MATERIAL_ID = #{saleOrderMaterialId}
  4298. </select>
  4299. <select id="getPlaceId" parameterType="DECIMAL" resultType="DECIMAL" >
  4300. SELECT ASOM.SALE_SHIPPING_ADDRESS_ID "placeId"
  4301. FROM AMS_SALE_ORDER_MATERIAL ASOM
  4302. WHERE ASOM.SALE_ORDER_MATERIAL_ID = #{saleOrderMaterialId}
  4303. </select>
  4304. <select id="getAddressPriceList" parameterType="java.util.Map" resultType="java.util.Map" >
  4305. SELECT ACTP.PRICE_ID AS "priceId"
  4306. FROM AMS_CONTRACT_TRANSPORT_PRICE ACTP
  4307. LEFT JOIN RMS_RECEIVE_PLACE RRP
  4308. ON RRP.PLACE_ID = ACTP.PLACE_ID
  4309. WHERE ACTP.CARRIER_ID = #{carrierId}
  4310. AND RRP.ADDRESS_ID = #{addressId}
  4311. ORDER BY ACTP.PRICE_ID DESC
  4312. </select>
  4313. <select id="findSelfMention" parameterType="DECIMAL" resultType="java.lang.String" >
  4314. SELECT ASO.SALE_ORDER_ISSELF_MENTION AS "selfMention"
  4315. FROM AMS_SALE_ORDER_MATERIAL ASOM
  4316. LEFT JOIN AMS_SALE_ORDER ASO
  4317. ON ASO.SALE_ORDER_ID = ASOM.SALE_ORDER_ID
  4318. WHERE ASOM.SALE_ORDER_MATERIAL_ID = #{saleOrderMaterialId}
  4319. </select>
  4320. <select id="findReceiveId" parameterType="java.lang.String" resultType="DECIMAL" >
  4321. SELECT RC.CONSIGNEE_ID AS "receiveId"
  4322. FROM RMS_CONSIGNEE RC
  4323. WHERE RC.CONSIGNEE_COMPANY_NAME = #{receiveName}
  4324. </select>
  4325. <select id="findSalerId" parameterType="java.lang.String" resultType="DECIMAL" >
  4326. SELECT RS.SALER_ID AS "salerId"
  4327. FROM RMS_SALER RS
  4328. WHERE RS.SALER_NAME = #{salerName}
  4329. </select>
  4330. <select id="findMaterialId" parameterType="java.util.Map" resultType="DECIMAL">
  4331. SELECT RM.MATERIAL_ID AS "materialId"
  4332. FROM RMS_MATERIAL RM
  4333. WHERE RM.MATERIAL_NAME = #{name}
  4334. AND RM.MATERIAL_SPECIFICATION = #{specification}
  4335. <if test="model != null">
  4336. AND RM.MATERIAL_MODEL = #{model}
  4337. </if>
  4338. </select>
  4339. <select id="findAddressId" parameterType="java.util.Map" resultType="DECIMAL" >
  4340. SELECT RRA.ADDRESS_ID AS "addressId"
  4341. FROM RMS_RECEIVE_ADDRESS RRA
  4342. WHERE RRA.ADDRESS_PROVINCE = #{province}
  4343. AND RRA.ADDRESS_DISTRICT = #{district}
  4344. AND RRA.ADDRESS_TOWN = #{town}
  4345. </select>
  4346. <select id="getSaleMaterialMessage" parameterType="DECIMAL" resultType="java.util.Map" >
  4347. SELECT ASM.MATERIAL_ID "materialId",
  4348. OO.ORDER_ID "orderId",
  4349. TTR.RESULT_TOTAL_ID "resultTotalId",
  4350. OO.ORDER_STATUS "orderStatus",
  4351. WOR.RESULT_ID "outBoundId",
  4352. ASM.MATERIAL_NUMBER "materialNumber"
  4353. FROM AMS_SALE_MATERIAL ASM
  4354. LEFT JOIN AMS_SALE_TRUCKNO_MATERIAL ASTM
  4355. ON ASTM.MATERIAL_ID = ASM.SALE_MATERIAL_ID
  4356. LEFT JOIN OMSTRUCK_ORDER OO
  4357. ON ASTM.SALE_ORDER_MATERIAL_ID = OO.ORDER_PLAN_ID
  4358. AND OO.ORDER_TYPE = 1
  4359. LEFT JOIN WMSP_OUTBOUND_RESULT WOR
  4360. ON WOR.BILL_LADING_ID = OO.ORDER_ID
  4361. LEFT JOIN TMSTRUCK_TOTAL_RESULT TTR
  4362. ON TTR.ORDER_ID = OO.ORDER_ID
  4363. WHERE ASM.SALE_MATERIAL_ID = #{saleMaterialId}
  4364. </select>
  4365. <select id="findOrderMaxNum" parameterType="DECIMAL" resultType="java.lang.Integer" >
  4366. SELECT TLFR.SEGMENT_SQE "maxNum"
  4367. FROM TMSTRUCK_LEAVE_FACTORY_RESULT TLFR
  4368. WHERE TLFR.RESULT_TOTAL_ID = #{resultTotalId}
  4369. </select>
  4370. <select id="getKucunList" resultType="java.util.Map" parameterType="java.util.Map">
  4371. SELECT * FROM (
  4372. SELECT ASO.SALE_NUMBER "saleNo", ASO.SALE_REMARK "saleRemark",
  4373. RAS1.ARRIVAL_NAME "sendStation",
  4374. RAS.ARRIVAL_NAME "toTheStation",
  4375. RM.MATERIAL_NAME "materialName",
  4376. RM.MATERIAL_SPECIFICATION||'('||RM.MATERIAL_MODEL||')' "materialSpa",
  4377. ASM.MATERIAL_NUMBER "materialNum",
  4378. ASM.MATERIAL_WEIGHT "materialWeight",
  4379. RDOINDEP.ORG_NAME "transInDep",
  4380. RDOOUTDEP.ORG_NAME "transOutDep",
  4381. RISWINOF.INWARD_WAREHOUSE_NAME "transInWarehouse",
  4382. RC.CONSIGNEE_COMPANY_NAME "receiveName",
  4383. ASO.SALE_ORDER_ID "saleOrderId",
  4384. RAS1.ARRIVAL_ID "sendStationId",
  4385. RAS.ARRIVAL_ID "toTheStationId",
  4386. ASM.IS_POUND_SALE "isPoundSale",
  4387. ASM.SALE_MATERIAL_ID "saleMaterialId",
  4388. TPAR.RESULT_ID "approveId",
  4389. ASM.IS_POUND_SALE "isPoundSale"
  4390. FROM AMS_SALE_ORDER ASO
  4391. LEFT JOIN AMS_SALE_MATERIAL ASM
  4392. ON ASM.SALE_ORDER_ID = ASO.SALE_ORDER_ID
  4393. LEFT JOIN RMS_MATERIAL RM
  4394. ON RM.MATERIAL_ID = ASM.MATERIAL_ID
  4395. LEFT JOIN TMSTRAIN_PLEASE_APPROVE_RESULT TPAR
  4396. ON TPAR.RAIL_PLAN_ID = ASM.SALE_MATERIAL_ID
  4397. LEFT JOIN RMSTRAIN_ARRIVAL_SEND RAS
  4398. ON RAS.ARRIVAL_ID = TPAR.TO_THE_STATION_ID
  4399. LEFT JOIN RMSTRAIN_ARRIVAL_SEND RAS1
  4400. ON RAS1.ARRIVAL_ID = TPAR.SEND_STATION_ID
  4401. LEFT JOIN RMS_CONSIGNEE RC
  4402. ON RC.CONSIGNEE_ID = ASO.RECEIVE_ID
  4403. LEFT JOIN RMS_DEP_ORG RDOINDEP
  4404. ON RDOINDEP.ORG_CODE = ASO.TRANSFER_IN_DEP
  4405. LEFT JOIN RMS_DEP_ORG RDOOUTDEP
  4406. ON RDOOUTDEP.ORG_CODE = ASO.TRANSFER_OUT_DEP
  4407. LEFT JOIN RMS_INWARD_STEEL_WAREHOUSE RISWINOF
  4408. ON RISWINOF.INWARD_WAREHOUSE_CODE = ASM.TRANSFER_IN_OF_WAREHOUSE
  4409. WHERE ASO.SALE_TYPE = 4
  4410. <if test="oneDate != null">
  4411. and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt; = ASO.INSERT_TIME
  4412. </if>
  4413. <if test="startDate != null">
  4414. and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= ASO.INSERT_TIME
  4415. and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >= ASO.INSERT_TIME
  4416. </if>
  4417. <if test="remark != null">
  4418. and ASO.SALE_REMARK||RM.MATERIAL_NAME LIKE #{remark}
  4419. </if>
  4420. <if test="totheStation != null">
  4421. and RAS.ARRIVAL_NAME LIKE #{totheStation}
  4422. </if>
  4423. <if test="consigneeName != null">
  4424. and RC.CONSIGNEE_COMPANY_NAME like #{consigneeName}
  4425. </if>
  4426. <if test="transferIndep != null">
  4427. and RISWINDEP.INWARD_WAREHOUSE_NAME = #{transferIndep}
  4428. </if>
  4429. )
  4430. </select>
  4431. </mapper>