Commit 79537a3e authored by chai's avatar chai

mybatis_plus

parent c3eb2d4c
...@@ -25,169 +25,169 @@ public class CustProject extends Model<CustProject> { ...@@ -25,169 +25,169 @@ public class CustProject extends Model<CustProject> {
*/ */
private String id; private String id;
/** // /**
* 客户ID // * 客户ID
*/ // */
// private String customerId; // private String customerId;
//
/** // /**
* 父项目ID // * 父项目ID
*/ // */
private Long parentId; // private Long parentId;
//
/** // /**
* 签约工单ID // * 签约工单ID
*/ // */
private Long woId; // private Long woId;
//
/** // /**
* 项目负责人账号(父项目才有) // * 项目负责人账号(父项目才有)
*/ // */
private String managerAccount; // private String managerAccount;
//
/** // /**
* 项目负责人名称(父项目才有) // * 项目负责人名称(父项目才有)
*/ // */
private String managerName; // private String managerName;
//
/** // /**
* 项目名称 // * 项目名称
*/ // */
private String projectName; // private String projectName;
//
/** // /**
* 项目编码 // * 项目编码
*/ // */
private String projectCode; // private String projectCode;
//
/** // /**
* 产品类型编码 // * 产品类型编码
*/ // */
private String businessTypeCode; // private String businessTypeCode;
//
/** // /**
* 产品类型名称 // * 产品类型名称
*/ // */
private String businessTypeName; // private String businessTypeName;
//
/** // /**
* 签约公司ID // * 签约公司ID
*/ // */
private Integer signCompanyId; // private Integer signCompanyId;
//
/** // /**
* 签约公司 // * 签约公司
*/ // */
private String signCompanyName; // private String signCompanyName;
//
/** // /**
* 是否排他 // * 是否排他
*/ // */
private String isExclusive; // private String isExclusive;
//
/** // /**
* 是否排他说明 // * 是否排他说明
*/ // */
private String exclusiveDescription; // private String exclusiveDescription;
//
/** // /**
* NC编码 // * NC编码
*/ // */
private String ncCode; // private String ncCode;
//
/** // /**
* 子项目接口人 // * 子项目接口人
*/ // */
private String interfaceMan; // private String interfaceMan;
//
/** // /**
* 子项目接口人属地 // * 子项目接口人属地
*/ // */
private String interfaceManTerritory; // private String interfaceManTerritory;
//
private String interfaceManCity; // private String interfaceManCity;
//
private String interfaceManProvince; // private String interfaceManProvince;
//
/** // /**
* 子项目接口人联系电话 // * 子项目接口人联系电话
*/ // */
private String interfaceManPhone; // private String interfaceManPhone;
//
/** // /**
* 子项目接口人邮箱 // * 子项目接口人邮箱
*/ // */
private String interfaceManEmail; // private String interfaceManEmail;
//
/** // /**
* 其他备注 // * 其他备注
*/ // */
private String remark; // private String remark;
//
/** // /**
* 是否需要招聘 // * 是否需要招聘
*/ // */
private String ifNeedRecruitment; // private String ifNeedRecruitment;
//
/** // /**
* 招聘方 // * 招聘方
*/ // */
private String recruiter; // private String recruiter;
//
/** // /**
* 服务状态 // * 服务状态
*/ // */
private Boolean serviceStatus; // private Boolean serviceStatus;
//
/** // /**
* e家银工资自动到卡 // * e家银工资自动到卡
*/ // */
private Boolean ejyWageAutoCard; // private Boolean ejyWageAutoCard;
//
/** // /**
* 数据来源 // * 数据来源
*/ // */
private String dataSource; // private String dataSource;
//
/** // /**
* 服务方式 // * 服务方式
*/ // */
private String serviceMode; // private String serviceMode;
//
/** // /**
* 服务地点-省份 // * 服务地点-省份
*/ // */
private String serviceProvince; // private String serviceProvince;
//
/** // /**
* 服务地点-城市 // * 服务地点-城市
*/ // */
private String serviceCity; // private String serviceCity;
//
/** // /**
* 大区code // * 大区code
*/ // */
private String areaCode; // private String areaCode;
//
/** // /**
* 税率 // * 税率
*/ // */
private String taxRate; // private String taxRate;
//
/** // /**
* 创建时间 // * 创建时间
*/ // */
private LocalDateTime createTime; // private LocalDateTime createTime;
//
/** // /**
* 更新时间 // * 更新时间
*/ // */
private LocalDateTime updateTime; // private LocalDateTime updateTime;
//
/** // /**
* 销售过程ID // * 销售过程ID
*/ // */
private String custSaleProcessId; // private String custSaleProcessId;
@Override @Override
......
<?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="com.dianmi.mapper.CustProjectMapper">
<resultMap id="BaseResultMap" type="com.dianmi.entity.CustProject">
<id column="id" property="id"/>
<!-- <result column="customer_id" property="customerId"/>-->
<!-- <result column="parent_id" property="parentId"/>-->
<!-- <result column="wo_id" property="woId"/>-->
<!-- <result column="project_name" property="projectName"/>-->
<!-- <result column="project_code" property="projectCode"/>-->
<!-- <result column="business_type_name" property="businessTypeName"/>-->
<!-- <result column="business_type_code" property="businessTypeCode"/>-->
<!-- <result column="sign_company_id" property="signCompanyId"/>-->
<!-- <result column="sign_company_name" property="signCompanyName"/>-->
<!-- <result column="is_exclusive" property="isExclusive"/>-->
<!-- <result column="exclusive_description" property="exclusiveDescription"/>-->
<!-- <result column="nc_code" property="ncCode"/>-->
<!-- <result column="interface_man" property="interfaceMan"/>-->
<!-- <result column="interface_man_territory" property="interfaceManTerritory"/>-->
<!-- <result column="interface_man_phone" property="interfaceManPhone"/>-->
<!-- <result column="interface_man_email" property="interfaceManEmail"/>-->
<!-- <result column="remark" property="remark"/>-->
<!-- <result column="if_need_recruitment" property="ifNeedRecruitment"/>-->
<!-- <result column="recruiter" property="recruiter"/>-->
<!-- <result column="service_status" property="serviceStatus"/>-->
<!-- <result column="ejy_wage_auto_card" property="ejyWageAutoCard"/>-->
<!-- <result column="data_source" property="dataSource"/>-->
<!-- <result column="service_mode" property="serviceMode"/>-->
<!-- <result column="service_province" property="serviceProvince"/>-->
<!-- <result column="service_city" property="serviceCity"/>-->
<!-- <result column="tax_rate" property="taxRate"/>-->
<!-- <result column="create_time" property="createTime"/>-->
<!-- <result column="update_time" property="updateTime"/>-->
</resultMap>
<sql id="Base_Column_List">
id,
customer_id,
parent_id,
wo_id,
project_name,
project_code,
business_type_name,
business_type_code,
sign_company_id,
sign_company_name,
is_exclusive,
exclusive_description,
nc_code,
interface_man,
interface_man_territory,
interface_man_phone,
interface_man_email,
remark,
if_need_recruitment,
recruiter,
service_status,
ejy_wage_auto_card,
data_source,
service_mode,
service_province,
service_city,
tax_rate,
create_time,
update_time
</sql>
</mapper>
<?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="com.dianmi.dao.CustProjectDao">
<resultMap id="BaseResultMap" type="com.dianmi.domain.entity.CustProject">
<id column="id" property="id"/>
<result column="customer_id" property="customerId"/>
<result column="parent_id" property="parentId"/>
<result column="wo_id" property="woId"/>
<result column="project_name" property="projectName"/>
<result column="project_code" property="projectCode"/>
<result column="business_type_name" property="businessTypeName"/>
<result column="business_type_code" property="businessTypeCode"/>
<result column="sign_company_id" property="signCompanyId"/>
<result column="sign_company_name" property="signCompanyName"/>
<result column="is_exclusive" property="isExclusive"/>
<result column="exclusive_description" property="exclusiveDescription"/>
<result column="nc_code" property="ncCode"/>
<result column="interface_man" property="interfaceMan"/>
<result column="interface_man_territory" property="interfaceManTerritory"/>
<result column="interface_man_phone" property="interfaceManPhone"/>
<result column="interface_man_email" property="interfaceManEmail"/>
<result column="remark" property="remark"/>
<result column="if_need_recruitment" property="ifNeedRecruitment"/>
<result column="recruiter" property="recruiter"/>
<result column="service_status" property="serviceStatus"/>
<result column="ejy_wage_auto_card" property="ejyWageAutoCard"/>
<result column="data_source" property="dataSource"/>
<result column="service_mode" property="serviceMode"/>
<result column="service_province" property="serviceProvince"/>
<result column="service_city" property="serviceCity"/>
<result column="tax_rate" property="taxRate"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
</resultMap>
<sql id="Base_Column_List">
id,
customer_id,
parent_id,
wo_id,
project_name,
project_code,
business_type_name,
business_type_code,
sign_company_id,
sign_company_name,
is_exclusive,
exclusive_description,
nc_code,
interface_man,
interface_man_territory,
interface_man_phone,
interface_man_email,
remark,
if_need_recruitment,
recruiter,
service_status,
ejy_wage_auto_card,
data_source,
service_mode,
service_province,
service_city,
tax_rate,
create_time,
update_time
</sql>
<select id="selectProject" resultType="com.dianmi.dto.proj.CustProjectDto">
select
cp.id,
cp.project_name,
cp.project_code,
cp.customer_id,
cp.cust_sale_process_id as custSaleProcessId,
c.customer_name,
c.customer_code,
(SELECT id FROM cust_project WHERE parent_id = cp.id order by id LIMIT 1) firstProjectId,
(SELECT GROUP_CONCAT(DISTINCT user_name) FROM proj_member WHERE project_id in (SELECT id FROM cust_project WHERE
parent_id = cp.id and `type` = '销售')) sellerName,
cp.business_type_name,
cp.sign_company_name,
cp.service_status
from
cust_project cp
left join customer c on c.id = cp.customer_id
where
parent_id = 0 and ((cp.area_code != 'AR0003' AND cp.area_code != 'AR0001') or cp.area_code is null)
<if test="pojo!=null">
and cp.id in (
SELECT parent_id FROM cust_project WHERE id in
( select project_id from proj_member where user_account in
<foreach item="item" index="index" open="(" separator="," close=")" collection="pojo.memberSet">
#{item}
</foreach>
)
)
<if test="pojo.searchType==1">
<if test="pojo.searchContent!=null">
and (c.customer_name like #{pojo.searchContent} or c.customer_code like #{pojo.searchContent})
</if>
</if>
<if test="pojo.searchType==2">
<if test="pojo.searchContent!=null">
and (cp.project_name like #{pojo.searchContent} or cp.project_code like #{pojo.searchContent})
</if>
</if>
<if test="pojo.searchType==3">
<if test="pojo.searchContent!=null">
and cp.id in
(
select parent_id from cust_project
where (project_name like #{pojo.searchContent} or project_code like #{pojo.searchContent})
)
</if>
</if>
<if test="pojo.sellerAccounts!=null">
and cp.id in (
select project_id from proj_member where `type` = '销售' and user_account in
<foreach item="item" index="index" open="(" separator="," close=")"
collection="pojo.sellerAccounts">
#{item}
</foreach>
UNION
SELECT project_id FROM proj_contract
where
zwzy_acct in
<foreach item="item" index="index" open="(" separator="," close=")"
collection="pojo.sellerAccounts">
#{item}
</foreach>
or kf_followup_account in
<foreach item="item" index="index" open="(" separator="," close=")"
collection="pojo.sellerAccounts">
#{item}
</foreach>
)
</if>
</if>
<if test="projectIds != null and projectIds.size()>0">
and cp.id in
<foreach item="item" index="index" open="(" separator="," close=")" collection="projectIds">
#{item}
</foreach>
</if>
order by cp.id desc
</select>
<!--财务角色,看到全部数据,筛选条件 -->
<select id="selectProjectByCaiWu" resultType="com.dianmi.dto.proj.CustProjectDto">
select
cp.id,
cp.project_name,
cp.project_code,
cp.customer_id,
c.customer_name,
c.customer_code,
cp.cust_sale_process_id as custSaleProcessId,
(SELECT id FROM cust_project WHERE parent_id = cp.id order by id LIMIT 1) firstProjectId,
(SELECT GROUP_CONCAT(DISTINCT user_name) FROM proj_member WHERE project_id in (SELECT id FROM cust_project WHERE
parent_id = cp.id and `type` = '销售')) sellerName,
cp.business_type_name,
cp.sign_company_name,
cp.service_status
from
cust_project cp
left join customer c on c.id = cp.customer_id
where
parent_id = 0 and ((cp.area_code != 'AR0003' AND cp.area_code != 'AR0001') or cp.area_code is null)
<if test="pojo!=null">
<if test="pojo.searchType==1">
<if test="pojo.searchContent!=null">
and (c.customer_name like #{pojo.searchContent} or c.customer_code like #{pojo.searchContent})
</if>
</if>
<if test="pojo.searchType==2">
<if test="pojo.searchContent!=null">
and (cp.project_name like #{pojo.searchContent} or cp.project_code like #{pojo.searchContent})
</if>
</if>
<if test="pojo.searchType==3">
<if test="pojo.searchContent!=null">
and cp.id in
(
select parent_id from cust_project
where (project_name like #{pojo.searchContent} or project_code like #{pojo.searchContent})
)
</if>
</if>
<if test="pojo.sellerAccounts!=null">
and cp.id in (
select project_id from proj_member where `type` = '销售' and user_account in
<foreach item="item" index="index" open="(" separator="," close=")"
collection="pojo.sellerAccounts">
#{item}
</foreach>
UNION
SELECT project_id FROM proj_contract
where
zwzy_acct in
<foreach item="item" index="index" open="(" separator="," close=")"
collection="pojo.sellerAccounts">
#{item}
</foreach>
or kf_followup_account in
<foreach item="item" index="index" open="(" separator="," close=")"
collection="pojo.sellerAccounts">
#{item}
</foreach>
)
</if>
</if>
<if test="projectIds != null and projectIds.size()>0">
and cp.id in
<foreach item="item" index="index" open="(" separator="," close=")" collection="projectIds">
#{item}
</foreach>
</if>
order by cp.id desc
</select>
<select id="selectChildList" resultType="com.dianmi.dto.proj.CustProjectDto">
select
cp.id,
cp.project_name,
cp.project_code,
cp.customer_id,
c.customer_name,
c.customer_code,
(select GROUP_CONCAT(user_name) from proj_member where project_id = cp.id and `type` = '销售') seller_name,
cp.business_type_name,
cp.sign_company_name,
cp.service_status
from
cust_project cp
left join customer c on c.id = cp.customer_id
where cp.parent_id in
<foreach item="item" index="index" open="(" separator="," close=")" collection="projectIdList">
#{item}
</foreach>
order by cp.id desc
</select>
<select id="selectByAccounts" resultType="com.dianmi.domain.entity.CustProject">
select
<include refid="Base_Column_List"/>
from cust_project
where
parent_id != 0
and service_status = 1
and id in (
select project_id from proj_member where user_account in
<foreach item="item" index="index" open="(" separator="," close=")" collection="accountList">
#{item}
</foreach>
and `type` = '销售'
)and parent_id in (
select project_id from proj_contract
)
and id not in (
select project_id from company_sign where sign_type = 2
)
order by id desc
</select>
<select id="selectNotInvalidCount" resultType="java.lang.Integer">
select count(*) from cust_project where service_status = 1 and customer_id = #{customerId}
</select>
<select id="listLigongCustProjects" resultType="com.dianmi.dto.ligong.CustProjectLigongDto">
SELECT
foo.project_code as parentProjectCode,
cp.*,
pc.id as crmContactId
FROM
cust_project cp
JOIN customer c on c.id = cp.customer_id
join business_type bt on bt.composite_code=cp.business_type_code
left join cust_project foo on foo.id = cp.parent_id
left JOIN proj_contract pc on pc.project_id = foo.id
WHERE cp.customer_id = #{customerId}
and cp.parent_id != 0 and cp.project_code!=''
<if test="signCompanyId != null and signCompanyId != ''">
and cp.sign_company_id =#{signCompanyId}
</if>
and bt.composite_code='YG0302'
and bt.area_code='AR0002'
order by cp.id desc
</select>
<!--根据客户id查询父项目-->
<select id="getFooProjectsByCustomerId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM
cust_project
WHERE
parent_id = 0
AND customer_id = #{customerId}
</select>
<select id="selectByProjectCode" resultType="com.dianmi.domain.entity.CustProject">
SELECT
<include refid="Base_Column_List"/>
from cust_project
where project_code = #{projectCode}
</select>
<select id="selectChildByProjectCode" resultType="com.dianmi.domain.entity.CustProject">
SELECT
<include refid="Base_Column_List"/>
from cust_project
where parent_id in (
SELECT
id
from cust_project
where project_code = #{projectCode}
)
</select>
<select id="selectFirstProjectId" resultType="java.lang.String">
SELECT id FROM cust_project WHERE parent_id = #{parentProjectId} order by id LIMIT 1
</select>
<select id="selectAreaChild" resultType="com.dianmi.crm.api.dto.CustProjectInfoDto">
select
cp.id id,
cp.project_name projectName,
cp.project_code projectCode,
cp.customer_id customerId,
CAST(cp.tax_rate AS decimal(14,2)) taxRate,
c.customer_name customerName,
c.customer_code customerCode,
c.area_name areaName,
cp.business_type_name businessTypeName,
cp.sign_company_name signCompanyName,
cp.service_status serviceStatus,
cp.parent_id parentId
from
cust_project cp
left join customer c on c.id = cp.customer_id
where
c.area_code = #{areaCode}
and cp.parent_id != 0
</select>
<select id="selectSubProjectsBySubProjectCodes" resultType="com.dianmi.dto.proj.CustProjectDto">
select
<include refid="Base_Column_List"/>
from cust_project
where project_code in
<foreach item="item" index="index" open="(" separator="," close=")" collection="subProjectCodes">
#{item}
</foreach>
and parent_id !=0
</select>
<select id="getProjectByprojectIds" resultType="com.dianmi.crm.api.dto.CustProjectInfoDto">
select
cp.id id,
cp.project_name projectName,
cp.project_code projectCode,
cp.customer_id customerId,
CAST(cp.tax_rate AS decimal(14,2)) taxRate,
c.customer_name customerName,
c.customer_code customerCode,
c.area_name areaName,
cp.business_type_name businessTypeName,
cp.sign_company_name signCompanyName,
cp.service_status serviceStatus,
cp.parent_id parentId
from
cust_project cp
left join customer c on c.id = cp.customer_id
where cp.id in
<foreach item="item" index="index" open="(" separator="," close=")" collection="projectIds">
#{item}
</foreach>
and cp.parent_id != 0
</select>
<select id="selectChildByCode" resultType="com.dianmi.crm.api.dto.CustProjectInfoDto">
select
cp.id id,
cp.project_name projectName,
cp.project_code projectCode,
cp.customer_id customerId,
CAST(cp.tax_rate AS decimal(14,2)) taxRate,
c.customer_name customerName,
c.customer_code customerCode,
c.area_name areaName,
c.area_code areaCode,
cp.business_type_name businessTypeName,
cp.business_type_code businessTypeCode,
cp.sign_company_name signCompanyName,
cp.service_status serviceStatus,
cp.parent_id parentId
from
cust_project cp
left join customer c on c.id = cp.customer_id
where
cp.project_code in
<foreach item="item" index="index" open="(" separator="," close=")" collection="subProjectCodeList">
#{item}
</foreach>
and cp.parent_id != 0
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment