|
|
@@ -1,13 +1,28 @@
|
|
1
|
1
|
package com.huimv.employment.service.registration;
|
|
2
|
2
|
|
|
|
3
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
3
|
4
|
import com.huimv.employment.common.exception.BizException;
|
|
4
|
5
|
import com.huimv.employment.common.exception.ErrorCode;
|
|
5
|
6
|
import com.huimv.employment.dao.entity.FeEmploymentDraft;
|
|
6
|
7
|
import com.huimv.employment.dao.entity.FeEmploymentOrder;
|
|
|
8
|
+import com.huimv.employment.dao.entity.FeEnterprise;
|
|
7
|
9
|
import com.huimv.employment.dao.entity.FeRegistrationBatch;
|
|
|
10
|
+import com.huimv.employment.dao.entity.FeWorkerRegistration;
|
|
|
11
|
+import com.huimv.employment.dao.entity.FeWorkflowDefinition;
|
|
|
12
|
+import com.huimv.employment.dao.entity.FeWorkflowStep;
|
|
|
13
|
+import com.huimv.employment.dao.mapper.FeEmploymentDraftMapper;
|
|
8
|
14
|
import com.huimv.employment.dao.mapper.FeEmploymentOrderMapper;
|
|
9
|
15
|
import com.huimv.employment.dao.mapper.FeRegistrationBatchMapper;
|
|
|
16
|
+import com.huimv.employment.dao.mapper.FeWorkerRegistrationMapper;
|
|
|
17
|
+import com.huimv.employment.dao.mapper.FeWorkflowDefinitionMapper;
|
|
|
18
|
+import com.huimv.employment.dao.mapper.FeWorkflowStepMapper;
|
|
10
|
19
|
import com.huimv.employment.service.config.RegistrationQrProperties;
|
|
|
20
|
+import com.huimv.employment.service.enterprise.EnterpriseService;
|
|
|
21
|
+import com.huimv.employment.service.registration.dto.RegistrationBatchDetailResponse;
|
|
|
22
|
+import com.huimv.employment.service.registration.dto.RegistrationBatchProgressResponse;
|
|
|
23
|
+import com.huimv.employment.service.registration.dto.RegistrationBatchStatsResponse;
|
|
|
24
|
+import com.huimv.employment.service.registration.dto.RegistrationBatchStepResponse;
|
|
|
25
|
+import com.huimv.employment.service.registration.dto.RegistrationBatchWorkerItemResponse;
|
|
11
|
26
|
import com.huimv.employment.service.wechat.WeChatMiniAppService;
|
|
12
|
27
|
import org.slf4j.Logger;
|
|
13
|
28
|
import org.slf4j.LoggerFactory;
|
|
|
@@ -20,11 +35,15 @@ import java.nio.file.Files;
|
|
20
|
35
|
import java.nio.file.Path;
|
|
21
|
36
|
import java.nio.file.Paths;
|
|
22
|
37
|
import java.time.LocalDateTime;
|
|
|
38
|
+import java.time.format.DateTimeFormatter;
|
|
|
39
|
+import java.util.ArrayList;
|
|
|
40
|
+import java.util.Collections;
|
|
|
41
|
+import java.util.List;
|
|
23
|
42
|
import java.util.regex.Pattern;
|
|
24
|
43
|
|
|
25
|
44
|
/**
|
|
26
|
|
- * 方案确认后创建登记批次,并立刻生成小程序码写入 {@code fe_registration_batch.qr_code_url}。
|
|
27
|
|
- * <p>小程序码 scene = 订单编号,page = pages/worker/job-offer(见微信 getwxacodeunlimit)。</p>
|
|
|
45
|
+ * 登记批次:确认方案后创建批次与小程序码;企业端查询进度详情。
|
|
|
46
|
+ * <p>办理流程步骤来自启用中的 {@code fe_workflow_definition} + {@code fe_workflow_step}。</p>
|
|
28
|
47
|
*/
|
|
29
|
48
|
@Service
|
|
30
|
49
|
public class RegistrationBatchService {
|
|
|
@@ -34,20 +53,48 @@ public class RegistrationBatchService {
|
|
34
|
53
|
private static final String STATUS_ACTIVE = "active";
|
|
35
|
54
|
private static final String STEP_REGISTRATION = "registration";
|
|
36
|
55
|
private static final String PUBLIC_PATH_TEMPLATE = "/api/v1/public/registration-qr/%s.png";
|
|
37
|
|
- /** 订单编号 / 文件名安全字符 */
|
|
38
|
56
|
private static final Pattern SAFE_SCENE = Pattern.compile("^[A-Za-z0-9_-]{1,32}$");
|
|
|
57
|
+ private static final Pattern NUMERIC_ID = Pattern.compile("^\\d+$");
|
|
|
58
|
+ private static final DateTimeFormatter STEP_TIME_FMT = DateTimeFormatter.ofPattern("MM-dd HH:mm");
|
|
|
59
|
+
|
|
|
60
|
+ private static final String STEP_STATUS_DONE = "done";
|
|
|
61
|
+ private static final String STEP_STATUS_ACTIVE = "active";
|
|
|
62
|
+ private static final String STEP_STATUS_PENDING = "pending";
|
|
|
63
|
+
|
|
|
64
|
+ private static final String REG_PENDING = "pending";
|
|
|
65
|
+ private static final String REG_REGISTERING = "registering";
|
|
|
66
|
+ private static final String REG_UNDER_REVIEW = "under_review";
|
|
|
67
|
+ private static final String REG_COMPLETED = "completed";
|
|
|
68
|
+ private static final String REG_VERIFY_FAILED = "verify_failed";
|
|
|
69
|
+
|
|
|
70
|
+ private static final String WORKFLOW_CODE_EMPLOYMENT = "employment_compliance";
|
|
39
|
71
|
|
|
40
|
72
|
private final FeRegistrationBatchMapper feRegistrationBatchMapper;
|
|
41
|
73
|
private final FeEmploymentOrderMapper feEmploymentOrderMapper;
|
|
|
74
|
+ private final FeEmploymentDraftMapper feEmploymentDraftMapper;
|
|
|
75
|
+ private final FeWorkerRegistrationMapper feWorkerRegistrationMapper;
|
|
|
76
|
+ private final FeWorkflowDefinitionMapper feWorkflowDefinitionMapper;
|
|
|
77
|
+ private final FeWorkflowStepMapper feWorkflowStepMapper;
|
|
|
78
|
+ private final EnterpriseService enterpriseService;
|
|
42
|
79
|
private final WeChatMiniAppService weChatMiniAppService;
|
|
43
|
80
|
private final RegistrationQrProperties qrProperties;
|
|
44
|
81
|
|
|
45
|
82
|
public RegistrationBatchService(FeRegistrationBatchMapper feRegistrationBatchMapper,
|
|
46
|
83
|
FeEmploymentOrderMapper feEmploymentOrderMapper,
|
|
|
84
|
+ FeEmploymentDraftMapper feEmploymentDraftMapper,
|
|
|
85
|
+ FeWorkerRegistrationMapper feWorkerRegistrationMapper,
|
|
|
86
|
+ FeWorkflowDefinitionMapper feWorkflowDefinitionMapper,
|
|
|
87
|
+ FeWorkflowStepMapper feWorkflowStepMapper,
|
|
|
88
|
+ EnterpriseService enterpriseService,
|
|
47
|
89
|
WeChatMiniAppService weChatMiniAppService,
|
|
48
|
90
|
RegistrationQrProperties qrProperties) {
|
|
49
|
91
|
this.feRegistrationBatchMapper = feRegistrationBatchMapper;
|
|
50
|
92
|
this.feEmploymentOrderMapper = feEmploymentOrderMapper;
|
|
|
93
|
+ this.feEmploymentDraftMapper = feEmploymentDraftMapper;
|
|
|
94
|
+ this.feWorkerRegistrationMapper = feWorkerRegistrationMapper;
|
|
|
95
|
+ this.feWorkflowDefinitionMapper = feWorkflowDefinitionMapper;
|
|
|
96
|
+ this.feWorkflowStepMapper = feWorkflowStepMapper;
|
|
|
97
|
+ this.enterpriseService = enterpriseService;
|
|
51
|
98
|
this.weChatMiniAppService = weChatMiniAppService;
|
|
52
|
99
|
this.qrProperties = qrProperties;
|
|
53
|
100
|
}
|
|
|
@@ -62,7 +109,6 @@ public class RegistrationBatchService {
|
|
62
|
109
|
if (!StringUtils.hasText(order.getOrderNo()) || !SAFE_SCENE.matcher(order.getOrderNo().trim()).matches()) {
|
|
63
|
110
|
throw new BizException(ErrorCode.BAD_REQUEST, "订单编号无效,无法作为小程序码 scene");
|
|
64
|
111
|
}
|
|
65
|
|
- // getwxacodeunlimit.scene = 订单编号(≤32)
|
|
66
|
112
|
String scene = order.getOrderNo().trim();
|
|
67
|
113
|
int validDays = resolveValidDays(draft);
|
|
68
|
114
|
String page = normalizePage(qrProperties.getPage());
|
|
|
@@ -102,6 +148,93 @@ public class RegistrationBatchService {
|
|
102
|
148
|
return feRegistrationBatchMapper.selectById(batch.getId());
|
|
103
|
149
|
}
|
|
104
|
150
|
|
|
|
151
|
+ /**
|
|
|
152
|
+ * 企业端登记进度详情:按草稿 ID 定位订单 → 登记批次。
|
|
|
153
|
+ */
|
|
|
154
|
+ public RegistrationBatchDetailResponse getDetailByDraftId(Long userId, Long draftId) {
|
|
|
155
|
+ FeEnterprise enterprise = enterpriseService.findEnterpriseByUserId(userId);
|
|
|
156
|
+ if (enterprise == null) {
|
|
|
157
|
+ throw new BizException(ErrorCode.NOT_FOUND, "企业信息不存在");
|
|
|
158
|
+ }
|
|
|
159
|
+ if (draftId == null) {
|
|
|
160
|
+ throw new BizException(ErrorCode.BAD_REQUEST, "draft_id 不能为空");
|
|
|
161
|
+ }
|
|
|
162
|
+ FeEmploymentDraft draft = feEmploymentDraftMapper.selectById(draftId);
|
|
|
163
|
+ if (draft == null || !enterprise.getId().equals(draft.getEnterpriseId())) {
|
|
|
164
|
+ throw new BizException(ErrorCode.NOT_FOUND, "草稿不存在");
|
|
|
165
|
+ }
|
|
|
166
|
+ FeEmploymentOrder order = feEmploymentOrderMapper.selectOne(new LambdaQueryWrapper<FeEmploymentOrder>()
|
|
|
167
|
+ .eq(FeEmploymentOrder::getDraftId, draftId)
|
|
|
168
|
+ .orderByDesc(FeEmploymentOrder::getId)
|
|
|
169
|
+ .last("LIMIT 1"));
|
|
|
170
|
+ if (order == null) {
|
|
|
171
|
+ throw new BizException(ErrorCode.NOT_FOUND, "尚未确认方案,暂无登记批次");
|
|
|
172
|
+ }
|
|
|
173
|
+ FeRegistrationBatch batch = feRegistrationBatchMapper.selectOne(new LambdaQueryWrapper<FeRegistrationBatch>()
|
|
|
174
|
+ .eq(FeRegistrationBatch::getOrderId, order.getId())
|
|
|
175
|
+ .orderByDesc(FeRegistrationBatch::getId)
|
|
|
176
|
+ .last("LIMIT 1"));
|
|
|
177
|
+ if (batch == null || !enterprise.getId().equals(batch.getEnterpriseId())) {
|
|
|
178
|
+ throw new BizException(ErrorCode.NOT_FOUND, "登记批次不存在");
|
|
|
179
|
+ }
|
|
|
180
|
+ return toDetailResponse(batch, order, draft);
|
|
|
181
|
+ }
|
|
|
182
|
+
|
|
|
183
|
+ /**
|
|
|
184
|
+ * 企业端登记进度详情:按批次主键 ID 或业务编号(如 bat_1)。
|
|
|
185
|
+ */
|
|
|
186
|
+ public RegistrationBatchDetailResponse getDetail(Long userId, String batchKey) {
|
|
|
187
|
+ FeEnterprise enterprise = enterpriseService.findEnterpriseByUserId(userId);
|
|
|
188
|
+ if (enterprise == null) {
|
|
|
189
|
+ throw new BizException(ErrorCode.NOT_FOUND, "企业信息不存在");
|
|
|
190
|
+ }
|
|
|
191
|
+ FeRegistrationBatch batch = requireOwnedBatch(enterprise.getId(), batchKey);
|
|
|
192
|
+ FeEmploymentOrder order = feEmploymentOrderMapper.selectById(batch.getOrderId());
|
|
|
193
|
+ if (order == null) {
|
|
|
194
|
+ throw new BizException(ErrorCode.NOT_FOUND, "用工订单不存在");
|
|
|
195
|
+ }
|
|
|
196
|
+ FeEmploymentDraft draft = order.getDraftId() != null
|
|
|
197
|
+ ? feEmploymentDraftMapper.selectById(order.getDraftId()) : null;
|
|
|
198
|
+ return toDetailResponse(batch, order, draft);
|
|
|
199
|
+ }
|
|
|
200
|
+
|
|
|
201
|
+ private RegistrationBatchDetailResponse toDetailResponse(FeRegistrationBatch batch,
|
|
|
202
|
+ FeEmploymentOrder order,
|
|
|
203
|
+ FeEmploymentDraft draft) {
|
|
|
204
|
+ List<FeWorkerRegistration> registrations = feWorkerRegistrationMapper.selectList(
|
|
|
205
|
+ new LambdaQueryWrapper<FeWorkerRegistration>()
|
|
|
206
|
+ .eq(FeWorkerRegistration::getBatchId, batch.getId())
|
|
|
207
|
+ .orderByAsc(FeWorkerRegistration::getId));
|
|
|
208
|
+
|
|
|
209
|
+ RegistrationBatchStatsResponse stats = buildStats(batch, registrations);
|
|
|
210
|
+ RegistrationBatchProgressResponse progress = buildProgress(stats);
|
|
|
211
|
+ List<RegistrationBatchStepResponse> steps = buildSteps(order, draft, progress);
|
|
|
212
|
+ List<RegistrationBatchWorkerItemResponse> workers = buildWorkers(registrations);
|
|
|
213
|
+
|
|
|
214
|
+ String title = StringUtils.hasText(order.getTitle()) ? order.getTitle().trim() : "用工批次";
|
|
|
215
|
+ String batchNo = batch.getBatchNo();
|
|
|
216
|
+
|
|
|
217
|
+ RegistrationBatchDetailResponse response = new RegistrationBatchDetailResponse();
|
|
|
218
|
+ response.setBatchId(batch.getId());
|
|
|
219
|
+ response.setBatchNo(batchNo);
|
|
|
220
|
+ response.setTitle(title);
|
|
|
221
|
+ response.setSubtitle(title + (StringUtils.hasText(batchNo) ? " " + batchNo : ""));
|
|
|
222
|
+ response.setOrderId(order.getId());
|
|
|
223
|
+ response.setOrderNo(order.getOrderNo());
|
|
|
224
|
+ response.setStatus(batch.getStatus());
|
|
|
225
|
+ response.setQrCodeUrl(batch.getQrCodeUrl());
|
|
|
226
|
+ response.setRegistrationUrl(batch.getRegistrationUrl());
|
|
|
227
|
+ response.setQrToken(batch.getQrToken());
|
|
|
228
|
+ response.setValidFrom(batch.getValidFrom());
|
|
|
229
|
+ response.setValidUntil(batch.getValidUntil());
|
|
|
230
|
+ response.setCurrentStepCode(order.getCurrentStepCode());
|
|
|
231
|
+ response.setStats(stats);
|
|
|
232
|
+ response.setProgress(progress);
|
|
|
233
|
+ response.setSteps(steps);
|
|
|
234
|
+ response.setWorkers(workers);
|
|
|
235
|
+ return response;
|
|
|
236
|
+ }
|
|
|
237
|
+
|
|
105
|
238
|
/** 按订单编号(scene)读取本地小程序码 PNG;不存在返回 null。 */
|
|
106
|
239
|
public byte[] readQrPng(String scene) {
|
|
107
|
240
|
if (!StringUtils.hasText(scene) || !SAFE_SCENE.matcher(scene.trim()).matches()) {
|
|
|
@@ -119,6 +252,243 @@ public class RegistrationBatchService {
|
|
119
|
252
|
}
|
|
120
|
253
|
}
|
|
121
|
254
|
|
|
|
255
|
+ private FeRegistrationBatch requireOwnedBatch(Long enterpriseId, String batchKey) {
|
|
|
256
|
+ if (!StringUtils.hasText(batchKey)) {
|
|
|
257
|
+ throw new BizException(ErrorCode.BAD_REQUEST, "batch_id 不能为空");
|
|
|
258
|
+ }
|
|
|
259
|
+ String key = batchKey.trim();
|
|
|
260
|
+ FeRegistrationBatch batch = null;
|
|
|
261
|
+ if (NUMERIC_ID.matcher(key).matches()) {
|
|
|
262
|
+ try {
|
|
|
263
|
+ batch = feRegistrationBatchMapper.selectById(Long.parseLong(key));
|
|
|
264
|
+ } catch (NumberFormatException ignored) {
|
|
|
265
|
+ batch = null;
|
|
|
266
|
+ }
|
|
|
267
|
+ }
|
|
|
268
|
+ if (batch == null) {
|
|
|
269
|
+ batch = feRegistrationBatchMapper.selectOne(new LambdaQueryWrapper<FeRegistrationBatch>()
|
|
|
270
|
+ .eq(FeRegistrationBatch::getBatchNo, key)
|
|
|
271
|
+ .orderByDesc(FeRegistrationBatch::getId)
|
|
|
272
|
+ .last("LIMIT 1"));
|
|
|
273
|
+ }
|
|
|
274
|
+ if (batch == null || !enterpriseId.equals(batch.getEnterpriseId())) {
|
|
|
275
|
+ throw new BizException(ErrorCode.NOT_FOUND, "登记批次不存在");
|
|
|
276
|
+ }
|
|
|
277
|
+ return batch;
|
|
|
278
|
+ }
|
|
|
279
|
+
|
|
|
280
|
+ private RegistrationBatchStatsResponse buildStats(FeRegistrationBatch batch,
|
|
|
281
|
+ List<FeWorkerRegistration> registrations) {
|
|
|
282
|
+ int expected = batch.getExpectedCount() != null ? batch.getExpectedCount() : 0;
|
|
|
283
|
+ int completed = 0;
|
|
|
284
|
+ int inProgress = 0;
|
|
|
285
|
+ int abnormal = 0;
|
|
|
286
|
+ int appliedPending = 0;
|
|
|
287
|
+ if (registrations != null) {
|
|
|
288
|
+ for (FeWorkerRegistration reg : registrations) {
|
|
|
289
|
+ String status = reg.getRegStatus();
|
|
|
290
|
+ if (REG_COMPLETED.equals(status)) {
|
|
|
291
|
+ completed++;
|
|
|
292
|
+ } else if (REG_VERIFY_FAILED.equals(status)) {
|
|
|
293
|
+ abnormal++;
|
|
|
294
|
+ } else if (REG_PENDING.equals(status)) {
|
|
|
295
|
+ appliedPending++;
|
|
|
296
|
+ } else {
|
|
|
297
|
+ inProgress++;
|
|
|
298
|
+ }
|
|
|
299
|
+ }
|
|
|
300
|
+ }
|
|
|
301
|
+ int applied = registrations != null ? registrations.size() : 0;
|
|
|
302
|
+ int pending = Math.max(0, expected - applied) + appliedPending;
|
|
|
303
|
+ inProgress = inProgress + abnormal;
|
|
|
304
|
+ if (expected <= 0) {
|
|
|
305
|
+ expected = pending + inProgress + completed;
|
|
|
306
|
+ }
|
|
|
307
|
+ int registered = Math.max(0, expected - pending);
|
|
|
308
|
+
|
|
|
309
|
+ RegistrationBatchStatsResponse stats = new RegistrationBatchStatsResponse();
|
|
|
310
|
+ stats.setPendingCount(pending);
|
|
|
311
|
+ stats.setInProgressCount(inProgress);
|
|
|
312
|
+ stats.setCompletedCount(completed);
|
|
|
313
|
+ stats.setAbnormalCount(abnormal);
|
|
|
314
|
+ stats.setExpectedCount(expected);
|
|
|
315
|
+ stats.setRegisteredCount(registered);
|
|
|
316
|
+ return stats;
|
|
|
317
|
+ }
|
|
|
318
|
+
|
|
|
319
|
+ private RegistrationBatchProgressResponse buildProgress(RegistrationBatchStatsResponse stats) {
|
|
|
320
|
+ int total = stats.getExpectedCount() != null ? stats.getExpectedCount() : 0;
|
|
|
321
|
+ int current = stats.getRegisteredCount() != null ? stats.getRegisteredCount() : 0;
|
|
|
322
|
+ int percent = total > 0 ? (int) Math.round(current * 100.0 / total) : 0;
|
|
|
323
|
+ if (percent > 100) {
|
|
|
324
|
+ percent = 100;
|
|
|
325
|
+ }
|
|
|
326
|
+ RegistrationBatchProgressResponse progress = new RegistrationBatchProgressResponse();
|
|
|
327
|
+ progress.setCurrent(current);
|
|
|
328
|
+ progress.setTotal(total);
|
|
|
329
|
+ progress.setPercent(percent);
|
|
|
330
|
+ return progress;
|
|
|
331
|
+ }
|
|
|
332
|
+
|
|
|
333
|
+ private List<RegistrationBatchStepResponse> buildSteps(FeEmploymentOrder order,
|
|
|
334
|
+ FeEmploymentDraft draft,
|
|
|
335
|
+ RegistrationBatchProgressResponse progress) {
|
|
|
336
|
+ List<FeWorkflowStep> flowSteps = listActiveWorkflowSteps();
|
|
|
337
|
+ if (flowSteps.isEmpty()) {
|
|
|
338
|
+ log.warn("未配置启用的 fe_workflow_step,进度页办理流程为空");
|
|
|
339
|
+ return Collections.emptyList();
|
|
|
340
|
+ }
|
|
|
341
|
+
|
|
|
342
|
+ String currentCode = StringUtils.hasText(order.getCurrentStepCode())
|
|
|
343
|
+ ? order.getCurrentStepCode().trim() : STEP_REGISTRATION;
|
|
|
344
|
+ int currentIndex = indexOfStep(flowSteps, currentCode);
|
|
|
345
|
+ if (currentIndex < 0) {
|
|
|
346
|
+ currentIndex = indexOfStep(flowSteps, STEP_REGISTRATION);
|
|
|
347
|
+ }
|
|
|
348
|
+ if (currentIndex < 0) {
|
|
|
349
|
+ currentIndex = 0;
|
|
|
350
|
+ }
|
|
|
351
|
+
|
|
|
352
|
+ List<RegistrationBatchStepResponse> steps = new ArrayList<>();
|
|
|
353
|
+ for (int i = 0; i < flowSteps.size(); i++) {
|
|
|
354
|
+ FeWorkflowStep def = flowSteps.get(i);
|
|
|
355
|
+ String code = def.getStepCode();
|
|
|
356
|
+ RegistrationBatchStepResponse step = new RegistrationBatchStepResponse();
|
|
|
357
|
+ step.setStepCode(code);
|
|
|
358
|
+ step.setTitle(def.getStepName());
|
|
|
359
|
+ if (i < currentIndex) {
|
|
|
360
|
+ step.setStatus(STEP_STATUS_DONE);
|
|
|
361
|
+ step.setTime(resolveStepTime(code, draft, order));
|
|
|
362
|
+ } else if (i == currentIndex) {
|
|
|
363
|
+ step.setStatus(STEP_STATUS_ACTIVE);
|
|
|
364
|
+ if (STEP_REGISTRATION.equals(code) && progress != null) {
|
|
|
365
|
+ step.setHighlight(String.format("进行中 %d/%d",
|
|
|
366
|
+ progress.getCurrent() != null ? progress.getCurrent() : 0,
|
|
|
367
|
+ progress.getTotal() != null ? progress.getTotal() : 0));
|
|
|
368
|
+ }
|
|
|
369
|
+ } else {
|
|
|
370
|
+ step.setStatus(STEP_STATUS_PENDING);
|
|
|
371
|
+ }
|
|
|
372
|
+ steps.add(step);
|
|
|
373
|
+ }
|
|
|
374
|
+ return steps;
|
|
|
375
|
+ }
|
|
|
376
|
+
|
|
|
377
|
+ /**
|
|
|
378
|
+ * 读取当前启用合规流程下的步骤定义(按 step_order 升序)。
|
|
|
379
|
+ */
|
|
|
380
|
+ private List<FeWorkflowStep> listActiveWorkflowSteps() {
|
|
|
381
|
+ FeWorkflowDefinition definition = feWorkflowDefinitionMapper.selectOne(
|
|
|
382
|
+ new LambdaQueryWrapper<FeWorkflowDefinition>()
|
|
|
383
|
+ .eq(FeWorkflowDefinition::getWorkflowCode, WORKFLOW_CODE_EMPLOYMENT)
|
|
|
384
|
+ .eq(FeWorkflowDefinition::getIsActive, Boolean.TRUE)
|
|
|
385
|
+ .orderByDesc(FeWorkflowDefinition::getVersion)
|
|
|
386
|
+ .last("LIMIT 1"));
|
|
|
387
|
+ if (definition == null) {
|
|
|
388
|
+ // 兼容初始化脚本未显式筛选时:取 employment_compliance 最新版
|
|
|
389
|
+ definition = feWorkflowDefinitionMapper.selectOne(
|
|
|
390
|
+ new LambdaQueryWrapper<FeWorkflowDefinition>()
|
|
|
391
|
+ .eq(FeWorkflowDefinition::getWorkflowCode, WORKFLOW_CODE_EMPLOYMENT)
|
|
|
392
|
+ .orderByDesc(FeWorkflowDefinition::getVersion)
|
|
|
393
|
+ .last("LIMIT 1"));
|
|
|
394
|
+ }
|
|
|
395
|
+ if (definition == null) {
|
|
|
396
|
+ definition = feWorkflowDefinitionMapper.selectOne(
|
|
|
397
|
+ new LambdaQueryWrapper<FeWorkflowDefinition>()
|
|
|
398
|
+ .eq(FeWorkflowDefinition::getIsActive, Boolean.TRUE)
|
|
|
399
|
+ .orderByDesc(FeWorkflowDefinition::getVersion)
|
|
|
400
|
+ .last("LIMIT 1"));
|
|
|
401
|
+ }
|
|
|
402
|
+ if (definition == null) {
|
|
|
403
|
+ return Collections.emptyList();
|
|
|
404
|
+ }
|
|
|
405
|
+ List<FeWorkflowStep> steps = feWorkflowStepMapper.selectList(
|
|
|
406
|
+ new LambdaQueryWrapper<FeWorkflowStep>()
|
|
|
407
|
+ .eq(FeWorkflowStep::getWorkflowId, definition.getId())
|
|
|
408
|
+ .orderByAsc(FeWorkflowStep::getStepOrder)
|
|
|
409
|
+ .orderByAsc(FeWorkflowStep::getId));
|
|
|
410
|
+ return steps != null ? steps : Collections.<FeWorkflowStep>emptyList();
|
|
|
411
|
+ }
|
|
|
412
|
+
|
|
|
413
|
+ private static int indexOfStep(List<FeWorkflowStep> flowSteps, String stepCode) {
|
|
|
414
|
+ if (!StringUtils.hasText(stepCode) || flowSteps == null) {
|
|
|
415
|
+ return -1;
|
|
|
416
|
+ }
|
|
|
417
|
+ for (int i = 0; i < flowSteps.size(); i++) {
|
|
|
418
|
+ if (stepCode.equals(flowSteps.get(i).getStepCode())) {
|
|
|
419
|
+ return i;
|
|
|
420
|
+ }
|
|
|
421
|
+ }
|
|
|
422
|
+ return -1;
|
|
|
423
|
+ }
|
|
|
424
|
+
|
|
|
425
|
+ private static String resolveStepTime(String stepCode, FeEmploymentDraft draft, FeEmploymentOrder order) {
|
|
|
426
|
+ LocalDateTime time = null;
|
|
|
427
|
+ if ("draft_created".equals(stepCode) && draft != null) {
|
|
|
428
|
+ time = draft.getCreateTime();
|
|
|
429
|
+ } else if ("plan_confirmed".equals(stepCode)) {
|
|
|
430
|
+ if (draft != null && draft.getConfirmedAt() != null) {
|
|
|
431
|
+ time = draft.getConfirmedAt();
|
|
|
432
|
+ } else if (order != null) {
|
|
|
433
|
+ time = order.getCreateTime();
|
|
|
434
|
+ }
|
|
|
435
|
+ }
|
|
|
436
|
+ return time != null ? STEP_TIME_FMT.format(time) : null;
|
|
|
437
|
+ }
|
|
|
438
|
+
|
|
|
439
|
+ private List<RegistrationBatchWorkerItemResponse> buildWorkers(List<FeWorkerRegistration> registrations) {
|
|
|
440
|
+ List<RegistrationBatchWorkerItemResponse> workers = new ArrayList<>();
|
|
|
441
|
+ if (registrations == null) {
|
|
|
442
|
+ return workers;
|
|
|
443
|
+ }
|
|
|
444
|
+ for (FeWorkerRegistration reg : registrations) {
|
|
|
445
|
+ RegistrationBatchWorkerItemResponse item = new RegistrationBatchWorkerItemResponse();
|
|
|
446
|
+ item.setRegistrationId(reg.getId());
|
|
|
447
|
+ item.setWorkerId(reg.getWorkerId());
|
|
|
448
|
+ item.setRealName(reg.getRealName());
|
|
|
449
|
+ item.setMobileMask(reg.getMobileMask());
|
|
|
450
|
+ item.setRegStatus(reg.getRegStatus());
|
|
|
451
|
+ item.setStatusTag(toStatusTag(reg.getRegStatus()));
|
|
|
452
|
+ item.setStatusText(toStatusText(reg.getRegStatus()));
|
|
|
453
|
+ item.setFailReason(reg.getFailReason());
|
|
|
454
|
+ item.setSubmittedAt(reg.getSubmittedAt());
|
|
|
455
|
+ workers.add(item);
|
|
|
456
|
+ }
|
|
|
457
|
+ return workers;
|
|
|
458
|
+ }
|
|
|
459
|
+
|
|
|
460
|
+ private static String toStatusTag(String regStatus) {
|
|
|
461
|
+ if (REG_COMPLETED.equals(regStatus)) {
|
|
|
462
|
+ return "done";
|
|
|
463
|
+ }
|
|
|
464
|
+ if (REG_VERIFY_FAILED.equals(regStatus)) {
|
|
|
465
|
+ return "fail";
|
|
|
466
|
+ }
|
|
|
467
|
+ if (REG_UNDER_REVIEW.equals(regStatus)) {
|
|
|
468
|
+ return "review";
|
|
|
469
|
+ }
|
|
|
470
|
+ if (REG_REGISTERING.equals(regStatus)) {
|
|
|
471
|
+ return "registering";
|
|
|
472
|
+ }
|
|
|
473
|
+ return "pending";
|
|
|
474
|
+ }
|
|
|
475
|
+
|
|
|
476
|
+ private static String toStatusText(String regStatus) {
|
|
|
477
|
+ if (REG_COMPLETED.equals(regStatus)) {
|
|
|
478
|
+ return "已完成";
|
|
|
479
|
+ }
|
|
|
480
|
+ if (REG_VERIFY_FAILED.equals(regStatus)) {
|
|
|
481
|
+ return "核验失败";
|
|
|
482
|
+ }
|
|
|
483
|
+ if (REG_UNDER_REVIEW.equals(regStatus)) {
|
|
|
484
|
+ return "审核中";
|
|
|
485
|
+ }
|
|
|
486
|
+ if (REG_REGISTERING.equals(regStatus)) {
|
|
|
487
|
+ return "登记中";
|
|
|
488
|
+ }
|
|
|
489
|
+ return "待登记";
|
|
|
490
|
+ }
|
|
|
491
|
+
|
|
122
|
492
|
private void attachQrCode(FeRegistrationBatch batch, String scene, LocalDateTime now) {
|
|
123
|
493
|
try {
|
|
124
|
494
|
byte[] png;
|