v1.0.49 #61
@@ -1,7 +1,6 @@
|
||||
package com.imyeyu.api.modules.gao.ai.mcp;
|
||||
|
||||
import com.imyeyu.api.modules.common.service.SettingService;
|
||||
import com.imyeyu.api.modules.gao.ai.config.GaoAiProperties;
|
||||
import com.imyeyu.api.modules.gao.ai.entity.GaoAiSession;
|
||||
import com.imyeyu.api.modules.gao.ai.service.GaoAiSessionService;
|
||||
import com.imyeyu.api.modules.gao.ai.service.implement.GaoAiSessionServiceImplement.GaoAiSessionException;
|
||||
@@ -22,7 +21,6 @@ import java.security.MessageDigest;
|
||||
@RequiredArgsConstructor
|
||||
public class GaoAiMcpAuthentication {
|
||||
|
||||
private final GaoAiProperties properties;
|
||||
private final SettingService settingService;
|
||||
private final GaoAiSessionService sessionService;
|
||||
|
||||
|
||||
+19
-4
@@ -501,7 +501,11 @@ public class GaoAiChatServiceImplement implements GaoAiChatService {
|
||||
if (line.startsWith("event:")) {
|
||||
sseEvent.set(line.substring(6).trim());
|
||||
} else if (line.startsWith("data:")) {
|
||||
data.append(line.substring(5).trim());
|
||||
if (!data.isEmpty()) {
|
||||
data.append('\n');
|
||||
}
|
||||
String dataLine = line.substring(5);
|
||||
data.append(dataLine.startsWith(" ") ? dataLine.substring(1) : dataLine);
|
||||
} else if (line.isEmpty() && !data.isEmpty()) {
|
||||
processData(data.toString(), sseEvent.get(), emitter, status, finished, timeoutRef, auditRecorded,
|
||||
session, message, startedAt);
|
||||
@@ -565,9 +569,13 @@ public class GaoAiChatServiceImplement implements GaoAiChatService {
|
||||
}
|
||||
switch (event) {
|
||||
case "message", "agent_message", "text_chunk" -> {
|
||||
String answer = firstText(text(payload, "answer", null), text(payload, "text", null));
|
||||
if (answer != null) {
|
||||
safeSend(emitter, SseEmitter.event().name("message").data(answer), finished);
|
||||
String answer = firstRawText(payload, "answer");
|
||||
if (answer == null) {
|
||||
answer = firstRawText(payload, "text");
|
||||
}
|
||||
if (answer != null && !answer.isEmpty()) {
|
||||
Map<String, String> messageData = Map.of("answer", answer);
|
||||
safeSend(emitter, SseEmitter.event().name("message").data(messageData), finished);
|
||||
}
|
||||
}
|
||||
case "message_end" -> emitDone(emitter, session, startedAt, finished, timeoutRef, auditRecorded, message, status);
|
||||
@@ -719,6 +727,13 @@ public class GaoAiChatServiceImplement implements GaoAiChatService {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
private String firstRawText(JsonNode node, String field) {
|
||||
if (node != null && node.hasNonNull(field)) {
|
||||
return node.get(field).asText();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String firstText(String... values) {
|
||||
for (String value : values) {
|
||||
if (!isBlank(value)) {
|
||||
|
||||
@@ -19,11 +19,9 @@ public enum GaoSystemSetting implements SettingEnum {
|
||||
|
||||
DIFY_MCP_SERVICE_KEY(null, Setting.ValueType.STRING),
|
||||
|
||||
SERVICE_LICENSE(null, Setting.ValueType.STRING),
|
||||
AI_AGENT_EXAMPLE(null, Setting.ValueType.JSON_LIST),
|
||||
|
||||
PRIVACY_LICENSE(null, Setting.ValueType.STRING),
|
||||
|
||||
OPEN_SOURCE_LICENSE(null, Setting.ValueType.STRING);
|
||||
AGREEMENT(null, Setting.ValueType.JSON_OBJECT);
|
||||
|
||||
final String defaultValue;
|
||||
|
||||
|
||||
@@ -4,7 +4,9 @@ import com.imyeyu.api.modules.common.entity.Attachment;
|
||||
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoCustomer;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoFundRecord;
|
||||
import com.imyeyu.api.modules.gao.service.GaoCustomerService;
|
||||
import com.imyeyu.api.modules.gao.service.GaoFundRecordService;
|
||||
import com.imyeyu.api.modules.gao.service.GaoOrderPaymentService;
|
||||
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
|
||||
@@ -39,6 +41,7 @@ import java.util.stream.Stream;
|
||||
public class GaoFundRecordController {
|
||||
|
||||
private final GaoFundRecordService service;
|
||||
private final GaoCustomerService customerService;
|
||||
private final GaoOrderPaymentService orderPaymentService;
|
||||
private final GaoStoreScopeService storeScopeService;
|
||||
private final AttachmentService attachmentService;
|
||||
@@ -124,10 +127,23 @@ public class GaoFundRecordController {
|
||||
.distinct()
|
||||
.toList();
|
||||
Map<String, User> userMap = userIdList.isEmpty() ? Map.of() : userService.mapByIdList(userIdList);
|
||||
List<String> customerIdList = recordList.stream()
|
||||
.map(GaoFundRecord::getCustomerId)
|
||||
.filter(value -> value != null && !value.isBlank())
|
||||
.distinct()
|
||||
.toList();
|
||||
Map<String, GaoCustomer> customerMap = customerIdList.isEmpty() ? Map.of() : customerService.mapByIdList(customerIdList);
|
||||
Map<String, List<Attachment>> customerPhotoMap = customerIdList.isEmpty()
|
||||
? Map.of() : attachmentService.mapByBizIdList(Attachment.BizType.GAO_CUSTOMER, customerIdList, GaoCustomer.AttachType.PHOTO.name());
|
||||
for (GaoFundRecord record : recordList) {
|
||||
record.setAttachmentList(attachmentMap.getOrDefault(record.getId(), List.of()));
|
||||
record.setOperator(userMap.get(record.getOperatorUserId()));
|
||||
record.setVerifier(userMap.get(record.getVerifierUserId()));
|
||||
GaoCustomer customer = customerMap.get(record.getCustomerId());
|
||||
if (customer != null) {
|
||||
customer.setAttachmentList(customerPhotoMap.getOrDefault(customer.getId(), List.of()));
|
||||
}
|
||||
record.setCustomer(customer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,6 +120,10 @@ public class GaoFundRecord extends UUIDEntity {
|
||||
@Transient
|
||||
private User verifier;
|
||||
|
||||
/// 所属客户
|
||||
@Transient
|
||||
private GaoCustomer customer;
|
||||
|
||||
/// 附件
|
||||
@Transient
|
||||
private List<Attachment> attachmentList;
|
||||
|
||||
@@ -168,6 +168,10 @@ public class GaoProductStockRecord implements IDEntity<String>, Creatable {
|
||||
@Transient
|
||||
private User operator;
|
||||
|
||||
/// 所属客户
|
||||
@Transient
|
||||
private GaoCustomer customer;
|
||||
|
||||
/// 附件
|
||||
@Transient
|
||||
private List<Attachment> attachmentList;
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.imyeyu.api.modules.gao.vo.GaoOrderFulfillmentPage;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/// GAO 统一履约 Mapper
|
||||
@@ -19,6 +20,9 @@ public interface GaoOrderFulfillmentMapper extends BaseMapper<GaoOrderFulfillmen
|
||||
/// 按 ID 查询履约单
|
||||
GaoOrderFulfillment selectById(@Param("id") String id);
|
||||
|
||||
/// 按 ID 批量查询履约单
|
||||
List<GaoOrderFulfillment> selectByIdList(@Param("idList") Collection<String> idList);
|
||||
|
||||
/// 锁定履约单
|
||||
GaoOrderFulfillment selectForUpdate(@Param("id") String id);
|
||||
|
||||
|
||||
+16
@@ -159,6 +159,17 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
|
||||
logger.setContent(jackson.writeValueAsString(customer));
|
||||
GaoCustomer dbCustomer = get(customer.getId());
|
||||
TimiException.requiredTrue(dbCustomer.getStoreId().equals(customer.getStoreId()), "customer.storeId invalid");
|
||||
String oldIntroducerCustomerId = dbCustomer.getIntroducerCustomerId();
|
||||
String requestIntroducerCustomerId = customer.getIntroducerCustomerId();
|
||||
String introducerCustomerId = requestIntroducerCustomerId == null
|
||||
? oldIntroducerCustomerId
|
||||
: TimiJava.defaultIfEmpty(requestIntroducerCustomerId, null);
|
||||
if (TimiJava.isNotEmpty(introducerCustomerId)) {
|
||||
TimiException.requiredTrue(!introducerCustomerId.equals(customer.getId()), "customer.introducerCustomerId invalid");
|
||||
GaoCustomer introducerCustomer = get(introducerCustomerId);
|
||||
TimiException.required(introducerCustomer, "not found introducer customer");
|
||||
TimiException.requiredTrue(customer.getStoreId().equals(introducerCustomer.getStoreId()), "介绍人和客户不属于同一门店");
|
||||
}
|
||||
String code = TimiJava.defaultIfEmpty(customer.getCode(), null);
|
||||
{
|
||||
if (!Objects.equals(dbCustomer.getCode(), code) && TimiJava.isNotEmpty(code)) {
|
||||
@@ -184,7 +195,12 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
|
||||
dbCustomer.setRemark(customer.getRemark());
|
||||
dbCustomer.setDisease(customer.getDisease());
|
||||
dbCustomer.setConditioningPart(customer.getConditioningPart());
|
||||
dbCustomer.setIntroducerCustomerId(introducerCustomerId);
|
||||
mapper.update(dbCustomer);
|
||||
if (!Objects.equals(oldIntroducerCustomerId, introducerCustomerId)) {
|
||||
changeInvitedCount(oldIntroducerCustomerId, -1);
|
||||
changeInvitedCount(introducerCustomerId, 1);
|
||||
}
|
||||
|
||||
// 标签
|
||||
if (customer.getTagApply() != null) {
|
||||
|
||||
+44
-1
@@ -2,8 +2,12 @@ package com.imyeyu.api.modules.gao.service.implement;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoCustomer;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoOrderFulfillment;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoProductStockRecord;
|
||||
import com.imyeyu.api.modules.gao.mapper.GaoOrderFulfillmentMapper;
|
||||
import com.imyeyu.api.modules.gao.mapper.GaoProductStockRecordMapper;
|
||||
import com.imyeyu.api.modules.gao.service.GaoCustomerService;
|
||||
import com.imyeyu.api.modules.gao.service.GaoProductStockRecordService;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductStockRecordPage;
|
||||
import com.imyeyu.api.modules.user.entity.User;
|
||||
@@ -18,6 +22,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/// GAO 库存流水服务实现
|
||||
///
|
||||
@@ -28,7 +33,9 @@ import java.util.Map;
|
||||
public class GaoProductStockRecordServiceImplement extends AbstractEntityService<GaoProductStockRecord, String> implements GaoProductStockRecordService {
|
||||
|
||||
private final GaoProductStockRecordMapper mapper;
|
||||
private final GaoOrderFulfillmentMapper orderFulfillmentMapper;
|
||||
private final AttachmentService attachmentService;
|
||||
private final GaoCustomerService customerService;
|
||||
private final UserService userService;
|
||||
|
||||
@Override
|
||||
@@ -133,10 +140,46 @@ public class GaoProductStockRecordServiceImplement extends AbstractEntityService
|
||||
List<String> userIdList = recordList.stream().map(GaoProductStockRecord::getOperatorUserId)
|
||||
.filter(value -> value != null && !value.isBlank()).distinct().toList();
|
||||
Map<String, User> userMap = userIdList.isEmpty() ? Map.of() : userService.mapByIdList(userIdList);
|
||||
Map<String, List<Attachment>> userAvatarMap = userIdList.isEmpty()
|
||||
? Map.of() : attachmentService.mapByBizIdList(Attachment.BizType.USER, userIdList, User.AttachType.AVATAR.name());
|
||||
List<String> fulfillmentIdList = recordList.stream()
|
||||
.filter(record -> record.getBizType() == GaoProductStockRecord.BizType.ORDER_FULFILLMENT)
|
||||
.map(GaoProductStockRecord::getBizId)
|
||||
.filter(value -> value != null && !value.isBlank())
|
||||
.distinct()
|
||||
.toList();
|
||||
Map<String, GaoOrderFulfillment> fulfillmentMap = fulfillmentIdList.isEmpty()
|
||||
? Map.of() : orderFulfillmentMapper.selectByIdList(fulfillmentIdList).stream()
|
||||
.collect(Collectors.toMap(GaoOrderFulfillment::getId, item -> item));
|
||||
List<String> customerIdList = recordList.stream()
|
||||
.map(record -> getCustomerId(record, fulfillmentMap))
|
||||
.filter(value -> value != null && !value.isBlank())
|
||||
.distinct()
|
||||
.toList();
|
||||
Map<String, GaoCustomer> customerMap = customerIdList.isEmpty() ? Map.of() : customerService.mapByIdList(customerIdList);
|
||||
Map<String, List<Attachment>> customerPhotoMap = customerIdList.isEmpty()
|
||||
? Map.of() : attachmentService.mapByBizIdList(Attachment.BizType.GAO_CUSTOMER, customerIdList, GaoCustomer.AttachType.PHOTO.name());
|
||||
for (GaoProductStockRecord record : recordList) {
|
||||
record.setAttachmentList(attachmentMap.getOrDefault(record.getId(), List.of()));
|
||||
record.setOperator(userMap.get(record.getOperatorUserId()));
|
||||
User operator = userMap.get(record.getOperatorUserId());
|
||||
if (operator != null) {
|
||||
operator.setAttachmentList(userAvatarMap.getOrDefault(operator.getId(), List.of()));
|
||||
}
|
||||
record.setOperator(operator);
|
||||
GaoCustomer customer = customerMap.get(getCustomerId(record, fulfillmentMap));
|
||||
if (customer != null) {
|
||||
customer.setAttachmentList(customerPhotoMap.getOrDefault(customer.getId(), List.of()));
|
||||
}
|
||||
record.setCustomer(customer);
|
||||
}
|
||||
}
|
||||
|
||||
private String getCustomerId(GaoProductStockRecord record, Map<String, GaoOrderFulfillment> fulfillmentMap) {
|
||||
if (record.getBizType() != GaoProductStockRecord.BizType.ORDER_FULFILLMENT) {
|
||||
return null;
|
||||
}
|
||||
GaoOrderFulfillment fulfillment = fulfillmentMap.get(record.getBizId());
|
||||
return fulfillment == null ? null : fulfillment.getCustomerId();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
SELECT * FROM `gao_order_fulfillment`
|
||||
WHERE `id` = #{id}
|
||||
</select>
|
||||
<select id="selectByIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoOrderFulfillment">
|
||||
SELECT * FROM `gao_order_fulfillment`
|
||||
WHERE `id` IN
|
||||
<foreach collection="idList" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</select>
|
||||
<select id="selectForUpdate" resultType="com.imyeyu.api.modules.gao.entity.GaoOrderFulfillment">
|
||||
SELECT * FROM `gao_order_fulfillment`
|
||||
WHERE `id` = #{id}
|
||||
|
||||
Reference in New Issue
Block a user