更新统计相关内容

This commit is contained in:
xuyuncong 2025-11-03 18:00:42 +08:00
parent b0fd8b7896
commit b938f36e9d
3 changed files with 95 additions and 5 deletions

View File

@ -264,4 +264,15 @@ public interface RepairStatisticsMapper {
Map<String, Object> calculateAmountStatsByWorkType(@Param("startDate") String startDate,
@Param("endDate") String endDate,
@Param("workType") String workType);
/**
* 根据工种类型获取工单结算统计数据
* @param startDate 开始日期
* @param endDate 结束日期
* @param workType 工种类型
* @return 结算统计数据列表
*/
List<Map<String, Object>> selectSumAmountByWorkType(@Param("startDate") String startDate,
@Param("endDate") String endDate,
@Param("workType") String workType);
}

View File

@ -14,6 +14,7 @@ import cn.iocoder.yudao.module.tickets.entity.DlRepairTickets;
import cn.iocoder.yudao.module.tickets.service.DlRepairTicketsService;
import cn.iocoder.yudao.module.tickets.vo.DlRepairTicketsRespVO;
import cn.iocoder.yudao.util.StringUtils;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@ -22,8 +23,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import cn.iocoder.yudao.module.tickets.vo.TicketsSettlementVO;
import cn.hutool.core.util.ObjectUtil;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@ -43,6 +47,9 @@ public class RepairStatisticsServiceImpl implements RepairStatisticsService {
@Resource
private RepairStatisticsMapper statisticsMapper;
@Resource
private cn.iocoder.yudao.module.tickets.mapper.DlRepairTicketsMapper repairTicketsMapper;
@Resource
private DlRepairTicketsService ticketsService;
@ -70,6 +77,64 @@ public class RepairStatisticsServiceImpl implements RepairStatisticsService {
return resultMap;
}
/**
* 按工种类型统计金额信息已收款未收款待收款
*/
private Map<String, Object> calculateAmountStatsByWorkType(String startDate, String endDate, String workType) {
Map<String, Object> amountMap = new HashMap<>();
// 调用我们新创建的selectSumAmountByWorkType方法获取数据
List<Map<String, Object>> receivables = statisticsMapper.selectSumAmountByWorkType(startDate, endDate, workType);
BigDecimal receivableAmount = BigDecimal.ZERO;
Integer receivableCount = 0;
BigDecimal receivedAmount = BigDecimal.ZERO;
Integer receivedCount = 0;
for (Map<String, Object> receivable : receivables) {
// 转换为TicketsSettlementVO
Object otherData = receivable.get("otherData");
if (ObjectUtil.isNull(otherData)) {
continue;
}
TicketsSettlementVO settlement = JSONObject.parseObject(
otherData.toString(), TicketsSettlementVO.class
);
//计算实付金额的总和
BigDecimal actualMoney = settlement.getActualMoney();
if (actualMoney == null) {
continue;
}
receivableAmount = receivableAmount.add(actualMoney);
receivableCount++;
//判断是否是已经确认收款的
Object payType = receivable.get("payType");
if (payType != null && "03".equals(payType.toString())) {
// 计算已收款金额
BigDecimal isConfirmedReceive = settlement.getActualMoney();
receivedAmount = receivedAmount.add(isConfirmedReceive);
receivedCount++;
}
}
amountMap.put("receivableAmount", receivableAmount != null ? receivableAmount : BigDecimal.ZERO);
amountMap.put("receivableCount", receivableCount);
// 已收款应收款里面出纳确认收款的金额
amountMap.put("receivedAmount", receivedAmount != null ? receivedAmount : BigDecimal.ZERO);
amountMap.put("receivedCount", receivedCount);
// 待收款应收 - 已收
BigDecimal receivable = (BigDecimal) amountMap.get("receivableAmount");
BigDecimal received = (BigDecimal) amountMap.get("receivedAmount");
BigDecimal pendingAmount = receivable.subtract(received);
amountMap.put("pendingAmount", pendingAmount);
amountMap.put("pendingCount", receivableCount - receivedCount);
return amountMap;
}
/**
* 客户来源分析饼图
*
@ -545,10 +610,11 @@ public class RepairStatisticsServiceImpl implements RepairStatisticsService {
// 添加到结果map
resultMap.put("stats", statsList);
// 统计金额信息
Map<String, Object> amountStats = statisticsMapper.calculateAmountStatsByWorkType(startDate, endDate, workType);
if (amountStats != null)
resultMap.putAll(amountStats);
// 统计金额信息已收款未收款待收款
Map<String, Object> amountStats = calculateAmountStatsByWorkType(startDate, endDate, workType);
if (amountStats != null) {
resultMap.putAll(amountStats);
}
return resultMap;
}

View File

@ -624,4 +624,17 @@
</if>
GROUP BY drw.work_type
</select>
<select id="selectSumAmountByWorkType" resultType="java.util.Map">
select drr.other_data as otherData, drt.pay_status as payType
FROM dl_repair_tickets drt
JOIN dl_repair_records drr ON drt.id = drr.ticket_id
JOIN dl_repair_titem dri ON drt.id = dri.ticket_id
JOIN dl_repair_worker drw ON FIND_IN_SET(drw.user_id, dri.repair_ids) > 0
WHERE drt.deleted = 0 and drr.deleted = 0 and drr.type = 'jssp' and drt.pay_status != '04'
AND drw.work_type = #{workType}
<if test="startDate != null and endDate != null">
AND drt.create_time BETWEEN CONCAT(#{startDate}, ' 00:00:00') AND CONCAT(#{endDate}, ' 23:59:59')
</if>
</select>
</mapper>