|
|
@@ -7,15 +7,14 @@ import com.alibaba.fastjson.JSONObject;
|
|
7
|
7
|
import com.deepoove.poi.data.PictureRenderData;
|
|
8
|
8
|
import com.ruoyi.common.constant.CaseApplicationConstants;
|
|
9
|
9
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
10
|
+import com.ruoyi.common.core.domain.entity.SysDictData;
|
|
10
|
11
|
import com.ruoyi.common.core.redis.RedisCache;
|
|
11
|
|
-import com.ruoyi.common.utils.DateUtils;
|
|
12
|
|
-import com.ruoyi.common.utils.SmsUtils;
|
|
|
12
|
+import com.ruoyi.common.utils.*;
|
|
|
13
|
+import com.ruoyi.system.mapper.SysDictDataMapper;
|
|
13
|
14
|
import com.ruoyi.wisdomarbitrate.domain.vo.BookSendVO;
|
|
14
|
15
|
import com.ruoyi.wisdomarbitrate.domain.vo.ColumnValue;
|
|
15
|
16
|
import com.ruoyi.wisdomarbitrate.mapper.*;
|
|
16
|
17
|
import com.ruoyi.wisdomarbitrate.utils.CaseLogUtils;
|
|
17
|
|
-import com.ruoyi.common.utils.EmailOutUtil;
|
|
18
|
|
-import com.ruoyi.common.utils.WordUtil;
|
|
19
|
18
|
import com.ruoyi.wisdomarbitrate.domain.*;
|
|
20
|
19
|
import com.ruoyi.wisdomarbitrate.domain.vo.ArchivesDetailVO;
|
|
21
|
20
|
import com.ruoyi.wisdomarbitrate.domain.vo.LogisticsInfoVO;
|
|
|
@@ -49,6 +48,7 @@ import java.text.NumberFormat;
|
|
49
|
48
|
import java.text.SimpleDateFormat;
|
|
50
|
49
|
import java.time.LocalDate;
|
|
51
|
50
|
import java.util.*;
|
|
|
51
|
+import java.util.function.Function;
|
|
52
|
52
|
import java.util.regex.Matcher;
|
|
53
|
53
|
import java.util.regex.Pattern;
|
|
54
|
54
|
import java.util.stream.Collectors;
|
|
|
@@ -84,6 +84,11 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
|
|
84
|
84
|
private TemplateManageMapper templateManageMapper;
|
|
85
|
85
|
@Autowired
|
|
86
|
86
|
private ColumnValueMapper columnValueMapper;
|
|
|
87
|
+ @Autowired
|
|
|
88
|
+ private FatchRuleMapper fatchRuleMapper;
|
|
|
89
|
+ @Autowired
|
|
|
90
|
+ private SysDictDataMapper dictDataMapper;
|
|
|
91
|
+
|
|
87
|
92
|
// 仲裁反请求模板内容
|
|
88
|
93
|
private final String counterclaim= "在《2022年版仲裁规则》第十八条第(一)项规定的期限内,被申请人向秘书处提交了" +
|
|
89
|
94
|
"《仲裁反请求申请书》及证据材料。仲裁委依据《2022年版仲裁规则》第十八条的规定受理了该仲裁反请求案申请。" +
|
|
|
@@ -123,251 +128,418 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
|
|
123
|
128
|
// 被申请人缺席
|
|
124
|
129
|
String resAbsent="(二)当事人提供的证据材料\n" +
|
|
125
|
130
|
"申请人为证明其主张的事实和理由,向仲裁庭提交了如下证据材料:\n{{applicantFile}}";
|
|
|
131
|
+ // 日期格式化年月日
|
|
|
132
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
|
|
126
|
133
|
@Override
|
|
127
|
134
|
@Transactional
|
|
128
|
135
|
public AjaxResult createDocument(CaseApplication caseApplicationReq) {
|
|
129
|
|
- String templatePath="";
|
|
130
|
|
- String templateName="";
|
|
131
|
|
- String agentName="";
|
|
132
|
|
- String resName="";
|
|
|
136
|
+ String templatePath = "";
|
|
|
137
|
+ String templateName = "";
|
|
|
138
|
+ String agentName = "";
|
|
|
139
|
+ String resName = "";
|
|
133
|
140
|
try {
|
|
134
|
141
|
Map<String, Object> datas = new HashMap<>();
|
|
135
|
142
|
Long id = caseApplicationReq.getId();
|
|
136
|
|
- if (id == null) {
|
|
137
|
|
- return AjaxResult.error("案件id不能为空");
|
|
138
|
|
- }
|
|
139
|
|
-
|
|
140
|
143
|
//获取案件详细信息
|
|
141
|
144
|
CaseApplication caseApplicationById = caseApplicationService.selectCaseApplication(caseApplicationReq);
|
|
142
|
|
-
|
|
143
|
|
- if(caseApplicationById==null){
|
|
|
145
|
+ if (caseApplicationById == null) {
|
|
144
|
146
|
return AjaxResult.error("案件不存在");
|
|
145
|
147
|
}
|
|
|
148
|
+
|
|
|
149
|
+ if (caseApplicationById.getTemplateId() == null) {
|
|
|
150
|
+ return AjaxResult.error("请先指定裁决书模板");
|
|
|
151
|
+ }
|
|
146
|
152
|
// 根据模板id查找对应的模板
|
|
147
|
|
- if(caseApplicationById.getTemplateId()!=null) {
|
|
148
|
|
- TemplateManage templateManage = new TemplateManage();
|
|
149
|
|
- templateManage.setId(caseApplicationById.getTemplateId());
|
|
150
|
|
- List<TemplateManage> templateManages = templateManageMapper.selectTemplateList(templateManage);
|
|
151
|
|
- if(CollectionUtil.isEmpty(templateManages)){
|
|
152
|
|
- return AjaxResult.error("请先指定裁决书模板");
|
|
153
|
|
- }
|
|
154
|
|
- templatePath=templateManages.get(0).getTemOrigPath();
|
|
155
|
|
- templateName=templateManages.get(0).getFileName();
|
|
|
153
|
+ TemplateManage templateManage = new TemplateManage();
|
|
|
154
|
+ templateManage.setId(caseApplicationById.getTemplateId());
|
|
|
155
|
+ List<TemplateManage> templateManages = templateManageMapper.selectTemplateList(templateManage);
|
|
|
156
|
+ if (CollectionUtil.isEmpty(templateManages)) {
|
|
|
157
|
+ return AjaxResult.error("请先指定裁决书模板");
|
|
156
|
158
|
}
|
|
|
159
|
+ templatePath = templateManages.get(0).getTemOrigPath();
|
|
|
160
|
+ templateName = templateManages.get(0).getFileName();
|
|
|
161
|
+ // 查询案件相关表信息
|
|
|
162
|
+ CaseAffiliate caseAffiliate = new CaseAffiliate();
|
|
|
163
|
+ caseAffiliate.setCaseAppliId(id);
|
|
|
164
|
+ List<CaseAffiliate> caseAffiliates = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate);
|
|
157
|
165
|
//获取仲裁记录表里的相关信息
|
|
158
|
166
|
ArbitrateRecord arbitrateRecord = new ArbitrateRecord();
|
|
159
|
167
|
arbitrateRecord.setCaseAppliId(id);
|
|
160
|
168
|
ArbitrateRecord arbitrateRecordSelect = arbitrateRecordMapper.selectArbitrateRecord(arbitrateRecord);
|
|
|
169
|
+ // 在系统表中查询案件内置字段
|
|
|
170
|
+ SysDictData sysDictData = new SysDictData();
|
|
|
171
|
+ sysDictData.setDictType("case_built_type");
|
|
|
172
|
+ List<SysDictData> dictDataList = dictDataMapper.selectDictDataList(sysDictData);
|
|
|
173
|
+ // 根据模板id查询抓取规则,判断从主表取值还是从columnValue值取
|
|
|
174
|
+ List<FatchRule> fatchRuleList = fatchRuleMapper.listByTemplateId(caseApplicationById.getTemplateId());
|
|
|
175
|
+ // 抓取规则,0-内置字段,1-自定义字段
|
|
|
176
|
+ Map<Integer, List<FatchRule>> fatchRuleMap = new HashMap<>();
|
|
|
177
|
+ // 裁决书需要的字段和内容,占位符需要配置成中文
|
|
|
178
|
+ Map<String, String> valueMap = new HashMap<>();
|
|
|
179
|
+ // 如果未设置抓取规则,则从主表取数据,设置内置字段值
|
|
|
180
|
+ if (CollectionUtil.isNotEmpty(fatchRuleList)) {
|
|
|
181
|
+ fatchRuleMap = fatchRuleList.stream().collect(Collectors.groupingBy(FatchRule::getIsDefault));
|
|
|
182
|
+ }
|
|
|
183
|
+ // 自定义字段,从columnValue值取
|
|
|
184
|
+ if (fatchRuleMap.size()>0&&fatchRuleMap.containsKey(1)) {
|
|
|
185
|
+ // 根据案件id查询key-value表
|
|
|
186
|
+ List<ColumnValue> columnValueList = columnValueMapper.listByCaseId(caseApplicationReq.getId());
|
|
|
187
|
+ if (CollectionUtil.isNotEmpty(columnValueList)) {
|
|
|
188
|
+ columnValueList.forEach(columnValue -> valueMap.put(columnValue.getName(), columnValue.getValue()));
|
|
|
189
|
+ }
|
|
|
190
|
+ }
|
|
|
191
|
+ // 组装内置字段,在主表中查出内容
|
|
|
192
|
+ buildDefaultColumnValue(dictDataList,caseAffiliates,valueMap,caseApplicationById);
|
|
161
|
193
|
|
|
162
|
|
- // todo 获取模板中的所有占位符,该占位符字段必须和抓取字段一致,暂时写死
|
|
163
|
|
- // todo 生成裁决书的内容从key-value表中取,不从案件基本信息表取,会有问题,如果修改的话会有问题,暂不考虑该情况
|
|
164
|
|
-
|
|
165
|
|
- // 根据案件id查询key-value表
|
|
166
|
|
- List<ColumnValue> columnValueList = columnValueMapper.listByCaseId(caseApplicationReq.getId());
|
|
167
|
194
|
// 获取模板中的占位符key
|
|
168
|
195
|
List<String> bookmarkList = getBookmarkByDocx(templatePath);
|
|
169
|
|
- if(CollectionUtil.isEmpty(bookmarkList)){
|
|
|
196
|
+ if (CollectionUtil.isEmpty(bookmarkList)) {
|
|
170
|
197
|
// 直接保存模板为裁决书
|
|
171
|
|
- saveArbitorFile(id,templateName,templatePath,caseApplicationById,arbitrateRecordSelect);
|
|
|
198
|
+ saveArbitorFile(id, templateName, templatePath, caseApplicationById, arbitrateRecordSelect);
|
|
172
|
199
|
return AjaxResult.success("生成裁决书成功");
|
|
173
|
200
|
}
|
|
174
|
|
- // 如果该表没值,在从主表填充裁决书模板
|
|
175
|
|
- if(CollectionUtil.isNotEmpty(columnValueList)){
|
|
176
|
|
- Map<String, String> columnValueMap = columnValueList.stream().collect(Collectors.toMap(ColumnValue::getColumn, ColumnValue::getValue));
|
|
177
|
|
- agentName=columnValueMap.get("agentName");
|
|
178
|
|
- resName=columnValueMap.get("respondentName");
|
|
179
|
|
- resName=columnValueMap.get("respondentName");
|
|
180
|
|
- // 懒得if,暂时这样
|
|
181
|
|
- //
|
|
182
|
|
- for (String bookmark : bookmarkList) {
|
|
183
|
|
- if(columnValueMap.containsKey(bookmark)){
|
|
184
|
|
- if(bookmark.equals("resSex")){
|
|
185
|
|
- String responSex = columnValueMap.get(bookmark);
|
|
186
|
|
- if (responSex.equals("0")) {
|
|
187
|
|
- datas.put(bookmark, "男");
|
|
188
|
|
- } else {
|
|
189
|
|
- datas.put(bookmark, "女");
|
|
190
|
|
- }
|
|
191
|
|
- }else {
|
|
192
|
|
- datas.put(bookmark, columnValueMap.get(bookmark));
|
|
193
|
|
- }
|
|
194
|
|
- }
|
|
195
|
|
- }
|
|
196
|
|
- }else {
|
|
197
|
|
-
|
|
198
|
|
- }
|
|
|
201
|
+ // 遍历书签,给书签赋值
|
|
|
202
|
+ replaceBookmark(bookmarkList,datas,valueMap);
|
|
|
203
|
+ // 根据条件替换书签
|
|
|
204
|
+ conditionReplaceBookmark(caseApplicationById,datas,agentName,resName,arbitrateRecordSelect);
|
|
199
|
205
|
// 裁决书生成时间
|
|
200
|
206
|
LocalDate now = LocalDate.now();
|
|
201
|
207
|
String year = Integer.toString(now.getYear());
|
|
202
|
|
- datas.put("year", year);
|
|
|
208
|
+ datas.put("裁决书生成时间", year);
|
|
203
|
209
|
//生成编码
|
|
204
|
210
|
String equipmentNo = getNewEquipmentNo();
|
|
205
|
211
|
// 裁决书编号
|
|
206
|
|
- datas.put("num", equipmentNo);
|
|
|
212
|
+ datas.put("裁决书编号", equipmentNo);
|
|
|
213
|
+ // 仲裁费
|
|
|
214
|
+ datas.put("仲裁费", caseApplicationById.getFeePayable().toString());
|
|
207
|
215
|
// 案件创建时间
|
|
208
|
216
|
Date createTime = caseApplicationById.getCreateTime();
|
|
209
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
|
|
210
|
217
|
// 将日期格式化为字符串
|
|
211
|
218
|
String createTimeStr = sdf.format(createTime);
|
|
212
|
|
- datas.put("submissionDate", createTimeStr);
|
|
|
219
|
+ datas.put("案件创建时间", createTimeStr);
|
|
213
|
220
|
// 立案日期
|
|
214
|
221
|
Date registerDate = caseApplicationById.getRegisterDate();
|
|
215
|
222
|
String registerDateStr = sdf.format(registerDate);
|
|
216
|
|
- datas.put("acceptDate", registerDateStr);
|
|
|
223
|
+ datas.put("立案日期", registerDateStr);
|
|
217
|
224
|
|
|
218
|
|
- // 如果有仲裁反请求,该字段设置值
|
|
219
|
|
- Integer adjudicaCounter = caseApplicationById.getAdjudicaCounter();
|
|
220
|
|
- if (adjudicaCounter!=null&&adjudicaCounter == 1) {
|
|
221
|
|
- datas.put("counterclaim", counterclaim);
|
|
222
|
|
- }
|
|
223
|
|
- //财产保全
|
|
224
|
|
- Integer properPreser = caseApplicationById.getProperPreser();
|
|
225
|
|
- if (properPreser!=null&&properPreser == 1) {
|
|
226
|
|
- datas.put("preservation", preservation);
|
|
227
|
|
- }
|
|
228
|
|
- //管辖权异议
|
|
229
|
|
- Integer objectiJuris = caseApplicationById.getObjectiJuris();
|
|
230
|
|
- if (objectiJuris!=null&&objectiJuris == 1) {
|
|
231
|
|
- datas.put("jurisdictionalObjection", jurisdictionalObjection);
|
|
232
|
|
- }
|
|
233
|
225
|
|
|
234
|
|
- // 出席庭审人员角色名称
|
|
235
|
|
- String attendName="秘书、";
|
|
236
|
|
- boolean isAbsenceFlag = caseApplicationById.getIsAbsence() != null && caseApplicationById.getIsAbsence().equals(0);
|
|
237
|
|
- boolean appIsAbsenceFlag = caseApplicationById.getAppliIsAbsen() != null && caseApplicationById.getAppliIsAbsen().equals(0);
|
|
238
|
|
- if(isAbsenceFlag||appIsAbsenceFlag){
|
|
239
|
|
- if(isAbsenceFlag) {
|
|
240
|
|
- attendName += "申请代理人" + agentName+"、";
|
|
241
|
|
- }
|
|
242
|
|
- if(appIsAbsenceFlag) {
|
|
243
|
|
- attendName += "被申请人" + resName;
|
|
244
|
|
- }
|
|
245
|
|
- if(attendName.endsWith("、")){
|
|
246
|
|
- agentName=attendName.replace("、","");
|
|
247
|
|
- }
|
|
248
|
|
- }
|
|
|
226
|
+ String month = String.format("%02d", now.getMonthValue());
|
|
|
227
|
+ String day = String.format("%02d", now.getDayOfMonth());
|
|
|
228
|
+ // todo
|
|
|
229
|
+// String modalFilePath = "/data/arbitrate-document/template/新裁决书模板.docx";
|
|
|
230
|
+ // todo
|
|
|
231
|
+// String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
|
|
|
232
|
+ String saveFolderPath = "D:/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
|
|
|
233
|
+ String fileName = UUID.randomUUID().toString().replace("-", "") + ".docx";
|
|
|
234
|
+ // todo
|
|
|
235
|
+// String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
|
|
|
236
|
+ String saveName = "D:/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day + "/" + fileName;
|
|
|
237
|
+ // 将word中的标签替换掉,生成新的word
|
|
|
238
|
+ String docFilePath = wordChangeText(templatePath,datas,saveFolderPath,fileName);
|
|
249
|
239
|
|
|
250
|
|
- // 仲裁员名称
|
|
251
|
|
- datas.put("arbitratorName", caseApplicationById.getArbitratorName());
|
|
252
|
|
- // 审理方式
|
|
253
|
|
- Integer arbitratMethod = caseApplicationById.getArbitratMethod();
|
|
254
|
|
- Date hearDate = caseApplicationById.getHearDate();
|
|
255
|
|
- if (hearDate != null) {
|
|
256
|
|
- // 审理日期
|
|
257
|
|
- String hearDateStr = sdf.format(hearDate);
|
|
258
|
|
- datas.put("hearDate",hearDateStr);
|
|
259
|
|
- // todo 线上仲裁/线下仲裁方式未选择
|
|
260
|
|
- //线上开庭时
|
|
261
|
|
- if (arbitratMethod == 1) {
|
|
262
|
|
- String replace = onLine.replace(onLineDate, Optional.ofNullable(hearDateStr).orElse(""));
|
|
263
|
|
- datas.put("onLine", replace);
|
|
|
240
|
+ String savePath = docFilePath.substring(0, docFilePath.indexOf("/upload/") + 8);
|
|
|
241
|
+ // 保存裁决书附件
|
|
|
242
|
+ saveArbitorFile(id, saveName, savePath, caseApplicationById, arbitrateRecordSelect);
|
|
264
|
243
|
|
|
265
|
|
- } else {
|
|
266
|
|
- //书面仲裁时
|
|
267
|
|
- String replace = written.replace(writtenDate, Optional.ofNullable(hearDateStr).orElse(""));
|
|
268
|
|
- datas.put("written", replace);
|
|
|
244
|
+ return AjaxResult.success("裁决书已生成");
|
|
|
245
|
+ } catch (IOException e) {
|
|
|
246
|
+ return AjaxResult.error(e + "请检查文件路径是否有误");
|
|
|
247
|
+ }
|
|
|
248
|
+ }
|
|
269
|
249
|
|
|
270
|
|
- }
|
|
|
250
|
+ /**
|
|
|
251
|
+ * 将word中的标签替换掉,生成新的word
|
|
|
252
|
+ * @param modalFilePath 裁决书模板路径
|
|
|
253
|
+ * @param datas 替换标签的内容
|
|
|
254
|
+ * @param saveFolderPath 保存路径
|
|
|
255
|
+ * @param fileName 保存文件名
|
|
|
256
|
+ * @return
|
|
|
257
|
+ * @throws IOException
|
|
|
258
|
+ */
|
|
|
259
|
+ private String wordChangeText(String modalFilePath, Map<String, Object> datas, String saveFolderPath,String fileName) throws IOException {
|
|
|
260
|
+ String resultFilePath = saveFolderPath + "/" + fileName;
|
|
|
261
|
+ // 创建日期目录
|
|
|
262
|
+ File saveFolder = new File(saveFolderPath);
|
|
|
263
|
+ if (!saveFolder.exists()) {
|
|
|
264
|
+ saveFolder.mkdirs();
|
|
|
265
|
+ }
|
|
|
266
|
+ Path sourcePath = new File(modalFilePath).toPath();
|
|
|
267
|
+ Path destinationPath = new File(resultFilePath).toPath();
|
|
|
268
|
+ Files.copy(sourcePath, destinationPath, StandardCopyOption.REPLACE_EXISTING);
|
|
|
269
|
+ String docFilePath = WordUtil.getDocFilePath(datas, modalFilePath, resultFilePath);
|
|
|
270
|
+ File file = new File(docFilePath);
|
|
|
271
|
+ if (file.exists()) {
|
|
|
272
|
+ InputStream in = new FileInputStream(file);
|
|
|
273
|
+ XWPFDocument xwpfDocument = new XWPFDocument(in);
|
|
|
274
|
+ WordUtil.changeText(xwpfDocument);
|
|
|
275
|
+ }
|
|
|
276
|
+ return docFilePath;
|
|
|
277
|
+ }
|
|
|
278
|
+
|
|
|
279
|
+ /**
|
|
|
280
|
+ * 根据条件判断裁决书中是否需要该内容
|
|
|
281
|
+ * @param caseApplicationById 案件信息
|
|
|
282
|
+ * @param datas 替换标签值
|
|
|
283
|
+ * @param agentName 代理人名称
|
|
|
284
|
+ * @param resName 被申请人名称
|
|
|
285
|
+ * @param arbitrateRecordSelect 仲裁记录
|
|
|
286
|
+ */
|
|
|
287
|
+ private void conditionReplaceBookmark(CaseApplication caseApplicationById, Map<String, Object> datas,String agentName,String resName, ArbitrateRecord arbitrateRecordSelect ) {
|
|
|
288
|
+ // 如果有仲裁反请求,该字段设置值
|
|
|
289
|
+ Integer adjudicaCounter = caseApplicationById.getAdjudicaCounter();
|
|
|
290
|
+ if (adjudicaCounter != null && adjudicaCounter == 1) {
|
|
|
291
|
+ datas.put("仲裁反请求", counterclaim);
|
|
|
292
|
+ }
|
|
|
293
|
+ //财产保全
|
|
|
294
|
+ Integer properPreser = caseApplicationById.getProperPreser();
|
|
|
295
|
+ if (properPreser != null && properPreser == 1) {
|
|
|
296
|
+ datas.put("财产保全", preservation);
|
|
|
297
|
+ }
|
|
|
298
|
+ //管辖权异议
|
|
|
299
|
+ Integer objectiJuris = caseApplicationById.getObjectiJuris();
|
|
|
300
|
+ if (objectiJuris != null && objectiJuris == 1) {
|
|
|
301
|
+ datas.put("管辖权异议", jurisdictionalObjection);
|
|
|
302
|
+ }
|
|
|
303
|
+
|
|
|
304
|
+ // 出席庭审人员角色名称
|
|
|
305
|
+ String attendName = "秘书、";
|
|
|
306
|
+ boolean isAbsenceFlag = caseApplicationById.getIsAbsence() != null && caseApplicationById.getIsAbsence().equals(0);
|
|
|
307
|
+ boolean appIsAbsenceFlag = caseApplicationById.getAppliIsAbsen() != null && caseApplicationById.getAppliIsAbsen().equals(0);
|
|
|
308
|
+ if (isAbsenceFlag || appIsAbsenceFlag) {
|
|
|
309
|
+ if (isAbsenceFlag) {
|
|
|
310
|
+ attendName += "申请代理人" + agentName + "、";
|
|
271
|
311
|
}
|
|
|
312
|
+ if (appIsAbsenceFlag) {
|
|
|
313
|
+ attendName += "被申请人" + resName;
|
|
|
314
|
+ }
|
|
|
315
|
+ if (attendName.endsWith("、")) {
|
|
|
316
|
+ attendName = attendName.replace("、", "");
|
|
|
317
|
+ }
|
|
|
318
|
+ datas.put("出席庭审人员", attendName);
|
|
|
319
|
+ }
|
|
|
320
|
+
|
|
|
321
|
+ // 仲裁员名称
|
|
|
322
|
+ datas.put("仲裁员姓名", caseApplicationById.getArbitratorName());
|
|
|
323
|
+ // 审理方式
|
|
|
324
|
+ Integer arbitratMethod = caseApplicationById.getArbitratMethod();
|
|
|
325
|
+ Date hearDate = caseApplicationById.getHearDate();
|
|
|
326
|
+ String hearDateStr = "";
|
|
|
327
|
+ if (hearDate != null) {
|
|
|
328
|
+ // 审理日期
|
|
|
329
|
+ hearDateStr = sdf.format(hearDate);
|
|
|
330
|
+ datas.put("审理日期", hearDateStr);
|
|
|
331
|
+ }
|
|
|
332
|
+ // todo 线上仲裁/线下仲裁方式未选择
|
|
|
333
|
+ //线上开庭时+线上仲裁
|
|
|
334
|
+ if (arbitratMethod!=null&&arbitratMethod == 1) {
|
|
|
335
|
+ String replace = onLine.replace(onLineDate, Optional.of(hearDateStr).orElse(""));
|
|
|
336
|
+ datas.put("线上开庭并线上仲裁", replace);
|
|
272
|
337
|
// 所有附件
|
|
273
|
338
|
List<CaseAttach> caseAttachList = caseApplicationById.getCaseAttachList();
|
|
274
|
|
- Map<Integer, List<CaseAttach>> caseAttachMap=new HashMap<>();
|
|
275
|
|
- if(caseAttachList!=null&&caseAttachList.size()>0){
|
|
|
339
|
+ Map<Integer, List<CaseAttach>> caseAttachMap = new HashMap<>();
|
|
|
340
|
+ if (caseAttachList != null && caseAttachList.size() > 0) {
|
|
276
|
341
|
caseAttachMap = caseAttachList.stream().collect(Collectors.groupingBy(CaseAttach::getAnnexType));
|
|
277
|
342
|
}
|
|
278
|
343
|
// 被申请人是否缺席
|
|
279
|
344
|
Integer isAbsence = caseApplicationById.getIsAbsence();
|
|
280
|
|
- // 线上开庭
|
|
281
|
|
- if (arbitratMethod == 1) {
|
|
282
|
|
- if (isAbsence != null && isAbsence == 1) {
|
|
283
|
|
- // 被申请人缺席
|
|
284
|
|
- String absentReplace = absent.replace("{{agentName}}", Optional.ofNullable(agentName).orElse(""));
|
|
285
|
|
- datas.put("absent",absentReplace);
|
|
286
|
|
- // 被申请人缺席
|
|
287
|
|
- String resAbsentReplace=resAbsent;
|
|
288
|
|
- if(caseAttachMap!=null && CollectionUtil.isNotEmpty(caseAttachMap.get(2))){
|
|
289
|
|
- List<CaseAttach> caseAttaches = caseAttachMap.get(2);
|
|
|
345
|
+ if (isAbsence != null && isAbsence == 1) {
|
|
|
346
|
+ // 被申请人缺席,开庭+缺席审理
|
|
|
347
|
+ String absentReplace = absent.replace("{{agentName}}", Optional.of(agentName).orElse(""));
|
|
|
348
|
+
|
|
|
349
|
+ // 被申请人缺席
|
|
|
350
|
+ String resAbsentReplace = resAbsent;
|
|
|
351
|
+ if (caseAttachMap != null && CollectionUtil.isNotEmpty(caseAttachMap.get(2))) {
|
|
|
352
|
+ List<CaseAttach> caseAttaches = caseAttachMap.get(2);
|
|
|
353
|
+ StringBuilder stringBuilder = new StringBuilder();
|
|
|
354
|
+ for (CaseAttach caseAttach : caseAttaches) {
|
|
|
355
|
+ stringBuilder.append(caseAttach.getAnnexName()).append("\n");
|
|
|
356
|
+ }
|
|
|
357
|
+ resAbsentReplace = resAttendOpinion.replace("{{applicantFile}}", stringBuilder.toString());
|
|
|
358
|
+ }
|
|
|
359
|
+ datas.put("开庭并缺席", absentReplace + resAbsentReplace);
|
|
|
360
|
+ } else {
|
|
|
361
|
+ // 被申出席
|
|
|
362
|
+ String attendReplace = attend.replace("{{agentName}}", Optional.ofNullable(agentName).orElse(""));
|
|
|
363
|
+ datas.put("开庭并出席", attendReplace);
|
|
|
364
|
+ // 被申请人证据
|
|
|
365
|
+ if (caseAttachMap != null && CollectionUtil.isNotEmpty(caseAttachMap.get(6))) {
|
|
|
366
|
+ // 开庭+出席+被申提供证据
|
|
|
367
|
+
|
|
|
368
|
+ // 开庭+出席+被申提供证据
|
|
|
369
|
+ String resFileReplace = resFile;
|
|
|
370
|
+ if (CollectionUtil.isNotEmpty(caseAttachMap.get(6))) {
|
|
|
371
|
+ List<CaseAttach> caseAttaches = caseAttachMap.get(6);
|
|
290
|
372
|
StringBuilder stringBuilder = new StringBuilder();
|
|
291
|
373
|
for (CaseAttach caseAttach : caseAttaches) {
|
|
292
|
374
|
stringBuilder.append(caseAttach.getAnnexName()).append("\n");
|
|
293
|
375
|
}
|
|
294
|
|
- resAbsentReplace = resAttendOpinion.replace("{{applicantFile}}", stringBuilder.toString());
|
|
|
376
|
+ resFileReplace = resFile.replace("{{resFile}}", stringBuilder.toString()).replace("{{applicantOpinion}}", (arbitrateRecordSelect == null || arbitrateRecordSelect.getApplicantOpinion() == null ? "" : arbitrateRecordSelect.getApplicantOpinion()));
|
|
295
|
377
|
}
|
|
296
|
|
- datas.put("resAbsent",resAbsentReplace);
|
|
|
378
|
+ datas.put("开庭并出席并被申提供证据", onLineAttendFile + resFileReplace);
|
|
297
|
379
|
} else {
|
|
298
|
|
- // 出席
|
|
299
|
|
- String attendReplace = attend.replace("{{agentName}}", Optional.ofNullable(agentName).orElse(""));
|
|
300
|
|
- datas.put("attend",attend);
|
|
301
|
|
- // 被申请人证据
|
|
302
|
|
- if(caseAttachMap!=null && CollectionUtil.isNotEmpty(caseAttachMap.get(6))){
|
|
303
|
|
- // 开庭+出席+被申提供证据
|
|
304
|
|
- datas.put("onLineAttendFile",onLineAttendFile);
|
|
305
|
|
- // 被申请人出席+被申请人提供了资料
|
|
306
|
|
- String resFileRplace=resFile;
|
|
307
|
|
- if(caseAttachMap!=null && CollectionUtil.isNotEmpty(caseAttachMap.get(6))){
|
|
308
|
|
- List<CaseAttach> caseAttaches = caseAttachMap.get(6);
|
|
309
|
|
- StringBuilder stringBuilder = new StringBuilder();
|
|
310
|
|
- for (CaseAttach caseAttach : caseAttaches) {
|
|
311
|
|
- stringBuilder.append(caseAttach.getAnnexName()).append("\n");
|
|
312
|
|
- }
|
|
313
|
|
- resFileRplace = resFile.replace("{{resFile}}", stringBuilder.toString()).replace("{{applicantOpinion}}", Optional.ofNullable(arbitrateRecordSelect.getApplicantOpinion()).orElse(""));
|
|
314
|
|
- }
|
|
315
|
|
- datas.put("resFile",resFileRplace);
|
|
316
|
|
- }else {
|
|
317
|
|
- // 开庭+出席+被申未提供证据
|
|
318
|
|
- datas.put("onLineAttend",onLineAttend);
|
|
|
380
|
+ // 开庭+出席+被申未提供证据
|
|
|
381
|
+ datas.put("开庭并出席并被申未提供证据", onLineAttend);
|
|
|
382
|
+ }
|
|
|
383
|
+ // 被申请人出席答辩意见
|
|
|
384
|
+ String resAttendOpinionReplace = resAttendOpinion;
|
|
|
385
|
+ if (caseAttachMap != null && CollectionUtil.isNotEmpty(caseAttachMap.get(2))) {
|
|
|
386
|
+ List<CaseAttach> caseAttaches = caseAttachMap.get(2);
|
|
|
387
|
+ StringBuilder stringBuilder = new StringBuilder();
|
|
|
388
|
+ for (CaseAttach caseAttach : caseAttaches) {
|
|
|
389
|
+ stringBuilder.append(caseAttach.getAnnexName()).append("\n");
|
|
319
|
390
|
}
|
|
320
|
|
- // 被申请人出席答辩意见
|
|
321
|
|
- String resAttendOpinionReplace=resAttendOpinion;
|
|
322
|
|
- if(caseAttachMap!=null && CollectionUtil.isNotEmpty(caseAttachMap.get(2))){
|
|
323
|
|
- List<CaseAttach> caseAttaches = caseAttachMap.get(2);
|
|
324
|
|
- StringBuilder stringBuilder = new StringBuilder();
|
|
325
|
|
- for (CaseAttach caseAttach : caseAttaches) {
|
|
326
|
|
- stringBuilder.append(caseAttach.getAnnexName()).append("\n");
|
|
327
|
|
- }
|
|
328
|
|
- resAttendOpinionReplace = resAttendOpinion.replace("{{applicantFile}}", stringBuilder.toString()).replace("{{respondentOpinion}}", arbitrateRecordSelect.getRespondentOpinion()==null?"":arbitrateRecordSelect.getRespondentOpinion());
|
|
|
391
|
+ resAttendOpinionReplace = resAttendOpinion.replace("{{applicantFile}}", stringBuilder.toString()).replace("{{respondentOpinion}}", (arbitrateRecordSelect == null || arbitrateRecordSelect.getRespondentOpinion() == null) ? "" : arbitrateRecordSelect.getRespondentOpinion());
|
|
|
392
|
+ }
|
|
|
393
|
+
|
|
|
394
|
+ datas.put("被申请人出席答辩意见", resAttendOpinionReplace);
|
|
|
395
|
+ }
|
|
|
396
|
+
|
|
|
397
|
+ } else {
|
|
|
398
|
+ //书面仲裁时
|
|
|
399
|
+ String replace = written.replace(writtenDate, Optional.of(hearDateStr).orElse(""));
|
|
|
400
|
+ datas.put("书面仲裁", replace);
|
|
|
401
|
+
|
|
|
402
|
+ }
|
|
|
403
|
+
|
|
|
404
|
+ }
|
|
|
405
|
+
|
|
|
406
|
+ /**
|
|
|
407
|
+ * 给模板中的占位符赋值
|
|
|
408
|
+ * @param bookmarkList 书签
|
|
|
409
|
+ * @param datas 书签赋值
|
|
|
410
|
+ * @param valueMap 案件内容
|
|
|
411
|
+ */
|
|
|
412
|
+ private void replaceBookmark(List<String> bookmarkList, Map<String, Object> datas, Map<String, String> valueMap) {
|
|
|
413
|
+ for (String bookmark : bookmarkList) {
|
|
|
414
|
+ if (valueMap.containsKey(bookmark)) {
|
|
|
415
|
+ if (bookmark.equals("仲裁请求")) {
|
|
|
416
|
+ // 请求仲裁庭裁决
|
|
|
417
|
+ String arbitratClaims = valueMap.get(bookmark);
|
|
|
418
|
+ if (StrUtil.isNotEmpty(arbitratClaims)) {
|
|
|
419
|
+ String replace = arbitratClaims.replace("甲方", "被申请人").replace("乙方", "申请人");
|
|
|
420
|
+ datas.put(bookmark, replace);
|
|
|
421
|
+
|
|
|
422
|
+ } else {
|
|
|
423
|
+ datas.put(bookmark, "");
|
|
329
|
424
|
}
|
|
|
425
|
+ } else if (bookmark.equals("本案事实")) {
|
|
|
426
|
+ // 查询本案事实如下
|
|
|
427
|
+ String mediationAgreement = valueMap.get(bookmark);
|
|
|
428
|
+ if (StrUtil.isNotEmpty(mediationAgreement)) {
|
|
|
429
|
+ String replace = mediationAgreement.replace("甲方", "被申请人").replace("乙方", "申请人");
|
|
|
430
|
+ datas.put(bookmark, replace);
|
|
330
|
431
|
|
|
331
|
|
- datas.put("resAttendOpinion",resAttendOpinionReplace);
|
|
|
432
|
+ } else {
|
|
|
433
|
+ datas.put(bookmark, "");
|
|
|
434
|
+ }
|
|
|
435
|
+ } else {
|
|
|
436
|
+ datas.put(bookmark, valueMap.get(bookmark));
|
|
332
|
437
|
}
|
|
333
|
438
|
}
|
|
|
439
|
+ }
|
|
|
440
|
+ }
|
|
334
|
441
|
|
|
|
442
|
+ /**
|
|
|
443
|
+ * 组装案件内置字段值,即主表和相关人员表信息
|
|
|
444
|
+ * @param dictDataList 内置字段
|
|
|
445
|
+ * @param caseAffiliates 关联人员
|
|
|
446
|
+ * @param valueMap 组装的值
|
|
|
447
|
+ */
|
|
|
448
|
+ private void buildDefaultColumnValue(List<SysDictData> dictDataList, List<CaseAffiliate> caseAffiliates, Map<String, String> valueMap, CaseApplication caseApplication) {
|
|
|
449
|
+ if (CollectionUtil.isNotEmpty(dictDataList)) {
|
|
|
450
|
+ Map<Integer, CaseAffiliate> affiliateMap = caseAffiliates.stream().collect(Collectors.toMap(CaseAffiliate::getIdentityType, Function.identity(), (n1, n2) -> n2));
|
|
|
451
|
+ for (SysDictData dictData : dictDataList) {
|
|
|
452
|
+ if (StrUtil.isNotEmpty(dictData.getDictLabel())) {
|
|
|
453
|
+ if (dictData.getDictLabel().contains("被申请人")) {
|
|
|
454
|
+ CaseAffiliate affiliate = affiliateMap.get(2);
|
|
|
455
|
+ if (affiliate == null) {
|
|
|
456
|
+ continue;
|
|
|
457
|
+ }
|
|
|
458
|
+ // 被申请人
|
|
|
459
|
+ switch (dictData.getDictLabel()) {
|
|
|
460
|
+ case "被申请人姓名":
|
|
|
461
|
+ valueMap.put(dictData.getDictLabel(), affiliate.getName());
|
|
|
462
|
+ break;
|
|
|
463
|
+ case "被申请人身份证号":
|
|
|
464
|
+ valueMap.put(dictData.getDictLabel(), affiliate.getIdentityNum());
|
|
|
465
|
+ break;
|
|
|
466
|
+ case "被申请人住所":
|
|
|
467
|
+ valueMap.put(dictData.getDictLabel(), affiliate.getResidenAffili());
|
|
|
468
|
+ break;
|
|
|
469
|
+ case "被申请人联系电话":
|
|
|
470
|
+ valueMap.put(dictData.getDictLabel(), affiliate.getContactTelphone());
|
|
|
471
|
+ break;
|
|
|
472
|
+ case "被申请人电子邮件":
|
|
|
473
|
+ valueMap.put(dictData.getDictLabel(), affiliate.getEmail());
|
|
|
474
|
+ break;
|
|
|
475
|
+ case "被申请人性别":
|
|
|
476
|
+ if (dictData.getDictLabel().equals("被申请人性别")) {
|
|
|
477
|
+ String responSex = affiliate.getResponSex();
|
|
|
478
|
+ if (responSex.equals("0")) {
|
|
|
479
|
+ valueMap.put(dictData.getDictLabel(), "男");
|
|
|
480
|
+ } else {
|
|
|
481
|
+ valueMap.put(dictData.getDictLabel(), "女");
|
|
|
482
|
+ }
|
|
|
483
|
+ }
|
|
|
484
|
+ break;
|
|
|
485
|
+ case "被申请人出生年月日":
|
|
|
486
|
+ Date responBirth = affiliate.getResponBirth();
|
|
|
487
|
+ if (responBirth != null) {
|
|
|
488
|
+ valueMap.put(dictData.getDictLabel(), sdf.format(responBirth));
|
|
|
489
|
+ } else {
|
|
|
490
|
+ valueMap.put(dictData.getDictLabel(), "");
|
|
|
491
|
+ }
|
|
|
492
|
+ break;
|
|
|
493
|
+ default:
|
|
|
494
|
+ break;
|
|
|
495
|
+ }
|
|
|
496
|
+ } else if (dictData.getDictLabel().contains("申请人") || dictData.getDictLabel().contains("统一社会信用代码")
|
|
|
497
|
+ || dictData.getDictLabel().contains("法定代表人") || dictData.getDictLabel().contains("法定代表人职位")
|
|
|
498
|
+ || dictData.getDictLabel().contains("代理人")) {
|
|
|
499
|
+ CaseAffiliate affiliate = affiliateMap.get(1);
|
|
|
500
|
+ if (affiliate == null) {
|
|
|
501
|
+ continue;
|
|
|
502
|
+ }
|
|
|
503
|
+ // 申请人
|
|
|
504
|
+ switch (dictData.getDictLabel()) {
|
|
|
505
|
+ case "申请人姓名":
|
|
|
506
|
+ valueMap.put(dictData.getDictLabel(), affiliate.getName());
|
|
|
507
|
+ break;
|
|
|
508
|
+ case "统一社会信用代码":
|
|
|
509
|
+ valueMap.put(dictData.getDictLabel(), affiliate.getIdentityNum());
|
|
|
510
|
+ break;
|
|
|
511
|
+ case "法定代表人":
|
|
|
512
|
+ valueMap.put(dictData.getDictLabel(), affiliate.getCompLegalPerson());
|
|
|
513
|
+ break;
|
|
|
514
|
+ case "法定代表人职位":
|
|
|
515
|
+ valueMap.put(dictData.getDictLabel(), affiliate.getCompLegalperPost());
|
|
|
516
|
+ break;
|
|
|
517
|
+ case "申请人住所":
|
|
|
518
|
+ valueMap.put(dictData.getDictLabel(), affiliate.getResidenAffili());
|
|
|
519
|
+ break;
|
|
|
520
|
+ case "申请人联系地址":
|
|
|
521
|
+ valueMap.put(dictData.getDictLabel(), affiliate.getContactAddress());
|
|
|
522
|
+ break;
|
|
|
523
|
+ case "委托代理人姓名":
|
|
|
524
|
+ valueMap.put(dictData.getDictLabel(), affiliate.getNameAgent());
|
|
|
525
|
+ break;
|
|
|
526
|
+ case "委托代理人联系电话":
|
|
|
527
|
+ valueMap.put(dictData.getDictLabel(), affiliate.getContactTelphoneAgent());
|
|
|
528
|
+ break;
|
|
|
529
|
+ case "委托代理人电子邮件":
|
|
|
530
|
+ valueMap.put(dictData.getDictLabel(), affiliate.getAgentEmail());
|
|
|
531
|
+ break;
|
|
|
532
|
+ default:
|
|
|
533
|
+ break;
|
|
|
534
|
+ }
|
|
|
535
|
+ }else {
|
|
|
536
|
+ valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(caseApplication, dictData.getDictValue()));
|
|
|
537
|
+ }
|
|
|
538
|
+ }else {
|
|
|
539
|
+ valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(caseApplication, dictData.getDictValue()));
|
|
|
540
|
+ }
|
|
335
|
541
|
|
|
336
|
|
- String month = String.format("%02d", now.getMonthValue());
|
|
337
|
|
- String day = String.format("%02d", now.getDayOfMonth());
|
|
338
|
|
- // todo
|
|
339
|
|
-// String modalFilePath = "/data/arbitrate-document/template/新裁决书模板.docx";
|
|
340
|
|
- String modalFilePath = templatePath;
|
|
341
|
|
- // todo
|
|
342
|
|
-// String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
|
|
343
|
|
- String saveFolderPath = "D:/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
|
|
344
|
|
- String fileName = UUID.randomUUID().toString().replace("-", "") + ".docx";
|
|
345
|
|
- // todo
|
|
346
|
|
-// String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
|
|
347
|
|
- String saveName = "D:/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day + "/" + fileName;
|
|
348
|
|
- String resultFilePath = saveFolderPath + "/" + fileName;
|
|
349
|
|
- // 创建日期目录
|
|
350
|
|
- File saveFolder = new File(saveFolderPath);
|
|
351
|
|
- if (!saveFolder.exists()) {
|
|
352
|
|
- saveFolder.mkdirs();
|
|
353
|
|
- }
|
|
354
|
|
- Path sourcePath = new File(modalFilePath).toPath();
|
|
355
|
|
- Path destinationPath = new File(resultFilePath).toPath();
|
|
356
|
|
- Files.copy(sourcePath, destinationPath, StandardCopyOption.REPLACE_EXISTING);
|
|
357
|
|
- String docFilePath = WordUtil.getDocFilePath(datas, modalFilePath, resultFilePath);
|
|
358
|
|
- File file = new File(docFilePath);
|
|
359
|
|
- if (file.exists()) {
|
|
360
|
|
- InputStream in = new FileInputStream(file);
|
|
361
|
|
- XWPFDocument xwpfDocument = new XWPFDocument(in);
|
|
362
|
|
- WordUtil.changeText(xwpfDocument);
|
|
363
|
542
|
}
|
|
364
|
|
- String savePath = docFilePath.substring(0, docFilePath.indexOf("/upload/") + 8);
|
|
365
|
|
- // 保存裁决书附件
|
|
366
|
|
- saveArbitorFile(id,saveName,savePath,caseApplicationById,arbitrateRecordSelect);
|
|
367
|
|
-
|
|
368
|
|
- return AjaxResult.success("裁决书已生成");
|
|
369
|
|
- } catch (IOException e) {
|
|
370
|
|
- return AjaxResult.error(e + "请检查文件路径是否有误");
|
|
371
|
543
|
}
|
|
372
|
544
|
}
|
|
373
|
545
|
|