|
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+package com.ruoyi.web.controller.wisdomarbitrate;
|
|
|
2
|
+
|
|
|
3
|
+import cn.hutool.core.io.resource.ClassPathResource;
|
|
|
4
|
+import com.deepoove.poi.XWPFTemplate;
|
|
|
5
|
+import com.deepoove.poi.data.PictureRenderData;
|
|
|
6
|
+import com.ruoyi.common.constant.CaseApplicationConstants;
|
|
|
7
|
+import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
8
|
+import com.ruoyi.common.core.redis.RedisCache;
|
|
|
9
|
+import com.ruoyi.common.utils.EmailOutUtil;
|
|
|
10
|
+import com.ruoyi.common.utils.WordUtil;
|
|
|
11
|
+import com.ruoyi.wisdomarbitrate.domain.ArbitrateRecord;
|
|
|
12
|
+import com.ruoyi.wisdomarbitrate.domain.CaseAffiliate;
|
|
|
13
|
+import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
|
|
|
14
|
+import com.ruoyi.wisdomarbitrate.domain.CaseAttach;
|
|
|
15
|
+import com.ruoyi.wisdomarbitrate.mapper.*;
|
|
|
16
|
+import com.ruoyi.wisdomarbitrate.service.ICaseApplicationService;
|
|
|
17
|
+import com.ruoyi.wisdomarbitrate.service.ICaseLogRecordService;
|
|
|
18
|
+import org.apache.poi.util.Units;
|
|
|
19
|
+import org.apache.poi.xwpf.usermodel.Document;
|
|
|
20
|
+import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
|
|
21
|
+import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
|
|
22
|
+import org.apache.poi.xwpf.usermodel.XWPFRun;
|
|
|
23
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
24
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
25
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
26
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
27
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
28
|
+
|
|
|
29
|
+import javax.imageio.ImageIO;
|
|
|
30
|
+import java.awt.image.BufferedImage;
|
|
|
31
|
+import java.io.*;
|
|
|
32
|
+import java.nio.file.Files;
|
|
|
33
|
+import java.nio.file.Path;
|
|
|
34
|
+import java.nio.file.StandardCopyOption;
|
|
|
35
|
+import java.text.SimpleDateFormat;
|
|
|
36
|
+import java.time.LocalDate;
|
|
|
37
|
+import java.util.*;
|
|
|
38
|
+
|
|
|
39
|
+@RestController
|
|
|
40
|
+@RequestMapping
|
|
|
41
|
+public class TestPOIController {
|
|
|
42
|
+
|
|
|
43
|
+ @Autowired
|
|
|
44
|
+ private CaseApplicationMapper caseApplicationMapper;
|
|
|
45
|
+ @Autowired
|
|
|
46
|
+ private CaseAffiliateMapper caseAffiliateMapper;
|
|
|
47
|
+ @Autowired
|
|
|
48
|
+ private ArbitrateRecordMapper arbitrateRecordMapper;
|
|
|
49
|
+ @Autowired
|
|
|
50
|
+ private CaseAttachMapper caseAttachMapper;
|
|
|
51
|
+ @Autowired
|
|
|
52
|
+ private RedisCache redisCache;
|
|
|
53
|
+ @Autowired
|
|
|
54
|
+ private SendMailRecordMapper sendMailRecordMapper;
|
|
|
55
|
+
|
|
|
56
|
+ @GetMapping("/test")
|
|
|
57
|
+ public AjaxResult createDocument(@RequestBody CaseApplication caseApplication) {
|
|
|
58
|
+ try {
|
|
|
59
|
+ Map<String, Object> datas = new HashMap<>();
|
|
|
60
|
+ Long id = caseApplication.getId();
|
|
|
61
|
+ if (id == null) {
|
|
|
62
|
+ return null;
|
|
|
63
|
+ }
|
|
|
64
|
+ //获取案件详细信息
|
|
|
65
|
+ CaseApplication caseApplication1 = caseApplicationMapper.selectCaseApplication(caseApplication);
|
|
|
66
|
+ //生成编码
|
|
|
67
|
+ String equipmentNo = getNewEquipmentNo();
|
|
|
68
|
+ datas.put("num", equipmentNo);
|
|
|
69
|
+ //获取仲裁记录表里的相关信息
|
|
|
70
|
+ ArbitrateRecord arbitrateRecord = new ArbitrateRecord();
|
|
|
71
|
+ arbitrateRecord.setCaseAppliId(id);
|
|
|
72
|
+ ArbitrateRecord arbitrateRecord1 = arbitrateRecordMapper.selectArbitrateRecord(arbitrateRecord);
|
|
|
73
|
+ //获取案件关联人信息
|
|
|
74
|
+ CaseAffiliate caseAffiliate = new CaseAffiliate();
|
|
|
75
|
+ caseAffiliate.setCaseAppliId(id);
|
|
|
76
|
+ List<CaseAffiliate> caseAffiliates = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate);
|
|
|
77
|
+ List<String> nameAgentList = new ArrayList<>();
|
|
|
78
|
+ if (caseAffiliates != null && caseAffiliates.size() > 0) {
|
|
|
79
|
+ for (CaseAffiliate affiliate : caseAffiliates) {
|
|
|
80
|
+ //获取身份类型
|
|
|
81
|
+ int identityType = affiliate.getIdentityType();
|
|
|
82
|
+ if (identityType == 1) { //申请人
|
|
|
83
|
+ datas.put("appName", affiliate.getName());
|
|
|
84
|
+ datas.put("appAddress", affiliate.getResidenAffili());
|
|
|
85
|
+ datas.put("appContactAddress", affiliate.getContactAddress());
|
|
|
86
|
+ datas.put("appLegalPerson", affiliate.getCompLegalPerson());
|
|
|
87
|
+ datas.put("appLegalPersonTitle", affiliate.getCompLegalperPost());
|
|
|
88
|
+ datas.put("appAgentName", affiliate.getNameAgent());
|
|
|
89
|
+ datas.put("appAgentTitle", affiliate.getAppliAgentTitle());
|
|
|
90
|
+ nameAgentList.add(affiliate.getNameAgent());
|
|
|
91
|
+ } else if (identityType == 2) { //被申请人
|
|
|
92
|
+ datas.put("resName", affiliate.getName());
|
|
|
93
|
+ datas.put("resAddress", affiliate.getResidenAffili());
|
|
|
94
|
+ String responSex = affiliate.getResponSex();
|
|
|
95
|
+ if (responSex.equals("0")){
|
|
|
96
|
+ datas.put("resSex","男");
|
|
|
97
|
+ }else{
|
|
|
98
|
+ datas.put("resSex","女");
|
|
|
99
|
+ }
|
|
|
100
|
+ Date responBirth = affiliate.getResponBirth();
|
|
|
101
|
+ if (responBirth != null) {
|
|
|
102
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
103
|
+ String responBirthStr = sdf.format(responBirth);
|
|
|
104
|
+ datas.put("resDateOfBirth", responBirthStr);
|
|
|
105
|
+
|
|
|
106
|
+ }
|
|
|
107
|
+ datas.put("resContactAddress", affiliate.getContactAddress());
|
|
|
108
|
+ nameAgentList.add(affiliate.getNameAgent());
|
|
|
109
|
+ }
|
|
|
110
|
+ }
|
|
|
111
|
+ }
|
|
|
112
|
+ Date createTime = caseApplication1.getCreateTime();
|
|
|
113
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
114
|
+ // 将日期格式化为字符串
|
|
|
115
|
+ String createTimeStr = sdf.format(createTime);
|
|
|
116
|
+ datas.put("submissionDate", createTimeStr);
|
|
|
117
|
+ Date registerDate = caseApplication1.getRegisterDate();
|
|
|
118
|
+ String registerDateStr = sdf.format(registerDate);
|
|
|
119
|
+ datas.put("acceptDate", registerDateStr);
|
|
|
120
|
+ //反请求
|
|
|
121
|
+ Integer adjudicaCounter = caseApplication1.getAdjudicaCounter();
|
|
|
122
|
+ String counterclaim = "在《2022年版仲裁规则》第十八条第(一)项规定的期限内,被申请人向秘书处提交了" +
|
|
|
123
|
+ "《仲裁反请求申请书》及证据材料。仲裁委依据《2022年版仲裁规则》第十八条的规定受理了该仲裁反请求案申请。" +
|
|
|
124
|
+ "仲裁反请求案件受理后,秘书处向被申请人发送了仲裁反请求通知书及附件,向申请人发送了仲裁反请求通知书及附件、仲裁反请求申请书及附件。";
|
|
|
125
|
+ if (adjudicaCounter == null) {
|
|
|
126
|
+ datas.put("counterclaim", null);
|
|
|
127
|
+ } else if (adjudicaCounter == 1) {
|
|
|
128
|
+ datas.put("counterclaim", counterclaim);
|
|
|
129
|
+ } else {
|
|
|
130
|
+ datas.put("counterclaim", null);
|
|
|
131
|
+ }
|
|
|
132
|
+ //财产保全
|
|
|
133
|
+ Integer properPreser = caseApplication1.getProperPreser();
|
|
|
134
|
+ String preservation = "本案受理后,申请人向仲裁委提交了财产保全申请,仲裁委根据《中华人民共和国仲裁法》" +
|
|
|
135
|
+ "第二十八条之规定,将该申请提交至法院。";
|
|
|
136
|
+ if (properPreser == null) {
|
|
|
137
|
+ datas.put("preservation", null);
|
|
|
138
|
+ } else if (properPreser == 1) {
|
|
|
139
|
+ datas.put("preservation", preservation);
|
|
|
140
|
+ } else {
|
|
|
141
|
+ datas.put("preservation", null);
|
|
|
142
|
+ }
|
|
|
143
|
+ //管辖权异议
|
|
|
144
|
+ Integer objectiJuris = caseApplication1.getObjectiJuris();
|
|
|
145
|
+ String jurisdictionalObjection = "本案受理后,被申请人向仲裁委提交了《XX管辖异议申请书》,认为XXXXXX" +
|
|
|
146
|
+ ",仲裁委经审理,当庭驳回了被申请人的管辖异议申请,并告知被申请人具体的事实和理由将在裁决书中一并列明。";
|
|
|
147
|
+ if (objectiJuris == null) {
|
|
|
148
|
+ datas.put("jurisdictionalObjection", null);
|
|
|
149
|
+ } else if (objectiJuris == 1) {
|
|
|
150
|
+ datas.put("jurisdictionalObjection", jurisdictionalObjection);
|
|
|
151
|
+ } else {
|
|
|
152
|
+ datas.put("jurisdictionalObjection", null);
|
|
|
153
|
+ }
|
|
|
154
|
+ String arbitratorName = caseApplication1.getArbitratorName();
|
|
|
155
|
+ datas.put("arbitratorName", arbitratorName);
|
|
|
156
|
+ Integer arbitratMethod = caseApplication1.getArbitratMethod();
|
|
|
157
|
+ Date hearDate = caseApplication1.getHearDate();
|
|
|
158
|
+ if (hearDate != null) {
|
|
|
159
|
+ String hearDateStr = sdf.format(hearDate);
|
|
|
160
|
+ //线上开庭时
|
|
|
161
|
+ if (arbitratMethod == 1) {
|
|
|
162
|
+ String onLine1 = "仲裁庭审阅了申请人提交的仲裁申请书、证据材料后,于";
|
|
|
163
|
+ String onLine2 = "通过仲裁委智慧仲裁平台开庭审理了本案。";
|
|
|
164
|
+ datas.put("onLine1", onLine1);
|
|
|
165
|
+ datas.put("hearDate", hearDateStr);
|
|
|
166
|
+ datas.put("onLine2", onLine2);
|
|
|
167
|
+ } else {
|
|
|
168
|
+ //书面仲裁时
|
|
|
169
|
+ String written1 = "仲裁庭审阅了申请人提交的仲裁申请书、证据材料后,于";
|
|
|
170
|
+ String written2 = "在仲裁委所在地开庭审理了本案。";
|
|
|
171
|
+ datas.put("written1", written1);
|
|
|
172
|
+ datas.put("hearDate1", hearDateStr);
|
|
|
173
|
+ datas.put("written2", written2);
|
|
|
174
|
+ }
|
|
|
175
|
+ }
|
|
|
176
|
+ Integer isAbsence = caseApplication1.getIsAbsence();
|
|
|
177
|
+ if (isAbsence == null) {
|
|
|
178
|
+ datas.put("absent1", null);
|
|
|
179
|
+ datas.put("absent2", null);
|
|
|
180
|
+ datas.put("absent3", null);
|
|
|
181
|
+ datas.put("absent4", null);
|
|
|
182
|
+ datas.put("absent5", null);
|
|
|
183
|
+ datas.put("attend1", null);
|
|
|
184
|
+ datas.put("attend2", null);
|
|
|
185
|
+ datas.put("attend3", null);
|
|
|
186
|
+ datas.put("attend4", null);
|
|
|
187
|
+ datas.put("attend5", null);
|
|
|
188
|
+ datas.put("attend6", null);
|
|
|
189
|
+ datas.put("attend7", null);
|
|
|
190
|
+ datas.put("appAgentName1", null);
|
|
|
191
|
+ datas.put("appAgentName2", null);
|
|
|
192
|
+ datas.put("resAgentName", null);
|
|
|
193
|
+ } else if (isAbsence == 1) {
|
|
|
194
|
+ //缺席审理
|
|
|
195
|
+ String absent1 = "申请人的特别授权委托代理人";
|
|
|
196
|
+ String absent2 = "出席了庭审。被申请人经依法送达开庭通知,无正当理由未出席庭审,故仲裁庭依据" +
|
|
|
197
|
+ "《2022年版仲裁规则》第四十条第(二)项的规定,对本案进行了缺席审理。";
|
|
|
198
|
+ String absent3 = "庭审中,申请人陈述了仲裁请求事项及事实与理由,出示了证据材料并进行了说明," +
|
|
|
199
|
+ "发表了意见,回答了仲裁庭的提问,并作了最后陈述。因被申请人缺席庭审,故仲裁庭无法组织调解。";
|
|
|
200
|
+ String absent4 = "(二/三)当事人提供的证据材料\n" +
|
|
|
201
|
+ "申请人为证明其主张的事实和理由,向仲裁庭提交了如下证据材料:";
|
|
|
202
|
+ String absent5 = "综上,仲裁庭依据《上海仲裁委员会仲裁规则》(2022年7月1日起施行的版本)" +
|
|
|
203
|
+ "第四十条第(二)项、第五十一条的规定,缺席裁决如下:";
|
|
|
204
|
+ datas.put("absent1", absent1);
|
|
|
205
|
+ datas.put("absent2", absent2);
|
|
|
206
|
+ datas.put("absent3", absent3);
|
|
|
207
|
+ datas.put("absent4", absent4);
|
|
|
208
|
+ datas.put("absent5", absent5);
|
|
|
209
|
+ datas.put("appAgentName1", nameAgentList.get(0));
|
|
|
210
|
+ } else {
|
|
|
211
|
+ //出席审理
|
|
|
212
|
+ String attend1 = "申请人的特别授权委托代理人";
|
|
|
213
|
+ String attend2 = "和被申请人本人/的特别授权委托代理人";
|
|
|
214
|
+ String attend3 = "出席了庭审。";
|
|
|
215
|
+ String attend4 = "庭审中,申请人陈述了仲裁请求事项及所依据的事实与理由,被申请人进行了答辩;" +
|
|
|
216
|
+ "双方当事人均出示了证据材料并对对方的证据材料进行了质证;申请人出示了证据材料," +
|
|
|
217
|
+ "被申请人对对方的证据材料进行了质证;双方当事人均回答了仲裁庭的提问,进行了辩论," +
|
|
|
218
|
+ "并分别作了最后陈述。双方当事人在仲裁庭的主持下进行了调解,但未能达成调解协议。";
|
|
|
219
|
+ String attend5 = "(二)被申请人的答辩意见";
|
|
|
220
|
+ String attend6 = "(二/三)当事人提供的证据材料及对方的质证意见\n" +
|
|
|
221
|
+ "申请人为证明其主张的事实和理由,向仲裁庭提交了如下证据材料:";
|
|
|
222
|
+ String attend7 = "被申请人对上述材料的质证意见为:";
|
|
|
223
|
+ datas.put("attend1", attend1);
|
|
|
224
|
+ datas.put("attend2", attend2);
|
|
|
225
|
+ datas.put("attend3", attend3);
|
|
|
226
|
+ datas.put("attend4", attend4);
|
|
|
227
|
+ datas.put("attend5", attend5);
|
|
|
228
|
+ datas.put("attend6", attend6);
|
|
|
229
|
+ datas.put("attend7", attend7);
|
|
|
230
|
+ datas.put("responCrossOpin", caseApplication1.getResponCrossOpin());
|
|
|
231
|
+ datas.put("appAgentName2", nameAgentList.get(0));
|
|
|
232
|
+ datas.put("resAgentName", nameAgentList.get(1));
|
|
|
233
|
+ if (arbitratMethod == 1) {
|
|
|
234
|
+ //被申出席+开庭
|
|
|
235
|
+ String attend8 = "综上,仲裁庭依据《上海仲裁委员会仲裁规则》(2022年7月1日起施行的版本)" +
|
|
|
236
|
+ "第五十一条的规定,裁决如下:";
|
|
|
237
|
+ datas.put("attend8", attend8);
|
|
|
238
|
+ } else {
|
|
|
239
|
+ //被申出席+书面
|
|
|
240
|
+ String attend9 = "综上,仲裁庭依据《上海仲裁委员会仲裁规则》(2022年7月1日起施行的版本)" +
|
|
|
241
|
+ "第五十一条、第五十八条的规定,裁决如下:";
|
|
|
242
|
+ datas.put("attend9", attend9);
|
|
|
243
|
+ }
|
|
|
244
|
+ }
|
|
|
245
|
+ datas.put("claims", caseApplication1.getArbitratClaims());
|
|
|
246
|
+ datas.put("request", caseApplication1.getRequestRule());
|
|
|
247
|
+ //申请人证据材料
|
|
|
248
|
+ datas.put("appEvidenceMaterial", null);
|
|
|
249
|
+ //被申请人证据材料
|
|
|
250
|
+
|
|
|
251
|
+ PictureRenderData pictureRenderData = WordUtil.rebuildImageContent(100, 100, null, "D:\\develop\\Snipaste_2023-10-27_09-59-23.jpg");
|
|
|
252
|
+ datas.put("resEvidenceMaterial", "证据详情可查询附件");
|
|
|
253
|
+ datas.put("applicaCrossOpin", caseApplication1.getApplicaCrossOpin());
|
|
|
254
|
+ if (arbitrateRecord1 != null) {
|
|
|
255
|
+ datas.put("factDetermi", arbitrateRecord1.getFactDetermi());
|
|
|
256
|
+ datas.put("arbitrateThink", arbitrateRecord1.getArbitrateThink());
|
|
|
257
|
+ datas.put("rulingFollows", arbitrateRecord1.getRulingFollows());
|
|
|
258
|
+ }
|
|
|
259
|
+ LocalDate now = LocalDate.now();
|
|
|
260
|
+ String year = Integer.toString(now.getYear());
|
|
|
261
|
+ datas.put("year", year);
|
|
|
262
|
+ String month = String.format("%02d", now.getMonthValue());
|
|
|
263
|
+ String day = String.format("%02d", now.getDayOfMonth());
|
|
|
264
|
+ //String modalFilePath = "/data/arbitrate-document/template/新裁决书模板.docx";
|
|
|
265
|
+ String modalFilePath = "D:/develop/新裁决书模板.docx";
|
|
|
266
|
+ //String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
|
|
|
267
|
+ String saveFolderPath = "D:/data/" + year + "/" + month + "/" + day;
|
|
|
268
|
+ String fileName = UUID.randomUUID().toString().replace("-", "") + ".docx";
|
|
|
269
|
+ String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
|
|
|
270
|
+ String resultFilePath = saveFolderPath + "/" + fileName;
|
|
|
271
|
+ // 创建日期目录
|
|
|
272
|
+ File saveFolder = new File(saveFolderPath);
|
|
|
273
|
+ if (!saveFolder.exists()) {
|
|
|
274
|
+ saveFolder.mkdirs();
|
|
|
275
|
+ }
|
|
|
276
|
+ Path sourcePath = new File(modalFilePath).toPath();
|
|
|
277
|
+ Path destinationPath = new File(resultFilePath).toPath();
|
|
|
278
|
+ Files.copy(sourcePath, destinationPath, StandardCopyOption.REPLACE_EXISTING);
|
|
|
279
|
+ String docFilePath = WordUtil.getDocFilePath(datas, modalFilePath, resultFilePath);
|
|
|
280
|
+ File file = new File(docFilePath);
|
|
|
281
|
+ if (file.exists()) {
|
|
|
282
|
+ InputStream in = new FileInputStream(file);
|
|
|
283
|
+ XWPFDocument xwpfDocument = new XWPFDocument(in);
|
|
|
284
|
+ WordUtil.changeText(xwpfDocument);
|
|
|
285
|
+ }
|
|
|
286
|
+ String savePath = docFilePath.substring(0, docFilePath.indexOf("/upload/") + 8);
|
|
|
287
|
+ CaseAttach caseAttach = CaseAttach.builder()
|
|
|
288
|
+ .caseAppliId(id)
|
|
|
289
|
+ .annexName(saveName)
|
|
|
290
|
+ .annexPath(savePath)
|
|
|
291
|
+ .annexType(3)
|
|
|
292
|
+ .build();
|
|
|
293
|
+ //保存到附件表里,先判断之前有没有,有的话更新,没有的话新增
|
|
|
294
|
+ List<CaseAttach> caseAttachList = caseAttachMapper.getCaseAttachByCaseIdAndType(caseAttach);
|
|
|
295
|
+ if (caseAttachList != null && caseAttachList.size() > 0) {
|
|
|
296
|
+ //之前已经生成过了,更新
|
|
|
297
|
+ int i = caseAttachMapper.updateCaseAttachBycaseid(caseAttach);
|
|
|
298
|
+ } else {
|
|
|
299
|
+ //之前没生成过,新增
|
|
|
300
|
+ int i = caseAttachMapper.save(caseAttach);
|
|
|
301
|
+ if (i > 0) {
|
|
|
302
|
+ if (arbitrateRecord1 != null) {
|
|
|
303
|
+ Integer annexId = caseAttach.getAnnexId();
|
|
|
304
|
+ //将附件id保存到仲裁记录表里面
|
|
|
305
|
+ arbitrateRecord1.setAnnexId(annexId);
|
|
|
306
|
+ arbitrateRecordMapper.updataArbitrateRecord(arbitrateRecord1);
|
|
|
307
|
+ }
|
|
|
308
|
+ }
|
|
|
309
|
+ }
|
|
|
310
|
+ //修改案件状态
|
|
|
311
|
+ caseApplication1.setCaseStatus(CaseApplicationConstants.VERPRIF_ARBITRATION);
|
|
|
312
|
+ caseApplicationMapper.submitCaseApplication(caseApplication1);
|
|
|
313
|
+ return AjaxResult.success("裁决书已生成");
|
|
|
314
|
+ } catch (IOException e) {
|
|
|
315
|
+ return AjaxResult.error(e + "请检查文件路径是否有误");
|
|
|
316
|
+ }
|
|
|
317
|
+ }
|
|
|
318
|
+
|
|
|
319
|
+ public String getNewEquipmentNo() {
|
|
|
320
|
+ Object awardNum = redisCache.getCacheObject("awardNum");
|
|
|
321
|
+ if (awardNum == null) {
|
|
|
322
|
+ redisCache.setCacheObject("awardNum", "00001");
|
|
|
323
|
+ String s = redisCache.getCacheObject("awardNum").toString();
|
|
|
324
|
+ // 字符串数字解析为整数
|
|
|
325
|
+ int no = Integer.parseInt(s);
|
|
|
326
|
+ // 最新设备编号自增1
|
|
|
327
|
+ int newEquipment = ++no;
|
|
|
328
|
+ // 将整数格式化为5位数字
|
|
|
329
|
+ s = String.format("%05d", newEquipment);
|
|
|
330
|
+ redisCache.setCacheObject("awardNum", s);
|
|
|
331
|
+ return s;
|
|
|
332
|
+ } else {
|
|
|
333
|
+ String s = awardNum.toString();
|
|
|
334
|
+ // 字符串数字解析为整数
|
|
|
335
|
+ int no = Integer.parseInt(s);
|
|
|
336
|
+ // 最新设备编号自增1
|
|
|
337
|
+ int newEquipment = ++no;
|
|
|
338
|
+ // 将整数格式化为5位数字
|
|
|
339
|
+ s = String.format("%05d", newEquipment);
|
|
|
340
|
+ redisCache.setCacheObject("awardNum", s);
|
|
|
341
|
+ return s;
|
|
|
342
|
+ }
|
|
|
343
|
+ }
|
|
|
344
|
+
|
|
|
345
|
+ public static void main(String[] args) throws Exception {
|
|
|
346
|
+ // 创建一个新的Word文档
|
|
|
347
|
+ XWPFDocument document = new XWPFDocument();
|
|
|
348
|
+
|
|
|
349
|
+ // 创建一个段落
|
|
|
350
|
+ XWPFParagraph paragraph = document.createParagraph();
|
|
|
351
|
+
|
|
|
352
|
+ // 创建一个文本区域
|
|
|
353
|
+ XWPFRun run = paragraph.createRun();
|
|
|
354
|
+
|
|
|
355
|
+ // 加载图片文件
|
|
|
356
|
+ File imageFile = new File("D:\\develop\\Snipaste_2023-10-27_09-59-23.jpg");
|
|
|
357
|
+ FileInputStream fis = new FileInputStream(imageFile);
|
|
|
358
|
+
|
|
|
359
|
+ // 将图片插入到文档中
|
|
|
360
|
+ run.addPicture(fis, Document.PICTURE_TYPE_JPEG, "image.jpg", Units.toEMU(100), Units.toEMU(100));
|
|
|
361
|
+
|
|
|
362
|
+ // 关闭输入流
|
|
|
363
|
+ fis.close();
|
|
|
364
|
+
|
|
|
365
|
+ // 保存文档
|
|
|
366
|
+ String filePath= "D:\\develop\\"+UUID.randomUUID()+"document.docx";
|
|
|
367
|
+ FileOutputStream fos = new FileOutputStream(filePath);
|
|
|
368
|
+ document.write(fos);
|
|
|
369
|
+ fos.close();
|
|
|
370
|
+ }
|
|
|
371
|
+
|
|
|
372
|
+ }
|