feat(可回溯): 重构
重构为mysql
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.wabestway.recall</groupId>
|
<groupId>com.wabestway.recall</groupId>
|
||||||
<artifactId>afis-recall</artifactId>
|
<artifactId>afis-recall</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<artifactId>afis-recall-service</artifactId>
|
<artifactId>afis-recall-service</artifactId>
|
||||||
|
|||||||
+4
-2
@@ -1,6 +1,8 @@
|
|||||||
package com.wabestway.recall.trace.dto;
|
package com.wabestway.recall.trace.dto;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import com.wabestway.commons.http.PageDTO;
|
import com.wabestway.commons.http.PageDTO;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
@@ -8,7 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @author wangH
|
* @author wangH
|
||||||
* @company 北京华焱坤泰科技有限公司
|
* @company 北京华焱坤泰科技有限公司
|
||||||
@@ -36,7 +38,7 @@ public class RecallRecordDTO extends PageDTO implements Serializable {
|
|||||||
private String content;
|
private String content;
|
||||||
/** 记录事件 */
|
/** 记录事件 */
|
||||||
@ApiModelProperty(value = "记录事件")
|
@ApiModelProperty(value = "记录事件")
|
||||||
private Blob events;
|
private List<String> events;
|
||||||
/** 回溯记录跟踪ID */
|
/** 回溯记录跟踪ID */
|
||||||
@ApiModelProperty(value = "回溯记录跟踪ID")
|
@ApiModelProperty(value = "回溯记录跟踪ID")
|
||||||
private String traceId;
|
private String traceId;
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
package com.wabestway.recall.trace.dto;
|
||||||
|
|
||||||
|
import com.wabestway.commons.http.PageDTO;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wangH
|
||||||
|
* @company 北京华焱坤泰科技有限公司
|
||||||
|
* @Time 2023-05-06 17:37:03
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel
|
||||||
|
public class TraceDTO implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "主键")
|
||||||
|
private String id;
|
||||||
|
/**
|
||||||
|
* 产品编码
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "产品编码")
|
||||||
|
private String productCode;
|
||||||
|
/**
|
||||||
|
* 产品名称
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "产品名称")
|
||||||
|
private String productName;
|
||||||
|
/**
|
||||||
|
* 模块
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "模块")
|
||||||
|
private String module;
|
||||||
|
/**
|
||||||
|
* 页面说明
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "页面说明")
|
||||||
|
private String content;
|
||||||
|
/**
|
||||||
|
* 记录事件
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "记录事件")
|
||||||
|
private List<String> events;
|
||||||
|
/**
|
||||||
|
* 回溯记录跟踪ID
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "回溯记录跟踪ID")
|
||||||
|
private String traceId;
|
||||||
|
/**
|
||||||
|
* 回溯订单Id
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "回溯订单Id")
|
||||||
|
private String orderId;
|
||||||
|
/**
|
||||||
|
* 是否最后提交
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "是否最后提交")
|
||||||
|
private boolean last;
|
||||||
|
/**
|
||||||
|
* 调用接口appKey
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "调用接口appKey")
|
||||||
|
private String appKey;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
+3
-1
@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
@@ -27,7 +29,7 @@ public class RecallRecordEntity {
|
|||||||
/** 页面说明 */
|
/** 页面说明 */
|
||||||
private String content;
|
private String content;
|
||||||
/** 记录事件 */
|
/** 记录事件 */
|
||||||
private Blob events;
|
private List<String> events;
|
||||||
/** 回溯记录跟踪ID */
|
/** 回溯记录跟踪ID */
|
||||||
private String traceId;
|
private String traceId;
|
||||||
/** 创建人 */
|
/** 创建人 */
|
||||||
|
|||||||
+14
@@ -44,5 +44,19 @@ public interface RecallOrderService extends IService<RecallOrderEntity> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
RecallOrderVO queryRecallOrderById(String id);
|
RecallOrderVO queryRecallOrderById(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据业务订单Id 查询回溯订单
|
||||||
|
* @param orderId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
RecallOrderEntity queryRecallOrderByOrderId(String orderId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据回溯轨迹ID 查询回溯订单
|
||||||
|
* @param traceId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
RecallOrderEntity queryRecallOrderByTraceId(String traceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+21
-4
@@ -1,7 +1,9 @@
|
|||||||
package com.wabestway.recall.trace.service.impl;
|
package com.wabestway.recall.trace.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
@@ -10,11 +12,10 @@ import com.wabestway.recall.trace.entity.RecallOrderEntity;
|
|||||||
import com.wabestway.recall.trace.dto.RecallOrderDTO;
|
import com.wabestway.recall.trace.dto.RecallOrderDTO;
|
||||||
import com.wabestway.recall.trace.vo.RecallOrderVO;
|
import com.wabestway.recall.trace.vo.RecallOrderVO;
|
||||||
import com.wabestway.recall.trace.service.RecallOrderService;
|
import com.wabestway.recall.trace.service.RecallOrderService;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
*
|
|
||||||
* @author wangH
|
* @author wangH
|
||||||
* @company 北京华焱坤泰科技有限公司
|
* @company 北京华焱坤泰科技有限公司
|
||||||
* @Time 2023-05-06 17:37:03
|
* @Time 2023-05-06 17:37:03
|
||||||
@@ -24,7 +25,7 @@ public class RecallOrderServiceImpl extends ServiceImpl<RecallOrderDao, RecallOr
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<RecallOrderVO> queryRecallOrderByCondition(long page, long size, RecallOrderDTO recallOrderDTO) {
|
public IPage<RecallOrderVO> queryRecallOrderByCondition(long page, long size, RecallOrderDTO recallOrderDTO) {
|
||||||
Page<RecallOrderDTO> paramReq = new Page<>(page,size);
|
Page<RecallOrderDTO> paramReq = new Page<>(page, size);
|
||||||
paramReq.addOrder(new OrderItem().setColumn("create_time").setAsc(false));//创建时间降序排序
|
paramReq.addOrder(new OrderItem().setColumn("create_time").setAsc(false));//创建时间降序排序
|
||||||
IPage<RecallOrderVO> iPage = baseMapper.queryRecallOrderByCondition(paramReq, recallOrderDTO);
|
IPage<RecallOrderVO> iPage = baseMapper.queryRecallOrderByCondition(paramReq, recallOrderDTO);
|
||||||
return iPage;
|
return iPage;
|
||||||
@@ -40,7 +41,23 @@ public class RecallOrderServiceImpl extends ServiceImpl<RecallOrderDao, RecallOr
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RecallOrderVO queryRecallOrderById(String id ) {
|
public RecallOrderVO queryRecallOrderById(String id) {
|
||||||
return baseMapper.queryRecallOrderById(id);
|
return baseMapper.queryRecallOrderById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RecallOrderEntity queryRecallOrderByOrderId(String orderId) {
|
||||||
|
LambdaQueryWrapper<RecallOrderEntity> orderQuery = Wrappers.lambdaQuery();
|
||||||
|
orderQuery.eq(RecallOrderEntity::getOrderId, orderId);
|
||||||
|
orderQuery.last("limit 1");
|
||||||
|
return baseMapper.selectOne(orderQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RecallOrderEntity queryRecallOrderByTraceId(String traceId) {
|
||||||
|
LambdaQueryWrapper<RecallOrderEntity> orderQuery = Wrappers.lambdaQuery();
|
||||||
|
orderQuery.eq(RecallOrderEntity::getOrderId, traceId);
|
||||||
|
orderQuery.last("limit 1");
|
||||||
|
return baseMapper.selectOne(orderQuery);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.wabestway.recall.trace.vo;
|
package com.wabestway.recall.trace.vo;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
@@ -34,7 +36,7 @@ public class RecallRecordVO implements Serializable {
|
|||||||
private String content;
|
private String content;
|
||||||
/** 记录事件 */
|
/** 记录事件 */
|
||||||
@ApiModelProperty(value = "记录事件")
|
@ApiModelProperty(value = "记录事件")
|
||||||
private Blob events;
|
private List<String> events;
|
||||||
/** 回溯记录跟踪ID */
|
/** 回溯记录跟踪ID */
|
||||||
@ApiModelProperty(value = "回溯记录跟踪ID")
|
@ApiModelProperty(value = "回溯记录跟踪ID")
|
||||||
private String traceId;
|
private String traceId;
|
||||||
|
|||||||
+34
-4
@@ -6,17 +6,41 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.wabestway.recall</groupId>
|
<groupId>com.wabestway.recall</groupId>
|
||||||
<artifactId>afis-recall</artifactId>
|
<artifactId>afis-recall</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>afis-recall-web</artifactId>
|
<artifactId>afis-recall-web</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.8</java.version>
|
|
||||||
<spring-cloud.version>Hoxton.SR9</spring-cloud.version>
|
<spring-cloud.version>Hoxton.SR9</spring-cloud.version>
|
||||||
<spring-cloud-alibaba.version>2.2.3.RELEASE</spring-cloud-alibaba.version>
|
<spring-cloud-alibaba.version>2.2.1.RELEASE</spring-cloud-alibaba.version>
|
||||||
</properties>
|
|
||||||
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
<mybatisplus.version>3.3.2</mybatisplus.version>
|
||||||
|
<alibaba.boot.druid>1.1.22</alibaba.boot.druid> </properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.wabestway.recall</groupId>
|
||||||
|
<artifactId>afis-recall-service</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||||
|
<version>${mybatisplus.version}</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-generator</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||||
@@ -26,6 +50,12 @@
|
|||||||
<artifactId>afis-engine-api</artifactId>
|
<artifactId>afis-engine-api</artifactId>
|
||||||
<version>2.5</version>
|
<version>2.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.wabestway.auth</groupId>
|
||||||
|
<artifactId>afis-auth-api</artifactId>
|
||||||
|
<version>1.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
package com.wabestway.recall.model;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.bson.codecs.pojo.annotations.BsonIgnore;
|
|
||||||
import org.springframework.data.annotation.Id;
|
|
||||||
import org.springframework.data.mongodb.core.index.Indexed;
|
|
||||||
import org.springframework.data.mongodb.core.mapping.Document;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@Document(collection = "orders")
|
|
||||||
public class Order {
|
|
||||||
@Id
|
|
||||||
private String id;
|
|
||||||
private String appKey;
|
|
||||||
private String tenantId;
|
|
||||||
private String productCode;
|
|
||||||
private String productName;
|
|
||||||
@BsonIgnore
|
|
||||||
private List<String> events;
|
|
||||||
@Indexed(unique = true)
|
|
||||||
private String traceId;
|
|
||||||
@Indexed(unique = true)
|
|
||||||
private String orderId;
|
|
||||||
private String complete;
|
|
||||||
private String archived;
|
|
||||||
private String fileId;
|
|
||||||
private String fileUrl;
|
|
||||||
private long createAt;
|
|
||||||
@BsonIgnore
|
|
||||||
private int page;
|
|
||||||
@BsonIgnore
|
|
||||||
private int pageSize;
|
|
||||||
|
|
||||||
private String startDate;
|
|
||||||
private String endDate;
|
|
||||||
private String policyNo;
|
|
||||||
private String holderName;
|
|
||||||
private String holderPhone;
|
|
||||||
private String supplierName;
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package com.wabestway.recall.model;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class OrderList {
|
|
||||||
private int page;
|
|
||||||
private int pageSize;
|
|
||||||
private long total;
|
|
||||||
private List<Order> list;
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package com.wabestway.recall.model;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.bson.codecs.pojo.annotations.BsonIgnore;
|
|
||||||
import org.springframework.data.annotation.Id;
|
|
||||||
import org.springframework.data.mongodb.core.index.Indexed;
|
|
||||||
import org.springframework.data.mongodb.core.mapping.Document;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@Document(collection = "records")
|
|
||||||
public class Record {
|
|
||||||
@Id
|
|
||||||
private String id;
|
|
||||||
private List<String> events;
|
|
||||||
private String traceId;
|
|
||||||
@BsonIgnore
|
|
||||||
private String orderId;
|
|
||||||
private boolean last;
|
|
||||||
private String productCode;
|
|
||||||
private String productName;
|
|
||||||
private long createAt;
|
|
||||||
@BsonIgnore
|
|
||||||
private String appKey;
|
|
||||||
private String module;
|
|
||||||
private String content;
|
|
||||||
}
|
|
||||||
@@ -1,173 +0,0 @@
|
|||||||
package com.wabestway.recall.model;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class ResObj<T> {
|
|
||||||
private static final String SUCCESS = "success";
|
|
||||||
|
|
||||||
private static final String FAILURE = "failure";
|
|
||||||
|
|
||||||
private static final Integer SUCCESS_CODE = 200;
|
|
||||||
|
|
||||||
private static final Integer FAILURE_CODE = 400;
|
|
||||||
|
|
||||||
private Integer code;
|
|
||||||
|
|
||||||
private String message;
|
|
||||||
|
|
||||||
private String _trackId;
|
|
||||||
|
|
||||||
private T data;
|
|
||||||
|
|
||||||
private Map extr;
|
|
||||||
|
|
||||||
private long timestamp;
|
|
||||||
|
|
||||||
private Integer _status;
|
|
||||||
|
|
||||||
private ResObj(Integer code, T data) {
|
|
||||||
this.code = code;
|
|
||||||
this.data = data;
|
|
||||||
this.timestamp = System.currentTimeMillis();
|
|
||||||
}
|
|
||||||
|
|
||||||
private ResObj(Integer code, String message, T data) {
|
|
||||||
this.code = code;
|
|
||||||
this.data = data;
|
|
||||||
this.message = message;
|
|
||||||
this.timestamp = System.currentTimeMillis();
|
|
||||||
}
|
|
||||||
|
|
||||||
private ResObj(T data) {
|
|
||||||
this.data = data;
|
|
||||||
this.timestamp = System.currentTimeMillis();
|
|
||||||
}
|
|
||||||
|
|
||||||
private ResObj(Integer code) {
|
|
||||||
this.code = code;
|
|
||||||
this.timestamp = System.currentTimeMillis();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOk() {
|
|
||||||
return SUCCESS_CODE.equals(this.code);
|
|
||||||
}
|
|
||||||
|
|
||||||
public T data() {
|
|
||||||
return (T) this.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object get(String key) {
|
|
||||||
if (this.data != null && key != null) {
|
|
||||||
return ((Map) this.data).get(key);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResObj() {
|
|
||||||
this.timestamp = System.currentTimeMillis();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ResObj ok() {
|
|
||||||
ResObj o = new ResObj(SUCCESS_CODE);
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ResObj ok(Object data) {
|
|
||||||
ResObj o = new ResObj(SUCCESS_CODE, data);
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ResObj fail(String msg) {
|
|
||||||
ResObj o = new ResObj(FAILURE_CODE, msg, null);
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static ResObj fail() {
|
|
||||||
ResObj o = new ResObj(FAILURE_CODE);
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ResObj result(Integer code, Object data) {
|
|
||||||
ResObj o = new ResObj(code, data);
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ResObj result(Integer code, String message, Object data) {
|
|
||||||
ResObj o = new ResObj(code, message, data);
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getCode() {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCode(Integer code) {
|
|
||||||
this.code = code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMessage() {
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMessage(String message) {
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public T getData() {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResObj<T> setData(T data) {
|
|
||||||
this.data = data;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getTimestamp() {
|
|
||||||
return timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResObj setTimestamp(Long timestamp) {
|
|
||||||
this.timestamp = timestamp;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map getExtr() {
|
|
||||||
return extr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Integer get_status() {
|
|
||||||
return _status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void set_status(Integer _status) {
|
|
||||||
this._status = _status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String get_trackId() {
|
|
||||||
return _trackId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void set_trackId(String _trackId) {
|
|
||||||
this._trackId = _trackId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResObj trackId(String _trackId) {
|
|
||||||
this._trackId = _trackId;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
if (message == null) {
|
|
||||||
return "ResObj(" + code + ")";
|
|
||||||
}
|
|
||||||
return "ResObj(" + code + "){" + message + "}";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package com.wabestway.recall.repository;
|
|
||||||
|
|
||||||
import com.wabestway.recall.model.Order;
|
|
||||||
import org.springframework.data.domain.*;
|
|
||||||
import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
|
|
||||||
import reactor.core.publisher.Flux;
|
|
||||||
import reactor.core.publisher.Mono;
|
|
||||||
|
|
||||||
public interface OrderRepository extends ReactiveMongoRepository<Order, String> {
|
|
||||||
Mono<Order> findByOrderId(String orderId);
|
|
||||||
|
|
||||||
Mono<Order> findByTraceId(String traceId);
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package com.wabestway.recall.repository;
|
|
||||||
|
|
||||||
|
|
||||||
import com.wabestway.recall.model.Record;
|
|
||||||
import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
|
|
||||||
import reactor.core.publisher.Flux;
|
|
||||||
|
|
||||||
|
|
||||||
public interface RecordRepository extends ReactiveMongoRepository<Record, String> {
|
|
||||||
Flux<Record> findAllByTraceIdOrderByCreateAtAsc(String traceId);
|
|
||||||
}
|
|
||||||
+8
-23
@@ -1,5 +1,6 @@
|
|||||||
package com.wabestway.recall.trace.controller;
|
package com.wabestway.recall.trace.controller;
|
||||||
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
@@ -10,16 +11,13 @@ import com.wabestway.recall.trace.service.RecallOrderApiService;
|
|||||||
import com.wabestway.commons.http.Paging;
|
import com.wabestway.commons.http.Paging;
|
||||||
import com.wabestway.commons.http.ResObj;
|
import com.wabestway.commons.http.ResObj;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
*
|
|
||||||
* @author wangH
|
* @author wangH
|
||||||
* @company 北京华焱坤泰科技有限公司
|
* @company 北京华焱坤泰科技有限公司
|
||||||
* @Time 2023-05-06 17:37:03
|
* @Time 2023-05-06 17:37:03
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/trace/recallOrder")
|
@RequestMapping("/order")
|
||||||
@Api(tags = {"-接口"}, description = "-接口")
|
@Api(tags = {"-接口"}, description = "-接口")
|
||||||
public class RecallOrderController {
|
public class RecallOrderController {
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -44,26 +42,13 @@ public class RecallOrderController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存
|
* 生成回溯MP4文件
|
||||||
|
*
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("/save")
|
@GetMapping("/ffmpeg")
|
||||||
@ApiOperation(value = "保存", notes = "保存", httpMethod = "POST")
|
public ResObj createMp4() {
|
||||||
public ResObj saveRecallOrder(@RequestBody RecallOrderDTO paramRequest) {
|
return recallOrderApiService.traceVideo();
|
||||||
return recallOrderApiService.saveRecallOrder(paramRequest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改
|
|
||||||
*/
|
|
||||||
@PostMapping("/update")
|
|
||||||
@ApiOperation(value = "修改", notes = "修改", httpMethod = "POST")
|
|
||||||
public ResObj updateRecallOrder(@RequestBody RecallOrderDTO paramRequest) {
|
|
||||||
return recallOrderApiService.updateRecallOrder(paramRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/changeStatus")
|
|
||||||
@ApiOperation(value = "启禁用更新", notes = "启禁用更新", httpMethod = "POST")
|
|
||||||
public ResObj changeStatus(@RequestBody RecallOrderDTO paramRequest) {
|
|
||||||
return recallOrderApiService.changeStatus(paramRequest.getId(), paramRequest.getStatus());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-39
@@ -1,69 +1,34 @@
|
|||||||
package com.wabestway.recall.trace.controller;
|
package com.wabestway.recall.trace.controller;
|
||||||
|
|
||||||
|
import com.wabestway.recall.trace.dto.TraceDTO;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import com.wabestway.recall.trace.dto.RecallRecordDTO;
|
|
||||||
import com.wabestway.recall.trace.vo.RecallRecordVO;
|
|
||||||
import com.wabestway.recall.trace.service.RecallRecordApiService;
|
import com.wabestway.recall.trace.service.RecallRecordApiService;
|
||||||
import com.wabestway.commons.http.Paging;
|
|
||||||
import com.wabestway.commons.http.ResObj;
|
import com.wabestway.commons.http.ResObj;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
*
|
|
||||||
* @author wangH
|
* @author wangH
|
||||||
* @company 北京华焱坤泰科技有限公司
|
* @company 北京华焱坤泰科技有限公司
|
||||||
* @Time 2023-05-06 17:37:03
|
* @Time 2023-05-06 17:37:03
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/trace/recallRecord")
|
@RequestMapping("/track")
|
||||||
@Api(tags = {"-接口"}, description = "-接口")
|
@Api(tags = {"-接口"}, description = "-接口")
|
||||||
public class RecallRecordController {
|
public class RecallRecordController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private RecallRecordApiService recallRecordApiService;
|
private RecallRecordApiService recallRecordApiService;
|
||||||
|
|
||||||
/**
|
|
||||||
* 列表
|
|
||||||
*/
|
|
||||||
@PostMapping("/list")
|
|
||||||
@ApiOperation(value = "分页列表查询", notes = "条件分页查询列表", httpMethod = "POST")
|
|
||||||
public ResObj<Paging<RecallRecordVO>> list(@RequestBody RecallRecordDTO paramRequest) {
|
|
||||||
return recallRecordApiService.list(paramRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 信息
|
|
||||||
*/
|
|
||||||
@GetMapping("/info/{id}")
|
|
||||||
@ApiOperation(value = "根据id查详情", notes = "根据id查详情", httpMethod = "GET")
|
|
||||||
public ResObj<RecallRecordVO> info(@PathVariable("id") String id) {
|
|
||||||
return recallRecordApiService.getRecallRecord(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存
|
* 保存
|
||||||
*/
|
*/
|
||||||
@PostMapping("/save")
|
@PostMapping("/save")
|
||||||
@ApiOperation(value = "保存", notes = "保存", httpMethod = "POST")
|
@ApiOperation(value = "保存", notes = "保存", httpMethod = "POST")
|
||||||
public ResObj saveRecallRecord(@RequestBody RecallRecordDTO paramRequest) {
|
public ResObj saveRecallRecord(@RequestBody TraceDTO record) {
|
||||||
return recallRecordApiService.saveRecallRecord(paramRequest);
|
return recallRecordApiService.save(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改
|
|
||||||
*/
|
|
||||||
@PostMapping("/update")
|
|
||||||
@ApiOperation(value = "修改", notes = "修改", httpMethod = "POST")
|
|
||||||
public ResObj updateRecallRecord(@RequestBody RecallRecordDTO paramRequest) {
|
|
||||||
return recallRecordApiService.updateRecallRecord(paramRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/changeStatus")
|
|
||||||
@ApiOperation(value = "启禁用更新", notes = "启禁用更新", httpMethod = "POST")
|
|
||||||
public ResObj changeStatus(@RequestBody RecallRecordDTO paramRequest) {
|
|
||||||
return recallRecordApiService.changeStatus(paramRequest.getId(), paramRequest.getStatus());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-19
@@ -29,26 +29,10 @@ public interface RecallOrderApiService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ResObj<RecallOrderVO> getRecallOrder(String id);
|
ResObj<RecallOrderVO> getRecallOrder(String id);
|
||||||
|
ResObj<RecallOrderVO> getRecallOrderByOrderId(String orderId);
|
||||||
/**
|
/**
|
||||||
* 保存
|
* 根据回溯文件生成MP4视频
|
||||||
* @param paramReq
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ResObj saveRecallOrder(RecallOrderDTO paramReq);
|
ResObj traceVideo();
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改
|
|
||||||
* @param paramReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
ResObj updateRecallOrder(RecallOrderDTO paramReq);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 启禁用
|
|
||||||
* @param id
|
|
||||||
* @param status
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
ResObj changeStatus(String id, String status);
|
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-33
@@ -1,15 +1,15 @@
|
|||||||
package com.wabestway.recall.trace.service;
|
package com.wabestway.recall.trace.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.wabestway.recall.trace.dto.RecallRecordDTO;
|
import com.wabestway.recall.trace.dto.RecallRecordDTO;
|
||||||
|
import com.wabestway.recall.trace.dto.TraceDTO;
|
||||||
import com.wabestway.recall.trace.vo.RecallRecordVO;
|
import com.wabestway.recall.trace.vo.RecallRecordVO;
|
||||||
import com.wabestway.commons.http.Paging;
|
import com.wabestway.commons.http.Paging;
|
||||||
import com.wabestway.commons.http.ResObj;
|
import com.wabestway.commons.http.ResObj;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
*
|
|
||||||
* @author wangH
|
* @author wangH
|
||||||
* @company 北京华焱坤泰科技有限公司
|
* @company 北京华焱坤泰科技有限公司
|
||||||
* @Time 2023-05-06 17:37:03
|
* @Time 2023-05-06 17:37:03
|
||||||
@@ -17,38 +17,11 @@ import com.wabestway.commons.http.ResObj;
|
|||||||
public interface RecallRecordApiService {
|
public interface RecallRecordApiService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表
|
* 回溯数据记录
|
||||||
* @param paramReq
|
*
|
||||||
|
* @param record
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ResObj<Paging<RecallRecordVO>> list(RecallRecordDTO paramReq);
|
ResObj save(TraceDTO record);
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询详情
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
ResObj<RecallRecordVO> getRecallRecord(String id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存
|
|
||||||
* @param paramReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
ResObj saveRecallRecord(RecallRecordDTO paramReq);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改
|
|
||||||
* @param paramReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
ResObj updateRecallRecord(RecallRecordDTO paramReq);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 启禁用
|
|
||||||
* @param id
|
|
||||||
* @param status
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
ResObj changeStatus(String id, String status);
|
|
||||||
}
|
}
|
||||||
|
|||||||
+129
-41
@@ -1,31 +1,48 @@
|
|||||||
package com.wabestway.recall.trace.service.impl;
|
package com.wabestway.recall.trace.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.io.FileUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.wabestway.commons.http.Paging;
|
import com.wabestway.commons.http.Paging;
|
||||||
import com.wabestway.commons.http.ResObj;
|
import com.wabestway.commons.http.ResObj;
|
||||||
import com.wabestway.commons.enums.DataValidEnum;
|
import com.wabestway.engine.api.dfs.UploadFileDTO;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import com.wabestway.engine.api.dfs.UploadRespVO;
|
||||||
import org.springframework.beans.BeanUtils;
|
import com.wabestway.engine.api.feign.DfsStorageFeignClient;
|
||||||
import com.wabestway.ins.utils.UUIDUtil;
|
|
||||||
import com.wabestway.recall.trace.entity.RecallOrderEntity;
|
import com.wabestway.recall.trace.entity.RecallOrderEntity;
|
||||||
|
import com.wabestway.recall.trace.entity.RecallRecordEntity;
|
||||||
|
import com.wabestway.recall.trace.service.RecallOrderService;
|
||||||
|
import com.wabestway.recall.trace.service.RecallRecordService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import com.wabestway.recall.trace.dto.RecallOrderDTO;
|
import com.wabestway.recall.trace.dto.RecallOrderDTO;
|
||||||
import com.wabestway.recall.trace.vo.RecallOrderVO;
|
import com.wabestway.recall.trace.vo.RecallOrderVO;
|
||||||
import com.wabestway.recall.trace.service.RecallOrderApiService;
|
import com.wabestway.recall.trace.service.RecallOrderApiService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import com.wabestway.recall.trace.util.HeaderDataUtil;
|
import java.io.*;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
*
|
|
||||||
* @author wangH
|
* @author wangH
|
||||||
* @company 北京华焱坤泰科技有限公司
|
* @company 北京华焱坤泰科技有限公司
|
||||||
* @Time 2023-05-06 17:37:03
|
* @Time 2023-05-06 17:37:03
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class RecallOrderApiServiceImpl implements RecallOrderApiService {
|
public class RecallOrderApiServiceImpl implements RecallOrderApiService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private RecallOrderService recallOrderService;
|
private RecallOrderService recallOrderService;
|
||||||
|
@Autowired
|
||||||
|
private DfsStorageFeignClient storageFeignClient;
|
||||||
|
@Autowired
|
||||||
|
private RecallRecordService recallRecordService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResObj<Paging<RecallOrderVO>> list(RecallOrderDTO paramReq) {
|
public ResObj<Paging<RecallOrderVO>> list(RecallOrderDTO paramReq) {
|
||||||
@@ -38,48 +55,119 @@ public class RecallOrderApiServiceImpl implements RecallOrderApiService {
|
|||||||
@Override
|
@Override
|
||||||
public ResObj<RecallOrderVO> getRecallOrder(String id) {
|
public ResObj<RecallOrderVO> getRecallOrder(String id) {
|
||||||
RecallOrderVO recallOrderVO = recallOrderService.queryRecallOrderById(id);
|
RecallOrderVO recallOrderVO = recallOrderService.queryRecallOrderById(id);
|
||||||
|
|
||||||
return ResObj.ok(recallOrderVO);
|
return ResObj.ok(recallOrderVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
|
||||||
@Override
|
@Override
|
||||||
public ResObj saveRecallOrder(RecallOrderDTO paramReq) {
|
public ResObj<RecallOrderVO> getRecallOrderByOrderId(String orderId) {
|
||||||
RecallOrderEntity recallOrder = new RecallOrderEntity();
|
return null;
|
||||||
BeanUtils.copyProperties(paramReq, recallOrder);
|
}
|
||||||
|
|
||||||
recallOrder.setId(UUIDUtil.generate());//赋值id
|
@Override
|
||||||
recallOrder.setStatus(DataValidEnum.VALID.getCode());
|
public ResObj traceVideo() {
|
||||||
recallOrder.setCreateBy(HeaderDataUtil.getUserId());//创建人
|
LambdaQueryWrapper<RecallOrderEntity> orderQuery = Wrappers.lambdaQuery();
|
||||||
recallOrder.setCreateTime(System.currentTimeMillis());//创建时间
|
orderQuery.eq(RecallOrderEntity::getComplete, "1");
|
||||||
recallOrder.setUpdateBy(HeaderDataUtil.getUserId());//更新人
|
orderQuery.isNull(RecallOrderEntity::getFileId);
|
||||||
recallOrder.setUpdateTime(System.currentTimeMillis());//更新时间
|
orderQuery.orderByDesc(RecallOrderEntity::getCompleteDate);
|
||||||
|
List<RecallOrderEntity> orderList = recallOrderService.getBaseMapper().selectList(orderQuery);
|
||||||
|
orderList.forEach(order -> {
|
||||||
|
LambdaQueryWrapper<RecallRecordEntity> recordQuery = Wrappers.lambdaQuery();
|
||||||
|
recordQuery.eq(RecallRecordEntity::getTraceId, order.getTraceId());
|
||||||
|
recordQuery.orderByAsc(RecallRecordEntity::getCreateTime);
|
||||||
|
List<RecallRecordEntity> recordList = recallRecordService.getBaseMapper().selectList(recordQuery);
|
||||||
|
|
||||||
recallOrderService.save(recallOrder);
|
List<String> events = recordList.stream()
|
||||||
|
.flatMap(entity -> entity.getEvents().stream())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
JSONArray array = JSONArray.parseArray(JSON.toJSONString(events));
|
||||||
|
try {
|
||||||
|
createVideo(order, array.toJSONString());
|
||||||
|
} catch (IOException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
return ResObj.ok();
|
return ResObj.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
void createVideo(RecallOrderEntity fo, String jsonData) throws IOException {
|
||||||
@Override
|
|
||||||
public ResObj updateRecallOrder(RecallOrderDTO paramReq) {
|
// 创建临时目录
|
||||||
RecallOrderEntity recallOrder = new RecallOrderEntity();
|
Path tempDir = null;
|
||||||
BeanUtils.copyProperties(paramReq, recallOrder);
|
try {
|
||||||
recallOrder.setUpdateBy(HeaderDataUtil.getUserId());//更新人
|
tempDir = Files.createTempDirectory("ts");
|
||||||
recallOrder.setUpdateTime(System.currentTimeMillis());//更新时间
|
} catch (IOException e) {
|
||||||
recallOrderService.updateById(recallOrder);
|
e.printStackTrace();
|
||||||
return ResObj.ok();
|
}
|
||||||
|
System.out.println("Created temporary directory: " + tempDir);
|
||||||
|
|
||||||
|
try {
|
||||||
|
File tempFile = new File(tempDir.toFile(), "traces.json");
|
||||||
|
FileWriter fw = new FileWriter(tempFile);
|
||||||
|
BufferedWriter bw = new BufferedWriter(fw);
|
||||||
|
bw.write(jsonData);
|
||||||
|
bw.flush();
|
||||||
|
bw.close();
|
||||||
|
fw.close();
|
||||||
|
String[] command = {"ts-node", "/opt/trace-transform/src/index.ts"};
|
||||||
|
ProcessBuilder processBuilder = new ProcessBuilder(command);
|
||||||
|
processBuilder.directory(tempDir.toFile());
|
||||||
|
// 在临时目录下执行命令
|
||||||
|
Process process = processBuilder.start();
|
||||||
|
|
||||||
|
Thread processThread = new Thread(() -> {
|
||||||
|
try {
|
||||||
|
// 读取命令输出
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||||
|
String line;
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
System.out.println(line);
|
||||||
|
}
|
||||||
|
reader.close();
|
||||||
|
// 等待命令执行完成
|
||||||
|
int exitCode = process.waitFor();
|
||||||
|
|
||||||
|
System.out.println("Command exited with code " + exitCode);
|
||||||
|
} catch (InterruptedException | IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
processThread.start();
|
||||||
|
|
||||||
|
// Continue with other tasks here...
|
||||||
|
|
||||||
|
try {
|
||||||
|
processThread.join();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
File file = new File(tempDir.toFile(), "video.mp4");
|
||||||
|
if (file.exists()) {
|
||||||
|
log.info(String.valueOf(file.length()));
|
||||||
|
//byte[] fileBytes = Files.readAllBytes(file.toPath());
|
||||||
|
byte[] fileBytes = FileUtil.readBytes(file);
|
||||||
|
String titles = fo.getOrderId() + ".mp4";
|
||||||
|
UploadFileDTO uploadFileDTO = new UploadFileDTO(fileBytes, "RECALL", titles);
|
||||||
|
|
||||||
|
ResObj<UploadRespVO> uploadResObj = storageFeignClient.uploadBytes(uploadFileDTO);
|
||||||
|
log.info(JSON.toJSONString(uploadResObj));
|
||||||
|
if (uploadResObj.isOk()) {
|
||||||
|
fo.setFileId(uploadResObj.getData().getFileId());
|
||||||
|
fo.setFileUrl(uploadResObj.getData().getFileUrl());
|
||||||
|
fo.setUpdateTime(System.currentTimeMillis());
|
||||||
|
recallOrderService.updateRecallOrderById(fo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error(e.getMessage());
|
||||||
|
} finally {
|
||||||
|
// 删除临时目录
|
||||||
|
Files.walk(tempDir)
|
||||||
|
.sorted(Comparator.reverseOrder())
|
||||||
|
.map(Path::toFile)
|
||||||
|
.forEach(File::delete);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
|
||||||
@Override
|
|
||||||
public ResObj changeStatus(String id, String status) {
|
|
||||||
RecallOrderEntity recallOrder = new RecallOrderEntity();
|
|
||||||
recallOrder.setId(id);
|
|
||||||
recallOrder.setStatus(status);
|
|
||||||
recallOrder.setUpdateBy(HeaderDataUtil.getUserId());
|
|
||||||
recallOrder.setUpdateTime(System.currentTimeMillis());
|
|
||||||
recallOrderService.updateRecallOrderById(recallOrder);
|
|
||||||
|
|
||||||
return ResObj.ok();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+58
-58
@@ -1,85 +1,85 @@
|
|||||||
package com.wabestway.recall.trace.service.impl;
|
package com.wabestway.recall.trace.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
||||||
import com.wabestway.commons.http.Paging;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.wabestway.commons.http.ResObj;
|
import com.wabestway.commons.http.ResObj;
|
||||||
import com.wabestway.commons.enums.DataValidEnum;
|
import com.wabestway.recall.trace.dto.TraceDTO;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import com.wabestway.recall.trace.entity.RecallOrderEntity;
|
||||||
import org.springframework.beans.BeanUtils;
|
|
||||||
import com.wabestway.ins.utils.UUIDUtil;
|
|
||||||
import com.wabestway.recall.trace.entity.RecallRecordEntity;
|
import com.wabestway.recall.trace.entity.RecallRecordEntity;
|
||||||
import com.wabestway.recall.trace.dto.RecallRecordDTO;
|
import com.wabestway.recall.trace.service.RecallOrderService;
|
||||||
import com.wabestway.recall.trace.vo.RecallRecordVO;
|
import com.wabestway.recall.trace.service.RecallRecordService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import com.wabestway.recall.trace.service.RecallRecordApiService;
|
import com.wabestway.recall.trace.service.RecallRecordApiService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import com.wabestway.recall.trace.util.HeaderDataUtil;
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
*
|
|
||||||
* @author wangH
|
* @author wangH
|
||||||
* @company 北京华焱坤泰科技有限公司
|
* @company 北京华焱坤泰科技有限公司
|
||||||
* @Time 2023-05-06 17:37:03
|
* @Time 2023-05-06 17:37:03
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@Slf4j
|
||||||
public class RecallRecordApiServiceImpl implements RecallRecordApiService {
|
public class RecallRecordApiServiceImpl implements RecallRecordApiService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private RecallRecordService recallRecordService;
|
private RecallRecordService recallRecordService;
|
||||||
|
@Autowired
|
||||||
|
private RecallOrderService recallOrderService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResObj<Paging<RecallRecordVO>> list(RecallRecordDTO paramReq) {
|
public ResObj save(TraceDTO record) {
|
||||||
IPage<RecallRecordVO> resultPage = recallRecordService.queryRecallRecordByCondition(paramReq.getPage(), paramReq.getPageSize(), paramReq);
|
String orderId = record.getOrderId();
|
||||||
|
String traceId = Optional.ofNullable(orderId)
|
||||||
|
.map(recallOrderService::queryRecallOrderByOrderId)
|
||||||
|
.map(RecallOrderEntity::getTraceId)
|
||||||
|
.orElse(UUID.randomUUID().toString().replace("-", ""));
|
||||||
|
|
||||||
Paging<RecallRecordVO> paging = new Paging(resultPage.getRecords(), paramReq.getPage(), resultPage.getSize(), resultPage.getTotal());
|
boolean isLastEvent = record.isLast();
|
||||||
return ResObj.ok(paging);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
RecallOrderEntity order = Optional.ofNullable(orderId)
|
||||||
public ResObj<RecallRecordVO> getRecallRecord(String id) {
|
.flatMap(id -> Optional.ofNullable(recallOrderService.queryRecallOrderByOrderId(id)))
|
||||||
RecallRecordVO recallRecordVO = recallRecordService.queryRecallRecordById(id);
|
.orElseGet(() -> {
|
||||||
|
RecallOrderEntity newOrder = new RecallOrderEntity();
|
||||||
|
newOrder.setId(UUID.randomUUID().toString().replace("-", ""));
|
||||||
|
newOrder.setOrderId(orderId);
|
||||||
|
newOrder.setTraceId(traceId);
|
||||||
|
newOrder.setProductCode(record.getProductCode());
|
||||||
|
newOrder.setProductName(record.getProductName());
|
||||||
|
newOrder.setCreateTime(System.currentTimeMillis());
|
||||||
|
newOrder.setUpdateTime(System.currentTimeMillis());
|
||||||
|
newOrder.setAppKey(record.getAppKey());
|
||||||
|
newOrder.setArchived("0");
|
||||||
|
newOrder.setComplete(isLastEvent ? "1" : "0");
|
||||||
|
if (isLastEvent) {
|
||||||
|
newOrder.setCompleteDate(System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
recallOrderService.save(newOrder);
|
||||||
|
|
||||||
return ResObj.ok(recallRecordVO);
|
record.setTraceId(traceId);
|
||||||
}
|
record.setOrderId(orderId);
|
||||||
|
return newOrder;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (isLastEvent) {
|
||||||
|
order.setComplete("1");
|
||||||
|
order.setCompleteDate(System.currentTimeMillis());
|
||||||
|
order.setUpdateTime(System.currentTimeMillis());
|
||||||
|
recallOrderService.updateRecallOrderById(order);
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional
|
|
||||||
@Override
|
|
||||||
public ResObj saveRecallRecord(RecallRecordDTO paramReq) {
|
|
||||||
RecallRecordEntity recallRecord = new RecallRecordEntity();
|
RecallRecordEntity recallRecord = new RecallRecordEntity();
|
||||||
BeanUtils.copyProperties(paramReq, recallRecord);
|
BeanUtils.copyProperties(record, recallRecord);
|
||||||
|
recallRecord.setId(UUID.randomUUID().toString().replace("-", ""));
|
||||||
recallRecord.setId(UUIDUtil.generate());//赋值id
|
recallRecord.setCreateTime(System.currentTimeMillis());
|
||||||
recallRecord.setStatus(DataValidEnum.VALID.getCode());
|
|
||||||
recallRecord.setCreateBy(HeaderDataUtil.getUserId());//创建人
|
|
||||||
recallRecord.setCreateTime(System.currentTimeMillis());//创建时间
|
|
||||||
recallRecord.setUpdateBy(HeaderDataUtil.getUserId());//更新人
|
|
||||||
recallRecord.setUpdateTime(System.currentTimeMillis());//更新时间
|
|
||||||
|
|
||||||
recallRecordService.save(recallRecord);
|
recallRecordService.save(recallRecord);
|
||||||
return ResObj.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
record.setEvents(null);
|
||||||
@Override
|
log.info("保存数据:{}", JSON.toJSONString(record));
|
||||||
public ResObj updateRecallRecord(RecallRecordDTO paramReq) {
|
return ResObj.ok(record);
|
||||||
RecallRecordEntity recallRecord = new RecallRecordEntity();
|
|
||||||
BeanUtils.copyProperties(paramReq, recallRecord);
|
|
||||||
recallRecord.setUpdateBy(HeaderDataUtil.getUserId());//更新人
|
|
||||||
recallRecord.setUpdateTime(System.currentTimeMillis());//更新时间
|
|
||||||
recallRecordService.updateById(recallRecord);
|
|
||||||
return ResObj.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
@Override
|
|
||||||
public ResObj changeStatus(String id, String status) {
|
|
||||||
RecallRecordEntity recallRecord = new RecallRecordEntity();
|
|
||||||
recallRecord.setId(id);
|
|
||||||
recallRecord.setStatus(status);
|
|
||||||
recallRecord.setUpdateBy(HeaderDataUtil.getUserId());
|
|
||||||
recallRecord.setUpdateTime(System.currentTimeMillis());
|
|
||||||
recallRecordService.updateRecallRecordById(recallRecord);
|
|
||||||
|
|
||||||
return ResObj.ok();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,196 +0,0 @@
|
|||||||
package com.wabestway.recall.web;
|
|
||||||
|
|
||||||
import cn.hutool.core.io.FileUtil;
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
|
||||||
import com.wabestway.commons.http.ResObj;
|
|
||||||
import com.wabestway.engine.api.dfs.UploadFileDTO;
|
|
||||||
import com.wabestway.engine.api.dfs.UploadRespVO;
|
|
||||||
import com.wabestway.engine.api.feign.DfsStorageFeignClient;
|
|
||||||
import com.wabestway.recall.model.Order;
|
|
||||||
import com.wabestway.recall.model.OrderList;
|
|
||||||
import com.wabestway.recall.model.Record;
|
|
||||||
import com.wabestway.recall.repository.OrderRepository;
|
|
||||||
import com.wabestway.recall.repository.RecordRepository;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.data.domain.*;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import reactor.core.publisher.Flux;
|
|
||||||
import reactor.core.publisher.Mono;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/order")
|
|
||||||
public class OrderController {
|
|
||||||
private final RecordRepository recordRepository;
|
|
||||||
private final OrderRepository orderRepository;
|
|
||||||
|
|
||||||
private final DfsStorageFeignClient storageFeignClient;
|
|
||||||
|
|
||||||
public OrderController(RecordRepository recordRepository, OrderRepository orderRepository, DfsStorageFeignClient storageFeignClient) {
|
|
||||||
this.recordRepository = recordRepository;
|
|
||||||
this.orderRepository = orderRepository;
|
|
||||||
this.storageFeignClient = storageFeignClient;
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping
|
|
||||||
public Flux<Order> getAllOrders() {
|
|
||||||
return orderRepository.findAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/list")
|
|
||||||
public Mono<ResObj> list(@RequestBody Order order) {
|
|
||||||
OrderList resList = new OrderList();
|
|
||||||
List<Order> list = new ArrayList<>();
|
|
||||||
Sort s = Sort.by("createAt").descending();
|
|
||||||
PageRequest pageRequest = PageRequest.of(order.getPage() - 1, order.getPageSize(), s);
|
|
||||||
ExampleMatcher matcher = ExampleMatcher.matching()
|
|
||||||
.withIgnoreNullValues().withIgnorePaths("createAt", "last", "page", "pageSize");
|
|
||||||
Example<Order> ep = Example.of(order, matcher);
|
|
||||||
Flux<Order> flux = orderRepository.findAll(ep, s);
|
|
||||||
flux.skip(pageRequest.getOffset()).limitRequest(pageRequest.getPageSize()).subscribe(list::add);
|
|
||||||
resList.setList(list);
|
|
||||||
return flux.count().flatMap(count -> {
|
|
||||||
resList.setTotal(count);
|
|
||||||
return Mono.just(ResObj.ok(resList));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/recallUp")
|
|
||||||
public Mono<ResObj> recallUp(@RequestBody Order order) {
|
|
||||||
Mono<Order> queryOrder = orderRepository.findByOrderId(order.getOrderId());
|
|
||||||
return queryOrder.flatMap(ss -> {
|
|
||||||
ss.setStartDate(order.getStartDate());
|
|
||||||
ss.setEndDate(order.getEndDate());
|
|
||||||
ss.setHolderName(order.getHolderName());
|
|
||||||
ss.setHolderPhone(order.getHolderPhone());
|
|
||||||
ss.setSupplierName(order.getSupplierName());
|
|
||||||
orderRepository.save(ss).subscribe();
|
|
||||||
return Mono.just(ResObj.ok());
|
|
||||||
}).defaultIfEmpty(ResObj.fail("订单不存在"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/info/{orderId}")
|
|
||||||
public Mono<ResObj> findByOrderId(@PathVariable String orderId) {
|
|
||||||
Mono<Order> forder = orderRepository.findByOrderId(orderId);
|
|
||||||
return forder.flatMap(fo -> {
|
|
||||||
Flux<Record> rs = recordRepository.findAllByTraceIdOrderByCreateAtAsc(fo.getTraceId());
|
|
||||||
Mono<List<List<String>>> es = rs.map(rr -> rr.getEvents()).collectList();
|
|
||||||
Mono<List<String>> events = es.flatMapIterable(lists -> lists).flatMapIterable(list -> list).collectList();
|
|
||||||
return events.flatMap(e -> {
|
|
||||||
fo.setEvents(e);
|
|
||||||
return Mono.just(ResObj.ok(fo));
|
|
||||||
});
|
|
||||||
}).defaultIfEmpty(ResObj.fail("订单不存在"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/ffmpeg")
|
|
||||||
public Mono<ResObj> createMp4() {
|
|
||||||
Order order = new Order();
|
|
||||||
order.setComplete("1");
|
|
||||||
ExampleMatcher matcher = ExampleMatcher.matching()
|
|
||||||
.withIgnoreNullValues().withIgnorePaths("createAt", "last", "page", "pageSize");
|
|
||||||
Example<Order> ep = Example.of(order, matcher);
|
|
||||||
Sort s = Sort.by("createAt");
|
|
||||||
Flux<Order> flux = orderRepository.findAll(ep, s);
|
|
||||||
flux.filter(fo -> fo.getFileId() == null).subscribe(fo -> {
|
|
||||||
Mono<List<List<String>>> es = recordRepository.findAllByTraceIdOrderByCreateAtAsc(fo.getTraceId()).map(rr -> rr.getEvents()).collectList();
|
|
||||||
Mono<List<String>> events = es.flatMapIterable(lists -> lists).flatMapIterable(list -> list).collectList();
|
|
||||||
events.subscribe(e -> {
|
|
||||||
JSONArray array = JSONArray.parseArray(JSON.toJSONString(e));
|
|
||||||
try {
|
|
||||||
createVideo(fo, array.toJSONString());
|
|
||||||
} catch (IOException ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return Mono.just(ResObj.ok());
|
|
||||||
}
|
|
||||||
|
|
||||||
void createVideo(Order fo, String jsonData) throws IOException {
|
|
||||||
|
|
||||||
// 创建临时目录
|
|
||||||
Path tempDir = null;
|
|
||||||
try {
|
|
||||||
tempDir = Files.createTempDirectory("ts");
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
System.out.println("Created temporary directory: " + tempDir);
|
|
||||||
|
|
||||||
try {
|
|
||||||
File tempFile = new File(tempDir.toFile(), "traces.json");
|
|
||||||
FileWriter fw = new FileWriter(tempFile);
|
|
||||||
BufferedWriter bw = new BufferedWriter(fw);
|
|
||||||
bw.write(jsonData);
|
|
||||||
bw.flush();
|
|
||||||
bw.close();
|
|
||||||
fw.close();
|
|
||||||
String[] command = {"ts-node", "/opt/trace-transform/src/index.ts"};
|
|
||||||
ProcessBuilder processBuilder = new ProcessBuilder(command);
|
|
||||||
processBuilder.directory(tempDir.toFile());
|
|
||||||
// 在临时目录下执行命令
|
|
||||||
Process process = processBuilder.start();
|
|
||||||
|
|
||||||
Thread processThread = new Thread(() -> {
|
|
||||||
try {
|
|
||||||
// 读取命令输出
|
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
|
||||||
String line;
|
|
||||||
while ((line = reader.readLine()) != null) {
|
|
||||||
System.out.println(line);
|
|
||||||
}
|
|
||||||
reader.close();
|
|
||||||
// 等待命令执行完成
|
|
||||||
int exitCode = process.waitFor();
|
|
||||||
|
|
||||||
System.out.println("Command exited with code " + exitCode);
|
|
||||||
} catch (InterruptedException | IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
processThread.start();
|
|
||||||
|
|
||||||
// Continue with other tasks here...
|
|
||||||
|
|
||||||
try {
|
|
||||||
processThread.join();
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
File file = new File(tempDir.toFile(), "video.mp4");
|
|
||||||
if (file.exists()) {
|
|
||||||
log.info(String.valueOf(file.length()));
|
|
||||||
//byte[] fileBytes = Files.readAllBytes(file.toPath());
|
|
||||||
byte[] fileBytes = FileUtil.readBytes(file);
|
|
||||||
String titles = fo.getOrderId() + ".mp4";
|
|
||||||
UploadFileDTO uploadFileDTO = new UploadFileDTO(fileBytes, "RECALL", titles);
|
|
||||||
|
|
||||||
ResObj<UploadRespVO> uploadResObj = storageFeignClient.uploadBytes(uploadFileDTO);
|
|
||||||
log.info(JSON.toJSONString(uploadResObj));
|
|
||||||
if (uploadResObj.isOk()) {
|
|
||||||
fo.setFileId(uploadResObj.getData().getFileId());
|
|
||||||
fo.setFileUrl(uploadResObj.getData().getFileUrl());
|
|
||||||
orderRepository.save(fo).subscribe();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
log.error(e.getMessage());
|
|
||||||
} finally {
|
|
||||||
// 删除临时目录
|
|
||||||
// Files.walk(tempDir)
|
|
||||||
// .sorted(Comparator.reverseOrder())
|
|
||||||
// .map(Path::toFile)
|
|
||||||
// .forEach(File::delete);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
package com.wabestway.recall.web;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.wabestway.recall.model.Order;
|
|
||||||
import com.wabestway.recall.model.Record;
|
|
||||||
import com.wabestway.recall.model.ResObj;
|
|
||||||
import com.wabestway.recall.repository.OrderRepository;
|
|
||||||
import com.wabestway.recall.repository.RecordRepository;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import reactor.core.publisher.Flux;
|
|
||||||
import reactor.core.publisher.Mono;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/track")
|
|
||||||
public class RecallController {
|
|
||||||
private final RecordRepository recordRepository;
|
|
||||||
private final OrderRepository orderRepository;
|
|
||||||
|
|
||||||
public RecallController(RecordRepository recordRepository, OrderRepository orderRepository) {
|
|
||||||
this.recordRepository = recordRepository;
|
|
||||||
this.orderRepository = orderRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping
|
|
||||||
public Flux<Record> getAllUsers() {
|
|
||||||
return recordRepository.findAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/save")
|
|
||||||
public Mono<ResObj> save(@RequestBody Record record) {
|
|
||||||
if (record.getOrderId() != null && !record.getOrderId().isEmpty()) {
|
|
||||||
Mono<Order> order = orderRepository.findByOrderId(record.getOrderId());
|
|
||||||
order.hasElement().subscribe(exit -> {
|
|
||||||
if (!exit) {
|
|
||||||
if (record.getTraceId() != null && !record.getTraceId().isEmpty()) {
|
|
||||||
Mono<Order> tcOrder = orderRepository.findByTraceId(record.getTraceId());
|
|
||||||
tcOrder.filter(to -> to.getId() != null).flatMap(to -> {
|
|
||||||
to.setOrderId(record.getOrderId());
|
|
||||||
if (record.isLast()) {
|
|
||||||
to.setComplete("1");
|
|
||||||
}
|
|
||||||
return orderRepository.save(to);
|
|
||||||
}).subscribe();
|
|
||||||
} else {
|
|
||||||
record.setTraceId(UUID.randomUUID().toString().replace("-", ""));
|
|
||||||
Order forder = new Order();
|
|
||||||
forder.setOrderId(record.getOrderId());
|
|
||||||
forder.setTraceId(record.getTraceId());
|
|
||||||
forder.setProductCode(record.getProductCode());
|
|
||||||
forder.setProductName(record.getProductName());
|
|
||||||
forder.setCreateAt(System.currentTimeMillis());
|
|
||||||
forder.setAppKey(record.getAppKey());
|
|
||||||
forder.setArchived("0");
|
|
||||||
forder.setComplete("0");
|
|
||||||
// forder.setHolderName("王五");
|
|
||||||
// forder.setHolderPhone("18515064530");
|
|
||||||
// forder.setSupplierName("阳光保险");
|
|
||||||
// forder.setStartDate("2023-01-01");
|
|
||||||
// forder.setEndDate("2035-01-01");
|
|
||||||
if (record.isLast()) {
|
|
||||||
forder.setComplete("1");
|
|
||||||
}
|
|
||||||
orderRepository.save(forder).subscribe();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
order.subscribe(to -> {
|
|
||||||
if (record.isLast()) {
|
|
||||||
to.setComplete("1");
|
|
||||||
orderRepository.save(to).subscribe();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
if (record.getTraceId() == null || record.getTraceId().isEmpty()) {
|
|
||||||
record.setTraceId(UUID.randomUUID().toString().replace("-", ""));
|
|
||||||
Order order = new Order();
|
|
||||||
order.setTraceId(record.getTraceId());
|
|
||||||
order.setProductCode(record.getProductCode());
|
|
||||||
order.setProductName(record.getProductName());
|
|
||||||
order.setCreateAt(System.currentTimeMillis());
|
|
||||||
order.setAppKey(record.getAppKey());
|
|
||||||
order.setArchived("0");
|
|
||||||
order.setComplete("0");
|
|
||||||
// order.setHolderName("王五");
|
|
||||||
// order.setHolderPhone("18515064530");
|
|
||||||
// order.setSupplierName("阳光保险");
|
|
||||||
// order.setStartDate("2023-01-01");
|
|
||||||
// order.setEndDate("2035-01-01");
|
|
||||||
if (record.isLast()) {
|
|
||||||
order.setComplete("1");
|
|
||||||
}
|
|
||||||
orderRepository.save(order).subscribe();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
record.setCreateAt(System.currentTimeMillis());
|
|
||||||
log.info("保存数据:{}", JSON.toJSONString(record));
|
|
||||||
return recordRepository.save(record).flatMap(ss -> {
|
|
||||||
ss.setEvents(null);
|
|
||||||
return Mono.just(ResObj.ok(ss));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user