fix(任务管理):锁粒度调整的更细
This commit is contained in:
+13
@@ -20,6 +20,7 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -210,4 +211,16 @@ public class FileController {
|
||||
throw new RuntimeException("Failed to fetch QR code: " + responseEntity.getStatusCode());
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/list/files")
|
||||
public List<String> getListFiles(@RequestParam String prefix) {
|
||||
|
||||
return fileService.listFiles(prefix);
|
||||
}
|
||||
|
||||
@GetMapping("/file/expires")
|
||||
public String getFileViewUrlForExpires(@RequestParam("id") String id) {
|
||||
String viewUrl = fileService.getViewUrlByPathAndExpires(id,3600*3000);
|
||||
return viewUrl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -34,4 +35,8 @@ public interface IFileService extends IService<FileInfo> {
|
||||
FileInfo getFileInfo(String id);
|
||||
|
||||
FileInfo createFile(String path);
|
||||
|
||||
List<String> listFiles(String prefix);
|
||||
|
||||
String getViewUrlByPathAndExpires(String name,int expires);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lsl
|
||||
@@ -87,6 +88,16 @@ public class CosService extends AbstractIFileService {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> listFiles(String prefix) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getViewUrlByPathAndExpires(String name, int expires) {
|
||||
return "";
|
||||
}
|
||||
|
||||
private COSObject parsePath(String path) {
|
||||
COSObject cosObject = new COSObject();
|
||||
if (StrUtil.isNotEmpty(path)) {
|
||||
|
||||
+11
@@ -11,6 +11,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.annotation.Resource;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zlt
|
||||
@@ -73,4 +74,14 @@ public class FastdfsService extends AbstractIFileService {
|
||||
public FileInfo createFile(String path) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> listFiles(String prefix) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getViewUrlByPathAndExpires(String name, int expires) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lsl
|
||||
@@ -135,6 +136,16 @@ public class OssService extends AbstractIFileService {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> listFiles(String prefix) {
|
||||
return ossTemplate.listFiles(fileServerProperties.getOss().getBucketName(), prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getViewUrlByPathAndExpires(String name, int expires) {
|
||||
return ossTemplate.getViewUrl(name,expires);
|
||||
}
|
||||
|
||||
private OSSObject parsePath(String path) {
|
||||
OSSObject ossObject = new OSSObject();
|
||||
if (StrUtil.isNotEmpty(path)) {
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.annotation.Resource;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zlt
|
||||
@@ -84,6 +85,16 @@ public class S3Service extends AbstractIFileService {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> listFiles(String prefix) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getViewUrlByPathAndExpires(String name, int expires) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
private class S3Object {
|
||||
|
||||
@@ -4,10 +4,10 @@ server:
|
||||
spring:
|
||||
application:
|
||||
name: file-center
|
||||
# cloud:
|
||||
# nacos:
|
||||
# discovery:
|
||||
# ip: 119.45.169.13
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
ip: 119.45.169.13
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 20MB
|
||||
|
||||
+57
@@ -204,6 +204,8 @@ public class OrderController {
|
||||
if (qrCode.getStatus().equals(CommonStatus.UNABLE.getId())){
|
||||
return Result.failed("该二维码已过期");
|
||||
}
|
||||
//设置订单所属tenantId
|
||||
TenantContextHolder.setTenant(qrCode.getTenantId());
|
||||
order.setTourismId(qrCode.getTourismId());
|
||||
order.setDeviceSn(qrCode.getDeviceSn());
|
||||
order.setOrderAmount(qrCode.getPrice());
|
||||
@@ -620,4 +622,59 @@ public class OrderController {
|
||||
// 在最后两位字符前添加小数点
|
||||
return prefix + "." + lastTwo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@Operation(summary = "查询用户订单临时演示")
|
||||
@Parameters({
|
||||
@Parameter(name = "page",description = "分页起始位置",required = true,in=ParameterIn.QUERY),
|
||||
@Parameter(name = "limit",description = "分页结束位置",required = true,in=ParameterIn.QUERY)
|
||||
})
|
||||
@GetMapping("/user/temp")
|
||||
public PageResult<Map> listInfoByUserForTemp(@RequestParam Map<String, Object> params) {
|
||||
params.put("orderNo", "332025051700001");
|
||||
String fileType = MapUtils.getString(params, "fileType");
|
||||
if (StringUtil.isBlank(fileType)) {
|
||||
fileType = "image/jpeg";
|
||||
}
|
||||
|
||||
PageResult<Order> result = orderService.findList(params);
|
||||
if (result.getCount() > 0){
|
||||
List<Map> page = new ArrayList<>();
|
||||
Map<String, String> fileMap = new HashMap<>();
|
||||
fileMap.put("style", fileStyle);
|
||||
for(Order order : result.getData()){
|
||||
Map<String,Object> orderFileMap = new HashMap<>();
|
||||
orderFileMap.put("time", sdf.format(order.getCreateTime()));
|
||||
orderFileMap.put("addr", tourismService.getTourismById(order.getTourismId()).getTourismAddress());
|
||||
orderFileMap.put("orderNo", order.getOrderNo());
|
||||
|
||||
// List<OrderFile> list = orderFileService.getOrderFileByOrderNoAndFileType(order.getOrderNo(),fileType);
|
||||
List<String> list = fileCenterService.getListFiles("temp/332025051700001/Remote-Control/");
|
||||
List<Map<String,String>> resultList = new ArrayList<>();
|
||||
if (!list.isEmpty()){
|
||||
list.remove(0);
|
||||
for (String orderFile : list){
|
||||
Map<String,String> imgMap = new HashMap<>();
|
||||
String url = fileCenterService.getViewUrlByPath(orderFile);
|
||||
imgMap.put("url", url.replace(cdnOssUrl,cdnUrl));
|
||||
if (orderFile.endsWith(".jpeg") || orderFile.endsWith(".png")){
|
||||
imgMap.put("contentType", "image/jpeg");
|
||||
}
|
||||
if (orderFile.endsWith(".mp4")){
|
||||
imgMap.put("contentType", "video/mp4");
|
||||
}
|
||||
fileMap.put("path",orderFile);
|
||||
imgMap.put("viewUrl", fileCenterService.getViewUrlByPathStyle(fileMap));
|
||||
resultList.add(imgMap);
|
||||
}
|
||||
}
|
||||
orderFileMap.put("imgList", resultList);
|
||||
page.add(orderFileMap);
|
||||
}
|
||||
return PageResult.<Map>builder().data(page).resp_code(0).count(result.getCount()).build();
|
||||
}
|
||||
return new PageResult<>();
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -145,7 +145,7 @@ public class OrderFileController {
|
||||
|
||||
@Operation(summary = "设备回传照片path记录创建")
|
||||
@PostMapping("/path")
|
||||
public void createOrderFileForPath(@RequestBody OrderFile orderFile) {
|
||||
public Result createOrderFileForPath(@RequestBody OrderFile orderFile) {
|
||||
|
||||
if (orderFile != null && orderFile.getOrderNo() != null) {
|
||||
Order order = orderService.getOrderByNumber(orderFile.getOrderNo());
|
||||
@@ -166,9 +166,10 @@ public class OrderFileController {
|
||||
order.setOrderStatus(OrderStatus.UPLOADING.getId());
|
||||
orderService.updateOrder(order);
|
||||
}
|
||||
return Result.succeed(order,"更新成功");
|
||||
}
|
||||
}
|
||||
|
||||
return Result.failed("素材内容为空");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.central.order.feign.fallback.FileCenterServiceFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -43,4 +44,7 @@ public interface FileCenterService {
|
||||
|
||||
@GetMapping("/files/path/style")
|
||||
String getViewUrlByPathStyle(@RequestParam("params") Map<String,String> params) ;
|
||||
|
||||
@GetMapping("/list/files")
|
||||
List<String> getListFiles(@RequestParam("prefix") String prefix) ;
|
||||
}
|
||||
|
||||
+6
@@ -7,6 +7,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -55,6 +56,11 @@ public class FileCenterServiceFallbackFactory implements FallbackFactory<FileCen
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getListFiles(String prefix) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+10
-2
@@ -90,9 +90,17 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
|
||||
order.setOrderStatus(OrderStatus.UNPAID.getId());
|
||||
String orderNo = generateOrderNumber(order.getTourismId());
|
||||
order.setOrderNo(orderNo);
|
||||
|
||||
// 幂等性校验:同一用户、同一二维码、未完成订单只能有一条
|
||||
String lockKey = "order:create:" + order.getUserId() + ":" + order.getCodeId();
|
||||
try {
|
||||
return super.saveIdempotency(order, lock
|
||||
, ORDER_LOCK+orderNo, new QueryWrapper<Order>().eq("order_no", orderNo), "订单已存在");
|
||||
return super.saveIdempotency(order, lock,
|
||||
lockKey,
|
||||
new QueryWrapper<Order>()
|
||||
.eq("user_id", order.getUserId())
|
||||
.eq("code_id", order.getCodeId())
|
||||
.ne("order_status", OrderStatus.UNPAID.getId()), // 未支付订单
|
||||
"已存在未完成订单");
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ public class WxMiniSubscribeServiceImpl implements WxMiniSubscribeService {
|
||||
dataList.add(new WxMaSubscribeMessage.MsgData("thing4", processDesc)); // 服务阶段
|
||||
dataList.add(new WxMaSubscribeMessage.MsgData("character_string7", orderNo)); // 订单编号
|
||||
dataList.add(new WxMaSubscribeMessage.MsgData("time8", orderTime)); // 已付金额
|
||||
dataList.add(new WxMaSubscribeMessage.MsgData("thing6", result)); // 备注
|
||||
dataList.add(new WxMaSubscribeMessage.MsgData("thing6", processDesc)); // 备注
|
||||
msg.setData(dataList);
|
||||
|
||||
wxMaService.getSubscribeService().sendSubscribeMsg(msg);
|
||||
|
||||
@@ -4,10 +4,10 @@ server:
|
||||
spring:
|
||||
application:
|
||||
name: order-center
|
||||
# cloud:
|
||||
# nacos:
|
||||
# discovery:
|
||||
# ip: 81.70.164.178
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
ip: 81.70.164.178
|
||||
# cloud:
|
||||
# nacos:
|
||||
# discovery:
|
||||
|
||||
+26
@@ -6,6 +6,8 @@ import com.aliyun.oss.OSSClientBuilder;
|
||||
import com.aliyun.oss.model.GeneratePresignedUrlRequest;
|
||||
import com.aliyun.oss.model.OSSObject;
|
||||
import com.aliyun.oss.model.ObjectMetadata;
|
||||
import com.aliyun.oss.model.ObjectListing;
|
||||
import com.aliyun.oss.model.OSSObjectSummary;
|
||||
import com.aliyun.oss.model.PutObjectRequest;
|
||||
import com.central.oss.model.ObjectInfo;
|
||||
import com.central.oss.properties.FileServerProperties;
|
||||
@@ -19,7 +21,9 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* cos 配置
|
||||
@@ -188,4 +192,26 @@ public class OssTemplate implements InitializingBean {
|
||||
// IOUtils.copy(ossis, os);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定bucket和前缀(目录)下的所有文件名
|
||||
* @param bucketName bucket名称
|
||||
* @param prefix 目录前缀(如 "folder/",可为空字符串表示根目录)
|
||||
* @return 文件名列表
|
||||
*/
|
||||
public List<String> listFiles(String bucketName, String prefix) {
|
||||
List<String> fileNames = new ArrayList<>();
|
||||
ObjectListing objectListing = ossClient.listObjects(bucketName, prefix);
|
||||
for (OSSObjectSummary summary : objectListing.getObjectSummaries()) {
|
||||
fileNames.add(summary.getKey());
|
||||
}
|
||||
return fileNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取默认bucket下指定前缀的所有文件名
|
||||
*/
|
||||
public List<String> listFiles(String prefix) {
|
||||
return listFiles(fileProperties.getOss().getBucketName(), prefix);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +145,10 @@ zlt:
|
||||
/api-order/home/carousel/app,
|
||||
/api-order/device/status,
|
||||
/api-order/token/callback,
|
||||
/api-order/live/stream-urls
|
||||
/api-device/stream-urls,
|
||||
/api-device/token/query,
|
||||
/api-order/user/temp,
|
||||
/api-file/file/expires
|
||||
auth:
|
||||
urlPermission:
|
||||
#是否开启url级别权限
|
||||
|
||||
@@ -9,43 +9,43 @@
|
||||
export default {
|
||||
dev: {
|
||||
'/api-uaa/': {
|
||||
// target: 'http://119.45.169.13:9900',
|
||||
target: 'http://127.0.0.1:9900',
|
||||
target: 'http://119.45.169.13:9900',
|
||||
// target: 'http://127.0.0.1:9900',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/api-user/': {
|
||||
// target: 'http://119.45.169.13:9900',
|
||||
target: 'http://127.0.0.1:9900',
|
||||
target: 'http://119.45.169.13:9900',
|
||||
// target: 'http://127.0.0.1:9900',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/api-log/': {
|
||||
// target: 'http://119.45.169.13:9900',
|
||||
target: 'http://127.0.0.1:9900',
|
||||
target: 'http://119.45.169.13:9900',
|
||||
// target: 'http://127.0.0.1:9900',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/api-search/': {
|
||||
// target: 'http://119.45.169.13:9900',
|
||||
target: 'http://127.0.0.1:9900',
|
||||
target: 'http://119.45.169.13:9900',
|
||||
// target: 'http://127.0.0.1:9900',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/api-generator/': {
|
||||
// target: 'http://119.45.169.13:9900',
|
||||
target: 'http://127.0.0.1:9900',
|
||||
target: 'http://119.45.169.13:9900',
|
||||
// target: 'http://127.0.0.1:9900',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/api-file/': {
|
||||
// target: 'http://119.45.169.13:9900',
|
||||
target: 'http://127.0.0.1:9900',
|
||||
target: 'http://119.45.169.13:9900',
|
||||
// target: 'http://127.0.0.1:9900',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/api-order/': {
|
||||
// target: 'http://119.45.169.13:9900',
|
||||
target: 'http://127.0.0.1:9900',
|
||||
target: 'http://119.45.169.13:9900',
|
||||
// target: 'http://127.0.0.1:9900',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/api-device/': {
|
||||
// target: 'http://119.45.169.13:9900',
|
||||
target: 'http://127.0.0.1:9900',
|
||||
target: 'http://119.45.169.13:9900',
|
||||
// target: 'http://127.0.0.1:9900',
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user