Browse Source

预算及成本重构

master
陈裕财 4 years ago
parent
commit
bfea7cbe86
  1. 181
      xm-core/src/main/java/com/xm/core/ctrl/XmProjectOptionsController.java
  2. 92
      xm-core/src/main/java/com/xm/core/entity/XmProjectOptions.java
  3. 5
      xm-core/src/main/java/com/xm/core/service/XmMenuService.java
  4. 17
      xm-core/src/main/java/com/xm/core/service/XmProjectOptionsService.java
  5. 5
      xm-core/src/main/java/com/xm/core/service/XmQuestionService.java
  6. 5
      xm-core/src/main/java/com/xm/core/service/XmRecordService.java
  7. 5
      xm-core/src/main/java/com/xm/core/service/XmTaskService.java
  8. 5
      xm-core/src/main/java/com/xm/core/service/XmTaskWorkloadService.java
  9. 603
      xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmPhaseMapper.xml

181
xm-core/src/main/java/com/xm/core/ctrl/XmProjectOptionsController.java

@ -1,181 +0,0 @@
package com.xm.core.ctrl;
import com.mdp.core.entity.Tips;
import com.mdp.core.utils.RequestUtils;
import com.mdp.mybatis.PageUtils;
import com.xm.core.entity.XmProjectOptions;
import com.xm.core.service.XmProjectOptionsService;
import io.swagger.annotations.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* url编制采用rest风格,如对XM.xm_project_options xm_project_options的操作有增删改查,对应的url分别为:<br>
* 新增: xm/xmProjectOptions/add <br>
* 查询: xm/xmProjectOptions/list<br>
* 模糊查询: xm/xmProjectOptions/listKey<br>
* 修改: xm/xmProjectOptions/edit <br>
* 删除: xm/xmProjectOptions/del<br>
* 批量删除: xm/xmProjectOptions/batchDel<br>
* 组织 com.qqkj 顶级模块 oa 大模块 xm 小模块 <br>
* 实体 XmProjectOptions XM.xm_project_options 当前主键(包括多主键): id;
***/
@RestController("xm.core.xmProjectOptionsController")
@RequestMapping(value="/**/xm/core/xmProjectOptions")
@Api(tags={"xm_project_options操作接口"})
public class XmProjectOptionsController {
static Log logger=LogFactory.getLog(XmProjectOptionsController.class);
@Autowired
private XmProjectOptionsService xmProjectOptionsService;
@ApiOperation( value = "查询xm_project_options信息列表",notes="listXmProjectOptions,条件之间是 and关系,模糊查询写法如 {studentName:'%才哥%'}")
@ApiImplicitParams({
@ApiImplicitParam(name="id",value="主键,主键",required=false),
@ApiImplicitParam(name="branchId",value="机构编号",required=false),
@ApiImplicitParam(name="optionType",value="选项类型,0项目类型,1紧急程度,2优先程度",required=false),
@ApiImplicitParam(name="name",value="选项名字",required=false),
@ApiImplicitParam(name="pageSize",value="每页记录数",required=false),
@ApiImplicitParam(name="pageNum",value="当前页码,从1开始",required=false),
@ApiImplicitParam(name="total",value="总记录数,服务器端收到0时,会自动计算总记录数,如果上传>0的不自动计算",required=false),
@ApiImplicitParam(name="orderBy",value="排序列 如性别、学生编号排序 orderBy = sex desc,student_id desc",required=false),
@ApiImplicitParam(name="count",value="是否进行总条数计算,count=true|false",required=false)
})
@ApiResponses({
@ApiResponse(code = 200,response= XmProjectOptions.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'错误码'},total:总记录数,data:[数据对象1,数据对象2,...]}")
})
@RequestMapping(value="/list",method=RequestMethod.GET)
public Map<String,Object> listXmProjectOptions( @ApiIgnore @RequestParam Map<String,Object> xmProjectOptions){
Map<String,Object> m = new HashMap<>();
RequestUtils.transformArray(xmProjectOptions, "ids");
PageUtils.startPage(xmProjectOptions);
List<Map<String,Object>> xmProjectOptionsList = xmProjectOptionsService.selectListMapByWhere(xmProjectOptions); //列出XmProjectOptions列表
PageUtils.responePage(m, xmProjectOptionsList);
m.put("data",xmProjectOptionsList);
Tips tips=new Tips("查询成功");
m.put("tips", tips);
return m;
}
/**
@ApiOperation( value = "新增一条xm_project_options信息",notes="addXmProjectOptions,主键如果为空,后台自动生成")
@ApiResponses({
@ApiResponse(code = 200,response=XmProjectOptions.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}")
})
@RequestMapping(value="/add",method=RequestMethod.POST)
public Map<String,Object> addXmProjectOptions(@RequestBody XmProjectOptions xmProjectOptions) {
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功新增一条数据");
try{
if(StringUtils.isEmpty(xmProjectOptions.getId())) {
xmProjectOptions.setId(xmProjectOptionsService.createKey("id"));
}else{
XmProjectOptions xmProjectOptionsQuery = new XmProjectOptions(xmProjectOptions.getId());
if(xmProjectOptionsService.countByWhere(xmProjectOptionsQuery)>0){
tips.setFailureMsg("编号重复,请修改编号再提交");
m.put("tips", tips);
return m;
}
}
xmProjectOptionsService.insert(xmProjectOptions);
m.put("data",xmProjectOptions);
}catch (BizException e) {
tips=e.getTips();
logger.error("",e);
}catch (Exception e) {
tips.setFailureMsg(e.getMessage());
logger.error("",e);
}
m.put("tips", tips);
return m;
}
*/
/**
@ApiOperation( value = "删除一条xm_project_options信息",notes="delXmProjectOptions,仅需要上传主键字段")
@ApiResponses({
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}")
})
@RequestMapping(value="/del",method=RequestMethod.POST)
public Map<String,Object> delXmProjectOptions(@RequestBody XmProjectOptions xmProjectOptions){
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功删除一条数据");
try{
xmProjectOptionsService.deleteByPk(xmProjectOptions);
}catch (BizException e) {
tips=e.getTips();
logger.error("",e);
}catch (Exception e) {
tips.setFailureMsg(e.getMessage());
logger.error("",e);
}
m.put("tips", tips);
return m;
}
*/
/**
@ApiOperation( value = "根据主键修改一条xm_project_options信息",notes="editXmProjectOptions")
@ApiResponses({
@ApiResponse(code = 200,response=XmProjectOptions.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}")
})
@RequestMapping(value="/edit",method=RequestMethod.POST)
public Map<String,Object> editXmProjectOptions(@RequestBody XmProjectOptions xmProjectOptions) {
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功更新一条数据");
try{
xmProjectOptionsService.updateByPk(xmProjectOptions);
m.put("data",xmProjectOptions);
}catch (BizException e) {
tips=e.getTips();
logger.error("",e);
}catch (Exception e) {
tips.setFailureMsg(e.getMessage());
logger.error("",e);
}
m.put("tips", tips);
return m;
}
*/
/**
@ApiOperation( value = "根据主键列表批量删除xm_project_options信息",notes="batchDelXmProjectOptions,仅需要上传主键字段")
@ApiResponses({
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}")
})
@RequestMapping(value="/batchDel",method=RequestMethod.POST)
public Map<String,Object> batchDelXmProjectOptions(@RequestBody List<XmProjectOptions> xmProjectOptionss) {
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功删除"+xmProjectOptionss.size()+"条数据");
try{
xmProjectOptionsService.batchDelete(xmProjectOptionss);
}catch (BizException e) {
tips=e.getTips();
logger.error("",e);
}catch (Exception e) {
tips.setFailureMsg(e.getMessage());
logger.error("",e);
}
m.put("tips", tips);
return m;
}
*/
}

