Commit 74d9ff7e authored by chenyuefang's avatar chenyuefang

成本汇总锁定

parent 6cca5fd0
......@@ -188,6 +188,7 @@ tenant:
- f_ads_bsi_kpi_proj_two
- cb_summary
- cb_summary_actual
- cb_summary_actual_lock
- cb_cost_measure
- cb_cost_measure_actual
- cb_direct_expense
......
......@@ -7,6 +7,7 @@ import com.dsk.common.core.domain.R;
import com.dsk.common.utils.poi.ExcelUtil;
import com.dsk.cscec.domain.bo.CbSummaryActualBo;
import com.dsk.cscec.domain.bo.CbSummaryActualListBo;
import com.dsk.cscec.domain.bo.CbSummaryActualLockBo;
import com.dsk.cscec.domain.bo.CbSummaryBo;
import com.dsk.cscec.domain.vo.CbSummaryActualListVo;
import com.dsk.cscec.domain.vo.CbSummaryCostAccountExportVo;
......@@ -64,10 +65,20 @@ public class CbSummaryController extends BaseController {
* @return
*/
@GetMapping("/expenseDateList")
public R<List<String>> getExpenseDateList(@Validated CbSummaryBo bo) {
public R<List<Map<String,Object>>> getExpenseDateList(@Validated CbSummaryBo bo) {
return R.ok(cbSummaryService.getExpenseDateList(bo));
}
/**
* 已锁定月份
* @param bo
* @return
*/
@GetMapping("/expenseDateList/locked")
public R<List<String>> getLockedList(@Validated CbSummaryBo bo) {
return R.ok(cbSummaryService.getLockedList(bo));
}
/**
* 编辑成本
*
......@@ -79,9 +90,25 @@ public class CbSummaryController extends BaseController {
return cbSummaryService.insertOrUpdateActual(boList) == true ? R.ok() : R.fail();
}
//锁定成本前提示未填项(按一级大类)
/**
* 锁定成本前提示未填项(按一级大类)
* @param bo
* @return
*/
@GetMapping("/getUnfilled")
public R getUnfilled(CbSummaryActualLockBo bo){
return cbSummaryService.getUnfilled(bo);
}
//锁定成本
/**
* 按月份锁定成本
* @param bo
* @return
*/
@PostMapping("/lockActual")
public R lockActual(@RequestBody CbSummaryActualLockBo bo) {
return cbSummaryService.lockActual(bo) == true ? R.ok() : R.fail();
}
/**
* 导出excel-按月导出所有
......@@ -89,7 +116,7 @@ public class CbSummaryController extends BaseController {
* @param response
*/
@PostMapping("/export")
public void export(CbSummaryActualListBo bo, HttpServletResponse response) {
public void export(@RequestBody CbSummaryActualListBo bo, HttpServletResponse response) {
List<CbSummaryActualListVo> actualListVoList = cbSummaryService.getAll(bo);
if(bo.getCbType()==1){
List<CbSummaryProjectExportVo> list = BeanUtil.copyToList(actualListVoList,CbSummaryProjectExportVo.class);
......
package com.dsk.cscec.domain;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Data;
import java.io.Serializable;
......@@ -83,6 +84,7 @@ public class CbSummary implements Serializable {
/**
* 删除状态(0:否、2:是)
*/
@TableLogic
private Integer delFlag;
/**
* 成本类型(1项目汇总,2成本科目汇总)
......
......@@ -40,7 +40,7 @@ public class CbSummaryActual implements Serializable {
/**
* 是否锁定(0否,1是)
*/
private Integer lockStatus;
// private Integer lockStatus;
/**
* 创建时间
*/
......
package com.dsk.cscec.domain;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Data;
import java.util.Date;
import java.io.Serializable;
/**
* 成本汇总-每月成本锁定(CbSummaryActualLock)实体类
*
* @author makejava
* @since 2024-02-19
*/
@Data
public class CbSummaryActualLock implements Serializable {
private static final long serialVersionUID = 849892917534518164L;
/**
* 主键id
*/
@TableId(value = "id")
private Long id;
/**
* 项目id
*/
private Long projectId;
/**
* 费用日期
*/
private String expenseDate;
/**
* 成本类型(1项目汇总,2成本科目汇总)
*/
private Integer cbType;
/**
* 创建时间
*/
private Date createTime;
/**
* 删除状态(0:否、2:是)
*/
@TableLogic
private Integer delFlag;
}
......@@ -15,6 +15,10 @@ public class CbSummaryActualListBo extends BaseEntity {
* 主键id
*/
private Long id;
/**
* 项目id
*/
private Long projectId;
/**
* 成本阶段( 0:标前成本、1:标后成本、2:转固成本)
*/
......
package com.dsk.cscec.domain.bo;
import com.dsk.common.core.domain.BaseEntity;
import lombok.Data;
/**
* 成本汇总-每月成本锁定(CbSummaryActualLock)bo
*
* @author cyf
* @since 2024-02-19
*/
@Data
public class CbSummaryActualLockBo extends BaseEntity {
/**
* 项目id
*/
private Long projectId;
/**
* 费用日期
*/
private String expenseDate;
/**
* 成本类型(1项目汇总,2成本科目汇总)
*/
private Integer cbType;
}
......@@ -26,6 +26,10 @@ public class CbSummaryActualListVo extends BaseEntity {
* 成本阶段( 0:标前成本、1:标后成本、2:转固成本)
*/
private Integer cbStage;
/**
* 层级
*/
private Integer level;
/**
* 序号
*/
......@@ -82,10 +86,6 @@ public class CbSummaryActualListVo extends BaseEntity {
* 费用日期
*/
private String expenseDate;
/**
* 是否锁定(0否,1是)
*/
private Integer lockStatus;
private List<CbSummaryActualListVo> children;
}
package com.dsk.cscec.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dsk.cscec.domain.CbSummaryActualLock;
import com.dsk.cscec.domain.bo.CbSummaryBo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 成本汇总-每月成本锁定(CbSummaryActualLock)表数据库访问层
*
* @author makejava
* @since 2024-02-19
*/
public interface CbSummaryActualLockMapper extends BaseMapper<CbSummaryActualLock> {
/**
* 获取已锁定成本月份
*
* @param bo
* @return
*/
List<String> getLockedList(@Param("bo") CbSummaryBo bo);
}
......@@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dsk.cscec.domain.CbSummaryActual;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
/**
* 成本汇总-每月费用(CbSummaryActual)表数据库访问层
......@@ -21,4 +23,11 @@ public interface CbSummaryActualMapper extends BaseMapper<CbSummaryActual> {
*/
int insertOrUpdateBatch(@Param("entities") List<CbSummaryActual> entities);
/**
* 截至本月费用
* @param cbSummaryId
* @param expenseDate
* @return
*/
Map<String, BigDecimal> getTotal(@Param("cbSummaryId") Long cbSummaryId, @Param("expenseDate") String expenseDate);
}
......@@ -22,6 +22,14 @@ public interface CbSummaryMapper extends BaseMapper<CbSummary> {
CbSummaryActualListVo getById(@Param("id") Long id, @Param("expenseDate") String expenseDate);
/**
* 根据ids获取实际成本
* @param entities
* @param expenseDate
* @return
*/
List<CbSummaryActualListVo> getByIds(@Param("entities") List<CbSummary> entities, @Param("expenseDate") String expenseDate);
/**
* 根据月份获取所有项目汇总数据
*
......@@ -44,7 +52,7 @@ public interface CbSummaryMapper extends BaseMapper<CbSummary> {
* @param bo
* @return
*/
List<String> getExpenseDateList(@Param("bo") CbSummaryBo bo);
List<Map<String,Object>> getExpenseDateList(@Param("bo") CbSummaryBo bo);
/**
* 根据level获取名称/成本科目
......
package com.dsk.cscec.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.dsk.common.core.domain.R;
import com.dsk.cscec.domain.CbSummary;
import com.dsk.cscec.domain.bo.CbSummaryActualBo;
import com.dsk.cscec.domain.bo.CbSummaryActualListBo;
import com.dsk.cscec.domain.bo.CbSummaryActualLockBo;
import com.dsk.cscec.domain.bo.CbSummaryBo;
import com.dsk.cscec.domain.vo.CbSummaryActualListVo;
......@@ -44,7 +46,15 @@ public interface CbSummaryService extends IService<CbSummary> {
* @param bo
* @return
*/
List<String> getExpenseDateList(CbSummaryBo bo);
List<Map<String,Object>> getExpenseDateList(CbSummaryBo bo);
/**
* 获取已锁定成本月份
*
* @param bo
* @return
*/
List<String> getLockedList(CbSummaryBo bo);
/**
* 新增/更新每月费用
......@@ -54,6 +64,20 @@ public interface CbSummaryService extends IService<CbSummary> {
*/
boolean insertOrUpdateActual(List<CbSummaryActualBo> boList);
/**
* 获取未填写成本一级大类
* @param bo
* @return
*/
R getUnfilled(CbSummaryActualLockBo bo);
/**
* 锁定成本
* @param bo
* @return
*/
boolean lockActual(CbSummaryActualLockBo bo);
/**
* 导出列表获取
* @param bo
......
......@@ -7,20 +7,16 @@ import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dsk.common.core.domain.R;
import com.dsk.common.exception.ServiceException;
import com.dsk.cscec.constant.CbProjectConstants;
import com.dsk.cscec.domain.CbProjectFile;
import com.dsk.cscec.domain.CbProjectRecord;
import com.dsk.cscec.domain.CbSummary;
import com.dsk.cscec.domain.CbSummaryActual;
import com.dsk.cscec.domain.*;
import com.dsk.cscec.domain.bo.CbSummaryActualBo;
import com.dsk.cscec.domain.bo.CbSummaryActualListBo;
import com.dsk.cscec.domain.bo.CbSummaryActualLockBo;
import com.dsk.cscec.domain.bo.CbSummaryBo;
import com.dsk.cscec.domain.vo.CbSummaryActualListVo;
import com.dsk.cscec.mapper.CbProjectFileMapper;
import com.dsk.cscec.mapper.CbProjectRecordMapper;
import com.dsk.cscec.mapper.CbSummaryActualMapper;
import com.dsk.cscec.mapper.CbSummaryMapper;
import com.dsk.cscec.mapper.*;
import com.dsk.cscec.service.CbSummaryService;
import jodd.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -28,6 +24,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
......@@ -50,6 +47,9 @@ public class CbSummaryServiceImpl extends ServiceImpl<CbSummaryMapper, CbSummary
@Autowired
private CbProjectRecordMapper cbProjectRecordMapper;
@Autowired
private CbSummaryActualLockMapper cbSummaryActualLockMapper;
@Override
public void importCbProject(Long projectId, Integer cbStage) {
//获取文件信息
......@@ -96,33 +96,43 @@ public class CbSummaryServiceImpl extends ServiceImpl<CbSummaryMapper, CbSummary
@Override
public List<CbSummaryActualListVo> getActualList(CbSummaryActualListBo bo) {
Assert.notNull(bo.getId(),"id不能为空");
Assert.notNull(bo.getCbType(),"成本类型不能为空");
Assert.notNull(bo.getId(), "id不能为空");
Assert.notNull(bo.getCbType(), "成本类型不能为空");
if (StringUtil.isBlank(bo.getExpenseDate())) {
//默认当前月
bo.setExpenseDate(DatePattern.SIMPLE_MONTH_FORMAT.format(new Date()));
}
CbSummary cbSummary = baseMapper.selectById(bo.getId());
if (ObjectUtil.isEmpty(cbSummary)) {
//当前父级数据
CbSummaryActualListVo cbSummaryActualListVo = baseMapper.getById(bo.getId(), bo.getExpenseDate());
if (ObjectUtil.isEmpty(cbSummaryActualListVo)) {
return null;
}
//截至本月费用汇总
Map<String, BigDecimal> parentTotal = cbSummaryActualMapper.getTotal(cbSummaryActualListVo.getId(), bo.getExpenseDate());
cbSummaryActualListVo.setTaxExclusiveExpenseTotal(parentTotal.get("taxExclusiveExpenseTotal"));
cbSummaryActualListVo.setTaxInclusiveExpenseTotal(parentTotal.get("taxInclusiveExpenseTotal"));
List<CbSummaryActualListVo> childrenList = baseMapper.getByParentId(bo.getId(), bo.getExpenseDate());
if (0 == cbSummary.getLevel() && 1 == bo.getCbType()) {
//项目汇总
//截至本月费用汇总
childrenList.forEach(children -> {
Map<String, BigDecimal> total = cbSummaryActualMapper.getTotal(children.getId(), bo.getExpenseDate());
children.setTaxExclusiveExpenseTotal(total.get("taxExclusiveExpenseTotal"));
children.setTaxInclusiveExpenseTotal(total.get("taxInclusiveExpenseTotal"));
});
if (0 == cbSummaryActualListVo.getLevel() && 1 == bo.getCbType()) {
//项目汇总一级列表
return childrenList;
}else if(0 == cbSummary.getLevel() && 2 == bo.getCbType()) {
//成本科目汇总
CbSummaryActualListVo cbSummaryActualListVo = baseMapper.getById(bo.getId(), bo.getExpenseDate());
} else if (0 == cbSummaryActualListVo.getLevel() && 2 == bo.getCbType()) {
//成本科目汇总一级列表
cbSummaryActualListVo.setChildren(childrenList);
List<CbSummaryActualListVo> list = new ArrayList<>();
list.add(cbSummaryActualListVo);
return list;
}else {
} else {
//递归列表
childrenList = getProjectSumList(bo);
CbSummaryActualListVo cbSummaryActualListVo = baseMapper.getById(bo.getId(),bo.getExpenseDate());
cbSummaryActualListVo.setChildren(childrenList);
List<CbSummaryActualListVo> list = new ArrayList<>();
......@@ -133,7 +143,7 @@ public class CbSummaryServiceImpl extends ServiceImpl<CbSummaryMapper, CbSummary
}
/**
* 成本汇总列表
* 成本汇总递归列表
*
* @param bo
* @return
......@@ -146,6 +156,10 @@ public class CbSummaryServiceImpl extends ServiceImpl<CbSummaryMapper, CbSummary
childBo.setId(children.getId());
childBo.setExpenseDate(bo.getExpenseDate());
children.setChildren(getProjectSumList(childBo));
//截至本月费用汇总
Map<String, BigDecimal> total = cbSummaryActualMapper.getTotal(children.getId(), bo.getExpenseDate());
children.setTaxExclusiveExpenseTotal(total.get("taxExclusiveExpenseTotal"));
children.setTaxInclusiveExpenseTotal(total.get("taxInclusiveExpenseTotal"));
});
return childrenList;
......@@ -153,50 +167,142 @@ public class CbSummaryServiceImpl extends ServiceImpl<CbSummaryMapper, CbSummary
}
@Override
public List<String> getExpenseDateList(CbSummaryBo bo) {
Assert.notNull(bo.getProjectId(),"项目id不能为空");
Assert.notNull(bo.getCbStage(),"成本阶段不能为空");
Assert.notNull(bo.getCbType(),"成本类型不能为空");
public List<Map<String, Object>> getExpenseDateList(CbSummaryBo bo) {
Assert.notNull(bo.getProjectId(), "项目id不能为空");
// Assert.notNull(bo.getCbStage(),"成本阶段不能为空");
Assert.notNull(bo.getCbType(), "成本类型不能为空");
return baseMapper.getExpenseDateList(bo);
}
@Override
public List<String> getLockedList(CbSummaryBo bo) {
Assert.notNull(bo.getProjectId(), "项目id不能为空");
Assert.notNull(bo.getCbType(), "成本类型不能为空");
return cbSummaryActualLockMapper.getLockedList(bo);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean insertOrUpdateActual(List<CbSummaryActualBo> boList) {
if (CollectionUtil.isEmpty(boList)) {
return false;
}
boList.forEach(bo->{
Assert.notNull(bo.getCbSummaryId(),"成本汇总id不能为空");
Assert.notNull(bo.getExpenseDate(),"费用日期不能为空");
boList.forEach(bo -> {
Assert.notNull(bo.getCbSummaryId(), "成本汇总id不能为空");
Assert.notNull(bo.getExpenseDate(), "费用日期不能为空");
});
List<CbSummaryActual> actualList = BeanUtil.copyToList(boList, CbSummaryActual.class);
//todo
// throw new ServiceException("当前成本已锁定,不允许编辑!");
CbSummary cbSummary = baseMapper.selectById(boList.get(0).getCbSummaryId());
Assert.isFalse(ObjectUtil.isNull(cbSummary), "成本汇总数据不存在!");
String expenseDate = boList.get(0).getExpenseDate();
boolean exists = cbSummaryActualLockMapper.exists(
new LambdaQueryWrapper<CbSummaryActualLock>()
.eq(CbSummaryActualLock::getProjectId, cbSummary.getProjectId())
.eq(CbSummaryActualLock::getExpenseDate, expenseDate)
.eq(CbSummaryActualLock::getCbType, cbSummary.getCbType())
);
Assert.isFalse(exists, "该月成本已锁定");
List<CbSummaryActual> actualList = BeanUtil.copyToList(boList, CbSummaryActual.class);
return cbSummaryActualMapper.insertOrUpdateBatch(actualList) > 0;
}
@Override
public R getUnfilled(CbSummaryActualLockBo bo) {
Assert.notNull(bo.getCbType(), "成本类型不能为空");
Assert.notNull(bo.getProjectId(), "项目id不能为空");
Assert.notBlank(bo.getExpenseDate(), "费用日期不能为空");
StringBuilder unfilled = new StringBuilder();
//获取一级大类成本id
List<CbSummary> firstList = baseMapper.selectList(
new LambdaQueryWrapper<CbSummary>()
.eq(CbSummary::getProjectId, bo.getProjectId())
.eq(CbSummary::getLevel, 1)
.eq(CbSummary::getCbType, bo.getCbType())
.orderByAsc(CbSummary::getSort)
);
firstList.forEach(firstCb -> {
//获取大类下的所有子级id
List<CbSummary> allList = new ArrayList<>();
allList.add(firstCb);
allList.addAll(getAllChild(firstCb.getId(), new ArrayList<>()));
//根据子级id查询是否填写实际成本
List<CbSummaryActualListVo> vos = baseMapper.getByIds(allList, bo.getExpenseDate());
if (CollectionUtil.isEmpty(vos)) {
unfilled.append(firstCb.getCbName()).append("、");
}
});
if (unfilled.length() > 0) {
unfilled.deleteCharAt(unfilled.lastIndexOf("、"));
unfilled.append(" 未填写成本,是否继续锁定?");
return R.fail(unfilled.toString());
} else {
return R.ok();
}
}
private List<CbSummary> getAllChild(Long id, List<CbSummary> resultList) {
List<CbSummary> childList = baseMapper.selectList(
new LambdaQueryWrapper<CbSummary>()
.eq(CbSummary::getParentId, id)
);
if (CollectionUtil.isNotEmpty(childList)) {
resultList.addAll(childList);
childList.forEach(child -> {
getAllChild(child.getId(), resultList);
});
}
return resultList;
}
@Override
public boolean lockActual(CbSummaryActualLockBo bo) {
Assert.notNull(bo.getCbType(), "成本类型不能为空");
Assert.notNull(bo.getProjectId(), "项目id不能为空");
Assert.notBlank(bo.getExpenseDate(), "费用日期不能为空");
boolean exists = cbSummaryActualLockMapper.exists(
new LambdaQueryWrapper<CbSummaryActualLock>()
.eq(CbSummaryActualLock::getProjectId, bo.getProjectId())
.eq(CbSummaryActualLock::getExpenseDate, bo.getExpenseDate())
.eq(CbSummaryActualLock::getCbType, bo.getCbType())
);
Assert.isFalse(exists, "该月成本已锁定,请勿重复操作!");
CbSummaryActualLock lock = BeanUtil.copyProperties(bo, CbSummaryActualLock.class);
return cbSummaryActualLockMapper.insert(lock) > 0;
}
@Override
public List<CbSummaryActualListVo> getAll(CbSummaryActualListBo bo) {
Assert.notNull(bo.getId(), "项目id不能为空");
Assert.notNull(bo.getProjectId(), "项目id不能为空");
Assert.notNull(bo.getCbType(), "成本类型不能为空");
Assert.notNull(bo.getExpenseDate(), "费用日期不能为空");
//获取项目成本阶段
CbProjectRecord cbProjectRecord = cbProjectRecordMapper.selectById(bo.getId());
CbProjectRecord cbProjectRecord = cbProjectRecordMapper.selectById(bo.getProjectId());
if (ObjectUtil.isNull(cbProjectRecord)) {
throw new ServiceException("当前项目不存在");
}
bo.setCbStage(cbProjectRecord.getCbStage());
// bo.setCbStage(cbProjectRecord.getCbStage());
List<CbSummaryActualListVo> resultList = new ArrayList<>();
if (bo.getCbType() == 1) {
return baseMapper.getProjectAll(bo);
resultList = baseMapper.getProjectAll(bo);
} else {
return baseMapper.getCostAccountAll(bo);
resultList = baseMapper.getCostAccountAll(bo);
}
//todo 截至本月费用汇总
//截至本月费用汇总
resultList.forEach(cbSummaryActualListVo -> {
Map<String, BigDecimal> total = cbSummaryActualMapper.getTotal(cbSummaryActualListVo.getId(), bo.getExpenseDate());
cbSummaryActualListVo.setTaxExclusiveExpenseTotal(total.get("taxExclusiveExpenseTotal"));
cbSummaryActualListVo.setTaxInclusiveExpenseTotal(total.get("taxInclusiveExpenseTotal"));
});
return resultList;
}
}
<?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.dsk.cscec.mapper.CbSummaryActualLockMapper">
<resultMap type="com.dsk.cscec.domain.CbSummaryActualLock" id="CbSummaryActualLockMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="projectId" column="project_id" jdbcType="INTEGER"/>
<result property="expenseDate" column="expense_date" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="delFlag" column="del_flag" jdbcType="INTEGER"/>
</resultMap>
<sql id="baseColumn">
id, project_id, expense_date, create_time, del_flag
</sql>
<select id="getLockedList" resultType="java.lang.String">
select csal.expense_date
from cb_summary_actual_lock csal
where
csal.project_id = #{bo.projectId}
and csal.cb_type = #{bo.cbType}
and csal.del_flag = 0
order by csal.expense_date desc
</select>
</mapper>
......@@ -8,13 +8,13 @@
<result property="taxInclusiveExpense" column="tax_inclusive_expense" jdbcType="NUMERIC"/>
<result property="taxExclusiveExpense" column="tax_exclusive_expense" jdbcType="NUMERIC"/>
<result property="expenseDate" column="expense_date" jdbcType="VARCHAR"/>
<result property="lockStatus" column="lock_status" jdbcType="INTEGER"/>
<!-- <result property="lockStatus" column="lock_status" jdbcType="INTEGER"/>-->
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="delFlag" column="del_flag" jdbcType="INTEGER"/>
</resultMap>
<sql id="baseColumn">
id, cb_summary_id, tax_inclusive_expense, tax_exclusive_expense, expense_date, lock_status, create_time, del_flag
id, cb_summary_id, tax_inclusive_expense, tax_exclusive_expense, expense_date, create_time, del_flag
</sql>
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
......@@ -27,5 +27,16 @@
cb_summary_id = values(cb_summary_id) , tax_inclusive_expense = values(tax_inclusive_expense) ,
tax_exclusive_expense = values(tax_exclusive_expense) , expense_date = values(expense_date)
</insert>
<select id="getTotal" resultType="map">
select ifnull(sum(csa.tax_inclusive_expense),0) taxInclusiveExpenseTotal,
ifnull(sum(csa.tax_exclusive_expense),0) taxExclusiveExpenseTotal
from cb_summary_actual csa
<where>
csa.cb_summary_id = #{cbSummaryId}
and csa.expense_date &lt;= #{expenseDate}
and csa.del_flag = 0
</where>
</select>
</mapper>
......@@ -50,15 +50,32 @@
</where>
</select>
<select id="getByIds" resultType="com.dsk.cscec.domain.vo.CbSummaryActualListVo">
select csu.*,csa.id actualId,csa.tax_inclusive_expense,csa.tax_exclusive_expense,csa.expense_date
from cb_summary csu
left join cb_summary_actual csa on csu.id = csa.cb_summary_id
<where>
csa.expense_date = #{expenseDate}
and csa.del_flag = 0
and csu.del_flag = 0
and csu.id in
<foreach collection="entities" item="entity" separator="," open="(" close=")">
#{entity.id}
</foreach>
</where>
</select>
<select id="getProjectAll" resultType="com.dsk.cscec.domain.vo.CbSummaryActualListVo">
select
<include refid="baseColumn"></include>,
csa.tax_inclusive_expense,csa.tax_exclusive_expense
csa.id actualId,csa.tax_inclusive_expense,csa.tax_exclusive_expense
from cb_summary csu
left join cb_summary_actual csa on csu.id = csa.cb_summary_id and csa.expense_date = #{expenseDate} AND csa.del_flag = 0
left join cb_summary_actual csa on csu.id = csa.cb_summary_id and csa.expense_date = #{bo.expenseDate} AND csa.del_flag = 0
<where>
csu.project_id = #{bo.id}
and csu.cb_stage = #{bo.cbStage}
csu.project_id = #{bo.projectId}
<if test="bo.cbStage != null">
and csu.cb_stage = #{bo.cbStage}
</if>
and csu.cb_type = #{bo.cbType}
and csu.del_flag = 0
and csu.level != 0
......@@ -69,30 +86,33 @@
<select id="getCostAccountAll" resultType="com.dsk.cscec.domain.vo.CbSummaryActualListVo">
select
<include refid="baseColumn"></include>,
csa.tax_inclusive_expense,csa.tax_exclusive_expense
csa.id actualId,csa.tax_inclusive_expense,csa.tax_exclusive_expense
from cb_summary csu
left join cb_summary_actual csa on csu.id = csa.cb_summary_id and csa.expense_date = #{expenseDate} AND csa.del_flag = 0
left join cb_summary_actual csa on csu.id = csa.cb_summary_id and csa.expense_date = #{bo.expenseDate} AND csa.del_flag = 0
<where>
csu.project_id = #{bo.projectId}
and csu.cb_stage = #{bo.cbStage}
<if test="bo.cbStage != null">
and csu.cb_stage = #{bo.cbStage}
</if>
and csu.cb_type = #{bo.cbType}
and csu.del_flag = 0
</where>
order by csu.sort
</select>
<select id="getExpenseDateList" resultType="string">
select csa.expense_date
<select id="getExpenseDateList" resultType="map">
select csa.expense_date expenseDate,
if(csal.id is null,0,1) as isLock
from cb_summary_actual csa
left join cb_summary csu on csu.id = csa.cb_summary_id
left join cb_summary_actual_lock csal on csal.project_id = csu.project_id and csal.expense_date = csa.expense_date and csal.del_flag = 0
where
csu.project_id = #{bo.projectId}
and csu.cb_stage = #{bo.cbStage}
and csu.cb_type = #{bo.cbType}
and csu.del_flag = 0
and csa.del_flag = 0
group by csa.expense_date
order by csa.expense_date asc
order by csa.expense_date desc
</select>
<select id="selectByLevel" resultType="map">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment