维修工单生成、接取工单维护
This commit is contained in:
parent
7c500fae18
commit
339b01526f
@ -1,10 +1,12 @@
|
||||
package com.cdzy.operations.controller;
|
||||
|
||||
import com.cdzy.common.enums.Message;
|
||||
import com.cdzy.common.model.request.PageParam;
|
||||
import com.cdzy.common.model.response.JsonResult;
|
||||
import com.cdzy.operations.enums.BikeOrderHandleState;
|
||||
import com.cdzy.operations.model.dto.EbikeBikeOrderInfoDto;
|
||||
import com.cdzy.operations.model.dto.EbikeBikeOrderPageDto;
|
||||
import com.cdzy.operations.model.vo.FaultOrderVo;
|
||||
import com.cdzy.operations.model.vo.InspectionSwapOrderVo;
|
||||
import com.cdzy.operations.service.EbikeBikeOrderService;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
@ -14,6 +16,7 @@ import jakarta.annotation.Resource;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@ -101,6 +104,18 @@ public class EbikeBikeOrderController {
|
||||
return JsonResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成维修工单。
|
||||
*
|
||||
* @param faultOrderVo 故障信息
|
||||
* @return 结果
|
||||
*/
|
||||
@GetMapping("faultOrder")
|
||||
public JsonResult<?> faultOrder(@Validated @RequestBody FaultOrderVo faultOrderVo) {
|
||||
ebikeBikeOrderService.faultOrder(faultOrderVo);
|
||||
return JsonResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 接取工单。
|
||||
*
|
||||
@ -112,4 +127,15 @@ public class EbikeBikeOrderController {
|
||||
ebikeBikeOrderService.acceptOrder(orderId);
|
||||
return JsonResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传远程故障图片
|
||||
* @param file 文件
|
||||
* @return 操作结果
|
||||
*/
|
||||
@PostMapping("upload")
|
||||
public JsonResult<?> upload(@RequestParam("file") MultipartFile file) throws Exception {
|
||||
String result = ebikeBikeOrderService.upload(file);
|
||||
return JsonResult.success(Message.SUCCESS,result);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,31 @@
|
||||
package com.cdzy.operations.model.vo;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author attiya
|
||||
* @since 2025-11-26
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class FaultOrderVo {
|
||||
|
||||
@NotNull(message = "车辆编号不能为空")
|
||||
private String bikeCode;
|
||||
|
||||
@NotNull(message = "故障部位不能为空")
|
||||
private List<Integer> parts;
|
||||
|
||||
@NotNull(message = "故障部位图片不能为空")
|
||||
private List<String> fileUrls;
|
||||
|
||||
private String remarks;
|
||||
}
|
||||
@ -1,9 +1,11 @@
|
||||
package com.cdzy.operations.service;
|
||||
|
||||
import com.cdzy.operations.model.dto.EbikeBikeOrderInfoDto;
|
||||
import com.cdzy.operations.model.entity.EbikeBikeOrder;
|
||||
import com.cdzy.operations.model.vo.FaultOrderVo;
|
||||
import com.cdzy.operations.model.vo.InspectionSwapOrderVo;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.cdzy.operations.model.entity.EbikeBikeOrder;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 工单信息 服务层。
|
||||
@ -44,4 +46,17 @@ public interface EbikeBikeOrderService extends IService<EbikeBikeOrder> {
|
||||
* @param orderId 工单ID
|
||||
*/
|
||||
void acceptOrder(Long orderId);
|
||||
|
||||
/**
|
||||
* 上传故障文件
|
||||
* @param file 上传文件
|
||||
* @return 文件路径
|
||||
*/
|
||||
String upload(MultipartFile file) throws Exception;
|
||||
|
||||
/**
|
||||
* 生成维修工单
|
||||
* @param faultOrderVo 故障信息
|
||||
*/
|
||||
void faultOrder(FaultOrderVo faultOrderVo);
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.cdzy.operations.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.io.file.FileNameUtil;
|
||||
import com.cdzy.common.ex.EbikeException;
|
||||
import com.cdzy.common.model.dto.ResGPSDto;
|
||||
import com.cdzy.operations.enums.*;
|
||||
@ -10,8 +11,10 @@ import com.cdzy.operations.model.entity.EbikeBikeInfo;
|
||||
import com.cdzy.operations.model.entity.EbikeBikeOrder;
|
||||
import com.cdzy.operations.model.entity.EbikeOrderFile;
|
||||
import com.cdzy.operations.model.entity.EbikeOrderPart;
|
||||
import com.cdzy.operations.model.vo.FaultOrderVo;
|
||||
import com.cdzy.operations.model.vo.InspectionSwapOrderVo;
|
||||
import com.cdzy.operations.service.EbikeBikeOrderService;
|
||||
import com.cdzy.operations.utils.MinioUtil;
|
||||
import com.cdzy.operations.utils.RedisUtil;
|
||||
import com.mybatisflex.core.keygen.impl.SnowFlakeIDKeyGenerator;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
@ -21,10 +24,12 @@ import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.cdzy.operations.model.entity.table.EbikeBikeInfoTableDef.EBIKE_BIKE_INFO;
|
||||
import static com.cdzy.operations.model.entity.table.EbikeBikeOrderTableDef.EBIKE_BIKE_ORDER;
|
||||
@ -42,6 +47,8 @@ public class EbikeBikeOrderServiceImpl extends ServiceImpl<EbikeBikeOrderMapper,
|
||||
|
||||
private static final SnowFlakeIDKeyGenerator snowFlakeIDKeyGenerator = new SnowFlakeIDKeyGenerator();
|
||||
|
||||
private static final String upgradeUrl = "/fault-file/";
|
||||
|
||||
@Resource
|
||||
EbikeEcuInfoMapper ebikeEcuInfoMapper;
|
||||
|
||||
@ -57,6 +64,9 @@ public class EbikeBikeOrderServiceImpl extends ServiceImpl<EbikeBikeOrderMapper,
|
||||
@Resource
|
||||
RedisUtil redisUtil;
|
||||
|
||||
@Resource
|
||||
MinioUtil minioUtil;
|
||||
|
||||
@Override
|
||||
public void createBatterySwapOrder(String ecuSn) {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
@ -176,12 +186,44 @@ public class EbikeBikeOrderServiceImpl extends ServiceImpl<EbikeBikeOrderMapper,
|
||||
public void acceptOrder(Long orderId) {
|
||||
UpdateChain.of(EbikeBikeOrder.class)
|
||||
.where(EBIKE_BIKE_ORDER.ORDER_ID.eq(orderId))
|
||||
.where(EBIKE_BIKE_ORDER.RECEIVER_ID.isNull())
|
||||
.where(EBIKE_BIKE_ORDER.HANDLE_STATE.eq(OrderHandleState.UNPROCESSED))
|
||||
.set(EBIKE_BIKE_ORDER.RECEIVER_ID, StpUtil.getLoginIdAsLong())
|
||||
.set(EBIKE_BIKE_ORDER.HANDLE_STATE, OrderHandleState.ACCEPTED)
|
||||
.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String upload(MultipartFile file) throws Exception {
|
||||
String objectName = upgradeUrl + UUID.randomUUID().toString().replace("-", "") + "." + FileNameUtil.extName(file.getOriginalFilename());
|
||||
minioUtil.uploadFile(file.getInputStream(), objectName);
|
||||
return minioUtil.getShowUrl(objectName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void faultOrder(FaultOrderVo faultOrderVo) {
|
||||
EbikeBikeInfo bikeInfo = checkBikeCode(faultOrderVo.getBikeCode());
|
||||
//故障工单不判定重复
|
||||
EbikeBikeOrder ebikeBikeOrder = EbikeBikeOrder.builder()
|
||||
.bikeCode(bikeInfo.getBikeCode())
|
||||
.orderCode(snowFlakeIDKeyGenerator.nextId())
|
||||
.orderType(BikeOrderType.REPAIR)
|
||||
.operatorId(bikeInfo.getOperatorId())
|
||||
.remarks(faultOrderVo.getRemarks())
|
||||
.build();
|
||||
this.mapper.insert(ebikeBikeOrder);
|
||||
Long orderId = ebikeBikeOrder.getOrderId();
|
||||
List<Integer> parts = faultOrderVo.getParts();
|
||||
List<String> fileUrls = faultOrderVo.getFileUrls();
|
||||
if (parts != null && !parts.isEmpty()) {
|
||||
List<EbikeOrderPart> list = parts.stream().map(e -> EbikeOrderPart.builder().orderId(orderId).orderPart(e).build()).toList();
|
||||
orderPartMapper.insertBatch(list);
|
||||
}
|
||||
if (fileUrls != null && !fileUrls.isEmpty()) {
|
||||
List<EbikeOrderFile> list = fileUrls.stream().map(e -> EbikeOrderFile.builder().orderId(orderId).fileUrl(e).build()).toList();
|
||||
orderFileMapper.insertBatch(list);
|
||||
}
|
||||
}
|
||||
|
||||
EbikeBikeInfo checkBikeCode(String bikeCode) {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.where(EBIKE_BIKE_INFO.BIKE_CODE.eq(bikeCode))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user