|
@@ -4,18 +4,25 @@ import cn.cslg.pas.common.core.base.IfConstant;
|
|
|
import cn.cslg.pas.common.dto.es.EsCustomFieldValueDTO;
|
|
|
import cn.cslg.pas.common.dto.es.EsValueCurveDTO;
|
|
|
import cn.cslg.pas.common.dto.es.SelectValueCurveDTO;
|
|
|
+import cn.cslg.pas.common.model.cronModel.PersonnelVO;
|
|
|
import cn.cslg.pas.common.model.cronModel.Records;
|
|
|
import cn.cslg.pas.common.model.request.OrderDTO;
|
|
|
+import cn.cslg.pas.common.utils.CacheUtils;
|
|
|
+import cn.cslg.pas.common.utils.LoginUtils;
|
|
|
import cn.cslg.pas.common.utils.parseQueryToTree.expressManager;
|
|
|
import cn.cslg.pas.common.utils.parseQueryToTree.operateNode;
|
|
|
import cn.cslg.pas.common.utils.parseQueryToTree.treeNode;
|
|
|
import cn.cslg.pas.common.vo.EsConfigVO;
|
|
|
import cn.cslg.pas.common.vo.es.EsCustomFieldBatchVO;
|
|
|
import cn.cslg.pas.common.vo.es.EsValueCurveVO;
|
|
|
+import cn.cslg.pas.domain.BaseEntity;
|
|
|
import cn.cslg.pas.domain.business.PermissionRecord;
|
|
|
+import cn.cslg.pas.domain.business.Product;
|
|
|
import cn.cslg.pas.domain.business.ProductMarketData;
|
|
|
import cn.cslg.pas.domain.es.Patent;
|
|
|
+import cn.cslg.pas.exception.XiaoShiException;
|
|
|
import cn.cslg.pas.mapper.PermissionRecordMapper;
|
|
|
+import cn.cslg.pas.mapper.ProductMapper;
|
|
|
import cn.cslg.pas.mapper.ProductMarketDataMapper;
|
|
|
import cn.cslg.pas.service.business.CommonService;
|
|
|
import cn.cslg.pas.service.query.FormatQueryService;
|
|
@@ -51,6 +58,12 @@ public class EsValueCurveService {
|
|
|
private final ElasticsearchClient client;
|
|
|
|
|
|
@Autowired
|
|
|
+ private CacheUtils cacheUtils;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private LoginUtils loginUtils;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private EsService esService;
|
|
|
|
|
|
@Autowired
|
|
@@ -62,6 +75,9 @@ public class EsValueCurveService {
|
|
|
@Autowired
|
|
|
private PermissionRecordMapper permissionRecordMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ProductMapper productMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 查询价值曲线
|
|
|
* @param vo
|
|
@@ -74,31 +90,40 @@ public class EsValueCurveService {
|
|
|
Integer startNum = vo.getStartNumber();
|
|
|
Integer endNum = vo.getEndNumber();
|
|
|
Integer timeType = vo.getTimeType();
|
|
|
+ //获取登陆人信息 用于设置创建人
|
|
|
+ PersonnelVO personnelVO = new PersonnelVO();
|
|
|
+ try {
|
|
|
+ personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new XiaoShiException("未登录");
|
|
|
+ }
|
|
|
+ Integer tenantId = personnelVO.getTenantId();
|
|
|
Map<String, List<Integer>> map = new HashMap<>();
|
|
|
if (!CollectionUtils.isEmpty(isAdd) && startNum <= 1 && endNum < 1) {
|
|
|
isAdd.removeAll(isDel);
|
|
|
- map = this.getProductIdByPatentNo(isAdd);
|
|
|
+ map = this.getProductIdByPatentNo(isAdd,tenantId);
|
|
|
} else if (startNum >= 1 && endNum > 0) {
|
|
|
List<String> patentNos = this.getPatentNos(vo);
|
|
|
- map = this.getProductIdByPatentNo(patentNos);
|
|
|
+ map = this.getProductIdByPatentNo(patentNos,tenantId);
|
|
|
}
|
|
|
- return this.getValueCurveList(map, timeType);
|
|
|
+ return this.getValueCurveList(map, timeType,tenantId);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 提取返回数据
|
|
|
+ *
|
|
|
* @param map
|
|
|
* @param timeType
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<EsValueCurveDTO> getValueCurveList(Map<String, List<Integer>> map, Integer timeType) {
|
|
|
+ public List<EsValueCurveDTO> getValueCurveList(Map<String, List<Integer>> map, Integer timeType, Integer tenantId) {
|
|
|
List<EsValueCurveDTO> curveDTOS = new ArrayList<>();
|
|
|
if (!CollectionUtils.isEmpty(map)) {
|
|
|
for (String patentNo : map.keySet()) {
|
|
|
List<SelectValueCurveDTO> listLicensee = new ArrayList<>();
|
|
|
List<SelectValueCurveDTO> listSale = new ArrayList<>();
|
|
|
//获取许可记录
|
|
|
- List<SelectValueCurveDTO> licenseeList = this.selectLicensee(patentNo, timeType);
|
|
|
+ List<SelectValueCurveDTO> licenseeList = this.selectLicensee(patentNo, timeType,tenantId);
|
|
|
if (!CollectionUtils.isEmpty(licenseeList)) {
|
|
|
Map<String, List<SelectValueCurveDTO>> licenseeMap = licenseeList.stream().collect(Collectors.groupingBy(SelectValueCurveDTO::getLicenseTime));
|
|
|
for (String key : licenseeMap.keySet()) {
|
|
@@ -250,7 +275,7 @@ public class EsValueCurveService {
|
|
|
if (!CollectionUtils.isEmpty(curveDTOS)) {
|
|
|
curveDTOS.forEach(i -> i.setTimeType(timeType));
|
|
|
}
|
|
|
- } else if (timeType == 0) {
|
|
|
+ } else if (timeType == 2) {
|
|
|
curveDTOS = productMarketDataMapper.selectSaleYearList(productIds);
|
|
|
if (!CollectionUtils.isEmpty(curveDTOS)) {
|
|
|
curveDTOS.forEach(i -> i.setTimeType(timeType));
|
|
@@ -270,20 +295,20 @@ public class EsValueCurveService {
|
|
|
* @param timeType
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<SelectValueCurveDTO> selectLicensee(String patentNo, Integer timeType) {
|
|
|
+ public List<SelectValueCurveDTO> selectLicensee(String patentNo, Integer timeType,Integer tenantId) {
|
|
|
List<SelectValueCurveDTO> curveDTOS = new ArrayList<>();
|
|
|
if (timeType == 0) {
|
|
|
- curveDTOS = permissionRecordMapper.selectLicenseeMonthList(patentNo);
|
|
|
+ curveDTOS = permissionRecordMapper.selectLicenseeMonthList(patentNo,tenantId);
|
|
|
if (!CollectionUtils.isEmpty(curveDTOS)) {
|
|
|
curveDTOS.forEach(i -> i.setTimeType(timeType));
|
|
|
}
|
|
|
} else if (timeType == 2) {
|
|
|
- curveDTOS = permissionRecordMapper.selectLicenseeYearList(patentNo);
|
|
|
+ curveDTOS = permissionRecordMapper.selectLicenseeYearList(patentNo,tenantId);
|
|
|
if (!CollectionUtils.isEmpty(curveDTOS)) {
|
|
|
curveDTOS.forEach(i -> i.setTimeType(timeType));
|
|
|
}
|
|
|
} else {
|
|
|
- curveDTOS = permissionRecordMapper.selectLicenseeQuarterList(patentNo);
|
|
|
+ curveDTOS = permissionRecordMapper.selectLicenseeQuarterList(patentNo,tenantId);
|
|
|
if (!CollectionUtils.isEmpty(curveDTOS)) {
|
|
|
curveDTOS.forEach(i -> i.setTimeType(timeType));
|
|
|
}
|
|
@@ -391,7 +416,7 @@ public class EsValueCurveService {
|
|
|
* @return
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
- public Map<String, List<Integer>> getProductIdByPatentNo(List<String> list) throws IOException {
|
|
|
+ public Map<String, List<Integer>> getProductIdByPatentNo(List<String> list,Integer tenantId) throws IOException {
|
|
|
Map<String, List<Integer>> map = new HashMap<>();
|
|
|
if (!CollectionUtils.isEmpty(list)) {
|
|
|
for (String patentNo : list) {
|
|
@@ -419,8 +444,13 @@ public class EsValueCurveService {
|
|
|
productIds.add(patent.getProductId());
|
|
|
}
|
|
|
}
|
|
|
+ List<Integer> ids = new ArrayList<>();
|
|
|
List<Integer> collect = productIds.stream().distinct().collect(Collectors.toList());
|
|
|
- map.put(patentNo, collect);
|
|
|
+ List<Product> products = productMapper.selectBatchIds(collect);
|
|
|
+ if (!CollectionUtils.isEmpty(products)) {
|
|
|
+ ids = products.stream().filter(i -> i.getTenantId().equals(tenantId)).map(BaseEntity::getId).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ map.put(patentNo, ids);
|
|
|
}
|
|
|
}
|
|
|
return map;
|