|
|
@@ -22,6 +22,7 @@ import com.huimv.employment.service.draft.dto.DraftConfirmResponse;
|
|
22
|
22
|
import com.huimv.employment.service.draft.dto.DraftDetailResponse;
|
|
23
|
23
|
import com.huimv.employment.service.draft.dto.DraftFieldResponse;
|
|
24
|
24
|
import com.huimv.employment.service.draft.dto.DraftUpdateRequest;
|
|
|
25
|
+import com.huimv.employment.service.draft.dto.DraftWithCostComparisonResponse;
|
|
25
|
26
|
import com.huimv.employment.service.draft.dto.McpDraftCalculateResponse;
|
|
26
|
27
|
import com.huimv.employment.service.enterprise.EnterpriseService;
|
|
27
|
28
|
import com.huimv.employment.service.conversation.ConversationService;
|
|
|
@@ -179,12 +180,13 @@ public class DraftService {
|
|
179
|
180
|
}
|
|
180
|
181
|
|
|
181
|
182
|
/**
|
|
182
|
|
- * 按会话查询其下全部草稿的成本测算结果。
|
|
183
|
|
- * <p>返回元素结构与 {@link #calculateCostComparison} / {@code GET .../drafts/{id}/cost-comparison} 相同。
|
|
184
|
|
- * 字段不足以测算的草稿跳过,不中断整次查询。</p>
|
|
|
183
|
+ * 按会话查询其下全部草稿信息,并附带成本测算。
|
|
|
184
|
+ * <p>外层为草稿详情;{@code cost_comparison} 与
|
|
|
185
|
+ * {@link #calculateCostComparison} / {@code GET .../drafts/{id}/cost-comparison} 实体相同。
|
|
|
186
|
+ * 无法测算时 {@code cost_comparison} 为 null,草稿本身仍返回。</p>
|
|
185
|
187
|
*/
|
|
186
|
188
|
@Transactional(rollbackFor = Exception.class)
|
|
187
|
|
- public List<McpDraftCalculateResponse> listCostComparisonsByConversation(Long userId, Long conversationId) {
|
|
|
189
|
+ public List<DraftWithCostComparisonResponse> listCostComparisonsByConversation(Long userId, Long conversationId) {
|
|
188
|
190
|
conversationService.requireOwned(userId, conversationId);
|
|
189
|
191
|
FeEnterprise enterprise = enterpriseService.findEnterpriseByUserId(userId);
|
|
190
|
192
|
if (enterprise == null) {
|
|
|
@@ -195,12 +197,14 @@ public class DraftService {
|
|
195
|
197
|
.eq(FeEmploymentDraft::getConversationId, conversationId)
|
|
196
|
198
|
.eq(FeEmploymentDraft::getEnterpriseId, enterprise.getId())
|
|
197
|
199
|
.orderByAsc(FeEmploymentDraft::getId));
|
|
198
|
|
- List<McpDraftCalculateResponse> result = new ArrayList<>();
|
|
|
200
|
+ List<DraftWithCostComparisonResponse> result = new ArrayList<>();
|
|
199
|
201
|
if (drafts == null || drafts.isEmpty()) {
|
|
200
|
202
|
return result;
|
|
201
|
203
|
}
|
|
202
|
204
|
LocalDateTime now = LocalDateTime.now();
|
|
203
|
205
|
for (FeEmploymentDraft draft : drafts) {
|
|
|
206
|
+ DraftDetailResponse detail = toDetail(draft, listFields(draft.getId()));
|
|
|
207
|
+ DraftWithCostComparisonResponse item = copyToWithCost(detail);
|
|
204
|
208
|
try {
|
|
205
|
209
|
List<DraftCostCalculationEngine.CalculatedScheme> schemes =
|
|
206
|
210
|
draftCostCalculationEngine.calculate(draft);
|
|
|
@@ -208,16 +212,55 @@ public class DraftService {
|
|
208
|
212
|
persistCostSnapshots(draft, schemes);
|
|
209
|
213
|
updateDraftEstimates(draft, schemes, now);
|
|
210
|
214
|
}
|
|
211
|
|
- McpDraftCalculateResponse response = draftCostCalculationEngine.toApiResponse(schemes);
|
|
212
|
|
- response.setDraftId(draft.getId());
|
|
213
|
|
- result.add(response);
|
|
|
215
|
+ McpDraftCalculateResponse cost = draftCostCalculationEngine.toApiResponse(schemes);
|
|
|
216
|
+ cost.setDraftId(draft.getId());
|
|
|
217
|
+ item.setCostComparison(cost);
|
|
214
|
218
|
} catch (BizException ignored) {
|
|
215
|
|
- // 草稿不完整或无法测算时跳过
|
|
|
219
|
+ item.setCostComparison(null);
|
|
216
|
220
|
}
|
|
|
221
|
+ result.add(item);
|
|
217
|
222
|
}
|
|
218
|
223
|
return result;
|
|
219
|
224
|
}
|
|
220
|
225
|
|
|
|
226
|
+ private static DraftWithCostComparisonResponse copyToWithCost(DraftDetailResponse source) {
|
|
|
227
|
+ DraftWithCostComparisonResponse target = new DraftWithCostComparisonResponse();
|
|
|
228
|
+ target.setId(source.getId());
|
|
|
229
|
+ target.setDraftNo(source.getDraftNo());
|
|
|
230
|
+ target.setEnterpriseId(source.getEnterpriseId());
|
|
|
231
|
+ target.setUserId(source.getUserId());
|
|
|
232
|
+ target.setConversationId(source.getConversationId());
|
|
|
233
|
+ target.setScenario(source.getScenario());
|
|
|
234
|
+ target.setTitle(source.getTitle());
|
|
|
235
|
+ target.setStatus(source.getStatus());
|
|
|
236
|
+ target.setWorkerCount(source.getWorkerCount());
|
|
|
237
|
+ target.setWorkDays(source.getWorkDays());
|
|
|
238
|
+ target.setWorkType(source.getWorkType());
|
|
|
239
|
+ target.setWorkContent(source.getWorkContent());
|
|
|
240
|
+ target.setWorkLocation(source.getWorkLocation());
|
|
|
241
|
+ target.setWorkLocationSource(source.getWorkLocationSource());
|
|
|
242
|
+ target.setSettlementMode(source.getSettlementMode());
|
|
|
243
|
+ target.setDailyWage(source.getDailyWage());
|
|
|
244
|
+ target.setInsuranceRequired(source.getInsuranceRequired());
|
|
|
245
|
+ target.setInsuranceLevel(source.getInsuranceLevel());
|
|
|
246
|
+ target.setCheckInRequired(source.getCheckInRequired());
|
|
|
247
|
+ target.setQrValidDays(source.getQrValidDays());
|
|
|
248
|
+ target.setWorkStartDate(source.getWorkStartDate());
|
|
|
249
|
+ target.setWorkEndDate(source.getWorkEndDate());
|
|
|
250
|
+ target.setJobRequirements(source.getJobRequirements());
|
|
|
251
|
+ target.setMissingFields(source.getMissingFields());
|
|
|
252
|
+ target.setRiskPrompts(source.getRiskPrompts());
|
|
|
253
|
+ target.setEstimatedTotal(source.getEstimatedTotal());
|
|
|
254
|
+ target.setEstimatedPerCapita(source.getEstimatedPerCapita());
|
|
|
255
|
+ target.setSelectedPlanId(source.getSelectedPlanId());
|
|
|
256
|
+ target.setQrCodeUrl(source.getQrCodeUrl());
|
|
|
257
|
+ target.setQrToken(source.getQrToken());
|
|
|
258
|
+ target.setFields(source.getFields());
|
|
|
259
|
+ target.setCreateTime(source.getCreateTime());
|
|
|
260
|
+ target.setUpdateTime(source.getUpdateTime());
|
|
|
261
|
+ return target;
|
|
|
262
|
+ }
|
|
|
263
|
+
|
|
221
|
264
|
/**
|
|
222
|
265
|
* 微信端确认此方案:选定 SCHEME_A/SCHEME_B,转正式订单。
|
|
223
|
266
|
* <p>若尚未测算,将自动先测算再确认。</p>
|