From 3fe8f3209a052d2fb3875dd1af889041fdd24fb4 Mon Sep 17 00:00:00 2001
From: kchh <365619549@qq.com>
Date: Thu, 8 Aug 2024 17:32:25 +0800
Subject: [PATCH] kchh
---
wx-applet/Dockerfile | 18 +
wx-applet/Dockerfile.back | 4 +
wx-applet/pom.xml | 241 ++
.../haitongauto/rtosac/ApplicationApplet.java | 17 +
.../rtosac/InterceptorConfiguration.java | 47 +
.../haitongauto/rtosac/PermInterceptor.java | 112 +
.../com/haitongauto/rtosac/SwaggerConfig.java | 21 +
.../rtosac/api/AppointmentController.java | 2492 +++++++++++++++++
.../rtosac/api/HeathCheckController.java | 19 +
.../rtosac/api/HomeController.java | 376 +++
.../rtosac/api/MessageController.java | 225 ++
.../rtosac/api/MineController.java | 1027 +++++++
.../rtosac/api/NewsController.java | 358 +++
.../rtosac/api/PunchClockController.java | 667 +++++
.../rtosac/api/VehicleController.java | 370 +++
.../rtosac/config/ConfigHelper.java | 23 +
.../rtosac/config/ForwardConfig.java | 11 +
.../haitongauto/rtosac/fangdou/Debounce.java | 30 +
.../rtosac/fangdou/DebounceInterface.java | 5 +
.../rtosac/service/AppointmentService.java | 145 +
.../rtosac/service/ForwardService.java | 31 +
.../rtosac/service/HomeService.java | 142 +
.../rtosac/service/MessageService.java | 50 +
.../rtosac/service/MineService.java | 137 +
.../rtosac/service/NewsService.java | 17 +
.../rtosac/service/PunchClockService.java | 110 +
.../haitongauto/rtosac/service/Response.java | 42 +
.../rtosac/service/UsersService.java | 15 +
.../rtosac/service/VehicleService.java | 59 +
.../service/impl/AppointmentServiceImpl.java | 816 ++++++
.../service/impl/ForwardServiceImpl.java | 287 ++
.../rtosac/service/impl/HomeServiceImpl.java | 540 ++++
.../service/impl/MessageServiceImpl.java | 241 ++
.../rtosac/service/impl/MineServiceImpl.java | 354 +++
.../rtosac/service/impl/NewsServiceImpl.java | 35 +
.../service/impl/PunchClockServiceImpl.java | 294 ++
.../rtosac/service/impl/ResponseImpl.java | 119 +
.../rtosac/service/impl/UsersServiceImpl.java | 38 +
.../service/impl/VehicleServiceImpl.java | 92 +
wx-applet/src/main/resources/back/111.yml | 98 +
wx-applet/src/main/resources/back/bannerX.txt | 22 +
.../main/resources/back/logback-spring.xml | 19 +
.../src/main/resources/back/本地调试.txt | 61 +
wx-applet/src/main/resources/back/远程.yml | 8 +
.../src/main/resources/bootstrap-pre.yml | 25 +
.../src/main/resources/bootstrap-prod.yml | 27 +
wx-applet/src/main/resources/bootstrap.yml | 70 +
wx-applet/src/main/resources/forward.json | 4 +
wx-applet/src/main/resources/log4j2.xml | 13 +
...27b40efe1e-462f-42df-8c3d-a56e4b3c34ce.jpg | Bin 0 -> 587608 bytes
...08f463bc91-85c6-46df-a1a3-67af8b0d3525.jpg | Bin 0 -> 587608 bytes
.../main/resources/static/client_img/aaa.txt | 1 +
wx-applet/src/main/resources/本地.yml | 66 +
wx-applet/src/main/resources/远程.yml | 10 +
wx-applet/wx-applet.iml | 6 +
55 files changed, 10057 insertions(+)
create mode 100644 wx-applet/Dockerfile
create mode 100644 wx-applet/Dockerfile.back
create mode 100644 wx-applet/pom.xml
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/ApplicationApplet.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/InterceptorConfiguration.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/PermInterceptor.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/SwaggerConfig.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/api/AppointmentController.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/api/HeathCheckController.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/api/HomeController.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/api/MessageController.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/api/MineController.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/api/NewsController.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/api/PunchClockController.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/api/VehicleController.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/config/ConfigHelper.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/config/ForwardConfig.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/fangdou/Debounce.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/fangdou/DebounceInterface.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/service/AppointmentService.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/service/ForwardService.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/service/HomeService.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/service/MessageService.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/service/MineService.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/service/NewsService.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/service/PunchClockService.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/service/Response.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/service/UsersService.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/service/VehicleService.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/AppointmentServiceImpl.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/ForwardServiceImpl.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/HomeServiceImpl.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/MessageServiceImpl.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/MineServiceImpl.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/NewsServiceImpl.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/PunchClockServiceImpl.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/ResponseImpl.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/UsersServiceImpl.java
create mode 100644 wx-applet/src/main/java/com/haitongauto/rtosac/service/impl/VehicleServiceImpl.java
create mode 100644 wx-applet/src/main/resources/back/111.yml
create mode 100644 wx-applet/src/main/resources/back/bannerX.txt
create mode 100644 wx-applet/src/main/resources/back/logback-spring.xml
create mode 100644 wx-applet/src/main/resources/back/本地调试.txt
create mode 100644 wx-applet/src/main/resources/back/远程.yml
create mode 100644 wx-applet/src/main/resources/bootstrap-pre.yml
create mode 100644 wx-applet/src/main/resources/bootstrap-prod.yml
create mode 100644 wx-applet/src/main/resources/bootstrap.yml
create mode 100644 wx-applet/src/main/resources/forward.json
create mode 100644 wx-applet/src/main/resources/log4j2.xml
create mode 100644 wx-applet/src/main/resources/static/client_img/20230427b40efe1e-462f-42df-8c3d-a56e4b3c34ce.jpg
create mode 100644 wx-applet/src/main/resources/static/client_img/20230508f463bc91-85c6-46df-a1a3-67af8b0d3525.jpg
create mode 100644 wx-applet/src/main/resources/static/client_img/aaa.txt
create mode 100644 wx-applet/src/main/resources/本地.yml
create mode 100644 wx-applet/src/main/resources/远程.yml
create mode 100644 wx-applet/wx-applet.iml
diff --git a/wx-applet/Dockerfile b/wx-applet/Dockerfile
new file mode 100644
index 0000000..07f58bd
--- /dev/null
+++ b/wx-applet/Dockerfile
@@ -0,0 +1,18 @@
+#FROM openjdk:8
+#LABEL name="rtosac" version="1.0.0" author="wsnet" maintainer="wsnet@wsmis.com"
+#COPY target/com.haitongauto.rtosac.jar rtosac-image.jar
+#CMD ["java","-jar","rtosac-image.jar"]
+
+FROM openjdk:8
+#adoptopenjdk/openjdk8:ubi
+LABEL name="docker" version="1.0.0" author="wsnet" maintainer="wsnet@wsmis.com"
+COPY target/com.haitongauto.rtosac.jar rtosac-image.jar
+
+RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
+RUN echo 'Asia/Shanghai' >/etc/timezone
+EXPOSE 8083
+
+ENV PROFILES_OPTS=""
+ENV JAVA_OPTS=""
+
+ENTRYPOINT [ "sh", "-c","java $PROFILES_OPTS $JAVA_OPTS -jar rtosac-image.jar" ]
\ No newline at end of file
diff --git a/wx-applet/Dockerfile.back b/wx-applet/Dockerfile.back
new file mode 100644
index 0000000..810ebc7
--- /dev/null
+++ b/wx-applet/Dockerfile.back
@@ -0,0 +1,4 @@
+FROM openjdk:8
+LABEL name="rtosac" version="1.0.0" author="wsnet" maintainer="wsnet@wsmis.com"
+COPY target/com.haitongauto.rtosac.jar rtosac-image.jar
+CMD ["java","-jar","rtosac-image.jar"]
\ No newline at end of file
diff --git a/wx-applet/pom.xml b/wx-applet/pom.xml
new file mode 100644
index 0000000..68cc75b
--- /dev/null
+++ b/wx-applet/pom.xml
@@ -0,0 +1,241 @@
+
+
+
+ rtos-wh
+ org.example
+ 1.0-SNAPSHOT
+
+ 4.0.0
+
+ wx-applet
+
+
+ 1.8
+ 1.8
+
+
+
+
+ org.apache.logging.log4j
+ log4j-api
+ 2.14.1
+
+
+ org.apache.logging.log4j
+ log4j-core
+ 2.14.1
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-logging
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-config
+
+
+
+
+ org.projectlombok
+ lombok
+ 1.18.20
+
+
+ com.alibaba
+ fastjson
+ 1.2.7
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ 2.6.6
+
+
+
+
+ com.github.pagehelper
+ pagehelper-spring-boot-starter
+ 1.4.2
+
+
+ com.github.pagehelper
+ pagehelper
+ 5.3.0
+
+
+ com.bestvike
+ linq
+ 3.1.0
+
+
+ org.example
+ models
+ 1.0-SNAPSHOT
+
+
+ org.example
+ utils
+ 1.0-SNAPSHOT
+
+
+ org.example
+ mapper
+ 1.0-SNAPSHOT
+
+
+ mybatis-spring-boot-starter
+ org.mybatis.spring.boot
+
+
+
+
+ org.example
+ interfaces
+ 1.0-SNAPSHOT
+
+
+
+
+ com.nuzar
+ rtops-openapi-client
+ 1.0-SNAPSHOT
+
+
+
+ com.nuzar
+ nuzar-security
+ 2.6.14.10-SNAPSHOT
+
+
+
+ org.springframework.security
+ spring-security-web
+ 5.6.9
+
+
+
+ org.springframework.security
+ spring-security-config
+ 5.6.9
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-oauth2-resource-server
+ 2.6.14
+
+
+
+ org.springframework.boot
+ spring-boot-starter-oauth2-client
+ 2.6.14
+
+
+
+ org.springframework.security
+ spring-security-oauth2-resource-server
+ 5.6.9
+
+
+ org.springframework.security
+ spring-security-oauth2-client
+ 5.6.9
+
+
+
+ org.springframework.security
+ spring-security-core
+ 5.6.9
+
+
+ org.springframework.cloud
+ spring-cloud-starter-bootstrap
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-loadbalancer
+
+
+
+
+
+ io.springfox
+ springfox-swagger2
+ 2.9.2
+
+
+ io.springfox
+ springfox-swagger-ui
+ 2.9.2
+
+
+ top.jfunc.json
+ Json-Gson
+ 1.0
+
+
+
+ net.sourceforge.tess4j
+ tess4j
+ 5.6.0
+
+
+
+
+
+ com.haitongauto.rtosac
+
+
+ src/main/resources
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ 2.2.2.RELEASE
+
+
+
+ repackage
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.2.1
+
+
+
+
+ org.springframework.boot
+ spring-boot-configuration-processor
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/ApplicationApplet.java b/wx-applet/src/main/java/com/haitongauto/rtosac/ApplicationApplet.java
new file mode 100644
index 0000000..a292fc7
--- /dev/null
+++ b/wx-applet/src/main/java/com/haitongauto/rtosac/ApplicationApplet.java
@@ -0,0 +1,17 @@
+package com.haitongauto.rtosac;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+@MapperScan("com.haitongauto.mapper")
+@EnableFeignClients(basePackages = {"com.haitongauto.interfaces"})
+@SpringBootApplication(scanBasePackages = {"com.haitongauto.interfaces","com.haitongauto.rtosac"})
+public class ApplicationApplet {
+ /**
+ * 启动微信小程序服务入口
+ * @param args args
+ */
+ public static void main(String[] args){
+ SpringApplication.run(ApplicationApplet.class,args);
+ }
+}
\ No newline at end of file
diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/InterceptorConfiguration.java b/wx-applet/src/main/java/com/haitongauto/rtosac/InterceptorConfiguration.java
new file mode 100644
index 0000000..37f4eab
--- /dev/null
+++ b/wx-applet/src/main/java/com/haitongauto/rtosac/InterceptorConfiguration.java
@@ -0,0 +1,47 @@
+package com.haitongauto.rtosac;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+import javax.annotation.PostConstruct;
+
+/**
+ * 拦截器的属性配置
+ *
+ */
+@Configuration
+@ConditionalOnClass(WebMvcConfigurer.class)
+public class InterceptorConfiguration implements WebMvcConfigurer {
+
+ @Autowired
+ private ObjectMapper objectMapper;
+
+ @PostConstruct
+ public void EnumObjectMapper() {
+ // 解决enum不匹配问题 默认值为false
+ objectMapper.configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, true);
+ }
+
+ /**
+ * 权限验证过滤器
+ * @return
+ */
+ @Bean
+ public PermInterceptor permInterceptor() {
+ return new PermInterceptor();
+ }
+
+
+ @Override
+ @ConditionalOnBean(PermInterceptor.class)
+ public void addInterceptors(InterceptorRegistry registry) {
+ // 拦截器
+ InterceptorRegistration registration = registry.addInterceptor(permInterceptor());
+ }
+}
\ No newline at end of file
diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/PermInterceptor.java b/wx-applet/src/main/java/com/haitongauto/rtosac/PermInterceptor.java
new file mode 100644
index 0000000..a12aca4
--- /dev/null
+++ b/wx-applet/src/main/java/com/haitongauto/rtosac/PermInterceptor.java
@@ -0,0 +1,112 @@
+package com.haitongauto.rtosac;
+
+import com.haitongauto.interfaces.UsersApi;
+import com.haitongauto.models.ido.login.UserInfoRes;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.util.AntPathMatcher;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+import org.springframework.web.servlet.HandlerInterceptor;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * 权限过滤器
+ */
+public class PermInterceptor implements HandlerInterceptor {
+ public static final String[] SWAGGER_EXCLUDE_PATHS = {"/doc.html", "/swagger-resources/**", "/webjars/**", "/v2/**", "/favicon.ico", "/swagger-ui.htmL/**", "/health/ping"};
+
+ @Override
+ public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
+ String uri = request.getRequestURI();
+ AntPathMatcher antPathMatcher = new AntPathMatcher();
+ for (String p : SWAGGER_EXCLUDE_PATHS) {
+ if (antPathMatcher.match(p, uri)) {
+ return true;
+ }
+ }
+ //判断是否登录
+ String userId = "";
+ String username = "";
+ try {
+ BeanFactory factory = WebApplicationContextUtils.getRequiredWebApplicationContext(request.getServletContext());
+ //老系统同步新系统 没有token(直接放过)
+ if (StringUtils.equalsAny(request.getRequestURI()
+ , "/appointment/execTruckOrderNsFin"
+ )) {
+ return true;
+ }
+ UsersApi openApi = factory.getBean(UsersApi.class);
+ UserInfoRes info = openApi.getUserInfo().getData();
+ userId = info.getId();
+ username = info.getName();
+ String me = "mini-app,app,pad,web";
+ String mt = info.getMediaType();
+ if (me.contains(mt) && StringUtils.equalsAny(request.getRequestURI()
+ , "/appointment/plateTruckScan"
+ , "/appointment/cancelAppointmentUnPlan"
+ , "/message/realMessage"
+ , "/message/punchClockOverByPrint"
+ , "/news/sendTruckThroughGateInfo"
+ , "/news/sendTruckThroughGateInfoUnconventionality"
+ )) {
+ return true;
+ }
+
+ if (!StringUtils.equalsIgnoreCase(info.getMediaType(), "mini-app")) {
+ response.setStatus(HttpServletResponse.SC_FORBIDDEN);
+ // 可以设置响应体
+ response.getWriter().write("Access Forbidden");
+ return false;
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+// response.setStatus(HttpServletResponse.SC_FORBIDDEN);
+// // 可以设置响应体
+// response.getWriter().write("Access Forbidden");
+// return false;
+ }
+
+
+ return true;
+ }
+
+ @Override
+ public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
+ // UserContext.clear();
+ }
+
+
+ /**
+ * 判断是否有权限
+ * 1.从请求头中获取token
+ *
+ * 2.通过token从redis中获取当前登录对象(object)
+ *
+ * 3.通过对象查询数据库是否存在当前对象
+ *
+ * 4.获取登录对象的登录名 判断是否是(admin或者总经理)这两个账号拥有最高权限
+ *
+ * 5.判断是否被授权,(获取临时授权时设置的开始时间,结束时间,当前时间),
+ *
+ * 获取这个三个时间的时间戳,判断当前时间是否在开始时间和结束时间之间
+ *
+ * 如果开始时间和结束时间为空的话表示当前登录对象未被临时授权,会执行后面的 4,5,6,
+ *
+ * 如果有时间,但是当前时间不在这个时间段也会执行 4,5,6
+ *
+ * 如果有时间,并且当前时间在这个时间段之中,就会直接返回true
+ *
+ * 6.从请求头中获取当前接口的地址,
+ *
+ * 7.通过当前登录对象的id查询权限
+ *
+ * 8.判断当前登录对象的权限中是否包含当前接口的地址,如果包含,允许当前登录对象访问,如果不包含,则不允许当前登录人访问
+ * ————————————————
+ * 版权声明:本文为CSDN博主「原你是阳光(#`O′)」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
+ * 原文链接:https://blog.csdn.net/weixin_58696998/article/details/124663181
+ * @param request
+ * @return
+ */
+}
diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/SwaggerConfig.java b/wx-applet/src/main/java/com/haitongauto/rtosac/SwaggerConfig.java
new file mode 100644
index 0000000..184dd52
--- /dev/null
+++ b/wx-applet/src/main/java/com/haitongauto/rtosac/SwaggerConfig.java
@@ -0,0 +1,21 @@
+package com.haitongauto.rtosac;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+//@Configuration
+//@EnableSwagger2
+public class SwaggerConfig {
+// @Bean
+// public Docket api() {
+// return new Docket(DocumentationType.SWAGGER_2)
+// .enable(true)//是否启动swagger
+// .select()
+// .apis(RequestHandlerSelectors.basePackage("com.haitongauto.rtosac.api"))
+// //.paths(PathSelectors.any())
+// .build();
+// }
+}
\ No newline at end of file
diff --git a/wx-applet/src/main/java/com/haitongauto/rtosac/api/AppointmentController.java b/wx-applet/src/main/java/com/haitongauto/rtosac/api/AppointmentController.java
new file mode 100644
index 0000000..e3552b3
--- /dev/null
+++ b/wx-applet/src/main/java/com/haitongauto/rtosac/api/AppointmentController.java
@@ -0,0 +1,2492 @@
+package com.haitongauto.rtosac.api;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.bestvike.linq.Linq;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.haitongauto.interfaces.*;
+import com.haitongauto.interfaces.impl.EnterPortTypeInterfaceImpl;
+import com.haitongauto.models.dto.*;
+import com.haitongauto.models.dto.app.ChuanItem;
+import com.haitongauto.models.dto.app.CommercialVehicleDetail;
+import com.haitongauto.models.dto.app.Vin;
+import com.haitongauto.models.dto.open.YardGoodsStateRespDTO;
+import com.haitongauto.models.forward.*;
+import com.haitongauto.models.ido.BasicDataIdo;
+import com.haitongauto.models.ido.CommonRes;
+import com.haitongauto.models.ido.CustomerRes;
+import com.haitongauto.models.ido.ShipVoyIdo;
+import com.haitongauto.models.ido.login.UserInfoRes;
+import com.haitongauto.models.pojo.*;
+import com.haitongauto.models.valid.cus.ValidCusVin;
+import com.haitongauto.models.valid.cus.ValidRequest;
+import com.haitongauto.models.valid.naz.CargoInfoNaz;
+import com.haitongauto.models.valid.naz.res.NarData;
+import com.haitongauto.models.valid.naz.res.NarRes;
+import com.haitongauto.rtosac.fangdou.Debounce;
+import com.haitongauto.rtosac.fangdou.DebounceInterface;
+import com.haitongauto.rtosac.service.*;
+import com.haitongauto.utils.DateTimeHelper;
+import com.haitongauto.utils.FormatDateTime;
+import com.haitongauto.utils.HttpClientHelper;
+import com.haitongauto.utils.check.CheckHelper;
+import com.haitongauto.utils.http.OkHttpUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.time.LocalDateTime;
+import java.util.*;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.stream.Collectors;
+
+@RestController
+@RequestMapping("/appointment")
+public class AppointmentController {
+ /**
+ * 读取nacos接口路径(正常物流,预约完成状态同步老系统的接口地址)
+ */
+ @Value("${rtos.syncold.expressurl}")
+ private String expressUrl;
+ @Autowired
+ MessageService messageService;
+ @Autowired
+ UsersService usersService;
+ @Autowired
+ AppointmentService appointmentService;
+ @Autowired
+ PunchClockService punchClockService;
+ @Autowired
+ Response response;
+ @Autowired
+ DicInterface dicInterface;
+ @Autowired
+ PortAreaInterface portAreaInterface;
+ @Resource
+ CusOrderApi cusOrderApi;
+ @Resource
+ OrderApi orderApi;
+ @Resource
+ YardOrderApi yardOrderApi;
+ @Resource
+ private UsersApi usersApi;
+
+ @Autowired
+ EnterPortTypeInterfaceImpl enterPortTypeInterface;
+ private static final Logger logger = LogManager.getLogger(AppointmentController.class);
+ private static final Lock lock = new ReentrantLock();
+
+ /**
+ * (发起预约时)获取用户注册的板车信息
+ * //@param users_id 司机id
+ *
+ * @return 返回用户注册的板车信息
+ */
+ @RequestMapping("/getPalletTruckInfo")
+ public String getPalletTruckInfo() {
+ CommonRes userInfoResCommonRes;
+ String userId;
+ String msg = "";
+ try {
+ //请求哪吒接口获得用户信息
+ userInfoResCommonRes = usersApi.getUserInfo();
+ UserInfoRes userInfoRes = userInfoResCommonRes.getData();
+ userId = userInfoRes.getId();
+ } catch (Exception ex) {
+ msg = "从rtos后台,获得用户信息异常," + ex.getMessage();
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ if (userId == null || userId.isEmpty()) {
+ msg = "用户id不能为空";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ Truck truck = appointmentService.getPalletTruck(userId);
+ //判断请求是否成功
+ Boolean bl = truck != null;
+ Map data = new HashMap<>();
+ data.put("PalletTruckInfo", truck);
+ //创建返回数据
+ return response.getResponseData(bl, data);
+ }
+
+ /**
+ * 港区列表
+ *
+ * @return 返回港区列表
+ */
+ @RequestMapping("/getPortAreaList")
+ public String getPortAreaList() {
+ List portAreaList = null;
+ String msg = "";
+ try {
+ portAreaList = portAreaInterface.getPortArea();
+ } catch (Exception e) {
+ msg = e.getMessage();
+ //判断请求是否成功
+ Boolean bl = false;
+ return response.getResponseData(bl, null, msg);
+ }
+ //判断请求是否成功
+ Boolean bl = portAreaList != null;
+ //创建返回数据
+ Map data = new HashMap<>();
+ data.put("PortAreaList", portAreaList);
+ //封装返回数据
+ return response.getResponseData(bl, data);
+ }
+
+ /**
+ * 进港类型列表
+ *
+ * @return 返回进港类型
+ */
+ @RequestMapping("/getEnterPortTypesList")
+ public String getEnterPortTypesList() {
+ List enterPortTypesList = null;
+ String msg = "";
+ try {
+ enterPortTypesList = enterPortTypeInterface.getEnterPortTypeList();
+ } catch (Exception e) {
+ msg = e.getMessage();
+ //判断请求是否成功
+ Boolean bl = false;
+ return response.getResponseData(bl, null, msg);
+ }
+ //判断请求是否成功
+ Boolean bl = true;
+ //创建返回数据
+ Map data = new HashMap<>();
+ data.put("EnterPortTypesList", enterPortTypesList);
+ //封装返回数据
+ //返回
+ return response.getResponseData(bl, data);
+ }
+
+ /**
+ * 运输方式 TRANSPORT_TYPE
+ *
+ * @return 返回运输方式
+ */
+ @RequestMapping("/getTransportTypeList")
+ public String getTransportTypeList() {
+ //通过外部接口获取
+ List myList = null;
+ List list = new ArrayList<>();
+ String msg = "";
+ try {
+ myList = dicInterface.getDicList("TRANSPORT_TYPE");
+ if (myList != null && myList.size() > 0) {
+ for (DicDto dicDto : myList) {
+ if (dicDto.getText().contains("板车")) {
+ list.add(dicDto);
+ }
+ }
+ for (DicDto dicDto : myList) {
+ if (!dicDto.getText().contains("板车")) {
+ list.add(dicDto);
+ }
+ }
+ }
+ } catch (Exception e) {
+ msg = e.getMessage();
+ //判断请求是否成功
+ Boolean bl = false;
+ return response.getResponseData(bl, null, msg);
+ }
+
+
+ //判断请求是否成功
+ Boolean bl = myList.size() > 0;
+ //创建返回数据
+ Map data = new HashMap<>();
+ data.put("TransportTypesList", list);
+ //封装数据
+ //返回
+ return response.getResponseDataJavaJson(bl, data);
+ }
+
+ /**
+ * 货物类型 CARGO_TYPE
+ *
+ * @return 返回货物类型
+ */
+ @RequestMapping("/getGoodsTypesList")
+ public String getGoodsTypesList() {
+ //通过外部接口获取
+ List myList = null;
+ String msg = "";
+ try {
+ myList = dicInterface.getDicList("APP_CARGO_TYPE");
+ } catch (Exception e) {
+ msg = e.getMessage();
+ //判断请求是否成功
+ Boolean bl = false;
+ return response.getResponseData(bl, null, msg);
+ }
+ //判断请求是否成功
+ Boolean bl = myList != null && myList.size() > 0;
+ //创建返回数据
+ Map data = new HashMap<>();
+ data.put("GoodsTypesList", myList);
+ //封装数据
+ return response.getResponseDataJavaJson(bl, data);
+ }
+
+ /**
+ * 提交预约信息
+ *
+ * @return 返回提交结果
+ */
+ @PostMapping("/postAppointment")
+ public String postAppointment(@RequestBody AppointmentPostDto appointmentPostDto) {
+ String msg = "";
+ if (appointmentPostDto.getAppointment() == null) {
+ msg = "预约信息不能为空";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ Appointment appointment = null;
+ List appointmentDetailList = null;
+ CommonRes userInfoResCommonRes;
+ try {
+ //请求哪吒接口获得用户信息
+ userInfoResCommonRes = usersApi.getUserInfo();
+ } catch (Exception ex) {
+ msg = "从rtos后台,获得用户信息异常," + ex.getMessage();
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ try {
+ appointment = appointmentPostDto.getAppointment();
+ UserInfoRes userInfoRes = userInfoResCommonRes.getData();
+ String userId = userInfoRes.getId();
+ appointment.setUsers_id(userId);
+ Integer appointment_type = appointment.getAppointment_type();
+ //如果是特保区预约,港区则绑定到临港
+ if (appointment_type != null && appointment_type.equals(2)) {
+ List portAreaList = portAreaInterface.getPortArea();
+ if (portAreaList != null && portAreaList.size() > 0) {
+ PortArea portArea = Linq.of(portAreaList).firstOrDefault(o -> o.getPort_area_name().contains("临港"));
+ if (portArea != null) {
+ appointment.setPort_area_id(portArea.getId());
+ }
+ }
+ }
+ } catch (Exception ex) {
+ msg = "获取预约信息实体失败。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ //用户id不能为空
+ if (appointment.getUsers_id() == null || appointment.getUsers_id().isEmpty()) {
+ msg = "用户id不能为空";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ //海通码头预约,港区不能为空
+ if (appointment.getAppointment_type() != null && appointment.getAppointment_type().equals(1)) {
+ if (appointment.getPort_area_id() == null || appointment.getPort_area_id().isEmpty()) {
+ msg = "预约港区不能为空";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ }
+ //预约日期验证
+ if (appointment.getApproach_date() == null || appointment.getApproach_date().isEmpty()) {
+ msg = "预约进场日期不能为空";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ //自开预约验证身份证
+ if (appointment.getTransport_type() != null && "3".equals(appointment.getTransport_type())) {
+ String idCode = appointment.getId_code();
+ if (idCode == null || idCode.isEmpty()) {
+ msg = "自开,身份证号码不能为空,请正确填写身份证号";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ if (idCode.length() != 18) {
+ msg = "身份证号码必须18位,请正确填写身份证号";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ }
+ //进港类型
+ String enter_type = appointment.getEnter_type();
+ //运输方式
+ String transport_type = appointment.getTransport_type();
+ //用户存在有效未完成的预约,不可以预约
+ Appointment myAppointment = null;
+ if ("2".equals(transport_type)) {
+ if (appointment.getTruck_number() != null && !appointment.getTruck_number().isEmpty()) {
+ myAppointment = appointmentService.getActiveAppointmentNew(appointment.getTruck_number());
+ if (myAppointment != null) {
+ msg = "板车" + appointment.getTruck_number() + " 存在未完成板车预约,请完成或取消后,再预约。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ }
+ } else if ("3".equals(transport_type)) {
+ if (appointment.getId_code() != null && !appointment.getId_code().isEmpty()) {
+ //myAppointment=appointmentService.getActiveAppointment(appointment.getUsers_id();
+ myAppointment = appointmentService.getActiveAppointmentNew(appointment.getId_code());
+ if (myAppointment != null) {
+ msg = "身份证" + appointment.getId_code() + " 存在未完成预约,请完成或取消后,再预约。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ }
+ } else if ("1".equals(transport_type)) {
+ if (appointment.getId_code() != null && !appointment.getId_code().isEmpty()) {
+ myAppointment = appointmentService.getActiveAppointmentNew(appointment.getId_code());
+ if (myAppointment != null) {
+ msg = "身份证" + appointment.getId_code() + " 存在未完成预约,请完成或取消后,再预约。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ }
+ }
+ if (true) {
+ //特保区预约,预约明细信息不能为空
+ if (appointmentPostDto.getAppointmentDetailList() == null || appointmentPostDto.getAppointmentDetailList().size() == 0) {
+ //外贸出口,第三步的船名、港口、品牌必填,车架号可以不填写,内贸出口第三步都是非必填 (张晓雅 需求修改) ,注释下面代码
+ //预约类型(1-普通码头预约,2-特保区预约) 新增字段
+ //验证特保区预约,预约明细信息不能为空
+ Integer appointment_type = appointment.getAppointment_type();
+ if (appointment_type != null && appointment_type.equals(2)) {
+ msg = "特保区预约,预约明细信息不能为空。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ }
+ if (appointmentPostDto.getAppointmentDetailList() != null && appointmentPostDto.getAppointmentDetailList().size() > 0) {
+ try {
+ appointmentDetailList = appointmentPostDto.getAppointmentDetailList();
+ } catch (Exception ex) {
+ msg = "获取预约明细信息实体失败。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ List vinlist;
+ if (appointmentDetailList != null && appointmentDetailList.size() > 0) {
+ if ("WE".equals(enter_type)) {
+ //外贸出口,验证船名必填
+ List detailsForShip = Linq.of(appointmentDetailList).where(p -> p.getShip_id() == null || p.getShip_id().isEmpty()).toList();
+ if (detailsForShip != null && detailsForShip.size() > 0) {
+ msg = "外贸出口,预约明细的船舶id必填。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ //外贸出口,预约明细的品牌必填
+ List detailsForBrand = Linq.of(appointmentDetailList).where(p -> p.getBrand_id() == null || p.getBrand_id().isEmpty()).toList();
+ if (detailsForBrand != null && detailsForBrand.size() > 0) {
+ msg = "外贸出口,预约明细的品牌必填。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ //外贸出口,预约明细的港口必填
+ List detailsForPort = Linq.of(appointmentDetailList).where(p -> p.getBrand_id() == null || p.getBrand_id().isEmpty()).toList();
+ if (detailsForPort != null && detailsForPort.size() > 0) {
+ msg = "外贸出口,预约明细的港口必填。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ }
+ //验证提交的Vins是否有重复的
+ List myallVins = Linq.of(appointmentDetailList).where(p -> p.getVin() != null && !p.getVin().isEmpty()).select(AppointmentDetail::getVin).toList();
+ List duplicatedElements = myallVins.stream().collect(Collectors.groupingBy(e -> e)).entrySet().stream().filter(entry -> entry.getValue().size() > 1).map(Map.Entry::getKey).collect(Collectors.toList());
+ if (duplicatedElements.size() > 0) {
+ String myVins = String.join(",", duplicatedElements);
+ msg = "vin:" + myVins + "重复提交。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ //内贸出口的品牌不能为空(商品车)(张小雅 内贸出口第三步都是非必填)
+ //if ("NE".equals(enter_type) && "C".equals(goods_type)) {
+ // List vinss = Linq.of(appointmentDetailList).where(p -> p.getBrand_id() == null || p.getBrand_id().isEmpty()).select(AppointmentDetail::getVin).distinct().toList();
+ // if (vinss != null && vinss.size() > 0) {
+ // String myVins = String.join(",", vinss);
+ // msg = "内贸出口,vin:" + myVins + "预约明细的品牌不能为空。";
+ // //判断请求是否成功
+ // Boolean bl = false;
+ // //创建返回数据
+ // Map data = new HashMap<>();
+ // //返回
+ // return response.getResponseData(bl, data, msg);
+ // }
+ //}
+ //验证vin是否是17位
+ if ("WE".equals(enter_type)) {
+ vinlist = Linq.of(appointmentDetailList).where(p -> p.getVin() != null && !p.getVin().isEmpty()).select(AppointmentDetail::getVin).toList();
+ } else {
+ vinlist = Linq.of(appointmentDetailList).select(AppointmentDetail::getVin).toList();
+ }
+ if (vinlist != null && vinlist.size() > 0) {
+ //验证vin 验证6-17 位(王文文2024-07-16)
+ List vinlistckl = CheckHelper.CheckVinLength(vinlist);
+ if (vinlistckl != null && vinlistckl.size() > 0) {
+ String myVins = String.join(",", vinlistckl);
+ msg = "vin:" + myVins + "长度小于17位。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+
+ //验证vin只能是字母或数据组成
+ List vinlistckcon = CheckHelper.CheckVinContainEnOrDi(vinlist);
+ if (vinlistckcon != null && vinlistckcon.size() > 0) {
+ String myVins = String.join(",", vinlistckcon);
+ msg = "vin只能是字母或数据组成," + "vin:" + myVins + "不符合。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+
+ //验证vin是否被别的板车预约过
+ //根据 Vin列表查询匹配的商品车明细,并筛选出不属于已取消和异常的预约的和预约已完成的
+ List mylist = appointmentService.getAppointmentDetailListByVinList(vinlist, appointment.getId());
+ //取Vin的列表
+ List myVinlist = null;
+ if (mylist != null && mylist.size() > 0) {
+ for (AppointmentDetail detail : mylist) {
+ Appointment appOin = appointmentService.getAppointmentById(detail.getAppointment_id());
+ if (appOin != null) {
+ msg = "vin:" + detail.getVin() + "已经被" + appOin.getTruck_number() + "预约过。";
+ } else {
+ msg = "vin:" + detail.getVin() + "已经被预约过。";
+ }
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ }
+
+ //判断车辆是否在场(出口业务)
+ if ("WE".equals(enter_type) || "NE".equals(enter_type)) {
+ //从哪吒接口获得vin的是否在场的信息
+ List vinlist_isOn = Linq.of(vinlist).where(p -> p != null && !p.isEmpty()).toList();
+ if (vinlist_isOn != null && vinlist_isOn.size() > 0) {
+ CommonRes> mycheckInYardFLag = yardOrderApi.checkInYardFLag(vinlist_isOn);
+ logger.info("接收到哪吒接口返回的在场验证数据:" + JSON.toJSONString(mycheckInYardFLag));
+ List yardGoodsStateRespDTOList = null;
+ if (mycheckInYardFLag != null) {
+ yardGoodsStateRespDTOList = mycheckInYardFLag.getData();
+ }
+ List vin_zc;//在场车辆
+ if (yardGoodsStateRespDTOList != null && yardGoodsStateRespDTOList.size() > 0) {
+ vin_zc = Linq.of(yardGoodsStateRespDTOList).where(p -> p.getInYardFlag().equals(1) && !"1".equals(p.getIsAllocate())).select(YardGoodsStateRespDTO::getVinCode).toList();
+ } else {
+ vin_zc = null;
+ }
+ if (vin_zc != null && vin_zc.size() > 0) {
+ String myVinliststr = String.join(",", vin_zc);
+ msg = "车架号:" + myVinliststr + "的车辆已在场且未调拨,不可预约进场。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ }
+
+ }
+ }
+ //特保区,验证vin是否激活
+ if (true) {//特保区验证先屏蔽调,让王琛先测试,后期需要打开再调试
+ if (appointment.getAppointment_type() != null && appointment.getAppointment_type().equals(2)) {
+ List pushIds = new ArrayList<>();
+ List chekvinlist = Linq.of(appointmentDetailList).select(AppointmentDetail::getVin).where(p -> p != null && !p.isEmpty()).toList();
+ if (chekvinlist != null && chekvinlist.size() > 0) {
+ List validCusVin = null;
+ try {
+ //激活验证
+ validCusVin = appointmentService.validCusVin(chekvinlist);
+ } catch (Exception e) {
+ msg = "vin:" + String.join(",", chekvinlist) + "/ 激活验证异常信息:" + e.getMessage();
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ List validCusVinStr;
+ if (validCusVin != null) {
+ validCusVinStr = Linq.of(validCusVin).select(p -> p.getVin()).toList();
+ } else {
+ validCusVinStr = null;
+ }
+ //如果邓军返回的vin数据为空,则所有的vin为未被激活
+ if (validCusVinStr == null || validCusVinStr.size() == 0) {
+ msg = "vin:" + String.join(",", chekvinlist) + "未被激活。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ } else {
+ if (validCusVin != null && validCusVin.size() > 0) {
+ //过滤出未激活的vin
+ logger.info("控制器收到激活验证回复0:" + JSON.toJSONString(validCusVin));
+ List vin_weijihuo = Linq.of(chekvinlist).where(p -> !validCusVinStr.contains(p)).toList();
+ if (vin_weijihuo != null && vin_weijihuo.size() > 0) {
+ msg = "vin:" + String.join(",", vin_weijihuo) + "未被激活。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ } else {
+ //智云验证开关
+ if (true) {
+ logger.info("控制器收到激活验证回复1:" + JSON.toJSONString(validCusVin));
+ //如果都是激活的vin,则请求哪吒智云接口
+ //将从邓军请求的企业参数,转化为请求智云的参数
+ List cargoInfoNazList = appointmentService.cargoInfoNaz(validCusVin, appointment.getTruck_number());
+ if (cargoInfoNazList != null && cargoInfoNazList.size() > 0) {
+ for (CargoInfoNaz infoNaz : cargoInfoNazList) {
+ List vin = Linq.of(infoNaz.getGoodsInfo()).select(p -> p.getVin()).toList();
+ NarRes narRes = null;
+ try {
+ logger.info("控制器请求智云接口参数:" + JSON.toJSONString(infoNaz));
+ narRes = orderApi.vehicleReserve(infoNaz);
+ logger.info("控制器请求智云接口回复:" + JSON.toJSONString(narRes));
+
+ } catch (Exception ex) {
+ logger.info("控制器请求智云接口回复1:" + JSON.toJSONString(ex.getMessage()));
+ msg = "vin:" + String.join(",", vin) + "智云请求异常,预约失败: " + ex.getMessage();
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ if (pushIds.size() > 0) {
+ for (String pushId : pushIds) {
+ try {
+ logger.info("特保区预约1,pushId:" + pushId + "智云取消请求");
+ NarRes narRes_c = orderApi.vehicleCancelReserve(pushId);
+ logger.info("特保区预约1,pushId:" + pushId + "智云取消请求返回0:" + JSON.toJSONString(narRes_c));
+ } catch (Exception ex1) {
+ logger.info("特保区预约1,pushId:" + pushId + "智云取消请求返回1:" + JSON.toJSONString(ex1.getMessage()));
+ }
+ }
+ pushIds.clear();
+ }
+ //返回
+ return response.getResponseData(bl, data, msg);
+ } finally {
+ }
+
+ if (!"S0000".equals(narRes.getCode())) {
+ msg = "vin:" + String.join(",", vin) + "智云请求失败,预约失败";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ if (pushIds.size() > 0) {
+ for (String pushId : pushIds) {
+ try {
+ logger.info("特保区预约1,pushId:" + pushId + "智云取消请求");
+ NarRes narRes_c = orderApi.vehicleCancelReserve(pushId);
+ logger.info("特保区预约1,pushId:" + pushId + "智云取消请求返回0:" + JSON.toJSONString(narRes_c));
+ } catch (Exception ex1) {
+ logger.info("特保区预约1,pushId:" + pushId + "智云取消请求返回1:" + JSON.toJSONString(ex1.getMessage()));
+ }
+ }
+ pushIds.clear();
+ }
+ //返回
+ return response.getResponseData(bl, data, msg);
+ } else {
+ //智云请求成功
+ NarData data = narRes.getData();
+ if (data != null) {
+ String pushId = data.getPushId();
+ if (pushId != null && !pushId.isEmpty()) {
+ pushIds.add(pushId);
+ }
+ }
+ }
+
+ }
+ if (pushIds.size() > 0) {
+ appointment.setPush_ids(String.join(",", pushIds));
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ //非特保区预约,非自开 才转发到老系统(待开放)
+ //商品车自开,有提示 板车号不能为空; 此处增加逻辑,当为商品车自开的时候,不调用老系统接口,即不同步数据(王文文)
+ if (true) {
+ if (appointment.getAppointment_type() != null && appointment.getAppointment_type().equals(1)) {
+ {
+ //运输方式字段是字符串,当为商品车自开的时候,不调用老系统接口,即不同步数据(王文文)
+ if (!"3".equals(appointment.getTransport_type()) && !"1".equals(appointment.getTransport_type())) {
+ //数据转发到老系统
+ //CompletableFuture future = forwardService.invokeApiAsyncForward(appointment, appointmentDetailList);
+ ForwardRes res = appointmentService.invokeForwardApi(appointment, appointmentDetailList);
+ if (res == null) {
+ //msg = "预约转发老系统失败预约不成功";
+ msg = "网络开小差了,请稍后再试";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ if (Objects.equals(res.getSuccess(), "0")) {
+ //msg = "预约转发老系统失败预约不成功,老系统返回信息:" + res.getErrmsg();
+ msg = "网络开小差了,请稍后再试";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ }
+ }
+ }
+ }
+ Integer x = null;
+ //防抖处理(前端手抖,连续点击2次以上提交)
+ lock.lock();
+ try {
+ Appointment appointment_cunzai = null;
+ if ("2".equals(transport_type)) {
+ if (appointment.getTruck_number() != null && !appointment.getTruck_number().isEmpty()) {
+ appointment_cunzai = appointmentService.getActiveAppointmentNew(appointment.getTruck_number());
+ }
+ } else if ("3".equals(transport_type)) {
+ if (appointment.getId_code() != null && !appointment.getId_code().isEmpty()) {
+ appointment_cunzai = appointmentService.getActiveAppointmentNew(appointment.getId_code());
+ }
+ } else if ("1".equals(transport_type)) {
+ if (appointment.getId_code() != null && !appointment.getId_code().isEmpty()) {
+ appointment_cunzai = appointmentService.getActiveAppointmentNew(appointment.getId_code());
+ }
+ }
+ if (appointment_cunzai == null) {
+ //提交保存
+ x = appointmentService.postAppointment(appointment);
+ if (appointmentDetailList != null && appointmentDetailList.size() > 0) {
+ int x1 = appointmentService.postAppointmentDetailList(appointment, appointmentDetailList);
+ }
+ //根据预约信息更新,用户和车辆
+ if (true) {
+ appointmentService.updateUserAndTruckByAppointment(appointment);
+ }
+ }
+ } finally {
+ lock.unlock();
+ }
+ //判断请求是否成功
+ Boolean bl = x > 0;
+ //创建返回数据
+ Map data = new HashMap<>();
+ data.put("result", x);
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+
+ /**
+ * 修改预约信息
+ *
+ * @return 返回提交结果
+ */
+ @PostMapping("/updateAppointment")
+ public String updateAppointment(@RequestBody AppointmentPostDto appointmentPostDto) {
+ String msg = "";
+ if (appointmentPostDto.getAppointment() == null) {
+ msg = "预约信息不能为空";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ Appointment appointment = null;
+ List appointmentDetailList = null;
+ CommonRes userInfoResCommonRes;
+ try {
+ //请求哪吒接口获得用户信息
+ userInfoResCommonRes = usersApi.getUserInfo();
+ } catch (Exception ex) {
+ msg = "从rtos后台,获得用户信息异常," + ex.getMessage();
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ try {
+ appointment = appointmentPostDto.getAppointment();
+ UserInfoRes userInfoRes = userInfoResCommonRes.getData();
+ String userId = userInfoRes.getId();
+ appointment.setUsers_id(userId);
+
+ Integer appointment_type = appointment.getAppointment_type();
+ String port_area_id = appointment.getPort_area_id();
+ //如果是特保区预约,港区则绑定到临港
+ if (appointment_type != null && appointment_type.equals(2)) {
+ //特保区预约不能修改,只能取消后重新预约(王正琰)
+ msg = "特保区预约不能修改,只能取消后重新预约";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ } catch (Exception ex) {
+ msg = "获取预约实体失败。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ if (appointment.getId() == null || appointment.getId().isEmpty()) {
+ msg = "修改预约,预约id不能为空";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ if (appointment.getUsers_id() == null || appointment.getUsers_id().isEmpty()) {
+ msg = "用户id不能为空";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ if (appointment.getAppointment_type() != null && appointment.getAppointment_type().equals(1)) {
+ if (appointment.getPort_area_id() == null || appointment.getPort_area_id().isEmpty()) {
+ msg = "预约港区不能为空";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ }
+ //预约日期空值判断
+ if (appointment.getApproach_date() == null || appointment.getApproach_date().isEmpty()) {
+ msg = "预约进场日期不能为空";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ //自开预约验证身份证
+ if (appointment.getTransport_type() != null && "3".equals(appointment.getTransport_type())) {
+ String idCode = appointment.getId_code();
+ if (idCode == null || idCode.isEmpty()) {
+ msg = "自开,身份证号码不能为空,请正确填写身份证号";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ if (idCode.length() != 18) {
+ msg = "身份证号码必须18位,请正确填写身份证号";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //封装数据
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+
+ }
+ //进港类型
+ String enter_type = appointment.getEnter_type();
+ //运输方式
+ String transport_type = appointment.getTransport_type();
+ Appointment myAppointment = null;
+ if ("2".equals(transport_type)) {
+ //板车运输是板车号
+ myAppointment = appointmentService.getActiveAppointmentNew(appointment.getTruck_number());
+ if (myAppointment != null) {
+ if (myAppointment.getAppointment_state().equals(6) || myAppointment.getAppointment_state().equals(7)) {
+ msg = "该预约信息已完工打卡,不能修改";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ }
+ } else if ("3".equals(transport_type)) {
+ //自开是身份证号
+ myAppointment = appointmentService.getActiveAppointmentNew(appointment.getId_code());
+ if (myAppointment != null) {
+ if (myAppointment.getAppointment_state().equals(6) || myAppointment.getAppointment_state().equals(7)) {
+ msg = "该预约信息已完工打卡,不能修改";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ }
+ } else if ("1".equals(transport_type)) {
+ //自开是身份证号
+ myAppointment = appointmentService.getActiveAppointmentNew(appointment.getId_code());
+ if (myAppointment != null) {
+ if (myAppointment.getAppointment_state().equals(6) || myAppointment.getAppointment_state().equals(7)) {
+ msg = "该预约信息已完工打卡,不能修改";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ }
+ }
+ if (true) {
+ if (appointmentPostDto.getAppointmentDetailList() == null) {
+ //外贸出口,第三步的船名、港口、品牌必填,车架号可以不填写,内贸出口第三步都是非必填 (张晓雅 需求修改) ,注释下面代码
+ // 预约类型(1-普通码头预约,2-特保区预约) 新增字段
+ //验证特保区预约,预约明细信息不能为空
+ Integer appointment_type = appointment.getAppointment_type();
+ if (appointment_type != null && appointment_type.equals(2)) {
+ msg = "特保区预约,预约明细信息不能为空。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ }
+ if (appointmentPostDto.getAppointmentDetailList() != null && appointmentPostDto.getAppointmentDetailList().size() > 0) {
+ try {
+ appointmentDetailList = appointmentPostDto.getAppointmentDetailList();
+ } catch (Exception ex) {
+ msg = "获取预约明细信息实体失败。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ List vinlist = new ArrayList<>();
+ if (appointmentDetailList != null && appointmentDetailList.size() > 0) {
+ if ("WE".equals(enter_type)) {
+ //验证船名必填
+ List detailsForShip = Linq.of(appointmentDetailList).where(p -> p.getShip_id() == null || p.getShip_id().isEmpty()).toList();
+ if (detailsForShip != null && detailsForShip.size() > 0) {
+ msg = "外贸出口,预约明细的船舶id必填。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ //验证品牌
+ List detailsForBrand = Linq.of(appointmentDetailList).where(p -> p.getBrand_id() == null || p.getBrand_id().isEmpty()).toList();
+ if (detailsForBrand != null && detailsForBrand.size() > 0) {
+ msg = "外贸出口,预约明细的品牌必填。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ //验证港口
+ List detailsForPort = Linq.of(appointmentDetailList).where(p -> p.getBrand_id() == null || p.getBrand_id().isEmpty()).toList();
+ if (detailsForPort != null && detailsForPort.size() > 0) {
+ msg = "外贸出口,预约明细的港口必填。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ }
+ //验证提交的Vins是否有重复的
+ List myallVins = Linq.of(appointmentDetailList).where(p -> p.getVin() != null && !p.getVin().isEmpty()).select(AppointmentDetail::getVin).toList();
+ List duplicatedElements = myallVins.stream().collect(Collectors.groupingBy(e -> e)).entrySet().stream().filter(entry -> entry.getValue().size() > 1).map(Map.Entry::getKey).collect(Collectors.toList());
+ if (duplicatedElements.size() > 0) {
+ String myVins = String.join(",", duplicatedElements);
+ msg = "vin:" + myVins + "重复提交。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ //内贸出口的品牌不能为空(商品车)(张小雅 内贸出口第三步都是非必填)
+ //验证vin是否是17位
+ vinlist = null;
+ if ("WE".equals(enter_type)) {
+ vinlist = Linq.of(appointmentDetailList).where(p -> p.getVin() != null && !p.getVin().isEmpty()).select(AppointmentDetail::getVin).toList();
+ } else {
+ vinlist = Linq.of(appointmentDetailList).select(AppointmentDetail::getVin).toList();
+ }
+ if (vinlist != null && vinlist.size() > 0) {
+ //验证vin 验证6-17 位(王文文2024-07-16)
+ List vinlistckl = CheckHelper.CheckVinLength(vinlist);
+ if (vinlistckl != null && vinlistckl.size() > 0) {
+ String myVins = String.join(",", vinlistckl);
+ msg = "vin:" + myVins + "长度小于17位。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+
+ //验证vin只能是字母或数据组成
+ List vinlistckcon = CheckHelper.CheckVinContainEnOrDi(vinlist);
+ if (vinlistckcon != null && vinlistckcon.size() > 0) {
+ String myVins = String.join(",", vinlistckcon);
+ msg = "vin只能是字母或数据组成," + "vin:" + myVins + "不符合。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+
+ //验证vin是否被别的板车预约过
+ //根据 Vin列表查询匹配的商品车明细,并筛选出不属于已取消和异常的预约的和预约已完成的
+ List mylist = appointmentService.getAppointmentDetailListByVinList(vinlist, appointment.getId());
+ //取Vin的列表
+ List myVinlist = null;
+ if (mylist != null && mylist.size() > 0) {
+ for (AppointmentDetail detail : mylist) {
+ Appointment appOin = appointmentService.getAppointmentById(detail.getAppointment_id());
+ if (appOin != null) {
+ msg = "vin:" + detail.getVin() + "已经被" + appOin.getTruck_number() + "预约过。";
+ } else {
+ msg = "vin:" + detail.getVin() + "已经被预约过。";
+ }
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ }
+
+ //判断车辆是否在场(出口业务)
+ if ("WE".equals(enter_type) || "NE".equals(enter_type)) {
+ List myAppointmentDetail_dataBase = appointmentService.getAppointmentDetailListByAppointmentId(appointment.getId());
+ List myVin_dataBase = new ArrayList();
+ if (myAppointmentDetail_dataBase != null && myAppointmentDetail_dataBase.size() > 0) {
+ for (AppointmentDetail item : myAppointmentDetail_dataBase) {
+ if (item.getVin() != null && !item.getVin().isEmpty()) {
+ myVin_dataBase.add(item.getVin());
+ }
+ }
+ }
+ //1本次预约在场的vin修改的时候不能删除
+ List vin_zc_yuanlai = null;//原来在场车辆
+ if (myVin_dataBase != null && myVin_dataBase.size() > 0) {
+ CommonRes> mycheckInYardFLag_yuanlai = yardOrderApi.checkInYardFLag(myVin_dataBase);
+ logger.info("接收到哪吒接口返回的在场验证数据:" + JSON.toJSONString(mycheckInYardFLag_yuanlai));
+ List yardGoodsStateRespDTOList_yuanlai = null;
+ if (mycheckInYardFLag_yuanlai != null) {
+ yardGoodsStateRespDTOList_yuanlai = mycheckInYardFLag_yuanlai.getData();
+ }
+ if (yardGoodsStateRespDTOList_yuanlai != null && yardGoodsStateRespDTOList_yuanlai.size() > 0) {
+ //vin_zc_yuanlai = Linq.of(yardGoodsStateRespDTOList_yuanlai).where(p -> p.getInYardFlag().equals(1) && !"1".equals(p.getIsAllocate())).select(o -> o.getVinCode()).toList();
+ vin_zc_yuanlai = Linq.of(yardGoodsStateRespDTOList_yuanlai).where(p -> p.getInYardFlag().equals(1)).select(o -> o.getVinCode()).toList();
+ } else {
+ vin_zc_yuanlai = new ArrayList<>();
+ }
+ }
+ if (vin_zc_yuanlai != null && vin_zc_yuanlai.size() > 0) {//appointmentDetailList
+ List vin_benci = Linq.of(appointmentDetailList).where(p -> p.getVin() != null).select(p -> p.getVin()).toList();
+ if (vin_benci == null) {
+ vin_benci = new ArrayList<>();
+ }
+ for (String vi : vin_zc_yuanlai) {
+ if (!vin_benci.contains(vi)) {
+ msg = "车架号:" + vi + "的已被该板车收车,已在场,不可从预约中删除。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ }
+ }
+
+ //2从哪吒接口获得vin的是否在场的信息
+ List vinlist_isOn = Linq.of(vinlist).where(p -> p != null && !p.isEmpty()).toList();
+ if (vinlist_isOn != null && vinlist_isOn.size() > 0) {
+ CommonRes> mycheckInYardFLag = yardOrderApi.checkInYardFLag(vinlist_isOn);
+ logger.info("接收到哪吒接口返回的在场验证数据:" + JSON.toJSONString(mycheckInYardFLag));
+ List yardGoodsStateRespDTOList = null;
+ if (mycheckInYardFLag != null) {
+ yardGoodsStateRespDTOList = mycheckInYardFLag.getData();
+ }
+ List vin_zc;//在场车辆
+ List vin_wzc = null;//未在场车辆
+ if (yardGoodsStateRespDTOList != null && yardGoodsStateRespDTOList.size() > 0) {
+ vin_zc = Linq.of(yardGoodsStateRespDTOList).where(p -> p.getInYardFlag().equals(1) && !"1".equals(p.getIsAllocate())).select(YardGoodsStateRespDTO::getVinCode).toList();
+ } else {
+ vin_zc = null;
+ }
+ if (vin_zc != null && vin_zc.size() > 0) {
+ //别的预约已在场的
+ List vin_zc_biedeyuyue = Linq.of(vin_zc).where(p -> !myVin_dataBase.contains(p)).toList();
+ if (vin_zc_biedeyuyue != null && vin_zc_biedeyuyue.size() > 0) {
+ String myVinliststr = String.join(",", vin_zc);
+ msg = "车架号:" + myVinliststr + "的车辆已在场,不可预约进场。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ //本次预约预约已在场的
+ List vin_zc_benciyuyue = Linq.of(vin_zc).where(p -> myVin_dataBase.contains(p)).toList();
+ for (String vin : vin_zc_benciyuyue) {
+ AppointmentDetail detail_dataBase = Linq.of(myAppointmentDetail_dataBase).firstOrDefault(p -> p.getVin() != null && p.getVin().equals(vin));
+ AppointmentDetail detail_benci = Linq.of(appointmentDetailList).firstOrDefault(p -> p.getVin() != null && p.getVin().equals(vin));
+ if (detail_dataBase != null && detail_benci != null) {
+ if (!Objects.equals(detail_benci.getBrand_id(), detail_dataBase.getBrand_id())) {
+ msg = "车架号:" + vin + "的车辆已在场,品牌不可修改。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ if (!Objects.equals(detail_benci.getShip_id(), detail_dataBase.getShip_id())) {
+ msg = "车架号:" + vin + "的车辆已在场,船舶不可修改。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ if (!Objects.equals(detail_benci.getDestination_port_id(), detail_dataBase.getDestination_port_id())) {
+ msg = "车架号:" + vin + "的车辆已在场,港口不可修改。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ }
+ }
+
+ }
+ }
+ }
+ }
+ //特保区,验证vin是否激活
+ if (false) {
+ if (appointment.getAppointment_type() != null && appointment.getAppointment_type().equals(2)) {
+ // Appointment myAppointment = appointmentService.getAppointmentById(appointment.getId());
+ String mypushidsStr = "";
+ List mypushIds = null;
+ if (myAppointment != null) {
+ mypushidsStr = myAppointment.getPush_ids();
+ }
+ if (mypushidsStr != null && !mypushidsStr.isEmpty()) {
+ mypushIds = Linq.of(mypushidsStr.split(",")).toList();
+ if (mypushIds != null && mypushIds.size() > 0) {
+ for (String pushId : mypushIds) {
+ try {
+ orderApi.vehicleCancelReserve(pushId);
+ } catch (Exception ex) {
+ }
+ }
+ mypushIds.clear();
+ }
+ }
+
+ List pushIds = new ArrayList<>();
+ List chekvinlist = Linq.of(appointmentDetailList).select(AppointmentDetail::getVin).where(p -> p != null && !p.isEmpty()).toList();
+ if (chekvinlist != null && chekvinlist.size() > 0) {
+ //List validCusVin = appointmentService.validCusVin(chekvinlist);
+ List validCusVin;
+ try {
+ validCusVin = appointmentService.validCusVin(chekvinlist);
+ } catch (Exception e) {
+ msg = "vin:" + String.join(",", chekvinlist) + "/ 激活验证异常信息:" + e.getMessage();
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ List validCusVinStr;
+ if (validCusVin != null) {
+ validCusVinStr = Linq.of(validCusVin).select(p -> p.getVin()).toList();
+ } else {
+ validCusVinStr = null;
+ }
+
+ //如果邓军返回的vin数据为空,则所有的vin为为激活
+ if (validCusVinStr == null || validCusVinStr.size() == 0) {
+ msg = "vin:" + String.join(",", chekvinlist) + "未被激活。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ } else {
+ if (validCusVin != null && validCusVin.size() > 0) {
+ //过滤出未激活的vin
+ List vin_weijihuo = Linq.of(chekvinlist).where(p -> !validCusVinStr.contains(p)).toList();
+ if (vin_weijihuo != null && vin_weijihuo.size() > 0) {
+ msg = "vin:" + String.join(",", vin_weijihuo) + "未被激活。";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ } else {
+ //智云验证开关
+ if (true) {
+ //如果都是激活的vin,则请求哪吒智云接口
+ //将从邓军请求的企业参数,转化为请求智云的参数
+ List cargoInfoNazList = appointmentService.cargoInfoNaz(validCusVin, appointment.getTruck_number());
+ if (cargoInfoNazList != null && cargoInfoNazList.size() > 0) {
+ for (CargoInfoNaz infoNaz : cargoInfoNazList) {
+ List vin = Linq.of(infoNaz.getGoodsInfo()).select(p -> p.getVin()).toList();
+ NarRes narRes = null;
+ try {
+ narRes = orderApi.vehicleReserve(infoNaz);
+ } catch (Exception ex) {
+ String[] sssss = ex.getMessage().split("]: ");
+ String json = sssss[1].replace("[", "").replace("]", "");
+ ObjectMapper objectMapper = new ObjectMapper();
+ JsonNode jsonNode = null;
+ try {
+ jsonNode = objectMapper.readTree(json);
+ } catch (JsonProcessingException e) {
+ throw new RuntimeException(e);
+ }
+ // 获取 "error" 属性的值
+ String error_description = jsonNode.get("error_description").asText();
+ msg = "vin:" + String.join(",", vin) + error_description + "智云请求异常,预约失败";
+ //msg = "vin:" + String.join(",", vin) + "智云请求异常,预约失败";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ if (pushIds.size() > 0) {
+ for (String pushId : pushIds) {
+ try {
+ orderApi.vehicleCancelReserve(pushId);
+ } catch (Exception ex1) {
+ logger.info(ex1.getMessage());
+ }
+ }
+ pushIds.clear();
+ }
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ if (!"S0000".equals(narRes.getCode())) {
+ msg = "vin:" + String.join(",", vin) + "智云请求失败,预约失败";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ if (pushIds.size() > 0) {
+ for (String pushId : pushIds) {
+ try {
+ orderApi.vehicleCancelReserve(pushId);
+ } catch (Exception ex) {
+ logger.info(ex.getMessage());
+ }
+ }
+ pushIds.clear();
+ }
+ //返回
+ return response.getResponseData(bl, data, msg);
+ } else {
+ NarData data = narRes.getData();
+ if (data != null) {
+ String pushId = data.getPushId();
+ if (pushId != null && !pushId.isEmpty()) {
+ pushIds.add(pushId);
+ }
+ }
+ }
+
+ }
+ if (pushIds.size() > 0) {
+ appointment.setPush_ids(String.join(",", pushIds));
+ }
+ }
+ }
+ }
+ }
+ }
+
+ }
+ }
+ }
+ }
+ }
+ }
+ //非特保区预约才转发到老系统(待开放)只有转发成功,才能修改预约
+ if (true) {
+ if (appointment.getAppointment_type() != null && appointment.getAppointment_type().equals(1)) {
+ {
+ //运输方式字段是字符串
+ if (!"3".equals(appointment.getTransport_type())) {
+ //数据转发到老系统
+ //CompletableFuture future = forwardService.invokeApiAsyncForward(appointment, appointmentDetailList);
+ ForwardRes res = appointmentService.invokeForwardApi(appointment, appointmentDetailList);
+ if (res == null) {
+ //msg = "预约转发老系统失败预约不成功";
+ msg = "网络开小差了,请稍后再试";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ if (Objects.equals(res.getSuccess(), "0")) {
+ //msg = "预约转发老系统失败预约不成功,老系统返回信息:" + res.getErrmsg();
+ msg = "网络开小差了,请稍后再试";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ }
+ }
+ }
+ }
+ Integer x = null;
+ //提交保存
+ x = appointmentService.updateAppointment(appointment);
+ if (appointmentDetailList != null && appointmentDetailList.size() > 0) {
+ int x1 = appointmentService.updateAppointmentDetailList(appointment, appointmentDetailList);
+ } else {
+ //修改的时候,没有填vin,则要清除原来的vin
+ int x2 = appointmentService.deleteAppointmentDetailByAppointmentId(appointment.getId());
+ }
+ //判断请求是否成功
+ Boolean bl = x > 0;
+ //创建返回数据
+ Map data = new HashMap<>();
+ data.put("result", x);
+ //封装数据
+ return response.getResponseData(bl, data, msg);
+ }
+
+ /**
+ * 查询指定用户是否存在已预约但未完成预约信息
+ * //@param users_id 司机id
+ *
+ * @return 返回查询结果
+ */
+ @RequestMapping("getActiveAppointment")
+ public String getActiveAppointment() {
+ CommonRes userInfoResCommonRes;
+ String userId;
+ String msg = "";
+ try {
+ //请求哪吒接口获得用户信息
+ userInfoResCommonRes = usersApi.getUserInfo();
+ UserInfoRes userInfoRes = userInfoResCommonRes.getData();
+ userId = userInfoRes.getId();
+ } catch (Exception ex) {
+ msg = "从rtos后台,获得用户信息异常," + ex.getMessage();
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ if (userId == null || userId.isEmpty()) {
+ msg = "用户Id不能为空";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ //获取该用户的全部预约数据
+ String portAreaName = null;
+ String truckNumber = null;
+ Appointment appointment = null;
+ Truck truck = appointmentService.getPalletTruck(userId);
+ Users users = usersService.getUsersByUserId(userId);
+ if (truck != null) {
+ truckNumber = truck.getTruck_number();
+ if (truckNumber != null && !truckNumber.isEmpty()) {
+ appointment = appointmentService.getActiveAppointmentNew(truckNumber);
+ }
+ }
+ if (appointment == null) {
+ String id_code = "";
+ if (users != null) {
+ id_code = users.getId_code();
+ if (id_code != null && !id_code.isEmpty()) {
+ appointment = appointmentService.getActiveAppointmentNew(id_code);
+ }
+ }
+ }
+ if (appointment == null) {
+ msg = "用户Id" + userId + ", 板车号" + truckNumber + "不存在未完成的预约";
+ //判断请求是否成功
+ Boolean bl = false;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //返回
+ return response.getResponseData(bl, data, msg);
+ }
+ String appointment_id = appointment.getId();
+ //获取该预约的打卡信息
+ PunchClock mypunchClock = (appointment_id != null) ? punchClockService.getPunchClockForAppintementId(appointment_id) : null;
+ //读取打卡的时间和地址信息
+ String punch_start_time = "";
+ String punch_over_time = "";
+ String punch_start_address = "";
+ String punch_over_address = "";
+ String punch_clock_id = "";
+ LocalDateTime start_time = null;
+ LocalDateTime over_time = null;
+ if (mypunchClock != null) {
+ if (mypunchClock.getStart_time() != null && !mypunchClock.getStart_time().isEmpty()) {
+ start_time = DateTimeHelper.DateTimeStrToLocalDateTime(mypunchClock.getStart_time());
+ }
+ if (mypunchClock.getOver_time() != null && !mypunchClock.getOver_time().isEmpty()) {
+ over_time = DateTimeHelper.DateTimeStrToLocalDateTime(mypunchClock.getOver_time());
+ }
+ if (start_time != null) {
+ punch_start_time = start_time.getHour() + ":" + start_time.getMinute() + ":" + start_time.getSecond();
+ }
+ if (over_time != null) {
+ punch_over_time = over_time.getHour() + ":" + over_time.getMinute() + ":" + over_time.getSecond();
+ }
+ punch_clock_id = mypunchClock.getId();
+ punch_start_address = mypunchClock.getPunch_address();
+ punch_over_address = mypunchClock.getOver_address();
+ }
+
+ //是否时本手机(1是本手机,0是别的手机)
+ Integer isSelf = null;
+ if (userId.equals(appointment.getUsers_id())) {
+ isSelf = 1;
+ } else {
+ isSelf = 0;
+ }
+ //判断请求是否成功
+ Boolean bl = true;
+ //创建返回数据
+ Map data = new HashMap<>();
+ //data.put("punch_clock_id", punch_clock_id);
+ data.put("punch_start_time", punch_start_time);
+ data.put("punch_over_time", punch_over_time);
+ data.put("punch_start_address", punch_start_address);
+ data.put("punch_over_address", punch_over_address);
+ data.put("portArea", portAreaName);
+ data.put("appointment", appointment);
+ data.put("isSelf", isSelf);
+ //封装数据
+ //返回
+ return response.getResponseData(bl, data);
+ }
+
+ /**
+ * 查询指定板车号是否存在活跃预约信息(王正炎特保区新接口)
+ *
+ * @param truckNumber 板车号
+ * @return 返回查询结果
+ */
+ @GetMapping("getActiveAppointmentByTruckNumber")
+ public String getActiveAppointmentByTruckNumber(@RequestParam("truckNumber") String truckNumber) {
+ com.haitongauto.models.res.Response