CommonMapper.xml 117 KB

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