123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- <?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.dayou.mapper.ItemMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.dayou.vo.ItemVO">
- <result column="id" property="id" />
- <result column="deleted" property="deleted" />
- <result column="created" property="created" />
- <result column="modified" property="modified" />
- <result column="business_no" property="businessNo" />
- <result column="oa_no" property="oaNo" />
- <result column="name" property="name" />
- <result column="cate" property="cate" />
- <result column="business_source" property="businessSource" />
- <result column="belong_to" property="belongTo" />
- <result column="client_unit" property="clientUnit" />
- <result column="client_name" property="clientName" />
- <result column="mobile" property="mobile" />
- <result column="client_manager" property="clientManager" />
- <result column="skiller" property="skiller" />
- <result column="sign_date" property="signDate" />
- <result column="payment_method" property="paymentMethod" />
- <result column="amount" property="amount" />
- <result column="state" property="state" />
- <result column="department_id" property="departmentId" />
- <result column="contract_url" property="contractUrl" />
- <result column="user_id" property="userId" />
- <result column="customer_id" property="customerId" />
- <collection property="userIds" ofType="java.lang.Long" select="selectItemUserId" column="id"/>
- </resultMap>
- <!-- 通用查询结果列 -->
- <sql id="Base_Column_List">
- i.id,
- i.deleted,
- i.created,
- i.modified,
- i.business_no, i.oa_no, i.name,i.cate, i.business_source,i.belong_to,i.client_unit,
- 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>
- <select id="stat" resultType="com.dayou.vo.ItemStatVO">
- SELECT
- ( SELECT count(*) FROM item WHERE state = '已完成' AND deleted = 0 ) AS doneNum,
- ( SELECT count(*) FROM item WHERE state = '进行中' AND deleted = 0 ) AS pendingNum,
- ( SELECT count(*) FROM item WHERE state = '未开始' AND deleted = 0 ) AS unplayedNum
- FROM
- item
- WHERE
- deleted =0
- </select>
- <select id="xDetail" parameterType="java.lang.Long" resultMap="BaseResultMap">
- select <include refid="Base_Column_List"/>, d.name as departmentName from item i left join department d on d.id = i.department_id where i.deleted = 0 and i.id =#{id}
- </select>
- <select id="selectItemUserId" parameterType="java.lang.Long" resultType="java.lang.Long">
- select user_id from item_user where item_id = #{id}
- </select>
- <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
- <if test="item!=null and item.name!=null and item.name!='' ">
- and i.name like concat ('%',#{item.name},'%')
- </if>
- <if test="item!=null and item.businessNo!=null and item.businessNo!='' ">
- and i.business_no like concat (#{item.businessNo},'%')
- </if>
- <if test="item!=null and item.clientManager!=null and item.clientManager!='' ">
- and i.client_manager like concat ('%',#{item.clientManager},'%')
- </if>
- <if test="item!=null and item.userIds!=null and item.userIds.size!=0">
- and i.user_id in
- <foreach collection="item.userIds" open="(" close=")" separator="," item="userId">
- #{userId}
- </foreach>
- </if>
- <if test="item!=null and item.departmentIds!=null and item.departmentIds.size!=0">
- and i.department_id in
- <foreach collection="item.departmentIds" open="(" close=")" separator="," item="departmentId">
- #{departmentId}
- </foreach>
- </if>
- </select>
- <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
- <if test="item!=null and item.name!=null and item.name!='' ">
- and i.name like concat ('%',#{item.name},'%')
- </if>
- <if test="item!=null and item.businessNo!=null and item.businessNo!='' ">
- and i.business_no like concat (#{item.businessNo},'%')
- </if>
- <if test="item!=null and item.clientManager!=null and item.clientManager!='' ">
- and i.client_manager like concat ('%',#{item.clientManager},'%')
- </if>
- <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 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">
- #{userId}
- </foreach>
- )
- </if>
- </if>
- <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.departmentIds!=null and item.departmentIds.size!=0">
- and i.department_id in
- <foreach collection="item.departmentIds" open="(" close=")" separator="," item="departmentId">
- #{departmentId}
- </foreach>
- </if>
- </if>
- <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 (
- <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
- <foreach collection="item.userIds" open="(" close=")" separator="," item="userId">
- #{userId}
- </foreach>
- )
- </if>
- <if test="item!=null and item.departmentIds!=null and item.departmentIds.size!=0">
- or i.department_id in
- <foreach collection="item.departmentIds" open="(" close=")" separator="," item="departmentId">
- #{departmentId}
- </foreach>
- </if>
- )
- </if>
- </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
- <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 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">
- #{userId}
- </foreach>
- )
- </if>
- </if>
- <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.departmentIds!=null and item.departmentIds.size!=0">
- and i.department_id in
- <foreach collection="item.departmentIds" open="(" close=")" separator="," item="departmentId">
- #{departmentId}
- </foreach>
- </if>
- </if>
- <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 (
- <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
- <foreach collection="item.userIds" open="(" close=")" separator="," item="userId">
- #{userId}
- </foreach>
- )
- </if>
- <if test="item!=null and item.departmentIds!=null and item.departmentIds.size!=0">
- or i.department_id in
- <foreach collection="item.departmentIds" open="(" close=")" separator="," item="departmentId">
- #{departmentId}
- </foreach>
- </if>
- )
- </if>
- </select>
- </mapper>
|