Commit d02ddb5c by HlQ

[add]

1.添加项目资料提交钉钉提醒
2.文件列表接口返回合同相关字段,并优化接口逻辑
1 parent abbf0977
......@@ -14,12 +14,12 @@
<artifactId>Vion-DevOps</artifactId>
<version>1</version>
<properties>
<pg.version>42.7.0</pg.version>
<pg.version>42.7.2</pg.version>
<sqlserver.version>12.2.0.jre8</sqlserver.version>
<lombok.version>1.18.30</lombok.version>
<hutool.version>6.0.0-M13</hutool.version>
<redisson.verion>3.27.1</redisson.verion>
<mapstruct-plus.version>1.3.5</mapstruct-plus.version>
<mapstruct-plus.version>1.4.3</mapstruct-plus.version>
<mp.version>3.5.5</mp.version>
<mp-join.version>1.4.7.2</mp-join.version>
<wx-mp.version>4.6.0</wx-mp.version>
......@@ -114,20 +114,20 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>17</source>
<target>17</target>
<encoding>UTF-8</encoding>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<version>${lombok.version}</version>
</path>
<path>
<groupId>io.github.linpeilie</groupId>
<artifactId>mapstruct-plus-processor</artifactId>
<version>1.3.5</version>
<version>${mapstruct-plus.version}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
......
package vion.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.net.URLEncodeUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
......@@ -10,6 +10,7 @@ import org.dromara.hutool.core.collection.CollUtil;
import org.dromara.hutool.core.date.DateUtil;
import org.dromara.hutool.core.io.file.FileNameUtil;
import org.dromara.hutool.core.io.file.FileUtil;
import org.dromara.hutool.core.net.url.UrlEncoder;
import org.dromara.hutool.core.text.StrUtil;
import org.dromara.hutool.core.util.ObjUtil;
import org.dromara.hutool.crypto.SecureUtil;
......@@ -21,8 +22,10 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import vion.dto.FileInfoDTO;
import vion.model.Contract;
import vion.model.FileInfo;
import vion.service.IFileService;
import vion.vo.FileInfoVO;
import java.io.File;
import java.io.IOException;
......@@ -43,15 +46,21 @@ public class FileController {
@GetMapping("/files")
@SaCheckPermission(value = "file:list", orRole = "admin")
public Page<FileInfo> getFiles(FileInfoDTO data) {
return fileService.lambdaQuery(converter.convert(data, new FileInfo()))
public Page<FileInfoVO> getFiles(FileInfoDTO data) {
var wrapper = new MPJLambdaWrapper<>(converter.convert(data, FileInfo.class))
.selectAll(FileInfo.class)
.selectAs(Contract::getContractNo, FileInfoVO::getContractNo)
.selectAs(Contract::getName, FileInfoVO::getContractName)
.leftJoin(Contract.class, Contract::getId, FileInfo::getContractId)
.eq(ObjUtil.isNotNull(data.getStoreId()), FileInfo::getStoreId, data.getStoreId())
.eq(ObjUtil.isNotNull(data.getSourceId()), FileInfo::getSourceId, data.getSourceId())
.eq(ObjUtil.isNotNull(data.getContractId()), FileInfo::getContractId, data.getContractId())
.eq(ObjUtil.isNotNull(data.getSourceType()), FileInfo::getSourceType, data.getSourceType())
.in(CollUtil.isNotEmpty(data.getSourceTypeList()), FileInfo::getSourceType, data.getSourceTypeList())
.orderByDesc(FileInfo::getCreateTime)
.page(Page.of(data.getPageNum(), data.getPageSize()));
.like(StrUtil.isNotBlank(data.getContractNo()), Contract::getContractNo, data.getContractNo())
.orderByDesc(FileInfo::getCreateTime);
return fileService.selectJoinListPage(Page.of(data.getPageNum(), data.getPageSize()), FileInfoVO.class, wrapper);
}
@GetMapping("/file/download")
......@@ -67,7 +76,8 @@ public class FileController {
HttpHeaders headers = new HttpHeaders();
headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_OCTET_STREAM_VALUE);
headers.add(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + URLEncodeUtil.encode(file.getName(), StandardCharsets.UTF_8).replace("+", "%20"));
headers.add(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + UrlEncoder.encodeAll(file.getName(),
StandardCharsets.UTF_8).replace("+", "%20"));
return ResponseEntity.ok()
.headers(headers)
......@@ -86,23 +96,23 @@ public class FileController {
@PostMapping("/file/formFileUpload")
@SaCheckPermission(value = "file:form:upload", orRole = "admin")
public String uploadFile(FileInfo fileInfo, @RequestParam(name = "file") MultipartFile infile) throws IOException {
public String uploadFile(FileInfoDTO dto, @RequestParam(name = "file") MultipartFile infile) throws IOException {
String orgName = infile.getOriginalFilename();
String mainName = FileNameUtil.mainName(orgName);
String fileExt = FileNameUtil.extName(orgName);
String filename = StrUtil.format("{}_{}.{}", mainName, DateUtil.format(new Date(), "yyyyMMdd_HHmmssSSS"), fileExt);
String path = getPath(fileInfo, filename);
String path = getPath(dto, filename);
File file = FileUtil.touch(path);
infile.transferTo(file);
FileInfo tempFileInfo = new FileInfo();
tempFileInfo.setStoreId(fileInfo.getStoreId());
tempFileInfo.setSourceId(fileInfo.getSourceId());
tempFileInfo.setSourceType(fileInfo.getSourceType());
tempFileInfo.setStoreId(dto.getStoreId());
tempFileInfo.setSourceId(dto.getSourceId());
tempFileInfo.setSourceType(dto.getSourceType());
tempFileInfo.setName(filename);
tempFileInfo.setUrl(path);
tempFileInfo.setType(FileNameUtil.extName(file));
tempFileInfo.setSha256(SecureUtil.sha256(file).toUpperCase());
tempFileInfo.setUploader(fileInfo.getUploader());
tempFileInfo.setUploader(dto.getUploader());
if (fileService.save(tempFileInfo)) {
return path;
......@@ -111,13 +121,12 @@ public class FileController {
}
}
private String getPath(FileInfo fileInfo, String filename) {
private String getPath(FileInfoDTO dto, String filename) {
String path;
if ("storeLog".equals(fileInfo.getFlag())) {
path = fileUrl + FileUtil.FILE_SEPARATOR + "form" + FileUtil.FILE_SEPARATOR + "storeLog" + FileUtil.FILE_SEPARATOR + fileInfo.getStoreId() + FileUtil.FILE_SEPARATOR + fileInfo.getSourceId() + FileUtil.FILE_SEPARATOR + filename;
if ("storeLog".equals(dto.getFlag())) {
path = fileUrl + FileUtil.FILE_SEPARATOR + "form" + FileUtil.FILE_SEPARATOR + "storeLog" + FileUtil.FILE_SEPARATOR + dto.getStoreId() + FileUtil.FILE_SEPARATOR + dto.getSourceId() + FileUtil.FILE_SEPARATOR + filename;
} else {
path = fileUrl + FileUtil.FILE_SEPARATOR + "form" + FileUtil.FILE_SEPARATOR + fileInfo.getStoreId() + FileUtil.FILE_SEPARATOR + fileInfo.getSourceId() + FileUtil.FILE_SEPARATOR + filename;
path = fileUrl + FileUtil.FILE_SEPARATOR + "form" + FileUtil.FILE_SEPARATOR + dto.getStoreId() + FileUtil.FILE_SEPARATOR + dto.getSourceId() + FileUtil.FILE_SEPARATOR + filename;
}
return path;
}
......@@ -138,6 +147,7 @@ public class FileController {
tempFileInfo.setStoreId(fileInfo.getStoreId());
tempFileInfo.setSourceId(fileInfo.getSourceId());
tempFileInfo.setSourceType(fileInfo.getSourceType());
tempFileInfo.setContractId(fileInfo.getContractId());
tempFileInfo.setName(filename);
tempFileInfo.setUrl(path);
tempFileInfo.setType(FileNameUtil.extName(file));
......
......@@ -220,4 +220,11 @@ public class StoreController {
public String remove(@PathVariable Long id) {
return storeConfederateService.removeById(id) ? "删除成功" : "删除失败";
}
@GetMapping("/store/fileNotify")
@SaCheckPermission(value = "store:fileNotify", orRole = "admin")
public String fileNotify(String storeName, String contractNo, String sourceName, String[] fileNameArr, String[] userIdStr) {
Assert.notEmpty(userIdStr, "未选择提醒人");
return storeService.fileNotify(storeName, contractNo, sourceName, fileNameArr, userIdStr) ? "钉钉提醒成功" : "钉钉提醒失败";
}
}
......@@ -13,13 +13,15 @@ public class FileInfoDTO extends BaseDTO {
private Long storeId;
/** 文件扩展名 */
private String type;
/** 文件来源(1项目、2工单预处理,3工单操作,4巡检) */
/** 文件来源 */
private Integer sourceType;
private List<Integer> sourceTypeList;
/** 文件来源id */
private Long sourceId;
/** 合同id */
private Long contractId;
/** 合同编号 */
private String contractNo;
/** 文件名称 */
private String name;
/** 文件地址 */
......@@ -30,4 +32,6 @@ public class FileInfoDTO extends BaseDTO {
private String sha256;
/** 上传人 */
private String uploader;
/** 标识:storeLog */
private String flag;
}
package vion.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.github.linpeilie.annotations.AutoMapper;
import io.github.linpeilie.annotations.AutoMappers;
import lombok.Data;
import vion.dto.FileInfoDTO;
import vion.vo.FileInfoVO;
import java.util.Date;
......@@ -16,6 +16,7 @@ import java.util.Date;
@TableName(value="tbl_file_info")
@AutoMappers({
@AutoMapper(target = FileInfoDTO.class),
@AutoMapper(target = FileInfoVO.class),
})
public class FileInfo {
@TableId(value = "id", type = IdType.AUTO)
......@@ -32,7 +33,7 @@ public class FileInfo {
* <br>16客户提交的门店图纸,17点位设计图,18合同范本,19客户上传的合同,20安装上线,与总部邮件截图</br>
* <br>21服务单等表单富文本编辑器里传图用这个类型</br>
* <br>22备件,23返修</br>
* <br>24验收报告,25竣工图纸,26点位表,27项目总结,28前期勘察</br>
* <br>24验收报告,25竣工图纸,26点位表,27项目总结,28前期勘察,29巡检报告,30结算资料</br>
*/
private Integer sourceType;
/** 文件来源id */
......@@ -46,7 +47,6 @@ public class FileInfo {
private String url;
/** 创建时间 */
@TableField(value = "create_time", fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
/** 备注 */
private String remark;
......@@ -54,8 +54,4 @@ public class FileInfo {
private String sha256;
/** 上传人 */
private String uploader;
/** 标识:storeLog */
@TableField(exist = false)
private String flag;
}
......@@ -35,4 +35,7 @@ public interface IStoreService extends MPJBaseService<Store> {
String stopCron(Long storeId);
Map<Integer, Long> statState();
Boolean fileNotify(String storeName, String contractNo, String sourceName, String[] fileNameArr, String[] userIdStr);
}
......@@ -535,6 +535,12 @@ public class StoreServiceImpl extends MPJBaseServiceImpl<StoreMapper, Store> imp
return storeList.stream().collect(Collectors.groupingBy(Store::getProjectStage, Collectors.counting()));
}
@Override
public Boolean fileNotify(String storeName, String contractNo, String sourceName, String[] fileNameArr, String[] userIdStr) {
var pushRes = dingMod.workMsg(buildMsg1(storeName, contractNo, sourceName, fileNameArr, userIdStr));
return StrUtil.containsIgnoreCase(pushRes, "ok");
}
JSONObject buildMsg(String storeName, String userid) {
var jsonObj = JSONUtil.ofObj()
.set("agent_id", 2358374016L)
......@@ -551,4 +557,31 @@ public class StoreServiceImpl extends MPJBaseServiceImpl<StoreMapper, Store> imp
jsonObj.set("msg", msg);
return jsonObj;
}
JSONObject buildMsg1(String storeName, String contractNo, String sourceName,
String[] fileNameArr, String[] userIdStr) {
var jsonObj = JSONUtil.ofObj()
.set("agent_id", 2358374016L)
.set("userid_list", String.join(",", userIdStr));
var msg = new JSONObject();
var content = new JSONObject();
String fileNameStr = Arrays.stream(fileNameArr).map(v -> StrUtil.format("{}.{}",
Arrays.asList(fileNameArr).indexOf(v) + 1, v)).collect(Collectors.joining("\n"));
content.set("title", "项目资料提交提醒")
.set("text", StrUtil.format("""
#### 项目名称:{}
#### 合同编号:{}
#### 资料类型:{}
#### 资料名称:
{}
#### 发送时间:{}""", storeName, contractNo, sourceName, fileNameStr, DateUtil.now()));
msg.set("msgtype", "markdown").set("markdown", content);
jsonObj.set("msg", msg);
return jsonObj;
}
}
package vion.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;
import java.util.Date;
@Getter
@Setter
public class FileInfoVO {
private Long id;
/** 门店id */
private Long storeId;
/** 文件扩展名 */
private String type;
/** 文件来源 */
private Integer sourceType;
/** 文件来源id */
private Long sourceId;
/** 合同id */
private Long contractId;
/** 合同编号 */
private String contractNo;
/** 合同名称 */
private String contractName;
/** 文件名称 */
private String name;
/** 文件地址 */
@JsonIgnore
private String url;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
/** 备注 */
private String remark;
/** sha256 */
private String sha256;
/** 上传人 */
private String uploader;
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!