| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961 |
- <?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="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
- <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.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>
- 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>
- </mapper>
|