Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
konke-ai-alibaba-mcp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
何金镒
konke-ai-alibaba-mcp
Commits
1027c09e
Commit
1027c09e
authored
Sep 18, 2025
by
何金镒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
建发接口优化 2
parent
6870a890
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
283 additions
and
169 deletions
+283
-169
src/main/java/com/ikonke/konkeaialibabamcp/aitools/CDCVisitorTools.java
...com/ikonke/konkeaialibabamcp/aitools/CDCVisitorTools.java
+5
-5
src/main/java/com/ikonke/konkeaialibabamcp/aitools/DeviceTools.java
...ava/com/ikonke/konkeaialibabamcp/aitools/DeviceTools.java
+151
-151
src/main/java/com/ikonke/konkeaialibabamcp/service/cdc/spaces/SpacesService.java
...e/konkeaialibabamcp/service/cdc/spaces/SpacesService.java
+25
-13
src/main/java/com/ikonke/konkeaialibabamcp/utils/TimeSlotMerger.java
...va/com/ikonke/konkeaialibabamcp/utils/TimeSlotMerger.java
+102
-0
No files found.
src/main/java/com/ikonke/konkeaialibabamcp/aitools/CDCVisitorTools.java
View file @
1027c09e
...
...
@@ -6,8 +6,8 @@ import org.springframework.stereotype.Service;
/**
* 访客相关
*/
@Slf4j
@Service
public
class
CDCVisitorTools
{
}
//
@Slf4j
//
@Service
//
public class CDCVisitorTools {
//
//
}
src/main/java/com/ikonke/konkeaialibabamcp/aitools/DeviceTools.java
View file @
1027c09e
This diff is collapsed.
Click to expand it.
src/main/java/com/ikonke/konkeaialibabamcp/service/cdc/spaces/SpacesService.java
View file @
1027c09e
...
...
@@ -9,6 +9,7 @@ import cn.hutool.json.JSONObject;
import
cn.hutool.json.JSONUtil
;
import
com.ikonke.konkeaialibabamcp.service.cdc.CdcHttpUtils
;
import
com.ikonke.konkeaialibabamcp.utils.CDCUtils
;
import
com.ikonke.konkeaialibabamcp.utils.TimeSlotMerger
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
@@ -164,22 +165,33 @@ public class SpacesService {
}
}
JSONArray
response_time
=
new
JSONArray
();
for
(
int
j
=
timeSegmentIndex
;
j
<
48
;
j
++){
Integer
number
=
info
.
getInt
(
j
);
//0=不可预定 1=可预订 2=已被预定
JSONObject
jsonObject1
=
new
JSONObject
();
jsonObject1
.
set
(
"timeSegment"
,
CDCUtils
.
time_segment
[
j
]);
if
(
number
==
1
){
jsonObject1
.
set
(
"availability"
,
"可预订"
);
}
else
if
(
number
==
2
){
jsonObject1
.
set
(
"availability"
,
"已被预定"
);
// JSONArray response_time = new JSONArray();
// for( int j = timeSegmentIndex; j < 48; j++){
// Integer number = info.getInt(j);//0=不可预定 1=可预订 2=已被预定
// JSONObject jsonObject1 = new JSONObject();
// jsonObject1.set("timeSegment", CDCUtils.time_segment[j]);
//
// if(number == 1){
// jsonObject1.set("availability", "可预订");
// }else if(number == 2){
// jsonObject1.set("availability", "已被预定");
// }else{
// jsonObject1.set("availability", "不可预定");
// }
// response_time.set(jsonObject1);
// }
int
[]
intArray
=
new
int
[
info
.
size
()];
for
(
int
i
=
0
;
i
<
info
.
size
();
i
++)
{
if
(
i
<
timeSegmentIndex
){
intArray
[
i
]
=
0
;
}
else
{
jsonObject1
.
set
(
"availability"
,
"不可预定"
);
intArray
[
i
]
=
info
.
getInt
(
i
);
}
response_time
.
set
(
jsonObject1
);
}
response
.
set
(
"time"
,
response_time
);
List
<
TimeSlotMerger
.
MergedSlot
>
merged
=
TimeSlotMerger
.
mergeTimeSlots
(
intArray
);
response
.
set
(
"time"
,
merged
);
}
else
{
response
.
set
(
"time"
,
"不可预约"
);
}
...
...
src/main/java/com/ikonke/konkeaialibabamcp/utils/TimeSlotMerger.java
0 → 100644
View file @
1027c09e
package
com.ikonke.konkeaialibabamcp.utils
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
TimeSlotMerger
{
public
static
class
MergedSlot
{
private
String
start
;
private
String
end
;
private
String
available
;
public
MergedSlot
(
String
start
,
String
end
,
String
available
)
{
this
.
start
=
start
;
this
.
end
=
end
;
this
.
available
=
available
;
}
public
String
getStart
()
{
return
start
;
}
public
String
getEnd
()
{
return
end
;
}
public
String
getAvailable
()
{
return
available
;
}
@Override
public
String
toString
()
{
return
String
.
format
(
"%s-%s: %s"
,
start
,
end
,
available
);
}
}
/**
* 合并时间段的方法
* @param slots 包含48个元素的数组,每个元素为0或1
* @return 合并后的时间段列表
* @throws IllegalArgumentException 如果输入不符合要求
*/
public
static
List
<
MergedSlot
>
mergeTimeSlots
(
int
[]
slots
)
{
// 验证输入
if
(
slots
==
null
||
slots
.
length
!=
48
)
{
throw
new
IllegalArgumentException
(
"输入必须是包含48个元素的数组"
);
}
// for (int slot : slots) {
// if (slot != 0 && slot != 1) {
// throw new IllegalArgumentException("数组元素只能是0或1");
// }
// }
List
<
MergedSlot
>
mergedSlots
=
new
ArrayList
<>();
if
(
slots
.
length
==
0
)
{
return
mergedSlots
;
}
int
currentStatus
=
slots
[
0
];
int
startTimeIndex
=
0
;
// 遍历所有时间段
for
(
int
i
=
1
;
i
<
slots
.
length
;
i
++)
{
if
(
slots
[
i
]
!=
currentStatus
)
{
// 状态改变,记录上一个时间段
mergedSlots
.
add
(
new
MergedSlot
(
formatTime
(
startTimeIndex
),
formatTime
(
i
),
currentStatus
==
1
?
"可预约"
:
"不可预约"
));
// 更新当前状态和开始索引
currentStatus
=
slots
[
i
];
startTimeIndex
=
i
;
}
}
// 添加最后一个时间段
mergedSlots
.
add
(
new
MergedSlot
(
formatTime
(
startTimeIndex
),
formatTime
(
slots
.
length
),
currentStatus
==
1
?
"可预约"
:
"不可预约"
));
return
mergedSlots
;
}
/**
* 将时间段索引转换为时间字符串
* @param index 时间段索引(0-48)
* @return 格式化的时间字符串,如"00:00"
*/
private
static
String
formatTime
(
int
index
)
{
int
hours
=
index
/
2
;
int
minutes
=
(
index
%
2
)
*
30
;
// 格式化小时和分钟为两位数
return
String
.
format
(
"%02d:%02d"
,
hours
,
minutes
);
}
public
static
void
main
(
String
[]
args
)
{
int
[]
slots
=
{
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
0
,
0
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
2
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
};
List
<
MergedSlot
>
merged
=
mergeTimeSlots
(
slots
);
// 输出结果
for
(
MergedSlot
slot
:
merged
)
{
System
.
out
.
println
(
slot
);
}
}
}
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