|
@@ -1,10 +1,14 @@
|
|
|
package com.sp.socket.script;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.sp.SocketApplication;
|
|
|
import com.sp.director.ienum.ContentTypeEnum;
|
|
|
import com.sp.director.ienum.OperationTypeEnum;
|
|
|
+import com.sp.director.ienum.RelativePositionEnum;
|
|
|
+import com.sp.director.module.script.dao.ScriptContentVersionHistoryDao;
|
|
|
import com.sp.director.module.script.entity.ScriptContentVersionHistory;
|
|
|
+import com.sp.director.module.script.help.ScriptContentVersionOperator;
|
|
|
import com.sp.director.module.script.model.LineContentModel;
|
|
|
import com.sp.director.module.script.model.LineInfoModel;
|
|
|
import com.sp.director.module.script.model.OperatorModel;
|
|
@@ -24,6 +28,7 @@ import javax.jms.JMSException;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
|
* @Descrption
|
|
@@ -43,10 +48,21 @@ public class ScriptOperator {
|
|
|
@Autowired
|
|
|
private DefaultCacheManager defaultCacheManager;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ScriptContentVersionHistoryDao scriptContentVersionHistoryDao;
|
|
|
+
|
|
|
@Test
|
|
|
+ public void insert() throws JMSException, InterruptedException {
|
|
|
+ insertNode(11111111L);
|
|
|
+ TimeUnit.SECONDS.sleep(10);
|
|
|
+ System.out.println("done");
|
|
|
+ chapterContent();
|
|
|
+ }
|
|
|
+
|
|
|
+// @Test
|
|
|
public void insertNode(Long chapterId) throws JMSException {
|
|
|
int contentIndex = 1;
|
|
|
- Long beforeLineId = null;
|
|
|
+ Long baseLineId = null;
|
|
|
List<ScriptContentVersionHistory> persistenceNodeList = new ArrayList<>(30);
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
OperatorModel operatorModel = new OperatorModel();
|
|
@@ -63,12 +79,13 @@ public class ScriptOperator {
|
|
|
lineInfoModel.setColorName(contentModel.getColorName());
|
|
|
operatorModel.setModel(lineInfoModel);
|
|
|
operatorModel.setOperationType(OperationTypeEnum.ADD);
|
|
|
- if(beforeLineId == null){
|
|
|
- operatorModel.setBeforeLineId(null);
|
|
|
- beforeLineId = 0L;
|
|
|
+ if(baseLineId == null){
|
|
|
+ operatorModel.setBaseLineId(null);
|
|
|
+ operatorModel.setPosition(null);
|
|
|
+ baseLineId = 0L;
|
|
|
}else{
|
|
|
- beforeLineId++;
|
|
|
- operatorModel.setBeforeLineId(beforeLineId.toString());
|
|
|
+ operatorModel.setBaseLineId(baseLineId.toString());
|
|
|
+ operatorModel.setPosition(RelativePositionEnum.AFTER);
|
|
|
}
|
|
|
|
|
|
operatorModel.setChapterId(chapterId.toString());
|
|
@@ -83,6 +100,7 @@ public class ScriptOperator {
|
|
|
scriptContentVersionHistoryService.evictCacheChapterLineNum(chapterId);
|
|
|
scriptContentVersionHistoryService.queryOrSaveCacheChapterLineNum(chapterId, lineNum);
|
|
|
model.setLineId(lineNum.toString());
|
|
|
+ baseLineId = lineNum;
|
|
|
}
|
|
|
String latestSerialNumStr = scriptContentVersionHistoryService.queryOrSaveCacheChapterSerialNum(chapterId, null);
|
|
|
System.err.println("serialNum" + latestSerialNumStr);
|
|
@@ -99,14 +117,15 @@ public class ScriptOperator {
|
|
|
bo.setSerialNumber(operatorModel.getSerialNumber());
|
|
|
bo.setModel(model);
|
|
|
bo.setOperationType(operatorModel.getOperationType());
|
|
|
- bo.setBeforeLineId(operatorModel.getBeforeLineId());
|
|
|
+ bo.setBaseLineId(operatorModel.getBaseLineId());
|
|
|
bo.setModifyDateTime(LocalDateTime.now());
|
|
|
|
|
|
ScriptContentVersionHistory history = new ScriptContentVersionHistory();
|
|
|
history.setChapterId(Long.valueOf(bo.getChapterId()));
|
|
|
history.setContent(JSON.toJSONString(bo.getModel()));
|
|
|
history.setType(bo.getOperationType());
|
|
|
- history.setBeforeLineId(bo.getBeforeLineId() != null ? Long.valueOf(bo.getBeforeLineId()) : null);
|
|
|
+ history.setBaseLineId(bo.getBaseLineId() != null ? Long.valueOf(bo.getBaseLineId()) : null);
|
|
|
+ history.setPosition(bo.getPosition());
|
|
|
history.setSerialNum(bo.getSerialNumber());
|
|
|
history.setLineId(Long.valueOf(bo.getModel().getLineId()));
|
|
|
history.setModifyUserId(bo.getModifyUserId());
|
|
@@ -118,5 +137,28 @@ public class ScriptOperator {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @Test
|
|
|
+ public void chapterContent(){
|
|
|
+ QueryWrapper<ScriptContentVersionHistory> qw = new QueryWrapper<>();
|
|
|
+ qw.lambda().eq(ScriptContentVersionHistory::getChapterId, 11111111L);
|
|
|
+ List<ScriptContentVersionHistory> list = scriptContentVersionHistoryDao.list(qw);
|
|
|
+ ScriptContentVersionOperator op = new ScriptContentVersionOperator(11111111L);
|
|
|
+ op.mergeVersion(list);
|
|
|
+ List<LineInfoModel> lineInfoModels = op.parseScriptContent();
|
|
|
+ for (LineInfoModel lineInfoModel : lineInfoModels) {
|
|
|
+ System.out.println(JSON.toJSONString(lineInfoModel));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void operatorList() {
|
|
|
+ List<OperatorModel> operatorModels =
|
|
|
+ scriptContentVersionHistoryService.listAndSortChapterEditHistory(11111111L, 50L);
|
|
|
+ for (OperatorModel operatorModel : operatorModels) {
|
|
|
+ LineInfoModel model = operatorModel.getModel();
|
|
|
+ String content = model.getContent();
|
|
|
+ }
|
|
|
+ System.out.println(JSON.toJSONString(operatorModels));
|
|
|
+ }
|
|
|
|
|
|
}
|