92
xm-core/src/main/java/com/xm/core/entity/XmProjectOptions.java

@ -1,92 +0,0 @@
package com.xm.core.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* 组织 com.qqkj 顶级模块 oa 大模块 xm 小模块 <br>
* 实体 XmProjectOptions所有属性名: <br>
* id,branchId,optionType,name;<br>
* XM.xm_project_options xm_project_options的所有字段名: <br>
* id,branch_id,option_type,name;<br>
* 当前主键(包括多主键):<br>
* id;<br>
*/
@ApiModel(description="xm_project_options")
public class XmProjectOptions implements java.io.Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(notes="主键,主键",allowEmptyValue=true,example="",allowableValues="")
String id;
@ApiModelProperty(notes="机构编号",allowEmptyValue=true,example="",allowableValues="")
String branchId;
@ApiModelProperty(notes="选项类型,0项目类型,1紧急程度,2优先程度",allowEmptyValue=true,example="",allowableValues="")
String optionType;
@ApiModelProperty(notes="选项名字",allowEmptyValue=true,example="",allowableValues="")
String name;
/**主键**/
public XmProjectOptions(String id) {
this.id = id;
}
/**xm_project_options**/
public XmProjectOptions() {
}
/**
* 主键
**/
public void setId(String id) {
this.id = id;
}
/**
* 机构编号
**/
public void setBranchId(String branchId) {
this.branchId = branchId;
}
/**
* 选项类型0项目类型1紧急程度2优先程度
**/
public void setOptionType(String optionType) {
this.optionType = optionType;
}
/**
* 选项名字
**/
public void setName(String name) {
this.name = name;
}
/**
* 主键
**/
public String getId() {
return this.id;
}
/**
* 机构编号
**/
public String getBranchId() {
return this.branchId;
}
/**
* 选项类型0项目类型1紧急程度2优先程度
**/
public String getOptionType() {
return this.optionType;
}
/**
* 选项名字
**/
public String getName() {
return this.name;
}
}

5
xm-core/src/main/java/com/xm/core/service/XmMenuService.java

@ -403,5 +403,10 @@ public class XmMenuService extends BaseService {
public List<Map<String, Object>> getXmMenuSort(Map<String, Object> xmMenu) { public List<Map<String, Object>> getXmMenuSort(Map<String, Object> xmMenu) {
return super.selectList("getXmMenuSort",xmMenu); return super.selectList("getXmMenuSort",xmMenu);
} }
@Override
public String createKey(String keyName) {
return "M"+sequenceService.getCommonNo("{date62:yyyyMMddHHmmss}{rands:4}");
}
} }

17
xm-core/src/main/java/com/xm/core/service/XmProjectOptionsService.java

@ -1,17 +0,0 @@
package com.xm.core.service;
import com.mdp.core.service.BaseService;
import org.springframework.stereotype.Service;
/**
* 父类已经支持增删改查操作,因此,即使本类什么也不写,也已经可以满足一般的增删改查操作了.<br>
* 组织 com.qqkj 顶级模块 oa 大模块 xm 小模块 <br>
* 实体 XmProjectOptions XM.xm_project_options 当前主键(包括多主键): id;
***/
@Service("xm.core.xmProjectOptionsService")
public class XmProjectOptionsService extends BaseService {
/** 请在此类添加自定义函数 */
}

5
xm-core/src/main/java/com/xm/core/service/XmQuestionService.java

