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

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 Long materialId;
private Object materialVo; private Object materialCost;
private Long userId; private Long userId;
private Object userVo; private Object userCost;
private Long claimId; private Long claimId;
private Object claimVo; private Object claimCost;
private Long financeId; private Long financeId;

View File

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

View File

@@ -151,6 +151,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND attendance_day = #{attendanceDay} AND attendance_day = #{attendanceDay}
</select> </select>
<delete id="delOaAttendanceAll"> <delete id="delOaAttendanceAll">
delete from sys_oa_attendance where delete from sys_oa_attendance where
attendance_day = #{day} attendance_day = #{day}
@@ -158,4 +159,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and create_time > #{firstDay} and create_time > #{firstDay}
</delete> </delete>
<select id="getAttendanceDay" resultType="java.lang.Double">
select sum(day_length)
from sys_oa_attendance
where user_id = #{userId} and project_id = #{projectId} and del_flag = '0'
</select>
</mapper> </mapper>

View File

@@ -168,6 +168,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join sys_oa_project sop on soc.project_id = sop.project_id left join sys_oa_project sop on soc.project_id = sop.project_id
where soc.proc_ins_id = #{procInsId} where soc.proc_ins_id = #{procInsId}
</select> </select>
<select id="getClaimCost" resultType="java.lang.Double">
SELECT SUM(cost) FROM sys_oa_claim WHERE claim_id = #{claimId} and del_flag = '0'
</select>
</mapper> </mapper>