src/main/java/com/ruoyi/aftersalesservice/controller/AfterSalesServiceController.java
@@ -49,8 +49,8 @@ @GetMapping("/listPage") @ApiOperation("售后服务-分页查询") @Log(title = "售后服务-分页查询", businessType = BusinessType.OTHER) public AjaxResult listPage(Page page, AfterSalesService afterSalesService) { IPage<AfterSalesService> listPage = afterSalesServiceService.listPage(page, afterSalesService); public AjaxResult listPage(Page page, AfterSalesServiceNewDto afterSalesService) { IPage<AfterSalesServiceNewDto> listPage = afterSalesServiceService.listPage(page, afterSalesService); return AjaxResult.success(listPage); } @@ -59,8 +59,8 @@ @ApiOperation("售后服务-反馈登记") public void export(HttpServletResponse response) { Page page = new Page(-1,-1); AfterSalesService afterSalesService = new AfterSalesService(); IPage<AfterSalesService> listPage = afterSalesServiceService.listPage(page, afterSalesService); AfterSalesServiceNewDto afterSalesService = new AfterSalesServiceNewDto(); IPage<AfterSalesServiceNewDto> listPage = afterSalesServiceService.listPage(page, afterSalesService); List<AfterSalesServiceExeclDto> list = new ArrayList<>(); listPage.getRecords().forEach(item -> { AfterSalesServiceExeclDto dto = new AfterSalesServiceExeclDto(); @@ -77,12 +77,12 @@ @ApiOperation("售后服务-售后处理") public void exportTwo(HttpServletResponse response) { Page page = new Page(-1,-1); AfterSalesService afterSalesService = new AfterSalesService(); IPage<AfterSalesService> listPage = afterSalesServiceService.listPage(page, afterSalesService); AfterSalesServiceNewDto afterSalesService = new AfterSalesServiceNewDto(); IPage<AfterSalesServiceNewDto> listPage = afterSalesServiceService.listPage(page, afterSalesService); listPage.getRecords().forEach(item -> { item.setStatusName(item.getStatus().toString()); }); ExcelUtil<AfterSalesService> util = new ExcelUtil<AfterSalesService>(AfterSalesService.class); ExcelUtil<AfterSalesServiceNewDto> util = new ExcelUtil<AfterSalesServiceNewDto>(AfterSalesServiceNewDto.class); util.exportExcel(response, listPage.getRecords() , "售后处理"); } @@ -148,4 +148,10 @@ return AjaxResult.success(afterSalesServiceService.getAfterSalesServiceNewDtoById(id)); } @ApiOperation("售后服务-统计工单情况") @GetMapping("count") public AjaxResult count() { return AjaxResult.success(afterSalesServiceService.countAfterSalesService()); } } src/main/java/com/ruoyi/aftersalesservice/dto/AfterSalesServiceNewDto.java
@@ -16,4 +16,6 @@ private List<Long> productModelIdList; private SalesLedgerDto salesLedgerDto; private String salesContractNo; } src/main/java/com/ruoyi/aftersalesservice/mapper/AfterSalesServiceMapper.java
@@ -3,8 +3,13 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.aftersalesservice.dto.AfterSalesServiceNewDto; import com.ruoyi.aftersalesservice.dto.CountDto; import com.ruoyi.aftersalesservice.pojo.AfterSalesService; import org.apache.ibatis.annotations.Param; import java.util.HashMap; import java.util.List; /** * @author :yys @@ -18,5 +23,7 @@ * @param afterSalesService * @return */ IPage<AfterSalesService> listPage(Page page,@Param("req") AfterSalesService afterSalesService); IPage<AfterSalesServiceNewDto> listPage(Page page, @Param("req") AfterSalesServiceNewDto afterSalesService); List<CountDto> countAfterSalesService(); } src/main/java/com/ruoyi/aftersalesservice/pojo/AfterSalesService.java
@@ -33,8 +33,12 @@ @ApiModelProperty("状态 1-待处理 2-已处理") private Integer status; @ApiModelProperty("售后单号") private String afterSalesServiceNo; @Excel(name = "状态", readConverterExp = "1=待处理,2=已处理") @TableField(exist = false) private String statusName; /** @@ -138,20 +142,20 @@ private String deptName; @TableField("售后类型") @ApiModelProperty("售后类型") private String serviceType; @TableField("紧急程度") @ApiModelProperty("紧急程度") private String urgency; @TableField("销售台账ID") @ApiModelProperty("销售台账ID") private Long salesLedgerId; @TableField("分配人ID") @ApiModelProperty("分配人ID") private Long distributionUserId; @TableField("产品型号IDs") @ApiModelProperty("产品型号IDs") private String productModelIds; src/main/java/com/ruoyi/aftersalesservice/service/AfterSalesServiceService.java
@@ -4,7 +4,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.aftersalesservice.dto.AfterSalesServiceNewDto; import com.ruoyi.aftersalesservice.dto.CountDto; import com.ruoyi.aftersalesservice.pojo.AfterSalesService; import java.util.List; /** * @author :yys @@ -19,9 +22,12 @@ * @param afterSalesService * @return */ IPage<AfterSalesService> listPage(Page page, AfterSalesService afterSalesService); IPage<AfterSalesServiceNewDto> listPage(Page page, AfterSalesServiceNewDto afterSalesService); boolean addAfterSalesServiceDto(AfterSalesServiceNewDto afterSalesServiceNewDto); AfterSalesServiceNewDto getAfterSalesServiceNewDtoById(Long id); List<CountDto> countAfterSalesService(); } src/main/java/com/ruoyi/aftersalesservice/service/impl/AfterSalesServiceServiceImpl.java
@@ -5,9 +5,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.aftersalesservice.dto.AfterSalesServiceNewDto; import com.ruoyi.aftersalesservice.dto.CountDto; import com.ruoyi.aftersalesservice.mapper.AfterSalesServiceMapper; import com.ruoyi.aftersalesservice.pojo.AfterSalesService; import com.ruoyi.aftersalesservice.service.AfterSalesServiceService; import com.ruoyi.common.utils.OrderUtils; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.project.system.domain.SysDept; @@ -19,8 +21,6 @@ import com.ruoyi.sales.pojo.SalesLedgerProduct; import com.ruoyi.sales.service.ISalesLedgerProductService; import com.ruoyi.sales.service.ISalesLedgerService; import com.ruoyi.sales.service.impl.SalesLedgerProductServiceImpl; import com.ruoyi.sales.service.impl.SalesLedgerServiceImpl; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -52,10 +52,10 @@ private ISalesLedgerService salesLedgerService; @Override public IPage<AfterSalesService> listPage(Page page, AfterSalesService afterSalesService) { public IPage<AfterSalesServiceNewDto> listPage(Page page, AfterSalesServiceNewDto afterSalesService) { Long tenantId = SecurityUtils.getLoginUser().getTenantId(); SysDept sysDept = sysDeptMapper.selectDeptById(tenantId); IPage<AfterSalesService> afterSalesServiceIPage = afterSalesServiceMapper.listPage(page, afterSalesService); IPage<AfterSalesServiceNewDto> afterSalesServiceIPage = afterSalesServiceMapper.listPage(page, afterSalesService); afterSalesServiceIPage.getRecords().forEach(item -> { item.setDeptName(sysDept.getDeptName()); }); @@ -74,6 +74,10 @@ SysUser sysUser = sysUserMapper.selectUserById(afterSalesServiceNewDto.getCheckUserId()); if(sysUser == null) throw new RuntimeException("审核人不存在"); afterSalesServiceNewDto.setCheckNickName(sysUser.getNickName()); if (StringUtils.isEmpty(afterSalesServiceNewDto.getAfterSalesServiceNo())) { String string = OrderUtils.countAfterServiceTodayByCreateTime(afterSalesServiceMapper, "SH_"); afterSalesServiceNewDto.setAfterSalesServiceNo(string); } return this.save(afterSalesServiceNewDto); } @@ -82,7 +86,7 @@ AfterSalesService afterSalesService = afterSalesServiceMapper.selectById(id); SalesLedger byId = salesLedgerService.getById(afterSalesService.getSalesLedgerId()); List<Long> collect = Arrays.stream(afterSalesService.getProductModelIds().split(",")).map(Long::valueOf).collect(Collectors.toList()); List<SalesLedgerProduct> list = salesLedgerProductService.list(new QueryWrapper<SalesLedgerProduct>().lambda().in(SalesLedgerProduct::getProductModelId, collect)); List<SalesLedgerProduct> list = salesLedgerProductService.list(new QueryWrapper<SalesLedgerProduct>().lambda().in(SalesLedgerProduct::getId, collect)); AfterSalesServiceNewDto afterSalesServiceNewDto = new AfterSalesServiceNewDto(); BeanUtils.copyProperties(afterSalesService, afterSalesServiceNewDto); SalesLedgerDto salesLedgerDto = new SalesLedgerDto(); @@ -91,4 +95,20 @@ afterSalesServiceNewDto.setSalesLedgerDto(salesLedgerDto); return afterSalesServiceNewDto; } @Override public List<CountDto> countAfterSalesService() { List<CountDto> stringIntegerHashMap = afterSalesServiceMapper.countAfterSalesService(); Integer total = 0; for (CountDto countDto : stringIntegerHashMap) { total += countDto.getCount(); } CountDto countDto = new CountDto(); countDto.setStatus(3); countDto.setCount(total); stringIntegerHashMap.add(countDto); return stringIntegerHashMap; } } src/main/java/com/ruoyi/common/utils/OrderUtils.java
@@ -54,4 +54,38 @@ // 拼接订单编号 preFix + 时间(yyyyMMdd) + 订单数量(001) return preFix + LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE).replaceAll("-", "") + String.format("%03d", (aLong + 1)) + "-" + new Date().getTime(); } /** * 查询当天(基于createTime字段)的记录数量 * @param mapper 实体类对应的BaseMapper * @param <T> 实体类泛型 * @return 当天记录数量 */ public static <T> String countAfterServiceTodayByCreateTime(BaseMapper<T> mapper,String preFix) { // 获取当天开始时间(00:00:00) LocalDateTime todayStart = LocalDateTime.of( LocalDateTime.now().toLocalDate(), LocalTime.MIN ); // 获取当天结束时间(23:59:59.999) LocalDateTime todayEnd = LocalDateTime.of( LocalDateTime.now().toLocalDate(), LocalTime.MAX ); // 转换为Date类型(如果实体类中createTime是LocalDateTime可直接使用) Date startDate = Date.from(todayStart.atZone(ZoneId.systemDefault()).toInstant()); Date endDate = Date.from(todayEnd.atZone(ZoneId.systemDefault()).toInstant()); // 构建查询条件 QueryWrapper<T> queryWrapper = new QueryWrapper<>(); queryWrapper.ge("create_time", startDate) // 大于等于当天开始 .lt("create_time", endDate); // 小于当天结束(避免毫秒精度问题) // 执行查询 Long aLong = mapper.selectCount(queryWrapper); // 拼接订单编号 preFix + 时间(yyyyMMdd) + 订单数量(001) return preFix + LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE).replaceAll("-", "") + String.format("%03d", (aLong + 1)); } } src/main/resources/mapper/aftersalesservice/AfterSalesServiceMapper.xml
@@ -2,8 +2,11 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.ruoyi.aftersalesservice.mapper.AfterSalesServiceMapper"> <select id="listPage" resultType="com.ruoyi.aftersalesservice.pojo.AfterSalesService"> select * from after_sales_service <select id="listPage" resultType="com.ruoyi.aftersalesservice.dto.AfterSalesServiceNewDto"> select ass.*, sl.sales_contract_no from after_sales_service ass left join sales_ledger sl on ass.sales_ledger_id = sl.id where 1 = 1 <if test="req.feedbackDate != null"> AND feedback_date BETWEEN #{req.feedbackDate} AND #{req.feedbackDate} @@ -17,6 +20,20 @@ <if test="req.status != null and req.status != ''"> and status = #{req.status} </if> <if test="req.urgency != null"> and urgency = #{req.urgency} </if> <if test="req.serviceType != null"> and service_type = #{req.serviceType} </if> order by update_time desc </select> <select id="countAfterSalesService" resultType="com.ruoyi.aftersalesservice.dto.CountDto"> select status, count(1) as count from after_sales_service group by status </select> </mapper>