|
@@ -1,13 +1,17 @@
|
1
|
1
|
package com.liang.service.impl;
|
2
|
2
|
|
3
|
|
-import com.liang.entity.PrjContract;
|
4
|
|
-import com.liang.entity.PrjPayplan;
|
5
|
|
-import com.liang.entity.PrjProject;
|
6
|
|
-import com.liang.entity.StaPayapproval;
|
|
3
|
+import com.liang.common.JsonTool;
|
|
4
|
+import com.liang.common.constants.CommonConstant;
|
|
5
|
+import com.liang.common.exception.CustomException;
|
|
6
|
+import com.liang.dao.BaseDictDao;
|
|
7
|
+import com.liang.entity.*;
|
7
|
8
|
import com.liang.dao.StaPayapprovalDao;
|
8
|
9
|
import com.liang.service.PrjContractService;
|
9
|
10
|
import com.liang.service.PrjPayplanService;
|
10
|
11
|
import com.liang.service.StaPayapprovalService;
|
|
12
|
+import com.liang.vo.dto.StaReimbursementVo;
|
|
13
|
+import com.liang.vo.dto.ViewFileVo;
|
|
14
|
+import io.jsonwebtoken.lang.Collections;
|
11
|
15
|
import org.springframework.stereotype.Service;
|
12
|
16
|
import org.springframework.data.domain.Page;
|
13
|
17
|
import org.springframework.data.domain.PageImpl;
|
|
@@ -18,6 +22,7 @@ import javax.annotation.Resource;
|
18
|
22
|
import java.util.HashMap;
|
19
|
23
|
import java.util.List;
|
20
|
24
|
import java.util.Map;
|
|
25
|
+import java.util.stream.Collectors;
|
21
|
26
|
|
22
|
27
|
/**
|
23
|
28
|
* 付款申请(StaPayapproval)表服务实现类
|
|
@@ -181,4 +186,43 @@ public class StaPayapprovalServiceImpl implements StaPayapprovalService {
|
181
|
186
|
public StaPayapproval getYFKJE(String fysq) {
|
182
|
187
|
return this.staPayapprovalDao.getYFKJE(fysq);
|
183
|
188
|
}
|
|
189
|
+
|
|
190
|
+ @Resource
|
|
191
|
+ private BaseDictDao dictDao;
|
|
192
|
+ @Override
|
|
193
|
+ public List<ViewFileVo> viewfile(String file) {
|
|
194
|
+
|
|
195
|
+ List<StaReimbursementVo> staReimbursementVos = JsonTool.parseArray(file, StaReimbursementVo.class);
|
|
196
|
+ //获取数据库配置 http://localhost:8081//files/
|
|
197
|
+ List<Map<String, String>> dictByCode = dictDao.getDictByCode(CommonConstant.VIEW_FILE_PATH);
|
|
198
|
+ if (Collections.isEmpty(dictByCode)) {
|
|
199
|
+ throw new CustomException("请联系管理员添加文件查看字典");
|
|
200
|
+ }
|
|
201
|
+ String viewFilePath = dictByCode.get(0).get("name");
|
|
202
|
+ if (!Collections.isEmpty(staReimbursementVos)) {
|
|
203
|
+ return staReimbursementVos.stream().map(item -> {
|
|
204
|
+ //从url "http:/1 ocalhost:8082/202305/dcccd096e08a4a1 obaacadae7477d996我的阅读推荐.docx",中截取 dcccd096e08a4a1 obaacadae7477d996我的阅读推荐.docx
|
|
205
|
+ String url = item.getUrl();
|
|
206
|
+ String substring = url.substring(url.lastIndexOf("/", url.lastIndexOf("/") - 1) + 1);
|
|
207
|
+ ;
|
|
208
|
+ String content = "";
|
|
209
|
+ if (substring.endsWith("png") || substring.endsWith("gif") || substring.endsWith("jpeg") || substring.endsWith("jpg")) {
|
|
210
|
+ //图片 使用img标签拼接 <img frameborder="0" src="http://localhost:8081//files/eaedfdfe22834ed391fc353085741c37_1715051628960.jpg" scrolling="auto" style="auto">
|
|
211
|
+ content = "<img frameborder=\"0\" src=\"" + viewFilePath + substring + "\" scrolling=\"auto\" style=\"max-width:100%; height: auto\">";
|
|
212
|
+ } else {
|
|
213
|
+ // 使用 iframe 标签拼接 <iframe frameborder="0" src="http://localhost:8081//files/eaedfdfe22834ed391fc353085741c37_1715051628960.pdf" scrolling="auto" style="width: 99%; height: 950px;"></iframe>
|
|
214
|
+ content = "<iframe frameborder=\"0\" src=\"" + viewFilePath + substring + "\" scrolling=\"auto\" style=\"width: 99%; height: 950px;\"></iframe>";
|
|
215
|
+ }
|
|
216
|
+ return ViewFileVo.builder()
|
|
217
|
+ //文件路径 http://localhost:8081//files/eaedfdfe22834ed391fc353085741c37_1715051628960.jpg
|
|
218
|
+ .content(content)
|
|
219
|
+ //文件名称
|
|
220
|
+ .title(item.getWjm())
|
|
221
|
+ .build();
|
|
222
|
+ }).collect(Collectors.toList());
|
|
223
|
+ } else {
|
|
224
|
+ throw new CustomException("暂无可查看文件");
|
|
225
|
+ }
|
|
226
|
+ }
|
|
227
|
+
|
184
|
228
|
}
|