@ -0,0 +1,66 @@ | |||
package com.digiwin.athena.app.chatFile.infra.entity; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import com.digiwin.athena.opt.persistence.domain.BaseMgrEntity; | |||
import com.google.gson.annotations.SerializedName; | |||
import lombok.AllArgsConstructor; | |||
import lombok.Builder; | |||
import lombok.Data; | |||
import lombok.NoArgsConstructor; | |||
import java.util.Date; | |||
/** | |||
* @auther: zhenggl | |||
* @date: 2023/9/7 | |||
*/ | |||
@Data | |||
@AllArgsConstructor | |||
@NoArgsConstructor | |||
@Builder | |||
@TableName(value = "cim_chat_file", autoResultMap = true) | |||
public class ChatFileEntity extends BaseMgrEntity<ChatFileEntity> { | |||
@SerializedName(value = "question") | |||
private String question; | |||
@SerializedName(value = "feedback_person") | |||
private String feedbackPerson; | |||
@SerializedName(value = "feedback_date") | |||
private Date feedbackDate; | |||
@SerializedName(value = "urgency") | |||
private Integer urgency; | |||
@SerializedName(value = "question_type") | |||
private Integer questionType; | |||
@SerializedName(value = "question_source") | |||
private Integer questionSource; | |||
@SerializedName(value = "question_complete_by") | |||
private String questionCompleteBy; | |||
@SerializedName(value = "complete_date") | |||
private Date completeDate; | |||
@SerializedName(value = "complete_explain") | |||
private String completeExplain; | |||
@SerializedName(value = "is_join") | |||
private Integer isJoin; | |||
@SerializedName(value = "tab_status") | |||
private Integer tabStatus; | |||
} |
@ -0,0 +1,26 @@ | |||
<?xml version="1.0" encoding="UTF-8" ?> | |||
<!DOCTYPE mapper | |||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
<mapper namespace="com.digiwin.athena.app.chatFile.infra.repository.ChatFileRepository"> | |||
<update id="updateBatch"> | |||
<foreach collection="list" item="item" index="index" separator=";" open="" close=""> | |||
UPDATE cim_chat_file | |||
<set> | |||
`question` = #{item.question}, | |||
`question_source` = #{item.questionSource}, | |||
`question_type` = #{item.questionType}, | |||
`urgency` = #{item.urgency}, | |||
`question_complete_by` = #{item.questionCompleteBy}, | |||
`complete_explain` = #{item.completeExplain}, | |||
`complete_date` = #{item.completeDate}, | |||
`is_join` = #{item.isJoin}, | |||
</set> | |||
WHERE `id`=#{item.id} | |||
</foreach> | |||
</update> | |||
</mapper> |
@ -0,0 +1,17 @@ | |||
package com.digiwin.athena.app.chatFile.infra.repository; | |||
import com.digiwin.athena.app.chatFile.infra.entity.ChatFileEntity; | |||
import com.digiwin.athena.opt.persistence.repository.BaseRepository; | |||
import org.apache.ibatis.annotations.Param; | |||
import java.util.List; | |||
/** | |||
* @auther: zhenggl | |||
* @date: 2023/9/7 | |||
*/ | |||
public interface ChatFileRepository extends BaseRepository<ChatFileEntity> { | |||
void updateBatch(@Param("list") List<ChatFileEntity> list); | |||
} |
@ -0,0 +1,11 @@ | |||
package com.digiwin.athena.app.chatFile.infra.service; | |||
import com.digiwin.athena.app.chatFile.infra.entity.ChatFileEntity; | |||
import com.digiwin.athena.opt.persistence.service.IBaseService; | |||
/** | |||
* @auther: zhenggl | |||
* @date: 2023/9/7 | |||
*/ | |||
public interface ChatFileService extends IBaseService<ChatFileEntity> { | |||
} |
@ -0,0 +1,15 @@ | |||
package com.digiwin.athena.app.chatFile.infra.service.impl; | |||
import com.digiwin.athena.app.chatFile.infra.entity.ChatFileEntity; | |||
import com.digiwin.athena.app.chatFile.infra.repository.ChatFileRepository; | |||
import com.digiwin.athena.app.chatFile.infra.service.ChatFileService; | |||
import com.digiwin.athena.opt.persistence.service.impl.AbsBaseService; | |||
import org.springframework.stereotype.Service; | |||
/** | |||
* @auther: zhenggl | |||
* @date: 2023/9/7 | |||
*/ | |||
@Service | |||
public class ChatFileServiceImpl extends AbsBaseService<ChatFileRepository, ChatFileEntity> implements ChatFileService { | |||
} |
@ -0,0 +1,24 @@ | |||
package com.digiwin.athena.app.chatFile.provider; | |||
import com.digiwin.app.service.DWEAIResult; | |||
import com.digiwin.app.service.DWService; | |||
import com.digiwin.app.service.eai.EAIService; | |||
import com.digiwin.athena.app.chatFile.service.chatFile.ChatFileUtil; | |||
import java.util.Map; | |||
/** | |||
* @auther: zhenggl | |||
* @date: 2023/9/7 | |||
*/ | |||
public interface ChatFileEAIService extends DWService { | |||
@EAIService(id = ChatFileUtil.CA_CHAT_FILE_INFO_GET) | |||
DWEAIResult get(Map<String, String> headers, String messageBody) throws Exception; | |||
@EAIService(id = ChatFileUtil.CA_CHAT_FILE_INFO_CREATE) | |||
DWEAIResult create(Map<String, String> headers, String messageBody) throws Exception; | |||
@EAIService(id = ChatFileUtil.CA_CHAT_FILE_INFO_UPDATE) | |||
DWEAIResult update(Map<String, String> headers, String messageBody) throws Exception; | |||
} |
@ -0,0 +1,35 @@ | |||
package com.digiwin.athena.app.chatFile.provider.impl; | |||
import com.digiwin.app.service.DWEAIResult; | |||
import com.digiwin.athena.app.chatFile.provider.ChatFileEAIService; | |||
import com.digiwin.athena.app.chatFile.service.chatFile.ChatFileUtil; | |||
import com.digiwin.athena.opt.common.eai.service.EAIServiceContext; | |||
import javax.annotation.Resource; | |||
import java.util.Map; | |||
/** | |||
* @auther: zhenggl | |||
* @date: 2023/9/7 | |||
*/ | |||
public class ChatFileEAIServiceImpl implements ChatFileEAIService { | |||
@Resource | |||
private EAIServiceContext eaiServiceContext; | |||
@Override | |||
public DWEAIResult get(Map<String, String> headers, String messageBody) throws Exception { | |||
return eaiServiceContext.execute(ChatFileUtil.CA_CHAT_FILE_INFO_GET,headers,messageBody); | |||
} | |||
@Override | |||
public DWEAIResult create(Map<String, String> headers, String messageBody) throws Exception { | |||
return eaiServiceContext.execute(ChatFileUtil.CA_CHAT_FILE_INFO_CREATE,headers,messageBody); | |||
} | |||
@Override | |||
public DWEAIResult update(Map<String, String> headers, String messageBody) throws Exception { | |||
return eaiServiceContext.execute(ChatFileUtil.CA_CHAT_FILE_INFO_UPDATE,headers,messageBody); | |||
} | |||
} |
@ -0,0 +1,54 @@ | |||
package com.digiwin.athena.app.chatFile.service.chatFile; | |||
import com.alibaba.fastjson.TypeReference; | |||
import com.alibaba.nacos.common.utils.StringUtils; | |||
import com.digiwin.app.container.exceptions.DWBusinessException; | |||
import com.digiwin.app.service.DWEAIResult; | |||
import com.digiwin.athena.app.chatFile.infra.entity.ChatFileEntity; | |||
import com.digiwin.athena.app.chatFile.infra.service.ChatFileService; | |||
import com.digiwin.athena.opt.common.eai.EAIRequest; | |||
import com.digiwin.athena.opt.common.eai.service.AbsEAIService; | |||
import lombok.extern.log4j.Log4j2; | |||
import org.springframework.stereotype.Service; | |||
import javax.annotation.Resource; | |||
import java.util.Date; | |||
import java.util.List; | |||
import java.util.Map; | |||
/** | |||
* @auther: zhenggl | |||
* @date: 2023/9/7 | |||
*/ | |||
@Service | |||
@Log4j2 | |||
public class ChatFileCreateEAIService extends AbsEAIService { | |||
@Resource | |||
private ChatFileService chatFileService; | |||
@Override | |||
public String getServiceName() { | |||
return ChatFileUtil.CA_CHAT_FILE_INFO_CREATE; | |||
} | |||
@Override | |||
public DWEAIResult execute(Map<String, String> headers, String messageBody) throws Exception { | |||
EAIRequest eaiRequest = EAIRequest.build(messageBody); | |||
List<ChatFileEntity> chatFileInfo = eaiRequest.getObject("chat_file_info", new TypeReference<List<ChatFileEntity>>(){}); | |||
Date date = new Date(); | |||
for (ChatFileEntity chatFileEntity : chatFileInfo) { | |||
if (StringUtils.isEmpty(chatFileEntity.getQuestion())){ | |||
throw new DWBusinessException("问题描述不能为空"); | |||
} | |||
//反馈时间 | |||
chatFileEntity.setFeedbackDate(date); | |||
} | |||
chatFileService.saveBatch(chatFileInfo); | |||
return buildOK("chat_file_info",chatFileInfo); | |||
} | |||
} |
@ -0,0 +1,55 @@ | |||
package com.digiwin.athena.app.chatFile.service.chatFile; | |||
import com.alibaba.fastjson.TypeReference; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.digiwin.app.service.DWEAIResult; | |||
import com.digiwin.athena.app.chatFile.infra.entity.ChatFileEntity; | |||
import com.digiwin.athena.app.chatFile.infra.service.ChatFileService; | |||
import com.digiwin.athena.opt.common.eai.EAIRequest; | |||
import com.digiwin.athena.opt.common.eai.service.AbsEAIService; | |||
import lombok.extern.log4j.Log4j2; | |||
import org.apache.commons.collections.CollectionUtils; | |||
import org.springframework.stereotype.Service; | |||
import javax.annotation.Resource; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.stream.Collectors; | |||
/** | |||
* @auther: zhenggl | |||
* @date: 2023/9/7 | |||
*/ | |||
@Service | |||
@Log4j2 | |||
public class ChatFileGetEAIService extends AbsEAIService { | |||
@Resource | |||
private ChatFileService chatFileService; | |||
@Override | |||
public String getServiceName() { | |||
return ChatFileUtil.CA_CHAT_FILE_INFO_GET; | |||
} | |||
@Override | |||
public DWEAIResult execute(Map<String, String> headers, String messageBody) throws Exception { | |||
EAIRequest eaiRequest = EAIRequest.build(messageBody); | |||
List<ChatFileEntity> chatFileInfo = eaiRequest.getObject("chat_file_info", new TypeReference<List<ChatFileEntity>>(){}); | |||
if (CollectionUtils.isEmpty(chatFileInfo)){ | |||
return buildOK(new HashMap<>()); | |||
} | |||
List<Long> idList = chatFileInfo.stream().map(ChatFileEntity::getId).collect(Collectors.toList()); | |||
LambdaQueryWrapper<ChatFileEntity> lmq = new LambdaQueryWrapper<>(); | |||
lmq.in(ChatFileEntity::getId,idList); | |||
List<ChatFileEntity> list = chatFileService.list(lmq); | |||
return buildOK("chat_file_info",list); | |||
} | |||
} |
@ -0,0 +1,47 @@ | |||
package com.digiwin.athena.app.chatFile.service.chatFile; | |||
import com.alibaba.fastjson.TypeReference; | |||
import com.digiwin.app.service.DWEAIResult; | |||
import com.digiwin.athena.app.chatFile.infra.entity.ChatFileEntity; | |||
import com.digiwin.athena.app.chatFile.infra.repository.ChatFileRepository; | |||
import com.digiwin.athena.opt.common.eai.EAIRequest; | |||
import com.digiwin.athena.opt.common.eai.service.AbsEAIService; | |||
import lombok.extern.log4j.Log4j2; | |||
import org.springframework.stereotype.Service; | |||
import javax.annotation.Resource; | |||
import java.util.Date; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
/** | |||
* @auther: zhenggl | |||
* @date: 2023/9/7 | |||
*/ | |||
@Service | |||
@Log4j2 | |||
public class ChatFileUpdateEAIService extends AbsEAIService { | |||
@Resource | |||
private ChatFileRepository chatFileRepository; | |||
@Override | |||
public String getServiceName() { | |||
return ChatFileUtil.CA_CHAT_FILE_INFO_UPDATE; | |||
} | |||
@Override | |||
public DWEAIResult execute(Map<String, String> headers, String messageBody) throws Exception { | |||
EAIRequest eaiRequest = EAIRequest.build(messageBody); | |||
List<ChatFileEntity> chatFileInfo = eaiRequest.getObject("chat_file_info", new TypeReference<List<ChatFileEntity>>(){}); | |||
chatFileInfo.forEach(item -> { | |||
item.setCompleteDate(new Date()); | |||
}); | |||
chatFileRepository.updateBatch(chatFileInfo); | |||
return buildOK(new HashMap<>()); | |||
} | |||
} |
@ -0,0 +1,17 @@ | |||
package com.digiwin.athena.app.chatFile.service.chatFile; | |||
/** | |||
* @auther: zhenggl | |||
* @date: 2023/9/7 | |||
*/ | |||
public class ChatFileUtil { | |||
/*** | |||
* 工博会chat_file | |||
*/ | |||
public static final String CA_CHAT_FILE_INFO_CREATE = "demo.kcfr.chat.file.info.create"; | |||
public static final String CA_CHAT_FILE_INFO_UPDATE = "demo.kcfr.chat.file.info.update"; | |||
public static final String CA_CHAT_FILE_INFO_GET = "demo.kcfr.chat.file.info.get"; | |||
} |