TechProjectMapper.xml 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836
  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.goafanti.common.dao.TechProjectMapper">
  4. <resultMap id="BaseResultMap" type="com.goafanti.common.model.TechProject">
  5. <id column="id" property="id" jdbcType="VARCHAR" />
  6. <result column="uid" property="uid" jdbcType="VARCHAR" />
  7. <result column="serial_number" property="serialNumber"
  8. jdbcType="INTEGER" />
  9. <result column="contacts" property="contacts" jdbcType="INTEGER" />
  10. <result column="department" property="department" jdbcType="VARCHAR" />
  11. <result column="dispatch_info" property="dispatchInfo"
  12. jdbcType="VARCHAR" />
  13. <result column="project_name" property="projectName" jdbcType="VARCHAR" />
  14. <result column="project_catagory" property="projectCatagory"
  15. jdbcType="VARCHAR" />
  16. <result column="tech_field" property="techField" jdbcType="VARCHAR" />
  17. <result column="project_des" property="projectDes" jdbcType="VARCHAR" />
  18. <result column="project_mode" property="projectMode" jdbcType="INTEGER" />
  19. <result column="project_approval" property="projectApproval"
  20. jdbcType="DECIMAL" />
  21. <result column="subsidy" property="subsidy" jdbcType="INTEGER" />
  22. <result column="consultant" property="consultant" jdbcType="VARCHAR" />
  23. <result column="approval_url" property="approvalUrl" jdbcType="VARCHAR" />
  24. <result column="state" property="state" jdbcType="INTEGER" />
  25. <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  26. <result column="accept_date" property="acceptDate" jdbcType="TIMESTAMP" />
  27. <result column="approved_date" property="approvedDate"
  28. jdbcType="TIMESTAMP" />
  29. <result column="record_time" property="recordTime" jdbcType="TIMESTAMP" />
  30. <result column="deleted_sign" property="deletedSign" jdbcType="INTEGER" />
  31. <result column="founder" property="founder" jdbcType="VARCHAR" />
  32. <result column="contract_id" property="contractId" jdbcType="VARCHAR" />
  33. <result column="principal" property="principal" jdbcType="VARCHAR" />
  34. </resultMap>
  35. <sql id="Base_Column_List">
  36. id, uid, serial_number, contacts, department, dispatch_info,
  37. project_name, project_catagory,
  38. tech_field, project_des, project_mode, project_approval, subsidy, consultant,
  39. approval_url,
  40. state, create_time, accept_date, approved_date, record_time, deleted_sign,
  41. founder, contract_id, principal
  42. </sql>
  43. <select id="selectByPrimaryKey" resultMap="BaseResultMap"
  44. parameterType="java.lang.String">
  45. select
  46. <include refid="Base_Column_List" />
  47. from tech_project
  48. where id = #{id,jdbcType=VARCHAR}
  49. </select>
  50. <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
  51. delete from tech_project
  52. where id = #{id,jdbcType=VARCHAR}
  53. </delete>
  54. <insert id="insert" parameterType="com.goafanti.common.model.TechProject">
  55. insert into tech_project (id, uid, serial_number,
  56. contacts, department, dispatch_info,
  57. project_name, project_catagory, tech_field,
  58. project_des, project_mode, project_approval,
  59. subsidy, consultant, approval_url,
  60. state, create_time, accept_date,
  61. approved_date, record_time, deleted_sign, founder, contract_id, principal
  62. )
  63. values (#{id,jdbcType=VARCHAR}, #{uid,jdbcType=VARCHAR},
  64. #{serialNumber,jdbcType=INTEGER},
  65. #{contacts,jdbcType=INTEGER}, #{department,jdbcType=VARCHAR}, #{dispatchInfo,jdbcType=VARCHAR},
  66. #{projectName,jdbcType=VARCHAR}, #{projectCatagory,jdbcType=VARCHAR},
  67. #{techField,jdbcType=VARCHAR},
  68. #{projectDes,jdbcType=VARCHAR}, #{projectMode,jdbcType=INTEGER}, #{projectApproval,jdbcType=DECIMAL},
  69. #{subsidy,jdbcType=INTEGER}, #{consultant,jdbcType=VARCHAR},
  70. #{approvalUrl,jdbcType=VARCHAR},
  71. #{state,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{acceptDate,jdbcType=TIMESTAMP},
  72. #{approvedDate,jdbcType=TIMESTAMP}, #{recordTime,jdbcType=TIMESTAMP},
  73. #{deletedSign,jdbcType=INTEGER}, #{founder,jdbcType=VARCHAR}, #{contractId,jdbcType=VARCHAR},
  74. #{principal,jdbcType=VARCHAR}
  75. )
  76. </insert>
  77. <insert id="insertSelective" parameterType="com.goafanti.common.model.TechProject">
  78. insert into tech_project
  79. <trim prefix="(" suffix=")" suffixOverrides=",">
  80. <if test="id != null">
  81. id,
  82. </if>
  83. <if test="uid != null">
  84. uid,
  85. </if>
  86. <if test="serialNumber != null">
  87. serial_number,
  88. </if>
  89. <if test="contacts != null">
  90. contacts,
  91. </if>
  92. <if test="department != null">
  93. department,
  94. </if>
  95. <if test="dispatchInfo != null">
  96. dispatch_info,
  97. </if>
  98. <if test="projectName != null">
  99. project_name,
  100. </if>
  101. <if test="projectCatagory != null">
  102. project_catagory,
  103. </if>
  104. <if test="techField != null">
  105. tech_field,
  106. </if>
  107. <if test="projectDes != null">
  108. project_des,
  109. </if>
  110. <if test="projectMode != null">
  111. project_mode,
  112. </if>
  113. <if test="projectApproval != null">
  114. project_approval,
  115. </if>
  116. <if test="subsidy != null">
  117. subsidy,
  118. </if>
  119. <if test="consultant != null">
  120. consultant,
  121. </if>
  122. <if test="approvalUrl != null">
  123. approval_url,
  124. </if>
  125. <if test="state != null">
  126. state,
  127. </if>
  128. <if test="createTime != null">
  129. create_time,
  130. </if>
  131. <if test="acceptDate != null">
  132. accept_date,
  133. </if>
  134. <if test="approvedDate != null">
  135. approved_date,
  136. </if>
  137. <if test="recordTime != null">
  138. record_time,
  139. </if>
  140. <if test="deletedSign != null">
  141. deleted_sign,
  142. </if>
  143. <if test="founder != null">
  144. founder,
  145. </if>
  146. <if test="contractId != null">
  147. contract_id,
  148. </if>
  149. <if test="principal != null">
  150. principal,
  151. </if>
  152. </trim>
  153. <trim prefix="values (" suffix=")" suffixOverrides=",">
  154. <if test="id != null">
  155. #{id,jdbcType=VARCHAR},
  156. </if>
  157. <if test="uid != null">
  158. #{uid,jdbcType=VARCHAR},
  159. </if>
  160. <if test="serialNumber != null">
  161. #{serialNumber,jdbcType=INTEGER},
  162. </if>
  163. <if test="contacts != null">
  164. #{contacts,jdbcType=INTEGER},
  165. </if>
  166. <if test="department != null">
  167. #{department,jdbcType=VARCHAR},
  168. </if>
  169. <if test="dispatchInfo != null">
  170. #{dispatchInfo,jdbcType=VARCHAR},
  171. </if>
  172. <if test="projectName != null">
  173. #{projectName,jdbcType=VARCHAR},
  174. </if>
  175. <if test="projectCatagory != null">
  176. #{projectCatagory,jdbcType=VARCHAR},
  177. </if>
  178. <if test="techField != null">
  179. #{techField,jdbcType=VARCHAR},
  180. </if>
  181. <if test="projectDes != null">
  182. #{projectDes,jdbcType=VARCHAR},
  183. </if>
  184. <if test="projectMode != null">
  185. #{projectMode,jdbcType=INTEGER},
  186. </if>
  187. <if test="projectApproval != null">
  188. #{projectApproval,jdbcType=DECIMAL},
  189. </if>
  190. <if test="subsidy != null">
  191. #{subsidy,jdbcType=INTEGER},
  192. </if>
  193. <if test="consultant != null">
  194. #{consultant,jdbcType=VARCHAR},
  195. </if>
  196. <if test="approvalUrl != null">
  197. #{approvalUrl,jdbcType=VARCHAR},
  198. </if>
  199. <if test="state != null">
  200. #{state,jdbcType=INTEGER},
  201. </if>
  202. <if test="createTime != null">
  203. #{createTime,jdbcType=TIMESTAMP},
  204. </if>
  205. <if test="acceptDate != null">
  206. #{acceptDate,jdbcType=TIMESTAMP},
  207. </if>
  208. <if test="approvedDate != null">
  209. #{approvedDate,jdbcType=TIMESTAMP},
  210. </if>
  211. <if test="recordTime != null">
  212. #{recordTime,jdbcType=TIMESTAMP},
  213. </if>
  214. <if test="deletedSign != null">
  215. #{deletedSign,jdbcType=INTEGER},
  216. </if>
  217. <if test="founder != null">
  218. #{founder,jdbcType=VARCHAR},
  219. </if>
  220. <if test="contractId != null">
  221. #{contractId,jdbcType=VARCHAR},
  222. </if>
  223. <if test="principal != null">
  224. #{principal,jdbcType=VARCHAR},
  225. </if>
  226. </trim>
  227. </insert>
  228. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.TechProject">
  229. update tech_project
  230. <set>
  231. <if test="uid != null">
  232. uid = #{uid,jdbcType=VARCHAR},
  233. </if>
  234. <if test="serialNumber != null">
  235. serial_number = #{serialNumber,jdbcType=INTEGER},
  236. </if>
  237. <if test="contacts != null">
  238. contacts = #{contacts,jdbcType=INTEGER},
  239. </if>
  240. <if test="department != null">
  241. department = #{department,jdbcType=VARCHAR},
  242. </if>
  243. <if test="dispatchInfo != null">
  244. dispatch_info = #{dispatchInfo,jdbcType=VARCHAR},
  245. </if>
  246. <if test="projectName != null">
  247. project_name = #{projectName,jdbcType=VARCHAR},
  248. </if>
  249. <if test="projectCatagory != null">
  250. project_catagory = #{projectCatagory,jdbcType=VARCHAR},
  251. </if>
  252. <if test="techField != null">
  253. tech_field = #{techField,jdbcType=VARCHAR},
  254. </if>
  255. <if test="projectDes != null">
  256. project_des = #{projectDes,jdbcType=VARCHAR},
  257. </if>
  258. <if test="projectMode != null">
  259. project_mode = #{projectMode,jdbcType=INTEGER},
  260. </if>
  261. <if test="projectApproval != null">
  262. project_approval = #{projectApproval,jdbcType=DECIMAL},
  263. </if>
  264. <if test="subsidy != null">
  265. subsidy = #{subsidy,jdbcType=INTEGER},
  266. </if>
  267. <if test="consultant != null">
  268. consultant = #{consultant,jdbcType=VARCHAR},
  269. </if>
  270. <if test="approvalUrl != null">
  271. approval_url = #{approvalUrl,jdbcType=VARCHAR},
  272. </if>
  273. <if test="state != null">
  274. state = #{state,jdbcType=INTEGER},
  275. </if>
  276. <if test="createTime != null">
  277. create_time = #{createTime,jdbcType=TIMESTAMP},
  278. </if>
  279. <if test="acceptDate != null">
  280. accept_date = #{acceptDate,jdbcType=TIMESTAMP},
  281. </if>
  282. <if test="approvedDate != null">
  283. approved_date = #{approvedDate,jdbcType=TIMESTAMP},
  284. </if>
  285. <if test="recordTime != null">
  286. record_time = #{recordTime,jdbcType=TIMESTAMP},
  287. </if>
  288. <if test="deletedSign != null">
  289. deleted_sign = #{deletedSign,jdbcType=INTEGER},
  290. </if>
  291. <if test="founder != null">
  292. founder = #{founder,jdbcType=VARCHAR},
  293. </if>
  294. <if test="contractId != null">
  295. contract_id = #{contractId,jdbcType=VARCHAR},
  296. </if>
  297. <if test="principal != null">
  298. principal = #{principal,jdbcType=VARCHAR},
  299. </if>
  300. </set>
  301. where id = #{id,jdbcType=VARCHAR}
  302. </update>
  303. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.TechProject">
  304. update tech_project
  305. set uid = #{uid,jdbcType=VARCHAR},
  306. serial_number = #{serialNumber,jdbcType=INTEGER},
  307. contacts = #{contacts,jdbcType=INTEGER},
  308. department = #{department,jdbcType=VARCHAR},
  309. dispatch_info = #{dispatchInfo,jdbcType=VARCHAR},
  310. project_name = #{projectName,jdbcType=VARCHAR},
  311. project_catagory = #{projectCatagory,jdbcType=VARCHAR},
  312. tech_field = #{techField,jdbcType=VARCHAR},
  313. project_des = #{projectDes,jdbcType=VARCHAR},
  314. project_mode = #{projectMode,jdbcType=INTEGER},
  315. project_approval = #{projectApproval,jdbcType=DECIMAL},
  316. subsidy = #{subsidy,jdbcType=INTEGER},
  317. consultant = #{consultant,jdbcType=VARCHAR},
  318. approval_url = #{approvalUrl,jdbcType=VARCHAR},
  319. state = #{state,jdbcType=INTEGER},
  320. create_time = #{createTime,jdbcType=TIMESTAMP},
  321. accept_date = #{acceptDate,jdbcType=TIMESTAMP},
  322. approved_date = #{approvedDate,jdbcType=TIMESTAMP},
  323. record_time = #{recordTime,jdbcType=TIMESTAMP},
  324. deleted_sign = #{deletedSign,jdbcType=INTEGER},
  325. founder = #{founder,jdbcType=VARCHAR},
  326. contract_id = #{contractId,jdbcType=VARCHAR},
  327. principal = #{principal,jdbcType=VARCHAR}
  328. where id = #{id,jdbcType=VARCHAR}
  329. </update>
  330. <select id="findTechProjectClientListByPage" parameterType="java.lang.String"
  331. resultType="com.goafanti.techproject.bo.TechProjectClientListBo">
  332. select p.id, p.uid, i.location_province as province,
  333. i.unit_name as unitName,
  334. p.serial_number as serialNumber, p.create_time as createTime, p.approved_date as approvedDate,
  335. p.accept_date as acceptDate, a.name as consultant, p.contacts,
  336. p.project_name as projectName, p.project_catagory as projectCatagory, p.tech_field as techField, p.state
  337. FROM tech_project p
  338. LEFT JOIN organization_identity i on i.uid = p.uid
  339. LEFT JOIN admin a on p.consultant = a.id
  340. where p.deleted_sign = 0
  341. <if test ="uid != null">
  342. and p.uid = #{uid,jdbcType=VARCHAR}
  343. </if>
  344. order by p.serial_number desc
  345. <if test="page_sql!=null">
  346. ${page_sql}
  347. </if>
  348. </select>
  349. <select id="findTechProjectClientCount" resultType="java.lang.Integer" parameterType="String">
  350. select count(1)
  351. FROM tech_project p
  352. LEFT JOIN organization_identity i on i.uid = p.uid
  353. LEFT JOIN admin a on p.consultant = a.id
  354. where p.deleted_sign = 0
  355. <if test ="uid != null">
  356. and p.uid = #{uid,jdbcType=VARCHAR}
  357. </if>
  358. </select>
  359. <select id ="findTechProjectManageListByPage" parameterType="java.lang.String"
  360. resultType="com.goafanti.techproject.bo.TechProjectManageListBo">
  361. select p.id, p.uid, i.licence_province as province, p.contract_id as contractId,
  362. i.unit_name as unitName,
  363. p.serial_number as serialNumber, p.create_time as createTime, p.approved_date as approvedDate,
  364. p.accept_date as acceptDate, a.name as consultant, p.contacts, ad.name as founder,
  365. p.project_name as projectName, p.project_catagory as projectCatagory, p.tech_field as techField, p.state,
  366. w.id as wid, w.website, w.account_number as accountNumber, w.department,
  367. w.password, c.serial_number as contractNumber
  368. FROM tech_project p
  369. LEFT JOIN organization_identity i on i.uid = p.uid
  370. LEFT JOIN admin a on p.consultant = a.id
  371. LEFT JOIN admin ad on p.founder = ad.id
  372. LEFT JOIN tech_website w on p.department = w.id
  373. LEFT JOIN contract c on c.id = p.contract_id
  374. <if test="principal != null">
  375. left join contract_log l on p.contract_id=l.cid
  376. </if>
  377. where p.deleted_sign = 0 and (w.deleted_sign is null or w.deleted_sign = 0)
  378. <if test="principal != null">
  379. and l.principal = #{principal,jdbcType=VARCHAR}
  380. </if>
  381. <if test="contractId != null">
  382. and p.contract_id = #{contractId,jdbcType=VARCHAR}
  383. </if>
  384. <if test="province != null">
  385. and i.licence_province = #{province,jdbcType=INTEGER}
  386. </if>
  387. <if test="uid != null">
  388. and p.uid = #{uid,jdbcType=VARCHAR}
  389. </if>
  390. <if test="unitName != null" >
  391. and i.unit_name like CONCAT('%', #{unitName,jdbcType=VARCHAR}, '%')
  392. </if>
  393. <if test="principal != null">
  394. group by p.id,i.id
  395. </if>
  396. order by p.serial_number desc
  397. <if test="page_sql!=null">
  398. ${page_sql}
  399. </if>
  400. </select>
  401. <select id="findTechProjectManageCount" resultType="java.lang.Integer" parameterType="String">
  402. select count(distinct(p.id))
  403. FROM tech_project p
  404. LEFT JOIN organization_identity i on i.uid = p.uid
  405. LEFT JOIN tech_website w on p.department = w.id
  406. <if test="principal != null">
  407. left join contract_log l on p.contract_id=l.cid
  408. </if>
  409. where p.deleted_sign = 0 and (w.deleted_sign is null or w.deleted_sign = 0)
  410. <if test="principal != null">
  411. and l.principal = #{principal,jdbcType=VARCHAR}
  412. </if>
  413. <if test="contractId != null">
  414. and p.contract_id = #{contractId,jdbcType=VARCHAR}
  415. </if>
  416. <if test="province != null">
  417. and i.licence_province = #{province,jdbcType=INTEGER}
  418. </if>
  419. <if test="uid != null">
  420. and p.uid = #{uid,jdbcType=VARCHAR}
  421. </if>
  422. <if test="unitName != null" >
  423. and i.unit_name like CONCAT('%', #{unitName,jdbcType=VARCHAR}, '%')
  424. </if>
  425. </select>
  426. <select id="selectProjectDetail" resultType="com.goafanti.techproject.bo.TechProjectDetailBo" parameterType="java.lang.String">
  427. select
  428. p.id, p.uid, i.licence_province as province,
  429. i.licence_city as city, i.licence_area as area, i.postal_address as postalAddress,
  430. i.unit_name as unitName, i.org_code as orgCode, p.serial_number as serialNumber,
  431. a.name as consultant, p.contacts, p.project_des as projectDes,
  432. p.subsidy, p.dispatch_info as dispatchInfo, p.project_mode as projectMode,
  433. p.project_approval as projectApproval, p.approval_url as approvalUrl , p.department,
  434. p.project_name as projectName, p.project_catagory as projectCatagory, p.tech_field as techField,
  435. p.state
  436. FROM tech_project p
  437. LEFT JOIN organization_identity i on i.uid = p.uid
  438. LEFT JOIN admin a on p.consultant = a.id
  439. where p.deleted_sign = 0 and p.id = #{uid,jdbcType=VARCHAR}
  440. </select>
  441. <update id="batchDeleteByPrimaryKey" parameterType="java.util.List">
  442. update tech_project set deleted_sign = 1
  443. where id in
  444. <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
  445. #{item}
  446. </foreach>
  447. </update>
  448. <select id="countTechProjectDone" resultType="java.lang.Integer">
  449. select
  450. count(1)
  451. from tech_project
  452. where uid = #{uid,jdbcType=VARCHAR}
  453. and
  454. deleted_sign = 0
  455. and state in (6,8)
  456. and approved_date >=
  457. (
  458. select
  459. str_to_date(CONCAT(#{year,jdbcType=INTEGER}-3,'-01-01'), '%Y-%m-%d %H')
  460. )
  461. and approved_date <![CDATA[ < ]]>
  462. (
  463. select
  464. str_to_date(CONCAT(#{year,jdbcType=INTEGER},'-01-01'), '%Y-%m-%d %H')
  465. )
  466. </select>
  467. <select id="countTechProjectUndone" resultType="java.lang.Integer">
  468. select
  469. count(1)
  470. from tech_project
  471. where uid = #{uid,jdbcType=VARCHAR}
  472. and deleted_sign = 0
  473. and state in (1,2,3,4,5,7)
  474. and approved_date >=
  475. (
  476. select
  477. str_to_date(CONCAT(#{year,jdbcType=INTEGER}-3,'-01-01'), '%Y-%m-%d %H')
  478. )
  479. and approved_date <![CDATA[ < ]]>
  480. (
  481. select
  482. str_to_date(CONCAT(#{year,jdbcType=INTEGER},'-01-01'), '%Y-%m-%d %H')
  483. )
  484. </select>
  485. <select id="selectWebsiteUnitNames" parameterType="java.lang.String" resultType="com.goafanti.user.bo.OrgUnitNames">
  486. select distinct(oi.uid), oi.unit_name as unitName
  487. from tech_project tp
  488. LEFT JOIN organization_identity oi on oi.uid = tp.uid
  489. <if test="_parameter != null">
  490. LEFT JOIN tech_project_log tpl on tp.id = tpl.pid
  491. </if>
  492. where tp.deleted_sign = 0
  493. <if test="_parameter != null">
  494. and tpl.principal = #{principal,jdbcType=VARCHAR}
  495. </if>
  496. <if test="_parameter != null">
  497. group by tp.id,oi.id
  498. </if>
  499. </select>
  500. <select id="listContractTechProjectByContractId" parameterType="java.lang.String" resultType="com.goafanti.techproject.bo.TechProjectContractListBo">
  501. select
  502. tp.id, tp.uid, tp.contract_id as contractId,
  503. tp.project_name as projectName, tp.project_catagory as projectCatagory, tp.state,
  504. tp.tech_field as techField, a.name as principle
  505. from tech_project tp
  506. left join admin a on a.id = tp.principal
  507. where tp.contract_id = #{contractId,jdbcType=VARCHAR}
  508. </select>
  509. <insert id="batchInsert" parameterType="com.goafanti.common.model.TechProject">
  510. insert into tech_project (id, uid, serial_number,
  511. contacts, department, dispatch_info,
  512. project_name, project_catagory, tech_field,
  513. project_des, project_mode, project_approval,
  514. subsidy, consultant, approval_url,
  515. state, create_time, accept_date,
  516. approved_date, record_time, deleted_sign, founder, contract_id, principal
  517. )
  518. values
  519. <foreach item="item" index="index" collection="list" separator=",">
  520. (
  521. #{item.id,jdbcType=VARCHAR}, #{item.uid,jdbcType=VARCHAR},
  522. #{item.serialNumber,jdbcType=INTEGER},
  523. #{item.contacts,jdbcType=INTEGER}, #{item.department,jdbcType=VARCHAR}, #{item.dispatchInfo,jdbcType=VARCHAR},
  524. #{item.projectName,jdbcType=VARCHAR}, #{item.projectCatagory,jdbcType=VARCHAR},
  525. #{item.techField,jdbcType=VARCHAR},
  526. #{item.projectDes,jdbcType=VARCHAR}, #{item.projectMode,jdbcType=INTEGER}, #{item.projectApproval,jdbcType=DECIMAL},
  527. #{item.subsidy,jdbcType=INTEGER}, #{item.consultant,jdbcType=VARCHAR},
  528. #{item.approvalUrl,jdbcType=VARCHAR},
  529. #{item.state,jdbcType=INTEGER}, #{item.createTime,jdbcType=TIMESTAMP}, #{item.acceptDate,jdbcType=TIMESTAMP},
  530. #{item.approvedDate,jdbcType=TIMESTAMP}, #{item.recordTime,jdbcType=TIMESTAMP},
  531. #{item.deletedSign,jdbcType=INTEGER}, #{item.founder,jdbcType=VARCHAR}, #{item.contractId,jdbcType=VARCHAR},
  532. #{item.principal,jdbcType=VARCHAR}
  533. )
  534. </foreach>
  535. </insert>
  536. <select id="findTechProjectNumByUid" parameterType="java.lang.String" resultType="java.lang.Integer">
  537. select
  538. count(1)
  539. from tech_project
  540. where
  541. deleted_sign = 0
  542. and uid = #{uid,jdbcType=VARCHAR}
  543. </select>
  544. <update id="batchDeleteByContractId" parameterType="java.util.List">
  545. update tech_project set deleted_sign = 1
  546. where contract_id in
  547. <foreach item="item" index="index" collection="list" open="("
  548. separator="," close=")">
  549. #{item}
  550. </foreach>
  551. </update>
  552. <select id="listProjectByPage" resultType="com.goafanti.techproject.bo.ProjectListBo">
  553. select
  554. a.id,
  555. a.serial_number as serialNumber,
  556. date_format(a.sign_date,'%Y-%m-%d %H:%i:%S') as signDate,
  557. date_format(a.create_time,'%Y-%m-%d %H:%i:%S') as projectTime,
  558. a.uid,
  559. a.status as projectStatus,
  560. a.deleted_sign as deletedSign,
  561. a.order_no as orderNo,
  562. a.type as projectType,
  563. b.nickname as buyerName,
  564. b.type as buyerType,
  565. f.cname as buyerType,
  566. c.create_time as orderTime,
  567. c.order_status as orderStatus,
  568. c.liquidation_status as liquidationStatus,
  569. c.approval,
  570. d.name as salesmanName,
  571. e.name as departmentName
  572. from
  573. contract a left join user b on
  574. a.uid = b.id left join t_order c on
  575. a.order_no = c.order_no left join admin d on
  576. c.salesman_id = d.id left join department_management e on
  577. d.department_id = e.id left join business_varieties f on
  578. a.type = f.id
  579. where 1=1
  580. <if test="deleteSign != null">
  581. and a.deleted_sign = #{deletedSign,jdbcType=INTEGER}
  582. </if>
  583. <if test="orderNo != null and orderNo != ''">
  584. and a.order_no = #{orderNo,jdbcType=VARCHAR}
  585. </if>
  586. <if test="serialNumber != null and serialNumber != ''">
  587. and a.serial_number = #{serialNumber,jdbcType=VARCHAR}
  588. </if>
  589. <if test="setUpStartDate != null and setUpStartDate != ''">
  590. and a.create_time &gt; #{setUpStartDate,jdbcType=TIMESTAMP}
  591. </if>
  592. <if test="setUpEndDate != null and setUpEndDate != ''">
  593. and a.create_time &lt; #{setUpEndDate,jdbcType=TIMESTAMP}
  594. </if>
  595. <if test="buyerName != null and buyerName != ''">
  596. and b.nickname = #{buyerName,jdbcType=VARCHAR}
  597. </if>
  598. <if test="salesmanName != null and salesmanName !=''">
  599. and d.name = #{salesmanName,jdbcType=VARCHAR}
  600. </if>
  601. <if test="depId != null and depId != ''">
  602. and d.department_id = #{depId,jdbcType=VARCHAR}
  603. </if>
  604. <if test="orderStartDate != null and orderStartDate != ''">
  605. and c.create_time &gt; #{orderStartDate,jdbcType=TIMESTAMP}
  606. </if>
  607. <if test="orderEndDate != null and orderEndDate != ''">
  608. and c.create_time &lt; #{orderEndDate,jdbcType=TIMESTAMP}
  609. </if>
  610. <if test="page_sql != null">
  611. ${page_sql}
  612. </if>
  613. </select>
  614. <select id="listProjectCount" resultType="java.lang.Integer">
  615. select
  616. count(0)
  617. from
  618. contract a left join user b on
  619. a.uid = b.id left join t_order c on
  620. a.order_no = c.order_no left join admin d on
  621. c.salesman_id = d.id left join department_management e on
  622. d.department_id = e.id left join business_varieties f on
  623. a.type = f.id
  624. where 1=1
  625. <if test="deletedSign != null">
  626. and a.deleted_sign = #{deletedSign,jdbcType=INTEGER}
  627. </if>
  628. <if test="orderNo != null and orderNo != ''">
  629. and a.order_no = #{orderNo,jdbcType=VARCHAR}
  630. </if>
  631. <if test="serialNumber != null and serialNumber != ''">
  632. and a.serial_number = #{serialNumber,jdbcType=VARCHAR}
  633. </if>
  634. <if test="setUpStartDate != null and setUpStartDate != ''">
  635. and a.create_time &gt; #{setUpStartDate,jdbcType=TIMESTAMP}
  636. </if>
  637. <if test="setUpEndDate != null and setUpEndDate != ''">
  638. and a.create_time &lt; #{setUpEndDate,jdbcType=TIMESTAMP}
  639. </if>
  640. <if test="buyerName != null and buyerName != ''">
  641. and b.nickname = #{buyerName,jdbcType=VARCHAR}
  642. </if>
  643. <if test="salesmanName != null and salesmanName !=''">
  644. and d.name = #{salesmanName,jdbcType=VARCHAR}
  645. </if>
  646. <if test="depId != null and depId != ''">
  647. and d.department_id = #{depId,jdbcType=VARCHAR}
  648. </if>
  649. <if test="orderStartDate != null and orderStartDate != ''">
  650. and c.create_time &gt; #{orderStartDate,jdbcType=TIMESTAMP}
  651. </if>
  652. <if test="orderEndDate != null and orderEndDate != ''">
  653. and c.create_time &lt; #{orderEndDate,jdbcType=TIMESTAMP}
  654. </if>
  655. </select>
  656. <select id="selectTechProjectDetail" resultType="com.goafanti.techproject.bo.ProjectDetailBo">
  657. <choose>
  658. <when test="buyerType == 0">
  659. select
  660. a.id,
  661. a.serial_number as serialNumber,
  662. a.sign_date as signDate,
  663. a.sign_comment as signComment,
  664. a.complete_date as completeDate,
  665. a.complete_comment as completeComment,
  666. a.uid,
  667. a.status as projectStatus,
  668. a.deleted_sign as deletedSign,
  669. a.order_no as orderNo,
  670. a.type as projectType,
  671. b.nickname as buyerName,
  672. c.name as technicianName,
  673. d.name as principalName,
  674. f.name as buyerProvince,
  675. g.cname as projectType
  676. from
  677. contract a left join user b on
  678. a.uid = b.id left join admin c on
  679. a.uid = c.id left join admin d on
  680. a.principal = d.id left join user_identity e on
  681. a.uid = e.uid left join district_glossory f on
  682. e.province = f.id left join business_varieties g on
  683. a.type = g.id
  684. where a.id = #{contractId,jdbcType=VARCHAR}
  685. </when>
  686. <when test="buyerType == 1">
  687. select
  688. a.id,
  689. a.serial_number as serialNumber,
  690. a.sign_date as signDate,
  691. a.sign_comment as signComment,
  692. a.complete_date as completeDate,
  693. a.complete_comment as completeComment,
  694. a.uid,
  695. a.status as projectStatus,
  696. a.deleted_sign as deletedSign,
  697. a.order_no as orderNo,
  698. a.type as projectType,
  699. b.nickname as buyerName,
  700. c.name as technicianName,
  701. d.name as principalName,
  702. f.name as buyerProvince,
  703. g.cname as projectType
  704. from
  705. contract a left join user b on
  706. a.uid = b.id left join admin c on
  707. a.uid = c.id left join admin d on
  708. a.principal = d.id left join organization_identity e on
  709. a.uid = e.uid left join district_glossory f on
  710. e.location_province = f.id left join business_varieties g on
  711. a.type = g.id
  712. where a.id = #{contractId,jdbcType=VARCHAR}
  713. </when>
  714. </choose>
  715. </select>
  716. <select id="selectProjectTask" resultType="com.goafanti.techproject.bo.TaskListBo">
  717. select
  718. a.id as taskId,
  719. a.commodity_name as commodityName,
  720. a.commodity_quantity as commodityQuantity,
  721. a.task_status as taskStatus,
  722. a.deleted_sign as deletedSign,
  723. a.task_comment as taskComment,
  724. b.name as technicianName
  725. from
  726. contract_task a left join admin b on
  727. a.task_receiver = b.id
  728. where a.contract_id = #{contractId,jdbcType=VARCHAR}
  729. </select>
  730. <select id="selectProjectTaskByPage" resultType="com.goafanti.techproject.bo.TaskListBo">
  731. select
  732. a.id as taskId,
  733. a.commodity_id as commodityId,
  734. a.serial_number as taskNo,
  735. a.task_status as taskStatus,
  736. a.deleted_sign as deletedSign,
  737. date_format(a.task_distribution_time,'%Y-%m-%d %H:%i:%S') as taskDistributionTimes,
  738. a.task_comment as taskComment,
  739. b.bname as commodityName ,
  740. c.cname as categoryName,
  741. c.id as categoryId,
  742. d.serial_number as projectNo,
  743. d.status,
  744. d.deleted_sign as deletedSign,
  745. e.nickname as buyerName,
  746. f.name as taskReceiverName
  747. from
  748. contract_task a left join business_project b on
  749. a.commodity_id = b.id left join business_varieties c on
  750. b.cid = c.id left join contract d on
  751. a.contract_id = d.id left join user e on
  752. d.uid = e.id left join admin f on
  753. a.task_receiver = f.id
  754. where 1=1
  755. <if test="taskReceiverId != null and taskReceiverId != ''">
  756. and a.task_receiver = #{taskReceiverId,jdbcType=VARCHAR}
  757. </if>
  758. <if test="taskStatus != null">
  759. and a.task_status = #{taskStatus,jdbcType=VARCHAR}
  760. </if>
  761. <if test="startDate != null">
  762. and a.task_distribution_time &gt; #{startDate,jdbcType=TIMESTAMP}
  763. </if>
  764. <if test="endDate != null">
  765. and a.task_distribution_time &lt; #{endDate,jdbcType=TIMESTAMP}
  766. </if>
  767. <if test="projectNo != null and projectNo != ''">
  768. and d.serial_number = #{projectNo,jdbcType=VARCHAR}
  769. </if>
  770. <if test="buyerName != null and buyerName != ''">
  771. and e.nickname = #{buyerName,jdbcType=VARCHAR}
  772. </if>
  773. <if test="taskReceiverName != null and taskReceiverName != ''">
  774. and f.name = #{taskReceiverName,jdbcType=VARCHAR}
  775. </if>
  776. <if test="categoryId != null and categoryId != ''">
  777. and c.id = #{categoryId,jdbcType=VARCHAR}
  778. </if>
  779. <if test="page_sql != null">
  780. ${page_sql}
  781. </if>
  782. </select>
  783. <select id="selectProjectTaskCount" resultType="java.lang.Integer">
  784. select
  785. count(0)
  786. from
  787. contract_task a left join business_project b on
  788. a.commodity_id = b.id left join business_varieties c on
  789. b.cid = c.id left join contract d on
  790. a.contract_id = d.id left join user e on
  791. d.uid = e.id left join admin f on
  792. a.task_receiver = f.id
  793. where 1=1
  794. <if test="taskReceiverId != null and taskReceiverId != ''">
  795. and a.task_receiver = #{taskReceiverId,jdbcType=VARCHAR}
  796. </if>
  797. <if test="taskStatus != null">
  798. and a.task_status = #{taskStatus,jdbcType=VARCHAR}
  799. </if>
  800. <if test="startDate != null">
  801. and a.task_distribution_time &gt; #{startDate,jdbcType=TIMESTAMP}
  802. </if>
  803. <if test="endDate != null">
  804. and a.task_distribution_time &lt; #{endDate,jdbcType=TIMESTAMP}
  805. </if>
  806. <if test="projectNo != null and projectNo != ''">
  807. and d.serial_number = #{projectNo,jdbcType=VARCHAR}
  808. </if>
  809. <if test="buyerName != null and buyerName != ''">
  810. and e.nickname = #{buyerName,jdbcType=VARCHAR}
  811. </if>
  812. <if test="taskReceiverName != null and taskReceiverName != ''">
  813. and f.name = #{taskReceiverName,jdbcType=VARCHAR}
  814. </if>
  815. <if test="categoryId != null and categoryId != ''">
  816. and c.id = #{categoryId,jdbcType=VARCHAR}
  817. </if>
  818. </select>
  819. </mapper>