|
@@ -1,23 +1,31 @@
|
|
|
package cn.cslg.pas.service.business;
|
|
|
|
|
|
+import cn.cslg.pas.common.dto.AllFieldOrderDTO;
|
|
|
import cn.cslg.pas.common.dto.business.CustomFieldDTO;
|
|
|
import cn.cslg.pas.common.dto.business.UpdateCustomFieldDTO;
|
|
|
+import cn.cslg.pas.common.dto.es.EsCustomFieldDTO;
|
|
|
+import cn.cslg.pas.common.dto.es.QueryEsCustomFieldDTO;
|
|
|
import cn.cslg.pas.common.model.cronModel.Personnel;
|
|
|
import cn.cslg.pas.common.model.cronModel.PersonnelVO;
|
|
|
import cn.cslg.pas.common.model.cronModel.Records;
|
|
|
import cn.cslg.pas.common.model.request.GroupRequest;
|
|
|
import cn.cslg.pas.common.model.request.QueryRequest;
|
|
|
import cn.cslg.pas.common.utils.CacheUtils;
|
|
|
+import cn.cslg.pas.common.utils.FormatUtil;
|
|
|
import cn.cslg.pas.common.utils.LoginUtils;
|
|
|
+import cn.cslg.pas.common.vo.FieldValueVO;
|
|
|
+import cn.cslg.pas.common.vo.PatentWithIdVO;
|
|
|
import cn.cslg.pas.common.vo.business.AllCustomFieldVO;
|
|
|
import cn.cslg.pas.common.vo.business.CustomFieldVO;
|
|
|
import cn.cslg.pas.common.vo.business.ProductVO;
|
|
|
-import cn.cslg.pas.domain.business.AssoProjectTreeNode;
|
|
|
-import cn.cslg.pas.domain.business.CustomField;
|
|
|
+import cn.cslg.pas.common.vo.es.QueryESCustomFieldVO;
|
|
|
+import cn.cslg.pas.domain.business.*;
|
|
|
import cn.cslg.pas.exception.UnLoginException;
|
|
|
import cn.cslg.pas.exception.XiaoShiException;
|
|
|
import cn.cslg.pas.factorys.businessFactory.Business;
|
|
|
import cn.cslg.pas.mapper.CustomFieldMapper;
|
|
|
+import cn.cslg.pas.service.AssoTaskFieldService;
|
|
|
+import cn.cslg.pas.service.business.es.EsCustomFieldService;
|
|
|
import cn.cslg.pas.service.permissions.PermissionService;
|
|
|
import cn.cslg.pas.service.query.FormatQueryService;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
@@ -25,12 +33,15 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 自定义栏位Service层
|
|
@@ -57,6 +68,20 @@ public class CustomFieldService extends ServiceImpl<CustomFieldMapper, CustomFie
|
|
|
private PermissionService permissionService;
|
|
|
@Autowired
|
|
|
private AssoProjectTreeNodeService assoProjectTreeNodeService;
|
|
|
+ @Autowired
|
|
|
+ private ProductCategoryService productCategoryService;
|
|
|
+ @Autowired
|
|
|
+ private ProductService productService;
|
|
|
+ @Autowired
|
|
|
+ private EsCustomFieldService esCustomFieldService;
|
|
|
+
|
|
|
+ @Lazy
|
|
|
+ @Autowired
|
|
|
+ private CustomOptionService customOptionService;
|
|
|
+ @Autowired
|
|
|
+ private TreeNodeService treeNodeService;
|
|
|
+ @Autowired
|
|
|
+ private AssoTaskFieldService assoTaskFieldService;
|
|
|
|
|
|
@Override
|
|
|
public Object queryMessage(QueryRequest queryRequest) throws Exception {
|
|
@@ -217,16 +242,237 @@ public class CustomFieldService extends ServiceImpl<CustomFieldMapper, CustomFie
|
|
|
}
|
|
|
|
|
|
|
|
|
- private void getAllPatentCustomField(Integer projectId) {
|
|
|
- //根据 project获得栏位值
|
|
|
- List<CustomField> customFields = new ArrayList<>();
|
|
|
- LambdaQueryWrapper<CustomField> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.eq(CustomField::getProjectId, projectId);
|
|
|
- customFields = this.list(queryWrapper);
|
|
|
- //
|
|
|
- LambdaQueryWrapper<AssoProjectTreeNode> assoQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- assoQueryWrapper.eq(AssoProjectTreeNode::getProjectId, projectId);
|
|
|
- List<AssoProjectTreeNode> projectTreeNodes = assoProjectTreeNodeService.list(assoQueryWrapper);
|
|
|
+ public List<AllCustomFieldVO> getAllProjectCustomField(Integer projectId) {
|
|
|
+ Integer order = 0;
|
|
|
+ List<AllCustomFieldVO> allCustomFieldVOS = cacheUtils.getPatentCustomField(projectId);
|
|
|
+ if (allCustomFieldVOS == null) {
|
|
|
+ allCustomFieldVOS = new ArrayList<>();
|
|
|
+ //根据 project获得栏位值
|
|
|
+ List<CustomField> customFields = new ArrayList<>();
|
|
|
+ LambdaQueryWrapper<CustomField> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(CustomField::getProjectId, projectId);
|
|
|
+ customFields = this.list(queryWrapper);
|
|
|
+ //
|
|
|
+ LambdaQueryWrapper<AssoProjectTreeNode> assoQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ assoQueryWrapper.eq(AssoProjectTreeNode::getProjectId, projectId);
|
|
|
+ List<AssoProjectTreeNode> projectTreeNodes = assoProjectTreeNodeService.list(assoQueryWrapper);
|
|
|
+
|
|
|
+ for (CustomField item : customFields) {
|
|
|
+ AllCustomFieldVO allCustomFieldVO = new AllCustomFieldVO();
|
|
|
+ allCustomFieldVO.setId(item.getId());
|
|
|
+ allCustomFieldVO.setName(item.getName());
|
|
|
+ allCustomFieldVO.setType(item.getType());
|
|
|
+ allCustomFieldVO.setSysOrder(order);
|
|
|
+ allCustomFieldVOS.add(allCustomFieldVO);
|
|
|
+ order += 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (AssoProjectTreeNode item : projectTreeNodes) {
|
|
|
+ //根据类型和id
|
|
|
+ AllCustomFieldVO allCustomFieldVO = new AllCustomFieldVO();
|
|
|
+ allCustomFieldVO.setId(item.getId());
|
|
|
+ allCustomFieldVO.setType(item.getTreeType());
|
|
|
+ allCustomFieldVO.setSysOrder(order);
|
|
|
+ switch (item.getTreeType()) {
|
|
|
+ case 7:
|
|
|
+ Product product = productService.getById(item.getId());
|
|
|
+ allCustomFieldVO.setName(product.getName());
|
|
|
+ break;
|
|
|
+ case 8:
|
|
|
+ ProductCategory productCategory = productCategoryService.getById(item.getId());
|
|
|
+ allCustomFieldVO.setName(productCategory.getName());
|
|
|
+ break;
|
|
|
+ case 9:
|
|
|
+ //TODO 技术类别
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ allCustomFieldVOS.add(allCustomFieldVO);
|
|
|
+ order += 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ cacheUtils.addPatentCustomField(projectId, allCustomFieldVOS);
|
|
|
+ }
|
|
|
+
|
|
|
+ return allCustomFieldVOS;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param taskId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<AllCustomFieldVO> getAllTaskCustomField(Integer taskId) {
|
|
|
+ Integer order = 0;
|
|
|
+ List<AllCustomFieldVO> allCustomFieldVOS = cacheUtils.getTaskCustomField(taskId);
|
|
|
+ if(allCustomFieldVOS==null||allCustomFieldVOS.size()==0) {
|
|
|
+ allCustomFieldVOS = new ArrayList<>();
|
|
|
+
|
|
|
+ //根据任务id查询
|
|
|
+ List<AssoTaskField> assoTaskFields = new ArrayList<>();
|
|
|
+ LambdaQueryWrapper<AssoTaskField> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(AssoTaskField::getTaskId, taskId);
|
|
|
+ assoTaskFields = assoTaskFieldService.list(queryWrapper);
|
|
|
+
|
|
|
+ //
|
|
|
+ if (assoTaskFields != null) {
|
|
|
+
|
|
|
+ //从自定义栏位表中获得自定义栏位id
|
|
|
+ List<Integer> fieldIds = assoTaskFields.stream()
|
|
|
+ .filter(item -> item.getFieldType().equals(0)
|
|
|
+ || item.getFieldType().equals(1)
|
|
|
+ || item.getFieldType().equals(2)
|
|
|
+ || item.getFieldType().equals(3)
|
|
|
+ || item.getFieldType().equals(4)
|
|
|
+ || item.getFieldType().equals(5)
|
|
|
+ || item.getFieldType().equals(6)).map(AssoTaskField::getFieldId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (fieldIds.size() != 0) {
|
|
|
+ LambdaQueryWrapper<CustomField> queryCWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryCWrapper.in(CustomField::getId, fieldIds);
|
|
|
+ List<CustomField> customFields = this.list(queryCWrapper);
|
|
|
+ for (CustomField item : customFields) {
|
|
|
+ AllCustomFieldVO allCustomFieldVO = new AllCustomFieldVO();
|
|
|
+ allCustomFieldVO.setId(item.getId());
|
|
|
+ allCustomFieldVO.setName(item.getName());
|
|
|
+ allCustomFieldVO.setType(item.getType());
|
|
|
+ allCustomFieldVO.setSysOrder(order);
|
|
|
+ allCustomFieldVOS.add(allCustomFieldVO);
|
|
|
+ order += 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //从关联表中获得产品id
|
|
|
+ List<Integer> productIds = assoTaskFields.stream()
|
|
|
+ .filter(item -> item.getFieldId().equals(7))
|
|
|
+ .map(AssoTaskField::getFieldId).collect(Collectors.toList());
|
|
|
+ if (productIds != null && productIds.size() != 0) {
|
|
|
+ LambdaQueryWrapper<Product> productLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ List<Product> products = productService.list(productLambdaQueryWrapper);
|
|
|
+ for (Product item : products) {
|
|
|
+ AllCustomFieldVO allCustomFieldVO = new AllCustomFieldVO();
|
|
|
+ allCustomFieldVO.setId(item.getId());
|
|
|
+ allCustomFieldVO.setName(item.getName());
|
|
|
+ allCustomFieldVO.setType(7);
|
|
|
+ allCustomFieldVO.setSysOrder(order);
|
|
|
+ allCustomFieldVOS.add(allCustomFieldVO);
|
|
|
+ order += 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ List<Integer> productCategoryIds = assoTaskFields.stream()
|
|
|
+ .filter(item -> item.getFieldId().equals(8))
|
|
|
+ .map(AssoTaskField::getFieldId).collect(Collectors.toList());
|
|
|
+ if (productCategoryIds != null && productCategoryIds.size() != 0) {
|
|
|
+ LambdaQueryWrapper<ProductCategory> LambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ List<ProductCategory> productCategories = productCategoryService.list(LambdaQueryWrapper);
|
|
|
+ for (ProductCategory item : productCategories) {
|
|
|
+ AllCustomFieldVO allCustomFieldVO = new AllCustomFieldVO();
|
|
|
+ allCustomFieldVO.setId(item.getId());
|
|
|
+ allCustomFieldVO.setName(item.getName());
|
|
|
+ allCustomFieldVO.setType(8);
|
|
|
+ allCustomFieldVO.setSysOrder(order);
|
|
|
+ allCustomFieldVOS.add(allCustomFieldVO);
|
|
|
+ order += 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //TODO 技术类别
|
|
|
+// List<Integer> technicalIds = assoTaskFields.stream()
|
|
|
+// .filter(item -> item.getFieldId().equals(9))
|
|
|
+// .map(AssoTaskField::getFieldId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ }
|
|
|
+ cacheUtils.addTaskCustomField(taskId, allCustomFieldVOS);
|
|
|
+ }
|
|
|
+ allCustomFieldVOS = allCustomFieldVOS.stream().sorted(Comparator.comparing(AllCustomFieldVO::getSysOrder)).collect(Collectors.toList());
|
|
|
+ return allCustomFieldVOS;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public Records getCustomFieldValues(QueryEsCustomFieldDTO queryEsCustomFieldDTO) throws Exception {
|
|
|
+ List<FieldValueVO> fieldValueVOS = new ArrayList<>();
|
|
|
+ Integer type = queryEsCustomFieldDTO.getFieldType();
|
|
|
+
|
|
|
+ EsCustomFieldDTO esCustomFieldDTO =new EsCustomFieldDTO();
|
|
|
+ esCustomFieldDTO.setFieldId(queryEsCustomFieldDTO.getFieldId());
|
|
|
+ esCustomFieldDTO.setProjectId((queryEsCustomFieldDTO.getProjectId()));
|
|
|
+ esCustomFieldDTO.setTaskId(queryEsCustomFieldDTO.getTaskId());
|
|
|
+ esCustomFieldDTO.setPatentNo(queryEsCustomFieldDTO.getPatentNo());
|
|
|
+ esCustomFieldDTO.setFieldType(queryEsCustomFieldDTO.getFieldType());
|
|
|
+
|
|
|
+ PatentWithIdVO patentVO = esCustomFieldService.getEsCustomField(esCustomFieldDTO);
|
|
|
+ if (patentVO != null){
|
|
|
+ List<String> value = patentVO.getPatent().getESCustomField().getFieldValue();
|
|
|
+ switch (type) {
|
|
|
+ case 0:
|
|
|
+
|
|
|
+ case 1:
|
|
|
+
|
|
|
+ case 2:
|
|
|
+ value.forEach(item -> {
|
|
|
+ FieldValueVO fieldValueVO = new FieldValueVO();
|
|
|
+ fieldValueVO.setValue(item);
|
|
|
+ fieldValueVOS.add(fieldValueVO);
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+
|
|
|
+ case 4:
|
|
|
+
|
|
|
+ case 5:
|
|
|
+ if (value!=null&&value.size() > 0) {
|
|
|
+ List<Integer> ids = FormatUtil.StringTOIntegerList(value);
|
|
|
+ LambdaQueryWrapper<CustomOption> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.in(CustomOption::getId, ids);
|
|
|
+ List<CustomOption> customOptions = customOptionService.list(queryWrapper);
|
|
|
+ customOptions.forEach(item -> {
|
|
|
+ FieldValueVO fieldValueVO = new FieldValueVO();
|
|
|
+ fieldValueVO.setValueId(item.getId());
|
|
|
+ fieldValueVO.setValue(item.getName());
|
|
|
+ fieldValueVOS.add(fieldValueVO);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 6:
|
|
|
+ case 7:
|
|
|
+ case 8:
|
|
|
+
|
|
|
+ case 9:
|
|
|
+ if (value!=null&&value.size() > 0) {
|
|
|
+ List<Integer> ids = FormatUtil.StringTOIntegerList(value);
|
|
|
+ LambdaQueryWrapper<TreeNode> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.in(TreeNode::getId, ids);
|
|
|
+ List<TreeNode> treeNodes = treeNodeService.list(queryWrapper);
|
|
|
+ treeNodes.forEach(item -> {
|
|
|
+ FieldValueVO fieldValueVO = new FieldValueVO();
|
|
|
+ fieldValueVO.setValueId(item.getId());
|
|
|
+ fieldValueVO.setValue(item.getName());
|
|
|
+ fieldValueVO.setPath(item.getPath());
|
|
|
+ fieldValueVOS.add(fieldValueVO);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ Records records = new Records();
|
|
|
+ records.setData(fieldValueVOS);
|
|
|
+ return records;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Records addAllPatentCustomFieldOrder(AllFieldOrderDTO allFieldOrderDTO) {
|
|
|
+ Integer projectId = allFieldOrderDTO.getProjectId();
|
|
|
+ List<AllCustomFieldVO> allCustomFieldVOS = allFieldOrderDTO.getAllCustomFieldVOs();
|
|
|
+ if(allFieldOrderDTO.getTaskId()!=null){
|
|
|
+ cacheUtils.addTaskCustomField(allFieldOrderDTO.getTaskId(),allCustomFieldVOS);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ cacheUtils.addPatentCustomField(projectId, allCustomFieldVOS);
|
|
|
+ }
|
|
|
+ Records records = new Records();
|
|
|
+ records.setData(allCustomFieldVOS);
|
|
|
+ return records;
|
|
|
+ }
|
|
|
+
|
|
|
}
|