用户订单故障上报查询接口实现
This commit is contained in:
parent
77489ee59d
commit
2dc1fed2e8
@ -4,8 +4,11 @@ import com.cdzy.common.model.JsonResult;
|
||||
import com.cdzy.common.model.EbikeUserFaultreportDto;
|
||||
import com.cdzy.common.model.EbikeUserFaultreportQueryDto;
|
||||
import com.cdzy.common.model.EbikeOrderAttachmentFileDto;
|
||||
import com.cdzy.orders.model.dto.req.UserOrderFaultQueryDto;
|
||||
import com.cdzy.orders.model.dto.res.OrderFaultReport;
|
||||
import com.cdzy.orders.service.EbikeOrderAttachmentFileService;
|
||||
import com.cdzy.orders.uitls.MinioUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -53,7 +56,7 @@ public class EbikeUserFaultreportController {
|
||||
@PostMapping("remove")
|
||||
public JsonResult<?> remove(@RequestParam(name = "id") String id) {
|
||||
boolean r = ebikeUserFaultreportService.deleteById(id);
|
||||
return r? JsonResult.success() : JsonResult.failed("删除用户上报故障信息失败");
|
||||
return r ? JsonResult.success() : JsonResult.failed("删除用户上报故障信息失败");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -65,7 +68,7 @@ public class EbikeUserFaultreportController {
|
||||
@PostMapping("update")
|
||||
public JsonResult<?> update(@RequestBody EbikeUserFaultreport ebikeUserFaultreport) {
|
||||
boolean r = ebikeUserFaultreportService.updateById(ebikeUserFaultreport);
|
||||
return r? JsonResult.success() : JsonResult.failed("更新用户上报故障信息失败");
|
||||
return r ? JsonResult.success() : JsonResult.failed("更新用户上报故障信息失败");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -83,7 +86,7 @@ public class EbikeUserFaultreportController {
|
||||
return ebikeUserFaultreport;
|
||||
}).toList();
|
||||
boolean r = ebikeUserFaultreportService.updateBatch(ebikeUserFaultreportList);
|
||||
return r? JsonResult.success() : JsonResult.failed("批量更新用户上报故障信息失败");
|
||||
return r ? JsonResult.success() : JsonResult.failed("批量更新用户上报故障信息失败");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -102,11 +105,11 @@ public class EbikeUserFaultreportController {
|
||||
BeanUtils.copyProperties(entity, dto);
|
||||
// 获取附件信息
|
||||
List<EbikeOrderAttachmentFileDto> attachmentFiles = ebikeOrderAttachmentFileService.getFilesByBusiId(id)
|
||||
.stream().map(attachmentFile ->{
|
||||
EbikeOrderAttachmentFileDto attachmentFileDto = new EbikeOrderAttachmentFileDto();
|
||||
BeanUtils.copyProperties(attachmentFile, attachmentFileDto);
|
||||
.stream().map(attachmentFile -> {
|
||||
EbikeOrderAttachmentFileDto attachmentFileDto = new EbikeOrderAttachmentFileDto();
|
||||
BeanUtils.copyProperties(attachmentFile, attachmentFileDto);
|
||||
attachmentFileDto.setUrl(minioUtil.getBucketFileUrl(attachmentFile.getFileKey()));
|
||||
return attachmentFileDto;
|
||||
return attachmentFileDto;
|
||||
}).toList();
|
||||
dto.setAttachmentFiles(attachmentFiles);
|
||||
return JsonResult.success(dto);
|
||||
@ -126,6 +129,7 @@ public class EbikeUserFaultreportController {
|
||||
}
|
||||
return JsonResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户上报故障信息userId获取列表信息。
|
||||
*
|
||||
@ -133,9 +137,24 @@ public class EbikeUserFaultreportController {
|
||||
* @return 用户上报故障信息userId获取列表信息
|
||||
*/
|
||||
@PostMapping("getFaultListByWeChatUser")
|
||||
public JsonResult<?> getFaultListByWeChatUser(@RequestBody Map<String,Object> params) {
|
||||
public JsonResult<?> getFaultListByWeChatUser(@RequestBody Map<String, Object> params) {
|
||||
List<EbikeUserFaultreport> faultListByWeChatUser = ebikeUserFaultreportService.getFaultListByWeChatUser(params);
|
||||
return JsonResult.success(faultListByWeChatUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户订单故障上报记录列表。
|
||||
*
|
||||
* @param userOrderFaultQueryDto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("getUserOrderFaultRecord")
|
||||
public JsonResult<?> getUserOrderFaultRecord(@RequestBody UserOrderFaultQueryDto userOrderFaultQueryDto) {
|
||||
try {
|
||||
Page<OrderFaultReport> orderFaultReports = ebikeUserFaultreportService.getUserOrderFaultRecord(userOrderFaultQueryDto);
|
||||
return JsonResult.success(orderFaultReports);
|
||||
} catch (Exception e) {
|
||||
return JsonResult.failed("getUserOrderFaultRecord===>出错了");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
package com.cdzy.orders.model.dto.req;
|
||||
|
||||
import com.cdzy.common.model.PageParam;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author:Ding
|
||||
* @ClassName:UserOrderFaultQueryDto
|
||||
* @Package:com.cdzy.orders.model.dto.req.UserOrderFaultQueryDto
|
||||
* @Description:用户订单故障上报查询参数
|
||||
* @CreateDate:2025年05月22日
|
||||
* @Version:V1.0
|
||||
**/
|
||||
@Data
|
||||
public class UserOrderFaultQueryDto {
|
||||
|
||||
/**
|
||||
* 订单编号
|
||||
*/
|
||||
private String orderId;
|
||||
|
||||
/**
|
||||
* 分页参数
|
||||
*/
|
||||
@NotNull(message = "分页参数不能为空")
|
||||
private PageParam pageParam;
|
||||
}
|
||||
@ -1,8 +1,9 @@
|
||||
package com.cdzy.payment.model.dto;
|
||||
package com.cdzy.orders.model.dto.res;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author:Ding
|
||||
@ -15,10 +16,12 @@ import java.time.LocalDateTime;
|
||||
@Data
|
||||
public class OrderFaultReport {
|
||||
|
||||
private String faultReportId;
|
||||
|
||||
/**
|
||||
* 反馈用户
|
||||
*/
|
||||
private String userName;
|
||||
private String reportUser;
|
||||
|
||||
/**
|
||||
* 坐标
|
||||
@ -28,20 +31,20 @@ public class OrderFaultReport {
|
||||
/**
|
||||
* 故障类型
|
||||
*/
|
||||
private String faultType;
|
||||
private String faultPart;
|
||||
|
||||
/**
|
||||
* 图片
|
||||
*/
|
||||
private String image;
|
||||
private List<String> image;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
private String faultDescription;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
private LocalDateTime reportAt;
|
||||
}
|
||||
@ -3,6 +3,7 @@ package com.cdzy.orders.model.entity;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@ -107,4 +108,9 @@ public class EbikeUserFaultreport implements Serializable {
|
||||
*/
|
||||
private String workorderId;
|
||||
|
||||
/**
|
||||
* 订单编号
|
||||
*/
|
||||
private String orderCode;
|
||||
|
||||
}
|
||||
|
||||
@ -2,6 +2,9 @@ package com.cdzy.orders.service;
|
||||
|
||||
import com.cdzy.common.model.EbikeUserFaultreportQueryDto;
|
||||
import com.cdzy.common.model.EbikeUserFaultreportDto;
|
||||
import com.cdzy.orders.model.dto.req.UserOrderFaultQueryDto;
|
||||
import com.cdzy.orders.model.dto.res.OrderFaultReport;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.cdzy.orders.model.entity.EbikeUserFaultreport;
|
||||
|
||||
@ -46,4 +49,11 @@ public interface EbikeUserFaultreportService extends IService<EbikeUserFaultrepo
|
||||
* @return 用户上报故障信息userId获取列表信息
|
||||
*/
|
||||
List<EbikeUserFaultreport> getFaultListByWeChatUser( Map<String,Object> params);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param userOrderFaultQueryDto
|
||||
* @return
|
||||
*/
|
||||
Page<OrderFaultReport> getUserOrderFaultRecord(UserOrderFaultQueryDto userOrderFaultQueryDto);
|
||||
}
|
||||
|
||||
@ -4,12 +4,17 @@ import cn.hutool.core.map.MapUtil;
|
||||
import com.cdzy.common.model.EbikeOrderAttachmentFileDto;
|
||||
import com.cdzy.common.model.EbikeUserFaultreportQueryDto;
|
||||
import com.cdzy.common.model.EbikeUserFaultreportDto;
|
||||
import com.cdzy.orders.mapper.EbikeOrderAttachmentFileMapper;
|
||||
import com.cdzy.orders.model.dto.req.UserOrderFaultQueryDto;
|
||||
import com.cdzy.orders.model.dto.res.EbikeUserDto;
|
||||
import com.cdzy.orders.model.dto.res.OrderFaultReport;
|
||||
import com.cdzy.orders.model.entity.EbikeAttachefileAssociated;
|
||||
import com.cdzy.orders.model.entity.EbikeOrderAttachmentFile;
|
||||
import com.cdzy.orders.service.EbikeAttachefileAssociatedService;
|
||||
import com.cdzy.orders.service.EbikeOrderAttachmentFileService;
|
||||
import com.cdzy.orders.uitls.MinioUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryMethods;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.cdzy.orders.model.entity.EbikeUserFaultreport;
|
||||
@ -22,11 +27,14 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.cdzy.orders.model.entity.table.EbikeAttachefileAssociatedTableDef.EBIKE_ATTACHEFILE_ASSOCIATED;
|
||||
import static com.cdzy.orders.model.entity.table.EbikeOrderAttachmentFileTableDef.EBIKE_ORDER_ATTACHMENT_FILE;
|
||||
import static com.cdzy.orders.model.entity.table.EbikeUserFaultreportTableDef.EBIKE_USER_FAULTREPORT;
|
||||
import static com.cdzy.orders.model.entity.table.EbikeUserTableDef.EBIKE_USER;
|
||||
|
||||
/**
|
||||
* 用户上报故障信息 服务层实现。
|
||||
@ -36,7 +44,7 @@ import static com.cdzy.orders.model.entity.table.EbikeUserFaultreportTableDef.EB
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class EbikeUserFaultreportServiceImpl extends ServiceImpl<EbikeUserFaultreportMapper, EbikeUserFaultreport> implements EbikeUserFaultreportService{
|
||||
public class EbikeUserFaultreportServiceImpl extends ServiceImpl<EbikeUserFaultreportMapper, EbikeUserFaultreport> implements EbikeUserFaultreportService {
|
||||
|
||||
@Resource
|
||||
private EbikeAttachefileAssociatedService ebikeAttachmentFileAssosiatedService;
|
||||
@ -47,6 +55,7 @@ public class EbikeUserFaultreportServiceImpl extends ServiceImpl<EbikeUserFaultr
|
||||
|
||||
@Autowired
|
||||
private EbikeUserFaultreportMapper ebikeUserFaultreportMapper;
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public boolean save(EbikeUserFaultreportDto ebikeUserFaultreport) {
|
||||
@ -77,7 +86,7 @@ public class EbikeUserFaultreportServiceImpl extends ServiceImpl<EbikeUserFaultr
|
||||
@Transactional
|
||||
@Override
|
||||
public boolean deleteById(String id) {
|
||||
try{
|
||||
try {
|
||||
// 删除附件信息
|
||||
List<EbikeOrderAttachmentFile> attachmentFiles = ebikeOrderAttachmentFileService.getFilesByBusiId(id);
|
||||
if (!attachmentFiles.isEmpty()) {
|
||||
@ -101,17 +110,17 @@ public class EbikeUserFaultreportServiceImpl extends ServiceImpl<EbikeUserFaultr
|
||||
public List<EbikeUserFaultreportDto> list(EbikeUserFaultreportQueryDto queryParam) {
|
||||
QueryWrapper query = QueryWrapper.create()
|
||||
.where(EBIKE_USER_FAULTREPORT.BIKE_CODE.eq(queryParam.getBikeCode()));
|
||||
if(queryParam.getWorkorderId()==null||queryParam.getWorkorderId().isEmpty()){
|
||||
if (queryParam.getWorkorderId() == null || queryParam.getWorkorderId().isEmpty()) {
|
||||
query.and(EBIKE_USER_FAULTREPORT.WORKORDER_ID.isNull());
|
||||
}else{
|
||||
} else {
|
||||
query.and(EBIKE_USER_FAULTREPORT.WORKORDER_ID.eq(queryParam.getWorkorderId()));
|
||||
}
|
||||
if(queryParam.getFaultPart()!=null&&!queryParam.getFaultPart().isEmpty()){
|
||||
if (queryParam.getFaultPart() != null && !queryParam.getFaultPart().isEmpty()) {
|
||||
query.and(EBIKE_USER_FAULTREPORT.FAULT_PART.like(queryParam.getFaultPart()));
|
||||
}
|
||||
|
||||
List<EbikeUserFaultreport> list = list(query);
|
||||
if (list==null) {
|
||||
if (list == null) {
|
||||
return null;
|
||||
}
|
||||
List<EbikeUserFaultreportDto> dtoList = list.stream().map(entity -> {
|
||||
@ -119,7 +128,7 @@ public class EbikeUserFaultreportServiceImpl extends ServiceImpl<EbikeUserFaultr
|
||||
BeanUtils.copyProperties(entity, dto);
|
||||
// 获取附件信息
|
||||
List<EbikeOrderAttachmentFileDto> attachmentFiles = ebikeOrderAttachmentFileService.getFilesByBusiId(dto.getFaultReportId())
|
||||
.stream().map(attachmentFile ->{
|
||||
.stream().map(attachmentFile -> {
|
||||
EbikeOrderAttachmentFileDto attachmentFileDto = new EbikeOrderAttachmentFileDto();
|
||||
BeanUtils.copyProperties(attachmentFile, attachmentFileDto);
|
||||
attachmentFileDto.setFileBucket(MinioUtil.BUCKET_ORDERS);
|
||||
@ -138,14 +147,46 @@ public class EbikeUserFaultreportServiceImpl extends ServiceImpl<EbikeUserFaultr
|
||||
* @param params
|
||||
* @return 用户上报故障信息userId获取列表信息
|
||||
*/
|
||||
public List<EbikeUserFaultreport> getFaultListByWeChatUser(Map<String,Object> params) {
|
||||
String userId= MapUtil.getStr(params,"userId");
|
||||
Map<String,Object> pageParam = ( Map<String,Object>)params.get("pageParam");
|
||||
Integer pageNum= MapUtil.getInt(pageParam,"pageNum");
|
||||
Integer pageSize= MapUtil.getInt(pageParam,"pageSize");
|
||||
public List<EbikeUserFaultreport> getFaultListByWeChatUser(Map<String, Object> params) {
|
||||
String userId = MapUtil.getStr(params, "userId");
|
||||
Map<String, Object> pageParam = (Map<String, Object>) params.get("pageParam");
|
||||
Integer pageNum = MapUtil.getInt(pageParam, "pageNum");
|
||||
Integer pageSize = MapUtil.getInt(pageParam, "pageSize");
|
||||
QueryWrapper query = QueryWrapper.create();
|
||||
query.eq("report_user",userId);
|
||||
query.eq("report_user", userId);
|
||||
Page<EbikeUserFaultreport> paginate = ebikeUserFaultreportMapper.paginate(pageNum, pageSize, query);
|
||||
return paginate.getRecords();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<OrderFaultReport> getUserOrderFaultRecord(UserOrderFaultQueryDto userOrderFaultQueryDto) {
|
||||
|
||||
QueryWrapper query = QueryWrapper.create()
|
||||
.select(EBIKE_USER_FAULTREPORT.FAULT_PART, EBIKE_USER_FAULTREPORT.REPORT_AT,
|
||||
EBIKE_USER_FAULTREPORT.FAULT_DESCRIPTION, EBIKE_USER.NICKNAME.as("report_user"),
|
||||
QueryMethods.concat(EBIKE_USER_FAULTREPORT.LONGITUDE,
|
||||
EBIKE_USER_FAULTREPORT.LATITUDE).as("coordinate"),
|
||||
EBIKE_USER_FAULTREPORT.FAULT_REPORT_ID)
|
||||
.leftJoin(EBIKE_USER).on(EBIKE_USER_FAULTREPORT.REPORT_USER.eq(EBIKE_USER.USER_ID))
|
||||
.where(EBIKE_USER_FAULTREPORT.ORDER_CODE.eq(userOrderFaultQueryDto.getOrderId()));
|
||||
|
||||
Page<OrderFaultReport> page = userOrderFaultQueryDto.getPageParam().getPage();
|
||||
Page<OrderFaultReport> orderFaultReportPage = ebikeUserFaultreportMapper.paginateAs(page, query, OrderFaultReport.class);
|
||||
List<OrderFaultReport> records = orderFaultReportPage.getRecords();
|
||||
for (OrderFaultReport record : records) {
|
||||
QueryWrapper file = QueryWrapper.create()
|
||||
.leftJoin(EBIKE_ATTACHEFILE_ASSOCIATED)
|
||||
.on(EBIKE_ATTACHEFILE_ASSOCIATED.ATTACHE_FILE
|
||||
.eq(EBIKE_ORDER_ATTACHMENT_FILE.FILE_KEY))
|
||||
.where(EBIKE_ATTACHEFILE_ASSOCIATED.BUSI_ID.eq(record.getFaultReportId()));
|
||||
List<EbikeOrderAttachmentFile> list = ebikeOrderAttachmentFileService.list(file);
|
||||
List<String> fileUrl = new ArrayList<>();
|
||||
for (EbikeOrderAttachmentFile ebikeOrderAttachmentFile : list) {
|
||||
String url = minioUtil.getBucketFileUrl(ebikeOrderAttachmentFile.getFileKey());
|
||||
fileUrl.add(url);
|
||||
}
|
||||
record.setImage(fileUrl);
|
||||
}
|
||||
return orderFaultReportPage;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user