This commit is contained in:
xuyuncong 2025-10-24 17:02:37 +08:00
parent 80aa8fd246
commit 6c05b30c1c
12 changed files with 133 additions and 19 deletions

View File

@ -171,4 +171,16 @@ public class RepairStatisticsController {
return CommonResult.success(statisticsService.pageByCustomerOrCar(reqVO,page));
}
/**
* @description :员工统计
* @author xyc
* @date 16:40 2025/10/23
* @param reqVO {@link QueryBusinessReqVO}
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
**/
@GetMapping("/staffStatistics")
public CommonResult<?> staffStatistics(QueryBusinessReqVO reqVO) {
return CommonResult.success(statisticsService.staffStatistics(reqVO));
}
}

View File

@ -0,0 +1,33 @@
package cn.iocoder.yudao.module.base.entity;
import lombok.Data;
import java.math.BigDecimal;
/**
* @ClassName StaffStatisticsResp
* @Description : 员工统计返回
* @Author
* @Date 2025/10/23 16:42
* @Version 1.0.0
*/
@Data
public class StaffStatisticsResp {
/** 用户id*/
private Long userId;
/** 用户名称 */
private String nickname;
/** 工单数量 */
private Long totalTasks;
/** 工单金额 */
private BigDecimal totalMoney;
/** 工单利润 */
private BigDecimal totalProfit;
/** 工单利润率 */
private BigDecimal totalProfitRate;
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.base.mapper;
import cn.iocoder.yudao.module.base.entity.StaffStatisticsResp;
import cn.iocoder.yudao.module.base.vo.*;
import cn.iocoder.yudao.module.tickets.vo.DlRepairTicketsRespVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -124,4 +125,13 @@ public interface RepairStatisticsMapper {
* @return com.baomidou.mybatisplus.core.metadata.IPage<cn.iocoder.yudao.module.base.vo.QueryTableResp>
**/
IPage<QueryTableResp> pageByCustomerOrCar(@Param("reqVO") QueryBusinessReqVO reqVO,@Param("page") Page<QueryTableResp> page);
/**
* @description : 员工统计
* @author xyc
* @date 16:45 2025/10/23
* @param reqVO {@link QueryBusinessReqVO}
* @return java.util.List<cn.iocoder.yudao.module.base.entity.StaffStatisticsResp>
**/
List<StaffStatisticsResp> staffStatistics(QueryBusinessReqVO reqVO);
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.base.service;
import cn.iocoder.yudao.module.base.entity.StaffStatisticsResp;
import cn.iocoder.yudao.module.base.vo.*;
import cn.iocoder.yudao.module.tickets.vo.DlRepairTicketsRespVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -100,4 +101,13 @@ public interface RepairStatisticsService {
* @return com.baomidou.mybatisplus.core.metadata.IPage<cn.iocoder.yudao.module.base.vo.QueryTableResp>
**/
IPage<QueryTableResp> pageByCustomerOrCar(QueryBusinessReqVO reqVO, Page<QueryTableResp> page);
/**
* @description : 员工统计
* @author xyc
* @date 16:44 2025/10/23
* @param reqVO {@link QueryBusinessReqVO}
* @return java.util.List<cn.iocoder.yudao.module.base.entity.StaffStatisticsResp>
**/
List<StaffStatisticsResp> staffStatistics(QueryBusinessReqVO reqVO);
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.base.service.impl;
import cn.iocoder.yudao.module.base.entity.StaffStatisticsResp;
import cn.iocoder.yudao.module.base.mapper.RepairStatisticsMapper;
import cn.iocoder.yudao.module.base.service.RepairStatisticsService;
import cn.iocoder.yudao.module.base.vo.*;
@ -10,10 +11,7 @@ import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -161,4 +159,17 @@ public class RepairStatisticsServiceImpl implements RepairStatisticsService {
IPage<QueryTableResp> queryTableResps = statisticsMapper.pageByCustomerOrCar(reqVO,page);
return queryTableResps;
}
/**
* @param reqVO {@link QueryBusinessReqVO}
* @return java.util.List<cn.iocoder.yudao.module.base.entity.StaffStatisticsResp>
* @description : 员工统计
* @author xyc
* @date 16:44 2025/10/23
**/
@Override
public List<StaffStatisticsResp> staffStatistics(QueryBusinessReqVO reqVO) {
List<StaffStatisticsResp> staffStatisticsResps = statisticsMapper.staffStatistics(reqVO);
return staffStatisticsResps;
}
}

View File

@ -11,6 +11,7 @@ import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
/**
* 针对表dl_repair_so(采购单领料单)的数据库操作Mapper
@ -29,7 +30,7 @@ public interface DlRepairSoMapper extends BaseMapper<DlRepairSo> {
* @param repairSoReqVO 查询条件
* @return 采购总金额
**/
BigDecimal getPurchaseAmount(DlRepairSoReqVO repairSoReqVO);
Map<String, Object> getPurchaseAmount(DlRepairSoReqVO repairSoReqVO);
/**
* 根据条件查询指定数量待确认的领料单 待确认的退料单
@ -50,14 +51,14 @@ public interface DlRepairSoMapper extends BaseMapper<DlRepairSo> {
* @return java.util.List<cn.iocoder.yudao.module.tickets.vo.AppWaresGroupVO>
**/
List<DlRepairSoiRespVO> selectByIdGroup(@Param("id")String id);
/**
* 根据ID查询主表及子表数据
* @param id 主表ID
* @return DlRepairSo 主表及子表数据
*/
DlRepairSo selectWithItemsById(@Param("id") String id);
/**
* 分页查询主表及子表数据
* @param repairSoReqVO 查询条件
@ -65,4 +66,4 @@ public interface DlRepairSoMapper extends BaseMapper<DlRepairSo> {
* @return IPage<DlRepairSo> 分页结果
*/
IPage<DlRepairSo> getRepairSoPageWithItems(@Param("map") DlRepairSoReqVO repairSoReqVO, Page<DlRepairSo> page);
}
}