@ -204,5 +204,10 @@ public class XmQuestionService extends BaseService {
public List<Map<String, Object>> getXmQuestionSort(Map<String, Object> xmQuestion) { public List<Map<String, Object>> getXmQuestionSort(Map<String, Object> xmQuestion) {
return super.selectList("getXmQuestionSort",xmQuestion); return super.selectList("getXmQuestionSort",xmQuestion);
} }
@Override
public String createKey(String keyName) {
return "Q"+sequenceService.getCommonNo("{date62:yyyyMMddHHmmss}{rands:4}");
}
} }

5
xm-core/src/main/java/com/xm/core/service/XmRecordService.java

@ -430,6 +430,9 @@ public class XmRecordService extends BaseService {
record.setGloNo(MDC.get("gloNo")); record.setGloNo(MDC.get("gloNo"));
this.insert(record); this.insert(record);
} }
@Override
public String createKey(String keyName) {
return "R"+sequenceService.getCommonNo("{date62:yyyyMMddHHmmss}{rands:4}");
}
} }

5
xm-core/src/main/java/com/xm/core/service/XmTaskService.java

@ -749,5 +749,10 @@ public class XmTaskService extends BaseService {
public List<Map<String, Object>> getXmTaskSort(Map<String, Object> xmTask) { public List<Map<String, Object>> getXmTaskSort(Map<String, Object> xmTask) {
return super.selectList("getXmTaskSort",xmTask); return super.selectList("getXmTaskSort",xmTask);
} }
@Override
public String createKey(String keyName) {
return "T"+sequenceService.getCommonNo("{date62:yyyyMMddHHmmss}{rands:4}");
}
} }

5
xm-core/src/main/java/com/xm/core/service/XmTaskWorkloadService.java

@ -66,5 +66,10 @@ public class XmTaskWorkloadService extends BaseService {
public void updateStatusAfterDetailDel(List<String> detailIds) { public void updateStatusAfterDetailDel(List<String> detailIds) {
super.update("updateStatusAfterDetailDel",detailIds); super.update("updateStatusAfterDetailDel",detailIds);
} }
@Override
public String createKey(String keyName) {
return "TW"+sequenceService.getCommonNo("{date62:yyyyMMddHHmmss}{rands:4}");
}
} }

603
xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmPhaseMapper.xml

