CommonMapper.xml 34 KB

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