| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.dk.mdm.mapper.common.CommonMapper">
- <!-- 获取显示顺序的最大值 -->
- <select id="getMaxDisplayNo" resultType="Integer">
- select max(display_no) + 1
- from ${table}
- where 1=1
- <if test="flgValid != null">
- and flg_valid = #{flgValid}
- </if>
- <if test="ftyId != null">
- and fty_id = #{ftyId}
- </if>
- <if test="otherCond">
- and ${otherCond}
- </if>
- <!--数据字典-->
- <if test="dictCode != null">
- and dict_code = #{dictCode}
- </if>
- </select>
- <!--获取编码-->
- <select id="getUniqueCode" resultType="java.util.Map">
- select out_id AS "outId", out_code AS "outNote"
- from dkic_b.f_create_code_id(#{cpId}, #{docName});
- </select>
- <!--获取单号-->
- <select id="getUniqueNote" resultType="java.util.Map">
- select out_id AS "outId", out_note AS "outNote"
- from dkic_b.f_create_note_id(#{cpId}, #{docName});
- </select>
- <!-- 获取用户菜单-->
- <select id="getMenuByUser" resultType="java.util.Map">
- select menu_uuid AS "menuUuid",
- name AS "name",
- menu_name AS "menuName",
- parent_uuid AS "parentUuid",
- menu_type AS "menuType",
- flg_menu AS "flgMenu",
- object_code AS "objectCode",
- object_path AS "objectPath",
- object_icon AS "icon",
- object_id AS "objectId",
- menu_tags AS "menuTags",
- level_code AS "levelCode",
- flg_same_route AS "flgSameRoute",
- flg_choose_id AS "flgChooseId",
- flg_auto_query AS "flgAutoQuery",
- page_grid_info AS "pageGridInfo",
- grade_code AS "gradeCode",
- grade_level AS "gradeLevel",
- is_vip AS "isVip",
- #{appCode} AS "appCode",
- menu_uuid AS "id",
- parent_uuid AS "parentId"
- from
- dkic_b.f_get_user_menu(#{appCode}, #{userId } ::uuid,#{cpId},#{lang})
- </select>
- <!--查用户功能权限-->
- <select id="getUserFunction" resultType="java.util.Map">
- select appm.menu_uuid AS "menuUuid"
- , appm.menu_name as name
- , sys.f_get_name_i18n(appm.menu_name_i18n, #{i18n}) as "menuName"
- , rr.fun_uuid AS "funUuid"
- , appm.object_code AS "objectCode"
- , appm.menu_type AS "menuType"
- from sys.t_app_menu appm
- inner join core.t_user_fun rr
- on rr.fun_uuid = appm.fun_uuid
- where appm.flg_valid
- and appm.app_code = #{appCode}
- and appm.menu_type IN (1, 2)
- and rr.user_id = #{userId};
- </select>
- <!--查询用于隐藏列信息-->
- <select id="getUserTableInfo" resultType="java.util.Map">
- select tuts.code,
- tuts.table_type AS "tableType",
- tuts.table_ref AS "tableRef",
- tuts.columns
- from pset.t_user_table_set tuts
- where tuts.flg_valid
- and tuts.user_id = #{userId};
- </select>
- <!--查导航菜单(自定义报表用)-->
- <select id="getMenuNavigation" resultType="java.util.Map">
- select appm.menu_uuid AS "menuUuid"
- ,sys.f_get_name_i18n(appm.menu_name_i18n,#{i18n}) as "menuName"
- ,appm.parent_uuid AS "parentUuid"
- from sys.t_app_menu appm
- where appm.flg_valid
- <if test="parentUuid">
- and appm.parent_uuid = #{parentUuid} ::uuid
- </if>
- and appm.app_code = 'WEB-MAIN'
- and appm.menu_type = 0
- </select>
- <!-- 获取应用-->
- <select id="getApplication" resultType="java.util.Map">
- select
- app_code as "appCode",
- app_name as "appName"
- from sys.t_application
- </select>
- <!--获取单据-->
- <select id="getDoc" resultType="java.util.Map">
- SELECT
- tsd.doc_name AS "docName"
- FROM
- sys.t_doc tsd
- <where>
- <if test="flgApproval!=null">
- and tsd.flg_approval = #{flgApproval}
- </if>
- <if test="flgPrint!=null">
- and tsd.flg_print = #{flgPrint}
- </if>
- </where>
- </select>
- <!-- 获取数据种类 -->
- <select id="getDataKind" resultType="java.util.Map">
- select kind_code AS "kindCode",
- sys.f_get_name_i18n(kind_name_i18n,#{i18n}) as "kindName",
- sys.f_get_name_i18n(kind_desc,#{i18n}) as "gradeKindDesc",
- kind_type AS "kindType",
- kind_tags AS "kindTags",
- display_no AS "displayNo",
- kind_code AS "id",
- remarks
- from sys.t_data_kind
- where flg_valid
- <if test="kindType != null">
- AND kind_type = #{kindType}
- </if>
- <if test="usedFlag != null">
- AND kind_tags -> 'used' ?? '标签'
- </if>
- <if test="kindTag != null">
- AND kind_tags -> 'used' ?? #{kindTag}
- </if>
- <if test="kindCodeList != null and kindCodeList.size()>0">
- AND kind_code =any(#{kindCodeList,typeHandler=StringListTypeHandler})
- </if>
- order by display_no
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <select id="getDataKindCount" resultType="Long">
- select
- count(1)
- from sys.t_data_kind
- where flg_valid
- <if test="kindType != null">
- AND kind_type = #{kindType}
- </if>
- <if test="usedFlag != null">
- AND kind_tags -> 'used' ?? '标签'
- </if>
- <if test="kindTag != null">
- AND kind_tags -> 'used' ?? #{kindTag}
- </if>
- <if test="kindCodeList != null and kindCodeList.size()>0">
- AND kind_code =any(#{kindCodeList,typeHandler=StringListTypeHandler})
- </if>
- </select>
- <!-- 获取组织部门 -->
- <select id="getOrg" resultType="java.util.Map">
- select org_Id AS "orgId",
- org_code AS "orgCode",
- org_name AS "orgName",
- org_Id AS "id",
- parent_id AS "parentId",
- top_Id AS "topId",
- display_no AS "displayNo",
- remarks
- ,flg_valid as "flgValid"
- ,flg_business as "flgBusiness"
- from dkic_b.t_mst_org
- where flg_valid
- and cp_id = #{cpId}
- <if test="topId != null">
- AND top_id = #{topId}
- </if>
- <if test="orgId != null">
- AND org_id != #{orgId}
- </if>
- <if test="orgCode != null">
- AND org_code LIKE concat('%',my_ex.likequery(#{orgCode}),'%')
- </if>
- <if test="orgName != null">
- AND org_name LIKE concat('%',my_ex.likequery(#{orgName}),'%')
- </if>
- <if test="flgBusiness != null">
- AND flg_business = #{flgBusiness}
- </if>
- <if test="ids != null and ids.size() > 0 ">
- order by case org_id
- <foreach collection="ids" index="index" item="item">
- when #{item}::uuid then #{item}::uuid
- </foreach>
- end
- </if>
- <if test="ids == null">
- order by display_no
- </if>
- </select>
- <!-- 只获取二级部门 按照level_code 排序 -->
- <select id="getProcureOrg" resultType="java.util.Map">
- select org_Id AS "orgId",
- org_code AS "orgCode",
- org_name AS "orgName",
- org_Id AS "id",
- parent_id AS "parentId",
- top_Id AS "topId",
- display_no AS "displayNo",
- remarks
- from dkic_b.t_mst_org
- where flg_valid
- and cp_id = #{cpId}
- and parent_id is NOT null
- <if test="topId != null">
- AND top_id = #{topId}
- </if>
- <if test="orgId != null">
- AND org_id != #{orgId}
- </if>
- <if test="orgCode != null">
- AND org_code LIKE concat('%',my_ex.likequery(#{orgCode}),'%')
- </if>
- <if test="orgName != null">
- AND org_name LIKE concat('%',my_ex.likequery(#{orgName}),'%')
- </if>
- order by level_code
- </select>
- <!-- t_mst_org,(条件查询)个数 -->
- <select id="getOrgCountByPage" resultType="Long">
- SELECT
- count(1)
- from dkic_b.t_mst_org
- where flg_valid
- and cp_id = #{cpId}
- <if test="topId != null">
- AND top_id = #{topId}
- </if>
- <if test="orgId != null">
- AND org_id != #{orgId}
- </if>
- <if test="orgCode != null">
- AND org_code LIKE concat('%',my_ex.likequery(#{orgCode}),'%')
- </if>
- <if test="orgName != null">
- AND org_name LIKE concat('%',my_ex.likequery(#{orgName}),'%')
- </if>
- </select>
- <!-- 获取角色 -->
- <select id="getRole" resultType="java.util.Map">
- select role_Id AS "roleId",
- role_code AS "roleCode",
- role_name AS "roleName",
- display_no AS "displayNo",
- remarks
- from dkic_b.t_mst_role
- where cp_id = #{cpId}
- and flg_valid
- order by display_no
- </select>
- <!-- 获取员工 -->
- <select id="getStaffByPage" resultType="java.util.Map">
- select staff.staff_id AS "staffId",
- staff.staff_code AS "staffCode",
- staff.staff_name AS "staffName",
- staff.staff_phone AS "staffPhone",
- sys.f_code_name(staff.staff_code, staff.staff_name) AS "staffCodeName",
- staff.remarks
- ,tmg.org_id as "orgId"
- ,tmg.org_code as "orgCode"
- ,tmg.org_name as "orgName"
- ,staff.flg_valid as "flgValid"
- from dkic_b.t_mst_staff AS staff
- left join dkic_b.t_mst_org tmg on tmg.org_id = staff.org_id
- where staff.flg_valid
- and staff.cp_id =#{cpId}
- <if test="staffCode != null and staffCode != ''">
- And position (#{staffCode} in staff.staff_code)>0
- </if>
- <if test="staffName != null and staffName != ''">
- And position (#{staffName} in staff.staff_name)>0
- </if>
- <if test="ids != null and ids.size() > 0 ">
- order by case staff.staff_id
- <foreach collection="ids" index="index" item="item">
- when #{item}::uuid then #{item}::uuid
- </foreach>
- end
- </if>
- <if test="ids == null ">
- order by staff.staff_code
- </if>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 查询表t_user,(条件查询)个数 -->
- <select id="getStaffCountByPage" resultType="Long">
- SELECT
- count(1)
- from dkic_b.t_mst_staff AS staff
- where staff.flg_valid
- and staff.cp_id =#{cpId}
- <if test="staffCode != null and staffCode != ''">
- And position (#{staffCode} in staff.staff_code)>0
- </if>
- <if test="staffName != null and staffName != ''">
- And position (#{staffName} in staff.staff_name)>0
- </if>
- </select>
- <!-- 函数查询单个系统参数-->
- <select id="getSettingValue" resultType="String">
- select dkic_b.f_get_setting_value(#{code}, #{cpId})
- </select>
- <!-- 函数查询所有系统参数-->
- <select id="getAllSettingValue" resultType="Map">
- select f_get_all_setting_value AS "setting" from dkic_b.f_get_all_setting_value(#{cpId})
- </select>
- <!-- 函数查询多个系统参数-->
- <select id="getSettingValues" resultType="Map">
- select core.f_get_setting_values(
- #{codes, typeHandler=StringListTypeHandler}, #{cpId})
- </select>
- <!-- 查询系统参数分类 -->
- <select id="getSettingKind" resultType="java.util.Map">
- select sk.kind_code as "classCode",
- sys.f_get_name_i18n_lang(sk.kind_name_i18n, #{i18n}) as "className",
- sk.display_no as "displayNo"
- from sys.t_setting_kind as sk
- where sk.flg_valid
- order by sk.display_no
- </select>
- <!-- 获取数据字典 -->
- <select id="getDictionaryData" resultType="java.util.Map">
- select dd.data_id as "dataId",
- dd.data_id as "id",
- dd.dict_code as "dictCode",
- dd.data_code as "dataCode",
- dd.data_value as "dataValue",
- dd.flg_default as "flgDefault"
- from dkic_b.t_mst_dictionary_data as dd
- where dd.flg_valid
- and dd.cp_id = #{cpId}
- and dd.dict_code = #{dictCode}
- <if test="searchText !=null">
- AND dd.data_value LIKE concat('%',my_ex.likequery(#{searchText}), '%')
- </if>
- order by dd.display_no
- </select>
- <!-- 获取数据字典项目 -->
- <select id="getDictionaryItemData" resultType="java.util.Map">
- SELECT stdi.dict_code AS "dictCode",
- sys.f_get_name_i18n_lang(stdi.dict_name_i18n, #{i18n}) AS "dictName"
- FROM sys.t_dictionary_item stdi
- WHERE stdi.flg_valid
- AND stdi.level_no NOT IN ('1')
- </select>
- <!-- 获取数据类型 -->
- <select id="getValueKind" resultType="java.util.Map">
- select tvk.kind_code AS "kindCode",
- tvk.kind_name as "kindName",
- sys.f_get_name_i18n_lang(tvk.kind_name_i18n,#{i18n}) AS "kindLabel"
- from sys.t_value_kind as tvk
- where tvk.flg_valid
- <if test="used != null and used != ''">
- and #{used} = ANY (tvk.used)
- </if>
- order by tvk.display_no
- </select>
- <!-- 获取仓库 -->
- <select id="getWarehouse" resultType="java.util.Map">
- SELECT t.wh_id as "whId"
- , t.wh_id AS "id"
- , t.wh_name as "whName"
- , t.wh_code as "whCode"
- , t.flg_default as "flgDefault"
- FROM dkic_b.t_mst_warehouse t
- WHERE t.cp_id = #{cpId}
- and t.flg_valid
- <if test="whCode!=null and whCode!=''">
- and position(#{whCode} in t.wh_code) > 0
- </if>
- <if test="whName!=null and whName!=''">
- and position(#{whName} in t.wh_name) > 0
- </if>
- <!-- 部门上有仓库,只能选部门上的仓库;部门上没有仓库,可选所有仓库 -->
- <if test="orgId != null">
- and (select count(1)
- from dkic_b.t_mst_org_wh as tmow
- where tmow.org_id = #{orgId}::uuid) = 0
- or (exists(select 1
- from dkic_b.t_mst_org_wh as tmow
- where tmow.org_id = #{orgId}::uuid
- and tmow.wh_id = t.wh_id))
- </if>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 获取商品 -->
- <select id="getGoods" resultType="java.util.Map">
- select tmgs.sku_id as "skuId",
- tmgs.sku_code as "skuCode",
- tmgs.sku_name as "skuName",
- tmgs.sku_model as "skuModel",
- tmgs.brand_id as "brandId",
- tmgb.brand_name as "brandName",
- tmgs.category_id as "categoryId",
- tmgc.cat_name as "categoryName",
- tmgs.unit_id as "unitId",
- tmgu.unit_name as "unitName",
- tmgs.sub_unit_id as "subUnitId",
- tmgs.conversion_factor as "conversionFactor",
- tmgs.series_id as "seriesId",
- tmgseries.series_name as "seriesName",
- tmgs.sku_spec as "skuSpec",
- tmgs.price_purchase as "pricePurchase",
- tmgs.price_standard as "priceStandard",
- tmgs.price_wholesale as "priceWholesale",
- tmgs.price_limited as "priceLimited",
- tmgs.sku_images as "skuImages",
- tmgs.remarks
- from dkic_b.t_mst_goods_sku as tmgs
- left join dkic_b.t_mst_goods_brand as tmgb on tmgs.brand_id = tmgb.brand_id
- left join dkic_b.t_mst_goods_category as tmgc on tmgs.category_id = tmgc.cat_id
- left join dkic_b.t_mst_goods_series as tmgseries on tmgs.series_id = tmgseries.series_id
- left join dkic_b.t_mst_unit as tmgu on tmgs.unit_id = tmgu.unit_id
- where tmgs.flg_valid
- AND tmgs.cp_id = #{cpId}
- <if test="skuCode != null">
- AND tmgs.sku_code LIKE concat('%',my_ex.likequery(#{skuCode}),'%')
- </if>
- <if test="skuName != null">
- AND tmgs.sku_name LIKE concat('%',my_ex.likequery(#{skuName}),'%')
- </if>
- <if test="brandId != null">
- AND tmgs.brand_id = #{brandId} ::uuid
- </if>
- </select>
- <!-- 获取商品个数 -->
- <select id="getGoodsCountByPage" resultType="Long">
- SELECT
- count(1)
- from dkic_b.t_mst_goods_sku as tmgs
- where tmgs.flg_valid
- AND tmgs.cp_id = #{cpId}
- <if test="skuCode != null">
- AND tmgs.sku_code LIKE concat('%',my_ex.likequery(#{skuCode}),'%')
- </if>
- <if test="skuName != null">
- AND tmgs.sku_name LIKE concat('%',my_ex.likequery(#{skuName}),'%')
- </if>
- </select>
- <!-- 获取商品 -->
- <select id="getGoodsForOrder" resultType="java.util.Map">
- select tmgs.sku_id as "skuId",
- tmgs.sku_code as "skuCode",
- tmgs.sku_name as "skuName",
- tmgs.sku_model as "skuModel",
- tmgs.brand_id as "brandId",
- tmgb.brand_name as "brandName",
- tmgb.short_name as "shortName",
- tmgs.category_id as "categoryId",
- tmgc.cat_name as "categoryName",
- tmgs.unit_id as "unitId",
- tmgu.unit_name as "unitName",
- tmgs.sub_unit_id as "subUnitId",
- tmgus.unit_name as "subUnitName",
- tmgs.flg_sub_unit as "flgSubUnit",
- tmgs.conversion_factor as "conversionFactor",
- tmgs.series_id as "seriesId",
- tmgseries.series_name as "seriesName",
- tmgs.sku_spec as "skuSpec",
- tmgs.price_purchase as "pricePurchase",
- tmgs.price_standard as "priceStandard",
- tmgs.price_wholesale as "priceWholesale",
- tmgs.price_other as "priceOther",
- tmgs.price_limited as "priceLimited",
- tmgs.sku_images as "skuImages",
- tmgs.remarks,
- tmgs.pack_box AS "packBox"
- ,tmgu.decimal_places as "decimalPlaces"
- from dkic_b.t_mst_goods_sku as tmgs
- left join dkic_b.t_mst_goods_brand as tmgb on tmgs.brand_id = tmgb.brand_id
- left join dkic_b.t_mst_goods_category as tmgc on tmgs.category_id = tmgc.cat_id
- left join dkic_b.t_mst_goods_series as tmgseries on tmgs.series_id = tmgseries.series_id
- left join dkic_b.t_mst_unit as tmgu on tmgs.unit_id = tmgu.unit_id
- left join dkic_b.t_mst_unit as tmgus on tmgs.sub_unit_id = tmgus.unit_id
- where tmgs.flg_valid
- AND tmgs.cp_id = #{cpId}
- <if test="skuCode != null">
- AND tmgs.sku_code LIKE concat('%',my_ex.likequery(#{skuCode}),'%')
- </if>
- <if test="skuName != null">
- AND tmgs.sku_name LIKE concat('%',my_ex.likequery(#{skuName}),'%')
- </if>
- <if test="brandId != null">
- AND tmgb.brand_id = #{brandId}::uuid
- </if>
- <if test="categoryId != null">
- AND tmgs.category_id = #{categoryId}::uuid
- </if>
- <if test="searchText != null">
- AND (tmgs.sku_model like concat('%', my_ex.likequery(#{searchText}) , '%')
- OR tmgs.sku_name like concat('%', my_ex.likequery(#{searchText}) , '%')
- )
- </if>
- </select>
- <!-- 获取商品个数 -->
- <select id="getGoodsForOrderCountByPage" resultType="Long">
- SELECT
- count(1)
- from dkic_b.t_mst_goods_sku as tmgs
- where tmgs.flg_valid
- AND tmgs.cp_id = #{cpId}
- <if test="skuCode != null">
- AND tmgs.sku_code LIKE concat('%',my_ex.likequery(#{skuCode}),'%')
- </if>
- <if test="skuName != null">
- AND tmgs.sku_name LIKE concat('%',my_ex.likequery(#{skuName}),'%')
- </if>
- <if test="searchText != null">
- AND (tmgs.sku_model like concat('%', my_ex.likequery(#{searchText}) , '%')
- OR tmgs.sku_name like concat('%', my_ex.likequery(#{searchText}) , '%')
- )
- </if>
- </select>
- <!-- 获取商品(采购) -->
- <select id="getGoodsForPurchase" resultType="java.util.Map">
- select tmgs.sku_id as "skuId",
- tmgs.sku_code as "skuCode",
- tmgs.sku_name as "skuName",
- tmgs.sku_model as "skuModel",
- tmgs.brand_id as "brandId",
- tmgb.brand_name as "brandName",
- tmgs.category_id as "categoryId",
- tmgc.cat_name as "categoryName",
- tmgs.unit_id as "unitId",
- tmgu.unit_name as "unitName",
- tmgu.decimal_places as "decimalPlaces",
- tmgs.sub_unit_id as "subUnitId",
- tmgus.unit_name as "subUnitName",
- tmgs.conversion_factor as "conversionFactor",
- tmgs.series_id as "seriesId",
- tmgseries.series_name as "seriesName",
- tmgs.sku_spec as "skuSpec",
- tmgs.price_purchase as "pricePurchase",
- tmgs.price_standard as "priceStandard",
- tmgs.price_wholesale as "priceWholesale",
- tmgs.price_limited as "priceLimited",
- tmgs.sku_images as "skuImages",
- tmgs.pack_box as "packBox",
- tmgs.remarks
- from dkic_b.t_mst_goods_sku as tmgs
- left join dkic_b.t_mst_goods_brand as tmgb on tmgs.brand_id = tmgb.brand_id
- left join dkic_b.t_mst_goods_category as tmgc on tmgs.category_id = tmgc.cat_id
- left join dkic_b.t_mst_goods_series as tmgseries on tmgs.series_id = tmgseries.series_id
- left join dkic_b.t_mst_unit as tmgu on tmgs.unit_id = tmgu.unit_id
- left join dkic_b.t_mst_unit as tmgus on tmgs.sub_unit_id = tmgus.unit_id
- where tmgs.flg_valid
- AND tmgs.cp_id = #{cpId}
- <if test="skuCode != null">
- AND tmgs.sku_code LIKE concat('%',my_ex.likequery(#{skuCode}),'%')
- </if>
- <if test="skuName != null">
- AND tmgs.sku_name LIKE concat('%',my_ex.likequery(#{skuName}),'%')
- </if>
- </select>
- <!-- 获取商品个数(采购) -->
- <select id="getGoodsForPurchaseCountByPage" resultType="Long">
- SELECT
- count(1)
- from dkic_b.t_mst_goods_sku as tmgs
- where tmgs.flg_valid
- AND tmgs.cp_id = #{cpId}
- <if test="skuCode != null">
- AND tmgs.sku_code LIKE concat('%',my_ex.likequery(#{skuCode}),'%')
- </if>
- <if test="skuName != null">
- AND tmgs.sku_name LIKE concat('%',my_ex.likequery(#{skuName}),'%')
- </if>
- </select>
- <!-- 获取客户 -->
- <select id="getCustomer" resultType="java.util.Map">
- select tmc.cus_id as "cusId",
- tmc.cus_code as "cusCode",
- tmc.cus_name as "cusName",
- tmc.cus_phone as "cusPhone",
- tmc.address_area as "addressArea",
- tmc.address_name as "addressName",
- tmc.address_no as "addressNo",
- tmc.address_gcj02 as "addressGcj02",
- tmc.address_full as "addressFull",
- tmc.contact_name as "contactName",
- tmc.contact_phone as "contactPhone",
- tmc.cus_from as "cusFrom",
- tmdd.data_value as "cusFromName",
- tmc.channel_id as "channelId",
- tmsc.channel_name as "channelName",
- tmc.org_id as "orgId",
- tmo.org_name as "orgName",
- tmc.staff_id as "staffId",
- tms.staff_name as "staffName",
- tmc.report_staff as "reportStaff",
- reportstaff.staff_name as "reportStaffName",
- tmc.report_time as "reportTime",
- tmc.sale_status as "saleStatus",
- tmc.remarks as "remarks",
- tmc.follow_staffs as "followStaffs",
- tmc.last_follow_staff as "lastFollowStaff",
- tmc.last_follow_id as "lastFollowId",
- tmc.last_follow_status as "lastFollowStatus",
- tmc.last_follow_time as "lastFollowTime"
- from dkic_b.t_mst_customer as tmc
- left join dkic_b.t_mst_org tmo on tmc.org_id = tmo.org_id
- left join dkic_b.t_mst_staff tms on tmc.staff_id = tms.staff_id
- left join dkic_b.t_mst_staff as reportstaff on tmc.report_staff = reportstaff.staff_id
- left join dkic_b.t_mst_sale_channel tmsc on tmc.channel_id = tmsc.channel_id
- left join dkic_b.t_mst_dictionary_data tmdd on tmc.cus_from = tmdd.data_id
- where tmc.flg_valid
- AND tmc.cp_id = #{cpId}
- <if test="skuCode != null">
- AND tmc.cus_code = #{cusCode}
- </if>
- <if test="skuName != null">
- AND tmc.cus_name = #{cusName}
- </if>
- </select>
- <!-- 获取客户个数 -->
- <select id="getCustomerCountByPage" resultType="Long">
- SELECT
- count(1)
- from dkic_b.t_mst_customer as tmc
- where tmc.flg_valid
- and tmc.cp_id = #{cpId}
- <if test="skuCode != null">
- AND tmc.cus_code = #{cusCode}
- </if>
- <if test="skuName != null">
- AND tmc.cus_name = #{cusName}
- </if>
- </select>
- <!-- 获取单据Id-->
- <select id="getUuidSeq" resultType="object">
- select sys.f_uuid_seq()
- </select>
- <!-- 获取单据单号-->
- <select id="getDocNo" resultType="java.lang.String">
- select dkic_b.f_create_note(#{cpId}, #{purId}::uuid, #{docCode})
- </select>
- <!--获取供应商-->
- <select id="getSupplier" resultType="java.util.Map">
- select tms.sup_code as "supplierCode",
- tms.sup_name as "supplierName",
- tms.sup_id as "supplierId",
- sys.f_get_name_i18n(tdk.kind_name_i18n, #{i18n}) AS "supplierType",
- tms.contact_name as "contactName",
- tms.contact_phone as "contactPhone",
- tms.flg_valid as "flgValid"
- from dkic_b.t_mst_supplier tms
- LEFT JOIN sys.t_data_kind tdk
- ON tdk.kind_code = tms.sup_type
- where tms.cp_id = #{cpId}
- <if test="supplierName!=null and supplierName!=''">
- AND tms.sup_name LIKE concat('%',my_ex.likequery(#{supplierName}),'%')
- </if>
- <if test="supplierCode!=null and supplierCode!=''">
- AND tms.sup_code LIKE concat('%',my_ex.likequery(#{supplierCode}),'%')
- </if>
- <if test="supplierType!=null and supplierType!=''">
- AND tms.sup_type = #{supplierType}
- </if>
- order by tms.sup_code
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- <if test="limit != null and limit != 0 ">
- limit #{limit}
- </if>
- </select>
- <!--获取供应商数量-->
- <select id="countSupplier" resultType="java.lang.Long">
- select count(1)
- from dkic_b.t_mst_supplier tms
- LEFT JOIN sys.t_data_kind tdk
- ON tdk.kind_code = tms.sup_type
- where tms.cp_id = #{cpId}
- <if test="supplierName!=null and supplierName!=''">
- AND tms.sup_name LIKE concat('%',my_ex.likequery(#{supplierName}),'%')
- </if>
- <if test="supplierCode!=null and supplierCode!=''">
- AND tms.sup_code LIKE concat('%',my_ex.likequery(#{supplierCode}),'%')
- </if>
- <if test="supplierType!=null and supplierType!=''">
- AND tms.sup_type LIKE concat('%',my_ex.likequery(#{supplierType}),'%')
- </if>
- </select>
- <!--获取渠道 -->
- <select id="getChannel" resultType="java.util.Map">
- select c.channel_id as "channelId",
- c.channel_code as "channelCode",
- c.channel_name as "channelName",
- c.sys_code as "sysCode",
- c.display_no as "displayNo"
- from dkic_b.t_mst_sale_channel as c
- where c.flg_valid
- and c.cp_id = #{cpId}
- <if test="channel_code!=null and channel_code!=''">
- AND c.channel_code LIKE concat('%', #{channelCode}, '%')
- </if>
- <if test="channel_name!=null and channel_name!=''">
- AND c.channel_name LIKE concat('%', #{channelName}, '%')
- </if>
- order by c.display_no
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- <if test="limit != null and limit != 0 ">
- limit #{limit}
- </if>
- </select>
- <!-- 查询商品档案-->
- <select id="getGoodsBrand" resultType="java.util.Map">
- SELECT
- tmgb.flg_valid AS "flgValid",
- tmgb.brand_id AS "brandId", tmgb.brand_code AS "brandCode", tmgb.brand_name AS "brandName",
- (SELECT COALESCE(array_to_string(array_agg(tsm.sup_name), ','),'')
- FROM dkic_b.t_mst_supplier_brand tsmb
- left join dkic_b.t_mst_supplier tsm on tsm.sup_id = tsmb.sup_id
- WHERE tsmb.brand_id = tmgb.brand_id) AS "supplierName"
- FROM dkic_b.t_mst_goods_brand tmgb
- <where>
- <if test="searchText !=null">
- AND tmgb.brand_name LIKE concat('%',my_ex.likequery(#{searchText}), '%')
- </if>
- <if test="cpId != null">
- AND tmgb.cp_id = #{cpId}
- </if>
- <if test="flgValid != null">
- AND tmgb.flg_valid = #{flgValid}
- </if>
- </where>
- order by tmgb.display_no asc
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 查询商品种类-->
- <select id="getGoodsCategoryTree" resultType="java.util.Map">
- SELECT
- T.cat_id AS "catId",
- T.cat_code AS "catCode",
- T.cat_name AS "catName",
- T.parent_id AS "parentId",
- T.flg_valid AS "flgValid"
- FROM
- (--当前数据
- SELECT
- tmgc.cat_id,
- tmgc.cat_code,
- tmgc.cat_name,
- tmgc.parent_id,
- tmgc.flg_valid
- FROM
- dkic_b.t_mst_goods_category tmgc
- <where>
- <if test="searchText !=null">
- AND ( tmgc.cat_name LIKE concat('%', my_ex.likequery(#{searchText}), '%')
- or tmgc.remarks LIKE concat('%', my_ex.likequery(#{searchText}), '%'))
- </if>
- <if test="cpId != null">
- AND tmgc.cp_id = #{cpId}
- </if>
- AND tmgc.flg_valid
- </where>
- UNION ALL--父级
- SELECT
- tmgcp.cat_id,
- tmgcp.cat_code,
- tmgcp.cat_name,
- tmgcp.parent_id,
- tmgcp.flg_valid
- FROM
- dkic_b.t_mst_goods_category tmgc
- LEFT JOIN dkic_b.t_mst_goods_category tmgcp ON tmgc.cat_id = ANY ( tmgcp.level_lower )
- <where>
- <if test="searchText !=null">
- AND ( tmgc.cat_name LIKE concat('%', my_ex.likequery(#{searchText}), '%')
- or tmgc.remarks LIKE concat('%', my_ex.likequery(#{searchText}), '%'))
- </if>
- <if test="cpId != null">
- AND tmgc.cp_id = #{cpId}
- </if>
- AND tmgc.flg_valid
- </where>
- ) T
- WHERE T.cat_id IS NOT NULL
- GROUP BY
- T.cat_id,
- T.cat_code,
- T.cat_name,
- T.parent_id,
- T.flg_valid
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 查询表t_mst_goods_brand,(条件查询)个数 -->
- <select id="countGoodsBrand" resultType="Long">
- SELECT
- count(1)
- FROM dkic_b.t_mst_goods_brand tmgb
- <where>
- <if test="searchText !=null">
- AND tmgb.brand_name LIKE concat('%',my_ex.likequery(#{searchText}), '%')
- </if>
- <if test="cpId != null">
- AND tmgb.cp_id = #{cpId}
- </if>
- <if test="flgValid != null">
- AND tmgb.flg_valid = #{flgValid}
- </if>
- </where>
- </select>
- <!-- 查询商品种类-->
- <select id="getGoodsCategory" resultType="java.util.Map">
- SELECT
- cat_id AS "catId",
- cat_code AS "catCode",
- cat_name AS "catName",
- parent_id AS "parentId",
- flg_valid AS "flgValid"
- FROM dkic_b.t_mst_goods_category
- <where>
- <if test="searchText !=null">
- AND ( cat_name LIKE concat('%', my_ex.likequery(#{searchText}), '%')
- or remarks LIKE concat('%', my_ex.likequery(#{searchText}), '%'))
- </if>
- <if test="cpId != null">
- AND cp_id = #{cpId}
- </if>
- </where>
- ORDER BY display_no
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 查询商品种类的个数-->
- <select id="countGoodsCategory" resultType="java.lang.Long">
- SELECT
- count(1)
- FROM dkic_b.t_mst_goods_category
- <where>
- <if test="searchText !=null">
- AND ( cat_name LIKE concat('%', #{searchText}, '%')
- or remarks LIKE concat('%', #{searchText}, '%'))
- </if>
- <if test="cpId != null">
- AND cp_id = #{cpId}
- </if>
- </where>
- </select>
- <!-- 查询商品系列-->
- <select id="getGoodsSeries" resultType="java.util.Map">
- SELECT
- series_id AS "seriesId",
- series_code AS "seriesCode",
- series_name AS "seriesName",
- flg_valid AS "flgValid"
- FROM dkic_b.t_mst_goods_series
- <where>
- <if test="searchText !=null">
- AND ( series_name LIKE concat('%',my_ex.likequery(#{searchText}), '%')
- or remarks LIKE concat('%', my_ex.likequery(#{searchText}), '%'))
- </if>
- <if test="cpId != null">
- AND cp_id = #{cpId}
- </if>
- AND flg_valid
- </where>
- order by display_no asc
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 商品系列个数-->
- <select id="countGoodsSeries" resultType="java.lang.Long">
- SELECT
- count(1)
- FROM dkic_b.t_mst_goods_series
- <where>
- <if test="searchText !=null">
- AND ( series_name LIKE concat('%', my_ex.likequery(#{searchText}), '%')
- or remarks LIKE concat('%', my_ex.likequery(#{searchText}), '%'))
- </if>
- <if test="cpId != null">
- AND cp_id = #{cpId}
- </if>
- </where>
- </select>
- <!-- 获取计量单位-->
- <select id="getUnit" resultType="java.util.Map">
- SELECT
- unit_id AS "unitId",
- unit_code AS "unitCode",
- unit_name AS "unitName",
- decimal_places AS "decimalPlaces",
- flg_valid AS "flgValid"
- FROM dkic_b.t_mst_unit
- <where>
- <if test="searchText !=null">
- AND ( unit_name LIKE concat('%', my_ex.likequery(#{searchText}), '%')
- or remarks LIKE concat('%', my_ex.likequery(#{searchText}), '%'))
- </if>
- <if test="cpId != null">
- AND cp_id = #{cpId}
- </if>
- AND flg_valid
- </where>
- order by display_no asc
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 获取计量单位个数-->
- <select id="countUnit" resultType="java.lang.Long">
- SELECT
- count(1)
- FROM dkic_b.t_mst_unit
- <where>
- <if test="searchText !=null">
- AND ( unit_name LIKE concat('%', my_ex.likequery(#{searchText}), '%')
- or remarks LIKE concat('%', my_ex.likequery(#{searchText}), '%'))
- </if>
- <if test="cpId != null">
- AND cp_id = #{cpId}
- </if>
- </where>
- </select>
- <!--获取仓库档案-->
- <select id="getWarehouseByPage" resultType="java.util.Map">
- SELECT t.wh_id AS "whId",
- t.wh_code AS "whCode",
- t.wh_name AS "whName",
- t.supervisor AS "supervisor",
- t.contact_phone AS "contactPhone",
- t.flg_valid AS "flgValid"
- FROM dkic_b.t_mst_warehouse as t
- <where>
- <if test="searchText !=null">
- AND ( t.wh_name LIKE concat('%', my_ex.likequery(#{searchText}), '%')
- or t.remarks LIKE concat('%', my_ex.likequery(#{searchText}), '%'))
- </if>
- <if test="cpId != null">
- AND t.cp_id = #{cpId}
- </if>
- <if test="flgValid != null">
- AND t.flg_valid = #{flgValid}
- </if>
- <!-- 部门上有仓库,只能选部门上的仓库;部门上没有仓库,可选所有仓库 -->
- <if test="orgId != null">
- and (select count(1)
- from dkic_b.t_mst_org_wh as tmow
- where tmow.org_id = #{orgId}::uuid) = 0
- or (exists(select 1
- from dkic_b.t_mst_org_wh as tmow
- where tmow.org_id = #{orgId}::uuid
- and tmow.wh_id = t.wh_id))
- </if>
- </where>
- order by display_no asc
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!--获取仓库档案个数-->
- <select id="countWarehouseByPage" resultType="Long">
- SELECT count(1)
- FROM dkic_b.t_mst_warehouse as t
- <where>
- <if test="searchText !=null">
- AND ( t.wh_name LIKE concat('%', my_ex.likequery(#{searchText}), '%')
- or t.remarks LIKE concat('%', my_ex.likequery(#{searchText}), '%'))
- </if>
- <if test="cpId != null">
- AND t.cp_id = #{cpId}
- </if>
- <!-- 部门上有仓库,只能选部门上的仓库;部门上没有仓库,可选所有仓库 -->
- <if test="orgId != null">
- and (select count(1)
- from dkic_b.t_mst_org_wh as tmow
- where tmow.org_id = #{orgId}::uuid) = 0
- or (exists(select 1
- from dkic_b.t_mst_org_wh as tmow
- where tmow.org_id = #{orgId}::uuid
- and tmow.wh_id = t.wh_id))
- </if>
- </where>
- </select>
- <!-- 查询库存 -->
- <select id="getInventory" resultType="java.util.Map">
- select tpi.inv_id as "invId",
- tpi.sku_id as "skuId",
- tmgs.sku_code as "skuCode",
- tmgs.sku_name as "skuName",
- tmgs.sku_model as "skuModel",
- tmgs.brand_id as "brandId",
- tmgb.brand_name as "brandName",
- tmgs.category_id as "categoryId",
- tmgc.cat_name as "categoryName",
- tmgs.unit_id as "unitId",
- tmgs.sub_unit_id as "subUnitId",
- tmgs.conversion_factor as "conversionFactor",
- tmgs.series_id as "seriesId",
- tmgseries.series_name as "seriesName",
- tmgs.sku_spec as "skuSpec",
- tmgs.price_purchase as "pricePurchase",
- tmgs.price_standard as "priceStandard",
- tmgs.price_wholesale as "priceWholesale",
- tmgs.price_limited as "priceLimited",
- tmgs.sku_images as "skuImages",
- tpi.non_std_code as "nonStdCode",
- tpi.inv_qty as "invQty",
- tpi.outing_qty as "outingQty",
- tpi.freeze_qty as "freezeQty",
- tpi.usable_qty as "usableQty",
- tpi.wh_id as "whId",
- tmw.wh_code as "whCode",
- tmw.wh_name as "whName",
- tmgs.pack_box as "packBox",
- tmgs.unit_id as "unitId",
- tmgs.sub_unit_id as "subUnitId",
- ul.unit_name as "unitName",
- u2.unit_name as "subUnitName",
- dkic_b.f_get_last_ivt_price(tpi.inv_id,null,null,null) as "priceInto",
- tpi.remarks
- from dkic_b.t_psi_inventory as tpi
- inner join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = tpi.wh_id
- inner join dkic_b.t_mst_goods_sku as tmgs on tmgs.sku_id = tpi.sku_id
- left join dkic_b.t_mst_goods_brand as tmgb on tmgs.brand_id = tmgb.brand_id
- left join dkic_b.t_mst_goods_category as tmgc on tmgs.category_id = tmgc.cat_id
- left join dkic_b.t_mst_goods_series as tmgseries on tmgs.series_id = tmgseries.series_id
- left join dkic_b.t_mst_unit as ul on tmgs.unit_id = ul.unit_id
- left join dkic_b.t_mst_unit as u2 on tmgs.sub_unit_id = u2.unit_id
- where tpi.flg_valid
- AND tpi.cp_id = #{cpId}
- <if test="skuId != null">
- AND tpi.sku_id = #{skuId} ::uuid
- </if>
- <if test="nonStdCode != null">
- AND tpi.non_std_code = #{nonStdCode}
- </if>
- <if test="skuCode != null">
- AND tmgs.sku_code LIKE concat('%',my_ex.likequery(#{skuCode}),'%')
- </if>
- <if test="skuName != null">
- AND tmgs.sku_name LIKE concat('%',my_ex.likequery(#{skuName}),'%')
- </if>
- <if test="whName != null">
- AND tmw.wh_name LIKE concat('%',my_ex.likequery(#{whName}),'%')
- </if>
- <if test="whId != null">
- AND tpi.wh_id = #{whId} ::uuid
- </if>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 查询库存个数 -->
- <select id="getInventoryCountByPage" resultType="Long">
- SELECT
- count(1)
- from dkic_b.t_psi_inventory as tpi
- inner join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = tpi.wh_id
- inner join dkic_b.t_mst_goods_sku as tmgs on tmgs.sku_id = tpi.sku_id
- where tpi.flg_valid
- AND tpi.cp_id = #{cpId}
- <if test="skuId != null">
- AND tpi.sku_id = #{skuId} ::uuid
- </if>
- <if test="nonStdCode != null">
- AND tpi.non_std_code = #{nonStdCode}
- </if>
- <if test="skuCode != null">
- AND tmgs.sku_code LIKE concat('%',my_ex.likequery(#{skuCode}),'%')
- </if>
- <if test="skuName != null">
- AND tmgs.sku_name LIKE concat('%',my_ex.likequery(#{skuName}),'%')
- </if>
- <if test="whName != null">
- AND tmgs.wh_name LIKE concat('%',my_ex.likequery(#{whName}),'%')
- </if>
- </select>
- <!-- 获取销售渠道-->
- <select id="getSaleChannel" resultType="java.util.Map">
- SELECT
- channel_id AS "channelId",
- channel_id AS "id",
- channel_code AS "channelCode",
- channel_name AS "channelName"
- FROM dkic_b.t_mst_sale_channel
- <where>
- flg_valid
- <if test="cpId != null">
- AND cp_id = #{cpId}
- </if>
- order by display_no
- </where>
- </select>
- <!--获取结算方式数据-->
- <select id="getSettlement" resultType="java.util.Map">
- SELECT T.mac_id id,
- T.mac_code AS "macCode",
- T.mac_name AS "macName",
- T.mac_Type,
- dd.data_value AS "macTypeName",
- T.balance,
- T.display_no,
- T.mac_receipt_code,
- T.acc_date,
- T.flg_negative,
- T.remarks,
- T.flg_valid,
- T.cp_id,
- COALESCE ( tmti.amt_trf, 0 ) AS "initBalance"
- FROM
- dkic_b.t_mst_money_account
- AS T LEFT JOIN dkic_b.t_mst_dictionary_data AS dd ON T.mac_type = dd.data_id
- LEFT JOIN (
- SELECT
- tmti.trf_in_mac,
- tmti.amt_trf
- FROM
- dkic_b.t_mac_transfer AS tmt
- INNER JOIN dkic_b.t_mac_transfer_item AS tmti ON tmti.trf_id = tmt.trf_id
- AND tmt.flg_valid
- AND tmti.flg_valid
- AND tmt.trf_type = 0
- ) tmti ON tmti.trf_in_mac = T.mac_id
- WHERE
- T.cp_id = #{cpId}
- and t.flg_valid
- ORDER BY
- T.display_no
- </select>
- <!-- 获取销售渠道-->
- <select id="getSaleChannelPurviewType" resultType="java.util.Map">
- SELECT
- sc.channel_id AS "channelId",
- sc.channel_id AS "id",
- sc.channel_code AS "channelCode",
- sc.channel_name AS "channelName",
- COALESCE ( ( SELECT flg_nolimit FROM dkic_b.t_mst_staff_purview WHERE staff_id = #{staffId} :: UUID and purview_code = #{purviewCode}), FALSE ) "flgNolimit",
- CASE WHEN scsc.channel_id IS NULL THEN FALSE ELSE TRUE END AS "checked"
- FROM dkic_b.t_mst_sale_channel sc
- left JOIN dkic_b.t_mst_sale_channel scsc ON scsc.channel_id = sc.channel_id and sc.channel_id::uuid = any ( (
- select data_ids from dkic_b.t_mst_staff_purview where staff_id = #{staffId}::uuid and purview_code = #{purviewCode})::uuid[])
- <where>
- sc.flg_valid
- <if test="cpId != null">
- AND sc.cp_id = #{cpId}
- </if>
- <if test="channelCode !=null and channelCode !=''">
- AND sc.channel_code LIKE concat('%',my_ex.likequery(#{channelCode}),'%')
- </if>
- <if test="channelName !=null and channelName !=''">
- AND sc.channel_name LIKE concat('%',my_ex.likequery(#{channelName}),'%')
- </if>
- order by sc.display_no
- </where>
- </select>
- <!--获取仓库档案-->
- <!--获取供应商和客户数据-->
- <select id="getSupplierAndCustomer" resultType="java.util.Map">
- select tms.sup_id as "objId",
- tms.sup_code as "objCode",
- tms.sup_name as "objName",
- '供应商' as "objTypeName",
- 1 as "objType",
- tms.flg_valid as "flgValid"
- null as "phone",
- null as "addressFull"
- from dkic_b.t_mst_supplier tms
- <where>
- <if test="flgValid">
- AND tms.flg_valid
- </if>
- <if test="objCode != null and objCode != ''">
- AND tms.sup_code LIKE concat('%',my_ex.likequery(#{objCode}),'%')
- </if>
- <if test="objName != null and objName != ''">
- AND tms.sup_name LIKE concat('%',my_ex.likequery(#{objCode}),'%')
- </if>
- </where>
- union all
- select cus.cus_id as "objId",
- cus.cus_code as "objCode",
- cus.cus_name as "objName",
- '客户' as "objTypeName",
- 2 as "objType",
- cus.flg_valid as "flgValid",
- cus.cus_phone as "phone",
- cus.address_full as "addressFull"
- from dkic_b.t_mst_customer cus
- <where>
- <if test="flgValid">
- AND cus.flg_valid
- </if>
- <if test="objCode != null and objCode != ''">
- AND cus.cus_code LIKE concat('%',my_ex.likequery(#{objCode}),'%')
- </if>
- <if test="objName != null and objName != ''">
- AND cus.cus_name LIKE concat('%',my_ex.likequery(#{objName}),'%')
- </if>
- </where>
- </select>
- <!--获取供应商和客户数据分页-->
- <select id="getSupplierAndCustomerByPage" resultType="java.util.Map">
- select * from (
- select tms.sup_id as "objId",
- tms.sup_code as "objCode",
- tms.sup_name as "objName",
- '供应商' as "objTypeName",
- 1 as "objType",
- tms.flg_valid as "flgValid",
- tms.contact_phone as "phone",
- tms.return_address as "addressFull"
- from dkic_b.t_mst_supplier tms
- <where >
- tms.sup_type = '供应商类别-采购'
- and tms.cp_id = #{cpId}
- <if test="flgValid">
- AND tms.flg_valid
- </if>
- <if test="objCode != null and objCode != ''">
- AND tms.sup_code LIKE concat('%',my_ex.likequery(#{objCode}),'%')
- </if>
- <if test="objName != null and objName != ''">
- AND tms.sup_name LIKE concat('%',my_ex.likequery(#{objCode}),'%')
- </if>
- <if test="searchText != null and searchText != ''">
- AND (
- tms.sup_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
- or tms.contact_phone LIKE concat('%',my_ex.likequery(#{searchText}),'%')
- or tms.return_address LIKE concat('%',my_ex.likequery(#{searchText}),'%')
- )
- </if>
- </where>
- union all
- select cus.cus_id as "objId",
- cus.cus_code as "objCode",
- cus.cus_name as "objName",
- '客户' as "objTypeName",
- 2 as "objType",
- cus.flg_valid as "flgValid",
- cus.cus_phone as "phone",
- cus.address_full as "addressFull"
- from dkic_b.t_mst_customer cus
- <where>
- cus.cp_id = #{cpId}
- <if test="flgValid">
- AND cus.flg_valid
- </if>
- <if test="objCode != null and objCode != ''">
- AND cus.cus_code LIKE concat('%',my_ex.likequery(#{objCode}),'%')
- </if>
- <if test="objName != null and objName != ''">
- AND cus.cus_name LIKE concat('%',my_ex.likequery(#{objName}),'%')
- </if>
- <if test="searchText != null and searchText != ''">
- AND ( cus.cus_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
- or cus.cus_phone LIKE concat('%',my_ex.likequery(#{searchText}),'%')
- or cus.address_full LIKE concat('%',my_ex.likequery(#{searchText}),'%')
- )
- </if>
- </where>
- ) tt
- <where>
- <if test="objType != null and objType != ''">
- AND tt."objType" = #{objType}
- </if>
- </where>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!--获取供应商和客户数据分页-->
- <select id="getSupplierAndCustomerByPageCount" resultType="Long">
- select count(1) from(
- select tms.sup_id as "objId",
- tms.sup_code as "objCode",
- tms.sup_name as "objName",
- '供应商' as "objTypeName",
- 1 as "objType",
- tms.flg_valid as "flgValid",
- null as "phone",
- null as "addressFull"
- from dkic_b.t_mst_supplier tms
- <where>
- tms.sup_type = '供应商类别-采购'
- and tms.cp_id = #{cpId}
- <if test="flgValid">
- AND tms.flg_valid
- </if>
- <if test="objCode != null and objCode != ''">
- AND tms.sup_code LIKE concat('%',my_ex.likequery(#{objCode}),'%')
- </if>
- <if test="objName != null and objName != ''">
- AND tms.sup_name LIKE concat('%',my_ex.likequery(#{objCode}),'%')
- </if>
- <if test="searchText != null and searchText != ''">
- AND (
- tms.sup_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
- or tms.contact_phone LIKE concat('%',my_ex.likequery(#{searchText}),'%')
- or tms.return_address LIKE concat('%',my_ex.likequery(#{searchText}),'%')
- )
- </if>
- </where>
- union all
- select cus.cus_id as "objId",
- cus.cus_code as "objCode",
- cus.cus_name as "objName",
- '客户' as "objTypeName",
- 2 as "objType",
- cus.flg_valid as "flgValid",
- cus.cus_phone as "phone",
- cus.address_full as "addressFull"
- from dkic_b.t_mst_customer cus
- <where>
- and cus.cp_id = #{cpId}
- <if test="flgValid">
- AND cus.flg_valid
- </if>
- <if test="objCode != null and objCode != ''">
- AND cus.cus_code LIKE concat('%',my_ex.likequery(#{objCode}),'%')
- </if>
- <if test="objName != null and objName != ''">
- AND cus.cus_name LIKE concat('%',my_ex.likequery(#{objName}),'%')
- </if>
- <if test="searchText != null and searchText != ''">
- AND ( cus.cus_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
- or cus.cus_phone LIKE concat('%',my_ex.likequery(#{searchText}),'%')
- or cus.address_full LIKE concat('%',my_ex.likequery(#{searchText}),'%')
- )
- </if>
- </where>
- ) tt
- <where>
- <if test="objType != null and objType != ''">
- AND tt."objType" = #{objType}
- </if>
- </where>
- </select>
- <!-- 获取用户 -->
- <select id="getStaff" resultType="java.util.Map">
- select
- s.staff_name as "staffName"
- , s.staff_code as "staffCode"
- , sys.f_code_name(s.staff_code, s.staff_name) AS "staffCodeName"
- , s.staff_id as "staffId"
- , s.staff_id AS "id"
- , s.org_id as "orgId"
- , o.org_name as "orgName"
- , c.cp_name as "cpName"
- FROM dkic_b.t_mst_staff s
- left join dkic_b.t_mst_org o on o.org_id = s.org_id
- left join dkic_a.t_a_company c on c.cp_id = s.cp_id
- where
- s.flg_valid
- and s.hr_status = 1
- and s.cp_id = #{cpId}
- <if test="staffCode !=null and staffCode !=''">
- AND s.staff_code LIKE concat('%',my_ex.likequery(#{staffCode}),'%')
- </if>
- <if test="staffName !=null and staffName !=''">
- AND s.staff_name LIKE concat('%',my_ex.likequery(#{staffName}),'%')
- </if>
- <if test="orgId !=null">
- AND s.org_id = #{orgId}
- </if>
- <if test="orgName !=null and orgName !=''">
- AND o.org_name LIKE concat('%',my_ex.likequery(#{orgName}),'%')
- </if>
- </select>
- <!-- 获取用户 -->
- <select id="getStaffPurviewType" resultType="java.util.Map">
- select
- s.staff_name as "staffName"
- , s.staff_code as "staffCode"
- , s.staff_id as "staffId",
- COALESCE ( ( SELECT flg_nolimit FROM dkic_b.t_mst_staff_purview WHERE staff_id = #{staffId} :: UUID and purview_code = #{purviewCode}), FALSE ) "flgNolimit",
- CASE WHEN ss.staff_id IS NULL THEN FALSE ELSE TRUE END AS "checked"
- FROM dkic_b.t_mst_staff s
- left JOIN dkic_b.t_mst_staff ss ON ss.staff_id = s.staff_id and s.staff_id::uuid = any ( (
- select data_ids from dkic_b.t_mst_staff_purview where staff_id = #{staffId}::uuid and purview_code = #{purviewCode})::uuid[])
- where
- s.flg_valid
- and s.hr_status = 1
- and s.cp_id = #{cpId}
- <if test="staffCode !=null and staffCode !=''">
- AND s.staff_code LIKE concat('%',my_ex.likequery(#{staffCode}),'%')
- </if>
- <if test="staffName !=null and staffName !=''">
- AND s.staff_name LIKE concat('%',my_ex.likequery(#{staffName}),'%')
- </if>
- </select>
- <!-- 获取组织机构 -->
- <select id="getOrganization" resultType="java.util.Map">
- select o.org_id as "orgId"
- , o.org_code as "orgCode"
- , o.org_name as "orgName"
- , sys.f_code_name(o.org_code, o.org_name) AS "orgCodeName"
- from dkic_b.t_mst_org o
- where
- o.flg_valid
- and o.cp_id = #{cpId}
- <if test="orgCode !=null and orgCode !=''">
- AND o.org_code LIKE concat('%',my_ex.likequery(#{orgCode}),'%')
- </if>
- <if test="orgName !=null and orgName !=''">
- AND o.org_name LIKE concat('%',my_ex.likequery(#{orgName}),'%')
- </if>
- order by o.level_code
- </select>
- <!-- 获取组织机构分页 -->
- <select id="getOrganizationByPage" resultType="java.util.Map">
- select o.org_id as "orgId"
- , o.org_code as "orgCode"
- , o.org_name as "orgName"
- , sys.f_code_name(o.org_code, o.org_name) AS "orgCodeName"
- from dkic_b.t_mst_org o
- where
- o.flg_valid
- and o.cp_id = #{cpId}
- <if test="orgCode !=null and orgCode !=''">
- AND o.org_code LIKE concat('%',my_ex.likequery(#{orgCode}),'%')
- </if>
- <if test="orgName !=null and orgName !=''">
- AND o.org_name LIKE concat('%',my_ex.likequery(#{orgName}),'%')
- </if>
- order by o.level_code
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 获取组织机构分个数-->
- <select id="getOrganizationCount" resultType="java.lang.Long">
- SELECT count(1)
- from dkic_b.t_mst_org o
- where
- o.flg_valid
- and o.cp_id = #{cpId}
- <if test="orgCode !=null and orgCode !=''">
- AND o.org_code LIKE concat('%',my_ex.likequery(#{orgCode}),'%')
- </if>
- <if test="orgName !=null and orgName !=''">
- AND o.org_name LIKE concat('%',my_ex.likequery(#{orgName}),'%')
- </if>
- </select>
- <!-- 获取资金账户(下拉)-->
- <select id="getMac" resultType="java.util.Map">
- select tmma.mac_id as "macId",
- tmma.mac_code as "macCode",
- tmma.mac_name as "macName",
- tmma.mac_type as "macType",
- tmma.balance,
- tmma.display_no as "displayNo",
- tmma.flg_default as "flgDefault",
- tmma.mac_receipt_code as "macReceiptCode",
- tmma.remarks
- from dkic_b.t_mst_money_account tmma
- where tmma.flg_valid
- and tmma.cp_id = #{cpId}
- <if test="macCode !=null and macCode !=''">
- AND tmma.mac_code LIKE concat('%',my_ex.likequery(#{macCode}),'%')
- </if>
- <if test="macName !=null and macName !=''">
- AND tmma.mac_name LIKE concat('%',my_ex.likequery(#{macName}),'%')
- </if>
- order by tmma.display_no
- </select>
- <!-- 获取资金账户(放大镜) -->
- <select id="getMoneyAccount" resultType="java.util.Map">
- select tmma.mac_id as "macId",
- tmma.mac_code as "macCode",
- tmma.mac_name as "macName",
- tmma.mac_type as "macType",
- tmma.balance,
- tmma.display_no as "displayNo",
- tmma.flg_default as "flgDefault",
- tmma.mac_receipt_code as "macReceiptCode",
- tmma.remarks
- from dkic_b.t_mst_money_account tmma
- where tmma.flg_valid
- and tmma.cp_id = #{cpId}
- <if test="macCode !=null and macCode !=''">
- AND tmma.mac_code LIKE concat('%',my_ex.likequery(#{macCode}),'%')
- </if>
- <if test="macName !=null and macName !=''">
- AND tmma.mac_name LIKE concat('%',my_ex.likequery(#{macName}),'%')
- </if>
- order by tmma.display_no
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 获取资金账户(放大镜)个数 -->
- <select id="getMoneyAccountCountByPage" resultType="Long">
- SELECT
- count(1)
- from dkic_b.t_mst_money_account tmma
- where tmma.flg_valid
- and tmma.cp_id = #{cpId}
- <if test="macCode !=null and macCode !=''">
- AND tmma.mac_code LIKE concat('%',my_ex.likequery(#{macCode}),'%')
- </if>
- <if test="macName !=null and macName !=''">
- AND tmma.mac_name LIKE concat('%',my_ex.likequery(#{macName}),'%')
- </if>
- </select>
- <!-- 查询表core.t_m_organization,查询业务部门多业务归属 -->
- <select id="selectMultiOrg" resultType="java.util.Map">
- select t.org_id as "orgId",
- t.org_code as "orgCode",
- t.org_name as "orgName",
- case when mo.allocation_ratio is null then 100 else mo.allocation_ratio end as "allocationRatio",
- case when mo.multi_id is null then 0 else 1 end as "selectFlag",
- case when mo.owner_type = '归属类型-主部门' then true else false end as "ownerFlag"
- from dkic_b.t_mst_org t
- left join (SELECT tpmo.owner_id, tpmo.allocation_ratio, tpmo.multi_id, tpmo.owner_type
- from dkic_b.t_psi_order tpo
- inner join dkic_b.t_psi_multi_owner tpmo
- on tpo.order_id = tpmo.order_id
- where tpmo.flg_valid
- and tpmo.owner_type = any (array ['归属类型-主部门' , '归属类型-从部门'])
- and tpo.order_id = #{orderId} ::uuid) mo
- on mo.owner_id = t.org_id
- where t.flg_valid
- <if test="orgCode !=null and orgCode !=''">
- AND t.org_code LIKE concat('%',my_ex.likequery(#{orgCode}),'%')
- </if>
- <if test="orgName !=null and orgName !=''">
- AND t.org_name LIKE concat('%',my_ex.likequery(#{orgName}),'%')
- </if>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 查询表core.t_m_user,查询员工多业务归属 -->
- <select id="selectMultiStaff" resultType="java.util.Map">
- select t.staff_id as "staffId",
- t.staff_code as "staffCode",
- t.staff_name as "staffName",
- tmo.org_name as "orgName",
- case when mo.allocation_ratio is null then 100 else mo.allocation_ratio end as "allocationRatio",
- case when mo.multi_id is null then 0 else 1 end as "selectFlag",
- case when mo.owner_type = '归属类型-主员工' then true else false end as "ownerFlag"
- from dkic_b.t_mst_staff t
- left join dkic_b.t_mst_org as tmo on tmo.org_id = t.org_id
- left join (SELECT tpmo.owner_id, tpmo.allocation_ratio, tpmo.multi_id, tpmo.owner_type
- from dkic_b.t_psi_order tpo
- inner join dkic_b.t_psi_multi_owner tpmo
- on tpo.order_id = tpmo.order_id
- where tpmo.flg_valid
- and tpmo.owner_type = any (array ['归属类型-主员工' , '归属类型-从员工'])
- and tpo.order_id = #{orderId} ::uuid
- ) mo
- on mo.owner_id = t.staff_id
- where t.flg_valid
- <if test="staffCode!=null and staffCode!='' ">
- and t.staff_code LIKE concat('%',my_ex.likequery(#{staffCode}),'%')
- </if>
- <if test="staffName!=null and staffName!='' ">
- and t.staff_name LIKE concat('%',my_ex.likequery(#{staffName}),'%')
- </if>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 查询表core.t_m_org_wh,查询组织仓库 -->
- <select id="selectMultiWarehouse" resultType="java.util.Map">
- select t.wh_id as "whId",
- t.wh_code as "whCode",
- t.wh_name as "whName",
- case when mo.wh_id is null then 0 else 1 end as "selectFlag",
- case when mo.wh_id is null then false else mo.flg_default end as "ownerFlag"
- from dkic_b.t_mst_warehouse t
- left join (SELECT orgwh.flg_default, orgwh.wh_id
- from dkic_b.t_mst_org org
- inner join dkic_b.t_mst_org_wh orgwh
- on org.org_id = orgwh.org_id
- where org.flg_valid
- and org.org_id = #{orgId} ::uuid) mo
- on mo.wh_id = t.wh_id
- where t.flg_valid
- <if test="whCode !=null and whCode !=''">
- AND t.wh_code LIKE concat('%',my_ex.likequery(#{whCode}),'%')
- </if>
- <if test="whName !=null and whName !=''">
- AND t.wh_name LIKE concat('%',my_ex.likequery(#{whName}),'%')
- </if>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 查询表core.t_m_org_mac,查询组织资金账户 -->
- <select id="selectMultiMoneyAccount" resultType="java.util.Map">
- select t.mac_id as "macId",
- t.mac_code as "macCode",
- t.mac_name as "macName",
- case when mo.mac_id is null then 0 else 1 end as "selectFlag",
- case when mo.mac_id is null then false else mo.flg_default end as "ownerFlag"
- from dkic_b.t_mst_money_account t
- left join (SELECT orgmac.flg_default,orgmac.mac_id
- from dkic_b.t_mst_org org
- inner join dkic_b.t_mst_org_mac orgmac
- on org.org_id = orgmac.org_id
- where org.flg_valid
- and org.org_id = #{orgId} ::uuid) mo
- on mo.mac_id = t.mac_id
- where t.flg_valid
- <if test="macCode !=null and macCode !=''">
- AND t.mac_code LIKE concat('%',my_ex.likequery(#{macCode}),'%')
- </if>
- <if test="macName !=null and macName !=''">
- AND t.mac_name LIKE concat('%',my_ex.likequery(#{macName}),'%')
- </if>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 查询库存 -->
- <select id="getGoodsForPurchaseReturn" resultType="java.util.Map">
- select tpi.inv_id as "invId",
- tpi.sku_id as "skuId",
- tmgs.sku_code as "skuCode",
- tmgs.sku_name as "skuName",
- tmgs.sku_model as "skuModel",
- tmgs.brand_id as "brandId",
- tmgb.brand_name as "brandName",
- tmgs.category_id as "categoryId",
- tmgc.cat_name as "categoryName",
- tmgs.unit_id as "unitId",
- tmgu.unit_name as "unitName",
- tmgs.sub_unit_id as "subUnitId",
- tmgs.conversion_factor as "conversionFactor",
- tmgs.series_id as "seriesId",
- tmgseries.series_name as "seriesName",
- tmgs.sku_spec as "skuSpec",
- tmgs.price_purchase as "pricePurchase",
- tmgs.price_standard as "priceStandard",
- tmgs.price_wholesale as "priceWholesale",
- tmgs.price_limited as "priceLimited",
- tmgs.sku_images as "skuImages",
- tpi.non_std_code as "nonStdCode",
- tpi.inv_qty as "invQty",
- tpi.outing_qty as "outingQty",
- tpi.usable_qty as "usableQty",
- tpi.wh_id as "whId",
- tmw.wh_code as "whCode",
- tmw.wh_name as "whName",
- tpi.cost_price as "costPrice",
- tpi.cost_amt as "costAmt",
- tpi.remarks
- from dkic_b.t_psi_inventory as tpi
- inner join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = tpi.wh_id
- inner join dkic_b.t_mst_goods_sku as tmgs on tmgs.sku_id = tpi.sku_id
- left join dkic_b.t_mst_goods_brand as tmgb on tmgs.brand_id = tmgb.brand_id
- left join dkic_b.t_mst_goods_category as tmgc on tmgs.category_id = tmgc.cat_id
- left join dkic_b.t_mst_goods_series as tmgseries on tmgs.series_id = tmgseries.series_id
- left join dkic_b.t_mst_unit as tmgu on tmgs.unit_id = tmgu.unit_id
- where tpi.flg_valid
- AND tpi.cp_id = #{cpId}
- <if test="skuId != null">
- AND tpi.sku_id = #{skuId} ::uuid
- </if>
- <if test="nonStdCode != null">
- AND tpi.non_std_code = #{nonStdCode}
- </if>
- <if test="skuCode != null">
- AND tmgs.sku_code LIKE concat('%',my_ex.likequery(#{skuCode}),'%')
- </if>
- <if test="skuName != null">
- AND tmgs.sku_name LIKE concat('%',my_ex.likequery(#{skuName}),'%')
- </if>
- <if test="whName != null">
- AND tmgs.wh_name LIKE concat('%',my_ex.likequery(#{whName}),'%')
- </if>
- <if test="whId != null">
- AND tpi.wh_id = #{whId} ::uuid
- </if>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 查询库存个数 -->
- <select id="getGoodsForPurchaseReturnByPage" resultType="Long">
- SELECT
- count(1)
- from dkic_b.t_psi_inventory as tpi
- inner join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = tpi.wh_id
- inner join dkic_b.t_mst_goods_sku as tmgs on tmgs.sku_id = tpi.sku_id
- where tpi.flg_valid
- AND tpi.cp_id = #{cpId}
- <if test="skuId != null">
- AND tpi.sku_id = #{skuId} ::uuid
- </if>
- <if test="nonStdCode != null">
- AND tpi.non_std_code = #{nonStdCode}
- </if>
- <if test="skuCode != null">
- AND tmgs.sku_code LIKE concat('%',my_ex.likequery(#{skuCode}),'%')
- </if>
- <if test="skuName != null">
- AND tmgs.sku_name LIKE concat('%',my_ex.likequery(#{skuName}),'%')
- </if>
- <if test="whName != null">
- AND tmgs.wh_name LIKE concat('%',my_ex.likequery(#{whName}),'%')
- </if>
- </select>
- <!--范围权限类型-->
- <select id="getPurviewType" resultType="java.util.Map">
- select tpt.purview_name_i18n as purviewName,
- tpt.purview_code as "code",
- "row_number"() OVER (ORDER BY tpt.display_no) as "id",
- sys.f_get_name_i18n(tpt.purview_name_i18n, #{i18n}) AS name
- from sys.t_purview_type tpt
- where tpt.flg_valid
- order by tpt.display_no
- </select>
- <select id="getInventoryByList" resultType="java.util.Map">
- select tpi.inv_id as "invId",
- tpi.sku_id as "skuId",
- tpi.non_std_code as "nonStdCode",
- tpi.inv_qty as "invQty",
- tpi.outing_qty as "outingQty",
- tpi.usable_qty as "usableQty",
- tpi.wh_id as "whId",
- tmw.wh_name as "whName",
- tpi.remarks
- from dkic_b.t_psi_inventory as tpi
- inner join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = tpi.wh_id
- where tpi.flg_valid
- AND tpi.cp_id = #{cpId} AND
- <foreach collection="skuIdNonStdCodeWhIdList" item="condition" separator=" OR ">
- <if test="condition.skuId != null">
- tpi.sku_id = #{condition.skuId} ::uuid
- </if>
- <if test="condition.nonStdCode != null">
- AND tpi.non_std_code = #{condition.nonStdCode}
- </if>
- <if test="condition.whId != null">
- AND tpi.wh_id = #{condition.whId} ::uuid
- </if>
- </foreach>
- </select>
- <!-- 查询标签打印项目 -->
- <select id="getLabelPrintItem" resultType="java.util.Map">
- select
- item_code as "itemCode",
- sys.f_get_name_i18n(item_name_i18n,#{i18n}) as "itemName",
- doc_name as "docName",
- item_type as "itemType",
- item_style as "itemStyle",
- item_sample as "itemSample",
- data_key as "dataKey",
- remarks as "remarks"
- from sys.t_label_print_item
- where flg_valid
- <if test="docName">
- and doc_name = #{docName}
- </if>
- order by display_no
- </select>
- <!--获取组织仓库-->
- <select id="getOrgWh" resultType="java.util.Map">
- select t.wh_id as "whId",
- tmw.wh_name as "whName",
- t.flg_default as "flgDefault"
- from dkic_b.t_mst_org_wh t
- inner join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = t.wh_id
- where t.cp_id = #{cpId}
- and t.org_id = #{orgId}::uuid
- order by t.display_no
- </select>
- <!-- 获取商品(其他入库开单用) -->
- <select id="getGoodsForInto" resultType="java.util.Map">
- select tmgs.sku_id as "skuId",
- tmgs.sku_code as "skuCode",
- tmgs.sku_name as "skuName",
- tmgs.sku_model as "skuModel",
- tmgs.brand_id as "brandId",
- tmgb.brand_name as "brandName",
- tmgs.category_id as "categoryId",
- tmgc.cat_name as "categoryName",
- tmgs.conversion_factor as "conversionFactor",
- tmgs.series_id as "seriesId",
- tmgseries.series_name as "seriesName",
- tmgs.sku_spec as "skuSpec",
- tmgs.price_purchase as "priceInto",
- tmgs.price_standard as "priceStandard",
- tmgs.price_wholesale as "priceWholesale",
- tmgs.price_limited as "priceLimited",
- tmgs.sku_images as "skuImages",
- tmgs.pack_box as "packBox",
- tmgs.unit_id as "unitId",
- tmgs.sub_unit_id as "subUnitId",
- ul.unit_name as "unitName",
- u2.unit_name as "subUnitName",
- tmgs.remarks
- from dkic_b.t_mst_goods_sku as tmgs
- left join dkic_b.t_mst_goods_brand as tmgb on tmgs.brand_id = tmgb.brand_id
- left join dkic_b.t_mst_goods_category as tmgc on tmgs.category_id = tmgc.cat_id
- left join dkic_b.t_mst_goods_series as tmgseries on tmgs.series_id = tmgseries.series_id
- left join dkic_b.t_mst_unit as ul on tmgs.unit_id = ul.unit_id
- left join dkic_b.t_mst_unit as u2 on tmgs.sub_unit_id = u2.unit_id
- where tmgs.flg_valid
- AND tmgs.cp_id = #{cpId}
- <if test="skuCode != null">
- AND tmgs.sku_code LIKE concat('%',my_ex.likequery(#{skuCode}),'%')
- </if>
- <if test="skuName != null">
- AND tmgs.sku_name LIKE concat('%',my_ex.likequery(#{skuName}),'%')
- </if>
- <if test="categoryId != null">
- AND tmgs.category_id = #{categoryId}::uuid
- </if>
- </select>
- <!-- 获取商品(其他入库开单用)(数量) -->
- <select id="getGoodsForIntoCountByPage" resultType="Long">
- SELECT
- count(1)
- from dkic_b.t_mst_goods_sku as tmgs
- where tmgs.flg_valid
- AND tmgs.cp_id = #{cpId}
- <if test="skuCode != null">
- AND tmgs.sku_code LIKE concat('%',my_ex.likequery(#{skuCode}),'%')
- </if>
- <if test="skuName != null">
- AND tmgs.sku_name LIKE concat('%',my_ex.likequery(#{skuName}),'%')
- </if>
- </select>
- <select id="selectDictionaryData" resultType="java.util.Map">
- select dd.data_id as "dataId",
- dd.data_id as "id",
- dd.dict_code as "dictCode",
- dd.data_code as "dataCode",
- dd.data_value as "dataValue",
- dd.flg_default as "flgDefault"
- from dkic_b.t_mst_dictionary_data as dd
- where dd.flg_valid
- and dd.cp_id = #{cpId}
- and dd.dict_code = #{dictCode}
- and dd.data_value = #{dataValue}
- </select>
- <!-- 销售分析-我的 门店助手的 销售金额 收款金额 库存成本 -->
- <select id="getHomeOrderRecCost" resultType="java.util.Map">
- select dkic_b.f_get_home_order_rec_cost(#{cpId},#{dateBegin}::date,#{dateEnd}::date)
- </select>
- <!--查询用户授权数-->
- <select id="selectUserCount" resultType="java.util.Map">
- SELECT
- (
- SELECT COUNT
- ( 1 ) "webNum"
- FROM
- dkic_b.t_mst_staff s
- WHERE
- s.flg_valid
- AND s.flg_can_login
- AND s.login_type IN ( 1, 3 )
- AND s.hr_status = 1
- AND s.cp_id = #{cpId}
- ),
- (
- SELECT COUNT
- ( 1 ) "wxNum"
- FROM
- dkic_b.t_mst_staff s
- WHERE
- s.flg_valid
- AND s.flg_can_login
- AND s.hr_status = 1
- AND s.login_type IN ( 2, 3 )
- AND s.cp_id = #{cpId}
- )
- </select>
- </mapper>
|