Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
3616e775
Commit
3616e775
authored
Jun 25, 2021
by
霍志良
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:im-灵犀2.0-回答问题接口
parent
5d070de9
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
132 additions
and
61 deletions
+132
-61
ImRetrofitApi.kt
m-im/src/main/java/com/yidianling/im/http/ImRetrofitApi.kt
+6
-0
CustomAttachLingxiWhichQuestion.java
m-im/src/main/java/com/yidianling/im/session/extension/CustomAttachLingxiWhichQuestion.java
+24
-25
MsgViewHolderLingxiWhichQuestion.java
m-im/src/main/java/com/yidianling/im/session/viewholder/MsgViewHolderLingxiWhichQuestion.java
+65
-25
AdapterLingxiMultipleChoice.kt
m-im/src/main/java/com/yidianling/im/session/viewholder/adapter/AdapterLingxiMultipleChoice.kt
+1
-1
AdapterLingxiWhichQuestion.kt
m-im/src/main/java/com/yidianling/im/session/viewholder/adapter/AdapterLingxiWhichQuestion.kt
+1
-1
LingxiWhichQuestionBean.kt
m-im/src/main/java/com/yidianling/im/session/viewholder/bean/LingxiWhichQuestionBean.kt
+35
-9
No files found.
m-im/src/main/java/com/yidianling/im/http/ImRetrofitApi.kt
View file @
3616e775
...
...
@@ -119,4 +119,9 @@ interface ImRetrofitApi {
@GET
(
"consult/user/order/affirmComplete"
)
@Headers
(
YDL_DOMAIN
+
YDL_DOMAIN_JAVA
)
fun
affirmComplete
(
@Query
(
"id"
)
orderId
:
String
):
Observable
<
BaseAPIResponse
<
Any
>>
//回答问题接口
@POST
(
"chat/sendCustomizeMessage"
)
@Headers
(
YDL_DOMAIN
+
YDL_DOMAIN_JAVA
)
fun
lingxiAnswerQuestion
(
@Body
body
:
RequestBody
):
Observable
<
BaseAPIResponse
<
Any
>>
}
\ No newline at end of file
m-im/src/main/java/com/yidianling/im/session/extension/CustomAttachLingxiWhichQuestion.java
View file @
3616e775
...
...
@@ -11,46 +11,45 @@ import java.util.ArrayList;
import
java.util.List
;
public
class
CustomAttachLingxiWhichQuestion
extends
CustomAttachment
{
private
final
String
XQUESTIONPAPERID
=
"x
questionPaperId"
;
//试卷id
private
final
String
XQUESTIONPAPERNAME
=
"xquestionPaperName"
;
//试卷名称
private
final
String
QUESTIONID
=
"questionId"
;
//问题id
private
final
String
QUESTIONTITLE
=
"questionTitle"
;
//问题题目
private
final
String
SELECTTYPE
=
"selectType"
;
//选项类型:1单选,2多选
private
final
String
SELECTVALS
=
"selectVals"
;
//选项
private
final
String
QUESTIONPAPERID
=
"
questionPaperId"
;
//试卷id
private
final
String
TYPE
=
"type"
;
//选项类型:radio单选,check多选
private
final
String
OPTIONS
=
"options"
;
//选项
private
final
String
EXAMID
=
"examId"
;
//考试ID
private
final
String
ID
=
"id"
;
//id
private
final
String
NAME
=
"name"
;
//name
public
String
xquestionPaperId
;
public
String
xquestionPaperName
;
public
String
questionId
;
public
String
questionTitle
;
public
String
selectType
;
public
List
<
QuestionItemBean
>
selectVals
;
public
String
questionPaperId
;
public
String
type
;
public
List
<
QuestionItemBean
>
options
;
public
String
examId
;
public
String
id
;
public
String
name
;
public
CustomAttachLingxiWhichQuestion
()
{
super
(
CustomAttachmentType
.
TYPE_LINGXI_WHICH_QUESTION
);
}
@Override
protected
void
parseData
(
JSONObject
data
)
{
this
.
xquestionPaperId
=
data
.
getString
(
XQUESTIONPAPERID
);
this
.
xquestionPaperName
=
data
.
getString
(
XQUESTIONPAPERNAME
);
this
.
questionId
=
data
.
getString
(
QUESTIONID
);
this
.
questionTitle
=
data
.
getString
(
QUESTIONTITLE
);
this
.
selectType
=
data
.
getString
(
SELECTTYPE
);
LogUtil
.
e
(
"aaaaa"
+
data
.
getString
(
SELECTVALS
));
this
.
selectVals
=(
ArrayList
<
QuestionItemBean
>)
JSON
.
parseArray
(
data
.
getString
(
SELECTVALS
),
QuestionItemBean
.
class
);
this
.
questionPaperId
=
data
.
getString
(
QUESTIONPAPERID
);
this
.
type
=
data
.
getString
(
TYPE
);
this
.
examId
=
data
.
getString
(
EXAMID
);
this
.
id
=
data
.
getString
(
ID
);
this
.
name
=
data
.
getString
(
NAME
);
this
.
options
=(
ArrayList
<
QuestionItemBean
>)
JSON
.
parseArray
(
data
.
getString
(
OPTIONS
),
QuestionItemBean
.
class
);
}
@Override
protected
JSONObject
packData
()
{
JSONObject
data
=
new
JSONObject
();
data
.
put
(
XQUESTIONPAPERID
,
x
questionPaperId
);
data
.
put
(
XQUESTIONPAPERNAME
,
xquestionPaperNam
e
);
data
.
put
(
QUESTIONID
,
questionId
);
data
.
put
(
QUESTIONTITLE
,
questionTitle
);
data
.
put
(
SELECTTYPE
,
selectType
);
data
.
put
(
SELECTVALS
,
selectVals
);
data
.
put
(
QUESTIONPAPERID
,
questionPaperId
);
data
.
put
(
TYPE
,
typ
e
);
data
.
put
(
OPTIONS
,
options
);
data
.
put
(
EXAMID
,
examId
);
data
.
put
(
ID
,
id
);
data
.
put
(
NAME
,
name
);
return
data
;
}
...
...
m-im/src/main/java/com/yidianling/im/session/viewholder/MsgViewHolderLingxiWhichQuestion.java
View file @
3616e775
...
...
@@ -2,27 +2,28 @@ package com.yidianling.im.session.viewholder;
import
android.widget.TextView
;
import
androidx.core.content.ContextCompat
;
import
androidx.recyclerview.widget.GridLayoutManager
;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.google.gson.Gson
;
import
com.netease.nimlib.sdk.NIMClient
;
import
com.netease.nimlib.sdk.RequestCallback
;
import
com.netease.nimlib.sdk.msg.MsgService
;
import
com.netease.nimlib.sdk.msg.attachment.MsgAttachment
;
import
com.netease.nimlib.sdk.msg.constant.SessionTypeEnum
;
import
com.netease.nimlib.sdk.msg.model.IMMessage
;
import
com.ydl.ydlcommon.data.http.RxUtils
;
import
com.yidianling.common.tools.LogUtil
;
import
com.yidianling.common.tools.ToastUtil
;
import
com.yidianling.im.R
;
import
com.yidianling.im.event.MultipleSelectedEvent
;
import
com.yidianling.im.http.ImRetrofitApi
;
import
com.yidianling.im.router.ImIn
;
import
com.yidianling.im.session.extension.CustomAttachLingxiWhichQuestion
;
import
com.yidianling.im.session.extension.CustomAttachmentConfirmOrder
;
import
com.yidianling.im.session.extension.CustomAttachmentOrderStatus
;
import
com.yidianling.im.session.viewholder.adapter.AdapterLingxiMultipleChoice
;
import
com.yidianling.im.session.viewholder.adapter.AdapterLingxiWhichQuestion
;
import
com.yidianling.im.session.viewholder.bean.LingxiWhichQuestionBean
;
import
com.yidianling.im.session.viewholder.bean.AnswerBean
;
import
com.yidianling.im.session.viewholder.bean.AnswersItem
;
import
com.yidianling.im.session.viewholder.bean.LingxiAnswerBean
;
import
com.yidianling.im.session.viewholder.bean.QuestionItemBean
;
import
com.yidianling.nimbase.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter
;
import
com.yidianling.uikit.business.session.viewholder.MsgViewHolderBase
;
...
...
@@ -35,6 +36,11 @@ import java.util.List;
import
java.util.Map
;
import
de.greenrobot.event.EventBus
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.disposables.Disposable
;
import
io.reactivex.schedulers.Schedulers
;
import
okhttp3.MediaType
;
import
okhttp3.RequestBody
;
public
class
MsgViewHolderLingxiWhichQuestion
extends
MsgViewHolderBase
implements
AdapterLingxiWhichQuestion
.
OnQuestionlItemClickListener
,
AdapterLingxiMultipleChoice
.
OnMultiplelItemClickListener
{
private
RecyclerView
recycleviewWhichQuestion
;
...
...
@@ -51,6 +57,12 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
private
StringBuffer
stringBuffer
=
new
StringBuffer
(
"已选:"
);
ArrayList
<
String
>
selectedStr
=
new
ArrayList
<
String
>();
private
Boolean
isClickable
=
true
;
//回答试卷接口
private
String
examId
;
private
String
questionPaperId
;
private
String
questionId
;
private
ArrayList
<
AnswersItem
>
answersItems
=
new
ArrayList
<>();
public
MsgViewHolderLingxiWhichQuestion
(
BaseMultiItemFetchLoadAdapter
adapter
)
{
super
(
adapter
);
}
...
...
@@ -58,17 +70,22 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
@Override
protected
int
getContentResId
()
{
customAttachLingxiWhichQuestion
=
((
CustomAttachLingxiWhichQuestion
)
message
.
getAttachment
());
switch
(
Integer
.
parseInt
(
customAttachLingxiWhichQuestion
.
selectType
)){
case
1
:
//您想要咨询下列哪类的问题?(单选)
if
(
customAttachLingxiWhichQuestion
.
type
!=
null
){
switch
(
customAttachLingxiWhichQuestion
.
type
){
case
"radio"
:
//您想要咨询下列哪类的问题?(单选)
return
R
.
layout
.
im_nim_lingxi_which_question
;
// return R.layout.im_nim_lingxi_multiple_choice;
case
2
:
//请问是发生了什么事情导致的呢?(多选)
case
"check"
:
//请问是发生了什么事情导致的呢?(多选)
return
R
.
layout
.
im_nim_lingxi_multiple_choice
;
case
3
:
//您是先生还是女生
case
"3"
:
//您是先生还是女生
return
R
.
layout
.
im_nim_lingxi_men_female
;
default
:
return
R
.
layout
.
im_nim_lingxi_which_question
;
}
}
else
{
return
R
.
layout
.
im_nim_lingxi_which_question
;
}
}
@Override
...
...
@@ -83,21 +100,26 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
@Override
protected
void
bindContentView
()
{
customAttachLingxiWhichQuestion
=
((
CustomAttachLingxiWhichQuestion
)
message
.
getAttachment
());
examId
=
customAttachLingxiWhichQuestion
.
examId
;
questionPaperId
=
customAttachLingxiWhichQuestion
.
questionPaperId
;
questionId
=
customAttachLingxiWhichQuestion
.
id
;
//您想要咨询下列哪类的问题?(单选)
if
(
customAttachLingxiWhichQuestion
.
selectVal
s
!=
null
){
questionList
=
(
ArrayList
<
QuestionItemBean
>)
customAttachLingxiWhichQuestion
.
selectVal
s
;
if
(
customAttachLingxiWhichQuestion
.
option
s
!=
null
){
questionList
=
(
ArrayList
<
QuestionItemBean
>)
customAttachLingxiWhichQuestion
.
option
s
;
}
adapterLingxiWhichQuestion
=
new
AdapterLingxiWhichQuestion
();
which_question_title
.
setText
(
customAttachLingxiWhichQuestion
.
xquestionPaperN
ame
);
which_question_title
.
setText
(
customAttachLingxiWhichQuestion
.
n
ame
);
for
(
int
i
=
0
;
i
<
questionList
.
size
();
i
++){
questionList
.
get
(
i
).
setSelected
(
false
);
if
(
questionList
.
get
(
i
).
get
Valu
e
().
length
()>
5
){
if
(
questionList
.
get
(
i
).
get
Nam
e
().
length
()>
5
){
isSingleChoice
=
true
;
break
;
}
}
switch
(
Integer
.
parseInt
(
customAttachLingxiWhichQuestion
.
selectType
)){
case
1
:
//您想要咨询下列哪类的问题?(单选)
if
(
customAttachLingxiWhichQuestion
.
type
!=
null
){
switch
(
customAttachLingxiWhichQuestion
.
type
){
case
"radio"
:
//您想要咨询下列哪类的问题?(单选)
if
(
questionList
!=
null
&&
questionList
.
size
()!=
0
){
adapterLingxiWhichQuestion
.
setTagData
(
questionList
,
isSingleChoice
);
adapterLingxiWhichQuestion
.
setItemListener
(
this
);
...
...
@@ -109,7 +131,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
recycleviewWhichQuestion
.
setAdapter
(
adapterLingxiWhichQuestion
);
}
break
;
case
2
:
//请问是发生了什么事情导致的呢?(多选)
case
"check"
:
//请问是发生了什么事情导致的呢?(多选)
// //请问是发生了什么事情导致的呢?(多选)
adapterLingxiMultipleChoice
=
new
AdapterLingxiMultipleChoice
();
adapterLingxiMultipleChoice
.
setTagData
(
questionList
);
...
...
@@ -121,11 +143,13 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
recycleviewMultipleChoice
.
setLayoutManager
(
multipleChoiceManager
);
recycleviewMultipleChoice
.
setAdapter
(
adapterLingxiMultipleChoice
);
break
;
case
3
:
//您是先生还是女生
case
"3"
:
//您是先生还是女生
break
;
default
:
break
;
}
}
try
{
Map
<
String
,
Object
>
map
=
message
.
getLocalExtension
();
if
(
map
!=
null
)
{
...
...
@@ -162,11 +186,32 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
}
adapterLingxiWhichQuestion
.
setTagData
(
questionList
,
isSingleChoice
);
isClickable
=
false
;
answersItems
.
add
(
new
AnswersItem
(
questionList
.
get
(
position
).
getId
(),
questionList
.
get
(
position
).
getName
(),
"其他"
,
questionList
.
get
(
position
).
getRelates
()));
//请求接口发送所选题目
answerLingxiQuestion
(
examId
,
questionPaperId
,
ImIn
.
INSTANCE
.
getUserInfo
().
getUid
().
toString
(),
questionId
,
answersItems
);
//更新本地消息
updateLocalMsg
(
position
);
}
}
/*
* 用户回答问题接口
* */
private
void
answerLingxiQuestion
(
String
examID
,
String
questionPaperId
,
String
uid
,
String
questionId
,
ArrayList
<
AnswersItem
>
answersItems
)
{
String
str
=
new
Gson
().
toJson
(
new
LingxiAnswerBean
(
new
AnswerBean
(
examID
,
questionPaperId
,
uid
,
questionId
,
answersItems
),
message
.
getFromAccount
(),
"56"
,
uid
));
RequestBody
body
=
RequestBody
.
create
(
MediaType
.
parse
(
"application/json; charset=utf-8"
),
str
);
Disposable
subscribe
=
ImRetrofitApi
.
Companion
.
getImRetrofitApi
().
lingxiAnswerQuestion
(
body
)
.
compose
(
RxUtils
.
INSTANCE
.
resultJavaData
())
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
it
->
{
LogUtil
.
e
(
"answerQuestion"
+
it
.
toString
());
},
throwable
->
LogUtil
.
e
(
throwable
.
getMessage
())
);
}
@Override
public
void
onMultipleItemClick
(
@NotNull
QuestionItemBean
string
,
int
position
)
{
//多选发送消息
...
...
@@ -174,12 +219,12 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
if
(
questionList
.
get
(
i
).
isSelected
()){
if
(
i
==
position
){
questionList
.
get
(
i
).
setSelected
(
false
);
selectedStr
.
remove
(
questionList
.
get
(
i
).
get
Valu
e
());
selectedStr
.
remove
(
questionList
.
get
(
i
).
get
Nam
e
());
}
}
else
{
if
(
i
==
position
){
questionList
.
get
(
i
).
setSelected
(
true
);
selectedStr
.
add
(
questionList
.
get
(
i
).
get
Valu
e
());
selectedStr
.
add
(
questionList
.
get
(
i
).
get
Nam
e
());
}
}
}
...
...
@@ -210,10 +255,6 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
for
(
IMMessage
msg
:
param
)
{
MsgAttachment
attachment
=
msg
.
getAttachment
();
if
(
attachment
instanceof
CustomAttachLingxiWhichQuestion
)
{
CustomAttachLingxiWhichQuestion
customattachlingxiwhichquestion
=
(
CustomAttachLingxiWhichQuestion
)
attachment
;
// if (customattachlingxiwhichquestion) {
//已经筛选过答案
//修改历史消息状态为已失效
Map
map1
=
msg
.
getLocalExtension
();
if
(
map1
==
null
)
{
map1
=
new
HashMap
();
...
...
@@ -224,7 +265,6 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
//通知ui刷新
getMsgAdapter
().
updateItemAtLocalExtension
(
msg
);
}
// }
}
}
}
...
...
m-im/src/main/java/com/yidianling/im/session/viewholder/adapter/AdapterLingxiMultipleChoice.kt
View file @
3616e775
...
...
@@ -41,7 +41,7 @@ class AdapterLingxiMultipleChoice : RecyclerView.Adapter<AdapterLingxiMultipleCh
}
override
fun
onBindViewHolder
(
holder
:
ViewHolder
,
position
:
Int
)
{
holder
.
tvWhichQuestion
.
text
=
tagList
[
position
].
valu
e
holder
.
tvWhichQuestion
.
text
=
tagList
[
position
].
nam
e
holder
.
tvWhichQuestion
.
setOnClickListener
{
onItemClickListener
?.
onMultipleItemClick
(
tagList
[
position
],
position
...
...
m-im/src/main/java/com/yidianling/im/session/viewholder/adapter/AdapterLingxiWhichQuestion.kt
View file @
3616e775
...
...
@@ -45,7 +45,7 @@ class AdapterLingxiWhichQuestion : RecyclerView.Adapter<AdapterLingxiWhichQuesti
}
override
fun
onBindViewHolder
(
holder
:
ViewHolder
,
position
:
Int
)
{
holder
.
tvWhichQuestion
.
text
=
tagList
[
position
].
valu
e
holder
.
tvWhichQuestion
.
text
=
tagList
[
position
].
nam
e
if
(
tagList
[
position
].
isSelected
!!
){
holder
.
tvWhichQuestion
.
background
=
ContextCompat
.
getDrawable
(
holder
.
itemView
.
context
,
R
.
drawable
.
im_background_18dp_1da1f2
)
holder
.
tvWhichQuestion
.
setTextColor
(
ContextCompat
.
getColor
(
holder
.
itemView
.
context
,
R
.
color
.
white
))
...
...
m-im/src/main/java/com/yidianling/im/session/viewholder/bean/LingxiWhichQuestionBean.kt
View file @
3616e775
package
com.yidianling.im.session.viewholder.bean
import
com.google.gson.annotations.SerializedName
data class
LingxiWhichQuestionBean
(
var
isSelected
:
Boolean
,
var
xquestionPaperId
:
String
?,
//试卷ID
var
xquestionPaperName
:
String
?,
//试卷名称
var
questionId
:
String
?,
//问题ID
var
questionTitle
:
String
?,
//问题题目
var
selectType
:
String
?,
//试卷type 1单选 2多选
var
selectVals
:
ArrayList
<
QuestionItemBean
>?
//选项
var
id
:
String
?,
//ID
var
questionPaperId
:
String
?,
//试卷ID
var
name
:
String
?,
//问题题目
var
type
:
String
?,
//试卷type radio单选,check 多选
var
options
:
ArrayList
<
QuestionItemBean
>?
//选项
)
data class
QuestionItemBean
(
var
id
:
String
?,
var
value
:
String
?,
var
isSelected
:
Boolean
?=
false
var
name
:
String
?,
var
relates
:
ArrayList
<
Relates
>?,
var
isSelected
:
Boolean
=
false
)
//回答问题bean
data class
LingxiAnswerBean
(
var
data
:
AnswerBean
,
var
fromUid
:
String
,
var
type
:
String
,
var
toUid
:
String
)
data class
AnswerBean
(
var
examId
:
String
,
var
questionPaperId
:
String
,
var
uid
:
String
,
var
questionId
:
String
,
var
answers
:
ArrayList
<
AnswersItem
>
)
data class
AnswersItem
(
var
optionId
:
String
,
var
name
:
String
,
var
other
:
String
,
var
relates
:
ArrayList
<
Relates
>
)
data class
Relates
(
var
id
:
String
?,
var
category
:
String
?,
var
name
:
String
?,
var
score
:
String
?
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment