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.

427 lines
18 KiB

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
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
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
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
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
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years 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="projectInfoSearch" parameterType="PlmProjectInfoData" resultType="PlmProjectInfoData">
  5. SELECT project_id,ori_project_id,project_type_db,project_name,status,project_source,customer_id,create_by,
  6. create_date,update_by,update_date,priority,site,id,project_desc,customer_remark,remark,dbo.get_projectTeamName(site,project_id,'owner') projectOwnerName
  7. ,dbo.get_projectTeamName(site,project_id,'manager') ProjectManagerName,dbo.plm_get_dictDataLabel('project_info_type_db',project_type_db,site) projectType,
  8. dbo.plm_get_projectBaseDesc(status,'project_status') projectStatusDesc,dbo.plm_get_dictDataLabel('project_info_source',project_source,site) projectSourceDesc,
  9. dbo.plm_get_customer_desc(site,customer_id) customerName,dbo.plm_get_dictDataLabel('project_info_priority',priority,site) priorityDesc,need_date,
  10. dbo.get_projectUserRoleName(site,project_id) userRoleName,bu_no,dbo.plm_get_bu_desc(site,bu_no) buDesc,parent_project_no,
  11. final_customer_id,dbo.plm_get_customer_desc(site,final_customer_id) finalCustomerName
  12. FROM plm_project_info
  13. <where>
  14. <if test="query.id != null">
  15. AND id = #{query.id}
  16. </if>
  17. <if test="query.site != null and query.site != ''">
  18. AND site = #{query.site}
  19. </if>
  20. <if test="query.projectId != null and query.projectId != ''">
  21. AND project_id like #{query.projectId}
  22. </if>
  23. <if test="query.projectType != null and query.projectType != ''">
  24. AND plm_project_info.project_type_db like #{query.projectType}
  25. </if>
  26. <if test="query.projectOwnerName != null and query.projectOwnerName != ''">
  27. AND dbo.get_projectTeamName(site,project_id,'ProjectOwner') like '%' + #{query.projectOwnerName} +'%'
  28. </if>
  29. <if test="query.userName != null and query.userName != '' and query.userName != 'admin'">
  30. AND project_id in ( select project_id from AccessProject where site=#{query.site} and username=#{query.userName} and searchFlag='Y' )
  31. AND bu_no in ( select bu_no from AccessBu where site=#{query.site} and username=#{query.userName})
  32. </if>
  33. </where>
  34. order by LEFT(project_id, CHARINDEX('-', project_id + '-') - 1) desc
  35. </select>
  36. <select id="checkPlmProjectInfoData" resultType="PlmProjectInfoData">
  37. SELECT project_id,ori_project_id,project_type_db,project_name,status,project_source,customer_id,create_by,
  38. create_date,update_by,update_date,priority,site,id,project_desc,customer_remark,remark,dbo.get_projectTeamName(site,project_id,'owner') projectOwnerName
  39. ,dbo.get_projectTeamName(site,project_id,'manager') ProjectManagerName,dbo.plm_get_dictDataLabel('project_info_type_db',project_type_db,site) projectType,
  40. dbo.plm_get_projectBaseDesc(status,'project_status') projectStatusDesc,dbo.plm_get_dictDataLabel('project_info_source',project_source,site) projectSourceDesc,
  41. dbo.plm_get_customer_desc(site,customer_id) customerName,dbo.plm_get_dictDataLabel('project_info_priority',priority,site) priorityDesc,need_date,
  42. dbo.get_projectUserRoleName(site,project_id) userRoleName,bu_no,dbo.plm_get_bu_desc(site,bu_no) buDesc,parent_project_no
  43. FROM plm_project_info where id=#{id}
  44. </select>
  45. <select id="searchOperatorWithSite" resultType="com.spring.modules.project.data.PlmOperatorData">
  46. select operator_id,operator_name from plm_operator
  47. <where>
  48. and site=#{site}
  49. <if test="operatorId != null and operatorId != ''">
  50. AND operator_id like #{operatorId}
  51. </if>
  52. </where>
  53. </select>
  54. <select id="searchProjectTeam" resultType="PlmOperatorData">
  55. select b.operator_id,b.operator_name
  56. from plm_project_team a left join plm_operator b on a.site=b.site and a.operator_id=b.operator_id
  57. where a.site=#{site} AND a.project_id=#{projectId} and b.operator_id is not null and type=#{type}
  58. </select>
  59. <select id="searchProjectTeamStr" resultType="String">
  60. select b.operator_id
  61. from plm_project_team a left join plm_operator b on a.site=b.site and a.operator_id=b.operator_id
  62. where a.site=#{site} AND a.project_id=#{projectId} and b.operator_id is not null and type=#{type}
  63. </select>
  64. <select id="searchUserRoll" resultType="PlmUserRoleData">
  65. select a.username,a.user_display,c.site,c.project_id,isnull(c.searchFlag,'N') searchFlag
  66. ,isnull(c.updateFlag,'N') updateFlag,isnull(c.downFlag,'N') downFlag,isnull(c.deleteFlag,'N') deleteFlag
  67. from sys_user a left join AccessSite b on a.username=b.UserID
  68. left join AccessProject c on a.username=c.username and c.project_id=#{projectId} and c.site=#{site}
  69. <where>
  70. and b.site=#{site}
  71. </where>
  72. </select>
  73. <insert id="saveProjectInfo">
  74. insert into plm_project_info
  75. (project_id,ori_project_id,project_type_db,project_name,status,project_source,customer_id,create_by,
  76. create_date,priority,site,project_desc,customer_remark,remark,need_date,bu_no,parent_project_no,final_customer_id) values
  77. (#{projectId},#{projectId},#{projectTypeDb},#{projectName},#{status},#{projectSource},#{customerId},
  78. #{createBy},GetDate(),#{priority},#{site},#{projectDesc},#{customerRemark},#{remark},#{needDate},#{buNo},#{parentProjectNo}
  79. ,#{finalCustomerId})
  80. </insert>
  81. <update id="updateProjectInfo">
  82. update plm_project_info set project_type_db=#{projectTypeDb},project_name=#{projectName},project_source=#{projectSource},status=#{status},
  83. customer_id=#{customerId},priority=#{priority},project_desc=#{projectDesc},customer_remark=#{customerRemark},remark=#{remark},need_date=#{needDate},
  84. update_by=#{updateBy},update_date=GetDate(),bu_no=#{buNo},parent_project_no = #{parentProjectNo},final_customer_id=#{finalCustomerId}
  85. where id=#{id}
  86. </update>
  87. <delete id="deletePlmProjectTeam">
  88. delete from plm_project_team where site=${site} and project_id=#{projectId}
  89. </delete>
  90. <delete id="deleteUserRoleList">
  91. delete from AccessProject where site=${site} and project_id=#{projectId}
  92. </delete>
  93. <insert id="saveProjectTeams">
  94. insert into plm_project_team (site,project_id,operator_id,type) values
  95. (#{site},#{projectId},#{operatorId},#{type})
  96. </insert>
  97. <insert id="savePlmUserRoleData">
  98. insert into AccessProject(site,project_id,username,searchFlag,updateFlag,downFlag,deleteFlag) values
  99. (#{site},#{projectId},#{username},#{searchFlag},#{updateFlag},#{downFlag},#{deleteFlag})
  100. </insert>
  101. <select id="getCustomerContactData" resultType="PlmProjectContactData">
  102. select b.site,b.customer_no,b.contact_name,b.contact_landline_number,b.contact_phone_number1,b.contact_phone_number2,
  103. b.contact_phone_number3,b.position,b.mailbox,b.primary_contact,b.contact_status,b.remark,b.create_date,b.create_by,
  104. b.update_date,b.update_by,b.contact_id,a.customer_id
  105. 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
  106. where a.site=#{site} and a.project_id=#{projectId} and a.customer_id=#{customerId} and b.contact_status='启用'
  107. </select>
  108. <select id="getPlmProjectContactString" resultType="String">
  109. select b.contact_id
  110. 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
  111. where a.site=#{site} and a.project_id=#{projectId} and a.customer_id=#{customerId} and b.contact_status='启用'
  112. </select>
  113. <select id="getCustomerContactString" resultType="PlmProjectContactData">
  114. select contact_id,contact_name from plm_customer_contact
  115. where site=#{site} and customer_no=#{customerId} and contact_status='启用'
  116. </select>
  117. <!-- <select id="getPlmProjectContactString2" resultType="PlmProjectContactData">-->
  118. <!-- select-->
  119. <!-- a.contact_id,-->
  120. <!-- b.contact_name-->
  121. <!-- from plm_project_contact a-->
  122. <!-- 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-->
  123. <!-- <where>-->
  124. <!-- a.site = #{site} and a.customer_id = #{customerId} AND b.contact_id is null-->
  125. <!-- </where>-->
  126. <!-- </select>-->
  127. <select id="getPlmProjectContactString2" resultType="PlmProjectContactData" parameterType="PlmProjectInfoData">
  128. select
  129. a.site,
  130. a.contact_id,
  131. a.contact_name
  132. from plm_customer_contact a
  133. 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}
  134. <where>
  135. a.site = #{site} and a.customer_no = #{customerId} AND b.project_id is null
  136. <if test = "contactName != null and contactName != ''">
  137. AND a.contact_name LIKE #{contactName}
  138. </if>
  139. </where>
  140. </select>
  141. <select id="getCustomerContactString2" resultType="PlmProjectContactData" parameterType="PlmProjectInfoData">
  142. select
  143. b.site,
  144. b.contact_id,
  145. b.contact_name
  146. from plm_project_contact as a
  147. 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
  148. where a.project_id = #{projectId} and a.site = #{site}
  149. </select>
  150. <select id="checkProjectContact" resultType="PlmProjectContactData" parameterType="ProjectContactData">
  151. select
  152. site,
  153. project_id,
  154. customer_id,
  155. contact_id
  156. from plm_project_contact
  157. where site = #{site} and project_id = #{projectId} and customer_id = #{customerId} and contact_id = #{contactId}
  158. </select>
  159. <select id="checkCustomerContact" resultType="PlmProjectContactData" parameterType="ProjectContactData">
  160. SELECT
  161. site,
  162. customer_no as customerId,
  163. contact_id
  164. FROM plm_customer_contact
  165. where site = #{site} and customer_no = #{customerId} and contact_id = #{contactId}
  166. </select>
  167. <insert id="addContact" parameterType="ProjectContactData">
  168. insert into plm_project_contact
  169. (site, project_id, customer_id, contact_id)
  170. values (#{site}, #{projectId}, #{customerId}, #{contactId})
  171. </insert>
  172. <delete id="deleteContact" parameterType="ProjectContactData">
  173. delete from plm_project_contact
  174. where site = #{site} and project_id = #{projectId} and customer_id = #{customerId} and contact_id = #{contactId}
  175. </delete>
  176. <delete id="deleteProjectContact">
  177. delete from plm_project_contact where site=#{site} and project_id=#{projectId}
  178. </delete>
  179. <insert id="saveProjectContactList">
  180. insert into plm_project_contact (site,project_id,contact_id,customer_id)
  181. values (#{site},#{projectId},#{contactId},#{customerId})
  182. </insert>
  183. <delete id="deleteProjectInfo">
  184. delete from plm_project_info where site=#{site} and project_id=#{projectId}
  185. </delete>
  186. <delete id="deleteProjectPart">
  187. delete from plm_project_part where site=#{site} and project_id=#{projectId}
  188. </delete>
  189. <select id="getProjectInfoPartList" resultType="PlmProjectPartData">
  190. select
  191. a.id,
  192. a.site,
  193. a.project_id,
  194. a.test_part_no,
  195. b.family_id as part_type,
  196. b.part_desc,
  197. b.remark,
  198. b.create_date,
  199. b.create_by,
  200. b.update_date,
  201. b.update_by,
  202. dbo.get_family_name(a.site, b.family_id) as partTypeDesc,
  203. b.code_no,
  204. dbo.get_code_desc(a.site, b.code_no, 'IP') as codeDesc,
  205. b.group_id,
  206. dbo.get_group_name(a.site, b.group_id) as groupName,
  207. b.product_group_id1,
  208. dbo.get_product_group_name(a.site, b.product_group_id1, '1') as productGroupName1,
  209. b.product_group_id2,
  210. dbo.get_product_group_name(a.site, b.product_group_id2, '2') as productGroupName2
  211. from view_Project_Part as a
  212. LEFT JOIN part as b on a.site = b.site and a.test_part_no = b.part_no
  213. where a.site = #{site} and a.project_id = #{projectId}
  214. </select>
  215. <select id="checkProjectInfoPartList" resultType="PlmProjectPartData">
  216. select top 1
  217. id,
  218. site,
  219. project_id,
  220. test_part_no,
  221. part_type,
  222. part_desc,
  223. part_spec,
  224. material_number,
  225. remark,
  226. create_date,
  227. create_by,
  228. update_date,
  229. part_name,
  230. update_by,
  231. dbo.get_family_name(site, part_type) as partTypeDesc,
  232. final_part_no,
  233. code_no,
  234. dbo.get_code_desc(site, code_no, 'IP') as codeDesc,
  235. group_id,
  236. dbo.get_group_name(site, group_id) as groupName,
  237. product_group_id1,
  238. dbo.get_product_group_name(site, product_group_id1, '1') as productGroupName1,
  239. product_group_id2,
  240. dbo.get_product_group_name(site, product_group_id2, '2') as productGroupName2
  241. from view_Project_Part where site=#{site} and test_part_no=#{testPartNo}
  242. </select>
  243. <select id="getTestPartNo" resultType="String">
  244. 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
  245. where site=#{site} and project_id=#{projectId}
  246. </select>
  247. <insert id="saveProjectPart">
  248. insert into plm_project_part
  249. (site,project_id,
  250. test_part_no,
  251. part_type,
  252. part_desc,
  253. part_spec,
  254. material_number,
  255. remark,
  256. create_date,
  257. create_by,
  258. part_name,
  259. code_no,
  260. group_id,
  261. product_group_id1,
  262. product_group_id2)
  263. values
  264. (#{site},
  265. #{projectId},
  266. #{testPartNo},
  267. #{partType},
  268. #{partDesc},
  269. #{partSpec},
  270. #{materialNumber},
  271. #{remark},
  272. GetDate(),
  273. #{username},
  274. #{partName},
  275. #{codeNo},
  276. #{groupId},
  277. #{productGroupId1},
  278. #{productGroupId2})
  279. </insert>
  280. <update id="updateProjectPart">
  281. update plm_project_part
  282. set part_type=#{partType},
  283. part_desc=#{partDesc},
  284. part_spec=#{partSpec},
  285. material_number=#{materialNumber},
  286. remark=#{remark},
  287. update_date=GetDate(),
  288. update_by=#{username},
  289. part_name=#{partName},
  290. code_no=#{codeNo},
  291. group_id = #{groupId},
  292. product_group_id1 = #{productGroupId1},
  293. product_group_id2 = #{productGroupId2}
  294. where id=#{id}
  295. </update>
  296. <delete id="deleteProjectPartWithId">
  297. delete from plm_project_part where id=#{id}
  298. </delete>
  299. <select id="getPlmToolPurchaseRequestDataByProject" resultType="PlmToolPurchaseRequestData">
  300. select id,site,order_no,test_part_no,project_id,tool_id,type,reason,tool_offset,qty,party_a,supplier_id,price,tool_cost,
  301. all_cost,IFS_PR_No,po_number,remark,create_by,create_date,update_by,update_date,planner,applicant,dbo.get_userDisPlay(applicant) applicantName,
  302. dbo.get_userDisPlay(planner) plannerName,dbo.plm_get_test_part_name(site,test_part_no) partName
  303. ,status ,dbo.plm_get_projectBaseDesc(status,'purchaseRequest_status') statusDesc
  304. from plm_tool_purchase_request
  305. where site=${site} and project_id=#{projectId}
  306. </select>
  307. <insert id="savePlmToolPurchaseRequestData">
  308. 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,
  309. all_cost,IFS_PR_No,po_number,remark,create_by,create_date,planner,applicant) values
  310. (#{site},#{orderNo},#{testPartNo},#{projectId},#{toolId},#{type},#{status},#{reason},#{toolOffset},#{qty},#{partyA},#{supplierId},${price},#{toolCost},
  311. #{allCost},#{ifsPrNo},#{poNumber},#{remark},#{username},GetDate(),#{planner},#{applicant})
  312. </insert>
  313. <select id="searchBIAddress" resultType="BiAddress">
  314. select top 1 menu_id ,address from BI_Address where menu_id=#{menuId}
  315. </select>
  316. <select id="getProjectUserRole" resultType="PlmUserRoleData">
  317. select site,project_id,username,searchFlag,updateFlag,downFlag,deleteFlag
  318. from AccessProject where site=#{site} and project_id=#{projectId} and username=#{username}
  319. </select>
  320. <select id="getProjectPartList" resultType="com.spring.modules.project.data.PlmProjectPartData">
  321. select
  322. id,
  323. site,
  324. project_id,
  325. test_part_no,
  326. part_type,
  327. part_desc,
  328. part_spec,
  329. material_number,
  330. remark,
  331. create_date,
  332. create_by,
  333. update_date,
  334. part_name,
  335. update_by,
  336. dbo.get_family_name(site, part_type) as partTypeDesc,
  337. final_part_no,
  338. code_no,
  339. dbo.get_code_desc(site, code_no, 'IP') as codeDesc,
  340. group_id,
  341. dbo.get_group_name(site, group_id) as groupName,
  342. product_group_id1,
  343. dbo.get_product_group_name(site, product_group_id1, '1') as productGroupName1,
  344. product_group_id2,
  345. dbo.get_product_group_name(site, product_group_id2, '2') as productGroupName2,
  346. um_id,type
  347. from view_Project_Part where site=#{site}
  348. <if test="testPartNo != null and testPartNo != ''">
  349. and test_part_no like #{testPartNo}
  350. </if>
  351. <if test="partDesc != null and partDesc != ''">
  352. and part_desc like #{partDesc}
  353. </if>
  354. <if test="projectId != null and projectId != ''">
  355. and project_id = #{projectId}
  356. and view_Project_Part.project_id = #{projectId}
  357. </if>
  358. </select>
  359. <select id="getProjectPart" resultType="com.spring.modules.project.data.PlmProjectPartData">
  360. select
  361. id,
  362. site,
  363. project_id,
  364. test_part_no,
  365. part_type,
  366. part_desc,
  367. part_spec,
  368. material_number,
  369. remark,
  370. create_date,
  371. create_by,
  372. update_date,
  373. part_name,
  374. update_by,
  375. dbo.get_family_name(site, part_type) as partTypeDesc,
  376. final_part_no,
  377. code_no,
  378. dbo.get_code_desc(site, code_no, 'IP') as codeDesc,
  379. group_id,
  380. dbo.get_group_name(site, group_id) as groupName,
  381. product_group_id1,
  382. dbo.get_product_group_name(site, product_group_id1, '1') as productGroupName1,
  383. product_group_id2,
  384. dbo.get_product_group_name(site, product_group_id2, '2') as productGroupName2
  385. from view_Project_Part where site=#{site}
  386. <if test="testPartNo != null and testPartNo != ''">
  387. and test_part_no = #{testPartNo}
  388. </if>
  389. </select>
  390. <select id="getProjectData" resultType="com.spring.modules.project.entity.PlmProjectInfo">
  391. select project_id,ori_project_id,project_type_db,project_name,status,project_source,customer_id,create_by,create_date,
  392. update_by,update_date,priority,site,id,project_desc,customer_remark,remark,need_date,bu_no,parent_project_no,final_customer_id
  393. from plm_project_info where site=#{site} and project_id=#{projectId}
  394. </select>
  395. </mapper>