初始代码
This commit is contained in:
32
yunzhupaas-extend/yunzhupaas-extend-controller/pom.xml
Normal file
32
yunzhupaas-extend/yunzhupaas-extend-controller/pom.xml
Normal file
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yunzhupaas-extend</artifactId>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<version>5.2.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yunzhupaas-extend-controller</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-extend-biz</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-file-entity</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-provider</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.yunzhupaas.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.yunzhupaas.util.DownUtil;
|
||||
import com.yunzhupaas.util.ServletUtil;
|
||||
import com.yunzhupaas.util.ZxingCodeUtil;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
/**
|
||||
* 生成条码
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
@RestController
|
||||
@Tag(name = "(待定)生成条码", description = "BarCode")
|
||||
@RequestMapping("/api/extend/BarCode")
|
||||
public class BarCodeController {
|
||||
|
||||
/**
|
||||
* 生成二维码
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "生成二维码")
|
||||
@GetMapping("/BuildQRCode")
|
||||
public void buildQrCode() {
|
||||
BufferedImage image = ZxingCodeUtil.createCode(ServletUtil.getHeader("F_QRCodeContent"), 400, 400);
|
||||
DownUtil.write(image);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成条形码
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "生成条形码")
|
||||
@GetMapping("/BuildBarCode")
|
||||
public void buildBarCode() {
|
||||
BufferedImage image = ZxingCodeUtil.getBarcode(ServletUtil.getHeader("F_BarCodeContent"), 265, 50);
|
||||
DownUtil.write(image);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.yunzhupaas.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.Pagination;
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import com.yunzhupaas.base.vo.PageListVO;
|
||||
import com.yunzhupaas.base.vo.PaginationVO;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.entity.BigDataEntity;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.model.bidata.BigBigDataListVO;
|
||||
import com.yunzhupaas.service.BigDataService;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 大数据测试
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
@Tag(name = "大数据测试", description = "BigData")
|
||||
@RestController
|
||||
@RequestMapping("/api/extend/BigData")
|
||||
public class BigDataController extends SuperController<BigDataService, BigDataEntity> {
|
||||
|
||||
@Autowired
|
||||
private BigDataService bigDataService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param pagination 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "列表")
|
||||
@GetMapping
|
||||
@SaCheckPermission("extend.bigData")
|
||||
public ActionResult<PageListVO<BigBigDataListVO>> list(Pagination pagination) {
|
||||
List<BigDataEntity> data = bigDataService.getList(pagination);
|
||||
List<BigBigDataListVO> list= JsonUtil.getJsonToList(data, BigBigDataListVO.class);
|
||||
PaginationVO paginationVO = JsonUtil.getJsonToBean(pagination,PaginationVO.class);
|
||||
return ActionResult.page(list,paginationVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "添加大数据测试")
|
||||
@PostMapping
|
||||
@SaCheckPermission("extend.bigData")
|
||||
public ActionResult create() throws WorkFlowException {
|
||||
bigDataService.create(10000);
|
||||
return ActionResult.success(MsgCode.ETD105.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
package com.yunzhupaas.controller;
|
||||
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.Pagination;
|
||||
import com.yunzhupaas.base.vo.PageListVO;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.entity.CustomerEntity;
|
||||
import com.yunzhupaas.model.customer.CustomerCrForm;
|
||||
import com.yunzhupaas.model.customer.CustomerInfoVO;
|
||||
import com.yunzhupaas.model.customer.CustomerListVO;
|
||||
import com.yunzhupaas.model.customer.CustomerUpForm;
|
||||
import com.yunzhupaas.service.CustomerService;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 客户信息
|
||||
*
|
||||
* @版本: V3.1.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2021-07-10 14:09:05
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Tag(name = "客户信息", description = "Customer")
|
||||
@RequestMapping("/api/extend/saleOrder/Customer")
|
||||
public class CustomerController extends SuperController<CustomerService, CustomerEntity> {
|
||||
|
||||
@Autowired
|
||||
private CustomerService customerService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param pagination 分页模型
|
||||
* @return
|
||||
*/
|
||||
@GetMapping
|
||||
@Operation(summary = "列表")
|
||||
public ActionResult<PageListVO<CustomerListVO>> list(Pagination pagination) {
|
||||
pagination.setPageSize(50);
|
||||
pagination.setCurrentPage(1);
|
||||
List<CustomerEntity> list = customerService.getList(pagination);
|
||||
List<CustomerListVO> listVO = JsonUtil.getJsonToList(list, CustomerListVO.class);
|
||||
PageListVO<CustomerListVO> vo = new PageListVO<>();
|
||||
vo.setList(listVO);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param customerCrForm 新建模型
|
||||
* @return
|
||||
*/
|
||||
@PostMapping
|
||||
@Operation(summary = "创建")
|
||||
@Parameters({
|
||||
@Parameter(name = "customerCrForm", description = "客户模型", required = true),
|
||||
})
|
||||
public ActionResult<String> create(@RequestBody @Valid CustomerCrForm customerCrForm) {
|
||||
CustomerEntity entity = JsonUtil.getJsonToBean(customerCrForm, CustomerEntity.class);
|
||||
customerService.create(entity);
|
||||
return ActionResult.success(MsgCode.SU001.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
@Operation(summary = "信息")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult<CustomerInfoVO> info(@PathVariable("id") String id) {
|
||||
CustomerEntity entity = customerService.getInfo(id);
|
||||
CustomerInfoVO vo = JsonUtil.getJsonToBean(entity, CustomerInfoVO.class);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param id 主键
|
||||
* @param customerUpForm 修改模型
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("/{id}")
|
||||
@Operation(summary = "更新")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "customerUpForm", description = "客户模型", required = true),
|
||||
})
|
||||
public ActionResult<String> update(@PathVariable("id") String id,
|
||||
@RequestBody @Valid CustomerUpForm customerUpForm) {
|
||||
CustomerEntity entity = JsonUtil.getJsonToBean(customerUpForm, CustomerEntity.class);
|
||||
boolean ok = customerService.update(id, entity);
|
||||
if (ok) {
|
||||
return ActionResult.success(MsgCode.SU004.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.FA002.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping("/{id}")
|
||||
@Operation(summary = "删除")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult<String> delete(@PathVariable("id") String id) {
|
||||
CustomerEntity entity = customerService.getInfo(id);
|
||||
if (entity != null) {
|
||||
customerService.delete(entity);
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,788 @@
|
||||
package com.yunzhupaas.controller;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.xuyanwu.spring.file.storage.FileInfo;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.Page;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import com.yunzhupaas.base.util.OptimizeUtil;
|
||||
import com.yunzhupaas.base.vo.DownloadVO;
|
||||
import com.yunzhupaas.base.vo.ListVO;
|
||||
import com.yunzhupaas.config.ConfigValueUtil;
|
||||
import com.yunzhupaas.constant.FileTypeConstant;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.entity.DocumentEntity;
|
||||
import com.yunzhupaas.entity.DocumentLogEntity;
|
||||
import com.yunzhupaas.entity.DocumentShareEntity;
|
||||
import com.yunzhupaas.exception.DataException;
|
||||
import com.yunzhupaas.extend.service.DocumentApi;
|
||||
import com.yunzhupaas.flowable.entity.TaskEntity;
|
||||
import com.yunzhupaas.flowable.model.task.FileModel;
|
||||
import com.yunzhupaas.model.MergeChunkDto;
|
||||
import com.yunzhupaas.model.document.*;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.permission.service.UserService;
|
||||
import com.yunzhupaas.service.DocumentLogService;
|
||||
import com.yunzhupaas.service.DocumentService;
|
||||
import com.yunzhupaas.util.*;
|
||||
import com.yunzhupaas.util.treeutil.SumTree;
|
||||
import com.yunzhupaas.util.treeutil.newtreeutil.TreeDotUtils;
|
||||
import com.yunzhupaas.workflow.service.TaskApi;
|
||||
import lombok.Cleanup;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 文档管理
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
@Slf4j
|
||||
@Tag(name = "知识管理", description = "Document")
|
||||
@RestController
|
||||
@RequestMapping("/api/extend/Document")
|
||||
public class DocumentController extends SuperController<DocumentService, DocumentEntity> implements DocumentApi {
|
||||
|
||||
@Autowired
|
||||
private DocumentService documentService;
|
||||
@Autowired
|
||||
private ConfigValueUtil configValueUtil;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private DocumentLogService documentLogService;
|
||||
@Autowired
|
||||
private TaskApi taskApi;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "列表")
|
||||
@GetMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult<DocumentInfoVO> info(@PathVariable("id") String id) throws DataException {
|
||||
DocumentEntity entity = documentService.getInfo(id);
|
||||
DocumentInfoVO vo = JsonUtil.getJsonToBean(entity, DocumentInfoVO.class);
|
||||
//截取后缀
|
||||
String[] fullName = vo.getFullName().split("\\.");
|
||||
if (fullName.length > 1) {
|
||||
String fullNames = "";
|
||||
for (int i = 0; i < fullName.length - 1; i++) {
|
||||
if (i > 0) {
|
||||
fullNames += "." + fullName[i];
|
||||
} else {
|
||||
fullNames += fullName[i];
|
||||
}
|
||||
}
|
||||
vo.setFullName(fullNames);
|
||||
}
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建
|
||||
*
|
||||
* @param documentCrForm 新建模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "新建")
|
||||
@PostMapping
|
||||
@Parameters({
|
||||
@Parameter(name = "documentCrForm", description = "知识模型", required = true),
|
||||
})
|
||||
public ActionResult create(@RequestBody @Valid DocumentCrForm documentCrForm) {
|
||||
DocumentEntity entity = JsonUtil.getJsonToBean(documentCrForm, DocumentEntity.class);
|
||||
if (documentService.isExistByFullName(documentCrForm.getFullName(), entity.getId(), documentCrForm.getParentId())) {
|
||||
return ActionResult.fail(MsgCode.EXIST004.get());
|
||||
}
|
||||
entity.setEnabledMark(1);
|
||||
documentService.create(entity);
|
||||
return ActionResult.success(MsgCode.SU001.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*
|
||||
* @param id 主键
|
||||
* @param documentUpForm 修改模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "修改")
|
||||
@PutMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "documentUpForm", description = "知识模型", required = true),
|
||||
})
|
||||
public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid DocumentUpForm documentUpForm) {
|
||||
DocumentEntity entity = JsonUtil.getJsonToBean(documentUpForm, DocumentEntity.class);
|
||||
if (documentService.isExistByFullName(documentUpForm.getFullName(), id, documentUpForm.getParentId())) {
|
||||
return ActionResult.fail(MsgCode.EXIST004.get());
|
||||
}
|
||||
DocumentEntity info = documentService.getInfo(id);
|
||||
//获取后缀名
|
||||
String[] fullName = info.getFullName().split("\\.");
|
||||
if (fullName.length > 1) {
|
||||
entity.setFullName(entity.getFullName() + "." + fullName[fullName.length - 1]);
|
||||
}
|
||||
boolean flag = documentService.update(id, entity);
|
||||
if (flag == false) {
|
||||
return ActionResult.fail(MsgCode.FA002.get());
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU004.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "删除")
|
||||
@DeleteMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult delete(@PathVariable("id") String id) {
|
||||
DocumentEntity entity = documentService.getInfo(id);
|
||||
if (entity != null) {
|
||||
List<DocumentEntity> allList = documentService.getAllList(entity.getId());
|
||||
if (allList.size() > 0) {
|
||||
return ActionResult.fail(MsgCode.FA016.get());
|
||||
}
|
||||
documentService.delete(entity);
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.FA003.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取知识管理列表(文件夹树)")
|
||||
@PostMapping("/FolderTree")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult<ListVO<DocumentFolderTreeVO>> folderTree(@RequestBody DocumentShareForm form) {
|
||||
List<DocumentEntity> data = documentService.getFolderList();
|
||||
if (StringUtil.isNotEmpty(form.getIds())) {
|
||||
form.getIds().forEach(t -> data.remove(documentService.getInfo(t)));
|
||||
}
|
||||
List<DocumentFolderTreeModel> treeList = new ArrayList<>();
|
||||
DocumentFolderTreeModel model = new DocumentFolderTreeModel();
|
||||
model.setId("-1");
|
||||
model.setFullName("全部文档");
|
||||
model.setParentId("0");
|
||||
model.setIcon("0");
|
||||
treeList.add(model);
|
||||
for (DocumentEntity entity : data) {
|
||||
DocumentFolderTreeModel treeModel = new DocumentFolderTreeModel();
|
||||
treeModel.setId(entity.getId());
|
||||
treeModel.setFullName(entity.getFullName());
|
||||
treeModel.setParentId(entity.getParentId());
|
||||
treeModel.setIcon("fa fa-folder");
|
||||
treeList.add(treeModel);
|
||||
}
|
||||
List<SumTree<DocumentFolderTreeModel>> trees = TreeDotUtils.convertListToTreeDotFilter(treeList);
|
||||
List<DocumentFolderTreeVO> listVO = JsonUtil.getJsonToList(trees, DocumentFolderTreeVO.class);
|
||||
ListVO vo = new ListVO();
|
||||
vo.setList(listVO);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表(全部文档)
|
||||
*
|
||||
* @param page 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取知识管理列表(全部文档)")
|
||||
@GetMapping
|
||||
public ActionResult<ListVO<DocumentListVO>> allList(PageDocument page) {
|
||||
List<DocumentEntity> data = documentService.getAllList(page.getParentId());
|
||||
if (StringUtil.isNotEmpty(page.getKeyword())) {
|
||||
data = documentService.getSearchAllList(page.getKeyword());
|
||||
}
|
||||
List<DocumentListVO> list = JsonUtil.getJsonToList(data, DocumentListVO.class);
|
||||
//读取允许文件预览类型
|
||||
String allowPreviewType = configValueUtil.getAllowPreviewFileType();
|
||||
String[] fileType = allowPreviewType.split(",");
|
||||
for (DocumentListVO documentListVO : list) {
|
||||
//文件预览类型检验
|
||||
String s = Arrays.asList(fileType).stream().filter(type -> type.equals(documentListVO.getFileExtension())).findFirst().orElse(null);
|
||||
documentListVO.setIsPreview(s);
|
||||
}
|
||||
|
||||
ListVO vo = new ListVO();
|
||||
vo.setList(list);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表(我的分享)
|
||||
*
|
||||
* @param page 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "知识管理(我的共享列表)")
|
||||
@GetMapping("/Share")
|
||||
public ActionResult<ListVO<DocumentListVO>> shareOutList(PageDocument page) {
|
||||
List<DocumentEntity> data = documentService.getShareOutList();
|
||||
if (StringUtil.isNotEmpty(page.getKeyword())) {
|
||||
List<DocumentEntity> dataSearch = new ArrayList<>();
|
||||
for (DocumentEntity datum : data) {
|
||||
if (Objects.equals(datum.getType(), 0)) {
|
||||
List<DocumentEntity> childList = new ArrayList<>();
|
||||
documentService.getChildSrcList(datum.getId(), childList, 1);
|
||||
List<DocumentEntity> collect = childList.stream().filter(t -> !Objects.equals(t.getType(), 0)).collect(Collectors.toList());
|
||||
dataSearch.addAll(collect);
|
||||
} else {
|
||||
dataSearch.add(datum);
|
||||
}
|
||||
|
||||
}
|
||||
data = dataSearch.stream().distinct().filter(t -> t.getFullName().contains(page.getKeyword())).collect(Collectors.toList());
|
||||
} else if (StringUtil.isNotEmpty(page.getParentId()) && !"0".equals(page.getParentId())) {
|
||||
data = documentService.getAllList(page.getParentId());
|
||||
}
|
||||
List<DocumentListVO> list = JsonUtil.getJsonToList(data, DocumentListVO.class);
|
||||
ListVO vo = new ListVO();
|
||||
vo.setList(list);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表(共享给我)
|
||||
*
|
||||
* @param page 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取知识管理列表(共享给我)")
|
||||
@GetMapping("/ShareTome")
|
||||
public ActionResult<ListVO<DocumentListVO>> shareTomeList(PageDocument page) {
|
||||
List<DocumentShareEntity> shareTomeList = documentService.getShareTomeList();
|
||||
List<String> ids = shareTomeList.stream().map(DocumentShareEntity::getDocumentId).collect(Collectors.toList());
|
||||
List<DocumentEntity> list = documentService.getInfoByIds(ids);
|
||||
|
||||
List<String> userIds = list.stream().map(t -> t.getCreatorUserId()).collect(Collectors.toList());
|
||||
List<UserEntity> userNames = userService.getUserName(userIds);
|
||||
List<DocumentListVO> dataRes = new ArrayList<>();
|
||||
if (StringUtil.isNotEmpty(page.getParentId()) && !"0".equals(page.getParentId())) {
|
||||
list = documentService.getChildList(page.getParentId(), true);
|
||||
DocumentShareEntity documentShareEntity = documentService.getShareByParentId(page.getParentId());
|
||||
for (DocumentEntity item : list) {
|
||||
DocumentListVO documentListVO = BeanUtil.copyProperties(item, DocumentListVO.class);
|
||||
if (documentShareEntity != null) {
|
||||
documentListVO.setShareTime(documentShareEntity.getShareTime());
|
||||
UserEntity userEntity = userNames.stream().filter(t -> t.getId().equals(documentShareEntity.getCreatorUserId())).findFirst().orElse(null);
|
||||
documentListVO.setCreatorUserId(userEntity != null ? userEntity.getRealName() + "/" + userEntity.getAccount() : "");
|
||||
}
|
||||
dataRes.add(documentListVO);
|
||||
}
|
||||
} else {
|
||||
for (DocumentEntity datum : list) {
|
||||
if (StringUtil.isNotEmpty(page.getKeyword())) {
|
||||
DocumentShareEntity documentShareEntity = shareTomeList.stream().filter(t -> t.getDocumentId().equals(datum.getId())).findFirst().orElse(null);
|
||||
if (documentShareEntity != null) {
|
||||
if (Objects.equals(datum.getType(), 0)) {
|
||||
List<DocumentEntity> childList = new ArrayList<>();
|
||||
documentService.getChildSrcList(datum.getId(), childList, 1);
|
||||
for (DocumentEntity item : childList) {
|
||||
DocumentListVO documentListVO = BeanUtil.copyProperties(item, DocumentListVO.class);
|
||||
if (item.getFullName().contains(page.getKeyword()) && Objects.equals(item.getEnabledMark(), 1) && !Objects.equals(item.getType(), 0)) {
|
||||
documentListVO.setShareTime(documentShareEntity.getShareTime());
|
||||
UserEntity userEntity = userNames.stream().filter(t -> t.getId().equals(documentShareEntity.getCreatorUserId())).findFirst().orElse(null);
|
||||
documentListVO.setCreatorUserId(userEntity != null ? userEntity.getRealName() + "/" + userEntity.getAccount() : "");
|
||||
dataRes.add(documentListVO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
DocumentShareEntity documentShareEntity = shareTomeList.stream().filter(t -> t.getDocumentId().equals(datum.getId())).findFirst().orElse(null);
|
||||
if (documentShareEntity != null) {
|
||||
DocumentListVO documentListVO = BeanUtil.copyProperties(datum, DocumentListVO.class);
|
||||
documentListVO.setShareTime(documentShareEntity.getShareTime());
|
||||
UserEntity userEntity = userNames.stream().filter(t -> t.getId().equals(documentShareEntity.getCreatorUserId())).findFirst().orElse(null);
|
||||
documentListVO.setCreatorUserId(userEntity != null ? userEntity.getRealName() + "/" + userEntity.getAccount() : "");
|
||||
dataRes.add(documentListVO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ListVO vo = new ListVO();
|
||||
vo.setList(dataRes);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表(回收站)
|
||||
*
|
||||
* @param page 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取知识管理列表(回收站)")
|
||||
@GetMapping("/Trash")
|
||||
public ActionResult<ListVO<DocumentTrashListVO>> trashList(Page page) {
|
||||
List<DocumentTrashListVO> data = documentService.getTrashList(page.getKeyword());
|
||||
ListVO vo = new ListVO();
|
||||
vo.setList(data);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表(共享人员)
|
||||
*
|
||||
* @param documentId 文档主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取知识管理列表(共享人员)")
|
||||
@GetMapping("/ShareUser/{documentId}")
|
||||
@Parameters({
|
||||
@Parameter(name = "documentId", description = "文档主键", required = true),
|
||||
})
|
||||
public ActionResult<ListVO<DocumentSuserListVO>> shareUserList(@PathVariable("documentId") String documentId) {
|
||||
List<DocumentShareEntity> data = documentService.getShareUserList(documentId);
|
||||
List<DocumentSuserListVO> list = JsonUtil.getJsonToList(data, DocumentSuserListVO.class);
|
||||
ListVO vo = new ListVO();
|
||||
vo.setList(list);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* app上传文件
|
||||
*
|
||||
* @param documentUploader 上传模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "知识管理上传文件")
|
||||
@PostMapping("/Uploader")
|
||||
public ActionResult uploader(DocumentUploader documentUploader) throws DataException {
|
||||
String fileType = UpUtil.getFileType(documentUploader.getFile());
|
||||
//验证类型
|
||||
if (!OptimizeUtil.fileType(configValueUtil.getAllowUploadFileType(), fileType)) {
|
||||
return ActionResult.fail(MsgCode.FA017.get());
|
||||
}
|
||||
|
||||
//上传
|
||||
uploaderVO(documentUploader);
|
||||
return ActionResult.success(MsgCode.SU015.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 分片组装
|
||||
*
|
||||
* @param mergeChunkDto 合并模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "分片组装")
|
||||
@PostMapping("/merge")
|
||||
public ActionResult merge(MergeChunkDto mergeChunkDto) {
|
||||
String identifier = XSSEscape.escapePath(mergeChunkDto.getIdentifier());
|
||||
String path = FileUploadUtils.getLocalBasePath() + configValueUtil.getTemporaryFilePath();
|
||||
String filePath = XSSEscape.escapePath(path + identifier);
|
||||
String partFile = XSSEscape.escapePath(path + mergeChunkDto.getFileName());
|
||||
try {
|
||||
List<File> mergeFileList = FileUtil.getFile(new File(filePath));
|
||||
@Cleanup FileOutputStream destTempfos = new FileOutputStream(partFile, true);
|
||||
for (int i = 0; i < mergeFileList.size(); i++) {
|
||||
String chunkName = identifier.concat("-") + (i + 1);
|
||||
File files = new File(filePath, chunkName);
|
||||
if (files.exists()) {
|
||||
FileUtils.copyFile(files, destTempfos);
|
||||
}
|
||||
}
|
||||
File partFiles = new File(partFile);
|
||||
if (partFiles.exists()) {
|
||||
MultipartFile multipartFile = FileUtil.createFileItem(partFiles);
|
||||
uploaderVO(new DocumentUploader(multipartFile, mergeChunkDto.getParentId()));
|
||||
FileUtil.deleteTmp(multipartFile);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("合并分片失败: {}", e.getMessage());
|
||||
throw new DataException(MsgCode.FA033.get());
|
||||
} finally {
|
||||
FileUtils.deleteQuietly(new File(filePath));
|
||||
FileUtils.deleteQuietly(new File(partFile));
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU015.get());
|
||||
}
|
||||
|
||||
@Operation(summary = "流程归档文件上传接口")
|
||||
@PostMapping("/UploadBlob")
|
||||
public ActionResult UploadBlob(DocumentUploader dub) throws DataException {
|
||||
uploaderVO(dub);
|
||||
taskApi.updateIsFile(dub.getTaskId());
|
||||
return ActionResult.success(MsgCode.SU015.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下载文件链接
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取下载文件链接")
|
||||
@PostMapping("/Download/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult download(@PathVariable("id") String id) {
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
DocumentEntity entity = documentService.getInfo(id);
|
||||
if (entity != null) {
|
||||
String name = entity.getFilePath();
|
||||
String fileName = name + "#" + "document#" + entity.getFullName() + "." + entity.getFileExtension();
|
||||
DownloadVO vo = DownloadVO.builder().name(entity.getFullName()).url(UploaderUtil.uploaderFile(fileName)).build();
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
return ActionResult.fail(MsgCode.FA018.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部下载文件链接(打包下载)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "打包下载")
|
||||
@PostMapping("/PackDownload")
|
||||
public ActionResult packDownloadUrl(@RequestBody DocumentShareForm obj) {
|
||||
//单个文件直接下载
|
||||
if (obj.getIds().size() == 1) {
|
||||
DocumentEntity entity = documentService.getInfo(obj.getIds().get(0));
|
||||
if (entity != null && !Objects.equals(entity.getType(), 0)) {
|
||||
String name = entity.getFilePath();
|
||||
String fileName = name + "#" + "document#" + entity.getFullName() + "." + entity.getFileExtension();
|
||||
DownloadVO vo = DownloadVO.builder().name(entity.getFullName()).url(UploaderUtil.uploaderFile(fileName)).build();
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
}
|
||||
String tempFilePath = FileUploadUtils.getLocalBasePath() + FilePathUtil.getFilePath(FileTypeConstant.FILEZIPDOWNTEMPPATH);
|
||||
String zipFileSrc = "我的文档" + RandomUtil.uuId();
|
||||
String zipFileName = zipFileSrc + ".zip";
|
||||
String mainPath = tempFilePath + zipFileSrc;
|
||||
new File(mainPath).mkdirs();
|
||||
//递归生成文件夹下的文件
|
||||
createdFiles(obj.getIds(), mainPath);
|
||||
|
||||
String filePath = tempFilePath + zipFileName;
|
||||
//打包
|
||||
FileUtil.toZip(filePath, true, tempFilePath + zipFileSrc);
|
||||
//删除源文件
|
||||
FileUtil.deleteFileAll(new File(tempFilePath + zipFileSrc));
|
||||
|
||||
//上传压缩包到服务器
|
||||
MultipartFile multipartFile = FileUtil.createFileItem(new File(XSSEscape.escapePath(filePath)));
|
||||
FileInfo fileInfo = FileUploadUtils.uploadFile(multipartFile, FilePathUtil.getFilePath(FileTypeConstant.FILEZIPDOWNTEMPPATH), zipFileName);
|
||||
// 删除压缩包
|
||||
FileUtil.deleteFileAll(new File(tempFilePath + zipFileName));
|
||||
|
||||
//获取服务器下载路径
|
||||
DownloadVO vo = DownloadVO.builder()
|
||||
.name(zipFileName)
|
||||
.url(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + FileTypeConstant.FILEZIPDOWNTEMPPATH))
|
||||
.build();
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归获取文件夹下的文件
|
||||
*
|
||||
* @param fileIdList
|
||||
* @param mainPath
|
||||
*/
|
||||
private void createdFiles(List<String> fileIdList, String mainPath) {
|
||||
for (String id : fileIdList) {
|
||||
DocumentEntity info = documentService.getInfo(id);
|
||||
if (info != null) {
|
||||
String fileId = StringUtil.isNotEmpty(info.getFilePath()) ? XSSEscape.escape(info.getFilePath()).trim() : "";
|
||||
String fileName = XSSEscape.escapePath(info.getFullName()).trim();
|
||||
if (Objects.equals(info.getType(), 0)) {
|
||||
//文件夹
|
||||
File file = new File(mainPath + "/" + fileName);
|
||||
if (!file.exists()) {
|
||||
file.mkdir();
|
||||
}
|
||||
List<DocumentEntity> allList = documentService.getChildList(id, true);
|
||||
List<String> collect = allList.stream().map(DocumentEntity::getId).collect(Collectors.toList());
|
||||
createdFiles(collect, mainPath + "/" + fileName);
|
||||
} else {
|
||||
try {
|
||||
//文件
|
||||
byte[] bytes = FileUploadUtils.downloadFileByte(FilePathUtil.getFilePath(FileTypeConstant.DOCUMENT), fileId, false);
|
||||
FileUtils.writeByteArrayToFile(new File(mainPath + "/" + fileName), bytes);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
@Operation(summary = "批量删除")
|
||||
@PostMapping("/BatchDelete")
|
||||
@Parameters({
|
||||
@Parameter(name = "ids", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult BatchDelete(@RequestBody DocumentShareForm obj) {
|
||||
for (String id : obj.getIds()) {
|
||||
DocumentEntity entity = documentService.getInfo(id);
|
||||
if (entity != null) {
|
||||
List<DocumentEntity> allList = new ArrayList<>();
|
||||
documentService.getChildSrcList(entity.getId(), allList, 1);
|
||||
allList.add(entity);
|
||||
//添加删除记录
|
||||
DocumentLogEntity logent = new DocumentLogEntity();
|
||||
logent.setDocumentId(id);
|
||||
List<String> collect = allList.stream().map(DocumentEntity::getId).collect(Collectors.toList());
|
||||
logent.setChildDocument(collect.stream().collect(Collectors.joining(",")));
|
||||
documentLogService.save(logent);
|
||||
for (DocumentEntity item : allList) {
|
||||
documentService.delete(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 回收站(彻底删除)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "回收站(彻底删除)")
|
||||
@PostMapping("/Trash")
|
||||
@Parameters({
|
||||
@Parameter(name = "ids", description = "主键数组", required = true),
|
||||
})
|
||||
public ActionResult trashdelete(@RequestBody DocumentShareForm obj) {
|
||||
documentService.trashdelete(obj.getIds());
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 回收站(还原文件)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "回收站(还原文件)")
|
||||
@PostMapping("/Trash/Actions/Recovery")
|
||||
@Parameters({
|
||||
@Parameter(name = "ids", description = "主键数组", required = true),
|
||||
})
|
||||
@Transactional
|
||||
public ActionResult trashRecovery(@RequestBody DocumentShareForm obj) {
|
||||
documentService.trashRecoveryConstainSrc(obj.getIds());
|
||||
return ActionResult.success(MsgCode.SU010.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 共享文件(创建)
|
||||
*
|
||||
* @param documentShareForm 分享模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "分享文件/文件夹")
|
||||
@PostMapping("/Actions/Share")
|
||||
@Parameters({
|
||||
@Parameter(name = "documentShareForm", description = "分享模型", required = true),
|
||||
})
|
||||
public ActionResult shareCreate(@RequestBody DocumentShareForm documentShareForm) {
|
||||
documentService.sharecreate(documentShareForm);
|
||||
return ActionResult.success(MsgCode.SU005.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消共享
|
||||
*
|
||||
* @param obj 主键值
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "取消分享文件/文件夹")
|
||||
@PostMapping("/Actions/CancelShare")
|
||||
@Parameters({
|
||||
@Parameter(name = "ids", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult shareCancel(@RequestBody DocumentShareForm obj) {
|
||||
documentService.shareCancel(obj.getIds());
|
||||
return ActionResult.success(MsgCode.SU005.get());
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "共享用户调整")
|
||||
@PostMapping("/Actions/ShareAdjustment/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "文档主键", required = true),
|
||||
@Parameter(name = "userIds", description = "共享用户组", required = true),
|
||||
})
|
||||
public ActionResult shareAdjustment(@PathVariable("id") String id, @RequestBody DocumentShareForm obj) {
|
||||
if (obj.getUserIds().size() > 0) {
|
||||
documentService.shareAdjustment(id, obj.getUserIds());
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU005.get());
|
||||
}
|
||||
|
||||
@Operation(summary = "移动文件/文件夹")
|
||||
@PutMapping("/Actions/MoveTo/{toId}")
|
||||
@Parameters({
|
||||
@Parameter(name = "ids", description = "主键", required = true),
|
||||
@Parameter(name = "toId", description = "将要移动到Id", required = true),
|
||||
})
|
||||
@Transactional
|
||||
public ActionResult moveTo(@RequestBody DocumentShareForm obj, @PathVariable("toId") String toId) {
|
||||
List<String> allIds = new ArrayList<>();
|
||||
allIds.addAll(obj.getIds());
|
||||
List<DocumentEntity> childList = new ArrayList<>();
|
||||
for (String oneId : obj.getIds()) {
|
||||
documentService.getChildSrcList(oneId, childList, 1);
|
||||
}
|
||||
allIds.addAll(childList.stream().map(DocumentEntity::getId).collect(Collectors.toList()));
|
||||
if (allIds.contains(toId)) {
|
||||
return ActionResult.fail(MsgCode.ETD103.get());
|
||||
}
|
||||
|
||||
for (String id : obj.getIds()) {
|
||||
boolean flag = documentService.moveTo(id, toId);
|
||||
if (flag == false) {
|
||||
return ActionResult.fail(MsgCode.FA002.get());
|
||||
}
|
||||
}
|
||||
|
||||
return ActionResult.success(MsgCode.SU004.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 封装上传附件
|
||||
* 流程归档-文件上传
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private void uploaderVO(DocumentUploader documentUploader) {
|
||||
MultipartFile file = documentUploader.getFile();
|
||||
String parentId = documentUploader.getParentId();
|
||||
String taskId = documentUploader.getTaskId();
|
||||
String fileName = StringUtil.isNotEmpty(documentUploader.getTaskId()) ? documentUploader.getTaskId() :
|
||||
StringUtil.isNotEmpty(documentUploader.getFileName()) ? documentUploader.getFileName() : file.getOriginalFilename();
|
||||
String fileType = UpUtil.getFileType(file);
|
||||
String creatorUserId = "";
|
||||
List<String> userList = new ArrayList<>();
|
||||
if (StringUtil.isNotEmpty(taskId)) {
|
||||
try { //获取流程信息
|
||||
FileModel fileModel = taskApi.getFileModel(taskId);
|
||||
fileName = fileModel.getFilename();
|
||||
creatorUserId = fileModel.getUserId();
|
||||
userList.addAll(fileModel.getUserList());
|
||||
fileType = "pdf";
|
||||
|
||||
List<DocumentEntity> allList = documentService.getAllList("0", creatorUserId);
|
||||
DocumentEntity documentEntity = allList.stream().filter(t -> Objects.equals(t.getType(), 0) && FileModel.FOLDER_NAME.equals(t.getFullName())).findFirst().orElse(null);
|
||||
if (Objects.isNull(documentEntity)) {
|
||||
documentEntity = new DocumentEntity();
|
||||
documentEntity.setFullName(FileModel.FOLDER_NAME);
|
||||
documentEntity.setType(0);
|
||||
documentEntity.setParentId("0");
|
||||
documentEntity.setCreatorUserId(creatorUserId);
|
||||
documentService.create(documentEntity);
|
||||
}
|
||||
parentId = documentEntity.getId();
|
||||
} catch (Exception e) {
|
||||
throw new DataException(MsgCode.FA001.get());
|
||||
}
|
||||
}
|
||||
|
||||
String filePath = configValueUtil.getDocumentFilePath();
|
||||
List<DocumentEntity> data = documentService.getAllList(parentId);
|
||||
String finalFileName = fileName;
|
||||
data = data.stream().filter(t -> finalFileName.equals(t.getFullName())).collect(Collectors.toList());
|
||||
if (data.size() > 0) {
|
||||
fileName = fileName.substring(0, fileName.lastIndexOf(".")) + "副本" + UUID.randomUUID().toString().substring(0, 5) + fileName.substring(fileName.lastIndexOf("."));
|
||||
}
|
||||
//上传
|
||||
FileInfo fileInfo = null;
|
||||
try {
|
||||
fileInfo = FileUploadUtils.uploadFile(file.getBytes(), filePath, fileName);
|
||||
} catch (IOException e) {
|
||||
throw new DataException(MsgCode.FA033.get());
|
||||
}
|
||||
DocumentEntity entity = new DocumentEntity();
|
||||
entity.setType(1);
|
||||
entity.setFullName(fileName);
|
||||
entity.setParentId(parentId);
|
||||
entity.setFileExtension(fileType);
|
||||
entity.setFilePath(fileInfo.getFilename());
|
||||
entity.setFileSize(String.valueOf(file.getSize()));
|
||||
entity.setCreatorUserId(creatorUserId);
|
||||
entity.setEnabledMark(1);
|
||||
String desc = null;
|
||||
TaskEntity taskEntity = taskApi.getInfoSubmit(taskId, TaskEntity::getId, TaskEntity::getTemplateId);
|
||||
if (null != taskEntity) {
|
||||
desc = taskId + "-" + taskEntity.getTemplateId();
|
||||
}
|
||||
entity.setDescription(desc);
|
||||
entity.setUploaderUrl(UploaderUtil.uploaderImg("/api/file/Image/document/", fileInfo.getFilename()));
|
||||
documentService.create(entity);
|
||||
if (StringUtil.isNotEmpty(taskId)) {
|
||||
DocumentShareForm documentShareForm = new DocumentShareForm();
|
||||
documentShareForm.setUserIds(userList);
|
||||
documentShareForm.setIds(new ArrayList() {{
|
||||
add(entity.getId());
|
||||
}});
|
||||
documentShareForm.setCreatorUserId(creatorUserId);
|
||||
documentService.sharecreate(documentShareForm);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否存在归档文件
|
||||
*
|
||||
* @param taskId 流程任务主键
|
||||
*/
|
||||
public Boolean checkFlowFile(String taskId) {
|
||||
QueryWrapper<DocumentEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().like(DocumentEntity::getDescription, taskId);
|
||||
return documentService.count(wrapper) < 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取归档文件
|
||||
*
|
||||
* @param model 参数
|
||||
*/
|
||||
public List<Map<String, Object>> getFlowFile(FlowFileModel model) {
|
||||
return documentService.getFlowFile(model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
package com.yunzhupaas.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.util.NoDataSourceBind;
|
||||
import com.yunzhupaas.base.Page;
|
||||
import com.yunzhupaas.config.ConfigValueUtil;
|
||||
|
||||
import com.yunzhupaas.enums.FilePreviewTypeEnum;
|
||||
import com.yunzhupaas.exception.DataException;
|
||||
|
||||
import com.yunzhupaas.model.YozoFileParams;
|
||||
import com.yunzhupaas.model.YozoParams;
|
||||
import com.yunzhupaas.model.FileListVO;
|
||||
import com.yunzhupaas.util.*;
|
||||
import com.yunzhupaas.utils.SplicingUrlUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 文档在线预览
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
@NoDataSourceBind()
|
||||
@Tag(name = "文档在线预览", description = "DocumentPreview")
|
||||
@RestController
|
||||
@RequestMapping("/api/extend/DocumentPreview")
|
||||
public class DocumentPreviewController {
|
||||
|
||||
@Autowired
|
||||
private ConfigValueUtil configValueUtil;
|
||||
|
||||
/**
|
||||
* 永中文件预览
|
||||
*
|
||||
* @param fileId 文件主键
|
||||
* @param params 永中模型
|
||||
* @param previewType 类型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "文件预览")
|
||||
@GetMapping("/{fileId}/Preview")
|
||||
@Parameters({
|
||||
@Parameter(name = "fileId", description = "文件主键", required = true),
|
||||
@Parameter(name = "previewType", description = "类型"),
|
||||
})
|
||||
@SaCheckPermission("extend.documentPreview")
|
||||
public ActionResult filePreview(@PathVariable("fileId") String fileId, YozoFileParams params,
|
||||
@RequestParam("previewType") String previewType) {
|
||||
FileListVO fileListVO = FileUploadUtils.getFileDetail(configValueUtil.getDocumentPreviewPath(), fileId);
|
||||
if (fileListVO == null) {
|
||||
return ActionResult.fail(MsgCode.ETD111.get());
|
||||
}
|
||||
if (fileListVO.getFileName() != null) {
|
||||
String[] split = fileListVO.getFileName().split("/");
|
||||
if (split.length > 0) {
|
||||
fileListVO.setFileName(split[split.length - 1]);
|
||||
}
|
||||
}
|
||||
String url = YozoParams.YUNZHUPAAS_DOMAINS + "/api/extend/DocumentPreview/down/" + fileListVO.getFileName();
|
||||
String urlPath;
|
||||
if (previewType.equals(FilePreviewTypeEnum.YOZO_ONLINE_PREVIEW.getType())) {
|
||||
params.setUrl(url);
|
||||
urlPath = SplicingUrlUtil.getPreviewUrl(params);
|
||||
return ActionResult.success("success", XSSEscape.escape(urlPath));
|
||||
}
|
||||
return ActionResult.success("success", url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param page 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取文档列表")
|
||||
@GetMapping
|
||||
@SaCheckPermission("extend.documentPreview")
|
||||
public ActionResult<List<FileListVO>> list(Page page) {
|
||||
List<FileListVO> fileList = FileUploadUtils.getFileList(configValueUtil.getDocumentPreviewPath());
|
||||
fileList.stream().forEach(t -> {
|
||||
if (t.getFileName() != null) {
|
||||
String[] split = t.getFileName().split("/");
|
||||
if (split.length > 0) {
|
||||
t.setFileName(split[split.length - 1]);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (StringUtil.isNotEmpty(page.getKeyword())) {
|
||||
fileList = fileList.stream().filter(t -> t.getFileName().contains(page.getKeyword()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
return ActionResult.success(fileList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件下载url
|
||||
*
|
||||
* @param fileName 名称
|
||||
*/
|
||||
@NoDataSourceBind()
|
||||
@GetMapping("/down/{fileName}")
|
||||
@Parameters({
|
||||
@Parameter(name = "fileName", description = "名称", required = true),
|
||||
})
|
||||
public void pointDown(@PathVariable("fileName") String fileName) throws DataException {
|
||||
boolean exists = FileUploadUtils.exists(configValueUtil.getDocumentPreviewPath(), fileName);
|
||||
if (!exists) {
|
||||
throw new DataException(MsgCode.FA006.get());
|
||||
}
|
||||
byte[] bytes = FileUploadUtils.downloadFileByte(configValueUtil.getDocumentPreviewPath(), fileName, false);
|
||||
FileDownloadUtil.downloadFile(bytes, fileName, null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,353 @@
|
||||
package com.yunzhupaas.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.model.MailAccount;
|
||||
import com.yunzhupaas.base.util.Pop3Util;
|
||||
import com.yunzhupaas.base.vo.PaginationVO;
|
||||
import com.yunzhupaas.base.service.SysconfigService;
|
||||
import com.yunzhupaas.base.entity.EmailConfigEntity;
|
||||
import com.yunzhupaas.base.entity.EmailReceiveEntity;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.entity.EmailSendEntity;
|
||||
import com.yunzhupaas.exception.DataException;
|
||||
import com.yunzhupaas.model.email.*;
|
||||
import com.yunzhupaas.service.EmailReceiveService;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.JsonUtilEx;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 邮件配置
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
@Tag(name = "邮件收发", description = "Email")
|
||||
@RestController
|
||||
@RequestMapping("/api/extend/Email")
|
||||
public class EmailController {
|
||||
|
||||
@Autowired
|
||||
private EmailReceiveService emailReceiveService;
|
||||
@Autowired
|
||||
private Pop3Util pop3Util;
|
||||
@Autowired
|
||||
private SysconfigService sysconfigService;
|
||||
|
||||
/**
|
||||
* 获取邮件列表(收件箱、标星件、草稿箱、已发送)
|
||||
*
|
||||
* @param paginationEmail 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取邮件列表(收件箱、标星件、草稿箱、已发送)")
|
||||
@GetMapping
|
||||
@SaCheckPermission("extend.email")
|
||||
public ActionResult receiveList(PaginationEmail paginationEmail) {
|
||||
String type = paginationEmail.getType() != null ? paginationEmail.getType() : "inBox";
|
||||
switch (type) {
|
||||
case "inBox":
|
||||
List<EmailReceiveEntity> entity = emailReceiveService.getReceiveList(paginationEmail);
|
||||
PaginationVO paginationVO = JsonUtil.getJsonToBean(paginationEmail, PaginationVO.class);
|
||||
List<EmailReceiveListVO> listVO = JsonUtil.getJsonToList(entity, EmailReceiveListVO.class);
|
||||
return ActionResult.page(listVO,paginationVO);
|
||||
case "star":
|
||||
List<EmailReceiveEntity> entity1 = emailReceiveService.getStarredList(paginationEmail);
|
||||
PaginationVO paginationVo1 = JsonUtil.getJsonToBean(paginationEmail, PaginationVO.class);
|
||||
List<EmailStarredListVO> listVo1 = JsonUtil.getJsonToList(entity1, EmailStarredListVO.class);
|
||||
return ActionResult.page(listVo1,paginationVo1);
|
||||
case "draft":
|
||||
List<EmailSendEntity> entity2 = emailReceiveService.getDraftList(paginationEmail);
|
||||
PaginationVO paginationVo2 = JsonUtil.getJsonToBean(paginationEmail, PaginationVO.class);
|
||||
List<EmailDraftListVO> listVo2 = JsonUtil.getJsonToList(entity2, EmailDraftListVO.class);
|
||||
return ActionResult.page(listVo2,paginationVo2);
|
||||
case "sent":
|
||||
List<EmailSendEntity> entity3 = emailReceiveService.getSentList(paginationEmail);
|
||||
PaginationVO paginationVo3 = JsonUtil.getJsonToBean(paginationEmail, PaginationVO.class);
|
||||
List<EmailSentListVO> listVo3 = JsonUtil.getJsonToList(entity3, EmailSentListVO.class);
|
||||
return ActionResult.page(listVo3,paginationVo3);
|
||||
default:
|
||||
return ActionResult.fail(MsgCode.ETD106.get());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取邮箱配置
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取邮箱配置")
|
||||
@GetMapping("/Config")
|
||||
@SaCheckPermission("extend.email")
|
||||
public ActionResult<EmailCofigInfoVO> configInfo() {
|
||||
EmailConfigEntity entity = emailReceiveService.getConfigInfo();
|
||||
EmailCofigInfoVO vo = JsonUtil.getJsonToBean(entity, EmailCofigInfoVO.class);
|
||||
if(vo==null){
|
||||
vo=new EmailCofigInfoVO();
|
||||
}
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取邮件信息
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取邮件信息")
|
||||
@GetMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键",required = true),
|
||||
})
|
||||
@SaCheckPermission("extend.email")
|
||||
public ActionResult<EmailInfoVO> info(@PathVariable("id") String id) throws DataException {
|
||||
Object entity = emailReceiveService.getInfo(id);
|
||||
EmailInfoVO vo = JsonUtil.getJsonToBeanEx(entity, EmailInfoVO.class);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "删除邮件")
|
||||
@DeleteMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键",required = true),
|
||||
})
|
||||
@SaCheckPermission("extend.email")
|
||||
public ActionResult delete(@PathVariable("id") String id) {
|
||||
boolean flag= emailReceiveService.delete(id);
|
||||
if(flag==false){
|
||||
return ActionResult.fail(MsgCode.FA003.get());
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置已读邮件
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "设置已读邮件")
|
||||
@PutMapping("/{id}/Actions/Read")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键",required = true),
|
||||
})
|
||||
@SaCheckPermission("extend.email")
|
||||
public ActionResult receiveRead(@PathVariable("id") String id) {
|
||||
boolean flag= emailReceiveService.receiveRead(id, 1);
|
||||
if(flag==false){
|
||||
return ActionResult.fail(MsgCode.FA007.get());
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU005.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置未读邮件
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "设置未读邮件")
|
||||
@PutMapping("/{id}/Actions/Unread")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键",required = true),
|
||||
})
|
||||
@SaCheckPermission("extend.email")
|
||||
public ActionResult receiveUnread(@PathVariable("id") String id) {
|
||||
boolean flag= emailReceiveService.receiveRead(id, 0);
|
||||
if(flag==false){
|
||||
return ActionResult.fail(MsgCode.FA007.get());
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU005.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置星标邮件
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "设置星标邮件")
|
||||
@PutMapping("/{id}/Actions/Star")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键",required = true),
|
||||
})
|
||||
@SaCheckPermission("extend.email")
|
||||
public ActionResult receiveYesStarred(@PathVariable("id") String id) {
|
||||
boolean flag= emailReceiveService.receiveStarred(id, 1);
|
||||
if(flag==false){
|
||||
return ActionResult.fail(MsgCode.FA007.get());
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU005.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置取消星标
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "设置取消星标")
|
||||
@PutMapping("/{id}/Actions/Unstar")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键",required = true),
|
||||
})
|
||||
@SaCheckPermission("extend.email")
|
||||
public ActionResult receiveNoStarred(@PathVariable("id") String id) {
|
||||
boolean flag= emailReceiveService.receiveStarred(id, 0);
|
||||
if(flag==false){
|
||||
return ActionResult.fail(MsgCode.FA007.get());
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU005.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 收邮件
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "收邮件")
|
||||
@PostMapping("/Receive")
|
||||
@SaCheckPermission("extend.email")
|
||||
public ActionResult receive() {
|
||||
EmailConfigEntity configEntity = emailReceiveService.getConfigInfo();
|
||||
if (configEntity != null) {
|
||||
MailAccount mailAccount = new MailAccount();
|
||||
mailAccount.setAccount(configEntity.getAccount());
|
||||
mailAccount.setPassword(configEntity.getPassword());
|
||||
mailAccount.setPop3Host(configEntity.getPop3Host());
|
||||
mailAccount.setPop3Port(configEntity.getPop3Port());
|
||||
mailAccount.setSmtpHost(configEntity.getSmtpHost());
|
||||
mailAccount.setSmtpPort(configEntity.getSmtpPort());
|
||||
if ("1".equals(String.valueOf(configEntity.getEmailSsl()))) {
|
||||
mailAccount.setSsl(true);
|
||||
} else {
|
||||
mailAccount.setSsl(false);
|
||||
}
|
||||
String checkResult=pop3Util.checkConnected(mailAccount);
|
||||
if ("true".equals(checkResult)) {
|
||||
int mailCount = emailReceiveService.receive(configEntity);
|
||||
return ActionResult.success(MsgCode.SU005.get(), mailCount);
|
||||
} else {
|
||||
return ActionResult.fail(MsgCode.ETD107.get());
|
||||
}
|
||||
} else {
|
||||
return ActionResult.fail(MsgCode.ETD108.get());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 存草稿
|
||||
*
|
||||
* @param emailSendCrForm 邮件模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "存草稿")
|
||||
@PostMapping("/Actions/SaveDraft")
|
||||
@Parameters({
|
||||
@Parameter(name = "emailSendCrForm", description = "邮件模型",required = true),
|
||||
})
|
||||
@SaCheckPermission("extend.email")
|
||||
public ActionResult saveDraft(@RequestBody @Valid EmailSendCrForm emailSendCrForm) {
|
||||
EmailSendEntity entity = JsonUtil.getJsonToBean(emailSendCrForm, EmailSendEntity.class);
|
||||
emailReceiveService.saveDraft(entity);
|
||||
return ActionResult.success(MsgCode.SU002.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 发邮件
|
||||
*
|
||||
* @param emailCrForm 发送邮件模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "发邮件")
|
||||
@PostMapping
|
||||
@Parameters({
|
||||
@Parameter(name = "emailCrForm", description = "发送邮件模型",required = true),
|
||||
})
|
||||
@SaCheckPermission("extend.email")
|
||||
public ActionResult saveSent(@RequestBody @Valid EmailCrForm emailCrForm) {
|
||||
EmailSendEntity entity = JsonUtil.getJsonToBean(emailCrForm, EmailSendEntity.class);
|
||||
EmailConfigEntity configEntity = emailReceiveService.getConfigInfo();
|
||||
if (configEntity != null) {
|
||||
MailAccount mailAccount = new MailAccount();
|
||||
mailAccount.setAccount(configEntity.getAccount());
|
||||
mailAccount.setPassword(configEntity.getPassword());
|
||||
mailAccount.setPop3Host(configEntity.getPop3Host());
|
||||
mailAccount.setPop3Port(configEntity.getPop3Port());
|
||||
mailAccount.setSmtpHost(configEntity.getSmtpHost());
|
||||
mailAccount.setSmtpPort(configEntity.getSmtpPort());
|
||||
if ("1".equals(String.valueOf(configEntity.getEmailSsl()))) {
|
||||
mailAccount.setSsl(true);
|
||||
} else {
|
||||
mailAccount.setSsl(false);
|
||||
}
|
||||
int flag = emailReceiveService.saveSent(entity, configEntity);
|
||||
if (flag == 0) {
|
||||
return ActionResult.success(MsgCode.SU012.get());
|
||||
} else {
|
||||
return ActionResult.fail(MsgCode.ETD107.get());
|
||||
}
|
||||
} else {
|
||||
return ActionResult.fail(MsgCode.ETD108.get());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新邮件配置
|
||||
*
|
||||
* @param emailCheckForm 邮件配置模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "更新邮件配置")
|
||||
@PutMapping("/Config")
|
||||
@Parameters({
|
||||
@Parameter(name = "emailCheckForm", description = "邮件配置模型",required = true),
|
||||
})
|
||||
@SaCheckPermission("extend.email")
|
||||
public ActionResult saveConfig(@RequestBody @Valid EmailCheckForm emailCheckForm) throws DataException {
|
||||
EmailConfigEntity entity = JsonUtil.getJsonToBean(emailCheckForm, EmailConfigEntity.class);
|
||||
emailReceiveService.saveConfig(entity);
|
||||
return ActionResult.success(MsgCode.SU002.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 邮箱配置-测试连接
|
||||
*
|
||||
* @param emailCheckForm 邮件配置模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "邮箱配置-测试连接")
|
||||
@PostMapping("/Config/Actions/CheckMail")
|
||||
@Parameters({
|
||||
@Parameter(name = "emailCheckForm", description = "邮件配置模型",required = true),
|
||||
})
|
||||
@SaCheckPermission("extend.email")
|
||||
public ActionResult checkLogin(@RequestBody @Valid EmailCheckForm emailCheckForm) {
|
||||
EmailConfigEntity entity = JsonUtil.getJsonToBean(emailCheckForm, EmailConfigEntity.class);
|
||||
String result = sysconfigService.checkLogin(entity);
|
||||
if ("true".equals(result)) {
|
||||
return ActionResult.success(MsgCode.SU017.get());
|
||||
} else {
|
||||
return ActionResult.fail(MsgCode.ETD107.get());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,519 @@
|
||||
package com.yunzhupaas.controller;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
||||
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
||||
import cn.xuyanwu.spring.file.storage.FileInfo;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import com.yunzhupaas.base.vo.DownloadVO;
|
||||
import com.yunzhupaas.base.vo.PageListVO;
|
||||
import com.yunzhupaas.base.vo.PaginationVO;
|
||||
import com.yunzhupaas.config.ConfigValueUtil;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.entity.EmployeeEntity;
|
||||
import com.yunzhupaas.exception.DataException;
|
||||
import com.yunzhupaas.exception.ImportException;
|
||||
import com.yunzhupaas.model.EmployeeModel;
|
||||
import com.yunzhupaas.model.employee.*;
|
||||
import com.yunzhupaas.service.EmployeeService;
|
||||
import com.yunzhupaas.util.*;
|
||||
import lombok.Cleanup;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.JsonUtilEx;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 职员信息
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
*/
|
||||
@Slf4j
|
||||
@Tag(name = "职员信息", description = "Employee")
|
||||
@RestController
|
||||
@RequestMapping("/api/extend/Employee")
|
||||
public class EmployeeController extends SuperController<EmployeeService, EmployeeEntity> {
|
||||
|
||||
@Autowired
|
||||
private EmployeeService employeeService;
|
||||
@Autowired
|
||||
private ConfigValueUtil configValueUtil;
|
||||
|
||||
/**
|
||||
* 列表(忽略验证Token)
|
||||
*
|
||||
* @param paginationEmployee 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取职员列表")
|
||||
@GetMapping
|
||||
public ActionResult<PageListVO<EmployeeListVO>> getList(PaginationEmployee paginationEmployee) {
|
||||
List<EmployeeEntity> data = employeeService.getList(paginationEmployee);
|
||||
List<EmployeeListVO> list = JsonUtil.getJsonToList(data, EmployeeListVO.class);
|
||||
PaginationVO paginationVO = JsonUtil.getJsonToBean(paginationEmployee, PaginationVO.class);
|
||||
return ActionResult.page(list, paginationVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取职员信息")
|
||||
@GetMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult<EmployeeInfoVO> info(@PathVariable("id") String id) throws DataException {
|
||||
EmployeeEntity entity = employeeService.getInfo(id);
|
||||
EmployeeInfoVO vo = JsonUtilEx.getJsonToBeanEx(entity, EmployeeInfoVO.class);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建
|
||||
*
|
||||
* @param employeeCrForm 职工模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "app添加职员信息")
|
||||
@PostMapping
|
||||
@Parameters({
|
||||
@Parameter(name = "employeeCrForm", description = "职工模型", required = true),
|
||||
})
|
||||
public ActionResult create(@RequestBody @Valid EmployeeCrForm employeeCrForm) {
|
||||
EmployeeEntity entity = JsonUtil.getJsonToBean(employeeCrForm, EmployeeEntity.class);
|
||||
employeeService.create(entity);
|
||||
return ActionResult.success(MsgCode.SU001.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param id 主键
|
||||
* @param employeeUpForm 职工模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "app修改职员信息")
|
||||
@PutMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "employeeUpForm", description = "职工模型", required = true),
|
||||
})
|
||||
public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid EmployeeUpForm employeeUpForm) {
|
||||
EmployeeEntity entity = JsonUtil.getJsonToBean(employeeUpForm, EmployeeEntity.class);
|
||||
employeeService.update(id, entity);
|
||||
return ActionResult.success(MsgCode.SU004.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "删除职员信息")
|
||||
@DeleteMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult delete(@PathVariable("id") String id) {
|
||||
EmployeeEntity entity = employeeService.getInfo(id);
|
||||
if (entity != null) {
|
||||
employeeService.delete(entity);
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.FA003.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 模板下载
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "模板下载")
|
||||
@GetMapping("/TemplateDownload")
|
||||
public ActionResult<DownloadVO> templateDownload() {
|
||||
DownloadVO vo = DownloadVO.builder().build();
|
||||
try {
|
||||
vo.setName("职员信息.xlsx");
|
||||
vo.setUrl(UploaderUtil.uploaderFile("/api/file/DownloadModel?encryption=", "职员信息" +
|
||||
".xlsx" + "#" + "Temporary"));
|
||||
} catch (Exception e) {
|
||||
log.error("信息导出Excel错误:{}", e.getMessage());
|
||||
}
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出Excel
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "导出 Excel")
|
||||
@GetMapping("/ExportExcel")
|
||||
@SuppressWarnings("unchecked")
|
||||
public ActionResult<DownloadVO> exportExcel() {
|
||||
List<EmployeeEntity> entityList = employeeService.getList();
|
||||
String jsonString = JsonUtilEx.getObjectToStringDateFormat(entityList, "yyyy-MM-dd");
|
||||
List<EmployeeExportVO> list = (List<EmployeeExportVO>) (List<?>) JsonUtil
|
||||
.listToJsonField(JsonUtil.getJsonToList(jsonString, EmployeeExportVO.class));
|
||||
List<ExcelExportEntity> entitys = new ArrayList<>();
|
||||
entitys.add(new ExcelExportEntity("工号", "enCode"));
|
||||
entitys.add(new ExcelExportEntity("姓名", "fullName"));
|
||||
entitys.add(new ExcelExportEntity("性别", "gender"));
|
||||
entitys.add(new ExcelExportEntity("部门", "departmentName"));
|
||||
entitys.add(new ExcelExportEntity("职务", "positionName", 25));
|
||||
entitys.add(new ExcelExportEntity("用工性质", "workingNature"));
|
||||
entitys.add(new ExcelExportEntity("身份证号", "idNumber", 25));
|
||||
entitys.add(new ExcelExportEntity("联系电话", "telephone", 20));
|
||||
entitys.add(new ExcelExportEntity("出生年月", "birthday", 20));
|
||||
entitys.add(new ExcelExportEntity("参加工作", "attendWorkTime", 20));
|
||||
entitys.add(new ExcelExportEntity("最高学历", "education"));
|
||||
entitys.add(new ExcelExportEntity("所学专业", "major"));
|
||||
entitys.add(new ExcelExportEntity("毕业院校", "graduationAcademy"));
|
||||
entitys.add(new ExcelExportEntity("毕业时间", "graduationTime", 20));
|
||||
ExportParams exportParams = new ExportParams(null, "职员信息");
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
DownloadVO vo = DownloadVO.builder().build();
|
||||
try {
|
||||
@Cleanup
|
||||
Workbook workbook = new HSSFWorkbook();
|
||||
if (entitys.size() > 0) {
|
||||
workbook = ExcelExportUtil.exportExcel(exportParams, entitys, list);
|
||||
}
|
||||
String name = "职员信息" + DateUtil.dateNow("yyyyMMdd") + "_" + RandomUtil.uuId() + ".xlsx";
|
||||
String fileName = configValueUtil.getTemporaryFilePath() + name;
|
||||
@Cleanup
|
||||
FileOutputStream output = new FileOutputStream(XSSEscape.escapePath(fileName));
|
||||
workbook.write(output);
|
||||
vo.setName(name);
|
||||
vo.setUrl(UploaderUtil.uploaderFile(name + "#" + "Temporary"));
|
||||
} catch (Exception e) {
|
||||
log.error("信息导出Excel错误:{}", e.getMessage());
|
||||
}
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出Word
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "导出Word")
|
||||
@GetMapping("/ExportWord")
|
||||
public ActionResult<DownloadVO> exportWord() {
|
||||
List<EmployeeEntity> list = employeeService.getList();
|
||||
// 模板文件地址
|
||||
String inputUrl = configValueUtil.getTemplateFilePath() + "employee_export_template.docx";
|
||||
// 新生产的模板文件
|
||||
String name = "职员信息" + DateUtil.dateNow("yyyyMMdd") + "_" + RandomUtil.uuId() + ".docx";
|
||||
String outputUrl = configValueUtil.getTemporaryFilePath() + name;
|
||||
List<String[]> testList = new ArrayList<>();
|
||||
Map<String, String> testMap = new HashMap<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
String[] employee = new String[13];
|
||||
EmployeeEntity entity = list.get(i);
|
||||
employee[0] = entity.getFullName();
|
||||
employee[1] = entity.getGender();
|
||||
employee[2] = entity.getDepartmentName();
|
||||
employee[3] = entity.getPositionName();
|
||||
employee[4] = entity.getWorkingNature();
|
||||
employee[5] = entity.getIdNumber();
|
||||
employee[6] = entity.getTelephone();
|
||||
employee[7] = entity.getBirthday() != null ? DateUtil.daFormat(entity.getBirthday()) : "";
|
||||
employee[8] = entity.getAttendWorkTime() != null ? DateUtil.daFormat(entity.getAttendWorkTime()) : "";
|
||||
employee[9] = entity.getEducation();
|
||||
employee[10] = entity.getMajor();
|
||||
employee[11] = entity.getGraduationAcademy();
|
||||
employee[12] = entity.getGraduationTime() != null ? DateUtil.daFormat(entity.getGraduationTime()) : "";
|
||||
testList.add(employee);
|
||||
}
|
||||
WordUtil.changWord(inputUrl, outputUrl, testMap, testList);
|
||||
if (FileUtil.fileIsFile(outputUrl)) {
|
||||
DownloadVO vo = DownloadVO.builder().name(name).url(UploaderUtil.uploaderFile(name + "#" + "Temporary"))
|
||||
.build();
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
return ActionResult.success(MsgCode.ETD109.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出pdf
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "导出pdf")
|
||||
@GetMapping("/ExportPdf")
|
||||
public ActionResult<DownloadVO> exportPdf() {
|
||||
String name = "职员信息" + DateUtil.dateNow("yyyyMMdd") + "_" + RandomUtil.uuId() + ".pdf";
|
||||
String outputUrl = FileUploadUtils.getLocalBasePath() + configValueUtil.getTemporaryFilePath() + name;
|
||||
employeeService.exportPdf(employeeService.getList(), outputUrl);
|
||||
if (FileUtil.fileIsFile(outputUrl)) {
|
||||
DownloadVO vo = DownloadVO.builder().name(name).url(UploaderUtil.uploaderFile(name + "#" + "Temporary"))
|
||||
.build();
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
return ActionResult.success(MsgCode.ETD109.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出Excel
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "导出Excel(备用)")
|
||||
@GetMapping("/Excel")
|
||||
public void excel() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
List<EmployeeEntity> list = employeeService.getList();
|
||||
TemplateExportParams param = new TemplateExportParams(
|
||||
configValueUtil.getTemplateFilePath() + "employee_import_template.xlsx", true);
|
||||
map.put("Employee", JSON.parse(JSONObject.toJSONStringWithDateFormat(list, "yyyy-MM-dd")));
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(param, map);
|
||||
ExcelUtil.dowloadExcel(workbook, "职员信息.xlsx");
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件(excel)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "上传文件")
|
||||
@PostMapping("/Uploader")
|
||||
public ActionResult<DownloadVO> uploader() {
|
||||
List<MultipartFile> list = UpUtil.getFileAll();
|
||||
MultipartFile file = list.get(0);
|
||||
if (file.getOriginalFilename().endsWith(".xlsx") || file.getOriginalFilename().endsWith(".xls")) {
|
||||
String filePath = configValueUtil.getTemporaryFilePath();
|
||||
String fileName = RandomUtil.uuId() + "." + UpUtil.getFileType(file);
|
||||
fileName = XSSEscape.escape(fileName);
|
||||
// 上传文件
|
||||
FileInfo fileInfo = FileUploadUtils.uploadFile(file, filePath, fileName);
|
||||
// FileUtil.upFile(file, filePath, fileName);
|
||||
DownloadVO vo = DownloadVO.builder().build();
|
||||
vo.setName(fileInfo.getFilename());
|
||||
return ActionResult.success(vo);
|
||||
} else {
|
||||
return ActionResult.fail(MsgCode.ETD110.get());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入预览
|
||||
*
|
||||
* @param fileName 文件名称
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "导入预览")
|
||||
@GetMapping("/ImportPreview")
|
||||
@Parameters({
|
||||
@Parameter(name = "fileName", description = "文件名称"),
|
||||
})
|
||||
public ActionResult importPreview(@RequestParam("fileName") String fileName) throws ImportException {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
try {
|
||||
String filePath = configValueUtil.getTemporaryFilePath();
|
||||
@Cleanup
|
||||
InputStream inputStream = new ByteArrayInputStream(
|
||||
FileUploadUtils.downloadFileByte(filePath, fileName, false));
|
||||
// 得到数据
|
||||
List<EmployeeModel> personList = ExcelUtil.importExcelByInputStream(inputStream, 0, 1, EmployeeModel.class);
|
||||
// 预览数据
|
||||
map = employeeService.importPreview(personList);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
throw new ImportException(e.getMessage());
|
||||
}
|
||||
return ActionResult.success(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入数据
|
||||
*
|
||||
* @param data 职工模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "导入数据")
|
||||
@PostMapping("/ImportData")
|
||||
@Parameters({
|
||||
@Parameter(name = "data", description = "职工模型"),
|
||||
})
|
||||
public ActionResult<EmployeeImportVO> importData(@RequestBody EmployeeModel data) throws Exception {
|
||||
List<EmployeeModel> dataList = new ArrayList<>();
|
||||
if (data.isType()) {
|
||||
ActionResult result = importPreview(data.getFileName());
|
||||
if (result == null) {
|
||||
throw new Exception(MsgCode.FA018.get());
|
||||
}
|
||||
if (result.getCode() != 200) {
|
||||
throw new Exception(result.getMsg());
|
||||
}
|
||||
if (result.getData() instanceof Map) {
|
||||
Map<String, Object> dataMap = (Map<String, Object>) result.getData();
|
||||
dataList = JsonUtil.getJsonToList(dataMap.get("dataRow"), EmployeeModel.class);
|
||||
}
|
||||
} else {
|
||||
dataList = data.getList();
|
||||
}
|
||||
// 导入数据
|
||||
EmployeeImportVO result = employeeService.importData(dataList);
|
||||
return ActionResult.success(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出 Excel(可选字段)
|
||||
*
|
||||
* @param paginationEmployee 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "导出 Excel(可选字段)")
|
||||
@GetMapping("/ExportData")
|
||||
@SuppressWarnings("unchecked")
|
||||
public ActionResult<DownloadVO> exportExcelData(PaginationEmployee paginationEmployee) {
|
||||
String dataType = paginationEmployee.getDataType();
|
||||
String selectKey = paginationEmployee.getSelectKey();
|
||||
List<EmployeeEntity> entityList = new ArrayList<>();
|
||||
if ("0".equals(dataType)) {
|
||||
entityList = employeeService.getList(paginationEmployee);
|
||||
} else if ("1".equals(dataType)) {
|
||||
entityList = employeeService.getList();
|
||||
}
|
||||
List<EmployeeModel> modeList = new ArrayList<>();
|
||||
for (EmployeeEntity employeeEntity : entityList) {
|
||||
EmployeeModel mode = new EmployeeModel();
|
||||
mode.setEnCode(employeeEntity.getEnCode());
|
||||
mode.setFullName(employeeEntity.getFullName());
|
||||
mode.setGender(employeeEntity.getGender());
|
||||
mode.setDepartmentName(employeeEntity.getDepartmentName());
|
||||
mode.setPositionName(employeeEntity.getPositionName());
|
||||
mode.setWorkingNature(employeeEntity.getWorkingNature());
|
||||
mode.setIdNumber(employeeEntity.getIdNumber());
|
||||
mode.setTelephone(employeeEntity.getTelephone());
|
||||
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
if (employeeEntity.getBirthday() != null) {
|
||||
String birthday = sf.format(employeeEntity.getBirthday());
|
||||
mode.setBirthday(birthday);
|
||||
}
|
||||
if (employeeEntity.getAttendWorkTime() != null) {
|
||||
String attendWorkTime = sf.format(employeeEntity.getAttendWorkTime());
|
||||
mode.setAttendWorkTime(attendWorkTime);
|
||||
}
|
||||
mode.setEducation(employeeEntity.getEducation());
|
||||
mode.setMajor(employeeEntity.getMajor());
|
||||
mode.setGraduationAcademy(employeeEntity.getGraduationAcademy());
|
||||
if (employeeEntity.getGraduationTime() != null) {
|
||||
String graduationTime = sf.format(employeeEntity.getGraduationTime());
|
||||
mode.setGraduationTime(graduationTime);
|
||||
}
|
||||
SimpleDateFormat sf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||
if (employeeEntity.getCreatorTime() != null) {
|
||||
String creatorTime = sf1.format(employeeEntity.getCreatorTime());
|
||||
mode.setCreatorTime(creatorTime);
|
||||
}
|
||||
modeList.add(mode);
|
||||
}
|
||||
String jsonString = JsonUtilEx.getObjectToStringDateFormat(modeList, "yyyy-MM-dd");
|
||||
List<EmployeeExportVO> list = (List<EmployeeExportVO>) (List<?>) JsonUtil
|
||||
.listToJsonField(JsonUtil.getJsonToList(jsonString, EmployeeExportVO.class));
|
||||
List<ExcelExportEntity> entitys = new ArrayList<>();
|
||||
String[] splitData = selectKey.split(",");
|
||||
if (splitData != null && splitData.length > 0) {
|
||||
for (int i = 0; i < splitData.length; i++) {
|
||||
if ("enCode".equals(splitData[i])) {
|
||||
entitys.add(new ExcelExportEntity("工号", "enCode"));
|
||||
}
|
||||
if ("fullName".equals(splitData[i])) {
|
||||
entitys.add(new ExcelExportEntity("姓名", "fullName"));
|
||||
}
|
||||
if ("gender".equals(splitData[i])) {
|
||||
entitys.add(new ExcelExportEntity("性别", "gender"));
|
||||
}
|
||||
if ("departmentName".equals(splitData[i])) {
|
||||
entitys.add(new ExcelExportEntity("部门", "departmentName"));
|
||||
}
|
||||
if ("positionName".equals(splitData[i])) {
|
||||
entitys.add(new ExcelExportEntity("职务", "positionName", 25));
|
||||
}
|
||||
if ("workingNature".equals(splitData[i])) {
|
||||
entitys.add(new ExcelExportEntity("用工性质", "workingNature"));
|
||||
}
|
||||
if ("idNumber".equals(splitData[i])) {
|
||||
entitys.add(new ExcelExportEntity("身份证号", "idNumber", 25));
|
||||
}
|
||||
if ("telephone".equals(splitData[i])) {
|
||||
entitys.add(new ExcelExportEntity("联系电话", "telephone", 20));
|
||||
}
|
||||
if ("birthday".equals(splitData[i])) {
|
||||
entitys.add(new ExcelExportEntity("出生年月", "birthday", 20));
|
||||
}
|
||||
if ("attendWorkTime".equals(splitData[i])) {
|
||||
entitys.add(new ExcelExportEntity("参加工作", "attendWorkTime", 20));
|
||||
}
|
||||
if ("education".equals(splitData[i])) {
|
||||
entitys.add(new ExcelExportEntity("最高学历", "education"));
|
||||
}
|
||||
if ("major".equals(splitData[i])) {
|
||||
entitys.add(new ExcelExportEntity("所学专业", "major"));
|
||||
}
|
||||
if ("graduationAcademy".equals(splitData[i])) {
|
||||
entitys.add(new ExcelExportEntity("毕业院校", "graduationAcademy"));
|
||||
}
|
||||
if ("graduationTime".equals(splitData[i])) {
|
||||
entitys.add(new ExcelExportEntity("毕业时间", "graduationTime", 20));
|
||||
}
|
||||
if ("creatorTime".equals(splitData[i])) {
|
||||
entitys.add(new ExcelExportEntity("创建时间", "creatorTime"));
|
||||
}
|
||||
}
|
||||
}
|
||||
ExportParams exportParams = new ExportParams(null, "职员信息");
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
DownloadVO vo = DownloadVO.builder().build();
|
||||
try {
|
||||
@Cleanup
|
||||
Workbook workbook = new HSSFWorkbook();
|
||||
if (entitys.size() > 0) {
|
||||
workbook = ExcelExportUtil.exportExcel(exportParams, entitys, list);
|
||||
}
|
||||
String name = "职员信息" + DateUtil.dateNow("yyyyMMdd") + "_" + RandomUtil.uuId() + ".xlsx";
|
||||
// 上传文件
|
||||
MultipartFile multipartFile = ExcelUtil.workbookToCommonsMultipartFile(workbook, name);
|
||||
String temporaryFilePath = configValueUtil.getTemporaryFilePath();
|
||||
FileInfo fileInfo = FileUploadUtils.uploadFile(multipartFile, temporaryFilePath, name);
|
||||
vo.setName(fileInfo.getFilename());
|
||||
vo.setUrl(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + "Temporary") + "&name=" + name);
|
||||
} catch (Exception e) {
|
||||
log.error("信息导出Excel错误:{}", e.getMessage());
|
||||
}
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.yunzhupaas.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.entity.LeaveApplyEntity;
|
||||
import com.yunzhupaas.model.leaveapply.LeaveApplyForm;
|
||||
import com.yunzhupaas.model.leaveapply.LeaveApplyInfoVO;
|
||||
import com.yunzhupaas.service.LeaveApplyService;
|
||||
import com.yunzhupaas.util.GeneraterSwapUtil;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 请假申请
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2023/09/27
|
||||
*/
|
||||
@Tag(name = "请假申请", description = "LeaveApply")
|
||||
@RestController
|
||||
@RequestMapping("/api/extend/Form/LeaveApply")
|
||||
public class LeaveApplyController extends SuperController<LeaveApplyService, LeaveApplyEntity> {
|
||||
|
||||
@Autowired
|
||||
private LeaveApplyService leaveApplyService;
|
||||
@Autowired
|
||||
private GeneraterSwapUtil generaterSwapUtil;
|
||||
|
||||
/**
|
||||
* 获取请假申请信息
|
||||
*
|
||||
* @param id 主键值
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取请假申请信息")
|
||||
@GetMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult<LeaveApplyInfoVO> info(@PathVariable("id") String id) {
|
||||
LeaveApplyEntity entity = leaveApplyService.getInfo(id);
|
||||
LeaveApplyInfoVO vo = JsonUtil.getJsonToBean(entity, LeaveApplyInfoVO.class);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建请假申请
|
||||
*
|
||||
* @param leaveApplyForm 表单对象
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "新建请假申请")
|
||||
@PostMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "leaveApplyForm", description = "请假模型", required = true),
|
||||
})
|
||||
public ActionResult create(@RequestBody LeaveApplyForm leaveApplyForm, @PathVariable("id") String id) {
|
||||
LeaveApplyEntity entity = JsonUtil.getJsonToBean(leaveApplyForm, LeaveApplyEntity.class);
|
||||
leaveApplyService.submit(id, entity, leaveApplyForm);
|
||||
return ActionResult.success(MsgCode.SU006.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改请假申请
|
||||
*
|
||||
* @param leaveApplyForm 表单对象
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "修改请假申请")
|
||||
@PutMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "leaveApplyForm", description = "请假模型", required = true),
|
||||
})
|
||||
public ActionResult update(@RequestBody LeaveApplyForm leaveApplyForm, @PathVariable("id") String id) {
|
||||
LeaveApplyEntity entity = JsonUtil.getJsonToBean(leaveApplyForm, LeaveApplyEntity.class);
|
||||
entity.setId(id);
|
||||
leaveApplyService.submit(id, entity, leaveApplyForm);
|
||||
return ActionResult.success(MsgCode.SU006.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除请假申请信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@Operation(summary = "删除请假申请信息")
|
||||
@DeleteMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult delete(@PathVariable("id") String id, @RequestParam(name = "forceDel", defaultValue = "false") Boolean forceDel) {
|
||||
LeaveApplyEntity entity = leaveApplyService.getInfo(id);
|
||||
if (null != entity) {
|
||||
if (!forceDel) {
|
||||
String errMsg = generaterSwapUtil.deleteFlowTask(entity.getId());
|
||||
if (StringUtil.isNotBlank(errMsg)) {
|
||||
throw new RuntimeException(errMsg);
|
||||
}
|
||||
}
|
||||
leaveApplyService.delete(entity);
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.FA003.get());
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,188 @@
|
||||
package com.yunzhupaas.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import com.yunzhupaas.base.vo.ListVO;
|
||||
import com.yunzhupaas.base.vo.PageListVO;
|
||||
import com.yunzhupaas.base.vo.PaginationVO;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.entity.ProductEntity;
|
||||
import com.yunzhupaas.entity.ProductEntryEntity;
|
||||
import com.yunzhupaas.exception.DataException;
|
||||
import com.yunzhupaas.model.product.*;
|
||||
import com.yunzhupaas.model.productEntry.ProductEntryInfoVO;
|
||||
import com.yunzhupaas.model.productEntry.ProductEntryListVO;
|
||||
import com.yunzhupaas.model.productEntry.ProductEntryMdoel;
|
||||
import com.yunzhupaas.service.ProductEntryService;
|
||||
import com.yunzhupaas.service.ProductService;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* 销售订单
|
||||
*
|
||||
* @版本: V3.1.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2021-07-10 10:40:59
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Tag(name = "销售订单", description = "Product")
|
||||
@RequestMapping("/api/extend/saleOrder/Product")
|
||||
public class ProductController extends SuperController<ProductService, ProductEntity> {
|
||||
|
||||
@Autowired
|
||||
private ProductService productService;
|
||||
@Autowired
|
||||
private ProductEntryService productEntryService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param productPagination 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "列表")
|
||||
@GetMapping
|
||||
@SaCheckPermission("saleOrder")
|
||||
public ActionResult<PageListVO<ProductListVO>> list(ProductPagination productPagination) {
|
||||
List<ProductEntity> list = productService.getList(productPagination);
|
||||
List<ProductListVO> listVO = JsonUtil.getJsonToList(list, ProductListVO.class);
|
||||
PageListVO vo = new PageListVO();
|
||||
vo.setList(listVO);
|
||||
PaginationVO page = JsonUtil.getJsonToBean(productPagination, PaginationVO.class);
|
||||
vo.setPagination(page);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param productCrForm 销售模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "创建")
|
||||
@PostMapping
|
||||
@Parameters({
|
||||
@Parameter(name = "productCrForm", description = "销售模型",required = true),
|
||||
})
|
||||
@SaCheckPermission("saleOrder")
|
||||
public ActionResult create(@RequestBody @Valid ProductCrForm productCrForm) throws DataException {
|
||||
ProductEntity entity = JsonUtil.getJsonToBean(productCrForm, ProductEntity.class);
|
||||
List<ProductEntryEntity> productEntryList = JsonUtil.getJsonToList(productCrForm.getProductEntryList(), ProductEntryEntity.class);
|
||||
productService.create(entity, productEntryList);
|
||||
return ActionResult.success(MsgCode.SU001.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "信息")
|
||||
@GetMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键",required = true),
|
||||
})
|
||||
@SaCheckPermission("saleOrder")
|
||||
public ActionResult<ProductInfoVO> info(@PathVariable("id") String id) {
|
||||
ProductEntity entity = productService.getInfo(id);
|
||||
ProductInfoVO vo = JsonUtil.getJsonToBean(entity, ProductInfoVO.class);
|
||||
List<ProductEntryEntity> productEntryList = productEntryService.getProductentryEntityList(id);
|
||||
List<ProductEntryInfoVO> productList = JsonUtil.getJsonToList(productEntryList, ProductEntryInfoVO.class);
|
||||
vo.setProductEntryList(productList);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param productUpForm 销售模型
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "更新")
|
||||
@PutMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键",required = true),
|
||||
@Parameter(name = "productUpForm", description = "销售模型",required = true),
|
||||
})
|
||||
@SaCheckPermission("saleOrder")
|
||||
public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid ProductUpForm productUpForm) {
|
||||
ProductEntity entity = productService.getInfo(id);
|
||||
if (entity != null) {
|
||||
List<ProductEntryEntity> productEntryList = JsonUtil.getJsonToList(productUpForm.getProductEntryList(), ProductEntryEntity.class);
|
||||
productService.update(id, entity, productEntryList);
|
||||
return ActionResult.success(MsgCode.SU004.get());
|
||||
} else {
|
||||
return ActionResult.fail(MsgCode.FA002.get());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "删除")
|
||||
@DeleteMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键",required = true),
|
||||
})
|
||||
@SaCheckPermission("saleOrder")
|
||||
public ActionResult delete(@PathVariable("id") String id) {
|
||||
ProductEntity entity = productService.getInfo(id);
|
||||
if (entity != null) {
|
||||
productService.delete(entity);
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取销售产品明细
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取销售明细")
|
||||
@GetMapping("/ProductEntry/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键",required = true),
|
||||
})
|
||||
@SaCheckPermission("saleOrder")
|
||||
public ActionResult<ListVO<ProductEntryInfoVO>> ProductEntryList(@PathVariable("id") String id) {
|
||||
String data = "[{\"id\":\"37c995b4044541009fb7e285bcf9845d\",\"productSpecification\":\"120ml\",\"qty\":16,\"money\":510,\"price\":120,\"commandType\":\"唯一码\",\"util\":\"盒\"},{\"id\":\"2dbb11d3cde04c299985ac944d130ba0\",\"productSpecification\":\"150ml\",\"qty\":15,\"money\":520,\"price\":310,\"commandType\":\"唯一码\",\"util\":\"盒\"},{\"id\":\"f8ec261ccdf045e5a2e1f0e5485cda76\",\"productSpecification\":\"40ml\",\"qty\":13,\"money\":530,\"price\":140,\"commandType\":\"唯一码\",\"util\":\"盒\"},{\"id\":\"6c110b57ae56445faa8ce9be501c8997\",\"productSpecification\":\"103ml\",\"qty\":2,\"money\":504,\"price\":150,\"commandType\":\"唯一码\",\"util\":\"盒\"},{\"id\":\"f2ee981aaf934147a4d090a0eed2203f\",\"productSpecification\":\"120ml\",\"qty\":21,\"money\":550,\"price\":160,\"commandType\":\"唯一码\",\"util\":\"盒\"}]";
|
||||
List<ProductEntryMdoel> dataAll = JsonUtil.getJsonToList(data, ProductEntryMdoel.class);
|
||||
List<ProductEntryEntity> productEntryList = productEntryService.getProductentryEntityList(id);
|
||||
List<ProductEntryListVO> productList = JsonUtil.getJsonToList(productEntryList, ProductEntryListVO.class);
|
||||
for (ProductEntryListVO entry : productList) {
|
||||
List<ProductEntryMdoel> dataList = new ArrayList<>();
|
||||
Random random = new Random();
|
||||
int num = random.nextInt(dataAll.size());
|
||||
for (int i = 0; i < num; i++) {
|
||||
dataList.add(dataAll.get(num));
|
||||
}
|
||||
entry.setDataList(dataList);
|
||||
}
|
||||
ListVO vo = new ListVO();
|
||||
vo.setList(productList);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
package com.yunzhupaas.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import com.yunzhupaas.base.vo.ListVO;
|
||||
import com.yunzhupaas.base.vo.PageListVO;
|
||||
import com.yunzhupaas.base.vo.PaginationVO;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.entity.ProductGoodsEntity;
|
||||
import com.yunzhupaas.model.productgoods.*;
|
||||
import com.yunzhupaas.service.ProductGoodsService;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 产品商品
|
||||
*
|
||||
* @版本: V3.1.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2021-07-10 15:57:50
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Tag(name = "产品商品", description = "Goods")
|
||||
@RequestMapping("/api/extend/saleOrder/Goods")
|
||||
public class ProductGoodsController extends SuperController<ProductGoodsService, ProductGoodsEntity> {
|
||||
|
||||
@Autowired
|
||||
private ProductGoodsService productgoodsService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param type 类型
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getGoodList")
|
||||
@Operation(summary = "列表")
|
||||
@Parameters({
|
||||
@Parameter(name = "type", description = "类型"),
|
||||
})
|
||||
@SaCheckPermission("saleOrder")
|
||||
public ActionResult<ListVO<ProductGoodsListVO>> list(@RequestParam("type")String type) {
|
||||
List<ProductGoodsEntity> list = productgoodsService.getGoodList(type);
|
||||
List<ProductGoodsListVO> listVO = JsonUtil.getJsonToList(list, ProductGoodsListVO.class);
|
||||
ListVO vo = new ListVO();
|
||||
vo.setList(listVO);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param goodsPagination 分页模型
|
||||
* @return
|
||||
*/
|
||||
@GetMapping
|
||||
@Operation(summary = "列表")
|
||||
@SaCheckPermission("saleOrder")
|
||||
public ActionResult<PageListVO<ProductGoodsListVO>> list(ProductGoodsPagination goodsPagination) {
|
||||
List<ProductGoodsEntity> list = productgoodsService.getList(goodsPagination);
|
||||
List<ProductGoodsListVO> listVO = JsonUtil.getJsonToList(list, ProductGoodsListVO.class);
|
||||
PageListVO vo = new PageListVO();
|
||||
vo.setList(listVO);
|
||||
PaginationVO page = JsonUtil.getJsonToBean(goodsPagination, PaginationVO.class);
|
||||
vo.setPagination(page);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param goodsCrForm 商品模型
|
||||
* @return
|
||||
*/
|
||||
@PostMapping
|
||||
@Operation(summary = "创建")
|
||||
@Parameters({
|
||||
@Parameter(name = "goodsCrForm", description = "商品模型",required = true),
|
||||
})
|
||||
@SaCheckPermission("saleOrder")
|
||||
public ActionResult create(@RequestBody @Valid ProductGoodsCrForm goodsCrForm) {
|
||||
ProductGoodsEntity entity = JsonUtil.getJsonToBean(goodsCrForm, ProductGoodsEntity.class);
|
||||
productgoodsService.create(entity);
|
||||
return ActionResult.success(MsgCode.SU001.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "信息")
|
||||
@GetMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
@SaCheckPermission("saleOrder")
|
||||
public ActionResult<ProductGoodsInfoVO> info(@PathVariable("id") String id) {
|
||||
ProductGoodsEntity entity = productgoodsService.getInfo(id);
|
||||
ProductGoodsInfoVO vo = JsonUtil.getJsonToBean(entity, ProductGoodsInfoVO.class);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param id 主键
|
||||
* @param goodsCrFormUpForm 商品模型
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("/{id}")
|
||||
@Operation(summary = "更新")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "goodsCrFormUpForm", description = "商品模型",required = true),
|
||||
})
|
||||
@SaCheckPermission("saleOrder")
|
||||
public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid ProductGoodsUpForm goodsCrFormUpForm) {
|
||||
ProductGoodsEntity entity = JsonUtil.getJsonToBean(goodsCrFormUpForm, ProductGoodsEntity.class);
|
||||
boolean ok = productgoodsService.update(id, entity);
|
||||
if (ok) {
|
||||
return ActionResult.success(MsgCode.SU004.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.FA002.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping("/{id}")
|
||||
@Operation(summary = "删除")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
@SaCheckPermission("saleOrder")
|
||||
public ActionResult delete(@PathVariable("id") String id) {
|
||||
ProductGoodsEntity entity = productgoodsService.getInfo(id);
|
||||
if (entity != null) {
|
||||
productgoodsService.delete(entity);
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 下拉
|
||||
*
|
||||
* @param goodsPagination 下拉模型
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/Selector")
|
||||
@Operation(summary = "下拉")
|
||||
@SaCheckPermission("saleOrder")
|
||||
public ActionResult<ListVO<ProductGoodsListVO>> listSelect(ProductGoodsPagination goodsPagination) {
|
||||
goodsPagination.setCurrentPage(1);
|
||||
goodsPagination.setPageSize(50);
|
||||
List<ProductGoodsEntity> list = productgoodsService.getList(goodsPagination);
|
||||
List<ProductGoodsListVO> listVO = JsonUtil.getJsonToList(list, ProductGoodsListVO.class);
|
||||
ListVO vo = new ListVO();
|
||||
vo.setList(listVO);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
package com.yunzhupaas.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import com.yunzhupaas.base.vo.ListVO;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.entity.ProductclassifyEntity;
|
||||
import com.yunzhupaas.model.productclassify.*;
|
||||
import com.yunzhupaas.service.ProductclassifyService;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.treeutil.SumTree;
|
||||
import com.yunzhupaas.util.treeutil.TreeDotUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 产品分类
|
||||
*
|
||||
* @版本: V3.1.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2021-07-10 14:34:04
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Tag(name = "产品分类", description = "Classify")
|
||||
@RequestMapping("/api/extend/saleOrder/Classify")
|
||||
public class ProductclassifyController extends SuperController<ProductclassifyService, ProductclassifyEntity> {
|
||||
|
||||
@Autowired
|
||||
private ProductclassifyService productclassifyService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping
|
||||
@Operation(summary = "列表")
|
||||
@SaCheckPermission("saleOrder")
|
||||
public ActionResult<ListVO<ProductclassifyListVO>> list() {
|
||||
List<ProductclassifyEntity> data = productclassifyService.getList();
|
||||
List<ProductclassifyModel> modelList = JsonUtil.getJsonToList(data, ProductclassifyModel.class);
|
||||
List<SumTree<ProductclassifyModel>> sumTrees = TreeDotUtils.convertListToTreeDot(modelList);
|
||||
List<ProductclassifyListVO> list = JsonUtil.getJsonToList(sumTrees, ProductclassifyListVO.class);
|
||||
ListVO vo = new ListVO();
|
||||
vo.setList(list);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param classifyCrForm 分类模型
|
||||
* @return
|
||||
*/
|
||||
@PostMapping
|
||||
@Operation(summary = "创建")
|
||||
@Parameters({
|
||||
@Parameter(name = "classifyCrForm", description = "分类模型", required = true),
|
||||
})
|
||||
@SaCheckPermission("saleOrder")
|
||||
public ActionResult create(@RequestBody @Valid ProductclassifyCrForm classifyCrForm) {
|
||||
ProductclassifyEntity entity = JsonUtil.getJsonToBean(classifyCrForm, ProductclassifyEntity.class);
|
||||
productclassifyService.create(entity);
|
||||
return ActionResult.success(MsgCode.SU001.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
@Operation(summary = "信息")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
@SaCheckPermission("saleOrder")
|
||||
public ActionResult<ProductclassifyInfoVO> info(@PathVariable("id") String id) {
|
||||
ProductclassifyEntity entity = productclassifyService.getInfo(id);
|
||||
ProductclassifyInfoVO vo = JsonUtil.getJsonToBean(entity, ProductclassifyInfoVO.class);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param id 主键
|
||||
* @param classifyUpForm 分类模型
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("/{id}")
|
||||
@Operation(summary = "更新")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "classifyUpForm", description = "分类模型", required = true),
|
||||
})
|
||||
@SaCheckPermission("saleOrder")
|
||||
public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid ProductclassifyUpForm classifyUpForm) {
|
||||
ProductclassifyEntity entity = JsonUtil.getJsonToBean(classifyUpForm, ProductclassifyEntity.class);
|
||||
boolean ok = productclassifyService.update(id, entity);
|
||||
if (ok) {
|
||||
return ActionResult.success(MsgCode.SU004.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.FA002.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping("/{id}")
|
||||
@Operation(summary = "删除")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
@SaCheckPermission("saleOrder")
|
||||
public ActionResult delete(@PathVariable("id") String id) {
|
||||
ProductclassifyEntity entity = productclassifyService.getInfo(id);
|
||||
if (entity != null) {
|
||||
productclassifyService.delete(entity);
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,323 @@
|
||||
package com.yunzhupaas.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.yunzhupaas.annotation.EncryptApi;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.Page;
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import com.yunzhupaas.base.vo.ListVO;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.entity.ProjectGanttEntity;
|
||||
import com.yunzhupaas.exception.DataException;
|
||||
import com.yunzhupaas.model.projectgantt.*;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.permission.service.UserService;
|
||||
import com.yunzhupaas.service.ProjectGanttService;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.JsonUtilEx;
|
||||
import com.yunzhupaas.util.UploaderUtil;
|
||||
import com.yunzhupaas.util.treeutil.ListToTreeUtil;
|
||||
import com.yunzhupaas.util.treeutil.SumTree;
|
||||
import com.yunzhupaas.util.treeutil.TreeDotUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 项目计划
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
@Tag(name = "项目计划", description = "ProjectGantt")
|
||||
@RestController
|
||||
@RequestMapping("/api/extend/ProjectGantt")
|
||||
public class ProjectGanttController extends SuperController<ProjectGanttService, ProjectGanttEntity> {
|
||||
|
||||
@Autowired
|
||||
private ProjectGanttService projectGanttService;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
|
||||
/**
|
||||
* 项目列表
|
||||
*
|
||||
* @param page 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取项目管理列表")
|
||||
@GetMapping
|
||||
@SaCheckPermission("extend.projectGantt")
|
||||
public ActionResult<ListVO<ProjectGanttListVO>> list(Page page) {
|
||||
List<ProjectGanttEntity> data = projectGanttService.getList(page);
|
||||
List<ProjectGanttListVO> list = JsonUtil.getJsonToList(data, ProjectGanttListVO.class);
|
||||
//获取用户给项目参与人员列表赋值
|
||||
List<String> userId = new ArrayList<>();
|
||||
list.forEach(t -> {
|
||||
String[] ids = t.getManagerIds().split(",");
|
||||
Collections.addAll(userId, ids);
|
||||
});
|
||||
List<UserEntity> userList = userService.getUserName(userId);
|
||||
for (ProjectGanttListVO vo : list) {
|
||||
List<String> managerList = new ArrayList<>();
|
||||
Collections.addAll(managerList, vo.getManagerIds().split(","));
|
||||
List<UserEntity> user = userList.stream().filter(t -> managerList.contains(t.getId())).collect(Collectors.toList());
|
||||
List<ProjectGanttManagerIModel> list1 = new ArrayList<>();
|
||||
user.forEach(t -> {
|
||||
ProjectGanttManagerIModel model1 = new ProjectGanttManagerIModel();
|
||||
model1.setAccount(t.getRealName() + "/" + t.getAccount());
|
||||
model1.setHeadIcon(UploaderUtil.uploaderImg(t.getHeadIcon()));
|
||||
list1.add(model1);
|
||||
});
|
||||
vo.setManagersInfo(list1);
|
||||
}
|
||||
ListVO listVO = new ListVO<>();
|
||||
listVO.setList(list);
|
||||
return ActionResult.success(listVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务列表
|
||||
*
|
||||
* @param page 分页模型
|
||||
* @param projectId 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取项目任务列表")
|
||||
@GetMapping("/{projectId}/Task")
|
||||
@Parameters({
|
||||
@Parameter(name = "projectId", description = "主键",required = true),
|
||||
})
|
||||
@SaCheckPermission("extend.projectGantt")
|
||||
public ActionResult<ListVO<ProjectGanttTaskTreeVO>> taskList(Page page, @PathVariable("projectId") String projectId) {
|
||||
List<ProjectGanttEntity> data = projectGanttService.getTaskList(projectId);
|
||||
List<ProjectGanttEntity> dataAll = data;
|
||||
if (!StringUtils.isEmpty(page.getKeyword())) {
|
||||
data = data.stream().filter(t -> String.valueOf(t.getFullName()).contains(page.getKeyword()) || String.valueOf(t.getEnCode()).contains(page.getKeyword())).collect(Collectors.toList());
|
||||
}
|
||||
List<ProjectGanttEntity> list = JsonUtil.getJsonToList(ListToTreeUtil.treeWhere(data, dataAll), ProjectGanttEntity.class);
|
||||
List<ProjectGanttTreeModel> treeList = JsonUtil.getJsonToList(list, ProjectGanttTreeModel.class);
|
||||
List<SumTree<ProjectGanttTreeModel>> trees = TreeDotUtils.convertListToTreeDot(treeList);
|
||||
List<ProjectGanttTaskTreeVO> listVO = JsonUtil.getJsonToList(trees, ProjectGanttTaskTreeVO.class);
|
||||
ListVO vo = new ListVO();
|
||||
vo.setList(listVO);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务树形
|
||||
*
|
||||
* @param projectId 主键
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取项目计划任务树形(新建任务)")
|
||||
@GetMapping("/{projectId}/Task/Selector/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "projectId", description = "主键",required = true),
|
||||
@Parameter(name = "id", description = "主键",required = true),
|
||||
})
|
||||
@SaCheckPermission("extend.projectGantt")
|
||||
public ActionResult<ListVO<ProjectGanttTaskTreeVO>> taskTreeView(@PathVariable("projectId") String projectId, @PathVariable("id") String id) {
|
||||
List<ProjectGanttTaskTreeModel> treeList = new ArrayList<>();
|
||||
List<ProjectGanttEntity> data = projectGanttService.getTaskList(projectId);
|
||||
if (!"0".equals(id)) {
|
||||
//上级不能选择自己
|
||||
data.remove(projectGanttService.getInfo(id));
|
||||
}
|
||||
for (ProjectGanttEntity entity : data) {
|
||||
ProjectGanttTaskTreeModel treeModel = new ProjectGanttTaskTreeModel();
|
||||
treeModel.setId(entity.getId());
|
||||
treeModel.setFullName(entity.getFullName());
|
||||
treeModel.setParentId(entity.getParentId());
|
||||
treeList.add(treeModel);
|
||||
}
|
||||
List<SumTree<ProjectGanttTaskTreeModel>> trees = TreeDotUtils.convertListToTreeDotFilter(treeList);
|
||||
List<ProjectGanttTaskTreeVO> listVO = JsonUtil.getJsonToList(trees, ProjectGanttTaskTreeVO.class);
|
||||
ListVO vo = new ListVO();
|
||||
vo.setList(listVO);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取项目计划信息")
|
||||
@GetMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键",required = true),
|
||||
})
|
||||
@SaCheckPermission("extend.projectGantt")
|
||||
public ActionResult<ProjectGanttInfoVO> info(@PathVariable("id") String id) throws DataException {
|
||||
ProjectGanttEntity entity = projectGanttService.getInfo(id);
|
||||
ProjectGanttInfoVO vo = JsonUtil.getJsonToBeanEx(entity, ProjectGanttInfoVO.class);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取项目计划信息")
|
||||
@GetMapping("Task/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键",required = true),
|
||||
})
|
||||
@SaCheckPermission("extend.projectGantt")
|
||||
public ActionResult<ProjectGanttTaskInfoVO> taskInfo(@PathVariable("id") String id) throws DataException {
|
||||
ProjectGanttEntity entity = projectGanttService.getInfo(id);
|
||||
ProjectGanttTaskInfoVO vo = JsonUtil.getJsonToBeanEx(entity, ProjectGanttTaskInfoVO.class);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "删除项目计划/任务")
|
||||
@DeleteMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键",required = true),
|
||||
})
|
||||
@SaCheckPermission("extend.projectGantt")
|
||||
public ActionResult delete(@PathVariable("id") String id) {
|
||||
if (projectGanttService.allowDelete(id)) {
|
||||
ProjectGanttEntity entity = projectGanttService.getInfo(id);
|
||||
if (entity != null) {
|
||||
projectGanttService.delete(entity);
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.FA003.get());
|
||||
} else {
|
||||
return ActionResult.fail(MsgCode.ETD112.get());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param projectGanttCrForm 项目模型
|
||||
* @return
|
||||
*/
|
||||
@EncryptApi
|
||||
@Operation(summary = "添加项目计划")
|
||||
@PostMapping
|
||||
@Parameters({
|
||||
@Parameter(name = "projectGanttCrForm", description = "项目模型",required = true),
|
||||
})
|
||||
@SaCheckPermission("extend.projectGantt")
|
||||
public ActionResult create(@RequestBody @Valid ProjectGanttCrForm projectGanttCrForm) {
|
||||
ProjectGanttEntity entity = JsonUtil.getJsonToBean(projectGanttCrForm, ProjectGanttEntity.class);
|
||||
entity.setType(1);
|
||||
entity.setParentId("0");
|
||||
if (projectGanttService.isExistByFullName(projectGanttCrForm.getFullName(), entity.getId())) {
|
||||
return ActionResult.fail(MsgCode.EXIST001.get());
|
||||
}
|
||||
if (projectGanttService.isExistByEnCode(projectGanttCrForm.getEnCode(), entity.getId())) {
|
||||
return ActionResult.fail(MsgCode.EXIST002.get());
|
||||
}
|
||||
projectGanttService.create(entity);
|
||||
return ActionResult.success(MsgCode.SU001.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param id 主键
|
||||
* @param projectGanttUpForm 项目模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "修改项目计划")
|
||||
@PutMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键",required = true),
|
||||
@Parameter(name = "projectGanttUpForm", description = "项目模型",required = true),
|
||||
})
|
||||
@SaCheckPermission("extend.projectGantt")
|
||||
public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid ProjectGanttUpForm projectGanttUpForm) {
|
||||
ProjectGanttEntity entity = JsonUtil.getJsonToBean(projectGanttUpForm, ProjectGanttEntity.class);
|
||||
if (projectGanttService.isExistByFullName(projectGanttUpForm.getFullName(), id)) {
|
||||
return ActionResult.fail(MsgCode.EXIST001.get());
|
||||
}
|
||||
if (projectGanttService.isExistByEnCode(projectGanttUpForm.getEnCode(), id)) {
|
||||
return ActionResult.fail(MsgCode.EXIST002.get());
|
||||
}
|
||||
boolean flag = projectGanttService.update(id, entity);
|
||||
if (flag == false) {
|
||||
return ActionResult.fail(MsgCode.FA002.get());
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU004.get());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param projectGanttTsakCrForm 项目模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "添加项目任务")
|
||||
@PostMapping("/Task")
|
||||
@Parameters({
|
||||
@Parameter(name = "projectGanttTsakCrForm", description = "项目模型",required = true),
|
||||
})
|
||||
@SaCheckPermission("extend.projectGantt")
|
||||
public ActionResult createTask(@RequestBody @Valid ProjectGanttTsakCrForm projectGanttTsakCrForm) {
|
||||
ProjectGanttEntity entity = JsonUtil.getJsonToBean(projectGanttTsakCrForm, ProjectGanttEntity.class);
|
||||
entity.setType(2);
|
||||
if (projectGanttService.isExistByFullName(projectGanttTsakCrForm.getFullName(), entity.getId())) {
|
||||
return ActionResult.fail(MsgCode.EXIST001.get());
|
||||
}
|
||||
projectGanttService.create(entity);
|
||||
return ActionResult.success(MsgCode.SU001.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param id 主键
|
||||
* @param projectGanttTsakCrForm 项目模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "修改项目任务")
|
||||
@PutMapping("/Task/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "projectGanttTsakCrForm", description = "项目模型",required = true),
|
||||
@Parameter(name = "id", description = "主键",required = true),
|
||||
})
|
||||
@SaCheckPermission("extend.projectGantt")
|
||||
public ActionResult updateTask(@PathVariable("id") String id, @RequestBody @Valid ProjectGanttTsakUpForm projectGanttTsakCrForm) {
|
||||
ProjectGanttEntity entity = JsonUtil.getJsonToBean(projectGanttTsakCrForm, ProjectGanttEntity.class);
|
||||
if (projectGanttService.isExistByFullName(projectGanttTsakCrForm.getFullName(), id)) {
|
||||
return ActionResult.fail(MsgCode.EXIST001.get());
|
||||
}
|
||||
boolean flag = projectGanttService.update(id, entity);
|
||||
if (flag == false) {
|
||||
return ActionResult.fail(MsgCode.FA002.get());
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU004.get());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.yunzhupaas.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.model.ReportManageModel;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.PinYinUtil;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 专业报表
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version 版 本:V3.0.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 日 期:2020.01.30
|
||||
*/
|
||||
@Tag(name = "专业报表", description = "获取专业报表列表")
|
||||
@RestController
|
||||
@RequestMapping("/api/extend/ReportManage")
|
||||
public class ReportManageController {
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取专业报表列表")
|
||||
@GetMapping
|
||||
public ActionResult list() {
|
||||
List<ReportManageModel> data = new ArrayList<>();
|
||||
int num = 1000000000;
|
||||
for (int i = 0; i < fullNameList().length; i++) {
|
||||
ReportManageModel model = new ReportManageModel();
|
||||
model.setId(String.valueOf(num+i+1));
|
||||
model.setFullName(fullNameList()[i]);
|
||||
model.setUrlAddress(PinYinUtil.getFullSpell(fullNameList()[i]));
|
||||
if (i < 8) {
|
||||
model.setCategory(categoryList()[0]);
|
||||
}else if(i>=8 && i<=12){
|
||||
model.setCategory(categoryList()[1]);
|
||||
}else if(i>=13 && i<=14){
|
||||
model.setCategory(categoryList()[2]);
|
||||
}else if(i>=15 && i<=17){
|
||||
model.setCategory(categoryList()[3]);
|
||||
}else if(i>=18 && i<=20){
|
||||
model.setCategory(categoryList()[4]);
|
||||
}else if(i>=21 && i<=23){
|
||||
model.setCategory(categoryList()[5]);
|
||||
}else if(i>23){
|
||||
model.setCategory(categoryList()[6]);
|
||||
}
|
||||
data.add(model);
|
||||
}
|
||||
return ActionResult.success(JsonUtil.listToJsonField(data));
|
||||
}
|
||||
|
||||
private String[] categoryList() {
|
||||
String[] category = {"报表示例", "Excel表格类", "Word文档类", "分栏与分组", "报表套打", "图表类", "其他示例"};
|
||||
return category;
|
||||
}
|
||||
|
||||
private String[] fullNameList() {
|
||||
String[] fullName = {"房地产驾驶舱", "数字化营销", "市场营销", "SMT车间看板", "学校综合业绩表", "热线机器人数据分析", "渠道零售",
|
||||
"承包方调查表", "多维透视表", "复杂交叉表", "煤矿三量基础表", "土地资源", "小学课程表", "销售合同模板", "干部任免审批表",
|
||||
"单级分组", "多级分组", "分栏报表", "国航机票", "客户订单套打", "快递单套打", "常规图表", "人员离职分析", "销售分析趋势",
|
||||
"标签打印", "报表水印", "文档目录"};
|
||||
return fullName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,131 @@
|
||||
package com.yunzhupaas.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.entity.SalesOrderEntity;
|
||||
import com.yunzhupaas.entity.SalesOrderEntryEntity;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.model.salesorder.SalesOrderEntryEntityInfoModel;
|
||||
import com.yunzhupaas.model.salesorder.SalesOrderForm;
|
||||
import com.yunzhupaas.model.salesorder.SalesOrderInfoVO;
|
||||
import com.yunzhupaas.service.SalesOrderService;
|
||||
import com.yunzhupaas.util.GeneraterSwapUtil;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 销售订单
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024-09-29 上午9:18
|
||||
*/
|
||||
@Tag(name = "销售订单", description = "SalesOrder")
|
||||
@RestController
|
||||
@RequestMapping("/api/extend/Form/SalesOrder")
|
||||
public class SalesOrderController extends SuperController<SalesOrderService, SalesOrderEntity> {
|
||||
|
||||
@Autowired
|
||||
private SalesOrderService salesOrderService;
|
||||
@Autowired
|
||||
private GeneraterSwapUtil generaterSwapUtil;
|
||||
|
||||
/**
|
||||
* 获取销售订单信息
|
||||
*
|
||||
* @param id 主键值
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取销售订单信息")
|
||||
@GetMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult info(@PathVariable("id") String id) {
|
||||
SalesOrderEntity entity = salesOrderService.getInfo(id);
|
||||
List<SalesOrderEntryEntity> entityList = salesOrderService.getSalesEntryList(id);
|
||||
SalesOrderInfoVO vo = JsonUtil.getJsonToBean(entity, SalesOrderInfoVO.class);
|
||||
if (vo != null) {
|
||||
vo.setEntryList(JsonUtil.getJsonToList(entityList, SalesOrderEntryEntityInfoModel.class));
|
||||
}
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建销售订单
|
||||
*
|
||||
* @param salesOrderForm 表单对象
|
||||
* @return
|
||||
* @throws WorkFlowException
|
||||
*/
|
||||
@Operation(summary = "新建销售订单")
|
||||
@PostMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "salesOrderForm", description = "销售模型", required = true),
|
||||
})
|
||||
public ActionResult create(@RequestBody SalesOrderForm salesOrderForm, @PathVariable("id") String id) throws WorkFlowException {
|
||||
SalesOrderEntity sales = JsonUtil.getJsonToBean(salesOrderForm, SalesOrderEntity.class);
|
||||
List<SalesOrderEntryEntity> salesEntryList = JsonUtil.getJsonToList(salesOrderForm.getEntryList(), SalesOrderEntryEntity.class);
|
||||
salesOrderService.submit(id, sales, salesEntryList, salesOrderForm);
|
||||
return ActionResult.success(MsgCode.SU006.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改销售订单
|
||||
*
|
||||
* @param salesOrderForm 表单对象
|
||||
* @param id 主键
|
||||
* @return
|
||||
* @throws WorkFlowException
|
||||
*/
|
||||
@Operation(summary = "修改销售订单")
|
||||
@PutMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "salesOrderForm", description = "销售模型", required = true),
|
||||
})
|
||||
public ActionResult update(@RequestBody SalesOrderForm salesOrderForm, @PathVariable("id") String id) throws WorkFlowException {
|
||||
SalesOrderEntity sales = JsonUtil.getJsonToBean(salesOrderForm, SalesOrderEntity.class);
|
||||
sales.setId(id);
|
||||
List<SalesOrderEntryEntity> salesEntryList = JsonUtil.getJsonToList(salesOrderForm.getEntryList(), SalesOrderEntryEntity.class);
|
||||
salesOrderService.submit(id, sales, salesEntryList, salesOrderForm);
|
||||
return ActionResult.success(MsgCode.SU006.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除销售订单信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@Operation(summary = "删除销售订单信息")
|
||||
@DeleteMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult delete(@PathVariable("id") String id, @RequestParam(name = "forceDel", defaultValue = "false") Boolean forceDel) {
|
||||
SalesOrderEntity entity = salesOrderService.getInfo(id);
|
||||
if (null != entity) {
|
||||
if (!forceDel) {
|
||||
String errMsg = generaterSwapUtil.deleteFlowTask(entity.getId());
|
||||
if (StringUtil.isNotBlank(errMsg)) {
|
||||
throw new RuntimeException(errMsg);
|
||||
}
|
||||
}
|
||||
salesOrderService.delete(entity);
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.FA003.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,450 @@
|
||||
package com.yunzhupaas.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.Page;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.permission.service.UserService;
|
||||
import com.yunzhupaas.util.JsonUtilEx;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.vo.PageListVO;
|
||||
import com.yunzhupaas.base.vo.PaginationVO;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.base.service.DictionaryDataService;
|
||||
import com.yunzhupaas.base.service.ProvinceService;
|
||||
import com.yunzhupaas.base.vo.ListVO;
|
||||
import com.yunzhupaas.entity.TableExampleEntity;
|
||||
import com.yunzhupaas.base.entity.DictionaryDataEntity;
|
||||
import com.yunzhupaas.base.entity.ProvinceEntity;
|
||||
import com.yunzhupaas.exception.DataException;
|
||||
import com.yunzhupaas.model.tableexample.*;
|
||||
import com.yunzhupaas.model.tableexample.postil.PostilInfoVO;
|
||||
import com.yunzhupaas.model.tableexample.postil.PostilModel;
|
||||
import com.yunzhupaas.model.tableexample.postil.PostilSendForm;
|
||||
import com.yunzhupaas.service.TableExampleService;
|
||||
import com.yunzhupaas.util.DateUtil;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import com.yunzhupaas.util.UserProvider;
|
||||
import com.yunzhupaas.util.treeutil.SumTree;
|
||||
import com.yunzhupaas.util.treeutil.TreeDotUtils;
|
||||
import com.yunzhupaas.util.type.StringNumber;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 表格示例数据
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
@Tag(name = "表格示例数据", description = "TableExample")
|
||||
@RestController
|
||||
@RequestMapping("/api/extend/TableExample")
|
||||
public class TableExampleController extends SuperController<TableExampleService, TableExampleEntity> {
|
||||
|
||||
@Autowired
|
||||
private TableExampleService tableExampleService;
|
||||
@Autowired
|
||||
private ProvinceService provinceService;
|
||||
@Autowired
|
||||
private DictionaryDataService dictionaryDataService;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param paginationTableExample 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取表格数据列表")
|
||||
@GetMapping
|
||||
@SaCheckPermission("extend.tableDemo.commonTable")
|
||||
public ActionResult<PageListVO<TableExampleListVO>> list(PaginationTableExample paginationTableExample) {
|
||||
List<TableExampleEntity> data = tableExampleService.getList(paginationTableExample);
|
||||
List<TableExampleListVO> list = JsonUtil.getJsonToList(data, TableExampleListVO.class);
|
||||
List<String> userId = list.stream().map(t -> t.getRegistrant()).collect(Collectors.toList());
|
||||
List<UserEntity> userList = userService.getUserName(userId);
|
||||
for (TableExampleListVO tableExampleListVO : list) {
|
||||
UserEntity user = userList.stream().filter(t -> t.getId().equals(tableExampleListVO.getRegistrant())).findFirst().orElse(null);
|
||||
tableExampleListVO.setRegistrant(user != null ? user.getRealName() + "/" + user.getAccount() : "");
|
||||
}
|
||||
PaginationVO paginationVO = JsonUtil.getJsonToBean(paginationTableExample, PaginationVO.class);
|
||||
return ActionResult.page(list, paginationVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表(树形表格)
|
||||
*
|
||||
* @param typeId 主键
|
||||
* @param paginationTableExample 查询模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "(树形表格)")
|
||||
@GetMapping("/ControlSample/{typeId}")
|
||||
@Parameters({
|
||||
@Parameter(name = "typeId", description = "主键", required = true),
|
||||
})
|
||||
@SaCheckPermission("extend.tableDemo.tableTree")
|
||||
public ActionResult<PageListVO<TableExampleListVO>> list(@PathVariable("typeId") String typeId, PaginationTableExample paginationTableExample) {
|
||||
List<TableExampleEntity> data = tableExampleService.getList(typeId, paginationTableExample);
|
||||
List<TableExampleListVO> list = JsonUtil.getJsonToList(data, TableExampleListVO.class);
|
||||
List<String> userId = list.stream().map(t -> t.getRegistrant()).collect(Collectors.toList());
|
||||
List<UserEntity> userList = userService.getUserName(userId);
|
||||
for (TableExampleListVO tableExampleListVO : list) {
|
||||
UserEntity user = userList.stream().filter(t -> t.getId().equals(tableExampleListVO.getRegistrant())).findFirst().orElse(null);
|
||||
tableExampleListVO.setRegistrant(user != null ? user.getRealName() + "/" + user.getAccount() : "");
|
||||
}
|
||||
PaginationVO paginationVO = JsonUtil.getJsonToBean(paginationTableExample, PaginationVO.class);
|
||||
return ActionResult.page(list, paginationVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取表格分组列表")
|
||||
@GetMapping("/All")
|
||||
@SaCheckPermission("extend.tableDemo.groupingTable")
|
||||
public ActionResult<ListVO<TableExampleListAllVO>> listAll() {
|
||||
List<TableExampleEntity> data = tableExampleService.getList();
|
||||
List<TableExampleListAllVO> list = JsonUtil.getJsonToList(data, TableExampleListAllVO.class);
|
||||
List<String> userId = list.stream().map(t -> t.getRegistrant()).collect(Collectors.toList());
|
||||
List<UserEntity> userList = userService.getUserName(userId);
|
||||
for (TableExampleListAllVO tableExampleListVO : list) {
|
||||
UserEntity user = userList.stream().filter(t -> t.getId().equals(tableExampleListVO.getRegistrant())).findFirst().orElse(null);
|
||||
tableExampleListVO.setRegistrant(user != null ? user.getRealName() + "/" + user.getAccount() : "");
|
||||
}
|
||||
ListVO<TableExampleListAllVO> vo = new ListVO<>();
|
||||
vo.setList(list);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param page 查询模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取延伸扩展列表(行政区划)")
|
||||
@GetMapping("/IndustryList")
|
||||
@SaCheckPermission("extend.tableDemo.extension")
|
||||
public ActionResult<ListVO<TableExampleIndustryListVO>> industryList(Page page) {
|
||||
String keyword = page.getKeyword();
|
||||
List<ProvinceEntity> data = provinceService.getList("-1");
|
||||
if (!StringUtil.isEmpty(keyword)) {
|
||||
data = data.stream().filter(t -> t.getFullName().contains(keyword)).collect(Collectors.toList());
|
||||
}
|
||||
List<TableExampleIndustryListVO> listVos = JsonUtil.getJsonToList(data, TableExampleIndustryListVO.class);
|
||||
ListVO<TableExampleIndustryListVO> vo = new ListVO<>();
|
||||
vo.setList(listVos);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param id 主键值
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取城市信息列表(获取延伸扩展列表(行政区划))")
|
||||
@GetMapping("/CityList/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
@SaCheckPermission("extend.tableDemo.extension")
|
||||
public ActionResult<ListVO<TableExampleCityListVO>> cityList(@PathVariable("id") String id) {
|
||||
List<ProvinceEntity> data = provinceService.getList(id);
|
||||
List<TableExampleCityListVO> listVos = JsonUtil.getJsonToList(data, TableExampleCityListVO.class);
|
||||
ListVO<TableExampleCityListVO> vo = new ListVO<>();
|
||||
vo.setList(listVos);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表(表格树形)
|
||||
*
|
||||
* @param isTree 类型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "表格树形")
|
||||
@GetMapping("/ControlSample/TreeList")
|
||||
@Parameters({
|
||||
@Parameter(name = "isTree", description = "类型"),
|
||||
})
|
||||
@SaCheckPermission("extend.tableDemo.tableTree")
|
||||
public ActionResult<ListVO<TableExampleTreeModel>> treeList(@RequestParam("isTree")String isTree) {
|
||||
List<DictionaryDataEntity> data = dictionaryDataService.getList("d59a3cf65f9847dbb08be449e3feae16");
|
||||
List<TableExampleTreeModel> treeList = new ArrayList<>();
|
||||
for (DictionaryDataEntity entity : data) {
|
||||
TableExampleTreeModel treeModel = new TableExampleTreeModel();
|
||||
treeModel.setId(entity.getId());
|
||||
treeModel.setText(entity.getFullName());
|
||||
treeModel.setParentId(entity.getParentId());
|
||||
treeModel.setLoaded(true);
|
||||
treeModel.setExpanded(true);
|
||||
treeModel.setHt(JsonUtil.entityToMap(entity));
|
||||
treeList.add(treeModel);
|
||||
}
|
||||
if (isTree != null && StringNumber.ONE.equals(isTree)) {
|
||||
List<SumTree<TableExampleTreeModel>> trees = TreeDotUtils.convertListToTreeDot(treeList);
|
||||
List<TableExampleTreeModel> listVO = JsonUtil.getJsonToList(trees, TableExampleTreeModel.class);
|
||||
ListVO vo = new ListVO();
|
||||
vo.setList(listVO);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
ListVO vo = new ListVO();
|
||||
vo.setList(treeList);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取普通表格示例信息")
|
||||
@GetMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
@SaCheckPermission("extend.tableDemo.extension")
|
||||
public ActionResult<TableExampleInfoVO> info(@PathVariable("id") String id) throws DataException {
|
||||
TableExampleEntity entity = tableExampleService.getInfo(id);
|
||||
TableExampleInfoVO vo = JsonUtil.getJsonToBeanEx(entity, TableExampleInfoVO.class);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "删除项目")
|
||||
@DeleteMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
@SaCheckPermission("extend.tableDemo.extension")
|
||||
public ActionResult delete(@PathVariable("id") String id) {
|
||||
TableExampleEntity entity = tableExampleService.getInfo(id);
|
||||
if (entity != null) {
|
||||
tableExampleService.delete(entity);
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.FA003.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param tableExampleCrForm 项目模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "新建项目")
|
||||
@PostMapping
|
||||
@Parameters({
|
||||
@Parameter(name = "tableExampleCrForm", description = "项目模型",required = true),
|
||||
})
|
||||
@SaCheckPermission("extend.tableDemo.extension")
|
||||
public ActionResult create(@RequestBody @Valid TableExampleCrForm tableExampleCrForm) {
|
||||
TableExampleEntity entity = JsonUtil.getJsonToBean(tableExampleCrForm, TableExampleEntity.class);
|
||||
entity.setCostAmount(entity.getCostAmount() == null ? new BigDecimal("0") : entity.getCostAmount());
|
||||
entity.setTunesAmount(entity.getTunesAmount() == null ? new BigDecimal("0") : entity.getTunesAmount());
|
||||
entity.setProjectedIncome(entity.getProjectedIncome() == null ? new BigDecimal("0") : entity.getProjectedIncome());
|
||||
entity.setSign("0000000");
|
||||
tableExampleService.create(entity);
|
||||
return ActionResult.success(MsgCode.SU001.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param id 主键
|
||||
* @param tableExampleUpForm 项目模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "更新项目")
|
||||
@PutMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "tableExampleUpForm", description = "项目模型",required = true),
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
@SaCheckPermission("extend.tableDemo.postilTable")
|
||||
public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid TableExampleUpForm tableExampleUpForm) {
|
||||
TableExampleEntity entity = JsonUtil.getJsonToBean(tableExampleUpForm, TableExampleEntity.class);
|
||||
entity.setCostAmount(entity.getCostAmount() == null ? new BigDecimal("0") : entity.getCostAmount());
|
||||
entity.setTunesAmount(entity.getTunesAmount() == null ? new BigDecimal("0") : entity.getTunesAmount());
|
||||
entity.setProjectedIncome(entity.getProjectedIncome() == null ? new BigDecimal("0") : entity.getProjectedIncome());
|
||||
boolean flag = tableExampleService.update(id, entity);
|
||||
if (flag == false) {
|
||||
return ActionResult.fail(MsgCode.FA002.get());
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU004.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新标签
|
||||
*
|
||||
* @param id 主键
|
||||
* @param tableExampleSignUpForm 项目模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "更新标记")
|
||||
@PutMapping("/UpdateSign/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "tableExampleSignUpForm", description = "项目模型",required = true),
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
@SaCheckPermission("extend.tableDemo.postilTable")
|
||||
public ActionResult updateSign(@PathVariable("id") String id, @RequestBody @Valid TableExampleSignUpForm tableExampleSignUpForm) {
|
||||
TableExampleEntity entity = JsonUtil.getJsonToBean(tableExampleSignUpForm, TableExampleEntity.class);
|
||||
TableExampleEntity tableExampleEntity = tableExampleService.getInfo(id);
|
||||
if (tableExampleEntity == null) {
|
||||
return ActionResult.success(MsgCode.FA002.get());
|
||||
}
|
||||
tableExampleEntity.setSign(entity.getSign());
|
||||
tableExampleService.update(id, entity);
|
||||
return ActionResult.success(MsgCode.SU004.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 行编辑
|
||||
*
|
||||
* @param tableExampleRowUpForm 项目模型
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "行编辑")
|
||||
@PutMapping("/{id}/Actions/RowsEdit")
|
||||
@Parameters({
|
||||
@Parameter(name = "tableExampleRowUpForm", description = "项目模型",required = true),
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
@SaCheckPermission("extend.tableDemo.redactTable")
|
||||
public ActionResult rowEditing(@PathVariable("id") String id, @RequestBody @Valid TableExampleRowUpForm tableExampleRowUpForm) {
|
||||
TableExampleEntity entity = JsonUtil.getJsonToBean(tableExampleRowUpForm, TableExampleEntity.class);
|
||||
entity.setCostAmount(entity.getCostAmount() == null ? new BigDecimal("0") : entity.getCostAmount());
|
||||
entity.setTunesAmount(entity.getTunesAmount() == null ? new BigDecimal("0") : entity.getTunesAmount());
|
||||
entity.setProjectedIncome(entity.getProjectedIncome() == null ? new BigDecimal("0") : entity.getProjectedIncome());
|
||||
entity.setId(id);
|
||||
boolean falg = tableExampleService.rowEditing(entity);
|
||||
if (falg == false) {
|
||||
return ActionResult.fail(MsgCode.FA002.get());
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU004.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送
|
||||
*
|
||||
* @param postilSendForm 项目模型
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "发送批注")
|
||||
@PostMapping("/{id}/Postil")
|
||||
@Parameters({
|
||||
@Parameter(name = "postilSendForm", description = "项目模型",required = true),
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
@SaCheckPermission("extend.tableDemo.postilTable")
|
||||
public ActionResult sendPostil(@PathVariable("id") String id, @RequestBody PostilSendForm postilSendForm) {
|
||||
TableExampleEntity tableExampleEntity = tableExampleService.getInfo(id);
|
||||
if (tableExampleEntity == null) {
|
||||
return ActionResult.success(MsgCode.FA005.get());
|
||||
}
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
PostilModel model = new PostilModel();
|
||||
model.setCreatorTime(DateUtil.getNow("+8"));
|
||||
model.setText(postilSendForm.getText());
|
||||
model.setUserId(userInfo != null ? userInfo.getUserName() + "/" + userInfo.getUserAccount() : "");
|
||||
List<PostilModel> list = new ArrayList<>();
|
||||
list.add(model);
|
||||
if (!StringUtil.isEmpty(tableExampleEntity.getPostilJson())) {
|
||||
list.addAll(JsonUtil.getJsonToList(tableExampleEntity.getPostilJson(), PostilModel.class));
|
||||
}
|
||||
|
||||
String postilJson = JsonUtil.getObjectToString(list);
|
||||
tableExampleEntity.setPostilJson(postilJson);
|
||||
tableExampleEntity.setPostilCount(list.size());
|
||||
tableExampleService.update(id, tableExampleEntity);
|
||||
return ActionResult.success(MsgCode.SU012.get());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发送
|
||||
*
|
||||
* @param id 主键值
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取批注")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
@GetMapping("/{id}/Actions/Postil")
|
||||
@SaCheckPermission("extend.tableDemo.postilTable")
|
||||
public ActionResult<PostilInfoVO> getPostil(@PathVariable("id") String id) {
|
||||
TableExampleEntity tableExampleEntity = tableExampleService.getInfo(id);
|
||||
if (tableExampleEntity == null) {
|
||||
return ActionResult.success(MsgCode.FA012.get());
|
||||
}
|
||||
PostilInfoVO vo = new PostilInfoVO();
|
||||
vo.setPostilJson(tableExampleEntity.getPostilJson());
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除批注
|
||||
*
|
||||
* @param id 主键值
|
||||
* @param index 行数
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "删除批注")
|
||||
@DeleteMapping("/{id}/Postil/{index}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "index", description = "行数", required = true),
|
||||
})
|
||||
@SaCheckPermission("extend.tableDemo.postilTable")
|
||||
public ActionResult deletePostil(@PathVariable("id") String id, @PathVariable("index") int index) {
|
||||
TableExampleEntity tableExampleEntity = tableExampleService.getInfo(id);
|
||||
if (tableExampleEntity == null) {
|
||||
return ActionResult.success(MsgCode.FA003.get());
|
||||
}
|
||||
List<PostilModel> list = JsonUtil.getJsonToList(tableExampleEntity.getPostilJson(), PostilModel.class);
|
||||
list.remove(index);
|
||||
String postilJson = JsonUtil.getObjectToString(list);
|
||||
tableExampleEntity.setPostilJson(postilJson);
|
||||
tableExampleEntity.setPostilCount((list.size()));
|
||||
tableExampleService.update(id, tableExampleEntity);
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
package com.yunzhupaas.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.Pagination;
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import com.yunzhupaas.base.vo.PageListVO;
|
||||
import com.yunzhupaas.base.vo.PaginationVO;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.entity.WorkLogEntity;
|
||||
import com.yunzhupaas.exception.DataException;
|
||||
import com.yunzhupaas.model.worklog.WorkLogCrForm;
|
||||
import com.yunzhupaas.model.worklog.WorkLogInfoVO;
|
||||
import com.yunzhupaas.model.worklog.WorkLogListVO;
|
||||
import com.yunzhupaas.model.worklog.WorkLogUpForm;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.permission.service.UserService;
|
||||
import com.yunzhupaas.service.WorkLogService;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.JsonUtilEx;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
/**
|
||||
* 工作日志
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
@Tag(name = "app工作日志", description = "WorkLog")
|
||||
@RestController
|
||||
@RequestMapping("/api/extend/WorkLog")
|
||||
public class WorkLogController extends SuperController<WorkLogService, WorkLogEntity> {
|
||||
|
||||
@Autowired
|
||||
private WorkLogService workLogService;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
/**
|
||||
* 列表(我发出的)
|
||||
*
|
||||
* @param pageModel 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "列表")
|
||||
@GetMapping("/Send")
|
||||
@SaCheckPermission("reportinglog")
|
||||
public ActionResult<PageListVO<WorkLogListVO>> getSendList(Pagination pageModel) {
|
||||
List<WorkLogEntity> data = workLogService.getSendList(pageModel);
|
||||
List<WorkLogListVO> list = JsonUtil.getJsonToList(data, WorkLogListVO.class);
|
||||
PaginationVO paginationVO = JsonUtil.getJsonToBean(pageModel, PaginationVO.class);
|
||||
return ActionResult.page(list, paginationVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表(我收到的)
|
||||
*
|
||||
* @param pageModel 分页模型
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/Receive")
|
||||
@SaCheckPermission("reportinglog")
|
||||
public ActionResult<PageListVO<WorkLogListVO>> getReceiveList(Pagination pageModel) {
|
||||
List<WorkLogEntity> data = workLogService.getReceiveList(pageModel);
|
||||
List<WorkLogListVO> list = JsonUtil.getJsonToList(data, WorkLogListVO.class);
|
||||
PaginationVO paginationVO = JsonUtil.getJsonToBean(pageModel, PaginationVO.class);
|
||||
return ActionResult.page(list, paginationVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
@SaCheckPermission("reportinglog")
|
||||
public ActionResult<WorkLogInfoVO> info(@PathVariable("id") String id) throws DataException {
|
||||
WorkLogEntity entity = workLogService.getInfo(id);
|
||||
StringJoiner userName = new StringJoiner(",");
|
||||
StringJoiner userIds = new StringJoiner(",");
|
||||
List<String> userId = Arrays.asList(entity.getToUserId().split(","));
|
||||
List<UserEntity> userList = userService.getUserName(userId);
|
||||
for (UserEntity user : userList) {
|
||||
userIds.add(user.getId());
|
||||
userName.add(user.getRealName() + "/" + user.getAccount());
|
||||
}
|
||||
entity.setToUserId(userName.toString());
|
||||
WorkLogInfoVO vo = JsonUtilEx.getJsonToBeanEx(entity, WorkLogInfoVO.class);
|
||||
vo.setUserIds(userIds.toString());
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建
|
||||
*
|
||||
* @param workLogCrForm 日志模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "新建")
|
||||
@PostMapping
|
||||
@Parameters({
|
||||
@Parameter(name = "workLogCrForm", description = "日志模型",required = true),
|
||||
})
|
||||
@SaCheckPermission("reportinglog")
|
||||
public ActionResult create(@RequestBody @Valid WorkLogCrForm workLogCrForm) {
|
||||
WorkLogEntity entity = JsonUtil.getJsonToBean(workLogCrForm, WorkLogEntity.class);
|
||||
workLogService.create(entity);
|
||||
return ActionResult.success(MsgCode.SU001.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param id 主键
|
||||
* @param workLogUpForm 日志模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "更新")
|
||||
@PutMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "workLogUpForm", description = "日志模型",required = true),
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
@SaCheckPermission("reportinglog")
|
||||
public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid WorkLogUpForm workLogUpForm) {
|
||||
WorkLogEntity entity = JsonUtil.getJsonToBean(workLogUpForm, WorkLogEntity.class);
|
||||
boolean flag = workLogService.update(id, entity);
|
||||
if (flag == false) {
|
||||
return ActionResult.fail(MsgCode.FA002.get());
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU004.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "删除")
|
||||
@DeleteMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
@SaCheckPermission("reportinglog")
|
||||
public ActionResult delete(@PathVariable("id") String id) {
|
||||
WorkLogEntity entity = workLogService.getInfo(id);
|
||||
if (entity != null) {
|
||||
workLogService.delete(entity);
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.FA003.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user