Browse Source

预算及成本重构

master
陈裕财 4 years ago
parent
commit
7dd6c268b4
  1. 41
      xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmBudgetLaborMapper.xml
  2. 234
      xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmProjectMBudgetCostNouserMapper.xml
  3. 245
      xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmProjectMBudgetCostUserMapper.xml

41
xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmBudgetLaborMapper.xml

@ -14,7 +14,48 @@
<if test="key != null and key !='' "> </if>
</sql>
<!-- 通过条件查询获取数据列表 返回list<map> -->
<select id="listSum" parameterType="HashMap" resultType="HashMap">
select res.project_id,res.userid,res.username,subject_id,subject_name,biz_month,sum(res.budget_cost) as budget_at from xm_budget_labor res
<where>
and res.project_id=#{projectId}
<if test="subjectId != null and subjectId !='' "> and res.subject_id =#{subjectId} </if>
<if test="costType != null and costType !='' "> and res.cost_type =#{costType} </if>
</where>
group by res.project_id,res.userid,res.username,subject_id,subject_name,bizz_month
</select>
<!-- 查询人力的预算及对应的项目的预算,人力总预算不能大于项目人力总预算 -->
<select id="selectTotalProjectAndUserBudgetCost" parameterType="HashMap" resultType="HashMap">
SELECT
sum( case when res.cost_type='1' then ifnull(res.budget_at,0) else 0 end ) AS budget_iuser_at,
sum( case when res.cost_type='2' then ifnull(res.budget_at,0) else 0 end ) AS budget_ouser_at,
sum( ifnull(res.budget_at,0) ) AS budget_at,
p.plan_nouser_at,
p.plan_iuser_at,
p.plan_ouser_at,
p.locked,
p.plan_workload,
p.total_receivables,
p.budget_margin_rate,
p.contract_amt,
p.plan_iuser_price,
p.plan_ouser_price,
p.plan_ouser_cnt,
p.plan_iuser_cnt,
p.plan_working_hours
FROM
XM.xm_project p
LEFT JOIN xm_budget_labor res ON p.id = res.project_id
<where>
p.id = #{projectId}
<if test=" excludeIds !=null "> and res.id not in
<foreach collection="excludeIds" item="item" index="index" open="(" separator="," close=")" >
#{item}
</foreach>
</if>
</where>
</select>
<!--结束 自定义sql函数区域-->

234
xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmProjectMBudgetCostNouserMapper.xml

