CommonMapper.xml 125 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175
  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)
  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. <resultMap id="BaseResultMap" type="java.util.Map">
  31. <result column="kindTags" property="kindTags" typeHandler="JsonTypeHandler"/>
  32. </resultMap>
  33. <!-- 获取数据种类 -->
  34. <select id="getDataKind" resultMap="BaseResultMap">
  35. select kind_code AS "kindCode",
  36. sys.f_get_name_i18n_lang(kind_name_i18n,#{i18n}) as "kindName",
  37. sys.f_get_name_i18n_lang(kind_desc,#{i18n}) as "gradeKindDesc",
  38. kind_type AS "kindType",
  39. kind_tags AS "kindTags",
  40. display_no AS "displayNo",
  41. remarks
  42. from sys.t_data_kind
  43. where flg_valid
  44. <if test="kindType != null">
  45. AND kind_type = #{kindType}
  46. </if>
  47. <if test="usedFlag != null">
  48. AND kind_tags -> 'used' ?? '标签'
  49. </if>
  50. <if test="kindTag != null">
  51. AND kind_tags -> 'used' ?? #{kindTag}
  52. </if>
  53. <if test="kindCodeList != null and kindCodeList.size()>0">
  54. AND kind_code =any(#{kindCodeList,typeHandler=StringListTypeHandler})
  55. </if>
  56. order by display_no
  57. </select>
  58. <!-- 获取型号分类 -->
  59. <select id="getModelCategory" resultType="java.util.Map">
  60. select tmc.category_id AS "categoryId",
  61. tmc.category_code AS "categoryCode",
  62. tmc.category_name AS "categoryName",
  63. tmc.model_kind AS "modelKind",
  64. sys.f_get_name_i18n_lang(tdk.kind_name_i18n,#{i18n}) AS "modelKindName",
  65. tmc.category_id AS "id",
  66. tmc.parent_id AS "parentId",
  67. tmc.top_id AS "topId",
  68. tmc.level_no AS "levelNo",
  69. tmc.level_code AS "levelCode",
  70. tmc.level_name AS "levelName",
  71. tmc.level_leaf as "levelLeaf",
  72. tmc.remarks
  73. from mst.t_model_category tmc
  74. inner join sys.t_data_kind tdk
  75. on tdk.kind_code = tmc.model_kind
  76. where tmc.fty_id = #{ftyId}
  77. and tmc.flg_valid
  78. <if test="modelKind!=null">
  79. and tmc.model_kind = #{modelKind}
  80. </if>
  81. <if test="topId!=null">
  82. and tmc.top_id = #{topId}
  83. </if>
  84. <if test="categoryId!=null">
  85. and tmc.category_id != #{categoryId}
  86. </if>
  87. <if test="levelLeaf != null and levelLeaf">
  88. And tmc.level_leaf
  89. </if>
  90. <if test="levelNo != null and levelNo != ''">
  91. AND tmc.level_no=#{levelNo}
  92. </if>
  93. order by tmc.display_no
  94. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  95. limit #{end} offset #{start}
  96. </if>
  97. </select>
  98. <select id="countModelCategory" resultType="Long">
  99. select count(1)
  100. from mst.t_model_category tmc
  101. where tmc.fty_id = #{ftyId}
  102. and tmc.flg_valid
  103. <if test="modelKind!=null">
  104. and tmc.model_kind = #{modelKind}
  105. </if>
  106. </select>
  107. <!-- 获取工种 -->
  108. <select id="getJob" resultType="java.util.Map">
  109. select tj.job_Id AS "jobId",
  110. tj.job_name AS "jobName",
  111. tj.work_kind AS "workKind",
  112. sys.f_get_name_i18n_lang(tdk.kind_name_i18n,#{i18n}) AS "workKindName",
  113. tj.work_unit AS "workUnit",
  114. tj.display_no AS "displayNo",
  115. tj.remarks
  116. from core.t_job tj
  117. LEFT join sys.t_data_kind tdk on tdk.kind_code = tj.work_kind
  118. where tj.fty_id = #{ftyId}
  119. and tj.flg_valid
  120. <if test="workFlag!=null">
  121. and tj.work_kind is not null
  122. </if>
  123. <if test="productId!=null">
  124. and exists(
  125. SELECT pp.flow_node_id, tpnjd.job_id
  126. FROM pdm.t_production pp
  127. INNER JOIN pdm.t_process_node n ON n.node_id = pp.flow_node_id
  128. left join pdm.t_process_node_job_defect tpnjd
  129. on tpnjd.node_id = n.node_id and tpnjd.pdt_defect_id = #{defectId}
  130. WHERE pp.flg_valid
  131. AND NOT pp.flg_undo
  132. AND pp.pdt_unique_id = #{productId}
  133. and tpnjd.job_id = tj.job_id
  134. <if test="node!=null and nodeId!=''">
  135. and n.node_id = #{nodeId}::uuid
  136. </if>
  137. )
  138. </if>
  139. order by tj.display_no
  140. </select>
  141. <!-- 获取个数 -->
  142. <select id="countJob" resultType="Long">
  143. select count(1)
  144. from core.t_job tj
  145. LEFT join sys.t_data_kind tdk on tdk.kind_code = tj.work_kind
  146. where tj.fty_id = #{ftyId}
  147. and tj.flg_valid
  148. <if test="workFlag!=null">
  149. and tj.work_kind is not null
  150. </if>
  151. <if test="productId!=null">
  152. and exists(
  153. SELECT pp.flow_node_id, tpnjd.job_id
  154. FROM pdm.t_production pp
  155. INNER JOIN pdm.t_process_node n ON n.node_id = pp.flow_node_id
  156. left join pdm.t_process_node_job_defect tpnjd
  157. on tpnjd.node_id = n.node_id and tpnjd.pdt_defect_id = #{defectId}
  158. WHERE pp.flg_valid
  159. AND NOT pp.flg_undo
  160. AND pp.pdt_unique_id = #{productId}
  161. and tpnjd.job_id = tj.job_id
  162. <if test="node!=null and nodeId!=''">
  163. and n.node_id = #{nodeId}::uuid
  164. </if>
  165. )
  166. </if>
  167. </select>
  168. <!-- 获取职务 -->
  169. <select id="getPost" resultType="java.util.Map">
  170. select post_Id AS "postId",
  171. post_name AS "postName",
  172. display_no AS "displayNo",
  173. remarks
  174. from core.t_post
  175. where fty_id = #{ftyId}
  176. and flg_valid
  177. order by display_no
  178. </select>
  179. <!-- 获取组织部门 -->
  180. <select id="getOrg" resultType="java.util.Map">
  181. select org_Id AS "orgId",
  182. org_code AS "orgCode",
  183. org_name AS "orgName",
  184. org_Id AS "id",
  185. parent_id AS "parentId",
  186. top_Id AS "topId",
  187. display_no AS "displayNo",
  188. remarks
  189. from dkic_b.t_mst_org
  190. where flg_valid
  191. and cp_id = #{cpId}
  192. <if test="topId != null">
  193. AND top_id = #{topId}
  194. </if>
  195. <if test="orgId != null">
  196. AND org_id != #{orgId}
  197. </if>
  198. order by display_no
  199. </select>
  200. <!-- t_mst_org,(条件查询)个数 -->
  201. <select id="getOrgCountByPage" resultType="Long">
  202. SELECT
  203. count(1)
  204. from dkic_b.t_mst_org
  205. where flg_valid
  206. and cp_id = #{cpId}
  207. <if test="topId != null">
  208. AND top_id = #{topId}
  209. </if>
  210. <if test="orgId != null">
  211. AND org_id != #{orgId}
  212. </if>
  213. </select>
  214. <!-- 产品品牌-->
  215. <select id="getBrand" resultType="java.util.Map">
  216. select brand_id as "brandId",
  217. brand_code as "brandCode",
  218. brand_name as "brandName",
  219. display_no as "displayNo",
  220. remarks
  221. from mst.t_product_brand
  222. where fty_id = #{ftyId}
  223. and flg_valid
  224. order by display_no
  225. </select>
  226. <!-- 获取用户菜单-->
  227. <select id="getMenuByUser" resultType="java.util.Map">
  228. select menu_uuid AS "menuUuid",
  229. name AS "name",
  230. menu_name AS "menuName",
  231. parent_uuid AS "parentUuid",
  232. menu_type AS "menuType",
  233. flg_menu AS "flgMenu",
  234. flg_right AS "flgRight",
  235. object_code AS "objectCode",
  236. object_paths AS "objectPaths",
  237. object_icon AS "icon",
  238. parent_path AS "parentPath",
  239. menu_tags AS "menuTags",
  240. level_code AS "levelCode",
  241. flg_fast AS "flgFast",
  242. fast_image AS "fastImage",
  243. fast_path AS "fastPath",
  244. ex_menu_uuid AS "exMenuUuid",
  245. flg_same_route AS "flgSameRoute",
  246. flg_choose_id AS "flgChooseId",
  247. #{appCode} AS "appCode",
  248. menu_uuid AS "id",
  249. parent_uuid AS "parentId"
  250. from
  251. <if test="appCode=='WEB-TOUCH'">
  252. core.f_get_user_menu_touch(#{appCode}, #{userId})
  253. </if>
  254. <if test="appCode!='WEB-TOUCH'">
  255. core.f_get_user_menu(#{appCode}, #{userId})
  256. </if>
  257. </select>
  258. <!-- 获取缺陷分类 -->
  259. <select id="getDefectType" resultType="java.util.Map">
  260. select type_id as "typeId",
  261. type_code as "typeCode",
  262. type_name as "typeName",
  263. display_no as "displayNo",
  264. remarks
  265. from mst.t_product_defect_type
  266. where fty_id = #{ftyId}
  267. and flg_valid
  268. <if test="defectKind != null">
  269. AND defect_kind = #{defectKind}
  270. </if>
  271. order by display_no
  272. </select>
  273. <!-- 获取角色 -->
  274. <select id="getRole" resultType="java.util.Map">
  275. select role_Id AS "roleId",
  276. role_name AS "roleName",
  277. display_no AS "displayNo",
  278. remarks
  279. from core.t_role
  280. where (fty_id = #{ftyId} OR fty_id = 0)
  281. and flg_valid
  282. order by display_no
  283. </select>
  284. <!-- 获取员工 -->
  285. <select id="getStaffByPage" resultType="java.util.Map">
  286. select staff.staff_id AS "staffId",
  287. staff.staff_code AS "staffCode",
  288. staff.staff_name AS "staffName",
  289. sys.f_code_name(staff.staff_code, staff.staff_name) AS "staffCodeName",
  290. staff.remarks
  291. from dkic_b.t_mst_staff AS staff
  292. where staff.flg_valid
  293. and staff.cp_id =#{cpId}
  294. <if test="staffCode != null and staffCode != ''">
  295. And position (#{staffCode} in staff.staff_code)>0
  296. </if>
  297. <if test="staffName != null and staffName != ''">
  298. And position (#{staffName} in staff.staff_name)>0
  299. </if>
  300. order by staff.staff_code
  301. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  302. limit #{end} offset #{start}
  303. </if>
  304. </select>
  305. <!-- 查询表t_user,(条件查询)个数 -->
  306. <select id="getStaffCountByPage" resultType="Long">
  307. SELECT
  308. count(1)
  309. from dkic_b.t_mst_staff AS staff
  310. where staff.flg_valid
  311. and staff.cp_id =#{cpId}
  312. <if test="staffCode != null and staffCode != ''">
  313. And position (#{staffCode} in staff.staff_code)>0
  314. </if>
  315. <if test="staffName != null and staffName != ''">
  316. And position (#{staffName} in staff.staff_name)>0
  317. </if>
  318. </select>
  319. <!-- 函数查询单个系统参数-->
  320. <select id="getSettingValue" resultType="String">
  321. select core.f_get_setting_value(#{code}, #{ftyId})
  322. </select>
  323. <!-- 函数查询多个系统参数-->
  324. <select id="getSettingValues" resultType="Map">
  325. select core.f_get_setting_values(
  326. #{codes, typeHandler=StringListTypeHandler}, #{ftyId})
  327. </select>
  328. <!-- 获取工厂区域 -->
  329. <select id="getFactorySpace" resultType="java.util.Map">
  330. select space_id as "spaceId",
  331. space_code as "spaceCode",
  332. space_name as "spaceName",
  333. display_no as "displayNo",
  334. space_id AS "id",
  335. case when parent_id = #{workShop} then 0 else parent_id end "parentId",
  336. --parent_id AS "parentId",
  337. top_id as "topId",
  338. level_no AS "levelNo",
  339. level_code AS "levelCode",
  340. level_name AS "levelName",
  341. remarks
  342. from mst.t_factory_space
  343. where fty_id = #{ftyId}
  344. and flg_valid
  345. <if test="workShop != null and workShop != ''">
  346. And #{workShop} = any(level_upper)
  347. </if>
  348. <if test="topId != null">
  349. And top_id = #{topId}
  350. </if>
  351. <if test="spaceId != null">
  352. And space_id != #{spaceId}
  353. </if>
  354. <if test="spaceKind != null and spaceKind != ''">
  355. and space_kind = #{spaceKind}
  356. </if>
  357. order by level_code
  358. </select>
  359. <!-- 查询系统参数分类 -->
  360. <select id="getSettingKind" resultType="java.util.Map">
  361. select sk.kind_code as "classCode",
  362. sys.f_get_name_i18n_lang(sk.kind_name_i18n, #{i18n}) as "className",
  363. sk.display_no as "displayNo"
  364. from sys.t_setting_kind as sk
  365. where sk.flg_valid
  366. order by sk.display_no
  367. </select>
  368. <!-- 获取员组织部门-->
  369. <select id="getOrganizationByPage" resultType="java.util.Map">
  370. select org.org_id AS "orgId",
  371. org.org_code AS "orgCode",
  372. org.org_name AS "orgName",
  373. org.level_name as "levelName",
  374. org.remarks
  375. from core.t_organization AS org
  376. where org.fty_id = #{ftyId}
  377. and org.flg_valid
  378. <if test="orgCode != null and orgCode != ''">
  379. And position (#{orgCode} in org.org_code)>0
  380. </if>
  381. <if test="orgName != null and orgName != ''">
  382. And position (#{orgName} in org.org_name)>0
  383. </if>
  384. order by org.org_code
  385. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  386. limit #{end} offset #{start}
  387. </if>
  388. </select>
  389. <!-- 查询表t_organization,(条件查询)个数 -->
  390. <select id="getOrganizationCountByPage" resultType="Long">
  391. SELECT
  392. count(1)
  393. from core.t_organization AS org
  394. where org.fty_id = #{ftyId}
  395. and org.flg_valid
  396. <if test="orgCode != null and orgCode != ''">
  397. And position (#{orgCode} in org.org_code)>0
  398. </if>
  399. <if test="orgName != null and orgName != ''">
  400. And position (#{orgName} in org.org_name)>0
  401. </if>
  402. </select>
  403. <!-- 获取窑炉 -->
  404. <select id="getKiln" resultType="java.util.Map">
  405. select unique_id as "kilnId",
  406. unique_code as "kilnCode",
  407. kiln_name as "kilnName",
  408. sys.f_code_name(unique_code,kiln_name) AS "kilnCodeName",
  409. display_no as "displayNo",
  410. space_id as "spaceId",
  411. remarks
  412. from mst.t_kiln
  413. where fty_id = #{ftyId}
  414. and flg_valid
  415. order by display_no
  416. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  417. limit #{end} offset #{start}
  418. </if>
  419. </select>
  420. <select id="countKiln" resultType="Long">
  421. select count(1)
  422. from mst.t_kiln
  423. where fty_id = #{ftyId}
  424. and flg_valid
  425. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  426. limit #{end} offset #{start}
  427. </if>
  428. </select>
  429. <!-- 获取型号 -->
  430. <select id="getModelMould" resultType="java.util.Map">
  431. select model_id as "modelId", model_code as "modelCode", model_name as "modelName",
  432. sys.f_code_name(model_code,model_name) AS "codeName"
  433. from
  434. <if test="modelKind==null or modelKind=='型号种类-模具'">
  435. mst.t_model_mould
  436. </if>
  437. <if test="modelKind=='型号种类-物料'">
  438. mst.t_model_material
  439. </if>
  440. <if test="modelKind=='型号种类-载具'">
  441. mst.t_model_carrier
  442. </if>
  443. <if test="modelKind=='型号种类-设备'">
  444. mst.t_model_equipment
  445. </if>
  446. where fty_id = #{ftyId}
  447. and flg_valid
  448. </select>
  449. <!-- 获取用户 -->
  450. <select id="getUser" resultType="java.util.Map">
  451. select tu.user_id as "userId", tu.user_code as "userCode", tu.user_name as "userName",
  452. sys.f_code_name(tu.user_code,tu.user_name) AS "userCodeName"
  453. from core.t_user tu
  454. where fty_id = #{ftyId}
  455. and flg_valid
  456. <if test="userCode != null and userCode != ''">
  457. And position (#{userCode} in user_code)>0
  458. </if>
  459. <if test="userCodeSame != null and userCodeSame != ''">
  460. And #{userCodeSame} = user_code
  461. </if>
  462. <if test="userName != null and userName != ''">
  463. And position (#{userName} in user_name)>0
  464. </if>
  465. <if test="userType != null">
  466. And user_type = #{userType}
  467. </if>
  468. <if test="jobId != null">
  469. And exists(
  470. select 1 from core.t_work_team twt
  471. where twt.wt_job_id = #{jobId} and twt.user_id = user_id
  472. )
  473. </if>
  474. <if test="productId != null">
  475. and exists(
  476. SELECT 1
  477. FROM pdm.t_production pp
  478. INNER JOIN pdm.t_process_node n ON n.node_id = pp.flow_node_id
  479. left join pdm.t_process_node_user tpnu
  480. on tpnu.node_id = pp.flow_node_id and tpnu.user_kind = n.user_kind
  481. WHERE pp.flg_valid
  482. AND NOT pp.flg_undo
  483. AND pp.pdt_unique_id = #{productId}
  484. and tpnu.user_id = tu.user_id
  485. <if test="node != null and nodeId != ''">
  486. and n.node_id = #{nodeId}
  487. </if>
  488. )
  489. </if>
  490. <if test="flowNodeId != null and flowNodeId != ''">
  491. and exists(
  492. SELECT 1
  493. FROM pdm.t_process_node_user where node_id = #{flowNodeId, typeHandler=UuidTypeHandler} and user_id = tu.user_id
  494. )
  495. </if>
  496. ORDER BY user_code
  497. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  498. limit #{end} offset #{start}
  499. </if>
  500. </select>
  501. <select id="countUser" resultType="Long">
  502. select count(1)
  503. from core.t_user tu
  504. where fty_id = #{ftyId}
  505. and flg_valid
  506. <if test="userCode != null and userCode != ''">
  507. And position (#{userCode} in user_code)>0
  508. </if>
  509. <if test="userName != null and userName != ''">
  510. And position (#{userName} in user_name)>0
  511. </if>
  512. <if test="userType != null">
  513. And user_type = #{userType}
  514. </if>
  515. <if test="jobId != null">
  516. And exists(
  517. select 1 from core.t_work_team twt
  518. where twt.wt_job_id = #{jobId} and twt.user_id = user_id
  519. )
  520. </if>
  521. <if test="productId != null">
  522. and exists(
  523. SELECT 1
  524. FROM pdm.t_production pp
  525. INNER JOIN pdm.t_process_node n ON n.node_id = pp.flow_node_id
  526. left join pdm.t_process_node_user tpnu
  527. on tpnu.node_id = pp.flow_node_id and tpnu.user_kind = n.user_kind
  528. WHERE pp.flg_valid
  529. AND NOT pp.flg_undo
  530. AND pp.pdt_unique_id = #{productId}
  531. and tpnu.user_id = tu.user_id
  532. <if test="node != null and nodeId != ''">
  533. and n.node_id = #{nodeId}
  534. </if>
  535. )
  536. </if>
  537. <if test="flowNodeId != null and flowNodeId != ''">
  538. and exists(
  539. SELECT 1
  540. FROM pdm.t_process_node_user where node_id = #{flowNodeId, typeHandler=UuidTypeHandler} and user_id = tu.user_id
  541. )
  542. </if>
  543. </select>
  544. <!-- 获取窑车位置 -->
  545. <select id="getKilnCarPlace" resultType="java.util.Map">
  546. select range_id as "rangeId",
  547. range_name as "rangeName",
  548. range_no as "rangeNo",
  549. remarks
  550. from mst.t_model_carrier_range
  551. where fty_id = #{ftyId}
  552. and flg_valid
  553. <if test="carModelId != null">
  554. And car_model_id = #{carModelId}
  555. </if>
  556. order by display_no
  557. </select>
  558. <!-- 查询产品视图 -->
  559. <select id="getProductView" resultType="java.util.Map">
  560. select tpv.view_id as "viewId",
  561. tpv.view_code as "viewCode",
  562. tpv.view_name as "viewName",
  563. tpv.remarks as "remarks",
  564. tpv.flg_valid as "flgValid"
  565. from mst.t_product_view tpv
  566. where tpv.flg_valid
  567. and tpv.fty_id = #{ftyId}
  568. </select>
  569. <!-- 查询产品商标-->
  570. <select id="getProductLogo" resultType="java.util.Map">
  571. select logo.logo_id as "logoId",
  572. logo.logo_code as "logoCode",
  573. logo.logo_name as "logoName",
  574. logo.logo_paths as "logoPaths",
  575. logo.brand_id as "brandId",
  576. logo.display_no as "displayNo",
  577. logo.remarks as "remarks"
  578. from mst.t_product_logo logo
  579. where logo.flg_valid
  580. and logo.fty_id = #{ftyId}
  581. order by logo.display_no
  582. </select>
  583. <!-- 查询产品釉色 -->
  584. <select id="getProductColour" resultType="java.util.Map">
  585. select colour.colour_id as "colourId",
  586. colour.colour_code as "colourCode",
  587. colour.colour_name as "colourName",
  588. colour.display_no as "displayNo",
  589. colour.remarks as "remarks"
  590. from mst.t_product_colour as colour
  591. where colour.flg_valid
  592. and colour.fty_id = #{ftyId}
  593. order by colour.display_no
  594. </select>
  595. <!-- 查询产品ERP物料 -->
  596. <select id="getProductErpSku" resultType="java.util.Map">
  597. select sku_id as "skuId",
  598. sku_code as "skuCode",
  599. sku_name as "skuName",
  600. remarks as "remarks"
  601. from mst.t_erp_sku
  602. where flg_valid
  603. and fty_id = #{ftyId}
  604. order by sku_code
  605. </select>
  606. <!-- 获取模具档案 -->
  607. <select id="getMould" resultType="java.util.Map">
  608. select
  609. tm.unique_id as "uniqueId",
  610. tm.unique_code as "uniqueCode",
  611. tm.output_qty as "outputQty",
  612. tmo.output_std_num as "outputStdNum",
  613. tmo.output_molded_num as "outputMoldedNum",
  614. (
  615. select json_agg(json_build_object('modelId', tmp.model_id, 'modelCode', tmp.model_code, 'modelName',
  616. tmp.model_name))
  617. from mst.t_mould_output tmo2
  618. left join mst.t_model_product tmp on tmo2.pdt_model_id = tmp.model_id
  619. where tm.unique_id = tmo2.mould_id
  620. ) as "model"
  621. from mst.t_mould tm
  622. left join mst.t_mould_output tmo on tm.unique_id = tmo.mould_id and tmo.output_no = 1
  623. where tm.fty_id = #{ftyId}
  624. and tm.flg_valid and tm.flg_barcode
  625. <if test="uniqueCode != null and uniqueCode != ''">
  626. And position (#{uniqueCode} in tm.unique_code) > 0
  627. </if>
  628. <if test="mouldKind != null and mouldKind != ''">
  629. And tm.mould_kind = #{mouldKind}
  630. </if>
  631. ORDER BY tm.unique_code
  632. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  633. limit #{end} offset #{start}
  634. </if>
  635. </select>
  636. <select id="countMould" resultType="Long">
  637. select count(1)
  638. from mst.t_mould tm
  639. left join mst.t_mould_output tmo on tm.unique_id = tmo.mould_id and tmo.output_no = 1
  640. where tm.fty_id = #{ftyId}
  641. and tm.flg_valid and tm.flg_barcode
  642. <if test="uniqueCode != null and uniqueCode != ''">
  643. And position (#{uniqueCode} in unique_code)>0
  644. </if>
  645. <if test="mouldKind != null and mouldKind != ''">
  646. And tm.mould_kind = #{mouldKind}
  647. </if>
  648. </select>
  649. <!-- 获取数据字典 -->
  650. <select id="getDictionaryData" resultType="java.util.Map">
  651. select dd.data_id as "dataId",
  652. dd.dict_code as "dictCode",
  653. dd.data_code as "dataCode",
  654. dd.data_value as "dataValue",
  655. dd.flg_default as "flgDefault"
  656. from dkic_b.t_mst_dictionary_data as dd
  657. where dd.flg_valid
  658. and dd.cp_id = #{cpId}
  659. and dd.dict_code = #{dictCode}
  660. order by dd.display_no
  661. </select>
  662. <!-- 获取数据类型 -->
  663. <select id="getValueKind" resultType="java.util.Map">
  664. select tvk.kind_code AS "kindCode",
  665. tvk.kind_name as "kindName",
  666. sys.f_get_name_i18n_lang(tvk.kind_name_i18n,#{i18n}) AS "kindLabel"
  667. from sys.t_value_kind as tvk
  668. where tvk.flg_valid
  669. <if test="used != null and used != ''">
  670. and #{used} = ANY (tvk.used)
  671. </if>
  672. order by tvk.display_no
  673. </select>
  674. <!-- 获取最大窑车序号 -->
  675. <select id="getMaxCarNo" resultType="Integer">
  676. select max(car_no)
  677. from ${table}
  678. <where>
  679. <if test="ftyId != null">
  680. AND fty_id = #{ftyId}
  681. </if>
  682. <if test="kilnId != null">
  683. AND kiln_id = #{kilnId}
  684. </if>
  685. </where>
  686. </select>
  687. <!-- 获取模具型号t_model_mould -->
  688. <select id="getModelMouldByPage" resultType="java.util.Map">
  689. select tmm.model_id AS "modelId",
  690. tmm.model_code AS "modelCode",
  691. tmm.model_name AS "modelName",
  692. sys.f_code_name(tmm.model_code, tmm.model_name) AS "mouldCodeName",
  693. tmm.std_num AS "stdNum",
  694. tmm.output_qty AS "outputQty",
  695. tmm.output_std_sum AS "outputStdSum",
  696. tmc.category_name AS "modelCategoryName",
  697. tmm.remarks
  698. from mst.t_model_mould AS tmm
  699. left join mst.t_model_category AS tmc
  700. on tmm.model_category = tmc.category_id
  701. where tmm.fty_id = #{ftyId}
  702. and tmm.flg_valid
  703. <if test="modelCode != null and modelCode != ''">
  704. And position (#{modelCode} in tmm.model_code)>0
  705. </if>
  706. <if test="modelName != null and modelName != ''">
  707. And position (#{modelName} in tmm.model_name)>0
  708. </if>
  709. order by tmm.model_code
  710. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  711. limit #{end} offset #{start}
  712. </if>
  713. </select>
  714. <!-- 获取产品位置 -->
  715. <select id="getProductPlace" resultType="java.util.Map">
  716. select place_id as "placeId", place_code as "placeCode", place_name as "placeName"
  717. from mst.t_product_place
  718. where fty_id = #{ftyId}
  719. and flg_valid
  720. <if test="placeCode != null and placeCode != ''">
  721. And position (#{placeCode} in place_code)>0
  722. </if>
  723. ORDER BY place_code
  724. </select>
  725. <!-- 查询表t_model_mould,(条件查询)个数 -->
  726. <select id="getModelMouldCountByPage" resultType="Long">
  727. SELECT
  728. count(1)
  729. from mst.t_model_mould AS tmm
  730. left join mst.t_model_category AS tmc
  731. on tmm.model_category = tmc.category_id
  732. where tmm.fty_id = #{ftyId}
  733. and tmm.flg_valid
  734. <if test="modelCode != null and modelCode != ''">
  735. And position (#{modelCode} in tmm.model_code)>0
  736. </if>
  737. <if test="modelName != null and modelName != ''">
  738. And position (#{modelName} in tmm.model_name)>0
  739. </if>
  740. </select>
  741. <!-- 获取获取载具型号 -->
  742. <select id="getModelCarrier" resultType="java.util.Map">
  743. select tmc.model_id AS "modelId",
  744. tmc.model_code as "modelCode",
  745. tmc.model_name AS "modelName"
  746. from mst.t_model_carrier as tmc
  747. where tmc.flg_valid
  748. and tmc.fty_id = #{ftyId}
  749. <if test="flgBarcode != null">
  750. and tmc.flg_barcode = #{flgBarcode}
  751. </if>
  752. <if test="modelKind != null">
  753. and tmc.model_kind = #{modelKind}
  754. </if>
  755. <if test="modelCode != null and modelCode != ''">
  756. And position (#{modelCode} in tmc.model_code)>0
  757. </if>
  758. <if test="modelName != null and modelName != ''">
  759. And position (#{modelName} in tmc.model_name)>0
  760. </if>
  761. </select>
  762. <!-- 获取获取载具型号 -->
  763. <select id="getModelEquipment" resultType="java.util.Map">
  764. select tme.model_id AS "modelId",
  765. tme.model_code as "modelCode",
  766. tme.model_name AS "modelName"
  767. from mst.t_model_equipment as tme
  768. where tme.flg_valid
  769. and tme.fty_id = #{ftyId}
  770. </select>
  771. <!-- 获取产品型号 -->
  772. <select id="getModelProduct" resultType="java.util.Map">
  773. select mp.model_id as "modelId", mp.model_code as "modelCode", mp.model_name as "modelName"
  774. ,mp.model_name as "repPdtModelName",mc.category_name as "categoryName",mc.level_name as "levelName",
  775. sys.f_code_name(mp.model_code,mp.model_name) AS "codeName",
  776. mp.model_category as "categoryId",
  777. mp.remarks, mp.unit_id as "unitId"
  778. from mst.t_model_product AS mp
  779. left join mst.t_model_category AS mc
  780. on mp.model_category = mc.category_id
  781. where mp.fty_id = #{ftyId}
  782. and mp.flg_valid
  783. <if test="modelCode != null and modelCode != '' and pdaFlag != 1">
  784. And position (#{modelCode} in mp.model_code)>0
  785. </if>
  786. <if test="modelCode != null and pdaFlag == 1">
  787. And mp.model_code = #{modelCode}
  788. </if>
  789. <if test="modelName != null and modelName != ''">
  790. And position (#{modelName} in mp.model_name)>0
  791. </if>
  792. <if test="idList != null and idList != ''">
  793. And mp.model_id = ANY(#{idList,typeHandler=BigIntListTypeHandler})
  794. </if>
  795. <if test="modelCategoryName != null and modelCategoryName != ''">
  796. And position (#{modelCategoryName} in mc.category_name)>0
  797. </if>
  798. <if test="modelCategoryId != null and modelCategoryId != ''">
  799. And mp.model_category = #{modelCategoryId}
  800. </if>
  801. ORDER BY mp.model_code
  802. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  803. limit #{end} offset #{start}
  804. </if>
  805. </select>
  806. <select id="countModelProduct" resultType="Long">
  807. select count(1)
  808. from mst.t_model_product AS mp
  809. left join mst.t_model_category AS mc
  810. on mp.model_category = mc.category_id
  811. where mp.fty_id = #{ftyId}
  812. and mp.flg_valid
  813. <if test="modelCode != null and modelCode != '' and pdaFlag != 1">
  814. And position (#{modelCode} in mp.model_code)>0
  815. </if>
  816. <if test="modelCode != null and pdaFlag == 1">
  817. And mp.model_code = #{modelCode}
  818. </if>
  819. <if test="modelName != null and modelName != ''">
  820. And position (#{modelName} in mp.model_name)>0
  821. </if>
  822. <if test="modelCategoryName != null and modelCategoryName != ''">
  823. And position (#{modelCategoryName} in mc.category_name)>0
  824. </if>
  825. <if test="modelCategoryId != null and modelCategoryId != ''">
  826. And mp.model_category = #{modelCategoryId}
  827. </if>
  828. </select>
  829. <!-- 根据模具型号id 查询模具产出型号和可变更产品型号 -->
  830. <select id="getMouldOutputById" resultType="java.util.Map">
  831. select mouldOutPut.mould_model_id as "mouldModelId",
  832. mouldOutPut.output_no as "outputNo",
  833. mouldOutPut.pdt_model_id as "pdtModelId",
  834. mouldOutPut.rep_pdt_model_ids as "repPdtModelIds",
  835. mouldOutPut.output_qty as "outputQty",
  836. mouldOutPut.remarks as "remarks",
  837. (select json_agg(t.*)
  838. from (select modelpdt.model_id as "modelId",
  839. modelpdt.model_code as "modelCode",
  840. modelpdt.model_name as "modelName",
  841. modelpdt.model_name as "repPdtModelName",
  842. '[' || modelpdt.model_code || ']' || modelpdt.model_name AS "codeName",
  843. modelpdt.remarks as "remarks"
  844. from mst.t_model_product as modelpdt
  845. where modelpdt.model_id = any (mouldOutPut.rep_pdt_model_ids)
  846. and modelpdt.flg_valid) t ) as "modelProductList",
  847. model.model_name as "pdtModelId_Name"
  848. from mst.t_model_mould_output as mouldOutPut
  849. left join mst.t_model_product as model
  850. on model.model_id = mouldOutPut.pdt_model_id
  851. where mouldoutPut.flg_valid
  852. and mouldoutPut.fty_id = #{ftyId}
  853. <if test="mouldModelId != null and mouldModelId != ''">
  854. And mouldoutPut.mould_model_id=#{mouldModelId}
  855. </if>
  856. <if test="outputNo != null and outputNo != ''">
  857. And mouldoutPut.output_no=#{outputNo}
  858. </if>
  859. </select>
  860. <!-- 查询产品型号 -->
  861. <select id="getModelPdt" resultType="java.util.Map">
  862. select modelpdt.model_id as "modelId",
  863. modelpdt.model_code as "modelCode",
  864. modelpdt.model_name as "modelName",
  865. category.category_name as "modelCategoryName",
  866. '[' || modelpdt.model_code || ']' || modelpdt.model_name AS "codeName",
  867. false as "ownerFlag"
  868. from mst.t_model_product as modelpdt
  869. left join mst.t_model_category as category
  870. on modelpdt.model_category = category.category_id
  871. where modelpdt.flg_valid
  872. and modelpdt.fty_id = #{ftyId}
  873. <if test="modelCode != null and modelCode != ''">
  874. And position (#{modelCode} in modelpdt.model_code)>0
  875. </if>
  876. <if test="modelName != null and modelName != ''">
  877. And position (#{modelName} in modelpdt.model_name)>0
  878. </if>
  879. </select>
  880. <!-- 查询产品缺陷扣罚数据 -->
  881. <select id="getDefectFines" resultType="java.util.Map">
  882. select defevtFine.fine_id as "fineId",
  883. defevtFine.fine_name as "fineName",
  884. defevtFine.deduct_num as "deductNum",
  885. defevtFine.display_no as "displayNo",
  886. defevtFine.remarks as "remarks"
  887. from mst.t_product_defect_fine as defevtFine
  888. where defevtFine.flg_valid
  889. and defevtFine.fty_id = #{ftyId}
  890. order by defevtFine.display_no
  891. </select>
  892. <!-- 查询打印模板分类 -->
  893. <select id="getLabelPrintType" resultType="java.util.Map">
  894. select lpt.type_id as "typeId",
  895. lpt.type_name as "typeName",
  896. lpt.label_kind as "labelKind",
  897. lpt.display_no as "displayNo",
  898. lpt.remarks as "remarks"
  899. from mst.t_label_print_type as lpt
  900. where lpt.flg_valid
  901. and lpt.fty_id = #{ftyId}
  902. <if test="labelKind != null and labelKind != ''">
  903. And #{labelKind} = lpt.label_kind
  904. </if>
  905. order by lpt.display_no
  906. </select>
  907. <!-- 查询工位 -->
  908. <select id="getWorkStation" resultType="java.util.Map">
  909. select ws.station_id as "stationId",
  910. ws.station_code as "stationCode",
  911. ws.station_name as "stationName",
  912. ws.kiln_id as "kilnId",
  913. ws.flow_node_id as "flowNodeId"
  914. from pdm.t_work_station as ws
  915. where ws.flg_valid
  916. and ws.fty_id = #{ftyId}
  917. <if test="flowNodeId!=null and flowNodeId!=''">
  918. and ws.flow_node_id = #{flowNodeId}::uuid
  919. </if>
  920. <if test="flgPrint!=null and flgPrint!=''">
  921. and ws.flg_print = #{flgPrint}
  922. </if>
  923. <!-- 只查询检查类型 -->
  924. <if test="onlyCheck!=null and onlyCheck">
  925. and exists(select 1
  926. from pdm.t_process_node tpn
  927. left join pdm.t_process_flow tpf on tpn.flow_id = tpf.flow_id
  928. where tpn.node_id = ws.flow_node_id
  929. and (tpn.node_kind = '工艺节点-半检' or tpn.node_kind = '工艺节点-成检')
  930. and tpf.flg_valid
  931. )
  932. and (
  933. exists(select 1 from pdm.t_work_station_user where user_id = #{userId} and station_id = ws.station_id)
  934. or
  935. exists(select 1 from pdm.t_process_node_user where user_id = #{userId} and node_id = ws.flow_node_id)
  936. or
  937. (
  938. not exists(select 1 from pdm.t_work_station_user where station_id = ws.station_id)
  939. and
  940. not exists(select 1 from pdm.t_process_node_user where node_id = ws.flow_node_id)
  941. )
  942. )
  943. </if>
  944. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  945. limit #{end} offset #{start}
  946. </if>
  947. </select>
  948. <!-- 查询工位 -->
  949. <select id="countWorkStation" resultType="Long">
  950. select count(1)
  951. from pdm.t_work_station as ws
  952. where ws.flg_valid
  953. and ws.fty_id = #{ftyId}
  954. <if test="flowNodeId!=null and flowNodeId!=''">
  955. and ws.flow_node_id = #{flowNodeId}::uuid
  956. </if>
  957. <if test="flgPrint!=null and flgPrint!=''">
  958. and ws.flg_print = #{flgPrint}
  959. </if>
  960. <!-- 只查询检查类型 -->
  961. <if test="onlyCheck!=null and onlyCheck">
  962. and exists(select 1
  963. from pdm.t_process_node tpn
  964. left join pdm.t_process_flow tpf on tpn.flow_id = tpf.flow_id
  965. where tpn.node_id = ws.flow_node_id
  966. and (tpn.node_kind = '工艺节点-半检' or tpn.node_kind = '工艺节点-成检')
  967. and tpf.flg_valid
  968. )
  969. and (
  970. exists(select 1 from pdm.t_work_station_user where user_id = #{userId} and station_id = ws.station_id)
  971. or
  972. exists(select 1 from pdm.t_process_node_user where user_id = #{userId} and node_id = ws.flow_node_id)
  973. or
  974. (
  975. not exists(select 1 from pdm.t_work_station_user where station_id = ws.station_id)
  976. and
  977. not exists(select 1 from pdm.t_process_node_user where node_id = ws.flow_node_id)
  978. )
  979. )
  980. </if>
  981. </select>
  982. <resultMap id="getProcessNodeByPage" type="java.util.Map">
  983. <result column="stationList" property="stationList" typeHandler="JsonTypeHandler"/>
  984. </resultMap>
  985. <!-- 获取工艺节点-->
  986. <select id="getProcessNodeByPage" resultMap="getProcessNodeByPage">
  987. select tpn.node_id AS "nodeId",
  988. tpn.node_id AS "opnFlowNodeId",
  989. tpn.node_id AS "missFlowNodeId",
  990. tpn.node_id AS "pdtFlowNodeId",
  991. sys.f_get_name_i18n_lang(tdk2.kind_name_i18n,#{i18n}) as "userKindName",
  992. sys.f_get_name_i18n_lang(tdk.kind_name_i18n,#{i18n}) as "nodeKindName",
  993. tdk.kind_code AS "kindCode",
  994. tpn.node_name AS "nodeName",
  995. sys.f_code_name(tpf.flow_name,tpn.node_name) AS "nodeCodeName",
  996. tpf.flow_name AS "flowName",
  997. tpn.work_shop AS "workShop",
  998. tfs.space_name AS "workShopName",
  999. (
  1000. select json_agg(json_build_object('stationId', ws.station_id , 'stationName',ws.station_name))
  1001. from pdm.t_work_station as ws
  1002. where tpn.node_id = ws.flow_node_id
  1003. ) as "stationList",
  1004. tpn.remarks
  1005. from pdm.t_process_node AS tpn
  1006. left join sys.t_data_kind as tdk
  1007. on tpn.node_kind = tdk.kind_code
  1008. left join sys.t_data_kind as tdk2
  1009. on tpn.user_kind = tdk2.kind_code
  1010. left join pdm.t_process_flow AS tpf
  1011. on tpn.flow_id = tpf.flow_id
  1012. left join mst.t_factory_space AS tfs
  1013. on tpn.work_shop = tfs.space_id
  1014. where tpn.fty_id = #{ftyId}
  1015. and tpn.flg_valid
  1016. <if test="nodeName != null and nodeName != ''">
  1017. And position (#{nodeName} in tpn.node_name)>0
  1018. </if>
  1019. <if test="flowKind != null and flowKind != ''">
  1020. And tpn.flow_kind = #{flowKind}
  1021. </if>
  1022. <if test="nodeKind != null and nodeKind != ''">
  1023. And tpn.node_kind = #{nodeKind}
  1024. </if>
  1025. ORDER BY tpf.display_no, tpf.flow_name,tpn.display_no
  1026. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  1027. limit #{end} offset #{start}
  1028. </if>
  1029. </select>
  1030. <!-- 获取成型线分组 -->
  1031. <select id="getMoldlineGroup" resultType="java.util.Map">
  1032. select tmg.group_id as "groupId", tmg.moldline_id as "moldlineId", tmg.group_no as "groupNo"
  1033. , tmg.group_name as "groupName", tm.unique_code as "moldlineCode", tm.moldline_name as "moldlineName",
  1034. '[' || tm.unique_code || '] ' || tm.moldline_name AS "moldlineCodeName",
  1035. tmg.remarks as "remarks",tm.pdt_glue_kind as "pdtGlueKind"
  1036. from mst.t_moldline_group tmg
  1037. left join mst.t_moldline tm
  1038. on tmg.moldline_id = tm.unique_id
  1039. where tmg.fty_id = #{ftyId}
  1040. and tmg.flg_valid
  1041. and tm.flg_valid
  1042. and tm.moldline_kind = '成线状态-在产'
  1043. <if test="groupName != null and groupName != ''">
  1044. And position (#{groupName} in tmg.group_name)>0
  1045. </if>
  1046. <if test="moldlineCode != null and moldlineCode != ''">
  1047. And position (#{moldlineCode} in tm.unique_code)>0
  1048. </if>
  1049. <if test="moldlineName != null and moldlineName != ''">
  1050. And position (#{moldlineName} in tm.moldline_name)>0
  1051. </if>
  1052. <if test="groupNo != null and groupNo != ''">
  1053. And tmg.group_no = #{groupNo}::Integer
  1054. </if>
  1055. ORDER BY tm.unique_code, tmg.group_no
  1056. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  1057. limit #{end} offset #{start}
  1058. </if>
  1059. </select>
  1060. <select id="countMoldlineGroup" resultType="Long">
  1061. select count(1)
  1062. from mst.t_moldline_group tmg
  1063. left join mst.t_moldline tm
  1064. on tmg.moldline_id = tm.unique_id and tm.flg_valid
  1065. where tmg.fty_id = #{ftyId}
  1066. and tmg.flg_valid
  1067. <if test="groupName != null and groupName != ''">
  1068. And position (#{groupName} in tmg.group_name)>0
  1069. </if>
  1070. <if test="moldlineCode != null and moldlineCode != ''">
  1071. And position (#{moldlineCode} in tm.unique_code)>0
  1072. </if>
  1073. <if test="moldlineName != null and moldlineName != ''">
  1074. And position (#{moldlineName} in tm.moldline_name)>0
  1075. </if>
  1076. <if test="groupNo != null and groupNo != ''">
  1077. And tmg.group_no = #{groupNo}::Integer
  1078. </if>
  1079. </select>
  1080. <!-- 查询表t_process_node,(条件查询)个数 -->
  1081. <select id="getProcessNodeCountByPage" resultType="Long">
  1082. SELECT
  1083. count(1)
  1084. from pdm.t_process_node AS tpn
  1085. left join sys.t_data_kind as tdk
  1086. on tpn.node_kind = tdk.kind_code
  1087. where tpn.fty_id = #{ftyId}
  1088. and tpn.flg_valid
  1089. <if test="nodeName != null and nodeName != ''">
  1090. And position (#{nodeName} in tpn.node_name)>0
  1091. </if>
  1092. <if test="flowKind != null and flowKind != ''">
  1093. And tpn.flow_kind = #{flowKind}
  1094. </if>
  1095. <if test="nodeKind != null and nodeKind != ''">
  1096. And tpn.node_kind = #{nodeKind}
  1097. </if>
  1098. </select>
  1099. <!-- 查询工位 -->
  1100. <select id="getWorkStationUser" resultType="java.util.Map">
  1101. select tu.user_id as "userId",
  1102. tu.user_code as "userCode",
  1103. tu.user_name as "userName",
  1104. twsu.station_id as "stationId",
  1105. tws.station_code as "stationCode",
  1106. tws.station_name as "stationName"
  1107. from core.t_user as tu
  1108. left join pdm.t_work_station_user twsu
  1109. on twsu.user_id = tu.user_id
  1110. and twsu.flg_valid
  1111. left join pdm.t_work_station tws
  1112. on twsu.station_id = tws.station_id
  1113. where tu.flg_valid
  1114. and tu.fty_id = #{ftyId}
  1115. and tu.user_type = 2
  1116. and twsu.user_kind = '节点工号-操作'
  1117. <if test="userCode != null and userCode != ''">
  1118. And position (#{userCode} in tu.user_code)>0
  1119. </if>
  1120. <if test="userName != null and userName != ''">
  1121. And position (#{userName} in tu.user_name)>0
  1122. </if>
  1123. <if test="stationId != null and stationId != ''">
  1124. And #{stationId} = tws.station_id
  1125. </if>
  1126. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  1127. limit #{end} offset #{start}
  1128. </if>
  1129. </select>
  1130. <!-- 查询产品信息数量(条码变更)-->
  1131. <select id="getWorkStationUserCount" resultType="Long">
  1132. select count(1)
  1133. from core.t_user as tu
  1134. left join pdm.t_work_station_user twsu
  1135. on twsu.user_id = tu.user_id
  1136. and twsu.flg_valid
  1137. left join pdm.t_work_station tws
  1138. on twsu.station_id = tws.station_id
  1139. where tu.flg_valid
  1140. and tu.fty_id = #{ftyId}
  1141. and tu.user_type = 2
  1142. and twsu.user_kind = '节点工号-操作'
  1143. <if test="userCode != null and userCode != ''">
  1144. And position (#{userCode} in tu.user_code)>0
  1145. </if>
  1146. <if test="userName != null and userName != ''">
  1147. And position (#{userName} in tu.user_name)>0
  1148. </if>
  1149. <if test="stationId != null and stationId != ''">
  1150. And #{stationId} = wsu.station_id
  1151. </if>
  1152. </select>
  1153. <resultMap id="getProductDefectMap" type="java.util.Map">
  1154. <result column="defectFines" property="defectFines" typeHandler="JsonTypeHandler"/>
  1155. </resultMap>
  1156. <!-- 查询损坯原因/产品缺陷/开模损原因-->
  1157. <select id="getProductDefect" resultMap="getProductDefectMap">
  1158. select tpd.defect_id AS "defectId",
  1159. tpd.defect_name AS "defectName",
  1160. tpd.defect_code AS "defectCode",
  1161. sys.f_code_name(tpd.defect_code, tpd.defect_name) AS "codeName",
  1162. tpd.defect_types as "defectTypes",
  1163. (
  1164. select json_agg(jsonb_build_object('fineId', fine_id, 'fineName', fine_name,
  1165. 'deductNum', deduct_num, 'fineCodeName',
  1166. sys.f_code_name(fine_code, fine_name)))
  1167. from mst.t_product_defect_fine
  1168. where fine_id = any (tpd.defect_fines)
  1169. ) as "defectFines"
  1170. from mst.t_product_defect tpd
  1171. where tpd.fty_id = #{ftyId}
  1172. and tpd.flg_valid
  1173. and tpd.defect_kind = #{defectKind}
  1174. </select>
  1175. <!-- 根据成型线Id查询成型记录明细 -->
  1176. <select id="getMoldingItemByMoldlineId" resultType="java.util.Map">
  1177. select tmi.item_id AS "itemId",
  1178. tmi.molding_id AS "moldingId",
  1179. tmi.moldline_id AS "moldlineId",
  1180. tmi.moldline_group_id AS "moldlineGroupId",
  1181. tmi.moldline_group_no AS "moldlineGroupNo",
  1182. tmi.molding_date AS "moldingDate",
  1183. tmi.molding_batch AS "moldingBatch",
  1184. tmi.moldline_item_id AS "moldlineItemId",
  1185. tmi.moldline_item_no AS "moldlineItemNo",
  1186. tmi.moldline_item_code AS "moldlineItemCode",
  1187. tmi.moldline_item_kind AS "moldlineItemKind",
  1188. tmi.mould_id AS "mouldId",
  1189. tmi.output_no AS "outputNo",
  1190. tmi.mould_pdt_tags AS "mouldPdtTags",
  1191. tmi.flow_node_id AS "flowNodeId",
  1192. tmi.station_id AS "stationId",
  1193. tmi.molding_user AS "moldingUser",
  1194. tmi.user_clock_id AS "userClockId",
  1195. tmi.pdt_model_id AS "pdtModelId",
  1196. tmi.pdt_logo_id AS "pdtLogoId",
  1197. tmi.pdt_colour_id AS "pdtColourId",
  1198. tmi.erp_model_code AS "erpModelCode",
  1199. tmi.this_molded_num AS "thisMoldedNum",
  1200. tmi.flg_molding AS "flgMolding",
  1201. tmi.unmolded_reason_id AS "unmoldedReasonId",
  1202. tmi.flg_scrap AS "flgScrap",
  1203. tmi.scrap_date AS "scrapDate",
  1204. tmi.scrap_reason_id AS "scrapReasonId",
  1205. tpd.defect_name AS "scrapReasonName",
  1206. tmi.flg_bind_unique AS "flgBindUnique",
  1207. tmi.pdt_unique_id AS "pdtUniqueId",
  1208. tmi.remarks,
  1209. tmp.model_name AS "pdtModelName",
  1210. tpl.logo_name AS "pdtLogoName",
  1211. tpc.colour_name AS "pdtColourName",
  1212. tdd.data_value AS "unmoldedReasonName",
  1213. tm.moldline_name AS "moldlineName",
  1214. tmp.model_code AS "pdtModelCode",
  1215. tmp.model_name AS "pdtModelName",
  1216. tpl.logo_name AS "pdtLogoName",
  1217. tpc.colour_name AS "pdtColourName",
  1218. tdd.data_value AS "unmoldedReasonName",
  1219. tm.moldline_name AS "moldlineName",
  1220. tm.unique_code AS "moldlineCode",
  1221. sys.f_get_name_i18n_lang(tdk.kind_name_i18n,#{i18n}) AS "moldlineItemKindName",
  1222. tws.station_name AS "stationName",
  1223. tu.user_name AS "moldingUserName",
  1224. '[' || tu.user_code || '] ' || tu.user_name AS "moldingUserCodeName",
  1225. mtu.user_name AS "manageUserName",
  1226. tp.unique_code as "productCode"
  1227. from pdm.t_molding_item tmi
  1228. left join pdm.t_molding as molding
  1229. on molding.molding_id = tmi.molding_id
  1230. left join core.t_user mtu
  1231. on molding.manage_user = mtu.user_id
  1232. left join mst.t_model_product tmp
  1233. on tmi.pdt_model_id = tmp.model_id
  1234. left join mst.t_product_logo tpl
  1235. on tmi.pdt_logo_id = tpl.logo_id
  1236. left join mst.t_product_colour tpc
  1237. on tmi.pdt_colour_id = tpc.colour_id
  1238. left join core.t_dictionary_data tdd
  1239. on tmi.unmolded_reason_id = tdd.data_id
  1240. left join mst.t_product_defect tpd
  1241. on tmi.scrap_reason_id = tpd.defect_id
  1242. left join pdm.t_product tp
  1243. on tmi.pdt_unique_id = tp.unique_id
  1244. left join mst.t_moldline tm
  1245. on tmi.moldline_id = tm.unique_id
  1246. left join mst.t_moldline_item tmli
  1247. on tmi.moldline_item_id = tmli.item_id
  1248. left join sys.t_data_kind tdk
  1249. on tmi.moldline_item_kind = tdk.kind_code
  1250. left join mst.t_mould mould
  1251. on tmi.mould_id = mould.unique_id
  1252. left join pdm.t_work_station tws
  1253. on tmi.station_id = tws.station_id
  1254. left join core.t_user tu
  1255. on tmi.molding_user = tu.user_id
  1256. left join pdm.t_ws_clock twc
  1257. on tmi.user_clock_id = twc.clock_id
  1258. where tmi.flg_valid
  1259. <if test="moldlineId != null and moldlineId != ''">
  1260. and tmi.moldline_id = #{moldlineId}
  1261. </if>
  1262. <if test="moldingId != null and moldingId != ''">
  1263. and tmi.molding_id = #{moldingId}
  1264. </if>
  1265. <if test="moldingGroupId != null and moldingGroupId != ''">
  1266. and tmi.moldline_group_id = #{moldingGroupId}
  1267. </if>
  1268. <if test="moldingDate != null and moldingDate != ''">
  1269. and tmi.molding_date = CAST( #{moldingDate} as date)
  1270. </if>
  1271. <if test="moldingBatch != null and moldingBatch != ''">
  1272. and tmi.molding_batch = #{moldingBatch}
  1273. </if>
  1274. </select>
  1275. <!-- 查询产品信息(条码变更)-->
  1276. <select id="getProductForChange" resultType="java.util.Map">
  1277. select
  1278. pdtCode.pdt_unique_id as "pdtUniqueId",--产品唯一码
  1279. pdtCode.pdt_code_kind as "pdtCodeKind", --条码类型
  1280. product.model_id as "modelId", --型号Id
  1281. product.pdt_flow_node_id as "nodeId", --节点Id
  1282. pdtCode.pdt_barcode as "pdtBarcode", --产品条码
  1283. (select string_agg(pdtCodeHis.pdt_barcode, ' | ')
  1284. from pdm.t_product_code_his as pdtCodeHis
  1285. where pdtCodeHis.pdt_unique_id = product.unique_id)
  1286. as "hisPdtCodes", --历史条码
  1287. mLine.unique_code as "moldLineCode",--成型线编码
  1288. mLine.moldline_name as "moldLineName", --成型线名称
  1289. mItem.molding_date as "moldingDate",--成型日期
  1290. mItem.molding_batch as "moldingBatch",--注浆批次
  1291. mu.user_code as "moldingUser",--成型工号
  1292. sys.f_code_name(mu.user_code,mu.user_name) AS "moldingUserCodeName",--成型工号
  1293. mItem.molding_user as "moldingUserID",
  1294. sys.f_code_name(mp.model_code,mp.model_name) AS "productUniqueCode",--产品编码名称
  1295. mp.model_code AS "productCode",--产品编码
  1296. mItem.moldline_item_code as "mouldUniqueCode", --模具编号
  1297. sys.f_get_name_i18n_lang(dataKind.kind_name_i18n,#{i18n}) as "mouldKind",--模具状态
  1298. mItem.this_molded_num as "moldedNum", --成型次数
  1299. manageUser.user_name as "manageUserName", --成型班长
  1300. sys.f_code_name(manageUser.user_code,manageUser.user_name) AS "manageUserCodeName",--成型班长
  1301. to_char(product.render_m_time,'yyyy-MM-dd hh24:mi:ss') as "renderMTime", --交坯时间
  1302. node.node_name as "nodeName",--工序名称
  1303. to_char(product.finish_time,'yyyy-MM-dd hh24:mi:ss') as "finishTime" -- 完成时间
  1304. from pdm.t_product as product
  1305. inner join pdm.t_product_code as pdtCode
  1306. on product.unique_id = pdtCode.pdt_unique_id
  1307. left join pdm.t_molding_item as mItem
  1308. on mItem.item_id = product.molding_item_id
  1309. left join mst.t_moldline as mLine
  1310. on mItem.moldline_id = mLine.unique_id
  1311. left join core.t_user as mu
  1312. on mu.user_id = mItem.molding_user
  1313. left join mst.t_mould as mould
  1314. on mItem.mould_id = mould.unique_id
  1315. left join sys.t_data_kind as dataKind
  1316. on mould.mould_kind = dataKind.kind_code
  1317. left join pdm.t_molding as molding
  1318. on molding.molding_id = mItem.molding_id
  1319. left join core.t_user as manageUser
  1320. on molding.manage_user = manageUser.user_id
  1321. left join pdm.t_process_node as node
  1322. on product.pdt_flow_node_id = node.node_id
  1323. inner join mst.t_model_product as mp
  1324. on product.model_id = mp.model_id
  1325. where product.fty_id = #{ftyId}
  1326. and product.flg_valid
  1327. <!--条码值等查询-->
  1328. <if test="nodeName != null and nodeName != ''">
  1329. and position(#{nodeName} in node.node_name )>0
  1330. </if>
  1331. <if test="pdtBarcodeEqual != null and pdtBarcodeEqual != ''">
  1332. and #{pdtBarcodeEqual} = pdtCode.pdt_barcode
  1333. </if>
  1334. <if test="productUniqueCodeEqual != null and productUniqueCodeEqual != ''">
  1335. and #{productUniqueCodeEqual} = mp.model_code
  1336. </if>
  1337. <if test="moldingUserEqual != null and moldingUserEqual != ''">
  1338. and #{moldingUserEqual} = mu.user_code
  1339. </if>
  1340. <if test="moldLineCode != null and moldLineCode != '' and pdaFlag != 1">
  1341. and position (#{moldLineCode} in mLine.unique_code)>0
  1342. </if>
  1343. <if test="moldLineCode != null and pdaFlag == 1">
  1344. and mLine.unique_code = #{moldLineCode}
  1345. </if>
  1346. <if test="moldLineName != null and moldLineName != ''">
  1347. and position (#{moldLineName} in mLine.moldline_name)>0
  1348. </if>
  1349. <if test="mouldUniqueCode != null and mouldUniqueCode != ''">
  1350. and position(#{mouldUniqueCode} in mould.unique_code )>0
  1351. </if>
  1352. <if test="productUniqueCode != null and productUniqueCode != '' and pdaFlag != 1">
  1353. and position(#{productUniqueCode} in product.unique_code)>0
  1354. </if>
  1355. <if test="productUniqueCode != null and pdaFlag == 1">
  1356. and product.unique_code = #{productUniqueCode}
  1357. </if>
  1358. <if test="moldingUser != null and moldingUser != ''">
  1359. and position(#{moldingUser} in mu.user_code ) >0
  1360. </if>
  1361. <if test="pdtBarcode != null and pdaFlag == 1">
  1362. and pdtCode.pdt_barcode = #{pdtBarcode}
  1363. </if>
  1364. <if test="pdtBarcode != null and pdtBarcode != ''">
  1365. and position(#{pdtBarcode} in pdtCode.pdt_barcode)>0
  1366. </if>
  1367. <if test="renderMTimeStart != null and renderMTimeStart != ''">
  1368. and product.render_m_time >=#{renderMTimeStart}
  1369. </if>
  1370. <if test="renderMTimeEnd != null and renderMTimeEnd != ''">
  1371. and product.render_m_time &lt;=#{renderMTimeEnd}
  1372. </if>
  1373. <if test="moldingDateStart != null and moldingDateStart != ''">
  1374. and mItem.molding_date >=#{moldingDateStart}
  1375. </if>
  1376. <if test="moldingDateEnd != null and moldingDateEnd != ''">
  1377. and mItem.molding_date &lt;= #{moldingDateEnd}
  1378. </if>
  1379. <if test="moldingLastDate != null and moldingLastDate != ''">
  1380. and mItem.molding_date = CAST( #{moldingLastDate} as date)
  1381. </if>
  1382. <if test="moldingBatch != null and moldingBatch != ''">
  1383. and mItem.molding_batch = #{moldingBatch}
  1384. </if>
  1385. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  1386. limit #{end} offset #{start}
  1387. </if>
  1388. </select>
  1389. <!-- 查询产品信息数量(条码变更)-->
  1390. <select id="getProductForChangeCount" resultType="Long">
  1391. select count(1)
  1392. from pdm.t_product as product
  1393. inner join pdm.t_product_code as pdtCode
  1394. on product.unique_id = pdtCode.pdt_unique_id
  1395. left join pdm.t_molding_item as mItem
  1396. on mItem.item_id = product.molding_item_id
  1397. left join mst.t_moldline as mLine
  1398. on mItem.moldline_id = mLine.unique_id
  1399. left join core.t_user as mu
  1400. on mu.user_id = mItem.molding_user
  1401. left join mst.t_mould as mould
  1402. on mItem.mould_id = mould.unique_id
  1403. left join sys.t_data_kind as dataKind
  1404. on mould.mould_kind = dataKind.kind_code
  1405. left join pdm.t_molding as molding
  1406. on molding.molding_id = mItem.molding_id
  1407. left join core.t_user as manageUser
  1408. on molding.manage_user = manageUser.user_id
  1409. left join pdm.t_process_node as node
  1410. on product.pdt_flow_node_id = node.node_id
  1411. where product.fty_id = #{ftyId}
  1412. and product.flg_valid
  1413. <if test="moldLineCode != null and moldLineCode != ''">
  1414. and position (#{moldLineCode} in mLine.unique_code)>0
  1415. </if>
  1416. <if test="moldLineName != null and moldLineName != ''">
  1417. and position (#{moldLineName} in mLine.moldline_name)>0
  1418. </if>
  1419. <if test="mouldUniqueCode != null and mouldUniqueCode != ''">
  1420. and position(#{mouldUniqueCode} in mould.unique_code )>0
  1421. </if>
  1422. <if test="productUniqueCode != null and productUniqueCode != ''">
  1423. and position(#{productUniqueCode} in product.unique_code)>0
  1424. </if>
  1425. <if test="moldingUser != null and moldingUser != ''">
  1426. and position(#{moldingUser} in mu.user_code ) >0
  1427. </if>
  1428. <if test="pdtBarcode != null and pdtBarcode != ''">
  1429. and position(#{pdtBarcode} in pdtCode.pdt_barcode)>0
  1430. </if>
  1431. <if test="renderMTimeStart != null and renderMTimeStart != ''">
  1432. and product.render_m_time >=#{renderMTimeStart}
  1433. </if>
  1434. <if test="renderMTimeEnd != null and renderMTimeEnd != ''">
  1435. and product.render_m_time &lt;=#{renderMTimeEnd}
  1436. </if>
  1437. <if test="moldingDateStart != null and moldingDateStart != ''">
  1438. and mItem.molding_date >=#{moldingDateStart}
  1439. </if>
  1440. <if test="moldingDateEnd != null and moldingDateEnd != ''">
  1441. and mItem.molding_date &lt;= #{moldingDateEnd}
  1442. </if>
  1443. </select>
  1444. <!-- 查询产品釉色(釉色设定)-->
  1445. <select id="getColourForSet" resultType="java.util.Map">
  1446. select
  1447. moldingItem.item_id as "itemId",
  1448. productCode.pdt_barcode as "pdtBarcode",
  1449. moldingItem.pdt_colour_id as "pdtColourId",
  1450. colour.colour_name as "colourName"
  1451. from pdm.t_product_code as productCode
  1452. inner join pdm.t_product as product
  1453. on productCode.pdt_unique_id = product.unique_id
  1454. inner join pdm.t_molding_item as moldingItem
  1455. on product.molding_item_id = moldingItem.item_id
  1456. inner join mst.t_product_colour as colour
  1457. on moldingItem.pdt_colour_id = colour.colour_id
  1458. where productCode.flg_valid
  1459. <if test="pdtBarcode != null and pdtBarcode != ''">
  1460. AND position (#{pdtBarcode} in productCode.pdt_barcode)>0
  1461. </if>
  1462. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  1463. limit #{end} offset #{start}
  1464. </if>
  1465. </select>
  1466. <!-- 查询产品釉色数量 (釉色设定)-->
  1467. <select id="getColourForSetCount" resultType="Long">
  1468. select
  1469. count(1)
  1470. from pdm.t_product_code as productCode
  1471. inner join pdm.t_product as product
  1472. on productCode.pdt_unique_id = product.unique_id
  1473. inner join pdm.t_molding_item as moldingItem
  1474. on product.molding_item_id = moldingItem.item_id
  1475. inner join mst.t_product_colour as colour
  1476. on moldingItem.pdt_colour_id = colour.colour_id
  1477. where productCode.flg_valid and productCode.fty_id = #{ftyId}
  1478. <if test="pdtBarcode != null and pdtBarcode != ''">
  1479. AND position (#{pdtBarcode} in productCode.pdt_barcode)>0
  1480. </if>
  1481. </select>
  1482. <!-- 查询产品商标(商标设定)-->
  1483. <select id="getLogoForSet" resultType="java.util.Map">
  1484. select
  1485. moldingItem.item_id as "itemId",
  1486. productCode.pdt_barcode as "pdtBarcode",
  1487. moldingItem.pdt_logo_id as "pdtLogoId",
  1488. logo.logo_name as "logoName",
  1489. moldingItem.pdt_colour_id as "pdtColourId",
  1490. colour.colour_name as "colourName",
  1491. product.unique_id as "productId"
  1492. from pdm.t_product_code as productCode
  1493. inner join pdm.t_product as product
  1494. on productCode.pdt_unique_id = product.unique_id
  1495. inner join pdm.t_molding_item as moldingItem
  1496. on product.molding_item_id = moldingItem.item_id
  1497. inner join mst.t_product_logo as logo
  1498. on moldingItem.pdt_logo_id = logo.logo_id
  1499. inner join mst.t_product_colour as colour
  1500. on moldingItem.pdt_colour_id = colour.colour_id
  1501. where productCode.flg_valid and productCode.fty_id = #{ftyId}
  1502. <if test="pdtBarcodeEqual != null and pdtBarcodeEqual != ''">
  1503. AND #{pdtBarcodeEqual} = productCode.pdt_barcode
  1504. </if>
  1505. <if test="pdtBarcode != null and pdtBarcode != ''">
  1506. AND position (#{pdtBarcode} in productCode.pdt_barcode)>0
  1507. </if>
  1508. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  1509. limit #{end} offset #{start}
  1510. </if>
  1511. </select>
  1512. <!-- 查询产品商标(商标设定)-->
  1513. <select id="getProductModel" resultType="java.util.Map">
  1514. select
  1515. moldingItem.item_id as "itemId",
  1516. productCode.pdt_barcode as "pdtBarcode",
  1517. mp.model_id as "modelId",
  1518. mp.model_name as "modelName",
  1519. '[' || mp.model_code || '] ' || mp.model_name AS "codeName",
  1520. product.unique_id as "productId"
  1521. from pdm.t_product_code as productCode
  1522. inner join pdm.t_product as product
  1523. on productCode.pdt_unique_id = product.unique_id
  1524. inner join pdm.t_molding_item as moldingItem
  1525. on product.molding_item_id = moldingItem.item_id
  1526. inner join mst.t_model_product as mp
  1527. on moldingItem.pdt_model_id = mp.model_id
  1528. where productCode.flg_valid and productCode.fty_id = #{ftyId}
  1529. <if test="pdtBarcodeEqual != null and pdtBarcodeEqual != ''">
  1530. AND #{pdtBarcodeEqual} = productCode.pdt_barcode
  1531. </if>
  1532. <if test="pdtBarcode != null and pdtBarcode != '' and pdaFlag != 1">
  1533. AND position (#{pdtBarcode} in productCode.pdt_barcode)>0
  1534. </if>
  1535. <if test="pdtBarcode != null and pdaFlag == 1">
  1536. AND productCode.pdt_barcode = #{pdtBarcode}
  1537. </if>
  1538. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  1539. limit #{end} offset #{start}
  1540. </if>
  1541. </select>
  1542. <!--根据工号编码值等查询工号-->
  1543. <select id="getUserByCode" resultType="java.util.Map">
  1544. select
  1545. ctu.user_id as "userId",
  1546. ctu.user_code as "userCode",
  1547. ctu.user_name as "userName",
  1548. twuc.clock_id as "clockId",
  1549. twuc.station_id as "stationId"
  1550. from core.t_user ctu
  1551. inner join pdm.t_ws_user_clock twuc
  1552. on twuc.user_id = ctu.user_id
  1553. where ctu.fty_id = #{ftyId}
  1554. <if test="userCode != null and userCode != ''">
  1555. and position (#{userCode} in ctu.user_code )>0
  1556. </if>
  1557. <if test="userCodeByChange != null and userCodeByChange != ''">
  1558. and #{userCodeByChange} = ctu.user_code
  1559. </if>
  1560. <if test="userType != null and userType != ''">
  1561. and #{userType} = ctu.user_type
  1562. </if>
  1563. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  1564. limit #{end} offset #{start}
  1565. </if>
  1566. </select>
  1567. <!--根据工号编码值等查询工号数量-->
  1568. <select id="getUserByCodeCount" resultType="Long">
  1569. select
  1570. count(1)
  1571. from core.t_user ctu
  1572. inner join pdm.t_ws_user_clock twuc
  1573. on twuc.user_id = ctu.user_id
  1574. <where>
  1575. <if test="userCode != null and userCode != ''">
  1576. ctu.user_code =#{userCode}
  1577. </if>
  1578. <if test="userType != null and userType != ''">
  1579. and #{userType} = ctu.user_type
  1580. </if>
  1581. </where>
  1582. </select>
  1583. <!-- 获取工艺节点-->
  1584. <select id="getProcessNode" resultType="java.util.Map">
  1585. select tpn.node_id AS "nodeId",
  1586. sys.f_get_name_i18n_lang(tdk.kind_name_i18n, #{i18n}) as "nodeKind",
  1587. tpn.node_name AS "nodeName",
  1588. tpn.remarks
  1589. from pdm.t_process_node AS tpn
  1590. left join sys.t_data_kind as tdk
  1591. on tpn.node_kind = tdk.kind_code
  1592. where tpn.fty_id = #{ftyId}
  1593. and tpn.flg_valid
  1594. </select>
  1595. <!-- 获取成型线分页-->
  1596. <select id="getMoldLinePage" resultType="java.util.Map">
  1597. select moldLine.unique_id as "moldlineId",
  1598. moldLine.unique_code as "moldLineUniqueCode",
  1599. moldLine.moldline_name as "moldlineName",
  1600. '[' || moldLine.unique_code || '] ' || moldLine.moldline_name AS "moldlineCodeName",
  1601. moldLine.moldline_item_qty as "moldlineItemQty",
  1602. (select string_agg(u.user_name, ' | ')
  1603. from core.t_user as u
  1604. where u.user_id = any (moldLine.molding_users)) as "moldingUsers",
  1605. sys.f_get_name_i18n_lang(dataKind.kind_name_i18n,#{i18n}) as "moldlineKind",
  1606. to_char(moldLine.op_create_time,'YYYY-MM-DD HH24:MI:SS')as "opCreateTime"
  1607. from mst.t_moldline as moldLine
  1608. left join sys.t_data_kind as dataKind
  1609. on moldLine.moldline_kind = dataKind.kind_code
  1610. where moldLine.flg_valid and moldLine.fty_id = #{ftyId}
  1611. <if test="pdaMoldlineCode != null ">
  1612. AND moldLine.unique_code = #{pdaMoldlineCode}
  1613. </if>
  1614. <if test="moldlineCode != null and moldlineCode != ''">
  1615. AND position (#{moldlineCode} in moldLine.unique_code)>0
  1616. </if>
  1617. <if test="moldlineName != null and moldlineName != ''">
  1618. AND position (#{moldlineName} in moldLine.moldline_name)>0
  1619. </if>
  1620. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  1621. limit #{end} offset #{start}
  1622. </if>
  1623. </select>
  1624. <!-- 获取成型线分页数量-->
  1625. <select id="getMoldLinePageCount" resultType="Long">
  1626. select count(1)
  1627. from mst.t_moldline as moldLine
  1628. left join sys.t_data_kind as dataKind
  1629. on moldLine.moldline_kind = dataKind.kind_code
  1630. where moldLine.flg_valid and moldLine.fty_id = #{ftyId}
  1631. <if test="uniqueCode != null and uniqueCode != ''">
  1632. AND position (#{uniqueCode} in moldLine.uniqueCode)>0
  1633. </if>
  1634. <if test="moldlineName != null and moldlineName != ''">
  1635. AND position (#{moldlineName} in moldLine.moldline_name)>0
  1636. </if>
  1637. <if test="moldlineName != null and moldlineName != ''">
  1638. AND position (#{moldlineName} in moldLine.moldline_name)>0
  1639. </if>
  1640. </select>
  1641. <!-- 工位工号(工位打卡选择工位)-->
  1642. <select id="getWsStation" resultType="java.util.Map">
  1643. select distinct
  1644. station.station_id as "stationId",
  1645. station.station_name as "stationName",
  1646. station.station_code as "stationCode"
  1647. from pdm.t_work_station as station
  1648. inner join pdm.t_work_station_user as wsu
  1649. on station.station_id = wsu.station_id
  1650. where station.fty_id = #{ftyId}
  1651. and station.flg_valid
  1652. and wsu.flg_valid
  1653. <if test="userId != null and userId != ''">
  1654. And #{userId} = wsu.user_id
  1655. </if>
  1656. </select>
  1657. <!-- 查询班组信息-->
  1658. <select id="getWorkTeamByUserId" resultType="java.util.Map">
  1659. select twt.team_id as "teamId",
  1660. twt.user_id as "userId",
  1661. twt.wt_job_id as "wtJobId",
  1662. twt.wt_job_id as "jobId",
  1663. tj.job_name as "jobName",
  1664. twt.staff_id as "staffId",
  1665. ts.staff_name as "staffName"
  1666. from core.t_work_team twt
  1667. inner join core.t_job tj
  1668. on twt.wt_job_id = tj.job_id
  1669. inner join core.t_staff ts on ts.staff_id = twt.staff_id
  1670. where twt.flg_valid
  1671. and twt.user_id = #{userId}
  1672. order by tj.job_name
  1673. </select>
  1674. <!-- 查询产品分级 -->
  1675. <select id="getProductGrade" resultType="java.util.Map">
  1676. select grade_id as "gradeId",
  1677. grade_code as "gradeCode",
  1678. grade_name as "gradeName",
  1679. grade_kind as "gradeKind"
  1680. from mst.t_product_grade
  1681. where flg_valid
  1682. and fty_id = #{ftyId}
  1683. <if test="gradeCode != null and gradeCode != ''">
  1684. AND position (#{gradeCode} in grade_code)>0
  1685. </if>
  1686. <if test="gradeName != null and gradeName != ''">
  1687. AND position (#{gradeName} in grade_name)>0
  1688. </if>
  1689. <if test="nodeId != null and nodeId != ''">
  1690. AND exists (
  1691. select 1 from pdm.t_process_node
  1692. where grade_id = any(judge_grade_ids)
  1693. and node_id = #{nodeId}::uuid
  1694. )
  1695. </if>
  1696. <if test="gradeKind != null and gradeKind != ''">
  1697. AND grade_kind = #{gradeKind}
  1698. </if>
  1699. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  1700. limit #{end} offset #{start}
  1701. </if>
  1702. </select>
  1703. <select id="countProductGrade" resultType="Long">
  1704. select count(1)
  1705. from mst.t_product_grade
  1706. where flg_valid
  1707. and fty_id = #{ftyId}
  1708. <if test="gradeCode != null and gradeCode != ''">
  1709. AND position (#{gradeCode} in grade_code)>0
  1710. </if>
  1711. <if test="gradeName != null and gradeName != ''">
  1712. AND position (#{gradeName} in grade_name)>0
  1713. </if>
  1714. <if test="nodeId != null and nodeId != ''">
  1715. AND exists (
  1716. select 1 from pdm.t_process_node
  1717. where grade_id = any(judge_grade_ids)
  1718. and node_id = #{nodeId}::uuid
  1719. )
  1720. </if>
  1721. <if test="gradeKind != null and gradeKind != ''">
  1722. AND grade_kind = #{gradeKind}
  1723. </if>
  1724. </select>
  1725. <!-- 查询工艺流程(放大镜分页)-->
  1726. <select id="getProcessFlow" resultType="java.util.Map">
  1727. select
  1728. tpf.flow_id as "flowId",
  1729. tpf.flow_code as "flowCode",
  1730. tpf.flow_name as "flowName"
  1731. from pdm.t_process_flow as tpf
  1732. where tpf.flg_valid
  1733. and tpf.fty_id = #{ftyId}
  1734. <if test="flowCode != null and flowCode != ''">
  1735. AND position (#{flowCode} in flow_code)>0
  1736. </if>
  1737. <if test="flowName != null and flowName != ''">
  1738. AND position (#{flowName} in flow_name)>0
  1739. </if>
  1740. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  1741. limit #{end} offset #{start}
  1742. </if>
  1743. </select>
  1744. <!-- 查询工艺流程数量-->
  1745. <select id="getProcessFlowCount" resultType="Long">
  1746. select
  1747. count(1)
  1748. from pdm.t_process_flow as tpf
  1749. where tpf.flg_valid
  1750. and tpf.fty_id = #{ftyId}
  1751. <if test="flowCode != null and flowCode != ''">
  1752. AND position (#{flowCode} in flow_code)>0
  1753. </if>
  1754. <if test="flowName != null and flowName != ''">
  1755. AND position (#{flowName} in flow_name)>0
  1756. </if>
  1757. </select>
  1758. <!-- 查询产品分类(分页)-->
  1759. <select id="getModelCategoryPage" resultType="java.util.Map">
  1760. select tmc.category_id AS "categoryId",
  1761. tmc.category_code AS "categoryCode",
  1762. tmc.category_name AS "categoryName",
  1763. tmc.level_name AS "levelName",
  1764. sys.f_get_name_i18n_lang(tdk.kind_name_i18n,#{i18n}) AS "modelKindName"
  1765. from mst.t_model_category tmc
  1766. inner join sys.t_data_kind tdk
  1767. on tdk.kind_code = tmc.model_kind
  1768. where tmc.fty_id = #{ftyId}
  1769. and tmc.flg_valid
  1770. <if test="categoryName != null and categoryName != ''">
  1771. AND position (#{categoryName} in tmc.category_name)>0
  1772. </if>
  1773. <if test="categoryCode != null and categoryCode != ''">
  1774. AND position (#{categoryCode} in tmc.category_code)>0
  1775. </if>
  1776. <if test="modelKind != null and modelKind != ''">
  1777. AND #{modelKind} = tmc.model_kind
  1778. </if>
  1779. <if test="levelNo != null and levelNo != ''">
  1780. AND tmc.level_no=#{levelNo}
  1781. </if>
  1782. <if test="levelLeaf != null and levelLeaf">
  1783. And tmc.level_leaf
  1784. </if>
  1785. order by tmc.display_no
  1786. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  1787. limit #{end} offset #{start}
  1788. </if>
  1789. </select>
  1790. <!-- 查询产品分类(数量)-->
  1791. <select id="getModelCategoryCount" resultType="Long">
  1792. select count(1)
  1793. from mst.t_model_category tmc
  1794. inner join sys.t_data_kind tdk
  1795. on tdk.kind_code = tmc.model_kind
  1796. where tmc.fty_id = #{ftyId}
  1797. and tmc.flg_valid
  1798. <if test="categoryName != null and categoryName != ''">
  1799. AND position (#{categoryName} in tmc.category_name)>0
  1800. </if>
  1801. <if test="categoryCode != null and categoryCode != ''">
  1802. AND position (#{categoryCode} in tmc.category_code)>0
  1803. </if>
  1804. <if test="modelKind != null and modelKind != ''">
  1805. AND position (#{modelKind} in tmc.model_kind)>0
  1806. </if>
  1807. <if test="levelNo != null and levelNo != ''">
  1808. AND tmc.level_no=#{levelNo}
  1809. </if>
  1810. <if test="levelLeaf != null and levelLeaf">
  1811. And tmc.level_leaf
  1812. </if>
  1813. </select>
  1814. <!-- 查询打印机-->
  1815. <select id="getLabelPrinter" resultType="java.util.Map">
  1816. select mlp.printer_id as "printerId",
  1817. mlp.printer_name as "printerName",
  1818. mlp.printer_code as "printerCode",
  1819. mlp.printer_ip as "printerIp"
  1820. from mst.t_label_printer as mlp
  1821. where mlp.flg_valid
  1822. and mlp.fty_id = #{ftyId}
  1823. </select>
  1824. <!-- 查询打印模板 -->
  1825. <select id="getLabelPrintLayout" resultType="java.util.Map">
  1826. select
  1827. lpl.layout_id as "layoutId",
  1828. lpl.layout_name as "layoutName"
  1829. from mst.t_label_print_layout as lpl
  1830. where lpl.flg_valid
  1831. and lpl.fty_id = #{ftyId}
  1832. <if test="printType != null">
  1833. and lpl.print_type = #{printType}
  1834. </if>
  1835. </select>
  1836. <select id="getTeamStaff" resultType="java.util.Map">
  1837. select ts.staff_id as "staffId", ts.staff_code as "staffCode", ts.staff_name as "staffName",
  1838. sys.f_code_name(ts.staff_code,ts.staff_name) AS "staffCodeName",
  1839. ts.job_id as "jobId", tj.job_name as "jobName"
  1840. <if test="userId!=null">
  1841. ,
  1842. (
  1843. select 1 from core.t_work_team twt2
  1844. where twt2.user_id = #{userId} and twt2.staff_id = ts.staff_id
  1845. and twt2.flg_valid and twt2.fty_id = #{ftyId}
  1846. ) is not null as "defaultFlag"
  1847. </if>
  1848. from core.t_staff ts
  1849. left join core.t_job AS tj on ts.job_id = tj.job_id
  1850. where exists(
  1851. select 1
  1852. from core.t_work_team twt
  1853. where ts.staff_id = any (twt.staff_ids)
  1854. <if test="userId!=null">
  1855. and twt.user_id = #{userId}
  1856. </if>
  1857. )
  1858. <if test="jobId!=null">
  1859. and tj.job_id = #{jobId}
  1860. </if>
  1861. and ts.flg_valid
  1862. and ts.fty_id = #{ftyId}
  1863. order by ts.staff_code
  1864. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  1865. limit #{end} offset #{start}
  1866. </if>
  1867. </select>
  1868. <select id="countTeamStaff" resultType="Long">
  1869. select count(1)
  1870. from core.t_staff ts
  1871. where exists(
  1872. select 1
  1873. from core.t_work_team twt
  1874. where ts.staff_id = any (twt.staff_ids)
  1875. <if test="userId!=null">
  1876. and user_id = #{userId}
  1877. </if>
  1878. )
  1879. and ts.flg_valid
  1880. and ts.fty_id = #{ftyId}
  1881. </select>
  1882. <!-- 获取结转账务月开始日期,结束日期 -->
  1883. <select id="selectAccountDate" resultType="String">
  1884. SELECT sys.f_get_account_date(#{accountDay}, #{month}::date)
  1885. </select>
  1886. <!-- 工位(工位打卡选择工位,工号未绑定工位时,获取工序工号绑定的工位)-->
  1887. <select id="getWsStationByNode" resultType="java.util.Map">
  1888. select distinct tws.station_id as "stationId",
  1889. tws.station_code as "stationCode",
  1890. tws.station_name as "stationName"
  1891. from pdm.t_process_node_user as tpnu
  1892. inner join pdm.t_work_station as tws
  1893. on tpnu.node_id = tws.flow_node_id
  1894. where tpnu.flg_valid
  1895. and tpnu.fty_id = #{ftyId}
  1896. and tws.flg_valid
  1897. and tws.fty_id = #{ftyId}
  1898. <if test="userId != null and userId != ''">
  1899. And #{userId} = tpnu.user_id
  1900. </if>
  1901. </select>
  1902. <!-- 工位(工位打卡选择工位,工位未绑定工序和用户)-->
  1903. <select id="getWsStationNoUser" resultType="java.util.Map">
  1904. select distinct tws.station_id as "stationId",
  1905. tws.station_code as "stationCode",
  1906. tws.station_name as "stationName"
  1907. from pdm.t_work_station as tws
  1908. where tws.flg_valid
  1909. and tws.fty_id = #{ftyId}
  1910. and not exists(select 1
  1911. from pdm.t_work_station_user as twsu
  1912. where twsu.flg_valid
  1913. and twsu.fty_id = #{ftyId}
  1914. and twsu.station_id = tws.station_id)
  1915. and not exists(select 1
  1916. from pdm.t_process_node_user as tpnu
  1917. where tpnu.flg_valid
  1918. and tpnu.fty_id = #{ftyId}
  1919. and tpnu.node_id = tws.flow_node_id)
  1920. </select>
  1921. <!-- 获取湿温度计(分页)-->
  1922. <select id="thmeterRecordByPage" resultType="java.util.Map">
  1923. select
  1924. mtt.unique_id AS "thmeterId",
  1925. mtt.thmeter_name AS "thmeterName",
  1926. mtt.unique_code AS "thmeterCode",
  1927. sys.f_get_name_i18n_lang(tdk.kind_name_i18n,#{i18n}) AS "modelKindName",
  1928. mtu.user_name AS "manageUserName"
  1929. from mst.t_thmeter mtt
  1930. inner join sys.t_data_kind tdk
  1931. on tdk.kind_code = mtt.model_kind
  1932. left join core.t_user mtu
  1933. on mtt.manage_user = mtu.user_id
  1934. where mtt.fty_id = #{ftyId}
  1935. and mtt.flg_valid
  1936. <if test="thmeterName != null and thmeterName != ''">
  1937. AND position (#{thmeterName} in mtt.thmeter_name)>0
  1938. </if>
  1939. <if test="thmeterCode != null and thmeterCode != ''">
  1940. AND position (#{thmeterCode} in mtt.unique_code)>0
  1941. </if>
  1942. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  1943. limit #{end} offset #{start}
  1944. </if>
  1945. </select>
  1946. <!-- 获取湿温度计(数量)-->
  1947. <select id="getThmeterRecordByCount" resultType="Long">
  1948. select count(1)
  1949. from mst.t_thmeter mtt
  1950. inner join sys.t_data_kind tdk
  1951. on tdk.kind_code = mtt.model_kind
  1952. left join core.t_user mtu
  1953. on mtt.manage_user = mtu.user_id
  1954. where mtt.fty_id = #{ftyId}
  1955. and mtt.flg_valid
  1956. <if test="thmeterName != null and thmeterName != ''">
  1957. AND position (#{thmeterName} in mtt.thmeter_name)>0
  1958. </if>
  1959. <if test="thmeterCode != null and thmeterCode != ''">
  1960. AND position (#{thmeterCode} in mtt.unique_code)>0
  1961. </if>
  1962. </select>
  1963. <!-- 获取湿温度计-->
  1964. <select id="getThmeterRecord" resultType="java.util.Map">
  1965. select
  1966. mtt.unique_id AS "thmeterId",
  1967. mtt.thmeter_name AS "thmeterName",
  1968. mtt.unique_code AS "thmeterCode",
  1969. sys.f_get_name_i18n_lang(tdk.kind_name_i18n,#{i18n}) AS "modelKindName",
  1970. mtu.user_name AS "manageUserName"
  1971. from mst.t_thmeter mtt
  1972. inner join sys.t_data_kind tdk
  1973. on tdk.kind_code = mtt.model_kind
  1974. left join core.t_user mtu
  1975. on mtt.manage_user = mtu.user_id
  1976. where mtt.fty_id = #{ftyId}
  1977. and mtt.flg_valid
  1978. <if test="thmeterName != null and thmeterName != ''">
  1979. AND position (#{thmeterName} in mtt.thmeter_name)>0
  1980. </if>
  1981. <if test="thmeterCode != null and thmeterCode != ''">
  1982. AND position (#{thmeterCode} in mtt.unique_code)>0
  1983. </if>
  1984. </select>
  1985. <!--查询用于隐藏列信息-->
  1986. <select id="getUserTableInfo" resultType="java.util.Map">
  1987. select tuts.code,
  1988. tuts.table_type AS "tableType",
  1989. tuts.table_ref AS "tableRef",
  1990. tuts.columns
  1991. from pset.t_user_table_set tuts
  1992. where tuts.flg_valid
  1993. and tuts.user_id = #{userId};
  1994. </select>
  1995. <!-- 查询标签打印项目 -->
  1996. <select id="getLabelPrintItem" resultType="java.util.Map">
  1997. select
  1998. item_code as "itemCode",
  1999. sys.f_get_name_i18n_lang(item_name_i18n,#{i18n}) "itemName",
  2000. item_style as "itemStyle",
  2001. item_sample as "itemSample",
  2002. data_key as "dataKey",
  2003. item_tag as "itemTag",
  2004. remarks as "remarks"
  2005. from sys.t_label_print_item
  2006. where flg_valid
  2007. <if test="labelKind">
  2008. and label_kind = #{labelKind}
  2009. </if>
  2010. order by display_no
  2011. </select>
  2012. <!--查用户功能权限-->
  2013. <select id="getUserFunction" resultType="java.util.Map">
  2014. select appm.menu_uuid AS "menuUuid"
  2015. , appm.menu_name as name
  2016. , sys.f_get_name_i18n_lang(appm.menu_name_i18n, #{i18n}) as "menuName"
  2017. , rr.fun_uuid AS "funUuid"
  2018. , appm.object_code AS "objectCode"
  2019. , appm.menu_type AS "menuType"
  2020. from sys.t_app_menu appm
  2021. inner join core.t_user_fun rr
  2022. on rr.fun_uuid = appm.fun_uuid
  2023. where appm.flg_valid
  2024. and appm.app_code = #{appCode}
  2025. and appm.menu_type IN (1, 2)
  2026. and rr.user_id = #{userId};
  2027. </select>
  2028. <!--查用户功能权限-->
  2029. <select id="getUserFunctionAdmin" resultType="java.util.Map">
  2030. select appm.menu_uuid AS "menuUuid"
  2031. , appm.menu_name as name
  2032. , sys.f_get_name_i18n_lang(appm.menu_name_i18n, #{i18n}) as "menuName"
  2033. , appm.fun_uuid AS "funUuid"
  2034. , appm.object_code AS "objectCode"
  2035. , appm.menu_type AS "menuType"
  2036. from sys.t_app_menu appm
  2037. where appm.flg_valid
  2038. and appm.app_code = #{appCode}
  2039. and appm.menu_type IN (1, 2);
  2040. </select>
  2041. <!--查导航菜单(自定义报表用)-->
  2042. <select id="getMenuNavigation" resultType="java.util.Map">
  2043. select appm.menu_uuid AS "menuUuid"
  2044. ,sys.f_get_name_i18n_lang(appm.menu_name_i18n,#{i18n}) as "menuName"
  2045. ,appm.parent_uuid AS "parentUuid"
  2046. from sys.t_app_menu appm
  2047. where appm.flg_valid
  2048. <if test="parentUuid">
  2049. and appm.parent_uuid = #{parentUuid} ::uuid
  2050. </if>
  2051. and appm.app_code = 'WEB-MAIN'
  2052. and appm.menu_type = 0
  2053. </select>
  2054. <!-- 获取员工用于报工记录查询(分页)-->
  2055. <select id="getStaffWithWorkByPage" resultType="java.util.Map">
  2056. select
  2057. twt.team_id as "teamId",
  2058. twt.user_id as "userId",
  2059. twt.wt_job_id as "jobId",
  2060. tj.job_name as "jobName",
  2061. cts.staff_id as "staffId",
  2062. cts.staff_code as "staffCode",
  2063. cts.staff_name as "staffName"
  2064. from core.t_work_team twt
  2065. inner join core.t_job tj on twt.wt_job_id = tj.job_id
  2066. left join core.t_staff cts on cts.staff_id = any (twt.staff_ids)
  2067. where twt.flg_valid and cts.flg_valid
  2068. and twt.user_id = #{userId}
  2069. <if test="jobId != null">
  2070. AND #{jobId} = twt.wt_job_id
  2071. </if>
  2072. <if test="staffCode != null and staffCode != ''">
  2073. AND position(#{staffCode} in cts.staff_code) > 0
  2074. </if>
  2075. order by twt.display_no
  2076. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  2077. limit #{end} offset #{start}
  2078. </if>
  2079. </select>
  2080. <!-- 获取员工用于报工记录查询(数量)-->
  2081. <select id="getStaffWithWorkByCount" resultType="Long">
  2082. select count(1)
  2083. from core.t_work_team twt
  2084. inner join core.t_job tj on twt.wt_job_id = tj.job_id
  2085. left join core.t_staff cts on cts.staff_id = any (twt.staff_ids)
  2086. where twt.flg_valid and cts.flg_valid
  2087. and twt.user_id = #{userId}
  2088. <if test="jobId != null">
  2089. AND #{jobId} = twt.wt_job_id
  2090. </if>
  2091. <if test="staffCode != null and staffCode != ''">
  2092. AND position(#{staffCode} in cts.staff_code) > 0
  2093. </if>
  2094. </select>
  2095. <!-- 获取数据字典项目 -->
  2096. <select id="getDictionaryItemData" resultType="java.util.Map">
  2097. SELECT stdi.dict_code AS "dictCode",
  2098. sys.f_get_name_i18n_lang(stdi.dict_name_i18n, 'zh_CN') AS "dictName"
  2099. FROM sys.t_dictionary_item stdi
  2100. WHERE stdi.flg_valid
  2101. AND stdi.level_no NOT IN ('1')
  2102. </select>
  2103. <select id="getLabelPrintTypeKind" resultType="java.util.Map">
  2104. SELECT kind_code as "kindCode", sys.f_get_name_i18n_lang(kind_name_i18n, #{i18n}) as "kindName"
  2105. FROM sys.t_data_kind t
  2106. where t.kind_type = '型号种类'
  2107. and t.kind_tags - > 'used' ?? '标签' and flg_valid
  2108. order by t.display_no
  2109. </select>
  2110. <select id="getModelProductLabelType" resultType="java.util.Map">
  2111. SELECT kind_code as "kindCode", sys.f_get_name_i18n_lang(kind_name_i18n, #{i18n}) as "kindName"
  2112. from sys.t_data_kind t
  2113. where t.kind_type = '验证标签'
  2114. and (t.kind_tags ->>'source') = '产品型号'
  2115. </select>
  2116. <!-- 获取窑炉类型 -->
  2117. <select id="getKilnType" resultType="java.util.Map">
  2118. select
  2119. model_id AS "modelId",
  2120. model_code AS "modelCode",
  2121. model_name AS "modelName"
  2122. from mst.t_model_type_kiln
  2123. where fty_id = #{ftyId}
  2124. and flg_valid
  2125. order by model_code
  2126. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  2127. limit #{end} offset #{start}
  2128. </if>
  2129. </select>
  2130. <!-- 获取成型线类型 -->
  2131. <select id="getMoldlineType" resultType="java.util.Map">
  2132. select
  2133. model_id AS "modelId",
  2134. model_code AS "modelCode",
  2135. model_name AS "modelName"
  2136. from mst.t_model_type_moldline
  2137. where fty_id = #{ftyId}
  2138. and flg_valid
  2139. order by model_code
  2140. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  2141. limit #{end} offset #{start}
  2142. </if>
  2143. </select>
  2144. <!-- 获取物料编码 -->
  2145. <select id="getModelMaterialByPage" resultType="java.util.Map">
  2146. select mtmm.model_id as "modelId",
  2147. mtmm.model_code as "modelCode",
  2148. mtmm.model_name as "modelName",
  2149. sys.f_code_name(model_code,model_name) AS "codeName",
  2150. mtmc.category_name AS "categoryName",
  2151. mtmc.category_code AS "categoryCode",
  2152. mtmc.level_name AS "levelName"
  2153. from mst.t_model_material mtmm
  2154. left join mst.t_model_category mtmc on mtmc.category_id = mtmm.model_category
  2155. where mtmm.fty_id = #{ftyId}
  2156. and mtmm.flg_valid
  2157. <if test="modelCode != null and modelCode != ''">
  2158. (And position (#{modelCode} in mtmm.model_code)>0
  2159. OR position (#{modelCode} in mtmm.model_name)>0)
  2160. </if>
  2161. order by mtmm.model_code
  2162. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  2163. limit #{end} offset #{start}
  2164. </if>
  2165. </select>
  2166. <!-- 获取物料编码 -->
  2167. <select id="getModelMaterialCountByPage" resultType="Long">
  2168. select count(1)
  2169. from mst.t_model_material mtmm
  2170. left join mst.t_model_category mtmc on mtmc.category_id = mtmm.model_category
  2171. where mtmm.fty_id = #{ftyId}
  2172. and mtmm.flg_valid
  2173. <if test="modelCode != null and modelCode != ''">
  2174. (And position (#{modelCode} in mtmm.model_code)>0
  2175. OR position (#{modelCode} in mtmm.model_name)>0)
  2176. </if>
  2177. </select>
  2178. <!-- 获取物料编码 -->
  2179. <select id="getModelMaterial" resultType="java.util.Map">
  2180. select model_id as "modelId",
  2181. model_code as "modelCode",
  2182. model_name as "modelName",
  2183. model_specs as "modelSpecs", model_place as "modelPlace",
  2184. sys.f_code_name(model_code,model_name) AS "codeName",
  2185. mtmc.category_name AS "categoryName",
  2186. mtmc.category_code AS "categoryCode",
  2187. tmu.unit_name as "unitName"
  2188. from mst.t_model_material mtmm
  2189. left join mst.t_model_category mtmc on mtmc.category_id = mtmm.model_category
  2190. left join mst.t_model_units tmu on tmu.unit_id = mtmm.unit_id
  2191. where mtmm.fty_id = #{ftyId}
  2192. and mtmm.flg_valid
  2193. <if test="modelCode != null and modelCode != ''">
  2194. And position (#{modelCode} in mtmm.model_code)>0
  2195. </if>
  2196. order by mtmm.model_code
  2197. </select>
  2198. <!-- 产品信息数量-->
  2199. <select id="getProductForChangeNoPage" resultType="java.util.Map">
  2200. select
  2201. pdtCode.pdt_unique_id as "pdtUniqueId",--产品唯一码
  2202. pdtCode.pdt_code_kind as "pdtCodeKind", --条码类型
  2203. product.model_id as "modelId", --型号Id
  2204. product.pdt_flow_node_id as "nodeId", --节点Id
  2205. pdtCode.pdt_barcode as "pdtBarcode", --产品条码
  2206. (select string_agg(pdtCodeHis.pdt_barcode, ' | ')
  2207. from pdm.t_product_code_his as pdtCodeHis
  2208. where pdtCodeHis.pdt_unique_id = product.unique_id)
  2209. as "hisPdtCodes", --历史条码
  2210. mLine.unique_code as "moldLineCode",--成型线编码
  2211. mLine.moldline_name as "moldLineName", --成型线名称
  2212. mItem.molding_date as "moldingDate",--成型日期
  2213. mItem.molding_batch as "moldingBatch",--注浆批次
  2214. mu.user_code as "moldingUser",--成型工号
  2215. sys.f_code_name(mu.user_code,mu.user_name) AS "moldingUserCodeName",--成型工号
  2216. mItem.molding_user as "moldingUserID",
  2217. sys.f_code_name(mp.model_code,mp.model_name) AS "productUniqueCode",--产品编码名称
  2218. mItem.moldline_item_code as "mouldUniqueCode", --模具编号
  2219. sys.f_get_name_i18n_lang(dataKind.kind_name_i18n,#{i18n}) as "mouldKind",--模具状态
  2220. mItem.this_molded_num as "moldedNum", --成型次数
  2221. manageUser.user_name as "manageUserName", --成型班长
  2222. sys.f_code_name(manageUser.user_code,manageUser.user_name) AS "manageUserCodeName",--成型班长
  2223. product.render_m_time as "renderMTime", --交坯时间
  2224. node.node_name as "nodeName",--工序名称
  2225. product.finish_time as "finishTime" -- 完成时间
  2226. from pdm.t_product as product
  2227. inner join pdm.t_product_code as pdtCode
  2228. on product.unique_id = pdtCode.pdt_unique_id
  2229. left join pdm.t_molding_item as mItem
  2230. on mItem.item_id = product.molding_item_id
  2231. left join mst.t_moldline as mLine
  2232. on mItem.moldline_id = mLine.unique_id
  2233. left join core.t_user as mu
  2234. on mu.user_id = mItem.molding_user
  2235. left join mst.t_mould as mould
  2236. on mItem.mould_id = mould.unique_id
  2237. left join sys.t_data_kind as dataKind
  2238. on mould.mould_kind = dataKind.kind_code
  2239. left join pdm.t_molding as molding
  2240. on molding.molding_id = mItem.molding_id
  2241. left join core.t_user as manageUser
  2242. on molding.manage_user = manageUser.user_id
  2243. left join pdm.t_process_node as node
  2244. on product.pdt_flow_node_id = node.node_id
  2245. inner join mst.t_model_product as mp
  2246. on product.model_id = mp.model_id
  2247. where product.fty_id = #{ftyId}
  2248. and product.flg_valid
  2249. <!--条码值等查询-->
  2250. <if test="pdtBarcodeEqual != null and pdtBarcodeEqual != ''">
  2251. and #{pdtBarcodeEqual} = pdtCode.pdt_barcode
  2252. </if>
  2253. <if test="productUniqueCodeEqual != null and productUniqueCodeEqual != ''">
  2254. and #{productUniqueCodeEqual} = mp.model_code
  2255. </if>
  2256. <if test="moldingUserEqual != null and moldingUserEqual != ''">
  2257. and #{moldingUserEqual} = mu.user_code
  2258. </if>
  2259. <if test="moldLineCode != null and moldLineCode != '' and pdaFlag != 1">
  2260. and position (#{moldLineCode} in mLine.unique_code)>0
  2261. </if>
  2262. <if test="moldLineCode != null and pdaFlag == 1">
  2263. and mLine.unique_code = #{moldLineCode}
  2264. </if>
  2265. <if test="moldLineName != null and moldLineName != ''">
  2266. and position (#{moldLineName} in mLine.moldline_name)>0
  2267. </if>
  2268. <if test="mouldUniqueCode != null and mouldUniqueCode != ''">
  2269. and position(#{mouldUniqueCode} in mould.unique_code )>0
  2270. </if>
  2271. <if test="productUniqueCode != null and productUniqueCode != '' and pdaFlag != 1">
  2272. and position(#{productUniqueCode} in product.unique_code)>0
  2273. </if>
  2274. <if test="productUniqueCode != null and pdaFlag == 1">
  2275. and product.unique_code = #{productUniqueCode}
  2276. </if>
  2277. <if test="moldingUser != null and moldingUser != ''">
  2278. and position(#{moldingUser} in mu.user_code ) >0
  2279. </if>
  2280. <if test="pdtBarcode != null and pdtBarcode != ''">
  2281. and position(#{pdtBarcode} in pdtCode.pdt_barcode)>0
  2282. </if>
  2283. <if test="renderMTimeStart != null and renderMTimeStart != ''">
  2284. and product.render_m_time >=#{renderMTimeStart}
  2285. </if>
  2286. <if test="renderMTimeEnd != null and renderMTimeEnd != ''">
  2287. and product.render_m_time &lt;=#{renderMTimeEnd}
  2288. </if>
  2289. <if test="moldingDateStart != null and moldingDateStart != ''">
  2290. and mItem.molding_date >=#{moldingDateStart}
  2291. </if>
  2292. <if test="moldingDateEnd != null and moldingDateEnd != ''">
  2293. and mItem.molding_date &lt;= #{moldingDateEnd}
  2294. </if>
  2295. <if test="moldingLastDate != null and moldingLastDate != ''">
  2296. and mItem.molding_date = CAST( #{moldingLastDate} as date)
  2297. </if>
  2298. <if test="moldingBatch != null and moldingBatch != ''">
  2299. and mItem.molding_batch = #{moldingBatch}
  2300. </if>
  2301. <if test="limit != null and limit != 0 ">
  2302. limit #{limit}
  2303. </if>
  2304. </select>
  2305. <!-- 获取计量单位 -->
  2306. <select id="getModelUnits" resultType="java.util.Map">
  2307. select tmu.unit_id AS "unitId",
  2308. tmu.unit_code as "unitCode",
  2309. tmu.unit_name as "unitName",
  2310. tmu.unit_scale as "unitScale"
  2311. from mst.t_model_units as tmu
  2312. where tmu.flg_valid
  2313. and tmu.fty_id = #{ftyId}
  2314. order by tmu.display_no
  2315. </select>
  2316. <!-- 获取产品型号、物料型号 -->
  2317. <select id="getModelBase" resultType="java.util.Map">
  2318. select
  2319. tmb.model_id as "modelId",
  2320. tmb.model_kind as "modelKind",
  2321. tmb.model_code as "modelCode",
  2322. tmb.model_name as "modelName"
  2323. from mst.t_model_base tmb
  2324. where tmb.fty_id = #{ftyId}
  2325. and flg_valid
  2326. and tmb.model_kind in ('型号种类-产品','型号种类-物料')
  2327. <if test="modelCode != null and userCode != ''">
  2328. And position (#{modelCode} in tmb.model_code)>0
  2329. </if>
  2330. <if test="modelName != null and modelName != ''">
  2331. And position (#{modelName} in tmb.model_name)>0
  2332. </if>
  2333. ORDER BY tmb.model_code
  2334. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  2335. limit #{end} offset #{start}
  2336. </if>
  2337. </select>
  2338. <select id="countModelBase" resultType="Long">
  2339. select count(1)
  2340. from mst.t_model_base tmb
  2341. where tmb.fty_id = #{ftyId}
  2342. and flg_valid
  2343. and tmb.model_kind in ('型号种类-产品','型号种类-物料')
  2344. <if test="modelCode != null and userCode != ''">
  2345. And position (#{modelCode} in tmb.model_code)>0
  2346. </if>
  2347. <if test="modelName != null and modelName != ''">
  2348. And position (#{modelName} in tmb.model_name)>0
  2349. </if>
  2350. </select>
  2351. <!-- 获取报工项目-->
  2352. <select id="getWorkProject" resultType="java.util.Map">
  2353. select p.project_id as "projectIid",
  2354. p.project_code as "projectCode",
  2355. p.project_name as "projectName",
  2356. p.project_kind as "projectKind",
  2357. sys.f_get_name_i18n_lang(tdk.kind_name_i18n, #{i18n}) as "projectkindName",
  2358. p.item_kind as "itemKind",
  2359. p.station_id as "stationId",
  2360. p.pdt_grades as "pdtGrades",
  2361. p.pdt_defects as "pdtDefects",
  2362. p.remarks
  2363. from mst.t_work_project p
  2364. left join sys.t_data_kind as tdk
  2365. on p.project_kind = tdk.kind_code
  2366. where p.flg_valid
  2367. and p.fty_id = #{ftyId}
  2368. </select>
  2369. <!-- 获取报工项目-->
  2370. <select id="getWorkProjectByPage" resultType="java.util.Map">
  2371. select p.project_id as "projectId",
  2372. p.project_code as "projectCode",
  2373. p.project_name as "projectName",
  2374. p.project_kind as "projectKind",
  2375. sys.f_get_name_i18n_lang(tdk.kind_name_i18n,#{i18n}) as "projectKindName",
  2376. p.item_kind as "itemKind",
  2377. p.station_id as "stationId",
  2378. p.pdt_grades as "pdtGrades",
  2379. p.pdt_defects as "pdtDefects",
  2380. p.remarks
  2381. from mst.t_work_project p
  2382. left join sys.t_data_kind as tdk
  2383. on p.project_kind = tdk.kind_code
  2384. where p.flg_valid
  2385. and p.fty_id = #{ftyId}
  2386. <if test="projectCode != null and projectCode != ''">
  2387. And position (#{projectCode} in p.project_code)>0
  2388. </if>
  2389. <if test="projectName != null and projectName != ''">
  2390. And position (#{projectName} in p.project_name)>0
  2391. </if>
  2392. ORDER BY p.display_no
  2393. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  2394. limit #{end} offset #{start}
  2395. </if>
  2396. </select>
  2397. <select id="getWorkProjectCountByPage" resultType="Long">
  2398. select count(1)
  2399. from mst.t_work_project p
  2400. where p.flg_valid
  2401. and p.fty_id = #{ftyId}
  2402. <if test="projectCode != null and projectCode != ''">
  2403. And position (#{projectCode} in p.project_code)>0
  2404. </if>
  2405. <if test="projectName != null and projectName != ''">
  2406. And position (#{projectName} in p.project_name)>0
  2407. </if>
  2408. </select>
  2409. <!-- 查询产品缺陷-->
  2410. <select id="getProductDefects" resultMap="getProductDefectMap">
  2411. select tpd.defect_id AS "defectId",
  2412. tpd.defect_name AS "defectName",
  2413. tpd.defect_code AS "defectCode",
  2414. sys.f_code_name(tpd.defect_code,tpd.defect_name) AS "codeName",
  2415. tpd.defect_types as "defectTypes",
  2416. (
  2417. select json_agg(jsonb_build_object('fineId', fine_id, 'fineName', fine_name,
  2418. 'deductNum', deduct_num,'fineCodeName',sys.f_code_name(fine_code,fine_name)))
  2419. from mst.t_product_defect_fine
  2420. where fine_id = any(tpd.defect_fines)
  2421. ) as "defectFines"
  2422. from mst.t_product_defect tpd
  2423. where tpd.fty_id = #{ftyId}
  2424. and tpd.flg_valid
  2425. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  2426. limit #{end} offset #{start}
  2427. </if>
  2428. </select>
  2429. <select id="countProductDefects" resultType="Long">
  2430. select count(1)
  2431. from mst.t_product_defect tpd
  2432. where tpd.fty_id = #{ftyId}
  2433. and tpd.flg_valid
  2434. </select>
  2435. <!-- 获取应用-->
  2436. <select id="getApplication" resultType="java.util.Map">
  2437. select app_code as "appCode",
  2438. app_name as "appName"
  2439. from sys.t_application
  2440. </select>
  2441. <!--获取产品-->
  2442. <select id="getProduct" resultType="java.util.Map">
  2443. select unique_code as "productCode",
  2444. unique_id as "productId"
  2445. from pdm.t_product
  2446. where fty_id = #{ftyId}
  2447. and unique_code = #{productCode}
  2448. </select>
  2449. <!--获取工位打印机-->
  2450. <select id="getWsPrinter" resultType="java.util.Map">
  2451. select ptwp.wsp_id as "wspId",
  2452. ptwp.printer_id as "printerId",
  2453. mtlp.printer_code as "printerCode",
  2454. mtlp.printer_name as "printerName",
  2455. sys.f_code_name(mtlp.printer_code, mtlp.printer_name) AS "printerCodeName"
  2456. from pdm.t_ws_printer ptwp
  2457. left join mst.t_label_printer mtlp on mtlp.printer_id = ptwp.printer_id
  2458. where ptwp.fty_id = #{ftyId}
  2459. and ptwp.station_id = #{stationId}
  2460. and ptwp.flg_valid
  2461. </select>
  2462. <!-- 获取仓库 -->
  2463. <select id="getWarehouse" resultType="java.util.Map">
  2464. SELECT tmw.wh_id as "whId"
  2465. ,tmw.wh_name as "whName"
  2466. ,tmw.wh_code as "whCode"
  2467. FROM dkic_b.t_mst_warehouse tmw
  2468. WHERE tmw.cp_id = #{cpId}
  2469. and tmw.flg_valid
  2470. <if test="whCode!=null and whCode!=''">
  2471. and position(#{whCode} in tmw.wh_code) > 0
  2472. </if>
  2473. <if test="whName!=null and whName!=''">
  2474. and position(#{whName} in tmw.wh_name) > 0
  2475. </if>
  2476. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  2477. limit #{end} offset #{start}
  2478. </if>
  2479. </select>
  2480. <!--获取仓库-->
  2481. <select id="getWarehouseByPage" resultType="java.util.Map">
  2482. SELECT mtw.wh_id as "whId",sys.f_code_name(mtw.wh_code,mtw.wh_name) AS "whCodeName"
  2483. FROM mst.t_warehouse mtw left join core.t_user ctu on ctu.user_id = mtw.op_create_user_id
  2484. WHERE mtw.fty_id = #{ftyId}
  2485. and mtw.flg_valid
  2486. <if test="whCode!=null and whCode!=''">
  2487. and position(#{whCode} in mtw.wh_code) > 0
  2488. </if>
  2489. <if test="whName!=null and whName!=''">
  2490. and position(#{warehouseName} in mtw.wh_name) > 0
  2491. </if>
  2492. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  2493. limit #{end} offset #{start}
  2494. </if>
  2495. </select>
  2496. <!--获取仓库个数-->
  2497. <select id="countWarehouseByPage" resultType="Long">
  2498. select count(1)
  2499. from mst.t_warehouse mtw
  2500. WHERE mtw.fty_id = #{ftyId}
  2501. and mtw.flg_valid
  2502. <if test="whCode!=null and whCode!=''">
  2503. and position(#{whCode} in mtw.wh_code) > 0
  2504. </if>
  2505. <if test="whName!=null and whName!=''">
  2506. and position(#{warehouseName} in mtw.wh_name) > 0
  2507. </if>
  2508. </select>
  2509. <!--获取仓位-->
  2510. <select id="getWarehousePlaceByPage" resultType="java.util.Map">
  2511. SELECT mtwp.place_id as "placeId", mtwp.place_name as "placeName",
  2512. sys.f_code_name(mtw.wh_code,mtw.wh_name) AS "whCodeName"
  2513. FROM mst.t_warehouse_place mtwp
  2514. left join mst.t_warehouse mtw on mtw.wh_id = mtwp.wh_id
  2515. WHERE mtwp.fty_id = #{ftyId}
  2516. and mtwp.flg_valid
  2517. <if test="whId!=null">
  2518. and mtwp.wh_id = #{whId}
  2519. </if>
  2520. <if test="placeName!=null and placeName!=''">
  2521. and position(#{placeName} in mtwp.place_name) > 0
  2522. </if>
  2523. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  2524. limit #{end} offset #{start}
  2525. </if>
  2526. </select>
  2527. <!--获取仓位个数-->
  2528. <select id="countWarehousePlaceByPage" resultType="Long">
  2529. select count(1)
  2530. FROM mst.t_warehouse_place mtwp
  2531. WHERE mtwp.fty_id = #{ftyId}
  2532. and mtwp.flg_valid
  2533. <if test="whId!=null">
  2534. and mtwp.wh_id = #{whId}
  2535. </if>
  2536. <if test="placeName!=null and placeName!=''">
  2537. and position(#{placeName} in mtwp.place_name) > 0
  2538. </if>
  2539. </select>
  2540. <!--获取单据-->
  2541. <select id="getDoc" resultType="java.util.Map">
  2542. SELECT
  2543. tsd.doc_code AS "docCode",
  2544. sys.f_get_name_i18n_lang ( tsd.doc_name_i18n, #{i18n}) AS "docName"
  2545. FROM
  2546. sys.t_s_doc tsd
  2547. WHERE
  2548. tsd.flg_valid
  2549. <if test="flgApproval!=null">
  2550. and tsd.flg_approval = #{flgApproval}
  2551. </if>
  2552. </select>
  2553. <!--获取下拉选-->
  2554. <select id="getSelectType" resultType="java.util.Map">
  2555. SELECT select_id as "selectId",
  2556. select_name as "selectName"
  2557. FROM mst.t_custom_select_type
  2558. WHERE fty_id = #{ftyId}
  2559. and flg_valid
  2560. </select>
  2561. <!--获取下拉选-->
  2562. <select id="getSelectMagnifier" resultType="java.util.Map">
  2563. SELECT magnifier_id as "magnifierId",
  2564. magnifier_name as "magnifierName"
  2565. FROM mst.t_custom_select_magnifier
  2566. WHERE fty_id = #{ftyId}
  2567. and flg_valid
  2568. </select>
  2569. <!--获取理化检验单-->
  2570. <select id="getPhysicalCollectByPage" resultType="java.util.Map">
  2571. SELECT collect_id as "collectId", collect_no as "collectNo"
  2572. FROM sht.t_check_collect_rmat
  2573. WHERE fty_id = #{ftyId}
  2574. and flg_valid
  2575. <if test="collectNo!=null and collectNo!=''">
  2576. and position(#{collectNo} in collect_no) > 0
  2577. </if>
  2578. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  2579. limit #{end} offset #{start}
  2580. </if>
  2581. </select>
  2582. <!--获取理化检验单个数-->
  2583. <select id="countPhysicalCollectByPage" resultType="Long">
  2584. select count(1)
  2585. FROM sht.t_check_collect_rmat
  2586. WHERE fty_id = #{ftyId}
  2587. and flg_valid
  2588. <if test="collectNo!=null and collectNo!=''">
  2589. and position(#{collectNo} in collect_no) > 0
  2590. </if>
  2591. </select>
  2592. <!--获取生产工单-->
  2593. <select id="getSheetProduceByPage" resultType="java.util.Map">
  2594. SELECT tsp.produce_id as "produceId", tsp.produce_no as "produceNo"
  2595. FROM sht.t_sheet_produce tsp
  2596. WHERE tsp.fty_id = #{ftyId}
  2597. and tsp.flg_valid and tsp.produce_status = '工单状态-执行'
  2598. <if test="produceNo!=null and produceNo!=''">
  2599. and position(#{produceNo} in tsp.produce_no) > 0
  2600. </if>
  2601. order by tsp.produce_id desc
  2602. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  2603. limit #{end} offset #{start}
  2604. </if>
  2605. </select>
  2606. <!--获取生产工单个数-->
  2607. <select id="countSheetProduceByPage" resultType="Long">
  2608. select count(1)
  2609. FROM sht.t_sheet_produce
  2610. WHERE fty_id = #{ftyId}
  2611. and flg_valid and produce_status = '工单状态-执行'
  2612. <if test="produceNo!=null and produceNo!=''">
  2613. and position(#{produceNo} in produce_no) > 0
  2614. </if>
  2615. </select>
  2616. <!--获取载具型号分页-->
  2617. <select id="getModelCarrierByPage" resultType="java.util.Map">
  2618. select tmc.model_id AS "modelId",
  2619. tmc.model_code as "modelCode",
  2620. tmc.model_name AS "modelName",
  2621. sys.f_code_name(tmc.model_code,tmc.model_name) AS "carModelCodeName",
  2622. tmcg.category_name as "modelCategoryName",
  2623. tmcg.level_name as "modelCategoryLevelName",
  2624. tmc.remarks
  2625. from mst.t_model_carrier as tmc
  2626. left join mst.t_model_category tmcg on tmcg.category_id = tmc.model_category
  2627. where tmc.flg_valid
  2628. and tmc.fty_id = #{ftyId}
  2629. <if test="flgBarcode != null">
  2630. and tmc.flg_barcode = #{flgBarcode}
  2631. </if>
  2632. <if test="modelKind != null">
  2633. and tmc.model_kind = #{modelKind}
  2634. </if>
  2635. <if test="modelCode != null and modelCode != ''">
  2636. And position (#{modelCode} in tmc.model_code)>0
  2637. </if>
  2638. <if test="modelName != null and modelName != ''">
  2639. And position (#{modelName} in tmc.model_name)>0
  2640. </if>
  2641. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  2642. limit #{end} offset #{start}
  2643. </if>
  2644. </select>
  2645. <!--获取载具型号个数-->
  2646. <select id="countModelCarrierByPage" resultType="Long">
  2647. select count(1)
  2648. from mst.t_model_carrier as tmc
  2649. left join mst.t_model_category tmcg on tmcg.category_id = tmc.model_category
  2650. where tmc.flg_valid
  2651. and tmc.fty_id = #{ftyId}
  2652. <if test="flgBarcode != null">
  2653. and tmc.flg_barcode = #{flgBarcode}
  2654. </if>
  2655. <if test="modelKind != null">
  2656. and tmc.model_kind = #{modelKind}
  2657. </if>
  2658. <if test="modelCode != null and modelCode != ''">
  2659. And position (#{modelCode} in tmc.model_code)>0
  2660. </if>
  2661. <if test="modelName != null and modelName != ''">
  2662. And position (#{modelName} in tmc.model_name)>0
  2663. </if>
  2664. </select>
  2665. <!-- 获取商品 -->
  2666. <select id="getGoods" resultType="java.util.Map">
  2667. select tmgs.sku_id as "skuId",
  2668. tmgs.sku_code as "skuCode",
  2669. tmgs.sku_name as "skuName",
  2670. tmgs.sku_model as "skuModel",
  2671. tmgs.brand_id as "brandId",
  2672. tmgb.brand_name as "brandName",
  2673. tmgs.category_id as "categoryId",
  2674. tmgc.cat_name as "categoryName",
  2675. tmgs.unit_id as "unitId",
  2676. tmgu.unit_name as "unitName",
  2677. tmgs.sub_unit_id as "subUnitId",
  2678. tmgs.conversion_factor as "conversionFactor",
  2679. tmgs.series_id as "seriesId",
  2680. tmgseries.series_name as "seriesName",
  2681. tmgs.sku_spec as "skuSpec",
  2682. tmgs.price_purchase as "pricePurchase",
  2683. tmgs.price_standard as "priceStandard",
  2684. tmgs.price_wholesale as "priceWholesale",
  2685. tmgs.price_limited as "priceLimited",
  2686. tmgs.sku_images as "skuImages",
  2687. tmgs.remarks
  2688. from dkic_b.t_mst_goods_sku as tmgs
  2689. left join dkic_b.t_mst_goods_brand as tmgb on tmgs.brand_id = tmgb.brand_id
  2690. left join dkic_b.t_mst_goods_category as tmgc on tmgs.category_id = tmgc.cat_id
  2691. left join dkic_b.t_mst_goods_series as tmgseries on tmgs.series_id = tmgseries.series_id
  2692. left join dkic_b.t_mst_unit as tmgu on tmgs.unit_id = tmgu.unit_id
  2693. where tmgs.flg_valid
  2694. <if test="skuCode != null">
  2695. AND tmgs.sku_code = #{skuCode}
  2696. </if>
  2697. <if test="skuName != null">
  2698. AND tmgs.sku_name != #{skuName}
  2699. </if>
  2700. </select>
  2701. <!-- 获取商品个数 -->
  2702. <select id="getGoodsCountByPage" resultType="Long">
  2703. SELECT
  2704. count(1)
  2705. from dkic_b.t_mst_goods_sku as tmgs
  2706. where tmgs.flg_valid
  2707. <if test="skuCode != null">
  2708. AND tmgs.sku_code = #{skuCode}
  2709. </if>
  2710. <if test="skuName != null">
  2711. AND tmgs.sku_name != #{skuName}
  2712. </if>
  2713. </select>
  2714. <!-- 获取客户 -->
  2715. <select id="getCustomer" resultType="java.util.Map">
  2716. select tmc.cus_id as "cusId",
  2717. tmc.cus_code as "cusCode",
  2718. tmc.cus_name as "cusName",
  2719. tmc.cus_phone as "cusPhone",
  2720. tmc.address_area as "addressArea",
  2721. tmc.address_name as "addressName",
  2722. tmc.address_no as "addressNo",
  2723. tmc.address_gcj02 as "addressGcj02",
  2724. tmc.address_full as "addressFull",
  2725. tmc.contact_name as "contactName",
  2726. tmc.contact_phone as "contactPhone",
  2727. tmc.cus_from as "cusFrom",
  2728. tmdd.data_value as "cusFromName",
  2729. tmc.channel_id as "channelId",
  2730. tmsc.channel_name as "channelName",
  2731. tmc.org_id as "orgId",
  2732. tmo.org_name as "orgName",
  2733. tmc.staff_id as "staffId",
  2734. tms.staff_name as "staffName",
  2735. tmc.report_staff as "reportStaff",
  2736. reportstaff.staff_name as "reportStaffName",
  2737. tmc.report_time as "reportTime",
  2738. tmc.sale_status as "saleStatus",
  2739. tmc.remarks as "remarks",
  2740. tmc.follow_staffs as "followStaffs",
  2741. tmc.last_follow_staff as "lastFollowStaff",
  2742. tmc.last_follow_id as "lastFollowId",
  2743. tmc.last_follow_status as "lastFollowStatus",
  2744. tmc.last_follow_time as "lastFollowTime"
  2745. from dkic_b.t_mst_customer as tmc
  2746. inner join dkic_b.t_mst_org tmo on tmc.org_id = tmo.org_id
  2747. inner join dkic_b.t_mst_staff tms on tmc.staff_id = tms.staff_id
  2748. inner join dkic_b.t_mst_staff as reportstaff on tmc.report_staff = reportstaff.staff_id
  2749. inner join dkic_b.t_mst_sale_channel tmsc on tmc.channel_id = tmsc.channel_id
  2750. left join dkic_b.t_mst_dictionary_data tmdd on tmc.cus_from = tmdd.data_id
  2751. where tmc.flg_valid
  2752. <if test="skuCode != null">
  2753. AND tmc.cus_code = #{cusCode}
  2754. </if>
  2755. <if test="skuName != null">
  2756. AND tmc.cus_name != #{cusName}
  2757. </if>
  2758. </select>
  2759. <!-- 获取商品个数 -->
  2760. <select id="getCustomerCountByPage" resultType="Long">
  2761. SELECT
  2762. count(1)
  2763. from dkic_b.t_mst_customer as tmc
  2764. where tmc.flg_valid
  2765. and tmc.cp_id = #{cpId}
  2766. <if test="skuCode != null">
  2767. AND tmc.cus_code = #{cusCode}
  2768. </if>
  2769. <if test="skuName != null">
  2770. AND tmc.cus_name != #{cusName}
  2771. </if>
  2772. </select>
  2773. <!-- 获取单据Id-->
  2774. <select id="getUuidSeq" resultType="object">
  2775. select sys.f_uuid_seq()
  2776. </select>
  2777. <!-- 获取单据单号-->
  2778. <select id="getDocNo" resultType="java.lang.String">
  2779. select dkic_b.f_create_note(#{cpId}, #{purId}::uuid, #{docCode})
  2780. </select>
  2781. <!--获取供应商-->
  2782. <select id="getSupplier" resultType="java.util.Map">
  2783. select tms.sup_code as "supplierCode",
  2784. tms.sup_name as "supplierName",
  2785. tms.sup_id as "supplierId",
  2786. tms.sup_type as "supplierType",
  2787. tms.contact_name as "contactName",
  2788. tms.contact_phone as "contactPhone",
  2789. tms.flg_valid as "flgValid"
  2790. from dkic_b.t_mst_supplier tms
  2791. where tms.cp_id = #{cpId}
  2792. <if test="supplierName!=null and supplierName!=''">
  2793. AND tms.sup_name LIKE concat('%', #{supplierName}, '%')
  2794. </if>
  2795. <if test="supplierCode!=null and supplierCode!=''">
  2796. AND tms.sup_code LIKE concat('%', #{supplierCode}, '%')
  2797. </if>
  2798. <if test="supplierType!=null and supplierType!=''">
  2799. AND tms.sup_type LIKE concat('%', #{supplierType}, '%')
  2800. </if>
  2801. order by tms.sup_code
  2802. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  2803. limit #{end} offset #{start}
  2804. </if>
  2805. <if test="limit != null and limit != 0 ">
  2806. limit #{limit}
  2807. </if>
  2808. </select>
  2809. <!--获取供应商数量-->
  2810. <select id="countSupplier" resultType="java.lang.Long">
  2811. select count(1)
  2812. from dkic_b.t_mst_supplier tms
  2813. where tms.cp_id = #{cpId}
  2814. <if test="supplierName!=null and supplierName!=''">
  2815. AND tms.sup_name LIKE concat('%', #{supplierName}, '%')
  2816. </if>
  2817. <if test="supplierCode!=null and supplierCode!=''">
  2818. AND tms.sup_code LIKE concat('%', #{supplierCode}, '%')
  2819. </if>
  2820. </select>
  2821. <!--获取渠道 -->
  2822. <select id="getChannel" resultType="java.util.Map">
  2823. select c.channel_id as "channelId",
  2824. c.channel_code as "channelCode",
  2825. c.channel_name as "channelName",
  2826. c.sys_code as "sysCode",
  2827. c.display_no as "displayNo"
  2828. from dkic_b.t_mst_sale_channel as c
  2829. where c.flg_valid
  2830. and c.cp_id = #{cpId}
  2831. <if test="channel_code!=null and channel_code!=''">
  2832. AND c.channel_code LIKE concat('%', #{channelCode}, '%')
  2833. </if>
  2834. <if test="channel_name!=null and channel_name!=''">
  2835. AND c.channel_name LIKE concat('%', #{channelName}, '%')
  2836. </if>
  2837. order by c.display_no
  2838. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  2839. limit #{end} offset #{start}
  2840. </if>
  2841. <if test="limit != null and limit != 0 ">
  2842. limit #{limit}
  2843. </if>
  2844. </select>
  2845. <select id="getGoodsBrand" resultType="java.util.Map">
  2846. SELECT
  2847. tmgb.flg_valid AS "flgValid",
  2848. tmgb.brand_id AS "brandId", tmgb.brand_code AS "brandCode", tmgb.brand_name AS "brandName",
  2849. (SELECT COALESCE(array_to_string(array_agg(tsm.sup_name), ','),'')
  2850. FROM dkic_b.t_mst_supplier_brand tsmb
  2851. left join dkic_b.t_mst_supplier tsm on tsm.sup_id = tsmb.sup_id
  2852. WHERE tsmb.brand_id = tmgb.brand_id) AS "supplierName"
  2853. FROM dkic_b.t_mst_goods_brand tmgb
  2854. <where>
  2855. <if test="searchText !=null">
  2856. AND tmgb.brand_name LIKE concat('%', #{searchText}, '%')
  2857. </if>
  2858. <if test="cpId != null">
  2859. AND cp_id = #{cpId}
  2860. </if>
  2861. </where>
  2862. order by display_no asc
  2863. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  2864. limit #{end} offset #{start}
  2865. </if>
  2866. </select>
  2867. <!-- 查询表t_mst_goods_brand,(条件查询)个数 -->
  2868. <select id="countGoodsBrand" resultType="Long">
  2869. SELECT
  2870. count(1)
  2871. FROM dkic_b.t_mst_goods_brand tmgb
  2872. <where>
  2873. <if test="searchText !=null">
  2874. AND tmgb.brand_name LIKE concat('%', #{searchText}, '%')
  2875. </if>
  2876. <if test="cpId != null">
  2877. AND cp_id = #{cpId}
  2878. </if>
  2879. </where>
  2880. </select>
  2881. <select id="getGoodsCategory" resultType="java.util.Map">
  2882. SELECT
  2883. cat_id AS "catId",
  2884. cat_code AS "catCode",
  2885. cat_name AS "catName",
  2886. parent_id AS "parentId",
  2887. flg_valid AS "flgValid"
  2888. FROM dkic_b.t_mst_goods_category
  2889. <where>
  2890. <if test="searchText !=null">
  2891. AND ( cat_name LIKE concat('%', #{searchText}, '%')
  2892. or remarks LIKE concat('%', #{searchText}, '%'))
  2893. </if>
  2894. <if test="cpId != null">
  2895. AND cp_id = #{cpId}
  2896. </if>
  2897. </where>
  2898. ORDER BY display_no
  2899. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  2900. limit #{end} offset #{start}
  2901. </if>
  2902. </select>
  2903. <select id="countGoodsCategory" resultType="java.lang.Long">
  2904. SELECT
  2905. count(1)
  2906. FROM dkic_b.t_mst_goods_category
  2907. <where>
  2908. <if test="searchText !=null">
  2909. AND ( cat_name LIKE concat('%', #{searchText}, '%')
  2910. or remarks LIKE concat('%', #{searchText}, '%'))
  2911. </if>
  2912. <if test="cpId != null">
  2913. AND cp_id = #{cpId}
  2914. </if>
  2915. </where>
  2916. </select>
  2917. <select id="getGoodsSeries" resultType="java.util.Map">
  2918. SELECT
  2919. series_id AS "seriesId",
  2920. series_code AS "seriesCode",
  2921. series_name AS "serieName",
  2922. flg_valid AS "flgValid"
  2923. FROM dkic_b.t_mst_goods_series
  2924. <where>
  2925. <if test="searchText !=null">
  2926. AND ( series_name LIKE concat('%', #{searchText}, '%')
  2927. or remarks LIKE concat('%', #{searchText}, '%'))
  2928. </if>
  2929. <if test="cpId != null">
  2930. AND cp_id = #{cpId}
  2931. </if>
  2932. </where>
  2933. order by display_no asc
  2934. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  2935. limit #{end} offset #{start}
  2936. </if>
  2937. </select>
  2938. <select id="countGoodsSeries" resultType="java.lang.Long">
  2939. SELECT
  2940. count(1)
  2941. FROM dkic_b.t_mst_goods_series
  2942. <where>
  2943. <if test="searchText !=null">
  2944. AND ( series_name LIKE concat('%', #{searchText}, '%')
  2945. or remarks LIKE concat('%', #{searchText}, '%'))
  2946. </if>
  2947. <if test="cpId != null">
  2948. AND cp_id = #{cpId}
  2949. </if>
  2950. </where>
  2951. </select>
  2952. <select id="getUnit" resultType="java.util.Map">
  2953. SELECT
  2954. unit_id AS "unitId",
  2955. unit_code AS "unitCode",
  2956. unit_name AS "unitName",
  2957. decimal_places AS "decimalPlaces",
  2958. flg_valid AS "flgValid"
  2959. FROM dkic_b.t_mst_unit
  2960. <where>
  2961. <if test="searchText !=null">
  2962. AND ( unit_name LIKE concat('%', #{searchText}, '%')
  2963. or remarks LIKE concat('%', #{searchText}, '%'))
  2964. </if>
  2965. <if test="cpId != null">
  2966. AND cp_id = #{cpId}
  2967. </if>
  2968. </where>
  2969. order by display_no asc
  2970. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  2971. limit #{end} offset #{start}
  2972. </if>
  2973. </select>
  2974. <select id="countUnit" resultType="java.lang.Long">
  2975. SELECT
  2976. count(1)
  2977. FROM dkic_b.t_mst_unit
  2978. <where>
  2979. <if test="searchText !=null">
  2980. AND ( unit_name LIKE concat('%', #{searchText}, '%')
  2981. or remarks LIKE concat('%', #{searchText}, '%'))
  2982. </if>
  2983. <if test="cpId != null">
  2984. AND cp_id = #{cpId}
  2985. </if>
  2986. </where>
  2987. </select>
  2988. <!--获取仓库档案-->
  2989. <select id="getWarehouseByPage" resultType="java.util.Map">
  2990. SELECT
  2991. wh_id AS "whId",
  2992. wh_code AS "whCode",
  2993. wh_name AS "whName",
  2994. supervisor AS "supervisor",
  2995. contact_phone AS "contactPhone",
  2996. flg_valid AS "flgValid"
  2997. FROM dkic_b.t_mst_warehouse
  2998. <where>
  2999. <if test="searchText !=null">
  3000. AND ( wh_name LIKE concat('%', #{searchText}, '%')
  3001. or remarks LIKE concat('%', #{searchText}, '%'))
  3002. </if>
  3003. <if test="cpId != null">
  3004. AND cp_id = #{cpId}
  3005. </if>
  3006. </where>
  3007. order by display_no asc
  3008. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  3009. limit #{end} offset #{start}
  3010. </if>
  3011. </select>
  3012. <!--获取仓库档案个数-->
  3013. <select id="countWarehouseByPage" resultType="Long">
  3014. SELECT
  3015. count(1)
  3016. FROM dkic_b.t_mst_warehouse
  3017. <where>
  3018. <if test="searchText !=null">
  3019. AND ( wh_name LIKE concat('%', #{searchText}, '%')
  3020. or remarks LIKE concat('%', #{searchText}, '%'))
  3021. </if>
  3022. <if test="cpId != null">
  3023. AND cp_id = #{cpId}
  3024. </if>
  3025. </where>
  3026. </select>
  3027. </mapper>