|
@@ -1,12 +1,12 @@
|
|
|
package cn.cslg.pas.service.business;
|
|
|
|
|
|
import cn.cslg.pas.common.dto.business.ProductCategoryDTO;
|
|
|
-import cn.cslg.pas.common.model.cronModel.GroupVO;
|
|
|
-import cn.cslg.pas.common.model.cronModel.PersonnelVO;
|
|
|
+import cn.cslg.pas.common.model.cronModel.*;
|
|
|
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.LoginUtils;
|
|
|
+import cn.cslg.pas.common.vo.business.ProductCategoryVO;
|
|
|
import cn.cslg.pas.domain.business.AssoProductCategoryFile;
|
|
|
import cn.cslg.pas.domain.business.ProductCategory;
|
|
|
import cn.cslg.pas.exception.UnLoginException;
|
|
@@ -15,6 +15,9 @@ import cn.cslg.pas.factorys.businessFactory.Business;
|
|
|
import cn.cslg.pas.mapper.ProductCategoryMapper;
|
|
|
|
|
|
import cn.cslg.pas.service.common.FileManagerService;
|
|
|
+import cn.cslg.pas.service.permissions.PermissionService;
|
|
|
+import cn.cslg.pas.service.query.FormatQueryService;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -52,9 +55,26 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
|
|
|
@Autowired
|
|
|
private LoginUtils loginUtils;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private FormatQueryService formatQueryService;
|
|
|
+ @Autowired
|
|
|
+ private PermissionService permissionService;
|
|
|
+
|
|
|
@Override
|
|
|
public Object queryMessage(QueryRequest queryRequest) throws Exception {
|
|
|
- return null;
|
|
|
+ List<String> sqls = formatQueryService.reSqls(queryRequest);
|
|
|
+ //根据sql查询产品类别信息
|
|
|
+ List<ProductCategoryVO> productCategoryVOS = productCategoryMapper.getProductCategory(sqls.get(0),sqls.get(1),sqls.get(2));
|
|
|
+ //查询总数
|
|
|
+ Long total = productCategoryMapper.getProductCategoryCount(sqls.get(0));
|
|
|
+ //装载产品类别信息
|
|
|
+ this.loadProductCategory(productCategoryVOS);
|
|
|
+ Records records = new Records();
|
|
|
+ records.setCurrent(queryRequest.getCurrent());
|
|
|
+ records.setSize(queryRequest.getSize());
|
|
|
+ records.setData(productCategoryVOS);
|
|
|
+ records.setTotal(total);
|
|
|
+ return records;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -191,4 +211,66 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
|
|
|
public GroupVO getGroup(GroupRequest groupRequest,String name) throws Exception {
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+ private void loadProductCategory(List<ProductCategoryVO> productCategoryVOS) throws IOException {
|
|
|
+ List<Integer> createIds = new ArrayList<>();
|
|
|
+ List<Integer> ids = new ArrayList<>();
|
|
|
+ productCategoryVOS.forEach(
|
|
|
+ item -> {
|
|
|
+ if(item.getCreateId() != null){
|
|
|
+ createIds.add(item.getCreateId());
|
|
|
+ }
|
|
|
+ if (item.getId() != null) {
|
|
|
+ ids.add(item.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ List<Personnel> personnels = new ArrayList<>();
|
|
|
+ List<String> guids = new ArrayList<>();
|
|
|
+ List<SystemFile> systemFiles = new ArrayList<>();
|
|
|
+ List<AssoProductCategoryFile> assoProductCategoryFiles = new ArrayList<>();
|
|
|
+
|
|
|
+ if (ids.size() != 0) {
|
|
|
+ //根据产品类别id获得产品类别与文件关联表
|
|
|
+ LambdaQueryWrapper<AssoProductCategoryFile> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.in(AssoProductCategoryFile::getProductCategoryId, ids);
|
|
|
+ assoProductCategoryFiles = assoProductCategoryFileService.list(queryWrapper);
|
|
|
+ guids = assoProductCategoryFiles.stream().map(AssoProductCategoryFile::getFileGuid).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询创建人名称
|
|
|
+ if (createIds.size() != 0) {
|
|
|
+ String res = permissionService.getPersonnelByIdsFromPCS(createIds);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
+ personnels = JSONObject.parseArray(jsonObject.getString("data"), Personnel.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询文件
|
|
|
+ if (guids.size() != 0) {
|
|
|
+ String res = fileManagerService.getSystemFileFromFMS(guids);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
+ systemFiles = JSONObject.parseArray(jsonObject.getString("data"), SystemFile.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ //装载信息
|
|
|
+ for (ProductCategoryVO productCategoryVO:productCategoryVOS) {
|
|
|
+ //装载人员信息
|
|
|
+ Personnel personnel = personnels.stream().filter(item -> item.getId().equals(productCategoryVO.getCreateId())).findFirst().orElse(null);
|
|
|
+ if(personnel != null){
|
|
|
+ productCategoryVO.setCreateName(personnel.getPersonnelName());
|
|
|
+ }
|
|
|
+ //装载文件信息
|
|
|
+ List<AssoProductCategoryFile> assoProductCategoryFilesTemp = assoProductCategoryFiles.stream().filter(item -> item.getProductCategoryId().equals(productCategoryVO.getId())).collect(Collectors.toList());
|
|
|
+ if(assoProductCategoryFilesTemp.size() != 0){
|
|
|
+ List<String> guidTemp = assoProductCategoryFilesTemp.stream().map(AssoProductCategoryFile::getFileGuid).collect(Collectors.toList());
|
|
|
+ if (guidTemp.size() != 0) {
|
|
|
+ List<SystemFile> systemFileTemp = systemFiles.stream().filter(item -> guidTemp.contains(item.getGuid())).collect(Collectors.toList());
|
|
|
+ if (systemFileTemp.size() != 0) {
|
|
|
+ productCategoryVO.setSystemFileList(systemFileTemp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|