|
@@ -0,0 +1,522 @@
|
|
|
|
|
+package com.hz3r.infrastructure.park.client;
|
|
|
|
|
+
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
|
|
+
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+@Component
|
|
|
|
|
+public class OaClientImpl implements OaClient {
|
|
|
|
|
+//
|
|
|
|
|
+// private static final String OA_PATH = "/papi/openapi";
|
|
|
|
|
+// public static final String OAUTH2_AUTHORIZE_CODE_API = OA_PATH + "/oauth2/authorize";
|
|
|
|
|
+// public static final String OAUTH2_ACCESS_TOKEN_API = OA_PATH + "/oauth2/access_token";
|
|
|
|
|
+// public static final String WORKFLOW_CORE_PA_SERVICE_DO_CREATE_REQUEST_API = OA_PATH + "/api/workflow/core/paService/v1/doCreateRequest";
|
|
|
|
|
+// public static final String QUERY_HRM_API = OA_PATH + "/api/hrm/restful/queryOrg";
|
|
|
|
|
+// public static final String QUERY_EMPLOYEE_API = OA_PATH + "/api/hrm/restful/queryEmployee";
|
|
|
|
|
+//
|
|
|
|
|
+// @Value("${oa.host}")
|
|
|
|
|
+// private String host;
|
|
|
|
|
+// @Value("${oa.app_key}")
|
|
|
|
|
+// private String appKey;
|
|
|
|
|
+// @Value("${oa.app_secret}")
|
|
|
|
|
+// private String appSecret;
|
|
|
|
|
+//
|
|
|
|
|
+// // 工作流配置常量
|
|
|
|
|
+// private static final String WORKFLOW_ID = "1219290225737072720";
|
|
|
|
|
+// private static final String FORM_ID = "7833764773709572808";
|
|
|
|
|
+// private static final String FORM_DATA_ID = "1219290225737072642";
|
|
|
|
|
+// private static final String FORM_USER_ID = "1209986175391637546";
|
|
|
|
|
+//
|
|
|
|
|
+// private static final Integer PAGE_SIZE = 100;
|
|
|
|
|
+//
|
|
|
|
|
+// // 字段ID映射
|
|
|
|
|
+// private static final Map<String, String> FIELD_MAPPING = new HashMap<>();
|
|
|
|
|
+//
|
|
|
|
|
+// static {
|
|
|
|
|
+// // 基本信息字段
|
|
|
|
|
+// FIELD_MAPPING.put("reservationNo", "1221039694631534592");
|
|
|
|
|
+// FIELD_MAPPING.put("visitorName", "1221039694631534593");
|
|
|
|
|
+// FIELD_MAPPING.put("visitorPhone", "1221039694631534594");
|
|
|
|
|
+// FIELD_MAPPING.put("visitorIdType", "1221039694631534595");
|
|
|
|
|
+// FIELD_MAPPING.put("visitorIdNumber", "1221039694631534596");
|
|
|
|
|
+// FIELD_MAPPING.put("visitorCompany", "1221039827683246082");
|
|
|
|
|
+// FIELD_MAPPING.put("visitReason", "1221039827683246083");
|
|
|
|
|
+// FIELD_MAPPING.put("plannedVisitTime", "1221039827683246084");
|
|
|
|
|
+// FIELD_MAPPING.put("plannedLeaveTime", "1221039827683246085");
|
|
|
|
|
+// FIELD_MAPPING.put("intervieweeName", "1221039827683246086");
|
|
|
|
|
+// FIELD_MAPPING.put("intervieweePhone", "1221039930972176390");
|
|
|
|
|
+// FIELD_MAPPING.put("intervieweeDepartment", "1221039930972176391");
|
|
|
|
|
+// FIELD_MAPPING.put("visitLocation", "1221039930972176392");
|
|
|
|
|
+// FIELD_MAPPING.put("visitorCount", "1221039930972176393");
|
|
|
|
|
+//
|
|
|
|
|
+// // 车辆信息字段
|
|
|
|
|
+// FIELD_MAPPING.put("licensePlateNumber", "1221040197159485445");
|
|
|
|
|
+// FIELD_MAPPING.put("vehicleType", "1221040197159485446");
|
|
|
|
|
+// FIELD_MAPPING.put("vehicleBrand", "1221040197159485447");
|
|
|
|
|
+// FIELD_MAPPING.put("vehicleColor", "1221040197159485448");
|
|
|
|
|
+// FIELD_MAPPING.put("driverName", "1221040252994060290");
|
|
|
|
|
+// FIELD_MAPPING.put("driverPhone", "1221040252994060291");
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// @Resource
|
|
|
|
|
+// private RestTemplateUtil restTemplateUtil;
|
|
|
|
|
+// @Autowired
|
|
|
|
|
+// protected RedisUtil redisUtil;
|
|
|
|
|
+//
|
|
|
|
|
+// public final static String accessTokenKey = "access_token";
|
|
|
|
|
+// @Override
|
|
|
|
|
+// public String setAccessToken() {
|
|
|
|
|
+// JSONObject jsonObject = oauth2AccessToken();
|
|
|
|
|
+// redisUtil.set(accessTokenKey, jsonObject.getString("accessToken"), jsonObject.getLong("expires_in"), TimeUnit.MILLISECONDS);
|
|
|
|
|
+//
|
|
|
|
|
+// return jsonObject.getString("accessToken");
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// @Override
|
|
|
|
|
+// public String getAccessToken() {
|
|
|
|
|
+//// String access_token = (String) redisUtil.get(accessTokenKey);
|
|
|
|
|
+//// if(!StringUtils.hasText(access_token)){
|
|
|
|
|
+//// access_token = setAccessToken();
|
|
|
|
|
+//// }
|
|
|
|
|
+// JSONObject jsonObject = oauth2AccessToken();
|
|
|
|
|
+// return jsonObject.getString("accessToken");
|
|
|
|
|
+//// return access_token;
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// @Override
|
|
|
|
|
+// public String oauth2AuthorizeCode() {
|
|
|
|
|
+// Map<String, Object> params = new HashMap<>();
|
|
|
|
|
+//
|
|
|
|
|
+// params.put("corpid", "2bcaddf107fb6254d6cc6f29d0770883");
|
|
|
|
|
+// params.put("response_type", "code");
|
|
|
|
|
+// params.put("state", "");
|
|
|
|
|
+// JSONObject jsonObject = executeAndReturnRoot(OAUTH2_AUTHORIZE_CODE_API, null, params, HttpMethod.GET, null);
|
|
|
|
|
+//
|
|
|
|
|
+// return jsonObject.getString("code");
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// @Override
|
|
|
|
|
+// public JSONObject oauth2AccessToken() {
|
|
|
|
|
+// Map<String, Object> params = new HashMap<>();
|
|
|
|
|
+//
|
|
|
|
|
+// params.put("app_key", appKey);
|
|
|
|
|
+// params.put("app_secret",appSecret);
|
|
|
|
|
+// params.put("grant_type", "authorization_code");
|
|
|
|
|
+// params.put("code", oauth2AuthorizeCode());
|
|
|
|
|
+// JSONObject jsonObject = executeAndReturnRoot(OAUTH2_ACCESS_TOKEN_API, null, params, HttpMethod.POST, null);
|
|
|
|
|
+//
|
|
|
|
|
+// return jsonObject;
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// @Override
|
|
|
|
|
+// public JSONObject workflowCorePaServiceDoCreate(VisitorReservationRequest request) {
|
|
|
|
|
+// HttpHeaders headers = new HttpHeaders();
|
|
|
|
|
+// headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
|
+// Map<String, Object> params = buildWorkflowParams(request);
|
|
|
|
|
+// JSONObject jsonObject = executeAndReturnRootWithMessage(WORKFLOW_CORE_PA_SERVICE_DO_CREATE_REQUEST_API, params, null, HttpMethod.POST, headers);
|
|
|
|
|
+//
|
|
|
|
|
+// return jsonObject;
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// @Override
|
|
|
|
|
+// public List<CompanyAndDepartmentVo> hrmQuery(HrmQueryRequest request) {
|
|
|
|
|
+//
|
|
|
|
|
+// HttpHeaders headers = new HttpHeaders();
|
|
|
|
|
+// headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
|
+//
|
|
|
|
|
+// Map<String, Object> queryParams = new HashMap<>();
|
|
|
|
|
+//
|
|
|
|
|
+// // 基础参数
|
|
|
|
|
+// queryParams.put("access_token", getAccessToken());
|
|
|
|
|
+//
|
|
|
|
|
+// List<CompanyAndDepartmentVo> companyAndDepartmentVos = new ArrayList<>();
|
|
|
|
|
+//
|
|
|
|
|
+// int totalPageNo;
|
|
|
|
|
+// int current = 1;
|
|
|
|
|
+//
|
|
|
|
|
+// Map<String, Object> body = new HashMap<>();
|
|
|
|
|
+// body.put("pageSize", PAGE_SIZE);
|
|
|
|
|
+// body.put("typeList", Arrays.asList(request.getType().getCode()));
|
|
|
|
|
+//
|
|
|
|
|
+// Optional.ofNullable(request.getSubcompany()).ifPresent(arg->body.put("subcompanyList", Arrays.asList(arg)));
|
|
|
|
|
+//
|
|
|
|
|
+// do {
|
|
|
|
|
+// body.put("current", current);
|
|
|
|
|
+//
|
|
|
|
|
+// JSONObject result = executeAndReturnRootWithMessage(QUERY_HRM_API, body, queryParams, HttpMethod.POST, headers);
|
|
|
|
|
+// JSONObject data = result.getJSONObject("data");
|
|
|
|
|
+// totalPageNo = data.getIntValue("total") / PAGE_SIZE + 1;
|
|
|
|
|
+//
|
|
|
|
|
+// JSONArray list = data.getJSONArray("data");
|
|
|
|
|
+// if (!CollectionUtils.isEmpty(list)) {
|
|
|
|
|
+// list.toList(JSONObject.class).forEach(jsonObject -> {
|
|
|
|
|
+// CompanyAndDepartmentVo companyAndDepartmentVo = jsonObject.to(CompanyAndDepartmentVo.class);
|
|
|
|
|
+// companyAndDepartmentVos.add(companyAndDepartmentVo);
|
|
|
|
|
+// });
|
|
|
|
|
+// }
|
|
|
|
|
+// } while (current++ < totalPageNo);
|
|
|
|
|
+//
|
|
|
|
|
+// return companyAndDepartmentVos;
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// @Override
|
|
|
|
|
+// public List<CompanyAndDepartmentVo> hrmQuery1(HrmQueryRequest request) {
|
|
|
|
|
+// HttpHeaders headers = new HttpHeaders();
|
|
|
|
|
+// headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
|
+//
|
|
|
|
|
+// Map<String, Object> queryParams = new HashMap<>();
|
|
|
|
|
+//
|
|
|
|
|
+// // 基础参数
|
|
|
|
|
+// queryParams.put("access_token", getAccessToken());
|
|
|
|
|
+//
|
|
|
|
|
+// List<CompanyAndDepartmentVo> companyAndDepartmentVos = new ArrayList<>();
|
|
|
|
|
+//
|
|
|
|
|
+// int totalPageNo;
|
|
|
|
|
+// int current = 1;
|
|
|
|
|
+//
|
|
|
|
|
+// Map<String, Object> body = new HashMap<>();
|
|
|
|
|
+// body.put("pageSize", PAGE_SIZE);
|
|
|
|
|
+// body.put("typeList", Arrays.asList(SyncTypeEnum.DEPARTMENT.getCode(), SyncTypeEnum.SUBCOMPANY.getCode()));
|
|
|
|
|
+//
|
|
|
|
|
+// do {
|
|
|
|
|
+// body.put("current", current);
|
|
|
|
|
+//
|
|
|
|
|
+// JSONObject result = executeAndReturnRootWithMessage(QUERY_HRM_API, body, queryParams, HttpMethod.POST, headers);
|
|
|
|
|
+// JSONObject data = result.getJSONObject("data");
|
|
|
|
|
+// totalPageNo = data.getIntValue("total") / PAGE_SIZE + 1;
|
|
|
|
|
+//
|
|
|
|
|
+// JSONArray list = data.getJSONArray("data");
|
|
|
|
|
+// if (!CollectionUtils.isEmpty(list)) {
|
|
|
|
|
+// list.toList(JSONObject.class).forEach(jsonObject -> {
|
|
|
|
|
+// CompanyAndDepartmentVo companyAndDepartmentVo = jsonObject.to(CompanyAndDepartmentVo.class);
|
|
|
|
|
+// companyAndDepartmentVos.add(companyAndDepartmentVo);
|
|
|
|
|
+// });
|
|
|
|
|
+// }
|
|
|
|
|
+// } while (current++ < totalPageNo);
|
|
|
|
|
+//
|
|
|
|
|
+// return companyAndDepartmentVos;
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// @Override
|
|
|
|
|
+// public List<OaEmployeeVo> employeeQuery(EmployeeQueryRequest request) {
|
|
|
|
|
+// HttpHeaders headers = new HttpHeaders();
|
|
|
|
|
+// headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
|
+//
|
|
|
|
|
+// Map<String, Object> queryParams = new HashMap<>();
|
|
|
|
|
+//
|
|
|
|
|
+// // 基础参数
|
|
|
|
|
+// queryParams.put("access_token", getAccessToken());
|
|
|
|
|
+//
|
|
|
|
|
+// List<OaEmployeeVo> oaEmployeeVos = new ArrayList<>();
|
|
|
|
|
+//
|
|
|
|
|
+// int totalPageNo;
|
|
|
|
|
+// int current = 1;
|
|
|
|
|
+//
|
|
|
|
|
+// Map<String, Object> body = new HashMap<>();
|
|
|
|
|
+// body.put("pageSize", PAGE_SIZE);
|
|
|
|
|
+// body.put("subcompanyIds", Arrays.asList(request.getSubcompanyId()));
|
|
|
|
|
+//
|
|
|
|
|
+// do {
|
|
|
|
|
+// body.put("current", current);
|
|
|
|
|
+//
|
|
|
|
|
+// JSONObject result = executeAndReturnRootWithMessage(QUERY_EMPLOYEE_API, body, queryParams, HttpMethod.POST, headers);
|
|
|
|
|
+// JSONObject data = result.getJSONObject("data");
|
|
|
|
|
+// totalPageNo = data.getIntValue("total") / PAGE_SIZE + 1;
|
|
|
|
|
+//
|
|
|
|
|
+// JSONArray list = data.getJSONArray("data");
|
|
|
|
|
+// if (!CollectionUtils.isEmpty(list)) {
|
|
|
|
|
+// list.toList(JSONObject.class).forEach(jsonObject -> {
|
|
|
|
|
+// OaEmployeeVo oaEmployeeVo = jsonObject.to(OaEmployeeVo.class);
|
|
|
|
|
+// if (StringUtils.hasText(oaEmployeeVo.getJob_num())) {
|
|
|
|
|
+// oaEmployeeVos.add(oaEmployeeVo);
|
|
|
|
|
+// }
|
|
|
|
|
+// });
|
|
|
|
|
+// }
|
|
|
|
|
+// } while (current++ < totalPageNo);
|
|
|
|
|
+//
|
|
|
|
|
+// return oaEmployeeVos;
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// private JSONObject executeAndReturnRoot(String apiUrl, Object body, Map<String, Object> params, HttpMethod method, HttpHeaders headers) {
|
|
|
|
|
+//
|
|
|
|
|
+// try {
|
|
|
|
|
+//
|
|
|
|
|
+// JSONObject root = restTemplateUtil.exchange(host+apiUrl, method, headers, body, params, JSONObject.class);
|
|
|
|
|
+//
|
|
|
|
|
+// log.info("****************************");
|
|
|
|
|
+// log.info("****************************");
|
|
|
|
|
+// log.info("****************************");
|
|
|
|
|
+// log.info(apiUrl);
|
|
|
|
|
+// log.info("****************************");
|
|
|
|
|
+// log.info("************body************");
|
|
|
|
|
+// log.info(JSON.toJSONString(body));
|
|
|
|
|
+// log.info("****************************");
|
|
|
|
|
+// log.info("************param************");
|
|
|
|
|
+// log.info(JSON.toJSONString(params));
|
|
|
|
|
+// log.info("****************************");
|
|
|
|
|
+// log.info("****************************");
|
|
|
|
|
+// log.info(root.toJSONString());
|
|
|
|
|
+// log.info("****************************");
|
|
|
|
|
+// log.info("****************************");
|
|
|
|
|
+// log.info("****************************");
|
|
|
|
|
+//
|
|
|
|
|
+// if (ObjectUtils.isEmpty(root)
|
|
|
|
|
+// || !"0".equals(root.getString("errcode"))) {
|
|
|
|
|
+// throw new ServerRuntimeException("OAError", "OA接口执行失败");
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// return root;
|
|
|
|
|
+// } catch (Exception e) {
|
|
|
|
|
+// throw new ServerRuntimeException("OAError", "请求OA接口失败", e);
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// private JSONObject executeAndReturnRootWithMessage(String apiUrl, Object body, Map<String, Object> params, HttpMethod method, HttpHeaders headers) {
|
|
|
|
|
+//
|
|
|
|
|
+// try {
|
|
|
|
|
+//
|
|
|
|
|
+// JSONObject root = restTemplateUtil.exchange(host+apiUrl, method, headers, body, params, JSONObject.class);
|
|
|
|
|
+//
|
|
|
|
|
+// log.info("****************************");
|
|
|
|
|
+// log.info("****************************");
|
|
|
|
|
+// log.info("****************************");
|
|
|
|
|
+// log.info(apiUrl);
|
|
|
|
|
+// log.info("****************************");
|
|
|
|
|
+// log.info("************body************");
|
|
|
|
|
+// log.info(JSON.toJSONString(body));
|
|
|
|
|
+// log.info("****************************");
|
|
|
|
|
+// log.info("************param************");
|
|
|
|
|
+// log.info(JSON.toJSONString(params));
|
|
|
|
|
+// log.info("****************************");
|
|
|
|
|
+// log.info("****************************");
|
|
|
|
|
+// log.info(root.toJSONString());
|
|
|
|
|
+// log.info("****************************");
|
|
|
|
|
+// log.info("****************************");
|
|
|
|
|
+// log.info("****************************");
|
|
|
|
|
+//
|
|
|
|
|
+// if (ObjectUtils.isEmpty(root)
|
|
|
|
|
+// || !"0".equals(root.getJSONObject("message").getString("errcode"))) {
|
|
|
|
|
+// throw new ServerRuntimeException("OAError", "OA接口执行失败");
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// return root;
|
|
|
|
|
+// } catch (Exception e) {
|
|
|
|
|
+// throw new ServerRuntimeException("OAError", "请求OA接口失败", e);
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// /**
|
|
|
|
|
+// * 根据访客预约请求构建工作流提交参数
|
|
|
|
|
+// */
|
|
|
|
|
+// public Map<String, Object> buildWorkflowParams(VisitorReservationRequest request) {
|
|
|
|
|
+// try {
|
|
|
|
|
+// Map<String, Object> params = new HashMap<>();
|
|
|
|
|
+//
|
|
|
|
|
+// // 基础参数
|
|
|
|
|
+// params.put("access_token", getAccessToken());
|
|
|
|
|
+// params.put("userid", FORM_USER_ID);
|
|
|
|
|
+// params.put("requestname", generateRequestName(request));
|
|
|
|
|
+// params.put("workflowId", WORKFLOW_ID);
|
|
|
|
|
+// params.put("isnextflow", "1");
|
|
|
|
|
+// params.put("isVerifyFormRequired", "true");
|
|
|
|
|
+// params.put("isExecuteCreateAddAction", "true");
|
|
|
|
|
+// params.put("isVerifyPer", "1");
|
|
|
|
|
+// params.put("formId", FORM_ID);
|
|
|
|
|
+// params.put("module", "workflow");
|
|
|
|
|
+//
|
|
|
|
|
+// // 表单数据
|
|
|
|
|
+// params.put("formData", buildFormData(request));
|
|
|
|
|
+//
|
|
|
|
|
+// // 其他参数
|
|
|
|
|
+// Map<String, Object> otherParams = new HashMap<>();
|
|
|
|
|
+// otherParams.put("isnextflow", 1);
|
|
|
|
|
+// params.put("otherParams", otherParams);
|
|
|
|
|
+//
|
|
|
|
|
+// log.debug("构建工作流参数成功:{}", params);
|
|
|
|
|
+// return params;
|
|
|
|
|
+//
|
|
|
|
|
+// } catch (Exception e) {
|
|
|
|
|
+// log.error("构建工作流参数失败", e);
|
|
|
|
|
+// throw new RuntimeException("构建工作流参数失败", e);
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// /**
|
|
|
|
|
+// * 构建表单数据
|
|
|
|
|
+// */
|
|
|
|
|
+// private Map<String, Object> buildFormData(VisitorReservationRequest request) {
|
|
|
|
|
+// Map<String, Object> formData = new HashMap<>();
|
|
|
|
|
+// formData.put("formId", FORM_DATA_ID);
|
|
|
|
|
+// formData.put("module", "workflow");
|
|
|
|
|
+//
|
|
|
|
|
+// List<Map<String, Object>> dataDetails = new ArrayList<>();
|
|
|
|
|
+//
|
|
|
|
|
+// // 添加基本信息字段(dataIndex为0或不设置)
|
|
|
|
|
+// addBasicInfoFields(dataDetails, request);
|
|
|
|
|
+//
|
|
|
|
|
+// // 处理多条车辆信息
|
|
|
|
|
+// addVehicleInfoFields(dataDetails, request);
|
|
|
|
|
+//
|
|
|
|
|
+// formData.put("dataDetails", dataDetails.toArray());
|
|
|
|
|
+// return formData;
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// /**
|
|
|
|
|
+// * 添加基本信息字段
|
|
|
|
|
+// */
|
|
|
|
|
+// private void addBasicInfoFields(List<Map<String, Object>> dataDetails, VisitorReservationRequest request) {
|
|
|
|
|
+// addFieldData(dataDetails, FIELD_MAPPING.get("reservationNo"),
|
|
|
|
|
+// request.getReservationNo(), null);
|
|
|
|
|
+// addFieldData(dataDetails, FIELD_MAPPING.get("visitorName"),
|
|
|
|
|
+// request.getVisitorName(), null);
|
|
|
|
|
+// addFieldData(dataDetails, FIELD_MAPPING.get("visitorPhone"),
|
|
|
|
|
+// request.getVisitorPhone(), null);
|
|
|
|
|
+// addFieldData(dataDetails, FIELD_MAPPING.get("visitorIdType"),
|
|
|
|
|
+// request.getVisitorIdType(), null);
|
|
|
|
|
+// addFieldData(dataDetails, FIELD_MAPPING.get("visitorIdNumber"),
|
|
|
|
|
+// request.getVisitorIdNumber(), null);
|
|
|
|
|
+// addFieldData(dataDetails, FIELD_MAPPING.get("visitorCompany"),
|
|
|
|
|
+// request.getVisitorCompany(), null);
|
|
|
|
|
+// addFieldData(dataDetails, FIELD_MAPPING.get("visitReason"),
|
|
|
|
|
+// request.getVisitReason(), null);
|
|
|
|
|
+// addFieldData(dataDetails, FIELD_MAPPING.get("plannedVisitTime"),
|
|
|
|
|
+// formatDateTime(request.getPlannedVisitTime()), null);
|
|
|
|
|
+// addFieldData(dataDetails, FIELD_MAPPING.get("plannedLeaveTime"),
|
|
|
|
|
+// formatDateTime(request.getPlannedLeaveTime()), null);
|
|
|
|
|
+// addFieldData(dataDetails, FIELD_MAPPING.get("intervieweeName"),
|
|
|
|
|
+// request.getIntervieweeName(), null);
|
|
|
|
|
+// addFieldData(dataDetails, FIELD_MAPPING.get("intervieweePhone"),
|
|
|
|
|
+// request.getIntervieweePhone(), null);
|
|
|
|
|
+// addFieldData(dataDetails, FIELD_MAPPING.get("intervieweeDepartment"),
|
|
|
|
|
+// request.getIntervieweeDepartment(), null);
|
|
|
|
|
+// addFieldData(dataDetails, FIELD_MAPPING.get("visitLocation"),
|
|
|
|
|
+// request.getVisitLocation(), null);
|
|
|
|
|
+// addFieldData(dataDetails, FIELD_MAPPING.get("visitorCount"),
|
|
|
|
|
+// String.valueOf(request.getVisitorCount() != null ? request.getVisitorCount() : 1), null);
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// /**
|
|
|
|
|
+// * 添加多条车辆信息字段
|
|
|
|
|
+// */
|
|
|
|
|
+// private void addVehicleInfoFields(List<Map<String, Object>> dataDetails, VisitorReservationRequest request) {
|
|
|
|
|
+// if (request.getVehicles() != null && !request.getVehicles().isEmpty()) {
|
|
|
|
|
+// for (int i = 0; i < request.getVehicles().size(); i++) {
|
|
|
|
|
+// VehicleRegistrationRequest vehicle = request.getVehicles().get(i);
|
|
|
|
|
+// int dataIndex = i + 1; // dataIndex从1开始,与车辆序号对应
|
|
|
|
|
+//
|
|
|
|
|
+// // 添加当前车辆的各个字段
|
|
|
|
|
+// addVehicleField(dataDetails, vehicle, request, dataIndex, i);
|
|
|
|
|
+// }
|
|
|
|
|
+// } else {
|
|
|
|
|
+// // 如果没有车辆信息,至少添加一组空值
|
|
|
|
|
+// addVehicleField(dataDetails, null, request, 1, 0);
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// /**
|
|
|
|
|
+// * 添加单个车辆的所有字段
|
|
|
|
|
+// */
|
|
|
|
|
+// private void addVehicleField(List<Map<String, Object>> dataDetails,
|
|
|
|
|
+// VehicleRegistrationRequest vehicle,
|
|
|
|
|
+// VisitorReservationRequest request,
|
|
|
|
|
+// int dataIndex,
|
|
|
|
|
+// int vehicleIndex) {
|
|
|
|
|
+// // 车牌号码
|
|
|
|
|
+// addFieldData(dataDetails, FIELD_MAPPING.get("licensePlateNumber"),
|
|
|
|
|
+// vehicle != null ? vehicle.getPlateNumber() : "",
|
|
|
|
|
+// dataIndex);
|
|
|
|
|
+//
|
|
|
|
|
+// // 车辆类型
|
|
|
|
|
+// addFieldData(dataDetails, FIELD_MAPPING.get("vehicleType"),
|
|
|
|
|
+// vehicle != null ? vehicle.getVehicleType().getDescription() : "",
|
|
|
|
|
+// dataIndex);
|
|
|
|
|
+//
|
|
|
|
|
+// // 车辆品牌
|
|
|
|
|
+// addFieldData(dataDetails, FIELD_MAPPING.get("vehicleBrand"),
|
|
|
|
|
+// vehicle != null ? vehicle.getVehicleBrand() : "",
|
|
|
|
|
+// dataIndex);
|
|
|
|
|
+//
|
|
|
|
|
+// // 车辆颜色
|
|
|
|
|
+// addFieldData(dataDetails, FIELD_MAPPING.get("vehicleColor"),
|
|
|
|
|
+// vehicle != null ? vehicle.getVehicleColor() : "",
|
|
|
|
|
+// dataIndex);
|
|
|
|
|
+//
|
|
|
|
|
+// // 驾驶员姓名(如果有多个驾驶员信息,可以按需调整)
|
|
|
|
|
+// String driverName = getDriverName(request, vehicle, vehicleIndex);
|
|
|
|
|
+// addFieldData(dataDetails, FIELD_MAPPING.get("driverName"),
|
|
|
|
|
+// driverName, dataIndex);
|
|
|
|
|
+//
|
|
|
|
|
+// // 驾驶员电话(如果有多个驾驶员信息,可以按需调整)
|
|
|
|
|
+// String driverPhone = getDriverPhone(request, vehicle, vehicleIndex);
|
|
|
|
|
+// addFieldData(dataDetails, FIELD_MAPPING.get("driverPhone"),
|
|
|
|
|
+// driverPhone, dataIndex);
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// /**
|
|
|
|
|
+// * 获取驾驶员姓名
|
|
|
|
|
+// * 可以根据实际情况调整逻辑
|
|
|
|
|
+// */
|
|
|
|
|
+// private String getDriverName(VisitorReservationRequest request,
|
|
|
|
|
+// VehicleRegistrationRequest vehicle,
|
|
|
|
|
+// int vehicleIndex) {
|
|
|
|
|
+// if (vehicle != null && vehicle.getDriverName() != null) {
|
|
|
|
|
+// return vehicle.getDriverName();
|
|
|
|
|
+// }
|
|
|
|
|
+// // 默认使用访客姓名
|
|
|
|
|
+// return request.getVisitorName();
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// /**
|
|
|
|
|
+// * 获取驾驶员电话
|
|
|
|
|
+// * 可以根据实际情况调整逻辑
|
|
|
|
|
+// */
|
|
|
|
|
+// private String getDriverPhone(VisitorReservationRequest request,
|
|
|
|
|
+// VehicleRegistrationRequest vehicle,
|
|
|
|
|
+// int vehicleIndex) {
|
|
|
|
|
+// if (vehicle != null && vehicle.getDriverPhone() != null) {
|
|
|
|
|
+// return vehicle.getDriverPhone();
|
|
|
|
|
+// }
|
|
|
|
|
+// // 默认使用访客电话
|
|
|
|
|
+// return request.getVisitorPhone();
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// /**
|
|
|
|
|
+// * 添加字段数据
|
|
|
|
|
+// */
|
|
|
|
|
+// private void addFieldData(List<Map<String, Object>> dataDetails, String fieldId,
|
|
|
|
|
+// String content, Integer dataIndex) {
|
|
|
|
|
+// Map<String, Object> field = new HashMap<>();
|
|
|
|
|
+// field.put("content", content != null ? content : "");
|
|
|
|
|
+// field.put("fieldId", fieldId);
|
|
|
|
|
+//
|
|
|
|
|
+// if (dataIndex != null) {
|
|
|
|
|
+// field.put("dataIndex", dataIndex);
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// dataDetails.add(field);
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// /**
|
|
|
|
|
+// * 生成请求名称
|
|
|
|
|
+// */
|
|
|
|
|
+// private String generateRequestName(VisitorReservationRequest request) {
|
|
|
|
|
+// String applicant = Optional.ofNullable(request.getVisitorName()).orElse("未知");
|
|
|
|
|
+// String interviewee = Optional.ofNullable(request.getIntervieweeName()).orElse("未知");
|
|
|
|
|
+// String date = Optional.ofNullable(request.getPlannedVisitTime())
|
|
|
|
|
+// .map(time -> time.toLocalDate().toString())
|
|
|
|
|
+// .orElse(LocalDateTime.now().toLocalDate().toString());
|
|
|
|
|
+//
|
|
|
|
|
+// return String.format("园区访客申请-%s-%s-被访对象:%s", applicant, date, interviewee);
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// /**
|
|
|
|
|
+// * 格式化日期时间
|
|
|
|
|
+// */
|
|
|
|
|
+// private String formatDateTime(LocalDateTime dateTime) {
|
|
|
|
|
+// if (dateTime == null) {
|
|
|
|
|
+// return "";
|
|
|
|
|
+// }
|
|
|
|
|
+// return dateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"));
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+}
|