CommonMapper.xml 116 KB

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