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.

921 lines
39 KiB

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