|
@@ -20,14 +20,17 @@ import cn.cslg.pas.common.vo.business.CustomFieldVO;
|
|
import cn.cslg.pas.common.vo.business.ProductVO;
|
|
import cn.cslg.pas.common.vo.business.ProductVO;
|
|
import cn.cslg.pas.common.vo.es.QueryESCustomFieldVO;
|
|
import cn.cslg.pas.common.vo.es.QueryESCustomFieldVO;
|
|
import cn.cslg.pas.domain.business.*;
|
|
import cn.cslg.pas.domain.business.*;
|
|
|
|
+import cn.cslg.pas.domain.es.Patent;
|
|
import cn.cslg.pas.exception.UnLoginException;
|
|
import cn.cslg.pas.exception.UnLoginException;
|
|
import cn.cslg.pas.exception.XiaoShiException;
|
|
import cn.cslg.pas.exception.XiaoShiException;
|
|
import cn.cslg.pas.factorys.businessFactory.Business;
|
|
import cn.cslg.pas.factorys.businessFactory.Business;
|
|
import cn.cslg.pas.mapper.CustomFieldMapper;
|
|
import cn.cslg.pas.mapper.CustomFieldMapper;
|
|
import cn.cslg.pas.service.AssoTaskFieldService;
|
|
import cn.cslg.pas.service.AssoTaskFieldService;
|
|
import cn.cslg.pas.service.business.es.EsCustomFieldService;
|
|
import cn.cslg.pas.service.business.es.EsCustomFieldService;
|
|
|
|
+import cn.cslg.pas.service.business.es.EsService;
|
|
import cn.cslg.pas.service.permissions.PermissionService;
|
|
import cn.cslg.pas.service.permissions.PermissionService;
|
|
import cn.cslg.pas.service.query.FormatQueryService;
|
|
import cn.cslg.pas.service.query.FormatQueryService;
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
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;
|
|
@@ -39,10 +42,7 @@ import org.springframework.util.CollectionUtils;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.Arrays;
|
|
|
|
-import java.util.Comparator;
|
|
|
|
-import java.util.List;
|
|
|
|
|
|
+import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -84,6 +84,8 @@ public class CustomFieldService extends ServiceImpl<CustomFieldMapper, CustomFie
|
|
private TreeNodeService treeNodeService;
|
|
private TreeNodeService treeNodeService;
|
|
@Autowired
|
|
@Autowired
|
|
private AssoTaskFieldService assoTaskFieldService;
|
|
private AssoTaskFieldService assoTaskFieldService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private EsService esService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Object queryMessage(QueryRequest queryRequest) throws Exception {
|
|
public Object queryMessage(QueryRequest queryRequest) throws Exception {
|
|
@@ -583,7 +585,7 @@ public class CustomFieldService extends ServiceImpl<CustomFieldMapper, CustomFie
|
|
case 6:
|
|
case 6:
|
|
//TODO 根据名称和类型查询
|
|
//TODO 根据名称和类型查询
|
|
fieldId = this.GetIdByName(name, projectId, type);
|
|
fieldId = this.GetIdByName(name, projectId, type);
|
|
- value =treeNodeService.getIdByNames(value,fieldId,type);
|
|
|
|
|
|
+ value = treeNodeService.getIdByNames(value, fieldId, type);
|
|
;
|
|
;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -628,8 +630,198 @@ public class CustomFieldService extends ServiceImpl<CustomFieldMapper, CustomFie
|
|
return customField1.getId();
|
|
return customField1.getId();
|
|
}
|
|
}
|
|
|
|
|
|
- public void copyCustomField(){
|
|
|
|
|
|
+ public void copyCustomField(Integer oldProject, Integer newProject) {
|
|
|
|
+ LambdaQueryWrapper<CustomField> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper.eq(CustomField::getProjectId, oldProject);
|
|
|
|
+ List<CustomField> fields = this.list(queryWrapper);
|
|
|
|
+ if (fields.size() != 0) {
|
|
|
|
+ for (CustomField customField : fields) {
|
|
|
|
+ CustomField newCustomField = new CustomField();
|
|
|
|
+ BeanUtils.copyProperties(fields, newCustomField);
|
|
|
|
+ newCustomField.setId(null);
|
|
|
|
+ newCustomField.setProjectId(newProject);
|
|
|
|
+ newCustomField.insert();
|
|
|
|
+ this.copyCustomFieldValues(customField, newCustomField);
|
|
|
|
+ }
|
|
|
|
+ this.saveBatch(fields);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public void copyCustomFieldValues(CustomField customField, CustomField newCustomField) {
|
|
|
|
+
|
|
|
|
+ Integer type = customField.getType();
|
|
|
|
+ switch (type) {
|
|
|
|
+ case 0:
|
|
|
|
+ ;
|
|
|
|
+ case 1:
|
|
|
|
+ ;
|
|
|
|
+ case 2:
|
|
|
|
+ ;
|
|
|
|
+ case 3:
|
|
|
|
+ this.copyTextValues(customField, newCustomField);
|
|
|
|
+ break;
|
|
|
|
+ case 4:
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ case 5:
|
|
|
|
+ this.copyOptionValues(customField, newCustomField);
|
|
|
|
+ break;
|
|
|
|
+ case 6:
|
|
|
|
+ this.copyTreeValues(customField, newCustomField);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void copyTextValues(CustomField customField, CustomField newCustomField) {
|
|
|
|
+
|
|
|
|
+ List<PatentWithIdVO> patents = esCustomFieldService.getEsCustomFields(customField.getId().toString(), customField.getType(), customField.getProjectId());
|
|
|
|
+ for (PatentWithIdVO patentWithIdVO : patents) {
|
|
|
|
+ Patent patent = patentWithIdVO.getPatent();
|
|
|
|
+ patent.getESCustomField().setField(newCustomField.getId().toString());
|
|
|
|
+ patent.getESCustomField().setCreateTime(new Date());
|
|
|
|
+ patent.getESCustomField().setTaskId(null);
|
|
|
|
+ patent.getESCustomField().setProjectId(newCustomField.getProjectId());
|
|
|
|
+ String parentId = patent.getPatentJoin().getParent();
|
|
|
|
+ try {
|
|
|
|
+ esService.addChildPatent(patent, parentId);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new XiaoShiException("保存出错");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void copyOptionValues(CustomField customField, CustomField newCustomField) {
|
|
|
|
+ Integer newId = newCustomField.getId();
|
|
|
|
+ //查询自定义栏位的选项值
|
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
|
+ LambdaQueryWrapper<CustomOption> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper.eq(CustomOption::getCustomFieldId, customField.getId());
|
|
|
|
+ List<CustomOption> customOptions = customOptionService.list(queryWrapper);
|
|
|
|
+ for (CustomOption customOption : customOptions) {
|
|
|
|
+ CustomOption customOption1 = new CustomOption();
|
|
|
|
+ BeanUtils.copyProperties(customOption, customOption1);
|
|
|
|
+ customOption1.setCustomFieldId(newId);
|
|
|
|
+ customOption1.insert();
|
|
|
|
+ map.put(customOption.getId().toString(), customOption1.getId().toString());
|
|
|
|
|
|
|
|
+ }
|
|
|
|
+ List<PatentWithIdVO> patents = esCustomFieldService.getEsCustomFields(customField.getId().toString(), customField.getType(), customField.getProjectId());
|
|
|
|
+ for (PatentWithIdVO patentWithIdVO : patents) {
|
|
|
|
+ Patent patent = patentWithIdVO.getPatent();
|
|
|
|
+ patent.getESCustomField().setField(customField.getId().toString());
|
|
|
|
+ patent.getESCustomField().setCreateTime(new Date());
|
|
|
|
+ patent.getESCustomField().setTaskId(null);
|
|
|
|
+ List<String> fieldValues = patent.getESCustomField().getFieldValue();
|
|
|
|
+ fieldValues.forEach(item -> item = map.get(item));
|
|
|
|
+ patent.getESCustomField().setFieldValue(fieldValues);
|
|
|
|
+ patent.getESCustomField().setStatsValue(fieldValues);
|
|
|
|
+ String parentId = patent.getPatentJoin().getParent();
|
|
|
|
+ try {
|
|
|
|
+ esService.addChildPatent(patent, parentId);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new XiaoShiException("保存出错");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public void copyTreeValues(CustomField customField, CustomField newCustomField) {
|
|
|
|
+ Integer newId = newCustomField.getId();
|
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
|
+ //查询自定义栏位的选项值
|
|
|
|
+ LambdaQueryWrapper<TreeNode> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper.eq(TreeNode::getTypeId, customField.getId())
|
|
|
|
+ .eq(TreeNode::getType, customField.getType())
|
|
|
|
+ .orderByAsc(TreeNode::getLevel);
|
|
|
|
+ List<TreeNode> treeNodes = treeNodeService.list(queryWrapper);
|
|
|
|
+ for (TreeNode treeNode : treeNodes) {
|
|
|
|
+ TreeNode treeNode1 = new TreeNode();
|
|
|
|
+ BeanUtils.copyProperties(treeNode, treeNode1);
|
|
|
|
+ treeNode1.setTypeId(newCustomField.getId());
|
|
|
|
+ treeNode1.setId(null);
|
|
|
|
+ String path = treeNode.getPath();
|
|
|
|
+ if (path != null && !path.trim().equals("")) {
|
|
|
|
+ List<String> paths = Arrays.asList(path.split("/"));
|
|
|
|
+ paths.forEach(item -> item = map.get(item));
|
|
|
|
+ path = StringUtils.join(paths, "/");
|
|
|
|
+ treeNode1.setPath(path);
|
|
|
|
+ }
|
|
|
|
+ treeNode1.insert();
|
|
|
|
+ map.put(treeNode.getId().toString(), treeNode1.getId().toString());
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ List<PatentWithIdVO> patents = esCustomFieldService.getEsCustomFields(customField.getId().toString(), customField.getType(), customField.getProjectId());
|
|
|
|
+ for (PatentWithIdVO patentWithIdVO : patents) {
|
|
|
|
+ Patent patent = patentWithIdVO.getPatent();
|
|
|
|
+ patent.getESCustomField().setField(customField.getId().toString());
|
|
|
|
+ patent.getESCustomField().setCreateTime(new Date());
|
|
|
|
+ patent.getESCustomField().setTaskId(null);
|
|
|
|
+ List<String> fieldValues = patent.getESCustomField().getFieldValue();
|
|
|
|
+ List<String> statusValues = patent.getESCustomField().getStatsValue();
|
|
|
|
+ fieldValues.forEach(item -> item = map.get(item));
|
|
|
|
+ statusValues.forEach(item -> item = map.get(item));
|
|
|
|
+ patent.getESCustomField().setFieldValue(fieldValues);
|
|
|
|
+ patent.getESCustomField().setStatsValue(statusValues);
|
|
|
|
+ String parentId = patent.getPatentJoin().getParent();
|
|
|
|
+ //TODO添加path
|
|
|
|
+ try {
|
|
|
|
+ esService.addChildPatent(patent, parentId);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new XiaoShiException("保存出错");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// public void copyProductValues(CustomField customField,CustomField newCustomField) {
|
|
|
|
+// Integer newId =newCustomField.getId();
|
|
|
|
+// //查询自定义栏位的选项值
|
|
|
|
+// List<Map<String,String>> maps =new ArrayList<>();
|
|
|
|
+// LambdaQueryWrapper<TreeNode> queryWrapper =new LambdaQueryWrapper<>();
|
|
|
|
+// queryWrapper.eq(TreeNode::getTypeId,customField.getId())
|
|
|
|
+// .eq(TreeNode::getType,customField.getType())
|
|
|
|
+// .orderByAsc(TreeNode::getLevel);
|
|
|
|
+// List<TreeNode> treeNodes = treeNodeService.list(queryWrapper);
|
|
|
|
+// for (TreeNode treeNode:treeNodes){
|
|
|
|
+// TreeNode treeNode1 =new TreeNode();
|
|
|
|
+// BeanUtils.copyProperties(treeNode,treeNode1);
|
|
|
|
+// treeNode1.setTypeId(newCustomField.getId());
|
|
|
|
+// treeNode1.setId(null);
|
|
|
|
+// //TODO添加path
|
|
|
|
+// Map<String,String> map =new HashMap<>();
|
|
|
|
+// map.put(treeNode.getId().toString(),treeNode1.getId().toString());
|
|
|
|
+//
|
|
|
|
+// }
|
|
|
|
+// List<PatentWithIdVO> patents = esCustomFieldService.getEsCustomFields(customField.getId().toString(), customField.getType(), customField.getProjectId());
|
|
|
|
+// for (PatentWithIdVO patentWithIdVO : patents) {
|
|
|
|
+// Patent patent =patentWithIdVO.getPatent();
|
|
|
|
+// patent.getESCustomField().setField(customField.getId().toString());
|
|
|
|
+// patent.getESCustomField().setCreateTime(new Date());
|
|
|
|
+// patent.getESCustomField().setTaskId(null);
|
|
|
|
+// String parentId =patent.getPatentJoin().getParent();
|
|
|
|
+// //TODO添加path
|
|
|
|
+// try {
|
|
|
|
+// esService.addChildPatent(patent,parentId);
|
|
|
|
+// }
|
|
|
|
+// catch (Exception e){
|
|
|
|
+// throw new XiaoShiException("保存出错");
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// }
|
|
|
|
+
|
|
}
|
|
}
|