| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.dk.mdm.mapper.common.CommonMapper">
- <!-- 获取显示顺序的最大值 -->
- <select id="getMaxDisplayNo" resultType="Integer">
- select max(display_no)
- from ${table}
- where flg_valid
- <if test="ftyId != null">
- and fty_id = #{ftyId}
- </if>
- <if test="otherCond">
- and ${otherCond}
- </if>
- <!--数据字典-->
- <if test="dictCode != null">
- and dict_code = #{dictCode}
- </if>
- </select>
- <!--获取编码-->
- <select id="getUniqueCode" resultType="java.util.Map">
- select out_id AS "outId", out_code AS "outNote"
- from dkic_b.f_create_code_id(#{cpId}, #{docName});
- </select>
- <!--获取单号-->
- <select id="getUniqueNote" resultType="java.util.Map">
- select out_id AS "outId", out_note AS "outNote"
- from dkic_b.f_create_note_id(#{cpId}, #{docName});
- </select>
- <resultMap id="BaseResultMap" type="java.util.Map">
- <result column="kindTags" property="kindTags" typeHandler="JsonTypeHandler"/>
- </resultMap>
- <!-- 获取数据种类 -->
- <select id="getDataKind" resultMap="BaseResultMap">
- select kind_code AS "kindCode",
- sys.f_get_name_i18n_lang(kind_name_i18n,#{i18n}) as "kindName",
- sys.f_get_name_i18n_lang(kind_desc,#{i18n}) as "gradeKindDesc",
- kind_type AS "kindType",
- kind_tags AS "kindTags",
- display_no AS "displayNo",
- remarks
- from sys.t_data_kind
- where flg_valid
- <if test="kindType != null">
- AND kind_type = #{kindType}
- </if>
- <if test="usedFlag != null">
- AND kind_tags -> 'used' ?? '标签'
- </if>
- <if test="kindTag != null">
- AND kind_tags -> 'used' ?? #{kindTag}
- </if>
- <if test="kindCodeList != null and kindCodeList.size()>0">
- AND kind_code =any(#{kindCodeList,typeHandler=StringListTypeHandler})
- </if>
- order by display_no
- </select>
- <!-- 获取型号分类 -->
- <select id="getModelCategory" resultType="java.util.Map">
- select tmc.category_id AS "categoryId",
- tmc.category_code AS "categoryCode",
- tmc.category_name AS "categoryName",
- tmc.model_kind AS "modelKind",
- sys.f_get_name_i18n_lang(tdk.kind_name_i18n,#{i18n}) AS "modelKindName",
- tmc.category_id AS "id",
- tmc.parent_id AS "parentId",
- tmc.top_id AS "topId",
- tmc.level_no AS "levelNo",
- tmc.level_code AS "levelCode",
- tmc.level_name AS "levelName",
- tmc.level_leaf as "levelLeaf",
- tmc.remarks
- from mst.t_model_category tmc
- inner join sys.t_data_kind tdk
- on tdk.kind_code = tmc.model_kind
- where tmc.fty_id = #{ftyId}
- and tmc.flg_valid
- <if test="modelKind!=null">
- and tmc.model_kind = #{modelKind}
- </if>
- <if test="topId!=null">
- and tmc.top_id = #{topId}
- </if>
- <if test="categoryId!=null">
- and tmc.category_id != #{categoryId}
- </if>
- <if test="levelLeaf != null and levelLeaf">
- And tmc.level_leaf
- </if>
- <if test="levelNo != null and levelNo != ''">
- AND tmc.level_no=#{levelNo}
- </if>
- order by tmc.display_no
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <select id="countModelCategory" resultType="Long">
- select count(1)
- from mst.t_model_category tmc
- where tmc.fty_id = #{ftyId}
- and tmc.flg_valid
- <if test="modelKind!=null">
- and tmc.model_kind = #{modelKind}
- </if>
- </select>
- <!-- 获取工种 -->
- <select id="getJob" resultType="java.util.Map">
- select tj.job_Id AS "jobId",
- tj.job_name AS "jobName",
- tj.work_kind AS "workKind",
- sys.f_get_name_i18n_lang(tdk.kind_name_i18n,#{i18n}) AS "workKindName",
- tj.work_unit AS "workUnit",
- tj.display_no AS "displayNo",
- tj.remarks
- from core.t_job tj
- LEFT join sys.t_data_kind tdk on tdk.kind_code = tj.work_kind
- where tj.fty_id = #{ftyId}
- and tj.flg_valid
- <if test="workFlag!=null">
- and tj.work_kind is not null
- </if>
- <if test="productId!=null">
- and exists(
- SELECT pp.flow_node_id, tpnjd.job_id
- FROM pdm.t_production pp
- INNER JOIN pdm.t_process_node n ON n.node_id = pp.flow_node_id
- left join pdm.t_process_node_job_defect tpnjd
- on tpnjd.node_id = n.node_id and tpnjd.pdt_defect_id = #{defectId}
- WHERE pp.flg_valid
- AND NOT pp.flg_undo
- AND pp.pdt_unique_id = #{productId}
- and tpnjd.job_id = tj.job_id
- <if test="node!=null and nodeId!=''">
- and n.node_id = #{nodeId}::uuid
- </if>
- )
- </if>
- order by tj.display_no
- </select>
- <!-- 获取个数 -->
- <select id="countJob" resultType="Long">
- select count(1)
- from core.t_job tj
- LEFT join sys.t_data_kind tdk on tdk.kind_code = tj.work_kind
- where tj.fty_id = #{ftyId}
- and tj.flg_valid
- <if test="workFlag!=null">
- and tj.work_kind is not null
- </if>
- <if test="productId!=null">
- and exists(
- SELECT pp.flow_node_id, tpnjd.job_id
- FROM pdm.t_production pp
- INNER JOIN pdm.t_process_node n ON n.node_id = pp.flow_node_id
- left join pdm.t_process_node_job_defect tpnjd
- on tpnjd.node_id = n.node_id and tpnjd.pdt_defect_id = #{defectId}
- WHERE pp.flg_valid
- AND NOT pp.flg_undo
- AND pp.pdt_unique_id = #{productId}
- and tpnjd.job_id = tj.job_id
- <if test="node!=null and nodeId!=''">
- and n.node_id = #{nodeId}::uuid
- </if>
- )
- </if>
- </select>
- <!-- 获取职务 -->
- <select id="getPost" resultType="java.util.Map">
- select post_Id AS "postId",
- post_name AS "postName",
- display_no AS "displayNo",
- remarks
- from core.t_post
- where fty_id = #{ftyId}
- and flg_valid
- order by display_no
- </select>
- <!-- 获取组织部门 -->
- <select id="getOrg" resultType="java.util.Map">
- select org_Id AS "orgId",
- org_code AS "orgCode",
- org_name AS "orgName",
- org_Id AS "id",
- parent_id AS "parentId",
- top_Id AS "topId",
- display_no AS "displayNo",
- remarks
- from dkic_b.t_mst_org
- where flg_valid
- and cp_id = #{cpId}
- <if test="topId != null">
- AND top_id = #{topId}
- </if>
- <if test="orgId != null">
- AND org_id != #{orgId}
- </if>
- order by display_no
- </select>
- <!-- t_mst_org,(条件查询)个数 -->
- <select id="getOrgCountByPage" resultType="Long">
- SELECT
- count(1)
- from dkic_b.t_mst_org
- where flg_valid
- and cp_id = #{cpId}
- <if test="topId != null">
- AND top_id = #{topId}
- </if>
- <if test="orgId != null">
- AND org_id != #{orgId}
- </if>
- </select>
- <!-- 产品品牌-->
- <select id="getBrand" resultType="java.util.Map">
- select brand_id as "brandId",
- brand_code as "brandCode",
- brand_name as "brandName",
- display_no as "displayNo",
- remarks
- from mst.t_product_brand
- where fty_id = #{ftyId}
- and flg_valid
- order by display_no
- </select>
- <!-- 获取用户菜单-->
- <select id="getMenuByUser" resultType="java.util.Map">
- select menu_uuid AS "menuUuid",
- name AS "name",
- menu_name AS "menuName",
- parent_uuid AS "parentUuid",
- menu_type AS "menuType",
- flg_menu AS "flgMenu",
- flg_right AS "flgRight",
- object_code AS "objectCode",
- object_paths AS "objectPaths",
- object_icon AS "icon",
- parent_path AS "parentPath",
- menu_tags AS "menuTags",
- level_code AS "levelCode",
- flg_fast AS "flgFast",
- fast_image AS "fastImage",
- fast_path AS "fastPath",
- ex_menu_uuid AS "exMenuUuid",
- flg_same_route AS "flgSameRoute",
- flg_choose_id AS "flgChooseId",
- #{appCode} AS "appCode",
- menu_uuid AS "id",
- parent_uuid AS "parentId"
- from
- <if test="appCode=='WEB-TOUCH'">
- core.f_get_user_menu_touch(#{appCode}, #{userId})
- </if>
- <if test="appCode!='WEB-TOUCH'">
- core.f_get_user_menu(#{appCode}, #{userId})
- </if>
- </select>
- <!-- 获取缺陷分类 -->
- <select id="getDefectType" resultType="java.util.Map">
- select type_id as "typeId",
- type_code as "typeCode",
- type_name as "typeName",
- display_no as "displayNo",
- remarks
- from mst.t_product_defect_type
- where fty_id = #{ftyId}
- and flg_valid
- <if test="defectKind != null">
- AND defect_kind = #{defectKind}
- </if>
- order by display_no
- </select>
- <!-- 获取角色 -->
- <select id="getRole" resultType="java.util.Map">
- select role_Id AS "roleId",
- role_name AS "roleName",
- display_no AS "displayNo",
- remarks
- from core.t_role
- where (fty_id = #{ftyId} OR fty_id = 0)
- and flg_valid
- order by display_no
- </select>
- <!-- 获取员工 -->
- <select id="getStaffByPage" resultType="java.util.Map">
- select staff.staff_id AS "staffId",
- staff.staff_code AS "staffCode",
- staff.staff_name AS "staffName",
- sys.f_code_name(staff.staff_code, staff.staff_name) AS "staffCodeName",
- staff.remarks
- from dkic_b.t_mst_staff AS staff
- where staff.flg_valid
- and staff.cp_id =#{cpId}
- <if test="staffCode != null and staffCode != ''">
- And position (#{staffCode} in staff.staff_code)>0
- </if>
- <if test="staffName != null and staffName != ''">
- And position (#{staffName} in staff.staff_name)>0
- </if>
- order by staff.staff_code
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 查询表t_user,(条件查询)个数 -->
- <select id="getStaffCountByPage" resultType="Long">
- SELECT
- count(1)
- from dkic_b.t_mst_staff AS staff
- where staff.flg_valid
- and staff.cp_id =#{cpId}
- <if test="staffCode != null and staffCode != ''">
- And position (#{staffCode} in staff.staff_code)>0
- </if>
- <if test="staffName != null and staffName != ''">
- And position (#{staffName} in staff.staff_name)>0
- </if>
- </select>
- <!-- 函数查询单个系统参数-->
- <select id="getSettingValue" resultType="String">
- select core.f_get_setting_value(#{code}, #{ftyId})
- </select>
- <!-- 函数查询多个系统参数-->
- <select id="getSettingValues" resultType="Map">
- select core.f_get_setting_values(
- #{codes, typeHandler=StringListTypeHandler}, #{ftyId})
- </select>
- <!-- 获取工厂区域 -->
- <select id="getFactorySpace" resultType="java.util.Map">
- select space_id as "spaceId",
- space_code as "spaceCode",
- space_name as "spaceName",
- display_no as "displayNo",
- space_id AS "id",
- case when parent_id = #{workShop} then 0 else parent_id end "parentId",
- --parent_id AS "parentId",
- top_id as "topId",
- level_no AS "levelNo",
- level_code AS "levelCode",
- level_name AS "levelName",
- remarks
- from mst.t_factory_space
- where fty_id = #{ftyId}
- and flg_valid
- <if test="workShop != null and workShop != ''">
- And #{workShop} = any(level_upper)
- </if>
- <if test="topId != null">
- And top_id = #{topId}
- </if>
- <if test="spaceId != null">
- And space_id != #{spaceId}
- </if>
- <if test="spaceKind != null and spaceKind != ''">
- and space_kind = #{spaceKind}
- </if>
- order by level_code
- </select>
- <!-- 查询系统参数分类 -->
- <select id="getSettingKind" resultType="java.util.Map">
- select sk.kind_code as "classCode",
- sys.f_get_name_i18n_lang(sk.kind_name_i18n, #{i18n}) as "className",
- sk.display_no as "displayNo"
- from sys.t_setting_kind as sk
- where sk.flg_valid
- order by sk.display_no
- </select>
- <!-- 获取员组织部门-->
- <select id="getOrganizationByPage" resultType="java.util.Map">
- select org.org_id AS "orgId",
- org.org_code AS "orgCode",
- org.org_name AS "orgName",
- org.level_name as "levelName",
- org.remarks
- from core.t_organization AS org
- where org.fty_id = #{ftyId}
- and org.flg_valid
- <if test="orgCode != null and orgCode != ''">
- And position (#{orgCode} in org.org_code)>0
- </if>
- <if test="orgName != null and orgName != ''">
- And position (#{orgName} in org.org_name)>0
- </if>
- order by org.org_code
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 查询表t_organization,(条件查询)个数 -->
- <select id="getOrganizationCountByPage" resultType="Long">
- SELECT
- count(1)
- from core.t_organization AS org
- where org.fty_id = #{ftyId}
- and org.flg_valid
- <if test="orgCode != null and orgCode != ''">
- And position (#{orgCode} in org.org_code)>0
- </if>
- <if test="orgName != null and orgName != ''">
- And position (#{orgName} in org.org_name)>0
- </if>
- </select>
- <!-- 获取窑炉 -->
- <select id="getKiln" resultType="java.util.Map">
- select unique_id as "kilnId",
- unique_code as "kilnCode",
- kiln_name as "kilnName",
- sys.f_code_name(unique_code,kiln_name) AS "kilnCodeName",
- display_no as "displayNo",
- space_id as "spaceId",
- remarks
- from mst.t_kiln
- where fty_id = #{ftyId}
- and flg_valid
- order by display_no
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <select id="countKiln" resultType="Long">
- select count(1)
- from mst.t_kiln
- where fty_id = #{ftyId}
- and flg_valid
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 获取型号 -->
- <select id="getModelMould" resultType="java.util.Map">
- select model_id as "modelId", model_code as "modelCode", model_name as "modelName",
- sys.f_code_name(model_code,model_name) AS "codeName"
- from
- <if test="modelKind==null or modelKind=='型号种类-模具'">
- mst.t_model_mould
- </if>
- <if test="modelKind=='型号种类-物料'">
- mst.t_model_material
- </if>
- <if test="modelKind=='型号种类-载具'">
- mst.t_model_carrier
- </if>
- <if test="modelKind=='型号种类-设备'">
- mst.t_model_equipment
- </if>
- where fty_id = #{ftyId}
- and flg_valid
- </select>
- <!-- 获取用户 -->
- <select id="getUser" resultType="java.util.Map">
- select tu.user_id as "userId", tu.user_code as "userCode", tu.user_name as "userName",
- sys.f_code_name(tu.user_code,tu.user_name) AS "userCodeName"
- from core.t_user tu
- where fty_id = #{ftyId}
- and flg_valid
- <if test="userCode != null and userCode != ''">
- And position (#{userCode} in user_code)>0
- </if>
- <if test="userCodeSame != null and userCodeSame != ''">
- And #{userCodeSame} = user_code
- </if>
- <if test="userName != null and userName != ''">
- And position (#{userName} in user_name)>0
- </if>
- <if test="userType != null">
- And user_type = #{userType}
- </if>
- <if test="jobId != null">
- And exists(
- select 1 from core.t_work_team twt
- where twt.wt_job_id = #{jobId} and twt.user_id = user_id
- )
- </if>
- <if test="productId != null">
- and exists(
- SELECT 1
- FROM pdm.t_production pp
- INNER JOIN pdm.t_process_node n ON n.node_id = pp.flow_node_id
- left join pdm.t_process_node_user tpnu
- on tpnu.node_id = pp.flow_node_id and tpnu.user_kind = n.user_kind
- WHERE pp.flg_valid
- AND NOT pp.flg_undo
- AND pp.pdt_unique_id = #{productId}
- and tpnu.user_id = tu.user_id
- <if test="node != null and nodeId != ''">
- and n.node_id = #{nodeId}
- </if>
- )
- </if>
- <if test="flowNodeId != null and flowNodeId != ''">
- and exists(
- SELECT 1
- FROM pdm.t_process_node_user where node_id = #{flowNodeId, typeHandler=UuidTypeHandler} and user_id = tu.user_id
- )
- </if>
- ORDER BY user_code
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <select id="countUser" resultType="Long">
- select count(1)
- from core.t_user tu
- where fty_id = #{ftyId}
- and flg_valid
- <if test="userCode != null and userCode != ''">
- And position (#{userCode} in user_code)>0
- </if>
- <if test="userName != null and userName != ''">
- And position (#{userName} in user_name)>0
- </if>
- <if test="userType != null">
- And user_type = #{userType}
- </if>
- <if test="jobId != null">
- And exists(
- select 1 from core.t_work_team twt
- where twt.wt_job_id = #{jobId} and twt.user_id = user_id
- )
- </if>
- <if test="productId != null">
- and exists(
- SELECT 1
- FROM pdm.t_production pp
- INNER JOIN pdm.t_process_node n ON n.node_id = pp.flow_node_id
- left join pdm.t_process_node_user tpnu
- on tpnu.node_id = pp.flow_node_id and tpnu.user_kind = n.user_kind
- WHERE pp.flg_valid
- AND NOT pp.flg_undo
- AND pp.pdt_unique_id = #{productId}
- and tpnu.user_id = tu.user_id
- <if test="node != null and nodeId != ''">
- and n.node_id = #{nodeId}
- </if>
- )
- </if>
- <if test="flowNodeId != null and flowNodeId != ''">
- and exists(
- SELECT 1
- FROM pdm.t_process_node_user where node_id = #{flowNodeId, typeHandler=UuidTypeHandler} and user_id = tu.user_id
- )
- </if>
- </select>
- <!-- 获取窑车位置 -->
- <select id="getKilnCarPlace" resultType="java.util.Map">
- select range_id as "rangeId",
- range_name as "rangeName",
- range_no as "rangeNo",
- remarks
- from mst.t_model_carrier_range
- where fty_id = #{ftyId}
- and flg_valid
- <if test="carModelId != null">
- And car_model_id = #{carModelId}
- </if>
- order by display_no
- </select>
- <!-- 查询产品视图 -->
- <select id="getProductView" resultType="java.util.Map">
- select tpv.view_id as "viewId",
- tpv.view_code as "viewCode",
- tpv.view_name as "viewName",
- tpv.remarks as "remarks",
- tpv.flg_valid as "flgValid"
- from mst.t_product_view tpv
- where tpv.flg_valid
- and tpv.fty_id = #{ftyId}
- </select>
- <!-- 查询产品商标-->
- <select id="getProductLogo" resultType="java.util.Map">
- select logo.logo_id as "logoId",
- logo.logo_code as "logoCode",
- logo.logo_name as "logoName",
- logo.logo_paths as "logoPaths",
- logo.brand_id as "brandId",
- logo.display_no as "displayNo",
- logo.remarks as "remarks"
- from mst.t_product_logo logo
- where logo.flg_valid
- and logo.fty_id = #{ftyId}
- order by logo.display_no
- </select>
- <!-- 查询产品釉色 -->
- <select id="getProductColour" resultType="java.util.Map">
- select colour.colour_id as "colourId",
- colour.colour_code as "colourCode",
- colour.colour_name as "colourName",
- colour.display_no as "displayNo",
- colour.remarks as "remarks"
- from mst.t_product_colour as colour
- where colour.flg_valid
- and colour.fty_id = #{ftyId}
- order by colour.display_no
- </select>
- <!-- 查询产品ERP物料 -->
- <select id="getProductErpSku" resultType="java.util.Map">
- select sku_id as "skuId",
- sku_code as "skuCode",
- sku_name as "skuName",
- remarks as "remarks"
- from mst.t_erp_sku
- where flg_valid
- and fty_id = #{ftyId}
- order by sku_code
- </select>
- <!-- 获取模具档案 -->
- <select id="getMould" resultType="java.util.Map">
- select
- tm.unique_id as "uniqueId",
- tm.unique_code as "uniqueCode",
- tm.output_qty as "outputQty",
- tmo.output_std_num as "outputStdNum",
- tmo.output_molded_num as "outputMoldedNum",
- (
- select json_agg(json_build_object('modelId', tmp.model_id, 'modelCode', tmp.model_code, 'modelName',
- tmp.model_name))
- from mst.t_mould_output tmo2
- left join mst.t_model_product tmp on tmo2.pdt_model_id = tmp.model_id
- where tm.unique_id = tmo2.mould_id
- ) as "model"
- from mst.t_mould tm
- left join mst.t_mould_output tmo on tm.unique_id = tmo.mould_id and tmo.output_no = 1
- where tm.fty_id = #{ftyId}
- and tm.flg_valid and tm.flg_barcode
- <if test="uniqueCode != null and uniqueCode != ''">
- And position (#{uniqueCode} in tm.unique_code) > 0
- </if>
- <if test="mouldKind != null and mouldKind != ''">
- And tm.mould_kind = #{mouldKind}
- </if>
- ORDER BY tm.unique_code
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <select id="countMould" resultType="Long">
- select count(1)
- from mst.t_mould tm
- left join mst.t_mould_output tmo on tm.unique_id = tmo.mould_id and tmo.output_no = 1
- where tm.fty_id = #{ftyId}
- and tm.flg_valid and tm.flg_barcode
- <if test="uniqueCode != null and uniqueCode != ''">
- And position (#{uniqueCode} in unique_code)>0
- </if>
- <if test="mouldKind != null and mouldKind != ''">
- And tm.mould_kind = #{mouldKind}
- </if>
- </select>
- <!-- 获取数据字典 -->
- <select id="getDictionaryData" resultType="java.util.Map">
- select dd.data_id as "dataId",
- dd.dict_code as "dictCode",
- dd.data_code as "dataCode",
- dd.data_value as "dataValue",
- dd.flg_default as "flgDefault"
- from dkic_b.t_mst_dictionary_data as dd
- where dd.flg_valid
- and dd.cp_id = #{cpId}
- and dd.dict_code = #{dictCode}
- order by dd.display_no
- </select>
- <!-- 获取数据类型 -->
- <select id="getValueKind" resultType="java.util.Map">
- select tvk.kind_code AS "kindCode",
- tvk.kind_name as "kindName",
- sys.f_get_name_i18n_lang(tvk.kind_name_i18n,#{i18n}) AS "kindLabel"
- from sys.t_value_kind as tvk
- where tvk.flg_valid
- <if test="used != null and used != ''">
- and #{used} = ANY (tvk.used)
- </if>
- order by tvk.display_no
- </select>
- <!-- 获取最大窑车序号 -->
- <select id="getMaxCarNo" resultType="Integer">
- select max(car_no)
- from ${table}
- <where>
- <if test="ftyId != null">
- AND fty_id = #{ftyId}
- </if>
- <if test="kilnId != null">
- AND kiln_id = #{kilnId}
- </if>
- </where>
- </select>
- <!-- 获取模具型号t_model_mould -->
- <select id="getModelMouldByPage" resultType="java.util.Map">
- select tmm.model_id AS "modelId",
- tmm.model_code AS "modelCode",
- tmm.model_name AS "modelName",
- sys.f_code_name(tmm.model_code, tmm.model_name) AS "mouldCodeName",
- tmm.std_num AS "stdNum",
- tmm.output_qty AS "outputQty",
- tmm.output_std_sum AS "outputStdSum",
- tmc.category_name AS "modelCategoryName",
- tmm.remarks
- from mst.t_model_mould AS tmm
- left join mst.t_model_category AS tmc
- on tmm.model_category = tmc.category_id
- where tmm.fty_id = #{ftyId}
- and tmm.flg_valid
- <if test="modelCode != null and modelCode != ''">
- And position (#{modelCode} in tmm.model_code)>0
- </if>
- <if test="modelName != null and modelName != ''">
- And position (#{modelName} in tmm.model_name)>0
- </if>
- order by tmm.model_code
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 获取产品位置 -->
- <select id="getProductPlace" resultType="java.util.Map">
- select place_id as "placeId", place_code as "placeCode", place_name as "placeName"
- from mst.t_product_place
- where fty_id = #{ftyId}
- and flg_valid
- <if test="placeCode != null and placeCode != ''">
- And position (#{placeCode} in place_code)>0
- </if>
- ORDER BY place_code
- </select>
- <!-- 查询表t_model_mould,(条件查询)个数 -->
- <select id="getModelMouldCountByPage" resultType="Long">
- SELECT
- count(1)
- from mst.t_model_mould AS tmm
- left join mst.t_model_category AS tmc
- on tmm.model_category = tmc.category_id
- where tmm.fty_id = #{ftyId}
- and tmm.flg_valid
- <if test="modelCode != null and modelCode != ''">
- And position (#{modelCode} in tmm.model_code)>0
- </if>
- <if test="modelName != null and modelName != ''">
- And position (#{modelName} in tmm.model_name)>0
- </if>
- </select>
- <!-- 获取获取载具型号 -->
- <select id="getModelCarrier" resultType="java.util.Map">
- select tmc.model_id AS "modelId",
- tmc.model_code as "modelCode",
- tmc.model_name AS "modelName"
- from mst.t_model_carrier as tmc
- where tmc.flg_valid
- and tmc.fty_id = #{ftyId}
- <if test="flgBarcode != null">
- and tmc.flg_barcode = #{flgBarcode}
- </if>
- <if test="modelKind != null">
- and tmc.model_kind = #{modelKind}
- </if>
- <if test="modelCode != null and modelCode != ''">
- And position (#{modelCode} in tmc.model_code)>0
- </if>
- <if test="modelName != null and modelName != ''">
- And position (#{modelName} in tmc.model_name)>0
- </if>
- </select>
- <!-- 获取获取载具型号 -->
- <select id="getModelEquipment" resultType="java.util.Map">
- select tme.model_id AS "modelId",
- tme.model_code as "modelCode",
- tme.model_name AS "modelName"
- from mst.t_model_equipment as tme
- where tme.flg_valid
- and tme.fty_id = #{ftyId}
- </select>
- <!-- 获取产品型号 -->
- <select id="getModelProduct" resultType="java.util.Map">
- select mp.model_id as "modelId", mp.model_code as "modelCode", mp.model_name as "modelName"
- ,mp.model_name as "repPdtModelName",mc.category_name as "categoryName",mc.level_name as "levelName",
- sys.f_code_name(mp.model_code,mp.model_name) AS "codeName",
- mp.model_category as "categoryId",
- mp.remarks, mp.unit_id as "unitId"
- from mst.t_model_product AS mp
- left join mst.t_model_category AS mc
- on mp.model_category = mc.category_id
- where mp.fty_id = #{ftyId}
- and mp.flg_valid
- <if test="modelCode != null and modelCode != '' and pdaFlag != 1">
- And position (#{modelCode} in mp.model_code)>0
- </if>
- <if test="modelCode != null and pdaFlag == 1">
- And mp.model_code = #{modelCode}
- </if>
- <if test="modelName != null and modelName != ''">
- And position (#{modelName} in mp.model_name)>0
- </if>
- <if test="idList != null and idList != ''">
- And mp.model_id = ANY(#{idList,typeHandler=BigIntListTypeHandler})
- </if>
- <if test="modelCategoryName != null and modelCategoryName != ''">
- And position (#{modelCategoryName} in mc.category_name)>0
- </if>
- <if test="modelCategoryId != null and modelCategoryId != ''">
- And mp.model_category = #{modelCategoryId}
- </if>
- ORDER BY mp.model_code
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <select id="countModelProduct" resultType="Long">
- select count(1)
- from mst.t_model_product AS mp
- left join mst.t_model_category AS mc
- on mp.model_category = mc.category_id
- where mp.fty_id = #{ftyId}
- and mp.flg_valid
- <if test="modelCode != null and modelCode != '' and pdaFlag != 1">
- And position (#{modelCode} in mp.model_code)>0
- </if>
- <if test="modelCode != null and pdaFlag == 1">
- And mp.model_code = #{modelCode}
- </if>
- <if test="modelName != null and modelName != ''">
- And position (#{modelName} in mp.model_name)>0
- </if>
- <if test="modelCategoryName != null and modelCategoryName != ''">
- And position (#{modelCategoryName} in mc.category_name)>0
- </if>
- <if test="modelCategoryId != null and modelCategoryId != ''">
- And mp.model_category = #{modelCategoryId}
- </if>
- </select>
- <!-- 根据模具型号id 查询模具产出型号和可变更产品型号 -->
- <select id="getMouldOutputById" resultType="java.util.Map">
- select mouldOutPut.mould_model_id as "mouldModelId",
- mouldOutPut.output_no as "outputNo",
- mouldOutPut.pdt_model_id as "pdtModelId",
- mouldOutPut.rep_pdt_model_ids as "repPdtModelIds",
- mouldOutPut.output_qty as "outputQty",
- mouldOutPut.remarks as "remarks",
- (select json_agg(t.*)
- from (select modelpdt.model_id as "modelId",
- modelpdt.model_code as "modelCode",
- modelpdt.model_name as "modelName",
- modelpdt.model_name as "repPdtModelName",
- '[' || modelpdt.model_code || ']' || modelpdt.model_name AS "codeName",
- modelpdt.remarks as "remarks"
- from mst.t_model_product as modelpdt
- where modelpdt.model_id = any (mouldOutPut.rep_pdt_model_ids)
- and modelpdt.flg_valid) t ) as "modelProductList",
- model.model_name as "pdtModelId_Name"
- from mst.t_model_mould_output as mouldOutPut
- left join mst.t_model_product as model
- on model.model_id = mouldOutPut.pdt_model_id
- where mouldoutPut.flg_valid
- and mouldoutPut.fty_id = #{ftyId}
- <if test="mouldModelId != null and mouldModelId != ''">
- And mouldoutPut.mould_model_id=#{mouldModelId}
- </if>
- <if test="outputNo != null and outputNo != ''">
- And mouldoutPut.output_no=#{outputNo}
- </if>
- </select>
- <!-- 查询产品型号 -->
- <select id="getModelPdt" resultType="java.util.Map">
- select modelpdt.model_id as "modelId",
- modelpdt.model_code as "modelCode",
- modelpdt.model_name as "modelName",
- category.category_name as "modelCategoryName",
- '[' || modelpdt.model_code || ']' || modelpdt.model_name AS "codeName",
- false as "ownerFlag"
- from mst.t_model_product as modelpdt
- left join mst.t_model_category as category
- on modelpdt.model_category = category.category_id
- where modelpdt.flg_valid
- and modelpdt.fty_id = #{ftyId}
- <if test="modelCode != null and modelCode != ''">
- And position (#{modelCode} in modelpdt.model_code)>0
- </if>
- <if test="modelName != null and modelName != ''">
- And position (#{modelName} in modelpdt.model_name)>0
- </if>
- </select>
- <!-- 查询产品缺陷扣罚数据 -->
- <select id="getDefectFines" resultType="java.util.Map">
- select defevtFine.fine_id as "fineId",
- defevtFine.fine_name as "fineName",
- defevtFine.deduct_num as "deductNum",
- defevtFine.display_no as "displayNo",
- defevtFine.remarks as "remarks"
- from mst.t_product_defect_fine as defevtFine
- where defevtFine.flg_valid
- and defevtFine.fty_id = #{ftyId}
- order by defevtFine.display_no
- </select>
- <!-- 查询打印模板分类 -->
- <select id="getLabelPrintType" resultType="java.util.Map">
- select lpt.type_id as "typeId",
- lpt.type_name as "typeName",
- lpt.label_kind as "labelKind",
- lpt.display_no as "displayNo",
- lpt.remarks as "remarks"
- from mst.t_label_print_type as lpt
- where lpt.flg_valid
- and lpt.fty_id = #{ftyId}
- <if test="labelKind != null and labelKind != ''">
- And #{labelKind} = lpt.label_kind
- </if>
- order by lpt.display_no
- </select>
- <!-- 查询工位 -->
- <select id="getWorkStation" resultType="java.util.Map">
- select ws.station_id as "stationId",
- ws.station_code as "stationCode",
- ws.station_name as "stationName",
- ws.kiln_id as "kilnId",
- ws.flow_node_id as "flowNodeId"
- from pdm.t_work_station as ws
- where ws.flg_valid
- and ws.fty_id = #{ftyId}
- <if test="flowNodeId!=null and flowNodeId!=''">
- and ws.flow_node_id = #{flowNodeId}::uuid
- </if>
- <if test="flgPrint!=null and flgPrint!=''">
- and ws.flg_print = #{flgPrint}
- </if>
- <!-- 只查询检查类型 -->
- <if test="onlyCheck!=null and onlyCheck">
- and exists(select 1
- from pdm.t_process_node tpn
- left join pdm.t_process_flow tpf on tpn.flow_id = tpf.flow_id
- where tpn.node_id = ws.flow_node_id
- and (tpn.node_kind = '工艺节点-半检' or tpn.node_kind = '工艺节点-成检')
- and tpf.flg_valid
- )
- and (
- exists(select 1 from pdm.t_work_station_user where user_id = #{userId} and station_id = ws.station_id)
- or
- exists(select 1 from pdm.t_process_node_user where user_id = #{userId} and node_id = ws.flow_node_id)
- or
- (
- not exists(select 1 from pdm.t_work_station_user where station_id = ws.station_id)
- and
- not exists(select 1 from pdm.t_process_node_user where node_id = ws.flow_node_id)
- )
- )
- </if>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 查询工位 -->
- <select id="countWorkStation" resultType="Long">
- select count(1)
- from pdm.t_work_station as ws
- where ws.flg_valid
- and ws.fty_id = #{ftyId}
- <if test="flowNodeId!=null and flowNodeId!=''">
- and ws.flow_node_id = #{flowNodeId}::uuid
- </if>
- <if test="flgPrint!=null and flgPrint!=''">
- and ws.flg_print = #{flgPrint}
- </if>
- <!-- 只查询检查类型 -->
- <if test="onlyCheck!=null and onlyCheck">
- and exists(select 1
- from pdm.t_process_node tpn
- left join pdm.t_process_flow tpf on tpn.flow_id = tpf.flow_id
- where tpn.node_id = ws.flow_node_id
- and (tpn.node_kind = '工艺节点-半检' or tpn.node_kind = '工艺节点-成检')
- and tpf.flg_valid
- )
- and (
- exists(select 1 from pdm.t_work_station_user where user_id = #{userId} and station_id = ws.station_id)
- or
- exists(select 1 from pdm.t_process_node_user where user_id = #{userId} and node_id = ws.flow_node_id)
- or
- (
- not exists(select 1 from pdm.t_work_station_user where station_id = ws.station_id)
- and
- not exists(select 1 from pdm.t_process_node_user where node_id = ws.flow_node_id)
- )
- )
- </if>
- </select>
- <resultMap id="getProcessNodeByPage" type="java.util.Map">
- <result column="stationList" property="stationList" typeHandler="JsonTypeHandler"/>
- </resultMap>
- <!-- 获取工艺节点-->
- <select id="getProcessNodeByPage" resultMap="getProcessNodeByPage">
- select tpn.node_id AS "nodeId",
- tpn.node_id AS "opnFlowNodeId",
- tpn.node_id AS "missFlowNodeId",
- tpn.node_id AS "pdtFlowNodeId",
- sys.f_get_name_i18n_lang(tdk2.kind_name_i18n,#{i18n}) as "userKindName",
- sys.f_get_name_i18n_lang(tdk.kind_name_i18n,#{i18n}) as "nodeKindName",
- tdk.kind_code AS "kindCode",
- tpn.node_name AS "nodeName",
- sys.f_code_name(tpf.flow_name,tpn.node_name) AS "nodeCodeName",
- tpf.flow_name AS "flowName",
- tpn.work_shop AS "workShop",
- tfs.space_name AS "workShopName",
- (
- select json_agg(json_build_object('stationId', ws.station_id , 'stationName',ws.station_name))
- from pdm.t_work_station as ws
- where tpn.node_id = ws.flow_node_id
- ) as "stationList",
- tpn.remarks
- from pdm.t_process_node AS tpn
- left join sys.t_data_kind as tdk
- on tpn.node_kind = tdk.kind_code
- left join sys.t_data_kind as tdk2
- on tpn.user_kind = tdk2.kind_code
- left join pdm.t_process_flow AS tpf
- on tpn.flow_id = tpf.flow_id
- left join mst.t_factory_space AS tfs
- on tpn.work_shop = tfs.space_id
- where tpn.fty_id = #{ftyId}
- and tpn.flg_valid
- <if test="nodeName != null and nodeName != ''">
- And position (#{nodeName} in tpn.node_name)>0
- </if>
- <if test="flowKind != null and flowKind != ''">
- And tpn.flow_kind = #{flowKind}
- </if>
- <if test="nodeKind != null and nodeKind != ''">
- And tpn.node_kind = #{nodeKind}
- </if>
- ORDER BY tpf.display_no, tpf.flow_name,tpn.display_no
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 获取成型线分组 -->
- <select id="getMoldlineGroup" resultType="java.util.Map">
- select tmg.group_id as "groupId", tmg.moldline_id as "moldlineId", tmg.group_no as "groupNo"
- , tmg.group_name as "groupName", tm.unique_code as "moldlineCode", tm.moldline_name as "moldlineName",
- '[' || tm.unique_code || '] ' || tm.moldline_name AS "moldlineCodeName",
- tmg.remarks as "remarks",tm.pdt_glue_kind as "pdtGlueKind"
- from mst.t_moldline_group tmg
- left join mst.t_moldline tm
- on tmg.moldline_id = tm.unique_id
- where tmg.fty_id = #{ftyId}
- and tmg.flg_valid
- and tm.flg_valid
- and tm.moldline_kind = '成线状态-在产'
- <if test="groupName != null and groupName != ''">
- And position (#{groupName} in tmg.group_name)>0
- </if>
- <if test="moldlineCode != null and moldlineCode != ''">
- And position (#{moldlineCode} in tm.unique_code)>0
- </if>
- <if test="moldlineName != null and moldlineName != ''">
- And position (#{moldlineName} in tm.moldline_name)>0
- </if>
- <if test="groupNo != null and groupNo != ''">
- And tmg.group_no = #{groupNo}::Integer
- </if>
- ORDER BY tm.unique_code, tmg.group_no
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <select id="countMoldlineGroup" resultType="Long">
- select count(1)
- from mst.t_moldline_group tmg
- left join mst.t_moldline tm
- on tmg.moldline_id = tm.unique_id and tm.flg_valid
- where tmg.fty_id = #{ftyId}
- and tmg.flg_valid
- <if test="groupName != null and groupName != ''">
- And position (#{groupName} in tmg.group_name)>0
- </if>
- <if test="moldlineCode != null and moldlineCode != ''">
- And position (#{moldlineCode} in tm.unique_code)>0
- </if>
- <if test="moldlineName != null and moldlineName != ''">
- And position (#{moldlineName} in tm.moldline_name)>0
- </if>
- <if test="groupNo != null and groupNo != ''">
- And tmg.group_no = #{groupNo}::Integer
- </if>
- </select>
- <!-- 查询表t_process_node,(条件查询)个数 -->
- <select id="getProcessNodeCountByPage" resultType="Long">
- SELECT
- count(1)
- from pdm.t_process_node AS tpn
- left join sys.t_data_kind as tdk
- on tpn.node_kind = tdk.kind_code
- where tpn.fty_id = #{ftyId}
- and tpn.flg_valid
- <if test="nodeName != null and nodeName != ''">
- And position (#{nodeName} in tpn.node_name)>0
- </if>
- <if test="flowKind != null and flowKind != ''">
- And tpn.flow_kind = #{flowKind}
- </if>
- <if test="nodeKind != null and nodeKind != ''">
- And tpn.node_kind = #{nodeKind}
- </if>
- </select>
- <!-- 查询工位 -->
- <select id="getWorkStationUser" resultType="java.util.Map">
- select tu.user_id as "userId",
- tu.user_code as "userCode",
- tu.user_name as "userName",
- twsu.station_id as "stationId",
- tws.station_code as "stationCode",
- tws.station_name as "stationName"
- from core.t_user as tu
- left join pdm.t_work_station_user twsu
- on twsu.user_id = tu.user_id
- and twsu.flg_valid
- left join pdm.t_work_station tws
- on twsu.station_id = tws.station_id
- where tu.flg_valid
- and tu.fty_id = #{ftyId}
- and tu.user_type = 2
- and twsu.user_kind = '节点工号-操作'
- <if test="userCode != null and userCode != ''">
- And position (#{userCode} in tu.user_code)>0
- </if>
- <if test="userName != null and userName != ''">
- And position (#{userName} in tu.user_name)>0
- </if>
- <if test="stationId != null and stationId != ''">
- And #{stationId} = tws.station_id
- </if>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 查询产品信息数量(条码变更)-->
- <select id="getWorkStationUserCount" resultType="Long">
- select count(1)
- from core.t_user as tu
- left join pdm.t_work_station_user twsu
- on twsu.user_id = tu.user_id
- and twsu.flg_valid
- left join pdm.t_work_station tws
- on twsu.station_id = tws.station_id
- where tu.flg_valid
- and tu.fty_id = #{ftyId}
- and tu.user_type = 2
- and twsu.user_kind = '节点工号-操作'
- <if test="userCode != null and userCode != ''">
- And position (#{userCode} in tu.user_code)>0
- </if>
- <if test="userName != null and userName != ''">
- And position (#{userName} in tu.user_name)>0
- </if>
- <if test="stationId != null and stationId != ''">
- And #{stationId} = wsu.station_id
- </if>
- </select>
- <resultMap id="getProductDefectMap" type="java.util.Map">
- <result column="defectFines" property="defectFines" typeHandler="JsonTypeHandler"/>
- </resultMap>
- <!-- 查询损坯原因/产品缺陷/开模损原因-->
- <select id="getProductDefect" resultMap="getProductDefectMap">
- select tpd.defect_id AS "defectId",
- tpd.defect_name AS "defectName",
- tpd.defect_code AS "defectCode",
- sys.f_code_name(tpd.defect_code, tpd.defect_name) AS "codeName",
- tpd.defect_types as "defectTypes",
- (
- select json_agg(jsonb_build_object('fineId', fine_id, 'fineName', fine_name,
- 'deductNum', deduct_num, 'fineCodeName',
- sys.f_code_name(fine_code, fine_name)))
- from mst.t_product_defect_fine
- where fine_id = any (tpd.defect_fines)
- ) as "defectFines"
- from mst.t_product_defect tpd
- where tpd.fty_id = #{ftyId}
- and tpd.flg_valid
- and tpd.defect_kind = #{defectKind}
- </select>
- <!-- 根据成型线Id查询成型记录明细 -->
- <select id="getMoldingItemByMoldlineId" resultType="java.util.Map">
- select tmi.item_id AS "itemId",
- tmi.molding_id AS "moldingId",
- tmi.moldline_id AS "moldlineId",
- tmi.moldline_group_id AS "moldlineGroupId",
- tmi.moldline_group_no AS "moldlineGroupNo",
- tmi.molding_date AS "moldingDate",
- tmi.molding_batch AS "moldingBatch",
- tmi.moldline_item_id AS "moldlineItemId",
- tmi.moldline_item_no AS "moldlineItemNo",
- tmi.moldline_item_code AS "moldlineItemCode",
- tmi.moldline_item_kind AS "moldlineItemKind",
- tmi.mould_id AS "mouldId",
- tmi.output_no AS "outputNo",
- tmi.mould_pdt_tags AS "mouldPdtTags",
- tmi.flow_node_id AS "flowNodeId",
- tmi.station_id AS "stationId",
- tmi.molding_user AS "moldingUser",
- tmi.user_clock_id AS "userClockId",
- tmi.pdt_model_id AS "pdtModelId",
- tmi.pdt_logo_id AS "pdtLogoId",
- tmi.pdt_colour_id AS "pdtColourId",
- tmi.erp_model_code AS "erpModelCode",
- tmi.this_molded_num AS "thisMoldedNum",
- tmi.flg_molding AS "flgMolding",
- tmi.unmolded_reason_id AS "unmoldedReasonId",
- tmi.flg_scrap AS "flgScrap",
- tmi.scrap_date AS "scrapDate",
- tmi.scrap_reason_id AS "scrapReasonId",
- tpd.defect_name AS "scrapReasonName",
- tmi.flg_bind_unique AS "flgBindUnique",
- tmi.pdt_unique_id AS "pdtUniqueId",
- tmi.remarks,
- tmp.model_name AS "pdtModelName",
- tpl.logo_name AS "pdtLogoName",
- tpc.colour_name AS "pdtColourName",
- tdd.data_value AS "unmoldedReasonName",
- tm.moldline_name AS "moldlineName",
- tmp.model_code AS "pdtModelCode",
- tmp.model_name AS "pdtModelName",
- tpl.logo_name AS "pdtLogoName",
- tpc.colour_name AS "pdtColourName",
- tdd.data_value AS "unmoldedReasonName",
- tm.moldline_name AS "moldlineName",
- tm.unique_code AS "moldlineCode",
- sys.f_get_name_i18n_lang(tdk.kind_name_i18n,#{i18n}) AS "moldlineItemKindName",
- tws.station_name AS "stationName",
- tu.user_name AS "moldingUserName",
- '[' || tu.user_code || '] ' || tu.user_name AS "moldingUserCodeName",
- mtu.user_name AS "manageUserName",
- tp.unique_code as "productCode"
- from pdm.t_molding_item tmi
- left join pdm.t_molding as molding
- on molding.molding_id = tmi.molding_id
- left join core.t_user mtu
- on molding.manage_user = mtu.user_id
- left join mst.t_model_product tmp
- on tmi.pdt_model_id = tmp.model_id
- left join mst.t_product_logo tpl
- on tmi.pdt_logo_id = tpl.logo_id
- left join mst.t_product_colour tpc
- on tmi.pdt_colour_id = tpc.colour_id
- left join core.t_dictionary_data tdd
- on tmi.unmolded_reason_id = tdd.data_id
- left join mst.t_product_defect tpd
- on tmi.scrap_reason_id = tpd.defect_id
- left join pdm.t_product tp
- on tmi.pdt_unique_id = tp.unique_id
- left join mst.t_moldline tm
- on tmi.moldline_id = tm.unique_id
- left join mst.t_moldline_item tmli
- on tmi.moldline_item_id = tmli.item_id
- left join sys.t_data_kind tdk
- on tmi.moldline_item_kind = tdk.kind_code
- left join mst.t_mould mould
- on tmi.mould_id = mould.unique_id
- left join pdm.t_work_station tws
- on tmi.station_id = tws.station_id
- left join core.t_user tu
- on tmi.molding_user = tu.user_id
- left join pdm.t_ws_clock twc
- on tmi.user_clock_id = twc.clock_id
- where tmi.flg_valid
- <if test="moldlineId != null and moldlineId != ''">
- and tmi.moldline_id = #{moldlineId}
- </if>
- <if test="moldingId != null and moldingId != ''">
- and tmi.molding_id = #{moldingId}
- </if>
- <if test="moldingGroupId != null and moldingGroupId != ''">
- and tmi.moldline_group_id = #{moldingGroupId}
- </if>
- <if test="moldingDate != null and moldingDate != ''">
- and tmi.molding_date = CAST( #{moldingDate} as date)
- </if>
- <if test="moldingBatch != null and moldingBatch != ''">
- and tmi.molding_batch = #{moldingBatch}
- </if>
- </select>
- <!-- 查询产品信息(条码变更)-->
- <select id="getProductForChange" resultType="java.util.Map">
- select
- pdtCode.pdt_unique_id as "pdtUniqueId",--产品唯一码
- pdtCode.pdt_code_kind as "pdtCodeKind", --条码类型
- product.model_id as "modelId", --型号Id
- product.pdt_flow_node_id as "nodeId", --节点Id
- pdtCode.pdt_barcode as "pdtBarcode", --产品条码
- (select string_agg(pdtCodeHis.pdt_barcode, ' | ')
- from pdm.t_product_code_his as pdtCodeHis
- where pdtCodeHis.pdt_unique_id = product.unique_id)
- as "hisPdtCodes", --历史条码
- mLine.unique_code as "moldLineCode",--成型线编码
- mLine.moldline_name as "moldLineName", --成型线名称
- mItem.molding_date as "moldingDate",--成型日期
- mItem.molding_batch as "moldingBatch",--注浆批次
- mu.user_code as "moldingUser",--成型工号
- sys.f_code_name(mu.user_code,mu.user_name) AS "moldingUserCodeName",--成型工号
- mItem.molding_user as "moldingUserID",
- sys.f_code_name(mp.model_code,mp.model_name) AS "productUniqueCode",--产品编码名称
- mp.model_code AS "productCode",--产品编码
- mItem.moldline_item_code as "mouldUniqueCode", --模具编号
- sys.f_get_name_i18n_lang(dataKind.kind_name_i18n,#{i18n}) as "mouldKind",--模具状态
- mItem.this_molded_num as "moldedNum", --成型次数
- manageUser.user_name as "manageUserName", --成型班长
- sys.f_code_name(manageUser.user_code,manageUser.user_name) AS "manageUserCodeName",--成型班长
- to_char(product.render_m_time,'yyyy-MM-dd hh24:mi:ss') as "renderMTime", --交坯时间
- node.node_name as "nodeName",--工序名称
- to_char(product.finish_time,'yyyy-MM-dd hh24:mi:ss') as "finishTime" -- 完成时间
- from pdm.t_product as product
- inner join pdm.t_product_code as pdtCode
- on product.unique_id = pdtCode.pdt_unique_id
- left join pdm.t_molding_item as mItem
- on mItem.item_id = product.molding_item_id
- left join mst.t_moldline as mLine
- on mItem.moldline_id = mLine.unique_id
- left join core.t_user as mu
- on mu.user_id = mItem.molding_user
- left join mst.t_mould as mould
- on mItem.mould_id = mould.unique_id
- left join sys.t_data_kind as dataKind
- on mould.mould_kind = dataKind.kind_code
- left join pdm.t_molding as molding
- on molding.molding_id = mItem.molding_id
- left join core.t_user as manageUser
- on molding.manage_user = manageUser.user_id
- left join pdm.t_process_node as node
- on product.pdt_flow_node_id = node.node_id
- inner join mst.t_model_product as mp
- on product.model_id = mp.model_id
- where product.fty_id = #{ftyId}
- and product.flg_valid
- <!--条码值等查询-->
- <if test="nodeName != null and nodeName != ''">
- and position(#{nodeName} in node.node_name )>0
- </if>
- <if test="pdtBarcodeEqual != null and pdtBarcodeEqual != ''">
- and #{pdtBarcodeEqual} = pdtCode.pdt_barcode
- </if>
- <if test="productUniqueCodeEqual != null and productUniqueCodeEqual != ''">
- and #{productUniqueCodeEqual} = mp.model_code
- </if>
- <if test="moldingUserEqual != null and moldingUserEqual != ''">
- and #{moldingUserEqual} = mu.user_code
- </if>
- <if test="moldLineCode != null and moldLineCode != '' and pdaFlag != 1">
- and position (#{moldLineCode} in mLine.unique_code)>0
- </if>
- <if test="moldLineCode != null and pdaFlag == 1">
- and mLine.unique_code = #{moldLineCode}
- </if>
- <if test="moldLineName != null and moldLineName != ''">
- and position (#{moldLineName} in mLine.moldline_name)>0
- </if>
- <if test="mouldUniqueCode != null and mouldUniqueCode != ''">
- and position(#{mouldUniqueCode} in mould.unique_code )>0
- </if>
- <if test="productUniqueCode != null and productUniqueCode != '' and pdaFlag != 1">
- and position(#{productUniqueCode} in product.unique_code)>0
- </if>
- <if test="productUniqueCode != null and pdaFlag == 1">
- and product.unique_code = #{productUniqueCode}
- </if>
- <if test="moldingUser != null and moldingUser != ''">
- and position(#{moldingUser} in mu.user_code ) >0
- </if>
- <if test="pdtBarcode != null and pdaFlag == 1">
- and pdtCode.pdt_barcode = #{pdtBarcode}
- </if>
- <if test="pdtBarcode != null and pdtBarcode != ''">
- and position(#{pdtBarcode} in pdtCode.pdt_barcode)>0
- </if>
- <if test="renderMTimeStart != null and renderMTimeStart != ''">
- and product.render_m_time >=#{renderMTimeStart}
- </if>
- <if test="renderMTimeEnd != null and renderMTimeEnd != ''">
- and product.render_m_time <=#{renderMTimeEnd}
- </if>
- <if test="moldingDateStart != null and moldingDateStart != ''">
- and mItem.molding_date >=#{moldingDateStart}
- </if>
- <if test="moldingDateEnd != null and moldingDateEnd != ''">
- and mItem.molding_date <= #{moldingDateEnd}
- </if>
- <if test="moldingLastDate != null and moldingLastDate != ''">
- and mItem.molding_date = CAST( #{moldingLastDate} as date)
- </if>
- <if test="moldingBatch != null and moldingBatch != ''">
- and mItem.molding_batch = #{moldingBatch}
- </if>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 查询产品信息数量(条码变更)-->
- <select id="getProductForChangeCount" resultType="Long">
- select count(1)
- from pdm.t_product as product
- inner join pdm.t_product_code as pdtCode
- on product.unique_id = pdtCode.pdt_unique_id
- left join pdm.t_molding_item as mItem
- on mItem.item_id = product.molding_item_id
- left join mst.t_moldline as mLine
- on mItem.moldline_id = mLine.unique_id
- left join core.t_user as mu
- on mu.user_id = mItem.molding_user
- left join mst.t_mould as mould
- on mItem.mould_id = mould.unique_id
- left join sys.t_data_kind as dataKind
- on mould.mould_kind = dataKind.kind_code
- left join pdm.t_molding as molding
- on molding.molding_id = mItem.molding_id
- left join core.t_user as manageUser
- on molding.manage_user = manageUser.user_id
- left join pdm.t_process_node as node
- on product.pdt_flow_node_id = node.node_id
- where product.fty_id = #{ftyId}
- and product.flg_valid
- <if test="moldLineCode != null and moldLineCode != ''">
- and position (#{moldLineCode} in mLine.unique_code)>0
- </if>
- <if test="moldLineName != null and moldLineName != ''">
- and position (#{moldLineName} in mLine.moldline_name)>0
- </if>
- <if test="mouldUniqueCode != null and mouldUniqueCode != ''">
- and position(#{mouldUniqueCode} in mould.unique_code )>0
- </if>
- <if test="productUniqueCode != null and productUniqueCode != ''">
- and position(#{productUniqueCode} in product.unique_code)>0
- </if>
- <if test="moldingUser != null and moldingUser != ''">
- and position(#{moldingUser} in mu.user_code ) >0
- </if>
- <if test="pdtBarcode != null and pdtBarcode != ''">
- and position(#{pdtBarcode} in pdtCode.pdt_barcode)>0
- </if>
- <if test="renderMTimeStart != null and renderMTimeStart != ''">
- and product.render_m_time >=#{renderMTimeStart}
- </if>
- <if test="renderMTimeEnd != null and renderMTimeEnd != ''">
- and product.render_m_time <=#{renderMTimeEnd}
- </if>
- <if test="moldingDateStart != null and moldingDateStart != ''">
- and mItem.molding_date >=#{moldingDateStart}
- </if>
- <if test="moldingDateEnd != null and moldingDateEnd != ''">
- and mItem.molding_date <= #{moldingDateEnd}
- </if>
- </select>
- <!-- 查询产品釉色(釉色设定)-->
- <select id="getColourForSet" resultType="java.util.Map">
- select
- moldingItem.item_id as "itemId",
- productCode.pdt_barcode as "pdtBarcode",
- moldingItem.pdt_colour_id as "pdtColourId",
- colour.colour_name as "colourName"
- from pdm.t_product_code as productCode
- inner join pdm.t_product as product
- on productCode.pdt_unique_id = product.unique_id
- inner join pdm.t_molding_item as moldingItem
- on product.molding_item_id = moldingItem.item_id
- inner join mst.t_product_colour as colour
- on moldingItem.pdt_colour_id = colour.colour_id
- where productCode.flg_valid
- <if test="pdtBarcode != null and pdtBarcode != ''">
- AND position (#{pdtBarcode} in productCode.pdt_barcode)>0
- </if>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 查询产品釉色数量 (釉色设定)-->
- <select id="getColourForSetCount" resultType="Long">
- select
- count(1)
- from pdm.t_product_code as productCode
- inner join pdm.t_product as product
- on productCode.pdt_unique_id = product.unique_id
- inner join pdm.t_molding_item as moldingItem
- on product.molding_item_id = moldingItem.item_id
- inner join mst.t_product_colour as colour
- on moldingItem.pdt_colour_id = colour.colour_id
- where productCode.flg_valid and productCode.fty_id = #{ftyId}
- <if test="pdtBarcode != null and pdtBarcode != ''">
- AND position (#{pdtBarcode} in productCode.pdt_barcode)>0
- </if>
- </select>
- <!-- 查询产品商标(商标设定)-->
- <select id="getLogoForSet" resultType="java.util.Map">
- select
- moldingItem.item_id as "itemId",
- productCode.pdt_barcode as "pdtBarcode",
- moldingItem.pdt_logo_id as "pdtLogoId",
- logo.logo_name as "logoName",
- moldingItem.pdt_colour_id as "pdtColourId",
- colour.colour_name as "colourName",
- product.unique_id as "productId"
- from pdm.t_product_code as productCode
- inner join pdm.t_product as product
- on productCode.pdt_unique_id = product.unique_id
- inner join pdm.t_molding_item as moldingItem
- on product.molding_item_id = moldingItem.item_id
- inner join mst.t_product_logo as logo
- on moldingItem.pdt_logo_id = logo.logo_id
- inner join mst.t_product_colour as colour
- on moldingItem.pdt_colour_id = colour.colour_id
- where productCode.flg_valid and productCode.fty_id = #{ftyId}
- <if test="pdtBarcodeEqual != null and pdtBarcodeEqual != ''">
- AND #{pdtBarcodeEqual} = productCode.pdt_barcode
- </if>
- <if test="pdtBarcode != null and pdtBarcode != ''">
- AND position (#{pdtBarcode} in productCode.pdt_barcode)>0
- </if>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 查询产品商标(商标设定)-->
- <select id="getProductModel" resultType="java.util.Map">
- select
- moldingItem.item_id as "itemId",
- productCode.pdt_barcode as "pdtBarcode",
- mp.model_id as "modelId",
- mp.model_name as "modelName",
- '[' || mp.model_code || '] ' || mp.model_name AS "codeName",
- product.unique_id as "productId"
- from pdm.t_product_code as productCode
- inner join pdm.t_product as product
- on productCode.pdt_unique_id = product.unique_id
- inner join pdm.t_molding_item as moldingItem
- on product.molding_item_id = moldingItem.item_id
- inner join mst.t_model_product as mp
- on moldingItem.pdt_model_id = mp.model_id
- where productCode.flg_valid and productCode.fty_id = #{ftyId}
- <if test="pdtBarcodeEqual != null and pdtBarcodeEqual != ''">
- AND #{pdtBarcodeEqual} = productCode.pdt_barcode
- </if>
- <if test="pdtBarcode != null and pdtBarcode != '' and pdaFlag != 1">
- AND position (#{pdtBarcode} in productCode.pdt_barcode)>0
- </if>
- <if test="pdtBarcode != null and pdaFlag == 1">
- AND productCode.pdt_barcode = #{pdtBarcode}
- </if>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!--根据工号编码值等查询工号-->
- <select id="getUserByCode" resultType="java.util.Map">
- select
- ctu.user_id as "userId",
- ctu.user_code as "userCode",
- ctu.user_name as "userName",
- twuc.clock_id as "clockId",
- twuc.station_id as "stationId"
- from core.t_user ctu
- inner join pdm.t_ws_user_clock twuc
- on twuc.user_id = ctu.user_id
- where ctu.fty_id = #{ftyId}
- <if test="userCode != null and userCode != ''">
- and position (#{userCode} in ctu.user_code )>0
- </if>
- <if test="userCodeByChange != null and userCodeByChange != ''">
- and #{userCodeByChange} = ctu.user_code
- </if>
- <if test="userType != null and userType != ''">
- and #{userType} = ctu.user_type
- </if>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!--根据工号编码值等查询工号数量-->
- <select id="getUserByCodeCount" resultType="Long">
- select
- count(1)
- from core.t_user ctu
- inner join pdm.t_ws_user_clock twuc
- on twuc.user_id = ctu.user_id
- <where>
- <if test="userCode != null and userCode != ''">
- ctu.user_code =#{userCode}
- </if>
- <if test="userType != null and userType != ''">
- and #{userType} = ctu.user_type
- </if>
- </where>
- </select>
- <!-- 获取工艺节点-->
- <select id="getProcessNode" resultType="java.util.Map">
- select tpn.node_id AS "nodeId",
- sys.f_get_name_i18n_lang(tdk.kind_name_i18n, #{i18n}) as "nodeKind",
- tpn.node_name AS "nodeName",
- tpn.remarks
- from pdm.t_process_node AS tpn
- left join sys.t_data_kind as tdk
- on tpn.node_kind = tdk.kind_code
- where tpn.fty_id = #{ftyId}
- and tpn.flg_valid
- </select>
- <!-- 获取成型线分页-->
- <select id="getMoldLinePage" resultType="java.util.Map">
- select moldLine.unique_id as "moldlineId",
- moldLine.unique_code as "moldLineUniqueCode",
- moldLine.moldline_name as "moldlineName",
- '[' || moldLine.unique_code || '] ' || moldLine.moldline_name AS "moldlineCodeName",
- moldLine.moldline_item_qty as "moldlineItemQty",
- (select string_agg(u.user_name, ' | ')
- from core.t_user as u
- where u.user_id = any (moldLine.molding_users)) as "moldingUsers",
- sys.f_get_name_i18n_lang(dataKind.kind_name_i18n,#{i18n}) as "moldlineKind",
- to_char(moldLine.op_create_time,'YYYY-MM-DD HH24:MI:SS')as "opCreateTime"
- from mst.t_moldline as moldLine
- left join sys.t_data_kind as dataKind
- on moldLine.moldline_kind = dataKind.kind_code
- where moldLine.flg_valid and moldLine.fty_id = #{ftyId}
- <if test="pdaMoldlineCode != null ">
- AND moldLine.unique_code = #{pdaMoldlineCode}
- </if>
- <if test="moldlineCode != null and moldlineCode != ''">
- AND position (#{moldlineCode} in moldLine.unique_code)>0
- </if>
- <if test="moldlineName != null and moldlineName != ''">
- AND position (#{moldlineName} in moldLine.moldline_name)>0
- </if>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 获取成型线分页数量-->
- <select id="getMoldLinePageCount" resultType="Long">
- select count(1)
- from mst.t_moldline as moldLine
- left join sys.t_data_kind as dataKind
- on moldLine.moldline_kind = dataKind.kind_code
- where moldLine.flg_valid and moldLine.fty_id = #{ftyId}
- <if test="uniqueCode != null and uniqueCode != ''">
- AND position (#{uniqueCode} in moldLine.uniqueCode)>0
- </if>
- <if test="moldlineName != null and moldlineName != ''">
- AND position (#{moldlineName} in moldLine.moldline_name)>0
- </if>
- <if test="moldlineName != null and moldlineName != ''">
- AND position (#{moldlineName} in moldLine.moldline_name)>0
- </if>
- </select>
- <!-- 工位工号(工位打卡选择工位)-->
- <select id="getWsStation" resultType="java.util.Map">
- select distinct
- station.station_id as "stationId",
- station.station_name as "stationName",
- station.station_code as "stationCode"
- from pdm.t_work_station as station
- inner join pdm.t_work_station_user as wsu
- on station.station_id = wsu.station_id
- where station.fty_id = #{ftyId}
- and station.flg_valid
- and wsu.flg_valid
- <if test="userId != null and userId != ''">
- And #{userId} = wsu.user_id
- </if>
- </select>
- <!-- 查询班组信息-->
- <select id="getWorkTeamByUserId" resultType="java.util.Map">
- select twt.team_id as "teamId",
- twt.user_id as "userId",
- twt.wt_job_id as "wtJobId",
- twt.wt_job_id as "jobId",
- tj.job_name as "jobName",
- twt.staff_id as "staffId",
- ts.staff_name as "staffName"
- from core.t_work_team twt
- inner join core.t_job tj
- on twt.wt_job_id = tj.job_id
- inner join core.t_staff ts on ts.staff_id = twt.staff_id
- where twt.flg_valid
- and twt.user_id = #{userId}
- order by tj.job_name
- </select>
- <!-- 查询产品分级 -->
- <select id="getProductGrade" resultType="java.util.Map">
- select grade_id as "gradeId",
- grade_code as "gradeCode",
- grade_name as "gradeName",
- grade_kind as "gradeKind"
- from mst.t_product_grade
- where flg_valid
- and fty_id = #{ftyId}
- <if test="gradeCode != null and gradeCode != ''">
- AND position (#{gradeCode} in grade_code)>0
- </if>
- <if test="gradeName != null and gradeName != ''">
- AND position (#{gradeName} in grade_name)>0
- </if>
- <if test="nodeId != null and nodeId != ''">
- AND exists (
- select 1 from pdm.t_process_node
- where grade_id = any(judge_grade_ids)
- and node_id = #{nodeId}::uuid
- )
- </if>
- <if test="gradeKind != null and gradeKind != ''">
- AND grade_kind = #{gradeKind}
- </if>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <select id="countProductGrade" resultType="Long">
- select count(1)
- from mst.t_product_grade
- where flg_valid
- and fty_id = #{ftyId}
- <if test="gradeCode != null and gradeCode != ''">
- AND position (#{gradeCode} in grade_code)>0
- </if>
- <if test="gradeName != null and gradeName != ''">
- AND position (#{gradeName} in grade_name)>0
- </if>
- <if test="nodeId != null and nodeId != ''">
- AND exists (
- select 1 from pdm.t_process_node
- where grade_id = any(judge_grade_ids)
- and node_id = #{nodeId}::uuid
- )
- </if>
- <if test="gradeKind != null and gradeKind != ''">
- AND grade_kind = #{gradeKind}
- </if>
- </select>
- <!-- 查询工艺流程(放大镜分页)-->
- <select id="getProcessFlow" resultType="java.util.Map">
- select
- tpf.flow_id as "flowId",
- tpf.flow_code as "flowCode",
- tpf.flow_name as "flowName"
- from pdm.t_process_flow as tpf
- where tpf.flg_valid
- and tpf.fty_id = #{ftyId}
- <if test="flowCode != null and flowCode != ''">
- AND position (#{flowCode} in flow_code)>0
- </if>
- <if test="flowName != null and flowName != ''">
- AND position (#{flowName} in flow_name)>0
- </if>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 查询工艺流程数量-->
- <select id="getProcessFlowCount" resultType="Long">
- select
- count(1)
- from pdm.t_process_flow as tpf
- where tpf.flg_valid
- and tpf.fty_id = #{ftyId}
- <if test="flowCode != null and flowCode != ''">
- AND position (#{flowCode} in flow_code)>0
- </if>
- <if test="flowName != null and flowName != ''">
- AND position (#{flowName} in flow_name)>0
- </if>
- </select>
- <!-- 查询产品分类(分页)-->
- <select id="getModelCategoryPage" resultType="java.util.Map">
- select tmc.category_id AS "categoryId",
- tmc.category_code AS "categoryCode",
- tmc.category_name AS "categoryName",
- tmc.level_name AS "levelName",
- sys.f_get_name_i18n_lang(tdk.kind_name_i18n,#{i18n}) AS "modelKindName"
- from mst.t_model_category tmc
- inner join sys.t_data_kind tdk
- on tdk.kind_code = tmc.model_kind
- where tmc.fty_id = #{ftyId}
- and tmc.flg_valid
- <if test="categoryName != null and categoryName != ''">
- AND position (#{categoryName} in tmc.category_name)>0
- </if>
- <if test="categoryCode != null and categoryCode != ''">
- AND position (#{categoryCode} in tmc.category_code)>0
- </if>
- <if test="modelKind != null and modelKind != ''">
- AND #{modelKind} = tmc.model_kind
- </if>
- <if test="levelNo != null and levelNo != ''">
- AND tmc.level_no=#{levelNo}
- </if>
- <if test="levelLeaf != null and levelLeaf">
- And tmc.level_leaf
- </if>
- order by tmc.display_no
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 查询产品分类(数量)-->
- <select id="getModelCategoryCount" resultType="Long">
- select count(1)
- from mst.t_model_category tmc
- inner join sys.t_data_kind tdk
- on tdk.kind_code = tmc.model_kind
- where tmc.fty_id = #{ftyId}
- and tmc.flg_valid
- <if test="categoryName != null and categoryName != ''">
- AND position (#{categoryName} in tmc.category_name)>0
- </if>
- <if test="categoryCode != null and categoryCode != ''">
- AND position (#{categoryCode} in tmc.category_code)>0
- </if>
- <if test="modelKind != null and modelKind != ''">
- AND position (#{modelKind} in tmc.model_kind)>0
- </if>
- <if test="levelNo != null and levelNo != ''">
- AND tmc.level_no=#{levelNo}
- </if>
- <if test="levelLeaf != null and levelLeaf">
- And tmc.level_leaf
- </if>
- </select>
- <!-- 查询打印机-->
- <select id="getLabelPrinter" resultType="java.util.Map">
- select mlp.printer_id as "printerId",
- mlp.printer_name as "printerName",
- mlp.printer_code as "printerCode",
- mlp.printer_ip as "printerIp"
- from mst.t_label_printer as mlp
- where mlp.flg_valid
- and mlp.fty_id = #{ftyId}
- </select>
- <!-- 查询打印模板 -->
- <select id="getLabelPrintLayout" resultType="java.util.Map">
- select
- lpl.layout_id as "layoutId",
- lpl.layout_name as "layoutName"
- from mst.t_label_print_layout as lpl
- where lpl.flg_valid
- and lpl.fty_id = #{ftyId}
- <if test="printType != null">
- and lpl.print_type = #{printType}
- </if>
- </select>
- <select id="getTeamStaff" resultType="java.util.Map">
- select ts.staff_id as "staffId", ts.staff_code as "staffCode", ts.staff_name as "staffName",
- sys.f_code_name(ts.staff_code,ts.staff_name) AS "staffCodeName",
- ts.job_id as "jobId", tj.job_name as "jobName"
- <if test="userId!=null">
- ,
- (
- select 1 from core.t_work_team twt2
- where twt2.user_id = #{userId} and twt2.staff_id = ts.staff_id
- and twt2.flg_valid and twt2.fty_id = #{ftyId}
- ) is not null as "defaultFlag"
- </if>
- from core.t_staff ts
- left join core.t_job AS tj on ts.job_id = tj.job_id
- where exists(
- select 1
- from core.t_work_team twt
- where ts.staff_id = any (twt.staff_ids)
- <if test="userId!=null">
- and twt.user_id = #{userId}
- </if>
- )
- <if test="jobId!=null">
- and tj.job_id = #{jobId}
- </if>
- and ts.flg_valid
- and ts.fty_id = #{ftyId}
- order by ts.staff_code
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <select id="countTeamStaff" resultType="Long">
- select count(1)
- from core.t_staff ts
- where exists(
- select 1
- from core.t_work_team twt
- where ts.staff_id = any (twt.staff_ids)
- <if test="userId!=null">
- and user_id = #{userId}
- </if>
- )
- and ts.flg_valid
- and ts.fty_id = #{ftyId}
- </select>
- <!-- 获取结转账务月开始日期,结束日期 -->
- <select id="selectAccountDate" resultType="String">
- SELECT sys.f_get_account_date(#{accountDay}, #{month}::date)
- </select>
- <!-- 工位(工位打卡选择工位,工号未绑定工位时,获取工序工号绑定的工位)-->
- <select id="getWsStationByNode" resultType="java.util.Map">
- select distinct tws.station_id as "stationId",
- tws.station_code as "stationCode",
- tws.station_name as "stationName"
- from pdm.t_process_node_user as tpnu
- inner join pdm.t_work_station as tws
- on tpnu.node_id = tws.flow_node_id
- where tpnu.flg_valid
- and tpnu.fty_id = #{ftyId}
- and tws.flg_valid
- and tws.fty_id = #{ftyId}
- <if test="userId != null and userId != ''">
- And #{userId} = tpnu.user_id
- </if>
- </select>
- <!-- 工位(工位打卡选择工位,工位未绑定工序和用户)-->
- <select id="getWsStationNoUser" resultType="java.util.Map">
- select distinct tws.station_id as "stationId",
- tws.station_code as "stationCode",
- tws.station_name as "stationName"
- from pdm.t_work_station as tws
- where tws.flg_valid
- and tws.fty_id = #{ftyId}
- and not exists(select 1
- from pdm.t_work_station_user as twsu
- where twsu.flg_valid
- and twsu.fty_id = #{ftyId}
- and twsu.station_id = tws.station_id)
- and not exists(select 1
- from pdm.t_process_node_user as tpnu
- where tpnu.flg_valid
- and tpnu.fty_id = #{ftyId}
- and tpnu.node_id = tws.flow_node_id)
- </select>
- <!-- 获取湿温度计(分页)-->
- <select id="thmeterRecordByPage" resultType="java.util.Map">
- select
- mtt.unique_id AS "thmeterId",
- mtt.thmeter_name AS "thmeterName",
- mtt.unique_code AS "thmeterCode",
- sys.f_get_name_i18n_lang(tdk.kind_name_i18n,#{i18n}) AS "modelKindName",
- mtu.user_name AS "manageUserName"
- from mst.t_thmeter mtt
- inner join sys.t_data_kind tdk
- on tdk.kind_code = mtt.model_kind
- left join core.t_user mtu
- on mtt.manage_user = mtu.user_id
- where mtt.fty_id = #{ftyId}
- and mtt.flg_valid
- <if test="thmeterName != null and thmeterName != ''">
- AND position (#{thmeterName} in mtt.thmeter_name)>0
- </if>
- <if test="thmeterCode != null and thmeterCode != ''">
- AND position (#{thmeterCode} in mtt.unique_code)>0
- </if>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 获取湿温度计(数量)-->
- <select id="getThmeterRecordByCount" resultType="Long">
- select count(1)
- from mst.t_thmeter mtt
- inner join sys.t_data_kind tdk
- on tdk.kind_code = mtt.model_kind
- left join core.t_user mtu
- on mtt.manage_user = mtu.user_id
- where mtt.fty_id = #{ftyId}
- and mtt.flg_valid
- <if test="thmeterName != null and thmeterName != ''">
- AND position (#{thmeterName} in mtt.thmeter_name)>0
- </if>
- <if test="thmeterCode != null and thmeterCode != ''">
- AND position (#{thmeterCode} in mtt.unique_code)>0
- </if>
- </select>
- <!-- 获取湿温度计-->
- <select id="getThmeterRecord" resultType="java.util.Map">
- select
- mtt.unique_id AS "thmeterId",
- mtt.thmeter_name AS "thmeterName",
- mtt.unique_code AS "thmeterCode",
- sys.f_get_name_i18n_lang(tdk.kind_name_i18n,#{i18n}) AS "modelKindName",
- mtu.user_name AS "manageUserName"
- from mst.t_thmeter mtt
- inner join sys.t_data_kind tdk
- on tdk.kind_code = mtt.model_kind
- left join core.t_user mtu
- on mtt.manage_user = mtu.user_id
- where mtt.fty_id = #{ftyId}
- and mtt.flg_valid
- <if test="thmeterName != null and thmeterName != ''">
- AND position (#{thmeterName} in mtt.thmeter_name)>0
- </if>
- <if test="thmeterCode != null and thmeterCode != ''">
- AND position (#{thmeterCode} in mtt.unique_code)>0
- </if>
- </select>
- <!--查询用于隐藏列信息-->
- <select id="getUserTableInfo" resultType="java.util.Map">
- select tuts.code,
- tuts.table_type AS "tableType",
- tuts.table_ref AS "tableRef",
- tuts.columns
- from pset.t_user_table_set tuts
- where tuts.flg_valid
- and tuts.user_id = #{userId};
- </select>
- <!-- 查询标签打印项目 -->
- <select id="getLabelPrintItem" resultType="java.util.Map">
- select
- item_code as "itemCode",
- sys.f_get_name_i18n_lang(item_name_i18n,#{i18n}) "itemName",
- item_style as "itemStyle",
- item_sample as "itemSample",
- data_key as "dataKey",
- item_tag as "itemTag",
- remarks as "remarks"
- from sys.t_label_print_item
- where flg_valid
- <if test="labelKind">
- and label_kind = #{labelKind}
- </if>
- order by display_no
- </select>
- <!--查用户功能权限-->
- <select id="getUserFunction" resultType="java.util.Map">
- select appm.menu_uuid AS "menuUuid"
- , appm.menu_name as name
- , sys.f_get_name_i18n_lang(appm.menu_name_i18n, #{i18n}) as "menuName"
- , rr.fun_uuid AS "funUuid"
- , appm.object_code AS "objectCode"
- , appm.menu_type AS "menuType"
- from sys.t_app_menu appm
- inner join core.t_user_fun rr
- on rr.fun_uuid = appm.fun_uuid
- where appm.flg_valid
- and appm.app_code = #{appCode}
- and appm.menu_type IN (1, 2)
- and rr.user_id = #{userId};
- </select>
- <!--查用户功能权限-->
- <select id="getUserFunctionAdmin" resultType="java.util.Map">
- select appm.menu_uuid AS "menuUuid"
- , appm.menu_name as name
- , sys.f_get_name_i18n_lang(appm.menu_name_i18n, #{i18n}) as "menuName"
- , appm.fun_uuid AS "funUuid"
- , appm.object_code AS "objectCode"
- , appm.menu_type AS "menuType"
- from sys.t_app_menu appm
- where appm.flg_valid
- and appm.app_code = #{appCode}
- and appm.menu_type IN (1, 2);
- </select>
- <!--查导航菜单(自定义报表用)-->
- <select id="getMenuNavigation" resultType="java.util.Map">
- select appm.menu_uuid AS "menuUuid"
- ,sys.f_get_name_i18n_lang(appm.menu_name_i18n,#{i18n}) as "menuName"
- ,appm.parent_uuid AS "parentUuid"
- from sys.t_app_menu appm
- where appm.flg_valid
- <if test="parentUuid">
- and appm.parent_uuid = #{parentUuid} ::uuid
- </if>
- and appm.app_code = 'WEB-MAIN'
- and appm.menu_type = 0
- </select>
- <!-- 获取员工用于报工记录查询(分页)-->
- <select id="getStaffWithWorkByPage" resultType="java.util.Map">
- select
- twt.team_id as "teamId",
- twt.user_id as "userId",
- twt.wt_job_id as "jobId",
- tj.job_name as "jobName",
- cts.staff_id as "staffId",
- cts.staff_code as "staffCode",
- cts.staff_name as "staffName"
- from core.t_work_team twt
- inner join core.t_job tj on twt.wt_job_id = tj.job_id
- left join core.t_staff cts on cts.staff_id = any (twt.staff_ids)
- where twt.flg_valid and cts.flg_valid
- and twt.user_id = #{userId}
- <if test="jobId != null">
- AND #{jobId} = twt.wt_job_id
- </if>
- <if test="staffCode != null and staffCode != ''">
- AND position(#{staffCode} in cts.staff_code) > 0
- </if>
- order by twt.display_no
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 获取员工用于报工记录查询(数量)-->
- <select id="getStaffWithWorkByCount" resultType="Long">
- select count(1)
- from core.t_work_team twt
- inner join core.t_job tj on twt.wt_job_id = tj.job_id
- left join core.t_staff cts on cts.staff_id = any (twt.staff_ids)
- where twt.flg_valid and cts.flg_valid
- and twt.user_id = #{userId}
- <if test="jobId != null">
- AND #{jobId} = twt.wt_job_id
- </if>
- <if test="staffCode != null and staffCode != ''">
- AND position(#{staffCode} in cts.staff_code) > 0
- </if>
- </select>
- <!-- 获取数据字典项目 -->
- <select id="getDictionaryItemData" resultType="java.util.Map">
- SELECT stdi.dict_code AS "dictCode",
- sys.f_get_name_i18n_lang(stdi.dict_name_i18n, 'zh_CN') AS "dictName"
- FROM sys.t_dictionary_item stdi
- WHERE stdi.flg_valid
- AND stdi.level_no NOT IN ('1')
- </select>
- <select id="getLabelPrintTypeKind" resultType="java.util.Map">
- SELECT kind_code as "kindCode", sys.f_get_name_i18n_lang(kind_name_i18n, #{i18n}) as "kindName"
- FROM sys.t_data_kind t
- where t.kind_type = '型号种类'
- and t.kind_tags - > 'used' ?? '标签' and flg_valid
- order by t.display_no
- </select>
- <select id="getModelProductLabelType" resultType="java.util.Map">
- SELECT kind_code as "kindCode", sys.f_get_name_i18n_lang(kind_name_i18n, #{i18n}) as "kindName"
- from sys.t_data_kind t
- where t.kind_type = '验证标签'
- and (t.kind_tags ->>'source') = '产品型号'
- </select>
- <!-- 获取窑炉类型 -->
- <select id="getKilnType" resultType="java.util.Map">
- select
- model_id AS "modelId",
- model_code AS "modelCode",
- model_name AS "modelName"
- from mst.t_model_type_kiln
- where fty_id = #{ftyId}
- and flg_valid
- order by model_code
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 获取成型线类型 -->
- <select id="getMoldlineType" resultType="java.util.Map">
- select
- model_id AS "modelId",
- model_code AS "modelCode",
- model_name AS "modelName"
- from mst.t_model_type_moldline
- where fty_id = #{ftyId}
- and flg_valid
- order by model_code
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 获取物料编码 -->
- <select id="getModelMaterialByPage" resultType="java.util.Map">
- select mtmm.model_id as "modelId",
- mtmm.model_code as "modelCode",
- mtmm.model_name as "modelName",
- sys.f_code_name(model_code,model_name) AS "codeName",
- mtmc.category_name AS "categoryName",
- mtmc.category_code AS "categoryCode",
- mtmc.level_name AS "levelName"
- from mst.t_model_material mtmm
- left join mst.t_model_category mtmc on mtmc.category_id = mtmm.model_category
- where mtmm.fty_id = #{ftyId}
- and mtmm.flg_valid
- <if test="modelCode != null and modelCode != ''">
- (And position (#{modelCode} in mtmm.model_code)>0
- OR position (#{modelCode} in mtmm.model_name)>0)
- </if>
- order by mtmm.model_code
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 获取物料编码 -->
- <select id="getModelMaterialCountByPage" resultType="Long">
- select count(1)
- from mst.t_model_material mtmm
- left join mst.t_model_category mtmc on mtmc.category_id = mtmm.model_category
- where mtmm.fty_id = #{ftyId}
- and mtmm.flg_valid
- <if test="modelCode != null and modelCode != ''">
- (And position (#{modelCode} in mtmm.model_code)>0
- OR position (#{modelCode} in mtmm.model_name)>0)
- </if>
- </select>
- <!-- 获取物料编码 -->
- <select id="getModelMaterial" resultType="java.util.Map">
- select model_id as "modelId",
- model_code as "modelCode",
- model_name as "modelName",
- model_specs as "modelSpecs", model_place as "modelPlace",
- sys.f_code_name(model_code,model_name) AS "codeName",
- mtmc.category_name AS "categoryName",
- mtmc.category_code AS "categoryCode",
- tmu.unit_name as "unitName"
- from mst.t_model_material mtmm
- left join mst.t_model_category mtmc on mtmc.category_id = mtmm.model_category
- left join mst.t_model_units tmu on tmu.unit_id = mtmm.unit_id
- where mtmm.fty_id = #{ftyId}
- and mtmm.flg_valid
- <if test="modelCode != null and modelCode != ''">
- And position (#{modelCode} in mtmm.model_code)>0
- </if>
- order by mtmm.model_code
- </select>
- <!-- 产品信息数量-->
- <select id="getProductForChangeNoPage" resultType="java.util.Map">
- select
- pdtCode.pdt_unique_id as "pdtUniqueId",--产品唯一码
- pdtCode.pdt_code_kind as "pdtCodeKind", --条码类型
- product.model_id as "modelId", --型号Id
- product.pdt_flow_node_id as "nodeId", --节点Id
- pdtCode.pdt_barcode as "pdtBarcode", --产品条码
- (select string_agg(pdtCodeHis.pdt_barcode, ' | ')
- from pdm.t_product_code_his as pdtCodeHis
- where pdtCodeHis.pdt_unique_id = product.unique_id)
- as "hisPdtCodes", --历史条码
- mLine.unique_code as "moldLineCode",--成型线编码
- mLine.moldline_name as "moldLineName", --成型线名称
- mItem.molding_date as "moldingDate",--成型日期
- mItem.molding_batch as "moldingBatch",--注浆批次
- mu.user_code as "moldingUser",--成型工号
- sys.f_code_name(mu.user_code,mu.user_name) AS "moldingUserCodeName",--成型工号
- mItem.molding_user as "moldingUserID",
- sys.f_code_name(mp.model_code,mp.model_name) AS "productUniqueCode",--产品编码名称
- mItem.moldline_item_code as "mouldUniqueCode", --模具编号
- sys.f_get_name_i18n_lang(dataKind.kind_name_i18n,#{i18n}) as "mouldKind",--模具状态
- mItem.this_molded_num as "moldedNum", --成型次数
- manageUser.user_name as "manageUserName", --成型班长
- sys.f_code_name(manageUser.user_code,manageUser.user_name) AS "manageUserCodeName",--成型班长
- product.render_m_time as "renderMTime", --交坯时间
- node.node_name as "nodeName",--工序名称
- product.finish_time as "finishTime" -- 完成时间
- from pdm.t_product as product
- inner join pdm.t_product_code as pdtCode
- on product.unique_id = pdtCode.pdt_unique_id
- left join pdm.t_molding_item as mItem
- on mItem.item_id = product.molding_item_id
- left join mst.t_moldline as mLine
- on mItem.moldline_id = mLine.unique_id
- left join core.t_user as mu
- on mu.user_id = mItem.molding_user
- left join mst.t_mould as mould
- on mItem.mould_id = mould.unique_id
- left join sys.t_data_kind as dataKind
- on mould.mould_kind = dataKind.kind_code
- left join pdm.t_molding as molding
- on molding.molding_id = mItem.molding_id
- left join core.t_user as manageUser
- on molding.manage_user = manageUser.user_id
- left join pdm.t_process_node as node
- on product.pdt_flow_node_id = node.node_id
- inner join mst.t_model_product as mp
- on product.model_id = mp.model_id
- where product.fty_id = #{ftyId}
- and product.flg_valid
- <!--条码值等查询-->
- <if test="pdtBarcodeEqual != null and pdtBarcodeEqual != ''">
- and #{pdtBarcodeEqual} = pdtCode.pdt_barcode
- </if>
- <if test="productUniqueCodeEqual != null and productUniqueCodeEqual != ''">
- and #{productUniqueCodeEqual} = mp.model_code
- </if>
- <if test="moldingUserEqual != null and moldingUserEqual != ''">
- and #{moldingUserEqual} = mu.user_code
- </if>
- <if test="moldLineCode != null and moldLineCode != '' and pdaFlag != 1">
- and position (#{moldLineCode} in mLine.unique_code)>0
- </if>
- <if test="moldLineCode != null and pdaFlag == 1">
- and mLine.unique_code = #{moldLineCode}
- </if>
- <if test="moldLineName != null and moldLineName != ''">
- and position (#{moldLineName} in mLine.moldline_name)>0
- </if>
- <if test="mouldUniqueCode != null and mouldUniqueCode != ''">
- and position(#{mouldUniqueCode} in mould.unique_code )>0
- </if>
- <if test="productUniqueCode != null and productUniqueCode != '' and pdaFlag != 1">
- and position(#{productUniqueCode} in product.unique_code)>0
- </if>
- <if test="productUniqueCode != null and pdaFlag == 1">
- and product.unique_code = #{productUniqueCode}
- </if>
- <if test="moldingUser != null and moldingUser != ''">
- and position(#{moldingUser} in mu.user_code ) >0
- </if>
- <if test="pdtBarcode != null and pdtBarcode != ''">
- and position(#{pdtBarcode} in pdtCode.pdt_barcode)>0
- </if>
- <if test="renderMTimeStart != null and renderMTimeStart != ''">
- and product.render_m_time >=#{renderMTimeStart}
- </if>
- <if test="renderMTimeEnd != null and renderMTimeEnd != ''">
- and product.render_m_time <=#{renderMTimeEnd}
- </if>
- <if test="moldingDateStart != null and moldingDateStart != ''">
- and mItem.molding_date >=#{moldingDateStart}
- </if>
- <if test="moldingDateEnd != null and moldingDateEnd != ''">
- and mItem.molding_date <= #{moldingDateEnd}
- </if>
- <if test="moldingLastDate != null and moldingLastDate != ''">
- and mItem.molding_date = CAST( #{moldingLastDate} as date)
- </if>
- <if test="moldingBatch != null and moldingBatch != ''">
- and mItem.molding_batch = #{moldingBatch}
- </if>
- <if test="limit != null and limit != 0 ">
- limit #{limit}
- </if>
- </select>
- <!-- 获取计量单位 -->
- <select id="getModelUnits" resultType="java.util.Map">
- select tmu.unit_id AS "unitId",
- tmu.unit_code as "unitCode",
- tmu.unit_name as "unitName",
- tmu.unit_scale as "unitScale"
- from mst.t_model_units as tmu
- where tmu.flg_valid
- and tmu.fty_id = #{ftyId}
- order by tmu.display_no
- </select>
- <!-- 获取产品型号、物料型号 -->
- <select id="getModelBase" resultType="java.util.Map">
- select
- tmb.model_id as "modelId",
- tmb.model_kind as "modelKind",
- tmb.model_code as "modelCode",
- tmb.model_name as "modelName"
- from mst.t_model_base tmb
- where tmb.fty_id = #{ftyId}
- and flg_valid
- and tmb.model_kind in ('型号种类-产品','型号种类-物料')
- <if test="modelCode != null and userCode != ''">
- And position (#{modelCode} in tmb.model_code)>0
- </if>
- <if test="modelName != null and modelName != ''">
- And position (#{modelName} in tmb.model_name)>0
- </if>
- ORDER BY tmb.model_code
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <select id="countModelBase" resultType="Long">
- select count(1)
- from mst.t_model_base tmb
- where tmb.fty_id = #{ftyId}
- and flg_valid
- and tmb.model_kind in ('型号种类-产品','型号种类-物料')
- <if test="modelCode != null and userCode != ''">
- And position (#{modelCode} in tmb.model_code)>0
- </if>
- <if test="modelName != null and modelName != ''">
- And position (#{modelName} in tmb.model_name)>0
- </if>
- </select>
- <!-- 获取报工项目-->
- <select id="getWorkProject" resultType="java.util.Map">
- select p.project_id as "projectIid",
- p.project_code as "projectCode",
- p.project_name as "projectName",
- p.project_kind as "projectKind",
- sys.f_get_name_i18n_lang(tdk.kind_name_i18n, #{i18n}) as "projectkindName",
- p.item_kind as "itemKind",
- p.station_id as "stationId",
- p.pdt_grades as "pdtGrades",
- p.pdt_defects as "pdtDefects",
- p.remarks
- from mst.t_work_project p
- left join sys.t_data_kind as tdk
- on p.project_kind = tdk.kind_code
- where p.flg_valid
- and p.fty_id = #{ftyId}
- </select>
- <!-- 获取报工项目-->
- <select id="getWorkProjectByPage" resultType="java.util.Map">
- select p.project_id as "projectId",
- p.project_code as "projectCode",
- p.project_name as "projectName",
- p.project_kind as "projectKind",
- sys.f_get_name_i18n_lang(tdk.kind_name_i18n,#{i18n}) as "projectKindName",
- p.item_kind as "itemKind",
- p.station_id as "stationId",
- p.pdt_grades as "pdtGrades",
- p.pdt_defects as "pdtDefects",
- p.remarks
- from mst.t_work_project p
- left join sys.t_data_kind as tdk
- on p.project_kind = tdk.kind_code
- where p.flg_valid
- and p.fty_id = #{ftyId}
- <if test="projectCode != null and projectCode != ''">
- And position (#{projectCode} in p.project_code)>0
- </if>
- <if test="projectName != null and projectName != ''">
- And position (#{projectName} in p.project_name)>0
- </if>
- ORDER BY p.display_no
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <select id="getWorkProjectCountByPage" resultType="Long">
- select count(1)
- from mst.t_work_project p
- where p.flg_valid
- and p.fty_id = #{ftyId}
- <if test="projectCode != null and projectCode != ''">
- And position (#{projectCode} in p.project_code)>0
- </if>
- <if test="projectName != null and projectName != ''">
- And position (#{projectName} in p.project_name)>0
- </if>
- </select>
- <!-- 查询产品缺陷-->
- <select id="getProductDefects" resultMap="getProductDefectMap">
- select tpd.defect_id AS "defectId",
- tpd.defect_name AS "defectName",
- tpd.defect_code AS "defectCode",
- sys.f_code_name(tpd.defect_code,tpd.defect_name) AS "codeName",
- tpd.defect_types as "defectTypes",
- (
- select json_agg(jsonb_build_object('fineId', fine_id, 'fineName', fine_name,
- 'deductNum', deduct_num,'fineCodeName',sys.f_code_name(fine_code,fine_name)))
- from mst.t_product_defect_fine
- where fine_id = any(tpd.defect_fines)
- ) as "defectFines"
- from mst.t_product_defect tpd
- where tpd.fty_id = #{ftyId}
- and tpd.flg_valid
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <select id="countProductDefects" resultType="Long">
- select count(1)
- from mst.t_product_defect tpd
- where tpd.fty_id = #{ftyId}
- and tpd.flg_valid
- </select>
- <!-- 获取应用-->
- <select id="getApplication" resultType="java.util.Map">
- select app_code as "appCode",
- app_name as "appName"
- from sys.t_application
- </select>
- <!--获取产品-->
- <select id="getProduct" resultType="java.util.Map">
- select unique_code as "productCode",
- unique_id as "productId"
- from pdm.t_product
- where fty_id = #{ftyId}
- and unique_code = #{productCode}
- </select>
- <!--获取工位打印机-->
- <select id="getWsPrinter" resultType="java.util.Map">
- select ptwp.wsp_id as "wspId",
- ptwp.printer_id as "printerId",
- mtlp.printer_code as "printerCode",
- mtlp.printer_name as "printerName",
- sys.f_code_name(mtlp.printer_code, mtlp.printer_name) AS "printerCodeName"
- from pdm.t_ws_printer ptwp
- left join mst.t_label_printer mtlp on mtlp.printer_id = ptwp.printer_id
- where ptwp.fty_id = #{ftyId}
- and ptwp.station_id = #{stationId}
- and ptwp.flg_valid
- </select>
- <!-- 获取仓库 -->
- <select id="getWarehouse" resultType="java.util.Map">
- SELECT tmw.wh_id as "whId"
- ,tmw.wh_name as "whName"
- ,tmw.wh_code as "whCode"
- FROM dkic_b.t_mst_warehouse tmw
- WHERE tmw.cp_id = #{cpId}
- and tmw.flg_valid
- <if test="whCode!=null and whCode!=''">
- and position(#{whCode} in tmw.wh_code) > 0
- </if>
- <if test="whName!=null and whName!=''">
- and position(#{whName} in tmw.wh_name) > 0
- </if>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!--获取仓库-->
- <select id="getWarehouseByPage" resultType="java.util.Map">
- SELECT mtw.wh_id as "whId",sys.f_code_name(mtw.wh_code,mtw.wh_name) AS "whCodeName"
- FROM mst.t_warehouse mtw left join core.t_user ctu on ctu.user_id = mtw.op_create_user_id
- WHERE mtw.fty_id = #{ftyId}
- and mtw.flg_valid
- <if test="whCode!=null and whCode!=''">
- and position(#{whCode} in mtw.wh_code) > 0
- </if>
- <if test="whName!=null and whName!=''">
- and position(#{warehouseName} in mtw.wh_name) > 0
- </if>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!--获取仓库个数-->
- <select id="countWarehouseByPage" resultType="Long">
- select count(1)
- from mst.t_warehouse mtw
- WHERE mtw.fty_id = #{ftyId}
- and mtw.flg_valid
- <if test="whCode!=null and whCode!=''">
- and position(#{whCode} in mtw.wh_code) > 0
- </if>
- <if test="whName!=null and whName!=''">
- and position(#{warehouseName} in mtw.wh_name) > 0
- </if>
- </select>
- <!--获取仓位-->
- <select id="getWarehousePlaceByPage" resultType="java.util.Map">
- SELECT mtwp.place_id as "placeId", mtwp.place_name as "placeName",
- sys.f_code_name(mtw.wh_code,mtw.wh_name) AS "whCodeName"
- FROM mst.t_warehouse_place mtwp
- left join mst.t_warehouse mtw on mtw.wh_id = mtwp.wh_id
- WHERE mtwp.fty_id = #{ftyId}
- and mtwp.flg_valid
- <if test="whId!=null">
- and mtwp.wh_id = #{whId}
- </if>
- <if test="placeName!=null and placeName!=''">
- and position(#{placeName} in mtwp.place_name) > 0
- </if>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!--获取仓位个数-->
- <select id="countWarehousePlaceByPage" resultType="Long">
- select count(1)
- FROM mst.t_warehouse_place mtwp
- WHERE mtwp.fty_id = #{ftyId}
- and mtwp.flg_valid
- <if test="whId!=null">
- and mtwp.wh_id = #{whId}
- </if>
- <if test="placeName!=null and placeName!=''">
- and position(#{placeName} in mtwp.place_name) > 0
- </if>
- </select>
- <!--获取单据-->
- <select id="getDoc" resultType="java.util.Map">
- SELECT
- tsd.doc_code AS "docCode",
- sys.f_get_name_i18n_lang ( tsd.doc_name_i18n, #{i18n}) AS "docName"
- FROM
- sys.t_s_doc tsd
- WHERE
- tsd.flg_valid
- <if test="flgApproval!=null">
- and tsd.flg_approval = #{flgApproval}
- </if>
- </select>
- <!--获取下拉选-->
- <select id="getSelectType" resultType="java.util.Map">
- SELECT select_id as "selectId",
- select_name as "selectName"
- FROM mst.t_custom_select_type
- WHERE fty_id = #{ftyId}
- and flg_valid
- </select>
- <!--获取下拉选-->
- <select id="getSelectMagnifier" resultType="java.util.Map">
- SELECT magnifier_id as "magnifierId",
- magnifier_name as "magnifierName"
- FROM mst.t_custom_select_magnifier
- WHERE fty_id = #{ftyId}
- and flg_valid
- </select>
- <!--获取理化检验单-->
- <select id="getPhysicalCollectByPage" resultType="java.util.Map">
- SELECT collect_id as "collectId", collect_no as "collectNo"
- FROM sht.t_check_collect_rmat
- WHERE fty_id = #{ftyId}
- and flg_valid
- <if test="collectNo!=null and collectNo!=''">
- and position(#{collectNo} in collect_no) > 0
- </if>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!--获取理化检验单个数-->
- <select id="countPhysicalCollectByPage" resultType="Long">
- select count(1)
- FROM sht.t_check_collect_rmat
- WHERE fty_id = #{ftyId}
- and flg_valid
- <if test="collectNo!=null and collectNo!=''">
- and position(#{collectNo} in collect_no) > 0
- </if>
- </select>
- <!--获取生产工单-->
- <select id="getSheetProduceByPage" resultType="java.util.Map">
- SELECT tsp.produce_id as "produceId", tsp.produce_no as "produceNo"
- FROM sht.t_sheet_produce tsp
- WHERE tsp.fty_id = #{ftyId}
- and tsp.flg_valid and tsp.produce_status = '工单状态-执行'
- <if test="produceNo!=null and produceNo!=''">
- and position(#{produceNo} in tsp.produce_no) > 0
- </if>
- order by tsp.produce_id desc
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!--获取生产工单个数-->
- <select id="countSheetProduceByPage" resultType="Long">
- select count(1)
- FROM sht.t_sheet_produce
- WHERE fty_id = #{ftyId}
- and flg_valid and produce_status = '工单状态-执行'
- <if test="produceNo!=null and produceNo!=''">
- and position(#{produceNo} in produce_no) > 0
- </if>
- </select>
- <!--获取载具型号分页-->
- <select id="getModelCarrierByPage" resultType="java.util.Map">
- select tmc.model_id AS "modelId",
- tmc.model_code as "modelCode",
- tmc.model_name AS "modelName",
- sys.f_code_name(tmc.model_code,tmc.model_name) AS "carModelCodeName",
- tmcg.category_name as "modelCategoryName",
- tmcg.level_name as "modelCategoryLevelName",
- tmc.remarks
- from mst.t_model_carrier as tmc
- left join mst.t_model_category tmcg on tmcg.category_id = tmc.model_category
- where tmc.flg_valid
- and tmc.fty_id = #{ftyId}
- <if test="flgBarcode != null">
- and tmc.flg_barcode = #{flgBarcode}
- </if>
- <if test="modelKind != null">
- and tmc.model_kind = #{modelKind}
- </if>
- <if test="modelCode != null and modelCode != ''">
- And position (#{modelCode} in tmc.model_code)>0
- </if>
- <if test="modelName != null and modelName != ''">
- And position (#{modelName} in tmc.model_name)>0
- </if>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!--获取载具型号个数-->
- <select id="countModelCarrierByPage" resultType="Long">
- select count(1)
- from mst.t_model_carrier as tmc
- left join mst.t_model_category tmcg on tmcg.category_id = tmc.model_category
- where tmc.flg_valid
- and tmc.fty_id = #{ftyId}
- <if test="flgBarcode != null">
- and tmc.flg_barcode = #{flgBarcode}
- </if>
- <if test="modelKind != null">
- and tmc.model_kind = #{modelKind}
- </if>
- <if test="modelCode != null and modelCode != ''">
- And position (#{modelCode} in tmc.model_code)>0
- </if>
- <if test="modelName != null and modelName != ''">
- And position (#{modelName} in tmc.model_name)>0
- </if>
- </select>
- <!-- 获取商品 -->
- <select id="getGoods" resultType="java.util.Map">
- select tmgs.sku_id as "skuId",
- tmgs.sku_code as "skuCode",
- tmgs.sku_name as "skuName",
- tmgs.sku_model as "skuModel",
- tmgs.brand_id as "brandId",
- tmgb.brand_name as "brandName",
- tmgs.category_id as "categoryId",
- tmgc.cat_name as "categoryName",
- tmgs.unit_id as "unitId",
- tmgu.unit_name as "unitName",
- tmgs.sub_unit_id as "subUnitId",
- tmgs.conversion_factor as "conversionFactor",
- tmgs.series_id as "seriesId",
- tmgseries.series_name as "seriesName",
- tmgs.sku_spec as "skuSpec",
- tmgs.price_purchase as "pricePurchase",
- tmgs.price_standard as "priceStandard",
- tmgs.price_wholesale as "priceWholesale",
- tmgs.price_limited as "priceLimited",
- tmgs.sku_images as "skuImages",
- tmgs.remarks
- from dkic_b.t_mst_goods_sku as tmgs
- left join dkic_b.t_mst_goods_brand as tmgb on tmgs.brand_id = tmgb.brand_id
- left join dkic_b.t_mst_goods_category as tmgc on tmgs.category_id = tmgc.cat_id
- left join dkic_b.t_mst_goods_series as tmgseries on tmgs.series_id = tmgseries.series_id
- left join dkic_b.t_mst_unit as tmgu on tmgs.unit_id = tmgu.unit_id
- where tmgs.flg_valid
- <if test="skuCode != null">
- AND tmgs.sku_code = #{skuCode}
- </if>
- <if test="skuName != null">
- AND tmgs.sku_name != #{skuName}
- </if>
- </select>
- <!-- 获取商品个数 -->
- <select id="getGoodsCountByPage" resultType="Long">
- SELECT
- count(1)
- from dkic_b.t_mst_goods_sku as tmgs
- where tmgs.flg_valid
- <if test="skuCode != null">
- AND tmgs.sku_code = #{skuCode}
- </if>
- <if test="skuName != null">
- AND tmgs.sku_name != #{skuName}
- </if>
- </select>
- <!-- 获取客户 -->
- <select id="getCustomer" resultType="java.util.Map">
- select tmc.cus_id as "cusId",
- tmc.cus_code as "cusCode",
- tmc.cus_name as "cusName",
- tmc.cus_phone as "cusPhone",
- tmc.address_area as "addressArea",
- tmc.address_name as "addressName",
- tmc.address_no as "addressNo",
- tmc.address_gcj02 as "addressGcj02",
- tmc.address_full as "addressFull",
- tmc.contact_name as "contactName",
- tmc.contact_phone as "contactPhone",
- tmc.cus_from as "cusFrom",
- tmdd.data_value as "cusFromName",
- tmc.channel_id as "channelId",
- tmsc.channel_name as "channelName",
- tmc.org_id as "orgId",
- tmo.org_name as "orgName",
- tmc.staff_id as "staffId",
- tms.staff_name as "staffName",
- tmc.report_staff as "reportStaff",
- reportstaff.staff_name as "reportStaffName",
- tmc.report_time as "reportTime",
- tmc.sale_status as "saleStatus",
- tmc.remarks as "remarks",
- tmc.follow_staffs as "followStaffs",
- tmc.last_follow_staff as "lastFollowStaff",
- tmc.last_follow_id as "lastFollowId",
- tmc.last_follow_status as "lastFollowStatus",
- tmc.last_follow_time as "lastFollowTime"
- from dkic_b.t_mst_customer as tmc
- inner join dkic_b.t_mst_org tmo on tmc.org_id = tmo.org_id
- inner join dkic_b.t_mst_staff tms on tmc.staff_id = tms.staff_id
- inner join dkic_b.t_mst_staff as reportstaff on tmc.report_staff = reportstaff.staff_id
- inner join dkic_b.t_mst_sale_channel tmsc on tmc.channel_id = tmsc.channel_id
- left join dkic_b.t_mst_dictionary_data tmdd on tmc.cus_from = tmdd.data_id
- where tmc.flg_valid
- <if test="skuCode != null">
- AND tmc.cus_code = #{cusCode}
- </if>
- <if test="skuName != null">
- AND tmc.cus_name != #{cusName}
- </if>
- </select>
- <!-- 获取商品个数 -->
- <select id="getCustomerCountByPage" resultType="Long">
- SELECT
- count(1)
- from dkic_b.t_mst_customer as tmc
- where tmc.flg_valid
- and tmc.cp_id = #{cpId}
- <if test="skuCode != null">
- AND tmc.cus_code = #{cusCode}
- </if>
- <if test="skuName != null">
- AND tmc.cus_name != #{cusName}
- </if>
- </select>
- <!-- 获取单据Id-->
- <select id="getUuidSeq" resultType="object">
- select sys.f_uuid_seq()
- </select>
- <!-- 获取单据单号-->
- <select id="getDocNo" resultType="java.lang.String">
- select dkic_b.f_create_note(#{cpId}, #{purId}::uuid, #{docCode})
- </select>
- <!--获取供应商-->
- <select id="getSupplier" resultType="java.util.Map">
- select tms.sup_code as "supplierCode",
- tms.sup_name as "supplierName",
- tms.sup_id as "supplierId",
- tms.sup_type as "supplierType",
- tms.contact_name as "contactName",
- tms.contact_phone as "contactPhone",
- tms.flg_valid as "flgValid"
- from dkic_b.t_mst_supplier tms
- where tms.cp_id = #{cpId}
- <if test="supplierName!=null and supplierName!=''">
- AND tms.sup_name LIKE concat('%', #{supplierName}, '%')
- </if>
- <if test="supplierCode!=null and supplierCode!=''">
- AND tms.sup_code LIKE concat('%', #{supplierCode}, '%')
- </if>
- <if test="supplierType!=null and supplierType!=''">
- AND tms.sup_type LIKE concat('%', #{supplierType}, '%')
- </if>
- order by tms.sup_code
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- <if test="limit != null and limit != 0 ">
- limit #{limit}
- </if>
- </select>
- <!--获取供应商数量-->
- <select id="countSupplier" resultType="java.lang.Long">
- select count(1)
- from dkic_b.t_mst_supplier tms
- where tms.cp_id = #{cpId}
- <if test="supplierName!=null and supplierName!=''">
- AND tms.sup_name LIKE concat('%', #{supplierName}, '%')
- </if>
- <if test="supplierCode!=null and supplierCode!=''">
- AND tms.sup_code LIKE concat('%', #{supplierCode}, '%')
- </if>
- </select>
- <!--获取渠道 -->
- <select id="getChannel" resultType="java.util.Map">
- select c.channel_id as "channelId",
- c.channel_code as "channelCode",
- c.channel_name as "channelName",
- c.sys_code as "sysCode",
- c.display_no as "displayNo"
- from dkic_b.t_mst_sale_channel as c
- where c.flg_valid
- and c.cp_id = #{cpId}
- <if test="channel_code!=null and channel_code!=''">
- AND c.channel_code LIKE concat('%', #{channelCode}, '%')
- </if>
- <if test="channel_name!=null and channel_name!=''">
- AND c.channel_name LIKE concat('%', #{channelName}, '%')
- </if>
- order by c.display_no
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- <if test="limit != null and limit != 0 ">
- limit #{limit}
- </if>
- </select>
- <select id="getGoodsBrand" resultType="java.util.Map">
- SELECT
- tmgb.flg_valid AS "flgValid",
- tmgb.brand_id AS "brandId", tmgb.brand_code AS "brandCode", tmgb.brand_name AS "brandName",
- (SELECT COALESCE(array_to_string(array_agg(tsm.sup_name), ','),'')
- FROM dkic_b.t_mst_supplier_brand tsmb
- left join dkic_b.t_mst_supplier tsm on tsm.sup_id = tsmb.sup_id
- WHERE tsmb.brand_id = tmgb.brand_id) AS "supplierName"
- FROM dkic_b.t_mst_goods_brand tmgb
- <where>
- <if test="searchText !=null">
- AND tmgb.brand_name LIKE concat('%', #{searchText}, '%')
- </if>
- <if test="cpId != null">
- AND cp_id = #{cpId}
- </if>
- </where>
- order by display_no asc
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 查询表t_mst_goods_brand,(条件查询)个数 -->
- <select id="countGoodsBrand" resultType="Long">
- SELECT
- count(1)
- FROM dkic_b.t_mst_goods_brand tmgb
- <where>
- <if test="searchText !=null">
- AND tmgb.brand_name LIKE concat('%', #{searchText}, '%')
- </if>
- <if test="cpId != null">
- AND cp_id = #{cpId}
- </if>
- </where>
- </select>
- <select id="getGoodsCategory" resultType="java.util.Map">
- SELECT
- cat_id AS "catId",
- cat_code AS "catCode",
- cat_name AS "catName",
- parent_id AS "parentId",
- flg_valid AS "flgValid"
- FROM dkic_b.t_mst_goods_category
- <where>
- <if test="searchText !=null">
- AND ( cat_name LIKE concat('%', #{searchText}, '%')
- or remarks LIKE concat('%', #{searchText}, '%'))
- </if>
- <if test="cpId != null">
- AND cp_id = #{cpId}
- </if>
- </where>
- ORDER BY display_no
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <select id="countGoodsCategory" resultType="java.lang.Long">
- SELECT
- count(1)
- FROM dkic_b.t_mst_goods_category
- <where>
- <if test="searchText !=null">
- AND ( cat_name LIKE concat('%', #{searchText}, '%')
- or remarks LIKE concat('%', #{searchText}, '%'))
- </if>
- <if test="cpId != null">
- AND cp_id = #{cpId}
- </if>
- </where>
- </select>
- <select id="getGoodsSeries" resultType="java.util.Map">
- SELECT
- series_id AS "seriesId",
- series_code AS "seriesCode",
- series_name AS "serieName",
- flg_valid AS "flgValid"
- FROM dkic_b.t_mst_goods_series
- <where>
- <if test="searchText !=null">
- AND ( series_name LIKE concat('%', #{searchText}, '%')
- or remarks LIKE concat('%', #{searchText}, '%'))
- </if>
- <if test="cpId != null">
- AND cp_id = #{cpId}
- </if>
- </where>
- order by display_no asc
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <select id="countGoodsSeries" resultType="java.lang.Long">
- SELECT
- count(1)
- FROM dkic_b.t_mst_goods_series
- <where>
- <if test="searchText !=null">
- AND ( series_name LIKE concat('%', #{searchText}, '%')
- or remarks LIKE concat('%', #{searchText}, '%'))
- </if>
- <if test="cpId != null">
- AND cp_id = #{cpId}
- </if>
- </where>
- </select>
- <select id="getUnit" resultType="java.util.Map">
- SELECT
- unit_id AS "unitId",
- unit_code AS "unitCode",
- unit_name AS "unitName",
- decimal_places AS "decimalPlaces",
- flg_valid AS "flgValid"
- FROM dkic_b.t_mst_unit
- <where>
- <if test="searchText !=null">
- AND ( unit_name LIKE concat('%', #{searchText}, '%')
- or remarks LIKE concat('%', #{searchText}, '%'))
- </if>
- <if test="cpId != null">
- AND cp_id = #{cpId}
- </if>
- </where>
- order by display_no asc
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <select id="countUnit" resultType="java.lang.Long">
- SELECT
- count(1)
- FROM dkic_b.t_mst_unit
- <where>
- <if test="searchText !=null">
- AND ( unit_name LIKE concat('%', #{searchText}, '%')
- or remarks LIKE concat('%', #{searchText}, '%'))
- </if>
- <if test="cpId != null">
- AND cp_id = #{cpId}
- </if>
- </where>
- </select>
- <!--获取仓库档案-->
- <select id="getWarehouseByPage" resultType="java.util.Map">
- SELECT
- wh_id AS "whId",
- wh_code AS "whCode",
- wh_name AS "whName",
- supervisor AS "supervisor",
- contact_phone AS "contactPhone",
- flg_valid AS "flgValid"
- FROM dkic_b.t_mst_warehouse
- <where>
- <if test="searchText !=null">
- AND ( wh_name LIKE concat('%', #{searchText}, '%')
- or remarks LIKE concat('%', #{searchText}, '%'))
- </if>
- <if test="cpId != null">
- AND cp_id = #{cpId}
- </if>
- </where>
- order by display_no asc
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!--获取仓库档案个数-->
- <select id="countWarehouseByPage" resultType="Long">
- SELECT
- count(1)
- FROM dkic_b.t_mst_warehouse
- <where>
- <if test="searchText !=null">
- AND ( wh_name LIKE concat('%', #{searchText}, '%')
- or remarks LIKE concat('%', #{searchText}, '%'))
- </if>
- <if test="cpId != null">
- AND cp_id = #{cpId}
- </if>
- </where>
- </select>
- </mapper>
|