更新0911

This commit is contained in:
xyc 2025-09-11 10:14:08 +08:00
parent 79c5ac04d4
commit b16dca836e
7 changed files with 88 additions and 45 deletions

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.business.controller.admin; package cn.iocoder.yudao.module.business.controller.admin;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.business.entity.DlBusinessChannel; import cn.iocoder.yudao.module.business.entity.DlBusinessChannel;
import cn.iocoder.yudao.module.business.service.BusinessChannelService; import cn.iocoder.yudao.module.business.service.BusinessChannelService;
@ -31,12 +32,17 @@ public class BusinessChannelController {
return CommonResult.success(businessChannelService.list(Wrappers.<DlBusinessChannel>lambdaQuery() return CommonResult.success(businessChannelService.list(Wrappers.<DlBusinessChannel>lambdaQuery()
.eq(ObjectUtil.isNotEmpty(channel.getType()), DlBusinessChannel::getType, channel.getType()) .eq(ObjectUtil.isNotEmpty(channel.getType()), DlBusinessChannel::getType, channel.getType())
.like(ObjectUtil.isNotEmpty(channel.getName()), DlBusinessChannel::getName, channel.getName()) .like(ObjectUtil.isNotEmpty(channel.getName()), DlBusinessChannel::getName, channel.getName())
.eq(StrUtil.isNotEmpty(channel.getSystemCode()), DlBusinessChannel::getSystemCode, channel.getSystemCode())
.orderByAsc(DlBusinessChannel::getSort))); .orderByAsc(DlBusinessChannel::getSort)));
} }
/** /**
* 新增业务渠道或客户来源 * @Author
*/ * @Description 新增业务渠道来源
* @Date 13:44 2025/9/9
* @Param [channel]
* @return boolean
**/
@PostMapping("/add") @PostMapping("/add")
public boolean addChannel(@RequestBody DlBusinessChannel channel) { public boolean addChannel(@RequestBody DlBusinessChannel channel) {
if (ObjectUtil.isNotEmpty(channel.getUserIdList())) { if (ObjectUtil.isNotEmpty(channel.getUserIdList())) {
@ -50,8 +56,12 @@ public class BusinessChannelController {
} }
/** /**
* 获取业务渠道或客户来源 * @Author
*/ * @Description 获取业务来源和渠道
* @Date 13:45 2025/9/9
* @Param [id]
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<cn.iocoder.yudao.module.business.entity.DlBusinessChannel>
**/
@GetMapping("/{id}") @GetMapping("/{id}")
public CommonResult<DlBusinessChannel> getChannelById(@PathVariable("id") Long id) { public CommonResult<DlBusinessChannel> getChannelById(@PathVariable("id") Long id) {
DlBusinessChannel info = businessChannelService.getById(id); DlBusinessChannel info = businessChannelService.getById(id);
@ -68,8 +78,12 @@ public class BusinessChannelController {
} }
/** /**
* 修改业务渠道或客户来源 * @Author
*/ * @Description 修改
* @Date 13:45 2025/9/9
* @Param [channel]
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
**/
@PutMapping("/update") @PutMapping("/update")
public CommonResult<?> updateChannel(@RequestBody DlBusinessChannel channel) { public CommonResult<?> updateChannel(@RequestBody DlBusinessChannel channel) {
if (ObjectUtil.isNotEmpty(channel.getUserIdList())) { if (ObjectUtil.isNotEmpty(channel.getUserIdList())) {
@ -84,8 +98,12 @@ public class BusinessChannelController {
} }
/** /**
* 删除业务渠道或客户来源 * @Author
*/ * @Description 删除
* @Date 13:45 2025/9/9
* @Param [id]
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
**/
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public CommonResult<?> deleteChannel(@PathVariable("id") Long id) { public CommonResult<?> deleteChannel(@PathVariable("id") Long id) {
return CommonResult.success(businessChannelService.removeById(id)); return CommonResult.success(businessChannelService.removeById(id));

View File

@ -65,4 +65,9 @@ public class QueryBusinessResp {
* 经办人 * 经办人
*/ */
private String handleName; private String handleName;
/**
* 累计消费次数
*/
private Integer consumeCount;
} }

View File

@ -124,6 +124,9 @@ public class DlTicketWaresController {
@PostMapping("/audit") @PostMapping("/audit")
@Operation(summary = "审核") @Operation(summary = "审核")
public CommonResult<?> auditTicketWares(@RequestBody DlTicketWaresRespVO respVO){ public CommonResult<?> auditTicketWares(@RequestBody DlTicketWaresRespVO respVO){
if (CollUtil.isEmpty(respVO.getItems())) {
throw exception0(500,"请添加配件");
}
dlTicketWaresService.auditTicketWares(respVO); dlTicketWaresService.auditTicketWares(respVO);
return CommonResult.ok(); return CommonResult.ok();
} }

View File

@ -912,12 +912,34 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
// 根据条件查询工单 // 根据条件查询工单
List<DlRepairTickets> ticketsInRange = this.list(queryWrapper); List<DlRepairTickets> ticketsInRange = this.list(queryWrapper);
// 进厂数所有在范围内创建的
Map<String, Long> newOrderStats = ticketsInRange.stream()
.collect(Collectors.groupingBy(DlRepairTickets::getRepairType, Collectors.counting()));
statsList.add(createStatsNode("newOrderNum", "订单(进厂数)", newOrderStats));
// 维修中 repairType 分组 // 维修中 repairType 分组
Map<String, Long> workingStats = ticketsInRange.stream() Map<String, Long> workingStats = ticketsInRange.stream()
.filter(item -> TicketsStatusEnum.WORKING.getCode().equals(item.getTicketsStatus())) .filter(item -> TicketsStatusEnum.WORKING.getCode().equals(item.getTicketsStatus()))
.collect(Collectors.groupingBy(DlRepairTickets::getRepairType, Collectors.counting())); .collect(Collectors.groupingBy(DlRepairTickets::getRepairType, Collectors.counting()));
statsList.add(createStatsNode("workingNum", "维修中", workingStats)); statsList.add(createStatsNode("workingNum", "维修中", workingStats));
// 已竣工通过 mapper 查询并按 repairType 分组
Map<String, Long> overStats = getOverStatsByRepairType(startDate, endDate);
statsList.add(createStatsNode("overNum", "已竣工", overStats));
// 竣工已结算
// 竣工未结算
List<String> noPayCodeList = Arrays.asList("04", "05", "07", "01");
Map<String, Long> noPayStats = ticketsInRange.stream()
.filter(item -> noPayCodeList.contains(item.getTicketsStatus()))
.collect(Collectors.groupingBy(DlRepairTickets::getRepairType, Collectors.counting()));
statsList.add(createStatsNode("noPayNum", "未结算", noPayStats));
// 已交车通过 mapper 查询并按 repairType 分组
Map<String, Long> giveCusStats = getGiveCusStatsByRepairType(startDate, endDate);
statsList.add(createStatsNode("giveCusNum", "已交车", giveCusStats));
// 在厂未交车且不是已完成状态 03 // 在厂未交车且不是已完成状态 03
Map<String, Long> inCompanyStats = ticketsInRange.stream() Map<String, Long> inCompanyStats = ticketsInRange.stream()
.filter(item -> "0".equals(item.getIsHandover())) .filter(item -> "0".equals(item.getIsHandover()))
@ -925,26 +947,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
.collect(Collectors.groupingBy(DlRepairTickets::getRepairType, Collectors.counting())); .collect(Collectors.groupingBy(DlRepairTickets::getRepairType, Collectors.counting()));
statsList.add(createStatsNode("inCompanyNum", "在厂", inCompanyStats)); statsList.add(createStatsNode("inCompanyNum", "在厂", inCompanyStats));
// 未结算
List<String> noPayCodeList = Arrays.asList("04", "05", "07", "01");
Map<String, Long> noPayStats = ticketsInRange.stream()
.filter(item -> noPayCodeList.contains(item.getTicketsStatus()))
.collect(Collectors.groupingBy(DlRepairTickets::getRepairType, Collectors.counting()));
statsList.add(createStatsNode("noPayNum", "未结算", noPayStats));
// 进厂数所有在范围内创建的
Map<String, Long> newOrderStats = ticketsInRange.stream()
.collect(Collectors.groupingBy(DlRepairTickets::getRepairType, Collectors.counting()));
statsList.add(createStatsNode("newOrderNum", "进厂数", newOrderStats));
// 已完成通过 mapper 查询并按 repairType 分组
Map<String, Long> overStats = getOverStatsByRepairType(startDate, endDate);
statsList.add(createStatsNode("overNum", "已完成", overStats));
// 已交车通过 mapper 查询并按 repairType 分组
Map<String, Long> giveCusStats = getGiveCusStatsByRepairType(startDate, endDate);
statsList.add(createStatsNode("giveCusNum", "已交车", giveCusStats));
// 添加到结果map // 添加到结果map
resultMap.put("stats", statsList); resultMap.put("stats", statsList);
@ -968,13 +970,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
} }
queryWrapper.eq("drr.type", RecordTypeEnum.ZJ.getCode()); queryWrapper.eq("drr.type", RecordTypeEnum.ZJ.getCode());
// // 使用 group by 直接在数据库层面分组统计
// List<Map<String, Object>> result = repairTicketsMapper.selectMaps(
// queryWrapper.select("repair_type", "count(*) as count")
// .groupBy("repair_type")
// queryWrapper.getSqlSelect()
// );
// 使用 group by 直接在数据库层面分组统计 // 使用 group by 直接在数据库层面分组统计
List<Map<String, Object>> result = repairTicketsMapper.selectTicketIdByParamsNew( List<Map<String, Object>> result = repairTicketsMapper.selectTicketIdByParamsNew(
queryWrapper.select("repair_type", "count(*) as count") queryWrapper.select("repair_type", "count(*) as count")

View File

@ -58,4 +58,7 @@ public class DlRepairTicketsReqVO extends DlRepairTickets {
/** 工种 */ /** 工种 */
private String workType; private String workType;
/** 时间类型 */
private String timeType = "create";
} }

View File

@ -10,6 +10,7 @@ import cn.iocoder.yudao.module.tickets.entity.DlRepairTitem;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -86,4 +87,7 @@ public class DlRepairTicketsRespVO extends DlRepairTickets {
private BigDecimal profitRateNo; private BigDecimal profitRateNo;
private List<JobTypeProfitDTO> groupByJobType; private List<JobTypeProfitDTO> groupByJobType;
/** 结算时间 */
private LocalDateTime settlementTime;
} }

View File

@ -124,6 +124,7 @@
<result property="canOperate" column="can_operate" /> <result property="canOperate" column="can_operate" />
<result property="handleName" column="handle_name" /> <result property="handleName" column="handle_name" />
<result property="handleMobile" column="handle_mobile" /> <result property="handleMobile" column="handle_mobile" />
<result property="settlementTime" column="settlementTime" />
<association property="booking" javaType="cn.iocoder.yudao.module.booking.entity.DlRepairBooking" select="selectBookingById" column="id"/> <association property="booking" javaType="cn.iocoder.yudao.module.booking.entity.DlRepairBooking" select="selectBookingById" column="id"/>
<collection property="itemList" column="id" ofType="cn.iocoder.yudao.module.tickets.entity.DlRepairTitem" select="selectItemList" /> <collection property="itemList" column="id" ofType="cn.iocoder.yudao.module.tickets.entity.DlRepairTitem" select="selectItemList" />
</resultMap> </resultMap>
@ -411,7 +412,7 @@
</select> </select>
<select id="getPageTypeAll" resultMap="APPBaseResultMap"> <select id="getPageTypeAll" resultMap="APPBaseResultMap">
SELECT drt.* SELECT drt.*,drr.create_time AS settlementTime
FROM dl_repair_tickets drt FROM dl_repair_tickets drt
<if test="map.cusFrom != null and map.cusFrom!=''"> <if test="map.cusFrom != null and map.cusFrom!=''">
-- 按客户来源查,需要关联客户表 -- -- 按客户来源查,需要关联客户表 --
@ -421,9 +422,22 @@
ON drt.id = drti.ticket_id AND drti.deleted = '0' AND drti.item_type='01' ON drt.id = drti.ticket_id AND drti.deleted = '0' AND drti.item_type='01'
LEFT JOIN dl_repair_worker drw LEFT JOIN dl_repair_worker drw
ON FIND_IN_SET(drw.user_id, drti.repair_ids) > 0 AND drw.deleted = '0' ON FIND_IN_SET(drw.user_id, drti.repair_ids) > 0 AND drw.deleted = '0'
LEFT JOIN dl_repair_records drr
ON drr.ticket_id = drt.id AND drr.deleted = '0' AND drr.type = 'jssp'
WHERE drt.deleted = '0' AND tickets_status!='03' WHERE drt.deleted = '0' AND tickets_status!='03'
<!-- 模糊搜索 --> <!-- 模糊搜索 -->
<if test="map.searchTimeArray != null and map.searchTimeArray.length > 0">
<if test="map.timeType == 'create'">
AND (drt.create_time BETWEEN CONCAT(#{map.searchTimeArray[0]}, ' 00:00:00') AND CONCAT(#{map.searchTimeArray[1]}, ' 23:59:59'))
</if>
<if test="map.timeType == 'settlement'">
AND (drr.create_time BETWEEN CONCAT(#{map.searchTimeArray[0]}, ' 00:00:00') AND CONCAT(#{map.searchTimeArray[1]}, ' 23:59:59'))
</if>
</if>
<!-- 时间区间 -->
<if test="map.ticketNo != null and map.ticketNo != ''"> <if test="map.ticketNo != null and map.ticketNo != ''">
AND ( AND (
drt.ticket_no LIKE CONCAT('%', #{map.ticketNo}, '%') drt.ticket_no LIKE CONCAT('%', #{map.ticketNo}, '%')
@ -436,11 +450,6 @@
OR drti.item_name LIKE CONCAT('%', #{map.ticketNo}, '%') OR drti.item_name LIKE CONCAT('%', #{map.ticketNo}, '%')
) )
</if> </if>
<!-- 时间区间 -->
<if test="map.searchTimeArray != null and map.searchTimeArray.length > 0">
AND (drt.create_time BETWEEN CONCAT(#{map.searchTimeArray[0]}, ' 00:00:00') AND CONCAT(#{map.searchTimeArray[1]}, ' 23:59:59'))
</if>
<if test="map.startDate != null and map.startDate != ''"> <if test="map.startDate != null and map.startDate != ''">
AND (drt.create_time &gt;= #{map.startDate} AND drt.create_time &lt;= #{map.endDate}) AND (drt.create_time &gt;= #{map.startDate} AND drt.create_time &lt;= #{map.endDate})
</if> </if>
@ -587,8 +596,14 @@
</if> </if>
<if test="map.searchTimeArray != null and map.searchTimeArray.length > 0"> <if test="map.searchTimeArray != null and map.searchTimeArray.length > 0">
<if test="map.timeType == 'create'">
AND (drt.create_time BETWEEN CONCAT(#{map.searchTimeArray[0]}, ' 00:00:00') AND CONCAT(#{map.searchTimeArray[1]}, ' 23:59:59')) AND (drt.create_time BETWEEN CONCAT(#{map.searchTimeArray[0]}, ' 00:00:00') AND CONCAT(#{map.searchTimeArray[1]}, ' 23:59:59'))
</if> </if>
<if test="map.timeType == 'settlement'">
AND (drr.create_time BETWEEN CONCAT(#{map.searchTimeArray[0]}, ' 00:00:00') AND CONCAT(#{map.searchTimeArray[1]}, ' 23:59:59'))
</if>
</if>
<if test="map.startDate != null and map.startDate != ''"> <if test="map.startDate != null and map.startDate != ''">
AND (drt.create_time &gt;= #{map.startDate} AND drt.create_time &lt;= #{map.endDate}) AND (drt.create_time &gt;= #{map.startDate} AND drt.create_time &lt;= #{map.endDate})
</if> </if>