条款对比
This commit is contained in:
+33
-15
@@ -16,9 +16,11 @@ import com.jero.common.exception.JeroBootException;
|
|||||||
import com.jero.common.system.base.controller.JeroController;
|
import com.jero.common.system.base.controller.JeroController;
|
||||||
import com.jero.common.system.vo.LoginUser;
|
import com.jero.common.system.vo.LoginUser;
|
||||||
import com.jero.common.util.MessageUtils;
|
import com.jero.common.util.MessageUtils;
|
||||||
|
import com.jero.common.util.UUIDUtils;
|
||||||
import com.jero.generater.modules.online.cgform.service.impl.OnlCgformFieldServiceImpl;
|
import com.jero.generater.modules.online.cgform.service.impl.OnlCgformFieldServiceImpl;
|
||||||
import com.jero.modules.compare.entity.SarFileCompareDetailVO;
|
import com.jero.modules.compare.entity.SarFileCompareDetailVO;
|
||||||
import com.jero.modules.compare.entity.SarFileCompareInfo;
|
import com.jero.modules.compare.entity.SarFileCompareInfo;
|
||||||
|
import com.jero.modules.compare.enums.CompareTypeEnum;
|
||||||
import com.jero.modules.compare.enums.ReleaseConditionEnum;
|
import com.jero.modules.compare.enums.ReleaseConditionEnum;
|
||||||
import com.jero.modules.compare.service.ISarFileCompareInfoService;
|
import com.jero.modules.compare.service.ISarFileCompareInfoService;
|
||||||
import com.jero.modules.system.service.ISysUserService;
|
import com.jero.modules.system.service.ISysUserService;
|
||||||
@@ -39,10 +41,7 @@ import org.springframework.web.servlet.ModelAndView;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
@@ -105,6 +104,7 @@ public class SarFileCompareInfoController extends JeroController<SarFileCompareI
|
|||||||
|
|
||||||
for (SarFileCompareInfo info : pageList.getRecords()) {
|
for (SarFileCompareInfo info : pageList.getRecords()) {
|
||||||
info.setReleaseStateTitle(ReleaseConditionEnum.getTextByValue(info.getReleaseState(), cut));
|
info.setReleaseStateTitle(ReleaseConditionEnum.getTextByValue(info.getReleaseState(), cut));
|
||||||
|
info.setCompareTypeShow(CompareTypeEnum.getTextByValue(info.getCompareType()));
|
||||||
}
|
}
|
||||||
return Result.OK(pageList);
|
return Result.OK(pageList);
|
||||||
}
|
}
|
||||||
@@ -266,15 +266,6 @@ public class SarFileCompareInfoController extends JeroController<SarFileCompareI
|
|||||||
@ApiOperationSupport(order = 9)
|
@ApiOperationSupport(order = 9)
|
||||||
public Result<?> changeState(@Validated @RequestBody SarFileCompareInfo sarFileCompareInfo) {
|
public Result<?> changeState(@Validated @RequestBody SarFileCompareInfo sarFileCompareInfo) {
|
||||||
SarFileCompareInfo info = sarFileCompareInfoService.queryById(sarFileCompareInfo.getId());
|
SarFileCompareInfo info = sarFileCompareInfoService.queryById(sarFileCompareInfo.getId());
|
||||||
// 水平越权
|
|
||||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
||||||
if (!info.getCreateBy().equals(loginUser.getUsername())){
|
|
||||||
if(LanguageEnum.CN.equals(MessageUtils.getLanguage())) {
|
|
||||||
throw new JeroBootException("无权限!");
|
|
||||||
}else{
|
|
||||||
throw new JeroBootException("No access!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ReleaseConditionEnum.DRAFT.getValue().equals(sarFileCompareInfo.getReleaseState())) {
|
if (ReleaseConditionEnum.DRAFT.getValue().equals(sarFileCompareInfo.getReleaseState())) {
|
||||||
info.setReleaseState(ReleaseConditionEnum.PUBLISHED.getValue());
|
info.setReleaseState(ReleaseConditionEnum.PUBLISHED.getValue());
|
||||||
} else {
|
} else {
|
||||||
@@ -303,12 +294,39 @@ public class SarFileCompareInfoController extends JeroController<SarFileCompareI
|
|||||||
@PostMapping(value = "/editComments")
|
@PostMapping(value = "/editComments")
|
||||||
@ApiOperationSupport(order = 11)
|
@ApiOperationSupport(order = 11)
|
||||||
public Result<?> editComments(@Validated @RequestBody SarFileCompareInfo sarFileCompareInfo) {
|
public Result<?> editComments(@Validated @RequestBody SarFileCompareInfo sarFileCompareInfo) {
|
||||||
// 水平越权
|
|
||||||
sarFileCompareInfoService.isHorizontalOverstep(sarFileCompareInfo.getId());
|
|
||||||
SarFileCompareInfo info = sarFileCompareInfoService.getById(sarFileCompareInfo.getId());
|
SarFileCompareInfo info = sarFileCompareInfoService.getById(sarFileCompareInfo.getId());
|
||||||
info.setComments(sarFileCompareInfo.getComments());
|
info.setComments(sarFileCompareInfo.getComments());
|
||||||
sarFileCompareInfoService.editById(info);
|
sarFileCompareInfoService.editById(info);
|
||||||
return Result.OK(MessageUtils.getMessage(ResultCommon.OK));
|
return Result.OK(MessageUtils.getMessage(ResultCommon.OK));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发起条款对比
|
||||||
|
*
|
||||||
|
* @param json
|
||||||
|
* @return 对比详情ID
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "新旧拆分单对比-发起条款对比")
|
||||||
|
@ApiOperation(value = "新旧拆分单对比-发起条款对比", notes = "新旧拆分单对比-发起条款对比")
|
||||||
|
@RequestMapping(value = "/itemComparison", method = RequestMethod.POST)
|
||||||
|
@ApiOperationSupport(order = 12)
|
||||||
|
public Result<String> itemComparison(@RequestBody JSONObject json) {
|
||||||
|
try {
|
||||||
|
String leftStandard = json.get("leftStandard").toString();
|
||||||
|
String rightStandard = json.get("rightStandard").toString();
|
||||||
|
String remark = "";
|
||||||
|
if (json.get("remark") != null) {
|
||||||
|
remark = json.get("remark").toString();
|
||||||
|
}
|
||||||
|
String InfoId = sarFileCompareInfoService.itemComparison(leftStandard, rightStandard, remark);
|
||||||
|
Result<String> r = new Result<>();
|
||||||
|
r.setSuccess(true);
|
||||||
|
r.setCode(CommonConstant.SC_OK_200);
|
||||||
|
r.setResult(InfoId);
|
||||||
|
return r;
|
||||||
|
} catch (Exception ex) {
|
||||||
|
log.error("发起条款对比失败:" + ex.getMessage());
|
||||||
|
return Result.error("发起条款对比失败!" + ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-1
@@ -131,7 +131,6 @@ public class SarFileCompareItemCommentController extends JeroController<SarFileC
|
|||||||
public Result<?> delete(@RequestBody IdMapBody mapBody) {
|
public Result<?> delete(@RequestBody IdMapBody mapBody) {
|
||||||
// 水平越权
|
// 水平越权
|
||||||
SarFileCompareItemComment sarFileCompareItemComment = sarFileCompareItemCommentService.getById(mapBody.getId());
|
SarFileCompareItemComment sarFileCompareItemComment = sarFileCompareItemCommentService.getById(mapBody.getId());
|
||||||
sarFileCompareInfoService.isHorizontalOverstep(sarFileCompareItemComment.getInfoId());
|
|
||||||
sarFileCompareItemCommentService.deleteById(mapBody.getId());
|
sarFileCompareItemCommentService.deleteById(mapBody.getId());
|
||||||
return Result.OK("删除成功!");
|
return Result.OK("删除成功!");
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-1
@@ -22,9 +22,10 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 新旧拆分单对比条款表
|
* @Description: 新旧拆分单对比条款表
|
||||||
* @Author: jero-boot
|
* @Author: jero-boot
|
||||||
* @Date: 2022-08-02
|
* @Date: 2022-08-02
|
||||||
@@ -181,4 +182,10 @@ public class SarFileCompareItemController extends JeroController<SarFileCompareI
|
|||||||
return Result.OK(res);
|
return Result.OK(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "条款比对")
|
||||||
|
@PostMapping("/clauseComparisonEvent")
|
||||||
|
public Result<Map<String,Object>> clauseComparisonEvent(String oldItemId, String newItemId, String standHisId, String flag) throws Exception {
|
||||||
|
Map<String,Object> resultMap = sarFileCompareItemService.clauseComparisonEvent(oldItemId,newItemId,standHisId,flag);
|
||||||
|
return Result.OK(resultMap);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
@@ -160,4 +160,9 @@ public class SarFileCompareInfo implements Serializable {
|
|||||||
@ApiModelProperty(value = "创建人")
|
@ApiModelProperty(value = "创建人")
|
||||||
private String createNameNo;
|
private String createNameNo;
|
||||||
|
|
||||||
|
// 比对类型:条款比对、全文比对
|
||||||
|
@ApiModelProperty(value = "比对类型")
|
||||||
|
private String compareType;
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String compareTypeShow;
|
||||||
}
|
}
|
||||||
|
|||||||
+46
@@ -0,0 +1,46 @@
|
|||||||
|
package com.jero.modules.compare.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对比类型枚举类
|
||||||
|
*/
|
||||||
|
public enum CompareTypeEnum {
|
||||||
|
|
||||||
|
ITEM("条款对比","item"),
|
||||||
|
FULL_TEXT("全文对比","fullText"),
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
String cnName;
|
||||||
|
String value;
|
||||||
|
|
||||||
|
private CompareTypeEnum(String cnName, String value) {
|
||||||
|
this.cnName = cnName;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCnName() {
|
||||||
|
return cnName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCnName(String cnName) {
|
||||||
|
this.cnName = cnName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getTextByValue(String value) {
|
||||||
|
CompareTypeEnum[] values = values();
|
||||||
|
for (CompareTypeEnum releaseConditionEnum : values) {
|
||||||
|
if (releaseConditionEnum.value.equals(value)) {
|
||||||
|
return releaseConditionEnum.cnName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
+10
@@ -86,4 +86,14 @@ public interface ISarFileCompareInfoService extends IService<SarFileCompareInfo>
|
|||||||
void isHorizontalOverstep(String ids);
|
void isHorizontalOverstep(String ids);
|
||||||
|
|
||||||
void deleteByStandardId(String ids);
|
void deleteByStandardId(String ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发起条款对比
|
||||||
|
*
|
||||||
|
* @param leftStandard
|
||||||
|
* @param rightStandard
|
||||||
|
* @param remark
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String itemComparison(String leftStandard, String rightStandard, String remark) throws Exception;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -72,4 +72,6 @@ public interface ISarFileCompareItemService extends IService<SarFileCompareItem>
|
|||||||
Map<String, SarFileCompareItem> queryMapByInfoId(String infoId);
|
Map<String, SarFileCompareItem> queryMapByInfoId(String infoId);
|
||||||
|
|
||||||
List<String> clauseComparison(String lid,String rid);
|
List<String> clauseComparison(String lid,String rid);
|
||||||
|
|
||||||
|
Map<String,Object> clauseComparisonEvent(String oldItemId, String newItemId, String standHisId,String flag);
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-2
@@ -7,6 +7,7 @@ import com.jero.common.exception.JeroBootException;
|
|||||||
import com.jero.common.system.vo.LoginUser;
|
import com.jero.common.system.vo.LoginUser;
|
||||||
import com.jero.common.util.MessageUtils;
|
import com.jero.common.util.MessageUtils;
|
||||||
import com.jero.modules.compare.entity.*;
|
import com.jero.modules.compare.entity.*;
|
||||||
|
import com.jero.modules.compare.enums.CompareTypeEnum;
|
||||||
import com.jero.modules.compare.enums.ReleaseConditionEnum;
|
import com.jero.modules.compare.enums.ReleaseConditionEnum;
|
||||||
import com.jero.modules.compare.mapper.SarFileCompareInfoMapper;
|
import com.jero.modules.compare.mapper.SarFileCompareInfoMapper;
|
||||||
import com.jero.modules.compare.service.ISarFileCompareInfoService;
|
import com.jero.modules.compare.service.ISarFileCompareInfoService;
|
||||||
@@ -142,7 +143,7 @@ public class SarFileCompareInfoServiceImpl extends ServiceImpl<SarFileCompareInf
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String fullTextComparison(String leftStandard, String rightStandard, String remark) throws Exception {
|
public String fullTextComparison(String leftStandard, String rightStandard, String remark) throws Exception {
|
||||||
SarFileCompareInfo sfcInfo = addStandCompareHis(leftStandard, rightStandard, remark);
|
SarFileCompareInfo sfcInfo = addStandCompareHis(leftStandard, rightStandard, remark, CompareTypeEnum.FULL_TEXT.getValue());
|
||||||
//文档对比信息目录
|
//文档对比信息目录
|
||||||
List<SarFileSplitMenuEO> leftMenuEOList = sarFileSplitMenuEOService.queryByInfoId(leftStandard);
|
List<SarFileSplitMenuEO> leftMenuEOList = sarFileSplitMenuEOService.queryByInfoId(leftStandard);
|
||||||
Map<String, SarFileCompareMenu> leftMenuMap = wrapperMenuMap(leftMenuEOList, sfcInfo.getId(), CompareConst.POS_LEFT);
|
Map<String, SarFileCompareMenu> leftMenuMap = wrapperMenuMap(leftMenuEOList, sfcInfo.getId(), CompareConst.POS_LEFT);
|
||||||
@@ -254,7 +255,7 @@ public class SarFileCompareInfoServiceImpl extends ServiceImpl<SarFileCompareInf
|
|||||||
* @param remark
|
* @param remark
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public SarFileCompareInfo addStandCompareHis(String leftStandId, String rightStandId, String remark) throws Exception {
|
public SarFileCompareInfo addStandCompareHis(String leftStandId, String rightStandId, String remark, String compareType) throws Exception {
|
||||||
SarFileSplitInfoEO leftInfo = sarFileSplitInfoEOService.queryById(leftStandId);
|
SarFileSplitInfoEO leftInfo = sarFileSplitInfoEOService.queryById(leftStandId);
|
||||||
SarFileSplitInfoEO rightInfo = sarFileSplitInfoEOService.queryById(rightStandId);
|
SarFileSplitInfoEO rightInfo = sarFileSplitInfoEOService.queryById(rightStandId);
|
||||||
//保存标准比对历史表数据
|
//保存标准比对历史表数据
|
||||||
@@ -287,6 +288,7 @@ public class SarFileCompareInfoServiceImpl extends ServiceImpl<SarFileCompareInf
|
|||||||
|
|
||||||
sarFileCompareInfo.setReleaseState(ReleaseConditionEnum.DRAFT.getValue());
|
sarFileCompareInfo.setReleaseState(ReleaseConditionEnum.DRAFT.getValue());
|
||||||
sarFileCompareInfo.setRemark(remark);
|
sarFileCompareInfo.setRemark(remark);
|
||||||
|
sarFileCompareInfo.setCompareType(compareType);
|
||||||
this.add(sarFileCompareInfo);
|
this.add(sarFileCompareInfo);
|
||||||
return sarFileCompareInfo;
|
return sarFileCompareInfo;
|
||||||
}
|
}
|
||||||
@@ -464,4 +466,17 @@ public class SarFileCompareInfoServiceImpl extends ServiceImpl<SarFileCompareInf
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 条款对比
|
||||||
|
*
|
||||||
|
* @param leftStandard
|
||||||
|
* @param rightStandard
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String itemComparison(String leftStandard, String rightStandard, String remark) throws Exception {
|
||||||
|
SarFileCompareInfo sfcInfo = addStandCompareHis(leftStandard, rightStandard, remark, CompareTypeEnum.ITEM.getValue());
|
||||||
|
return sfcInfo.getId();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-1
@@ -100,7 +100,6 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
|
|||||||
@Override
|
@Override
|
||||||
public void editById(SarFileCompareItemComment sarFileCompareItemComment) {
|
public void editById(SarFileCompareItemComment sarFileCompareItemComment) {
|
||||||
// 水平越权
|
// 水平越权
|
||||||
sarFileCompareInfoService.isHorizontalOverstep(sarFileCompareItemComment.getInfoId());
|
|
||||||
SarFileCompareItemComment ic = queryById(sarFileCompareItemComment.getId());
|
SarFileCompareItemComment ic = queryById(sarFileCompareItemComment.getId());
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
ic.setUpdateTime(now);
|
ic.setUpdateTime(now);
|
||||||
|
|||||||
+141
-4
@@ -2,18 +2,26 @@ package com.jero.modules.compare.service.impl;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.jero.common.util.UUIDUtils;
|
||||||
|
import com.jero.modules.compare.entity.SarFileCompareInfo;
|
||||||
import com.jero.modules.compare.entity.SarFileCompareItem;
|
import com.jero.modules.compare.entity.SarFileCompareItem;
|
||||||
import com.jero.modules.compare.mapper.SarFileCompareItemMapper;
|
import com.jero.modules.compare.mapper.SarFileCompareItemMapper;
|
||||||
import com.jero.modules.compare.service.ISarFileCompareItemService;
|
import com.jero.modules.compare.service.ISarFileCompareItemService;
|
||||||
|
import com.jero.modules.compare.utils.CompHanLPUtils;
|
||||||
import com.jero.modules.compare.utils.CompareConst;
|
import com.jero.modules.compare.utils.CompareConst;
|
||||||
import com.jero.modules.compare.utils.DiffUtils;
|
import com.jero.modules.compare.utils.DiffUtils;
|
||||||
|
import com.jero.modules.compare.utils.EventEditHistoryHighLightUtil;
|
||||||
|
import com.jero.modules.split.entity.SarFileSplitItemsEO;
|
||||||
|
import com.jero.modules.split.entity.SarFileSplitItemsValEO;
|
||||||
|
import com.jero.modules.split.page.SarFileSplitItemsValEOPage;
|
||||||
|
import com.jero.modules.split.service.ISarFileSplitItemsValEOService;
|
||||||
import com.jero.modules.system.util.MyStringUtils;
|
import com.jero.modules.system.util.MyStringUtils;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.text.NumberFormat;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 文档对比信息条款表
|
* @Description: 文档对比信息条款表
|
||||||
@@ -24,6 +32,9 @@ import java.util.Map;
|
|||||||
@Service
|
@Service
|
||||||
public class SarFileCompareItemServiceImpl extends ServiceImpl<SarFileCompareItemMapper, SarFileCompareItem> implements ISarFileCompareItemService {
|
public class SarFileCompareItemServiceImpl extends ServiceImpl<SarFileCompareItemMapper, SarFileCompareItem> implements ISarFileCompareItemService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISarFileSplitItemsValEOService sarFileSplitItemsValEOService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存
|
* 保存
|
||||||
*
|
*
|
||||||
@@ -132,4 +143,130 @@ public class SarFileCompareItemServiceImpl extends ServiceImpl<SarFileCompareIte
|
|||||||
List<String> htmlDiffStr = dmp.getHtmlDiffStr(leftItem.getItemsText(), rightItem.getItemsText());
|
List<String> htmlDiffStr = dmp.getHtmlDiffStr(leftItem.getItemsText(), rightItem.getItemsText());
|
||||||
return htmlDiffStr;
|
return htmlDiffStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> clauseComparisonEvent(String oldItemId, String newItemId, String standHisId, String flag) {
|
||||||
|
Map<String,Object> resultMap = new HashMap<String, Object>();
|
||||||
|
String oldTxt = "";
|
||||||
|
SarFileSplitItemsValEOPage oldPage = new SarFileSplitItemsValEOPage();
|
||||||
|
oldPage.setItemId(oldItemId);
|
||||||
|
oldPage.setType("TEXT");
|
||||||
|
oldPage.setOrderBy("DISPLAY_SEQ,ID");
|
||||||
|
List<SarFileSplitItemsValEO> oldList = sarFileSplitItemsValEOService.queryByList(oldPage);
|
||||||
|
if(oldList!=null && !oldList.isEmpty()){
|
||||||
|
for(int i = 1;i<=oldList.size();i++){
|
||||||
|
if(i==oldList.size()) {
|
||||||
|
oldTxt += oldList.get(i-1).getItemContent();
|
||||||
|
}else{
|
||||||
|
oldTxt += oldList.get(i-1).getItemContent() + "i#2\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String newTxt = "";
|
||||||
|
SarFileSplitItemsValEOPage newPage = new SarFileSplitItemsValEOPage();
|
||||||
|
newPage.setItemId(newItemId);
|
||||||
|
newPage.setType("TEXT");
|
||||||
|
newPage.setOrderBy("DISPLAY_SEQ,ID");
|
||||||
|
List<SarFileSplitItemsValEO> newList = sarFileSplitItemsValEOService.queryByList(newPage);
|
||||||
|
if(newList!=null && !newList.isEmpty()){
|
||||||
|
for(int i = 1;i<=newList.size();i++){
|
||||||
|
if(i==newList.size()) {
|
||||||
|
newTxt += newList.get(i-1).getItemContent();
|
||||||
|
}else{
|
||||||
|
newTxt += newList.get(i-1).getItemContent() + "i#2\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String similarityDegree="";
|
||||||
|
double similarity = 100.00;
|
||||||
|
if(!StringUtils.isNotBlank(oldTxt.trim()) && !StringUtils.isNotBlank(newTxt.trim())){
|
||||||
|
similarityDegree = "100.00";
|
||||||
|
}else if(StringUtils.isNotBlank(oldTxt.trim()) && StringUtils.isNotBlank(newTxt.trim())){
|
||||||
|
similarity = CompHanLPUtils.findSimilarity(oldTxt.trim(), newTxt.trim());
|
||||||
|
NumberFormat nf = java.text.NumberFormat.getPercentInstance();
|
||||||
|
//nf.setMaximumIntegerDigits(2);//小数点前保留几位
|
||||||
|
nf.setMinimumFractionDigits(2);// 小数点后保留几位
|
||||||
|
similarityDegree = nf.format(similarity);
|
||||||
|
}else{
|
||||||
|
similarity = 0.00;
|
||||||
|
similarityDegree = "0.00";
|
||||||
|
}
|
||||||
|
resultMap.put("similarityDegree",similarityDegree);
|
||||||
|
List<String> leftString = new ArrayList<>();
|
||||||
|
List<String> rightString = new ArrayList<>();
|
||||||
|
if(similarity >= 0.6){
|
||||||
|
String[] anb = EventEditHistoryHighLightUtil.getHighLightDifferent(oldTxt.trim(), newTxt.trim());
|
||||||
|
if(StringUtils.isNotBlank(flag) && flag.equals("2")){
|
||||||
|
anb[0] = anb[0].replaceAll("red;", "#ffffff;background-color: red;").replaceAll("i#2\n", "<br/>");
|
||||||
|
anb[1] = anb[1].replaceAll("red;", "#ffffff;background-color: rgb(51, 145, 206);").replaceAll("i#2\n", "<br/>");
|
||||||
|
}else {
|
||||||
|
anb[0] = anb[0].replaceAll("red;", "#ffffff;background-color: rgb(51, 145, 206);").replaceAll("i#2\n", "<br/>");
|
||||||
|
anb[1] = anb[1].replaceAll("red;", "#ffffff;background-color: red;").replaceAll("i#2\n", "<br/>");
|
||||||
|
}
|
||||||
|
resultMap.put("leftString",anb[0]);
|
||||||
|
resultMap.put("rightString",anb[1]);
|
||||||
|
}else{
|
||||||
|
String oldTxtTemp = oldTxt.replace("i#2\n", "<br/>");
|
||||||
|
List<String> stringList1 = Arrays.asList(oldTxtTemp.split("<br/>"));
|
||||||
|
for(String left : stringList1){
|
||||||
|
StringBuilder stringBuilder = new StringBuilder(left);
|
||||||
|
stringBuilder.append("</div>");
|
||||||
|
stringBuilder.insert(0,"<div>");
|
||||||
|
leftString.add(stringBuilder.toString());
|
||||||
|
}
|
||||||
|
resultMap.put("leftString",leftString);
|
||||||
|
String newTxtTemp = newTxt.replace("i#2\n", "<br/>");
|
||||||
|
List<String> stringList2 = Arrays.asList(newTxtTemp.split("<br/>"));
|
||||||
|
for(String right : stringList2){
|
||||||
|
StringBuilder stringBuilder = new StringBuilder(right);
|
||||||
|
stringBuilder.append("</div>");
|
||||||
|
stringBuilder.insert(0,"<div>");
|
||||||
|
rightString.add(stringBuilder.toString());
|
||||||
|
}
|
||||||
|
resultMap.put("rightString",rightString);
|
||||||
|
}
|
||||||
|
//往条款比对历史表中添加数据
|
||||||
|
if(standHisId != null && !standHisId.isEmpty()){
|
||||||
|
// SarFileSplitItemsEO leftEo = sarFileSplitItemsEOService.selectByPrimaryKey(oldItemId);
|
||||||
|
// SarFileSplitItemsEO rightEo = sarFileSplitItemsEOService.selectByPrimaryKey(newItemId);
|
||||||
|
// String leftItemsText = "";
|
||||||
|
// if(leftString != null && !leftString.isEmpty()){
|
||||||
|
// for(String left : leftString){
|
||||||
|
// leftItemsText += left;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// String rightItemsText = "";
|
||||||
|
// if(rightString != null && !rightString.isEmpty()){
|
||||||
|
// for(String right : rightString){
|
||||||
|
// rightItemsText += right;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
/* SarItemsCompareHisEO sarItemsCompareHisEO = new SarItemsCompareHisEO();
|
||||||
|
sarItemsCompareHisEO.setId(UUIDUtils.randomUUID20());
|
||||||
|
sarItemsCompareHisEO.setOldItemsId(leftEo.getId());
|
||||||
|
sarItemsCompareHisEO.setOldItemsName(leftEo.getItemsName());
|
||||||
|
sarItemsCompareHisEO.setOldItemsNum(leftEo.getItemsNum());
|
||||||
|
sarItemsCompareHisEO.setOldItemsText(leftItemsText);
|
||||||
|
sarItemsCompareHisEO.setNewItemsId(rightEo.getId());
|
||||||
|
sarItemsCompareHisEO.setNewItemsName(rightEo.getItemsName());
|
||||||
|
sarItemsCompareHisEO.setNewItemsNum(rightEo.getItemsNum());
|
||||||
|
sarItemsCompareHisEO.setNewItemsText(rightItemsText);
|
||||||
|
sarItemsCompareHisEO.setStandHisId(standHisId);
|
||||||
|
sarItemsCompareHisEO.setSimilarityDegree(similarityDegree);
|
||||||
|
sarItemsCompareHisEO.setCreateUser(LoginUserUtil.getUserId());
|
||||||
|
sarItemsCompareHisEO.setModifyUser(LoginUserUtil.getUserId());
|
||||||
|
sarItemsCompareHisEO.setModifyTime(new Date());
|
||||||
|
sarItemsCompareHisEO.setCreateTime(new Date());
|
||||||
|
sarItemsCompareHisEOService.insertSelective(sarItemsCompareHisEO);*/
|
||||||
|
}
|
||||||
|
SarFileCompareInfo sarStandCompareHisEO =new SarFileCompareInfo();
|
||||||
|
sarStandCompareHisEO.setId(standHisId);
|
||||||
|
// sarStandCompareHisEO.setCompareStatus("比对完成");
|
||||||
|
// sarStandCompareHisEODao.updateByPrimaryKeySelective(sarStandCompareHisEO);
|
||||||
|
if (oldList.size()==0 || newList.size()==0){
|
||||||
|
resultMap.put("error","比对数据已删除");
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2276
File diff suppressed because it is too large
Load Diff
+209
@@ -0,0 +1,209 @@
|
|||||||
|
package com.jero.modules.compare.utils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: TODO
|
||||||
|
* @author: super_liu
|
||||||
|
* @date: 2021年11月28日 12:28
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文本差异高亮算法
|
||||||
|
*
|
||||||
|
* @Author : cron
|
||||||
|
* @Date: 2020-01-15
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
public class EventEditHistoryHighLightUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 传入2个字符串进行相比高亮显示
|
||||||
|
* eg:
|
||||||
|
* 原数据一:王五张三
|
||||||
|
* 原数据二:张三李四
|
||||||
|
* <span style='color:red'>王五</span>张三
|
||||||
|
* 张三<span style='color:red'>李四</span>
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static String[] getHighLightDifferentOld(String a, String b) {
|
||||||
|
String[] temp = getDiff(a, b);
|
||||||
|
String[] result = {getHighLight(a, temp[0]), getHighLight(b, temp[1])};
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getHighLight(String source, String temp) {
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
char[] sourceChars = source.toCharArray();
|
||||||
|
char[] tempChars = temp.toCharArray();
|
||||||
|
boolean flag = false;
|
||||||
|
for (int i = 0; i < sourceChars.length; i++) {
|
||||||
|
if (tempChars[i] != ' ') {
|
||||||
|
if (i == 0) {
|
||||||
|
sb.append("<span style='color:red'>").append(sourceChars[i]);
|
||||||
|
} else if (flag) {
|
||||||
|
sb.append(sourceChars[i]);
|
||||||
|
} else {
|
||||||
|
sb.append("<span style='color:red'>").append(sourceChars[i]);
|
||||||
|
}
|
||||||
|
flag = true;
|
||||||
|
if (i == sourceChars.length - 1) {
|
||||||
|
sb.append("</span>");
|
||||||
|
}
|
||||||
|
} else if (flag) {
|
||||||
|
sb.append("</span>").append(sourceChars[i]);
|
||||||
|
flag = false;
|
||||||
|
} else {
|
||||||
|
sb.append(sourceChars[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] getDiff(String a, String b) {
|
||||||
|
String[] result = null;
|
||||||
|
//选取长度较小的字符串用来穷举子串
|
||||||
|
if (a.length() < b.length()) {
|
||||||
|
result = getDiff(a, b, 0, a.length());
|
||||||
|
} else {
|
||||||
|
result = getDiff(b, a, 0, b.length());
|
||||||
|
result = new String[]{result[1], result[0]};
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将a的指定部分与b进行比较生成比对结果
|
||||||
|
*/
|
||||||
|
private static String[] getDiff(String a, String b, int start, int end) {
|
||||||
|
String[] result = new String[]{a, b};
|
||||||
|
int len = result[0].length();
|
||||||
|
while (len > 0) {
|
||||||
|
for (int i = start; i < end - len + 1; i++) {
|
||||||
|
String sub = result[0].substring(i, i + len);
|
||||||
|
int idx = -1;
|
||||||
|
if ((idx = result[1].indexOf(sub)) != -1) {
|
||||||
|
result[0] = setEmpty(result[0], i, i + len);
|
||||||
|
result[1] = setEmpty(result[1], idx, idx + len);
|
||||||
|
if (i > 0) {
|
||||||
|
//递归获取空白区域左边差异
|
||||||
|
result = getDiff(result[0], result[1], 0, i);
|
||||||
|
}
|
||||||
|
if (i + len < end) {
|
||||||
|
//递归获取空白区域右边差异
|
||||||
|
result = getDiff(result[0], result[1], i + len, end);
|
||||||
|
}
|
||||||
|
len = 0;//退出while循环
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
len = len / 2;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将字符串s指定的区域设置成空格
|
||||||
|
*/
|
||||||
|
public static String setEmpty(String s, int start, int end) {
|
||||||
|
char[] array = s.toCharArray();
|
||||||
|
for (int i = start; i < end; i++) {
|
||||||
|
array[i] = ' ';
|
||||||
|
}
|
||||||
|
return new String(array);
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------new -------------------------
|
||||||
|
|
||||||
|
public static String[] getHighLightDifferent(String altbe, String altaf) {
|
||||||
|
//字符串1 altbe 字符串2 altaf
|
||||||
|
List<Integer> beList = rememberSpacing(altbe);
|
||||||
|
List<Integer> afList = rememberSpacing(altaf);
|
||||||
|
altbe = altbe.replace(" ", "");
|
||||||
|
altaf = altaf.replace(" ", "");
|
||||||
|
LinkedList<DiffMatchPatch.Diff> t = new DiffMatchPatch().diff_main(altbe, altaf);
|
||||||
|
StringBuffer s1 = new StringBuffer();
|
||||||
|
StringBuffer s2 = new StringBuffer();
|
||||||
|
Integer indexBe = 0;
|
||||||
|
Integer indexAf = 0;
|
||||||
|
for (DiffMatchPatch.Diff diff : t) {
|
||||||
|
StringBuffer diffTextBe = new StringBuffer(diff.text);
|
||||||
|
StringBuffer diffTextAf = new StringBuffer(diff.text);
|
||||||
|
if ("EQUAL".equalsIgnoreCase(diff.operation.toString())) {
|
||||||
|
addSpacing(beList, indexBe, diffTextBe);
|
||||||
|
addSpacing(afList, indexAf, diffTextAf);
|
||||||
|
s1.append(diffTextBe);
|
||||||
|
s2.append(diffTextAf);
|
||||||
|
indexBe += diffTextBe.length();
|
||||||
|
indexAf += diffTextAf.length();
|
||||||
|
}
|
||||||
|
indexBe = appendString2("DELETE", diff, s1, s2, beList, indexBe);
|
||||||
|
indexAf = appendString2("INSERT", diff, s2, s1, afList, indexAf);
|
||||||
|
}
|
||||||
|
String[] result = new String[2];
|
||||||
|
result[0] = s1.toString();
|
||||||
|
result[1] = s2.toString();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// public static void appendString(String type, Diff diff, StringBuffer sbOne, StringBuffer sbTwo) {
|
||||||
|
// if (type.equals(diff.operation.toString())) {
|
||||||
|
// if (" ".equals(diff.text)) {
|
||||||
|
// sbOne.append(" ");
|
||||||
|
// sbTwo.append(" ");
|
||||||
|
// } else {
|
||||||
|
// sbOne.append("<em class='f-required'>").append(diff.text).append("</em>");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
private static List<Integer> rememberSpacing(String str) {
|
||||||
|
List<Integer> list = new ArrayList<>();
|
||||||
|
for (int i = 0; i < str.length(); i++) {
|
||||||
|
if (' ' == str.charAt(i)) {
|
||||||
|
list.add(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addSpacing(List<Integer> list, Integer index, StringBuffer str) {
|
||||||
|
for (Integer o : list) {
|
||||||
|
if (o >= index && o < index + str.length()) {
|
||||||
|
str.insert(o - index, ' ');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Integer appendString2(String type, DiffMatchPatch.Diff diff, StringBuffer sbOne,
|
||||||
|
StringBuffer sbTwo, List<Integer> list, Integer i) {
|
||||||
|
Integer result = i;
|
||||||
|
if (type.equals(diff.operation.toString())) {
|
||||||
|
StringBuffer sb = new StringBuffer(diff.text);
|
||||||
|
for (Integer o : list) {
|
||||||
|
if (o >= i && o < i + sb.length()) {
|
||||||
|
sb.insert(o - i, ' ');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sbOne.append("<span style='color:red;'>").append(sb).append("</span>");
|
||||||
|
result = i + sb.length();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// public static void main(String[] args) {
|
||||||
|
// String a = "测试测试测试仅关注界面和功能,数据准确性在暂不测试";
|
||||||
|
// String b = "提交留言数据仅关注界面和功能,数据准确性在暂不测试";
|
||||||
|
// String[] anb = getHighLightDifferent(a, b);
|
||||||
|
// System.out.println(Arrays.toString(anb));
|
||||||
|
//
|
||||||
|
//// String altbe = "提交留言数据仅关注界面和 功能,数据准确性在暂不测试";
|
||||||
|
//// String altaf = "提交留言数据仅关注界面和功能,数据准确性在暂不测试提交 留言数据仅关注界面和功能,数据准确性在暂不测试";
|
||||||
|
//// String[] highLightDifferentNew = getHighLightDifferent(altbe, altaf);
|
||||||
|
//// System.out.println(Arrays.toString(highLightDifferentNew));
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user