Commit fac803b5 authored by wangyangyang's avatar wangyangyang

项目查询接口

parent 9f65105a
package com.yonde.dex.basic.core.controller; package com.yonde.dex.basic.core.controller;
import com.yonde.dex.basedata.auth.annos.PermissionObject;
import com.yonde.dex.basedata.auth.annos.SubPermission;
import com.yonde.dex.basedata.data.search.SearchQueryCondition;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import java.util.List; import java.util.List;
import com.yonde.dex.basic.common.vo.ExtProgramVO; import com.yonde.dex.basic.common.vo.ExtProgramVO;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -12,21 +17,28 @@ import org.springframework.web.bind.annotation.*; ...@@ -12,21 +17,28 @@ import org.springframework.web.bind.annotation.*;
import com.yonde.dex.basic.core.service.ExtProgramService; import com.yonde.dex.basic.core.service.ExtProgramService;
import com.yonde.dex.basedata.entity.api.ApiResult; import com.yonde.dex.basedata.entity.api.ApiResult;
import com.yonde.dex.basic.core.controller.shadow.ExtProgramControllerShadow; import com.yonde.dex.basic.core.controller.shadow.ExtProgramControllerShadow;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
/** /**
* @description: ExtProgram-Controller * @description: ExtProgram-Controller
* @author: dexadmin * @author: dexadmin
* @version: V * @version: V
* @date: 2024-9-9 11:04:24 * @date: 2024-9-9 11:04:24
**/ **/
@Api(tags = "ExtProgram管理服务") @Api(tags = "ExtProgram管理服务")
@RequestMapping("/ExtProgram") @RequestMapping("/ExtProgram")
@ResponseBody() @ResponseBody()
@Controller(ExtProgramController.BEAN_NAME) @Controller(ExtProgramController.BEAN_NAME)
public class ExtProgramController<V extends ExtProgramVO, S extends ExtProgramService<V>> extends ExtProgramControllerShadow<V, S> { public class ExtProgramController<V extends ExtProgramVO, S extends ExtProgramService<V>> extends ExtProgramControllerShadow<V, S> {
@ApiOperation("项目群查询")
@PostMapping({"/search/props"})
public ApiResult searchProps(@RequestBody SearchQueryCondition searchQueryCondition) {
return ApiResult.ok(this.getService().searchProps(searchQueryCondition));
}
} }
......
package com.yonde.dex.basic.core.service; package com.yonde.dex.basic.core.service;
import com.yonde.dex.basedata.data.search.SearchQueryCondition;
import com.yonde.dex.basic.common.vo.ExtProgramVO; import com.yonde.dex.basic.common.vo.ExtProgramVO;
import com.yonde.dex.basic.core.service.shadow.ExtProgramServiceShadow; import com.yonde.dex.basic.core.service.shadow.ExtProgramServiceShadow;
import org.springframework.data.domain.Page;
/** /**
* @description: ExtProgram-service * @description: ExtProgram-service
* @author: dexadmin * @author: dexadmin
...@@ -10,4 +13,14 @@ import com.yonde.dex.basic.core.service.shadow.ExtProgramServiceShadow; ...@@ -10,4 +13,14 @@ import com.yonde.dex.basic.core.service.shadow.ExtProgramServiceShadow;
**/ **/
public interface ExtProgramService<V extends ExtProgramVO> extends ExtProgramServiceShadow<V> { public interface ExtProgramService<V extends ExtProgramVO> extends ExtProgramServiceShadow<V> {
/**
* @description: 项目群查询展开
* @param: [searchQueryCondition]
* @return: com.yonde.dex.basic.common.vo.ExtProgramVO
* @author: dexadmin
* @date: 2024-9-9 11:04:24
**/
Page<V> searchProps(SearchQueryCondition searchQueryCondition);
} }
package com.yonde.dex.basic.core.service.impl; package com.yonde.dex.basic.core.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.yonde.dex.basedata.data.search.SearchItem;
import com.yonde.dex.basedata.data.search.SearchQueryBuilder;
import com.yonde.dex.basedata.data.search.SearchQueryCondition;
import com.yonde.dex.basedata.entity.data.DxPageImpl;
import com.yonde.dex.basic.common.vo.ExtProgramProjectLinkVO;
import com.yonde.dex.basic.core.service.ExtProgramProjectLinkService;
import com.yonde.dex.basic.core.service.expand.ExtDxContextService;
import com.yonde.dex.basic.core.util.SearchUtil;
import com.yonde.dex.context.common.vo.DxContextProjectVO;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import java.util.List; import java.util.List;
import com.yonde.dex.basic.common.vo.ExtProgramVO; import com.yonde.dex.basic.common.vo.ExtProgramVO;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -11,17 +25,18 @@ import org.springframework.web.bind.annotation.*; ...@@ -11,17 +25,18 @@ import org.springframework.web.bind.annotation.*;
import com.yonde.dex.basic.core.service.ExtProgramService; import com.yonde.dex.basic.core.service.ExtProgramService;
import com.yonde.dex.basic.core.repository.ExtProgramRepository; import com.yonde.dex.basic.core.repository.ExtProgramRepository;
import com.yonde.dex.basic.entity.po.ExtProgram; import com.yonde.dex.basic.entity.po.ExtProgram;
import javax.annotation.Resource; import javax.annotation.Resource;
/** /**
* @description: ExtProgram-ServiceImpl * @description: ExtProgram-ServiceImpl
* @author: dexadmin * @author: dexadmin
* @version: V * @version: V
* @date: 2024-9-9 11:04:24 * @date: 2024-9-9 11:04:24
**/ **/
@Slf4j @Slf4j
@Service(ExtProgramServiceImpl.BEAN_NAME) @Service(ExtProgramServiceImpl.BEAN_NAME)
public class ExtProgramServiceImpl<V extends ExtProgramVO> implements ExtProgramService<V>{ public class ExtProgramServiceImpl<V extends ExtProgramVO> implements ExtProgramService<V> {
public static final String BEAN_NAME = "extProgramServiceImpl"; public static final String BEAN_NAME = "extProgramServiceImpl";
...@@ -29,6 +44,35 @@ public class ExtProgramServiceImpl<V extends ExtProgramVO> implements ExtProgram ...@@ -29,6 +44,35 @@ public class ExtProgramServiceImpl<V extends ExtProgramVO> implements ExtProgram
@Autowired @Autowired
ExtProgramRepository<ExtProgram> extProgramRepository; ExtProgramRepository<ExtProgram> extProgramRepository;
@Autowired
ExtProgramProjectLinkService extProgramProjectLinkService;
@Autowired
ExtDxContextService extDxContextService;
public void test() {
this.findRecursion(new SearchQueryCondition());
}
@Override
public Page<V> searchProps(SearchQueryCondition searchQueryCondition) {
Page<V> page = search(searchQueryCondition);
if (page.hasContent()) {
for (V v : page.getContent()) {
//设置项目子级
SearchQueryCondition queryCondition = SearchUtil.buildQueryWithOpenAttr("sourceId", SearchItem.Operator.EQ, v.getId(), "target");
List<ExtProgramProjectLinkVO> content = extProgramProjectLinkService.findRecursion(queryCondition).getContent();
for (ExtProgramProjectLinkVO linkVO : content) {
Long targetId = linkVO.getTargetId();
List<DxContextProjectVO> children = extDxContextService.getSingleChild(targetId);
linkVO.getTarget().setChildren(children);
}
v.setExtProgramProjectLinks(content);
}
}
// Page<V> result = new PageImpl<>(page.getContent(), page.getPageable(), page.getTotalElements());
return page;
}
} }
package com.yonde.dex.basic.core.util;
import com.yonde.dex.dao.service.util.ApplicationContextUtil;
import com.yonde.dex.dict.feign.DictDataFeignService;
import com.yonde.dex.dict.service.vo.DictDataVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.List;
@Slf4j
@Component
public class CommonUtils {
private static DictDataFeignService dictDataFeignService;
public CommonUtils() {
this.dictDataFeignService = ApplicationContextUtil.getBean(DictDataFeignService.class);
}
/**
*根据字典code获取字典code和字典项的值获取key(中文转英文,key是英文,value是中文)
* @param dictCode
* @param dictValue
* @return
*/
public static String searchDictDataByDictCode(String dictCode, String dictValue) {
if (!StringUtils.isEmpty(dictValue)) {
//字典type 项目代号 ProjectCode
List<DictDataVO> dictDatasByDictCode = dictDataFeignService.getDictDatas(dictCode);
if (CollectionUtils.isEmpty(dictDatasByDictCode)) {
log.error("所查字典为空!字典code为:" + dictCode);
return "";
} else {
for (DictDataVO dictDataVO : dictDatasByDictCode) {
if (dictValue.equals(dictDataVO.getDictValue())) {
return dictDataVO.getDictKey();
}
}
log.error("所查字典数据项为空!字典code为:" + dictCode);
return "";
}
}
log.error("所查字典Key为空!字典code为:" + dictCode);
return "";
}
/**
*根据字典code获取字典code和字典项的值获取key(英文转中文,key是英文,value是中文)
* @param dictCode
* @return
*/
public static String searchDictDataValueByDictCode(String dictCode, String dictKey) {
if (!StringUtils.isEmpty(dictKey)) {
//字典type 项目代号 ProjectCode
List<DictDataVO> dictDatasByDictCode = dictDataFeignService.getDictDatas(dictCode);
if (CollectionUtils.isEmpty(dictDatasByDictCode)) {
log.error("所查字典为空!字典code为:" + dictCode);
return "";
} else {
for (DictDataVO dictDataVO : dictDatasByDictCode) {
if (dictKey.equals(dictDataVO.getDictKey())) {
return dictDataVO.getDictValue();
}
}
log.error("所查字典数据项为空!字典code为:" + dictCode);
return "";
}
}
log.error("所查字典Key为空!字典code为:" + dictCode);
return "";
}
}
package com.yonde.dex.basic.core.util;
import cn.hutool.core.io.IoUtil;
import com.yonde.dex.basedata.exception.DxBusinessException;
import lombok.extern.slf4j.Slf4j;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
/**
* @author xfchai
* @ClassName FileUtils.java
* @Description 文件工具类
* @createTime 2022/05/31 14:13:00
*/
@Slf4j
public class FileUtils {
public static void main(String[] args) {
String contentType = "application/vnd.ms-excel;charset=utf-8";
String fileName = "定额工时模板.xlsx";
}
/**
* 导出通用文件
*
* @param response
* @param fileInputStream
* @throws IOException
*/
public static void exportFile(HttpServletResponse response, FileInputStream fileInputStream, String exportType, String name) throws IOException {
//放到缓冲流里面
BufferedInputStream bins = new BufferedInputStream(fileInputStream);
//获取文件输出IO流
OutputStream outs = response.getOutputStream();
BufferedOutputStream bouts = new BufferedOutputStream(outs);
response.setContentType(exportType);
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
response.setHeader("Content-disposition", "attachment;filename=" + name);
//修正 Excel在“xxx.xlsx”中发现不可读取的内容。是否恢复此工作薄的内容?如果信任此工作簿的来源,请点击"是"
OutputStream out = response.getOutputStream();
byte[] b = new byte[2048];
int len;
while ((len = fileInputStream.read(b)) != -1) {
out.write(b, 0, len);
}
//TODO 设置Content-Length大小
response.setHeader("Content-Length", String.valueOf(fileInputStream.getChannel().size()));
int bytesRead = 0;
byte[] buffer = new byte[8192];
//开始向网络传输文件流
while ((bytesRead = bins.read(buffer, 0, 8192)) != -1) {
bouts.write(buffer, 0, bytesRead);
}
//调用flush()方法
bouts.flush();
fileInputStream.close();
bins.close();
outs.close();
bouts.close();
out.close();
}
/**
* 删除目录下的所有文件
*
* @param file
* @param deleteDir 是否删除最外层目录
*/
public static void deleteDir(File file, Boolean deleteDir) {
//判断文件不为null或文件目录存在
if (file == null || !file.exists()) {
System.out.println("文件删除失败,请检查文件路径是否正确");
return;
}
//取得这个目录下的所有子文件对象
File[] files = file.listFiles();
//遍历该目录下的文件对象
for (File f : files) {
//打印文件名
String name = file.getName();
System.out.println(name);
//判断子目录是否存在子目录,如果是文件则删除
if (f.isDirectory()) {
deleteDir(f, true);
} else {
f.delete();
}
}
//删除空文件夹 for循环已经把上一层节点的目录清空。
if (deleteDir) {
file.delete();
}
}
/**
* 保存到本地目录
*
* @param inputStream
* @param fileUrl 文件绝对路径
*/
public static void inputToFile(InputStream inputStream, String fileUrl) {
OutputStream outputStream = null;
try {
try {
outputStream = new FileOutputStream(fileUrl);
} catch (FileNotFoundException e) {
log.info("保存到本地临时目录失败:{}!", fileUrl);
throw new DxBusinessException("500", "保存文件到本地临时目录失败:" + fileUrl);
}
IoUtil.copy(inputStream, outputStream);
} finally {
IoUtil.close(inputStream);
IoUtil.close(outputStream);
}
}
}
package com.yonde.dex.basic.core.util;
import cn.hutool.core.io.FileUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.system.ApplicationHome;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import java.util.UUID;
/**
* @program: service
* @description: 外部资源配置类
* @author: dang wei
* @create: 2021-01-04 11:29
*/
@Slf4j
public class ResourceHelper {
public static String baseHomeDir;
/**
* 获取外部资源配置
*
* @return
*/
public static Properties getResource() {
Properties prop = new Properties();
try {
prop.load(new FileInputStream("resource/esignConfig.properties"));
} catch (FileNotFoundException e) {
log.error("找不到配置资源文件:" + e.getMessage());
} catch (IOException e) {
log.error("读取外部配置资源文件报错:" + e.getMessage());
}
return prop;
}
/**
* 项目经费 模板文件目录
*
* @return
*/
public static String getFundsDir() {
return getBaseHomeDir() + File.separator +
"config" + File.separator +
"funds";
}
/**
* 项目经费 模板文件目录
*
* @return
*/
public static String getIndexDir() {
return getBaseHomeDir() + File.separator +
"config" + File.separator +
"index";
}
/**
* 手写体签名路径
*
* @return
*/
public static String getHandImage() {
return getBaseHomeDir() + File.separator +
"config" + File.separator +
"handImage";
}
/**
* 受控文件路径
*
* @return
*/
public static String getSKImage() {
return getBaseHomeDir() + File.separator +
"config" + File.separator + "doc" + File.separator +
"skImage.png"
;
}
/**
* 作废文件路径
*
* @return
*/
public static String getZFImage() {
return getBaseHomeDir() + File.separator +
"config" + File.separator + "doc" + File.separator +
"zfImage.png";
}
/**
* 设计资源模板
*
* @return
*/
public static String getProductTemplateDir() {
return getBaseHomeDir() + File.separator +
"config" + File.separator +
"product";
}
/**
* 明细表配置坐标
*
* @return
*/
public static String getScheduleDir() {
return getBaseHomeDir() + File.separator +
"config" + File.separator +
"detailed";
}
/**
* 工序卡片 提取属性+模板目录
*
* @return
*/
public static String getOperationCardDir() {
return getBaseHomeDir() + File.separator +
"config" + File.separator +
"operation";
}
/**
* 工艺 封面 路径
*
* @return
*/
public static String getPlanDir() {
return getBaseHomeDir() + File.separator +
"config" + File.separator +
"operation" + File.separator +
"工艺模板";
}
/**
* 相关卡片 的坐标配置目录
*
* @return
*/
public static String getCardPositionDir() {
return getBaseHomeDir() + File.separator +
"config" + File.separator +
"operation" + File.separator +
"position";
}
/**
* 获取jar包所在目录
*
* @return
*/
public static String getBaseHomeDir() {
if (StringUtils.isEmpty(baseHomeDir)) {
ApplicationHome home = new ApplicationHome(ResourceHelper.class);
baseHomeDir = home.getSource().getParentFile().getPath();
}
return baseHomeDir;
}
public static File CreateTemDir() {
String uuid = UUID.randomUUID().toString().replace("-", "");
String temDir = getBaseHomeDir() + File.separator +
"tem" + File.separator +
uuid;
return FileUtil.mkdir(temDir);
}
}
package com.yonde.dex.basic.core.util;
import com.yonde.dex.basedata.data.search.SearchItem;
import com.yonde.dex.basedata.data.search.SearchQueryBuilder;
import com.yonde.dex.basedata.data.search.SearchQueryCondition;
public class SearchUtil {
/**
* 构建查询条件
*
* @param key
* @param value
* @return
*/
public static SearchQueryCondition buildQuery(String key, SearchItem.Operator operator, Object value) {
return SearchQueryBuilder.openBuild()
.openFilterBuilder()
.setItem(key, operator, value)
.builder().build();
}
/**
* 构建带扩展属性的查询条件
*
* @param key
* @param value
* @param openAttr
* @return
*/
public static SearchQueryCondition buildQueryWithOpenAttr(String key, SearchItem.Operator operator, Object value, String openAttr) {
return SearchQueryBuilder.openBuild()
.setPropName(openAttr)
.openFilterBuilder()
.setItem(key, operator, value)
.builder().build();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment