成本分析查询所有项目成本接口初步修改

This commit is contained in:
liuzongkun999
2025-03-06 20:46:01 +08:00
parent c70a3de1ca
commit c31f440510
7 changed files with 53 additions and 20 deletions

View File

@@ -29,15 +29,15 @@ public class SysOaCostAllVo {
private Long materialId;
private Object materialVo;
private Object materialCost;
private Long userId;
private Object userVo;
private Object userCost;
private Long claimId;
private Object claimVo;
private Object claimCost;
private Long financeId;

View File

@@ -32,4 +32,10 @@ public interface SysOaAttendanceMapper extends BaseMapperPlus<SysOaAttendanceMap
@Param("startTime") Date startTime,
@Param("endTime") Date endTime);
/**
* 计算人天数
*/
Double getAttendanceDay(@Param("userId") Long userId,
@Param("projectId") Long projectId );
}

View File

@@ -23,4 +23,6 @@ public interface SysOaClaimMapper extends BaseMapperPlus<SysOaClaimMapper, SysOa
Page<SysOaClaimVo> selectPageVo(Page<Object> build, @Param(Constants.WRAPPER) Wrapper<SysOaClaim> lqw);
SysOaClaimVo selectSysOaClaimVoByProcInsId(String procInsId);
Double getClaimCost(Long claimId);
}

View File

@@ -9,6 +9,7 @@ import com.ruoyi.common.core.domain.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.oa.domain.SysOaAttendance;
import com.ruoyi.oa.domain.SysOaProject;
import com.ruoyi.oa.domain.vo.*;
import com.ruoyi.oa.mapper.*;
@@ -42,6 +43,8 @@ public class SysOaCostServiceImpl implements ISysOaCostService {
private final SysOaWarehouseMapper warehouseMapper;
private final SysOaAttendanceMapper attendanceMapper;
/**
* 查询项目成本分析
@@ -134,29 +137,39 @@ public class SysOaCostServiceImpl implements ISysOaCostService {
*/
@Override
public TableDataInfo<SysOaCostAllVo> AllList(String projectName, String createTime) {
public TableDataInfo<SysOaCostAllVo> AllList(String projectName, String createTime) { // 包括每个项目的成本分析,每个都有这几种类型,即每个项目返回几列数据
List<SysOaCostAll> alls = baseMapper.AllList(projectName,createTime);
log.info("alls:{}",alls);
List<SysOaCostAllVo> allVos = new java.util.ArrayList<>(Collections.emptyList());
if (alls.isEmpty()) return TableDataInfo.build(allVos);
for (SysOaCostAll all : alls) {
SysOaCostAllVo allVo = BeanUtil.toBean(all, SysOaCostAllVo.class);
log.info("allVo:{}", allVo);
// 车间用工
if (allVo.getCostType() == 1) {
allVo.setUserVo(userMapper.selectUserById(allVo.getUserId()));
} else if (allVo.getCostType() == 2) { // 差旅花费
allVo.setClaimVo(claimMapper.selectSysOaClaimVoById(allVo.getClaimId()));
if (allVo.getCostType() == null) allVo.setCost(0.0);
// 车间用工
else {if (allVo.getCostType() == 1) { //根据出勤,计算人天数
Double days = attendanceMapper.getAttendanceDay(allVo.getUserId(), allVo.getProjectId());
Long laborCost = userMapper.selectUserById(allVo.getUserId()).getLaborCost();
if (days == null || laborCost == null) allVo.setUserCost(0.0);
else allVo.setUserCost(days * laborCost);
} else if (allVo.getCostType() == 2) { // 差旅花费 差旅花费 = 该项目下的所有差旅费用
allVo.setClaimCost(claimMapper.getClaimCost(allVo.getClaimId()));
} else if (allVo.getCostType() == 3) { // 库房物料
allVo.setMaterialVo(warehouseMapper.selectVoById(allVo.getMaterialId()));
} else if (allVo.getCostType() == 3) { // 库房物料 物料花费 =物料价格*数量
SysOaWarehouseVo warehouseVo = warehouseMapper.selectVoById(allVo.getMaterialId());
if (warehouseVo == null) allVo.setMaterialCost(0.0);
else allVo.setMaterialCost(warehouseVo.getInventory() * warehouseVo.getPrice());
} else if (allVo.getCostType() == 4) { // 其他
} else if (allVo.getCostType() == 5) { // 接待
}
}}
// 往vos里面加
allVos.add(allVo);
}
return TableDataInfo.build(allVos);
@@ -167,12 +180,12 @@ public class SysOaCostServiceImpl implements ISysOaCostService {
*/
@Override
public TableDataInfo<SysOaCostRow> getDetail(Long projectId) {
log.info("查询projectId = {}", projectId);
// log.info("查询projectId = {}", projectId);
// LambdaQueryWrapper<SysOaCost> lqw = Wrappers.lambdaQuery(SysOaCost.class);
// lqw.eq(SysOaCost::getProjectId,projectId);
// List<SysOaCost> costs = baseMapper.selectList(lqw);
List<SysOaCost> costs = baseMapper.getListByProjectId(projectId);
log.info("查询costs = {}", costs);
// log.info("查询costs = {}", costs);
if (costs.isEmpty()) {
return TableDataInfo.build();
@@ -188,15 +201,15 @@ public class SysOaCostServiceImpl implements ISysOaCostService {
log.info("sysOaCostList = {}", sysOaCostList);
if(cost.getCostType() == 1) {
log.info("查询useVo = {}", userMapper.selectUserById(cost.getUserId()));
// log.info("查询useVo = {}", userMapper.selectUserById(cost.getUserId()));
sysOaCostList.setUserVo(userMapper.selectUserById(cost.getUserId()));
sysOaCostRow.getUserCostList().add(sysOaCostList);
} else if(cost.getCostType() == 2) {
log.info("查询claimMapperVo = {}", claimMapper.selectSysOaClaimVoById(cost.getClaimId()));
// log.info("查询claimMapperVo = {}", claimMapper.selectSysOaClaimVoById(cost.getClaimId()));
sysOaCostList.setClaimVo(claimMapper.selectSysOaClaimVoById(cost.getClaimId()));
sysOaCostRow.getClaimList().add(sysOaCostList);
} else if(cost.getCostType() == 3) {
log.info("查询warehouseMapperVo = {}",warehouseMapper.selectVoById(cost.getMaterialId()));
// log.info("查询warehouseMapperVo = {}",warehouseMapper.selectVoById(cost.getMaterialId()));
sysOaCostList.setMaterialVo(warehouseMapper.selectVoById(cost.getMaterialId()));
sysOaCostRow.getMaterialList().add(sysOaCostList);
} else{
@@ -204,7 +217,7 @@ public class SysOaCostServiceImpl implements ISysOaCostService {
}
}
log.info("sysOaCostRow = {}", sysOaCostRow);
// log.info("sysOaCostRow = {}", sysOaCostRow);
List<SysOaCostRow> rows = new java.util.ArrayList<>(Collections.singletonList(sysOaCostRow));
return TableDataInfo.build(rows);