CommonMapper.xml 130 KB

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