CommonMapper.xml 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264
  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. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  876. limit #{end} offset #{start}
  877. </if>
  878. </select>
  879. <!-- 查询库存个数 -->
  880. <select id="getInventoryCountByPage" resultType="Long">
  881. SELECT
  882. count(1)
  883. from dkic_b.t_psi_inventory as tpi
  884. inner join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = tpi.wh_id
  885. inner join dkic_b.t_mst_goods_sku as tmgs on tmgs.sku_id = tpi.sku_id
  886. where tpi.flg_valid
  887. AND tpi.cp_id = #{cpId}
  888. <if test="skuId != null">
  889. AND tpi.sku_id = #{skuId} ::uuid
  890. </if>
  891. <if test="nonStdCode != null">
  892. AND tpi.non_std_code = #{nonStdCode}
  893. </if>
  894. <if test="skuCode != null">
  895. AND tmgs.sku_code LIKE concat('%',my_ex.likequery(#{skuCode}),'%')
  896. </if>
  897. <if test="skuName != null">
  898. AND tmgs.sku_name LIKE concat('%',my_ex.likequery(#{skuName}),'%')
  899. </if>
  900. <if test="whName != null">
  901. AND tmgs.wh_name LIKE concat('%',my_ex.likequery(#{whName}),'%')
  902. </if>
  903. </select>
  904. <!-- 获取销售渠道-->
  905. <select id="getSaleChannel" resultType="java.util.Map">
  906. SELECT
  907. channel_id AS "channelId",
  908. channel_id AS "id",
  909. channel_code AS "channelCode",
  910. channel_name AS "channelName"
  911. FROM dkic_b.t_mst_sale_channel
  912. <where>
  913. <if test="cpId != null">
  914. AND cp_id = #{cpId}
  915. </if>
  916. </where>
  917. </select>
  918. <!--获取仓库档案-->
  919. <!--获取供应商和客户数据-->
  920. <select id="getSupplierAndCustomer" resultType="java.util.Map">
  921. select tms.sup_id as "objId",
  922. tms.sup_code as "objCode",
  923. tms.sup_name as "objName",
  924. '供应商' as "objTypeName",
  925. 1 as "objType",
  926. tms.flg_valid as "flgValid"
  927. null as "phone",
  928. null as "addressFull"
  929. from dkic_b.t_mst_supplier tms
  930. <where>
  931. <if test="flgValid">
  932. AND tms.flgValid
  933. </if>
  934. <if test="objCode != null and objCode != ''">
  935. AND tms.sup_code LIKE concat('%',my_ex.likequery(#{objCode}),'%')
  936. </if>
  937. <if test="objName != null and objName != ''">
  938. AND tms.sup_name LIKE concat('%',my_ex.likequery(#{objCode}),'%')
  939. </if>
  940. </where>
  941. union all
  942. select cus.cus_id as "objId",
  943. cus.cus_code as "objCode",
  944. cus.cus_name as "objName",
  945. '客户' as "objTypeName",
  946. 2 as "objType",
  947. cus.flg_valid as "flgValid",
  948. cus.cus_phone as "phone",
  949. cus.address_full as "addressFull"
  950. from dkic_b.t_mst_customer cus
  951. <where>
  952. <if test="flgValid">
  953. AND cus.flgValid
  954. </if>
  955. <if test="objCode != null and objCode != ''">
  956. AND cus.cus_code LIKE concat('%',my_ex.likequery(#{objCode}),'%')
  957. </if>
  958. <if test="objName != null and objName != ''">
  959. AND cus.cus_name LIKE concat('%',my_ex.likequery(#{objName}),'%')
  960. </if>
  961. </where>
  962. </select>
  963. <!--获取供应商和客户数据分页-->
  964. <select id="getSupplierAndCustomerByPage" resultType="java.util.Map">
  965. select * from(
  966. select tms.sup_id as "objId",
  967. tms.sup_code as "objCode",
  968. tms.sup_name as "objName",
  969. '供应商' as "objTypeName",
  970. 1 as "objType",
  971. tms.flg_valid as "flgValid",
  972. null as "phone",
  973. null as "addressFull"
  974. from dkic_b.t_mst_supplier tms
  975. <where >
  976. <if test="flgValid">
  977. AND tms.flgValid
  978. </if>
  979. <if test="objCode != null and objCode != ''">
  980. AND tms.sup_code LIKE concat('%',my_ex.likequery(#{objCode}),'%')
  981. </if>
  982. <if test="objName != null and objName != ''">
  983. AND tms.sup_name LIKE concat('%',my_ex.likequery(#{objCode}),'%')
  984. </if>
  985. </where>
  986. union all
  987. select cus.cus_id as "objId",
  988. cus.cus_code as "objCode",
  989. cus.cus_name as "objName",
  990. '客户' as "objTypeName",
  991. 2 as "objType",
  992. cus.flg_valid as "flgValid",
  993. cus.cus_phone as "phone",
  994. cus.address_full as "addressFull"
  995. from dkic_b.t_mst_customer cus
  996. <where>
  997. <if test="flgValid">
  998. AND cus.flgValid
  999. </if>
  1000. <if test="objCode != null and objCode != ''">
  1001. AND cus.cus_code LIKE concat('%',my_ex.likequery(#{objCode}),'%')
  1002. </if>
  1003. <if test="objName != null and objName != ''">
  1004. AND cus.cus_name LIKE concat('%',my_ex.likequery(#{objName}),'%')
  1005. </if>
  1006. <if test="flgValid">
  1007. AND cus.flgValid
  1008. </if>
  1009. </where>
  1010. ) tt
  1011. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  1012. limit #{end} offset #{start}
  1013. </if>
  1014. </select>
  1015. <!--获取供应商和客户数据分页-->
  1016. <select id="getSupplierAndCustomerByPageCount" resultType="Long">
  1017. select count(1) from(
  1018. select tms.sup_id as "objId",
  1019. tms.sup_code as "objCode",
  1020. tms.sup_name as "objName",
  1021. '供应商' as "objTypeName",
  1022. 1 as "objType",
  1023. tms.flg_valid as "flgValid",
  1024. null as "phone",
  1025. null as "addressFull"
  1026. from dkic_b.t_mst_supplier tms
  1027. <where>
  1028. <if test="flgValid">
  1029. AND tms.flgValid
  1030. </if>
  1031. <if test="objCode != null and objCode != ''">
  1032. AND tms.sup_code LIKE concat('%',my_ex.likequery(#{objCode}),'%')
  1033. </if>
  1034. <if test="objName != null and objName != ''">
  1035. AND tms.sup_name LIKE concat('%',my_ex.likequery(#{objCode}),'%')
  1036. </if>
  1037. </where>
  1038. union all
  1039. select cus.cus_id as "objId",
  1040. cus.cus_code as "objCode",
  1041. cus.cus_name as "objName",
  1042. '客户' as "objTypeName",
  1043. 2 as "objType",
  1044. cus.flg_valid as "flgValid",
  1045. cus.cus_phone as "phone",
  1046. cus.address_full as "addressFull"
  1047. from dkic_b.t_mst_customer cus
  1048. <where>
  1049. <if test="flgValid">
  1050. AND cus.flgValid
  1051. </if>
  1052. <if test="objCode != null and objCode != ''">
  1053. AND cus.cus_code LIKE concat('%',my_ex.likequery(#{objCode}),'%')
  1054. </if>
  1055. <if test="objName != null and objName != ''">
  1056. AND cus.cus_name LIKE concat('%',my_ex.likequery(#{objName}),'%')
  1057. </if>
  1058. </where>
  1059. ) tt
  1060. </select>
  1061. <!-- 获取用户 -->
  1062. <select id="getStaff" resultType="java.util.Map">
  1063. select
  1064. s.staff_name as "staffName"
  1065. , s.staff_code as "staffCode"
  1066. , sys.f_code_name(s.staff_code, s.staff_name) AS "staffCodeName",
  1067. , s.staff_id as "staffId"
  1068. , s.staff_id AS "id",
  1069. , s.org_id as "orgId"
  1070. , o.org_name as "orgName"
  1071. , c.cp_name as "cpName"
  1072. FROM dkic_b.t_mst_staff s
  1073. left join dkic_b.t_mst_org o on o.org_id = s.org_id
  1074. left join dkic_a.t_a_company c on c.cp_id = s.cp_id
  1075. where
  1076. u.cp_id = #{cpId}
  1077. <if test="staffCode !=null and staffCode !=''">
  1078. AND s.staff_code LIKE concat('%',my_ex.likequery(#{staffCode}),'%')
  1079. </if>
  1080. <if test="staffName !=null and staffName !=''">
  1081. AND s.staff_name LIKE concat('%',my_ex.likequery(#{staffName}),'%')
  1082. </if>
  1083. <if test="orgId !=null">
  1084. AND s.org_id = #{orgId}
  1085. </if>
  1086. <if test="orgName !=null and orgName !=''">
  1087. AND o.org_name LIKE concat('%',my_ex.likequery(#{orgName}),'%')
  1088. </if>
  1089. </select>
  1090. <!-- 获取组织机构 -->
  1091. <select id="getOrganization" resultType="java.util.Map">
  1092. select o.org_id as "orgId"
  1093. , o.org_code as "orgCode"
  1094. , o.org_name as "orgName"
  1095. , sys.f_code_name(o.org_code, o.org_name) AS "orgCodeName"
  1096. from dkic_b.t_mst_org o
  1097. where
  1098. o.flg_valid
  1099. and o.cp_id = #{cpId}
  1100. <if test="orgCode !=null and orgCode !=''">
  1101. AND o.org_code LIKE concat('%',my_ex.likequery(#{orgCode}),'%')
  1102. </if>
  1103. <if test="orgName !=null and orgName !=''">
  1104. AND o.org_name LIKE concat('%',my_ex.likequery(#{orgName}),'%')
  1105. </if>
  1106. order by o.level_code
  1107. </select>
  1108. <!-- 获取组织机构分页 -->
  1109. <select id="getOrganizationByPage" resultType="java.util.Map">
  1110. select o.org_id as "orgId"
  1111. , o.org_code as "orgCode"
  1112. , o.org_name as "orgName"
  1113. , sys.f_code_name(o.org_code, o.org_name) AS "orgCodeName"
  1114. from dkic_b.t_mst_org o
  1115. where
  1116. o.flg_valid
  1117. and o.cp_id = #{cpId}
  1118. <if test="orgCode !=null and orgCode !=''">
  1119. AND o.org_code LIKE concat('%',my_ex.likequery(#{orgCode}),'%')
  1120. </if>
  1121. <if test="orgName !=null and orgName !=''">
  1122. AND o.org_name LIKE concat('%',my_ex.likequery(#{orgName}),'%')
  1123. </if>
  1124. order by o.level_code
  1125. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  1126. limit #{end} offset #{start}
  1127. </if>
  1128. </select>
  1129. <!-- 获取组织机构分个数-->
  1130. <select id="getOrganizationCount" resultType="java.lang.Long">
  1131. SELECT count(1)
  1132. from dkic_b.t_mst_org o
  1133. where
  1134. o.flg_valid
  1135. and o.cp_id = #{cpId}
  1136. <if test="orgCode !=null and orgCode !=''">
  1137. AND o.org_code LIKE concat('%',my_ex.likequery(#{orgCode}),'%')
  1138. </if>
  1139. <if test="orgName !=null and orgName !=''">
  1140. AND o.org_name LIKE concat('%',my_ex.likequery(#{orgName}),'%')
  1141. </if>
  1142. </select>
  1143. <!-- 获取资金账户(下拉)-->
  1144. <select id="getMac" resultType="java.util.Map">
  1145. select tmma.mac_id as "macId",
  1146. tmma.mac_code as "macCode",
  1147. tmma.mac_name as "macName",
  1148. tmma.mac_type as "macType",
  1149. tmma.balance,
  1150. tmma.display_no as "displayNo",
  1151. tmma.flg_default as "flgDefault",
  1152. tmma.mac_receipt_code as "macReceiptCode",
  1153. tmma.remarks
  1154. from dkic_b.t_mst_money_account tmma
  1155. where tmma.flg_valid
  1156. and tmma.cp_id = #{cpId}
  1157. <if test="macCode !=null and macCode !=''">
  1158. AND tmma.mac_code LIKE concat('%',my_ex.likequery(#{macCode}),'%')
  1159. </if>
  1160. <if test="macName !=null and macName !=''">
  1161. AND tmma.mac_name LIKE concat('%',my_ex.likequery(#{macName}),'%')
  1162. </if>
  1163. order by tmma.display_no
  1164. </select>
  1165. <!-- 获取资金账户(放大镜) -->
  1166. <select id="getMoneyAccount" resultType="java.util.Map">
  1167. select tmma.mac_id as "macId",
  1168. tmma.mac_code as "macCode",
  1169. tmma.mac_name as "macName",
  1170. tmma.mac_type as "macType",
  1171. tmma.balance,
  1172. tmma.display_no as "displayNo",
  1173. tmma.flg_default as "flgDefault",
  1174. tmma.mac_receipt_code as "macReceiptCode",
  1175. tmma.remarks
  1176. from dkic_b.t_mst_money_account tmma
  1177. where tmma.flg_valid
  1178. and tmma.cp_id = #{cpId}
  1179. <if test="macCode !=null and macCode !=''">
  1180. AND tmma.mac_code LIKE concat('%',my_ex.likequery(#{macCode}),'%')
  1181. </if>
  1182. <if test="macName !=null and macName !=''">
  1183. AND tmma.mac_name LIKE concat('%',my_ex.likequery(#{macName}),'%')
  1184. </if>
  1185. order by tmma.display_no
  1186. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  1187. limit #{end} offset #{start}
  1188. </if>
  1189. </select>
  1190. <!-- 获取资金账户(放大镜)个数 -->
  1191. <select id="getMoneyAccountCountByPage" resultType="Long">
  1192. SELECT
  1193. count(1)
  1194. from dkic_b.t_mst_money_account tmma
  1195. where tmma.flg_valid
  1196. and tmma.cp_id = #{cpId}
  1197. <if test="macCode !=null and macCode !=''">
  1198. AND tmma.mac_code LIKE concat('%',my_ex.likequery(#{macCode}),'%')
  1199. </if>
  1200. <if test="macName !=null and macName !=''">
  1201. AND tmma.mac_name LIKE concat('%',my_ex.likequery(#{macName}),'%')
  1202. </if>
  1203. </select>
  1204. </mapper>