三期差了一个接口

This commit is contained in:
2025-03-10 21:02:00 +08:00
parent 038cf04f4c
commit 5379f60c45
11 changed files with 144 additions and 286 deletions

View File

@@ -99,22 +99,35 @@ public class SysOaCostController extends BaseController {
/**
// /**
// * 查询所有项目成本
// */
// @SaCheckPermission("oa:oaCost:list")
// @GetMapping("/list")
// public TableDataInfo<SysOaCostAllVo> AllList(@RequestParam(required = false) String projectName) {
// return iSysOaCostService.AllList(projectName);
// }
/**
* 查询所有项目成本
*/
@SaCheckPermission("oa:oaCost:list")
@GetMapping("/list")
public TableDataInfo<SysOaCostAllVo> AllList(@RequestParam(required = false) String projectName, @RequestParam(required = false)String createTime) {
return iSysOaCostService.AllList(projectName, createTime);
public TableDataInfo<SysOaCostAllVo> AllList(SysOaCostBo bo,PageQuery pageQuery) {
return iSysOaCostService.calcProjectCostList(bo,pageQuery);
}
/**
* 查询详情
*/
@SaCheckPermission("oa:oaCost:query")
@GetMapping("/{projectId}")
public TableDataInfo<SysOaCostRow> getDetail(@NotNull(message = "项目id不能为空")
public R<SysOaCostRow> getDetail(@NotNull(message = "项目id不能为空")
@PathVariable Long projectId) {
return iSysOaCostService.getDetail(projectId);
return R.ok(iSysOaCostService.getDetail(projectId));
}
/**

View File

@@ -69,5 +69,10 @@ public class SysOaCostBo extends BaseEntity {
*/
private Long claimId;
/**
* 项目名称
*/
private String projectName;
}

View File

@@ -43,4 +43,6 @@ public class SysOaCostAllVo {
private Long financeId;
private Double peopleDay;
}

View File

@@ -14,7 +14,7 @@ public class SysOaCostList {
private Long userId;
private String nickName;
private Double laborCost;
private Double attendenceNum;
private Double attendanceNum;
/**
* materialList

View File

@@ -4,9 +4,12 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.oa.domain.SysOaOutWarehouse;
import com.ruoyi.oa.domain.SysOaProject;
import com.ruoyi.oa.domain.bo.SysOaProjectBo;
import com.ruoyi.oa.domain.vo.SysOaCostAllVo;
import com.ruoyi.oa.domain.vo.SysOaOutWarehouseListVo;
import com.ruoyi.oa.domain.vo.SysOaProjectVo;
import com.ruoyi.common.core.mapper.BaseMapperPlus;
@@ -31,4 +34,7 @@ public interface SysOaProjectMapper extends BaseMapperPlus<SysOaProjectMapper, S
List<SysOaProjectVo> getProjectDataByMonthAndDate(@Param("firstDay") Date firstDay, @Param("lastDay") Date lastDay);
Page<SysOaCostAllVo> selectListToCost(@Param("page") Page<SysOaProject> page,@Param(Constants.WRAPPER) QueryWrapper<SysOaProjectBo> queryWrapper);
}

View File

@@ -7,7 +7,6 @@ import com.ruoyi.oa.domain.bo.SysOaCostBo;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.domain.PageQuery;
import javax.validation.constraints.NotNull;
import java.util.Collection;
import java.util.List;
@@ -57,8 +56,16 @@ public interface ISysOaCostService {
/**
* 查询详情
*/
TableDataInfo<SysOaCostRow> getDetail(Long projectId);
SysOaCostRow getDetail(Long projectId);
/**
* 项目成本分析改进
*
* @param bo
* @param pageQuery
* @return
*/
TableDataInfo<SysOaCostAllVo> calcProjectCostList(SysOaCostBo bo, PageQuery pageQuery);
}

View File

@@ -11,6 +11,7 @@ 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.*;
import com.ruoyi.oa.domain.bo.SysOaProjectBo;
import com.ruoyi.oa.domain.vo.*;
import com.ruoyi.oa.mapper.*;
import com.ruoyi.system.mapper.SysUserMapper;
@@ -24,7 +25,6 @@ import java.math.BigDecimal;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 项目成本分析Service业务层处理
@@ -143,13 +143,11 @@ public class SysOaCostServiceImpl implements ISysOaCostService {
@Override
public TableDataInfo<SysOaCostAllVo> AllList(String projectName, String createTime) {
log.info("查询所有项目对应的/物料费用/工资费用/差旅费用//其他费用");
LambdaQueryWrapper<SysOaProject> lqw = Wrappers.lambdaQuery(SysOaProject.class);
if (StringUtils.isNotBlank(projectName)) {
lqw.like(SysOaProject::getProjectName, projectName);
}
List<SysOaProject> projects = projectMapper.selectList(lqw);
log.info(" 查询projects: {}", projects);
if (projects.isEmpty()) {
return TableDataInfo.build();
}
@@ -159,22 +157,16 @@ public class SysOaCostServiceImpl implements ISysOaCostService {
SysOaCostAllVo sysOaCostAllVo = new SysOaCostAllVo();
Long projectId = project.getProjectId();
sysOaCostAllVo.setProjectId(projectId);
sysOaCostAllVo.setProjectName(project.getProjectName());
// 2、 查询所有项目对应的物料
List<SysOaOutWarehouse> outWarehouses = outWarehouseMapper.List(projectId);
Double materialCost = 0.0;
if (!outWarehouses.isEmpty()) {
Map<Long, SysOaWarehouse> warehouseMap = warehouseMapper.selectList(Wrappers.lambdaQuery(SysOaWarehouse.class)).stream().collect(Collectors.toMap(SysOaWarehouse::getId, Function.identity()));
log.info("查询所有项目对应的物料:{}",warehouseMap);
materialCost = outWarehouses.stream().map(v -> {
Long warehouseId = v.getWarehouseId();
BigDecimal amount = BigDecimal.valueOf(v.getAmount());
SysOaWarehouse warehouse = warehouseMap.get(warehouseId);
if (warehouse == null) {
log.error("仓库信息不存在仓库ID: " + warehouseId);
return BigDecimal.ZERO;
}
BigDecimal price = BigDecimal.valueOf(warehouse.getPrice());
@@ -182,7 +174,6 @@ public class SysOaCostServiceImpl implements ISysOaCostService {
}).reduce(BigDecimal.ZERO, BigDecimal::add).doubleValue();
}
sysOaCostAllVo.setMaterialCost(materialCost);
// 3、 查询所有项目对应的工资费用
LambdaQueryWrapper<SysOaAttendance> lqw2 = Wrappers.lambdaQuery(SysOaAttendance.class);
lqw2.eq(SysOaAttendance::getProjectId, projectId);
@@ -196,7 +187,7 @@ public class SysOaCostServiceImpl implements ISysOaCostService {
double attendanceDay = Optional.ofNullable(attendance.getAttendanceDay()).orElse(0L);
double dayLength = Optional.ofNullable(attendance.getDayLength()).orElse(0.0);
double hour = Optional.ofNullable(attendance.getHour()).orElse(0.0);
return attendanceDay * dayLength * 9 + hour;
return (attendanceDay * dayLength * 9 + hour)/9;
})
));
// 获取user表中的劳务费用
@@ -207,7 +198,6 @@ public class SysOaCostServiceImpl implements ISysOaCostService {
Long userId = v.getUserId();
SysUser user = userMap.get(userId);
if (user == null) {
log.warn("用户ID信息不存在用户ID: {}", userId);
return BigDecimal.ZERO;
}
Long laborCost = Optional.ofNullable(user.getLaborCost()).orElse(0L);
@@ -218,9 +208,7 @@ public class SysOaCostServiceImpl implements ISysOaCostService {
}).reduce(BigDecimal.ZERO, BigDecimal::add).doubleValue();
}
sysOaCostAllVo.setUserCost(userCost);
// 4、 查询所有项目对应的差旅费用
List<SysOaClaim> claims = claimMapper.List(projectId);
Double claimCost = 0.0;
if (!claims.isEmpty()) {
@@ -232,12 +220,7 @@ public class SysOaCostServiceImpl implements ISysOaCostService {
sysOaCostAllVo.setCost(materialCost + userCost + claimCost);
// 6、 将 sysOaCostAllVo 添加到 sysOaCostAllVos 中
sysOaCostAllVos.add(sysOaCostAllVo);
log.info("查询项目对应的费用信息:{}", sysOaCostAllVo);
if (sysOaCostAllVo.getProjectId() == 1862663507129614338L) {
log.info("查询项目对应的费用信息:{}", sysOaCostAllVo);
}
}
log.info("查询所有项目对应的费用信息:{}", sysOaCostAllVos);
return TableDataInfo.build(sysOaCostAllVos);
}
@@ -246,7 +229,7 @@ public class SysOaCostServiceImpl implements ISysOaCostService {
* 查询详情
*/
@Override
public TableDataInfo<SysOaCostRow> getDetail(Long projectId) {
public SysOaCostRow getDetail(Long projectId) {
SysOaCostRow sysOaCostRow = new SysOaCostRow();
List<SysOaCostList> UserCostList = new ArrayList<>();
@@ -293,7 +276,7 @@ public class SysOaCostServiceImpl implements ISysOaCostService {
sysOaCostList.setUserId(userId);
sysOaCostList.setNickName(user.getNickName());
sysOaCostList.setLaborCost(laborCost * dayNum);
sysOaCostList.setAttendenceNum(dayNum);
sysOaCostList.setAttendanceNum(dayNum);
UserCostList.add(sysOaCostList);
}
@@ -324,7 +307,6 @@ public class SysOaCostServiceImpl implements ISysOaCostService {
lqw2.eq(SysOaClaim::getProjectId, projectId);
List<SysOaClaimVo> claims = claimMapper.selectVoList(lqw2);
Map<Long, SysOaClaimVo> claimMap = claims.stream().collect(Collectors.toMap(SysOaClaimVo::getClaimId, Function.identity()));
log.info("查询项目对应的差旅详情:{}", claims);
Set<Long> claimIds = claimMap.keySet();
if (!claims.isEmpty()) {
for (Long claimId : claimIds) {
@@ -337,15 +319,22 @@ public class SysOaCostServiceImpl implements ISysOaCostService {
ClaimList.add(sysOaCostList);
}
}
sysOaCostRow.setUserCostList(UserCostList);
sysOaCostRow.setMaterialList(MaterialList);
sysOaCostRow.setClaimList(ClaimList);
sysOaCostRow.setOtherList(OtherList);
List<SysOaCostRow> rows = new java.util.ArrayList<>(Collections.singletonList(sysOaCostRow));
return TableDataInfo.build(rows);
return sysOaCostRow;
}
@Override
public TableDataInfo<SysOaCostAllVo> calcProjectCostList(SysOaCostBo bo, PageQuery pageQuery) {
// 查询所有的项目拿到项目之后分别计算他们的各种成本联查四表
QueryWrapper<SysOaProjectBo> queryWrapper = new QueryWrapper<>();
queryWrapper.like(bo.getProjectName()!=null,"sop.project_name", bo.getProjectName());
queryWrapper.orderByDesc("sop.create_time");
Page<SysOaCostAllVo> sysOaCostAllVos = projectMapper.selectListToCost(pageQuery.build(),queryWrapper);
// 查询user laborCost 查attendance 拿签到
return TableDataInfo.build(sysOaCostAllVos);
}
}