Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
yangxiujun
/
paidan_demo
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 80de6c84
authored
Oct 18, 2023
by
刘鑫
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
替换资源文件读取方式
1 parent
49bf1f7f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
110 deletions
project-order/src/main/java/com/dituhui/pea/order/controller/PeaApiController.java
project-order/src/main/resources/json/capacity.json
project-order/src/main/resources/json/stage.json
project-order/src/main/java/com/dituhui/pea/order/controller/PeaApiController.java
View file @
80de6c8
package
com
.
dituhui
.
pea
.
order
.
controller
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.json.JSONConfig
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.order.common.jackson.JsonUtil
;
import
com.dituhui.pea.order.dto.OrganizationTreeDTO
;
import
com.dituhui.pea.order.dto.param.*
;
import
com.dituhui.pea.order.service.EngineerCalendarService
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer
;
import
com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.ResourceLoader
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -23,7 +14,6 @@ import org.springframework.web.bind.annotation.*;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
java.io.IOException
;
import
java.nio.charset.StandardCharsets
;
import
java.time.LocalDate
;
import
java.time.ZoneId
;
import
java.util.Date
;
...
...
@@ -38,7 +28,10 @@ import java.util.Date;
public
class
PeaApiController
{
private
final
EngineerCalendarService
engineerCalendarService
;
private
final
ResourceLoader
resourceLoader
;
private
static
final
String
capacity
=
"{\"groupId\": \"G100038\", \"params\": {\"beginDate\": \"2023-07-21\", \"endDate\": \"2023-07-27\", \"services\": [{\"brand\": \"博世\", \"productType\": \"多门冰箱\", \"serviceType\": \"商场样机安装\"}], \"location\": {\"addressId\":\"21231231\", \"latitude\": 120.608463, \"longitude\": 31.318442, \"name\": \"江苏省苏州市姑苏区蒋庙前\", \"address\": \"江苏省苏州市姑苏区解放大街123号\"}}, \"takeTime\": 720, \"datas\": [{\"date\": \"2023-07-21\", \"segments\": [{\"maxDuration\": 90, \"name\": \"全天\", \"beginTime\": \"2023-07-21 08:00:00\", \"endTime\": \"2023-07-21 17:59:59\", \"status\": 1, \"remain\": 3500}, {\"maxDuration\": 45, \"name\": \"上午\", \"beginTime\": \"2023-07-21 08:00:00\", \"endTime\": \"2023-07-21 11:59:59\", \"status\": 1, \"remain\": 2500}, {\"maxDuration\": 60, \"name\": \"下午\", \"beginTime\": \"2023-07-21 13:00:00\", \"endTime\": \"2023-07-21 17:59:59\", \"status\": 0, \"remain\": 1000}, {\"maxDuration\": 60, \"name\": \"时间段\", \"beginTime\": \"2023-07-21 13:00:00\", \"endTime\": \"2023-07-21 15:00:00\", \"status\": 1, \"remain\": 480}]}]}"
;
private
static
final
String
stage
=
"{\"orderId\": \"X10001\", \"engineerCode\": \"E12005\", \"engineerName\": \"祝枝山\", \"engineerCodeAssist\": \"E12446\", \"engineerNameAssist\": \"李晓阳\", \"planVisitTime\": \"2023-07-27 12:00:00\", \"realtimeInfo\": {\"engineerLocation\": {\"latitude\": 31.349701, \"longitude\": 120.675945, \"address\": \"江苏省苏州市苏州工业园区和顺路\", \"name\": \"和顺大酒店\"}, \"estimate\": {\"distance\": 2300, \"arriveTime\": \"2023-07-27 12:12:00\"}}}"
;
/**
...
...
@@ -114,9 +107,7 @@ public class PeaApiController {
//查询日期起止参数限制为一月
ClassPathResource
classPathResource
=
new
ClassPathResource
(
"json/capacity.json"
);
String
jsonStr
=
FileUtil
.
readString
(
classPathResource
.
getFile
(),
StandardCharsets
.
UTF_8
);
CapacityQueryDTO
.
Result
result
=
JsonUtil
.
parse
(
jsonStr
,
CapacityQueryDTO
.
Result
.
class
).
get
();
CapacityQueryDTO
.
Result
result
=
JsonUtil
.
parse
(
capacity
,
CapacityQueryDTO
.
Result
.
class
).
get
();
result
.
setParams
(
reqDTO
);
return
Result
.
success
(
result
);
}
...
...
@@ -140,9 +131,7 @@ public class PeaApiController {
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
,
timezone
=
"GMT+8"
)
@RequestParam
(
"endDate"
)
Date
endDate
)
throws
IOException
{
ClassPathResource
classPathResource
=
new
ClassPathResource
(
"json/capacity.json"
);
String
jsonStr
=
FileUtil
.
readString
(
classPathResource
.
getFile
(),
StandardCharsets
.
UTF_8
);
CapacityQueryDTO
.
Result
resultTemp
=
JsonUtil
.
parse
(
jsonStr
,
CapacityQueryDTO
.
Result
.
class
).
get
();
CapacityQueryDTO
.
Result
resultTemp
=
JsonUtil
.
parse
(
capacity
,
CapacityQueryDTO
.
Result
.
class
).
get
();
CapacityQueryDTO
.
PersonalResult
result
=
new
CapacityQueryDTO
.
PersonalResult
();
result
.
setDatas
(
resultTemp
.
getDatas
());
...
...
@@ -180,21 +169,19 @@ public class PeaApiController {
}
/**
* 6.2GET 预约单服务进度查询
*
* @param orderId 工单号码
* @return 工单进度信息
* @apiNote 查询预约单状态,返回指定技术员(主,副)信息、推荐上门时间。如果查询为服务当日,增加对应技术员准实时位置,距离公里数,预计到达时间等
*/
@GetMapping
(
"/order/stage/query"
)
public
Result
<
OrderDTO
.
StageResult
>
orderStage
(
@NotBlank
@RequestParam
(
"orderId"
)
String
orderId
)
throws
IOException
{
/**
* 6.2GET 预约单服务进度查询
*
* @param orderId 工单号码
* @return 工单进度信息
* @apiNote 查询预约单状态,返回指定技术员(主,副)信息、推荐上门时间。如果查询为服务当日,增加对应技术员准实时位置,距离公里数,预计到达时间等
*/
@GetMapping
(
"/order/stage/query"
)
public
Result
<
OrderDTO
.
StageResult
>
orderStage
(
@NotBlank
@RequestParam
(
"orderId"
)
String
orderId
)
throws
IOException
{
ClassPathResource
classPathResource
=
new
ClassPathResource
(
"json/stage.json"
);
String
jsonStr
=
FileUtil
.
readString
(
classPathResource
.
getFile
(),
StandardCharsets
.
UTF_8
);
OrderDTO
.
StageResult
stageResult
=
JsonUtil
.
parse
(
jsonStr
,
OrderDTO
.
StageResult
.
class
).
get
();
stageResult
.
setOrderId
(
orderId
);
OrderDTO
.
StageResult
stageResult
=
JsonUtil
.
parse
(
stage
,
OrderDTO
.
StageResult
.
class
).
get
();
stageResult
.
setOrderId
(
orderId
);
return
Result
.
success
(
stageResult
);
}
...
...
project-order/src/main/resources/json/capacity.json
deleted
100644 → 0
View file @
49bf1f7
{
"groupId"
:
"G100038"
,
"params"
:
{
"beginDate"
:
"2023-07-21"
,
"endDate"
:
"2023-07-27"
,
"services"
:
[{
"brand"
:
"博世"
,
"productType"
:
"多门冰箱"
,
"serviceType"
:
"商场样机安装"
}],
"location"
:
{
"addressId"
:
"21231231"
,
"latitude"
:
120.608463
,
"longitude"
:
31.318442
,
"name"
:
"江苏省苏州市姑苏区蒋庙前"
,
"address"
:
"江苏省苏州市姑苏区解放大街123号"
}
},
"takeTime"
:
720
,
"datas"
:
[
{
"date"
:
"2023-07-21"
,
"segments"
:
[
{
"maxDuration"
:
90
,
"name"
:
"全天"
,
"beginTime"
:
"2023-07-21 08:00:00"
,
"endTime"
:
"2023-07-21 17:59:59"
,
"status"
:
1
,
"remain"
:
3500
},
{
"maxDuration"
:
45
,
"name"
:
"上午"
,
"beginTime"
:
"2023-07-21 08:00:00"
,
"endTime"
:
"2023-07-21 11:59:59"
,
"status"
:
1
,
"remain"
:
2500
},
{
"maxDuration"
:
60
,
"name"
:
"下午"
,
"beginTime"
:
"2023-07-21 13:00:00"
,
"endTime"
:
"2023-07-21 17:59:59"
,
"status"
:
0
,
"remain"
:
1000
},
{
"maxDuration"
:
60
,
"name"
:
"时间段"
,
"beginTime"
:
"2023-07-21 13:00:00"
,
"endTime"
:
"2023-07-21 15:00:00"
,
"status"
:
1
,
"remain"
:
480
}
]
}
]
}
\ No newline at end of file
project-order/src/main/resources/json/stage.json
deleted
100644 → 0
View file @
49bf1f7
{
"orderId"
:
"X10001"
,
"engineerCode"
:
"E12005"
,
"engineerName"
:
"祝枝山"
,
"engineerCodeAssist"
:
"E12446"
,
"engineerNameAssist"
:
"李晓阳"
,
"planVisitTime"
:
"2023-07-27 12:00:00"
,
"realtimeInfo"
:
{
"engineerLocation"
:
{
"latitude"
:
31.349701
,
"longitude"
:
120.675945
,
"address"
:
"江苏省苏州市苏州工业园区和顺路"
,
"name"
:
"和顺大酒店"
},
"estimate"
:
{
"distance"
:
2300
,
"arriveTime"
:
"2023-07-27 12:12:00"
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
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 post a comment