Bladeren bron

增加与ai大模型对话

wwh 2 weken geleden
bovenliggende
commit
292722422c

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

@@ -15,6 +15,8 @@ import com.huimv.employment.service.conversation.dto.ConversationMessagePageResp
15 15
 import com.huimv.employment.service.conversation.dto.ConversationSummaryResponse;
16 16
 import com.huimv.employment.service.draft.DraftService;
17 17
 import com.huimv.employment.service.draft.dto.McpDraftCalculateResponse;
18
+import com.huimv.employment.service.order.EmploymentOrderService;
19
+import com.huimv.employment.service.order.dto.EmploymentOrderItemResponse;
18 20
 import com.huimv.employment.service.registration.RegistrationBatchService;
19 21
 import com.huimv.employment.service.registration.dto.RegistrationBatchDetailResponse;
20 22
 import io.swagger.v3.oas.annotations.Operation;
@@ -60,17 +62,20 @@ public class ConversationController {
60 62
     private final ConversationMessageService conversationMessageService;
61 63
     private final DraftService draftService;
62 64
     private final RegistrationBatchService registrationBatchService;
65
+    private final EmploymentOrderService employmentOrderService;
63 66
 
64 67
     public ConversationController(ConversationService conversationService,
65 68
                                   ConversationChatService conversationChatService,
66 69
                                   ConversationMessageService conversationMessageService,
67 70
                                   DraftService draftService,
68
-                                  RegistrationBatchService registrationBatchService) {
71
+                                  RegistrationBatchService registrationBatchService,
72
+                                  EmploymentOrderService employmentOrderService) {
69 73
         this.conversationService = conversationService;
70 74
         this.conversationChatService = conversationChatService;
71 75
         this.conversationMessageService = conversationMessageService;
72 76
         this.draftService = draftService;
73 77
         this.registrationBatchService = registrationBatchService;
78
+        this.employmentOrderService = employmentOrderService;
74 79
     }
75 80
 
76 81
     /**
@@ -146,6 +151,21 @@ public class ConversationController {
146 151
                 loginUser.getUserId(), conversationId));
147 152
     }
148 153
 
154
+    /**
155
+     * 查询指定会话下全部草稿已转成正式订单的列表。
156
+     */
157
+    @GetMapping("/{id}/drafts/orders")
158
+    @Operation(summary = "按会话查询草稿关联订单列表",
159
+            description = "返回该会话下草稿已确认并生成的正式订单;"
160
+                    + "仅「有订单」的草稿会出现在结果中,尚未确认方案的草稿不返回。"
161
+                    + "仅可查询本企业用户自己的会话。")
162
+    public R<List<EmploymentOrderItemResponse>> listDraftOrders(
163
+            @PathVariable("id") Long conversationId) {
164
+        LoginUser loginUser = requireEnterprise();
165
+        return R.ok(employmentOrderService.listByConversation(
166
+                loginUser.getUserId(), conversationId));
167
+    }
168
+
149 169
     /**
150 170
      * 在已有会话内发起 AI 对话(SSE 流式,流结束后落库)。
151 171
      */

+ 111 - 0
huimv-employment/fe-service/src/main/java/com/huimv/employment/service/order/EmploymentOrderService.java

@@ -0,0 +1,111 @@
1
+package com.huimv.employment.service.order;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
4
+import com.huimv.employment.common.exception.BizException;
5
+import com.huimv.employment.common.exception.ErrorCode;
6
+import com.huimv.employment.dao.entity.FeEmploymentDraft;
7
+import com.huimv.employment.dao.entity.FeEmploymentOrder;
8
+import com.huimv.employment.dao.entity.FeEnterprise;
9
+import com.huimv.employment.dao.mapper.FeEmploymentDraftMapper;
10
+import com.huimv.employment.dao.mapper.FeEmploymentOrderMapper;
11
+import com.huimv.employment.service.conversation.ConversationService;
12
+import com.huimv.employment.service.enterprise.EnterpriseService;
13
+import com.huimv.employment.service.order.dto.EmploymentOrderItemResponse;
14
+import org.springframework.stereotype.Service;
15
+
16
+import java.util.ArrayList;
17
+import java.util.Collections;
18
+import java.util.List;
19
+
20
+/**
21
+ * 企业端用工订单查询。
22
+ */
23
+@Service
24
+public class EmploymentOrderService {
25
+
26
+    private final FeEmploymentOrderMapper feEmploymentOrderMapper;
27
+    private final FeEmploymentDraftMapper feEmploymentDraftMapper;
28
+    private final ConversationService conversationService;
29
+    private final EnterpriseService enterpriseService;
30
+
31
+    public EmploymentOrderService(FeEmploymentOrderMapper feEmploymentOrderMapper,
32
+                                  FeEmploymentDraftMapper feEmploymentDraftMapper,
33
+                                  ConversationService conversationService,
34
+                                  EnterpriseService enterpriseService) {
35
+        this.feEmploymentOrderMapper = feEmploymentOrderMapper;
36
+        this.feEmploymentDraftMapper = feEmploymentDraftMapper;
37
+        this.conversationService = conversationService;
38
+        this.enterpriseService = enterpriseService;
39
+    }
40
+
41
+    /**
42
+     * 按会话查询其下草稿已转成正式订单的列表。
43
+     * <p>仅返回已存在订单的草稿;无订单的草稿不出现在结果中。</p>
44
+     */
45
+    public List<EmploymentOrderItemResponse> listByConversation(Long userId, Long conversationId) {
46
+        conversationService.requireOwned(userId, conversationId);
47
+        FeEnterprise enterprise = enterpriseService.findEnterpriseByUserId(userId);
48
+        if (enterprise == null) {
49
+            throw new BizException(ErrorCode.BAD_REQUEST, "请先完成企业登记");
50
+        }
51
+
52
+        List<FeEmploymentDraft> drafts = feEmploymentDraftMapper.selectList(
53
+                new LambdaQueryWrapper<FeEmploymentDraft>()
54
+                        .eq(FeEmploymentDraft::getConversationId, conversationId)
55
+                        .eq(FeEmploymentDraft::getEnterpriseId, enterprise.getId())
56
+                        .orderByAsc(FeEmploymentDraft::getId));
57
+        if (drafts == null || drafts.isEmpty()) {
58
+            return Collections.emptyList();
59
+        }
60
+
61
+        List<Long> draftIds = new ArrayList<>(drafts.size());
62
+        for (FeEmploymentDraft draft : drafts) {
63
+            if (draft.getId() != null) {
64
+                draftIds.add(draft.getId());
65
+            }
66
+        }
67
+        if (draftIds.isEmpty()) {
68
+            return Collections.emptyList();
69
+        }
70
+
71
+        List<FeEmploymentOrder> orders = feEmploymentOrderMapper.selectList(
72
+                new LambdaQueryWrapper<FeEmploymentOrder>()
73
+                        .eq(FeEmploymentOrder::getEnterpriseId, enterprise.getId())
74
+                        .in(FeEmploymentOrder::getDraftId, draftIds)
75
+                        .orderByDesc(FeEmploymentOrder::getCreateTime)
76
+                        .orderByDesc(FeEmploymentOrder::getId));
77
+        if (orders == null || orders.isEmpty()) {
78
+            return Collections.emptyList();
79
+        }
80
+
81
+        List<EmploymentOrderItemResponse> result = new ArrayList<>(orders.size());
82
+        for (FeEmploymentOrder order : orders) {
83
+            result.add(toItem(order));
84
+        }
85
+        return result;
86
+    }
87
+
88
+    private static EmploymentOrderItemResponse toItem(FeEmploymentOrder order) {
89
+        EmploymentOrderItemResponse item = new EmploymentOrderItemResponse();
90
+        item.setDraftId(order.getDraftId());
91
+        item.setOrderId(order.getId());
92
+        item.setOrderNo(order.getOrderNo());
93
+        item.setTitle(order.getTitle());
94
+        item.setWorkerCount(order.getWorkerCount());
95
+        item.setWorkDays(order.getWorkDays());
96
+        item.setWorkType(order.getWorkType());
97
+        item.setWorkLocation(order.getWorkLocation());
98
+        item.setWorkStartDate(order.getWorkStartDate());
99
+        item.setWorkEndDate(order.getWorkEndDate());
100
+        item.setOrderStatus(order.getOrderStatus());
101
+        item.setCurrentStepCode(order.getCurrentStepCode());
102
+        item.setRegisteredCount(order.getRegisteredCount());
103
+        item.setPendingCount(order.getPendingCount());
104
+        item.setAbnormalCount(order.getAbnormalCount());
105
+        item.setTotalOutflow(order.getTotalOutflow());
106
+        item.setSelectedPlanId(order.getSelectedPlanId());
107
+        item.setCreateTime(order.getCreateTime());
108
+        item.setUpdateTime(order.getUpdateTime());
109
+        return item;
110
+    }
111
+}

+ 231 - 0
huimv-employment/fe-service/src/main/java/com/huimv/employment/service/order/dto/EmploymentOrderItemResponse.java

@@ -0,0 +1,231 @@
1
+package com.huimv.employment.service.order.dto;
2
+
3
+import com.fasterxml.jackson.annotation.JsonProperty;
4
+import io.swagger.v3.oas.annotations.media.Schema;
5
+
6
+import java.math.BigDecimal;
7
+import java.time.LocalDate;
8
+import java.time.LocalDateTime;
9
+
10
+@Schema(description = "用工订单列表项")
11
+public class EmploymentOrderItemResponse {
12
+
13
+    @JsonProperty("draft_id")
14
+    @Schema(description = "关联草稿 ID")
15
+    private Long draftId;
16
+
17
+    @JsonProperty("order_id")
18
+    @Schema(description = "订单主键 ID")
19
+    private Long orderId;
20
+
21
+    @JsonProperty("order_no")
22
+    @Schema(description = "订单编号", example = "ord_123")
23
+    private String orderNo;
24
+
25
+    @Schema(description = "订单标题")
26
+    private String title;
27
+
28
+    @JsonProperty("worker_count")
29
+    @Schema(description = "用工人数")
30
+    private Integer workerCount;
31
+
32
+    @JsonProperty("work_days")
33
+    @Schema(description = "工作天数")
34
+    private Integer workDays;
35
+
36
+    @JsonProperty("work_type")
37
+    @Schema(description = "岗位类型")
38
+    private String workType;
39
+
40
+    @JsonProperty("work_location")
41
+    @Schema(description = "工作地点")
42
+    private String workLocation;
43
+
44
+    @JsonProperty("work_start_date")
45
+    private LocalDate workStartDate;
46
+
47
+    @JsonProperty("work_end_date")
48
+    private LocalDate workEndDate;
49
+
50
+    @JsonProperty("order_status")
51
+    @Schema(description = "订单状态", example = "confirmed")
52
+    private String orderStatus;
53
+
54
+    @JsonProperty("current_step_code")
55
+    @Schema(description = "当前流程步骤")
56
+    private String currentStepCode;
57
+
58
+    @JsonProperty("registered_count")
59
+    private Integer registeredCount;
60
+
61
+    @JsonProperty("pending_count")
62
+    private Integer pendingCount;
63
+
64
+    @JsonProperty("abnormal_count")
65
+    private Integer abnormalCount;
66
+
67
+    @JsonProperty("total_outflow")
68
+    @Schema(description = "企业总支出")
69
+    private BigDecimal totalOutflow;
70
+
71
+    @JsonProperty("selected_plan_id")
72
+    private Long selectedPlanId;
73
+
74
+    @JsonProperty("create_time")
75
+    private LocalDateTime createTime;
76
+
77
+    @JsonProperty("update_time")
78
+    private LocalDateTime updateTime;
79
+
80
+    public Long getDraftId() {
81
+        return draftId;
82
+    }
83
+
84
+    public void setDraftId(Long draftId) {
85
+        this.draftId = draftId;
86
+    }
87
+
88
+    public Long getOrderId() {
89
+        return orderId;
90
+    }
91
+
92
+    public void setOrderId(Long orderId) {
93
+        this.orderId = orderId;
94
+    }
95
+
96
+    public String getOrderNo() {
97
+        return orderNo;
98
+    }
99
+
100
+    public void setOrderNo(String orderNo) {
101
+        this.orderNo = orderNo;
102
+    }
103
+
104
+    public String getTitle() {
105
+        return title;
106
+    }
107
+
108
+    public void setTitle(String title) {
109
+        this.title = title;
110
+    }
111
+
112
+    public Integer getWorkerCount() {
113
+        return workerCount;
114
+    }
115
+
116
+    public void setWorkerCount(Integer workerCount) {
117
+        this.workerCount = workerCount;
118
+    }
119
+
120
+    public Integer getWorkDays() {
121
+        return workDays;
122
+    }
123
+
124
+    public void setWorkDays(Integer workDays) {
125
+        this.workDays = workDays;
126
+    }
127
+
128
+    public String getWorkType() {
129
+        return workType;
130
+    }
131
+
132
+    public void setWorkType(String workType) {
133
+        this.workType = workType;
134
+    }
135
+
136
+    public String getWorkLocation() {
137
+        return workLocation;
138
+    }
139
+
140
+    public void setWorkLocation(String workLocation) {
141
+        this.workLocation = workLocation;
142
+    }
143
+
144
+    public LocalDate getWorkStartDate() {
145
+        return workStartDate;
146
+    }
147
+
148
+    public void setWorkStartDate(LocalDate workStartDate) {
149
+        this.workStartDate = workStartDate;
150
+    }
151
+
152
+    public LocalDate getWorkEndDate() {
153
+        return workEndDate;
154
+    }
155
+
156
+    public void setWorkEndDate(LocalDate workEndDate) {
157
+        this.workEndDate = workEndDate;
158
+    }
159
+
160
+    public String getOrderStatus() {
161
+        return orderStatus;
162
+    }
163
+
164
+    public void setOrderStatus(String orderStatus) {
165
+        this.orderStatus = orderStatus;
166
+    }
167
+
168
+    public String getCurrentStepCode() {
169
+        return currentStepCode;
170
+    }
171
+
172
+    public void setCurrentStepCode(String currentStepCode) {
173
+        this.currentStepCode = currentStepCode;
174
+    }
175
+
176
+    public Integer getRegisteredCount() {
177
+        return registeredCount;
178
+    }
179
+
180
+    public void setRegisteredCount(Integer registeredCount) {
181
+        this.registeredCount = registeredCount;
182
+    }
183
+
184
+    public Integer getPendingCount() {
185
+        return pendingCount;
186
+    }
187
+
188
+    public void setPendingCount(Integer pendingCount) {
189
+        this.pendingCount = pendingCount;
190
+    }
191
+
192
+    public Integer getAbnormalCount() {
193
+        return abnormalCount;
194
+    }
195
+
196
+    public void setAbnormalCount(Integer abnormalCount) {
197
+        this.abnormalCount = abnormalCount;
198
+    }
199
+
200
+    public BigDecimal getTotalOutflow() {
201
+        return totalOutflow;
202
+    }
203
+
204
+    public void setTotalOutflow(BigDecimal totalOutflow) {
205
+        this.totalOutflow = totalOutflow;
206
+    }
207
+
208
+    public Long getSelectedPlanId() {
209
+        return selectedPlanId;
210
+    }
211
+
212
+    public void setSelectedPlanId(Long selectedPlanId) {
213
+        this.selectedPlanId = selectedPlanId;
214
+    }
215
+
216
+    public LocalDateTime getCreateTime() {
217
+        return createTime;
218
+    }
219
+
220
+    public void setCreateTime(LocalDateTime createTime) {
221
+        this.createTime = createTime;
222
+    }
223
+
224
+    public LocalDateTime getUpdateTime() {
225
+        return updateTime;
226
+    }
227
+
228
+    public void setUpdateTime(LocalDateTime updateTime) {
229
+        this.updateTime = updateTime;
230
+    }
231
+}