CompanyDao.xml 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788
  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="platform.modules.build.dao.CompanyDao">
  4. <select id="findByCompanyName" resultType="platform.modules.build.entity.Company">
  5. SELECT * FROM y_company u WHERE u.company_name = #{company_name}
  6. and u.del_flag=0 limit 0,1
  7. </select>
  8. <select id="findListByCompanyName" resultType="platform.modules.build.entity.Company">
  9. SELECT * FROM y_company u
  10. WHERE
  11. 1=1
  12. <if test="company_name!=null and company_name!=''">
  13. and
  14. u.company_name LIKE CONCAT('%',#{company_name},'%')
  15. </if>
  16. <if test="ids.size() > 0 ">
  17. AND u.id NOT IN
  18. <foreach collection="ids" index="index" item="item" open="(" separator="," close=")">
  19. #{item}
  20. </foreach>
  21. </if>
  22. and u.del_flag=0
  23. </select>
  24. <select id="findListByCompanyIds" resultType="platform.modules.build.entity.Company">
  25. SELECT * FROM y_company u
  26. WHERE
  27. id in
  28. <foreach item="item" index="index" collection="ids"
  29. open="(" separator="," close=")">
  30. #{item}
  31. </foreach>
  32. and u.del_flag=0
  33. </select>
  34. <select id="findCompanyFee" resultType="platform.modules.build.DTO.CompanyFeeDto">
  35. select
  36. temp.fee_id ,
  37. temp.fee_type ,
  38. temp.total_fee ,
  39. temp.status ,
  40. temp.pay_time ,
  41. temp.is_paid,
  42. temp.remind_count
  43. from (
  44. select
  45. p.id as fee_id,
  46. case when p.fee_type='0' then '停车费' else '物业费' end as fee_type,
  47. (p.price*p.number*p.payment_cycle) as total_fee,
  48. case when p.actural_paid_date is null then '未缴费' else '已缴费' end as status,
  49. case when p.actural_paid_date is null then '0' else '1' end as is_paid,
  50. p.pay_time as pay_time,
  51. p.create_time,
  52. p.update_time,
  53. ifnull(p.remind_count,0) as remind_count
  54. FROM y_contract_property p
  55. where p.company_id=#{company_id} and p.del_flag=0
  56. union
  57. select
  58. tenancy.id as fee_id,
  59. '房租' as fee_type,
  60. tenancy.house_fee as total_fee,
  61. case tenancy.`status` when '0' then '未缴费' when'1' then '部分缴费' else '已缴费' end as status,
  62. case tenancy.`status` when '0' then '0' when'1' then '1' else '0' end as is_paid,
  63. tenancy.pay_time as pay_time,
  64. tenancy.create_time,
  65. tenancy.update_time,
  66. ifnull(tenancy.remind_count,0) as remind_count
  67. FROM y_contract_tenancy tenancy
  68. where tenancy.company_id=#{company_id} and tenancy.del_flag=0
  69. union
  70. select
  71. water.id as fee_id,
  72. '水费' as fee_type,
  73. water.water_fee as total_fee,
  74. case when water.status='2' then '已缴费' else '未缴费' end as status,
  75. case when water.status='2' then '1' else '0' end as is_paid,
  76. '' as pay_time,
  77. water.create_time,
  78. water.update_time,
  79. ifnull(water.remind_count,0) as remind_count
  80. FROM y_water_fee water
  81. where water.company_id=#{company_id} and water.del_flag=0 and is_water=true
  82. union
  83. select
  84. electric.id as fee_id,
  85. '电费' as fee_type,
  86. electric.electric_fee as total_fee,
  87. case when electric.status='2' then '已缴费' else '未缴费' end as status,
  88. case when electric.status='2' then '1' else '0' end as is_paid,
  89. '' as pay_time,
  90. electric.create_time,
  91. electric.update_time,
  92. ifnull(electric.remind_count,0) as remind_count
  93. FROM y_electric_fee electric
  94. where electric.company_id=#{company_id} and electric.del_flag=0 and is_electric=true
  95. ) temp
  96. where 1=1
  97. <if test="is_paid!=null">
  98. and temp.is_paid = #{is_paid}
  99. </if>
  100. <if test="fee_type!=null and fee_type!=''">
  101. and temp.fee_type = #{fee_type}
  102. </if>
  103. <if test="status!=null and status!=''">
  104. and temp.status = #{status}
  105. </if>
  106. order by temp.remind_count desc, temp.is_paid asc, temp.pay_time asc
  107. <if test="count!=null">
  108. limit #{count}
  109. </if>
  110. </select>
  111. <select id="getCompanyCountByStreetName" resultType="Integer">
  112. SELECT count(u.id) FROM y_company u
  113. left join s_street s on s.id=u.street_id
  114. WHERE s.name = #{name}
  115. and u.del_flag=0 and u.is_register = 1
  116. </select>
  117. <select id="findCuntCompanyByBuildId" resultType="Integer">
  118. SELECT count(id) FROM y_company u WHERE u.build_id = #{build_id}
  119. and u.del_flag=0 and u.is_start=1 and u.is_register = 1
  120. <![CDATA[ and DATE_FORMAT(u.`create_time`, '%Y-%m-%d')>= DATE_FORMAT(#{date_from}, '%Y-%m-%d') ]]>
  121. <![CDATA[ and DATE_FORMAT(u.`create_time`, '%Y-%m-%d')<= DATE_FORMAT(#{date_to}, '%Y-%m-%d')
  122. ]]>
  123. </select>
  124. <select id="findAllCuntCompanyByBuildId" resultType="Integer">
  125. SELECT count(id) FROM y_company u WHERE u.build_id = #{build_id}
  126. and u.del_flag=0 and u.is_register = 1
  127. </select>
  128. <select id="countByType" resultType="Integer">
  129. SELECT count(id) FROM y_company u WHERE u.type_id = #{type_id}
  130. and u.del_flag=0 and u.is_register = 1
  131. </select>
  132. <select id="countAllCompany" resultType="Integer">
  133. SELECT count(id) FROM y_company u WHERE is_start=true
  134. and u.del_flag=0 and is_register = 1
  135. <if test="condition.street_id != null and condition.street_id !='' ">
  136. <![CDATA[ and street_id = #{condition.street_id} ]]>
  137. </if>
  138. </select>
  139. <select id="findCompanyByWaterId" resultType="platform.modules.build.entity.Company">
  140. SELECT u.company_name as company_name,u.company_id as id FROM y_contract_water u WHERE u.del_flag=0 and water_id=#{water_id}
  141. </select>
  142. <select id="findCompanyByElectricId" resultType="platform.modules.build.entity.Company">
  143. SELECT company_name as company_name,company_id as id FROM y_contract_electric WHERE del_flag=0 and electric_id=#{electric_id}
  144. </select>
  145. <!-- 企业信息多条件模糊查询 -->
  146. <select id="findByCondition" resultType="platform.modules.build.entity.Company">
  147. SELECT *
  148. FROM y_company com
  149. WHERE
  150. com.DEL_FLAG = 0
  151. AND
  152. com.is_register = 1
  153. <if test="companyInfoManageDto.Kcompany_name != null and companyInfoManageDto.Kcompany_name !=''">
  154. AND com.company_name LIKE CONCAT(CONCAT('%',#{companyInfoManageDto.Kcompany_name}),'%')
  155. </if>
  156. <if test="companyInfoManageDto.Kuscc != null and companyInfoManageDto.Kuscc !=''">
  157. AND com.uscc LIKE CONCAT(CONCAT('%',#{companyInfoManageDto.Kuscc}),'%')
  158. </if>
  159. <if test="companyInfoManageDto.Korganization_code != null and companyInfoManageDto.Korganization_code !=''">
  160. AND com.organization_code LIKE CONCAT(CONCAT('%',#{companyInfoManageDto.Korganization_code}),'%')
  161. </if>
  162. <if test="companyInfoManageDto.Kindustry_code != null and companyInfoManageDto.Kindustry_code !=''">
  163. AND (
  164. com.industry_code LIKE CONCAT(CONCAT('%',#{companyInfoManageDto.Kindustry_code}),'%')
  165. or
  166. com.industry_name LIKE CONCAT(CONCAT('%',#{companyInfoManageDto.Kindustry_code}),'%')
  167. )
  168. </if>
  169. <if test="companyInfoManageDto.Klegal_representative != null and companyInfoManageDto.Klegal_representative !=''">
  170. AND com.legal_representative LIKE CONCAT(CONCAT('%',#{companyInfoManageDto.Klegal_representative}),'%')
  171. </if>
  172. <if test="companyInfoManageDto.Kstreet_id != null and companyInfoManageDto.Kstreet_id !=''">
  173. AND com.street_id = #{companyInfoManageDto.Kstreet_id}
  174. </if>
  175. <if test="companyInfoManageDto.Kbuild_id != null and companyInfoManageDto.Kbuild_id !=''">
  176. AND com.build_id = #{companyInfoManageDto.Kbuild_id}
  177. </if>
  178. <if test="companyInfoManageDto.Kregistration_capital_min!=null and companyInfoManageDto.Kregistration_capital_min !=''
  179. and companyInfoManageDto.Kregistration_capital_min!=null and companyInfoManageDto.Kregistration_capital_min !=''">
  180. AND (com.registration_capital BETWEEN #{companyInfoManageDto.Kregistration_capital_min}
  181. AND #{companyInfoManageDto.Kregistration_capital_max}
  182. )
  183. </if>
  184. <if test="companyInfoManageDto.street_id != null and companyInfoManageDto.street_id !=''">
  185. AND com.street_id = #{companyInfoManageDto.street_id}
  186. </if>
  187. ORDER BY com.create_time DESC
  188. </select>
  189. <!-- 企业信息多条件模糊查询 -->
  190. <select id="findByConditions" resultType="platform.modules.build.entity.Company">
  191. SELECT com.*,u.nick_name
  192. FROM y_company com
  193. RIGHT JOIN z_user u ON com.id = u.company_id
  194. WHERE
  195. com.DEL_FLAG = 0
  196. AND
  197. com.is_register = 1
  198. <if test="companyInfoManageDto.Kcompany_name != null and companyInfoManageDto.Kcompany_name !=''">
  199. AND com.company_name LIKE CONCAT(CONCAT('%',#{companyInfoManageDto.Kcompany_name}),'%')
  200. </if>
  201. <if test="companyInfoManageDto.street_id != null and companyInfoManageDto.street_id !=''">
  202. AND u.street_id = #{companyInfoManageDto.street_id}
  203. </if>
  204. <if test="companyInfoManageDto.Kuscc != null and companyInfoManageDto.Kuscc !=''">
  205. AND com.uscc LIKE CONCAT(CONCAT('%',#{companyInfoManageDto.Kuscc}),'%')
  206. </if>
  207. <if test="companyInfoManageDto.Korganization_code != null and companyInfoManageDto.Korganization_code !=''">
  208. AND com.organization_code LIKE CONCAT(CONCAT('%',#{companyInfoManageDto.Korganization_code}),'%')
  209. </if>
  210. <if test="companyInfoManageDto.Kindustry_code != null and companyInfoManageDto.Kindustry_code !=''">
  211. AND (
  212. com.industry_code LIKE CONCAT(CONCAT('%',#{companyInfoManageDto.Kindustry_code}),'%')
  213. or
  214. com.industry_name LIKE CONCAT(CONCAT('%',#{companyInfoManageDto.Kindustry_code}),'%')
  215. )
  216. </if>
  217. <if test="companyInfoManageDto.Klegal_representative != null and companyInfoManageDto.Klegal_representative !=''">
  218. AND com.legal_representative LIKE CONCAT(CONCAT('%',#{companyInfoManageDto.Klegal_representative}),'%')
  219. </if>
  220. <if test="companyInfoManageDto.Kstreet_id != null and companyInfoManageDto.Kstreet_id !=''">
  221. AND com.street_id = #{companyInfoManageDto.Kstreet_id}
  222. </if>
  223. <if test="companyInfoManageDto.Kbuild_id != null and companyInfoManageDto.Kbuild_id !=''">
  224. AND com.build_id = #{companyInfoManageDto.Kbuild_id}
  225. </if>
  226. <if test="companyInfoManageDto.Kregistration_capital_min!=null and companyInfoManageDto.Kregistration_capital_min !=''
  227. and companyInfoManageDto.Kregistration_capital_min!=null and companyInfoManageDto.Kregistration_capital_min !=''">
  228. AND (com.registration_capital BETWEEN #{companyInfoManageDto.Kregistration_capital_min}
  229. AND #{companyInfoManageDto.Kregistration_capital_max}
  230. )
  231. </if>
  232. <if test="companyInfoManageDto.street_id != null and companyInfoManageDto.street_id !=''">
  233. AND com.street_id = #{companyInfoManageDto.street_id}
  234. </if>
  235. ORDER BY
  236. com.company_name,
  237. u.nick_name
  238. </select>
  239. <select id="selectCompanyByCondition" resultType="platform.modules.build.entity.Company">
  240. SELECT distinct (com.id),
  241. com.NO,
  242. com.company_name,
  243. com.location,
  244. com.type_id,
  245. com.type,
  246. com.nature,
  247. com.is_product,
  248. com.business,
  249. com.uscc,
  250. com.organization_code,
  251. com.industry_code,
  252. com.legal_representative,
  253. com.street_id,
  254. com.build_id,
  255. com.relation_name,
  256. com.registration_capital,
  257. com.is_start ,
  258. com.create_time,
  259. com.create_by
  260. FROM
  261. y_company com
  262. LEFT JOIN y_company_contact cc ON cc.company_id = com.id
  263. WHERE
  264. com.del_flag = 0
  265. AND
  266. com.is_register = 1
  267. <if test="is_start!=null">
  268. and com.is_start = #{is_start}
  269. </if>
  270. <if test="street_id!=null">
  271. and com.street_id = #{street_id}
  272. </if>
  273. <if test="build_id !=null">
  274. and com.build_id = #{build_id}
  275. </if>
  276. <if test="param != null and param != ''">
  277. AND
  278. ((com.company_name LIKE CONCAT(CONCAT('%',#{param}),'%'))
  279. OR (cc.phone LIKE CONCAT(CONCAT('%',#{param}),'%'))
  280. OR (cc.contact LIKE CONCAT(CONCAT('%',#{param}),'%'))
  281. )
  282. </if>
  283. ORDER BY com.create_time DESC
  284. </select>
  285. <!-- 企业注册已审批列表 -->
  286. <select id="findCompanyByCondition" resultType="platform.modules.build.entity.Company">
  287. SELECT DISTINCT
  288. c.id,
  289. c.NO,
  290. c.company_name,
  291. c.uscc,
  292. c.organization_code,
  293. c.industry_code,
  294. c.legal_representative,
  295. c.street_id,
  296. c.build_id,
  297. c.relation_name,
  298. c.registration_capital,
  299. c.is_start,
  300. c.user_name,
  301. c.nick_name,
  302. c.phone,
  303. c.create_time_approval
  304. FROM
  305. (
  306. SELECT
  307. a.*,
  308. b.CHECKER,
  309. a.create_time create_time_company,
  310. b.create_time create_time_approval,
  311. u.user_name as user_name,
  312. u.nick_name as nick_name,
  313. u.phone as phone
  314. FROM
  315. y_company a
  316. LEFT JOIN (
  317. <include refid="query_last_approval"/>
  318. )
  319. b ON a.id = b.APPLY_ID
  320. LEFT JOIN z_user u ON a.create_by = u.id
  321. WHERE
  322. b.TYPE = #{type}
  323. and a.street_id=#{currentStreet_id}
  324. <if test="currentUserId !=null">
  325. and b.CHECKER =#{currentUserId}
  326. </if>
  327. <if test="keyword != null and keyword !='' ">
  328. AND a.company_name LIKE CONCAT('%',#{keyword},'%')
  329. </if>
  330. <if test="searchCondition.organization_code != null and searchCondition.organization_code !='' ">
  331. AND a.organization_code LIKE CONCAT('%',#{searchCondition.organization_code},'%')
  332. </if>
  333. <if test="searchCondition.user_name != null and searchCondition.user_name !='' ">
  334. AND u.user_name LIKE CONCAT('%',#{searchCondition.user_name},'%')
  335. </if>
  336. <if test="searchCondition.nick_name != null and searchCondition.nick_name !='' ">
  337. AND u.nick_name LIKE CONCAT('%',#{searchCondition.nick_name},'%')
  338. </if>
  339. <if test="searchCondition.phone != null and searchCondition.phone !='' ">
  340. AND u.phone LIKE CONCAT('%',#{searchCondition.phone},'%')
  341. </if>
  342. and b.after_approvalstatus is not null
  343. ) c
  344. ORDER BY c.create_time_approval DESC
  345. </select>
  346. <sql id="query_last_approval">
  347. select approval.* from z_approval approval, (
  348. select APPLY_ID, max(id) as id from z_approval
  349. GROUP BY APPLY_ID ) approval_b
  350. where approval.id = approval_b.id
  351. </sql>
  352. <!-- 企业注册待审批列表 -->
  353. <select id="findListByContidion" resultType="platform.modules.build.entity.Company">
  354. SELECT
  355. a.*,
  356. b.NEXTCHECKER,
  357. u.user_name as user_name,
  358. u.nick_name as nick_name,
  359. u.phone as phone
  360. FROM
  361. y_company a
  362. LEFT JOIN (
  363. <include refid="query_last_approval"/>
  364. ) b ON a.id = b.APPLY_ID
  365. LEFT JOIN z_user u ON a.create_by = u.id
  366. WHERE
  367. b.TYPE = #{companyRegister}
  368. and a.street_id=#{currentStreet_id}
  369. <if test="currentUserId !=null">
  370. and b.NEXTCHECKER LIKE CONCAT(CONCAT('%',#{currentUserId}), '%')
  371. </if>
  372. <if test="keyword != null and keyword !='' ">
  373. AND a.company_name LIKE CONCAT('%',#{keyword},'%')
  374. </if>
  375. <if test="searchCondition.organization_code != null and searchCondition.organization_code !='' ">
  376. AND a.organization_code LIKE CONCAT('%',#{searchCondition.organization_code},'%')
  377. </if>
  378. <if test="searchCondition.user_name != null and searchCondition.user_name !='' ">
  379. AND u.user_name LIKE CONCAT('%',#{searchCondition.user_name},'%')
  380. </if>
  381. <if test="searchCondition.nick_name != null and searchCondition.nick_name !='' ">
  382. AND u.nick_name LIKE CONCAT('%',#{searchCondition.nick_name},'%')
  383. </if>
  384. <if test="searchCondition.phone != null and searchCondition.phone !='' ">
  385. AND u.phone LIKE CONCAT('%',#{searchCondition.phone},'%')
  386. </if>
  387. and b.after_approvalstatus is null
  388. order by a.create_time desc
  389. </select>
  390. <select id="isCompanyExist" resultType="Integer">
  391. SELECT COUNT(1)
  392. FROM
  393. y_company com
  394. WHERE
  395. com.company_name = #{company_name}
  396. AND
  397. com.organization_code = #{organization_code}
  398. AND
  399. com.del_flag = 0
  400. </select>
  401. <select id="isCompanyNameExist" resultType="Integer">
  402. SELECT COUNT(1)
  403. FROM
  404. y_company com
  405. WHERE
  406. com.company_name = #{company_name}
  407. AND
  408. com.del_flag = 0
  409. </select>
  410. <select id="isCompanyUsccExist" resultType="Integer">
  411. SELECT COUNT(1)
  412. FROM
  413. y_company com
  414. WHERE
  415. com.uscc = #{uscc}
  416. AND
  417. com.del_flag = 0
  418. </select>
  419. <select id="isCompanyOrganizationCodeExist" resultType="Integer">
  420. SELECT COUNT(1)
  421. FROM
  422. y_company com
  423. WHERE
  424. com.organization_code = #{organization_code}
  425. <if test="company_id !=null and company_id !=''">
  426. AND com.id != #{company_id}
  427. </if>
  428. AND
  429. com.del_flag = 0
  430. </select>
  431. <select id="selectCompanyContractInfo" resultType="platform.modules.government.response.CompanyDataResp">
  432. SELECT
  433. c.id,
  434. c.company_name AS `name`,
  435. CASE WHEN p.`name` IS NULL THEN s.name ELSE CONCAT(p.`name`,'/',s.`name`) END AS area,
  436. con.location,
  437. con.area AS leaseArea,
  438. con.contract_end_date AS contractEndDate,
  439. con.contract_start_date AS contractStartDate
  440. FROM
  441. y_company c
  442. LEFT JOIN y_info p ON p.id = c.build_id
  443. LEFT JOIN s_street s ON s.id = c.street_id
  444. RIGHT JOIN y_contract con ON con.company_id = c.id
  445. WHERE
  446. p.id = #{parkId}
  447. ORDER BY c.company_name DESC, con.contract_end_date ASC
  448. </select>
  449. <select id="selectCompanyContractInfoOutsidePark" resultType="platform.modules.government.response.CompanyDataResp">
  450. SELECT
  451. a.id AS id,
  452. a.company_name AS `name`,
  453. b.name AS area,
  454. con.location,
  455. con.area AS leaseArea,
  456. con.contract_end_date AS contractEndDate,
  457. con.contract_start_date AS contractStartDate
  458. FROM
  459. y_company a
  460. LEFT JOIN y_info p ON p.id = a.build_id
  461. LEFT JOIN s_street b ON a.street_id = b.id
  462. RIGHT JOIN y_contract con ON con.company_id = a.id
  463. WHERE a.build_id is null and a.del_flag = 0
  464. <if test="streetId!=null and streetId!=''">
  465. AND a.street_id = #{streetId}
  466. </if>
  467. </select>
  468. <select id="selectCompStatisticInfo" resultType="platform.modules.government.response.CompanyDataResp">
  469. SELECT
  470. a.id AS id,
  471. a.uscc AS creditCode,
  472. a.organization_code AS orgCode,
  473. a.company_name AS name,
  474. a.legal_representative AS legalRepresentative,
  475. CASE WHEN c.`name` IS NULL THEN b.name ELSE CONCAT(b.`name`,'/',c.`name`) END AS area,
  476. a.industry_code AS indesturyCode,
  477. a.registration_capital AS registerFunds,
  478. a.establishment_date AS registertTime
  479. FROM
  480. y_company a LEFT JOIN s_street b ON a.street_id = b.id
  481. LEFT JOIN y_info c ON a.build_id = c.id
  482. WHERE a.del_flag = 0
  483. <if test="name!=null and name!=''"><!-- 注册时间 -->
  484. AND a.company_name like #{name}
  485. </if>
  486. <if test="registerTime_left!=null and registerTime_left!=''"><!-- 注册时间 -->
  487. AND establishment_date &gt;= #{registerTime_left}
  488. </if>
  489. <if test="registerTime_right!=null and registerTime_right!=''"><!-- 注册时间 -->
  490. AND establishment_date &lt;= #{registerTime_left}
  491. </if>
  492. <if test="registerFunds_left !=null and registerFunds_left!=''"><!-- 注册资金 -->
  493. AND registration_capital &gt;= #{registerFunds_left}
  494. </if>
  495. <if test="registerFunds_right !=null and registerFunds_right!=''"><!-- 注册资金 -->
  496. AND registration_capital &lt;= #{registerFunds_right}
  497. </if>
  498. <if test="compArea_left !=null and compArea_right !=null"><!-- 公司面积 -->
  499. AND EXISTS(SELECT 1 FROM y_contract con LEFT JOIN y_floor_contract_relate rel ON con.id = rel.contract_id
  500. WHERE con.company_id = a.id GROUP BY con.company_id HAVING SUM(rel.use_area)&gt;=#{compArea_left} AND
  501. SUM(rel.use_area)&lt;=#{compArea_right})
  502. </if>
  503. <if test="compArea_left !=null and compArea_right ==null"><!-- 公司面积 -->
  504. AND EXISTS(SELECT 1 FROM y_contract con LEFT JOIN y_floor_contract_relate rel ON con.id = rel.contract_id
  505. WHERE con.company_id = a.id GROUP BY con.company_id HAVING SUM(rel.use_area)&gt;=#{compArea_left})
  506. </if>
  507. <if test="compArea_left ==null and compArea_right !=null"><!-- 公司面积 -->
  508. AND EXISTS(SELECT 1 FROM y_contract con LEFT JOIN y_floor_contract_relate rel ON con.id = rel.contract_id
  509. WHERE con.company_id = a.id GROUP BY con.company_id HAVING SUM(rel.use_area)&lt;=#{compArea_right})
  510. </if>
  511. <if test="ownerShip !=null and ownerShip !=''"><!-- 所属级别 -->
  512. AND subordination_relation = #{ownerShip}
  513. </if>
  514. <if test="area_street !=null and area_street !=''"><!-- 街道id -->
  515. AND a.street_id = #{area_street}
  516. </if>
  517. <if test="area_park !=null and area_park !=''"><!-- 园区id -->
  518. AND a.build_id = #{area_park}
  519. </if>
  520. <if test="industryCode !=null and industryCode !=''"><!-- 行业代码 -->
  521. AND industry_code = #{industryCode}
  522. </if>
  523. <if test="parkId !=null and parkId !=''"><!-- 园区id -->
  524. AND a.build_id = #{parkId}
  525. </if>
  526. </select>
  527. <select id="selectCompStatisticInfoOutsidePark" resultType="platform.modules.government.response.CompanyDataResp">
  528. SELECT
  529. a.id AS id,
  530. a.uscc AS creditCode,
  531. a.organization_code AS orgCode,
  532. a.company_name AS name,
  533. a.legal_representative AS legalRepresentative,
  534. b.name AS area,
  535. a.industry_code AS industry_code,
  536. a.registration_capital AS registerFunds,
  537. a.establishment_date AS registertTime
  538. FROM
  539. y_company a LEFT JOIN s_street b ON a.street_id = b.id
  540. WHERE a.build_id is null and a.del_flag = 0
  541. <if test="streetId!=null and streetId!=''">
  542. AND a.street_id = #{streetId}
  543. </if>
  544. </select>
  545. <select id="selectCompDetailInfo" resultType="platform.modules.government.response.CompanyDetail">
  546. SELECT
  547. a.id AS id,
  548. a.uscc AS uscc,
  549. a.organization_code AS orgCode,
  550. a.company_name AS name,
  551. a.legal_representative AS legalRepresentative,
  552. a.legal_representative_concat AS lrTel,
  553. a.lr_position AS lrPosition,
  554. a.relation_name AS relationName,
  555. CASE WHEN c.`name` IS NULL THEN b.name ELSE CONCAT(b.`name`,'/',c.`name`) END AS area,
  556. a.industry_code AS industryCode,
  557. a.registration_capital AS registFunds,
  558. a.establishment_date AS registTime,
  559. a.location AS location,
  560. a.business AS business,
  561. (SELECT SUM(rel.use_area) FROM y_contract con LEFT JOIN y_floor_contract_relate rel ON con.id = rel.contract_id WHERE con.company_id = a.id AND con.del_flag =FALSE AND rel.del_flag = FALSE GROUP BY con.company_id) AS compArea
  562. FROM
  563. y_company a LEFT JOIN s_street b ON a.street_id = b.id
  564. LEFT JOIN y_info c ON a.build_id = c.id
  565. WHERE a.del_flag = 0 AND a.id=#{id}
  566. </select>
  567. <select id="selectCompanyById" resultType="platform.modules.build.entity.Company">
  568. SELECT com.*,
  569. s.`name` AS street_name,
  570. y.`name` AS build_name,
  571. dic1.`name` AS type_name,
  572. dic2.`name` AS currency_unit_name
  573. FROM
  574. y_company com
  575. LEFT JOIN s_street s ON s.id = com.street_id
  576. LEFT JOIN y_info y ON y.id = com.build_id
  577. LEFT JOIN dictionary_item dic1 ON dic1.id = com.type
  578. LEFT JOIN dictionary_item dic2 ON dic2.id = com.currency_unit
  579. WHERE
  580. com.id = #{id}
  581. AND
  582. com.del_flag = 0
  583. AND
  584. s.del_flag = 0
  585. AND
  586. y.del_flag = 0
  587. AND
  588. dic1.del_flag = 0
  589. </select>
  590. <select id="selectStockLandCompany" resultType="platform.modules.build.entity.Company">
  591. SELECT
  592. distinct a.*
  593. FROM
  594. y_company a
  595. LEFT JOIN y_company_contact c on a.id = c.company_id
  596. WHERE
  597. a.del_flag = 0
  598. and a.is_start = 1
  599. <if test="street_id !=null">
  600. and (
  601. a.street_id=#{street_id}
  602. or
  603. a.id in (select company_id from y_company_building_street b where b.del_flag = 0 and b.street_id =#{street_id} )
  604. )
  605. </if>
  606. <if test="build_id !=null">
  607. and a.build_id=#{build_id}
  608. </if>
  609. <if test="keyword !=null">
  610. and (
  611. (a.company_name LIKE CONCAT(CONCAT('%',#{keyword}), '%') )
  612. OR
  613. (c.contact LIKE CONCAT(CONCAT('%',#{keyword}), '%'))
  614. )
  615. </if>
  616. </select>
  617. <select id="getStreetCompanys" resultType="platform.modules.government.dto.StreetCompanys">
  618. SELECT
  619. s.id AS id,
  620. s.`name` AS streetName,
  621. COUNT( 1 OR NULL ) AS companyNum
  622. FROM
  623. y_company c
  624. RIGHT JOIN s_street s ON s.id = c.street_id
  625. WHERE
  626. c.del_flag = 0
  627. AND c.is_register = 1
  628. AND c.is_start = 1
  629. AND c.street_id IS NOT NULL
  630. AND s.`name` IS NOT NULL
  631. GROUP BY
  632. c.street_id
  633. ORDER BY
  634. s.id ASC
  635. </select>
  636. <select id="getCompanyByCondition" resultType="platform.modules.build.entity.Company">
  637. select
  638. id,
  639. company_name,
  640. `no`,
  641. is_product,
  642. house_number,
  643. floor,
  644. business,
  645. remark,
  646. is_start,
  647. build_id,
  648. street_id,
  649. type_id,
  650. `type`,
  651. nature,
  652. staff_number,
  653. property,
  654. location,
  655. uscc,
  656. organization_code,
  657. industry_code,
  658. industry_name,
  659. legal_representative,
  660. lr_position,
  661. registration_capital,
  662. currency_unit,
  663. operated,
  664. establishment_date,
  665. subordination_relation,
  666. relation_name,
  667. registration_address,
  668. post_address
  669. from y_company
  670. where del_flag = 0
  671. <if test="condition.no != null and condition.no != ''">
  672. and `no` like concat('%', concat(#{condition.no},'%'))
  673. </if>
  674. <if test="condition.companyName != null and condition.companyName != ''">
  675. and company_name like concat('%', concat(#{condition.companyName},'%'))
  676. </if>
  677. <if test="condition.buildId != null and condition.buildId != ''">
  678. and build_id = #{condition.buildId}
  679. </if>
  680. <if test="condition.type != null and condition.type != ''">
  681. and type = #{condition.type}
  682. </if>
  683. <if test="condition.industryCode != null and condition.industryCode != ''">
  684. and industry_code = #{condition.industryCode}
  685. </if>
  686. <if test="condition.minStaffNumber != null and condition.minStaffNumber != ''">
  687. and staff_number >= #{condition.minStaffNumber}
  688. </if>
  689. <if test="condition.maxStaffNumber != null and condition.maxStaffNumber != ''">
  690. and staff_number <![CDATA[ <= ]]> #{condition.maxStaffNumber}
  691. </if>
  692. <if test="condition.lessThan50 != null and condition.lessThan50 != ''">
  693. and staff_number <![CDATA[ < ]]> #{condition.lessThan50}
  694. </if>
  695. <if test="condition.moreThan500 != null and condition.moreThan500 != ''">
  696. and staff_number > #{condition.lessThan50}
  697. </if>
  698. </select>
  699. <select id="findByParkIdAndCompanyName" resultType="platform.modules.build.entity.Company">
  700. SELECT * FROM y_company u WHERE u.company_name = #{company_name} and u.build_id = #{park_id}
  701. and u.del_flag=0 limit 0,1
  702. </select>
  703. <select id="findByUserId" resultType="platform.modules.api.dto.CompanyInfoDto">
  704. SELECT DISTINCT
  705. c.id,
  706. c.company_name,
  707. c.uscc,
  708. c.business,
  709. c.registration_capital,
  710. c.registration_address,
  711. c.establishment_date,
  712. cc.contact,
  713. cc.phone,
  714. cc.tel,
  715. cc.email,
  716. cc.position,
  717. cc.wechat,
  718. '' AS fax
  719. FROM
  720. y_company c
  721. LEFT JOIN z_user u ON u.company_id = c.id
  722. LEFT JOIN y_company_contact cc ON cc.company_id = c.id
  723. WHERE
  724. c.del_flag = 0 AND cc.del_flag = 0 AND u.id = #{userId}
  725. </select>
  726. <select id="findListByUscc" resultType="platform.modules.build.entity.Company">
  727. select * from y_company where uscc = #{uscc} and del_flag = 0
  728. </select>
  729. </mapper>