@ -1,234 +0,0 @@
<?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.xm.core.entity.XmProjectMBudgetCostNouser">
<!--开始 自定sql函数区域 请在此区域添加自定义函数,其它区域尽量不要动,因为代码随时重新生成 -->
<sql id="whereForMap">
<if test=" ids != null"> and (res.id) in
<foreach collection="ids" item="item" index="index" open="(" separator="," close=")" >
( #{item})
</foreach>
</if>
<if test="key != null and key !='' "> </if>
</sql>
<!-- 通过条件查询获取数据列表 返回list<map> -->
<select id="listSum" parameterType="HashMap" resultType="HashMap">
select res.project_id,res.subject_id,res.subject_name,bizz_month,sum(res.budget_cost) as budget_cost from xm_project_m_budget_cost_nouser res
<where>
and res.project_id=#{projectId}
<if test="subjectId != null and subjectId !='' "> and res.subject_id =#{subjectId} </if>
<if test="costType != null and costType !='' "> and res.cost_type =#{costType} </if>
</where>
group by res.project_id ,res.subject_id,res.subject_name,res.bizz_month
</select>
<!-- 查询非人力的预算及对应的项目的预算,非人力总预算不能大于项目非人力总预算 -->
<select id="selectTotalProjectAndNouserBudgetCost" parameterType="HashMap" resultType="HashMap">
SELECT
sum( ifnull(res.budget_cost,0) ) AS budget_cost,
p.plan_nouser_at,
p.plan_iuser_at,
p.plan_ouser_at,
p.locked,
p.plan_workload,
p.total_receivables,
p.budget_margin_rate,
p.contract_amt,
p.plan_iuser_price,
p.plan_ouser_price,
p.plan_ouser_cnt,
p.plan_iuser_cnt,
p.plan_working_hours
FROM
XM.xm_project p
LEFT JOIN xm_project_m_budget_cost_nouser res ON p.id = res.project_id
<where>
p.id = #{projectId}
<if test=" excludeIds !=null "> and res.id not in
<foreach collection="excludeIds" item="item" index="index" open="(" separator="," close=")" >
#{item}
</foreach>
</if>
</where>
</select>
<!--结束 自定义sql函数区域-->
<!-- 通过条件查询获取数据列表 返回list<map> -->
<select id="selectListMapByWhere" parameterType="HashMap" resultType="HashMap">
select res.* from xm_project_m_budget_cost_nouser res
<where>
<include refid="whereForMap"></include>
<include refid="where"/>
</where>
</select>
<!-- 通过条件查询获取数据列表 不分页 返回 list<Object> -->
<select id="selectListByWhere" parameterType="com.xm.core.entity.XmProjectMBudgetCostNouser" resultType="com.xm.core.entity.XmProjectMBudgetCostNouser">
select * from xm_project_m_budget_cost_nouser res
<where>
<include refid="where"/>
</where>
</select>
<!-- 通过主键查询获取数据对象 返回object -->
<select id="selectOneObject" parameterType="com.xm.core.entity.XmProjectMBudgetCostNouser" resultType="com.xm.core.entity.XmProjectMBudgetCostNouser">
select * from xm_project_m_budget_cost_nouser res
where
res.id = #{id}
</select>
<select id="selectListByIds" parameterType="List" resultType="com.xm.core.entity.XmProjectMBudgetCostNouser">
select * from xm_project_m_budget_cost_nouser res
where (res.id) in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")" >
( #{item})
</foreach>
</select>
<!-- 通过主键查询获取数据对象 返回map-->
<select id="selectOneMap" parameterType="HashMap" resultType="HashMap">
select * from xm_project_m_budget_cost_nouser res
where
res.id = #{id}
</select>
<!-- 获取数据条目 返回long -->
<select id="countByWhere" parameterType="com.xm.core.entity.XmProjectMBudgetCostNouser" resultType="long">
select count(1) from xm_project_m_budget_cost_nouser res
<where>
<include refid="where"/>
</where>
</select>
<!-- 新增一条记录 主键id,-->
<insert id="insert" parameterType="com.xm.core.entity.XmProjectMBudgetCostNouser" useGeneratedKeys="false" keyProperty="id">
insert into xm_project_m_budget_cost_nouser(
<include refid="columns"/>
) values (
#{projectId},#{budgetCost},#{id},#{remark},#{subjectId},#{bizzStartDate},#{bizzEndDate},#{bizProcInstId},#{bizFlowState},#{phaseId},#{costType},#{bizzMonth},#{subjectName}
)
</insert>
<!-- 按条件删除若干条记录-->
<delete id="deleteByWhere" parameterType="com.xm.core.entity.XmProjectMBudgetCostNouser">
delete from xm_project_m_budget_cost_nouser res
<where>
<include refid="where"/>
</where>
</delete>
<!-- 按主键删除一条记录-->
<delete id="deleteByPk" parameterType="com.xm.core.entity.XmProjectMBudgetCostNouser">
delete from xm_project_m_budget_cost_nouser
where id = #{id}
</delete>
<!-- 根据条件修改若干条记录 -->
<update id="updateSomeFieldByPk" parameterType="com.xm.core.entity.XmProjectMBudgetCostNouser">
update xm_project_m_budget_cost_nouser
<set>
<include refid="someFieldSet"/>
</set>
where id = #{id}
</update>
<!-- 根据主键修改一条记录 -->
<update id="updateByPk" parameterType="com.xm.core.entity.XmProjectMBudgetCostNouser">
update xm_project_m_budget_cost_nouser
<set>
<include refid="set"/>
</set>
where id = #{id}
</update>
<!-- 批量新增 批量插入 借用insert 循环插入实现
<insert id="batchInsert" parameterType="List">
</insert>
-->
<!-- 批量更新 -->
<update id="batchUpdate" parameterType="List">
<foreach collection="list" item="item" index="index" separator=";" >
update xm_project_m_budget_cost_nouser
set
<include refid="batchSet"/>
where id = #{item.id}
</foreach>
</update>
<!-- 批量删除 -->
<delete id="batchDelete" parameterType="List">
delete from xm_project_m_budget_cost_nouser
where
(id) in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")" >
( #{item.id} )
</foreach>
</delete>
<!--sql片段 列-->
<sql id="columns">
project_id,budget_cost,id,remark,subject_id,bizz_start_date,bizz_end_date,biz_proc_inst_id,biz_flow_state,phase_id,cost_type,bizz_month,subject_name
</sql>
<!--sql片段 动态条件 YYYY-MM-DD HH24:MI:SS-->
<sql id="where">
<if test="projectId != null and projectId != ''"> and res.project_id = #{projectId} </if>
<if test="budgetCost != null and budgetCost != ''"> and res.budget_cost = #{budgetCost} </if>
<if test="id != null and id != ''"> and res.id = #{id} </if>
<if test="remark != null and remark != ''"> and res.remark = #{remark} </if>
<if test="subjectId != null and subjectId != ''"> and res.subject_id = #{subjectId} </if>
<if test="bizzStartDate != null"> and date_format(res.bizz_start_date,'%Y-%m-%d') = date_format(#{bizzStartDate},'%Y-%m-%d') </if>
<if test="bizzEndDate != null"> and date_format(res.bizz_end_date,'%Y-%m-%d') = date_format(#{bizzEndDate},'%Y-%m-%d') </if>
<if test="bizProcInstId != null and bizProcInstId != ''"> and res.biz_proc_inst_id = #{bizProcInstId} </if>
<if test="bizFlowState != null and bizFlowState != ''"> and res.biz_flow_state = #{bizFlowState} </if>
<if test="phaseId != null and phaseId != ''"> and res.phase_id = #{phaseId} </if>
<if test="costType != null and costType != ''"> and res.cost_type = #{costType} </if>
<if test="bizzMonth != null and bizzMonth != ''"> and res.bizz_month = #{bizzMonth} </if>
<if test="subjectName != null and subjectName != ''"> and res.subject_name = #{subjectName} </if>
</sql>
<!--sql片段 更新字段 -->
<sql id="set">
project_id = #{projectId},
budget_cost = #{budgetCost},
remark = #{remark},
subject_id = #{subjectId},
bizz_start_date = #{bizzStartDate},
bizz_end_date = #{bizzEndDate},
biz_proc_inst_id = #{bizProcInstId},
biz_flow_state = #{bizFlowState},
phase_id = #{phaseId},
cost_type = #{costType},
bizz_month = #{bizzMonth},
subject_name = #{subjectName}
</sql>
<sql id="someFieldSet">
<if test="projectId != null and projectId != ''"> project_id = #{projectId}, </if>
<if test="budgetCost != null and budgetCost != ''"> budget_cost = #{budgetCost}, </if>
<if test="remark != null and remark != ''"> remark = #{remark}, </if>
<if test="subjectId != null and subjectId != ''"> subject_id = #{subjectId}, </if>
<if test="bizzStartDate != null"> bizz_start_date = #{bizzStartDate}, </if>
<if test="bizzEndDate != null"> bizz_end_date = #{bizzEndDate}, </if>
<if test="bizProcInstId != null and bizProcInstId != ''"> biz_proc_inst_id = #{bizProcInstId}, </if>
<if test="bizFlowState != null and bizFlowState != ''"> biz_flow_state = #{bizFlowState}, </if>
<if test="phaseId != null and phaseId != ''"> phase_id = #{phaseId}, </if>
<if test="costType != null and costType != ''"> cost_type = #{costType}, </if>
<if test="bizzMonth != null and bizzMonth != ''"> bizz_month = #{bizzMonth}, </if>
<if test="subjectName != null and subjectName != ''"> subject_name = #{subjectName}, </if>
</sql>
<!--sql片段 批量更新 -->
<sql id="batchSet">
project_id = #{item.projectId},
budget_cost = #{item.budgetCost},
remark = #{item.remark},
subject_id = #{item.subjectId},
bizz_start_date = #{item.bizzStartDate},
bizz_end_date = #{item.bizzEndDate},
biz_proc_inst_id = #{item.bizProcInstId},
biz_flow_state = #{item.bizFlowState},
phase_id = #{item.phaseId},
cost_type = #{item.costType},
bizz_month = #{item.bizzMonth},
subject_name = #{item.subjectName}
</sql>
</mapper>

245
xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmProjectMBudgetCostUserMapper.xml

@ -1,245 +0,0 @@
<?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.xm.core.entity.XmProjectMBudgetCostUser">
<!--开始 自定sql函数区域 请在此区域添加自定义函数,其它区域尽量不要动,因为代码随时重新生成 -->
<sql id="whereForMap">
<if test=" ids != null"> and (res.id) in
<foreach collection="ids" item="item" index="index" open="(" separator="," close=")" >
( #{item})
</foreach>
</if>
<if test="key != null and key !='' "> </if>
</sql>
<!-- 通过条件查询获取数据列表 返回list<map> -->
<select id="listSum" parameterType="HashMap" resultType="HashMap">
select res.project_id,res.userid,res.username,subject_id,subject_name,bizz_month,sum(res.budget_cost) as budget_cost from xm_project_m_budget_cost_user res
<where>
and res.project_id=#{projectId}
<if test="subjectId != null and subjectId !='' "> and res.subject_id =#{subjectId} </if>
<if test="costType != null and costType !='' "> and res.cost_type =#{costType} </if>
</where>
group by res.project_id,res.userid,res.username,subject_id,subject_name,bizz_month
</select>
<!-- 查询人力的预算及对应的项目的预算,人力总预算不能大于项目人力总预算 -->
<select id="selectTotalProjectAndUserBudgetCost" parameterType="HashMap" resultType="HashMap">
SELECT
sum( case when res.cost_type='1' then ifnull(res.budget_cost,0) else 0 end ) AS budget_cost_iuser_at,
sum( case when res.cost_type='2' then ifnull(res.budget_cost,0) else 0 end ) AS budget_cost_ouser_at,
sum( ifnull(res.budget_cost,0) ) AS budget_cost,
p.plan_nouser_at,
p.plan_iuser_at,
p.plan_ouser_at,
p.locked,
p.plan_workload,
p.total_receivables,
p.budget_margin_rate,
p.contract_amt,
p.plan_iuser_price,
p.plan_ouser_price,
p.plan_ouser_cnt,
p.plan_iuser_cnt,
p.plan_working_hours
FROM
XM.xm_project p
LEFT JOIN xm_project_m_budget_cost_user res ON p.id = res.project_id
<where>
p.id = #{projectId}
<if test=" excludeIds !=null "> and res.id not in
<foreach collection="excludeIds" item="item" index="index" open="(" separator="," close=")" >
#{item}
</foreach>
</if>
</where>
</select>
<!--结束 自定义sql函数区域-->
<!-- 通过条件查询获取数据列表 返回list<map> -->
<select id="selectListMapByWhere" parameterType="HashMap" resultType="HashMap">
select res.* from xm_project_m_budget_cost_user res
<where>
<include refid="whereForMap"></include>
<include refid="where"/>
</where>
</select>
<!-- 通过条件查询获取数据列表 不分页 返回 list<Object> -->
<select id="selectListByWhere" parameterType="com.xm.core.entity.XmProjectMBudgetCostUser" resultType="com.xm.core.entity.XmProjectMBudgetCostUser">
select * from xm_project_m_budget_cost_user res
<where>
<include refid="where"/>
</where>
</select>
<!-- 通过主键查询获取数据对象 返回object -->
<select id="selectOneObject" parameterType="com.xm.core.entity.XmProjectMBudgetCostUser" resultType="com.xm.core.entity.XmProjectMBudgetCostUser">
select * from xm_project_m_budget_cost_user res
where
res.id = #{id}
</select>
<select id="selectListByIds" parameterType="List" resultType="com.xm.core.entity.XmProjectMBudgetCostUser">
select * from xm_project_m_budget_cost_user res
where (res.id) in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")" >
( #{item})
</foreach>
</select>
<!-- 通过主键查询获取数据对象 返回map-->
<select id="selectOneMap" parameterType="HashMap" resultType="HashMap">
select * from xm_project_m_budget_cost_user res
where
res.id = #{id}
</select>
<!-- 获取数据条目 返回long -->
<select id="countByWhere" parameterType="com.xm.core.entity.XmProjectMBudgetCostUser" resultType="long">
select count(1) from xm_project_m_budget_cost_user res
<where>
<include refid="where"/>
</where>
</select>
<!-- 新增一条记录 主键id,-->
<insert id="insert" parameterType="com.xm.core.entity.XmProjectMBudgetCostUser" useGeneratedKeys="false" keyProperty="id">
insert into xm_project_m_budget_cost_user(
<include refid="columns"/>
) values (
#{projectId},#{userid},#{budgetCost},#{id},#{remark},#{username},#{subjectId},#{bizzStartDate},#{bizzEndDate},#{bizzMonth},#{bizProcInstId},#{bizFlowState},#{phaseId},#{costType},#{subjectName}
)
</insert>
<!-- 按条件删除若干条记录-->
<delete id="deleteByWhere" parameterType="com.xm.core.entity.XmProjectMBudgetCostUser">
delete from xm_project_m_budget_cost_user res
<where>
<include refid="where"/>
</where>
</delete>
<!-- 按主键删除一条记录-->
<delete id="deleteByPk" parameterType="com.xm.core.entity.XmProjectMBudgetCostUser">
delete from xm_project_m_budget_cost_user
where id = #{id}
</delete>
<!-- 根据条件修改若干条记录 -->
<update id="updateSomeFieldByPk" parameterType="com.xm.core.entity.XmProjectMBudgetCostUser">
update xm_project_m_budget_cost_user
<set>
<include refid="someFieldSet"/>
</set>
where id = #{id}
</update>
<!-- 根据主键修改一条记录 -->
<update id="updateByPk" parameterType="com.xm.core.entity.XmProjectMBudgetCostUser">
update xm_project_m_budget_cost_user
<set>
<include refid="set"/>
</set>
where id = #{id}
</update>
<!-- 批量新增 批量插入 借用insert 循环插入实现
<insert id="batchInsert" parameterType="List">
</insert>
-->
<!-- 批量更新 -->
<update id="batchUpdate" parameterType="List">
<foreach collection="list" item="item" index="index" separator=";" >
update xm_project_m_budget_cost_user
set
<include refid="batchSet"/>
where id = #{item.id}
</foreach>
</update>
<!-- 批量删除 -->
<delete id="batchDelete" parameterType="List">
delete from xm_project_m_budget_cost_user
where
(id) in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")" >
( #{item.id} )
</foreach>
</delete>
<!--sql片段 列-->
<sql id="columns">
project_id,userid,budget_cost,id,remark,username,subject_id,bizz_start_date,bizz_end_date,bizz_month,biz_proc_inst_id,biz_flow_state,phase_id,cost_type,subject_name
</sql>
<!--sql片段 动态条件 YYYY-MM-DD HH24:MI:SS-->
<sql id="where">
<if test="projectId != null and projectId != ''"> and res.project_id = #{projectId} </if>
<if test="userid != null and userid != ''"> and res.userid = #{userid} </if>
<if test="budgetCost != null and budgetCost != ''"> and res.budget_cost = #{budgetCost} </if>
<if test="id != null and id != ''"> and res.id = #{id} </if>
<if test="remark != null and remark != ''"> and res.remark = #{remark} </if>
<if test="username != null and username != ''"> and res.username = #{username} </if>
<if test="subjectId != null and subjectId != ''"> and res.subject_id = #{subjectId} </if>
<if test="bizzStartDate != null"> and date_format(res.bizz_start_date,'%Y-%m-%d') = date_format(#{bizzStartDate},'%Y-%m-%d') </if>
<if test="bizzEndDate != null"> and date_format(res.bizz_end_date,'%Y-%m-%d') = date_format(#{bizzEndDate},'%Y-%m-%d') </if>
<if test="bizzMonth != null and bizzMonth != ''"> and res.bizz_month = #{bizzMonth} </if>
<if test="bizProcInstId != null and bizProcInstId != ''"> and res.biz_proc_inst_id = #{bizProcInstId} </if>
<if test="bizFlowState != null and bizFlowState != ''"> and res.biz_flow_state = #{bizFlowState} </if>
<if test="phaseId != null and phaseId != ''"> and res.phase_id = #{phaseId} </if>
<if test="costType != null and costType != ''"> and res.cost_type = #{costType} </if>
<if test="subjectName != null and subjectName != ''"> and res.subject_name = #{subjectName} </if>
</sql>
<!--sql片段 更新字段 -->
<sql id="set">
project_id = #{projectId},
userid = #{userid},
budget_cost = #{budgetCost},
remark = #{remark},
username = #{username},
subject_id = #{subjectId},
bizz_start_date = #{bizzStartDate},
bizz_end_date = #{bizzEndDate},
bizz_month = #{bizzMonth},
biz_proc_inst_id = #{bizProcInstId},
biz_flow_state = #{bizFlowState},
phase_id = #{phaseId},
cost_type = #{costType},
subject_name = #{subjectName}
</sql>
<sql id="someFieldSet">
<if test="projectId != null and projectId != ''"> project_id = #{projectId}, </if>
<if test="userid != null and userid != ''"> userid = #{userid}, </if>
<if test="budgetCost != null and budgetCost != ''"> budget_cost = #{budgetCost}, </if>
<if test="remark != null and remark != ''"> remark = #{remark}, </if>
<if test="username != null and username != ''"> username = #{username}, </if>
<if test="subjectId != null and subjectId != ''"> subject_id = #{subjectId}, </if>
<if test="bizzStartDate != null"> bizz_start_date = #{bizzStartDate}, </if>
<if test="bizzEndDate != null"> bizz_end_date = #{bizzEndDate}, </if>
<if test="bizzMonth != null and bizzMonth != ''"> bizz_month = #{bizzMonth}, </if>
<if test="bizProcInstId != null and bizProcInstId != ''"> biz_proc_inst_id = #{bizProcInstId}, </if>
<if test="bizFlowState != null and bizFlowState != ''"> biz_flow_state = #{bizFlowState}, </if>
<if test="phaseId != null and phaseId != ''"> phase_id = #{phaseId}, </if>
<if test="costType != null and costType != ''"> cost_type = #{costType}, </if>
<if test="subjectName != null and subjectName != ''"> subject_name = #{subjectName}, </if>
</sql>
<!--sql片段 批量更新 -->
<sql id="batchSet">
project_id = #{item.projectId},
userid = #{item.userid},
budget_cost = #{item.budgetCost},
remark = #{item.remark},
username = #{item.username},
subject_id = #{item.subjectId},
bizz_start_date = #{item.bizzStartDate},
bizz_end_date = #{item.bizzEndDate},
bizz_month = #{item.bizzMonth},
biz_proc_inst_id = #{item.bizProcInstId},
biz_flow_state = #{item.bizFlowState},
phase_id = #{item.phaseId},
cost_type = #{item.costType},
subject_name = #{item.subjectName}
</sql>
</mapper>
Loading…
Cancel
Save