You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

882 lines
37 KiB

2 years ago
2 years ago
10 months ago
2 years ago
2 years ago
10 months ago
2 years ago
10 months ago
2 years ago
1 year ago
10 months ago
1 year ago
2 years ago
2 years ago
10 months ago
2 years ago
2 years ago
1 year ago
2 years ago
10 months ago
7 months ago
2 years ago
2 years ago
11 months ago
2 years ago
2 years ago
2 years ago
2 years ago
10 months ago
2 years ago
2 years ago
2 years ago
10 months ago
10 months ago
10 months ago
2 years ago
10 months ago
10 months ago
2 years ago
10 months ago
1 year ago
10 months ago
10 months ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
11 months ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year ago
1 year ago
12 months ago
1 year ago
1 year ago
11 months ago
12 months ago
1 year ago
11 months ago
12 months ago
1 year ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
9 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
  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.spring.modules.project.dao.ProjectDao">
  4. <select id="selectProjectInfoList" resultType="PlmProjectInfoData">
  5. SELECT project_id,
  6. ori_project_id,
  7. project_type_db,
  8. project_name,
  9. status,
  10. project_source,
  11. customer_id,
  12. create_by,
  13. create_date,
  14. update_by,
  15. update_date,
  16. priority,
  17. site,
  18. id,
  19. project_desc,
  20. customer_remark,
  21. remark,
  22. dbo.get_projectTeamName(site, project_id, 'owner') projectOwnerName,
  23. dbo.get_projectTeamName(site, project_id, 'manager') ProjectManagerName,
  24. dbo.plm_get_dictDataLabel('project_info_type_db', project_type_db, site) projectType,
  25. dbo.plm_get_projectBaseDesc(status, 'project_status') projectStatusDesc,
  26. dbo.plm_get_dictDataLabel('project_info_source', project_source, site) projectSourceDesc,
  27. dbo.plm_get_customer_desc(site, customer_id) customerName,
  28. dbo.plm_get_dictDataLabel('project_info_priority', priority, site) priorityDesc,
  29. need_date,
  30. dbo.get_projectUserRoleName(site, project_id) userRoleName,
  31. parent_project_no,
  32. final_customer_id,
  33. dbo.plm_get_dictDataLabel('finalCustomer', final_customer_id, site) finalCustomerName,
  34. productSet
  35. FROM plm_project_info
  36. <where>
  37. <if test="site != null and site != ''">
  38. AND site = #{site}
  39. </if>
  40. <if test="projectId != null and projectId != ''">
  41. AND project_id like #{projectId}
  42. </if>
  43. <if test="projectName != null and projectName != ''">
  44. AND project_name like #{projectName}
  45. </if>
  46. <if test="customerId != null and customerId != ''">
  47. AND customer_id like #{customerId}
  48. </if>
  49. </where>
  50. order by LEFT(project_id, CHARINDEX('-', project_id + '-') - 1) desc
  51. </select>
  52. <select id="projectInfoSearch" parameterType="PlmProjectInfoData" resultType="PlmProjectInfoData">
  53. SELECT project_id,
  54. ori_project_id,
  55. project_type_db,
  56. project_name,
  57. status,
  58. project_source,
  59. customer_id,
  60. create_by,
  61. create_date,
  62. update_by,
  63. update_date,
  64. priority,
  65. site,
  66. id,
  67. project_desc,
  68. customer_remark,
  69. remark,
  70. dbo.get_projectTeamName(site, project_id, 'owner') projectOwnerName,
  71. dbo.get_projectTeamName(site, project_id, 'manager') ProjectManagerName,
  72. dbo.plm_get_dictDataLabel('project_info_type_db', project_type_db, site) projectType,
  73. dbo.plm_get_projectBaseDesc(status, 'project_status') projectStatusDesc,
  74. dbo.plm_get_dictDataLabel('project_info_source', project_source, site) projectSourceDesc,
  75. dbo.plm_get_customer_desc(site, customer_id) customerName,
  76. dbo.plm_get_dictDataLabel('project_info_priority', priority, site) priorityDesc,
  77. need_date,
  78. dbo.get_projectUserRoleName(site, project_id) userRoleName,
  79. parent_project_no,
  80. customer_project_no,
  81. final_customer_id,
  82. dbo.plm_get_dictDataLabel('finalCustomer', final_customer_id, site) finalCustomerName,
  83. productSet
  84. FROM plm_project_info
  85. <where>
  86. <if test="query.id != null">
  87. AND id = #{query.id}
  88. </if>
  89. <if test="query.customerProjectNo != null and query.customerProjectNo != ''">
  90. AND customer_project_no like #{query.customerProjectNo}
  91. </if>
  92. <if test="query.site != null and query.site != ''">
  93. AND site = #{query.site}
  94. </if>
  95. <if test="query.projectId != null and query.projectId != ''">
  96. AND project_id like #{query.projectId}
  97. </if>
  98. <if test="query.projectName != null and query.projectName != ''">
  99. AND plm_project_info.project_name like #{query.projectName}
  100. </if>
  101. <if test="query.projectType != null and query.projectType != ''">
  102. AND plm_project_info.project_type_db like #{query.projectType}
  103. </if>
  104. <if test="query.projectOwnerName != null and query.projectOwnerName != ''">
  105. AND dbo.get_projectTeamName(site,project_id,'owner') like #{query.projectOwnerName}
  106. </if>
  107. <!-- <if test="query.roleId != 1">-->
  108. <!-- AND project_id in ( select project_id from AccessProject where site=#{query.site} and username=#{query.userName} and searchFlag='Y' )-->
  109. <!-- </if>-->
  110. <if test="flag">
  111. AND project_id in ( select project_id from AccessProject where site=#{query.site} and username=#{query.userName} and searchFlag='Y' )
  112. </if>
  113. <if test="query.priority != null and query.priority != ''">
  114. AND plm_project_info.priority = #{query.priority}
  115. </if>
  116. <if test="query.customerName != null and query.customerName != ''">
  117. AND dbo.plm_get_customer_desc(site,customer_id) like #{query.customerName}
  118. </if>
  119. <if test="query.customerId != null and query.customerId != ''">
  120. AND plm_project_info.customer_Id like #{query.customerId}
  121. </if>
  122. </where>
  123. order by LEFT(project_id, CHARINDEX('-', project_id + '-') - 1) desc
  124. </select>
  125. <select id="checkPlmProjectInfoData" resultType="PlmProjectInfoData">
  126. SELECT project_id,
  127. ori_project_id,
  128. project_type_db,
  129. project_name,
  130. status,
  131. project_source,
  132. customer_id,
  133. create_by,
  134. create_date,
  135. update_by,
  136. update_date,
  137. priority,
  138. site,
  139. id,
  140. project_desc,
  141. customer_remark,
  142. remark,
  143. dbo.get_projectTeamName(site, project_id, 'owner') projectOwnerName,
  144. dbo.get_projectTeamName(site, project_id, 'manager') ProjectManagerName,
  145. dbo.plm_get_dictDataLabel('project_info_type_db', project_type_db, site) projectType,
  146. dbo.plm_get_projectBaseDesc(status, 'project_status') projectStatusDesc,
  147. dbo.plm_get_dictDataLabel('project_info_source', project_source, site) projectSourceDesc,
  148. dbo.plm_get_customer_desc(site, customer_id) customerName,
  149. dbo.plm_get_dictDataLabel('project_info_priority', priority, site) priorityDesc,
  150. need_date,
  151. dbo.get_projectUserRoleName(site, project_id) userRoleName,
  152. parent_project_no,
  153. productSet
  154. FROM plm_project_info where id=#{id}
  155. </select>
  156. <select id="searchOperatorWithSite" resultType="com.spring.modules.project.data.PlmOperatorData">
  157. select operator_id,operator_name from plm_operator u
  158. <if test="roleNo != null and roleNo != ''">
  159. inner join AccessRole r on u.site = r.site and u.operator_id = r.username and role_no = #{roleNo}
  160. </if>
  161. <where>
  162. and u.site=#{site}
  163. <if test="operatorId != null and operatorId != ''">
  164. AND u.operator_id like #{operatorId}
  165. </if>
  166. </where>
  167. order by operator_id desc
  168. </select>
  169. <select id="searchProjectTeam" resultType="PlmOperatorData">
  170. select b.operator_id,b.operator_name
  171. from plm_project_team a left join plm_operator b on a.site=b.site and a.operator_id=b.operator_id
  172. where a.site=#{site} AND a.project_id=#{projectId} and b.operator_id is not null and type=#{type}
  173. </select>
  174. <select id="searchProjectTeamStr" resultType="String">
  175. select b.operator_id
  176. from plm_project_team a left join plm_operator b on a.site=b.site and a.operator_id=b.operator_id
  177. where a.site=#{site} AND a.project_id=#{projectId} and b.operator_id is not null and type=#{type}
  178. </select>
  179. <select id="searchUserRoll" resultType="PlmUserRoleData">
  180. select
  181. a.username,
  182. a.user_display,
  183. c.site,
  184. c.project_id,
  185. isnull(c.searchFlag,'N') as searchFlag,
  186. isnull(c.updateFlag,'N') as updateFlag,
  187. isnull(c.downFlag,'N') as downFlag,
  188. isnull(c.deleteFlag,'N') as deleteFlag
  189. from sys_user a
  190. left join AccessSite b on a.username = b.UserID
  191. left join AccessProject c on a.username = c.username and c.project_id = #{projectId} and c.site = b.site
  192. <!-- left join AccessRole e on a.username=e.username and e.site= #{site}-->
  193. <where>
  194. <!-- and e.role_no='R001'-->
  195. <if test="site != null and site != ''">
  196. and b.site = #{site}
  197. </if>
  198. <if test="username != null and username != ''">
  199. and a.username like #{username}
  200. </if>
  201. <if test="userDisplay != null and userDisplay != ''">
  202. and a.user_display like #{userDisplay}
  203. </if>
  204. </where>
  205. </select>
  206. <insert id="saveProjectInfo">
  207. insert into plm_project_info
  208. (project_id, ori_project_id, project_type_db, project_name, status, project_source, customer_id, create_by,
  209. create_date, priority, site, project_desc, customer_remark, remark, need_date, parent_project_no, final_customer_id,
  210. customer_Project_No, productSet)
  211. values
  212. (#{projectId}, #{projectId}, #{projectTypeDb}, #{projectName}, #{status}, #{projectSource}, #{customerId}, #{createBy},
  213. GetDate(), #{priority}, #{site}, #{projectDesc}, #{customerRemark}, #{remark}, #{needDate}, #{parentProjectNo}, #{finalCustomerId},
  214. #{customerProjectNo}, #{productSet})
  215. </insert>
  216. <update id="updateProjectInfo">
  217. update plm_project_info set project_type_db=#{projectTypeDb},project_name=#{projectName},project_source=#{projectSource},status=#{status},
  218. customer_id=#{customerId},priority=#{priority},project_desc=#{projectDesc},customer_remark=#{customerRemark},remark=#{remark},need_date=#{needDate},
  219. update_by=#{updateBy},update_date=GetDate(),parent_project_no = #{parentProjectNo},final_customer_id=#{finalCustomerId},productSet=#{productSet}
  220. ,customer_Project_No=#{customerProjectNo} where id=#{id}
  221. </update>
  222. <delete id="deletePlmProjectTeam">
  223. delete from plm_project_team where site=#{site} and project_id=#{projectId}
  224. </delete>
  225. <delete id="deleteUserRoleList">
  226. delete from AccessProject where site=#{site} and project_id=#{projectId}
  227. </delete>
  228. <insert id="saveProjectTeams">
  229. insert into plm_project_team (site,project_id,operator_id,type) values
  230. (#{site},#{projectId},#{operatorId},#{type})
  231. </insert>
  232. <insert id="savePlmUserRoleData">
  233. insert into AccessProject(site,project_id,username,searchFlag,updateFlag,downFlag,deleteFlag) values
  234. (#{site},#{projectId},#{username},#{searchFlag},#{updateFlag},#{downFlag},#{deleteFlag})
  235. </insert>
  236. <select id="getCustomerContactData" resultType="PlmProjectContactData">
  237. select b.site,b.customer_no,b.contact_name,b.contact_landline_number,b.contact_phone_number1,b.contact_phone_number2,
  238. b.contact_phone_number3,b.position,b.mailbox,b.primary_contact,b.contact_status,b.remark,b.create_date,b.create_by,
  239. b.update_date,b.update_by,b.contact_id,a.customer_id
  240. from plm_project_contact a left join plm_customer_contact b on a.site=b.site and a.customer_id=b.customer_no and a.contact_id=b.contact_id
  241. where a.site=#{site} and a.project_id=#{projectId} and a.customer_id=#{customerId} and b.contact_status='启用'
  242. </select>
  243. <select id="getPlmProjectContactString" resultType="String">
  244. select b.contact_id
  245. from plm_project_contact a left join plm_customer_contact b on a.site=b.site and a.customer_id=b.customer_no and a.contact_id=b.contact_id
  246. where a.site=#{site} and a.project_id=#{projectId} and a.customer_id=#{customerId} and b.contact_status='启用'
  247. </select>
  248. <select id="getCustomerContactString" resultType="PlmProjectContactData">
  249. select contact_id,contact_name from plm_customer_contact
  250. where site=#{site} and customer_no=#{customerId} and contact_status='启用'
  251. </select>
  252. <!-- <select id="getPlmProjectContactString2" resultType="PlmProjectContactData">-->
  253. <!-- select-->
  254. <!-- a.contact_id,-->
  255. <!-- b.contact_name-->
  256. <!-- from plm_project_contact a-->
  257. <!-- left join plm_customer_contact b on a.site = b.site and a.customer_id = b.customer_no and a.contact_id = b.contact_id-->
  258. <!-- <where>-->
  259. <!-- a.site = #{site} and a.customer_id = #{customerId} AND b.contact_id is null-->
  260. <!-- </where>-->
  261. <!-- </select>-->
  262. <select id="getPlmProjectContactString2" resultType="PlmProjectContactData" parameterType="PlmProjectInfoData">
  263. select
  264. a.site,
  265. a.contact_id,
  266. a.contact_name
  267. from plm_customer_contact a
  268. left join plm_project_contact b on a.site = b.site and a.customer_no = b.customer_id and a.contact_id = b.contact_id and b.project_id = #{projectId}
  269. <where>
  270. a.site = #{site} and a.customer_no = #{customerId} AND b.project_id is null
  271. <if test = "contactName != null and contactName != ''">
  272. AND a.contact_name LIKE #{contactName}
  273. </if>
  274. </where>
  275. </select>
  276. <select id="getCustomerContactString2" resultType="PlmProjectContactData" parameterType="PlmProjectInfoData">
  277. select
  278. b.site,
  279. b.contact_id,
  280. b.contact_name
  281. from plm_project_contact as a
  282. left join plm_customer_contact as b on a.site = b.site and a.customer_id = b.customer_no and a.contact_id = b.contact_id
  283. where a.project_id = #{projectId} and a.site = #{site}
  284. </select>
  285. <select id="checkProjectContact" resultType="PlmProjectContactData" parameterType="ProjectContactData">
  286. select
  287. site,
  288. project_id,
  289. customer_id,
  290. contact_id
  291. from plm_project_contact
  292. where site = #{site} and project_id = #{projectId} and customer_id = #{customerId} and contact_id = #{contactId}
  293. </select>
  294. <select id="checkCustomerContact" resultType="PlmProjectContactData" parameterType="ProjectContactData">
  295. SELECT
  296. site,
  297. customer_no as customerId,
  298. contact_id
  299. FROM plm_customer_contact
  300. where site = #{site} and customer_no = #{customerId} and contact_id = #{contactId}
  301. </select>
  302. <insert id="addContact" parameterType="ProjectContactData">
  303. insert into plm_project_contact
  304. (site, project_id, customer_id, contact_id)
  305. values (#{site}, #{projectId}, #{customerId}, #{contactId})
  306. </insert>
  307. <delete id="deleteContact" parameterType="ProjectContactData">
  308. delete from plm_project_contact
  309. where site = #{site} and project_id = #{projectId} and customer_id = #{customerId} and contact_id = #{contactId}
  310. </delete>
  311. <delete id="deleteProjectContact">
  312. delete from plm_project_contact where site=#{site} and project_id=#{projectId}
  313. </delete>
  314. <insert id="saveProjectContactList">
  315. insert into plm_project_contact (site,project_id,contact_id,customer_id)
  316. values (#{site},#{projectId},#{contactId},#{customerId})
  317. </insert>
  318. <delete id="deleteProjectInfo">
  319. delete from plm_project_info where site=#{site} and project_id=#{projectId}
  320. </delete>
  321. <delete id="deleteProjectPart">
  322. delete from plm_project_part where site=#{site} and project_id=#{projectId}
  323. </delete>
  324. <select id="getProjectInfoPartList" resultType="PlmProjectPartData">
  325. select
  326. a.id,
  327. a.site,
  328. a.project_id,
  329. b.plm_part_no as test_part_no,
  330. b.family_id as partType,
  331. b.part_desc,
  332. dbo.get_family_name(b.site, b.family_id) as partTypeDesc,
  333. b.code_no,
  334. dbo.get_code_desc(b.site, b.code_no, 'IP') as codeDesc,
  335. b.group_id,
  336. dbo.get_group_name(b.site, b.group_id) as groupName,
  337. b.product_group_id1,
  338. dbo.get_product_group_name(b.site, b.product_group_id1, '1') as productGroupName1,
  339. b.product_group_id2,
  340. dbo.get_product_group_name(b.site, b.product_group_id2, '2') as productGroupName2,
  341. b.remark,
  342. b.create_date,
  343. b.create_by,
  344. b.update_date,
  345. b.update_by,
  346. c.customer_id,
  347. b.status,
  348. b.plm_part_no,
  349. case when b.status = 'Y' or (b.ifs_part_no is not null and b.ifs_part_no <![CDATA[<>]]> '') then '正式物料' else '临时物料' end as statusDesc,
  350. a.final_part_no,
  351. a.part_no_source,
  352. a.unit_price,
  353. a.tax_unit_price,
  354. a.bu_no,
  355. dbo.plm_get_bu_desc(a.site,a.bu_no) buDesc,
  356. d.customer_part_no
  357. from plm_project_part as a
  358. LEFT JOIN part as b on a.site = b.site and a.test_part_no = b.part_no
  359. left join plm_project_info as c on a.site = c.site and a.project_id = c.project_id
  360. left join plm_customer_part_info as d on c.site = d.site and c.customer_id = d.customer_no and a.test_part_no = d.part_no
  361. where a.site = #{query.site} and a.project_id = #{query.projectId}
  362. </select>
  363. <select id="checkProjectInfoPartList" resultType="PlmProjectPartData">
  364. select top 1
  365. id,
  366. site,
  367. project_id,
  368. test_part_no,
  369. part_type,
  370. part_desc,
  371. part_spec,
  372. material_number,
  373. remark,
  374. create_date,
  375. create_by,
  376. update_date,
  377. part_name,
  378. update_by,
  379. dbo.get_family_name(site, part_type) as partTypeDesc,
  380. final_part_no,
  381. code_no,
  382. dbo.get_code_desc(site, code_no, 'IP') as codeDesc,
  383. group_id,
  384. dbo.get_group_name(site, group_id) as groupName,
  385. product_group_id1,
  386. dbo.get_product_group_name(site, product_group_id1, '1') as productGroupName1,
  387. product_group_id2,
  388. dbo.get_product_group_name(site, product_group_id2, '2') as productGroupName2
  389. from view_Project_Part where site=#{site} and test_part_no=#{testPartNo}
  390. </select>
  391. <select id="getTestPartNo" resultType="String">
  392. select top 1 #{projectId}+'-'+ Right( '0000'+ convert(VARCHAR(10), isnull(max(convert(INT,RIGHT(test_part_no, 4))),0)+1) ,4) from view_Project_Part
  393. where site=#{site} and project_id=#{projectId}
  394. </select>
  395. <insert id="saveProjectPart">
  396. insert into plm_project_part
  397. (site,project_id,
  398. test_part_no,
  399. part_type,
  400. part_desc,
  401. part_spec,
  402. material_number,
  403. remark,
  404. create_date,
  405. create_by,
  406. part_name,
  407. code_no,
  408. group_id,
  409. product_group_id1,
  410. product_group_id2)
  411. values
  412. (#{site},
  413. #{projectId},
  414. #{testPartNo},
  415. #{partType},
  416. #{partDesc},
  417. #{partSpec},
  418. #{materialNumber},
  419. #{remark},
  420. GetDate(),
  421. #{username},
  422. #{partName},
  423. #{codeNo},
  424. #{groupId},
  425. #{productGroupId1},
  426. #{productGroupId2})
  427. </insert>
  428. <update id="updateProjectPart">
  429. update plm_project_part
  430. set part_type=#{partType},
  431. part_desc=#{partDesc},
  432. part_spec=#{partSpec},
  433. material_number=#{materialNumber},
  434. remark=#{remark},
  435. update_date=GetDate(),
  436. update_by=#{username},
  437. part_name=#{partName},
  438. code_no=#{codeNo},
  439. group_id = #{groupId},
  440. product_group_id1 = #{productGroupId1},
  441. product_group_id2 = #{productGroupId2}
  442. where id=#{id}
  443. </update>
  444. <delete id="deleteProjectPartWithId">
  445. delete from plm_project_part where id=#{id}
  446. </delete>
  447. <select id="getPlmToolPurchaseRequestDataByProject" resultType="PlmToolPurchaseRequestData">
  448. select id,site,order_no,test_part_no,project_id,tool_id,type,reason,tool_offset,qty,party_a,supplier_id,price,tool_cost,
  449. all_cost,IFS_PR_No,po_number,remark,create_by,create_date,update_by,update_date,planner,applicant,dbo.get_userDisPlay(applicant) applicantName,
  450. dbo.get_userDisPlay(planner) plannerName,dbo.plm_get_test_part_name(site,test_part_no) partName
  451. ,status ,dbo.plm_get_projectBaseDesc(status,'purchaseRequest_status') statusDesc
  452. from plm_tool_purchase_request
  453. where site=#{site} and project_id=#{projectId}
  454. </select>
  455. <insert id="savePlmToolPurchaseRequestData">
  456. insert into plm_tool_purchase_request (site,order_no,test_part_no,project_id,tool_id,type,status,reason,tool_offset,qty,party_a,supplier_id,price,tool_cost,
  457. all_cost,IFS_PR_No,po_number,remark,create_by,create_date,planner,applicant) values
  458. (#{site},#{orderNo},#{testPartNo},#{projectId},#{toolId},#{type},#{status},#{reason},#{toolOffset},#{qty},#{partyA},#{supplierId},${price},#{toolCost},
  459. #{allCost},#{ifsPrNo},#{poNumber},#{remark},#{username},GetDate(),#{planner},#{applicant})
  460. </insert>
  461. <select id="searchBIAddress" resultType="BiAddress">
  462. select top 1 menu_id ,address from BI_Address where menu_id=#{menuId}
  463. </select>
  464. <select id="getProjectUserRole" resultType="PlmUserRoleData">
  465. select site,project_id,username,searchFlag,updateFlag,downFlag,deleteFlag
  466. from AccessProject where site=#{site} and project_id=#{projectId} and username=#{username}
  467. </select>
  468. <select id="getProjectPartList" resultType="com.spring.modules.project.data.PlmProjectPartData">
  469. select vpp.id,
  470. vpp.site,
  471. vpp.project_id,
  472. vpp.test_part_no,
  473. vpp.part_type,
  474. vpp.part_desc,
  475. vpp.part_spec,
  476. vpp.material_number,
  477. vpp.remark,
  478. vpp.create_date,
  479. vpp.create_by,
  480. vpp.update_date,
  481. vpp.part_name,
  482. vpp.update_by,
  483. dbo.get_family_name(vpp.site, vpp.part_type) as partTypeDesc,
  484. vpp.final_part_no,
  485. vpp.code_no,
  486. dbo.get_code_desc(vpp.site, vpp.code_no, 'IP') as codeDesc,
  487. vpp.group_id,
  488. dbo.get_group_name(vpp.site, vpp.group_id) as groupName,
  489. vpp.product_group_id1,
  490. dbo.get_product_group_name(vpp.site, vpp.product_group_id1, '1') as productGroupName1,
  491. vpp.product_group_id2,
  492. dbo.get_product_group_name(vpp.site, vpp.product_group_id2, '2') as productGroupName2,
  493. vpp.um_id,
  494. vpp.type,
  495. pcpi.customer_part_no
  496. from view_Project_Part vpp
  497. left join plm_project_info ppi on vpp.site = ppi.site and vpp.project_id = ppi.project_id
  498. left join plm_customer_part_info pcpi on vpp.site = pcpi.site and ppi.customer_id = pcpi.customer_no and vpp.test_part_no = pcpi.part_no
  499. where vpp.site = #{params.site}
  500. <if test="params.projectId != null and params.projectId != ''">
  501. and vpp.project_id = #{params.projectId}
  502. </if>
  503. <if test="params.testPartNo != null and params.testPartNo != ''">
  504. and vpp.test_part_no like #{params.testPartNo}
  505. </if>
  506. <if test="params.partDesc != null and params.partDesc != ''">
  507. and vpp.part_desc like #{params.partDesc}
  508. </if>
  509. <if test="params.finalPartNo != null and params.finalPartNo != ''">
  510. and vpp.final_part_no like #{params.finalPartNo}
  511. </if>
  512. <if test="params.customerPartNo != null and params.customerPartNo != ''">
  513. and pcpi.customer_part_no like #{params.customerPartNo}
  514. </if>
  515. <if test="params.partType != null and params.partType != ''">
  516. and vpp.type = #{params.partType}
  517. </if>
  518. </select>
  519. <select id="getProjectPart" resultType="com.spring.modules.project.data.PlmProjectPartData">
  520. select
  521. id,
  522. site,
  523. project_id,
  524. test_part_no,
  525. part_type,
  526. part_desc,
  527. part_spec,
  528. material_number,
  529. remark,
  530. create_date,
  531. create_by,
  532. update_date,
  533. part_name,
  534. update_by,
  535. dbo.get_family_name(site, part_type) as partTypeDesc,
  536. final_part_no,
  537. code_no,
  538. dbo.get_code_desc(site, code_no, 'IP') as codeDesc,
  539. group_id,
  540. dbo.get_group_name(site, group_id) as groupName,
  541. product_group_id1,
  542. dbo.get_product_group_name(site, product_group_id1, '1') as productGroupName1,
  543. product_group_id2,
  544. dbo.get_product_group_name(site, product_group_id2, '2') as productGroupName2
  545. from view_Project_Part where site=#{site}
  546. <if test="testPartNo != null and testPartNo != ''">
  547. and test_part_no = #{testPartNo}
  548. </if>
  549. </select>
  550. <select id="getProjectData" resultType="com.spring.modules.project.entity.PlmProjectInfo">
  551. select project_id,ori_project_id,project_type_db,project_name,status,project_source,customer_id,create_by,create_date,
  552. update_by,update_date,priority,site,id,project_desc,customer_remark,remark,need_date,parent_project_no,final_customer_id
  553. from plm_project_info where site=#{site} and project_id=#{projectId}
  554. </select>
  555. <select id="projectInfoPartSearch" resultType="PlmProjectPartData">
  556. select
  557. a.id,
  558. a.site,
  559. a.bu_no,
  560. a.project_id,
  561. a.test_part_no,
  562. a.final_part_no,
  563. a.material_number,
  564. a.part_name,
  565. a.part_desc,
  566. a.part_spec,
  567. a.create_date,
  568. a.create_by,
  569. a.update_date,
  570. a.update_by,
  571. a.code_no,
  572. dbo.get_code_desc(a.site, a.code_no, 'IP') as codeDesc,
  573. a.um_id,
  574. a.group_id,
  575. dbo.get_group_name(a.site, a.group_id) as groupName,
  576. a.part_type,
  577. dbo.get_family_name(a.site, a.part_type) as partTypeDesc,
  578. a.type,
  579. a.product_group_id1,
  580. dbo.get_product_group_name(a.site, a.product_group_id1, '1') as productGroupName1,
  581. a.product_group_id2,
  582. dbo.get_product_group_name(a.site, a.product_group_id2, '2') as productGroupName2,
  583. a.remark,
  584. b.customer_id,
  585. c.customer_part_no,
  586. b.final_customer_id
  587. from view_Project_Part as a
  588. left join plm_project_info as b on a.site = b.site and a.project_id = b.project_id
  589. left join plm_customer_part_info as c on b.site = c.site and b.customer_id = c.customer_no and a.test_part_no = c.part_no
  590. where a.site = #{query.site}
  591. <if test = "query.buNo != null and query.buNo != ''">
  592. AND a.bu_no = #{query.buNo}
  593. </if>
  594. <if test = "query.customerPartNo != null and query.customerPartNo != ''">
  595. AND c.customer_part_no like #{query.customerPartNo}
  596. </if>
  597. <if test = "query.finalPartNo != null and query.finalPartNo != ''">
  598. AND a.final_part_no like #{query.finalPartNo}
  599. </if>
  600. <if test="query.testPartNo != null and query.testPartNo != ''">
  601. and a.test_part_no like #{query.testPartNo}
  602. </if>
  603. <if test="query.projectId != null and query.projectId != ''">
  604. and a.project_id like #{query.projectId}
  605. </if>
  606. </select>
  607. <select id="queryProject" resultType="com.spring.modules.project.data.PlmProjectInfoData">
  608. select project_id,
  609. project_name,
  610. final_customer_id,
  611. dbo.plm_get_dictDataLabel('finalCustomer',final_customer_id,site) finalCustomerName
  612. from plm_project_info
  613. where site = #{site}
  614. and project_id = #{projectId}
  615. and customer_id = #{customerId}
  616. </select>
  617. <select id="queryProjectPart" resultType="com.spring.modules.project.entity.PlmProjectPart">
  618. select
  619. project_id,
  620. test_part_no,
  621. part_desc
  622. from
  623. view_Project_Part
  624. where site = #{site} and project_id = #{projectId} and test_part_no = #{testPartNo}
  625. </select>
  626. <select id="getProjectPartNewBm" resultType="PlmProjectPartData">
  627. select
  628. site,
  629. project_id,
  630. test_part_no,
  631. part_desc,
  632. now_bm,
  633. final_part_no
  634. from
  635. plm_project_part
  636. where site = #{site} and (test_part_no = #{testPartNo} or final_part_no= #{testPartNo}) and now_bm is not null
  637. </select>
  638. <select id="queryProjectCustomer" resultType="com.spring.modules.customer.vo.CustomerInformationVo">
  639. select top 1 pci.site,
  640. pci.customer_no,
  641. pci.customer_desc,
  642. dbo.plm_get_dictDataLabel('plm_customer_information_customer_customer_currency', pci.customer_currency,pci.site) as customer_currency,
  643. pci.turnover_of_year,
  644. pci.potential_revenue_of_year,
  645. pci.customer_status,
  646. pci.customer_type,
  647. dbo.plm_get_dictDataLabel('plm_customer_information_customer_industry', pci.customer_industry,
  648. pci.site) as customer_industry,
  649. case
  650. when pci.customer_status = 'Y' then '启用'
  651. when pci.customer_status = 'N' then '停用'
  652. else '' end as customerStatusDesc,
  653. pci.customer_description,
  654. dbo.plm_get_dictDataLabel('plm_customer_information_important_customer', pci.important_customer, pci.site) as important_customer,
  655. pci.customer_group
  656. from plm_project_info ppi
  657. left join dbo.plm_customer_information pci on ppi.customer_id = pci.customer_no
  658. where ppi.project_id = #{projectId} and ppi.site = #{site}
  659. </select>
  660. <select id="queryProjectFinalCustomer" resultType="com.spring.modules.customer.entity.CustomerInformationEntity">
  661. select top 1 pci.site,
  662. pci.customer_no,
  663. pci.customer_desc,
  664. dbo.plm_get_dictDataLabel('plm_customer_information_customer_customer_currency', pci.customer_currency,
  665. pci.site) as customer_currency,
  666. pci.turnover_of_year,
  667. pci.potential_revenue_of_year,
  668. pci.customer_status,
  669. pci.customer_description,
  670. dbo.plm_get_dictDataLabel('plm_customer_information_important_customer', pci.important_customer, ppi.site) as important_customer,
  671. pci.customer_industry,
  672. pci.customer_group,
  673. pci.customer_type
  674. from plm_project_info ppi
  675. left join dbo.plm_customer_information pci on ppi.final_customer_id = pci.customer_no
  676. where ppi.project_id = #{projectId} and ppi.site = #{site}
  677. </select>
  678. <select id="selectProjectInfoListSys" resultType="com.spring.modules.project.data.PlmProjectInfoData">
  679. SELECT project_id,
  680. ori_project_id,
  681. project_type_db,
  682. project_name,
  683. status,
  684. project_source,
  685. customer_id,
  686. create_by,
  687. create_date,
  688. update_by,
  689. update_date,
  690. priority,
  691. site,
  692. id,
  693. project_desc,
  694. customer_remark,
  695. remark,
  696. dbo.get_projectTeamName(site, project_id, 'owner') projectOwnerName,
  697. dbo.get_projectTeamName(site, project_id, 'manager') ProjectManagerName,
  698. dbo.plm_get_dictDataLabel('project_info_type_db', project_type_db, site) projectType,
  699. dbo.plm_get_projectBaseDesc(status, 'project_status') projectStatusDesc,
  700. dbo.plm_get_dictDataLabel('project_info_source', project_source, site) projectSourceDesc,
  701. dbo.plm_get_customer_desc(site, customer_id) customerName,
  702. dbo.plm_get_dictDataLabel('project_info_priority', priority, site) priorityDesc,
  703. need_date,
  704. dbo.get_projectUserRoleName(site, project_id) userRoleName,
  705. parent_project_no,
  706. final_customer_id,
  707. dbo.plm_get_dictDataLabel('finalCustomer', final_customer_id, site) finalCustomerName,
  708. productSet
  709. FROM plm_project_info
  710. <where>
  711. <!-- AND project_id in ( select project_id from AccessProject where site=#{site} and username=#{username} and searchFlag='Y' )-->
  712. <if test="site != null and site != ''">
  713. AND site = #{site}
  714. </if>
  715. <if test="projectId != null and projectId != ''">
  716. AND project_id like #{projectId}
  717. </if>
  718. <if test="projectName != null and projectName != ''">
  719. AND project_name like #{projectName}
  720. </if>
  721. <if test="customerId != null and customerId != ''">
  722. AND customer_id like #{customerId}
  723. </if>
  724. </where>
  725. order by LEFT(project_id, CHARINDEX('-', project_id + '-') - 1) desc
  726. </select>
  727. <update id="updateProjectFinalCustomerNo">
  728. update plm_project_info
  729. set final_customer_id = #{finalCustomerId}
  730. where site = #{site} and project_id = #{projectId}
  731. </update>
  732. <select id="queryProjectSiteUserRole" resultType="com.spring.modules.sys.entity.SysUserEntity">
  733. select
  734. u.username,
  735. u.user_display
  736. from sys_user u
  737. left join AccessSite s on u.username = s.UserID
  738. left join sys_user_role ur on u.user_id = ur.user_id
  739. left join sys_role r on ur.role_id = r.role_id
  740. where s.Site = #{site} and r.super_flag = 'Y'
  741. </select>
  742. <select id="projectInfoSearchByAnyField" resultType="com.spring.modules.project.data.PlmProjectInfoData">
  743. SELECT
  744. project_id,
  745. ori_project_id,
  746. project_type_db,
  747. project_name,
  748. status,
  749. project_source,
  750. customer_id,
  751. create_by,
  752. create_date,
  753. update_by,
  754. update_date,
  755. priority,
  756. site,
  757. id,
  758. project_desc,
  759. customer_remark,
  760. remark,
  761. dbo.get_projectTeamName (site, project_id, 'owner') projectOwnerName,
  762. dbo.get_projectTeamName (site, project_id, 'manager') ProjectManagerName,
  763. dbo.plm_get_dictDataLabel ('project_info_type_db', project_type_db, site) projectType,
  764. dbo.plm_get_projectBaseDesc (status, 'project_status') projectStatusDesc,
  765. dbo.plm_get_dictDataLabel ('project_info_source', project_source, site) projectSourceDesc,
  766. dbo.plm_get_customer_desc (site, customer_id) customerName,
  767. dbo.plm_get_dictDataLabel ('project_info_priority', priority, site) priorityDesc,
  768. need_date,
  769. dbo.get_projectUserRoleName (site, project_id) userRoleName,
  770. parent_project_no,
  771. customer_project_no,
  772. final_customer_id,
  773. dbo.plm_get_dictDataLabel ('finalCustomer', final_customer_id, site) finalCustomerName,
  774. productSet
  775. FROM
  776. plm_project_info
  777. <if test="params.whereClause != null and params.whereClause != ''">
  778. WHERE ${params.whereClause}
  779. </if>
  780. <if test="params.userName != null and params.userName != '' and params.superFlag != 'Y'">
  781. AND project_id in ( select project_id from AccessProject where site=#{params.site} and username=#{params.userName} and searchFlag='Y' )
  782. </if>
  783. <if test="params.orderClause != null and params.orderClause != ''">
  784. ORDER BY ${params.orderClause}
  785. </if>
  786. <if test="params.orderClause == null or params.orderClause == ''">
  787. ORDER BY project_id
  788. </if>
  789. </select>
  790. <select id="projectPartSearchByAnyField" resultType="com.spring.modules.project.data.PlmProjectPartData">
  791. select
  792. a.id,
  793. a.site,
  794. a.bu_no,
  795. a.project_id,
  796. a.test_part_no,
  797. a.final_part_no,
  798. a.material_number,
  799. a.part_name,
  800. a.part_desc,
  801. a.part_spec,
  802. a.create_date,
  803. a.create_by,
  804. a.update_date,
  805. a.update_by,
  806. a.code_no,
  807. dbo.get_code_desc(a.site, a.code_no, 'IP') as codeDesc,
  808. a.um_id,
  809. a.group_id,
  810. dbo.get_group_name(a.site, a.group_id) as groupName,
  811. a.part_type,
  812. dbo.get_family_name(a.site, a.part_type) as partTypeDesc,
  813. a.type,
  814. a.product_group_id1,
  815. dbo.get_product_group_name(a.site, a.product_group_id1, '1') as productGroupName1,
  816. a.product_group_id2,
  817. dbo.get_product_group_name(a.site, a.product_group_id2, '2') as productGroupName2,
  818. a.remark,
  819. b.customer_id,
  820. c.customer_part_no,
  821. b.final_customer_id
  822. from view_Project_Part as a
  823. left join plm_project_info as b on a.site = b.site and a.project_id = b.project_id
  824. left join plm_customer_part_info as c on b.site = c.site and b.customer_id = c.customer_no and a.test_part_no = c.part_no
  825. <if test="params.whereClause != null and params.whereClause != ''">
  826. WHERE ${params.whereClause}
  827. </if>
  828. <if test="params.orderClause != null and params.orderClause != ''">
  829. ORDER BY ${params.orderClause}
  830. </if>
  831. <if test="params.orderClause == null or params.orderClause == ''">
  832. ORDER BY a.project_id
  833. </if>
  834. </select>
  835. <select id="getProjectByName" resultType="com.spring.modules.project.data.PlmProjectInfoData">
  836. select project_name
  837. from plm_project_info
  838. where site = #{site} and project_name = #{projectName}
  839. </select>
  840. </mapper>