View File

@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import java.math.BigDecimal;
import java.util.Map;
/**
* 针对表dl_repair_so(采购单领料单)的数据库操作Service
@ -34,7 +35,7 @@ public interface DlRepairSoService extends IService<DlRepairSo> {
* @date 18:14 2024/9/14
**/
IPage<DlRepairSo> getRepairSoPage(DlRepairSoReqVO repairSoReqVO, Page<DlRepairSo> page);
/**
* 采购单/领料单新增分页包含子表数据
*
@ -45,7 +46,7 @@ public interface DlRepairSoService extends IService<DlRepairSo> {
* @date 18:14 2024/9/14
**/
IPage<DlRepairSo> getRepairSoPageWithItems(DlRepairSoReqVO repairSoReqVO, Page<DlRepairSo> page);
/**
* 统计采购金额
*
@ -54,7 +55,7 @@ public interface DlRepairSoService extends IService<DlRepairSo> {
* @author 系统管理员
* @date 2024/12/10
**/
BigDecimal getPurchaseAmount(DlRepairSoReqVO repairSoReqVO);
Map<String, Object> getPurchaseAmount(DlRepairSoReqVO repairSoReqVO);
/**
* 采购单/领料单 作废

View File

@ -183,7 +183,7 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
public IPage<DlRepairSo> getRepairSoPage(DlRepairSoReqVO repairSoReqVO, Page<DlRepairSo> page) {
return baseMapper.getRepairSoPage(repairSoReqVO, page);
}
/**
* 采购单/领料单新增分页包含子表数据
* @param repairSoReqVO 查询对象
@ -198,7 +198,7 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
}
@Override
public BigDecimal getPurchaseAmount(DlRepairSoReqVO repairSoReqVO) {
public Map<String, Object> getPurchaseAmount(DlRepairSoReqVO repairSoReqVO) {
return dlRepairSoMapper.getPurchaseAmount(repairSoReqVO);
}

View File

@ -948,6 +948,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
// 进厂数所有在范围内创建的
Map<String, Long> newOrderStats = ticketsInRange.stream()
// .filter(item -> TicketsStatusEnum.NO_WORK.getCode().equals(item.getTicketsStatus()))
.collect(Collectors.groupingBy(DlRepairTickets::getRepairType, Collectors.counting()));
statsList.add(createStatsNode("newOrderNum", "订单(进厂数)", newOrderStats, "jinchang"));
@ -1694,7 +1695,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
statusList = Arrays.asList("04", "05", "07", "01", "06", "02");
} else if ("jinchang".equals(repairTicketsReqVO.getTicketsStatus())) {
//进厂
statusList.add(TicketsStatusEnum.NO_WORK.getCode());
// statusList.add(TicketsStatusEnum.NO_WORK.getCode());
} else if ("yijungong".equals(repairTicketsReqVO.getTicketsStatus())) {
//已竣工
statusList = Arrays.asList("07", "01", "06", "02", "08");
@ -2845,7 +2846,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
statusList = Arrays.asList("04", "05", "07", "01", "06", "02");
} else if ("jinchang".equals(repairTicketsReqVO.getTicketsStatus())) {
//进厂
statusList.add(TicketsStatusEnum.NO_WORK.getCode());
// statusList.add(TicketsStatusEnum.NO_WORK.getCode());
} else if ("yijungong".equals(repairTicketsReqVO.getTicketsStatus())) {
//已竣工
statusList = Arrays.asList("07", "01", "06", "02", "08");

View File

@ -219,4 +219,39 @@
AND drt.car_no LIKE CONCAT('%', #{reqVO.carNo}, '%')
</if>
</select>
<select id="staffStatistics" resultType="cn.iocoder.yudao.module.base.entity.StaffStatisticsResp"
parameterType="cn.iocoder.yudao.module.base.vo.QueryBusinessReqVO">
SELECT
su.id AS userId,
su.username,
su.nickname,
su.user_type,
su.dept_id,
su.mobile,
su.sex,
su.avatar,
COUNT(drt.id) AS totalTasks, -- 工单数量
SUM(drt.item_money) AS totalMoney, -- 总金额
SUM(drt.item_profit) AS totalProfit, -- 总毛利
AVG(IFNULL(drt.item_profit_rate, 0)) AS averageProfitRate -- 平均毛利率
FROM
system_users su
LEFT JOIN
dl_repair_titem drt ON FIND_IN_SET(su.id, drt.repair_ids) > 0 -- 匹配维修人员
INNER JOIN
system_user_role sr ON su.id = sr.user_id AND sr.deleted = 0
INNER JOIN
system_role sr2 ON sr.role_id = sr2.id
INNER JOIN
company_staff dsc ON dsc.user_id = su.id
WHERE
su.deleted = 0
AND sr2.service_package_id = 'weixiu' -- 服务包 ID
AND dsc.deleted = 0
GROUP BY
su.id
ORDER BY
totalTasks DESC;
</select>
</mapper>

View File

@ -375,15 +375,15 @@
</select>
<!-- 统计采购金额 -->
<select id="getPurchaseAmount" resultType="java.math.BigDecimal">
<select id="getPurchaseAmount">
SELECT
COALESCE(SUM(so.total_price), 0)
COALESCE(SUM(so.total_price), 0) AS purchaseAmount,
SUM(so.item_count) AS purchaseCount
FROM
dl_repair_so so
LEFT JOIN dl_ticket_wares dtw ON so.tw_id = dtw.id
WHERE
so.deleted = '0'
AND so.so_type = '01' <!-- 01表示采购单 -->
<if test="soType != null and soType != ''">
and so.so_type = #{soType}
</if>

View File

@ -726,7 +726,7 @@
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
<where>drt.deleted = 0 and drr.deleted = 0 and drr.type = 'jssp'
<where>drt.deleted = 0 and drr.deleted = 0 and drr.type = 'jssp' and drt.pay_status != '04'
<if test="ew != null and ew.customSqlSegment != null and ew.customSqlSegment != ''">
AND ${ew.sqlSegment}
</if>