CommonMapper.xml 35 KB

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