12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088 |
- <?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.management.platform.mapper.ProjectMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.management.platform.entity.Project">
- <id column="id" property="id" />
- <result column="project_name" property="projectName" />
- <result column="company_id" property="companyId" />
- <result column="project_code" property="projectCode" />
- <result column="incharger_id" property="inchargerId" />
- <result column="plan_start_date" property="planStartDate" />
- <result column="plan_end_date" property="planEndDate" />
- <result column="progress" property="progress" />
- <result column="level" property="level" />
- <result column="status" property="status" />
- <result column="finish_date" property="finishDate" />
- <result column="creator_id" property="creatorId" />
- <result column="creator_name" property="creatorName" />
- <result column="create_date" property="createDate" />
- <result column="contract_amount" property="contractAmount" />
- <result column="budget" property="budget" />
- <result column="base_man" property="baseMan" />
- <result column="base_outsourcing" property="baseOutsourcing" />
- <result column="base_risk1" property="baseRisk1" />
- <result column="base_risk2" property="baseRisk2" />
- <result column="base_fee" property="baseFee" />
- <result column="fee_normal" property="feeNormal" />
- <result column="fee_travel" property="feeTravel" />
- <result column="fee_outsourcing" property="feeOutsourcing" />
- <result column="fee_man" property="feeMan" />
- <result column="customer_id" property="customerId" />
- <result column="customer_name" property="customerName" />
- <result column="is_public" property="isPublic" />
- <result column="associate_degrees" property="associateDegrees" />
- <result column="associate_degree_names" property="associateDegreeNames" />
- <result column="task_gp_incharge" property="taskGpIncharge" />
- <result column="category" property="category" />
- <result column="category_name" property="categoryName" />
- <result column="project_desc" property="projectDesc" />
- <result column="project_main_id" property="projectMainId" />
- <result column="provider_ids" property="providerIds" />
- <result column="provider_names" property="providerNames" />
- <result column="current_stage_id" property="currentStageId" />
- <result column="current_stage_name" property="currentStageName" />
- <result column="output_value" property="outputValue" />
- <result column="dept_id" property="deptId" />
- <result column="dept_cascade" property="deptCascade" />
- </resultMap>
- <!-- 通用查询结果列 -->
- <sql id="Base_Column_List">
- id, project_name, company_id, project_code, incharger_id, plan_start_date, plan_end_date, progress, level, status, finish_date, creator_id, creator_name, create_date, contract_amount, budget, base_man, base_outsourcing, base_risk1, base_risk2, base_fee, fee_normal, fee_travel, fee_outsourcing, fee_man, customer_id, customer_name, is_public, associate_degrees, associate_degree_names, task_gp_incharge, category, category_name, project_desc, project_main_id, provider_ids, provider_names, current_stage_id, current_stage_name, output_value, dept_id, dept_cascade
- </sql>
- <resultMap id="BaseResultMap2" type="com.management.platform.entity.vo.ProjectWithStage">
- <result column="id" property="id" />
- <result column="project_name" property="projectName" />
- <result column="project_code" property="projectCode" />
- <collection property="stageCostList" javaType="java.util.ArrayList"
- ofType="com.management.platform.entity.vo.StageCost"
- select="selectStageSum" column="projectId=id"></collection>
- </resultMap>
- <resultMap id="CustomerResultMap" type="com.management.platform.entity.vo.CustomerProject" >
- <result column="customer_id" property="customerId" />
- <result column="customer_name" property="customerName" />
- <result column="contract_amount" property="contractAmount" />
- <result column="fee_normal" property="feeNormal" />
- <result column="fee_travel" property="feeTravel" />
- <result column="fee_outsourcing" property="feeOutsourcing" />
- <result column="fee_man" property="feeMan" />
- <result column="project_num" property="projectNum" />
- <result column="project_ids" property="projectIds" />
- <result column="project_names" property="projectNames" />
- </resultMap>
- <select id="selectWithStage" resultMap="BaseResultMap2" >
- select id, project_code, project_name from project
- where company_id = #{companyId}
- <if test="projectId != null">
- and id = #{projectId}
- </if>
- <if test="inchagerIds!=null and inchagerIds.size()>0">
- and id in
- <foreach collection="inchagerIds" open="(" close=")" separator="," item="item">
- #{item}
- </foreach>
- </if>
- order by is_public desc, id asc
- <if test="startIndex != null">
- limit ${startIndex}, ${endIndex}
- </if>
- </select>
- <select id="selectStageSum" resultType="com.management.platform.entity.vo.StageCost">
- select IFNULL(report.stage, '-') AS stage_name, IFNULL(SUM(report.`cost`),0) AS cost,
- IFNULL(SUM(report.`working_time`), 0) AS working_time
- FROM report where report.state = 1 and report.`project_id` = #{projectId}
- GROUP BY report.stage
- </select>
- <!--获取查询者所在公司每个项目的工时成本-->
- <select id="getParticipatedProject" resultType="java.util.Map">
- SELECT id, project_code AS projectCode, project_name AS projectName, status, task_gp_incharge as taskGpIncharge, project_desc as projectDesc
- FROM project
- WHERE id IN (
- SELECT project_id
- FROM participation
- WHERE user_id = #{userId}
- ) or incharger_id = #{userId}
- or creator_id = #{userId}
- or (is_public = 1 and company_id = #{companyId})
- ORDER BY is_public DESC, id DESC
- </select>
- <select id="getOnlyJoinProjects" resultType="java.util.Map">
- SELECT id, project_code AS projectCode, project_name AS projectName, status, task_gp_incharge as taskGpIncharge, project_desc as projectDesc
- FROM project
- WHERE id IN (
- SELECT project_id
- FROM participation
- WHERE user_id = #{userId}
- )
- or (is_public = 1 and company_id = #{companyId})
- ORDER BY is_public DESC, id ASC
- </select>
- <!--获取查询者所在公司每个项目的工时成本-->
- <select id="getTimeCost" resultType="java.util.Map">
- SELECT a.id, a.project_code as projectCode, a.project_name AS project, SUM(b.working_time) AS cost, SUM(b.cost) AS costMoney,a.category_name as categoryName
- FROM project AS a
- LEFT JOIN report AS b ON b.project_id = a.id
- JOIN user AS c ON b.creator_id = c.id
- WHERE a.company_id = #{companyId}
- <if test="projectId != null">
- AND a.id = #{projectId}
- </if>
- <if test="userId != null">
- AND b.creator_id = #{userId}
- </if>
- <if test="startDate != null and endDate != null">
- AND b.create_date between #{startDate} and #{endDate}
- </if>
- <choose>
- <when test="filterDeptIds!=null and filterDeptIds.size()>0">
- and b.dept_id in
- <foreach collection="filterDeptIds" open="(" item="item" separator="," close=")">
- #{item}
- </foreach>
- </when>
- <otherwise>
- <if test="deptIds!=null and deptIds.size()>0">
- and b.dept_id in
- <foreach collection="deptIds" open="(" item="item" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </otherwise>
- </choose>
- AND b.state = 1
- GROUP BY a.id
- ORDER BY a.id ASC
- </select>
- <!--获取查询者所在公司每个项目的工时成本-->
- <select id="getTimeCostByMainProject" resultType="java.util.Map">
- SELECT SUM(b.working_time) AS cost, SUM(b.cost) AS costMoney,a.category_name as categoryName,IFNULL(pm.name,'未分类') as mainProjectName
- FROM project AS a
- LEFT JOIN report AS b ON b.project_id = a.id
- JOIN user AS c ON b.creator_id = c.id
- LEFT JOIN project_main pm on pm.id=a.project_main_id
- WHERE a.company_id = #{companyId}
- <if test="projectId != null">
- AND a.id = #{projectId}
- </if>
- <if test="startDate != null and endDate != null">
- AND b.create_date between #{startDate} and #{endDate}
- </if>
- <if test="deptIds!=null and deptIds.size()>0">
- and b.dept_id in
- <foreach collection="deptIds" open="(" item="item" separator="," close=")">
- #{item}
- </foreach>
- </if>
- AND b.state = 1
- GROUP BY a.project_main_id
- ORDER BY a.id ASC
- </select>
- <!--获取查询者所在公司每个项目分类的工时成本-->
- <select id="getTimeCostByCategory" resultType="java.util.Map">
- SELECT SUM(b.working_time) AS cost, SUM(b.cost) AS costMoney,IFNULL(a.category_name,'未分类')as categoryName,IFNULL(a.category,0) as category
- FROM project AS a
- LEFT JOIN report AS b ON b.project_id = a.id
- JOIN user AS c ON b.creator_id = c.id
- WHERE a.company_id = #{companyId}
- <if test="projectCategoryId != null">
- AND a.category = #{projectCategoryId}
- </if>
- <if test="userId != null">
- AND b.creator_id = #{userId}
- </if>
- <if test="startDate != null and endDate != null">
- AND b.create_date between #{startDate} and #{endDate}
- </if>
- <if test="deptIds!=null and deptIds.size()>0">
- and b.dept_id in
- <foreach collection="deptIds" open="(" item="item" separator="," close=")">
- #{item}
- </foreach>
- </if>
- AND b.state = 1
- GROUP BY a.category
- ORDER BY a.category ASC
- </select>
- <!--获取自定义数值的项目统计 -->
- <select id="getCustomDataSum" resultType="java.util.Map">
- SELECT a.id, a.project_code as projectCode, a.project_name AS project, IFNULL(SUM(b.custom_data), 0) AS cost
- FROM project AS a
- LEFT JOIN report AS b ON b.project_id = a.id
- JOIN user AS c ON b.creator_id = c.id
- WHERE a.company_id = #{companyId}
- <if test="projectId != null">
- AND a.id = #{projectId}
- </if>
- <if test="userId != null">
- AND b.creator_id = #{userId}
- </if>
- <if test="startDate != null and endDate != null">
- AND b.create_date between #{startDate} and #{endDate}
- </if>
- AND b.state = 1
- GROUP BY a.id
- ORDER BY SUM(b.custom_data) DESC
- </select>
- <!--获取日报的人员月度工时 -->
- <select id="getTimeCostReport" resultType="java.util.Map">
- SELECT a.working_time as cost, b.id as projectId, b.project_name AS project, a.creator_id as creatorId
- FROM report AS a
- LEFT JOIN project AS b ON a.project_id = b.id
- LEFT JOIN user AS c ON a.creator_id = c.id
- WHERE b.company_id = #{companyId}
- <if test="projectId != null">
- AND b.id = #{projectId}
- </if>
- <if test="startDate != null and endDate != null">
- AND a.create_date between #{startDate} and #{endDate}
- </if>
- <if test="deptIds!=null and deptIds.size()>0">
- and a.dept_id in
- <foreach collection="deptIds" separator="," close=")" open="(" item="item">
- #{item}
- </foreach>
- </if>
- AND a.state = 1
- </select>
- <!--获取人员的月度总工时 -->
- <select id="getUserMonthTimeCost" resultType="java.util.Map">
- SELECT a.creator_id as creatorId, sum(a.working_time) as cost
- FROM report AS a, user as b
- WHERE a.creator_id = b.id
- and b.company_id = #{companyId}
- <if test="startDate != null and endDate != null">
- AND a.create_date between #{startDate} and #{endDate}
- </if>
- AND a.state = 1
- group by a.creator_id
- </select>
- <!--获取某个项目每个人分别需要的工时-->
- <select id="getProjectCost" resultType="java.util.Map">
- SELECT b.id as creatorId,a.project_id as projectId, b.name,a.dept_id as deptId, IFNULL(department.department_name, '未分配') as departmentName, SUM(a.working_time) AS cost, SUM(a.cost) AS costMoney
- FROM report AS a
- JOIN user AS b ON a.creator_id = b.id
- left join department on department.department_id = a.dept_id
- WHERE a.company_id=#{companyId}
- <choose>
- <when test="stateKey!=null and stateKey==1">
- and a.state = 1
- </when>
- <otherwise>
- and (a.state = 1 or a.state =0)
- </otherwise>
- </choose>
- <if test="projectId != null">
- and a.project_id = #{projectId}
- </if>
- <if test="startDate != null and endDate != null">
- AND a.create_date between #{startDate} and #{endDate}
- </if>
- <if test="userId != null">
- AND a.creator_id = #{userId}
- </if>
- <choose>
- <when test="filterDeptIds!=null and filterDeptIds.size()>0">
- and a.dept_id in
- <foreach collection="filterDeptIds" open="(" item="item" separator="," close=")">
- #{item}
- </foreach>
- </when>
- <otherwise>
- <if test="deptIds!=null and deptIds.size()>0">
- and a.dept_id in
- <foreach collection="deptIds" open="(" item="item" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </otherwise>
- </choose>
- GROUP BY b.id, a.dept_id
- ORDER BY b.id ASC, a.dept_id ASC
- </select>
- <!--获取某个项目分类每个人分别需要的工时-->
- <select id="getProjectCostByCategory" resultType="java.util.Map">
- SELECT b.id as creatorId,ifnull(c.category_name,'未分类') as categoryName,ifnull(c.category,0) as category, b.name,a.dept_id as deptId, IFNULL(department.department_name, '未分配') as departmentName, SUM(a.working_time) AS cost, SUM(a.cost) AS costMoney
- FROM report AS a
- JOIN user AS b ON a.creator_id = b.id
- left join department on department.department_id = a.dept_id
- left join project c on c.id=a.project_id
- WHERE a.company_id=#{companyId} and a.state = 1
- <if test="curProjectCategoryId != null">
- and c.category = #{curProjectCategoryId}
- </if>
- <if test="startDate != null and endDate != null">
- AND a.create_date between #{startDate} and #{endDate}
- </if>
- <if test="userId != null">
- AND a.creator_id = #{userId}
- </if>
- GROUP BY c.category, a.dept_id
- ORDER BY c.category ASC, a.dept_id ASC
- </select>
- <!--获取个人每个项目分别需要的工时-->
- <select id="getProjectCostGroupByProject" resultType="java.util.Map">
- SELECT b.id as creatorId,a.project_id as projectId, b.name,a.dept_id as deptId, IFNULL(department.department_name, '未分配') as departmentName, SUM(a.working_time) AS cost, SUM(a.cost) AS costMoney
- FROM report AS a
- JOIN user AS b ON a.creator_id = b.id
- left join department on department.department_id = a.dept_id
- WHERE a.company_id=#{companyId} and a.state = 1
- <if test="projectId != null">
- and a.project_id = #{projectId}
- </if>
- <if test="startDate != null and endDate != null">
- AND a.create_date between #{startDate} and #{endDate}
- </if>
- <if test="userId != null">
- AND a.creator_id = #{userId}
- </if>
- <if test="deptIds!=null and deptIds.size()>0">
- and a.dept_id in
- <foreach collection="deptIds" separator="," close=")" open="(" item="item">
- #{item}
- </foreach>
- </if>
- GROUP BY b.id,a.project_id
- ORDER BY b.id ASC, a.dept_id ASC
- </select>
- <!--获取个人每个项目分类分别需要的工时-->
- <select id="getProjectCostGroupByCategory" resultType="java.util.Map">
- SELECT a.creator_id as creatorId,ifnull(c.category_name,'未分类') as categoryName,ifnull(c.category,0) as category, b.name,a.dept_id as deptId, IFNULL(department.department_name, '未分配') as departmentName, SUM(a.working_time) AS cost, SUM(a.cost) AS costMoney
- FROM report AS a
- JOIN user AS b ON a.creator_id = b.id
- left join department on department.department_id = a.dept_id
- left join project c on c.id=a.project_id
- WHERE a.company_id=#{companyId} and a.state = 1
- <if test="projectCategoryId != null">
- and c.category = #{projectCategoryId}
- </if>
- <if test="startDate != null and endDate != null">
- AND a.create_date between #{startDate} and #{endDate}
- </if>
- <if test="userId != null">
- AND a.creator_id = #{userId}
- </if>
- <if test="deptIds!=null and deptIds.size()>0">
- and a.dept_id in
- <foreach collection="deptIds" separator="," close=")" open="(" item="item">
- #{item}
- </foreach>
- </if>
- GROUP BY b.id,c.category
- ORDER BY b.id ASC, a.dept_id ASC
- </select>
- <!-- 获取人员在日报填写的自定义数值 -->
- <select id="getProjectCusDataSumItem" resultType="java.util.Map">
- SELECT b.id as creatorId,
- b.name,department.department_name as departmentName, IFNULL(SUM(a.custom_data),0) AS cost
- FROM report AS a
- JOIN user AS b ON a.creator_id = b.id
- left join department on department.department_id = b.department_id
- WHERE a.state = 1 and b.company_id = #{companyId} and a.custom_data <> 0
- <if test="startDate != null and endDate != null">
- AND a.create_date between #{startDate} and #{endDate}
- </if>
- <if test="projectId != null">
- AND a.project_id = #{projectId}
- </if>
- <if test="userId != null">
- AND a.creator_id = #{userId}
- </if>
- group by b.id
- ORDER BY b.id ASC
- </select>
- <select id="getProjectCusDataDetailItem" resultType="java.util.Map">
- SELECT b.id as creatorId,project.project_code as projectCode, project.project_name as projectName,
- b.name,department.department_name as departmentName, IFNULL(a.custom_data,0) AS cost, a.create_date as createDate
- FROM report AS a
- JOIN user AS b ON a.creator_id = b.id
- left join department on department.department_id = b.department_id
- left join project on project.id = a.project_id
- WHERE a.state = 1 and b.company_id = #{companyId} and a.custom_data <> 0
- <if test="startDate != null and endDate != null">
- AND a.create_date between #{startDate} and #{endDate}
- </if>
- <if test="projectId != null">
- AND a.project_id = #{projectId}
- </if>
- <if test="userId != null">
- AND a.creator_id = #{userId}
- </if>
- ORDER BY a.create_date desc
- </select>
- <!--按照项目内的阶段名称分组统计工时-->
- <select id="getCostInStage" resultType="java.util.Map">
- SELECT IFNULL(a.stage, "未分配") as name, SUM(a.working_time) AS cost, SUM(a.cost) AS costMoney
- FROM report AS a
- WHERE a.project_id = #{projectId}
- AND a.state = 1
- <if test="startDate != null and endDate != null">
- AND a.create_date between #{startDate} and #{endDate}
- </if>
- GROUP BY a.stage
- ORDER BY a.stage ASC
- </select>
- <!--按照项目内的阶段名称分组统计工时-->
- <select id="getCostByGroup" resultType="java.util.Map">
- SELECT IFNULL(tg.name, "未分配") as GroupName, SUM(a.working_time) AS cost, SUM(a.cost) AS costMoney
- FROM report AS a
- left join task_group tg on tg.id=a.group_id
- WHERE a.project_id = #{projectId}
- AND a.state = 1
- <if test="startDate != null and endDate != null">
- AND a.create_date between #{startDate} and #{endDate}
- </if>
- GROUP BY a.group_id
- ORDER BY a.group_id ASC
- </select>
- <!--获取全部人员工时 -->
- <select id="getAllMembCost" resultType="java.util.Map">
- SELECT b.name, SUM(a.working_time) AS cost, SUM(a.cost) AS costMoney
- FROM user AS b
- left JOIN report AS a ON a.creator_id = b.id
- WHERE a.state = 1
- and b.company_id = #{companyId}
- <if test="startDate != null and endDate != null">
- AND a.create_date between #{startDate} and #{endDate}
- </if>
- <if test="projectId != null">
- AND a.project_id = #{projectId}
- </if>
- GROUP BY b.id
- ORDER BY b.id ASC
- </select>
- <!--分页获取项目成本 -->
- <select id="getAllProjectCost" resultMap="BaseResultMap">
- SELECT id, project_code, project_name,
- (SELECT IFNULL(SUM(cost),0) FROM report WHERE state = 1 AND project_id = project.id) AS fee_man,
- (SELECT IFNULL(SUM(amount),0) FROM expense_item , expense_sheet WHERE project_id = project.id AND expense_sheet.id = expense_item.`expense_id` AND expense_sheet.type = 0 and expense_sheet.status = 0) AS fee_normal,
- (SELECT IFNULL(SUM(amount),0) FROM expense_item , expense_sheet WHERE project_id = project.id AND expense_sheet.id = expense_item.`expense_id` AND expense_sheet.type = 1 and expense_sheet.status = 0) AS fee_travel,
- (SELECT IFNULL(SUM(amount),0) FROM expense_item , expense_sheet WHERE project_id = project.id AND expense_sheet.id = expense_item.`expense_id` AND expense_sheet.type = 2 and expense_sheet.status = 0) AS fee_outsourcing
- FROM project WHERE project.`company_id` = #{companyId}
- and (project.status <> 3 or project.status is null)
- <if test="projectId != null">
- and project.id = #{projectId}
- </if>
- <if test="inchagerIds!=null and inchagerIds.size()>0">
- and project.id in
- <foreach collection="inchagerIds" open="(" separator="," close=")" item="item">
- #{item}
- </foreach>
- </if>
- order by project.is_public desc, project.id asc
- <if test="pageStart != null and pageSize != null">
- LIMIT #{pageStart},#{pageSize}
- </if>
- </select>
- <!--分页获取项目收支平衡 -->
- <select id="getProjectInAndOut" resultMap="BaseResultMap">
- SELECT project_code, project_name,contract_amount,
- (SELECT IFNULL(SUM(cost),0) FROM report WHERE state = 1 AND project_id = project.id) AS fee_man,
- (SELECT IFNULL(SUM(amount),0) FROM expense_item , expense_sheet WHERE project_id = project.id AND expense_sheet.id = expense_item.`expense_id` AND expense_sheet.type = 0 and expense_sheet.status = 0) AS fee_normal,
- (SELECT IFNULL(SUM(amount),0) FROM expense_item , expense_sheet WHERE project_id = project.id AND expense_sheet.id = expense_item.`expense_id` AND expense_sheet.type = 1 and expense_sheet.status = 0) AS fee_travel,
- (SELECT IFNULL(SUM(amount),0) FROM expense_item , expense_sheet WHERE project_id = project.id AND expense_sheet.id = expense_item.`expense_id` AND expense_sheet.type = 2 and expense_sheet.status = 0) AS fee_outsourcing
- FROM project WHERE project.`company_id` = #{companyId}
- and (project.status <> 3 or project.status is null)
- <if test="projectId != null">
- and project.id = #{projectId}
- </if>
- <if test="inchagerIds!=null and inchagerIds.size()>0">
- and project.id in
- <foreach collection="inchagerIds" open="(" separator="," close=")" item="item">
- #{item}
- </foreach>
- </if>
- order by is_public desc, id asc
- <if test="pageStart != null and pageSize != null">
- LIMIT #{pageStart},#{pageSize}
- </if>
- </select>
- <!--分页获取客户项目的成本利润报表 -->
- <select id="getCustomerProjectInAndOut" resultMap="CustomerResultMap">
- SELECT customer_id, customer_name, COUNT(1) AS project_num, GROUP_CONCAT( project.id) AS project_ids, GROUP_CONCAT( project_name) AS project_names,
- SUM(contract_amount) AS contract_amount ,
- SUM((SELECT IFNULL(SUM(cost),0) FROM report WHERE state = 1 AND project_id = project.id)) AS fee_man,
- SUM((SELECT IFNULL(SUM(amount),0) FROM expense_item , expense_sheet WHERE project_id = project.id AND expense_sheet.id = expense_item.`expense_id` AND expense_sheet.type = 0 and expense_sheet.status = 0)) AS fee_normal,
- SUM((SELECT IFNULL(SUM(amount),0) FROM expense_item , expense_sheet WHERE project_id = project.id AND expense_sheet.id = expense_item.`expense_id` AND expense_sheet.type = 1 and expense_sheet.status = 0)) AS fee_travel,
- SUM((SELECT IFNULL(SUM(amount),0) FROM expense_item , expense_sheet WHERE project_id = project.id AND expense_sheet.id = expense_item.`expense_id` AND expense_sheet.type = 2 and expense_sheet.status = 0)) AS fee_outsourcing
- FROM project WHERE project.`company_id` = #{companyId} AND customer_id > 0
- AND (project.status <> 3 OR project.status IS NULL)
- <if test="customerId!=null">
- and project.customer_id=#{customerId}
- </if>
- <if test="projectId!=null">
- and project.id=#{projectId}
- </if>
- GROUP BY customer_id
- <if test="pageStart != null and pageSize != null">
- LIMIT #{pageStart},#{pageSize}
- </if>
- </select>
- <select id="getCustomerProjectInAndOutCount" resultType="java.lang.Integer">
- SELECT COUNT(DISTINCT customer_id) FROM project WHERE project.`company_id` = #{companyId} AND customer_id > 0
- AND (project.status <> 3 OR project.status IS NULL)
- <if test="customerId!=null">
- and project.customer_id=#{customerId}
- </if>
- <if test="projectId!=null">
- and project.id=#{projectId}
- </if>
- </select>
- <!--分页获取项目收支平衡 -->
- <select id="getProjectInAndOutByRange" resultMap="CustomerResultMap">
- SELECT project.id as id, project.id as project_ids, project_code, project_name as project_names,contract_amount,
- (SELECT IFNULL(SUM(cost),0) FROM report WHERE state = 1 AND project_id = project.id) AS fee_man,
- (SELECT IFNULL(SUM(amount),0) FROM expense_item , expense_sheet WHERE project_id = project.id AND expense_sheet.id = expense_item.`expense_id` AND expense_sheet.type = 0 and expense_sheet.status = 0) AS fee_normal,
- (SELECT IFNULL(SUM(amount),0) FROM expense_item , expense_sheet WHERE project_id = project.id AND expense_sheet.id = expense_item.`expense_id` AND expense_sheet.type = 1 and expense_sheet.status = 0) AS fee_travel,
- (SELECT IFNULL(SUM(amount),0) FROM expense_item , expense_sheet WHERE project_id = project.id AND expense_sheet.id = expense_item.`expense_id` AND expense_sheet.type = 2 and expense_sheet.status = 0) AS fee_outsourcing
- FROM project WHERE project.`company_id` = #{companyId}
- and id IN <foreach collection="ids" close=")" open="(" separator="," index="" item="item">
- #{item}
- </foreach>
- </select>
- <select id="getGanttData" resultType="java.util.Map">
- SELECT participation.`user_id`, user.`name`,project.id, project.`project_name`, project.`plan_start_date` as start_date, project.`plan_end_date`,
- TIMESTAMPDIFF(DAY,project.`plan_start_date`, project.`plan_end_date`) AS duration FROM participation
- LEFT JOIN user ON user.id = participation.`user_id`
- LEFT JOIN project ON project.`id` = participation.`project_id`
- WHERE participation.`user_id` IN
- <foreach collection="userIds" close=")" open="(" separator="," index="" item="item">
- #{item}
- </foreach>
- AND project.`status` = 1 and project.plan_start_date is not null and project.plan_end_date is not null
- ORDER BY participation.user_id, project.`plan_start_date`
- </select>
- <select id="getTaskPlanByMemb" resultType="java.util.Map">
- SELECT user.`id` as user_id, user.`name`,project.id, project.`project_name`,task.id as task_id, task.name as task_name,task_executor.id as exe_id,
- IFNULL(task.`start_date`, task.end_date) as start_date, task.`end_date`, task_executor.plan_hours as duration FROM user
- LEFT JOIN task_executor ON user.id = task_executor.`executor_id`
- left join task on task.id = task_executor.task_id
- LEFT JOIN project ON project.`id` = task.`project_id`
- WHERE user.`id` IN
- <foreach collection="userIds" close=")" open="(" separator="," index="" item="item">
- #{item}
- </foreach>
- and ((IFNULL(task.start_date , task.end_date) between #{startDate} and #{endDate}) or (task.end_date between #{startDate} and #{endDate}))
- and task.end_date is not null
- AND project.`status` = 1
- ORDER BY user.id, task.start_date
- </select>
- <select id="getTaskPlanByProject" resultType="java.util.Map">
- SELECT task.executor_id as user_id, task.executor_name as `name`,project.id, project.`project_name`,task.id as task_id, task.name as task_name,
- IFNULL(task.`start_date`, task.end_date) as start_date, task.`end_date`, task.plan_hours as duration FROM project
- LEFT JOIN task ON task.project_id = project.id
- WHERE project.company_id = #{companyId}
- <if test="projectIds != null">
- and project.`id` IN
- <foreach collection="projectIds" close=")" open="(" separator="," index="" item="item">
- #{item}
- </foreach>
- </if>
- and ((IFNULL(task.start_date , task.end_date) between #{startDate} and #{endDate}) or (task.end_date between #{startDate} and #{endDate}))
- and task.end_date is not null
- AND project.`status` = 1
- ORDER BY project.id, task.start_date
- </select>
- <!--获取加班统计报表 -->
- <!-- <select id="getOvertimeList" resultType="java.util.Map">-->
- <!-- SELECT report.`creator_id` AS userId, user.`name` AS username, SUM(report.`working_time`) AS workingTime,-->
- <!-- IFNULL(SUM(report.`overtime_hours`),0) AS overtimeHours,-->
- <!-- group_concat(distinct(project.project_code)) as projectCode,-->
- <!-- IFNULL(SUM(report.overtime_cost), 0) AS cost FROM report LEFT JOIN user ON user.id = report.`creator_id`-->
- <!-- left join project on project.id = report.project_id-->
- <!-- WHERE report.is_overtime = 1-->
- <!-- and report.`state` = 1-->
- <!-- AND report.`create_date` BETWEEN #{startDate} and #{endDate}-->
- <!-- AND user.`company_id` = #{companyId}-->
- <!-- <if test="projectId != null">-->
- <!-- AND report.`project_id` = #{projectId}-->
- <!-- </if>-->
- <!-- <if test="userId != null">-->
- <!-- AND report.`creator_id` = #{userId}-->
- <!-- </if>-->
- <!-- GROUP BY report.creator_id-->
- <!-- </select>-->
- <!-- 获取某个员工的某时间段内的加班详情 -->
- <select id="getOvertimeDetail" resultType="java.util.Map">
- SELECT date_format(report.`create_date`, '%Y-%m-%d') AS createDate,
- report.`creator_id` AS userId, user.`name` AS username, report.`working_time` AS workingTime,
- IFNULL(report.`overtime_hours`, 0) AS overtimeHours,
- project.project_name as projectName,project.project_code as projectCode,
- IFNULL(report.overtime_cost, 0) AS cost,
- IFNULL(report_extra_degree.name,'') as degreeName, department.department_name as departmentName FROM report LEFT JOIN user ON user.id = report.`creator_id`
- left join project on project.id = report.project_id
- left join report_extra_degree on report_extra_degree.id = report.degree_id
- left join department on department.department_id = report.dept_id
- WHERE report.is_overtime = 1
- and report.`state` = 1
- AND report.`create_date` BETWEEN #{startDate} and #{endDate}
- AND user.`company_id` = #{companyId}
- <if test="projectId != null">
- AND report.`project_id` = #{projectId}
- </if>
- <if test="userId != null">
- AND report.`creator_id` = #{userId}
- </if>
- <if test="branchDepartment!=null and branchDepartment.size()>0">
- and report.dept_id in
- <foreach collection="branchDepartment" open="(" close=")" separator="," item="item">
- #{item}
- </foreach>
- </if>
- <if test="deptIds!=null and deptIds.size()>0">
- and report.dept_id in
- <foreach collection="deptIds" open="(" item="item" separator="," close=")">
- #{item}
- </foreach>
- </if>
- order by user.create_time asc, report.create_date desc
- </select>
- <!--获取人员工时-->
- <select id="getUserWorkingTimeList" resultType="java.util.Map">
- SELECT report.`creator_id` AS userId, user.`name` AS username,
- ifnull(SUM(if(project.is_public=0,report.working_time,null)),0) as unPublic,
- ifnull(SUM(if(project.is_public=1,report.working_time,null)),0) as isPublic,
- ifnull(SUM(report.`working_time`),0) AS workingTime
- FROM report LEFT JOIN user ON user.id = report.`creator_id`
- left join project on project.id = report.project_id
- WHERE
- report.`state` = 1
- AND report.`create_date` BETWEEN #{startDate} and #{endDate}
- AND user.`company_id` =#{companyId}
- <if test="userId!=null">
- and user.id=#{userId}
- </if>
- <if test="projectId!=null">
- and project.id=#{projectId}
- </if>
- <if test="branchDepartment!=null and branchDepartment.size()>0">
- and report.dept_id in
- <foreach collection="branchDepartment" open="(" close=")" item="item" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="deptIds!=null and deptIds.size()>0">
- and report.dept_id in
- <foreach collection="deptIds" open="(" item="item" separator="," close=")">
- #{item}
- </foreach>
- </if>
- group by user.id
- order by user.create_time asc, report.create_date desc
- <if test="start!=null and size!=null">
- limit #{start},#{size}
- </if>
- </select>
- <select id="findCountWithUser" resultType="java.lang.Long">
- select count(*)
- from (SELECT report.`creator_id` AS userId, user.`name` AS username,
- ifnull(SUM(if(project.is_public=0,report.working_time,null)),0) as unPublic,
- ifnull(SUM(if(project.is_public=1,report.working_time,null)),0) as isPublic,
- ifnull(SUM(report.`working_time`),0) AS workingTime
- FROM report LEFT JOIN user ON user.id = report.`creator_id`
- left join project on project.id = report.project_id
- WHERE
- report.`state` = 1
- AND report.`create_date` BETWEEN #{startDate} and #{endDate}
- AND user.`company_id` =#{companyId}
- <if test="userId!=null">
- and user.id=#{userId}
- </if>
- <if test="projectId!=null">
- and project.id=#{projectId}
- </if>
- <if test="departmentId!=null">
- and report.dept_id=#{departmentId}
- </if>
- <if test="deptIds!=null and deptIds.size()>0">
- and report.dept_id in
- <foreach collection="deptIds" open="(" item="item" separator="," close=")">
- #{item}
- </foreach>
- </if>
- group by user.id
- order by user.create_time asc, report.create_date desc
- <if test="start!=null and size!=null">
- limit #{start},#{size}
- </if>) as total
- </select>
- <!--按照项目内的阶段名称分组统计工时-->
- <select id="getDegreeCost" resultType="java.util.Map">
- SELECT IFNULL(b.name, "未分配") as name, SUM(a.working_time) AS cost, SUM(a.cost) AS costMoney
- FROM report AS a
- left join report_extra_degree b on b.id = a.degree_id
- WHERE
- a.state = 1
- and a.company_id = #{companyId}
- <if test="departmentIds!=null and departmentIds.size()>0">
- and a.dept_id in
- <foreach collection="departmentIds" open="(" item="item" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="projectId != null">
- and a.project_id = #{projectId}
- </if>
- <if test="startDate != null and endDate != null">
- AND a.create_date between #{startDate} and #{endDate}
- </if>
- GROUP BY a.degree_id
- ORDER BY a.degree_id ASC
- </select>
- <!--项目导出数据-->
- <select id="getExportData" resultType="java.util.HashMap" >
- SELECT project.id, project_name, project_code,category_name,is_public,plan_start_date, d.name AS incharger_name,GROUP_CONCAT(u.name) AS participators,
- plan_end_date, progress, LEVEL, STATUS, finish_date, creator_id, creator_name, create_date, contract_amount,
- customer_name, associate_degree_names, provider_names,provider_ids
- FROM project LEFT JOIN sub_project ON sub_project.id = project.`id`
- LEFT JOIN participation c ON c.project_id = project.`id`
- LEFT JOIN user u ON u.id = c.user_id
- LEFT JOIN user d ON d.id = project.`incharger_id`
- WHERE project.`company_id` = #{companyId}
- <if test="userId != null" >
- and (project.creator_id = #{userId} or c.user_id = #{userId})
- </if>
- GROUP BY project.id
- </select>
- <!--分页获取项目工时成本预警表 -->
- <select id="getProjectCostAlarm" resultType="java.util.HashMap">
- SELECT project.id, project.`project_code` as projectCode, project.`project_name` as projectName,(SELECT IFNULL(SUM(base_amount), 0) FROM project_currentcost
- WHERE base_id IN(SELECT id FROM project_basecost_setting WHERE company_id=#{companyId})
- AND project_id=project.id) AS cur_cost, (SELECT IFNULL(SUM(base_amount), 0) FROM project_currentcost
- WHERE base_id IN(SELECT id FROM project_basecost_setting WHERE company_id=#{companyId} AND alarm_type = 1)
- AND project_id=project.id) AS costLimit,
- (SELECT IFNULL(SUM(cost),0) FROM report WHERE state = 1 AND project_id = project.id) AS feeMan
- FROM project WHERE company_id=#{companyId}
- and (project.status <> 3 or project.status is null)
- <if test="projectId != null">
- and project.id = #{projectId}
- </if>
- <if test="pageStart != null and pageSize != null">
- LIMIT #{pageStart},#{pageSize}
- </if>
- </select>
- <select id="getBaseCostAndRealCost" resultType="java.util.HashMap">
- SELECT project.id,project_code as projectCode, project.`project_name` as projectName,
- (SELECT IFNULL(SUM(base_amount), 0) FROM project_basecost LEFT JOIN project_basecost_setting
- ON project_basecost_setting.id = project_basecost.`base_id` WHERE alarm_type=1 AND company_id=#{companyId} AND project_basecost.`project_id`=project.id) AS baseCost,
- (SELECT IFNULL(SUM(base_amount), 0) FROM project_currentcost LEFT JOIN project_basecost_setting
- ON project_basecost_setting.id = project_currentcost.`base_id` WHERE alarm_type=1 AND company_id=#{companyId} AND project_currentcost.`project_id`=project.id) AS baseCurcost,
- (SELECT IFNULL(SUM(cost), 0) FROM report WHERE report.`company_id` = #{companyId} AND project_id = project.id AND state=1 AND basecost_id >0) AS feeMan
- FROM project WHERE (STATUS <> 3 OR project.status IS NULL) AND company_id=#{companyId}
- <if test="projectId != null">
- and project.id = #{projectId}
- </if>
- <if test="pageStart != null and pageSize != null">
- LIMIT #{pageStart},#{pageSize}
- </if>
- </select>
- <select id="getWaitingReviewList" resultType="java.util.Map">
- <choose>
- <when test="stateKey==0">
- select us.name as userName,dp2.department_name as departmentName,COUNT(rp.state=0 or null) as num
- from department dp
- left join user us on dp.manager_id=us.id
- left join report rp on rp.audit_deptid=us.manage_dept_id and rp.create_date between #{startDate} and #{endDate} and rp.audit_deptid !=0
- left join department dp2 on dp2.department_id=dp.department_id
- </when>
- <otherwise>
- select us.name as userName,dp.department_name as departmentName,COUNT(rp.state=0 or null) as num
- from project_auditor pa
- left join user us on pa.auditor_id=us.id
- left join report rp on rp.project_auditor_id=us.id and pa.project_id=rp.project_id and rp.create_date between #{startDate} and #{endDate}
- left join department dp on dp.department_id=us.department_id
- </otherwise>
- </choose>
- where us.company_id=#{companyId} and us.is_active=1
- <if test="userId!=null">
- and us.id=#{userId}
- </if>
- <if test="departmentId!=null">
- and us.department_id=#{departmentId}
- </if>
- group by us.id
- order by us.department_id
- <if test="start!=null and size!=null">
- limit #{start},#{size}
- </if>
- </select>
- <select id="findCount" resultType="java.lang.Long">
- select count(1)
- from (<choose>
- <when test="stateKey==0">
- select us.name as userName,dp2.department_name as departmentName,COUNT(rp.state=0 or null) as num
- from department dp
- left join user us on dp.manager_id=us.id
- left join report rp on rp.audit_deptid=us.manage_dept_id and rp.create_date between #{startDate} and #{endDate} and rp.audit_deptid !=0
- left join department dp2 on dp2.department_id=dp.department_id
- </when>
- <otherwise>
- select us.name as userName,dp.department_name as departmentName,COUNT(rp.state=0 or null) as num
- from project_auditor pa
- left join user us on pa.auditor_id=us.id
- left join report rp on rp.project_auditor_id=us.id and pa.project_id=rp.project_id and rp.create_date between #{startDate} and #{endDate}
- left join department dp on dp.department_id=us.department_id
- </otherwise>
- </choose>
- where us.company_id=#{companyId} and us.is_active=1
- <if test="userId!=null">
- and us.id=#{userId}
- </if>
- <if test="departmentId!=null">
- and us.department_id=#{departmentId}
- </if>
- group by us.id
- order by us.department_id
- <if test="start!=null and size!=null">
- limit #{start},#{size}
- </if>) total
- </select>
- <select id="getUserWorkingTimeStatic" resultType="java.util.Map">
- select us.name,dp.department_name as departmentName,
- (select SUM(te.plan_hours) from task_executor te
- left join task on task.id=te.task_id
- where te.executor_id=us.id
- <if test="startDate!=null and endDate!=null">
- and task.create_date >=#{startDate} and task.create_date <=#{endDate}
- </if>) as planHours,
- (select SUM(report.working_time) from report
- left join task on task.id=report.task_id
- where report.creator_id=us.id and task_id is not null and report.state=1
- <if test="startDate!=null and endDate!=null">
- and report.create_date >=#{startDate} and report.create_date <=#{endDate}
- </if>) as workingTime
- from user us
- left join department dp on dp.department_id=us.department_id
- where us.company_id=#{companyId}
- <if test="userId!=null and userId!=''">
- and us.id=#{userId}
- </if>
- <if test="branchDepartment!=null and branchDepartment.size()>0">
- and us.department_id in
- <foreach collection="branchDepartment" open="(" close=")" separator="," item="item">
- #{item}
- </foreach>
- </if>
- <if test="deptIds!=null and deptIds.size()>0">
- and us.department_id in
- <foreach collection="deptIds" open="(" item="item" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- group by us.id
- order by us.department_id
- <if test="start!=null and size!=null">
- limit #{start},#{size}
- </if>
- </select>
- <select id="findCountWithUserWorkingTime" resultType="java.lang.Long">
- select count(1)
- from(select us.name,dp.department_name as departmentName,
- (select SUM(te.plan_hours) from task_executor te
- left join task on task.id=te.task_id
- where te.executor_id=us.id
- <if test="startDate!=null and endDate!=null">
- and task.create_date >=#{startDate} and task.create_date <=#{endDate}
- </if>) as planHours,
- (select SUM(report.working_time) from report
- left join task on task.id=report.task_id
- where report.creator_id=us.id and task_id is not null
- <if test="startDate!=null and endDate!=null">
- and task.create_date >=#{startDate} and task.create_date <=#{endDate}
- </if>) as workingTime
- from user us
- left join department dp on dp.department_id=us.department_id
- where us.company_id=#{companyId}
- <if test="userId!=null and userId!=''">
- and us.id=#{userId}
- </if>
- <if test="branchDepartment!=null and branchDepartment.size()>0">
- and us.department_id in
- <foreach collection="branchDepartment" open="(" close=")" separator="," item="item">
- #{item}
- </foreach>
- </if>
- <if test="deptIds!=null and deptIds.size()>0">
- and us.department_id in
- <foreach collection="deptIds" open="(" item="item" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- group by us.id
- order by us.department_id)as total
- </select>
- <select id="selectWithGroup" resultType="java.util.Map">
- select SUM(a.working_time) as workingTime,IFNULL(b.name,'未分组') as groupName
- from report a
- left join task_group b on a.group_id=b.id
- left join project c on a.project_id=c.id
- where c.company_id=#{companyId} and a.state=1
- <if test="startDate!=null and endDate!=null">
- and a.create_date >=#{startDate} and a.create_date <=#{endDate}
- </if>
- <if test="projectId!=null">
- and c.id=#{projectId}
- </if>
- <if test="inchagerIds!=null and inchagerIds.size()>0">
- and c.id in
- <foreach collection="inchagerIds" open="(" separator="," close=")" item="item">
- #{item}
- </foreach>
- </if>
- <if test="groupId!=null">
- and a.group_id=#{groupId}
- </if>
- group by b.name
- order by c.id
- <if test="startIndex!=null and endIndex!=null">
- limit #{startIndex},#{endIndex}
- </if>
- </select>
- <select id="selectCountWithGroup" resultType="java.lang.Long">
- select count(1) from(
- select SUM(a.working_time) as workingTime,IFNULL(b.name,'未分组') as groupName
- from report a
- left join task_group b on a.group_id=b.id
- left join project c on a.project_id=c.id
- where c.company_id=#{companyId} and a.state=1
- <if test="startDate!=null and endDate!=null">
- and a.create_date >=#{startDate} and a.create_date <=#{endDate}
- </if>
- <if test="projectId!=null">
- and c.id=#{projectId}
- </if>
- <if test="inchagerIds!=null and inchagerIds.size()>0">
- and c.id in
- <foreach collection="inchagerIds" open="(" separator="," close=")" item="item">
- #{item}
- </foreach>
- </if>
- <if test="groupId!=null">
- and a.group_id=#{groupId}
- </if>
- group by b.name
- order by c.id
- <if test="startIndex!=null and endIndex!=null">
- limit #{startIndex},#{endIndex}
- </if>) as total
- </select>
- <select id="selectWithGroupProject" resultType="java.util.Map">
- select SUM(a.working_time) as workingTime,IFNULL(b.name,'未分组') as groupName ,c.project_name as projectName,c.project_code as projectCode
- from report a
- left join task_group b on a.group_id=b.id
- left join project c on a.project_id=c.id
- where c.company_id=#{companyId} and a.state=1
- <if test="startDate!=null and endDate!=null">
- and a.create_date >=#{startDate} and a.create_date <=#{endDate}
- </if>
- <if test="projectId!=null">
- and c.id=#{projectId}
- </if>
- <if test="inchagerIds!=null and inchagerIds.size()>0">
- and c.id in
- <foreach collection="inchagerIds" open="(" separator="," close=")" item="item">
- #{item}
- </foreach>
- </if>
- <if test="groupId!=null">
- and a.group_id=#{groupId}
- </if>
- group by c.id,b.id
- order by c.id
- <if test="startIndex!=null and endIndex!=null">
- limit #{startIndex},#{endIndex}
- </if>
- </select>
- <select id="selectCountWithGroupProject" resultType="java.lang.Long">
- select count(1) from(
- select SUM(a.working_time) as workingTime,IFNULL(b.name,'未分组') as groupName ,c.project_name as projectName,c.project_code as projectCode
- from report a
- left join task_group b on a.group_id=b.id
- left join project c on a.project_id=c.id
- where c.company_id=#{companyId} and a.state=1
- <if test="startDate!=null and endDate!=null">
- and a.create_date >=#{startDate} and a.create_date <=#{endDate}
- </if>
- <if test="projectId!=null">
- and c.id=#{projectId}
- </if>
- <if test="inchagerIds!=null and inchagerIds.size()>0">
- and c.id in
- <foreach collection="inchagerIds" open="(" separator="," close=")" item="item">
- #{item}
- </foreach>
- </if>
- <if test="groupId!=null">
- and a.group_id=#{groupId}
- </if>
- group by c.id,b.id
- order by c.id
- <if test="startIndex!=null and endIndex!=null">
- limit #{startIndex},#{endIndex}
- </if>) as total
- </select>
- <select id="getCostByUserCustom" resultType="java.util.Map">
- SELECT IFNULL(suc.name,'未定义') as name,SUM(b.working_time) AS cost, SUM(b.cost) AS costMoney
- FROM user AS a
- LEFT JOIN report AS b ON a.id = b.creator_id
- LEFT JOIN project AS c ON b.project_id = c.id
- left join user_custom uc on uc.company_id=a.company_id
- left join sub_user_custom suc on suc.name=a.${fieldName} and suc.user_custom_id=uc.id
- WHERE b.state = 1
- AND a.company_id = #{companyId}
- <if test="startDate!=null and endDate!=null">
- AND b.create_date between #{startDate} and #{endDate}
- </if>
- and uc.id=#{customId}
- <if test="deptIds!=null and deptIds.size()>0">
- and a.department_id in
- <foreach collection="deptIds" open="(" item="item" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="subCustomName!=null">
- and suc.name=#{subCustomName}
- </if>
- GROUP BY suc.name
- </select>
- </mapper>
|