@ -1,603 +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.XmPhase">
<!--开始 自定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=" pidPathsList != null"> and
<foreach collection="pidPathsList" item="item" index="index" open="(" separator=" or " close=")" >
#{item} like concat(res.pid_paths,'%')
</foreach>
</if>
<if test=" taskFilterType !=null and taskFilterType!=''">
and <if test="taskFilterType=='not-join'"> not </if>
exists( select 1 from xm_task t where t.phase_id=res.id)
</if>
<if test="key != null and key !='' "> </if>
<if test="isTop!=null and isTop!=''">
and (res.parent_id is null or res.parent_id='')
</if>
</sql>
<select id="selectTotalProjectAndPhaseBudgetCost" parameterType="HashMap" resultType="HashMap">
SELECT
sum( ifnull(res.budget_workload,0) ) AS budget_workload,
sum( ifnull(res.budget_nouser_at,0) ) AS budget_nouser_at,
sum( ifnull(res.budget_iuser_at,0) ) AS budget_iuser_at,
sum( ifnull(res.budget_ouser_at,0) ) 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,
p.plan_total_cost
FROM
XM.xm_project p
LEFT JOIN XM.xm_phase res
ON p.id = res.project_id and res.lvl=1
<if test=" excludePhaseIds !=null "> and res.id not in
<foreach collection="excludePhaseIds" item="item" index="index" open="(" separator="," close=")" >
#{item}
</foreach>
</if>
where p.id=#{projectId}
</select>
<select id="selectTotalProductAndPhaseBudgetCost" parameterType="HashMap" resultType="HashMap">
SELECT
sum( ifnull(res.budget_workload,0) ) AS budget_workload,
sum( ifnull(res.budget_nouser_at,0) ) AS budget_nouser_at,
sum( ifnull(res.budget_iuser_at,0) ) AS budget_iuser_at,
sum( ifnull(res.budget_ouser_at,0) ) AS budget_ouser_at,
sum( ifnull(res.budget_at,0) ) AS budget_at,
p.pbudget_workload,
p.pbudget_amount,
p.pmenu_budget_workload,
p.pmenu_budget_amount
FROM
XM.xm_product p
LEFT JOIN XM.xm_phase res
ON p.id = res.product_id and res.lvl=1
<if test=" excludePhaseIds !=null "> and res.id not in
<foreach collection="excludePhaseIds" item="item" index="index" open="(" separator="," close=")" >
#{item}
</foreach>
</if>
where p.id=#{productId}
</select>
<select id="selectPhaseBudgetCost" parameterType="HashMap" resultType="HashMap">
select
res2.id,
res2.budget_workload,
res2.budget_nouser_at,
res2.budget_iuser_at,
res2.budget_ouser_at,
res2.budget_at,
res0.child_budget_workload,
res0.child_budget_nouser_at,
res0.child_budget_iuser_at,
res0.child_budget_ouser_at,
res0.child_budget_at
from xm_phase res2 left join
(
SELECT
res.parent_id,
sum( ifnull(res.budget_workload,0) ) AS child_budget_workload,
sum( ifnull(res.budget_nouser_at,0) ) AS child_budget_nouser_at,
sum( ifnull(res.budget_iuser_at,0) ) AS child_budget_iuser_at,
sum( ifnull(res.budget_ouser_at,0) ) AS child_budget_ouser_at,
sum( ifnull(res.budget_at,0) ) AS child_budget_at
FROM xm_phase res where res.parent_id=#{id}
<if test=" excludePhaseIds !=null "> and res.id not in
<foreach collection="excludePhaseIds" item="item" index="index" open="(" separator="," close=")" >
#{item}
</foreach>
</if>
group by res.parent_id
) as res0 on res0.parent_id=res2.id
where res2.id=#{id}
</select>
<update id="loadTasksToXmProjectPhase" parameterType="String" statementType="CALLABLE">
{call load_tasks_to_xm_phase(#{projectId,mode=IN})}
</update>
<update id="loaMenusToXmProductPhase" parameterType="String" statementType="CALLABLE">
{call loaMenusToXmProductPhase(#{productId,mode=IN})}
</update>
<select id="checkExistsTask" parameterType="String" resultType="Long">
select count(1) from xm_task t where t.phase_id=#{phaseId}
</select>
<select id="checkExistsChildren" parameterType="String" resultType="Long" >
select count(1) from xm_phase res where res.parent_id = #{id}
</select>
<update id="updatePhaseChildrenCntByPhaseId" parameterType="String">
UPDATE xm_phase t
LEFT JOIN ( SELECT count( 1 ) AS children_cnt, tt.parent_id AS id FROM xm_phase tt WHERE tt.parent_id = #{id} ) t2 ON t2.id = t.id
SET t.children_cnt = ifnull( t2.children_cnt, 0 )
WHERE
t.id = #{id}
</update>
<update id="updateChildrenCntByIds" parameterType="List">
UPDATE xm_phase t
LEFT JOIN ( SELECT count( 1 ) AS children_cnt, tt.parent_id AS id FROM xm_phase tt WHERE
(tt.parent_id) in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")" >
( #{item})
</foreach>
group by tt.parent_id ) t2 ON t2.id = t.id
SET t.children_cnt = ifnull( t2.children_cnt, 0 )
WHERE (t.id) in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")" >
( #{item})
</foreach>
</update>
<update id="sumParents" parameterType="List">
<foreach collection="list" item="item" index="index" separator=";" >
UPDATE XM.xm_phase res
LEFT JOIN (
SELECT
t.project_id,
t.parent_id,
count(1) as children_cnt,
sum(t.act_iuser_workload) as act_iuser_workload,
sum(t.act_ouser_workload) as act_ouser_workload,
sum(t.act_workload) as act_workload,
sum(t.act_iuser_at) as act_iuser_at,
sum(t.act_ouser_at) as act_ouser_at,
sum(ifnull(t.act_rate,0)*ifnull(t.task_budget_workload,0)) as task_budget_workload_act_rate,
sum(t.task_budget_workload) as task_budget_workload,
sum(t.task_budget_at) as task_budget_at
FROM xm_phase t
WHERE
t.parent_id=#{item}
GROUP BY
t.project_id,
t.parent_id
) AS tc ON res.project_id = tc.project_id and res.id=tc.parent_id
SET res.act_iuser_workload = tc.act_iuser_workload,
res.act_ouser_workload = tc.act_ouser_workload,
res.act_workload = tc.act_workload,
res.act_iuser_at = tc.act_iuser_at,
res.act_ouser_at = tc.act_ouser_at,
res.act_rate= case when tc.task_budget_workload_act_rate=0 then 0 else tc.task_budget_workload_act_rate / tc.task_budget_workload end,
res.task_budget_workload=tc.task_budget_workload,
res.task_budget_at=tc.task_budget_at,
res.calc_time=now(),
res.children_cnt=ifnull(tc.children_cnt,0)
where res.id=#{item} and res.ntype='1'
</foreach>
</update>
<update id="batchSumParents" parameterType="List">
UPDATE XM.xm_phase res
LEFT JOIN (
SELECT
t.project_id,
t.parent_id,
count(1) as children_cnt,
sum(t.act_iuser_workload) as act_iuser_workload,
sum(t.act_ouser_workload) as act_ouser_workload,
sum(t.act_workload) as act_workload,
sum(t.act_iuser_at) as act_iuser_at,
sum(t.act_ouser_at) as act_ouser_at,
sum(ifnull(t.act_rate,0)*ifnull(t.task_budget_workload,0)) as task_budget_workload_act_rate,
sum(t.task_budget_workload) as task_budget_workload,
sum(t.task_budget_at) as task_budget_at
FROM xm_phase t
WHERE
t.parent_id in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")" >
#{item}
</foreach>
GROUP BY
t.project_id,
t.parent_id
) AS tc ON res.project_id = tc.project_id and res.id=tc.parent_id
SET res.act_iuser_workload = tc.act_iuser_workload,
res.act_ouser_workload = tc.act_ouser_workload,
res.act_workload = tc.act_workload,
res.act_iuser_at = tc.act_iuser_at,
res.act_ouser_at = tc.act_ouser_at,
res.act_rate= case when tc.task_budget_workload_act_rate=0 then 0 else tc.task_budget_workload_act_rate / tc.task_budget_workload end,
res.task_budget_workload=tc.task_budget_workload,
res.task_budget_at=tc.task_budget_at,
res.calc_time=now(),
res.children_cnt=ifnull(tc.children_cnt,0)
where res.id in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")" >
#{item}
</foreach>
and res.ntype='1'
</update>
<select id="selectListByIds" parameterType="List" resultType="com.xm.core.entity.XmPhase">
select (select sum(1) from xm_phase p where p.parent_id = res.id) as children_cnt,res.* from xm_phase res where res.id in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")" >
#{item}
</foreach>
</select>
<select id="batchRelTasksWithPhase" parameterType="com.xm.core.vo.BatchRelTasksWithPhase">
update xm_task res set res.phase_id = #{phaseId} where res.id in
<foreach collection="taskIds" item="item" index="index" open="(" separator="," close=")" >
#{item}
</foreach>
and res.ntype='0'
</select>
<!--结束 自定义sql函数区域-->
<!-- 通过条件查询获取数据列表 返回list<map> -->
<select id="selectListMapByWhere" parameterType="HashMap" resultType="HashMap">
select (select sum(1) from xm_phase p where p.parent_id = res.id) as children_cnt,res.* from xm_phase res
<where>
<include refid="whereForMap"/>
<include refid="where"/>
</where>
order by res.seq_no asc
</select>
<!-- 通过条件查询获取数据列表 不分页 返回 list<Object> -->
<select id="selectListByWhere" parameterType="com.xm.core.entity.XmPhase" resultType="com.xm.core.entity.XmPhase">
select (select sum(1) from xm_phase p where p.parent_id = res.id) as children_cnt,res.* from xm_phase res
<where>
<include refid="where"/>
</where>
</select>
<!-- 通过主键查询获取数据对象 返回object -->
<select id="selectOneObject" parameterType="com.xm.core.entity.XmPhase" resultType="com.xm.core.entity.XmPhase">
select (select sum(1) from xm_phase p where p.parent_id = res.id) as children_cnt,res.* from xm_phase res
where
res.id = #{id}
</select>
<!-- 通过主键查询获取数据对象 返回map-->
<select id="selectOneMap" parameterType="HashMap" resultType="HashMap">
select * from xm_phase res
where
res.id = #{id}
</select>
<!-- 获取数据条目 返回long -->
<select id="countByWhere" parameterType="com.xm.core.entity.XmPhase" resultType="long">
select count(1) from xm_phase res
<where>
<include refid="where"/>
</where>
</select>
<!-- 新增一条记录 主键id,-->
<insert id="insert" parameterType="com.xm.core.entity.XmPhase" useGeneratedKeys="false" keyProperty="id">
insert into xm_phase(
<include refid="columns"/>
) values (
#{id},#{name},#{remark},#{parentId},#{branchId},#{projectId},#{beginDate},#{endDate},#{budgetHours},#{budgetStaffNu},#{ctime},#{budgetNouserAt},#{budgetIuserAt},#{budgetOuserAt},#{baselineId},#{bizProcInstId},#{bizFlowState},#{budgetWorkload},#{actWorkload},#{actIuserWorkload},#{actOuserWorkload},#{taskType},#{planType},#{seqNo},#{budgetIuserWorkload},#{budgetOuserWorkload},#{actNouserAt},#{actIuserAt},#{budgetIuserPrice},#{budgetOuserPrice},#{budgetOuserCnt},#{budgetIuserCnt},#{actRate},#{pstatus},#{actOuserAt},#{taskCnt},#{finishTaskCnt},#{iterationCnt},#{calcTime},#{taskBudgetWorkload},#{taskBudgetAt},#{mngUserid},#{mngUsername},#{milestone},#{pleaf},#{tagIds},#{tagNames},#{ntype},#{childrenCnt},#{ltime},#{isKeyPath},#{pidPaths},#{lvl},#{isTpl},#{phaseClass},#{productId},#{budgetAt},#{calcType},#{actAt}
)
</insert>
<!-- 按条件删除若干条记录-->
<delete id="deleteByWhere" parameterType="com.xm.core.entity.XmPhase">
delete from xm_phase res
<where>
<include refid="where"/>
</where>
</delete>
<!-- 按主键删除一条记录-->
<delete id="deleteByPk" parameterType="com.xm.core.entity.XmPhase">
delete from xm_phase
where id = #{id}
</delete>
<!-- 根据条件修改若干条记录 -->
<update id="updateSomeFieldByPk" parameterType="com.xm.core.entity.XmPhase">
update xm_phase
<set>
<include refid="someFieldSet"/>
</set>
where id = #{id}
</update>
<!-- 根据主键修改一条记录 -->
<update id="updateByPk" parameterType="com.xm.core.entity.XmPhase">
update xm_phase
<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_phase
set
<include refid="batchSet"/>
where id = #{item.id}
</foreach>
</update>
<!-- 批量删除 -->
<delete id="batchDelete" parameterType="List">
delete from xm_phase
where
(id) in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")" >
( #{item.id} )
</foreach>
</delete>
<!--sql片段 列-->
<sql id="columns">
id,name,remark,parent_id,branch_id,project_id,begin_date,end_date,budget_hours,budget_staff_nu,ctime,budget_nouser_at,budget_iuser_at,budget_ouser_at,baseline_id,biz_proc_inst_id,biz_flow_state,budget_workload,act_workload,act_iuser_workload,act_ouser_workload,task_type,plan_type,seq_no,budget_iuser_workload,budget_ouser_workload,act_nouser_at,act_iuser_at,budget_iuser_price,budget_ouser_price,budget_ouser_cnt,budget_iuser_cnt,act_rate,pstatus,act_ouser_at,task_cnt,finish_task_cnt,iteration_cnt,calc_time,task_budget_workload,task_budget_at,mng_userid,mng_username,milestone,pleaf,tag_ids,tag_names,ntype,children_cnt,ltime,is_key_path,pid_paths,lvl,is_tpl,phase_class,product_id,budget_at,calc_type,act_at
</sql>
<!--sql片段 动态条件 YYYY-MM-DD HH24:MI:SS-->
<sql id="where">
<if test="id != null and id != ''"> and res.id = #{id} </if>
<if test="name != null and name != ''"> and res.name = #{name} </if>
<if test="remark != null and remark != ''"> and res.remark = #{remark} </if>
<if test="parentId != null and parentId != ''"> and res.parent_id = #{parentId} </if>
<if test="branchId != null and branchId != ''"> and res.branch_id = #{branchId} </if>
<if test="projectId != null and projectId != ''"> and res.project_id = #{projectId} </if>
<if test="beginDate != null"> and date_format(res.begin_date,'%Y-%m-%d') = date_format(#{beginDate},'%Y-%m-%d') </if>
<if test="endDate != null"> and date_format(res.end_date,'%Y-%m-%d') = date_format(#{endDate},'%Y-%m-%d') </if>
<if test="budgetHours != null and budgetHours != ''"> and res.budget_hours = #{budgetHours} </if>
<if test="budgetStaffNu != null and budgetStaffNu != ''"> and res.budget_staff_nu = #{budgetStaffNu} </if>
<if test="ctime != null"> and date_format(res.ctime,'%Y-%m-%d') = date_format(#{ctime},'%Y-%m-%d') </if>
<if test="budgetNouserAt != null and budgetNouserAt != ''"> and res.budget_nouser_at = #{budgetNouserAt} </if>
<if test="budgetIuserAt != null and budgetIuserAt != ''"> and res.budget_iuser_at = #{budgetIuserAt} </if>
<if test="budgetOuserAt != null and budgetOuserAt != ''"> and res.budget_ouser_at = #{budgetOuserAt} </if>
<if test="baselineId != null and baselineId != ''"> and res.baseline_id = #{baselineId} </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="budgetWorkload != null and budgetWorkload != ''"> and res.budget_workload = #{budgetWorkload} </if>
<if test="actWorkload != null and actWorkload != ''"> and res.act_workload = #{actWorkload} </if>
<if test="actIuserWorkload != null and actIuserWorkload != ''"> and res.act_iuser_workload = #{actIuserWorkload} </if>
<if test="actOuserWorkload != null and actOuserWorkload != ''"> and res.act_ouser_workload = #{actOuserWorkload} </if>
<if test="taskType != null and taskType != ''"> and res.task_type = #{taskType} </if>
<if test="planType != null and planType != ''"> and res.plan_type = #{planType} </if>
<if test="seqNo != null and seqNo != ''"> and res.seq_no = #{seqNo} </if>
<if test="budgetIuserWorkload != null and budgetIuserWorkload != ''"> and res.budget_iuser_workload = #{budgetIuserWorkload} </if>
<if test="budgetOuserWorkload != null and budgetOuserWorkload != ''"> and res.budget_ouser_workload = #{budgetOuserWorkload} </if>
<if test="actNouserAt != null and actNouserAt != ''"> and res.act_nouser_at = #{actNouserAt} </if>
<if test="actIuserAt != null and actIuserAt != ''"> and res.act_iuser_at = #{actIuserAt} </if>
<if test="budgetIuserPrice != null and budgetIuserPrice != ''"> and res.budget_iuser_price = #{budgetIuserPrice} </if>
<if test="budgetOuserPrice != null and budgetOuserPrice != ''"> and res.budget_ouser_price = #{budgetOuserPrice} </if>
<if test="budgetOuserCnt != null and budgetOuserCnt != ''"> and res.budget_ouser_cnt = #{budgetOuserCnt} </if>
<if test="budgetIuserCnt != null and budgetIuserCnt != ''"> and res.budget_iuser_cnt = #{budgetIuserCnt} </if>
<if test="actRate != null and actRate != ''"> and res.act_rate = #{actRate} </if>
<if test="pstatus != null and pstatus != ''"> and res.pstatus = #{pstatus} </if>
<if test="actOuserAt != null and actOuserAt != ''"> and res.act_ouser_at = #{actOuserAt} </if>
<if test="taskCnt != null and taskCnt != ''"> and res.task_cnt = #{taskCnt} </if>
<if test="finishTaskCnt != null and finishTaskCnt != ''"> and res.finish_task_cnt = #{finishTaskCnt} </if>
<if test="iterationCnt != null and iterationCnt != ''"> and res.iteration_cnt = #{iterationCnt} </if>
<if test="calcTime != null"> and date_format(res.calc_time,'%Y-%m-%d') = date_format(#{calcTime},'%Y-%m-%d') </if>
<if test="taskBudgetWorkload != null and taskBudgetWorkload != ''"> and res.task_budget_workload = #{taskBudgetWorkload} </if>
<if test="taskBudgetAt != null and taskBudgetAt != ''"> and res.task_budget_at = #{taskBudgetAt} </if>
<if test="mngUserid != null and mngUserid != ''"> and res.mng_userid = #{mngUserid} </if>
<if test="mngUsername != null and mngUsername != ''"> and res.mng_username = #{mngUsername} </if>
<if test="milestone != null and milestone != ''"> and res.milestone = #{milestone} </if>
<if test="pleaf != null and pleaf != ''"> and res.pleaf = #{pleaf} </if>
<if test="tagIds != null and tagIds != ''"> and res.tag_ids = #{tagIds} </if>
<if test="tagNames != null and tagNames != ''"> and res.tag_names = #{tagNames} </if>
<if test="ntype != null and ntype != ''"> and res.ntype = #{ntype} </if>
<if test="childrenCnt != null and childrenCnt != ''"> and res.children_cnt = #{childrenCnt} </if>
<if test="ltime != null"> and date_format(res.ltime,'%Y-%m-%d') = date_format(#{ltime},'%Y-%m-%d') </if>
<if test="isKeyPath != null and isKeyPath != ''"> and res.is_key_path = #{isKeyPath} </if>
<if test="pidPaths != null and pidPaths != ''"> and res.pid_paths = #{pidPaths} </if>
<if test="lvl != null and lvl != ''"> and res.lvl = #{lvl} </if>
<if test="isTpl != null and isTpl != ''"> and res.is_tpl = #{isTpl} </if>
<if test="phaseClass != null and phaseClass != ''"> and res.phase_class = #{phaseClass} </if>
<if test="productId != null and productId != ''"> and res.product_id = #{productId} </if>
<if test="budgetAt != null and budgetAt != ''"> and res.budget_at = #{budgetAt} </if>
<if test="calcType != null and calcType != ''"> and res.calc_type = #{calcType} </if>
<if test="actAt != null and actAt != ''"> and res.act_at = #{actAt} </if>
</sql>
<!--sql片段 更新字段 -->
<sql id="set">
name = #{name},
remark = #{remark},
parent_id = #{parentId},
branch_id = #{branchId},
project_id = #{projectId},
begin_date = #{beginDate},
end_date = #{endDate},
budget_hours = #{budgetHours},
budget_staff_nu = #{budgetStaffNu},
ctime = #{ctime},
budget_nouser_at = #{budgetNouserAt},
budget_iuser_at = #{budgetIuserAt},
budget_ouser_at = #{budgetOuserAt},
baseline_id = #{baselineId},
biz_proc_inst_id = #{bizProcInstId},
biz_flow_state = #{bizFlowState},
budget_workload = #{budgetWorkload},
act_workload = #{actWorkload},
act_iuser_workload = #{actIuserWorkload},
act_ouser_workload = #{actOuserWorkload},
task_type = #{taskType},
plan_type = #{planType},
seq_no = #{seqNo},
budget_iuser_workload = #{budgetIuserWorkload},
budget_ouser_workload = #{budgetOuserWorkload},
act_nouser_at = #{actNouserAt},
act_iuser_at = #{actIuserAt},
budget_iuser_price = #{budgetIuserPrice},
budget_ouser_price = #{budgetOuserPrice},
budget_ouser_cnt = #{budgetOuserCnt},
budget_iuser_cnt = #{budgetIuserCnt},
act_rate = #{actRate},
pstatus = #{pstatus},
act_ouser_at = #{actOuserAt},
task_cnt = #{taskCnt},
finish_task_cnt = #{finishTaskCnt},
iteration_cnt = #{iterationCnt},
calc_time = #{calcTime},
task_budget_workload = #{taskBudgetWorkload},
task_budget_at = #{taskBudgetAt},
mng_userid = #{mngUserid},
mng_username = #{mngUsername},
milestone = #{milestone},
pleaf = #{pleaf},
tag_ids = #{tagIds},
tag_names = #{tagNames},
ntype = #{ntype},
children_cnt = #{childrenCnt},
ltime = #{ltime},
is_key_path = #{isKeyPath},
pid_paths = #{pidPaths},
lvl = #{lvl},
is_tpl = #{isTpl},
phase_class = #{phaseClass},
product_id = #{productId},
budget_at = #{budgetAt},
calc_type = #{calcType},
act_at = #{actAt}
</sql>
<sql id="someFieldSet">
<if test="name != null and name != ''"> name = #{name}, </if>
<if test="remark != null and remark != ''"> remark = #{remark}, </if>
<if test="parentId != null and parentId != ''"> parent_id = #{parentId}, </if>
<if test="branchId != null and branchId != ''"> branch_id = #{branchId}, </if>
<if test="projectId != null and projectId != ''"> project_id = #{projectId}, </if>
<if test="beginDate != null"> begin_date = #{beginDate}, </if>
<if test="endDate != null"> end_date = #{endDate}, </if>
<if test="budgetHours != null and budgetHours != ''"> budget_hours = #{budgetHours}, </if>
<if test="budgetStaffNu != null and budgetStaffNu != ''"> budget_staff_nu = #{budgetStaffNu}, </if>
<if test="ctime != null"> ctime = #{ctime}, </if>
<if test="budgetNouserAt != null and budgetNouserAt != ''"> budget_nouser_at = #{budgetNouserAt}, </if>
<if test="budgetIuserAt != null and budgetIuserAt != ''"> budget_iuser_at = #{budgetIuserAt}, </if>
<if test="budgetOuserAt != null and budgetOuserAt != ''"> budget_ouser_at = #{budgetOuserAt}, </if>
<if test="baselineId != null and baselineId != ''"> baseline_id = #{baselineId}, </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="budgetWorkload != null and budgetWorkload != ''"> budget_workload = #{budgetWorkload}, </if>
<if test="actWorkload != null and actWorkload != ''"> act_workload = #{actWorkload}, </if>
<if test="actIuserWorkload != null and actIuserWorkload != ''"> act_iuser_workload = #{actIuserWorkload}, </if>
<if test="actOuserWorkload != null and actOuserWorkload != ''"> act_ouser_workload = #{actOuserWorkload}, </if>
<if test="taskType != null and taskType != ''"> task_type = #{taskType}, </if>
<if test="planType != null and planType != ''"> plan_type = #{planType}, </if>
<if test="seqNo != null and seqNo != ''"> seq_no = #{seqNo}, </if>
<if test="budgetIuserWorkload != null and budgetIuserWorkload != ''"> budget_iuser_workload = #{budgetIuserWorkload}, </if>
<if test="budgetOuserWorkload != null and budgetOuserWorkload != ''"> budget_ouser_workload = #{budgetOuserWorkload}, </if>
<if test="actNouserAt != null and actNouserAt != ''"> act_nouser_at = #{actNouserAt}, </if>
<if test="actIuserAt != null and actIuserAt != ''"> act_iuser_at = #{actIuserAt}, </if>
<if test="budgetIuserPrice != null and budgetIuserPrice != ''"> budget_iuser_price = #{budgetIuserPrice}, </if>
<if test="budgetOuserPrice != null and budgetOuserPrice != ''"> budget_ouser_price = #{budgetOuserPrice}, </if>
<if test="budgetOuserCnt != null and budgetOuserCnt != ''"> budget_ouser_cnt = #{budgetOuserCnt}, </if>
<if test="budgetIuserCnt != null and budgetIuserCnt != ''"> budget_iuser_cnt = #{budgetIuserCnt}, </if>
<if test="actRate != null and actRate != ''"> act_rate = #{actRate}, </if>
<if test="pstatus != null and pstatus != ''"> pstatus = #{pstatus}, </if>
<if test="actOuserAt != null and actOuserAt != ''"> act_ouser_at = #{actOuserAt}, </if>
<if test="taskCnt != null and taskCnt != ''"> task_cnt = #{taskCnt}, </if>
<if test="finishTaskCnt != null and finishTaskCnt != ''"> finish_task_cnt = #{finishTaskCnt}, </if>
<if test="iterationCnt != null and iterationCnt != ''"> iteration_cnt = #{iterationCnt}, </if>
<if test="calcTime != null"> calc_time = #{calcTime}, </if>
<if test="taskBudgetWorkload != null and taskBudgetWorkload != ''"> task_budget_workload = #{taskBudgetWorkload}, </if>
<if test="taskBudgetAt != null and taskBudgetAt != ''"> task_budget_at = #{taskBudgetAt}, </if>
<if test="mngUserid != null and mngUserid != ''"> mng_userid = #{mngUserid}, </if>
<if test="mngUsername != null and mngUsername != ''"> mng_username = #{mngUsername}, </if>
<if test="milestone != null and milestone != ''"> milestone = #{milestone}, </if>
<if test="pleaf != null and pleaf != ''"> pleaf = #{pleaf}, </if>
<if test="tagIds != null and tagIds != ''"> tag_ids = #{tagIds}, </if>
<if test="tagNames != null and tagNames != ''"> tag_names = #{tagNames}, </if>
<if test="ntype != null and ntype != ''"> ntype = #{ntype}, </if>
<if test="childrenCnt != null and childrenCnt != ''"> children_cnt = #{childrenCnt}, </if>
<if test="ltime != null"> ltime = #{ltime}, </if>
<if test="isKeyPath != null and isKeyPath != ''"> is_key_path = #{isKeyPath}, </if>
<if test="pidPaths != null and pidPaths != ''"> pid_paths = #{pidPaths}, </if>
<if test="lvl != null and lvl != ''"> lvl = #{lvl}, </if>
<if test="isTpl != null and isTpl != ''"> is_tpl = #{isTpl}, </if>
<if test="phaseClass != null and phaseClass != ''"> phase_class = #{phaseClass}, </if>
<if test="productId != null and productId != ''"> product_id = #{productId}, </if>
<if test="budgetAt != null and budgetAt != ''"> budget_at = #{budgetAt}, </if>
<if test="calcType != null and calcType != ''"> calc_type = #{calcType}, </if>
<if test="actAt != null and actAt != ''"> act_at = #{actAt}, </if>
</sql>
<!--sql片段 批量更新 -->
<sql id="batchSet">
name = #{item.name},
remark = #{item.remark},
parent_id = #{item.parentId},
branch_id = #{item.branchId},
project_id = #{item.projectId},
begin_date = #{item.beginDate},
end_date = #{item.endDate},
budget_hours = #{item.budgetHours},
budget_staff_nu = #{item.budgetStaffNu},
ctime = #{item.ctime},
budget_nouser_at = #{item.budgetNouserAt},
budget_iuser_at = #{item.budgetIuserAt},
budget_ouser_at = #{item.budgetOuserAt},
baseline_id = #{item.baselineId},
biz_proc_inst_id = #{item.bizProcInstId},
biz_flow_state = #{item.bizFlowState},
budget_workload = #{item.budgetWorkload},
act_workload = #{item.actWorkload},
act_iuser_workload = #{item.actIuserWorkload},
act_ouser_workload = #{item.actOuserWorkload},
task_type = #{item.taskType},
plan_type = #{item.planType},
seq_no = #{item.seqNo},
budget_iuser_workload = #{item.budgetIuserWorkload},
budget_ouser_workload = #{item.budgetOuserWorkload},
act_nouser_at = #{item.actNouserAt},
act_iuser_at = #{item.actIuserAt},
budget_iuser_price = #{item.budgetIuserPrice},
budget_ouser_price = #{item.budgetOuserPrice},
budget_ouser_cnt = #{item.budgetOuserCnt},
budget_iuser_cnt = #{item.budgetIuserCnt},
act_rate = #{item.actRate},
pstatus = #{item.pstatus},
act_ouser_at = #{item.actOuserAt},
task_cnt = #{item.taskCnt},
finish_task_cnt = #{item.finishTaskCnt},
iteration_cnt = #{item.iterationCnt},
calc_time = #{item.calcTime},
task_budget_workload = #{item.taskBudgetWorkload},
task_budget_at = #{item.taskBudgetAt},
mng_userid = #{item.mngUserid},
mng_username = #{item.mngUsername},
milestone = #{item.milestone},
pleaf = #{item.pleaf},
tag_ids = #{item.tagIds},
tag_names = #{item.tagNames},
ntype = #{item.ntype},
children_cnt = #{item.childrenCnt},
ltime = #{item.ltime},
is_key_path = #{item.isKeyPath},
pid_paths = #{item.pidPaths},
lvl = #{item.lvl},
is_tpl = #{item.isTpl},
phase_class = #{item.phaseClass},
product_id = #{item.productId},
budget_at = #{item.budgetAt},
calc_type = #{item.calcType},
act_at = #{item.actAt}
</sql>
</mapper>
Loading…
Cancel
Save