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.

1039 lines
44 KiB

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