取消预约对接
This commit is contained in:
1 parent
2ac305e479
commit
5db050464a
4 files changed
+35
-12
No files matched your search
+18
@@ -318,6 +318,7 @@ public class VisitorsServiceImpl extends ServiceImpl<VisitorsMapper, VisitorsEnt
|
||||
wrapper.eq(VisitorsEntity::getUserId, userId);
|
||||
wrapper.eq(VisitorsEntity::getType, VisitorTypeEnum.FKSQ.getType());
|
||||
wrapper.eq(StrUtils.isNotBlank(visitors.getCheckStatus()),VisitorsEntity::getCheckStatus, visitors.getCheckStatus());
|
||||
wrapper.orderByDesc(VisitorsEntity::getCreateTime);
|
||||
Page pageData = baseMapper.selectPage(page, wrapper);
|
||||
List<VisitorsEntity> records = pageData.getRecords();
|
||||
|
||||
@@ -329,11 +330,28 @@ public class VisitorsServiceImpl extends ServiceImpl<VisitorsMapper, VisitorsEnt
|
||||
return resultPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消访客预约
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public Object cancelVisitor(Long id) {
|
||||
//查询该访客的信息,获取预约的订单ID
|
||||
VisitorsEntity dataVisitors = baseMapper.selectById(id);
|
||||
if (dataVisitors == null) {
|
||||
throw new ServiceException("没有该预约信息");
|
||||
}
|
||||
VisitorsEntity visitors = new VisitorsEntity();
|
||||
visitors.setId(id);
|
||||
visitors.setCheckStatus(TaskCheckStatusEnum.CANCEL.getCode());
|
||||
|
||||
|
||||
String appointRecordId = dataVisitors.getAppointRecordId();
|
||||
List<String> list = Arrays.asList(appointRecordId);
|
||||
remoterVisitorService.cancelAppointments(list);
|
||||
|
||||
return baseMapper.updateById(visitors);
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -55,15 +55,15 @@ public interface RemoterVisitorService {
|
||||
* @param recordIds
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/cancel")
|
||||
public R cancelAppointments(@RequestBody List<String> recordIds);
|
||||
@PostMapping("/visitors/cancel")
|
||||
public void cancelAppointments(@RequestBody List<String> recordIds);
|
||||
|
||||
/**
|
||||
* 预约登记
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/register")
|
||||
@PostMapping("/visitors/register")
|
||||
public R<RegisterAppointmentResponse> registerAppointment(@Valid @RequestBody RegisterAppointmentRequest request);
|
||||
|
||||
/**
|
||||
@@ -71,6 +71,6 @@ public interface RemoterVisitorService {
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/checkout")
|
||||
@PostMapping("/visitors/checkout")
|
||||
public R checkOut(@Valid @RequestBody CheckOutRequest request);
|
||||
}
|
||||
+2
-2
@@ -68,9 +68,9 @@ public class VisitorController {
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/cancel")
|
||||
public R cancelAppointments(@RequestBody List<String> recordIds) {
|
||||
public void cancelAppointments(@RequestBody List<String> recordIds) {
|
||||
visitorService.cancelAppointments(recordIds);
|
||||
return R.ok();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+11
-6
@@ -22,6 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -57,9 +58,7 @@ public class VisitorService extends BaseHikvisionService {
|
||||
String code = visitorObjectResponse.getCode();
|
||||
if (code.equals("0")) {
|
||||
// 成功情况
|
||||
log.info("海康预约成功,预约记录ID: {}",
|
||||
visitorObjectResponse.getData() != null ?
|
||||
visitorObjectResponse.getData().getAppointRecordId() : "null");
|
||||
log.info("海康预约成功");
|
||||
} else if (code.equals("0x0531f002")) {
|
||||
throw new ServiceException("预约时间不能小于当前日期");
|
||||
} else if (code.equals("0x0531401d")) {
|
||||
@@ -225,9 +224,12 @@ public class VisitorService extends BaseHikvisionService {
|
||||
String apiPath = properties.getArtemisPath() +
|
||||
properties.getApis().get("cancel-appointment");
|
||||
|
||||
// 3. 构建请求体
|
||||
JSONObject requestBody = new JSONObject();
|
||||
requestBody.put("appointRecordIds", recordIds);
|
||||
// 3. 构建请求体 - 直接传递字符串数组,格式如: ["321654987"]
|
||||
JSONArray requestBody = new JSONArray();
|
||||
requestBody.addAll(recordIds);
|
||||
|
||||
// 添加日志便于调试
|
||||
log.info("取消预约请求体: {}", requestBody.toJSONString());
|
||||
|
||||
// 4. 发送请求
|
||||
String response = ArtemisHttpUtil.doPostStringArtemis(
|
||||
@@ -235,6 +237,9 @@ public class VisitorService extends BaseHikvisionService {
|
||||
requestBody.toJSONString(),
|
||||
null, null, "application/json", null
|
||||
);
|
||||
|
||||
// 添加日志便于调试
|
||||
log.info("取消预约响应: {}", response);
|
||||
|
||||
// 5. 处理响应
|
||||
CancelAppointmentResponse res = parseResponse(response);
|
||||
|
||||
Reference in new issue
Block a user