| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="platform.modules.build.dao.CompanyDao">
- <select id="findByCompanyName" resultType="platform.modules.build.entity.Company">
- SELECT * FROM y_company u WHERE u.company_name = #{company_name}
- and u.del_flag=0 limit 0,1
- </select>
- <select id="findListByCompanyName" resultType="platform.modules.build.entity.Company">
- SELECT * FROM y_company u
- WHERE
- 1=1
- <if test="company_name!=null and company_name!=''">
- and
- u.company_name LIKE CONCAT('%',#{company_name},'%')
- </if>
- <if test="ids.size() > 0 ">
- AND u.id NOT IN
- <foreach collection="ids" index="index" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- and u.del_flag=0
- </select>
- <select id="findListByCompanyIds" resultType="platform.modules.build.entity.Company">
- SELECT * FROM y_company u
- WHERE
- id in
- <foreach item="item" index="index" collection="ids"
- open="(" separator="," close=")">
- #{item}
- </foreach>
- and u.del_flag=0
- </select>
- <select id="findCompanyFee" resultType="platform.modules.build.DTO.CompanyFeeDto">
- select
- temp.fee_id ,
- temp.fee_type ,
- temp.total_fee ,
- temp.status ,
- temp.pay_time ,
- temp.is_paid,
- temp.remind_count
- from (
- select
- p.id as fee_id,
- case when p.fee_type='0' then '停车费' else '物业费' end as fee_type,
- (p.price*p.number*p.payment_cycle) as total_fee,
- case when p.actural_paid_date is null then '未缴费' else '已缴费' end as status,
- case when p.actural_paid_date is null then '0' else '1' end as is_paid,
- p.pay_time as pay_time,
- p.create_time,
- p.update_time,
- ifnull(p.remind_count,0) as remind_count
- FROM y_contract_property p
- where p.company_id=#{company_id} and p.del_flag=0
- union
- select
- tenancy.id as fee_id,
- '房租' as fee_type,
- tenancy.house_fee as total_fee,
- case tenancy.`status` when '0' then '未缴费' when'1' then '部分缴费' else '已缴费' end as status,
- case tenancy.`status` when '0' then '0' when'1' then '1' else '0' end as is_paid,
- tenancy.pay_time as pay_time,
- tenancy.create_time,
- tenancy.update_time,
- ifnull(tenancy.remind_count,0) as remind_count
- FROM y_contract_tenancy tenancy
- where tenancy.company_id=#{company_id} and tenancy.del_flag=0
- union
- select
- water.id as fee_id,
- '水费' as fee_type,
- water.water_fee as total_fee,
- case when water.status='2' then '已缴费' else '未缴费' end as status,
- case when water.status='2' then '1' else '0' end as is_paid,
- '' as pay_time,
- water.create_time,
- water.update_time,
- ifnull(water.remind_count,0) as remind_count
- FROM y_water_fee water
- where water.company_id=#{company_id} and water.del_flag=0 and is_water=true
- union
- select
- electric.id as fee_id,
- '电费' as fee_type,
- electric.electric_fee as total_fee,
- case when electric.status='2' then '已缴费' else '未缴费' end as status,
- case when electric.status='2' then '1' else '0' end as is_paid,
- '' as pay_time,
- electric.create_time,
- electric.update_time,
- ifnull(electric.remind_count,0) as remind_count
- FROM y_electric_fee electric
- where electric.company_id=#{company_id} and electric.del_flag=0 and is_electric=true
- ) temp
- where 1=1
- <if test="is_paid!=null">
- and temp.is_paid = #{is_paid}
- </if>
- <if test="fee_type!=null and fee_type!=''">
- and temp.fee_type = #{fee_type}
- </if>
- <if test="status!=null and status!=''">
- and temp.status = #{status}
- </if>
- order by temp.remind_count desc, temp.is_paid asc, temp.pay_time asc
- <if test="count!=null">
- limit #{count}
- </if>
- </select>
- <select id="getCompanyCountByStreetName" resultType="Integer">
- SELECT count(u.id) FROM y_company u
- left join s_street s on s.id=u.street_id
- WHERE s.name = #{name}
- and u.del_flag=0 and u.is_register = 1
- </select>
- <select id="findCuntCompanyByBuildId" resultType="Integer">
- SELECT count(id) FROM y_company u WHERE u.build_id = #{build_id}
- and u.del_flag=0 and u.is_start=1 and u.is_register = 1
- <![CDATA[ and DATE_FORMAT(u.`create_time`, '%Y-%m-%d')>= DATE_FORMAT(#{date_from}, '%Y-%m-%d') ]]>
- <![CDATA[ and DATE_FORMAT(u.`create_time`, '%Y-%m-%d')<= DATE_FORMAT(#{date_to}, '%Y-%m-%d')
- ]]>
- </select>
- <select id="findAllCuntCompanyByBuildId" resultType="Integer">
- SELECT count(id) FROM y_company u WHERE u.build_id = #{build_id}
- and u.del_flag=0 and u.is_register = 1
- </select>
- <select id="countByType" resultType="Integer">
- SELECT count(id) FROM y_company u WHERE u.type_id = #{type_id}
- and u.del_flag=0 and u.is_register = 1
- </select>
- <select id="countAllCompany" resultType="Integer">
- SELECT count(id) FROM y_company u WHERE is_start=true
- and u.del_flag=0 and is_register = 1
- <if test="condition.street_id != null and condition.street_id !='' ">
- <![CDATA[ and street_id = #{condition.street_id} ]]>
- </if>
- </select>
- <select id="findCompanyByWaterId" resultType="platform.modules.build.entity.Company">
- 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}
- </select>
- <select id="findCompanyByElectricId" resultType="platform.modules.build.entity.Company">
- SELECT company_name as company_name,company_id as id FROM y_contract_electric WHERE del_flag=0 and electric_id=#{electric_id}
- </select>
- <!-- 企业信息多条件模糊查询 -->
- <select id="findByCondition" resultType="platform.modules.build.entity.Company">
- SELECT *
- FROM y_company com
- WHERE
- com.DEL_FLAG = 0
- AND
- com.is_register = 1
- <if test="companyInfoManageDto.Kcompany_name != null and companyInfoManageDto.Kcompany_name !=''">
- AND com.company_name LIKE CONCAT(CONCAT('%',#{companyInfoManageDto.Kcompany_name}),'%')
- </if>
- <if test="companyInfoManageDto.Kuscc != null and companyInfoManageDto.Kuscc !=''">
- AND com.uscc LIKE CONCAT(CONCAT('%',#{companyInfoManageDto.Kuscc}),'%')
- </if>
- <if test="companyInfoManageDto.Korganization_code != null and companyInfoManageDto.Korganization_code !=''">
- AND com.organization_code LIKE CONCAT(CONCAT('%',#{companyInfoManageDto.Korganization_code}),'%')
- </if>
- <if test="companyInfoManageDto.Kindustry_code != null and companyInfoManageDto.Kindustry_code !=''">
- AND (
- com.industry_code LIKE CONCAT(CONCAT('%',#{companyInfoManageDto.Kindustry_code}),'%')
- or
- com.industry_name LIKE CONCAT(CONCAT('%',#{companyInfoManageDto.Kindustry_code}),'%')
- )
- </if>
- <if test="companyInfoManageDto.Klegal_representative != null and companyInfoManageDto.Klegal_representative !=''">
- AND com.legal_representative LIKE CONCAT(CONCAT('%',#{companyInfoManageDto.Klegal_representative}),'%')
- </if>
- <if test="companyInfoManageDto.Kstreet_id != null and companyInfoManageDto.Kstreet_id !=''">
- AND com.street_id = #{companyInfoManageDto.Kstreet_id}
- </if>
- <if test="companyInfoManageDto.Kbuild_id != null and companyInfoManageDto.Kbuild_id !=''">
- AND com.build_id = #{companyInfoManageDto.Kbuild_id}
- </if>
- <if test="companyInfoManageDto.Kregistration_capital_min!=null and companyInfoManageDto.Kregistration_capital_min !=''
- and companyInfoManageDto.Kregistration_capital_min!=null and companyInfoManageDto.Kregistration_capital_min !=''">
- AND (com.registration_capital BETWEEN #{companyInfoManageDto.Kregistration_capital_min}
- AND #{companyInfoManageDto.Kregistration_capital_max}
- )
- </if>
- <if test="companyInfoManageDto.street_id != null and companyInfoManageDto.street_id !=''">
- AND com.street_id = #{companyInfoManageDto.street_id}
- </if>
- ORDER BY com.create_time DESC
- </select>
- <!-- 企业信息多条件模糊查询 -->
- <select id="findByConditions" resultType="platform.modules.build.entity.Company">
- SELECT com.*,u.nick_name
- FROM y_company com
- RIGHT JOIN z_user u ON com.id = u.company_id
- WHERE
- com.DEL_FLAG = 0
- AND
- com.is_register = 1
- <if test="companyInfoManageDto.Kcompany_name != null and companyInfoManageDto.Kcompany_name !=''">
- AND com.company_name LIKE CONCAT(CONCAT('%',#{companyInfoManageDto.Kcompany_name}),'%')
- </if>
- <if test="companyInfoManageDto.street_id != null and companyInfoManageDto.street_id !=''">
- AND u.street_id = #{companyInfoManageDto.street_id}
- </if>
- <if test="companyInfoManageDto.Kuscc != null and companyInfoManageDto.Kuscc !=''">
- AND com.uscc LIKE CONCAT(CONCAT('%',#{companyInfoManageDto.Kuscc}),'%')
- </if>
- <if test="companyInfoManageDto.Korganization_code != null and companyInfoManageDto.Korganization_code !=''">
- AND com.organization_code LIKE CONCAT(CONCAT('%',#{companyInfoManageDto.Korganization_code}),'%')
- </if>
- <if test="companyInfoManageDto.Kindustry_code != null and companyInfoManageDto.Kindustry_code !=''">
- AND (
- com.industry_code LIKE CONCAT(CONCAT('%',#{companyInfoManageDto.Kindustry_code}),'%')
- or
- com.industry_name LIKE CONCAT(CONCAT('%',#{companyInfoManageDto.Kindustry_code}),'%')
- )
- </if>
- <if test="companyInfoManageDto.Klegal_representative != null and companyInfoManageDto.Klegal_representative !=''">
- AND com.legal_representative LIKE CONCAT(CONCAT('%',#{companyInfoManageDto.Klegal_representative}),'%')
- </if>
- <if test="companyInfoManageDto.Kstreet_id != null and companyInfoManageDto.Kstreet_id !=''">
- AND com.street_id = #{companyInfoManageDto.Kstreet_id}
- </if>
- <if test="companyInfoManageDto.Kbuild_id != null and companyInfoManageDto.Kbuild_id !=''">
- AND com.build_id = #{companyInfoManageDto.Kbuild_id}
- </if>
- <if test="companyInfoManageDto.Kregistration_capital_min!=null and companyInfoManageDto.Kregistration_capital_min !=''
- and companyInfoManageDto.Kregistration_capital_min!=null and companyInfoManageDto.Kregistration_capital_min !=''">
- AND (com.registration_capital BETWEEN #{companyInfoManageDto.Kregistration_capital_min}
- AND #{companyInfoManageDto.Kregistration_capital_max}
- )
- </if>
- <if test="companyInfoManageDto.street_id != null and companyInfoManageDto.street_id !=''">
- AND com.street_id = #{companyInfoManageDto.street_id}
- </if>
- ORDER BY
- com.company_name,
- u.nick_name
- </select>
- <select id="selectCompanyByCondition" resultType="platform.modules.build.entity.Company">
- SELECT distinct (com.id),
- com.NO,
- com.company_name,
- com.location,
- com.type_id,
- com.type,
- com.nature,
- com.is_product,
- com.business,
- com.uscc,
- com.organization_code,
- com.industry_code,
- com.legal_representative,
- com.street_id,
- com.build_id,
- com.relation_name,
- com.registration_capital,
- com.is_start ,
- com.create_time,
- com.create_by
- FROM
- y_company com
- LEFT JOIN y_company_contact cc ON cc.company_id = com.id
- WHERE
- com.del_flag = 0
- AND
- com.is_register = 1
- <if test="is_start!=null">
- and com.is_start = #{is_start}
- </if>
- <if test="street_id!=null">
- and com.street_id = #{street_id}
- </if>
- <if test="build_id !=null">
- and com.build_id = #{build_id}
- </if>
- <if test="param != null and param != ''">
- AND
- ((com.company_name LIKE CONCAT(CONCAT('%',#{param}),'%'))
- OR (cc.phone LIKE CONCAT(CONCAT('%',#{param}),'%'))
- OR (cc.contact LIKE CONCAT(CONCAT('%',#{param}),'%'))
- )
- </if>
- ORDER BY com.create_time DESC
- </select>
- <!-- 企业注册已审批列表 -->
- <select id="findCompanyByCondition" resultType="platform.modules.build.entity.Company">
- SELECT DISTINCT
- c.id,
- c.NO,
- c.company_name,
- c.uscc,
- c.organization_code,
- c.industry_code,
- c.legal_representative,
- c.street_id,
- c.build_id,
- c.relation_name,
- c.registration_capital,
- c.is_start,
- c.user_name,
- c.nick_name,
- c.phone,
- c.create_time_approval
- FROM
- (
- SELECT
- a.*,
- b.CHECKER,
- a.create_time create_time_company,
- b.create_time create_time_approval,
- u.user_name as user_name,
- u.nick_name as nick_name,
- u.phone as phone
- FROM
- y_company a
- LEFT JOIN (
- <include refid="query_last_approval"/>
- )
- b ON a.id = b.APPLY_ID
- LEFT JOIN z_user u ON a.create_by = u.id
- WHERE
- b.TYPE = #{type}
- and a.street_id=#{currentStreet_id}
- <if test="currentUserId !=null">
- and b.CHECKER =#{currentUserId}
- </if>
- <if test="keyword != null and keyword !='' ">
- AND a.company_name LIKE CONCAT('%',#{keyword},'%')
- </if>
- <if test="searchCondition.organization_code != null and searchCondition.organization_code !='' ">
- AND a.organization_code LIKE CONCAT('%',#{searchCondition.organization_code},'%')
- </if>
- <if test="searchCondition.user_name != null and searchCondition.user_name !='' ">
- AND u.user_name LIKE CONCAT('%',#{searchCondition.user_name},'%')
- </if>
- <if test="searchCondition.nick_name != null and searchCondition.nick_name !='' ">
- AND u.nick_name LIKE CONCAT('%',#{searchCondition.nick_name},'%')
- </if>
- <if test="searchCondition.phone != null and searchCondition.phone !='' ">
- AND u.phone LIKE CONCAT('%',#{searchCondition.phone},'%')
- </if>
- and b.after_approvalstatus is not null
- ) c
- ORDER BY c.create_time_approval DESC
- </select>
- <sql id="query_last_approval">
- select approval.* from z_approval approval, (
- select APPLY_ID, max(id) as id from z_approval
- GROUP BY APPLY_ID ) approval_b
- where approval.id = approval_b.id
- </sql>
- <!-- 企业注册待审批列表 -->
- <select id="findListByContidion" resultType="platform.modules.build.entity.Company">
- SELECT
- a.*,
- b.NEXTCHECKER,
- u.user_name as user_name,
- u.nick_name as nick_name,
- u.phone as phone
- FROM
- y_company a
- LEFT JOIN (
- <include refid="query_last_approval"/>
- ) b ON a.id = b.APPLY_ID
- LEFT JOIN z_user u ON a.create_by = u.id
- WHERE
- b.TYPE = #{companyRegister}
- and a.street_id=#{currentStreet_id}
- <if test="currentUserId !=null">
- and b.NEXTCHECKER LIKE CONCAT(CONCAT('%',#{currentUserId}), '%')
- </if>
- <if test="keyword != null and keyword !='' ">
- AND a.company_name LIKE CONCAT('%',#{keyword},'%')
- </if>
- <if test="searchCondition.organization_code != null and searchCondition.organization_code !='' ">
- AND a.organization_code LIKE CONCAT('%',#{searchCondition.organization_code},'%')
- </if>
- <if test="searchCondition.user_name != null and searchCondition.user_name !='' ">
- AND u.user_name LIKE CONCAT('%',#{searchCondition.user_name},'%')
- </if>
- <if test="searchCondition.nick_name != null and searchCondition.nick_name !='' ">
- AND u.nick_name LIKE CONCAT('%',#{searchCondition.nick_name},'%')
- </if>
- <if test="searchCondition.phone != null and searchCondition.phone !='' ">
- AND u.phone LIKE CONCAT('%',#{searchCondition.phone},'%')
- </if>
- and b.after_approvalstatus is null
- order by a.create_time desc
- </select>
- <select id="isCompanyExist" resultType="Integer">
- SELECT COUNT(1)
- FROM
- y_company com
- WHERE
- com.company_name = #{company_name}
- AND
- com.organization_code = #{organization_code}
- AND
- com.del_flag = 0
- </select>
- <select id="isCompanyNameExist" resultType="Integer">
- SELECT COUNT(1)
- FROM
- y_company com
- WHERE
- com.company_name = #{company_name}
- AND
- com.del_flag = 0
- </select>
- <select id="isCompanyUsccExist" resultType="Integer">
- SELECT COUNT(1)
- FROM
- y_company com
- WHERE
- com.uscc = #{uscc}
- AND
- com.del_flag = 0
- </select>
- <select id="isCompanyOrganizationCodeExist" resultType="Integer">
- SELECT COUNT(1)
- FROM
- y_company com
- WHERE
- com.organization_code = #{organization_code}
- <if test="company_id !=null and company_id !=''">
- AND com.id != #{company_id}
- </if>
- AND
- com.del_flag = 0
- </select>
- <select id="selectCompanyContractInfo" resultType="platform.modules.government.response.CompanyDataResp">
- SELECT
- c.id,
- c.company_name AS `name`,
- CASE WHEN p.`name` IS NULL THEN s.name ELSE CONCAT(p.`name`,'/',s.`name`) END AS area,
- con.location,
- con.area AS leaseArea,
- con.contract_end_date AS contractEndDate,
- con.contract_start_date AS contractStartDate
- FROM
- y_company c
- LEFT JOIN y_info p ON p.id = c.build_id
- LEFT JOIN s_street s ON s.id = c.street_id
- RIGHT JOIN y_contract con ON con.company_id = c.id
- WHERE
- p.id = #{parkId}
- ORDER BY c.company_name DESC, con.contract_end_date ASC
- </select>
- <select id="selectCompanyContractInfoOutsidePark" resultType="platform.modules.government.response.CompanyDataResp">
- SELECT
- a.id AS id,
- a.company_name AS `name`,
- b.name AS area,
- con.location,
- con.area AS leaseArea,
- con.contract_end_date AS contractEndDate,
- con.contract_start_date AS contractStartDate
- FROM
- y_company a
- LEFT JOIN y_info p ON p.id = a.build_id
- LEFT JOIN s_street b ON a.street_id = b.id
- RIGHT JOIN y_contract con ON con.company_id = a.id
- WHERE a.build_id is null and a.del_flag = 0
- <if test="streetId!=null and streetId!=''">
- AND a.street_id = #{streetId}
- </if>
- </select>
- <select id="selectCompStatisticInfo" resultType="platform.modules.government.response.CompanyDataResp">
- SELECT
- a.id AS id,
- a.uscc AS creditCode,
- a.organization_code AS orgCode,
- a.company_name AS name,
- a.legal_representative AS legalRepresentative,
- CASE WHEN c.`name` IS NULL THEN b.name ELSE CONCAT(b.`name`,'/',c.`name`) END AS area,
- a.industry_code AS indesturyCode,
- a.registration_capital AS registerFunds,
- a.establishment_date AS registertTime
- FROM
- y_company a LEFT JOIN s_street b ON a.street_id = b.id
- LEFT JOIN y_info c ON a.build_id = c.id
- WHERE a.del_flag = 0
- <if test="name!=null and name!=''"><!-- 注册时间 -->
- AND a.company_name like #{name}
- </if>
- <if test="registerTime_left!=null and registerTime_left!=''"><!-- 注册时间 -->
- AND establishment_date >= #{registerTime_left}
- </if>
- <if test="registerTime_right!=null and registerTime_right!=''"><!-- 注册时间 -->
- AND establishment_date <= #{registerTime_left}
- </if>
- <if test="registerFunds_left !=null and registerFunds_left!=''"><!-- 注册资金 -->
- AND registration_capital >= #{registerFunds_left}
- </if>
- <if test="registerFunds_right !=null and registerFunds_right!=''"><!-- 注册资金 -->
- AND registration_capital <= #{registerFunds_right}
- </if>
- <if test="compArea_left !=null and compArea_right !=null"><!-- 公司面积 -->
- AND EXISTS(SELECT 1 FROM y_contract con LEFT JOIN y_floor_contract_relate rel ON con.id = rel.contract_id
- WHERE con.company_id = a.id GROUP BY con.company_id HAVING SUM(rel.use_area)>=#{compArea_left} AND
- SUM(rel.use_area)<=#{compArea_right})
- </if>
- <if test="compArea_left !=null and compArea_right ==null"><!-- 公司面积 -->
- AND EXISTS(SELECT 1 FROM y_contract con LEFT JOIN y_floor_contract_relate rel ON con.id = rel.contract_id
- WHERE con.company_id = a.id GROUP BY con.company_id HAVING SUM(rel.use_area)>=#{compArea_left})
- </if>
- <if test="compArea_left ==null and compArea_right !=null"><!-- 公司面积 -->
- AND EXISTS(SELECT 1 FROM y_contract con LEFT JOIN y_floor_contract_relate rel ON con.id = rel.contract_id
- WHERE con.company_id = a.id GROUP BY con.company_id HAVING SUM(rel.use_area)<=#{compArea_right})
- </if>
- <if test="ownerShip !=null and ownerShip !=''"><!-- 所属级别 -->
- AND subordination_relation = #{ownerShip}
- </if>
- <if test="area_street !=null and area_street !=''"><!-- 街道id -->
- AND a.street_id = #{area_street}
- </if>
- <if test="area_park !=null and area_park !=''"><!-- 园区id -->
- AND a.build_id = #{area_park}
- </if>
- <if test="industryCode !=null and industryCode !=''"><!-- 行业代码 -->
- AND industry_code = #{industryCode}
- </if>
- <if test="parkId !=null and parkId !=''"><!-- 园区id -->
- AND a.build_id = #{parkId}
- </if>
- </select>
- <select id="selectCompStatisticInfoOutsidePark" resultType="platform.modules.government.response.CompanyDataResp">
- SELECT
- a.id AS id,
- a.uscc AS creditCode,
- a.organization_code AS orgCode,
- a.company_name AS name,
- a.legal_representative AS legalRepresentative,
- b.name AS area,
- a.industry_code AS industry_code,
- a.registration_capital AS registerFunds,
- a.establishment_date AS registertTime
- FROM
- y_company a LEFT JOIN s_street b ON a.street_id = b.id
- WHERE a.build_id is null and a.del_flag = 0
- <if test="streetId!=null and streetId!=''">
- AND a.street_id = #{streetId}
- </if>
- </select>
- <select id="selectCompDetailInfo" resultType="platform.modules.government.response.CompanyDetail">
- SELECT
- a.id AS id,
- a.uscc AS uscc,
- a.organization_code AS orgCode,
- a.company_name AS name,
- a.legal_representative AS legalRepresentative,
- a.legal_representative_concat AS lrTel,
- a.lr_position AS lrPosition,
- a.relation_name AS relationName,
- CASE WHEN c.`name` IS NULL THEN b.name ELSE CONCAT(b.`name`,'/',c.`name`) END AS area,
- a.industry_code AS industryCode,
- a.registration_capital AS registFunds,
- a.establishment_date AS registTime,
- a.location AS location,
- a.business AS business,
- (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
- FROM
- y_company a LEFT JOIN s_street b ON a.street_id = b.id
- LEFT JOIN y_info c ON a.build_id = c.id
- WHERE a.del_flag = 0 AND a.id=#{id}
- </select>
- <select id="selectCompanyById" resultType="platform.modules.build.entity.Company">
- SELECT com.*,
- s.`name` AS street_name,
- y.`name` AS build_name,
- dic1.`name` AS type_name,
- dic2.`name` AS currency_unit_name
-
- FROM
- y_company com
- LEFT JOIN s_street s ON s.id = com.street_id
- LEFT JOIN y_info y ON y.id = com.build_id
- LEFT JOIN dictionary_item dic1 ON dic1.id = com.type
- LEFT JOIN dictionary_item dic2 ON dic2.id = com.currency_unit
-
- WHERE
- com.id = #{id}
- AND
- com.del_flag = 0
- AND
- s.del_flag = 0
- AND
- y.del_flag = 0
- AND
- dic1.del_flag = 0
-
- </select>
- <select id="selectStockLandCompany" resultType="platform.modules.build.entity.Company">
- SELECT
- distinct a.*
- FROM
- y_company a
- LEFT JOIN y_company_contact c on a.id = c.company_id
- WHERE
- a.del_flag = 0
- and a.is_start = 1
- <if test="street_id !=null">
- and (
- a.street_id=#{street_id}
- or
- a.id in (select company_id from y_company_building_street b where b.del_flag = 0 and b.street_id =#{street_id} )
- )
- </if>
- <if test="build_id !=null">
- and a.build_id=#{build_id}
- </if>
- <if test="keyword !=null">
- and (
- (a.company_name LIKE CONCAT(CONCAT('%',#{keyword}), '%') )
- OR
- (c.contact LIKE CONCAT(CONCAT('%',#{keyword}), '%'))
- )
- </if>
- </select>
- <select id="getStreetCompanys" resultType="platform.modules.government.dto.StreetCompanys">
- SELECT
- s.id AS id,
- s.`name` AS streetName,
- COUNT( 1 OR NULL ) AS companyNum
- FROM
- y_company c
- RIGHT JOIN s_street s ON s.id = c.street_id
- WHERE
- c.del_flag = 0
- AND c.is_register = 1
- AND c.is_start = 1
- AND c.street_id IS NOT NULL
- AND s.`name` IS NOT NULL
- GROUP BY
- c.street_id
- ORDER BY
- s.id ASC
- </select>
- <select id="getCompanyByCondition" resultType="platform.modules.build.entity.Company">
- select
- id,
- company_name,
- `no`,
- is_product,
- house_number,
- floor,
- business,
- remark,
- is_start,
- build_id,
- street_id,
- type_id,
- `type`,
- nature,
- staff_number,
- property,
- location,
- uscc,
- organization_code,
- industry_code,
- industry_name,
- legal_representative,
- lr_position,
- registration_capital,
- currency_unit,
- operated,
- establishment_date,
- subordination_relation,
- relation_name,
- registration_address,
- post_address
- from y_company
- where del_flag = 0
- <if test="condition.no != null and condition.no != ''">
- and `no` like concat('%', concat(#{condition.no},'%'))
- </if>
- <if test="condition.companyName != null and condition.companyName != ''">
- and company_name like concat('%', concat(#{condition.companyName},'%'))
- </if>
- <if test="condition.buildId != null and condition.buildId != ''">
- and build_id = #{condition.buildId}
- </if>
- <if test="condition.type != null and condition.type != ''">
- and type = #{condition.type}
- </if>
- <if test="condition.industryCode != null and condition.industryCode != ''">
- and industry_code = #{condition.industryCode}
- </if>
- <if test="condition.minStaffNumber != null and condition.minStaffNumber != ''">
- and staff_number >= #{condition.minStaffNumber}
- </if>
- <if test="condition.maxStaffNumber != null and condition.maxStaffNumber != ''">
- and staff_number <![CDATA[ <= ]]> #{condition.maxStaffNumber}
- </if>
- <if test="condition.lessThan50 != null and condition.lessThan50 != ''">
- and staff_number <![CDATA[ < ]]> #{condition.lessThan50}
- </if>
- <if test="condition.moreThan500 != null and condition.moreThan500 != ''">
- and staff_number > #{condition.lessThan50}
- </if>
- </select>
- <select id="findByParkIdAndCompanyName" resultType="platform.modules.build.entity.Company">
- SELECT * FROM y_company u WHERE u.company_name = #{company_name} and u.build_id = #{park_id}
- and u.del_flag=0 limit 0,1
- </select>
- <select id="findByUserId" resultType="platform.modules.api.dto.CompanyInfoDto">
- SELECT DISTINCT
- c.id,
- c.company_name,
- c.uscc,
- c.business,
- c.registration_capital,
- c.registration_address,
- c.establishment_date,
- cc.contact,
- cc.phone,
- cc.tel,
- cc.email,
- cc.position,
- cc.wechat,
- '' AS fax
- FROM
- y_company c
- LEFT JOIN z_user u ON u.company_id = c.id
- LEFT JOIN y_company_contact cc ON cc.company_id = c.id
- WHERE
- c.del_flag = 0 AND cc.del_flag = 0 AND u.id = #{userId}
- </select>
- <select id="findListByUscc" resultType="platform.modules.build.entity.Company">
- select * from y_company where uscc = #{uscc} and del_flag = 0
- </select>
- </mapper>
|