소스 검색

增加与ai大模型对话

wwh 2 주 전
부모
커밋
38b0598e2a

+ 6 - 6
huimv-employment/fe-api/src/main/java/com/huimv/employment/controller/mp/ConversationController.java

@@ -14,7 +14,7 @@ import com.huimv.employment.service.conversation.dto.ConversationCreateRequest;
14 14
 import com.huimv.employment.service.conversation.dto.ConversationMessagePageResponse;
15 15
 import com.huimv.employment.service.conversation.dto.ConversationSummaryResponse;
16 16
 import com.huimv.employment.service.draft.DraftService;
17
-import com.huimv.employment.service.draft.dto.McpDraftCalculateResponse;
17
+import com.huimv.employment.service.draft.dto.DraftWithCostComparisonResponse;
18 18
 import com.huimv.employment.service.order.EmploymentOrderService;
19 19
 import com.huimv.employment.service.order.dto.EmploymentOrderItemResponse;
20 20
 import com.huimv.employment.service.registration.RegistrationBatchService;
@@ -125,11 +125,11 @@ public class ConversationController {
125 125
      * 查询指定会话下全部草稿的成本测算(方案对比)。
126 126
      */
127 127
     @GetMapping("/{id}/drafts/cost-comparison")
128
-    @Operation(summary = "按会话查询全部草稿成本测算",
129
-            description = "返回该会话下可测算草稿的方案对比列表;"
130
-                    + "每个元素结构与 GET /api/v1/mp/drafts/{id}/cost-comparison 一致(含 draft_id、schemes)。"
131
-                    + "字段不完整无法测算的草稿自动跳过。仅可查询本企业用户自己的会话。")
132
-    public R<List<McpDraftCalculateResponse>> listDraftCostComparisons(
128
+    @Operation(summary = "按会话查询全部草稿成本测算",
129
+            description = "返回该会话下全部草稿信息;每条草稿内嵌 cost_comparison,"
130
+                    + "结构与 GET /api/v1/mp/drafts/{id}/cost-comparison 一致。"
131
+                    + "无法测算时 cost_comparison 为 null。仅可查询本企业用户自己的会话。")
132
+    public R<List<DraftWithCostComparisonResponse>> listDraftCostComparisons(
133 133
             @PathVariable("id") Long conversationId) {
134 134
         LoginUser loginUser = requireEnterprise();
135 135
         return R.ok(draftService.listCostComparisonsByConversation(

+ 52 - 9
huimv-employment/fe-service/src/main/java/com/huimv/employment/service/draft/DraftService.java

@@ -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>

+ 25 - 0
huimv-employment/fe-service/src/main/java/com/huimv/employment/service/draft/dto/DraftWithCostComparisonResponse.java

@@ -0,0 +1,25 @@
1
+package com.huimv.employment.service.draft.dto;
2
+
3
+import com.fasterxml.jackson.annotation.JsonInclude;
4
+import com.fasterxml.jackson.annotation.JsonProperty;
5
+import io.swagger.v3.oas.annotations.media.Schema;
6
+
7
+/**
8
+ * 会话下草稿信息 + 成本测算(测算实体同单草稿 cost-comparison)。
9
+ */
10
+@Schema(description = "草稿信息(含成本测算)")
11
+public class DraftWithCostComparisonResponse extends DraftDetailResponse {
12
+
13
+    @JsonProperty("cost_comparison")
14
+    @JsonInclude(JsonInclude.Include.ALWAYS)
15
+    @Schema(description = "成本测算结果,结构同 GET /api/v1/mp/drafts/{id}/cost-comparison;无法测算时为 null")
16
+    private McpDraftCalculateResponse costComparison;
17
+
18
+    public McpDraftCalculateResponse getCostComparison() {
19
+        return costComparison;
20
+    }
21
+
22
+    public void setCostComparison(McpDraftCalculateResponse costComparison) {
23
+        this.costComparison = costComparison;
24
+    }
25
+}