CommonMapper.xml 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.dk.mdm.mapper.common.CommonMapper">
  4. <!-- 获取显示顺序的最大值 -->
  5. <select id="getMaxDisplayNo" resultType="Integer">
  6. select max(display_no) + 1
  7. from ${table}
  8. where flg_valid
  9. <if test="ftyId != null">
  10. and fty_id = #{ftyId}
  11. </if>
  12. <if test="otherCond">
  13. and ${otherCond}
  14. </if>
  15. <!--数据字典-->
  16. <if test="dictCode != null">
  17. and dict_code = #{dictCode}
  18. </if>
  19. </select>
  20. <!--获取编码-->
  21. <select id="getUniqueCode" resultType="java.util.Map">
  22. select out_id AS "outId", out_code AS "outNote"
  23. from dkic_b.f_create_code_id(#{cpId}, #{docName});
  24. </select>
  25. <!--获取单号-->
  26. <select id="getUniqueNote" resultType="java.util.Map">
  27. select out_id AS "outId", out_note AS "outNote"
  28. from dkic_b.f_create_note_id(#{cpId}, #{docName});
  29. </select>
  30. <!-- 获取用户菜单-->
  31. <select id="getMenuByUser" resultType="java.util.Map">
  32. select menu_uuid AS "menuUuid",
  33. name AS "name",
  34. menu_name AS "menuName",
  35. parent_uuid AS "parentUuid",
  36. menu_type AS "menuType",
  37. flg_menu AS "flgMenu",
  38. object_code AS "objectCode",
  39. object_path AS "objectPath",
  40. object_icon AS "icon",
  41. object_id AS "objectId",
  42. menu_tags AS "menuTags",
  43. level_code AS "levelCode",
  44. flg_same_route AS "flgSameRoute",
  45. flg_choose_id AS "flgChooseId",
  46. flg_auto_query AS "flgAutoQuery",
  47. page_grid_info AS "pageGridInfo",
  48. grade_code AS "gradeCode",
  49. grade_level AS "gradeLevel",
  50. is_vip AS "isVip",
  51. #{appCode} AS "appCode",
  52. menu_uuid AS "id",
  53. parent_uuid AS "parentId"
  54. from
  55. dkic_b.f_get_user_menu(#{appCode}, #{userId } ::uuid,#{cpId},#{lang})
  56. </select>
  57. <!--查用户功能权限-->
  58. <select id="getUserFunction" resultType="java.util.Map">
  59. select appm.menu_uuid AS "menuUuid"
  60. , appm.menu_name as name
  61. , sys.f_get_name_i18n_lang(appm.menu_name_i18n, #{i18n}) as "menuName"
  62. , rr.fun_uuid AS "funUuid"
  63. , appm.object_code AS "objectCode"
  64. , appm.menu_type AS "menuType"
  65. from sys.t_app_menu appm
  66. inner join core.t_user_fun rr
  67. on rr.fun_uuid = appm.fun_uuid
  68. where appm.flg_valid
  69. and appm.app_code = #{appCode}
  70. and appm.menu_type IN (1, 2)
  71. and rr.user_id = #{userId};
  72. </select>
  73. <!--查询用于隐藏列信息-->
  74. <select id="getUserTableInfo" resultType="java.util.Map">
  75. select tuts.code,
  76. tuts.table_type AS "tableType",
  77. tuts.table_ref AS "tableRef",
  78. tuts.columns
  79. from pset.t_user_table_set tuts
  80. where tuts.flg_valid
  81. and tuts.user_id = #{userId};
  82. </select>
  83. <!--查导航菜单(自定义报表用)-->
  84. <select id="getMenuNavigation" resultType="java.util.Map">
  85. select appm.menu_uuid AS "menuUuid"
  86. ,sys.f_get_name_i18n_lang(appm.menu_name_i18n,#{i18n}) as "menuName"
  87. ,appm.parent_uuid AS "parentUuid"
  88. from sys.t_app_menu appm
  89. where appm.flg_valid
  90. <if test="parentUuid">
  91. and appm.parent_uuid = #{parentUuid} ::uuid
  92. </if>
  93. and appm.app_code = 'WEB-MAIN'
  94. and appm.menu_type = 0
  95. </select>
  96. <!-- 获取应用-->
  97. <select id="getApplication" resultType="java.util.Map">
  98. select
  99. app_code as "appCode",
  100. app_name as "appName"
  101. from sys.t_application
  102. </select>
  103. <!--获取单据-->
  104. <select id="getDoc" resultType="java.util.Map">
  105. SELECT
  106. tsd.doc_code AS "docCode",
  107. sys.f_get_name_i18n_lang ( tsd.doc_name_i18n, #{i18n}) AS "docName"
  108. FROM
  109. sys.t_s_doc tsd
  110. WHERE
  111. tsd.flg_valid
  112. <if test="flgApproval!=null">
  113. and tsd.flg_approval = #{flgApproval}
  114. </if>
  115. </select>
  116. <!-- 获取数据种类 -->
  117. <select id="getDataKind" resultType="java.util.Map">
  118. select kind_code AS "kindCode",
  119. sys.f_get_name_i18n(kind_name_i18n,#{i18n}) as "kindName",
  120. sys.f_get_name_i18n(kind_desc,#{i18n}) as "gradeKindDesc",
  121. kind_type AS "kindType",
  122. kind_tags AS "kindTags",
  123. display_no AS "displayNo",
  124. kind_code AS "id",
  125. remarks
  126. from sys.t_data_kind
  127. where flg_valid
  128. <if test="kindType != null">
  129. AND kind_type = #{kindType}
  130. </if>
  131. <if test="usedFlag != null">
  132. AND kind_tags -> 'used' ?? '标签'
  133. </if>
  134. <if test="kindTag != null">
  135. AND kind_tags -> 'used' ?? #{kindTag}
  136. </if>
  137. <if test="kindCodeList != null and kindCodeList.size()>0">
  138. AND kind_code =any(#{kindCodeList,typeHandler=StringListTypeHandler})
  139. </if>
  140. order by display_no
  141. </select>
  142. <!-- 获取组织部门 -->
  143. <select id="getOrg" resultType="java.util.Map">
  144. select org_Id AS "orgId",
  145. org_code AS "orgCode",
  146. org_name AS "orgName",
  147. org_Id AS "id",
  148. parent_id AS "parentId",
  149. top_Id AS "topId",
  150. display_no AS "displayNo",
  151. remarks
  152. from dkic_b.t_mst_org
  153. where flg_valid
  154. and cp_id = #{cpId}
  155. <if test="topId != null">
  156. AND top_id = #{topId}
  157. </if>
  158. <if test="orgId != null">
  159. AND org_id != #{orgId}
  160. </if>
  161. <if test="orgCode != null">
  162. AND org_code LIKE concat('%',my_ex.likequery(#{orgCode}),'%')
  163. </if>
  164. <if test="orgName != null">
  165. AND org_name LIKE concat('%',my_ex.likequery(#{orgName}),'%')
  166. </if>
  167. order by display_no
  168. </select>
  169. <!-- 只获取二级部门 按照level_code 排序 -->
  170. <select id="getProcureOrg" resultType="java.util.Map">
  171. select org_Id AS "orgId",
  172. org_code AS "orgCode",
  173. org_name AS "orgName",
  174. org_Id AS "id",
  175. parent_id AS "parentId",
  176. top_Id AS "topId",
  177. display_no AS "displayNo",
  178. remarks
  179. from dkic_b.t_mst_org
  180. where flg_valid
  181. and cp_id = #{cpId}
  182. and parent_id is NOT null
  183. <if test="topId != null">
  184. AND top_id = #{topId}
  185. </if>
  186. <if test="orgId != null">
  187. AND org_id != #{orgId}
  188. </if>
  189. <if test="orgCode != null">
  190. AND org_code LIKE concat('%',my_ex.likequery(#{orgCode}),'%')
  191. </if>
  192. <if test="orgName != null">
  193. AND org_name LIKE concat('%',my_ex.likequery(#{orgName}),'%')
  194. </if>
  195. order by level_code
  196. </select>
  197. <!-- t_mst_org,(条件查询)个数 -->
  198. <select id="getOrgCountByPage" resultType="Long">
  199. SELECT
  200. count(1)
  201. from dkic_b.t_mst_org
  202. where flg_valid
  203. and cp_id = #{cpId}
  204. <if test="topId != null">
  205. AND top_id = #{topId}
  206. </if>
  207. <if test="orgId != null">
  208. AND org_id != #{orgId}
  209. </if>
  210. <if test="orgCode != null">
  211. AND org_code LIKE concat('%',my_ex.likequery(#{orgCode}),'%')
  212. </if>
  213. <if test="orgName != null">
  214. AND org_name LIKE concat('%',my_ex.likequery(#{orgName}),'%')
  215. </if>
  216. </select>
  217. <!-- 获取角色 -->
  218. <select id="getRole" resultType="java.util.Map">
  219. select role_Id AS "roleId",
  220. role_name AS "roleName",
  221. display_no AS "displayNo",
  222. remarks
  223. from dkic_b.t_mst_role
  224. where cp_id = #{cpId}
  225. and flg_valid
  226. order by display_no
  227. </select>
  228. <!-- 获取员工 -->
  229. <select id="getStaffByPage" resultType="java.util.Map">
  230. select staff.staff_id AS "staffId",
  231. staff.staff_code AS "staffCode",
  232. staff.staff_name AS "staffName",
  233. sys.f_code_name(staff.staff_code, staff.staff_name) AS "staffCodeName",
  234. staff.remarks
  235. ,tmg.org_id as "orgId"
  236. ,tmg.org_code as "orgCode"
  237. ,tmg.org_name as "orgName"
  238. from dkic_b.t_mst_staff AS staff
  239. left join dkic_b.t_mst_org tmg on tmg.org_id = staff.org_id
  240. where staff.flg_valid
  241. and staff.cp_id =#{cpId}
  242. <if test="staffCode != null and staffCode != ''">
  243. And position (#{staffCode} in staff.staff_code)>0
  244. </if>
  245. <if test="staffName != null and staffName != ''">
  246. And position (#{staffName} in staff.staff_name)>0
  247. </if>
  248. order by staff.staff_code
  249. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  250. limit #{end} offset #{start}
  251. </if>
  252. </select>
  253. <!-- 查询表t_user,(条件查询)个数 -->
  254. <select id="getStaffCountByPage" resultType="Long">
  255. SELECT
  256. count(1)
  257. from dkic_b.t_mst_staff AS staff
  258. where staff.flg_valid
  259. and staff.cp_id =#{cpId}
  260. <if test="staffCode != null and staffCode != ''">
  261. And position (#{staffCode} in staff.staff_code)>0
  262. </if>
  263. <if test="staffName != null and staffName != ''">
  264. And position (#{staffName} in staff.staff_name)>0
  265. </if>
  266. </select>
  267. <!-- 函数查询单个系统参数-->
  268. <select id="getSettingValue" resultType="String">
  269. select core.f_get_setting_value(#{code}, #{ftyId})
  270. </select>
  271. <!-- 函数查询多个系统参数-->
  272. <select id="getSettingValues" resultType="Map">
  273. select core.f_get_setting_values(
  274. #{codes, typeHandler=StringListTypeHandler}, #{ftyId})
  275. </select>
  276. <!-- 查询系统参数分类 -->
  277. <select id="getSettingKind" resultType="java.util.Map">
  278. select sk.kind_code as "classCode",
  279. sys.f_get_name_i18n_lang(sk.kind_name_i18n, #{i18n}) as "className",
  280. sk.display_no as "displayNo"
  281. from sys.t_setting_kind as sk
  282. where sk.flg_valid
  283. order by sk.display_no
  284. </select>
  285. <!-- 获取数据字典 -->
  286. <select id="getDictionaryData" resultType="java.util.Map">
  287. select dd.data_id as "dataId",
  288. dd.data_id as "id",
  289. dd.dict_code as "dictCode",
  290. dd.data_code as "dataCode",
  291. dd.data_value as "dataValue",
  292. dd.flg_default as "flgDefault"
  293. from dkic_b.t_mst_dictionary_data as dd
  294. where dd.flg_valid
  295. and dd.cp_id = #{cpId}
  296. and dd.dict_code = #{dictCode}
  297. order by dd.display_no
  298. </select>
  299. <!-- 获取数据字典项目 -->
  300. <select id="getDictionaryItemData" resultType="java.util.Map">
  301. SELECT stdi.dict_code AS "dictCode",
  302. sys.f_get_name_i18n_lang(stdi.dict_name_i18n, 'zh_CN') AS "dictName"
  303. FROM sys.t_dictionary_item stdi
  304. WHERE stdi.flg_valid
  305. AND stdi.level_no NOT IN ('1')
  306. </select>
  307. <!-- 获取数据类型 -->
  308. <select id="getValueKind" resultType="java.util.Map">
  309. select tvk.kind_code AS "kindCode",
  310. tvk.kind_name as "kindName",
  311. sys.f_get_name_i18n_lang(tvk.kind_name_i18n,#{i18n}) AS "kindLabel"
  312. from sys.t_value_kind as tvk
  313. where tvk.flg_valid
  314. <if test="used != null and used != ''">
  315. and #{used} = ANY (tvk.used)
  316. </if>
  317. order by tvk.display_no
  318. </select>
  319. <!-- 获取仓库 -->
  320. <select id="getWarehouse" resultType="java.util.Map">
  321. SELECT tmw.wh_id as "whId"
  322. ,tmw.wh_id AS "id"
  323. ,tmw.wh_name as "whName"
  324. ,tmw.wh_code as "whCode"
  325. ,tmw.flg_default as "flgDefault"
  326. FROM dkic_b.t_mst_warehouse tmw
  327. WHERE tmw.cp_id = #{cpId}
  328. and tmw.flg_valid
  329. <if test="whCode!=null and whCode!=''">
  330. and position(#{whCode} in tmw.wh_code) > 0
  331. </if>
  332. <if test="whName!=null and whName!=''">
  333. and position(#{whName} in tmw.wh_name) > 0
  334. </if>
  335. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  336. limit #{end} offset #{start}
  337. </if>
  338. </select>
  339. <!-- 获取商品 -->
  340. <select id="getGoods" resultType="java.util.Map">
  341. select tmgs.sku_id as "skuId",
  342. tmgs.sku_code as "skuCode",
  343. tmgs.sku_name as "skuName",
  344. tmgs.sku_model as "skuModel",
  345. tmgs.brand_id as "brandId",
  346. tmgb.brand_name as "brandName",
  347. tmgs.category_id as "categoryId",
  348. tmgc.cat_name as "categoryName",
  349. tmgs.unit_id as "unitId",
  350. tmgu.unit_name as "unitName",
  351. tmgs.sub_unit_id as "subUnitId",
  352. tmgs.conversion_factor as "conversionFactor",
  353. tmgs.series_id as "seriesId",
  354. tmgseries.series_name as "seriesName",
  355. tmgs.sku_spec as "skuSpec",
  356. tmgs.price_purchase as "pricePurchase",
  357. tmgs.price_standard as "priceStandard",
  358. tmgs.price_wholesale as "priceWholesale",
  359. tmgs.price_limited as "priceLimited",
  360. tmgs.sku_images as "skuImages",
  361. tmgs.remarks
  362. from dkic_b.t_mst_goods_sku as tmgs
  363. left join dkic_b.t_mst_goods_brand as tmgb on tmgs.brand_id = tmgb.brand_id
  364. left join dkic_b.t_mst_goods_category as tmgc on tmgs.category_id = tmgc.cat_id
  365. left join dkic_b.t_mst_goods_series as tmgseries on tmgs.series_id = tmgseries.series_id
  366. left join dkic_b.t_mst_unit as tmgu on tmgs.unit_id = tmgu.unit_id
  367. where tmgs.flg_valid
  368. AND tmgs.cp_id = #{cpId}
  369. <if test="skuCode != null">
  370. AND tmgs.sku_code LIKE concat('%',my_ex.likequery(#{skuCode}),'%')
  371. </if>
  372. <if test="skuName != null">
  373. AND tmgs.sku_name LIKE concat('%',my_ex.likequery(#{skuName}),'%')
  374. </if>
  375. </select>
  376. <!-- 获取商品个数 -->
  377. <select id="getGoodsCountByPage" resultType="Long">
  378. SELECT
  379. count(1)
  380. from dkic_b.t_mst_goods_sku as tmgs
  381. where tmgs.flg_valid
  382. AND tmgs.cp_id = #{cpId}
  383. <if test="skuCode != null">
  384. AND tmgs.sku_code LIKE concat('%',my_ex.likequery(#{skuCode}),'%')
  385. </if>
  386. <if test="skuName != null">
  387. AND tmgs.sku_name LIKE concat('%',my_ex.likequery(#{skuName}),'%')
  388. </if>
  389. </select>
  390. <!-- 获取商品 -->
  391. <select id="getGoodsForOrder" resultType="java.util.Map">
  392. select tmgs.sku_id as "skuId",
  393. tmgs.sku_code as "skuCode",
  394. tmgs.sku_name as "skuName",
  395. tmgs.sku_model as "skuModel",
  396. tmgs.brand_id as "brandId",
  397. tmgb.brand_name as "brandName",
  398. tmgs.category_id as "categoryId",
  399. tmgc.cat_name as "categoryName",
  400. tmgs.unit_id as "unitId",
  401. tmgu.unit_name as "unitName",
  402. tmgs.sub_unit_id as "subUnitId",
  403. tmgs.conversion_factor as "conversionFactor",
  404. tmgs.series_id as "seriesId",
  405. tmgseries.series_name as "seriesName",
  406. tmgs.sku_spec as "skuSpec",
  407. tmgs.price_purchase as "pricePurchase",
  408. tmgs.price_standard as "priceStandard",
  409. tmgs.price_wholesale as "priceWholesale",
  410. tmgs.price_limited as "priceLimited",
  411. tmgs.sku_images as "skuImages",
  412. tmgs.remarks
  413. from dkic_b.t_mst_goods_sku as tmgs
  414. left join dkic_b.t_mst_goods_brand as tmgb on tmgs.brand_id = tmgb.brand_id
  415. left join dkic_b.t_mst_goods_category as tmgc on tmgs.category_id = tmgc.cat_id
  416. left join dkic_b.t_mst_goods_series as tmgseries on tmgs.series_id = tmgseries.series_id
  417. left join dkic_b.t_mst_unit as tmgu on tmgs.unit_id = tmgu.unit_id
  418. where tmgs.flg_valid
  419. AND tmgs.cp_id = #{cpId}
  420. <if test="skuCode != null">
  421. AND tmgs.sku_code LIKE concat('%',my_ex.likequery(#{skuCode}),'%')
  422. </if>
  423. <if test="skuName != null">
  424. AND tmgs.sku_name LIKE concat('%',my_ex.likequery(#{skuName}),'%')
  425. </if>
  426. </select>
  427. <!-- 获取商品个数 -->
  428. <select id="getGoodsForOrderCountByPage" resultType="Long">
  429. SELECT
  430. count(1)
  431. from dkic_b.t_mst_goods_sku as tmgs
  432. where tmgs.flg_valid
  433. AND tmgs.cp_id = #{cpId}
  434. <if test="skuCode != null">
  435. AND tmgs.sku_code LIKE concat('%',my_ex.likequery(#{skuCode}),'%')
  436. </if>
  437. <if test="skuName != null">
  438. AND tmgs.sku_name LIKE concat('%',my_ex.likequery(#{skuName}),'%')
  439. </if>
  440. </select>
  441. <!-- 获取商品(采购) -->
  442. <select id="getGoodsForPurchase" resultType="java.util.Map">
  443. select tmgs.sku_id as "skuId",
  444. tmgs.sku_code as "skuCode",
  445. tmgs.sku_name as "skuName",
  446. tmgs.sku_model as "skuModel",
  447. tmgs.brand_id as "brandId",
  448. tmgb.brand_name as "brandName",
  449. tmgs.category_id as "categoryId",
  450. tmgc.cat_name as "categoryName",
  451. tmgs.unit_id as "unitId",
  452. tmgu.unit_name as "unitName",
  453. tmgs.sub_unit_id as "subUnitId",
  454. tmgs.conversion_factor as "conversionFactor",
  455. tmgs.series_id as "seriesId",
  456. tmgseries.series_name as "seriesName",
  457. tmgs.sku_spec as "skuSpec",
  458. tmgs.price_purchase as "pricePurchase",
  459. tmgs.price_standard as "priceStandard",
  460. tmgs.price_wholesale as "priceWholesale",
  461. tmgs.price_limited as "priceLimited",
  462. tmgs.sku_images as "skuImages",
  463. tmgs.remarks
  464. from dkic_b.t_mst_goods_sku as tmgs
  465. left join dkic_b.t_mst_goods_brand as tmgb on tmgs.brand_id = tmgb.brand_id
  466. left join dkic_b.t_mst_goods_category as tmgc on tmgs.category_id = tmgc.cat_id
  467. left join dkic_b.t_mst_goods_series as tmgseries on tmgs.series_id = tmgseries.series_id
  468. left join dkic_b.t_mst_unit as tmgu on tmgs.unit_id = tmgu.unit_id
  469. where tmgs.flg_valid
  470. AND tmgs.cp_id = #{cpId}
  471. <if test="skuCode != null">
  472. AND tmgs.sku_code LIKE concat('%',my_ex.likequery(#{skuCode}),'%')
  473. </if>
  474. <if test="skuName != null">
  475. AND tmgs.sku_name LIKE concat('%',my_ex.likequery(#{skuName}),'%')
  476. </if>
  477. </select>
  478. <!-- 获取商品个数(采购) -->
  479. <select id="getGoodsForPurchaseCountByPage" resultType="Long">
  480. SELECT
  481. count(1)
  482. from dkic_b.t_mst_goods_sku as tmgs
  483. where tmgs.flg_valid
  484. AND tmgs.cp_id = #{cpId}
  485. <if test="skuCode != null">
  486. AND tmgs.sku_code LIKE concat('%',my_ex.likequery(#{skuCode}),'%')
  487. </if>
  488. <if test="skuName != null">
  489. AND tmgs.sku_name LIKE concat('%',my_ex.likequery(#{skuName}),'%')
  490. </if>
  491. </select>
  492. <!-- 获取客户 -->
  493. <select id="getCustomer" resultType="java.util.Map">
  494. select tmc.cus_id as "cusId",
  495. tmc.cus_code as "cusCode",
  496. tmc.cus_name as "cusName",
  497. tmc.cus_phone as "cusPhone",
  498. tmc.address_area as "addressArea",
  499. tmc.address_name as "addressName",
  500. tmc.address_no as "addressNo",
  501. tmc.address_gcj02 as "addressGcj02",
  502. tmc.address_full as "addressFull",
  503. tmc.contact_name as "contactName",
  504. tmc.contact_phone as "contactPhone",
  505. tmc.cus_from as "cusFrom",
  506. tmdd.data_value as "cusFromName",
  507. tmc.channel_id as "channelId",
  508. tmsc.channel_name as "channelName",
  509. tmc.org_id as "orgId",
  510. tmo.org_name as "orgName",
  511. tmc.staff_id as "staffId",
  512. tms.staff_name as "staffName",
  513. tmc.report_staff as "reportStaff",
  514. reportstaff.staff_name as "reportStaffName",
  515. tmc.report_time as "reportTime",
  516. tmc.sale_status as "saleStatus",
  517. tmc.remarks as "remarks",
  518. tmc.follow_staffs as "followStaffs",
  519. tmc.last_follow_staff as "lastFollowStaff",
  520. tmc.last_follow_id as "lastFollowId",
  521. tmc.last_follow_status as "lastFollowStatus",
  522. tmc.last_follow_time as "lastFollowTime"
  523. from dkic_b.t_mst_customer as tmc
  524. inner join dkic_b.t_mst_org tmo on tmc.org_id = tmo.org_id
  525. inner join dkic_b.t_mst_staff tms on tmc.staff_id = tms.staff_id
  526. inner join dkic_b.t_mst_staff as reportstaff on tmc.report_staff = reportstaff.staff_id
  527. inner join dkic_b.t_mst_sale_channel tmsc on tmc.channel_id = tmsc.channel_id
  528. left join dkic_b.t_mst_dictionary_data tmdd on tmc.cus_from = tmdd.data_id
  529. where tmc.flg_valid
  530. AND tmc.cp_id = #{cpId}
  531. <if test="skuCode != null">
  532. AND tmc.cus_code = #{cusCode}
  533. </if>
  534. <if test="skuName != null">
  535. AND tmc.cus_name = #{cusName}
  536. </if>
  537. </select>
  538. <!-- 获取客户个数 -->
  539. <select id="getCustomerCountByPage" resultType="Long">
  540. SELECT
  541. count(1)
  542. from dkic_b.t_mst_customer as tmc
  543. where tmc.flg_valid
  544. and tmc.cp_id = #{cpId}
  545. <if test="skuCode != null">
  546. AND tmc.cus_code = #{cusCode}
  547. </if>
  548. <if test="skuName != null">
  549. AND tmc.cus_name = #{cusName}
  550. </if>
  551. </select>
  552. <!-- 获取单据Id-->
  553. <select id="getUuidSeq" resultType="object">
  554. select sys.f_uuid_seq()
  555. </select>
  556. <!-- 获取单据单号-->
  557. <select id="getDocNo" resultType="java.lang.String">
  558. select dkic_b.f_create_note(#{cpId}, #{purId}::uuid, #{docCode})
  559. </select>
  560. <!--获取供应商-->
  561. <select id="getSupplier" resultType="java.util.Map">
  562. select tms.sup_code as "supplierCode",
  563. tms.sup_name as "supplierName",
  564. tms.sup_id as "supplierId",
  565. sys.f_get_name_i18n(tdk.kind_name_i18n,'zh_CN' ) AS "supplierType",
  566. tms.contact_name as "contactName",
  567. tms.contact_phone as "contactPhone",
  568. tms.flg_valid as "flgValid"
  569. from dkic_b.t_mst_supplier tms
  570. LEFT JOIN sys.t_data_kind tdk
  571. ON tdk.kind_code = tms.sup_type
  572. where tms.cp_id = #{cpId}
  573. <if test="supplierName!=null and supplierName!=''">
  574. AND tms.sup_name LIKE concat('%',my_ex.likequery(#{supplierName}),'%')
  575. </if>
  576. <if test="supplierCode!=null and supplierCode!=''">
  577. AND tms.sup_code LIKE concat('%',my_ex.likequery(#{supplierCode}),'%')
  578. </if>
  579. <if test="supplierType!=null and supplierType!=''">
  580. AND tms.sup_type = #{supplierType}
  581. </if>
  582. order by tms.sup_code
  583. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  584. limit #{end} offset #{start}
  585. </if>
  586. <if test="limit != null and limit != 0 ">
  587. limit #{limit}
  588. </if>
  589. </select>
  590. <!--获取供应商数量-->
  591. <select id="countSupplier" resultType="java.lang.Long">
  592. select count(1)
  593. from dkic_b.t_mst_supplier tms
  594. LEFT JOIN sys.t_data_kind tdk
  595. ON tdk.kind_code = tms.sup_type
  596. where tms.cp_id = #{cpId}
  597. <if test="supplierName!=null and supplierName!=''">
  598. AND tms.sup_name LIKE concat('%',my_ex.likequery(#{supplierName}),'%')
  599. </if>
  600. <if test="supplierCode!=null and supplierCode!=''">
  601. AND tms.sup_code LIKE concat('%',my_ex.likequery(#{supplierCode}),'%')
  602. </if>
  603. <if test="supplierType!=null and supplierType!=''">
  604. AND tms.sup_type LIKE concat('%',my_ex.likequery(#{supplierType}),'%')
  605. </if>
  606. </select>
  607. <!--获取渠道 -->
  608. <select id="getChannel" resultType="java.util.Map">
  609. select c.channel_id as "channelId",
  610. c.channel_code as "channelCode",
  611. c.channel_name as "channelName",
  612. c.sys_code as "sysCode",
  613. c.display_no as "displayNo"
  614. from dkic_b.t_mst_sale_channel as c
  615. where c.flg_valid
  616. and c.cp_id = #{cpId}
  617. <if test="channel_code!=null and channel_code!=''">
  618. AND c.channel_code LIKE concat('%', #{channelCode}, '%')
  619. </if>
  620. <if test="channel_name!=null and channel_name!=''">
  621. AND c.channel_name LIKE concat('%', #{channelName}, '%')
  622. </if>
  623. order by c.display_no
  624. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  625. limit #{end} offset #{start}
  626. </if>
  627. <if test="limit != null and limit != 0 ">
  628. limit #{limit}
  629. </if>
  630. </select>
  631. <!-- 查询商品档案-->
  632. <select id="getGoodsBrand" resultType="java.util.Map">
  633. SELECT
  634. tmgb.flg_valid AS "flgValid",
  635. tmgb.brand_id AS "brandId", tmgb.brand_code AS "brandCode", tmgb.brand_name AS "brandName",
  636. (SELECT COALESCE(array_to_string(array_agg(tsm.sup_name), ','),'')
  637. FROM dkic_b.t_mst_supplier_brand tsmb
  638. left join dkic_b.t_mst_supplier tsm on tsm.sup_id = tsmb.sup_id
  639. WHERE tsmb.brand_id = tmgb.brand_id) AS "supplierName"
  640. FROM dkic_b.t_mst_goods_brand tmgb
  641. <where>
  642. <if test="searchText !=null">
  643. AND tmgb.brand_name LIKE concat('%',my_ex.likequery(#{searchText}), '%')
  644. </if>
  645. <if test="cpId != null">
  646. AND tmgb.cp_id = #{cpId}
  647. </if>
  648. </where>
  649. order by tmgb.display_no asc
  650. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  651. limit #{end} offset #{start}
  652. </if>
  653. </select>
  654. <!-- 查询表t_mst_goods_brand,(条件查询)个数 -->
  655. <select id="countGoodsBrand" resultType="Long">
  656. SELECT
  657. count(1)
  658. FROM dkic_b.t_mst_goods_brand tmgb
  659. <where>
  660. <if test="searchText !=null">
  661. AND tmgb.brand_name LIKE concat('%', #{searchText}, '%')
  662. </if>
  663. <if test="cpId != null">
  664. AND tmgb.cp_id = #{cpId}
  665. </if>
  666. </where>
  667. </select>
  668. <!-- 查询商品种类-->
  669. <select id="getGoodsCategory" resultType="java.util.Map">
  670. SELECT
  671. cat_id AS "catId",
  672. cat_code AS "catCode",
  673. cat_name AS "catName",
  674. parent_id AS "parentId",
  675. flg_valid AS "flgValid"
  676. FROM dkic_b.t_mst_goods_category
  677. <where>
  678. <if test="searchText !=null">
  679. AND ( cat_name LIKE concat('%', my_ex.likequery(#{searchText}), '%')
  680. or remarks LIKE concat('%', my_ex.likequery(#{searchText}), '%'))
  681. </if>
  682. <if test="cpId != null">
  683. AND cp_id = #{cpId}
  684. </if>
  685. </where>
  686. ORDER BY display_no
  687. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  688. limit #{end} offset #{start}
  689. </if>
  690. </select>
  691. <!-- 查询商品种类的个数-->
  692. <select id="countGoodsCategory" resultType="java.lang.Long">
  693. SELECT
  694. count(1)
  695. FROM dkic_b.t_mst_goods_category
  696. <where>
  697. <if test="searchText !=null">
  698. AND ( cat_name LIKE concat('%', #{searchText}, '%')
  699. or remarks LIKE concat('%', #{searchText}, '%'))
  700. </if>
  701. <if test="cpId != null">
  702. AND cp_id = #{cpId}
  703. </if>
  704. </where>
  705. </select>
  706. <!-- 查询商品系列-->
  707. <select id="getGoodsSeries" resultType="java.util.Map">
  708. SELECT
  709. series_id AS "seriesId",
  710. series_code AS "seriesCode",
  711. series_name AS "serieName",
  712. flg_valid AS "flgValid"
  713. FROM dkic_b.t_mst_goods_series
  714. <where>
  715. <if test="searchText !=null">
  716. AND ( series_name LIKE concat('%',my_ex.likequery(#{searchText}), '%')
  717. or remarks LIKE concat('%', my_ex.likequery(#{searchText}), '%'))
  718. </if>
  719. <if test="cpId != null">
  720. AND cp_id = #{cpId}
  721. </if>
  722. </where>
  723. order by display_no asc
  724. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  725. limit #{end} offset #{start}
  726. </if>
  727. </select>
  728. <!-- 商品系列个数-->
  729. <select id="countGoodsSeries" resultType="java.lang.Long">
  730. SELECT
  731. count(1)
  732. FROM dkic_b.t_mst_goods_series
  733. <where>
  734. <if test="searchText !=null">
  735. AND ( series_name LIKE concat('%', my_ex.likequery(#{searchText}), '%')
  736. or remarks LIKE concat('%', my_ex.likequery(#{searchText}), '%'))
  737. </if>
  738. <if test="cpId != null">
  739. AND cp_id = #{cpId}
  740. </if>
  741. </where>
  742. </select>
  743. <!-- 获取计量单位-->
  744. <select id="getUnit" resultType="java.util.Map">
  745. SELECT
  746. unit_id AS "unitId",
  747. unit_code AS "unitCode",
  748. unit_name AS "unitName",
  749. decimal_places AS "decimalPlaces",
  750. flg_valid AS "flgValid"
  751. FROM dkic_b.t_mst_unit
  752. <where>
  753. <if test="searchText !=null">
  754. AND ( unit_name LIKE concat('%', my_ex.likequery(#{searchText}), '%')
  755. or remarks LIKE concat('%', my_ex.likequery(#{searchText}), '%'))
  756. </if>
  757. <if test="cpId != null">
  758. AND cp_id = #{cpId}
  759. </if>
  760. </where>
  761. order by display_no asc
  762. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  763. limit #{end} offset #{start}
  764. </if>
  765. </select>
  766. <!-- 获取计量单位个数-->
  767. <select id="countUnit" resultType="java.lang.Long">
  768. SELECT
  769. count(1)
  770. FROM dkic_b.t_mst_unit
  771. <where>
  772. <if test="searchText !=null">
  773. AND ( unit_name LIKE concat('%', my_ex.likequery(#{searchText}), '%')
  774. or remarks LIKE concat('%', my_ex.likequery(#{searchText}), '%'))
  775. </if>
  776. <if test="cpId != null">
  777. AND cp_id = #{cpId}
  778. </if>
  779. </where>
  780. </select>
  781. <!--获取仓库档案-->
  782. <select id="getWarehouseByPage" resultType="java.util.Map">
  783. SELECT
  784. wh_id AS "whId",
  785. wh_code AS "whCode",
  786. wh_name AS "whName",
  787. supervisor AS "supervisor",
  788. contact_phone AS "contactPhone",
  789. flg_valid AS "flgValid"
  790. FROM dkic_b.t_mst_warehouse
  791. <where>
  792. <if test="searchText !=null">
  793. AND ( wh_name LIKE concat('%', my_ex.likequery(#{searchText}), '%')
  794. or remarks LIKE concat('%', my_ex.likequery(#{searchText}), '%'))
  795. </if>
  796. <if test="cpId != null">
  797. AND cp_id = #{cpId}
  798. </if>
  799. </where>
  800. order by display_no asc
  801. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  802. limit #{end} offset #{start}
  803. </if>
  804. </select>
  805. <!--获取仓库档案个数-->
  806. <select id="countWarehouseByPage" resultType="Long">
  807. SELECT
  808. count(1)
  809. FROM dkic_b.t_mst_warehouse
  810. <where>
  811. <if test="searchText !=null">
  812. AND ( wh_name LIKE concat('%', my_ex.likequery(#{searchText}), '%')
  813. or remarks LIKE concat('%', my_ex.likequery(#{searchText}), '%'))
  814. </if>
  815. <if test="cpId != null">
  816. AND cp_id = #{cpId}
  817. </if>
  818. </where>
  819. </select>
  820. <!-- 查询库存 -->
  821. <select id="getInventory" resultType="java.util.Map">
  822. select tpi.inv_id as "invId",
  823. tpi.sku_id as "skuId",
  824. tmgs.sku_code as "skuCode",
  825. tmgs.sku_name as "skuName",
  826. tmgs.sku_model as "skuModel",
  827. tmgs.brand_id as "brandId",
  828. tmgb.brand_name as "brandName",
  829. tmgs.category_id as "categoryId",
  830. tmgc.cat_name as "categoryName",
  831. tmgs.unit_id as "unitId",
  832. tmgu.unit_name as "unitName",
  833. tmgs.sub_unit_id as "subUnitId",
  834. tmgs.conversion_factor as "conversionFactor",
  835. tmgs.series_id as "seriesId",
  836. tmgseries.series_name as "seriesName",
  837. tmgs.sku_spec as "skuSpec",
  838. tmgs.price_purchase as "pricePurchase",
  839. tmgs.price_standard as "priceStandard",
  840. tmgs.price_wholesale as "priceWholesale",
  841. tmgs.price_limited as "priceLimited",
  842. tmgs.sku_images as "skuImages",
  843. tpi.non_std_code as "nonStdCode",
  844. tpi.inv_qty as "invQty",
  845. tpi.outing_qty as "outingQty",
  846. tpi.usable_qty as "usableQty",
  847. tpi.wh_id as "whId",
  848. tmw.wh_code as "whCode",
  849. tmw.wh_name as "whName",
  850. tpi.remarks
  851. from dkic_b.t_psi_inventory as tpi
  852. inner join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = tpi.wh_id
  853. inner join dkic_b.t_mst_goods_sku as tmgs on tmgs.sku_id = tpi.sku_id
  854. left join dkic_b.t_mst_goods_brand as tmgb on tmgs.brand_id = tmgb.brand_id
  855. left join dkic_b.t_mst_goods_category as tmgc on tmgs.category_id = tmgc.cat_id
  856. left join dkic_b.t_mst_goods_series as tmgseries on tmgs.series_id = tmgseries.series_id
  857. left join dkic_b.t_mst_unit as tmgu on tmgs.unit_id = tmgu.unit_id
  858. where tpi.flg_valid
  859. AND tpi.cp_id = #{cpId}
  860. <if test="skuId != null">
  861. AND tpi.sku_id = #{skuId} ::uuid
  862. </if>
  863. <if test="nonStdCode != null">
  864. AND tpi.non_std_code = #{nonStdCode}
  865. </if>
  866. <if test="skuCode != null">
  867. AND tmgs.sku_code LIKE concat('%',my_ex.likequery(#{skuCode}),'%')
  868. </if>
  869. <if test="skuName != null">
  870. AND tmgs.sku_name LIKE concat('%',my_ex.likequery(#{skuName}),'%')
  871. </if>
  872. <if test="whName != null">
  873. AND tmgs.wh_name LIKE concat('%',my_ex.likequery(#{whName}),'%')
  874. </if>
  875. </select>
  876. <!-- 查询库存个数 -->
  877. <select id="getInventoryCountByPage" resultType="Long">
  878. SELECT
  879. count(1)
  880. from dkic_b.t_psi_inventory as tpi
  881. inner join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = tpi.wh_id
  882. inner join dkic_b.t_mst_goods_sku as tmgs on tmgs.sku_id = tpi.sku_id
  883. where tpi.flg_valid
  884. AND tpi.cp_id = #{cpId}
  885. <if test="skuId != null">
  886. AND tpi.sku_id = #{skuId} ::uuid
  887. </if>
  888. <if test="nonStdCode != null">
  889. AND tpi.non_std_code = #{nonStdCode}
  890. </if>
  891. <if test="skuCode != null">
  892. AND tmgs.sku_code = #{skuCode}
  893. </if>
  894. <if test="skuName != null">
  895. AND tmgs.sku_name = #{skuName}
  896. </if>
  897. <if test="whName != null">
  898. AND tmgs.wh_name = #{whName}
  899. </if>
  900. </select>
  901. <!-- 获取销售渠道-->
  902. <select id="getSaleChannel" resultType="java.util.Map">
  903. SELECT
  904. channel_id AS "channelId",
  905. channel_id AS "id",
  906. channel_code AS "channelCode",
  907. channel_name AS "channelName"
  908. FROM dkic_b.t_mst_sale_channel
  909. <where>
  910. <if test="cpId != null">
  911. AND cp_id = #{cpId}
  912. </if>
  913. </where>
  914. </select>
  915. <!--获取员工-->
  916. <select id="getStaff" resultType="java.util.Map">
  917. SELECT
  918. staff_id AS "staffId",
  919. staff_id AS "id",
  920. staff_code AS "staffCode",
  921. staff_name AS "staffName"
  922. FROM dkic_b.t_mst_staff
  923. <where>
  924. <if test="cpId != null">
  925. AND cp_id = #{cpId}
  926. </if>
  927. </where>
  928. </select>
  929. <!--获取仓库档案-->
  930. </mapper>