| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896 |
- <?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 flg_valid
- <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>
- <resultMap id="BaseResultMap" type="java.util.Map">
- <result column="kindTags" property="kindTags" typeHandler="JsonTypeHandler"/>
- </resultMap>
- <!-- 获取应用-->
- <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_code AS "docCode",
- sys.f_get_name_i18n_lang ( tsd.doc_name_i18n, #{i18n}) AS "docName"
- FROM
- sys.t_s_doc tsd
- WHERE
- tsd.flg_valid
- <if test="flgApproval!=null">
- and tsd.flg_approval = #{flgApproval}
- </if>
- </select>
- <!-- 获取数据种类 -->
- <select id="getDataKind" resultMap="BaseResultMap">
- 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",
- 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
- </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
- 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>
- order by display_no
- </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="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",
- flg_right AS "flgRight",
- object_code AS "objectCode",
- object_paths AS "objectPaths",
- object_icon AS "icon",
- parent_path AS "parentPath",
- menu_tags AS "menuTags",
- level_code AS "levelCode",
- flg_fast AS "flgFast",
- fast_image AS "fastImage",
- fast_path AS "fastPath",
- ex_menu_uuid AS "exMenuUuid",
- flg_same_route AS "flgSameRoute",
- flg_choose_id AS "flgChooseId",
- #{appCode} AS "appCode",
- menu_uuid AS "id",
- parent_uuid AS "parentId"
- from
- <if test="appCode=='WEB-TOUCH'">
- core.f_get_user_menu_touch(#{appCode}, #{userId})
- </if>
- <if test="appCode!='WEB-TOUCH'">
- core.f_get_user_menu(#{appCode}, #{userId})
- </if>
- </select>
- <!-- 获取角色 -->
- <select id="getRole" resultType="java.util.Map">
- select role_Id AS "roleId",
- 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",
- sys.f_code_name(staff.staff_code, staff.staff_name) AS "staffCodeName",
- staff.remarks
- 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>
- order by staff.staff_code
- <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 core.f_get_setting_value(#{code}, #{ftyId})
- </select>
- <!-- 函数查询多个系统参数-->
- <select id="getSettingValues" resultType="Map">
- select core.f_get_setting_values(
- #{codes, typeHandler=StringListTypeHandler}, #{ftyId})
- </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.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}
- order by dd.display_no
- </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 tmw.wh_id as "whId"
- ,tmw.wh_name as "whName"
- ,tmw.wh_code as "whCode"
- ,tmw.flg_default as "flgDefault"
- FROM dkic_b.t_mst_warehouse tmw
- WHERE tmw.cp_id = #{cpId}
- and tmw.flg_valid
- <if test="whCode!=null and whCode!=''">
- and position(#{whCode} in tmw.wh_code) > 0
- </if>
- <if test="whName!=null and whName!=''">
- and position(#{whName} in tmw.wh_name) > 0
- </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>
- </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",
- 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>
- </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>
- </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",
- 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>
- </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
- inner join dkic_b.t_mst_org tmo on tmc.org_id = tmo.org_id
- inner join dkic_b.t_mst_staff tms on tmc.staff_id = tms.staff_id
- inner join dkic_b.t_mst_staff as reportstaff on tmc.report_staff = reportstaff.staff_id
- inner 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",
- tms.sup_type as "supplierType",
- tms.contact_name as "contactName",
- tms.contact_phone as "contactPhone",
- tms.flg_valid as "flgValid"
- from dkic_b.t_mst_supplier tms
- 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>
- 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
- 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>
- </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>
- <!-- 查询表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('%', #{searchText}, '%')
- </if>
- <if test="cpId != null">
- AND tmgb.cp_id = #{cpId}
- </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 "serieName",
- 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>
- </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>
- </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
- wh_id AS "whId",
- wh_code AS "whCode",
- wh_name AS "whName",
- supervisor AS "supervisor",
- contact_phone AS "contactPhone",
- flg_valid AS "flgValid"
- FROM dkic_b.t_mst_warehouse
- <where>
- <if test="searchText !=null">
- AND ( wh_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 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
- <where>
- <if test="searchText !=null">
- AND ( wh_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="getInventory" resultType="java.util.Map">
- select 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",
- tmw.wh_code as "whCode",
- 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
- 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 = #{skuCode}
- </if>
- <if test="skuName != null">
- AND tmgs.sku_name = #{skuName}
- </if>
- <if test="whName != null">
- AND tmgs.wh_name = #{whName}
- </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 = #{skuCode}
- </if>
- <if test="skuName != null">
- AND tmgs.sku_name = #{skuName}
- </if>
- <if test="whName != null">
- AND tmgs.wh_name = #{whName}
- </if>
- </select>
- </mapper>
|