|
@@ -40,6 +40,65 @@
|
|
i.client_name, i.mobile, i.client_manager, i.skiller, i.sign_date, i.payment_method, i.amount, i.state,i.department_id,i.contract_url,i.user_id,i.customer_id
|
|
i.client_name, i.mobile, i.client_manager, i.skiller, i.sign_date, i.payment_method, i.amount, i.state,i.department_id,i.contract_url,i.user_id,i.customer_id
|
|
</sql>
|
|
</sql>
|
|
|
|
|
|
|
|
+ <sql id="Common_query_item">
|
|
|
|
+ SELECT
|
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
|
+ , d.name as departmentName,dd1.name as cateName,dd2.name as businessSourceName,
|
|
|
|
+ (select name from item_stage s where curDate() >= s.start_date and curDate() <= s.end_date and s.item_id = i.id) as stageName,
|
|
|
|
+ ( SELECT
|
|
|
|
+ s.id
|
|
|
|
+ FROM
|
|
|
|
+ item_stage s
|
|
|
|
+ WHERE
|
|
|
|
+ curDate() >= s.start_date
|
|
|
|
+ AND curDate() <= s.end_date
|
|
|
|
+ AND s.item_id = i.id
|
|
|
|
+ ) AS stageId,
|
|
|
|
+
|
|
|
|
+ ( CASE when ((SELECT count(*) FROM item_stage s
|
|
|
|
+ WHERE
|
|
|
|
+ s.item_id = i.id
|
|
|
|
+ AND curDate() >= ( SELECT min( start_date ) FROM item_stage WHERE item_id = i.id )
|
|
|
|
+ AND curDate() <= ( SELECT max( end_date ) FROM item_stage WHERE item_id = i.id )
|
|
|
|
+ )=0
|
|
|
|
+
|
|
|
|
+ AND
|
|
|
|
+
|
|
|
|
+ ( SELECT count(*) FROM item_stage s WHERE s.item_id = i.id ) !=0 )
|
|
|
|
+
|
|
|
|
+ THEN
|
|
|
|
+ '已完成'
|
|
|
|
+
|
|
|
|
+ WHEN
|
|
|
|
+ (SELECT
|
|
|
|
+ count(*)
|
|
|
|
+ FROM
|
|
|
|
+ item_stage s
|
|
|
|
+ WHERE
|
|
|
|
+ s.item_id = i.id
|
|
|
|
+ AND curDate() >= ( SELECT min( start_date ) FROM item_stage WHERE item_id = i.id )
|
|
|
|
+ AND curDate() <= ( SELECT max( end_date ) FROM item_stage WHERE item_id = i.id ) )
|
|
|
|
+ !=0
|
|
|
|
+ THEN
|
|
|
|
+ '进行中'
|
|
|
|
+ WHEN
|
|
|
|
+ (SELECT
|
|
|
|
+ count(*)
|
|
|
|
+ FROM
|
|
|
|
+ item_stage s
|
|
|
|
+ WHERE
|
|
|
|
+ s.item_id = i.id)= 0
|
|
|
|
+ THEN
|
|
|
|
+ '未开始'
|
|
|
|
+ ELSE ''
|
|
|
|
+ END
|
|
|
|
+ ) AS itemStatus
|
|
|
|
+ FROM
|
|
|
|
+ item i left join department d on i.department_id = d.id left join dict_data dd1 on i.cate = dd1.id
|
|
|
|
+ left join dict_data dd2 on i.business_source = dd2.id
|
|
|
|
+ where i.deleted = 0 and dd1.deleted =0 and dd2.deleted = 0
|
|
|
|
+ </sql>
|
|
|
|
+
|
|
<select id="stat" resultType="com.dayou.vo.ItemStatVO">
|
|
<select id="stat" resultType="com.dayou.vo.ItemStatVO">
|
|
SELECT
|
|
SELECT
|
|
( SELECT count(*) FROM item WHERE state = '已完成' AND deleted = 0 ) AS doneNum,
|
|
( SELECT count(*) FROM item WHERE state = '已完成' AND deleted = 0 ) AS doneNum,
|
|
@@ -60,15 +119,7 @@
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<select id="getPage" resultType="com.dayou.vo.ItemVO">
|
|
<select id="getPage" resultType="com.dayou.vo.ItemVO">
|
|
- SELECT
|
|
|
|
- <include refid="Base_Column_List"/> , d.name as departmentName,dd1.name as cateName,dd2.name as businessSourceName,
|
|
|
|
- (select name from item_stage s where curDate() >= s.start_date and curDate() <= s.end_date and s.item_id = i.id) as stageName,
|
|
|
|
- (select id from item_stage s where curDate() >= s.start_date and curDate() <= s.end_date and s.item_id and s.item_id = i.id) as stageId
|
|
|
|
- FROM
|
|
|
|
- item i left join department d on i.department_id = d.id left join dict_data dd1 on i.cate = dd1.id
|
|
|
|
- left join dict_data dd2 on i.business_source = dd2.id
|
|
|
|
- WHERE
|
|
|
|
- i.deleted = 0 and dd1.deleted =0 and dd2.deleted = 0
|
|
|
|
|
|
+ <include refid="Common_query_item"/>
|
|
<if test="item!=null and item.name!=null and item.name!='' ">
|
|
<if test="item!=null and item.name!=null and item.name!='' ">
|
|
and i.name like concat ('%',#{item.name},'%')
|
|
and i.name like concat ('%',#{item.name},'%')
|
|
</if>
|
|
</if>
|
|
@@ -90,20 +141,14 @@
|
|
#{departmentId}
|
|
#{departmentId}
|
|
</foreach>
|
|
</foreach>
|
|
</if>
|
|
</if>
|
|
-
|
|
|
|
|
|
+ <if test="item!=null and item.state!=null and item.state!='' ">
|
|
|
|
+ GROUP BY i.id
|
|
|
|
+ HAVING itemStatus =#{item.state}
|
|
|
|
+ </if>
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<select id="getXPage" resultType="com.dayou.vo.ItemVO">
|
|
<select id="getXPage" resultType="com.dayou.vo.ItemVO">
|
|
- SELECT
|
|
|
|
- <include refid="Base_Column_List"/> , d.name as departmentName,dd1.name as cateName,dd2.name as businessSourceName,
|
|
|
|
- (select name from item_stage s where curDate() >= s.start_date and curDate() <= s.end_date and s.item_id = i.id) as stageName,
|
|
|
|
- (select id from item_stage s where curDate() >= s.start_date and curDate() <= s.end_date and s.item_id and s.item_id = i.id) as stageId
|
|
|
|
- FROM
|
|
|
|
- item i left join department d on i.department_id = d.id
|
|
|
|
- left join dict_data dd1 on i.cate = dd1.id
|
|
|
|
- left join dict_data dd2 on i.business_source = dd2.id
|
|
|
|
- WHERE
|
|
|
|
- i.deleted = 0 and dd1.deleted =0 and dd2.deleted = 0
|
|
|
|
|
|
+ <include refid="Common_query_item"/>
|
|
<if test="item!=null and item.name!=null and item.name!='' ">
|
|
<if test="item!=null and item.name!=null and item.name!='' ">
|
|
and i.name like concat ('%',#{item.name},'%')
|
|
and i.name like concat ('%',#{item.name},'%')
|
|
</if>
|
|
</if>
|
|
@@ -133,7 +178,7 @@
|
|
<if test="item!=null and item.userIds!=null and item.userIds.size!=0 and item!=null and item.departmentIds!=null and item.departmentIds.size!=0">
|
|
<if test="item!=null and item.userIds!=null and item.userIds.size!=0 and item!=null and item.departmentIds!=null and item.departmentIds.size!=0">
|
|
and (
|
|
and (
|
|
<if test="item!=null and item.userIds!=null and item.userIds.size!=0">
|
|
<if test="item!=null and item.userIds!=null and item.userIds.size!=0">
|
|
- EXISTS ( SELECT item_id FROM item_user iu WHERE iu.item_id = i.id AND iu.user_id in
|
|
|
|
|
|
+ EXISTS ( SELECT item_id FROM item_user iu WHERE iu.item_id = i.id AND iu.user_id in
|
|
<foreach collection="item.userIds" open="(" close=")" separator="," item="userId">
|
|
<foreach collection="item.userIds" open="(" close=")" separator="," item="userId">
|
|
#{userId}
|
|
#{userId}
|
|
</foreach>
|
|
</foreach>
|
|
@@ -147,12 +192,14 @@
|
|
</if>
|
|
</if>
|
|
)
|
|
)
|
|
</if>
|
|
</if>
|
|
|
|
+ <if test="item!=null and item.state!=null and item.state!='' ">
|
|
|
|
+ GROUP BY i.id
|
|
|
|
+ HAVING itemStatus =#{item.state}
|
|
|
|
+ </if>
|
|
</select>
|
|
</select>
|
|
|
|
|
|
- <select id="xSelectList" parameterType="com.dayou.vo.ItemStageVO" resultType="com.dayou.entity.Item">
|
|
|
|
- select <include refid="Base_Column_List"/> ,dd1.name as cateName,dd2.name as businessSourceName from item i left join dict_data dd1 on i.cate = dd1.id
|
|
|
|
- left join dict_data dd2 on i.business_source = dd2.id
|
|
|
|
- where i.deleted = 0 and dd1.deleted =0 and dd2.deleted = 0
|
|
|
|
|
|
+ <select id="xSelectList" parameterType="com.dayou.vo.ItemStageVO" resultType="com.dayou.vo.ItemVO">
|
|
|
|
+ <include refid="Common_query_item"/>
|
|
<if test="item!=null and item.userIds!=null and item.userIds.size!=0 and item!=null and item.departmentIds!=null and item.departmentIds.size==0">
|
|
<if test="item!=null and item.userIds!=null and item.userIds.size!=0 and item!=null and item.departmentIds!=null and item.departmentIds.size==0">
|
|
<if test="item!=null and item.userIds!=null and item.userIds.size!=0">
|
|
<if test="item!=null and item.userIds!=null and item.userIds.size!=0">
|
|
and EXISTS ( SELECT item_id FROM item_user iu WHERE iu.item_id = i.id AND iu.user_id in
|
|
and EXISTS ( SELECT item_id FROM item_user iu WHERE iu.item_id = i.id AND iu.user_id in
|
|
@@ -187,6 +234,10 @@
|
|
</if>
|
|
</if>
|
|
)
|
|
)
|
|
</if>
|
|
</if>
|
|
|
|
+ <if test="item!=null and item.state!=null and item.state!='' ">
|
|
|
|
+ GROUP BY i.id
|
|
|
|
+ HAVING itemStatus =#{item.state}
|
|
|
|
+ </if>
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
|